hc
2023-12-11 d2ccde1c8e90d38cee87a1b0309ad2827f3fd30d
kernel/drivers/regulator/ltc3676.c
....@@ -1,15 +1,6 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /*
23 * Copyright (C) 2016 Gateworks Corporation, Inc. All Rights Reserved.
3
- *
4
- * This program is free software; you can redistribute it and/or modify
5
- * it under the terms of the GNU General Public License version 2
6
- * as published by the Free Software Foundation.
7
- *
8
- * This program is distributed in the hope that it will be useful,
9
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
10
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
- * GNU General Public License for more details.
12
- *
134 */
145 #include <linux/i2c.h>
156 #include <linux/init.h>
....@@ -230,7 +221,7 @@
230221 #define LTC3676_FIXED_REG(_id, _name, _en_reg, _en_bit) \
231222 LTC3676_REG(_id, _name, fixed, LTC3676_ ## _en_reg, _en_bit, 0, 0)
232223
233
-static struct regulator_desc ltc3676_regulators[LTC3676_NUM_REGULATORS] = {
224
+static const struct regulator_desc ltc3676_regulators[LTC3676_NUM_REGULATORS] = {
234225 LTC3676_LINEAR_REG(SW1, sw1, BUCK1, DVB1A),
235226 LTC3676_LINEAR_REG(SW2, sw2, BUCK2, DVB2A),
236227 LTC3676_LINEAR_REG(SW3, sw3, BUCK3, DVB3A),
....@@ -241,61 +232,10 @@
241232 LTC3676_FIXED_REG(LDO4, ldo4, LDOB, 2),
242233 };
243234
244
-static bool ltc3676_writeable_reg(struct device *dev, unsigned int reg)
235
+static bool ltc3676_readable_writeable_reg(struct device *dev, unsigned int reg)
245236 {
246237 switch (reg) {
247
- case LTC3676_IRQSTAT:
248
- case LTC3676_BUCK1:
249
- case LTC3676_BUCK2:
250
- case LTC3676_BUCK3:
251
- case LTC3676_BUCK4:
252
- case LTC3676_LDOA:
253
- case LTC3676_LDOB:
254
- case LTC3676_SQD1:
255
- case LTC3676_SQD2:
256
- case LTC3676_CNTRL:
257
- case LTC3676_DVB1A:
258
- case LTC3676_DVB1B:
259
- case LTC3676_DVB2A:
260
- case LTC3676_DVB2B:
261
- case LTC3676_DVB3A:
262
- case LTC3676_DVB3B:
263
- case LTC3676_DVB4A:
264
- case LTC3676_DVB4B:
265
- case LTC3676_MSKIRQ:
266
- case LTC3676_MSKPG:
267
- case LTC3676_USER:
268
- case LTC3676_HRST:
269
- case LTC3676_CLIRQ:
270
- return true;
271
- }
272
- return false;
273
-}
274
-
275
-static bool ltc3676_readable_reg(struct device *dev, unsigned int reg)
276
-{
277
- switch (reg) {
278
- case LTC3676_IRQSTAT:
279
- case LTC3676_BUCK1:
280
- case LTC3676_BUCK2:
281
- case LTC3676_BUCK3:
282
- case LTC3676_BUCK4:
283
- case LTC3676_LDOA:
284
- case LTC3676_LDOB:
285
- case LTC3676_SQD1:
286
- case LTC3676_SQD2:
287
- case LTC3676_CNTRL:
288
- case LTC3676_DVB1A:
289
- case LTC3676_DVB1B:
290
- case LTC3676_DVB2A:
291
- case LTC3676_DVB2B:
292
- case LTC3676_DVB3A:
293
- case LTC3676_DVB3B:
294
- case LTC3676_DVB4A:
295
- case LTC3676_DVB4B:
296
- case LTC3676_MSKIRQ:
297
- case LTC3676_MSKPG:
298
- case LTC3676_USER:
238
+ case LTC3676_BUCK1 ... LTC3676_IRQSTAT:
299239 case LTC3676_HRST:
300240 case LTC3676_CLIRQ:
301241 return true;
....@@ -306,9 +246,7 @@
306246 static bool ltc3676_volatile_reg(struct device *dev, unsigned int reg)
307247 {
308248 switch (reg) {
309
- case LTC3676_IRQSTAT:
310
- case LTC3676_PGSTATL:
311
- case LTC3676_PGSTATRT:
249
+ case LTC3676_IRQSTAT ... LTC3676_PGSTATRT:
312250 return true;
313251 }
314252 return false;
....@@ -317,11 +255,12 @@
317255 static const struct regmap_config ltc3676_regmap_config = {
318256 .reg_bits = 8,
319257 .val_bits = 8,
320
- .writeable_reg = ltc3676_writeable_reg,
321
- .readable_reg = ltc3676_readable_reg,
258
+ .writeable_reg = ltc3676_readable_writeable_reg,
259
+ .readable_reg = ltc3676_readable_writeable_reg,
322260 .volatile_reg = ltc3676_volatile_reg,
323261 .max_register = LTC3676_CLIRQ,
324
- .use_single_rw = true,
262
+ .use_single_read = true,
263
+ .use_single_write = true,
325264 .cache_type = REGCACHE_RBTREE,
326265 };
327266
....@@ -356,8 +295,7 @@
356295 return IRQ_HANDLED;
357296 }
358297
359
-static int ltc3676_regulator_probe(struct i2c_client *client,
360
- const struct i2c_device_id *id)
298
+static int ltc3676_regulator_probe(struct i2c_client *client)
361299 {
362300 struct device *dev = &client->dev;
363301 struct regulator_init_data *init_data = dev_get_platdata(dev);
....@@ -424,7 +362,7 @@
424362 };
425363 MODULE_DEVICE_TABLE(i2c, ltc3676_i2c_id);
426364
427
-static const struct of_device_id ltc3676_of_match[] = {
365
+static const struct of_device_id __maybe_unused ltc3676_of_match[] = {
428366 { .compatible = "lltc,ltc3676" },
429367 { },
430368 };
....@@ -435,11 +373,11 @@
435373 .name = DRIVER_NAME,
436374 .of_match_table = of_match_ptr(ltc3676_of_match),
437375 },
438
- .probe = ltc3676_regulator_probe,
376
+ .probe_new = ltc3676_regulator_probe,
439377 .id_table = ltc3676_i2c_id,
440378 };
441379 module_i2c_driver(ltc3676_driver);
442380
443381 MODULE_AUTHOR("Tim Harvey <tharvey@gateworks.com>");
444
-MODULE_DESCRIPTION("Regulator driver for Linear Technology LTC1376");
382
+MODULE_DESCRIPTION("Regulator driver for Linear Technology LTC3676");
445383 MODULE_LICENSE("GPL v2");