hc
2023-12-11 d2ccde1c8e90d38cee87a1b0309ad2827f3fd30d
kernel/drivers/regulator/wm831x-isink.c
....@@ -1,15 +1,10 @@
1
-/*
2
- * wm831x-isink.c -- Current sink driver for the WM831x series
3
- *
4
- * Copyright 2009 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 modify it
9
- * under the terms of the GNU General Public License as published by the
10
- * Free Software Foundation; either version 2 of the License, or (at your
11
- * option) any later version.
12
- */
1
+// SPDX-License-Identifier: GPL-2.0+
2
+//
3
+// wm831x-isink.c -- Current sink driver for the WM831x series
4
+//
5
+// Copyright 2009 Wolfson Microelectronics PLC.
6
+//
7
+// Author: Mark Brown <broonie@opensource.wolfsonmicro.com>
138
149 #include <linux/module.h>
1510 #include <linux/moduleparam.h>
....@@ -92,48 +87,12 @@
9287 return 0;
9388 }
9489
95
-static int wm831x_isink_set_current(struct regulator_dev *rdev,
96
- int min_uA, int max_uA)
97
-{
98
- struct wm831x_isink *isink = rdev_get_drvdata(rdev);
99
- struct wm831x *wm831x = isink->wm831x;
100
- int ret, i;
101
-
102
- for (i = 0; i < ARRAY_SIZE(wm831x_isinkv_values); i++) {
103
- int val = wm831x_isinkv_values[i];
104
- if (min_uA <= val && val <= max_uA) {
105
- ret = wm831x_set_bits(wm831x, isink->reg,
106
- WM831X_CS1_ISEL_MASK, i);
107
- return ret;
108
- }
109
- }
110
-
111
- return -EINVAL;
112
-}
113
-
114
-static int wm831x_isink_get_current(struct regulator_dev *rdev)
115
-{
116
- struct wm831x_isink *isink = rdev_get_drvdata(rdev);
117
- struct wm831x *wm831x = isink->wm831x;
118
- int ret;
119
-
120
- ret = wm831x_reg_read(wm831x, isink->reg);
121
- if (ret < 0)
122
- return ret;
123
-
124
- ret &= WM831X_CS1_ISEL_MASK;
125
- if (ret > WM831X_ISINK_MAX_ISEL)
126
- ret = WM831X_ISINK_MAX_ISEL;
127
-
128
- return wm831x_isinkv_values[ret];
129
-}
130
-
13190 static const struct regulator_ops wm831x_isink_ops = {
13291 .is_enabled = wm831x_isink_is_enabled,
13392 .enable = wm831x_isink_enable,
13493 .disable = wm831x_isink_disable,
135
- .set_current_limit = wm831x_isink_set_current,
136
- .get_current_limit = wm831x_isink_get_current,
94
+ .set_current_limit = regulator_set_current_limit_regmap,
95
+ .get_current_limit = regulator_get_current_limit_regmap,
13796 };
13897
13998 static irqreturn_t wm831x_isink_irq(int irq, void *data)
....@@ -187,10 +146,15 @@
187146 isink->desc.ops = &wm831x_isink_ops;
188147 isink->desc.type = REGULATOR_CURRENT;
189148 isink->desc.owner = THIS_MODULE;
149
+ isink->desc.curr_table = wm831x_isinkv_values,
150
+ isink->desc.n_current_limits = ARRAY_SIZE(wm831x_isinkv_values),
151
+ isink->desc.csel_reg = isink->reg,
152
+ isink->desc.csel_mask = WM831X_CS1_ISEL_MASK,
190153
191154 config.dev = pdev->dev.parent;
192155 config.init_data = pdata->isink[id];
193156 config.driver_data = isink;
157
+ config.regmap = wm831x->regmap;
194158
195159 isink->regulator = devm_regulator_register(&pdev->dev, &isink->desc,
196160 &config);