forked from ~ljy/RK356X_SDK_RELEASE

hc
2023-12-08 01573e231f18eb2d99162747186f59511f56b64d
kernel/drivers/regulator/twl-regulator.c
....@@ -1,12 +1,8 @@
1
+// SPDX-License-Identifier: GPL-2.0-or-later
12 /*
23 * twl-regulator.c -- support regulators in twl4030/twl6030 family chips
34 *
45 * Copyright (C) 2008 David Brownell
5
- *
6
- * This program is free software; you can redistribute it and/or modify
7
- * it under the terms of the GNU General Public License as published by
8
- * the Free Software Foundation; either version 2 of the License, or
9
- * (at your option) any later version.
106 */
117
128 #include <linux/module.h>
....@@ -363,6 +359,17 @@
363359 2500, 2750,
364360 };
365361
362
+/* 600mV to 1450mV in 12.5 mV steps */
363
+static const struct linear_range VDD1_ranges[] = {
364
+ REGULATOR_LINEAR_RANGE(600000, 0, 68, 12500)
365
+};
366
+
367
+/* 600mV to 1450mV in 12.5 mV steps, everything above = 1500mV */
368
+static const struct linear_range VDD2_ranges[] = {
369
+ REGULATOR_LINEAR_RANGE(600000, 0, 68, 12500),
370
+ REGULATOR_LINEAR_RANGE(1500000, 69, 69, 12500)
371
+};
372
+
366373 static int twl4030ldo_list_voltage(struct regulator_dev *rdev, unsigned index)
367374 {
368375 struct twlreg_info *info = rdev_get_drvdata(rdev);
....@@ -392,7 +399,7 @@
392399 return vsel;
393400 }
394401
395
-static struct regulator_ops twl4030ldo_ops = {
402
+static const struct regulator_ops twl4030ldo_ops = {
396403 .list_voltage = twl4030ldo_list_voltage,
397404
398405 .set_voltage_sel = twl4030ldo_set_voltage_sel,
....@@ -430,14 +437,16 @@
430437 return vsel * 12500 + 600000;
431438 }
432439
433
-static struct regulator_ops twl4030smps_ops = {
440
+static const struct regulator_ops twl4030smps_ops = {
441
+ .list_voltage = regulator_list_voltage_linear_range,
442
+
434443 .set_voltage = twl4030smps_set_voltage,
435444 .get_voltage = twl4030smps_get_voltage,
436445 };
437446
438447 /*----------------------------------------------------------------------*/
439448
440
-static struct regulator_ops twl4030fixed_ops = {
449
+static const struct regulator_ops twl4030fixed_ops = {
441450 .list_voltage = regulator_list_voltage_linear,
442451
443452 .enable = twl4030reg_enable,
....@@ -470,7 +479,8 @@
470479 }, \
471480 }
472481
473
-#define TWL4030_ADJUSTABLE_SMPS(label, offset, num, turnon_delay, remap_conf) \
482
+#define TWL4030_ADJUSTABLE_SMPS(label, offset, num, turnon_delay, remap_conf, \
483
+ n_volt) \
474484 static const struct twlreg_info TWL4030_INFO_##label = { \
475485 .base = offset, \
476486 .id = num, \
....@@ -483,6 +493,9 @@
483493 .owner = THIS_MODULE, \
484494 .enable_time = turnon_delay, \
485495 .of_map_mode = twl4030reg_map_mode, \
496
+ .n_voltages = n_volt, \
497
+ .n_linear_ranges = ARRAY_SIZE(label ## _ranges), \
498
+ .linear_ranges = label ## _ranges, \
486499 }, \
487500 }
488501
....@@ -522,8 +535,8 @@
522535 TWL4030_ADJUSTABLE_LDO(VDAC, 0x3b, 10, 100, 0x08);
523536 TWL4030_ADJUSTABLE_LDO(VINTANA2, 0x43, 12, 100, 0x08);
524537 TWL4030_ADJUSTABLE_LDO(VIO, 0x4b, 14, 1000, 0x08);
525
-TWL4030_ADJUSTABLE_SMPS(VDD1, 0x55, 15, 1000, 0x08);
526
-TWL4030_ADJUSTABLE_SMPS(VDD2, 0x63, 16, 1000, 0x08);
538
+TWL4030_ADJUSTABLE_SMPS(VDD1, 0x55, 15, 1000, 0x08, 68);
539
+TWL4030_ADJUSTABLE_SMPS(VDD2, 0x63, 16, 1000, 0x08, 69);
527540 /* VUSBCP is managed *only* by the USB subchip */
528541 TWL4030_FIXED_LDO(VINTANA1, 0x3f, 1500, 11, 100, 0x08);
529542 TWL4030_FIXED_LDO(VINTDIG, 0x47, 1500, 13, 100, 0x08);
....@@ -576,14 +589,9 @@
576589 struct regulator_init_data *initdata;
577590 struct regulation_constraints *c;
578591 struct regulator_dev *rdev;
579
- const struct of_device_id *match;
580592 struct regulator_config config = { };
581593
582
- match = of_match_device(twl_of_match, &pdev->dev);
583
- if (!match)
584
- return -ENODEV;
585
-
586
- template = match->data;
594
+ template = of_device_get_match_data(&pdev->dev);
587595 if (!template)
588596 return -ENODEV;
589597