15 #include <linux/kernel.h>
16 #include <linux/module.h>
26 #include <linux/slab.h>
59 static const unsigned int ldo_vauxn_voltages[] = {
78 static const unsigned int ldo_vaux3_voltages[] = {
89 static const unsigned int ldo_vintcore_voltages[] = {
114 "couldn't set enable bits for regulator\n");
117 "%s-enable (bank, reg, mask, value): 0x%x, 0x%x, 0x%x, 0x%x\n",
124 static int ab8500_regulator_disable(
struct regulator_dev *rdev)
139 "couldn't set disable bits for regulator\n");
142 "%s-disable (bank, reg, mask, value): 0x%x, 0x%x, 0x%x, 0x%x\n",
149 static int ab8500_regulator_is_enabled(
struct regulator_dev *rdev)
164 "couldn't read 0x%x register\n", info->
update_reg);
169 "%s-is_enabled (bank, reg, mask, value): 0x%x, 0x%x, 0x%x,"
180 static int ab8500_regulator_get_voltage_sel(
struct regulator_dev *rdev)
195 "couldn't read voltage reg for regulator\n");
200 "%s-get_voltage (bank, reg, mask, shift, value): "
201 "0x%x, 0x%x, 0x%x, 0x%x, 0x%x\n",
210 static int ab8500_regulator_set_voltage_sel(
struct regulator_dev *rdev,
229 "couldn't set voltage reg for regulator\n");
232 "%s-set_voltage (bank, reg, mask, value): 0x%x, 0x%x, 0x%x,"
240 static int ab8500_regulator_set_voltage_time_sel(
struct regulator_dev *rdev,
241 unsigned int old_sel,
242 unsigned int new_sel)
250 .enable = ab8500_regulator_enable,
251 .disable = ab8500_regulator_disable,
252 .is_enabled = ab8500_regulator_is_enabled,
253 .get_voltage_sel = ab8500_regulator_get_voltage_sel,
254 .set_voltage_sel = ab8500_regulator_set_voltage_sel,
256 .set_voltage_time_sel = ab8500_regulator_set_voltage_time_sel,
260 .enable = ab8500_regulator_enable,
261 .disable = ab8500_regulator_disable,
262 .is_enabled = ab8500_regulator_is_enabled,
277 .ops = &ab8500_regulator_ops,
282 .volt_table = ldo_vauxn_voltages,
287 .update_val_enable = 0x01,
288 .voltage_bank = 0x04,
290 .voltage_mask = 0x0f,
295 .ops = &ab8500_regulator_ops,
300 .volt_table = ldo_vauxn_voltages,
305 .update_val_enable = 0x04,
306 .voltage_bank = 0x04,
308 .voltage_mask = 0x0f,
313 .ops = &ab8500_regulator_ops,
318 .volt_table = ldo_vaux3_voltages,
323 .update_val_enable = 0x01,
324 .voltage_bank = 0x04,
326 .voltage_mask = 0x07,
330 .name =
"LDO-INTCORE",
331 .ops = &ab8500_regulator_ops,
335 .n_voltages =
ARRAY_SIZE(ldo_vintcore_voltages),
336 .volt_table = ldo_vintcore_voltages,
341 .update_val_enable = 0x04,
342 .voltage_bank = 0x03,
344 .voltage_mask = 0x38,
356 .ops = &ab8500_regulator_fixed_ops,
362 .enable_time = 10000,
368 .update_val_enable = 0x02,
373 .ops = &ab8500_regulator_fixed_ops,
383 .update_val_enable = 0x01,
388 .ops = &ab8500_regulator_fixed_ops,
398 .update_val_enable = 0x02,
402 .name =
"LDO-ANAMIC1",
403 .ops = &ab8500_regulator_fixed_ops,
413 .update_val_enable = 0x08,
417 .name =
"LDO-ANAMIC2",
418 .ops = &ab8500_regulator_fixed_ops,
428 .update_val_enable = 0x10,
433 .ops = &ab8500_regulator_fixed_ops,
443 .update_val_enable = 0x04,
448 .ops = &ab8500_regulator_fixed_ops,
458 .update_val_enable = 0x04,
470 #define REG_INIT(_id, _bank, _addr, _mask) \
649 if (value & ~ab8500_reg_init[
id].
mask) {
651 "Configuration error: value outside mask.\n");
657 ab8500_reg_init[
id].
bank,
658 ab8500_reg_init[
id].
addr,
659 ab8500_reg_init[
id].
mask,
663 "Failed to initialize 0x%02x, 0x%02x.\n",
664 ab8500_reg_init[
id].
bank,
665 ab8500_reg_init[
id].
addr);
670 "init: 0x%02x, 0x%02x, 0x%02x, 0x%02x\n",
671 ab8500_reg_init[
id].
bank,
672 ab8500_reg_init[
id].
addr,
673 ab8500_reg_init[
id].
mask,
684 struct ab8500_regulator_info *info =
NULL;
689 info = &ab8500_regulator_info[
id];
700 info->
desc.n_voltages =
702 info->
desc.volt_table = ldo_vauxn_voltages;
711 dev_err(&pdev->
dev,
"failed to register regulator %s\n",
715 info = &ab8500_regulator_info[
id];
725 { .name =
"ab8500_ldo_aux1", .driver_data = (
void *)
AB8500_LDO_AUX1, },
726 { .name =
"ab8500_ldo_aux2", .driver_data = (
void *)
AB8500_LDO_AUX2, },
727 { .name =
"ab8500_ldo_aux3", .driver_data = (
void *)
AB8500_LDO_AUX3, },
730 { .name =
"ab8500_ldo_usb", .driver_data = (
void *)
AB8500_LDO_USB, },
734 { .name =
"ab8500_ldo_dmic", .driver_data = (
void *)
AB8500_LDO_DMIC, },
735 { .name =
"ab8500_ldo_ana", .driver_data = (
void *)
AB8500_LDO_ANA, },
743 for (i = 0; i <
ARRAY_SIZE(ab8500_regulator_info); i++) {
744 err = ab8500_regulator_register(
745 pdev, ab8500_regulator_matches[i].init_data,
746 i, ab8500_regulator_matches[i].
of_node);
763 ab8500_regulator_matches,
767 "Error parsing regulator init data: %d\n", err);
771 err = ab8500_regulator_of_probe(pdev, np);
779 pdata = dev_get_platdata(ab8500->
dev);
787 dev_err(&pdev->
dev,
"Configuration error: size mismatch.\n");
801 "Configuration error: id outside range.\n");
805 err = ab8500_regulator_init_registers(pdev,
id, value);
811 for (i = 0; i <
ARRAY_SIZE(ab8500_regulator_info); i++) {
812 err = ab8500_regulator_register(pdev, &pdata->
regulator[i], i,
NULL);
824 for (i = 0; i <
ARRAY_SIZE(ab8500_regulator_info); i++) {
825 struct ab8500_regulator_info *info =
NULL;
826 info = &ab8500_regulator_info[
i];
829 "%s-remove\n", info->
desc.name);
838 .probe = ab8500_regulator_probe,
841 .name =
"ab8500-regulator",
846 static int __init ab8500_regulator_init(
void)
852 pr_err(
"Failed to register ab8500 regulator: %d\n", ret);
858 static void __exit ab8500_regulator_exit(
void)