1 // SPDX-License-Identifier: GPL-2.0+
3 * (C) Copyright 2017 Texas Instruments Incorporated, <www.ti.com>
4 * Keerthy <j-keerthy@ti.com>
12 #include <power/pmic.h>
13 #include <power/regulator.h>
14 #include <power/lp87565.h>
15 #include <dm/device.h>
17 static const struct pmic_child_info pmic_children_info[] = {
18 { .prefix = "buck", .driver = LP87565_BUCK_DRIVER },
22 static int lp87565_write(struct udevice *dev, uint reg, const uint8_t *buff,
27 ret = dm_i2c_write(dev, reg, buff, len);
29 pr_err("write error to device: %p register: %#x!", dev, reg);
34 static int lp87565_read(struct udevice *dev, uint reg, uint8_t *buff, int len)
38 ret = dm_i2c_read(dev, reg, buff, len);
40 pr_err("read error from device: %p register: %#x!", dev, reg);
45 static int lp87565_bind(struct udevice *dev)
47 ofnode regulators_node;
50 regulators_node = dev_read_subnode(dev, "regulators");
51 if (!ofnode_valid(regulators_node)) {
52 debug("%s: %s regulators subnode not found!", __func__,
57 debug("%s: '%s' - found regulators subnode\n", __func__, dev->name);
59 children = pmic_bind_children(dev, regulators_node, pmic_children_info);
61 printf("%s: %s - no child found\n", __func__, dev->name);
63 /* Always return success for this device */
67 static struct dm_pmic_ops lp87565_ops = {
69 .write = lp87565_write,
72 static const struct udevice_id lp87565_ids[] = {
73 { .compatible = "ti,lp87565", .data = LP87565 },
74 { .compatible = "ti,lp87565-q1", .data = LP87565_Q1 },
78 U_BOOT_DRIVER(pmic_lp87565) = {
79 .name = "lp87565_pmic",
81 .of_match = lp87565_ids,