1 // SPDX-License-Identifier: GPL-2.0+
3 * (C) 2018 Theobroma Systems Design und Consulting GmbH
8 #include <dm/device-internal.h>
11 #include <power/pmic.h>
12 #include <power/regulator.h>
14 static int pmic_fan53555_reg_count(struct udevice *dev)
19 static int pmic_fan53555_read(struct udevice *dev, uint reg,
22 if (dm_i2c_read(dev, reg, buff, len)) {
23 pr_err("%s: read error for register: %#x!", dev->name, reg);
30 static int pmic_fan53555_write(struct udevice *dev, uint reg,
31 const u8 *buff, int len)
33 if (dm_i2c_write(dev, reg, buff, len)) {
34 pr_err("%s: write error for register: %#x!", dev->name, reg);
41 static int pmic_fan53555_bind(struct udevice *dev)
44 * The FAN53555 has only a single regulator and therefore doesn't
45 * have a subnode. So we have to rebind a child device (the one
49 const char *regulator_driver_name = "fan53555_regulator";
50 struct udevice *child;
53 debug("%s\n", __func__);
55 drv = lists_driver_lookup_name(regulator_driver_name);
57 dev_err(dev, "no driver '%s'\n", regulator_driver_name);
61 return device_bind_with_driver_data(dev, drv, "SW", 0,
62 dev_ofnode(dev), &child);
65 static struct dm_pmic_ops pmic_fan53555_ops = {
66 .reg_count = pmic_fan53555_reg_count,
67 .read = pmic_fan53555_read,
68 .write = pmic_fan53555_write,
71 static const struct udevice_id pmic_fan53555_match[] = {
72 { .compatible = "fcs,fan53555" },
76 U_BOOT_DRIVER(pmic_fan53555) = {
77 .name = "pmic_fan53555",
79 .of_match = pmic_fan53555_match,
80 .bind = pmic_fan53555_bind,
81 .ops = &pmic_fan53555_ops,