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/fan53555.h>
12 #include <power/pmic.h>
13 #include <power/regulator.h>
15 static int pmic_fan53555_reg_count(struct udevice *dev)
20 static int pmic_fan53555_read(struct udevice *dev, uint reg,
23 if (dm_i2c_read(dev, reg, buff, len)) {
24 pr_err("%s: read error for register: %#x!", dev->name, reg);
31 static int pmic_fan53555_write(struct udevice *dev, uint reg,
32 const u8 *buff, int len)
34 if (dm_i2c_write(dev, reg, buff, len)) {
35 pr_err("%s: write error for register: %#x!", dev->name, reg);
42 static int pmic_fan53555_bind(struct udevice *dev)
45 * The FAN53555 has only a single regulator and therefore doesn't
46 * have a subnode. So we have to rebind a child device (the one
50 const char *regulator_driver_name = "fan53555_regulator";
51 struct udevice *child;
54 debug("%s\n", __func__);
56 drv = lists_driver_lookup_name(regulator_driver_name);
58 dev_err(dev, "no driver '%s'\n", regulator_driver_name);
62 return device_bind_with_driver_data(dev, drv, "SW", dev->driver_data,
63 dev_ofnode(dev), &child);
66 static struct dm_pmic_ops pmic_fan53555_ops = {
67 .reg_count = pmic_fan53555_reg_count,
68 .read = pmic_fan53555_read,
69 .write = pmic_fan53555_write,
72 static const struct udevice_id pmic_fan53555_match[] = {
73 { .compatible = "fcs,fan53555", .data = FAN53555_VENDOR_FAIRCHILD, },
74 { .compatible = "silergy,syr827", .data = FAN53555_VENDOR_SILERGY, },
75 { .compatible = "silergy,syr828", .data = FAN53555_VENDOR_SILERGY, },
79 U_BOOT_DRIVER(pmic_fan53555) = {
80 .name = "pmic_fan53555",
82 .of_match = pmic_fan53555_match,
83 .bind = pmic_fan53555_bind,
84 .ops = &pmic_fan53555_ops,