1 // SPDX-License-Identifier: GPL-2.0+
3 * Copyright (C) 2015 Samsung Electronics
4 * Przemyslaw Marczak <p.marczak@samsung.com>
13 #include <power/pmic.h>
14 #include <power/s2mps11.h>
16 static const struct pmic_child_info pmic_children_info[] = {
17 { .prefix = S2MPS11_OF_LDO_PREFIX, .driver = S2MPS11_LDO_DRIVER },
18 { .prefix = S2MPS11_OF_BUCK_PREFIX, .driver = S2MPS11_BUCK_DRIVER },
22 static int s2mps11_reg_count(struct udevice *dev)
24 return S2MPS11_REG_COUNT;
27 static int s2mps11_write(struct udevice *dev, uint reg, const uint8_t *buff,
32 ret = dm_i2c_write(dev, reg, buff, len);
34 pr_err("write error to device: %p register: %#x!\n", dev, reg);
39 static int s2mps11_read(struct udevice *dev, uint reg, uint8_t *buff, int len)
43 ret = dm_i2c_read(dev, reg, buff, len);
45 pr_err("read error from device: %p register: %#x!\n", dev, reg);
50 static int s2mps11_probe(struct udevice *dev)
52 ofnode regulators_node;
55 regulators_node = dev_read_subnode(dev, "voltage-regulators");
56 if (!ofnode_valid(regulators_node)) {
57 debug("%s: %s regulators subnode not found!\n", __func__,
62 debug("%s: '%s' - found regulators subnode\n", __func__, dev->name);
64 children = pmic_bind_children(dev, regulators_node, pmic_children_info);
66 debug("%s: %s - no child found\n", __func__, dev->name);
71 static struct dm_pmic_ops s2mps11_ops = {
72 .reg_count = s2mps11_reg_count,
74 .write = s2mps11_write,
77 static const struct udevice_id s2mps11_ids[] = {
78 { .compatible = "samsung,s2mps11-pmic" },
82 U_BOOT_DRIVER(pmic_s2mps11) = {
83 .name = "s2mps11_pmic",
85 .of_match = s2mps11_ids,
87 .probe = s2mps11_probe,