1 // SPDX-License-Identifier: GPL-2.0+
3 * Copyright (C) EETS GmbH, 2017, Felix Brack <f.brack@eets.ch>
9 #include <power/pmic.h>
10 #include <power/regulator.h>
11 #include <power/tps65910_pmic.h>
13 static const struct pmic_child_info pmic_children_info[] = {
14 { .prefix = "ldo_", .driver = TPS65910_LDO_DRIVER },
15 { .prefix = "buck_", .driver = TPS65910_BUCK_DRIVER },
16 { .prefix = "boost_", .driver = TPS65910_BOOST_DRIVER },
20 static int pmic_tps65910_reg_count(struct udevice *dev)
22 return TPS65910_NUM_REGS;
25 static int pmic_tps65910_write(struct udevice *dev, uint reg, const u8 *buffer,
30 ret = dm_i2c_write(dev, reg, buffer, len);
32 pr_err("%s write error on register %02x\n", dev->name, reg);
37 static int pmic_tps65910_read(struct udevice *dev, uint reg, u8 *buffer,
42 ret = dm_i2c_read(dev, reg, buffer, len);
44 pr_err("%s read error on register %02x\n", dev->name, reg);
49 static int pmic_tps65910_bind(struct udevice *dev)
51 ofnode regulators_node;
54 regulators_node = dev_read_subnode(dev, "regulators");
55 if (!ofnode_valid(regulators_node)) {
56 debug("%s regulators subnode not found\n", dev->name);
60 children = pmic_bind_children(dev, regulators_node, pmic_children_info);
62 debug("%s has no children (regulators)\n", dev->name);
67 static int pmic_tps65910_probe(struct udevice *dev)
69 /* use I2C control interface instead of I2C smartreflex interface to
70 * access smartrefelex registers VDD1_OP_REG, VDD1_SR_REG, VDD2_OP_REG
73 return pmic_clrsetbits(dev, TPS65910_REG_DEVICE_CTRL, 0,
74 TPS65910_I2C_SEL_MASK);
77 static struct dm_pmic_ops pmic_tps65910_ops = {
78 .reg_count = pmic_tps65910_reg_count,
79 .read = pmic_tps65910_read,
80 .write = pmic_tps65910_write,
83 static const struct udevice_id pmic_tps65910_match[] = {
84 { .compatible = "ti,tps65910" },
88 U_BOOT_DRIVER(pmic_tps65910) = {
89 .name = "pmic_tps65910",
91 .of_match = pmic_tps65910_match,
92 .bind = pmic_tps65910_bind,
93 .probe = pmic_tps65910_probe,
94 .ops = &pmic_tps65910_ops,