forked from ~ljy/RK356X_SDK_RELEASE

hc
2023-12-09 95099d4622f8cb224d94e314c7a8e0df60b13f87
kernel/drivers/regulator/tps80031-regulator.c
....@@ -1,27 +1,13 @@
1
-/*
2
- * tps80031-regulator.c -- TI TPS80031 regulator driver.
3
- *
4
- * Regulator driver for TI TPS80031/TPS80032 Fully Integrated Power
5
- * Management with Power Path and Battery Charger.
6
- *
7
- * Copyright (c) 2012, NVIDIA Corporation.
8
- *
9
- * Author: Laxman Dewangan <ldewangan@nvidia.com>
10
- *
11
- * This program is free software; you can redistribute it and/or
12
- * modify it under the terms of the GNU General Public License as
13
- * published by the Free Software Foundation version 2.
14
- *
15
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any kind,
16
- * whether express or implied; without even the implied warranty of
17
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18
- * General Public License for more details.
19
- *
20
- * You should have received a copy of the GNU General Public License
21
- * along with this program; if not, write to the Free Software
22
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
23
- * 02111-1307, USA
24
- */
1
+// SPDX-License-Identifier: GPL-2.0
2
+//
3
+// tps80031-regulator.c -- TI TPS80031 regulator driver.
4
+//
5
+// Regulator driver for TI TPS80031/TPS80032 Fully Integrated Power
6
+// Management with Power Path and Battery Charger.
7
+//
8
+// Copyright (c) 2012, NVIDIA Corporation.
9
+//
10
+// Author: Laxman Dewangan <ldewangan@nvidia.com>
2511
2612 #include <linux/delay.h>
2713 #include <linux/err.h>
....@@ -85,7 +71,6 @@
8571
8672 struct tps80031_regulator {
8773 struct device *dev;
88
- struct regulator_dev *rdev;
8974 struct tps80031_regulator_info *rinfo;
9075
9176 u8 device_flags;
....@@ -155,7 +140,7 @@
155140 }
156141
157142 /* DCDC voltages for the selector of 58 to 63 */
158
-static int tps80031_dcdc_voltages[4][5] = {
143
+static const int tps80031_dcdc_voltages[4][5] = {
159144 { 1350, 1500, 1800, 1900, 2100},
160145 { 1350, 1500, 1800, 1900, 2100},
161146 { 2084, 2315, 2778, 2932, 3241},
....@@ -286,7 +271,7 @@
286271 {
287272 struct tps80031_regulator *ri = rdev_get_drvdata(rdev);
288273 struct device *parent = to_tps80031_dev(rdev);
289
- int ret = -EIO;
274
+ int ret;
290275 uint8_t ctrl1 = 0;
291276 uint8_t ctrl3 = 0;
292277
....@@ -337,7 +322,7 @@
337322 {
338323 struct tps80031_regulator *ri = rdev_get_drvdata(rdev);
339324 struct device *parent = to_tps80031_dev(rdev);
340
- int ret = 0;
325
+ int ret;
341326
342327 if (ri->config_flags & TPS80031_VBUS_DISCHRG_EN_PDN) {
343328 ret = tps80031_write(parent, TPS80031_SLAVE_ID2,
....@@ -378,7 +363,7 @@
378363 return ret;
379364 }
380365
381
-static struct regulator_ops tps80031_dcdc_ops = {
366
+static const struct regulator_ops tps80031_dcdc_ops = {
382367 .list_voltage = tps80031_dcdc_list_voltage,
383368 .set_voltage_sel = tps80031_dcdc_set_voltage_sel,
384369 .get_voltage_sel = tps80031_dcdc_get_voltage_sel,
....@@ -387,7 +372,7 @@
387372 .is_enabled = tps80031_reg_is_enabled,
388373 };
389374
390
-static struct regulator_ops tps80031_ldo_ops = {
375
+static const struct regulator_ops tps80031_ldo_ops = {
391376 .list_voltage = tps80031_ldo_list_voltage,
392377 .map_voltage = tps80031_ldo_map_voltage,
393378 .set_voltage_sel = regulator_set_voltage_sel_regmap,
....@@ -397,18 +382,18 @@
397382 .is_enabled = tps80031_reg_is_enabled,
398383 };
399384
400
-static struct regulator_ops tps80031_vbus_sw_ops = {
385
+static const struct regulator_ops tps80031_vbus_sw_ops = {
401386 .list_voltage = regulator_list_voltage_linear,
402387 .enable = tps80031_vbus_enable,
403388 .disable = tps80031_vbus_disable,
404389 .is_enabled = tps80031_vbus_is_enabled,
405390 };
406391
407
-static struct regulator_ops tps80031_vbus_hw_ops = {
392
+static const struct regulator_ops tps80031_vbus_hw_ops = {
408393 .list_voltage = regulator_list_voltage_linear,
409394 };
410395
411
-static struct regulator_ops tps80031_ext_reg_ops = {
396
+static const struct regulator_ops tps80031_ext_reg_ops = {
412397 .list_voltage = regulator_list_voltage_linear,
413398 .enable = tps80031_reg_enable,
414399 .disable = tps80031_reg_disable,
....@@ -545,7 +530,8 @@
545530 case TPS80031_REGULATOR_LDOUSB:
546531 if (ri->config_flags & (TPS80031_USBLDO_INPUT_VSYS |
547532 TPS80031_USBLDO_INPUT_PMID)) {
548
- unsigned val = 0;
533
+ unsigned val;
534
+
549535 if (ri->config_flags & TPS80031_USBLDO_INPUT_VSYS)
550536 val = MISC2_LDOUSB_IN_VSYS;
551537 else
....@@ -736,7 +722,6 @@
736722 ri->rinfo->desc.name);
737723 return PTR_ERR(rdev);
738724 }
739
- ri->rdev = rdev;
740725 }
741726
742727 platform_set_drvdata(pdev, pmic);