1 // SPDX-License-Identifier: GPL-2.0+ OR BSD-3-Clause
3 * Copyright (C) 2018, STMicroelectronics - All Rights Reserved
10 #include <power/pmic.h>
11 #include <power/stpmu1.h>
13 #define STMPU1_NUM_OF_REGS 0x100
15 #ifndef CONFIG_SPL_BUILD
16 static const struct pmic_child_info stpmu1_children_info[] = {
17 { .prefix = "ldo", .driver = "stpmu1_ldo" },
18 { .prefix = "buck", .driver = "stpmu1_buck" },
19 { .prefix = "vref_ddr", .driver = "stpmu1_vref_ddr" },
20 { .prefix = "pwr_sw", .driver = "stpmu1_pwr_sw" },
21 { .prefix = "boost", .driver = "stpmu1_boost" },
24 #endif /* CONFIG_SPL_BUILD */
26 static int stpmu1_reg_count(struct udevice *dev)
28 return STMPU1_NUM_OF_REGS;
31 static int stpmu1_write(struct udevice *dev, uint reg, const uint8_t *buff,
36 ret = dm_i2c_write(dev, reg, buff, len);
38 dev_err(dev, "%s: failed to write register %#x :%d",
44 static int stpmu1_read(struct udevice *dev, uint reg, uint8_t *buff, int len)
48 ret = dm_i2c_read(dev, reg, buff, len);
50 dev_err(dev, "%s: failed to read register %#x : %d",
56 static int stpmu1_bind(struct udevice *dev)
58 #ifndef CONFIG_SPL_BUILD
59 ofnode regulators_node;
62 regulators_node = dev_read_subnode(dev, "regulators");
63 if (!ofnode_valid(regulators_node)) {
64 dev_dbg(dev, "regulators subnode not found!");
67 dev_dbg(dev, "found regulators subnode\n");
69 children = pmic_bind_children(dev, regulators_node,
70 stpmu1_children_info);
72 dev_dbg(dev, "no child found\n");
73 #endif /* CONFIG_SPL_BUILD */
78 static struct dm_pmic_ops stpmu1_ops = {
79 .reg_count = stpmu1_reg_count,
81 .write = stpmu1_write,
84 static const struct udevice_id stpmu1_ids[] = {
85 { .compatible = "st,stpmu1" },
89 U_BOOT_DRIVER(pmic_stpmu1) = {
90 .name = "stpmu1_pmic",
92 .of_match = stpmu1_ids,