hc
2024-05-11 04dd17822334871b23ea2862f7798fb0e0007777
kernel/drivers/regulator/as3711-regulator.c
....@@ -1,12 +1,9 @@
1
+// SPDX-License-Identifier: GPL-2.0
12 /*
23 * AS3711 PMIC regulator driver, using DCDC Step Down and LDO supplies
34 *
45 * Copyright (C) 2012 Renesas Electronics Corporation
56 * Author: Guennadi Liakhovetski, <g.liakhovetski@gmx.de>
6
- *
7
- * This program is free software; you can redistribute it and/or modify
8
- * it under the terms of the version 2 of the GNU General Public License as
9
- * published by the Free Software Foundation
107 */
118
129 #include <linux/err.h>
....@@ -19,14 +16,6 @@
1916 #include <linux/regulator/driver.h>
2017 #include <linux/regulator/of_regulator.h>
2118 #include <linux/slab.h>
22
-
23
-struct as3711_regulator_info {
24
- struct regulator_desc desc;
25
-};
26
-
27
-struct as3711_regulator {
28
- struct as3711_regulator_info *reg_info;
29
-};
3019
3120 /*
3221 * The regulator API supports 4 modes of operataion: FAST, NORMAL, IDLE and
....@@ -114,25 +103,24 @@
114103 .map_voltage = regulator_map_voltage_linear_range,
115104 };
116105
117
-static const struct regulator_linear_range as3711_sd_ranges[] = {
106
+static const struct linear_range as3711_sd_ranges[] = {
118107 REGULATOR_LINEAR_RANGE(612500, 0x1, 0x40, 12500),
119108 REGULATOR_LINEAR_RANGE(1425000, 0x41, 0x70, 25000),
120109 REGULATOR_LINEAR_RANGE(2650000, 0x71, 0x7f, 50000),
121110 };
122111
123
-static const struct regulator_linear_range as3711_aldo_ranges[] = {
112
+static const struct linear_range as3711_aldo_ranges[] = {
124113 REGULATOR_LINEAR_RANGE(1200000, 0, 0xf, 50000),
125114 REGULATOR_LINEAR_RANGE(1800000, 0x10, 0x1f, 100000),
126115 };
127116
128
-static const struct regulator_linear_range as3711_dldo_ranges[] = {
117
+static const struct linear_range as3711_dldo_ranges[] = {
129118 REGULATOR_LINEAR_RANGE(900000, 0, 0x10, 50000),
130119 REGULATOR_LINEAR_RANGE(1750000, 0x20, 0x3f, 50000),
131120 };
132121
133122 #define AS3711_REG(_id, _en_reg, _en_bit, _vmask, _sfx) \
134123 [AS3711_REGULATOR_ ## _id] = { \
135
- .desc = { \
136124 .name = "as3711-regulator-" # _id, \
137125 .id = AS3711_REGULATOR_ ## _id, \
138126 .n_voltages = (_vmask + 1), \
....@@ -145,10 +133,9 @@
145133 .enable_mask = BIT(_en_bit), \
146134 .linear_ranges = as3711_ ## _sfx ## _ranges, \
147135 .n_linear_ranges = ARRAY_SIZE(as3711_ ## _sfx ## _ranges), \
148
- }, \
149136 }
150137
151
-static struct as3711_regulator_info as3711_reg_info[] = {
138
+static const struct regulator_desc as3711_reg_desc[] = {
152139 AS3711_REG(SD_1, SD_CONTROL, 0, 0x7f, sd),
153140 AS3711_REG(SD_2, SD_CONTROL, 1, 0x7f, sd),
154141 AS3711_REG(SD_3, SD_CONTROL, 2, 0x7f, sd),
....@@ -164,7 +151,7 @@
164151 /* StepUp output voltage depends on supplying regulator */
165152 };
166153
167
-#define AS3711_REGULATOR_NUM ARRAY_SIZE(as3711_reg_info)
154
+#define AS3711_REGULATOR_NUM ARRAY_SIZE(as3711_reg_desc)
168155
169156 static struct of_regulator_match
170157 as3711_regulator_matches[AS3711_REGULATOR_NUM] = {
....@@ -218,11 +205,8 @@
218205 struct as3711_regulator_pdata *pdata = dev_get_platdata(&pdev->dev);
219206 struct as3711 *as3711 = dev_get_drvdata(pdev->dev.parent);
220207 struct regulator_config config = {.dev = &pdev->dev,};
221
- struct as3711_regulator *reg = NULL;
222
- struct as3711_regulator *regs;
223208 struct device_node *of_node[AS3711_REGULATOR_NUM] = {};
224209 struct regulator_dev *rdev;
225
- struct as3711_regulator_info *ri;
226210 int ret;
227211 int id;
228212
....@@ -239,30 +223,20 @@
239223 }
240224 }
241225
242
- regs = devm_kcalloc(&pdev->dev,
243
- AS3711_REGULATOR_NUM,
244
- sizeof(struct as3711_regulator),
245
- GFP_KERNEL);
246
- if (!regs)
247
- return -ENOMEM;
248
-
249
- for (id = 0, ri = as3711_reg_info; id < AS3711_REGULATOR_NUM; ++id, ri++) {
250
- reg = &regs[id];
251
- reg->reg_info = ri;
252
-
226
+ for (id = 0; id < AS3711_REGULATOR_NUM; id++) {
253227 config.init_data = pdata->init_data[id];
254
- config.driver_data = reg;
255228 config.regmap = as3711->regmap;
256229 config.of_node = of_node[id];
257230
258
- rdev = devm_regulator_register(&pdev->dev, &ri->desc, &config);
231
+ rdev = devm_regulator_register(&pdev->dev, &as3711_reg_desc[id],
232
+ &config);
259233 if (IS_ERR(rdev)) {
260234 dev_err(&pdev->dev, "Failed to register regulator %s\n",
261
- ri->desc.name);
235
+ as3711_reg_desc[id].name);
262236 return PTR_ERR(rdev);
263237 }
264238 }
265
- platform_set_drvdata(pdev, regs);
239
+
266240 return 0;
267241 }
268242