Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge series "regulator: da9211: support changing modes" from Anand K Mistry <amistry@google.com>:

This patchset adds support for being able to change regulator modes for
the da9211 regulator. This is needed to allow the voltage scaling
support in the MT8173 SoC to be used in the elm (Acer Chromebook R13)
and hana (several Lenovo Chromebooks) devices.

Anand K Mistry (4):
regulator: da9211: Move buck modes into header file
dt-bindings: regulator: da9211: Document allowed modes
regulator: da9211: Implement of_map_mode
arm64: dts: mediatek: Update allowed regulator modes for elm boards

.../devicetree/bindings/regulator/da9211.txt | 4 +++
arch/arm64/boot/dts/mediatek/mt8173-elm.dtsi | 4 ++-
drivers/regulator/da9211-regulator.c | 30 +++++++++++++++----
.../regulator/dlg,da9211-regulator.h | 16 ++++++++++
4 files changed, 47 insertions(+), 7 deletions(-)
create mode 100644 include/dt-bindings/regulator/dlg,da9211-regulator.h

--
2.27.0.212.ge8ba1cc988-goog

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

+44 -6
+4
Documentation/devicetree/bindings/regulator/da9211.txt
··· 15 15 Optional properties: 16 16 - enable-gpios: platform gpio for control of BUCKA/BUCKB. 17 17 - Any optional property defined in regulator.txt 18 + - regulator-initial-mode and regulator-allowed-modes may be specified using 19 + mode values from dt-bindings/regulator/dlg,da9211-regulator.h 18 20 19 21 Example 1) DA9211 20 22 pmic: da9211@68 { ··· 32 30 regulator-min-microamp = <2000000>; 33 31 regulator-max-microamp = <5000000>; 34 32 enable-gpios = <&gpio 27 0>; 33 + regulator-allowed-modes = <DA9211_BUCK_MODE_SYNC 34 + DA9211_BUCK_MODE_AUTO>; 35 35 }; 36 36 }; 37 37 };
+24 -6
drivers/regulator/da9211-regulator.c
··· 17 17 #include <linux/gpio/consumer.h> 18 18 #include <linux/regulator/of_regulator.h> 19 19 #include <linux/regulator/da9211.h> 20 + #include <dt-bindings/regulator/dlg,da9211-regulator.h> 20 21 #include "da9211-regulator.h" 21 22 22 23 /* DEVICE IDs */ 23 24 #define DA9211_DEVICE_ID 0x22 24 25 #define DA9213_DEVICE_ID 0x23 25 26 #define DA9215_DEVICE_ID 0x24 26 - 27 - #define DA9211_BUCK_MODE_SLEEP 1 28 - #define DA9211_BUCK_MODE_SYNC 2 29 - #define DA9211_BUCK_MODE_AUTO 3 30 27 31 28 /* DA9211 REGULATOR IDs */ 32 29 #define DA9211_ID_BUCKA 0 ··· 85 88 4000000, 4200000, 4400000, 4600000, 4800000, 5000000, 5200000, 5400000, 86 89 5600000, 5800000, 6000000, 6200000, 6400000, 6600000, 6800000, 7000000 87 90 }; 91 + 92 + static unsigned int da9211_map_buck_mode(unsigned int mode) 93 + { 94 + switch (mode) { 95 + case DA9211_BUCK_MODE_SLEEP: 96 + return REGULATOR_MODE_STANDBY; 97 + case DA9211_BUCK_MODE_SYNC: 98 + return REGULATOR_MODE_FAST; 99 + case DA9211_BUCK_MODE_AUTO: 100 + return REGULATOR_MODE_NORMAL; 101 + default: 102 + return REGULATOR_MODE_INVALID; 103 + } 104 + } 88 105 89 106 static unsigned int da9211_buck_get_mode(struct regulator_dev *rdev) 90 107 { ··· 247 236 .vsel_reg = DA9211_REG_VBUCKA_A + DA9211_ID_##_id * 2,\ 248 237 .vsel_mask = DA9211_VBUCK_MASK,\ 249 238 .owner = THIS_MODULE,\ 239 + .of_map_mode = da9211_map_buck_mode,\ 250 240 } 251 241 252 242 static struct regulator_desc da9211_regulators[] = { ··· 257 245 258 246 #ifdef CONFIG_OF 259 247 static struct of_regulator_match da9211_matches[] = { 260 - [DA9211_ID_BUCKA] = { .name = "BUCKA" }, 261 - [DA9211_ID_BUCKB] = { .name = "BUCKB" }, 248 + [DA9211_ID_BUCKA] = { 249 + .name = "BUCKA", 250 + .desc = &da9211_regulators[DA9211_ID_BUCKA], 251 + }, 252 + [DA9211_ID_BUCKB] = { 253 + .name = "BUCKB", 254 + .desc = &da9211_regulators[DA9211_ID_BUCKB], 255 + }, 262 256 }; 263 257 264 258 static struct da9211_pdata *da9211_parse_regulators_dt(
+16
include/dt-bindings/regulator/dlg,da9211-regulator.h
··· 1 + /* SPDX-License-Identifier: GPL-2.0 */ 2 + 3 + #ifndef _DT_BINDINGS_REGULATOR_DLG_DA9211_H 4 + #define _DT_BINDINGS_REGULATOR_DLG_DA9211_H 5 + 6 + /* 7 + * These buck mode constants may be used to specify values in device tree 8 + * properties (e.g. regulator-initial-mode, regulator-allowed-modes). 9 + * A description of the following modes is in the manufacturers datasheet. 10 + */ 11 + 12 + #define DA9211_BUCK_MODE_SLEEP 1 13 + #define DA9211_BUCK_MODE_SYNC 2 14 + #define DA9211_BUCK_MODE_AUTO 3 15 + 16 + #endif