16 #include <linux/kernel.h>
17 #include <linux/module.h>
23 #include <linux/slab.h>
28 #define TPS65912_REG_DCDC1 0
29 #define TPS65912_REG_DCDC2 1
30 #define TPS65912_REG_DCDC3 2
31 #define TPS65912_REG_DCDC4 3
34 #define TPS65912_REG_LDO1 4
35 #define TPS65912_REG_LDO2 5
36 #define TPS65912_REG_LDO3 6
37 #define TPS65912_REG_LDO4 7
38 #define TPS65912_REG_LDO5 8
39 #define TPS65912_REG_LDO6 9
40 #define TPS65912_REG_LDO7 10
41 #define TPS65912_REG_LDO8 11
42 #define TPS65912_REG_LDO9 12
43 #define TPS65912_REG_LDO10 13
46 #define TPS65912_NUM_DCDC 4
49 #define TPS65912_NUM_LDO 10
52 #define TPS65912_NUM_REGULATOR (TPS65912_NUM_DCDC + TPS65912_NUM_LDO)
54 #define TPS65912_REG_ENABLED 0x80
55 #define OP_SELREG_MASK 0x40
56 #define OP_SELREG_SHIFT 6
62 static struct tps_info tps65912_regs[] = {
121 static int tps65912_get_range(
struct tps65912_reg *pmic,
int id)
151 static unsigned long tps65912_vsel_to_uv_range0(
u8 vsel)
155 uv = ((vsel * 12500) + 500000);
159 static unsigned long tps65912_vsel_to_uv_range1(
u8 vsel)
163 uv = ((vsel * 12500) + 700000);
167 static unsigned long tps65912_vsel_to_uv_range2(
u8 vsel)
171 uv = ((vsel * 25000) + 500000);
175 static unsigned long tps65912_vsel_to_uv_range3(
u8 vsel)
182 uv = ((vsel * 50000) + 500000);
187 static unsigned long tps65912_vsel_to_uv_ldo(
u8 vsel)
189 unsigned long uv = 0;
192 uv = ((vsel * 25000) + 800000);
193 else if (vsel > 32 && vsel <= 60)
194 uv = (((vsel - 32) * 50000) + 1600000);
196 uv = (((vsel - 60) * 100000) + 3000000);
201 static int tps65912_get_ctrl_register(
int id)
211 static int tps65912_get_sel_register(
struct tps65912_reg *pmic,
int id)
232 static int tps65912_get_mode_regiters(
struct tps65912_reg *pmic,
int id)
314 tps65912_get_mode_regiters(pmic,
id);
325 if (pwm_mode && !eco)
332 if (!pwm_mode && !eco)
338 if (!pwm_mode && eco)
350 static unsigned int tps65912_get_mode(
struct regulator_dev *dev)
354 int pwm_mode, eco, mode = 0,
id =
rdev_get_id(dev);
356 tps65912_get_mode_regiters(pmic,
id);
364 if (pwm_mode && !eco)
366 else if (!pwm_mode && !eco)
368 else if (!pwm_mode && eco)
380 return tps65912_vsel_to_uv_ldo(selector);
390 voltage = tps65912_vsel_to_uv_range0(selector);
394 voltage = tps65912_vsel_to_uv_range1(selector);
398 voltage = tps65912_vsel_to_uv_range2(selector);
402 voltage = tps65912_vsel_to_uv_range3(selector);
408 static int tps65912_get_voltage_sel(
struct regulator_dev *dev)
415 reg = tps65912_get_sel_register(pmic,
id);
425 static int tps65912_set_voltage_sel(
struct regulator_dev *dev,
434 reg = tps65912_get_sel_register(pmic,
id);
442 .is_enabled = tps65912_reg_is_enabled,
443 .enable = tps65912_reg_enable,
444 .disable = tps65912_reg_disable,
445 .set_mode = tps65912_set_mode,
446 .get_mode = tps65912_get_mode,
447 .get_voltage_sel = tps65912_get_voltage_sel,
448 .set_voltage_sel = tps65912_set_voltage_sel,
449 .list_voltage = tps65912_list_voltage,
454 .is_enabled = tps65912_reg_is_enabled,
455 .enable = tps65912_reg_enable,
456 .disable = tps65912_reg_disable,
457 .get_voltage_sel = tps65912_get_voltage_sel,
458 .set_voltage_sel = tps65912_set_voltage_sel,
459 .list_voltage = tps65912_list_voltage,
473 pmic_plat_data = dev_get_platdata(tps65912->
dev);
484 pmic->
mfd = tps65912;
485 platform_set_drvdata(pdev, pmic);
488 info = tps65912_regs;
495 pmic->
desc[
i].name = info->name;
497 pmic->
desc[
i].n_voltages = 64;
499 &tps65912_ops_ldo : &tps65912_ops_dcdc);
502 range = tps65912_get_range(pmic, i);
504 config.
dev = tps65912->
dev;
511 "failed to register %s regulator\n",
540 .name =
"tps65912-pmic",
543 .probe = tps65912_probe,
547 static int __init tps65912_init(
void)
553 static void __exit tps65912_cleanup(
void)