.. | .. |
---|
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> |
---|
13 | 8 | |
---|
14 | 9 | #include <linux/module.h> |
---|
15 | 10 | #include <linux/moduleparam.h> |
---|
.. | .. |
---|
92 | 87 | return 0; |
---|
93 | 88 | } |
---|
94 | 89 | |
---|
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 | | - |
---|
131 | 90 | static const struct regulator_ops wm831x_isink_ops = { |
---|
132 | 91 | .is_enabled = wm831x_isink_is_enabled, |
---|
133 | 92 | .enable = wm831x_isink_enable, |
---|
134 | 93 | .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, |
---|
137 | 96 | }; |
---|
138 | 97 | |
---|
139 | 98 | static irqreturn_t wm831x_isink_irq(int irq, void *data) |
---|
.. | .. |
---|
187 | 146 | isink->desc.ops = &wm831x_isink_ops; |
---|
188 | 147 | isink->desc.type = REGULATOR_CURRENT; |
---|
189 | 148 | 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, |
---|
190 | 153 | |
---|
191 | 154 | config.dev = pdev->dev.parent; |
---|
192 | 155 | config.init_data = pdata->isink[id]; |
---|
193 | 156 | config.driver_data = isink; |
---|
| 157 | + config.regmap = wm831x->regmap; |
---|
194 | 158 | |
---|
195 | 159 | isink->regulator = devm_regulator_register(&pdev->dev, &isink->desc, |
---|
196 | 160 | &config); |
---|