1 // SPDX-License-Identifier: GPL-2.0+
3 * Copyright (C) 2015 Google, Inc
4 * Written by Simon Glass <sjg@chromium.org>
11 #include <linux/libfdt.h>
12 #include <power/act8846_pmic.h>
13 #include <power/pmic.h>
15 static const struct pmic_child_info pmic_children_info[] = {
16 { .prefix = "REG", .driver = "act8846_reg"},
20 static int act8846_reg_count(struct udevice *dev)
22 return ACT8846_NUM_OF_REGS;
25 static int act8846_write(struct udevice *dev, uint reg, const uint8_t *buff,
28 if (dm_i2c_write(dev, reg, buff, len)) {
29 debug("write error to device: %p register: %#x!\n", dev, reg);
36 static int act8846_read(struct udevice *dev, uint reg, uint8_t *buff, int len)
38 if (dm_i2c_read(dev, reg, buff, len)) {
39 debug("read error from device: %p register: %#x!\n", dev, reg);
46 static int act8846_bind(struct udevice *dev)
48 ofnode regulators_node;
51 regulators_node = dev_read_subnode(dev, "regulators");
52 if (!ofnode_valid(regulators_node)) {
53 debug("%s: %s regulators subnode not found!\n", __func__,
58 debug("%s: '%s' - found regulators subnode\n", __func__, dev->name);
60 children = pmic_bind_children(dev, regulators_node, pmic_children_info);
62 debug("%s: %s - no child found\n", __func__, dev->name);
64 /* Always return success for this device */
68 static struct dm_pmic_ops act8846_ops = {
69 .reg_count = act8846_reg_count,
71 .write = act8846_write,
74 static const struct udevice_id act8846_ids[] = {
75 { .compatible = "active-semi,act8846" },
79 U_BOOT_DRIVER(pmic_act8846) = {
80 .name = "act8846 pmic",
82 .of_match = act8846_ids,