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

Merge series "regulator: mt6397: Implement of_map_mode regulator_desc function" from Anand K Mistry <amistry@google.com>:

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

Without a of_map_mode implementation, the regulator-allowed-modes
devicetree field is skipped, and attempting to change the regulator mode
results in an error:
[ 1.439165] vpca15: mode operation not allowed

Changes in v2:
- Introduce constants in dt-bindings
- Improve conditional readability

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

.../bindings/regulator/mt6397-regulator.txt | 3 +++
arch/arm64/boot/dts/mediatek/mt8173-elm.dtsi | 4 +++-
drivers/regulator/mt6397-regulator.c | 17 ++++++++++++++---
.../regulator/mediatek,mt6397-regulator.h | 15 +++++++++++++++
4 files changed, 35 insertions(+), 4 deletions(-)
create mode 100644 include/dt-bindings/regulator/mediatek,mt6397-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

+32 -3
+3
Documentation/devicetree/bindings/regulator/mt6397-regulator.txt
··· 16 16 ldo_vemc3v3, ldo_vgp1, ldo_vgp2, ldo_vgp3, ldo_vgp4, ldo_vgp5, ldo_vgp6, 17 17 ldo_vibr 18 18 19 + BUCK regulators can set regulator-initial-mode and regulator-allowed-modes to 20 + values specified in dt-bindings/regulator/mediatek,mt6397-regulator.h 21 + 19 22 Example: 20 23 pmic { 21 24 compatible = "mediatek,mt6397";
+14 -3
drivers/regulator/mt6397-regulator.c
··· 13 13 #include <linux/regulator/machine.h> 14 14 #include <linux/regulator/mt6397-regulator.h> 15 15 #include <linux/regulator/of_regulator.h> 16 - 17 - #define MT6397_BUCK_MODE_AUTO 0 18 - #define MT6397_BUCK_MODE_FORCE_PWM 1 16 + #include <dt-bindings/regulator/mediatek,mt6397-regulator.h> 19 17 20 18 /* 21 19 * MT6397 regulators' information ··· 53 55 .vsel_mask = vosel_mask, \ 54 56 .enable_reg = enreg, \ 55 57 .enable_mask = BIT(0), \ 58 + .of_map_mode = mt6397_map_mode, \ 56 59 }, \ 57 60 .qi = BIT(13), \ 58 61 .vselon_reg = voselon, \ ··· 144 145 static const unsigned int ldo_volt_table7[] = { 145 146 1300000, 1500000, 1800000, 2000000, 2500000, 2800000, 3000000, 3300000, 146 147 }; 148 + 149 + static unsigned int mt6397_map_mode(unsigned int mode) 150 + { 151 + switch (mode) { 152 + case MT6397_BUCK_MODE_AUTO: 153 + return REGULATOR_MODE_NORMAL; 154 + case MT6397_BUCK_MODE_FORCE_PWM: 155 + return REGULATOR_MODE_FAST; 156 + default: 157 + return REGULATOR_MODE_INVALID; 158 + } 159 + } 147 160 148 161 static int mt6397_regulator_set_mode(struct regulator_dev *rdev, 149 162 unsigned int mode)
+15
include/dt-bindings/regulator/mediatek,mt6397-regulator.h
··· 1 + /* SPDX-License-Identifier: GPL-2.0 */ 2 + 3 + #ifndef _DT_BINDINGS_REGULATOR_MEDIATEK_MT6397_H_ 4 + #define _DT_BINDINGS_REGULATOR_MEDIATEK_MT6397_H_ 5 + 6 + /* 7 + * Buck mode constants which may be used in devicetree properties (eg. 8 + * regulator-initial-mode, regulator-allowed-modes). 9 + * See the manufacturer's datasheet for more information on these modes. 10 + */ 11 + 12 + #define MT6397_BUCK_MODE_AUTO 0 13 + #define MT6397_BUCK_MODE_FORCE_PWM 1 14 + 15 + #endif