2 * Copyright (C) 2014-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/max77686_pmic.h>
17 DECLARE_GLOBAL_DATA_PTR;
19 static const struct pmic_child_info pmic_childs_info[] = {
20 { .prefix = "ldo", .driver = MAX77686_LDO_DRIVER },
21 { .prefix = "buck", .driver = MAX77686_BUCK_DRIVER },
25 static int max77686_write(struct udevice *dev, uint reg, const uint8_t *buff,
28 if (dm_i2c_write(dev, reg, buff, len)) {
29 error("write error to device: %p register: %#x!", dev, reg);
36 static int max77686_read(struct udevice *dev, uint reg, uint8_t *buff, int len)
38 if (dm_i2c_read(dev, reg, buff, len)) {
39 error("read error from device: %p register: %#x!", dev, reg);
46 static int max77686_bind(struct udevice *dev)
49 const void *blob = gd->fdt_blob;
52 regulators_node = fdt_subnode_offset(blob, dev->of_offset,
53 "voltage-regulators");
54 if (regulators_node <= 0) {
55 debug("%s: %s regulators subnode not found!", __func__,
60 debug("%s: '%s' - found regulators subnode\n", __func__, dev->name);
62 childs = pmic_bind_childs(dev, regulators_node, pmic_childs_info);
64 debug("%s: %s - no child found\n", __func__, dev->name);
66 /* Always return success for this device */
70 static struct dm_pmic_ops max77686_ops = {
71 .reg_count = MAX77686_NUM_OF_REGS,
72 .read = max77686_read,
73 .write = max77686_write,
76 static const struct udevice_id max77686_ids[] = {
77 { .compatible = "maxim,max77686" },
81 U_BOOT_DRIVER(pmic_max77686) = {
82 .name = "max77686 pmic",
84 .of_match = max77686_ids,
85 .bind = max77686_bind,