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/palmas.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 = PALMAS_LDO_DRIVER },
22 { .prefix = "smps", .driver = PALMAS_SMPS_DRIVER },
26 static int palmas_write(struct udevice *dev, uint reg, const uint8_t *buff,
29 if (dm_i2c_write(dev, reg, buff, len)) {
30 error("write error to device: %p register: %#x!", dev, reg);
37 static int palmas_read(struct udevice *dev, uint reg, uint8_t *buff, int len)
39 if (dm_i2c_read(dev, reg, buff, len)) {
40 error("read error from device: %p register: %#x!", dev, reg);
47 static int palmas_bind(struct udevice *dev)
49 ofnode pmic_node = ofnode_null(), regulators_node;
53 dev_for_each_subnode(subnode, dev) {
57 name = ofnode_get_name(subnode);
58 temp = strstr(name, "pmic");
65 if (!ofnode_valid(pmic_node)) {
66 debug("%s: %s pmic subnode not found!", __func__, dev->name);
70 regulators_node = ofnode_find_subnode(pmic_node, "regulators");
72 if (!ofnode_valid(regulators_node)) {
73 debug("%s: %s reg subnode not found!", __func__, dev->name);
77 children = pmic_bind_children(dev, regulators_node, pmic_children_info);
79 debug("%s: %s - no child found\n", __func__, dev->name);
81 /* Always return success for this device */
85 static struct dm_pmic_ops palmas_ops = {
87 .write = palmas_write,
90 static const struct udevice_id palmas_ids[] = {
91 { .compatible = "ti,tps659038", .data = TPS659038 },
92 { .compatible = "ti,tps65917" , .data = TPS65917 },
96 U_BOOT_DRIVER(pmic_palmas) = {
97 .name = "palmas_pmic",
99 .of_match = palmas_ids,