Support ROHM BD96801 scalable PMIC
Subsystems (5)
Matti Vaittinen
maintainerv2 cover Support ROHM BD96801 scalable PMIC
Support ROHM BD96801 "scalable" PMIC.
The ROHM BD96801 is automotive grade PMIC, intended to be usable in multiple solutions. The BD96801 can be used as a stand-alone, or together with separate 'companion PMICs'. This modular approach aims to make this PMIC suitable for various use-cases.
This is sent as an RFC because of the regulator features which can be configured only when the PMIC is in STBY state. This is described more detailed in the regulator patch.
Another "oddity" is that the PMIC has two physical IRQ lines. When using regmap IRQ to create own IRQ controller instance for both HWIRQs, there will be a naming collison in debugfs for the IRQ domains. As a work-around the MFD driver uses irq_domain_update_bus_token(intb_domain, DOMAIN_BUS_WIRED); to append '-1' at the end of the domain name.
Rest of the series ought to be business as usual.
Revision history:
RFCv1 => RFCv2:
- Tidying code based on feedback form Krzysztof Kozlowski and Lee Jones.
- Documented undocumented watchdog related DT properties.
- Added usage of the watchdog IRQ.
- Use irq_domain_update_bus_token() to work-around debugFS name collision for IRQ domains.
---
Matti Vaittinen (6):
dt-bindings: ROHM BD96801 PMIC regulators
dt-bindings: mfd: bd96801 PMIC core
mfd: support ROHM BD96801 PMIC core
regulator: bd96801: ROHM BD96801 PMIC regulators
watchdog: ROHM BD96801 PMIC WDG driver
MAINTAINERS: Add ROHM BD96801 'scalable PMIC' entries
.../bindings/mfd/rohm,bd96801-pmic.yaml | 171 ++ .../regulator/rohm,bd96801-regulator.yaml | 69 + MAINTAINERS | 4 + drivers/mfd/Kconfig | 13 + drivers/mfd/Makefile | 1 + drivers/mfd/rohm-bd96801.c | 476 ++++ drivers/regulator/Kconfig | 12 + drivers/regulator/Makefile | 2 + drivers/regulator/bd96801-regulator.c | 2114 +++++++++++++++++ drivers/watchdog/Kconfig | 13 + drivers/watchdog/Makefile | 1 + drivers/watchdog/bd96801_wdt.c | 389 +++ include/linux/mfd/rohm-bd96801.h | 211 ++ include/linux/mfd/rohm-generic.h | 1 + 14 files changed, 3477 insertions(+) create mode 100644 Documentation/devicetree/bindings/mfd/rohm,bd96801-pmic.yaml create mode 100644 Documentation/devicetree/bindings/regulator/rohm,bd96801-regulator.yaml create mode 100644 drivers/mfd/rohm-bd96801.c create mode 100644 drivers/regulator/bd96801-regulator.c create mode 100644 drivers/watchdog/bd96801_wdt.c create mode 100644 include/linux/mfd/rohm-bd96801.h
base-commit: 4cece764965020c22cff7665b18a012006359095
Signature · 14 lines
2.43.2 -- Matti Vaittinen, Linux device drivers ROHM Semiconductors, Finland SWDC Kiviharjunlenkki 1E 90220 OULU FINLAND ~~~ "I don't think so," said Rene Descartes. Just then he vanished ~~~ Simon says - in Latin please. ~~~ "non cogito me" dixit Rene Descarte, deinde evanescavit ~~~ Thanks to Simon Glass for the translation =]
Matti Vaittinen
maintainerRFC PATCH v2 1/6 dt-bindings: ROHM BD96801 PMIC regulators
ROHM BD96801 is a highly configurable automotive grade PMIC. Introduce DT bindings for the BD96801 regulators.
---
Revision history:
- No changes since RFCv1
.../regulator/rohm,bd96801-regulator.yaml | 69 +++++++++++++++++++ 1 file changed, 69 insertions(+) create mode 100644 Documentation/devicetree/bindings/regulator/rohm,bd96801-regulator.yaml
Documentation/devicetree/bindings/regulator/rohm,bd96801-regulator.yaml new file +69 -0
@@ -0,0 +1,69 @@ +# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/regulator/rohm,bd96801-regulator.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: ROHM BD96801 Power Management Integrated Circuit regulators + +maintainers: + - Matti Vaittinen <[email protected]> + +description: | + This module is part of the ROHM BD96801 MFD device. For more details + see Documentation/devicetree/bindings/mfd/rohm,bd96801-pmic.yaml. + + The regulator controller is represented as a sub-node of the PMIC node + on the device tree. + + Regulator nodes should be named to BUCK_<number> and LDO_<number>. + The valid names for BD96801 regulator nodes are + BUCK1, BUCK2, BUCK3, BUCK4, LDO5, LDO6, LDO7 + +patternProperties: + "^LDO[5-7]$": + type: object + description: + Properties for single LDO regulator. + $ref: regulator.yaml# + + properties: + regulator-name: + pattern: "^ldo[5-7]$" + description: + Name of the regulator. Should be "ldo5", ..., "ldo7" + rohm,initial-voltage-microvolt: + description: + Initial voltage for regulator. Voltage can be tuned +/-150 mV from + this value. NOTE, This can be modified via I2C only when PMIC is in + STBY state. + minimum: 300000 + maximum: 3300000 + + "^BUCK[1-4]$": + type: object + description: + Properties for single BUCK regulator. + $ref: regulator.yaml# + + properties: + regulator-name: + pattern: "^buck[1-4]$" + description: + should be "buck1", ..., "buck4" + rohm,initial-voltage-microvolt: + description: + Initial voltage for regulator. Voltage can be tuned +/-150 mV from + this value. NOTE, This can be modified via I2C only when PMIC is in + STBY state. + minimum: 500000 + maximum: 3300000 + rohm,keep-on-stby: + description: + Keep the regulator powered when PMIC transitions to STBY state. + type: boolean + + required: + - regulator-name + additionalProperties: false +additionalProperties: false
Signature · 14 lines
2.43.2 -- Matti Vaittinen, Linux device drivers ROHM Semiconductors, Finland SWDC Kiviharjunlenkki 1E 90220 OULU FINLAND ~~~ "I don't think so," said Rene Descartes. Just then he vanished ~~~ Simon says - in Latin please. ~~~ "non cogito me" dixit Rene Descarte, deinde evanescavit ~~~ Thanks to Simon Glass for the translation =]
Re: [RFC PATCH v2 1/6] dt-bindings: ROHM BD96801 PMIC regulators
Quoted 7 lines · Matti Vaittinen
ROHM BD96801 is a highly configurable automotive grade PMIC. Introduce DT bindings for the BD96801 regulators.
Signed-off-by Matti Vaittinen <[email protected]>---
Revision history:
- No changes since RFCv1
Subject: missing "regulator" prefix, as first.
Quoted 25 lines
.../regulator/rohm,bd96801-regulator.yaml | 69 +++++++++++++++++++ 1 file changed, 69 insertions(+) create mode 100644 Documentation/devicetree/bindings/regulator/rohm,bd96801-regulator.yamlDocumentation/devicetree/bindings/regulator/rohm,bd96801-regulator.yaml new file +14
-0@@ -0,0 +1,69 @@ +# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/regulator/rohm,bd96801-regulator.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: ROHM BD96801 Power Management Integrated Circuit regulators + +maintainers: + - Matti Vaittinen <[email protected]> + +description: | + This module is part of the ROHM BD96801 MFD device. For more details + see Documentation/devicetree/bindings/mfd/rohm,bd96801-pmic.yaml.
Documentation/devicetree/bindings/regulator/rohm,bd96801-regulator.yaml line 24
Quoted 10 lines
Documentation/devicetree/bindings/regulator/rohm,bd96801-regulator.yaml new file +10
-0+ + The regulator controller is represented as a sub-node of the PMIC node + on the device tree. + + Regulator nodes should be named to BUCK_<number> and LDO_<number>. + The valid names for BD96801 regulator nodes are + BUCK1, BUCK2, BUCK3, BUCK4, LDO5, LDO6, LDO7 + +patternProperties: + "^LDO[5-7]$":
lowercase
Documentation/devicetree/bindings/regulator/rohm,bd96801-regulator.yaml line 28
Quoted 4 lines
Documentation/devicetree/bindings/regulator/rohm,bd96801-regulator.yaml new file +4
-0+ type: object + description: + Properties for single LDO regulator. + $ref: regulator.yaml#
Missing unevaluatedProperties: false
Documentation/devicetree/bindings/regulator/rohm,bd96801-regulator.yaml line 34
Quoted 6 lines
Documentation/devicetree/bindings/regulator/rohm,bd96801-regulator.yaml new file +6
-0+ + properties: + regulator-name: + pattern: "^ldo[5-7]$" + description: + Name of the regulator. Should be "ldo5", ..., "ldo7"
Why do you enforce the name? The name should match board schematics, not regulator datasheet.
Documentation/devicetree/bindings/regulator/rohm,bd96801-regulator.yaml line 41
Quoted 7 lines
Documentation/devicetree/bindings/regulator/rohm,bd96801-regulator.yaml new file +7
-0+ rohm,initial-voltage-microvolt: + description: + Initial voltage for regulator. Voltage can be tuned +/-150 mV from + this value. NOTE, This can be modified via I2C only when PMIC is in + STBY state. + minimum: 300000 + maximum: 3300000
Hm, regulator min/max microvolts properties don't work for you? The initial will be just middle?
Documentation/devicetree/bindings/regulator/rohm,bd96801-regulator.yaml line 43
Quoted 2 lines
Documentation/devicetree/bindings/regulator/rohm,bd96801-regulator.yaml new file +2
-0+ + "^BUCK[1-4]$":
lowercase
Quoted 7 lines
Documentation/devicetree/bindings/regulator/rohm,bd96801-regulator.yaml new file +7
-0+ type: object + description: + Properties for single BUCK regulator. + $ref: regulator.yaml# + + properties: + regulator-name:
Documentation/devicetree/bindings/regulator/rohm,bd96801-regulator.yaml line 60
Quoted 10 lines
Documentation/devicetree/bindings/regulator/rohm,bd96801-regulator.yaml new file +10
-0+ pattern: "^buck[1-4]$" + description: + should be "buck1", ..., "buck4" + rohm,initial-voltage-microvolt: + description: + Initial voltage for regulator. Voltage can be tuned +/-150 mV from + this value. NOTE, This can be modified via I2C only when PMIC is in + STBY state. + minimum: 500000 + maximum: 3300000
Missing blank line
Documentation/devicetree/bindings/regulator/rohm,bd96801-regulator.yaml line 68
Quoted 8 lines
Documentation/devicetree/bindings/regulator/rohm,bd96801-regulator.yaml new file +8
-0+ rohm,keep-on-stby: + description: + Keep the regulator powered when PMIC transitions to STBY state. + type: boolean + + required: + - regulator-name + additionalProperties: false
Blank line
Documentation/devicetree/bindings/regulator/rohm,bd96801-regulator.yaml line 69
Quoted 1 line
Documentation/devicetree/bindings/regulator/rohm,bd96801-regulator.yaml new file +1
-0+additionalProperties: false
Best regards,
Krzysztof
Matti Vaittinen
maintainerRe: [RFC PATCH v2 1/6] dt-bindings: ROHM BD96801 PMIC regulators
Quoted 63 lines · Krzysztof Kozlowski
Quoted 7 lines · Matti Vaittinen
ROHM BD96801 is a highly configurable automotive grade PMIC. Introduce DT bindings for the BD96801 regulators.
Signed-off-by Matti Vaittinen <[email protected]>---
Revision history:
- No changes since RFCv1Subject: missing "regulator" prefix, as first.
Quoted 25 lines
.../regulator/rohm,bd96801-regulator.yaml | 69 +++++++++++++++++++ 1 file changed, 69 insertions(+)create mode 100644
Documentation/devicetree/bindings/regulator/rohm,bd96801-regulator.yamlDocumentation/devicetree/bindings/regulator/rohm,bd96801-regulator.yaml new file +14
-0@@ -0,0 +1,69 @@ +# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/regulator/rohm,bd96801-regulator.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: ROHM BD96801 Power Management Integrated Circuit regulators + +maintainers: + - Matti Vaittinen <[email protected]> + +description: | + This module is part of the ROHM BD96801 MFD device. For more details + see Documentation/devicetree/bindings/mfd/rohm,bd96801-pmic.yaml.Documentation/devicetree/bindings/regulator/rohm,bd96801-regulator.yaml line 24
Quoted 10 lines
Documentation/devicetree/bindings/regulator/rohm,bd96801-regulator.yaml new file +10
-0+ + The regulator controller is represented as a sub-node of the PMIC node + on the device tree. + + Regulator nodes should be named to BUCK_<number> and LDO_<number>. + The valid names for BD96801 regulator nodes are + BUCK1, BUCK2, BUCK3, BUCK4, LDO5, LDO6, LDO7 + +patternProperties: + "^LDO[5-7]$":lowercase
Documentation/devicetree/bindings/regulator/rohm,bd96801-regulator.yaml line 28
Quoted 4 lines
Documentation/devicetree/bindings/regulator/rohm,bd96801-regulator.yaml new file +4
-0+ type: object + description: + Properties for single LDO regulator. + $ref: regulator.yaml#Missing unevaluatedProperties: false
Documentation/devicetree/bindings/regulator/rohm,bd96801-regulator.yaml line 34
Quoted 6 lines
Documentation/devicetree/bindings/regulator/rohm,bd96801-regulator.yaml new file +6
-0+ + properties: + regulator-name: + pattern: "^ldo[5-7]$" + description: + Name of the regulator. Should be "ldo5", ..., "ldo7"
Quoted 2 lines
Why do you enforce the name? The name should match board schematics, not regulator datasheet.
If my memory serves me right, the slightly peculiar thing with the regulator core is it does matching of the regulators based on the names of the nodes. There was the regulator-compatible property, but I think it has been deprecated long ago.
https://elixir.bootlin.com/linux/latest/source/drivers/regulator/of_regulator.c#L380
Hence the regulators tend to have fixed names for the nodes. Unless there has been some recent changes I am not aware of...
Quoted 10 lines
Documentation/devicetree/bindings/regulator/rohm,bd96801-regulator.yaml line 41
Quoted 7 lines
Documentation/devicetree/bindings/regulator/rohm,bd96801-regulator.yaml new file +7
-0+ rohm,initial-voltage-microvolt: + description: + Initial voltage for regulator. Voltage can be tuned +/-150 mV from + this value. NOTE, This can be modified via I2C only when PMIC is in + STBY state. + minimum: 300000 + maximum: 3300000Hm, regulator min/max microvolts properties don't work for you? The initial will be just middle?
I had not even thought of this!
I think this is a good idea. The problem I see is if the system where the PMIC is used will need to have 'initial power level' at start-up, which is near the one end of the allowed voltage area. (This because the "tuning"-range is quite narrow after the initial voltage is set). Wide allowed voltage range may be needed if the PMIC is reconfigured using the PMIC STBY state during the runtime.
Eg, sequence would look like:
Bootup:
PMIC STBY:
- initial value 'A' from DT
=> PMIC ACTIVE
- desired (early) voltages 'A' + 'tune'
...
Voltage state differing more than the 'tune' needed due to some runtime use-case:
=> PMIC STBY
- initial value 'B'
=> PMIC ACTIVE
- desired voltages 'B' + 'tune'
Now, if the 'A' can be 'far' from the mid point of the 'allowed voltages' -range.
I have no idea how valid this use-case is though. Once again, I work for a component vendor and don't get to see the forest from the trees... But sure I would like to enable as many possible use-cases as, well, possible :)
Yours,
-- Matti
Signature · 5 lines
Matti Vaittinen Linux kernel developer at ROHM Semiconductors Oulu Finland ~~ When things go utterly wrong vim users can always type :help! ~~
Re: [RFC PATCH v2 1/6] dt-bindings: ROHM BD96801 PMIC regulators
Quoted 72 lines · Matti Vaittinen
Quoted 63 lines · Krzysztof Kozlowski
Quoted 7 lines · Matti Vaittinen
ROHM BD96801 is a highly configurable automotive grade PMIC. Introduce DT bindings for the BD96801 regulators.
Signed-off-by Matti Vaittinen <[email protected]>---
Revision history:
- No changes since RFCv1Subject: missing "regulator" prefix, as first.
Quoted 25 lines
.../regulator/rohm,bd96801-regulator.yaml | 69 +++++++++++++++++++ 1 file changed, 69 insertions(+)create mode 100644
Documentation/devicetree/bindings/regulator/rohm,bd96801-regulator.yamlDocumentation/devicetree/bindings/regulator/rohm,bd96801-regulator.yaml new file +14
-0@@ -0,0 +1,69 @@ +# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/regulator/rohm,bd96801-regulator.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: ROHM BD96801 Power Management Integrated Circuit regulators + +maintainers: + - Matti Vaittinen <[email protected]> + +description: | + This module is part of the ROHM BD96801 MFD device. For more details + see Documentation/devicetree/bindings/mfd/rohm,bd96801-pmic.yaml.Documentation/devicetree/bindings/regulator/rohm,bd96801-regulator.yaml line 24
Quoted 10 lines
Documentation/devicetree/bindings/regulator/rohm,bd96801-regulator.yaml new file +10
-0+ + The regulator controller is represented as a sub-node of the PMIC node + on the device tree. + + Regulator nodes should be named to BUCK_<number> and LDO_<number>. + The valid names for BD96801 regulator nodes are + BUCK1, BUCK2, BUCK3, BUCK4, LDO5, LDO6, LDO7 + +patternProperties: + "^LDO[5-7]$":lowercase
Documentation/devicetree/bindings/regulator/rohm,bd96801-regulator.yaml line 28
Quoted 4 lines
Documentation/devicetree/bindings/regulator/rohm,bd96801-regulator.yaml new file +4
-0+ type: object + description: + Properties for single LDO regulator. + $ref: regulator.yaml#Missing unevaluatedProperties: false
Documentation/devicetree/bindings/regulator/rohm,bd96801-regulator.yaml line 34
Quoted 6 lines
Documentation/devicetree/bindings/regulator/rohm,bd96801-regulator.yaml new file +6
-0+ + properties: + regulator-name: + pattern: "^ldo[5-7]$" + description: + Name of the regulator. Should be "ldo5", ..., "ldo7"Quoted 2 lines
Why do you enforce the name? The name should match board schematics, not regulator datasheet.
If my memory serves me right, the slightly peculiar thing with the regulator core is it does matching of the regulators based on the names of the nodes. There was the regulator-compatible property, but I think it has been deprecated long ago.
Quoted 4 lines
https://elixir.bootlin.com/linux/latest/source/drivers/regulator/of_regulator.c#L380
Hence the regulators tend to have fixed names for the nodes. Unless there has been some recent changes I am not aware of...
Yes, names of the nodes, but not "regulator-name" property.
Quoted 38 lines
Quoted 11 lines
Documentation/devicetree/bindings/regulator/rohm,bd96801-regulator.yaml line 41
Quoted 8 lines
Documentation/devicetree/bindings/regulator/rohm,bd96801-regulator.yaml new file +7
-0+ rohm,initial-voltage-microvolt: + description: + Initial voltage for regulator. Voltage can be tuned +/-150 mV from + this value. NOTE, This can be modified via I2C only when PMIC is in + STBY state. + minimum: 300000 + maximum: 3300000Hm, regulator min/max microvolts properties don't work for you? The initial will be just middle?
I had not even thought of this!
I think this is a good idea. The problem I see is if the system where the PMIC is used will need to have 'initial power level' at start-up, which is near the one end of the allowed voltage area. (This because the "tuning"-range is quite narrow after the initial voltage is set). Wide allowed voltage range may be needed if the PMIC is reconfigured using the PMIC STBY state during the runtime.
Eg, sequence would look like:
Bootup:
PMIC STBY:
- initial value 'A' from DT
=> PMIC ACTIVE
- desired (early) voltages 'A' + 'tune'...
Voltage state differing more than the 'tune' needed due to some runtime use-case:
=> PMIC STBY
- initial value 'B'
=> PMIC ACTIVE
- desired voltages 'B' + 'tune'
Quoted 6 lines
Now, if the 'A' can be 'far' from the mid point of the 'allowed voltages' -range.
I have no idea how valid this use-case is though. Once again, I work for a component vendor and don't get to see the forest from the trees... But sure I would like to enable as many possible use-cases as, well, possible :)
Still I think min/max microvolt solves your case. The property is board-specific and should match what is really on the board. Therefore when writing DTS, one must properly set min/max which in this particular meaning would choose the starting voltage.
I am also fine with this property if somehow min/max create confusion or aren't solving the problem.
Best regards,
Krzysztof
Matti Vaittinen
maintainerRFC PATCH v2 2/6 dt-bindings: mfd: bd96801 PMIC core
In reply to Matti VaittinenROHM BD96801 is a highly configurable automotive grade PMIC. Introduce DT bindings for the BD96801 core.
---
Revision history:
RFCv1 => RFCv2:
- Document rohm,hw-timeout-ms
- Document rohm,wdg-action
--- .../bindings/mfd/rohm,bd96801-pmic.yaml | 171 ++++++++++++++++++ 1 file changed, 171 insertions(+) create mode 100644 Documentation/devicetree/bindings/mfd/rohm,bd96801-pmic.yaml
Documentation/devicetree/bindings/mfd/rohm,bd96801-pmic.yaml new file +171 -0
@@ -0,0 +1,171 @@ +# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/mfd/rohm,bd96801-pmic.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: ROHM BD96801 Scalable Power Management Integrated Circuit + +maintainers: + - Matti Vaittinen <[email protected]> + +description: | + BD96801 is an automotive grade single-chip power management IC. + It integrates 4 buck converters and 3 LDOs with safety features like + over-/under voltage and over current detection and a watchdog. + +properties: + compatible: + const: rohm,bd96801 + + reg: + description: + I2C slave address. + maxItems: 1 + + interrupts: + description: + The PMIC provides intb and errb IRQ lines. The errb IRQ line is used + for fatal IRQs which will cause the PMIC to shut down power outputs. + In many systems this will shut down the SoC contolling the PMIC and + connecting/handling the errb can be omitted. However, there are cases + where the SoC is not powered by the PMIC. In that case it may be + useful to connect the errb and handle errb events. + minItems: 1 + maxItems: 2 + + interrupt-names: + minItems: 1 + items: + - enum: [intb, errb] + - const: errb + + rohm,hw-timeout-ms: + description: + Watchdog timeout value(s). First walue is timeout limit. Second value is + optional value for 'too early' watchdog ping if window timeout mode is + to be used. + minItems: 1 + maxItems: 2 + + rohm,wdg-action: + description: + Whether the watchdog failure must turn off the regulator power outputs or + just toggle the INTB line. + enum: + - prstb + - intb-only + + regulators: + $ref: ../regulator/rohm,bd96801-regulator.yaml + description: + List of child nodes that specify the regulators. + +required: + - compatible + - reg + - interrupts + - interrupt-names + - regulators + +additionalProperties: false + +examples: + - | + #include <dt-bindings/interrupt-controller/irq.h> + #include <dt-bindings/leds/common.h> + i2c { + #address-cells = <1>; + #size-cells = <0>; + pmic: pmic@60 { + reg = <0x60>; + compatible = "rohm,bd96801"; + interrupt-parent = <&gpio1>; + interrupts = <29 IRQ_TYPE_LEVEL_LOW>, <6 IRQ_TYPE_LEVEL_LOW>; + interrupt-names = "intb", "errb"; + + regulators { + buck1: BUCK1 { + regulator-name = "buck1"; + regulator-ramp-delay = <1250>; + /* 0.5V min INITIAL - 150 mV tune */ + regulator-min-microvolt = <350000>; + /* 3.3V + 150mV tune */ + regulator-max-microvolt = <3450000>; + + /* These can be set only when PMIC is in STBY */ + rohm,initial-voltage-microvolt = <500000>; + regulator-ov-error-microvolt = <230000>; + regulator-uv-error-microvolt = <230000>; + regulator-temp-protection-kelvin = <1>; + regulator-temp-warn-kelvin = <0>; + }; + buck2: BUCK2 { + regulator-name = "buck2"; + regulator-min-microvolt = <350000>; + regulator-max-microvolt = <3450000>; + + rohm,initial-voltage-microvolt = <3000000>; + regulator-ov-error-microvolt = <18000>; + regulator-uv-error-microvolt = <18000>; + regulator-temp-protection-kelvin = <1>; + regulator-temp-warn-kelvin = <1>; + }; + buck3: BUCK3 { + regulator-name = "buck3"; + regulator-min-microvolt = <350000>; + regulator-max-microvolt = <3450000>; + + rohm,initial-voltage-microvolt = <600000>; + regulator-ov-warn-microvolt = <18000>; + regulator-uv-warn-microvolt = <18000>; + regulator-temp-protection-kelvin = <1>; + regulator-temp-error-kelvin = <0>; + }; + buck4: BUCK4 { + regulator-name = "buck4"; + regulator-min-microvolt = <350000>; + regulator-max-microvolt = <3450000>; + + rohm,initial-voltage-microvolt = <600000>; + regulator-ov-warn-microvolt = <18000>; + regulator-uv-warn-microvolt = <18000>; + regulator-temp-protection-kelvin = <1>; + regulator-temp-error-kelvin = <0>; + }; + ldo5: LDO5 { + regulator-name = "ldo5"; + regulator-min-microvolt = <300000>; + regulator-max-microvolt = <3300000>; + + rohm,initial-voltage-microvolt = <500000>; + regulator-ov-error-microvolt = <36000>; + regulator-uv-error-microvolt = <34000>; + regulator-temp-protection-kelvin = <1>; + regulator-temp-warn-kelvin = <0>; + }; + ldo6: LDO6 { + regulator-name = "ldo6"; + regulator-min-microvolt = <300000>; + regulator-max-microvolt = <3300000>; + + rohm,initial-voltage-microvolt = <300000>; + regulator-ov-error-microvolt = <36000>; + regulator-uv-error-microvolt = <34000>; + regulator-temp-protection-kelvin = <1>; + regulator-temp-warn-kelvin = <0>; + }; + ldo7: LDO7 { + regulator-name = "ldo7"; + regulator-min-microvolt = <300000>; + regulator-max-microvolt = <3300000>; + + rohm,initial-voltage-microvolt = <500000>; + regulator-ov-error-microvolt = <36000>; + regulator-uv-error-microvolt = <34000>; + regulator-temp-protection-kelvin = <1>; + regulator-temp-warn-kelvin = <0>; + }; + }; + }; + };
Signature · 14 lines
2.43.2 -- Matti Vaittinen, Linux device drivers ROHM Semiconductors, Finland SWDC Kiviharjunlenkki 1E 90220 OULU FINLAND ~~~ "I don't think so," said Rene Descartes. Just then he vanished ~~~ Simon says - in Latin please. ~~~ "non cogito me" dixit Rene Descarte, deinde evanescavit ~~~ Thanks to Simon Glass for the translation =]
Re: [RFC PATCH v2 2/6] dt-bindings: mfd: bd96801 PMIC core
Quoted 23 lines · Matti Vaittinen
ROHM BD96801 is a highly configurable automotive grade PMIC. Introduce DT bindings for the BD96801 core.
Signed-off-by Matti Vaittinen <[email protected]>---
Revision history:
RFCv1 => RFCv2:
- Document rohm,hw-timeout-ms
- Document rohm,wdg-action--- .../bindings/mfd/rohm,bd96801-pmic.yaml | 171 ++++++++++++++++++ 1 file changed, 171 insertions(+) create mode 100644 Documentation/devicetree/bindings/mfd/rohm,bd96801-pmic.yamlDocumentation/devicetree/bindings/mfd/rohm,bd96801-pmic.yaml new file +2
-0@@ -0,0 +1,171 @@ +# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause +%YAML 1.2
Documentation/devicetree/bindings/mfd/rohm,bd96801-pmic.yaml line 12
Quoted 10 lines
Documentation/devicetree/bindings/mfd/rohm,bd96801-pmic.yaml new file +10
-0+--- +$id: http://devicetree.org/schemas/mfd/rohm,bd96801-pmic.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: ROHM BD96801 Scalable Power Management Integrated Circuit + +maintainers: + - Matti Vaittinen <[email protected]> + +description: |
Do not need '|' unless you need to preserve formatting.
Documentation/devicetree/bindings/mfd/rohm,bd96801-pmic.yaml line 23
Quoted 11 lines
Documentation/devicetree/bindings/mfd/rohm,bd96801-pmic.yaml new file +11
-0+ BD96801 is an automotive grade single-chip power management IC. + It integrates 4 buck converters and 3 LDOs with safety features like + over-/under voltage and over current detection and a watchdog. + +properties: + compatible: + const: rohm,bd96801 + + reg: + description: + I2C slave address.
Drop description, obvious.
Quoted 14 lines
Documentation/devicetree/bindings/mfd/rohm,bd96801-pmic.yaml new file +14
-0+ maxItems: 1 + + interrupts: + description: + The PMIC provides intb and errb IRQ lines. The errb IRQ line is used + for fatal IRQs which will cause the PMIC to shut down power outputs. + In many systems this will shut down the SoC contolling the PMIC and + connecting/handling the errb can be omitted. However, there are cases + where the SoC is not powered by the PMIC. In that case it may be + useful to connect the errb and handle errb events. + minItems: 1 + maxItems: 2 + + interrupt-names:
Documentation/devicetree/bindings/mfd/rohm,bd96801-pmic.yaml line 47
Quoted 10 lines
Documentation/devicetree/bindings/mfd/rohm,bd96801-pmic.yaml new file +10
-0+ minItems: 1 + items: + - enum: [intb, errb] + - const: errb + + rohm,hw-timeout-ms: + description: + Watchdog timeout value(s). First walue is timeout limit. Second value is + optional value for 'too early' watchdog ping if window timeout mode is + to be used.
Standard property timeout-sec does not work for you? It should allow two items as well.
Documentation/devicetree/bindings/mfd/rohm,bd96801-pmic.yaml line 57
Quoted 10 lines
Documentation/devicetree/bindings/mfd/rohm,bd96801-pmic.yaml new file +10
-0+ minItems: 1 + maxItems: 2 + + rohm,wdg-action: + description: + Whether the watchdog failure must turn off the regulator power outputs or + just toggle the INTB line. + enum: + - prstb + - intb-only
This is second property controlling bite behavior. The other being:
https://lore.kernel.org/all/[email protected]/
Probably we need common property in watchdog.yaml.
Documentation/devicetree/bindings/mfd/rohm,bd96801-pmic.yaml line 60
Quoted 3 lines
Documentation/devicetree/bindings/mfd/rohm,bd96801-pmic.yaml new file +3
-0+ + regulators: + $ref: ../regulator/rohm,bd96801-regulator.yaml
Full path, so /schemas/regulator/....
Documentation/devicetree/bindings/mfd/rohm,bd96801-pmic.yaml line 70
Quoted 10 lines
Documentation/devicetree/bindings/mfd/rohm,bd96801-pmic.yaml new file +10
-0+ description: + List of child nodes that specify the regulators. + +required: + - compatible + - reg + - interrupts + - interrupt-names + - regulators +
Missing allOf and $ref to watchdog.yaml
Documentation/devicetree/bindings/mfd/rohm,bd96801-pmic.yaml line 73
Quoted 3 lines
Documentation/devicetree/bindings/mfd/rohm,bd96801-pmic.yaml new file +3
-0+additionalProperties: false + +examples:
Best regards,
Krzysztof
Re: [RFC PATCH v2 2/6] dt-bindings: mfd: bd96801 PMIC core
Quoted 8 lines · Krzysztof Kozlowski
Documentation/devicetree/bindings/mfd/rohm,bd96801-pmic.yaml line 57
Quoted 7 lines
Documentation/devicetree/bindings/mfd/rohm,bd96801-pmic.yaml new file +7
-0+ rohm,wdg-action: + description: + Whether the watchdog failure must turn off the regulator power outputs or + just toggle the INTB line. + enum: + - prstb + - intb-only
Quoted 4 lines
This is second property controlling bite behavior. The other being:
https://lore.kernel.org/all/[email protected]/Probably we need common property in
watchdog.yaml.
No, that's not the same case. I mixed up topics.
Best regards,
Krzysztof
Matti Vaittinen
maintainerRe: [RFC PATCH v2 2/6] dt-bindings: mfd: bd96801 PMIC core
In reply to Krzysztof KozlowskiMorning Krzysztof,
Thanks again for the review/help!
Quoted 10 lines · Krzysztof Kozlowski
On 12/04/2024 13:21, Matti Vaittinen wrote
Documentation/devicetree/bindings/mfd/rohm,bd96801-pmic.yaml line 47
Quoted 6 lines
Documentation/devicetree/bindings/mfd/rohm,bd96801-pmic.yaml new file +6
-0+ + rohm,hw-timeout-ms: + description: + Watchdog timeout value(s). First walue is timeout limit. Second value is + optional value for 'too early' watchdog ping if window timeout mode is + to be used.Standard property timeout-sec does not work for you? It should allow two items as well.
I don't think so. We need sub-second units. Furthermore, the timeout-sec (if I understand it correctly) updates the "timeout policy", which tells the expected ping-interval. This can be different from the "HW heart-beat" which tells the HW's ping expectation. Hence the "hw-" prefix.
Quoted 1 line
Missing allOf
This just about summarizes my feelings when I try write the bindings. XD I do feel completely lost. Hence I do really appreciate someone like you taking the time to help me through ^^;
Enjoy the Seattle!
Yours,
-- Matti
Signature · 5 lines
Matti Vaittinen Linux kernel developer at ROHM Semiconductors Oulu Finland ~~ When things go utterly wrong vim users can always type :help! ~~
Matti Vaittinen
maintainerRe: [RFC PATCH v2 2/6] dt-bindings: mfd: bd96801 PMIC core
Quoted 15 lines · Matti Vaittinen
Morning Krzysztof,
Thanks again for the review/help!
Quoted 10 lines · Krzysztof Kozlowski
On 12/04/2024 13:21, Matti Vaittinen wrote
Quoted 8 lines
+
+ rohm,hw-timeout-ms:
+ description:
+ Watchdog timeout value(s). First walue is timeout limit. Second value is
+ optional value for 'too early' watchdog ping if window timeout mode is
+ to be used.
Quoted 4 lines
Quoted 2 lines
Standard property timeout-sec does not work for you? It should allow two items as well.
I don't think so. We need sub-second units. Furthermore, the timeout-sec (if I understand it correctly) updates the "timeout policy", which tells the expected ping-interval. This can be different from the "HW heart-beat" which tells the HW's ping expectation. Hence the "hw-" prefix.
Oh, I just found out that this is an existing property. The ROHM BD9576/BD9573 do aleady use this. It seems I've had some discussion about it with Rob/Guenter when adding it. Frightening thing is that I didin't remember the discussion or that the property existed at all... Well, luckily we have lore :)
https://lore.kernel.org/all/[email protected]/#r
(I don't see the final conclusion in this discussion, it has probably been done on some later version of the series).
Yours,
-- Matti
Signature · 5 lines
Matti Vaittinen Linux kernel developer at ROHM Semiconductors Oulu Finland ~~ When things go utterly wrong vim users can always type :help! ~~
Re: [RFC PATCH v2 2/6] dt-bindings: mfd: bd96801 PMIC core
Quoted 30 lines · Matti Vaittinen
Quoted 15 lines · Matti Vaittinen
Morning Krzysztof,
Thanks again for the review/help!
Quoted 10 lines · Krzysztof Kozlowski
On 12/04/2024 13:21, Matti Vaittinen wrote
Quoted 8 lines
+
+ rohm,hw-timeout-ms:
+ description:
+ Watchdog timeout value(s). First walue is timeout limit. Second value is
+ optional value for 'too early' watchdog ping if window timeout mode is
+ to be used.Quoted 7 lines
Quoted 2 lines
Standard property timeout-sec does not work for you? It should allow two items as well.
I don't think so. We need sub-second units. Furthermore, the timeout-sec (if I understand it correctly) updates the "timeout policy", which tells the expected ping-interval. This can be different from the "HW heart-beat" which tells the HW's ping expectation. Hence the "hw-" prefix.
Oh, I just found out that this is an existing property. The ROHM BD9576/BD9573 do aleady use this. It seems I've had some discussion about it with Rob/Guenter when adding it. Frightening thing is that I didin't remember the discussion or that the property existed at all... Well, luckily we have lore :)
Quoted 5 lines
https://lore.kernel.org/all/[email protected]/#r
(I don't see the final conclusion in this discussion, it has probably been done on some later version of the series).
Sure, it's fine then.
Best regards,
Krzysztof
Matti Vaittinen
maintainerRe: [RFC PATCH v2 2/6] dt-bindings: mfd: bd96801 PMIC core
In reply to Krzysztof KozlowskiQuoted 17 lines · Krzysztof Kozlowski
Quoted 16 lines · Matti Vaittinen
ROHM BD96801 is a highly configurable automotive grade PMIC. Introduce DT bindings for the BD96801 core.
Signed-off-by Matti Vaittinen <[email protected]>---
Revision history:
RFCv1 => RFCv2:
- Document rohm,hw-timeout-ms
- Document rohm,wdg-action--- .../bindings/mfd/rohm,bd96801-pmic.yaml | 171 ++++++++++++++++++ 1 file changed, 171 insertions(+)create mode 100644
Documentation/devicetree/bindings/mfd/rohm,bd96801-pmic.yamlDocumentation/devicetree/bindings/mfd/rohm,bd96801-pmic.yaml +0
-0
...
Quoted 2 lines
Missing allOf and $ref to
watchdog.yaml
Huh. The watchdog.yaml contains:
select:
properties:
$nodename:
pattern: "^watchdog(@.*|-([0-9]|[1-9][0-9]+))?$"properties:
$nodename:
pattern: "^(timer|watchdog)(@.*|-([0-9]|[1-9][0-9]+))?$"
This means the watchdog _must_ have own sub-node inside the PMIC node, right?
Yours,
-- Matti
Signature · 5 lines
Matti Vaittinen Linux kernel developer at ROHM Semiconductors Oulu Finland ~~ When things go utterly wrong vim users can always type :help! ~~
Re: [RFC PATCH v2 2/6] dt-bindings: mfd: bd96801 PMIC core
Quoted 10 lines · Matti Vaittinen
Quoted 2 lines
Missing allOf and $ref to
watchdog.yamlHuh. The
watchdog.yamlcontains:select:
properties: $nodename: pattern: "^watchdog(@.*|-([0-9]|[1-9][0-9]+))?$"
Quoted 6 lines
properties:
$nodename: pattern: "^(timer|watchdog)(@.*|-([0-9]|[1-9][0-9]+))?$"This means the watchdog _must_ have own sub-node inside the PMIC node,
Yes, that's a bit of a trouble. Then instead maybe just add timeout-sec with maxItems: 2.
Best regards,
Krzysztof
Matti Vaittinen
maintainerRe: [RFC PATCH v2 2/6] dt-bindings: mfd: bd96801 PMIC core
Quoted 11 lines · Krzysztof Kozlowski
Quoted 10 lines · Matti Vaittinen
Quoted 2 lines
Missing allOf and $ref to
watchdog.yamlHuh. The
watchdog.yamlcontains:select:
properties: $nodename: pattern: "^watchdog(@.*|-([0-9]|[1-9][0-9]+))?$"
Quoted 8 lines
Quoted 6 lines
properties:
$nodename: pattern: "^(timer|watchdog)(@.*|-([0-9]|[1-9][0-9]+))?$"This means the watchdog _must_ have own sub-node inside the PMIC node,
Yes, that's a bit of a trouble.
Agree. I'm not 100% sure why this requirement? I guess it is a bit of a problem for many MFD devices with a watchdog.
Quoted 2 lines
Then instead maybe just add timeout-sec
with maxItems: 2.
Nice idea. Thanks for the suggestion, I'll do just that!
Yours,
-- Matti
Signature · 5 lines
Matti Vaittinen Linux kernel developer at ROHM Semiconductors Oulu Finland ~~ When things go utterly wrong vim users can always type :help! ~~
Matti Vaittinen
maintainerRFC PATCH v2 3/6 mfd: support ROHM BD96801 PMIC core
In reply to Matti VaittinenThe ROHM BD96801 PMIC is highly customizable automotive grade PMIC which integrates regulator and watchdog funtionalities.
Provide IRQ and register accesses for regulator/watchdog drivers.
---
Changelog: RFCv1 => RFCv2
- Work-around the IRQ domain name conflict
- Add watchdog IRQ
- Various styling fixes based on review by Lee
--- drivers/mfd/Kconfig | 13 + drivers/mfd/Makefile | 1 + drivers/mfd/rohm-bd96801.c | 476 +++++++++++++++++++++++++++++++ include/linux/mfd/rohm-bd96801.h | 211 ++++++++++++++ include/linux/mfd/rohm-generic.h | 1 + 5 files changed, 702 insertions(+) create mode 100644 drivers/mfd/rohm-bd96801.c create mode 100644 include/linux/mfd/rohm-bd96801.h
drivers/mfd/Kconfig +13 -0
@@ -2089,6 +2089,19 @@ config MFD_ROHM_BD957XMUF BD9573MUF Power Management ICs. BD9576 and BD9573 are primarily designed to be used to power R-Car series processors. +config MFD_ROHM_BD96801 + tristate "ROHM BD96801 Power Management IC" + depends on I2C=y + depends on OF + select REGMAP_I2C + select REGMAP_IRQ + select MFD_CORE + help + Select this option to get support for the ROHM BD96801 Power + Management IC. The ROHM BD96801 is a highly scalable Power Management + IC for industrial and automotive use. The BD96801 can be used as a + master PMIC in a chained PMIC solution with suitable companion PMICs. + config MFD_STM32_LPTIMER tristate "Support for STM32 Low-Power Timer" depends on (ARCH_STM32 && OF) || COMPILE_TEST
drivers/mfd/Makefile +1 -0
@@ -264,6 +264,7 @@ obj-$(CONFIG_RAVE_SP_CORE) += rave-sp.o obj-$(CONFIG_MFD_ROHM_BD71828) += rohm-bd71828.o obj-$(CONFIG_MFD_ROHM_BD718XX) += rohm-bd718x7.o obj-$(CONFIG_MFD_ROHM_BD957XMUF) += rohm-bd9576.o +obj-$(CONFIG_MFD_ROHM_BD96801) += rohm-bd96801.o obj-$(CONFIG_MFD_STMFX) += stmfx.o obj-$(CONFIG_MFD_KHADAS_MCU) += khadas-mcu.o obj-$(CONFIG_MFD_ACER_A500_EC) += acer-ec-a500.o
drivers/mfd/rohm-bd96801.c new file +476 -0
476 lines not on this page · raw message
include/linux/mfd/rohm-bd96801.h new file +211 -0
211 lines not on this page · raw message
include/linux/mfd/rohm-generic.h +1 -0
@@ -16,6 +16,7 @@ enum rohm_chip_type {ROHM_CHIP_TYPE_BD71828 ,ROHM_CHIP_TYPE_BD71837 ,ROHM_CHIP_TYPE_BD71847 , +ROHM_CHIP_TYPE_BD96801 , ROHM_CHIP_TYPE_AMOUNT };
Signature · 14 lines
2.43.2 -- Matti Vaittinen, Linux device drivers ROHM Semiconductors, Finland SWDC Kiviharjunlenkki 1E 90220 OULU FINLAND ~~~ "I don't think so," said Rene Descartes. Just then he vanished ~~~ Simon says - in Latin please. ~~~ "non cogito me" dixit Rene Descarte, deinde evanescavit ~~~ Thanks to Simon Glass for the translation =]
Matti Vaittinen
maintainerRFC PATCH v2 4/6 regulator: bd96801: ROHM BD96801 PMIC regulators
In reply to Matti VaittinenThe ROHM BD96801 "Scalable PMIC" is an automotive grade PMIC which can scale to different applications by allowing chaining of PMICs. The PMIC also supports various protection features which can be configured either to fire IRQs - or to shut down power outputs when failure is detected.
The driver supports the basic control of BUCKs and LDOs and configuring Over/Under-voltage, over-current, over-temperature protections via device-tree. Following constrains are worth noting:
The voltages can be enabled/disabled and protections configured only when the PMIC is in STANDBY state.
The protections can't be disabled. UVP limit can't be configured. OVP and OCP limits can be configured.
OVD and UVD for a regulator have common limit.
OCP and thermal protections are implemented by turning all INTB notifications fatal. This means that OVD/UVD can not be used together with OCP and thermal protection.
Thermal limits can't be configured. TSD is fixed to 175 Celsius, and thermal warning is fixed close to 140 Celsius.
LDO's do not have own temperature monitor. The LDO limits use PMIC core temperature.
---
Revision history:
RFCv1 => RFCv2:
- Use devm_kcalloc() instead of devm_kzalloc() where appropriate
- Use devm_kmemdup()
- Add MODULE_DEVICE_TABLE
- drop MODULE_ALIAS
This patch requires the regulator_irq_helper() IRQ name duplication patch which is already in regulator tree 'for-6.9' -branch.
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/regulator.git/commit/?h=for-6.9&id=7ab681ddedd4b6dd2b047c74af95221c5f827e1d
Note. This patch implements controls which can only be done when the BD96801 PMIC is in a 'standby' state. These controls include the protection settings and 'initial' voltage settings.
The PMIC has a STBY pin which is used to control the PMIC power-state.
I don't have visibility to the design process or to most of the customer use cases - so following is speculation:
- Original idea seems to have been that, when the PMIC goes to STBY state, controlling processor will be powered-off. In the original DS1 version all power outputs from the PMIC were turned off when PMIC entered STBY.
- Someone somewhere needed to be able to keep the controlling processor and some peripherials powered on when the PMIC is in STBY. A very potential reason is to be able to do the initial voltage / protection configurations by software. A configuration option to keep desired power outputs enabled when PMIC is in STBY was added.
- Current PMIC state can be read from the PMIC registers.
Obvious(?) dilemma for these 'STBY only' configurations is that it is difficult to design generic way for the PMIC driver to synchronize the configurations with the state changes. Designing it would at least require knowledge on:
- What is the PMIC STBY-state used for? Is it intended to be a power-off (or other low-power) state for the system? Or, is it intended to be used just a state where some of the configurations are done?
- How is the hardware designed to control the STBY pin?
We *could* assume the STBY pin is controlled by a GPIO. We could grab the GPIO here, and export functions to toggle the STBY state. We could then 'lock' the state for the duration of config changes. But problem is, I don't know what is the right thing to do.
So, this version of the patch just checks the PMIC state - and attempts to write the configs if PMIC is in STBY state. This is racy unless the entity controlling the STBY-pin is somehow (external to this driver) synchronized. We could send a notification when configurations are completed to help building such synchronization but this is not done as I don't have a real-world user for it.
I am unsure if these 'STBY-only' controls should be just dropped, or if they should be kept here to serve as an example / basis to build on. If they are removed, it will be very hard for anyone using this PMIC to implement those controls. OTOH, if they are kept here, it may potentially encourage 'works on my machine' designs - although, I believe that those who really need to do 'STBY-only' configs at run-time will find a way to toggle the STBY-pin in a way that is synchronized with the configs here.
--- drivers/regulator/Kconfig | 12 + drivers/regulator/Makefile | 2 + drivers/regulator/bd96801-regulator.c | 2114 +++++++++++++++++++++++++ 3 files changed, 2128 insertions(+) create mode 100644 drivers/regulator/bd96801-regulator.c
drivers/regulator/Kconfig +12 -0
@@ -268,6 +268,18 @@ config REGULATOR_BD957XMUF This driver can also be built as a module. If so, the module will be called bd9576-regulator. +config REGULATOR_BD96801 + tristate "ROHM BD96801 Power Regulator" + depends on MFD_ROHM_BD96801 + select REGULATOR_ROHM + help + This driver supports voltage regulators on ROHM BD96801 PMIC. + This will enable support for the software controllable buck + and LDO regulators. + + This driver can also be built as a module. If so, the module + will be called bd96801-regulator. + config REGULATOR_CPCAP tristate "Motorola CPCAP regulator" depends on MFD_CPCAP
drivers/regulator/Makefile +2 -0
@@ -37,6 +37,8 @@ obj-$(CONFIG_REGULATOR_BD718XX) += bd718x7-regulator.o obj-$(CONFIG_REGULATOR_BD9571MWV) += bd9571mwv-regulator.o obj-$(CONFIG_REGULATOR_BD957XMUF) += bd9576-regulator.o obj-$(CONFIG_REGULATOR_DA903X) += da903x-regulator.o +obj-$(CONFIG_REGULATOR_BD96801) += bd96801-regulator.o +obj-$(CONFIG_REGULATOR_DA903X) += da903x.o obj-$(CONFIG_REGULATOR_DA9052) += da9052-regulator.o obj-$(CONFIG_REGULATOR_DA9055) += da9055-regulator.o obj-$(CONFIG_REGULATOR_DA9062) += da9062-regulator.o
drivers/regulator/bd96801-regulator.c new file +2114 -0
2,114 lines not on this page · raw message
Signature · 14 lines
2.43.2 -- Matti Vaittinen, Linux device drivers ROHM Semiconductors, Finland SWDC Kiviharjunlenkki 1E 90220 OULU FINLAND ~~~ "I don't think so," said Rene Descartes. Just then he vanished ~~~ Simon says - in Latin please. ~~~ "non cogito me" dixit Rene Descarte, deinde evanescavit ~~~ Thanks to Simon Glass for the translation =]
Matti Vaittinen
maintainerRFC PATCH v2 5/6 watchdog: ROHM BD96801 PMIC WDG driver
In reply to Matti VaittinenIntroduce driver for WDG block on ROHM BD96801 scalable PMIC.
This driver only supports watchdog with I2C feeding and delayed response detection. Whether the watchdog toggles PRSTB pin or just causes an interrupt can be configured via device-tree.
The BD96801 PMIC HW supports also window watchdog (too early feeding detection) and Q&A mode. These are not supported by this driver.
---
Revision history:
RFCv1 => RFCv2:
- remove always running
- add IRQ handling
- call emergency_restart()
- drop MODULE_ALIAS and add MODULE_DEVICE_TABLE
--- drivers/watchdog/Kconfig | 13 ++ drivers/watchdog/Makefile | 1 + drivers/watchdog/bd96801_wdt.c | 389 +++++++++++++++++++++++++++++++++ 3 files changed, 403 insertions(+) create mode 100644 drivers/watchdog/bd96801_wdt.c
drivers/watchdog/Kconfig +13 -0
@@ -181,6 +181,19 @@ config BD957XMUF_WATCHDOG watchdog. Alternatively say M to compile the driver as a module, which will be called bd9576_wdt. +config BD96801_WATCHDOG + tristate "ROHM BD96801 PMIC Watchdog" + depends on MFD_ROHM_BD96801 + select WATCHDOG_CORE + help + Support for the watchdog in the ROHM BD96801 PMIC. Watchdog can be + configured to only generate IRQ or to trigger system reset via reset + pin. + + Say Y here to include support for the ROHM BD96801 watchdog. + Alternatively say M to compile the driver as a module, + which will be called bd96801_wdt. + config CROS_EC_WATCHDOG tristate "ChromeOS EC-based watchdog" select WATCHDOG_CORE
drivers/watchdog/Makefile +1 -0
@@ -217,6 +217,7 @@ obj-$(CONFIG_XEN_WDT) += xen_wdt.o # Architecture Independent obj-$(CONFIG_BD957XMUF_WATCHDOG) += bd9576_wdt.o +obj-$(CONFIG_BD96801_WATCHDOG) += bd96801_wdt.o obj-$(CONFIG_CROS_EC_WATCHDOG) += cros_ec_wdt.o obj-$(CONFIG_DA9052_WATCHDOG) += da9052_wdt.o obj-$(CONFIG_DA9055_WATCHDOG) += da9055_wdt.o
drivers/watchdog/bd96801_wdt.c new file +389 -0
389 lines not on this page · raw message
Signature · 14 lines
2.43.2 -- Matti Vaittinen, Linux device drivers ROHM Semiconductors, Finland SWDC Kiviharjunlenkki 1E 90220 OULU FINLAND ~~~ "I don't think so," said Rene Descartes. Just then he vanished ~~~ Simon says - in Latin please. ~~~ "non cogito me" dixit Rene Descarte, deinde evanescavit ~~~ Thanks to Simon Glass for the translation =]
Re: [RFC PATCH v2 5/6] watchdog: ROHM BD96801 PMIC WDG driver
Quoted 156 lines · Matti Vaittinen
Introduce driver for WDG block on ROHM BD96801 scalable PMIC.
This driver only supports watchdog with I2C feeding and delayed response detection. Whether the watchdog toggles PRSTB pin or just causes an interrupt can be configured via device-tree.
The BD96801 PMIC HW supports also window watchdog (too early feeding detection) and Q&A mode. These are not supported by this driver.
Signed-off-by Matti Vaittinen <[email protected]>---
Revision history:
RFCv1 => RFCv2:
- remove always running
- add IRQ handling
- callemergency_restart()
- dropMODULE_ALIASand addMODULE_DEVICE_TABLE--- drivers/watchdog/Kconfig | 13 ++ drivers/watchdog/Makefile | 1 + drivers/watchdog/bd96801_wdt.c | 389 +++++++++++++++++++++++++++++++++ 3 files changed, 403 insertions(+) create mode 100644 drivers/watchdog/bd96801_wdt.cdrivers/watchdog/Kconfig +13
-0@@ -181,6 +181,19 @@ config BD957XMUF_WATCHDOG watchdog. Alternatively say M to compile the driver as a module, which will be called bd9576_wdt. +config BD96801_WATCHDOG + tristate "ROHM BD96801 PMIC Watchdog" + depends on MFD_ROHM_BD96801 + select WATCHDOG_CORE + help + Support for the watchdog in the ROHM BD96801 PMIC. Watchdog can be + configured to only generate IRQ or to trigger system reset via reset + pin. + + Say Y here to include support for the ROHM BD96801 watchdog. + Alternatively say M to compile the driver as a module, + which will be called bd96801_wdt. + config CROS_EC_WATCHDOG tristate "ChromeOS EC-based watchdog" select WATCHDOG_COREdrivers/watchdog/Makefile +1
-0@@ -217,6 +217,7 @@ obj-$(CONFIG_XEN_WDT) += xen_wdt.o # Architecture Independent obj-$(CONFIG_BD957XMUF_WATCHDOG) += bd9576_wdt.o +obj-$(CONFIG_BD96801_WATCHDOG) += bd96801_wdt.o obj-$(CONFIG_CROS_EC_WATCHDOG) += cros_ec_wdt.o obj-$(CONFIG_DA9052_WATCHDOG) += da9052_wdt.o obj-$(CONFIG_DA9055_WATCHDOG) += da9055_wdt.odrivers/watchdog/bd96801_wdt.c new file +88
-0@@ -0,0 +1,389 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* +* Copyright (C) 2024 ROHM Semiconductors +* +* ROHM BD96801 watchdog driver +*/ + +#include <linux/interrupt.h> +#include <linux/kernel.h> +#include <linux/mfd/rohm-bd96801.h> +#include <linux/mfd/rohm-generic.h> +#include <linux/module.h> +#include <linux/of.h> +#include <linux/platform_device.h> +#include <linux/regmap.h> +#include <linux/watchdog.h> + +static bool nowayout; +module_param (nowayout, bool,0 ); +MODULE_PARM_DESC (nowayout, +"Watchdog cannot be stopped once started (default=\"false\")" ); + +#define BD96801_WD_TMO_SHORT_MASK 0x70 +#define BD96801_WD_RATIO_MASK 0x3 +#define BD96801_WD_TYPE_MASK 0x4 +#define BD96801_WD_TYPE_SLOW 0x4 +#define BD96801_WD_TYPE_WIN 0x0 + +#define BD96801_WD_EN_MASK 0x3 +#define BD96801_WD_IF_EN 0x1 +#define BD96801_WD_QA_EN 0x2 +#define BD96801_WD_DISABLE 0x0 + +#define BD96801_WD_ASSERT_MASK 0x8 +#define BD96801_WD_ASSERT_RST 0x8 +#define BD96801_WD_ASSERT_IRQ 0x0 + +#define BD96801_WD_FEED_MASK 0x1 +#define BD96801_WD_FEED 0x1 + +/* units in uS */ +#define FASTNG_MIN 3370 +#define BD96801_WDT_DEFAULT_MARGIN 6905120 +/* Unit is seconds */ +#define DEFAULT_TIMEOUT 30 + +/* +* BD96801 WDG supports window mode so the TMO consists of SHORT and LONG +* timeout values. SHORT time is meaningfull only in window mode where feeding +* period shorter than SHORT would be an error. LONG time is used to detect if +* feeding is not occurring within given time limit (SoC SW hangs). The LONG +* timeout time is a multiple of (2, 4, 8 0r 16 times) the SHORT timeout. +*/ + +struct wdtbd96801 { +struct device *dev; +struct regmap *regmap; +struct watchdog_device wdt; +}; + +static int bd96801_wdt_ping (struct watchdog_device *wdt) +{ +struct wdtbd96801 *w =watchdog_get_drvdata (wdt); + +return regmap_update_bits (w->regmap,BD96801_REG_WD_FEED , +BD96801_WD_FEED_MASK ,BD96801_WD_FEED ); +} + +static int bd96801_wdt_start (struct watchdog_device *wdt) +{ +struct wdtbd96801 *w =watchdog_get_drvdata (wdt); +int ret; + + ret =regmap_update_bits (w->regmap,BD96801_REG_WD_CONF , +BD96801_WD_EN_MASK ,BD96801_WD_IF_EN ); + +return ret; +} + +static int bd96801_wdt_stop (struct watchdog_device *wdt) +{ +struct wdtbd96801 *w =watchdog_get_drvdata (wdt); + +return regmap_update_bits (w->regmap,BD96801_REG_WD_CONF , +BD96801_WD_EN_MASK ,BD96801_WD_DISABLE ); +} + +static const struct watchdog_info bd96801_wdt_info = {
drivers/watchdog/bd96801_wdt.c line 98
Quoted 10 lines
drivers/watchdog/bd96801_wdt.c new file +10
-0+ .options = WDIOF_MAGICCLOSE | WDIOF_KEEPALIVEPING | + WDIOF_SETTIMEOUT, + .identity = "BD96801 Watchdog", +}; + +static const struct watchdog_ops bd96801_wdt_ops = { + .start = bd96801_wdt_start, + .stop = bd96801_wdt_stop, + .ping = bd96801_wdt_ping, +};
Is there no way to setup a timeout to the WDOG device from userspace?
Quoted 147 lines
drivers/watchdog/bd96801_wdt.c new file +147
-0+ +static int find_closest_fast (int target,int *sel,int *val) +{ +int i; +int window =FASTNG_MIN ; + +for (i =0 ; i <8 && window < target; i++) + window <<=1 ; + + *val = window; + *sel = i; + +if (i ==8 ) +return -EINVAL ; + +return 0 ; +} + +static int find_closest_slow_by_fast (int fast_val,int *target,int *slowsel) +{ +int sel; +static const int multipliers[] = {2 ,4 ,8 ,16 }; + +for (sel =0 ; sel <ARRAY_SIZE (multipliers) && + multipliers[sel] * fast_val < *target; sel++) + ; + +if (sel ==ARRAY_SIZE (multipliers)) +return -EINVAL ; + + *slowsel = sel; + *target = multipliers[sel] * fast_val; + +return 0 ; +} + +static int find_closest_slow (int *target,int *slow_sel,int *fast_sel) +{ +static const int multipliers[] = {2 ,4 ,8 ,16 }; +int i, j; +int val =0 ; +int window =FASTNG_MIN ; + +for (i =0 ; i <8 ; i++) { +for (j =0 ; j <ARRAY_SIZE (multipliers); j++) { +int slow; + + slow = window * multipliers[j]; +if (slow >= *target && (!val || slow < val)) { + val = slow; + *fast_sel = i; + *slow_sel = j; + } + } + window <<=1 ; + } +if (!val) +return -EINVAL ; + + *target = val; + +return 0 ; +} + +static int bd96801_set_wdt_mode (struct wdtbd96801 *w,int hw_margin, +int hw_margin_min) +{ +int ret, fastng, slowng, type, reg, mask; +struct device *dev = w->dev; + +/* convert to uS */ + hw_margin *=1000 ; + hw_margin_min *=1000 ; +if (hw_margin_min) { +int min; + + type =BD96801_WD_TYPE_WIN ; +dev_dbg (dev,"Setting type WINDOW 0x%x\n" , type); + ret =find_closest_fast (hw_margin_min, &fastng, &min); +if (ret) { +dev_err (dev,"bad WDT window for fast timeout\n" ); +return ret; + } + + ret =find_closest_slow_by_fast (min, &hw_margin, &slowng); +if (ret) { +dev_err (dev,"bad WDT window\n" ); +return ret; + } + w->wdt.min_hw_heartbeat_ms = min /1000 ; + }else { + type =BD96801_WD_TYPE_SLOW ; +dev_dbg (dev,"Setting type SLOW 0x%x\n" , type); + ret =find_closest_slow (&hw_margin, &slowng, &fastng); +if (ret) { +dev_err (dev,"bad WDT window\n" ); +return ret; + } + } + + w->wdt.max_hw_heartbeat_ms = hw_margin /1000 ; + + fastng <<=ffs (BD96801_WD_TMO_SHORT_MASK ) -1 ; + + reg = slowng | fastng; + mask =BD96801_WD_RATIO_MASK |BD96801_WD_TMO_SHORT_MASK ; + ret =regmap_update_bits (w->regmap,BD96801_REG_WD_TMO , + mask, reg); +if (ret) +return ret; + + ret =regmap_update_bits (w->regmap,BD96801_REG_WD_CONF , +BD96801_WD_TYPE_MASK , type); + +return ret; +} + +static int bd96801_set_heartbeat_from_hw (struct wdtbd96801 *w, +unsigned int conf_reg) +{ +int ret; +unsigned int val, sel, fast; + +/* +* The BD96801 supports a somewhat peculiar QA-mode, which we do not +* support in this driver. If the QA-mode is enabled then we just +* warn and bail-out. +*/ +if ((conf_reg &BD96801_WD_EN_MASK ) !=BD96801_WD_IF_EN ) { +dev_warn (w->dev,"watchdog set to Q&A mode - exiting\n" ); +return -EINVAL ; + } + + ret =regmap_read (w->regmap,BD96801_REG_WD_TMO , &val); +if (ret) +return ret; + + sel = val &BD96801_WD_TMO_SHORT_MASK ; + sel >>=ffs (BD96801_WD_TMO_SHORT_MASK ) -1 ; + fast =FASTNG_MIN << sel; + + sel = (val &BD96801_WD_RATIO_MASK ) +1 ; + w->wdt.max_hw_heartbeat_ms = (fast << sel) /USEC_PER_MSEC ; + +if ((conf_reg &BD96801_WD_TYPE_MASK ) ==BD96801_WD_TYPE_WIN ) + w->wdt.min_hw_heartbeat_ms = fast /USEC_PER_MSEC ; +
drivers/watchdog/bd96801_wdt.c line 255
Quoted 10 lines
drivers/watchdog/bd96801_wdt.c new file +10
-0+return 0 ; +} + +static int init_wdg_hw (struct wdtbd96801 *w) +{ +u32 hw_margin[2 ]; +int count, ret; +u32 hw_margin_max =BD96801_WDT_DEFAULT_MARGIN , hw_margin_min =0 ; + + count =device_property_count_u32 (w->dev->parent,"rohm,hw-timeout-ms" );
Why is that timeout need to be configured from a devicce-tree property? set_timeout/get_timeout can't be done for this device?
Quoted 41 lines
drivers/watchdog/bd96801_wdt.c new file +41
-0+if (count <0 && count != -EINVAL ) +return count; + +if (count >0 ) { +if (count >ARRAY_SIZE (hw_margin)) +return -EINVAL ; + + ret =device_property_read_u32_array (w->dev->parent, +"rohm,hw-timeout-ms" , + &hw_margin[0 ], count); +if (ret <0 ) +return ret; + +if (count ==1 ) + hw_margin_max = hw_margin[0 ]; + +if (count ==2 ) { + hw_margin_max = hw_margin[1 ]; + hw_margin_min = hw_margin[0 ]; + } + } + + ret =bd96801_set_wdt_mode (w, hw_margin_max, hw_margin_min); +if (ret) +return ret; + + ret =device_property_match_string (w->dev->parent,"rohm,wdg-action" , +"prstb" ); +if (ret >=0 ) { + ret =regmap_update_bits (w->regmap,BD96801_REG_WD_CONF , +BD96801_WD_ASSERT_MASK , +BD96801_WD_ASSERT_RST ); +return ret; + } + + ret =device_property_match_string (w->dev->parent,"rohm,wdg-action" , +"intb-only" ); +if (ret >=0 ) { + ret =regmap_update_bits (w->regmap,BD96801_REG_WD_CONF , +BD96801_WD_ASSERT_MASK , +BD96801_WD_ASSERT_IRQ );
drivers/watchdog/bd96801_wdt.c line 306
Quoted 10 lines
drivers/watchdog/bd96801_wdt.c new file +10
-0+return ret; + } + +return 0 ; +} + +extern void emergency_restart (void ); +static irqreturn_t bd96801_irq_hnd (int irq,void *data) +{ +emergency_restart ();
In case of a full system hang will this function get executed?
Quoted 98 lines
drivers/watchdog/bd96801_wdt.c new file +83
-0+return IRQ_NONE ; +} + +static int bd96801_wdt_probe (struct platform_device *pdev) +{ +struct wdtbd96801 *w; +int ret, irq; +unsigned int val; + + w =devm_kzalloc (&pdev->dev,sizeof (*w),GFP_KERNEL ); +if (!w) +return -ENOMEM ; + + w->regmap =dev_get_regmap (pdev->dev.parent,NULL ); + w->dev = &pdev->dev; + + w->wdt.info = &bd96801_wdt_info; + w->wdt.ops = &bd96801_wdt_ops; + w->wdt.parent = pdev->dev.parent; + w->wdt.timeout =DEFAULT_TIMEOUT ; +watchdog_set_drvdata (&w->wdt, w); + + ret =regmap_read (w->regmap,BD96801_REG_WD_CONF , &val); +if (ret) +return dev_err_probe (&pdev->dev, ret, +"Failed to get the watchdog state\n" ); + +/* +* If the WDG is already enabled we assume it is configured by boot. +* In this case we just update the hw-timeout based on values set to +* the timeout / mode registers and leave the hardware configs +* untouched. +*/ +if ((val &BD96801_WD_EN_MASK ) !=BD96801_WD_DISABLE ) { +dev_dbg (&pdev->dev,"watchdog was running during probe\n" ); + ret =bd96801_set_heartbeat_from_hw (w, val); +if (ret) +return ret; + +set_bit (WDOG_HW_RUNNING , &w->wdt.status); + }else { +/* If WDG is not running so we will initializate it */ + ret =init_wdg_hw (w); +if (ret) +return ret; + } + +watchdog_init_timeout (&w->wdt,0 , pdev->dev.parent); +watchdog_set_nowayout (&w->wdt, nowayout); +watchdog_stop_on_reboot (&w->wdt); + + irq =platform_get_irq_byname (pdev,"bd96801-wdg" ); +if (irq >0 ) { + ret =devm_request_threaded_irq (&pdev->dev, irq,NULL , + bd96801_irq_hnd, +IRQF_ONESHOT ,"bd96801-wdg" , +NULL ); +if (ret) +return dev_err_probe (&pdev->dev, ret, +"Failed to register IRQ\n" ); + } + +return devm_watchdog_register_device (&pdev->dev, &w->wdt); +} + +static const struct platform_device_id bd96801_wdt_id[] = { + {"bd96801-wdt" , }, + { } +}; +MODULE_DEVICE_TABLE (platform, bd96801_wdt_id); + +static struct platform_driver bd96801_wdt = { + .driver = { + .name ="bd96801-wdt" + }, + .probe = bd96801_wdt_probe, + .id_table = bd96801_wdt_id, +}; +module_platform_driver (bd96801_wdt); + +MODULE_AUTHOR ("Matti Vaittinen <[email protected]>" ); +MODULE_DESCRIPTION ("BD96801 watchdog driver" ); +MODULE_LICENSE ("GPL" );Signature · 14 lines
2.43.2 -- Matti Vaittinen, Linux device drivers ROHM Semiconductors, Finland SWDC Kiviharjunlenkki 1E 90220 OULU FINLAND ~~~ "I don't think so," said Rene Descartes. Just then he vanished ~~~ Simon says - in Latin please. ~~~ "non cogito me" dixit Rene Descarte, deinde evanescavit ~~~ Thanks to Simon Glass for the translation =]
-George
Matti Vaittinen
maintainerRe: [RFC PATCH v2 5/6] watchdog: ROHM BD96801 PMIC WDG driver
Hi George,
Thanks for the input! Reviewing is very much appreciated :)
Quoted 26 lines · George Cherian
Quoted 25 lines · Matti Vaittinen
Introduce driver for WDG block on ROHM BD96801 scalable PMIC.
This driver only supports watchdog with I2C feeding and delayed response detection. Whether the watchdog toggles PRSTB pin or just causes an interrupt can be configured via device-tree.
The BD96801 PMIC HW supports also window watchdog (too early feeding detection) and Q&A mode. These are not supported by this driver.
Signed-off-by Matti Vaittinen <[email protected]>---
Revision history:
RFCv1 => RFCv2:
- remove always running
- add IRQ handling
- callemergency_restart()
- dropMODULE_ALIASand addMODULE_DEVICE_TABLE--- drivers/watchdog/Kconfig | 13 ++ drivers/watchdog/Makefile | 1 + drivers/watchdog/bd96801_wdt.c | 389 +++++++++++++++++++++++++++++++++ 3 files changed, 403 insertions(+)create mode 100644
drivers/watchdog/bd96801_wdt.c
Quoted 9 lines
drivers/watchdog/bd96801_wdt.c line 98
Quoted 7 lines
4
drivers/watchdog/bd96801_wdt.c new file +6
-0+ +static const struct watchdog_ops bd96801_wdt_ops = { + .start = bd96801_wdt_start, + .stop = bd96801_wdt_stop, + .ping = bd96801_wdt_ping, +};Is there no way to setup a timeout to the WDOG device from userspace?
For the BD96801 hardware? Currently no. (See below)
Quoted 10 lines
drivers/watchdog/bd96801_wdt.c line 255
Quoted 8 lines
drivers/watchdog/bd96801_wdt.c new file +8
-0+ +static int init_wdg_hw (struct wdtbd96801 *w) +{ +u32 hw_margin[2 ]; +int count, ret; +u32 hw_margin_max =BD96801_WDT_DEFAULT_MARGIN , hw_margin_min =0 ; + + count =device_property_count_u32 (w->dev->parent,"rohm,hw-timeout-ms" );Why is that timeout need to be configured from a devicce-tree property? set_timeout/get_timeout can't be done for this device?
The BD96801 supports 32 different "slow detection" timeouts - only 1 of which is guaranteed to be greater than 1s (1.8432 Sec). The timeout setting interface uses seconds.
Furthermore, I think that the HW heartbeat is not all that meaningful to the user-space. What is meaningful to user-space is how often the userland daemon needs to write the watchdog file to keep system alive. This is different thing. With the sub-second HW timeouts it is better the kernel keeps feeding the watchdog based on a timer (adjusted to meet the HW requirements) and can thus require the userspace to ping less frequently than the HW heartbeat.
Quoted 44 lines
Quoted 44 lines
drivers/watchdog/bd96801_wdt.c new file +44
-0+if (count <0 && count != -EINVAL ) +return count; + +if (count >0 ) { +if (count >ARRAY_SIZE (hw_margin)) +return -EINVAL ; + + ret =device_property_read_u32_array (w->dev->parent, +"rohm,hw-timeout-ms" , + &hw_margin[0 ], count); +if (ret <0 ) +return ret; + +if (count ==1 ) + hw_margin_max = hw_margin[0 ]; + +if (count ==2 ) { + hw_margin_max = hw_margin[1 ]; + hw_margin_min = hw_margin[0 ]; + } + } + + ret =bd96801_set_wdt_mode (w, hw_margin_max, hw_margin_min); +if (ret) +return ret; + + ret =device_property_match_string (w->dev->parent,"rohm,wdg-action" , +"prstb" ); +if (ret >=0 ) { + ret =regmap_update_bits (w->regmap,BD96801_REG_WD_CONF , +BD96801_WD_ASSERT_MASK , +BD96801_WD_ASSERT_RST ); +return ret; + } + + ret =device_property_match_string (w->dev->parent,"rohm,wdg-action" , +"intb-only" ); +if (ret >=0 ) { + ret =regmap_update_bits (w->regmap,BD96801_REG_WD_CONF , +BD96801_WD_ASSERT_MASK , +BD96801_WD_ASSERT_IRQ ); +return ret; + } +
Quoted 8 lines
drivers/watchdog/bd96801_wdt.c line 306
Quoted 7 lines
drivers/watchdog/bd96801_wdt.c new file +7
-0+return 0 ; +} + +extern void emergency_restart (void ); +static irqreturn_t bd96801_irq_hnd (int irq,void *data) +{ +emergency_restart ();In case of a full system hang will this function get executed?
Maybe, maybe not. It is probably still the best we can do if the watchdog has not been configured to kill the power by HW. Or, do you have some other suggestion? (The emergency_restart() was actually suggested by Guenter during the v1 review).
Quoted 2 lines
Review
Quoted 2 lines
(quoted diff) +2
-0+ return IRQ_NONE; +}
Yours,
-- Matti
Signature · 5 lines
Matti Vaittinen Linux kernel developer at ROHM Semiconductors Oulu Finland ~~ When things go utterly wrong vim users can always type :help! ~~
Matti Vaittinen
maintainerRe: [RFC PATCH v2 5/6] watchdog: ROHM BD96801 PMIC WDG driver
In reply to Matti VaittinenQuoted 68 lines · Matti Vaittinen
Introduce driver for WDG block on ROHM BD96801 scalable PMIC.
This driver only supports watchdog with I2C feeding and delayed response detection. Whether the watchdog toggles PRSTB pin or just causes an interrupt can be configured via device-tree.
The BD96801 PMIC HW supports also window watchdog (too early feeding detection) and Q&A mode. These are not supported by this driver.
Signed-off-by Matti Vaittinen <[email protected]>---
Revision history:
RFCv1 => RFCv2:
- remove always running
- add IRQ handling
- callemergency_restart()
- dropMODULE_ALIASand addMODULE_DEVICE_TABLE--- drivers/watchdog/Kconfig | 13 ++ drivers/watchdog/Makefile | 1 + drivers/watchdog/bd96801_wdt.c | 389 +++++++++++++++++++++++++++++++++ 3 files changed, 403 insertions(+)create mode 100644
drivers/watchdog/bd96801_wdt.cdrivers/watchdog/Kconfig +13
-0@@ -181,6 +181,19 @@ config BD957XMUF_WATCHDOG watchdog. Alternatively say M to compile the driver as a module, which will be called bd9576_wdt. +config BD96801_WATCHDOG + tristate "ROHM BD96801 PMIC Watchdog" + depends on MFD_ROHM_BD96801 + select WATCHDOG_CORE + help + Support for the watchdog in the ROHM BD96801 PMIC. Watchdog can be + configured to only generate IRQ or to trigger system reset via reset + pin. + + Say Y here to include support for the ROHM BD96801 watchdog. + Alternatively say M to compile the driver as a module, + which will be called bd96801_wdt. + config CROS_EC_WATCHDOG tristate "ChromeOS EC-based watchdog" select WATCHDOG_COREdrivers/watchdog/Makefile +1
-0@@ -217,6 +217,7 @@ obj-$(CONFIG_XEN_WDT) += xen_wdt.o # Architecture Independent obj-$(CONFIG_BD957XMUF_WATCHDOG) += bd9576_wdt.o +obj-$(CONFIG_BD96801_WATCHDOG) += bd96801_wdt.o obj-$(CONFIG_CROS_EC_WATCHDOG) += cros_ec_wdt.o obj-$(CONFIG_DA9052_WATCHDOG) += da9052_wdt.o obj-$(CONFIG_DA9055_WATCHDOG) += da9055_wdt.odrivers/watchdog/bd96801_wdt.c new file +0
-0@@ -0,0 +1,389 @@
...
Quoted 52 lines
drivers/watchdog/bd96801_wdt.c new file +52
-0+static int find_closest_fast (int target,int *sel,int *val) +{ +int i; +int window =FASTNG_MIN ; + +for (i =0 ; i <8 && window < target; i++) + window <<=1 ; + + *val = window; + *sel = i; + +if (i ==8 ) +return -EINVAL ; + +return 0 ; +} + +static int find_closest_slow_by_fast (int fast_val,int *target,int *slowsel) +{ +int sel; +static const int multipliers[] = {2 ,4 ,8 ,16 }; + +for (sel =0 ; sel <ARRAY_SIZE (multipliers) && + multipliers[sel] * fast_val < *target; sel++) + ; + +if (sel ==ARRAY_SIZE (multipliers)) +return -EINVAL ; + + *slowsel = sel; + *target = multipliers[sel] * fast_val; + +return 0 ; +} + +static int find_closest_slow (int *target,int *slow_sel,int *fast_sel) +{ +static const int multipliers[] = {2 ,4 ,8 ,16 }; +int i, j; +int val =0 ; +int window =FASTNG_MIN ; + +for (i =0 ; i <8 ; i++) { +for (j =0 ; j <ARRAY_SIZE (multipliers); j++) { +int slow; + + slow = window * multipliers[j]; +if (slow >= *target && (!val || slow < val)) { + val = slow; + *fast_sel = i; + *slow_sel = j; + }
drivers/watchdog/bd96801_wdt.c line 161
Quoted 10 lines
drivers/watchdog/bd96801_wdt.c new file +10
-0+ } + window <<=1 ; + } +if (!val) +return -EINVAL ; + + *target = val; + +return 0 ; +}
Thanks to the review comments by George, I took a more careful look on the supported watchdog time-outs. It appears the functions above don't work as intended. I think the logic is flawed, and some of the values correspond to an early design sample.
I will fix (and test) the timeout computations for the next version - but it is likely to take some time since I'd rather sent the v3 without the 'RFC'. Just wanted to warn people that it might be best to postpone proper review to v3.
Sorry...
Yours,
-- Matti
Signature · 5 lines
Matti Vaittinen Linux kernel developer at ROHM Semiconductors Oulu Finland ~~ When things go utterly wrong vim users can always type :help! ~~
Matti Vaittinen
maintainerRFC PATCH v2 6/6 MAINTAINERS: Add ROHM BD96801 'scalable PMIC' entries
In reply to Matti VaittinenAdd maintainer entries for ROHM BD96801 a.k.a 'scalable PMIC'
--- MAINTAINERS | 4 ++++ 1 file changed, 4 insertions(+)
MAINTAINERS +4 -0
@@ -19111,17 +19111,21 @@ F: drivers/gpio/gpio-bd71828.c F: drivers/mfd/rohm-bd71828.c F: drivers/mfd/rohm-bd718x7.c F: drivers/mfd/rohm-bd9576.c +F: drivers/mfd/rohm-bd96801.c F: drivers/regulator/bd71815-regulator.c F: drivers/regulator/bd71828-regulator.c F: drivers/regulator/bd718x7-regulator.c F: drivers/regulator/bd9576-regulator.c +F: drivers/regulator/bd96801-regulator.c F: drivers/regulator/rohm-regulator.c F: drivers/rtc/rtc-bd70528.c F: drivers/watchdog/bd9576_wdt.c +F: drivers/watchdog/bd96801_wdt.c F: include/linux/mfd/rohm-bd71815.h F: include/linux/mfd/rohm-bd71828.h F: include/linux/mfd/rohm-bd718x7.h F: include/linux/mfd/rohm-bd957x.h +F: include/linux/mfd/rohm-bd96801.h F: include/linux/mfd/rohm-generic.h F: include/linux/mfd/rohm-shared.h
Signature · 14 lines
2.43.2 -- Matti Vaittinen, Linux device drivers ROHM Semiconductors, Finland SWDC Kiviharjunlenkki 1E 90220 OULU FINLAND ~~~ "I don't think so," said Rene Descartes. Just then he vanished ~~~ Simon says - in Latin please. ~~~ "non cogito me" dixit Rene Descarte, deinde evanescavit ~~~ Thanks to Simon Glass for the translation =]