regulator: rtmv20: Adds support for Richtek RTMV20 load switch regulator
Subsystems (2)
PATCH v2 1/2 regulator: rtmv20: Adds support for Richtek RTMV20 load switch regulator
From: ChiYuan Huang <[email protected]>
Add support for Richtek RTMV20 load switch regulator.
---
v1 to v2
1. Use regcache related APIs when HW disable and enable.
2. Because of regcache, refine the initial properties flow.
3. Change all propertiy name to use dash, not underline.
4. Re-check all the comment lines not to over 80 characters.
5. Same as item 3, and also change all 0/1 properties to boolean type in dt-binding document.
6. No need is_chip_enabled flag.
--- drivers/regulator/Kconfig | 9 + drivers/regulator/Makefile | 1 + drivers/regulator/rtmv20-regulator.c | 392 +++++++++++++++++++++++++++++++++++ 3 files changed, 402 insertions(+) create mode 100644 drivers/regulator/rtmv20-regulator.c
drivers/regulator/Kconfig +9 -0
@@ -902,6 +902,15 @@ config REGULATOR_RT5033 RT5033 PMIC. The device supports multiple regulators like current source, LDO and Buck. +config REGULATOR_RTMV20 + tristate "RTMV20 Laser Diode Regulator" + depends on I2C + select REGMAP_I2C + help + This driver adds support for the load switch current regulator on + the Richtek RTMV20. It can support the load current up to 6A and + integrate strobe/vsync/fsin signal to synchronize the IR camera. + config REGULATOR_S2MPA01 tristate "Samsung S2MPA01 voltage regulator" depends on MFD_SEC_CORE
drivers/regulator/Makefile +1 -0
@@ -112,6 +112,7 @@ obj-$(CONFIG_REGULATOR_RK808) += rk808-regulator.o obj-$(CONFIG_REGULATOR_RN5T618) += rn5t618-regulator.o obj-$(CONFIG_REGULATOR_ROHM) += rohm-regulator.o obj-$(CONFIG_REGULATOR_RT5033) += rt5033-regulator.o +obj-$(CONFIG_REGULATOR_RTMV20) += rtmv20-regulator.o obj-$(CONFIG_REGULATOR_S2MPA01) += s2mpa01.o obj-$(CONFIG_REGULATOR_S2MPS11) += s2mps11.o obj-$(CONFIG_REGULATOR_S5M8767) += s5m8767.o
drivers/regulator/rtmv20-regulator.c new file +392 -0
392 lines not on this page · raw message
Signature · 1 line
2.7.4
PATCH v2 2/2 regulator: rtmv20: Add DT-binding document for Richtek RTMV20
From: ChiYuan Huang <[email protected]>
Add DT-binding document for Richtek RTMV20
--- .../regulator/richtek,rtmv20-regulator.yaml | 168 +++++++++++++++++++++ 1 file changed, 168 insertions(+) create mode 100644 Documentation/devicetree/bindings/regulator/richtek,rtmv20-regulator.yaml
Documentation/devicetree/bindings/regulator/richtek,rtmv20-regulator.yaml new file +168 -0
@@ -0,0 +1,168 @@ +# SPDX-License-Identifier: GPL-2.0 +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/regulator/richtek,rtmv20-regulator.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Richtek RTMV20 laser diode regulator + +maintainers: + - ChiYuan Huang <[email protected]> + +description: | + Richtek RTMV20 is a load switch current regulator that can supply up to 6A. + It is used to drive laser diode. There're two signals for chip controls + (Enable/Fail), Enable pin to turn chip on, and Fail pin as fault indication. + There're still four pins for camera control, two inputs (strobe and vsync), + the others for outputs (fsin1 and fsin2). Strobe input to start the current + supply, vsync input from IR camera, and fsin1/fsin2 output for the optional. + +properties: + compatible: + const: richtek,rtmv20 + + reg: + maxItems: 1 + + wakeup-source: true + + interrupts-extend: + maxItems: 1 + + enable-gpios: + description: A connection of the 'enable' gpio line. + maxItems: 1 + + ld-pulse-delay-us: + description: | + load current pulse delay in microsecond after strobe pin pulse high. + $ref: "/schemas/types.yaml#/definitions/uint32" + minimum: 0 + maximum: 100000 + default: 0 + + ld-pulse-width-us: + description: | + Load current pulse width in microsecond after strobe pin pulse high. + $ref: "/schemas/types.yaml#/definitions/uint32" + minimum: 0 + maximum: 10000 + default: 1200 + + fsin1-delay-us: + description: | + Fsin1 pulse high delay in microsecond after vsync signal pulse high. + $ref: "/schemas/types.yaml#/definitions/uint32" + minimum: 0 + maximum: 100000 + default: 23000 + + fsin1-width-us: + description: | + Fsin1 pulse high width in microsecond after vsync signal pulse high. + $ref: "/schemas/types.yaml#/definitions/uint32" + minimum: 40 + maximum: 10000 + default: 160 + + fsin2-delay-us: + description: | + Fsin2 pulse high delay in microsecond after vsync signal pulse high. + $ref: "/schemas/types.yaml#/definitions/uint32" + minimum: 0 + maximum: 100000 + default: 23000 + + fsin2-width-us: + description: | + Fsin2 pulse high width in microsecond after vsync signal pulse high. + $ref: "/schemas/types.yaml#/definitions/uint32" + minimum: 40 + maximum: 10000 + default: 160 + + es-pulse-width-us: + description: Eye safety function pulse width limit in microsecond. + $ref: "/schemas/types.yaml#/definitions/uint32" + minimum: 0 + maximum: 10000 + default: 1200 + + es-ld-current-microamp: + description: Eye safety function load current limit in microamp. + $ref: "/schemas/types.yaml#/definitions/uint32" + minimum: 0 + maximum: 6000000 + default: 3000000 + + lbp-level-microvolt: + description: Low battery protection level in microvolt. + $ref: "/schemas/types.yaml#/definitions/uint32" + minimum: 2400000 + maximum: 3700000 + default: 2700000 + + lbp-enable: + description: Low battery protection function enable control. + type: boolean + + strobe-polarity-high: + description: Strobe pin active polarity control. + type: boolean + + vsync-polarity-high: + description: Vsync pin active polarity control. + type: boolean + + fsin-enable: + description: Fsin function enable control. + type: boolean + + fsin-output: + description: Fsin function output control. + type: boolean + + es-enable: + description: Eye safety function enable control. + type: boolean + +patternProperties: + "lsw": + type: object + $ref: "regulator.yaml#" + +required: + - compatible + - reg + - wakeup-source + - interrupts-extend + - enable-gpios + - lsw + +additionalProperties: false + +examples: + - | + #include <dt-bindings/interrupt-controller/irq.h> + i2c { + #address-cells = <1>; + #size-cells = <0>; + + rtmv20@34 { + compatible = "richtek,rtmv20"; + reg = <0x34>; + wakeup-source; + interrupts-extend = <&gpio26 2 IRQ_TYPE_LEVEL_LOW>; + enable-gpios = <&gpio26 3 0>; + + strobe-polarity-high; + vsync-polarity-high; + + lsw { + regulator-name = "rtmv20,lsw"; + regulator-min-microamp = <0>; + regulator-max-microamp = <6000000>; + }; + }; + }; +...
Signature · 1 line
2.7.4
Rob Herring
maintainerRe: [PATCH v2 2/2] regulator: rtmv20: Add DT-binding document for Richtek RTMV20
Quoted 35 lines · cy_huang
From: ChiYuan Huang <[email protected]>
Add DT-binding document for Richtek RTMV20
Signed-off-by ChiYuan Huang <[email protected]>--- .../regulator/richtek,rtmv20-regulator.yaml | 168 +++++++++++++++++++++ 1 file changed, 168 insertions(+) create mode 100644 Documentation/devicetree/bindings/regulator/richtek,rtmv20-regulator.yamlDocumentation/devicetree/bindings/regulator/richtek,rtmv20-regulator.yaml new file +19
-0@@ -0,0 +1,168 @@ +# SPDX-License-Identifier: GPL-2.0 +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/regulator/richtek,rtmv20-regulator.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Richtek RTMV20 laser diode regulator + +maintainers: + - ChiYuan Huang <[email protected]> + +description: | + Richtek RTMV20 is a load switch current regulator that can supply up to 6A. + It is used to drive laser diode. There're two signals for chip controls + (Enable/Fail), Enable pin to turn chip on, and Fail pin as fault indication. + There're still four pins for camera control, two inputs (strobe and vsync), + the others for outputs (fsin1 and fsin2). Strobe input to start the current + supply, vsync input from IR camera, and fsin1/fsin2 output for the optional. +
Documentation/devicetree/bindings/regulator/richtek,rtmv20-regulator.yaml line 29
Quoted 10 lines
Documentation/devicetree/bindings/regulator/richtek,rtmv20-regulator.yaml new file +10
-0+properties: + compatible: + const: richtek,rtmv20 + + reg: + maxItems: 1 + + wakeup-source: true + + interrupts-extend:
You mean interrupts-extended?
In any case, use 'interrupts' here and the tooling allows for either.
Documentation/devicetree/bindings/regulator/richtek,rtmv20-regulator.yaml line 39
Quoted 10 lines
Documentation/devicetree/bindings/regulator/richtek,rtmv20-regulator.yaml new file +10
-0+ maxItems: 1 + + enable-gpios: + description: A connection of the 'enable' gpio line. + maxItems: 1 + + ld-pulse-delay-us: + description: | + load current pulse delay in microsecond after strobe pin pulse high. + $ref: "/schemas/types.yaml#/definitions/uint32"
Don't need a type ref when you have a standard property unit suffix, so drop.
This and all the following need a vendor prefix too.
Quoted 81 lines
Documentation/devicetree/bindings/regulator/richtek,rtmv20-regulator.yaml new file +81
-0+ minimum: 0 + maximum: 100000 + default: 0 + + ld-pulse-width-us: + description: | + Load current pulse width in microsecond after strobe pin pulse high. + $ref: "/schemas/types.yaml#/definitions/uint32" + minimum: 0 + maximum: 10000 + default: 1200 + + fsin1-delay-us: + description: | + Fsin1 pulse high delay in microsecond after vsync signal pulse high. + $ref: "/schemas/types.yaml#/definitions/uint32" + minimum: 0 + maximum: 100000 + default: 23000 + + fsin1-width-us: + description: | + Fsin1 pulse high width in microsecond after vsync signal pulse high. + $ref: "/schemas/types.yaml#/definitions/uint32" + minimum: 40 + maximum: 10000 + default: 160 + + fsin2-delay-us: + description: | + Fsin2 pulse high delay in microsecond after vsync signal pulse high. + $ref: "/schemas/types.yaml#/definitions/uint32" + minimum: 0 + maximum: 100000 + default: 23000 + + fsin2-width-us: + description: | + Fsin2 pulse high width in microsecond after vsync signal pulse high. + $ref: "/schemas/types.yaml#/definitions/uint32" + minimum: 40 + maximum: 10000 + default: 160 + + es-pulse-width-us: + description: Eye safety function pulse width limit in microsecond. + $ref: "/schemas/types.yaml#/definitions/uint32" + minimum: 0 + maximum: 10000 + default: 1200 + + es-ld-current-microamp: + description: Eye safety function load current limit in microamp. + $ref: "/schemas/types.yaml#/definitions/uint32" + minimum: 0 + maximum: 6000000 + default: 3000000 + + lbp-level-microvolt: + description: Low battery protection level in microvolt. + $ref: "/schemas/types.yaml#/definitions/uint32" + minimum: 2400000 + maximum: 3700000 + default: 2700000 + + lbp-enable: + description: Low battery protection function enable control. + type: boolean + + strobe-polarity-high: + description: Strobe pin active polarity control. + type: boolean + + vsync-polarity-high: + description: Vsync pin active polarity control. + type: boolean + + fsin-enable: + description: Fsin function enable control. + type: boolean +
Documentation/devicetree/bindings/regulator/richtek,rtmv20-regulator.yaml line 130
Quoted 10 lines
Documentation/devicetree/bindings/regulator/richtek,rtmv20-regulator.yaml new file +10
-0+ fsin-output: + description: Fsin function output control. + type: boolean + + es-enable: + description: Eye safety function enable control. + type: boolean + +patternProperties: + "lsw":
This matches ".*lsw.*". What you wanted? If just 'lsw', then it's not a pattern.
Quoted 15 lines
Documentation/devicetree/bindings/regulator/richtek,rtmv20-regulator.yaml new file +15
-0+ type: object + $ref: "regulator.yaml#" + +required: + - compatible + - reg + - wakeup-source + - interrupts-extend + - enable-gpios + - lsw + +additionalProperties: false + +examples: + - |
Documentation/devicetree/bindings/regulator/richtek,rtmv20-regulator.yaml line 155
Quoted 10 lines
Documentation/devicetree/bindings/regulator/richtek,rtmv20-regulator.yaml new file +10
-0+ #include <dt-bindings/interrupt-controller/irq.h> + i2c { + #address-cells = <1>; + #size-cells = <0>; + + rtmv20@34 { + compatible = "richtek,rtmv20"; + reg = <0x34>; + wakeup-source; + interrupts-extend = <&gpio26 2 IRQ_TYPE_LEVEL_LOW>;
2 wrongs make a right... But your driver interrupt probably doesn't work too well.
Quoted 16 lines
Documentation/devicetree/bindings/regulator/richtek,rtmv20-regulator.yaml new file +13
-0+ enable-gpios = <&gpio26 3 0>; + + strobe-polarity-high; + vsync-polarity-high; + + lsw { + regulator-name = "rtmv20,lsw"; + regulator-min-microamp = <0>; + regulator-max-microamp = <6000000>; + }; + }; + }; +...Signature · 1 line
2.7.4
Re: [PATCH v2 2/2] regulator: rtmv20: Add DT-binding document for Richtek RTMV20
Hi, Rob
Ack is in below comments.
Hi, Mark:
Due to that already merged into your regulator for-next git, may I
send the patch to fix Rob's comment?
And I also found one line need to be added into rtmv20 probe phase. Please check below.
/*
* keep in shutdown mode to minimize the current consumption
* and also mark regcache as dirty
*/
+ regcache_cache_only(priv->regmap, true);
regcache_mark_dirty(priv->regmap);
gpiod_set_value(priv->enable_gpio, 0);Can I directly merge into one that includes Rob's comment and the above line to be added?
Rob Herring <[email protected]> 於 2020年9月29日 週二 下午11:06寫道:
Quoted 50 lines · cy_huang
Quoted 35 lines
From: ChiYuan Huang <[email protected]>
Add DT-binding document for Richtek RTMV20
Signed-off-by ChiYuan Huang <[email protected]>--- .../regulator/richtek,rtmv20-regulator.yaml | 168 +++++++++++++++++++++ 1 file changed, 168 insertions(+) create mode 100644 Documentation/devicetree/bindings/regulator/richtek,rtmv20-regulator.yamlDocumentation/devicetree/bindings/regulator/richtek,rtmv20-regulator.yaml new file +19
-0@@ -0,0 +1,168 @@ +# SPDX-License-Identifier: GPL-2.0 +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/regulator/richtek,rtmv20-regulator.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Richtek RTMV20 laser diode regulator + +maintainers: + - ChiYuan Huang <[email protected]> + +description: | + Richtek RTMV20 is a load switch current regulator that can supply up to 6A. + It is used to drive laser diode. There're two signals for chip controls + (Enable/Fail), Enable pin to turn chip on, and Fail pin as fault indication. + There're still four pins for camera control, two inputs (strobe and vsync), + the others for outputs (fsin1 and fsin2). Strobe input to start the current + supply, vsync input from IR camera, and fsin1/fsin2 output for the optional. +Documentation/devicetree/bindings/regulator/richtek,rtmv20-regulator.yaml line 29
Quoted 10 lines
Documentation/devicetree/bindings/regulator/richtek,rtmv20-regulator.yaml new file +10
-0+properties: + compatible: + const: richtek,rtmv20 + + reg: + maxItems: 1 + + wakeup-source: true + + interrupts-extend:You mean interrupts-extended?
Quoted 1 line
In any case, use 'interrupts' here and the tooling allows for either.
Yes, you're righ.
Sorry, I key in the yaml file, line by line.
It's really a typo.
Quoted 14 lines
Documentation/devicetree/bindings/regulator/richtek,rtmv20-regulator.yaml line 39
Quoted 11 lines
Documentation/devicetree/bindings/regulator/richtek,rtmv20-regulator.yaml new file +10
-0+ maxItems: 1 + + enable-gpios: + description: A connection of the 'enable' gpio line. + maxItems: 1 + + ld-pulse-delay-us: + description: | + load current pulse delay in microsecond after strobe pin pulse high. + $ref: "/schemas/types.yaml#/definitions/uint32"Don't need a type ref when you have a standard property unit suffix, so drop.
Ack, remove type ref for all properties that included unit suffix.
Quoted 2 lines
This and all the following need a vendor prefix too.
Is it okay to Add "richtek," prefix for all the properties except lsw regulator node?
Quoted 87 lines
Quoted 87 lines
Documentation/devicetree/bindings/regulator/richtek,rtmv20-regulator.yaml new file +86
-0+ minimum: 0 + maximum: 100000 + default: 0 + + ld-pulse-width-us: + description: | + Load current pulse width in microsecond after strobe pin pulse high. + $ref: "/schemas/types.yaml#/definitions/uint32" + minimum: 0 + maximum: 10000 + default: 1200 + + fsin1-delay-us: + description: | + Fsin1 pulse high delay in microsecond after vsync signal pulse high. + $ref: "/schemas/types.yaml#/definitions/uint32" + minimum: 0 + maximum: 100000 + default: 23000 + + fsin1-width-us: + description: | + Fsin1 pulse high width in microsecond after vsync signal pulse high. + $ref: "/schemas/types.yaml#/definitions/uint32" + minimum: 40 + maximum: 10000 + default: 160 + + fsin2-delay-us: + description: | + Fsin2 pulse high delay in microsecond after vsync signal pulse high. + $ref: "/schemas/types.yaml#/definitions/uint32" + minimum: 0 + maximum: 100000 + default: 23000 + + fsin2-width-us: + description: | + Fsin2 pulse high width in microsecond after vsync signal pulse high. + $ref: "/schemas/types.yaml#/definitions/uint32" + minimum: 40 + maximum: 10000 + default: 160 + + es-pulse-width-us: + description: Eye safety function pulse width limit in microsecond. + $ref: "/schemas/types.yaml#/definitions/uint32" + minimum: 0 + maximum: 10000 + default: 1200 + + es-ld-current-microamp: + description: Eye safety function load current limit in microamp. + $ref: "/schemas/types.yaml#/definitions/uint32" + minimum: 0 + maximum: 6000000 + default: 3000000 + + lbp-level-microvolt: + description: Low battery protection level in microvolt. + $ref: "/schemas/types.yaml#/definitions/uint32" + minimum: 2400000 + maximum: 3700000 + default: 2700000 + + lbp-enable: + description: Low battery protection function enable control. + type: boolean + + strobe-polarity-high: + description: Strobe pin active polarity control. + type: boolean + + vsync-polarity-high: + description: Vsync pin active polarity control. + type: boolean + + fsin-enable: + description: Fsin function enable control. + type: boolean + + fsin-output: + description: Fsin function output control. + type: boolean + + es-enable:
Quoted 9 lines
Documentation/devicetree/bindings/regulator/richtek,rtmv20-regulator.yaml line 130
Quoted 5 lines
Documentation/devicetree/bindings/regulator/richtek,rtmv20-regulator.yaml new file +5
-0+ description: Eye safety function enable control. + type: boolean + +patternProperties: + "lsw":This matches ".*lsw.*". What you wanted? If just 'lsw', then it's not a pattern.
OK
Quoted 20 lines
Quoted 20 lines
Documentation/devicetree/bindings/regulator/richtek,rtmv20-regulator.yaml new file +20
-0+ type: object + $ref: "regulator.yaml#" + +required: + - compatible + - reg + - wakeup-source + - interrupts-extend + - enable-gpios + - lsw + +additionalProperties: false + +examples: + - | + #include <dt-bindings/interrupt-controller/irq.h> + i2c { + #address-cells = <1>; + #size-cells = <0>; +
Quoted 8 lines
Documentation/devicetree/bindings/regulator/richtek,rtmv20-regulator.yaml line 155
Quoted 5 lines
Documentation/devicetree/bindings/regulator/richtek,rtmv20-regulator.yaml new file +5
-0+ rtmv20@34 { + compatible = "richtek,rtmv20"; + reg = <0x34>; + wakeup-source; + interrupts-extend = <&gpio26 2 IRQ_TYPE_LEVEL_LOW>;2 wrongs make a right... But your driver interrupt probably doesn't work too well.
Yes, fix it right now.
Quoted 17 lines
Quoted 17 lines
Documentation/devicetree/bindings/regulator/richtek,rtmv20-regulator.yaml new file +13
-1+ enable-gpios = <&gpio26 3 0>; + + strobe-polarity-high; + vsync-polarity-high; + + lsw { + regulator-name = "rtmv20,lsw"; + regulator-min-microamp = <0>; + regulator-max-microamp = <6000000>; + }; + }; + }; +... --2.7.4
Mark Brown
maintainerRe: [PATCH v2 2/2] regulator: rtmv20: Add DT-binding document for Richtek RTMV20
Quoted 2 lines · ChiYuan Huang
Due to that already merged into your regulator for-next git, may I
send the patch to fix Rob's comment?
Of course, yes please.
Quoted 6 lines
And I also found one line need to be added into rtmv20 probe phase. Please check below.
/*
* keep in shutdown mode to minimize the current consumption
* and also mark regcache as dirty
*/
Quoted 6 lines
+ regcache_cache_only(priv->regmap, true); regcache_mark_dirty(priv->regmap); gpiod_set_value(priv->enable_gpio, 0);Can I directly merge into one that includes Rob's comment and the above line to be added?
Please make it a separate patch.
Re: [PATCH v2 2/2] regulator: rtmv20: Add DT-binding document for Richtek RTMV20
Mark Brown <[email protected]> 於 2020年9月30日 週三 下午5:43寫道:
Quoted 7 lines · ChiYuan Huang
Quoted 3 lines
Due to that already merged into your regulator for-next git, may I
send the patch to fix Rob's comment?Of course, yes please.
OK, Thx.
Quoted 11 lines
Quoted 11 lines
And I also found one line need to be added into rtmv20 probe phase. Please check below.
/*
* keep in shutdown mode to minimize the current consumption
* and also mark regcache as dirty
*/+ regcache_cache_only(priv->regmap, true); regcache_mark_dirty(priv->regmap); gpiod_set_value(priv->enable_gpio, 0);
Quoted 4 lines
Quoted 2 lines
Can I directly merge into one that includes Rob's comment and the above line to be added?
Please make it a separate patch.
I'll send the separate patch by next.
Mark Brown
maintainerQuoted 1 line · cy_huang
Add support for Richtek RTMV20 load switch regulator.
Applied to
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/regulator.git for-next
Thanks!
[1/2] regulator: rtmv20: Adds support for Richtek RTMV20 load switch regulator
commit: b8c054a5eaf0cf2b9532969e5168ce5e2d78c284
[2/2] regulator: rtmv20: Add DT-binding document for Richtek RTMV20
commit: 9f4366ec2c50dc478a06cb2cf0fadd3b38495650All 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