2 * (C) Copyright 2016 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/lp873x.h>
16 #include <dm/device.h>
18 DECLARE_GLOBAL_DATA_PTR
;
20 static const struct pmic_child_info pmic_children_info
[] = {
21 { .prefix
= "ldo", .driver
= LP873X_LDO_DRIVER
},
22 { .prefix
= "buck", .driver
= LP873X_BUCK_DRIVER
},
26 static int lp873x_write(struct udevice
*dev
, uint reg
, const uint8_t *buff
,
29 if (dm_i2c_write(dev
, reg
, buff
, len
)) {
30 pr_err("write error to device: %p register: %#x!", dev
, reg
);
37 static int lp873x_read(struct udevice
*dev
, uint reg
, uint8_t *buff
, int len
)
39 if (dm_i2c_read(dev
, reg
, buff
, len
)) {
40 pr_err("read error from device: %p register: %#x!", dev
, reg
);
47 static int lp873x_bind(struct udevice
*dev
)
49 ofnode regulators_node
;
52 regulators_node
= dev_read_subnode(dev
, "regulators");
53 if (!ofnode_valid(regulators_node
)) {
54 debug("%s: %s regulators subnode not found!", __func__
,
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 lp873x_ops
= {
69 .write
= lp873x_write
,
72 static const struct udevice_id lp873x_ids
[] = {
73 { .compatible
= "ti,lp8732", .data
= LP8732
},
74 { .compatible
= "ti,lp8733" , .data
= LP8733
},
78 U_BOOT_DRIVER(pmic_lp873x
) = {
79 .name
= "lp873x_pmic",
81 .of_match
= lp873x_ids
,