18 #include <linux/kernel.h>
19 #include <linux/module.h>
26 #include <linux/slab.h>
30 #define TPS6507X_DCDC_1 0
31 #define TPS6507X_DCDC_2 1
32 #define TPS6507X_DCDC_3 2
34 #define TPS6507X_LDO_1 3
35 #define TPS6507X_LDO_2 4
37 #define TPS6507X_MAX_REG_ID TPS6507X_LDO_2
40 #define TPS6507X_NUM_DCDC 3
42 #define TPS6507X_NUM_LDO 2
44 #define TPS6507X_NUM_REGULATOR (TPS6507X_NUM_DCDC + TPS6507X_NUM_LDO)
47 static const unsigned int VDCDCx_VSEL_table[] = {
48 725000, 750000, 775000, 800000,
49 825000, 850000, 875000, 900000,
50 925000, 950000, 975000, 1000000,
51 1025000, 1050000, 1075000, 1100000,
52 1125000, 1150000, 1175000, 1200000,
53 1225000, 1250000, 1275000, 1300000,
54 1325000, 1350000, 1375000, 1400000,
55 1425000, 1450000, 1475000, 1500000,
56 1550000, 1600000, 1650000, 1700000,
57 1750000, 1800000, 1850000, 1900000,
58 1950000, 2000000, 2050000, 2100000,
59 2150000, 2200000, 2250000, 2300000,
60 2350000, 2400000, 2450000, 2500000,
61 2550000, 2600000, 2650000, 2700000,
62 2750000, 2800000, 2850000, 2900000,
63 3000000, 3100000, 3200000, 3300000,
66 static const unsigned int LDO1_VSEL_table[] = {
67 1000000, 1100000, 1200000, 1250000,
68 1300000, 1350000, 1400000, 1500000,
69 1600000, 1800000, 2500000, 2750000,
70 2800000, 3000000, 3100000, 3300000,
74 #define LDO2_VSEL_table VDCDCx_VSEL_table
79 const unsigned int *
table;
85 static struct tps_info tps6507x_pmic_regs[] = {
89 .table = VDCDCx_VSEL_table,
94 .table = VDCDCx_VSEL_table,
99 .table = VDCDCx_VSEL_table,
104 .table = LDO1_VSEL_table,
125 err = tps->
mfd->read_dev(tps->
mfd, reg, 1, &val);
135 return tps->
mfd->write_dev(tps->
mfd, reg, 1, &val);
144 data = tps6507x_pmic_read(tps, reg);
146 dev_err(tps->
mfd->dev,
"Read from reg 0x%x failed\n", reg);
152 err = tps6507x_pmic_write(tps, reg, data);
154 dev_err(tps->
mfd->dev,
"Write for reg 0x%x failed\n", reg);
167 data = tps6507x_pmic_read(tps, reg);
169 dev_err(tps->
mfd->dev,
"Read from reg 0x%x failed\n", reg);
175 err = tps6507x_pmic_write(tps, reg, data);
177 dev_err(tps->
mfd->dev,
"Write for reg 0x%x failed\n", reg);
190 data = tps6507x_pmic_read(tps, reg);
192 dev_err(tps->
mfd->dev,
"Read from reg 0x%x failed\n", reg);
204 err = tps6507x_pmic_write(tps, reg, val);
206 dev_err(tps->
mfd->dev,
"Write for reg 0x%x failed\n", reg);
227 return (data & 1<<shift) ? 1 : 0;
236 if (rid < TPS6507X_DCDC_1 || rid > TPS6507X_LDO_2)
249 if (rid < TPS6507X_DCDC_1 || rid > TPS6507X_LDO_2)
257 static int tps6507x_pmic_get_voltage_sel(
struct regulator_dev *dev)
269 if (tps->
info[rid]->defdcdc_default)
276 if (tps->
info[rid]->defdcdc_default)
294 data = tps6507x_pmic_reg_read(tps, reg);
302 static int tps6507x_pmic_set_voltage_sel(
struct regulator_dev *dev,
315 if (tps->
info[rid]->defdcdc_default)
322 if (tps->
info[rid]->defdcdc_default)
340 data = tps6507x_pmic_reg_read(tps, reg);
347 return tps6507x_pmic_reg_write(tps, reg, data);
351 .is_enabled = tps6507x_pmic_is_enabled,
352 .enable = tps6507x_pmic_enable,
353 .disable = tps6507x_pmic_disable,
354 .get_voltage_sel = tps6507x_pmic_get_voltage_sel,
355 .set_voltage_sel = tps6507x_pmic_set_voltage_sel,
376 tps_board = dev_get_platdata(tps6507x_dev->
dev);
395 tps->
mfd = tps6507x_dev;
406 tps->
desc[
i].name = info->name;
408 tps->
desc[
i].n_voltages = info->table_len;
409 tps->
desc[
i].volt_table = info->table;
410 tps->
desc[
i].ops = &tps6507x_pmic_ops;
414 config.
dev = tps6507x_dev->
dev;
421 "failed to register %s regulator\n",
423 error = PTR_ERR(rdev);
432 platform_set_drvdata(pdev, tps6507x_dev);
444 struct tps6507x_dev *tps6507x_dev = platform_get_drvdata(pdev);
455 .name =
"tps6507x-pmic",
458 .probe = tps6507x_pmic_probe,
462 static int __init tps6507x_pmic_init(
void)
468 static void __exit tps6507x_pmic_cleanup(
void)