21 #include <linux/module.h>
28 #include <linux/slab.h>
30 #define MAX8907_II2RR_VERSION_MASK 0xF0
31 #define MAX8907_II2RR_VERSION_REV_A 0x00
32 #define MAX8907_II2RR_VERSION_REV_B 0x10
33 #define MAX8907_II2RR_VERSION_REV_C 0x30
43 .supply_name = "mbatt", \
44 .id = MAX8907_MBATT, \
45 .ops = &max8907_mbatt_ops, \
46 .type = REGULATOR_VOLTAGE, \
47 .owner = THIS_MODULE, \
50 #define REG_LDO(ids, supply, base, min, max, step) \
53 .supply_name = supply, \
54 .id = MAX8907_##ids, \
55 .n_voltages = ((max) - (min)) / (step) + 1, \
56 .ops = &max8907_ldo_ops, \
57 .type = REGULATOR_VOLTAGE, \
58 .owner = THIS_MODULE, \
61 .vsel_reg = (base) + MAX8907_VOUT, \
63 .enable_reg = (base) + MAX8907_CTL, \
64 .enable_mask = MAX8907_MASK_LDO_EN, \
67 #define REG_FIXED(ids, supply, voltage) \
70 .supply_name = supply, \
71 .id = MAX8907_##ids, \
73 .ops = &max8907_fixed_ops, \
74 .type = REGULATOR_VOLTAGE, \
75 .owner = THIS_MODULE, \
76 .min_uV = (voltage), \
79 #define REG_OUT5V(ids, supply, base, voltage) \
82 .supply_name = supply, \
83 .id = MAX8907_##ids, \
85 .ops = &max8907_out5v_ops, \
86 .type = REGULATOR_VOLTAGE, \
87 .owner = THIS_MODULE, \
88 .min_uV = (voltage), \
89 .enable_reg = (base), \
90 .enable_mask = MAX8907_MASK_OUT5V_EN, \
93 #define REG_BBAT(ids, supply, base, min, max, step) \
96 .supply_name = supply, \
97 .id = MAX8907_##ids, \
98 .n_voltages = ((max) - (min)) / (step) + 1, \
99 .ops = &max8907_bbat_ops, \
100 .type = REGULATOR_VOLTAGE, \
101 .owner = THIS_MODULE, \
104 .vsel_reg = (base), \
105 .vsel_mask = MAX8907_MASK_VBBATTCV, \
108 #define LDO_750_50(id, supply, base) REG_LDO(id, supply, (base), \
109 750000, 3900000, 50000)
110 #define LDO_650_25(id, supply, base) REG_LDO(id, supply, (base), \
111 650000, 2225000, 25000)
180 2400000, 3000000, 200000),
187 #define MATCH(_name, _id) \
188 [MAX8907_##_id] = { \
190 .driver_data = (void *)&max8907_regulators[MAX8907_##_id], \
219 MATCH(out33v, OUT33V),
231 if (!pdev->
dev.parent->of_node)
236 dev_err(&pdev->
dev,
"regulators node not found\n");
244 dev_err(&pdev->
dev,
"Error parsing regulator init data: %d\n",
288 const char *mbatt_rail_name =
NULL;
290 ret = max8907_regulator_parse_dt(pdev);
296 dev_err(&pdev->
dev,
"Failed to alloc pmic\n");
299 platform_set_drvdata(pdev, pmic);
310 (1425000 - 637500) / 12500 + 1;
314 config.
dev = pdev->
dev.parent;
318 idata = match_init_data(i);
322 config.
of_node = match_of_node(i);
324 switch (pmic->
desc[i].id) {
329 mbatt_rail_name = pmic->
desc[
i].name;
338 if (pmic->
desc[i].ops == &max8907_ldo_ops) {
342 MAX8907_MASK_LDO_SEQ)
343 pmic->
desc[
i].ops = &max8907_ldo_hwctl_ops;
344 }
else if (pmic->
desc[i].ops == &max8907_out5v_ops) {
350 pmic->
desc[
i].ops = &max8907_out5v_hwctl_ops;
354 if (IS_ERR(pmic->
rdev[i])) {
356 "failed to register %s regulator\n",
358 ret = PTR_ERR(pmic->
rdev[i]);
359 goto err_unregister_regulator;
365 err_unregister_regulator:
384 .name =
"max8907-regulator",
387 .probe = max8907_regulator_probe,
391 static int __init max8907_regulator_init(
void)
398 static void __exit max8907_reg_exit(
void)