hc
2023-12-11 d2ccde1c8e90d38cee87a1b0309ad2827f3fd30d
kernel/drivers/regulator/lp8788-buck.c
....@@ -1,14 +1,10 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /*
23 * TI LP8788 MFD - buck regulator driver
34 *
45 * Copyright 2012 Texas Instruments
56 *
67 * Author: Milo(Woogyom) Kim <milo.kim@ti.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 version 2 as
10
- * published by the Free Software Foundation.
11
- *
128 */
139
1410 #include <linux/module.h>
....@@ -95,12 +91,10 @@
9591 void *dvs;
9692 };
9793
98
-/* BUCK 1 ~ 4 voltage table */
99
-static const int lp8788_buck_vtbl[] = {
100
- 500000, 800000, 850000, 900000, 950000, 1000000, 1050000, 1100000,
101
- 1150000, 1200000, 1250000, 1300000, 1350000, 1400000, 1450000, 1500000,
102
- 1550000, 1600000, 1650000, 1700000, 1750000, 1800000, 1850000, 1900000,
103
- 1950000, 2000000,
94
+/* BUCK 1 ~ 4 voltage ranges */
95
+static const struct linear_range buck_volt_ranges[] = {
96
+ REGULATOR_LINEAR_RANGE(500000, 0, 0, 0),
97
+ REGULATOR_LINEAR_RANGE(800000, 1, 25, 50000),
10498 };
10599
106100 static void lp8788_buck1_set_dvs(struct lp8788_buck *buck)
....@@ -345,8 +339,8 @@
345339 }
346340
347341 static const struct regulator_ops lp8788_buck12_ops = {
348
- .list_voltage = regulator_list_voltage_table,
349
- .map_voltage = regulator_map_voltage_ascend,
342
+ .list_voltage = regulator_list_voltage_linear_range,
343
+ .map_voltage = regulator_map_voltage_linear_range,
350344 .set_voltage_sel = lp8788_buck12_set_voltage_sel,
351345 .get_voltage_sel = lp8788_buck12_get_voltage_sel,
352346 .enable = regulator_enable_regmap,
....@@ -358,8 +352,8 @@
358352 };
359353
360354 static const struct regulator_ops lp8788_buck34_ops = {
361
- .list_voltage = regulator_list_voltage_table,
362
- .map_voltage = regulator_map_voltage_ascend,
355
+ .list_voltage = regulator_list_voltage_linear_range,
356
+ .map_voltage = regulator_map_voltage_linear_range,
363357 .set_voltage_sel = regulator_set_voltage_sel_regmap,
364358 .get_voltage_sel = regulator_get_voltage_sel_regmap,
365359 .enable = regulator_enable_regmap,
....@@ -370,13 +364,14 @@
370364 .get_mode = lp8788_buck_get_mode,
371365 };
372366
373
-static struct regulator_desc lp8788_buck_desc[] = {
367
+static const struct regulator_desc lp8788_buck_desc[] = {
374368 {
375369 .name = "buck1",
376370 .id = BUCK1,
377371 .ops = &lp8788_buck12_ops,
378
- .n_voltages = ARRAY_SIZE(lp8788_buck_vtbl),
379
- .volt_table = lp8788_buck_vtbl,
372
+ .n_voltages = 26,
373
+ .linear_ranges = buck_volt_ranges,
374
+ .n_linear_ranges = ARRAY_SIZE(buck_volt_ranges),
380375 .type = REGULATOR_VOLTAGE,
381376 .owner = THIS_MODULE,
382377 .enable_reg = LP8788_EN_BUCK,
....@@ -386,8 +381,9 @@
386381 .name = "buck2",
387382 .id = BUCK2,
388383 .ops = &lp8788_buck12_ops,
389
- .n_voltages = ARRAY_SIZE(lp8788_buck_vtbl),
390
- .volt_table = lp8788_buck_vtbl,
384
+ .n_voltages = 26,
385
+ .linear_ranges = buck_volt_ranges,
386
+ .n_linear_ranges = ARRAY_SIZE(buck_volt_ranges),
391387 .type = REGULATOR_VOLTAGE,
392388 .owner = THIS_MODULE,
393389 .enable_reg = LP8788_EN_BUCK,
....@@ -397,8 +393,9 @@
397393 .name = "buck3",
398394 .id = BUCK3,
399395 .ops = &lp8788_buck34_ops,
400
- .n_voltages = ARRAY_SIZE(lp8788_buck_vtbl),
401
- .volt_table = lp8788_buck_vtbl,
396
+ .n_voltages = 26,
397
+ .linear_ranges = buck_volt_ranges,
398
+ .n_linear_ranges = ARRAY_SIZE(buck_volt_ranges),
402399 .type = REGULATOR_VOLTAGE,
403400 .owner = THIS_MODULE,
404401 .vsel_reg = LP8788_BUCK3_VOUT,
....@@ -410,8 +407,9 @@
410407 .name = "buck4",
411408 .id = BUCK4,
412409 .ops = &lp8788_buck34_ops,
413
- .n_voltages = ARRAY_SIZE(lp8788_buck_vtbl),
414
- .volt_table = lp8788_buck_vtbl,
410
+ .n_voltages = 26,
411
+ .linear_ranges = buck_volt_ranges,
412
+ .n_linear_ranges = ARRAY_SIZE(buck_volt_ranges),
415413 .type = REGULATOR_VOLTAGE,
416414 .owner = THIS_MODULE,
417415 .vsel_reg = LP8788_BUCK4_VOUT,