hc
2024-10-22 8ac6c7a54ed1b98d142dce24b11c6de6a1e239a5
kernel/drivers/regulator/wm8400-regulator.c
....@@ -1,16 +1,10 @@
1
-/*
2
- * Regulator support for WM8400
3
- *
4
- * Copyright 2008 Wolfson Microelectronics PLC.
5
- *
6
- * Author: Mark Brown <broonie@opensource.wolfsonmicro.com>
7
- *
8
- * This program is free software; you can redistribute it and/or
9
- * modify it under the terms of the GNU General Public License as
10
- * published by the Free Software Foundation; either version 2 of the
11
- * License, or (at your option) any later version.
12
- *
13
- */
1
+// SPDX-License-Identifier: GPL-2.0+
2
+//
3
+// Regulator support for WM8400
4
+//
5
+// Copyright 2008 Wolfson Microelectronics PLC.
6
+//
7
+// Author: Mark Brown <broonie@opensource.wolfsonmicro.com>
148
159 #include <linux/bug.h>
1610 #include <linux/err.h>
....@@ -19,7 +13,7 @@
1913 #include <linux/regulator/driver.h>
2014 #include <linux/mfd/wm8400-private.h>
2115
22
-static const struct regulator_linear_range wm8400_ldo_ranges[] = {
16
+static const struct linear_range wm8400_ldo_ranges[] = {
2317 REGULATOR_LINEAR_RANGE(900000, 0, 14, 50000),
2418 REGULATOR_LINEAR_RANGE(1700000, 15, 31, 100000),
2519 };
....@@ -36,13 +30,12 @@
3630
3731 static unsigned int wm8400_dcdc_get_mode(struct regulator_dev *dev)
3832 {
39
- struct wm8400 *wm8400 = rdev_get_drvdata(dev);
33
+ struct regmap *rmap = rdev_get_regmap(dev);
4034 int offset = (rdev_get_id(dev) - WM8400_DCDC1) * 2;
4135 u16 data[2];
4236 int ret;
4337
44
- ret = wm8400_block_read(wm8400, WM8400_DCDC1_CONTROL_1 + offset, 2,
45
- data);
38
+ ret = regmap_bulk_read(rmap, WM8400_DCDC1_CONTROL_1 + offset, data, 2);
4639 if (ret != 0)
4740 return 0;
4841
....@@ -63,36 +56,36 @@
6356
6457 static int wm8400_dcdc_set_mode(struct regulator_dev *dev, unsigned int mode)
6558 {
66
- struct wm8400 *wm8400 = rdev_get_drvdata(dev);
59
+ struct regmap *rmap = rdev_get_regmap(dev);
6760 int offset = (rdev_get_id(dev) - WM8400_DCDC1) * 2;
6861 int ret;
6962
7063 switch (mode) {
7164 case REGULATOR_MODE_FAST:
7265 /* Datasheet: active with force PWM */
73
- ret = wm8400_set_bits(wm8400, WM8400_DCDC1_CONTROL_2 + offset,
66
+ ret = regmap_update_bits(rmap, WM8400_DCDC1_CONTROL_2 + offset,
7467 WM8400_DC1_FRC_PWM, WM8400_DC1_FRC_PWM);
7568 if (ret != 0)
7669 return ret;
7770
78
- return wm8400_set_bits(wm8400, WM8400_DCDC1_CONTROL_1 + offset,
71
+ return regmap_update_bits(rmap, WM8400_DCDC1_CONTROL_1 + offset,
7972 WM8400_DC1_ACTIVE | WM8400_DC1_SLEEP,
8073 WM8400_DC1_ACTIVE);
8174
8275 case REGULATOR_MODE_NORMAL:
8376 /* Datasheet: active */
84
- ret = wm8400_set_bits(wm8400, WM8400_DCDC1_CONTROL_2 + offset,
77
+ ret = regmap_update_bits(rmap, WM8400_DCDC1_CONTROL_2 + offset,
8578 WM8400_DC1_FRC_PWM, 0);
8679 if (ret != 0)
8780 return ret;
8881
89
- return wm8400_set_bits(wm8400, WM8400_DCDC1_CONTROL_1 + offset,
82
+ return regmap_update_bits(rmap, WM8400_DCDC1_CONTROL_1 + offset,
9083 WM8400_DC1_ACTIVE | WM8400_DC1_SLEEP,
9184 WM8400_DC1_ACTIVE);
9285
9386 case REGULATOR_MODE_IDLE:
9487 /* Datasheet: standby */
95
- return wm8400_set_bits(wm8400, WM8400_DCDC1_CONTROL_1 + offset,
88
+ return regmap_update_bits(rmap, WM8400_DCDC1_CONTROL_1 + offset,
9689 WM8400_DC1_ACTIVE | WM8400_DC1_SLEEP, 0);
9790 default:
9891 return -EINVAL;
....@@ -195,7 +188,7 @@
195188 .id = WM8400_DCDC2,
196189 .ops = &wm8400_dcdc_ops,
197190 .enable_reg = WM8400_DCDC2_CONTROL_1,
198
- .enable_mask = WM8400_DC1_ENA_MASK,
191
+ .enable_mask = WM8400_DC2_ENA_MASK,
199192 .n_voltages = WM8400_DC2_VSEL_MASK + 1,
200193 .vsel_reg = WM8400_DCDC2_CONTROL_1,
201194 .vsel_mask = WM8400_DC2_VSEL_MASK,
....@@ -241,9 +234,9 @@
241234 * the regulator API. It is intended to be called from the
242235 * platform_init() callback of the WM8400 MFD driver.
243236 *
244
- * @param dev The WM8400 device to operate on.
245
- * @param reg The regulator to control.
246
- * @param initdata Regulator initdata for the regulator.
237
+ * @dev: The WM8400 device to operate on.
238
+ * @reg: The regulator to control.
239
+ * @initdata: Regulator initdata for the regulator.
247240 */
248241 int wm8400_register_regulator(struct device *dev, int reg,
249242 struct regulator_init_data *initdata)