1 // SPDX-License-Identifier: GPL-2.0+
3 * Copyright (C) 2015 Samsung Electronics
4 * Przemyslaw Marczak <p.marczak@samsung.com>
12 #include <power/pmic.h>
13 #include <power/regulator.h>
14 #include <power/sandbox_pmic.h>
16 static const struct pmic_child_info pmic_children_info[] = {
17 { .prefix = SANDBOX_OF_LDO_PREFIX, .driver = SANDBOX_LDO_DRIVER },
18 { .prefix = SANDBOX_OF_BUCK_PREFIX, .driver = SANDBOX_BUCK_DRIVER },
22 static int sandbox_pmic_reg_count(struct udevice *dev)
24 return SANDBOX_PMIC_REG_COUNT;
27 static int sandbox_pmic_write(struct udevice *dev, uint reg,
28 const uint8_t *buff, int len)
30 if (dm_i2c_write(dev, reg, buff, len)) {
31 pr_err("write error to device: %p register: %#x!", dev, reg);
38 static int sandbox_pmic_read(struct udevice *dev, uint reg,
39 uint8_t *buff, int len)
41 if (dm_i2c_read(dev, reg, buff, len)) {
42 pr_err("read error from device: %p register: %#x!", dev, reg);
49 static int sandbox_pmic_bind(struct udevice *dev)
51 if (!pmic_bind_children(dev, dev_ofnode(dev), pmic_children_info))
52 pr_err("%s:%d PMIC: %s - no child found!", __func__, __LINE__,
55 /* Always return success for this device - allows for PMIC I/O */
59 static struct dm_pmic_ops sandbox_pmic_ops = {
60 .reg_count = sandbox_pmic_reg_count,
61 .read = sandbox_pmic_read,
62 .write = sandbox_pmic_write,
65 static const struct udevice_id sandbox_pmic_ids[] = {
66 { .compatible = "sandbox,pmic" },
70 U_BOOT_DRIVER(sandbox_pmic) = {
71 .name = "sandbox_pmic",
73 .of_match = sandbox_pmic_ids,
74 .bind = sandbox_pmic_bind,
75 .ops = &sandbox_pmic_ops,