18 #include <linux/slab.h>
19 #include <linux/module.h>
42 static int get_ramp_delay(
int ramp_delay)
44 unsigned char cnt = 0;
49 ramp_delay = ramp_delay >> 1;
79 #define regulator_desc_ldo1(num) { \
81 .id = S2MPS11_LDO##num, \
82 .ops = &s2mps11_ldo_ops, \
83 .type = REGULATOR_VOLTAGE, \
84 .owner = THIS_MODULE, \
85 .min_uV = S2MPS11_LDO_MIN, \
86 .uV_step = S2MPS11_LDO_STEP1, \
87 .n_voltages = S2MPS11_LDO_N_VOLTAGES, \
88 .vsel_reg = S2MPS11_REG_L1CTRL + num - 1, \
89 .vsel_mask = S2MPS11_LDO_VSEL_MASK, \
90 .enable_reg = S2MPS11_REG_L1CTRL + num - 1, \
91 .enable_mask = S2MPS11_ENABLE_MASK \
93 #define regulator_desc_ldo2(num) { \
95 .id = S2MPS11_LDO##num, \
96 .ops = &s2mps11_ldo_ops, \
97 .type = REGULATOR_VOLTAGE, \
98 .owner = THIS_MODULE, \
99 .min_uV = S2MPS11_LDO_MIN, \
100 .uV_step = S2MPS11_LDO_STEP2, \
101 .n_voltages = S2MPS11_LDO_N_VOLTAGES, \
102 .vsel_reg = S2MPS11_REG_L1CTRL + num - 1, \
103 .vsel_mask = S2MPS11_LDO_VSEL_MASK, \
104 .enable_reg = S2MPS11_REG_L1CTRL + num - 1, \
105 .enable_mask = S2MPS11_ENABLE_MASK \
108 #define regulator_desc_buck1_4(num) { \
109 .name = "BUCK"#num, \
110 .id = S2MPS11_BUCK##num, \
111 .ops = &s2mps11_buck_ops, \
112 .type = REGULATOR_VOLTAGE, \
113 .owner = THIS_MODULE, \
114 .min_uV = S2MPS11_BUCK_MIN1, \
115 .uV_step = S2MPS11_BUCK_STEP1, \
116 .n_voltages = S2MPS11_BUCK_N_VOLTAGES, \
117 .vsel_reg = S2MPS11_REG_B1CTRL2 + (num - 1) * 2, \
118 .vsel_mask = S2MPS11_BUCK_VSEL_MASK, \
119 .enable_reg = S2MPS11_REG_B1CTRL1 + (num - 1) * 2, \
120 .enable_mask = S2MPS11_ENABLE_MASK \
123 #define regulator_desc_buck5 { \
125 .id = S2MPS11_BUCK5, \
126 .ops = &s2mps11_buck_ops, \
127 .type = REGULATOR_VOLTAGE, \
128 .owner = THIS_MODULE, \
129 .min_uV = S2MPS11_BUCK_MIN1, \
130 .uV_step = S2MPS11_BUCK_STEP1, \
131 .n_voltages = S2MPS11_BUCK_N_VOLTAGES, \
132 .vsel_reg = S2MPS11_REG_B5CTRL2, \
133 .vsel_mask = S2MPS11_BUCK_VSEL_MASK, \
134 .enable_reg = S2MPS11_REG_B5CTRL1, \
135 .enable_mask = S2MPS11_ENABLE_MASK \
138 #define regulator_desc_buck6_8(num) { \
139 .name = "BUCK"#num, \
140 .id = S2MPS11_BUCK##num, \
141 .ops = &s2mps11_buck_ops, \
142 .type = REGULATOR_VOLTAGE, \
143 .owner = THIS_MODULE, \
144 .min_uV = S2MPS11_BUCK_MIN1, \
145 .uV_step = S2MPS11_BUCK_STEP1, \
146 .n_voltages = S2MPS11_BUCK_N_VOLTAGES, \
147 .vsel_reg = S2MPS11_REG_B6CTRL2 + (num - 6) * 2, \
148 .vsel_mask = S2MPS11_BUCK_VSEL_MASK, \
149 .enable_reg = S2MPS11_REG_B6CTRL1 + (num - 6) * 2, \
150 .enable_mask = S2MPS11_ENABLE_MASK \
153 #define regulator_desc_buck9 { \
155 .id = S2MPS11_BUCK9, \
156 .ops = &s2mps11_buck_ops, \
157 .type = REGULATOR_VOLTAGE, \
158 .owner = THIS_MODULE, \
159 .min_uV = S2MPS11_BUCK_MIN3, \
160 .uV_step = S2MPS11_BUCK_STEP3, \
161 .n_voltages = S2MPS11_BUCK_N_VOLTAGES, \
162 .vsel_reg = S2MPS11_REG_B9CTRL2, \
163 .vsel_mask = S2MPS11_BUCK_VSEL_MASK, \
164 .enable_reg = S2MPS11_REG_B9CTRL1, \
165 .enable_mask = S2MPS11_ENABLE_MASK \
168 #define regulator_desc_buck10 { \
170 .id = S2MPS11_BUCK10, \
171 .ops = &s2mps11_buck_ops, \
172 .type = REGULATOR_VOLTAGE, \
173 .owner = THIS_MODULE, \
174 .min_uV = S2MPS11_BUCK_MIN2, \
175 .uV_step = S2MPS11_BUCK_STEP2, \
176 .n_voltages = S2MPS11_BUCK_N_VOLTAGES, \
177 .vsel_reg = S2MPS11_REG_B9CTRL2, \
178 .vsel_mask = S2MPS11_BUCK_VSEL_MASK, \
179 .enable_reg = S2MPS11_REG_B9CTRL1, \
180 .enable_mask = S2MPS11_ENABLE_MASK \
241 unsigned char ramp_enable, ramp_reg = 0;
244 dev_err(pdev->
dev.parent,
"Platform data not supplied\n");
253 platform_set_drvdata(pdev, s2mps11);
272 ramp_reg |= get_ramp_delay(s2mps11->
ramp_delay2) >> 6;
279 ramp_reg |= get_ramp_delay(s2mps11->
ramp_delay5) >> 6;
293 if (IS_ERR(s2mps11->
rdev[i])) {
294 ret = PTR_ERR(s2mps11->
rdev[i]);
295 dev_err(&pdev->
dev,
"regulator init failed for %d\n",
312 struct s2mps11_info *s2mps11 = platform_get_drvdata(pdev);
322 {
"s2mps11-pmic", 0},
329 .name =
"s2mps11-pmic",
332 .probe = s2mps11_pmic_probe,
334 .id_table = s2mps11_pmic_id,
337 static int __init s2mps11_pmic_init(
void)
343 static void __exit s2mps11_pmic_exit(
void)