2 * (C) Copyright 2017 Texas Instruments Incorporated, <www.ti.com>
3 * Keerthy <j-keerthy@ti.com>
5 * SPDX-License-Identifier: GPL-2.0+
13 #include <power/pmic.h>
14 #include <power/regulator.h>
15 #include <power/lp87565.h>
16 #include <dm/device.h>
18 static const struct pmic_child_info pmic_children_info[] = {
19 { .prefix = "buck", .driver = LP87565_BUCK_DRIVER },
23 static int lp87565_write(struct udevice *dev, uint reg, const uint8_t *buff,
28 ret = dm_i2c_write(dev, reg, buff, len);
30 pr_err("write error to device: %p register: %#x!", dev, reg);
35 static int lp87565_read(struct udevice *dev, uint reg, uint8_t *buff, int len)
39 ret = dm_i2c_read(dev, reg, buff, len);
41 pr_err("read error from device: %p register: %#x!", dev, reg);
46 static int lp87565_bind(struct udevice *dev)
48 ofnode regulators_node;
51 regulators_node = dev_read_subnode(dev, "regulators");
52 if (!ofnode_valid(regulators_node)) {
53 debug("%s: %s regulators subnode not found!", __func__,
58 debug("%s: '%s' - found regulators subnode\n", __func__, dev->name);
60 children = pmic_bind_children(dev, regulators_node, pmic_children_info);
62 printf("%s: %s - no child found\n", __func__, dev->name);
64 /* Always return success for this device */
68 static struct dm_pmic_ops lp87565_ops = {
70 .write = lp87565_write,
73 static const struct udevice_id lp87565_ids[] = {
74 { .compatible = "ti,lp87565", .data = LP87565 },
75 { .compatible = "ti,lp87565-q1", .data = LP87565_Q1 },
79 U_BOOT_DRIVER(pmic_lp87565) = {
80 .name = "lp87565_pmic",
82 .of_match = lp87565_ids,