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_children_info
[] = {
20 { .prefix
= "LDO", .driver
= MAX77686_LDO_DRIVER
},
21 { .prefix
= "BUCK", .driver
= MAX77686_BUCK_DRIVER
},
25 static int max77686_reg_count(struct udevice
*dev
)
27 return MAX77686_NUM_OF_REGS
;
30 static int max77686_write(struct udevice
*dev
, uint reg
, const uint8_t *buff
,
33 if (dm_i2c_write(dev
, reg
, buff
, len
)) {
34 pr_err("write error to device: %p register: %#x!", dev
, reg
);
41 static int max77686_read(struct udevice
*dev
, uint reg
, uint8_t *buff
, int len
)
43 if (dm_i2c_read(dev
, reg
, buff
, len
)) {
44 pr_err("read error from device: %p register: %#x!", dev
, reg
);
51 static int max77686_bind(struct udevice
*dev
)
53 ofnode regulators_node
;
56 regulators_node
= dev_read_subnode(dev
, "voltage-regulators");
57 if (!ofnode_valid(regulators_node
)) {
58 debug("%s: %s regulators subnode not found!", __func__
,
63 debug("%s: '%s' - found regulators subnode\n", __func__
, dev
->name
);
65 children
= pmic_bind_children(dev
, regulators_node
, pmic_children_info
);
67 debug("%s: %s - no child found\n", __func__
, dev
->name
);
69 /* Always return success for this device */
73 static struct dm_pmic_ops max77686_ops
= {
74 .reg_count
= max77686_reg_count
,
75 .read
= max77686_read
,
76 .write
= max77686_write
,
79 static const struct udevice_id max77686_ids
[] = {
80 { .compatible
= "maxim,max77686" },
84 U_BOOT_DRIVER(pmic_max77686
) = {
85 .name
= "max77686_pmic",
87 .of_match
= max77686_ids
,
88 .bind
= max77686_bind
,