forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-10-09 244b2c5ca8b14627e4a17755e5922221e121c771
kernel/drivers/regulator/da9052-regulator.c
....@@ -1,16 +1,10 @@
1
-/*
2
-* da9052-regulator.c: Regulator driver for DA9052
3
-*
4
-* Copyright(c) 2011 Dialog Semiconductor Ltd.
5
-*
6
-* Author: David Dajun Chen <dchen@diasemi.com>
7
-*
8
-* This program is free software; you can redistribute it and/or modify
9
-* it under the terms of the GNU General Public License as published by
10
-* the Free Software Foundation; either version 2 of the License, or
11
-* (at your option) any later version.
12
-*
13
-*/
1
+// SPDX-License-Identifier: GPL-2.0+
2
+//
3
+// da9052-regulator.c: Regulator driver for DA9052
4
+//
5
+// Copyright(c) 2011 Dialog Semiconductor Ltd.
6
+//
7
+// Author: David Dajun Chen <dchen@diasemi.com>
148
159 #include <linux/module.h>
1610 #include <linux/moduleparam.h>
....@@ -19,10 +13,8 @@
1913 #include <linux/platform_device.h>
2014 #include <linux/regulator/driver.h>
2115 #include <linux/regulator/machine.h>
22
-#ifdef CONFIG_OF
2316 #include <linux/of.h>
2417 #include <linux/regulator/of_regulator.h>
25
-#endif
2618
2719 #include <linux/mfd/da9052/da9052.h>
2820 #include <linux/mfd/da9052/reg.h>
....@@ -291,10 +283,12 @@
291283 .disable = regulator_disable_regmap,
292284 };
293285
294
-#define DA9052_LDO(_id, step, min, max, sbits, ebits, abits) \
286
+#define DA9052_LDO(_id, _name, step, min, max, sbits, ebits, abits) \
295287 {\
296288 .reg_desc = {\
297
- .name = #_id,\
289
+ .name = #_name,\
290
+ .of_match = of_match_ptr(#_name),\
291
+ .regulators_node = of_match_ptr("regulators"),\
298292 .ops = &da9052_ldo_ops,\
299293 .type = REGULATOR_VOLTAGE,\
300294 .id = DA9052_ID_##_id,\
....@@ -311,10 +305,12 @@
311305 .activate_bit = (abits),\
312306 }
313307
314
-#define DA9052_DCDC(_id, step, min, max, sbits, ebits, abits) \
308
+#define DA9052_DCDC(_id, _name, step, min, max, sbits, ebits, abits) \
315309 {\
316310 .reg_desc = {\
317
- .name = #_id,\
311
+ .name = #_name,\
312
+ .of_match = of_match_ptr(#_name),\
313
+ .regulators_node = of_match_ptr("regulators"),\
318314 .ops = &da9052_dcdc_ops,\
319315 .type = REGULATOR_VOLTAGE,\
320316 .id = DA9052_ID_##_id,\
....@@ -332,37 +328,37 @@
332328 }
333329
334330 static struct da9052_regulator_info da9052_regulator_info[] = {
335
- DA9052_DCDC(BUCK1, 25, 500, 2075, 6, 6, DA9052_SUPPLY_VBCOREGO),
336
- DA9052_DCDC(BUCK2, 25, 500, 2075, 6, 6, DA9052_SUPPLY_VBPROGO),
337
- DA9052_DCDC(BUCK3, 25, 950, 2525, 6, 6, DA9052_SUPPLY_VBMEMGO),
338
- DA9052_DCDC(BUCK4, 50, 1800, 3600, 5, 6, 0),
339
- DA9052_LDO(LDO1, 50, 600, 1800, 5, 6, 0),
340
- DA9052_LDO(LDO2, 25, 600, 1800, 6, 6, DA9052_SUPPLY_VLDO2GO),
341
- DA9052_LDO(LDO3, 25, 1725, 3300, 6, 6, DA9052_SUPPLY_VLDO3GO),
342
- DA9052_LDO(LDO4, 25, 1725, 3300, 6, 6, 0),
343
- DA9052_LDO(LDO5, 50, 1200, 3600, 6, 6, 0),
344
- DA9052_LDO(LDO6, 50, 1200, 3600, 6, 6, 0),
345
- DA9052_LDO(LDO7, 50, 1200, 3600, 6, 6, 0),
346
- DA9052_LDO(LDO8, 50, 1200, 3600, 6, 6, 0),
347
- DA9052_LDO(LDO9, 50, 1250, 3650, 6, 6, 0),
348
- DA9052_LDO(LDO10, 50, 1200, 3600, 6, 6, 0),
331
+ DA9052_DCDC(BUCK1, buck1, 25, 500, 2075, 6, 6, DA9052_SUPPLY_VBCOREGO),
332
+ DA9052_DCDC(BUCK2, buck2, 25, 500, 2075, 6, 6, DA9052_SUPPLY_VBPROGO),
333
+ DA9052_DCDC(BUCK3, buck3, 25, 950, 2525, 6, 6, DA9052_SUPPLY_VBMEMGO),
334
+ DA9052_DCDC(BUCK4, buck4, 50, 1800, 3600, 5, 6, 0),
335
+ DA9052_LDO(LDO1, ldo1, 50, 600, 1800, 5, 6, 0),
336
+ DA9052_LDO(LDO2, ldo2, 25, 600, 1800, 6, 6, DA9052_SUPPLY_VLDO2GO),
337
+ DA9052_LDO(LDO3, ldo3, 25, 1725, 3300, 6, 6, DA9052_SUPPLY_VLDO3GO),
338
+ DA9052_LDO(LDO4, ldo4, 25, 1725, 3300, 6, 6, 0),
339
+ DA9052_LDO(LDO5, ldo5, 50, 1200, 3600, 6, 6, 0),
340
+ DA9052_LDO(LDO6, ldo6, 50, 1200, 3600, 6, 6, 0),
341
+ DA9052_LDO(LDO7, ldo7, 50, 1200, 3600, 6, 6, 0),
342
+ DA9052_LDO(LDO8, ldo8, 50, 1200, 3600, 6, 6, 0),
343
+ DA9052_LDO(LDO9, ldo9, 50, 1250, 3650, 6, 6, 0),
344
+ DA9052_LDO(LDO10, ldo10, 50, 1200, 3600, 6, 6, 0),
349345 };
350346
351347 static struct da9052_regulator_info da9053_regulator_info[] = {
352
- DA9052_DCDC(BUCK1, 25, 500, 2075, 6, 6, DA9052_SUPPLY_VBCOREGO),
353
- DA9052_DCDC(BUCK2, 25, 500, 2075, 6, 6, DA9052_SUPPLY_VBPROGO),
354
- DA9052_DCDC(BUCK3, 25, 950, 2525, 6, 6, DA9052_SUPPLY_VBMEMGO),
355
- DA9052_DCDC(BUCK4, 25, 950, 2525, 6, 6, 0),
356
- DA9052_LDO(LDO1, 50, 600, 1800, 5, 6, 0),
357
- DA9052_LDO(LDO2, 25, 600, 1800, 6, 6, DA9052_SUPPLY_VLDO2GO),
358
- DA9052_LDO(LDO3, 25, 1725, 3300, 6, 6, DA9052_SUPPLY_VLDO3GO),
359
- DA9052_LDO(LDO4, 25, 1725, 3300, 6, 6, 0),
360
- DA9052_LDO(LDO5, 50, 1200, 3600, 6, 6, 0),
361
- DA9052_LDO(LDO6, 50, 1200, 3600, 6, 6, 0),
362
- DA9052_LDO(LDO7, 50, 1200, 3600, 6, 6, 0),
363
- DA9052_LDO(LDO8, 50, 1200, 3600, 6, 6, 0),
364
- DA9052_LDO(LDO9, 50, 1250, 3650, 6, 6, 0),
365
- DA9052_LDO(LDO10, 50, 1200, 3600, 6, 6, 0),
348
+ DA9052_DCDC(BUCK1, buck1, 25, 500, 2075, 6, 6, DA9052_SUPPLY_VBCOREGO),
349
+ DA9052_DCDC(BUCK2, buck2, 25, 500, 2075, 6, 6, DA9052_SUPPLY_VBPROGO),
350
+ DA9052_DCDC(BUCK3, buck3, 25, 950, 2525, 6, 6, DA9052_SUPPLY_VBMEMGO),
351
+ DA9052_DCDC(BUCK4, buck4, 25, 950, 2525, 6, 6, 0),
352
+ DA9052_LDO(LDO1, ldo1, 50, 600, 1800, 5, 6, 0),
353
+ DA9052_LDO(LDO2, ldo2, 25, 600, 1800, 6, 6, DA9052_SUPPLY_VLDO2GO),
354
+ DA9052_LDO(LDO3, ldo3, 25, 1725, 3300, 6, 6, DA9052_SUPPLY_VLDO3GO),
355
+ DA9052_LDO(LDO4, ldo4, 25, 1725, 3300, 6, 6, 0),
356
+ DA9052_LDO(LDO5, ldo5, 50, 1200, 3600, 6, 6, 0),
357
+ DA9052_LDO(LDO6, ldo6, 50, 1200, 3600, 6, 6, 0),
358
+ DA9052_LDO(LDO7, ldo7, 50, 1200, 3600, 6, 6, 0),
359
+ DA9052_LDO(LDO8, ldo8, 50, 1200, 3600, 6, 6, 0),
360
+ DA9052_LDO(LDO9, ldo9, 50, 1250, 3650, 6, 6, 0),
361
+ DA9052_LDO(LDO10, ldo10, 50, 1200, 3600, 6, 6, 0),
366362 };
367363
368364 static inline struct da9052_regulator_info *find_regulator_info(u8 chip_id,
....@@ -418,36 +414,11 @@
418414 return -EINVAL;
419415 }
420416
421
- config.dev = &pdev->dev;
417
+ config.dev = da9052->dev;
422418 config.driver_data = regulator;
423419 config.regmap = da9052->regmap;
424
- if (pdata && pdata->regulators) {
420
+ if (pdata)
425421 config.init_data = pdata->regulators[cell->id];
426
- } else {
427
-#ifdef CONFIG_OF
428
- struct device_node *nproot = da9052->dev->of_node;
429
- struct device_node *np;
430
-
431
- if (!nproot)
432
- return -ENODEV;
433
-
434
- nproot = of_get_child_by_name(nproot, "regulators");
435
- if (!nproot)
436
- return -ENODEV;
437
-
438
- for_each_child_of_node(nproot, np) {
439
- if (!of_node_cmp(np->name,
440
- regulator->info->reg_desc.name)) {
441
- config.init_data = of_get_regulator_init_data(
442
- &pdev->dev, np,
443
- &regulator->info->reg_desc);
444
- config.of_node = np;
445
- break;
446
- }
447
- }
448
- of_node_put(nproot);
449
-#endif
450
- }
451422
452423 regulator->rdev = devm_regulator_register(&pdev->dev,
453424 &regulator->info->reg_desc,