1 // SPDX-License-Identifier: GPL-2.0+
3 * (C) Copyright 2016 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/palmas.h>
15 #include <dm/device.h>
17 static const struct pmic_child_info pmic_children_info[] = {
18 { .prefix = "ldo", .driver = PALMAS_LDO_DRIVER },
19 { .prefix = "smps", .driver = PALMAS_SMPS_DRIVER },
23 static int palmas_write(struct udevice *dev, uint reg, const uint8_t *buff,
26 if (dm_i2c_write(dev, reg, buff, len)) {
27 pr_err("write error to device: %p register: %#x!", dev, reg);
34 static int palmas_read(struct udevice *dev, uint reg, uint8_t *buff, int len)
36 if (dm_i2c_read(dev, reg, buff, len)) {
37 pr_err("read error from device: %p register: %#x!", dev, reg);
44 static int palmas_bind(struct udevice *dev)
46 ofnode pmic_node = ofnode_null(), regulators_node;
50 dev_for_each_subnode(subnode, dev) {
54 name = ofnode_get_name(subnode);
55 temp = strstr(name, "pmic");
62 if (!ofnode_valid(pmic_node)) {
63 debug("%s: %s pmic subnode not found!", __func__, dev->name);
67 regulators_node = ofnode_find_subnode(pmic_node, "regulators");
69 if (!ofnode_valid(regulators_node)) {
70 debug("%s: %s reg subnode not found!", __func__, dev->name);
74 children = pmic_bind_children(dev, regulators_node, pmic_children_info);
76 debug("%s: %s - no child found\n", __func__, dev->name);
78 /* Always return success for this device */
82 static struct dm_pmic_ops palmas_ops = {
84 .write = palmas_write,
87 static const struct udevice_id palmas_ids[] = {
88 { .compatible = "ti,tps659038", .data = TPS659038 },
89 { .compatible = "ti,tps65917" , .data = TPS65917 },
93 U_BOOT_DRIVER(pmic_palmas) = {
94 .name = "palmas_pmic",
96 .of_match = palmas_ids,