Krzysztof Kozlowski | 4f3fb28 | 2018-08-07 18:18:26 +0200 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
| 2 | // |
| 3 | // Copyright (c) 2013 Samsung Electronics Co., Ltd |
| 4 | // http://www.samsung.com |
Sachin Kamat | f187927 | 2014-03-14 17:21:58 +0530 | [diff] [blame] | 5 | |
| 6 | #include <linux/bug.h> |
| 7 | #include <linux/err.h> |
| 8 | #include <linux/gpio.h> |
| 9 | #include <linux/slab.h> |
| 10 | #include <linux/module.h> |
| 11 | #include <linux/of.h> |
| 12 | #include <linux/regmap.h> |
| 13 | #include <linux/platform_device.h> |
| 14 | #include <linux/regulator/driver.h> |
| 15 | #include <linux/regulator/machine.h> |
| 16 | #include <linux/regulator/of_regulator.h> |
| 17 | #include <linux/mfd/samsung/core.h> |
| 18 | #include <linux/mfd/samsung/s2mpa01.h> |
| 19 | |
Sachin Kamat | f187927 | 2014-03-14 17:21:58 +0530 | [diff] [blame] | 20 | struct s2mpa01_info { |
| 21 | int ramp_delay24; |
| 22 | int ramp_delay3; |
| 23 | int ramp_delay5; |
| 24 | int ramp_delay16; |
| 25 | int ramp_delay7; |
| 26 | int ramp_delay8910; |
| 27 | }; |
| 28 | |
| 29 | static int get_ramp_delay(int ramp_delay) |
| 30 | { |
| 31 | unsigned char cnt = 0; |
| 32 | |
| 33 | ramp_delay /= 6250; |
| 34 | |
| 35 | while (true) { |
| 36 | ramp_delay = ramp_delay >> 1; |
| 37 | if (ramp_delay == 0) |
| 38 | break; |
| 39 | cnt++; |
| 40 | } |
| 41 | |
| 42 | if (cnt > 3) |
| 43 | cnt = 3; |
| 44 | |
| 45 | return cnt; |
| 46 | } |
| 47 | |
| 48 | static int s2mpa01_regulator_set_voltage_time_sel(struct regulator_dev *rdev, |
| 49 | unsigned int old_selector, |
| 50 | unsigned int new_selector) |
| 51 | { |
| 52 | struct s2mpa01_info *s2mpa01 = rdev_get_drvdata(rdev); |
| 53 | unsigned int ramp_delay = 0; |
| 54 | int old_volt, new_volt; |
| 55 | |
Krzysztof Kozlowski | 0608032 | 2014-05-06 08:37:38 +0200 | [diff] [blame] | 56 | switch (rdev_get_id(rdev)) { |
Sachin Kamat | f187927 | 2014-03-14 17:21:58 +0530 | [diff] [blame] | 57 | case S2MPA01_BUCK2: |
| 58 | case S2MPA01_BUCK4: |
| 59 | ramp_delay = s2mpa01->ramp_delay24; |
| 60 | break; |
| 61 | case S2MPA01_BUCK3: |
| 62 | ramp_delay = s2mpa01->ramp_delay3; |
| 63 | break; |
| 64 | case S2MPA01_BUCK5: |
| 65 | ramp_delay = s2mpa01->ramp_delay5; |
| 66 | break; |
| 67 | case S2MPA01_BUCK1: |
| 68 | case S2MPA01_BUCK6: |
| 69 | ramp_delay = s2mpa01->ramp_delay16; |
| 70 | break; |
| 71 | case S2MPA01_BUCK7: |
| 72 | ramp_delay = s2mpa01->ramp_delay7; |
| 73 | break; |
| 74 | case S2MPA01_BUCK8: |
| 75 | case S2MPA01_BUCK9: |
| 76 | case S2MPA01_BUCK10: |
| 77 | ramp_delay = s2mpa01->ramp_delay8910; |
| 78 | break; |
| 79 | } |
| 80 | |
| 81 | if (ramp_delay == 0) |
| 82 | ramp_delay = rdev->desc->ramp_delay; |
| 83 | |
| 84 | old_volt = rdev->desc->min_uV + (rdev->desc->uV_step * old_selector); |
| 85 | new_volt = rdev->desc->min_uV + (rdev->desc->uV_step * new_selector); |
| 86 | |
| 87 | return DIV_ROUND_UP(abs(new_volt - old_volt), ramp_delay); |
| 88 | } |
| 89 | |
| 90 | static int s2mpa01_set_ramp_delay(struct regulator_dev *rdev, int ramp_delay) |
| 91 | { |
| 92 | struct s2mpa01_info *s2mpa01 = rdev_get_drvdata(rdev); |
| 93 | unsigned int ramp_val, ramp_shift, ramp_reg = S2MPA01_REG_RAMP2; |
| 94 | unsigned int ramp_enable = 1, enable_shift = 0; |
| 95 | int ret; |
| 96 | |
Krzysztof Kozlowski | 0608032 | 2014-05-06 08:37:38 +0200 | [diff] [blame] | 97 | switch (rdev_get_id(rdev)) { |
Sachin Kamat | f187927 | 2014-03-14 17:21:58 +0530 | [diff] [blame] | 98 | case S2MPA01_BUCK1: |
| 99 | enable_shift = S2MPA01_BUCK1_RAMP_EN_SHIFT; |
| 100 | if (!ramp_delay) { |
| 101 | ramp_enable = 0; |
| 102 | break; |
| 103 | } |
| 104 | |
| 105 | if (ramp_delay > s2mpa01->ramp_delay16) |
| 106 | s2mpa01->ramp_delay16 = ramp_delay; |
| 107 | else |
| 108 | ramp_delay = s2mpa01->ramp_delay16; |
| 109 | |
| 110 | ramp_shift = S2MPA01_BUCK16_RAMP_SHIFT; |
Sachin Kamat | f187927 | 2014-03-14 17:21:58 +0530 | [diff] [blame] | 111 | break; |
| 112 | case S2MPA01_BUCK2: |
| 113 | enable_shift = S2MPA01_BUCK2_RAMP_EN_SHIFT; |
| 114 | if (!ramp_delay) { |
| 115 | ramp_enable = 0; |
| 116 | break; |
| 117 | } |
| 118 | |
| 119 | if (ramp_delay > s2mpa01->ramp_delay24) |
| 120 | s2mpa01->ramp_delay24 = ramp_delay; |
| 121 | else |
| 122 | ramp_delay = s2mpa01->ramp_delay24; |
| 123 | |
| 124 | ramp_shift = S2MPA01_BUCK24_RAMP_SHIFT; |
| 125 | ramp_reg = S2MPA01_REG_RAMP1; |
| 126 | break; |
| 127 | case S2MPA01_BUCK3: |
| 128 | enable_shift = S2MPA01_BUCK3_RAMP_EN_SHIFT; |
| 129 | if (!ramp_delay) { |
| 130 | ramp_enable = 0; |
| 131 | break; |
| 132 | } |
| 133 | |
| 134 | s2mpa01->ramp_delay3 = ramp_delay; |
| 135 | ramp_shift = S2MPA01_BUCK3_RAMP_SHIFT; |
| 136 | ramp_reg = S2MPA01_REG_RAMP1; |
| 137 | break; |
| 138 | case S2MPA01_BUCK4: |
| 139 | enable_shift = S2MPA01_BUCK4_RAMP_EN_SHIFT; |
| 140 | if (!ramp_delay) { |
| 141 | ramp_enable = 0; |
| 142 | break; |
| 143 | } |
| 144 | |
| 145 | if (ramp_delay > s2mpa01->ramp_delay24) |
| 146 | s2mpa01->ramp_delay24 = ramp_delay; |
| 147 | else |
| 148 | ramp_delay = s2mpa01->ramp_delay24; |
| 149 | |
| 150 | ramp_shift = S2MPA01_BUCK24_RAMP_SHIFT; |
| 151 | ramp_reg = S2MPA01_REG_RAMP1; |
| 152 | break; |
| 153 | case S2MPA01_BUCK5: |
| 154 | s2mpa01->ramp_delay5 = ramp_delay; |
| 155 | ramp_shift = S2MPA01_BUCK5_RAMP_SHIFT; |
| 156 | break; |
| 157 | case S2MPA01_BUCK6: |
| 158 | if (ramp_delay > s2mpa01->ramp_delay16) |
| 159 | s2mpa01->ramp_delay16 = ramp_delay; |
| 160 | else |
| 161 | ramp_delay = s2mpa01->ramp_delay16; |
| 162 | |
| 163 | ramp_shift = S2MPA01_BUCK16_RAMP_SHIFT; |
| 164 | break; |
| 165 | case S2MPA01_BUCK7: |
| 166 | s2mpa01->ramp_delay7 = ramp_delay; |
| 167 | ramp_shift = S2MPA01_BUCK7_RAMP_SHIFT; |
| 168 | break; |
| 169 | case S2MPA01_BUCK8: |
| 170 | case S2MPA01_BUCK9: |
| 171 | case S2MPA01_BUCK10: |
| 172 | if (ramp_delay > s2mpa01->ramp_delay8910) |
| 173 | s2mpa01->ramp_delay8910 = ramp_delay; |
| 174 | else |
| 175 | ramp_delay = s2mpa01->ramp_delay8910; |
| 176 | |
| 177 | ramp_shift = S2MPA01_BUCK8910_RAMP_SHIFT; |
| 178 | break; |
| 179 | default: |
| 180 | return 0; |
| 181 | } |
| 182 | |
| 183 | if (!ramp_enable) |
| 184 | goto ramp_disable; |
| 185 | |
Krzysztof Kozlowski | 51e2fc0 | 2014-05-06 08:37:37 +0200 | [diff] [blame] | 186 | /* Ramp delay can be enabled/disabled only for buck[1234] */ |
| 187 | if (rdev_get_id(rdev) >= S2MPA01_BUCK1 && |
| 188 | rdev_get_id(rdev) <= S2MPA01_BUCK4) { |
| 189 | ret = regmap_update_bits(rdev->regmap, S2MPA01_REG_RAMP1, |
| 190 | 1 << enable_shift, 1 << enable_shift); |
| 191 | if (ret) { |
| 192 | dev_err(&rdev->dev, "failed to enable ramp rate\n"); |
| 193 | return ret; |
| 194 | } |
Sachin Kamat | f187927 | 2014-03-14 17:21:58 +0530 | [diff] [blame] | 195 | } |
| 196 | |
| 197 | ramp_val = get_ramp_delay(ramp_delay); |
| 198 | |
| 199 | return regmap_update_bits(rdev->regmap, ramp_reg, 0x3 << ramp_shift, |
| 200 | ramp_val << ramp_shift); |
| 201 | |
| 202 | ramp_disable: |
| 203 | return regmap_update_bits(rdev->regmap, S2MPA01_REG_RAMP1, |
| 204 | 1 << enable_shift, 0); |
| 205 | } |
| 206 | |
Krzysztof Kozlowski | f465bf9 | 2017-03-11 21:01:21 +0200 | [diff] [blame] | 207 | static const struct regulator_ops s2mpa01_ldo_ops = { |
Sachin Kamat | f187927 | 2014-03-14 17:21:58 +0530 | [diff] [blame] | 208 | .list_voltage = regulator_list_voltage_linear, |
| 209 | .map_voltage = regulator_map_voltage_linear, |
| 210 | .is_enabled = regulator_is_enabled_regmap, |
| 211 | .enable = regulator_enable_regmap, |
| 212 | .disable = regulator_disable_regmap, |
| 213 | .get_voltage_sel = regulator_get_voltage_sel_regmap, |
| 214 | .set_voltage_sel = regulator_set_voltage_sel_regmap, |
| 215 | .set_voltage_time_sel = regulator_set_voltage_time_sel, |
| 216 | }; |
| 217 | |
Krzysztof Kozlowski | f465bf9 | 2017-03-11 21:01:21 +0200 | [diff] [blame] | 218 | static const struct regulator_ops s2mpa01_buck_ops = { |
Sachin Kamat | f187927 | 2014-03-14 17:21:58 +0530 | [diff] [blame] | 219 | .list_voltage = regulator_list_voltage_linear, |
| 220 | .map_voltage = regulator_map_voltage_linear, |
| 221 | .is_enabled = regulator_is_enabled_regmap, |
| 222 | .enable = regulator_enable_regmap, |
| 223 | .disable = regulator_disable_regmap, |
| 224 | .get_voltage_sel = regulator_get_voltage_sel_regmap, |
| 225 | .set_voltage_sel = regulator_set_voltage_sel_regmap, |
| 226 | .set_voltage_time_sel = s2mpa01_regulator_set_voltage_time_sel, |
| 227 | .set_ramp_delay = s2mpa01_set_ramp_delay, |
| 228 | }; |
| 229 | |
Amit Daniel Kachhap | d264fd4 | 2014-07-15 16:32:52 +0530 | [diff] [blame] | 230 | #define regulator_desc_ldo(num, step) { \ |
Sachin Kamat | f187927 | 2014-03-14 17:21:58 +0530 | [diff] [blame] | 231 | .name = "LDO"#num, \ |
Axel Lin | 0677c3e | 2019-04-04 23:07:09 +0800 | [diff] [blame] | 232 | .of_match = of_match_ptr("LDO"#num), \ |
| 233 | .regulators_node = of_match_ptr("regulators"), \ |
Sachin Kamat | f187927 | 2014-03-14 17:21:58 +0530 | [diff] [blame] | 234 | .id = S2MPA01_LDO##num, \ |
| 235 | .ops = &s2mpa01_ldo_ops, \ |
| 236 | .type = REGULATOR_VOLTAGE, \ |
| 237 | .owner = THIS_MODULE, \ |
Amit Daniel Kachhap | 0e4f417 | 2014-07-15 16:32:51 +0530 | [diff] [blame] | 238 | .min_uV = MIN_800_MV, \ |
Amit Daniel Kachhap | d264fd4 | 2014-07-15 16:32:52 +0530 | [diff] [blame] | 239 | .uV_step = step, \ |
Sachin Kamat | f187927 | 2014-03-14 17:21:58 +0530 | [diff] [blame] | 240 | .n_voltages = S2MPA01_LDO_N_VOLTAGES, \ |
| 241 | .vsel_reg = S2MPA01_REG_L1CTRL + num - 1, \ |
| 242 | .vsel_mask = S2MPA01_LDO_VSEL_MASK, \ |
| 243 | .enable_reg = S2MPA01_REG_L1CTRL + num - 1, \ |
| 244 | .enable_mask = S2MPA01_ENABLE_MASK \ |
| 245 | } |
| 246 | |
| 247 | #define regulator_desc_buck1_4(num) { \ |
| 248 | .name = "BUCK"#num, \ |
Axel Lin | 0677c3e | 2019-04-04 23:07:09 +0800 | [diff] [blame] | 249 | .of_match = of_match_ptr("BUCK"#num), \ |
| 250 | .regulators_node = of_match_ptr("regulators"), \ |
Sachin Kamat | f187927 | 2014-03-14 17:21:58 +0530 | [diff] [blame] | 251 | .id = S2MPA01_BUCK##num, \ |
| 252 | .ops = &s2mpa01_buck_ops, \ |
| 253 | .type = REGULATOR_VOLTAGE, \ |
| 254 | .owner = THIS_MODULE, \ |
Amit Daniel Kachhap | 0e4f417 | 2014-07-15 16:32:51 +0530 | [diff] [blame] | 255 | .min_uV = MIN_600_MV, \ |
| 256 | .uV_step = STEP_6_25_MV, \ |
Sachin Kamat | f187927 | 2014-03-14 17:21:58 +0530 | [diff] [blame] | 257 | .n_voltages = S2MPA01_BUCK_N_VOLTAGES, \ |
| 258 | .ramp_delay = S2MPA01_RAMP_DELAY, \ |
| 259 | .vsel_reg = S2MPA01_REG_B1CTRL2 + (num - 1) * 2, \ |
| 260 | .vsel_mask = S2MPA01_BUCK_VSEL_MASK, \ |
| 261 | .enable_reg = S2MPA01_REG_B1CTRL1 + (num - 1) * 2, \ |
| 262 | .enable_mask = S2MPA01_ENABLE_MASK \ |
| 263 | } |
| 264 | |
| 265 | #define regulator_desc_buck5 { \ |
| 266 | .name = "BUCK5", \ |
Axel Lin | 0677c3e | 2019-04-04 23:07:09 +0800 | [diff] [blame] | 267 | .of_match = of_match_ptr("BUCK5"), \ |
| 268 | .regulators_node = of_match_ptr("regulators"), \ |
Sachin Kamat | f187927 | 2014-03-14 17:21:58 +0530 | [diff] [blame] | 269 | .id = S2MPA01_BUCK5, \ |
| 270 | .ops = &s2mpa01_buck_ops, \ |
| 271 | .type = REGULATOR_VOLTAGE, \ |
| 272 | .owner = THIS_MODULE, \ |
Amit Daniel Kachhap | 0e4f417 | 2014-07-15 16:32:51 +0530 | [diff] [blame] | 273 | .min_uV = MIN_800_MV, \ |
| 274 | .uV_step = STEP_6_25_MV, \ |
Sachin Kamat | f187927 | 2014-03-14 17:21:58 +0530 | [diff] [blame] | 275 | .n_voltages = S2MPA01_BUCK_N_VOLTAGES, \ |
| 276 | .ramp_delay = S2MPA01_RAMP_DELAY, \ |
| 277 | .vsel_reg = S2MPA01_REG_B5CTRL2, \ |
| 278 | .vsel_mask = S2MPA01_BUCK_VSEL_MASK, \ |
| 279 | .enable_reg = S2MPA01_REG_B5CTRL1, \ |
| 280 | .enable_mask = S2MPA01_ENABLE_MASK \ |
| 281 | } |
| 282 | |
Amit Daniel Kachhap | d264fd4 | 2014-07-15 16:32:52 +0530 | [diff] [blame] | 283 | #define regulator_desc_buck6_10(num, min, step) { \ |
Sachin Kamat | f187927 | 2014-03-14 17:21:58 +0530 | [diff] [blame] | 284 | .name = "BUCK"#num, \ |
Axel Lin | 0677c3e | 2019-04-04 23:07:09 +0800 | [diff] [blame] | 285 | .of_match = of_match_ptr("BUCK"#num), \ |
| 286 | .regulators_node = of_match_ptr("regulators"), \ |
Sachin Kamat | f187927 | 2014-03-14 17:21:58 +0530 | [diff] [blame] | 287 | .id = S2MPA01_BUCK##num, \ |
| 288 | .ops = &s2mpa01_buck_ops, \ |
| 289 | .type = REGULATOR_VOLTAGE, \ |
| 290 | .owner = THIS_MODULE, \ |
Amit Daniel Kachhap | d264fd4 | 2014-07-15 16:32:52 +0530 | [diff] [blame] | 291 | .min_uV = min, \ |
| 292 | .uV_step = step, \ |
Sachin Kamat | f187927 | 2014-03-14 17:21:58 +0530 | [diff] [blame] | 293 | .n_voltages = S2MPA01_BUCK_N_VOLTAGES, \ |
| 294 | .ramp_delay = S2MPA01_RAMP_DELAY, \ |
| 295 | .vsel_reg = S2MPA01_REG_B6CTRL2 + (num - 6) * 2, \ |
| 296 | .vsel_mask = S2MPA01_BUCK_VSEL_MASK, \ |
| 297 | .enable_reg = S2MPA01_REG_B6CTRL1 + (num - 6) * 2, \ |
| 298 | .enable_mask = S2MPA01_ENABLE_MASK \ |
| 299 | } |
| 300 | |
Krzysztof Kozlowski | 4b8e43f | 2014-10-27 16:44:14 +0100 | [diff] [blame] | 301 | static const struct regulator_desc regulators[] = { |
Amit Daniel Kachhap | d264fd4 | 2014-07-15 16:32:52 +0530 | [diff] [blame] | 302 | regulator_desc_ldo(1, STEP_25_MV), |
| 303 | regulator_desc_ldo(2, STEP_50_MV), |
| 304 | regulator_desc_ldo(3, STEP_50_MV), |
| 305 | regulator_desc_ldo(4, STEP_50_MV), |
Stuart Menefy | 28c4f73 | 2019-02-12 21:51:18 +0000 | [diff] [blame] | 306 | regulator_desc_ldo(5, STEP_25_MV), |
Amit Daniel Kachhap | d264fd4 | 2014-07-15 16:32:52 +0530 | [diff] [blame] | 307 | regulator_desc_ldo(6, STEP_25_MV), |
| 308 | regulator_desc_ldo(7, STEP_50_MV), |
| 309 | regulator_desc_ldo(8, STEP_50_MV), |
| 310 | regulator_desc_ldo(9, STEP_50_MV), |
| 311 | regulator_desc_ldo(10, STEP_50_MV), |
Stuart Menefy | 28c4f73 | 2019-02-12 21:51:18 +0000 | [diff] [blame] | 312 | regulator_desc_ldo(11, STEP_50_MV), |
Amit Daniel Kachhap | d264fd4 | 2014-07-15 16:32:52 +0530 | [diff] [blame] | 313 | regulator_desc_ldo(12, STEP_50_MV), |
| 314 | regulator_desc_ldo(13, STEP_50_MV), |
| 315 | regulator_desc_ldo(14, STEP_50_MV), |
| 316 | regulator_desc_ldo(15, STEP_50_MV), |
| 317 | regulator_desc_ldo(16, STEP_50_MV), |
| 318 | regulator_desc_ldo(17, STEP_50_MV), |
| 319 | regulator_desc_ldo(18, STEP_50_MV), |
| 320 | regulator_desc_ldo(19, STEP_50_MV), |
| 321 | regulator_desc_ldo(20, STEP_50_MV), |
| 322 | regulator_desc_ldo(21, STEP_50_MV), |
Stuart Menefy | 28c4f73 | 2019-02-12 21:51:18 +0000 | [diff] [blame] | 323 | regulator_desc_ldo(22, STEP_50_MV), |
| 324 | regulator_desc_ldo(23, STEP_50_MV), |
Amit Daniel Kachhap | d264fd4 | 2014-07-15 16:32:52 +0530 | [diff] [blame] | 325 | regulator_desc_ldo(24, STEP_50_MV), |
| 326 | regulator_desc_ldo(25, STEP_50_MV), |
Stuart Menefy | 28c4f73 | 2019-02-12 21:51:18 +0000 | [diff] [blame] | 327 | regulator_desc_ldo(26, STEP_25_MV), |
Sachin Kamat | f187927 | 2014-03-14 17:21:58 +0530 | [diff] [blame] | 328 | regulator_desc_buck1_4(1), |
| 329 | regulator_desc_buck1_4(2), |
| 330 | regulator_desc_buck1_4(3), |
| 331 | regulator_desc_buck1_4(4), |
| 332 | regulator_desc_buck5, |
Amit Daniel Kachhap | d264fd4 | 2014-07-15 16:32:52 +0530 | [diff] [blame] | 333 | regulator_desc_buck6_10(6, MIN_600_MV, STEP_6_25_MV), |
| 334 | regulator_desc_buck6_10(7, MIN_600_MV, STEP_6_25_MV), |
| 335 | regulator_desc_buck6_10(8, MIN_800_MV, STEP_12_5_MV), |
| 336 | regulator_desc_buck6_10(9, MIN_1500_MV, STEP_12_5_MV), |
| 337 | regulator_desc_buck6_10(10, MIN_1000_MV, STEP_12_5_MV), |
Sachin Kamat | f187927 | 2014-03-14 17:21:58 +0530 | [diff] [blame] | 338 | }; |
| 339 | |
| 340 | static int s2mpa01_pmic_probe(struct platform_device *pdev) |
| 341 | { |
| 342 | struct sec_pmic_dev *iodev = dev_get_drvdata(pdev->dev.parent); |
| 343 | struct sec_platform_data *pdata = dev_get_platdata(iodev->dev); |
Sachin Kamat | f187927 | 2014-03-14 17:21:58 +0530 | [diff] [blame] | 344 | struct regulator_config config = { }; |
| 345 | struct s2mpa01_info *s2mpa01; |
| 346 | int i; |
| 347 | |
| 348 | s2mpa01 = devm_kzalloc(&pdev->dev, sizeof(*s2mpa01), GFP_KERNEL); |
| 349 | if (!s2mpa01) |
| 350 | return -ENOMEM; |
| 351 | |
Axel Lin | 0677c3e | 2019-04-04 23:07:09 +0800 | [diff] [blame] | 352 | config.dev = iodev->dev; |
Sachin Kamat | f187927 | 2014-03-14 17:21:58 +0530 | [diff] [blame] | 353 | config.regmap = iodev->regmap_pmic; |
| 354 | config.driver_data = s2mpa01; |
| 355 | |
| 356 | for (i = 0; i < S2MPA01_REGULATOR_MAX; i++) { |
| 357 | struct regulator_dev *rdev; |
Axel Lin | 0677c3e | 2019-04-04 23:07:09 +0800 | [diff] [blame] | 358 | |
Sachin Kamat | f187927 | 2014-03-14 17:21:58 +0530 | [diff] [blame] | 359 | if (pdata) |
| 360 | config.init_data = pdata->regulators[i].initdata; |
Sachin Kamat | f187927 | 2014-03-14 17:21:58 +0530 | [diff] [blame] | 361 | |
| 362 | rdev = devm_regulator_register(&pdev->dev, |
| 363 | ®ulators[i], &config); |
| 364 | if (IS_ERR(rdev)) { |
| 365 | dev_err(&pdev->dev, "regulator init failed for %d\n", |
| 366 | i); |
| 367 | return PTR_ERR(rdev); |
| 368 | } |
| 369 | } |
| 370 | |
| 371 | return 0; |
| 372 | } |
| 373 | |
| 374 | static const struct platform_device_id s2mpa01_pmic_id[] = { |
| 375 | { "s2mpa01-pmic", 0}, |
| 376 | { }, |
| 377 | }; |
| 378 | MODULE_DEVICE_TABLE(platform, s2mpa01_pmic_id); |
| 379 | |
| 380 | static struct platform_driver s2mpa01_pmic_driver = { |
| 381 | .driver = { |
| 382 | .name = "s2mpa01-pmic", |
Sachin Kamat | f187927 | 2014-03-14 17:21:58 +0530 | [diff] [blame] | 383 | }, |
| 384 | .probe = s2mpa01_pmic_probe, |
| 385 | .id_table = s2mpa01_pmic_id, |
| 386 | }; |
| 387 | |
| 388 | module_platform_driver(s2mpa01_pmic_driver); |
| 389 | |
| 390 | /* Module information */ |
| 391 | MODULE_AUTHOR("Sangbeom Kim <sbkim73@samsung.com>"); |
| 392 | MODULE_AUTHOR("Sachin Kamat <sachin.kamat@samsung.com>"); |
| 393 | MODULE_DESCRIPTION("SAMSUNG S2MPA01 Regulator Driver"); |
| 394 | MODULE_LICENSE("GPL"); |