| .. | .. |
|---|
| 17 | 17 | #include <linux/mfd/samsung/core.h> |
|---|
| 18 | 18 | #include <linux/mfd/samsung/s2mpa01.h> |
|---|
| 19 | 19 | |
|---|
| 20 | | -#define S2MPA01_REGULATOR_CNT ARRAY_SIZE(regulators) |
|---|
| 21 | | - |
|---|
| 22 | 20 | struct s2mpa01_info { |
|---|
| 23 | | - struct of_regulator_match rdata[S2MPA01_REGULATOR_MAX]; |
|---|
| 24 | 21 | int ramp_delay24; |
|---|
| 25 | 22 | int ramp_delay3; |
|---|
| 26 | 23 | int ramp_delay5; |
|---|
| .. | .. |
|---|
| 232 | 229 | |
|---|
| 233 | 230 | #define regulator_desc_ldo(num, step) { \ |
|---|
| 234 | 231 | .name = "LDO"#num, \ |
|---|
| 232 | + .of_match = of_match_ptr("LDO"#num), \ |
|---|
| 233 | + .regulators_node = of_match_ptr("regulators"), \ |
|---|
| 235 | 234 | .id = S2MPA01_LDO##num, \ |
|---|
| 236 | 235 | .ops = &s2mpa01_ldo_ops, \ |
|---|
| 237 | 236 | .type = REGULATOR_VOLTAGE, \ |
|---|
| .. | .. |
|---|
| 247 | 246 | |
|---|
| 248 | 247 | #define regulator_desc_buck1_4(num) { \ |
|---|
| 249 | 248 | .name = "BUCK"#num, \ |
|---|
| 249 | + .of_match = of_match_ptr("BUCK"#num), \ |
|---|
| 250 | + .regulators_node = of_match_ptr("regulators"), \ |
|---|
| 250 | 251 | .id = S2MPA01_BUCK##num, \ |
|---|
| 251 | 252 | .ops = &s2mpa01_buck_ops, \ |
|---|
| 252 | 253 | .type = REGULATOR_VOLTAGE, \ |
|---|
| .. | .. |
|---|
| 263 | 264 | |
|---|
| 264 | 265 | #define regulator_desc_buck5 { \ |
|---|
| 265 | 266 | .name = "BUCK5", \ |
|---|
| 267 | + .of_match = of_match_ptr("BUCK5"), \ |
|---|
| 268 | + .regulators_node = of_match_ptr("regulators"), \ |
|---|
| 266 | 269 | .id = S2MPA01_BUCK5, \ |
|---|
| 267 | 270 | .ops = &s2mpa01_buck_ops, \ |
|---|
| 268 | 271 | .type = REGULATOR_VOLTAGE, \ |
|---|
| .. | .. |
|---|
| 279 | 282 | |
|---|
| 280 | 283 | #define regulator_desc_buck6_10(num, min, step) { \ |
|---|
| 281 | 284 | .name = "BUCK"#num, \ |
|---|
| 285 | + .of_match = of_match_ptr("BUCK"#num), \ |
|---|
| 286 | + .regulators_node = of_match_ptr("regulators"), \ |
|---|
| 282 | 287 | .id = S2MPA01_BUCK##num, \ |
|---|
| 283 | 288 | .ops = &s2mpa01_buck_ops, \ |
|---|
| 284 | 289 | .type = REGULATOR_VOLTAGE, \ |
|---|
| .. | .. |
|---|
| 336 | 341 | { |
|---|
| 337 | 342 | struct sec_pmic_dev *iodev = dev_get_drvdata(pdev->dev.parent); |
|---|
| 338 | 343 | struct sec_platform_data *pdata = dev_get_platdata(iodev->dev); |
|---|
| 339 | | - struct device_node *reg_np = NULL; |
|---|
| 340 | 344 | struct regulator_config config = { }; |
|---|
| 341 | | - struct of_regulator_match *rdata; |
|---|
| 342 | 345 | struct s2mpa01_info *s2mpa01; |
|---|
| 343 | 346 | int i; |
|---|
| 344 | 347 | |
|---|
| .. | .. |
|---|
| 346 | 349 | if (!s2mpa01) |
|---|
| 347 | 350 | return -ENOMEM; |
|---|
| 348 | 351 | |
|---|
| 349 | | - rdata = s2mpa01->rdata; |
|---|
| 350 | | - for (i = 0; i < S2MPA01_REGULATOR_CNT; i++) |
|---|
| 351 | | - rdata[i].name = regulators[i].name; |
|---|
| 352 | | - |
|---|
| 353 | | - if (iodev->dev->of_node) { |
|---|
| 354 | | - reg_np = of_get_child_by_name(iodev->dev->of_node, |
|---|
| 355 | | - "regulators"); |
|---|
| 356 | | - if (!reg_np) { |
|---|
| 357 | | - dev_err(&pdev->dev, |
|---|
| 358 | | - "could not find regulators sub-node\n"); |
|---|
| 359 | | - return -EINVAL; |
|---|
| 360 | | - } |
|---|
| 361 | | - |
|---|
| 362 | | - of_regulator_match(&pdev->dev, reg_np, rdata, |
|---|
| 363 | | - S2MPA01_REGULATOR_MAX); |
|---|
| 364 | | - of_node_put(reg_np); |
|---|
| 365 | | - } |
|---|
| 366 | | - |
|---|
| 367 | | - platform_set_drvdata(pdev, s2mpa01); |
|---|
| 368 | | - |
|---|
| 369 | | - config.dev = &pdev->dev; |
|---|
| 352 | + config.dev = iodev->dev; |
|---|
| 370 | 353 | config.regmap = iodev->regmap_pmic; |
|---|
| 371 | 354 | config.driver_data = s2mpa01; |
|---|
| 372 | 355 | |
|---|
| 373 | 356 | for (i = 0; i < S2MPA01_REGULATOR_MAX; i++) { |
|---|
| 374 | 357 | struct regulator_dev *rdev; |
|---|
| 358 | + |
|---|
| 375 | 359 | if (pdata) |
|---|
| 376 | 360 | config.init_data = pdata->regulators[i].initdata; |
|---|
| 377 | | - else |
|---|
| 378 | | - config.init_data = rdata[i].init_data; |
|---|
| 379 | | - |
|---|
| 380 | | - if (reg_np) |
|---|
| 381 | | - config.of_node = rdata[i].of_node; |
|---|
| 382 | 361 | |
|---|
| 383 | 362 | rdev = devm_regulator_register(&pdev->dev, |
|---|
| 384 | 363 | ®ulators[i], &config); |
|---|
| .. | .. |
|---|
| 411 | 390 | /* Module information */ |
|---|
| 412 | 391 | MODULE_AUTHOR("Sangbeom Kim <sbkim73@samsung.com>"); |
|---|
| 413 | 392 | MODULE_AUTHOR("Sachin Kamat <sachin.kamat@samsung.com>"); |
|---|
| 414 | | -MODULE_DESCRIPTION("SAMSUNG S2MPA01 Regulator Driver"); |
|---|
| 393 | +MODULE_DESCRIPTION("Samsung S2MPA01 Regulator Driver"); |
|---|
| 415 | 394 | MODULE_LICENSE("GPL"); |
|---|