forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-05-10 ee930fffee469d076998274a2ca55e13dc1efb67
kernel/drivers/regulator/s2mpa01.c
....@@ -17,10 +17,7 @@
1717 #include <linux/mfd/samsung/core.h>
1818 #include <linux/mfd/samsung/s2mpa01.h>
1919
20
-#define S2MPA01_REGULATOR_CNT ARRAY_SIZE(regulators)
21
-
2220 struct s2mpa01_info {
23
- struct of_regulator_match rdata[S2MPA01_REGULATOR_MAX];
2421 int ramp_delay24;
2522 int ramp_delay3;
2623 int ramp_delay5;
....@@ -232,6 +229,8 @@
232229
233230 #define regulator_desc_ldo(num, step) { \
234231 .name = "LDO"#num, \
232
+ .of_match = of_match_ptr("LDO"#num), \
233
+ .regulators_node = of_match_ptr("regulators"), \
235234 .id = S2MPA01_LDO##num, \
236235 .ops = &s2mpa01_ldo_ops, \
237236 .type = REGULATOR_VOLTAGE, \
....@@ -247,6 +246,8 @@
247246
248247 #define regulator_desc_buck1_4(num) { \
249248 .name = "BUCK"#num, \
249
+ .of_match = of_match_ptr("BUCK"#num), \
250
+ .regulators_node = of_match_ptr("regulators"), \
250251 .id = S2MPA01_BUCK##num, \
251252 .ops = &s2mpa01_buck_ops, \
252253 .type = REGULATOR_VOLTAGE, \
....@@ -263,6 +264,8 @@
263264
264265 #define regulator_desc_buck5 { \
265266 .name = "BUCK5", \
267
+ .of_match = of_match_ptr("BUCK5"), \
268
+ .regulators_node = of_match_ptr("regulators"), \
266269 .id = S2MPA01_BUCK5, \
267270 .ops = &s2mpa01_buck_ops, \
268271 .type = REGULATOR_VOLTAGE, \
....@@ -279,6 +282,8 @@
279282
280283 #define regulator_desc_buck6_10(num, min, step) { \
281284 .name = "BUCK"#num, \
285
+ .of_match = of_match_ptr("BUCK"#num), \
286
+ .regulators_node = of_match_ptr("regulators"), \
282287 .id = S2MPA01_BUCK##num, \
283288 .ops = &s2mpa01_buck_ops, \
284289 .type = REGULATOR_VOLTAGE, \
....@@ -336,9 +341,7 @@
336341 {
337342 struct sec_pmic_dev *iodev = dev_get_drvdata(pdev->dev.parent);
338343 struct sec_platform_data *pdata = dev_get_platdata(iodev->dev);
339
- struct device_node *reg_np = NULL;
340344 struct regulator_config config = { };
341
- struct of_regulator_match *rdata;
342345 struct s2mpa01_info *s2mpa01;
343346 int i;
344347
....@@ -346,39 +349,15 @@
346349 if (!s2mpa01)
347350 return -ENOMEM;
348351
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;
370353 config.regmap = iodev->regmap_pmic;
371354 config.driver_data = s2mpa01;
372355
373356 for (i = 0; i < S2MPA01_REGULATOR_MAX; i++) {
374357 struct regulator_dev *rdev;
358
+
375359 if (pdata)
376360 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;
382361
383362 rdev = devm_regulator_register(&pdev->dev,
384363 &regulators[i], &config);
....@@ -411,5 +390,5 @@
411390 /* Module information */
412391 MODULE_AUTHOR("Sangbeom Kim <sbkim73@samsung.com>");
413392 MODULE_AUTHOR("Sachin Kamat <sachin.kamat@samsung.com>");
414
-MODULE_DESCRIPTION("SAMSUNG S2MPA01 Regulator Driver");
393
+MODULE_DESCRIPTION("Samsung S2MPA01 Regulator Driver");
415394 MODULE_LICENSE("GPL");