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 DECLARE_GLOBAL_DATA_PTR;
20 static const struct pmic_child_info pmic_children_info[] = {
21 { .prefix = "buck", .driver = LP87565_BUCK_DRIVER },
25 static int lp87565_write(struct udevice *dev, uint reg, const uint8_t *buff,
30 ret = dm_i2c_write(dev, reg, buff, len);
32 error("write error to device: %p register: %#x!", dev, reg);
37 static int lp87565_read(struct udevice *dev, uint reg, uint8_t *buff, int len)
41 ret = dm_i2c_read(dev, reg, buff, len);
43 error("read error from device: %p register: %#x!", dev, reg);
48 static int lp87565_bind(struct udevice *dev)
50 ofnode regulators_node;
53 regulators_node = dev_read_subnode(dev, "regulators");
54 if (!ofnode_valid(regulators_node)) {
55 debug("%s: %s regulators subnode not found!", __func__,
60 debug("%s: '%s' - found regulators subnode\n", __func__, dev->name);
62 children = pmic_bind_children(dev, regulators_node, pmic_children_info);
64 printf("%s: %s - no child found\n", __func__, dev->name);
66 /* Always return success for this device */
70 static struct dm_pmic_ops lp87565_ops = {
72 .write = lp87565_write,
75 static const struct udevice_id lp87565_ids[] = {
76 { .compatible = "ti,lp87565", .data = LP87565 },
77 { .compatible = "ti,lp87565-q1", .data = LP87565_Q1 },
81 U_BOOT_DRIVER(pmic_lp87565) = {
82 .name = "lp87565_pmic",
84 .of_match = lp87565_ids,