18 #include <linux/kernel.h>
19 #include <linux/module.h>
25 #include <linux/i2c.h>
26 #include <linux/slab.h>
30 #define TPS65023_REG_VERSION 0
31 #define TPS65023_REG_PGOODZ 1
32 #define TPS65023_REG_MASK 2
33 #define TPS65023_REG_REG_CTRL 3
34 #define TPS65023_REG_CON_CTRL 4
35 #define TPS65023_REG_CON_CTRL2 5
36 #define TPS65023_REG_DEF_CORE 6
37 #define TPS65023_REG_DEFSLEW 7
38 #define TPS65023_REG_LDO_CTRL 8
41 #define TPS65023_PGOODZ_PWRFAILZ BIT(7)
42 #define TPS65023_PGOODZ_LOWBATTZ BIT(6)
43 #define TPS65023_PGOODZ_VDCDC1 BIT(5)
44 #define TPS65023_PGOODZ_VDCDC2 BIT(4)
45 #define TPS65023_PGOODZ_VDCDC3 BIT(3)
46 #define TPS65023_PGOODZ_LDO2 BIT(2)
47 #define TPS65023_PGOODZ_LDO1 BIT(1)
50 #define TPS65023_MASK_PWRFAILZ BIT(7)
51 #define TPS65023_MASK_LOWBATTZ BIT(6)
52 #define TPS65023_MASK_VDCDC1 BIT(5)
53 #define TPS65023_MASK_VDCDC2 BIT(4)
54 #define TPS65023_MASK_VDCDC3 BIT(3)
55 #define TPS65023_MASK_LDO2 BIT(2)
56 #define TPS65023_MASK_LDO1 BIT(1)
59 #define TPS65023_REG_CTRL_VDCDC1_EN BIT(5)
60 #define TPS65023_REG_CTRL_VDCDC2_EN BIT(4)
61 #define TPS65023_REG_CTRL_VDCDC3_EN BIT(3)
62 #define TPS65023_REG_CTRL_LDO2_EN BIT(2)
63 #define TPS65023_REG_CTRL_LDO1_EN BIT(1)
66 #define TPS65023_REG_CTRL2_GO BIT(7)
67 #define TPS65023_REG_CTRL2_CORE_ADJ BIT(6)
68 #define TPS65023_REG_CTRL2_DCDC2 BIT(2)
69 #define TPS65023_REG_CTRL2_DCDC1 BIT(1)
70 #define TPS65023_REG_CTRL2_DCDC3 BIT(0)
73 #define TPS65023_NUM_DCDC 3
75 #define TPS65023_NUM_LDO 2
77 #define TPS65023_NUM_REGULATOR (TPS65023_NUM_DCDC + TPS65023_NUM_LDO)
80 #define TPS65023_DCDC_1 0
81 #define TPS65023_DCDC_2 1
82 #define TPS65023_DCDC_3 2
84 #define TPS65023_LDO_1 3
85 #define TPS65023_LDO_2 4
87 #define TPS65023_MAX_REG_ID TPS65023_LDO_2
90 static const unsigned int VCORE_VSEL_table[] = {
91 800000, 825000, 850000, 875000,
92 900000, 925000, 950000, 975000,
93 1000000, 1025000, 1050000, 1075000,
94 1100000, 1125000, 1150000, 1175000,
95 1200000, 1225000, 1250000, 1275000,
96 1300000, 1325000, 1350000, 1375000,
97 1400000, 1425000, 1450000, 1475000,
98 1500000, 1525000, 1550000, 1600000,
101 static const unsigned int DCDC_FIXED_3300000_VSEL_table[] = {
105 static const unsigned int DCDC_FIXED_1800000_VSEL_table[] = {
110 static const unsigned int TPS65020_LDO1_VSEL_table[] = {
111 1000000, 1050000, 1100000, 1300000,
112 1800000, 2500000, 3000000, 3300000,
115 static const unsigned int TPS65020_LDO2_VSEL_table[] = {
116 1000000, 1050000, 1100000, 1300000,
117 1800000, 2500000, 3000000, 3300000,
122 static const unsigned int TPS65023_LDO1_VSEL_table[] = {
123 1000000, 1100000, 1300000, 1800000,
124 2200000, 2600000, 2800000, 3150000,
127 static const unsigned int TPS65023_LDO2_VSEL_table[] = {
128 1050000, 1200000, 1300000, 1800000,
129 2500000, 2800000, 3000000, 3300000,
167 data &= (tps->
info[dcdc]->table_len - 1);
202 .get_voltage_sel = tps65023_dcdc_get_voltage_sel,
203 .set_voltage_sel = tps65023_dcdc_set_voltage_sel,
217 static struct regmap_config tps65023_regmap_config = {
241 init_data =
client->dev.platform_data;
250 if (IS_ERR(tps->
regmap)) {
251 error = PTR_ERR(tps->
regmap);
252 dev_err(&
client->dev,
"Failed to allocate register map: %d\n",
264 tps->
desc[
i].name = info->name;
266 tps->
desc[
i].n_voltages = info->table_len;
267 tps->
desc[
i].volt_table = info->table;
269 &tps65023_ldo_ops : &tps65023_dcdc_ops);
277 tps->
desc[
i].vsel_mask = 0x07;
278 tps->
desc[
i].enable_mask = 1 << 1;
282 tps->
desc[
i].vsel_mask = 0x70;
283 tps->
desc[
i].enable_mask = 1 << 2;
286 tps->
desc[
i].enable_mask =
287 1 << (TPS65023_NUM_REGULATOR -
i);
291 config.init_data = init_data;
300 error = PTR_ERR(rdev);
308 i2c_set_clientdata(
client, tps);
324 struct tps_pmic *tps = i2c_get_clientdata(client);
332 static const struct tps_info tps65020_regs[] = {
335 .table_len =
ARRAY_SIZE(DCDC_FIXED_3300000_VSEL_table),
336 .table = DCDC_FIXED_3300000_VSEL_table,
340 .table_len =
ARRAY_SIZE(DCDC_FIXED_1800000_VSEL_table),
341 .table = DCDC_FIXED_1800000_VSEL_table,
346 .table = VCORE_VSEL_table,
350 .table_len =
ARRAY_SIZE(TPS65020_LDO1_VSEL_table),
351 .table = TPS65020_LDO1_VSEL_table,
355 .table_len =
ARRAY_SIZE(TPS65020_LDO2_VSEL_table),
356 .table = TPS65020_LDO2_VSEL_table,
360 static const struct tps_info tps65021_regs[] = {
363 .table_len =
ARRAY_SIZE(DCDC_FIXED_3300000_VSEL_table),
364 .table = DCDC_FIXED_3300000_VSEL_table,
368 .table_len =
ARRAY_SIZE(DCDC_FIXED_1800000_VSEL_table),
369 .table = DCDC_FIXED_1800000_VSEL_table,
374 .table = VCORE_VSEL_table,
378 .table_len =
ARRAY_SIZE(TPS65023_LDO1_VSEL_table),
379 .table = TPS65023_LDO1_VSEL_table,
383 .table_len =
ARRAY_SIZE(TPS65023_LDO2_VSEL_table),
384 .table = TPS65023_LDO2_VSEL_table,
388 static const struct tps_info tps65023_regs[] = {
392 .table = VCORE_VSEL_table,
396 .table_len =
ARRAY_SIZE(DCDC_FIXED_3300000_VSEL_table),
397 .table = DCDC_FIXED_3300000_VSEL_table,
401 .table_len =
ARRAY_SIZE(DCDC_FIXED_1800000_VSEL_table),
402 .table = DCDC_FIXED_1800000_VSEL_table,
406 .table_len =
ARRAY_SIZE(TPS65023_LDO1_VSEL_table),
407 .table = TPS65023_LDO1_VSEL_table,
411 .table_len =
ARRAY_SIZE(TPS65023_LDO2_VSEL_table),
412 .table = TPS65023_LDO2_VSEL_table,
417 .info = tps65020_regs,
422 .info = tps65021_regs,
427 .info = tps65023_regs,
433 .driver_data = (
unsigned long) &tps65023_drv_data},
435 .driver_data = (
unsigned long) &tps65021_drv_data,},
437 .driver_data = (
unsigned long) &tps65020_drv_data},
443 static struct i2c_driver tps_65023_i2c_driver = {
448 .probe = tps_65023_probe,
450 .id_table = tps_65023_id,
453 static int __init tps_65023_init(
void)
455 return i2c_add_driver(&tps_65023_i2c_driver);
459 static void __exit tps_65023_cleanup(
void)