| .. | .. |
|---|
| 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> |
|---|
| 14 | 8 | |
|---|
| 15 | 9 | #include <linux/bug.h> |
|---|
| 16 | 10 | #include <linux/err.h> |
|---|
| .. | .. |
|---|
| 19 | 13 | #include <linux/regulator/driver.h> |
|---|
| 20 | 14 | #include <linux/mfd/wm8400-private.h> |
|---|
| 21 | 15 | |
|---|
| 22 | | -static const struct regulator_linear_range wm8400_ldo_ranges[] = { |
|---|
| 16 | +static const struct linear_range wm8400_ldo_ranges[] = { |
|---|
| 23 | 17 | REGULATOR_LINEAR_RANGE(900000, 0, 14, 50000), |
|---|
| 24 | 18 | REGULATOR_LINEAR_RANGE(1700000, 15, 31, 100000), |
|---|
| 25 | 19 | }; |
|---|
| .. | .. |
|---|
| 36 | 30 | |
|---|
| 37 | 31 | static unsigned int wm8400_dcdc_get_mode(struct regulator_dev *dev) |
|---|
| 38 | 32 | { |
|---|
| 39 | | - struct wm8400 *wm8400 = rdev_get_drvdata(dev); |
|---|
| 33 | + struct regmap *rmap = rdev_get_regmap(dev); |
|---|
| 40 | 34 | int offset = (rdev_get_id(dev) - WM8400_DCDC1) * 2; |
|---|
| 41 | 35 | u16 data[2]; |
|---|
| 42 | 36 | int ret; |
|---|
| 43 | 37 | |
|---|
| 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); |
|---|
| 46 | 39 | if (ret != 0) |
|---|
| 47 | 40 | return 0; |
|---|
| 48 | 41 | |
|---|
| .. | .. |
|---|
| 63 | 56 | |
|---|
| 64 | 57 | static int wm8400_dcdc_set_mode(struct regulator_dev *dev, unsigned int mode) |
|---|
| 65 | 58 | { |
|---|
| 66 | | - struct wm8400 *wm8400 = rdev_get_drvdata(dev); |
|---|
| 59 | + struct regmap *rmap = rdev_get_regmap(dev); |
|---|
| 67 | 60 | int offset = (rdev_get_id(dev) - WM8400_DCDC1) * 2; |
|---|
| 68 | 61 | int ret; |
|---|
| 69 | 62 | |
|---|
| 70 | 63 | switch (mode) { |
|---|
| 71 | 64 | case REGULATOR_MODE_FAST: |
|---|
| 72 | 65 | /* 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, |
|---|
| 74 | 67 | WM8400_DC1_FRC_PWM, WM8400_DC1_FRC_PWM); |
|---|
| 75 | 68 | if (ret != 0) |
|---|
| 76 | 69 | return ret; |
|---|
| 77 | 70 | |
|---|
| 78 | | - return wm8400_set_bits(wm8400, WM8400_DCDC1_CONTROL_1 + offset, |
|---|
| 71 | + return regmap_update_bits(rmap, WM8400_DCDC1_CONTROL_1 + offset, |
|---|
| 79 | 72 | WM8400_DC1_ACTIVE | WM8400_DC1_SLEEP, |
|---|
| 80 | 73 | WM8400_DC1_ACTIVE); |
|---|
| 81 | 74 | |
|---|
| 82 | 75 | case REGULATOR_MODE_NORMAL: |
|---|
| 83 | 76 | /* Datasheet: active */ |
|---|
| 84 | | - ret = wm8400_set_bits(wm8400, WM8400_DCDC1_CONTROL_2 + offset, |
|---|
| 77 | + ret = regmap_update_bits(rmap, WM8400_DCDC1_CONTROL_2 + offset, |
|---|
| 85 | 78 | WM8400_DC1_FRC_PWM, 0); |
|---|
| 86 | 79 | if (ret != 0) |
|---|
| 87 | 80 | return ret; |
|---|
| 88 | 81 | |
|---|
| 89 | | - return wm8400_set_bits(wm8400, WM8400_DCDC1_CONTROL_1 + offset, |
|---|
| 82 | + return regmap_update_bits(rmap, WM8400_DCDC1_CONTROL_1 + offset, |
|---|
| 90 | 83 | WM8400_DC1_ACTIVE | WM8400_DC1_SLEEP, |
|---|
| 91 | 84 | WM8400_DC1_ACTIVE); |
|---|
| 92 | 85 | |
|---|
| 93 | 86 | case REGULATOR_MODE_IDLE: |
|---|
| 94 | 87 | /* Datasheet: standby */ |
|---|
| 95 | | - return wm8400_set_bits(wm8400, WM8400_DCDC1_CONTROL_1 + offset, |
|---|
| 88 | + return regmap_update_bits(rmap, WM8400_DCDC1_CONTROL_1 + offset, |
|---|
| 96 | 89 | WM8400_DC1_ACTIVE | WM8400_DC1_SLEEP, 0); |
|---|
| 97 | 90 | default: |
|---|
| 98 | 91 | return -EINVAL; |
|---|
| .. | .. |
|---|
| 195 | 188 | .id = WM8400_DCDC2, |
|---|
| 196 | 189 | .ops = &wm8400_dcdc_ops, |
|---|
| 197 | 190 | .enable_reg = WM8400_DCDC2_CONTROL_1, |
|---|
| 198 | | - .enable_mask = WM8400_DC1_ENA_MASK, |
|---|
| 191 | + .enable_mask = WM8400_DC2_ENA_MASK, |
|---|
| 199 | 192 | .n_voltages = WM8400_DC2_VSEL_MASK + 1, |
|---|
| 200 | 193 | .vsel_reg = WM8400_DCDC2_CONTROL_1, |
|---|
| 201 | 194 | .vsel_mask = WM8400_DC2_VSEL_MASK, |
|---|
| .. | .. |
|---|
| 241 | 234 | * the regulator API. It is intended to be called from the |
|---|
| 242 | 235 | * platform_init() callback of the WM8400 MFD driver. |
|---|
| 243 | 236 | * |
|---|
| 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. |
|---|
| 247 | 240 | */ |
|---|
| 248 | 241 | int wm8400_register_regulator(struct device *dev, int reg, |
|---|
| 249 | 242 | struct regulator_init_data *initdata) |
|---|