Chris Zhong | 2cd64ae | 2014-08-20 11:36:42 +0800 | [diff] [blame] | 1 | /* |
Wadim Egorov | 1137529 | 2016-08-29 13:07:59 +0200 | [diff] [blame] | 2 | * Regulator driver for Rockchip RK808/RK818 |
Chris Zhong | 2cd64ae | 2014-08-20 11:36:42 +0800 | [diff] [blame] | 3 | * |
| 4 | * Copyright (c) 2014, Fuzhou Rockchip Electronics Co., Ltd |
| 5 | * |
| 6 | * Author: Chris Zhong <zyw@rock-chips.com> |
| 7 | * Author: Zhang Qing <zhangqing@rock-chips.com> |
| 8 | * |
Wadim Egorov | 1137529 | 2016-08-29 13:07:59 +0200 | [diff] [blame] | 9 | * Copyright (C) 2016 PHYTEC Messtechnik GmbH |
| 10 | * |
| 11 | * Author: Wadim Egorov <w.egorov@phytec.de> |
| 12 | * |
Chris Zhong | 2cd64ae | 2014-08-20 11:36:42 +0800 | [diff] [blame] | 13 | * This program is free software; you can redistribute it and/or modify it |
| 14 | * under the terms and conditions of the GNU General Public License, |
| 15 | * version 2, as published by the Free Software Foundation. |
| 16 | * |
| 17 | * This program is distributed in the hope it will be useful, but WITHOUT |
| 18 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
| 19 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for |
| 20 | * more details. |
Chris Zhong | 2cd64ae | 2014-08-20 11:36:42 +0800 | [diff] [blame] | 21 | */ |
| 22 | |
Chris Zhong | bad47ad | 2015-07-20 17:23:53 +0800 | [diff] [blame] | 23 | #include <linux/delay.h> |
| 24 | #include <linux/gpio.h> |
Chris Zhong | 2cd64ae | 2014-08-20 11:36:42 +0800 | [diff] [blame] | 25 | #include <linux/i2c.h> |
Chris Zhong | bad47ad | 2015-07-20 17:23:53 +0800 | [diff] [blame] | 26 | #include <linux/module.h> |
Chris Zhong | 2cd64ae | 2014-08-20 11:36:42 +0800 | [diff] [blame] | 27 | #include <linux/of_device.h> |
Chris Zhong | bad47ad | 2015-07-20 17:23:53 +0800 | [diff] [blame] | 28 | #include <linux/of_gpio.h> |
| 29 | #include <linux/mfd/rk808.h> |
Chris Zhong | 2cd64ae | 2014-08-20 11:36:42 +0800 | [diff] [blame] | 30 | #include <linux/regulator/driver.h> |
| 31 | #include <linux/regulator/of_regulator.h> |
Uwe Kleine-König | 604d499 | 2015-07-21 16:46:24 +0200 | [diff] [blame] | 32 | #include <linux/gpio/consumer.h> |
Chris Zhong | 571a401 | 2014-09-10 09:18:06 +0800 | [diff] [blame] | 33 | |
| 34 | /* Field Definitions */ |
Chris Zhong | 2cd64ae | 2014-08-20 11:36:42 +0800 | [diff] [blame] | 35 | #define RK808_BUCK_VSEL_MASK 0x3f |
| 36 | #define RK808_BUCK4_VSEL_MASK 0xf |
| 37 | #define RK808_LDO_VSEL_MASK 0x1f |
| 38 | |
Wadim Egorov | 1137529 | 2016-08-29 13:07:59 +0200 | [diff] [blame] | 39 | #define RK818_BUCK_VSEL_MASK 0x3f |
| 40 | #define RK818_BUCK4_VSEL_MASK 0x1f |
| 41 | #define RK818_LDO_VSEL_MASK 0x1f |
| 42 | #define RK818_LDO3_ON_VSEL_MASK 0xf |
| 43 | #define RK818_BOOST_ON_VSEL_MASK 0xe0 |
| 44 | |
Doug Anderson | 8af2522 | 2014-09-16 10:22:54 -0700 | [diff] [blame] | 45 | /* Ramp rate definitions for buck1 / buck2 only */ |
| 46 | #define RK808_RAMP_RATE_OFFSET 3 |
| 47 | #define RK808_RAMP_RATE_MASK (3 << RK808_RAMP_RATE_OFFSET) |
| 48 | #define RK808_RAMP_RATE_2MV_PER_US (0 << RK808_RAMP_RATE_OFFSET) |
| 49 | #define RK808_RAMP_RATE_4MV_PER_US (1 << RK808_RAMP_RATE_OFFSET) |
| 50 | #define RK808_RAMP_RATE_6MV_PER_US (2 << RK808_RAMP_RATE_OFFSET) |
| 51 | #define RK808_RAMP_RATE_10MV_PER_US (3 << RK808_RAMP_RATE_OFFSET) |
| 52 | |
Chris Zhong | bad47ad | 2015-07-20 17:23:53 +0800 | [diff] [blame] | 53 | #define RK808_DVS2_POL BIT(2) |
| 54 | #define RK808_DVS1_POL BIT(1) |
| 55 | |
Chris Zhong | 251ce318 | 2014-10-10 15:35:06 -0700 | [diff] [blame] | 56 | /* Offset from XXX_ON_VSEL to XXX_SLP_VSEL */ |
| 57 | #define RK808_SLP_REG_OFFSET 1 |
| 58 | |
Chris Zhong | bad47ad | 2015-07-20 17:23:53 +0800 | [diff] [blame] | 59 | /* Offset from XXX_ON_VSEL to XXX_DVS_VSEL */ |
| 60 | #define RK808_DVS_REG_OFFSET 2 |
| 61 | |
Chris Zhong | 251ce318 | 2014-10-10 15:35:06 -0700 | [diff] [blame] | 62 | /* Offset from XXX_EN_REG to SLEEP_SET_OFF_XXX */ |
| 63 | #define RK808_SLP_SET_OFF_REG_OFFSET 2 |
| 64 | |
Chris Zhong | bad47ad | 2015-07-20 17:23:53 +0800 | [diff] [blame] | 65 | /* max steps for increase voltage of Buck1/2, equal 100mv*/ |
| 66 | #define MAX_STEPS_ONE_TIME 8 |
| 67 | |
Wadim Egorov | 9e9daa0 | 2016-05-10 15:18:55 +0200 | [diff] [blame] | 68 | #define RK8XX_DESC(_id, _match, _supply, _min, _max, _step, _vreg, \ |
| 69 | _vmask, _ereg, _emask, _etime) \ |
| 70 | [_id] = { \ |
| 71 | .name = (_match), \ |
| 72 | .supply_name = (_supply), \ |
| 73 | .of_match = of_match_ptr(_match), \ |
| 74 | .regulators_node = of_match_ptr("regulators"), \ |
| 75 | .type = REGULATOR_VOLTAGE, \ |
| 76 | .id = (_id), \ |
| 77 | .n_voltages = (((_max) - (_min)) / (_step) + 1), \ |
| 78 | .owner = THIS_MODULE, \ |
| 79 | .min_uV = (_min) * 1000, \ |
| 80 | .uV_step = (_step) * 1000, \ |
| 81 | .vsel_reg = (_vreg), \ |
| 82 | .vsel_mask = (_vmask), \ |
| 83 | .enable_reg = (_ereg), \ |
| 84 | .enable_mask = (_emask), \ |
| 85 | .enable_time = (_etime), \ |
| 86 | .ops = &rk808_reg_ops, \ |
| 87 | } |
| 88 | |
| 89 | #define RK8XX_DESC_SWITCH(_id, _match, _supply, _ereg, _emask) \ |
| 90 | [_id] = { \ |
| 91 | .name = (_match), \ |
| 92 | .supply_name = (_supply), \ |
| 93 | .of_match = of_match_ptr(_match), \ |
| 94 | .regulators_node = of_match_ptr("regulators"), \ |
| 95 | .type = REGULATOR_VOLTAGE, \ |
| 96 | .id = (_id), \ |
| 97 | .enable_reg = (_ereg), \ |
| 98 | .enable_mask = (_emask), \ |
| 99 | .owner = THIS_MODULE, \ |
| 100 | .ops = &rk808_switch_ops \ |
| 101 | } |
| 102 | |
| 103 | |
Chris Zhong | bad47ad | 2015-07-20 17:23:53 +0800 | [diff] [blame] | 104 | struct rk808_regulator_data { |
| 105 | struct gpio_desc *dvs_gpio[2]; |
| 106 | }; |
| 107 | |
Doug Anderson | 8af2522 | 2014-09-16 10:22:54 -0700 | [diff] [blame] | 108 | static const int rk808_buck_config_regs[] = { |
| 109 | RK808_BUCK1_CONFIG_REG, |
| 110 | RK808_BUCK2_CONFIG_REG, |
| 111 | RK808_BUCK3_CONFIG_REG, |
| 112 | RK808_BUCK4_CONFIG_REG, |
| 113 | }; |
| 114 | |
Chris Zhong | 2cd64ae | 2014-08-20 11:36:42 +0800 | [diff] [blame] | 115 | static const struct regulator_linear_range rk808_ldo3_voltage_ranges[] = { |
| 116 | REGULATOR_LINEAR_RANGE(800000, 0, 13, 100000), |
| 117 | REGULATOR_LINEAR_RANGE(2500000, 15, 15, 0), |
| 118 | }; |
| 119 | |
Chris Zhong | bad47ad | 2015-07-20 17:23:53 +0800 | [diff] [blame] | 120 | static int rk808_buck1_2_get_voltage_sel_regmap(struct regulator_dev *rdev) |
| 121 | { |
| 122 | struct rk808_regulator_data *pdata = rdev_get_drvdata(rdev); |
Axel Lin | bf8e276 | 2016-10-21 10:30:16 +0800 | [diff] [blame] | 123 | int id = rdev_get_id(rdev); |
Chris Zhong | bad47ad | 2015-07-20 17:23:53 +0800 | [diff] [blame] | 124 | struct gpio_desc *gpio = pdata->dvs_gpio[id]; |
| 125 | unsigned int val; |
| 126 | int ret; |
| 127 | |
Uwe Kleine-König | a13eaf0 | 2015-07-21 16:46:25 +0200 | [diff] [blame] | 128 | if (!gpio || gpiod_get_value(gpio) == 0) |
Chris Zhong | bad47ad | 2015-07-20 17:23:53 +0800 | [diff] [blame] | 129 | return regulator_get_voltage_sel_regmap(rdev); |
| 130 | |
| 131 | ret = regmap_read(rdev->regmap, |
| 132 | rdev->desc->vsel_reg + RK808_DVS_REG_OFFSET, |
| 133 | &val); |
| 134 | if (ret != 0) |
| 135 | return ret; |
| 136 | |
| 137 | val &= rdev->desc->vsel_mask; |
| 138 | val >>= ffs(rdev->desc->vsel_mask) - 1; |
| 139 | |
| 140 | return val; |
| 141 | } |
| 142 | |
| 143 | static int rk808_buck1_2_i2c_set_voltage_sel(struct regulator_dev *rdev, |
| 144 | unsigned sel) |
| 145 | { |
| 146 | int ret, delta_sel; |
| 147 | unsigned int old_sel, tmp, val, mask = rdev->desc->vsel_mask; |
| 148 | |
| 149 | ret = regmap_read(rdev->regmap, rdev->desc->vsel_reg, &val); |
| 150 | if (ret != 0) |
| 151 | return ret; |
| 152 | |
| 153 | tmp = val & ~mask; |
| 154 | old_sel = val & mask; |
| 155 | old_sel >>= ffs(mask) - 1; |
| 156 | delta_sel = sel - old_sel; |
| 157 | |
| 158 | /* |
| 159 | * If directly modify the register to change the voltage, we will face |
| 160 | * the risk of overshoot. Put it into a multi-step, can effectively |
| 161 | * avoid this problem, a step is 100mv here. |
| 162 | */ |
| 163 | while (delta_sel > MAX_STEPS_ONE_TIME) { |
| 164 | old_sel += MAX_STEPS_ONE_TIME; |
| 165 | val = old_sel << (ffs(mask) - 1); |
| 166 | val |= tmp; |
| 167 | |
| 168 | /* |
| 169 | * i2c is 400kHz (2.5us per bit) and we must transmit _at least_ |
| 170 | * 3 bytes (24 bits) plus start and stop so 26 bits. So we've |
| 171 | * got more than 65 us between each voltage change and thus |
| 172 | * won't ramp faster than ~1500 uV / us. |
| 173 | */ |
| 174 | ret = regmap_write(rdev->regmap, rdev->desc->vsel_reg, val); |
| 175 | delta_sel = sel - old_sel; |
| 176 | } |
| 177 | |
| 178 | sel <<= ffs(mask) - 1; |
| 179 | val = tmp | sel; |
| 180 | ret = regmap_write(rdev->regmap, rdev->desc->vsel_reg, val); |
| 181 | |
| 182 | /* |
| 183 | * When we change the voltage register directly, the ramp rate is about |
| 184 | * 100000uv/us, wait 1us to make sure the target voltage to be stable, |
| 185 | * so we needn't wait extra time after that. |
| 186 | */ |
| 187 | udelay(1); |
| 188 | |
| 189 | return ret; |
| 190 | } |
| 191 | |
| 192 | static int rk808_buck1_2_set_voltage_sel(struct regulator_dev *rdev, |
| 193 | unsigned sel) |
| 194 | { |
| 195 | struct rk808_regulator_data *pdata = rdev_get_drvdata(rdev); |
Axel Lin | bf8e276 | 2016-10-21 10:30:16 +0800 | [diff] [blame] | 196 | int id = rdev_get_id(rdev); |
Chris Zhong | bad47ad | 2015-07-20 17:23:53 +0800 | [diff] [blame] | 197 | struct gpio_desc *gpio = pdata->dvs_gpio[id]; |
| 198 | unsigned int reg = rdev->desc->vsel_reg; |
| 199 | unsigned old_sel; |
| 200 | int ret, gpio_level; |
| 201 | |
Uwe Kleine-König | a13eaf0 | 2015-07-21 16:46:25 +0200 | [diff] [blame] | 202 | if (!gpio) |
Chris Zhong | bad47ad | 2015-07-20 17:23:53 +0800 | [diff] [blame] | 203 | return rk808_buck1_2_i2c_set_voltage_sel(rdev, sel); |
| 204 | |
| 205 | gpio_level = gpiod_get_value(gpio); |
| 206 | if (gpio_level == 0) { |
| 207 | reg += RK808_DVS_REG_OFFSET; |
| 208 | ret = regmap_read(rdev->regmap, rdev->desc->vsel_reg, &old_sel); |
| 209 | } else { |
| 210 | ret = regmap_read(rdev->regmap, |
| 211 | reg + RK808_DVS_REG_OFFSET, |
| 212 | &old_sel); |
| 213 | } |
| 214 | |
| 215 | if (ret != 0) |
| 216 | return ret; |
| 217 | |
| 218 | sel <<= ffs(rdev->desc->vsel_mask) - 1; |
| 219 | sel |= old_sel & ~rdev->desc->vsel_mask; |
| 220 | |
| 221 | ret = regmap_write(rdev->regmap, reg, sel); |
| 222 | if (ret) |
| 223 | return ret; |
| 224 | |
| 225 | gpiod_set_value(gpio, !gpio_level); |
| 226 | |
| 227 | return ret; |
| 228 | } |
| 229 | |
| 230 | static int rk808_buck1_2_set_voltage_time_sel(struct regulator_dev *rdev, |
| 231 | unsigned int old_selector, |
| 232 | unsigned int new_selector) |
| 233 | { |
| 234 | struct rk808_regulator_data *pdata = rdev_get_drvdata(rdev); |
Axel Lin | bf8e276 | 2016-10-21 10:30:16 +0800 | [diff] [blame] | 235 | int id = rdev_get_id(rdev); |
Chris Zhong | bad47ad | 2015-07-20 17:23:53 +0800 | [diff] [blame] | 236 | struct gpio_desc *gpio = pdata->dvs_gpio[id]; |
| 237 | |
| 238 | /* if there is no dvs1/2 pin, we don't need wait extra time here. */ |
Uwe Kleine-König | a13eaf0 | 2015-07-21 16:46:25 +0200 | [diff] [blame] | 239 | if (!gpio) |
Chris Zhong | bad47ad | 2015-07-20 17:23:53 +0800 | [diff] [blame] | 240 | return 0; |
| 241 | |
| 242 | return regulator_set_voltage_time_sel(rdev, old_selector, new_selector); |
| 243 | } |
| 244 | |
Doug Anderson | 8af2522 | 2014-09-16 10:22:54 -0700 | [diff] [blame] | 245 | static int rk808_set_ramp_delay(struct regulator_dev *rdev, int ramp_delay) |
| 246 | { |
| 247 | unsigned int ramp_value = RK808_RAMP_RATE_10MV_PER_US; |
Axel Lin | bf8e276 | 2016-10-21 10:30:16 +0800 | [diff] [blame] | 248 | unsigned int reg = rk808_buck_config_regs[rdev_get_id(rdev)]; |
Doug Anderson | 8af2522 | 2014-09-16 10:22:54 -0700 | [diff] [blame] | 249 | |
| 250 | switch (ramp_delay) { |
| 251 | case 1 ... 2000: |
| 252 | ramp_value = RK808_RAMP_RATE_2MV_PER_US; |
| 253 | break; |
| 254 | case 2001 ... 4000: |
| 255 | ramp_value = RK808_RAMP_RATE_4MV_PER_US; |
| 256 | break; |
| 257 | case 4001 ... 6000: |
| 258 | ramp_value = RK808_RAMP_RATE_6MV_PER_US; |
| 259 | break; |
| 260 | case 6001 ... 10000: |
| 261 | break; |
| 262 | default: |
| 263 | pr_warn("%s ramp_delay: %d not supported, setting 10000\n", |
| 264 | rdev->desc->name, ramp_delay); |
| 265 | } |
| 266 | |
| 267 | return regmap_update_bits(rdev->regmap, reg, |
| 268 | RK808_RAMP_RATE_MASK, ramp_value); |
| 269 | } |
| 270 | |
Wei Yongjun | 5cb2f03 | 2014-12-09 21:19:51 +0800 | [diff] [blame] | 271 | static int rk808_set_suspend_voltage(struct regulator_dev *rdev, int uv) |
Chris Zhong | 251ce318 | 2014-10-10 15:35:06 -0700 | [diff] [blame] | 272 | { |
| 273 | unsigned int reg; |
Wadim Egorov | afcd666 | 2016-04-25 15:20:43 +0200 | [diff] [blame] | 274 | int sel = regulator_map_voltage_linear(rdev, uv, uv); |
| 275 | |
| 276 | if (sel < 0) |
| 277 | return -EINVAL; |
| 278 | |
| 279 | reg = rdev->desc->vsel_reg + RK808_SLP_REG_OFFSET; |
| 280 | |
| 281 | return regmap_update_bits(rdev->regmap, reg, |
| 282 | rdev->desc->vsel_mask, |
| 283 | sel); |
| 284 | } |
| 285 | |
Wadim Egorov | 129d7cf | 2016-04-26 16:54:04 +0200 | [diff] [blame] | 286 | static int rk808_set_suspend_voltage_range(struct regulator_dev *rdev, int uv) |
| 287 | { |
| 288 | unsigned int reg; |
| 289 | int sel = regulator_map_voltage_linear_range(rdev, uv, uv); |
| 290 | |
| 291 | if (sel < 0) |
| 292 | return -EINVAL; |
| 293 | |
| 294 | reg = rdev->desc->vsel_reg + RK808_SLP_REG_OFFSET; |
| 295 | |
| 296 | return regmap_update_bits(rdev->regmap, reg, |
| 297 | rdev->desc->vsel_mask, |
| 298 | sel); |
| 299 | } |
| 300 | |
Wei Yongjun | 5cb2f03 | 2014-12-09 21:19:51 +0800 | [diff] [blame] | 301 | static int rk808_set_suspend_enable(struct regulator_dev *rdev) |
Chris Zhong | 251ce318 | 2014-10-10 15:35:06 -0700 | [diff] [blame] | 302 | { |
| 303 | unsigned int reg; |
| 304 | |
| 305 | reg = rdev->desc->enable_reg + RK808_SLP_SET_OFF_REG_OFFSET; |
| 306 | |
| 307 | return regmap_update_bits(rdev->regmap, reg, |
| 308 | rdev->desc->enable_mask, |
| 309 | 0); |
| 310 | } |
| 311 | |
Wei Yongjun | 5cb2f03 | 2014-12-09 21:19:51 +0800 | [diff] [blame] | 312 | static int rk808_set_suspend_disable(struct regulator_dev *rdev) |
Chris Zhong | 251ce318 | 2014-10-10 15:35:06 -0700 | [diff] [blame] | 313 | { |
| 314 | unsigned int reg; |
| 315 | |
| 316 | reg = rdev->desc->enable_reg + RK808_SLP_SET_OFF_REG_OFFSET; |
| 317 | |
| 318 | return regmap_update_bits(rdev->regmap, reg, |
| 319 | rdev->desc->enable_mask, |
| 320 | rdev->desc->enable_mask); |
| 321 | } |
| 322 | |
Doug Anderson | 8af2522 | 2014-09-16 10:22:54 -0700 | [diff] [blame] | 323 | static struct regulator_ops rk808_buck1_2_ops = { |
Wadim Egorov | afcd666 | 2016-04-25 15:20:43 +0200 | [diff] [blame] | 324 | .list_voltage = regulator_list_voltage_linear, |
| 325 | .map_voltage = regulator_map_voltage_linear, |
Chris Zhong | bad47ad | 2015-07-20 17:23:53 +0800 | [diff] [blame] | 326 | .get_voltage_sel = rk808_buck1_2_get_voltage_sel_regmap, |
| 327 | .set_voltage_sel = rk808_buck1_2_set_voltage_sel, |
| 328 | .set_voltage_time_sel = rk808_buck1_2_set_voltage_time_sel, |
Doug Anderson | 8af2522 | 2014-09-16 10:22:54 -0700 | [diff] [blame] | 329 | .enable = regulator_enable_regmap, |
| 330 | .disable = regulator_disable_regmap, |
| 331 | .is_enabled = regulator_is_enabled_regmap, |
| 332 | .set_ramp_delay = rk808_set_ramp_delay, |
Chris Zhong | 251ce318 | 2014-10-10 15:35:06 -0700 | [diff] [blame] | 333 | .set_suspend_voltage = rk808_set_suspend_voltage, |
| 334 | .set_suspend_enable = rk808_set_suspend_enable, |
| 335 | .set_suspend_disable = rk808_set_suspend_disable, |
Doug Anderson | 8af2522 | 2014-09-16 10:22:54 -0700 | [diff] [blame] | 336 | }; |
| 337 | |
Chris Zhong | 2cd64ae | 2014-08-20 11:36:42 +0800 | [diff] [blame] | 338 | static struct regulator_ops rk808_reg_ops = { |
Wadim Egorov | afcd666 | 2016-04-25 15:20:43 +0200 | [diff] [blame] | 339 | .list_voltage = regulator_list_voltage_linear, |
| 340 | .map_voltage = regulator_map_voltage_linear, |
| 341 | .get_voltage_sel = regulator_get_voltage_sel_regmap, |
| 342 | .set_voltage_sel = regulator_set_voltage_sel_regmap, |
| 343 | .enable = regulator_enable_regmap, |
| 344 | .disable = regulator_disable_regmap, |
| 345 | .is_enabled = regulator_is_enabled_regmap, |
| 346 | .set_suspend_voltage = rk808_set_suspend_voltage, |
| 347 | .set_suspend_enable = rk808_set_suspend_enable, |
| 348 | .set_suspend_disable = rk808_set_suspend_disable, |
| 349 | }; |
| 350 | |
Wadim Egorov | 129d7cf | 2016-04-26 16:54:04 +0200 | [diff] [blame] | 351 | static struct regulator_ops rk808_reg_ops_ranges = { |
| 352 | .list_voltage = regulator_list_voltage_linear_range, |
| 353 | .map_voltage = regulator_map_voltage_linear_range, |
| 354 | .get_voltage_sel = regulator_get_voltage_sel_regmap, |
| 355 | .set_voltage_sel = regulator_set_voltage_sel_regmap, |
| 356 | .enable = regulator_enable_regmap, |
| 357 | .disable = regulator_disable_regmap, |
| 358 | .is_enabled = regulator_is_enabled_regmap, |
| 359 | .set_suspend_voltage = rk808_set_suspend_voltage_range, |
| 360 | .set_suspend_enable = rk808_set_suspend_enable, |
| 361 | .set_suspend_disable = rk808_set_suspend_disable, |
| 362 | }; |
| 363 | |
Chris Zhong | 2cd64ae | 2014-08-20 11:36:42 +0800 | [diff] [blame] | 364 | static struct regulator_ops rk808_switch_ops = { |
Chris Zhong | 251ce318 | 2014-10-10 15:35:06 -0700 | [diff] [blame] | 365 | .enable = regulator_enable_regmap, |
| 366 | .disable = regulator_disable_regmap, |
| 367 | .is_enabled = regulator_is_enabled_regmap, |
| 368 | .set_suspend_enable = rk808_set_suspend_enable, |
| 369 | .set_suspend_disable = rk808_set_suspend_disable, |
Chris Zhong | 2cd64ae | 2014-08-20 11:36:42 +0800 | [diff] [blame] | 370 | }; |
| 371 | |
| 372 | static const struct regulator_desc rk808_reg[] = { |
| 373 | { |
| 374 | .name = "DCDC_REG1", |
Doug Anderson | b8074eb | 2014-09-02 09:14:28 -0700 | [diff] [blame] | 375 | .supply_name = "vcc1", |
Wadim Egorov | 9e9daa0 | 2016-05-10 15:18:55 +0200 | [diff] [blame] | 376 | .of_match = of_match_ptr("DCDC_REG1"), |
| 377 | .regulators_node = of_match_ptr("regulators"), |
Chris Zhong | 2cd64ae | 2014-08-20 11:36:42 +0800 | [diff] [blame] | 378 | .id = RK808_ID_DCDC1, |
Doug Anderson | 8af2522 | 2014-09-16 10:22:54 -0700 | [diff] [blame] | 379 | .ops = &rk808_buck1_2_ops, |
Chris Zhong | 2cd64ae | 2014-08-20 11:36:42 +0800 | [diff] [blame] | 380 | .type = REGULATOR_VOLTAGE, |
Wadim Egorov | afcd666 | 2016-04-25 15:20:43 +0200 | [diff] [blame] | 381 | .min_uV = 712500, |
| 382 | .uV_step = 12500, |
Chris Zhong | 2cd64ae | 2014-08-20 11:36:42 +0800 | [diff] [blame] | 383 | .n_voltages = 64, |
Chris Zhong | 2cd64ae | 2014-08-20 11:36:42 +0800 | [diff] [blame] | 384 | .vsel_reg = RK808_BUCK1_ON_VSEL_REG, |
| 385 | .vsel_mask = RK808_BUCK_VSEL_MASK, |
| 386 | .enable_reg = RK808_DCDC_EN_REG, |
| 387 | .enable_mask = BIT(0), |
| 388 | .owner = THIS_MODULE, |
| 389 | }, { |
| 390 | .name = "DCDC_REG2", |
Doug Anderson | b8074eb | 2014-09-02 09:14:28 -0700 | [diff] [blame] | 391 | .supply_name = "vcc2", |
Wadim Egorov | 9e9daa0 | 2016-05-10 15:18:55 +0200 | [diff] [blame] | 392 | .of_match = of_match_ptr("DCDC_REG2"), |
| 393 | .regulators_node = of_match_ptr("regulators"), |
Chris Zhong | 2cd64ae | 2014-08-20 11:36:42 +0800 | [diff] [blame] | 394 | .id = RK808_ID_DCDC2, |
Doug Anderson | 8af2522 | 2014-09-16 10:22:54 -0700 | [diff] [blame] | 395 | .ops = &rk808_buck1_2_ops, |
Chris Zhong | 2cd64ae | 2014-08-20 11:36:42 +0800 | [diff] [blame] | 396 | .type = REGULATOR_VOLTAGE, |
Wadim Egorov | afcd666 | 2016-04-25 15:20:43 +0200 | [diff] [blame] | 397 | .min_uV = 712500, |
| 398 | .uV_step = 12500, |
Chris Zhong | 2cd64ae | 2014-08-20 11:36:42 +0800 | [diff] [blame] | 399 | .n_voltages = 64, |
Chris Zhong | 2cd64ae | 2014-08-20 11:36:42 +0800 | [diff] [blame] | 400 | .vsel_reg = RK808_BUCK2_ON_VSEL_REG, |
| 401 | .vsel_mask = RK808_BUCK_VSEL_MASK, |
| 402 | .enable_reg = RK808_DCDC_EN_REG, |
| 403 | .enable_mask = BIT(1), |
| 404 | .owner = THIS_MODULE, |
| 405 | }, { |
| 406 | .name = "DCDC_REG3", |
Doug Anderson | b8074eb | 2014-09-02 09:14:28 -0700 | [diff] [blame] | 407 | .supply_name = "vcc3", |
Wadim Egorov | 9e9daa0 | 2016-05-10 15:18:55 +0200 | [diff] [blame] | 408 | .of_match = of_match_ptr("DCDC_REG3"), |
| 409 | .regulators_node = of_match_ptr("regulators"), |
Chris Zhong | 2cd64ae | 2014-08-20 11:36:42 +0800 | [diff] [blame] | 410 | .id = RK808_ID_DCDC3, |
| 411 | .ops = &rk808_switch_ops, |
| 412 | .type = REGULATOR_VOLTAGE, |
| 413 | .n_voltages = 1, |
| 414 | .enable_reg = RK808_DCDC_EN_REG, |
| 415 | .enable_mask = BIT(2), |
| 416 | .owner = THIS_MODULE, |
Wadim Egorov | 9e9daa0 | 2016-05-10 15:18:55 +0200 | [diff] [blame] | 417 | }, |
| 418 | RK8XX_DESC(RK808_ID_DCDC4, "DCDC_REG4", "vcc4", 1800, 3300, 100, |
| 419 | RK808_BUCK4_ON_VSEL_REG, RK808_BUCK4_VSEL_MASK, |
| 420 | RK808_DCDC_EN_REG, BIT(3), 0), |
| 421 | RK8XX_DESC(RK808_ID_LDO1, "LDO_REG1", "vcc6", 1800, 3400, 100, |
| 422 | RK808_LDO1_ON_VSEL_REG, RK808_LDO_VSEL_MASK, RK808_LDO_EN_REG, |
| 423 | BIT(0), 400), |
| 424 | RK8XX_DESC(RK808_ID_LDO2, "LDO_REG2", "vcc6", 1800, 3400, 100, |
| 425 | RK808_LDO2_ON_VSEL_REG, RK808_LDO_VSEL_MASK, RK808_LDO_EN_REG, |
| 426 | BIT(1), 400), |
| 427 | { |
Chris Zhong | 2cd64ae | 2014-08-20 11:36:42 +0800 | [diff] [blame] | 428 | .name = "LDO_REG3", |
Doug Anderson | b8074eb | 2014-09-02 09:14:28 -0700 | [diff] [blame] | 429 | .supply_name = "vcc7", |
Wadim Egorov | 9e9daa0 | 2016-05-10 15:18:55 +0200 | [diff] [blame] | 430 | .of_match = of_match_ptr("LDO_REG3"), |
| 431 | .regulators_node = of_match_ptr("regulators"), |
Chris Zhong | 2cd64ae | 2014-08-20 11:36:42 +0800 | [diff] [blame] | 432 | .id = RK808_ID_LDO3, |
Wadim Egorov | 129d7cf | 2016-04-26 16:54:04 +0200 | [diff] [blame] | 433 | .ops = &rk808_reg_ops_ranges, |
Chris Zhong | 2cd64ae | 2014-08-20 11:36:42 +0800 | [diff] [blame] | 434 | .type = REGULATOR_VOLTAGE, |
| 435 | .n_voltages = 16, |
| 436 | .linear_ranges = rk808_ldo3_voltage_ranges, |
| 437 | .n_linear_ranges = ARRAY_SIZE(rk808_ldo3_voltage_ranges), |
| 438 | .vsel_reg = RK808_LDO3_ON_VSEL_REG, |
| 439 | .vsel_mask = RK808_BUCK4_VSEL_MASK, |
| 440 | .enable_reg = RK808_LDO_EN_REG, |
| 441 | .enable_mask = BIT(2), |
Doug Anderson | 28249b0 | 2015-02-20 16:53:38 -0800 | [diff] [blame] | 442 | .enable_time = 400, |
Chris Zhong | 2cd64ae | 2014-08-20 11:36:42 +0800 | [diff] [blame] | 443 | .owner = THIS_MODULE, |
Chris Zhong | 2cd64ae | 2014-08-20 11:36:42 +0800 | [diff] [blame] | 444 | }, |
Wadim Egorov | 9e9daa0 | 2016-05-10 15:18:55 +0200 | [diff] [blame] | 445 | RK8XX_DESC(RK808_ID_LDO4, "LDO_REG4", "vcc9", 1800, 3400, 100, |
| 446 | RK808_LDO4_ON_VSEL_REG, RK808_LDO_VSEL_MASK, RK808_LDO_EN_REG, |
| 447 | BIT(3), 400), |
| 448 | RK8XX_DESC(RK808_ID_LDO5, "LDO_REG5", "vcc9", 1800, 3400, 100, |
| 449 | RK808_LDO5_ON_VSEL_REG, RK808_LDO_VSEL_MASK, RK808_LDO_EN_REG, |
| 450 | BIT(4), 400), |
| 451 | RK8XX_DESC(RK808_ID_LDO6, "LDO_REG6", "vcc10", 800, 2500, 100, |
| 452 | RK808_LDO6_ON_VSEL_REG, RK808_LDO_VSEL_MASK, RK808_LDO_EN_REG, |
| 453 | BIT(5), 400), |
| 454 | RK8XX_DESC(RK808_ID_LDO7, "LDO_REG7", "vcc7", 800, 2500, 100, |
| 455 | RK808_LDO7_ON_VSEL_REG, RK808_LDO_VSEL_MASK, RK808_LDO_EN_REG, |
| 456 | BIT(6), 400), |
| 457 | RK8XX_DESC(RK808_ID_LDO8, "LDO_REG8", "vcc11", 1800, 3400, 100, |
| 458 | RK808_LDO8_ON_VSEL_REG, RK808_LDO_VSEL_MASK, RK808_LDO_EN_REG, |
| 459 | BIT(7), 400), |
| 460 | RK8XX_DESC_SWITCH(RK808_ID_SWITCH1, "SWITCH_REG1", "vcc8", |
| 461 | RK808_DCDC_EN_REG, BIT(5)), |
| 462 | RK8XX_DESC_SWITCH(RK808_ID_SWITCH2, "SWITCH_REG2", "vcc12", |
| 463 | RK808_DCDC_EN_REG, BIT(6)), |
Chris Zhong | 2cd64ae | 2014-08-20 11:36:42 +0800 | [diff] [blame] | 464 | }; |
| 465 | |
Wadim Egorov | 1137529 | 2016-08-29 13:07:59 +0200 | [diff] [blame] | 466 | static const struct regulator_desc rk818_reg[] = { |
| 467 | { |
| 468 | .name = "DCDC_REG1", |
| 469 | .supply_name = "vcc1", |
| 470 | .of_match = of_match_ptr("DCDC_REG1"), |
| 471 | .regulators_node = of_match_ptr("regulators"), |
| 472 | .id = RK818_ID_DCDC1, |
| 473 | .ops = &rk808_reg_ops, |
| 474 | .type = REGULATOR_VOLTAGE, |
| 475 | .min_uV = 712500, |
| 476 | .uV_step = 12500, |
| 477 | .n_voltages = 64, |
| 478 | .vsel_reg = RK818_BUCK1_ON_VSEL_REG, |
| 479 | .vsel_mask = RK818_BUCK_VSEL_MASK, |
| 480 | .enable_reg = RK818_DCDC_EN_REG, |
| 481 | .enable_mask = BIT(0), |
| 482 | .owner = THIS_MODULE, |
| 483 | }, { |
| 484 | .name = "DCDC_REG2", |
| 485 | .supply_name = "vcc2", |
| 486 | .of_match = of_match_ptr("DCDC_REG2"), |
| 487 | .regulators_node = of_match_ptr("regulators"), |
| 488 | .id = RK818_ID_DCDC2, |
| 489 | .ops = &rk808_reg_ops, |
| 490 | .type = REGULATOR_VOLTAGE, |
| 491 | .min_uV = 712500, |
| 492 | .uV_step = 12500, |
| 493 | .n_voltages = 64, |
| 494 | .vsel_reg = RK818_BUCK2_ON_VSEL_REG, |
| 495 | .vsel_mask = RK818_BUCK_VSEL_MASK, |
| 496 | .enable_reg = RK818_DCDC_EN_REG, |
| 497 | .enable_mask = BIT(1), |
| 498 | .owner = THIS_MODULE, |
| 499 | }, { |
| 500 | .name = "DCDC_REG3", |
| 501 | .supply_name = "vcc3", |
| 502 | .of_match = of_match_ptr("DCDC_REG3"), |
| 503 | .regulators_node = of_match_ptr("regulators"), |
| 504 | .id = RK818_ID_DCDC3, |
| 505 | .ops = &rk808_switch_ops, |
| 506 | .type = REGULATOR_VOLTAGE, |
| 507 | .n_voltages = 1, |
| 508 | .enable_reg = RK818_DCDC_EN_REG, |
| 509 | .enable_mask = BIT(2), |
| 510 | .owner = THIS_MODULE, |
| 511 | }, |
| 512 | RK8XX_DESC(RK818_ID_DCDC4, "DCDC_REG4", "vcc4", 1800, 3600, 100, |
| 513 | RK818_BUCK4_ON_VSEL_REG, RK818_BUCK4_VSEL_MASK, |
| 514 | RK818_DCDC_EN_REG, BIT(3), 0), |
| 515 | RK8XX_DESC(RK818_ID_BOOST, "DCDC_BOOST", "boost", 4700, 5400, 100, |
| 516 | RK818_BOOST_LDO9_ON_VSEL_REG, RK818_BOOST_ON_VSEL_MASK, |
| 517 | RK818_DCDC_EN_REG, BIT(4), 0), |
| 518 | RK8XX_DESC(RK818_ID_LDO1, "LDO_REG1", "vcc6", 1800, 3400, 100, |
| 519 | RK818_LDO1_ON_VSEL_REG, RK818_LDO_VSEL_MASK, RK818_LDO_EN_REG, |
| 520 | BIT(0), 400), |
| 521 | RK8XX_DESC(RK818_ID_LDO2, "LDO_REG2", "vcc6", 1800, 3400, 100, |
| 522 | RK818_LDO1_ON_VSEL_REG, RK818_LDO_VSEL_MASK, RK818_LDO_EN_REG, |
| 523 | BIT(1), 400), |
| 524 | { |
| 525 | .name = "LDO_REG3", |
| 526 | .supply_name = "vcc7", |
| 527 | .of_match = of_match_ptr("LDO_REG3"), |
| 528 | .regulators_node = of_match_ptr("regulators"), |
| 529 | .id = RK818_ID_LDO3, |
| 530 | .ops = &rk808_reg_ops_ranges, |
| 531 | .type = REGULATOR_VOLTAGE, |
| 532 | .n_voltages = 16, |
| 533 | .linear_ranges = rk808_ldo3_voltage_ranges, |
| 534 | .n_linear_ranges = ARRAY_SIZE(rk808_ldo3_voltage_ranges), |
| 535 | .vsel_reg = RK818_LDO3_ON_VSEL_REG, |
| 536 | .vsel_mask = RK818_LDO3_ON_VSEL_MASK, |
| 537 | .enable_reg = RK818_LDO_EN_REG, |
| 538 | .enable_mask = BIT(2), |
| 539 | .enable_time = 400, |
| 540 | .owner = THIS_MODULE, |
| 541 | }, |
| 542 | RK8XX_DESC(RK818_ID_LDO4, "LDO_REG4", "vcc8", 1800, 3400, 100, |
| 543 | RK818_LDO4_ON_VSEL_REG, RK818_LDO_VSEL_MASK, RK818_LDO_EN_REG, |
| 544 | BIT(3), 400), |
| 545 | RK8XX_DESC(RK818_ID_LDO5, "LDO_REG5", "vcc7", 1800, 3400, 100, |
| 546 | RK818_LDO5_ON_VSEL_REG, RK818_LDO_VSEL_MASK, RK818_LDO_EN_REG, |
| 547 | BIT(4), 400), |
| 548 | RK8XX_DESC(RK818_ID_LDO6, "LDO_REG6", "vcc8", 800, 2500, 100, |
| 549 | RK818_LDO6_ON_VSEL_REG, RK818_LDO_VSEL_MASK, RK818_LDO_EN_REG, |
| 550 | BIT(5), 400), |
| 551 | RK8XX_DESC(RK818_ID_LDO7, "LDO_REG7", "vcc7", 800, 2500, 100, |
| 552 | RK818_LDO7_ON_VSEL_REG, RK818_LDO_VSEL_MASK, RK818_LDO_EN_REG, |
| 553 | BIT(6), 400), |
| 554 | RK8XX_DESC(RK818_ID_LDO8, "LDO_REG8", "vcc8", 1800, 3400, 100, |
| 555 | RK818_LDO8_ON_VSEL_REG, RK818_LDO_VSEL_MASK, RK818_LDO_EN_REG, |
| 556 | BIT(7), 400), |
| 557 | RK8XX_DESC(RK818_ID_LDO9, "LDO_REG9", "vcc9", 1800, 3400, 100, |
| 558 | RK818_BOOST_LDO9_ON_VSEL_REG, RK818_LDO_VSEL_MASK, |
| 559 | RK818_DCDC_EN_REG, BIT(5), 400), |
| 560 | RK8XX_DESC_SWITCH(RK818_ID_SWITCH, "SWITCH_REG", "vcc9", |
| 561 | RK818_DCDC_EN_REG, BIT(6)), |
| 562 | RK8XX_DESC_SWITCH(RK818_ID_HDMI_SWITCH, "HDMI_SWITCH", "h_5v", |
| 563 | RK818_H5V_EN_REG, BIT(0)), |
| 564 | RK8XX_DESC_SWITCH(RK818_ID_OTG_SWITCH, "OTG_SWITCH", "usb", |
| 565 | RK818_DCDC_EN_REG, BIT(7)), |
| 566 | }; |
| 567 | |
Chris Zhong | bad47ad | 2015-07-20 17:23:53 +0800 | [diff] [blame] | 568 | static int rk808_regulator_dt_parse_pdata(struct device *dev, |
| 569 | struct device *client_dev, |
| 570 | struct regmap *map, |
| 571 | struct rk808_regulator_data *pdata) |
| 572 | { |
| 573 | struct device_node *np; |
Wadim Egorov | 9e9daa0 | 2016-05-10 15:18:55 +0200 | [diff] [blame] | 574 | int tmp, ret = 0, i; |
Chris Zhong | bad47ad | 2015-07-20 17:23:53 +0800 | [diff] [blame] | 575 | |
| 576 | np = of_get_child_by_name(client_dev->of_node, "regulators"); |
| 577 | if (!np) |
| 578 | return -ENXIO; |
| 579 | |
Chris Zhong | bad47ad | 2015-07-20 17:23:53 +0800 | [diff] [blame] | 580 | for (i = 0; i < ARRAY_SIZE(pdata->dvs_gpio); i++) { |
Uwe Kleine-König | a13eaf0 | 2015-07-21 16:46:25 +0200 | [diff] [blame] | 581 | pdata->dvs_gpio[i] = |
| 582 | devm_gpiod_get_index_optional(client_dev, "dvs", i, |
| 583 | GPIOD_OUT_LOW); |
Chris Zhong | bad47ad | 2015-07-20 17:23:53 +0800 | [diff] [blame] | 584 | if (IS_ERR(pdata->dvs_gpio[i])) { |
Uwe Kleine-König | a13eaf0 | 2015-07-21 16:46:25 +0200 | [diff] [blame] | 585 | ret = PTR_ERR(pdata->dvs_gpio[i]); |
| 586 | dev_err(dev, "failed to get dvs%d gpio (%d)\n", i, ret); |
| 587 | goto dt_parse_end; |
| 588 | } |
| 589 | |
| 590 | if (!pdata->dvs_gpio[i]) { |
Chris Zhong | bad47ad | 2015-07-20 17:23:53 +0800 | [diff] [blame] | 591 | dev_warn(dev, "there is no dvs%d gpio\n", i); |
| 592 | continue; |
| 593 | } |
| 594 | |
Chris Zhong | bad47ad | 2015-07-20 17:23:53 +0800 | [diff] [blame] | 595 | tmp = i ? RK808_DVS2_POL : RK808_DVS1_POL; |
| 596 | ret = regmap_update_bits(map, RK808_IO_POL_REG, tmp, |
| 597 | gpiod_is_active_low(pdata->dvs_gpio[i]) ? |
| 598 | 0 : tmp); |
| 599 | } |
| 600 | |
| 601 | dt_parse_end: |
| 602 | of_node_put(np); |
| 603 | return ret; |
| 604 | } |
| 605 | |
Chris Zhong | 571a401 | 2014-09-10 09:18:06 +0800 | [diff] [blame] | 606 | static int rk808_regulator_probe(struct platform_device *pdev) |
Chris Zhong | 2cd64ae | 2014-08-20 11:36:42 +0800 | [diff] [blame] | 607 | { |
Chris Zhong | 571a401 | 2014-09-10 09:18:06 +0800 | [diff] [blame] | 608 | struct rk808 *rk808 = dev_get_drvdata(pdev->dev.parent); |
| 609 | struct i2c_client *client = rk808->i2c; |
Chris Zhong | 571a401 | 2014-09-10 09:18:06 +0800 | [diff] [blame] | 610 | struct regulator_config config = {}; |
| 611 | struct regulator_dev *rk808_rdev; |
Chris Zhong | bad47ad | 2015-07-20 17:23:53 +0800 | [diff] [blame] | 612 | struct rk808_regulator_data *pdata; |
Wadim Egorov | 1137529 | 2016-08-29 13:07:59 +0200 | [diff] [blame] | 613 | const struct regulator_desc *regulators; |
| 614 | int ret, i, nregulators; |
Chris Zhong | 2cd64ae | 2014-08-20 11:36:42 +0800 | [diff] [blame] | 615 | |
Chris Zhong | bad47ad | 2015-07-20 17:23:53 +0800 | [diff] [blame] | 616 | pdata = devm_kzalloc(&pdev->dev, sizeof(*pdata), GFP_KERNEL); |
| 617 | if (!pdata) |
| 618 | return -ENOMEM; |
Chris Zhong | 2cd64ae | 2014-08-20 11:36:42 +0800 | [diff] [blame] | 619 | |
Chris Zhong | bad47ad | 2015-07-20 17:23:53 +0800 | [diff] [blame] | 620 | ret = rk808_regulator_dt_parse_pdata(&pdev->dev, &client->dev, |
| 621 | rk808->regmap, pdata); |
Chris Zhong | 571a401 | 2014-09-10 09:18:06 +0800 | [diff] [blame] | 622 | if (ret < 0) |
Chris Zhong | 2cd64ae | 2014-08-20 11:36:42 +0800 | [diff] [blame] | 623 | return ret; |
Chris Zhong | 2cd64ae | 2014-08-20 11:36:42 +0800 | [diff] [blame] | 624 | |
Chris Zhong | bad47ad | 2015-07-20 17:23:53 +0800 | [diff] [blame] | 625 | platform_set_drvdata(pdev, pdata); |
| 626 | |
Wadim Egorov | 1137529 | 2016-08-29 13:07:59 +0200 | [diff] [blame] | 627 | switch (rk808->variant) { |
| 628 | case RK808_ID: |
| 629 | regulators = rk808_reg; |
| 630 | nregulators = RK808_NUM_REGULATORS; |
| 631 | break; |
| 632 | case RK818_ID: |
| 633 | regulators = rk818_reg; |
| 634 | nregulators = RK818_NUM_REGULATORS; |
| 635 | break; |
| 636 | default: |
| 637 | dev_err(&client->dev, "unsupported RK8XX ID %lu\n", |
| 638 | rk808->variant); |
| 639 | return -EINVAL; |
| 640 | } |
| 641 | |
Wadim Egorov | 9e9daa0 | 2016-05-10 15:18:55 +0200 | [diff] [blame] | 642 | config.dev = &client->dev; |
| 643 | config.driver_data = pdata; |
| 644 | config.regmap = rk808->regmap; |
| 645 | |
Chris Zhong | 571a401 | 2014-09-10 09:18:06 +0800 | [diff] [blame] | 646 | /* Instantiate the regulators */ |
Wadim Egorov | 1137529 | 2016-08-29 13:07:59 +0200 | [diff] [blame] | 647 | for (i = 0; i < nregulators; i++) { |
Chris Zhong | 2cd64ae | 2014-08-20 11:36:42 +0800 | [diff] [blame] | 648 | rk808_rdev = devm_regulator_register(&pdev->dev, |
Wadim Egorov | 1137529 | 2016-08-29 13:07:59 +0200 | [diff] [blame] | 649 | ®ulators[i], &config); |
Chris Zhong | 2cd64ae | 2014-08-20 11:36:42 +0800 | [diff] [blame] | 650 | if (IS_ERR(rk808_rdev)) { |
Chris Zhong | d76c333 | 2014-08-25 21:37:06 +0800 | [diff] [blame] | 651 | dev_err(&client->dev, |
Chris Zhong | 2cd64ae | 2014-08-20 11:36:42 +0800 | [diff] [blame] | 652 | "failed to register %d regulator\n", i); |
| 653 | return PTR_ERR(rk808_rdev); |
| 654 | } |
Chris Zhong | 2cd64ae | 2014-08-20 11:36:42 +0800 | [diff] [blame] | 655 | } |
Chris Zhong | 571a401 | 2014-09-10 09:18:06 +0800 | [diff] [blame] | 656 | |
Chris Zhong | 2cd64ae | 2014-08-20 11:36:42 +0800 | [diff] [blame] | 657 | return 0; |
| 658 | } |
| 659 | |
| 660 | static struct platform_driver rk808_regulator_driver = { |
| 661 | .probe = rk808_regulator_probe, |
| 662 | .driver = { |
Markus Elfring | 556ae22 | 2016-08-15 10:30:31 +0200 | [diff] [blame] | 663 | .name = "rk808-regulator" |
Chris Zhong | 2cd64ae | 2014-08-20 11:36:42 +0800 | [diff] [blame] | 664 | }, |
| 665 | }; |
| 666 | |
| 667 | module_platform_driver(rk808_regulator_driver); |
| 668 | |
Wadim Egorov | 1137529 | 2016-08-29 13:07:59 +0200 | [diff] [blame] | 669 | MODULE_DESCRIPTION("regulator driver for the RK808/RK818 series PMICs"); |
| 670 | MODULE_AUTHOR("Chris Zhong <zyw@rock-chips.com>"); |
| 671 | MODULE_AUTHOR("Zhang Qing <zhangqing@rock-chips.com>"); |
| 672 | MODULE_AUTHOR("Wadim Egorov <w.egorov@phytec.de>"); |
Chris Zhong | 2cd64ae | 2014-08-20 11:36:42 +0800 | [diff] [blame] | 673 | MODULE_LICENSE("GPL"); |
| 674 | MODULE_ALIAS("platform:rk808-regulator"); |