2 * Copyright (C) 2015 Samsung Electronics
3 * Przemyslaw Marczak <p.marczak@samsung.com>
5 * SPDX-License-Identifier: GPL-2.0+
13 #include <power/pmic.h>
14 #include <power/regulator.h>
15 #include <power/sandbox_pmic.h>
17 static const struct pmic_child_info pmic_children_info[] = {
18 { .prefix = SANDBOX_OF_LDO_PREFIX, .driver = SANDBOX_LDO_DRIVER },
19 { .prefix = SANDBOX_OF_BUCK_PREFIX, .driver = SANDBOX_BUCK_DRIVER },
23 static int sandbox_pmic_reg_count(struct udevice *dev)
25 return SANDBOX_PMIC_REG_COUNT;
28 static int sandbox_pmic_write(struct udevice *dev, uint reg,
29 const uint8_t *buff, int len)
31 if (dm_i2c_write(dev, reg, buff, len)) {
32 pr_err("write error to device: %p register: %#x!", dev, reg);
39 static int sandbox_pmic_read(struct udevice *dev, uint reg,
40 uint8_t *buff, int len)
42 if (dm_i2c_read(dev, reg, buff, len)) {
43 pr_err("read error from device: %p register: %#x!", dev, reg);
50 static int sandbox_pmic_bind(struct udevice *dev)
52 if (!pmic_bind_children(dev, dev_ofnode(dev), pmic_children_info))
53 pr_err("%s:%d PMIC: %s - no child found!", __func__, __LINE__,
56 /* Always return success for this device - allows for PMIC I/O */
60 static struct dm_pmic_ops sandbox_pmic_ops = {
61 .reg_count = sandbox_pmic_reg_count,
62 .read = sandbox_pmic_read,
63 .write = sandbox_pmic_write,
66 static const struct udevice_id sandbox_pmic_ids[] = {
67 { .compatible = "sandbox,pmic" },
71 U_BOOT_DRIVER(sandbox_pmic) = {
72 .name = "sandbox_pmic",
74 .of_match = sandbox_pmic_ids,
75 .bind = sandbox_pmic_bind,
76 .ops = &sandbox_pmic_ops,