regulator: mt6397: Implement of_map_mode regulator_desc function
v2 cover regulator: mt6397: Implement of_map_mode regulator_desc function
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
Signature · 1 line
2.27.0.212.ge8ba1cc988-goog
PATCH v2 1/4 regulator: mt6397: Move buck modes into header file
This will allow device trees to make use of these constants.
---
Changes in v2: None
drivers/regulator/mt6397-regulator.c | 4 +--- .../regulator/mediatek,mt6397-regulator.h | 15 +++++++++++++++ 2 files changed, 16 insertions(+), 3 deletions(-) create mode 100644 include/dt-bindings/regulator/mediatek,mt6397-regulator.h
drivers/regulator/mt6397-regulator.c +1 -3
@@ -13,9 +13,7 @@#include <linux/regulator/machine.h> #include <linux/regulator/mt6397-regulator.h> #include <linux/regulator/of_regulator.h> - -#define MT6397_BUCK_MODE_AUTO 0 -#define MT6397_BUCK_MODE_FORCE_PWM 1 +#include <dt-bindings/regulator/mediatek,mt6397-regulator.h> /* * MT6397 regulators' information
include/dt-bindings/regulator/mediatek,mt6397-regulator.h new file +15 -0
@@ -0,0 +1,15 @@ +/* SPDX-License-Identifier: GPL-2.0 */ + +#ifndef _DT_BINDINGS_REGULATOR_MEDIATEK_MT6397_H_ +#define _DT_BINDINGS_REGULATOR_MEDIATEK_MT6397_H_ + +/* +* Buck mode constants which may be used in devicetree properties (eg. +* regulator-initial-mode, regulator-allowed-modes). +* See the manufacturer's datasheet for more information on these modes. +*/ + +#define MT6397_BUCK_MODE_AUTO 0 +#define MT6397_BUCK_MODE_FORCE_PWM 1 + +#endif
Signature · 1 line
2.27.0.212.ge8ba1cc988-goog
PATCH v2 2/4 dt-bindings: regulator: mt6397: Document valid modes
In reply to Anand K MistryDocument valid mode values for BUCK regulators.
---
Changes in v2: None
.../devicetree/bindings/regulator/mt6397-regulator.txt | 3 +++ 1 file changed, 3 insertions(+)
Documentation/devicetree/bindings/regulator/mt6397-regulator.txt +3 -0
@@ -16,6 +16,9 @@ LDO: ldo_vemc3v3, ldo_vgp1, ldo_vgp2, ldo_vgp3, ldo_vgp4, ldo_vgp5, ldo_vgp6, ldo_vibr +BUCK regulators can set regulator-initial-mode and regulator-allowed-modes to +values specified in dt-bindings/regulator/mediatek,mt6397-regulator.h + Example: pmic { compatible = "mediatek,mt6397";
Signature · 1 line
2.27.0.212.ge8ba1cc988-goog
PATCH v2 3/4 regulator: mt6397: Implement of_map_mode
In reply to Anand K MistryImplementing of_map_mode is necessary to be able to specify operating modes in the devicetree using 'regulator-allowed-modes', and to change regulator modes.
---
Changes in v2: None
drivers/regulator/mt6397-regulator.c | 13 +++++++++++++ 1 file changed, 13 insertions(+)
drivers/regulator/mt6397-regulator.c +13 -0
@@ -53,6 +53,7 @@ struct mt6397_regulator_info { .vsel_mask = vosel_mask, \ .enable_reg = enreg, \ .enable_mask = BIT(0), \ + .of_map_mode = mt6397_map_mode, \ }, \ .qi = BIT(13), \ .vselon_reg = voselon, \
@@ -144,6 +145,18 @@ static const unsigned int ldo_volt_table7[] = { 1300000, 1500000, 1800000, 2000000, 2500000, 2800000, 3000000, 3300000, }; +static unsigned int mt6397_map_mode (unsigned int mode) +{ +switch (mode) { +case MT6397_BUCK_MODE_AUTO : +return REGULATOR_MODE_NORMAL ; +case MT6397_BUCK_MODE_FORCE_PWM : +return REGULATOR_MODE_FAST ; +default : +return REGULATOR_MODE_INVALID ; + } +} +static int mt6397_regulator_set_mode (struct regulator_dev *rdev,unsigned int mode) {
Signature · 1 line
2.27.0.212.ge8ba1cc988-goog
PATCH v2 4/4 arm64: dts: mediatek: Update allowed mt6397 regulator modes for elm boards
In reply to Anand K MistryThis updates the allowed mt6397 regulator modes for elm (and derivative) boards to use named constants.
---
Changes in v2:
- Introduce constants in dt-bindings
- Improve conditional readability
arch/arm64/boot/dts/mediatek/mt8173-elm.dtsi | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
arch/arm64/boot/dts/mediatek/mt8173-elm.dtsi +3 -1
@@ -6,6 +6,7 @@ #include <dt-bindings/input/input.h> #include <dt-bindings/input/linux-event-codes.h> #include <dt-bindings/gpio/gpio.h> +#include <dt-bindings/regulator/mediatek,mt6397-regulator.h> #include "mt8173.dtsi" / {
@@ -926,7 +927,8 @@ mt6397_vpca15_reg: buck_vpca15 { regulator-max-microvolt = <1350000>; regulator-ramp-delay = <12500>; regulator-always-on; - regulator-allowed-modes = <0 1>; + regulator-allowed-modes = <MT6397_BUCK_MODE_AUTO + MT6397_BUCK_MODE_FORCE_PWM>; }; mt6397_vpca7_reg: buck_vpca7 {
Signature · 1 line
2.27.0.212.ge8ba1cc988-goog
Mark Brown
maintainerQuoted 11 lines · Anand K Mistry
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_modeimplementation, 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[...]
Applied to
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/regulator.git for-next
Thanks!
[1/3] regulator: mt6397: Move buck modes into header file
commit: 1c537b2d729698717f01fcea13721818be5adde7
[2/3] regulator: mt6397: Document valid modes
commit: 347f12d573412cb7ba4781b58f42f0ca7eecde6d
[3/3] regulator: mt6397: Implement of_map_mode
commit: 8096236db4349c43a2b19b8ceb11b0b997354223All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.
You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.
If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.
Please add any relevant lists and maintainers to the CCs when replying to this mail.
Thanks,
Mark