Support ROHM BD73800
Subsystems (7)
cover Support ROHM BD73800
Add support for the ROHM BD73800 PMIC and compatibles.
The ROHM BD73800 is a power management IC which integrates 8 BUCKs and 4 LDOs. There is also an ADC and operation amplifier intended for current / temperature measurement and accumulation. RTC and 32.768 kHz clock gate are also included. The PMIC can be customized via OTP and it has options for operating as a main PMIC in multi-PMIC installation. Some of the pins can also be used for GPO or GPI (including interrupt support).
There are also ROHM BD71851 and BD71885 PMICs out there. These are, from the SW-perspective, similar to the BD73800. There is only some different default values and OTP settings. The driver should be able to handle them just fine.
Oh, finally - there is absolutely no rush reviewing this. I am likely to be (mostly) offline for (at least) 3 weeks. So please, take your time, I probably will spin the next version only somewhere at August.
---
Matti Vaittinen (8):
dt-bindings: regulator: ROHM BD73800 regulators
dt-bindings: mfd: ROHM BD73800 PMIC
mfd: Support for ROHM BD73800 PMIC core
rtc: bd70528: Support RTC on ROHM BD73800
regulator: bd71828: Support ROHM BD73800
clk: bd718x7: Support ROHM BD73800
gpio: bd73800: Support ROHM BD73800 PMIC GPIOs
MAINTAINERS: Add ROHM BD73800 PMIC files
.../bindings/mfd/rohm,bd73800-pmic.yaml | 229 ++++++++ .../regulator/rohm,bd73800-regulator.yaml | 119 ++++ MAINTAINERS | 2 + drivers/clk/clk-bd718x7.c | 8 + drivers/gpio/Kconfig | 11 + drivers/gpio/Makefile | 1 + drivers/gpio/gpio-bd73800.c | 234 ++++++++ drivers/mfd/Kconfig | 15 +- drivers/mfd/rohm-bd71828.c | 145 ++++- drivers/regulator/Kconfig | 4 +- drivers/regulator/bd71828-regulator.c | 555 +++++++++++++++++- drivers/rtc/rtc-bd70528.c | 8 + include/linux/mfd/rohm-bd73800.h | 307 ++++++++++ include/linux/mfd/rohm-generic.h | 1 + 14 files changed, 1629 insertions(+), 10 deletions(-) create mode 100644 Documentation/devicetree/bindings/mfd/rohm,bd73800-pmic.yaml create mode 100644 Documentation/devicetree/bindings/regulator/rohm,bd73800-regulator.yaml create mode 100644 drivers/gpio/gpio-bd73800.c create mode 100644 include/linux/mfd/rohm-bd73800.h
base-commit: dc59e4fea9d83f03bad6bddf3fa2e52491777482
Signature · 1 line
2.54.0
PATCH 1/8 dt-bindings: regulator: ROHM BD73800 regulators
From: Matti Vaittinen <[email protected]>
Add bindings for the BUCKs and LDOs on ROHM BD73800. The PMIC state specific voltages can be set in same fashion as with a few other ROHM PMICs (for example with BD718[15,28,37,47,50,79]). Same properties are recycled :)
The LDOs 1 and 4 can use different voltage ranges depending on the OTP configuration.
--- .../regulator/rohm,bd73800-regulator.yaml | 119 ++++++++++++++++++ 1 file changed, 119 insertions(+) create mode 100644 Documentation/devicetree/bindings/regulator/rohm,bd73800-regulator.yaml
Documentation/devicetree/bindings/regulator/rohm,bd73800-regulator.yaml new file +119 -0
@@ -0,0 +1,119 @@ +# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/regulator/rohm,bd73800-regulator.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: ROHM BD73800 Power Management Integrated Circuit regulators + +maintainers: + - Matti Vaittinen <[email protected]> + +description: | + This module is part of the ROHM BD73800 MFD device. For more details + see Documentation/devicetree/bindings/mfd/rohm,bd73800-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 BD73800 regulator nodes are + buck1, buck2, buck3, buck4, buck5, buck6, buck7, buck8 + ldo1, ldo2, ldo3, ldo4 + +patternProperties: + "^buck[1-8]$": + type: object + description: + Properties for a single BUCK regulator. + $ref: regulator.yaml# + + properties: + regulator-name: + pattern: "^buck[1-8]$" + description: + should be "buck1", ..., "buck8" + + rohm,dvs-run-voltage: + description: + PMIC default "RUN" state voltage in uV. 0 means disabled. See the + explanation below for regulator specific details. + $ref: /schemas/types.yaml#/definitions/uint32 + minimum: 0 + maximum: 3500000 + + rohm,dvs-idle-voltage: + description: + PMIC default "IDLE" state voltage in uV. 0 means disabled. See the + explanation below for regulator specific details. + $ref: /schemas/types.yaml#/definitions/uint32 + minimum: 0 + maximum: 3500000 + + rohm,dvs-suspend-voltage: + description: + PMIC default "SUSPEND" state voltage in uV. 0 means disabled. See the + explanation below for regulator specific details. + $ref: /schemas/types.yaml#/definitions/uint32 + minimum: 0 + maximum: 3500000 + + # BUCKs 1,2,3,4 and 8 support voltages 0.5 - 1.3V + # BUCK 5 supports voltages 0.3 - 1.3V + # BUCKs 6 and 7 support voltages 1.5 - 3.5V + + required: + - regulator-name + + unevaluatedProperties: false + + "^ldo[1-4]$": + type: object + description: + Properties for single LDO regulator. + $ref: regulator.yaml# + + properties: + regulator-name: + pattern: "^ldo[1-4]$" + description: + should be "ldo1", ..., "ldo4" + + rohm,dvs-run-voltage: + description: + Set the default output state at PMIC's "RUN" state. + 0 is disabled, 1 is enabled. + $ref: /schemas/types.yaml#/definitions/uint32 + minimum: 0 + maximum: 1 + + rohm,dvs-idle-voltage: + description: + Set the default output state at PMIC's "IDLE" state. + 0 is disabled, 1 is enabled. + $ref: /schemas/types.yaml#/definitions/uint32 + minimum: 0 + maximum: 1 + + rohm,dvs-suspend-voltage: + description: + Set the default output state at PMIC's "SUSPEND" state. + 0 is disabled, 1 is enabled. + $ref: /schemas/types.yaml#/definitions/uint32 + minimum: 0 + maximum: 1 + + rohm,ldo-range-high: + type: boolean + description: + LDO1 and LDO3 voltage ranges can be "high" or "low" depending on + OTP. Indicate that the "high" range is used. See comment below + for voltages. + + # LDOs 2 and 4 support voltages 0.75 - 3.3V + # LDOs 1 and 3 may support different ranges depending on OTP. + # either 0.6 - 1.8V or 0.75 - 3.3V. + + unevaluatedProperties: false + +additionalProperties: false
Signature · 1 line
2.54.0
Rob Herring (Arm)
maintainerRe: [PATCH 1/8] dt-bindings: regulator: ROHM BD73800 regulators
Quoted 7 lines · Matti Vaittinen
From: Matti Vaittinen <[email protected]>
Add bindings for the BUCKs and LDOs on ROHM BD73800. The PMIC state specific voltages can be set in same fashion as with a few other ROHM PMICs (for example with BD718[15,28,37,47,50,79]). Same properties are recycled :)
Quoted 9 lines
The LDOs 1 and 4 can use different voltage ranges depending on the OTP configuration.
Signed-off-by Matti Vaittinen <[email protected]>--- .../regulator/rohm,bd73800-regulator.yaml | 119 ++++++++++++++++++ 1 file changed, 119 insertions(+) create mode 100644 Documentation/devicetree/bindings/regulator/rohm,bd73800-regulator.yaml
My bot found errors running 'make dt_binding_check' on your patch:
yamllint warnings/errors:
dtschema/dtc warnings/errors:
doc reference errors (make refcheckdocs):
Warning: Documentation/devicetree/bindings/regulator/rohm,bd73800-regulator.yaml references a file that doesn't exist: Documentation/devicetree/bindings/mfd/rohm,bd73800-pmic.yaml Documentation/devicetree/bindings/regulator/rohm,bd73800-regulator.yaml: Documentation/devicetree/bindings/mfd/rohm,bd73800-pmic.yaml
The base for the series is generally the latest rc1. A different dependency should be noted in *this* patch.
If you already ran 'make dt_binding_check' and didn't see the above error(s), then make sure 'yamllint' is installed and dt-schema is up to date:
pip3 install dtschema --upgrade
Please check and re-submit after running the above command yourself. Note that DT_SCHEMA_FILES can be set to your schema file to speed up checking your schema. However, it must be unset to test all examples with your schema.
Rob Herring
maintainerRe: [PATCH 1/8] dt-bindings: regulator: ROHM BD73800 regulators
In reply to Matti VaittinenQuoted 30 lines · Matti Vaittinen
From: Matti Vaittinen <[email protected]>
Add bindings for the BUCKs and LDOs on ROHM BD73800. The PMIC state specific voltages can be set in same fashion as with a few other ROHM PMICs (for example with BD718[15,28,37,47,50,79]). Same properties are recycled :)
The LDOs 1 and 4 can use different voltage ranges depending on the OTP configuration.
Signed-off-by Matti Vaittinen <[email protected]>--- .../regulator/rohm,bd73800-regulator.yaml | 119 ++++++++++++++++++ 1 file changed, 119 insertions(+) create mode 100644 Documentation/devicetree/bindings/regulator/rohm,bd73800-regulator.yamlDocumentation/devicetree/bindings/regulator/rohm,bd73800-regulator.yaml new file +7
-0+ rohm,dvs-run-voltage: + description: + PMIC default "RUN" state voltage in uV. 0 means disabled. See the + explanation below for regulator specific details. + $ref: /schemas/types.yaml#/definitions/uint32 + minimum: 0 + maximum: 3500000
[...]
Documentation/devicetree/bindings/regulator/rohm,bd73800-regulator.yaml line 88
Quoted 7 lines
Documentation/devicetree/bindings/regulator/rohm,bd73800-regulator.yaml new file +7
-0+ rohm,dvs-run-voltage: + description: + Set the default output state at PMIC's "RUN" state. + 0 is disabled, 1 is enabled. + $ref: /schemas/types.yaml#/definitions/uint32 + minimum: 0 + maximum: 1
Same property name with 2 different meanings. Not a good design pattern.
Also, if these properties are copied from other schemas, don't duplicate them. Put them in a common schema and reference it here.
Rob
Matti Vaittinen
maintainerRe: [PATCH 1/8] dt-bindings: regulator: ROHM BD73800 regulators
Hi Rob,
Thanks (again) for the review!
Quoted 42 lines · Rob Herring
Quoted 30 lines · Matti Vaittinen
From: Matti Vaittinen <[email protected]>
Add bindings for the BUCKs and LDOs on ROHM BD73800. The PMIC state specific voltages can be set in same fashion as with a few other ROHM PMICs (for example with BD718[15,28,37,47,50,79]). Same properties are recycled :)
The LDOs 1 and 4 can use different voltage ranges depending on the OTP configuration.
Signed-off-by Matti Vaittinen <[email protected]>--- .../regulator/rohm,bd73800-regulator.yaml | 119 ++++++++++++++++++ 1 file changed, 119 insertions(+)create mode 100644
Documentation/devicetree/bindings/regulator/rohm,bd73800-regulator.yamlDocumentation/devicetree/bindings/regulator/rohm,bd73800-regulator.yaml new file +7
-0+ rohm,dvs-run-voltage: + description: + PMIC default "RUN" state voltage in uV. 0 means disabled. See the + explanation below for regulator specific details. + $ref: /schemas/types.yaml#/definitions/uint32 + minimum: 0 + maximum: 3500000[...]
Documentation/devicetree/bindings/regulator/rohm,bd73800-regulator.yaml line 88
Quoted 7 lines
Documentation/devicetree/bindings/regulator/rohm,bd73800-regulator.yaml new file +7
-0+ rohm,dvs-run-voltage: + description: + Set the default output state at PMIC's "RUN" state. + 0 is disabled, 1 is enabled. + $ref: /schemas/types.yaml#/definitions/uint32 + minimum: 0 + maximum: 1
Quoted 1 line
Same property name with 2 different meanings. Not a good design pattern.
Hmm. They do actually have the same meaning. Setting the "RUN" -state voltage. Values '0' and '1' have special meaning "disable" and "enable" - also for BUCKs.
For LDOs on this PMIC, only the enable/disable configuration can be set for each hardware-state as the LDO voltage is same for all hardware states. Hence only subset of the property values (1/0) are supported for the LDOs.
Quoted 2 lines
Also, if these properties are copied from other schemas, don't duplicate them. Put them in a common schema and reference it here.
Ah. I think this is a great idea, and I should've thought that already a few PMICs ago :) We have been reviewing and discussing these properties with you since ... maybe 2018, as I've added new PMICs re-using them... ;)
Thanks! I'll rework this but v2 is likely to be out only at August.
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! ~~
PATCH 2/8 dt-bindings: mfd: ROHM BD73800 PMIC
In reply to Matti VaittinenFrom: Matti Vaittinen <[email protected]>
The ROHM BD73800 is a power management IC which integrates 8 BUCKs and 4 LDOs. There is also an ADC and operation amplifier intended for current / temperature measurement and accumulation. RTC and 32.768 kHz clock gate are also included. The PMIC can be customized via OTP and it has options for operating as a main PMIC in multi-PMIC installation. Some of the pins can also be used for GPO or GPI (including interrupt support).
There are also ROHM BD71851 and BD71885 PMICs out there. These are, from the SW-perspective, similar to the BD73800. There is only some different default values and OTP settings. The driver should be able to handle them just fine.
--- .../bindings/mfd/rohm,bd73800-pmic.yaml | 229 ++++++++++++++++++ 1 file changed, 229 insertions(+) create mode 100644 Documentation/devicetree/bindings/mfd/rohm,bd73800-pmic.yaml
Documentation/devicetree/bindings/mfd/rohm,bd73800-pmic.yaml new file +229 -0
@@ -0,0 +1,229 @@ +# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/mfd/rohm,bd73800-pmic.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: ROHM BD73800 Power Management Integrated Circuit + +maintainers: + - Matti Vaittinen <[email protected]> + +description: + BD73800GW is a single-chip power management IC for battery-powered + portable devices. It integrates 8 buck converters, 4 LDOs and a current + sense amplifier with ADC. Also included is a Real Time Clock (RTC) and a + 32.768 kHz clock gate. Depending on the OTP configuration the BD73800 + may also have interrupt controller and GPIOs. + + There are also different variants called BD71851 and BD71885 which are + almost identical from the software point of view. + +properties: + compatible: + oneOf: + - const: rohm,bd73800 + + - items: + - const: rohm,bd71851 + - const: rohm,bd73800 + + - items: + - const: rohm,bd71885 + - const: rohm,bd73800 + + reg: + maxItems: 1 + + interrupts: + maxItems: 1 + + # The GPIO1, CLKOUT (GPIO2), FAULT_B and EXTEN_OUT pins can be + # configured to interrupt pins by OTP. + interrupt-controller: true + + "#interrupt-cells": + const: 1 + description: + The IRQ number. 0 is GPIO1, 1 CLKOUT (GPIO2), 2 FAULT_B and 3 EXTEN_OUT. + NOTE, A pin can operate as IRQ source only when the OTP + configuration for it has been set to GPI. + + gpio-controller: true + + "#gpio-cells": + const: 2 + +# The GPIO1, CLKOUT, FAULT_B and EXTEN_OUT pins may be configured for a +# specific purpose (like ADC input, 32.768 clk output, fault indicator or +# delivering power sequence to a companion PMIC when multiple PMICs are +# used) - but also to be either a GPO or GPI. (When used as a GPI the pin +# can also be used as an IRQ source). The pin purpose is determined by +# OTP (One Time Programmable memory), typically during device manufacturing. +# The OTP can't be read at runtime so device-tree should describe the pins. + rohm,pin-gpio1: + $ref: /schemas/types.yaml#/definitions/string + description: + Indicate if the GPIO1 pin has been set to GPI or GPO at manufacturing. + enum: [gpi, gpo] + + rohm,pin-clkout: + $ref: /schemas/types.yaml#/definitions/string + description: + Indicate if the CLKOUT pin has been set to GPI or GPO at manufacturing. + enum: [gpi, gpo] + + rohm,pin-fault-b: + $ref: /schemas/types.yaml#/definitions/string + description: + Indicate if the FAULT_B pin has been set to GPI or GPO at manufacturing. + enum: [gpi, gpo] + + rohm,pin-exten: + $ref: /schemas/types.yaml#/definitions/string + description: + Indicate if the EXTEN_OUT pin has been set to GPI or GPO at + manufacturing. + enum: [gpi, gpo] + + # The CLKOUT pin may have its purpose overridden by OTP configuration. It is + # possible the BD73800 does not output a clock signal. Hence the optional clk + # properties. + clocks: + maxItems: 1 + + "#clock-cells": + const: 0 + + clock-output-names: + const: bd73800-32k-out + + rohm,clkout-open-drain: + description: clk32kout mode. Set to 1 for "open-drain" or 0 for "cmos". + $ref: /schemas/types.yaml#/definitions/uint32 + minimum: 0 + maximum: 1 + + regulators: + $ref: /schemas/regulator/rohm,bd73800-regulator.yaml + description: + List of child nodes that specify the regulators. + +required: + - compatible + - reg + - interrupts + - 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@4b { + compatible = "rohm,bd73800"; + reg = <0x4b>; + + interrupt-parent = <&gpio1>; + interrupts = <29 IRQ_TYPE_LEVEL_LOW>; + + clocks = <&osc 0>; + #clock-cells = <0>; + clock-output-names = "bd73800-32k-out"; + + gpio-controller; + #gpio-cells = <2>; + + rohm,pin-gpio1 = "gpo"; + rohm,pin-exten = "gpi"; + + regulators { + buck1: buck1 { + regulator-name = "buck1"; + regulator-min-microvolt = <800000>; + regulator-max-microvolt = <2000000>; + regulator-always-on; + regulator-ramp-delay = <1250>; + rohm,dvs-run-voltage = <1150000>; + rohm,dvs-suspend-voltage = <950000>; + }; + buck2: buck2 { + regulator-name = "buck2"; + regulator-min-microvolt = <800000>; + regulator-max-microvolt = <2000000>; + regulator-always-on; + regulator-ramp-delay = <1250>; + rohm,dvs-run-voltage = <1150000>; + rohm,dvs-suspend-voltage = <950000>; + }; + buck3: buck3 { + regulator-name = "buck3"; + regulator-min-microvolt = <1200000>; + regulator-max-microvolt = <2700000>; + rohm,dvs-run-voltage = <1150000>; + rohm,dvs-idle-voltage = <1100000>; + rohm,dvs-suspend-voltage = <950000>; + regulator-always-on; + }; + buck4: buck4 { + regulator-name = "buck4"; + regulator-min-microvolt = <1100000>; + regulator-max-microvolt = <1850000>; + regulator-always-on; + }; + buck5: buck5 { + regulator-name = "buck5"; + regulator-min-microvolt = <1800000>; + regulator-max-microvolt = <3300000>; + regulator-always-on; + }; + buck6: buck6 { + regulator-name = "buck6"; + regulator-min-microvolt = <1800000>; + regulator-max-microvolt = <3300000>; + regulator-always-on; + }; + buck7: buck7 { + regulator-name = "buck7"; + regulator-min-microvolt = <1800000>; + regulator-max-microvolt = <3300000>; + regulator-always-on; + }; + buck8: buck8 { + regulator-name = "buck8"; + regulator-min-microvolt = <500000>; + regulator-max-microvolt = <1300000>; + regulator-always-on; + }; + ldo1: ldo1 { + regulator-name = "ldo1"; + rohm,ldo-range-high; + regulator-min-microvolt = <800000>; + regulator-max-microvolt = <3300000>; + regulator-always-on; + }; + ldo2: ldo2 { + regulator-name = "ldo2"; + regulator-min-microvolt = <800000>; + regulator-max-microvolt = <3300000>; + regulator-always-on; + }; + ldo3: ldo3 { + regulator-name = "ldo3"; + regulator-min-microvolt = <800000>; + regulator-max-microvolt = <3300000>; + regulator-always-on; + }; + ldo4: ldo4 { + regulator-name = "ldo4"; + regulator-min-microvolt = <650000>; + regulator-max-microvolt = <1750000>; + regulator-always-on; + }; + }; + }; + };
Signature · 1 line
2.54.0
Re: [PATCH 2/8] dt-bindings: mfd: ROHM BD73800 PMIC
Quoted 11 lines · Matti Vaittinen
Documentation/devicetree/bindings/mfd/rohm,bd73800-pmic.yaml new file +11
-0+description: + BD73800GW is a single-chip power management IC for battery-powered + portable devices. It integrates 8 buck converters, 4 LDOs and a current + sense amplifier with ADC. Also included is a Real Time Clock (RTC) and a + 32.768 kHz clock gate. Depending on the OTP configuration the BD73800 + may also have interrupt controller and GPIOs. + + There are also different variants called BD71851 and BD71885 which are + almost identical from the software point of view. + +properties:
Documentation/devicetree/bindings/mfd/rohm,bd73800-pmic.yaml line 32
Quoted 10 lines
Documentation/devicetree/bindings/mfd/rohm,bd73800-pmic.yaml new file +10
-0+ compatible: + oneOf: + - const: rohm,bd73800 + + - items: + - const: rohm,bd71851 + - const: rohm,bd73800 + + - items: + - const: rohm,bd71885
items:
- enum:
-
-- const: rohm,bd73800
Quoted 15 lines
Documentation/devicetree/bindings/mfd/rohm,bd73800-pmic.yaml new file +15
-0+ - const: rohm,bd73800 + + reg: + maxItems: 1 + + interrupts: + maxItems: 1 + + # The GPIO1, CLKOUT (GPIO2), FAULT_B and EXTEN_OUT pins can be + # configured to interrupt pins by OTP. + interrupt-controller: true + + "#interrupt-cells": + const: 1 + description:
Documentation/devicetree/bindings/mfd/rohm,bd73800-pmic.yaml line 57
Quoted 10 lines
Documentation/devicetree/bindings/mfd/rohm,bd73800-pmic.yaml new file +10
-0+ The IRQ number. 0 is GPIO1, 1 CLKOUT (GPIO2), 2 FAULT_B and 3 EXTEN_OUT. + NOTE, A pin can operate as IRQ source only when the OTP + configuration for it has been set to GPI. + + gpio-controller: true + + "#gpio-cells": + const: 2 + +# The GPIO1, CLKOUT, FAULT_B and EXTEN_OUT pins may be configured for a
Missing two spaces (indent) before the comment, although this should be put into description. I understand it applies to each description - it is fine to add to the first one. Descriptions might be used to generate user-friendly representation of bindings (PDF). Comments won't, so comments are only to explain the binding/schema syntax choices.
Quoted 24 lines
Documentation/devicetree/bindings/mfd/rohm,bd73800-pmic.yaml new file +24
-0+# specific purpose (like ADC input, 32.768 clk output, fault indicator or +# delivering power sequence to a companion PMIC when multiple PMICs are +# used) - but also to be either a GPO or GPI. (When used as a GPI the pin +# can also be used as an IRQ source). The pin purpose is determined by +# OTP (One Time Programmable memory), typically during device manufacturing. +# The OTP can't be read at runtime so device-tree should describe the pins. + rohm,pin-gpio1: + $ref: /schemas/types.yaml#/definitions/string + description: + Indicate if the GPIO1 pin has been set to GPI or GPO at manufacturing. + enum: [gpi, gpo] + + rohm,pin-clkout: + $ref: /schemas/types.yaml#/definitions/string + description: + Indicate if the CLKOUT pin has been set to GPI or GPO at manufacturing. + enum: [gpi, gpo] + + rohm,pin-fault-b: + $ref: /schemas/types.yaml#/definitions/string + description: + Indicate if the FAULT_B pin has been set to GPI or GPO at manufacturing. + enum: [gpi, gpo] +
Documentation/devicetree/bindings/mfd/rohm,bd73800-pmic.yaml line 91
Quoted 10 lines
Documentation/devicetree/bindings/mfd/rohm,bd73800-pmic.yaml new file +10
-0+ rohm,pin-exten: + $ref: /schemas/types.yaml#/definitions/string + description: + Indicate if the EXTEN_OUT pin has been set to GPI or GPO at + manufacturing. + enum: [gpi, gpo] + + # The CLKOUT pin may have its purpose overridden by OTP configuration. It is + # possible the BD73800 does not output a clock signal. Hence the optional clk + # properties.
Same here
items:
- description: foo bar
Documentation/devicetree/bindings/mfd/rohm,bd73800-pmic.yaml line 99
Quoted 8 lines
Documentation/devicetree/bindings/mfd/rohm,bd73800-pmic.yaml new file +8
-0+ clocks: + maxItems: 1 + + "#clock-cells": + const: 0 + + clock-output-names: + const: bd73800-32k-out
If this is fixed, then drop clock-output-names. Otherwise should be just
maxItems: 1
Documentation/devicetree/bindings/mfd/rohm,bd73800-pmic.yaml line 105
Quoted 6 lines
Documentation/devicetree/bindings/mfd/rohm,bd73800-pmic.yaml new file +6
-0+ + rohm,clkout-open-drain: + description: clk32kout mode. Set to 1 for "open-drain" or 0 for "cmos". + $ref: /schemas/types.yaml#/definitions/uint32 + minimum: 0 + maximum: 1
Best regards,
Krzysztof
Matti Vaittinen
maintainerRe: [PATCH 2/8] dt-bindings: mfd: ROHM BD73800 PMIC
Hi dee Ho Krzysztof!
Thanks for the review (again)!
Quoted 25 lines · Krzysztof Kozlowski
Quoted 11 lines · Matti Vaittinen
Documentation/devicetree/bindings/mfd/rohm,bd73800-pmic.yaml new file +11
-0+description: + BD73800GW is a single-chip power management IC for battery-powered + portable devices. It integrates 8 buck converters, 4 LDOs and a current + sense amplifier with ADC. Also included is a Real Time Clock (RTC) and a + 32.768 kHz clock gate. Depending on the OTP configuration the BD73800 + may also have interrupt controller and GPIOs. + + There are also different variants called BD71851 and BD71885 which are + almost identical from the software point of view. + +properties:Documentation/devicetree/bindings/mfd/rohm,bd73800-pmic.yaml line 32
Quoted 10 lines
Documentation/devicetree/bindings/mfd/rohm,bd73800-pmic.yaml new file +10
-0+ compatible: + oneOf: + - const: rohm,bd73800 + + - items: + - const: rohm,bd71851 + - const: rohm,bd73800 + + - items: + - const: rohm,bd71885items:
- enum:
Quoted 3 lines
- -- const: rohm,bd73800
I suppose this will mean compatible is one of the enum values AND rohm,bd73800 as a fallback, while accepting also the rohm,bd73800 alone. (No need to reply, I will test it out). If so, then I'll do this for the next version (which is probably out only at August).
Quoted 24 lines
Quoted 24 lines
Documentation/devicetree/bindings/mfd/rohm,bd73800-pmic.yaml new file +23
-0+ - const: rohm,bd73800 + + reg: + maxItems: 1 + + interrupts: + maxItems: 1 + + # The GPIO1, CLKOUT (GPIO2), FAULT_B and EXTEN_OUT pins can be + # configured to interrupt pins by OTP. + interrupt-controller: true + + "#interrupt-cells": + const: 1 + description: + The IRQ number. 0 is GPIO1, 1 CLKOUT (GPIO2), 2 FAULT_B and 3 EXTEN_OUT. + NOTE, A pin can operate as IRQ source only when the OTP + configuration for it has been set to GPI. + + gpio-controller: true + + "#gpio-cells": + const: 2
Quoted 8 lines
Review
Quoted 2 lines
(quoted diff) +2
-0+ +# The GPIO1, CLKOUT, FAULT_B and EXTEN_OUT pins may be configured for aMissing two spaces (indent) before the comment, although this should be put into description. I understand it applies to each description - it is fine to add to the first one. Descriptions might be used to generate user-friendly representation of bindings (PDF). Comments won't, so comments are only to explain the binding/schema syntax choices.
This comment sounds like someone is crafting a tool which can convert the bindings to human-readable spec? For someone as yaml-illiterate as me, this really brings some hope :) Although, I would hope we saw some "comment-key" which could be used to mark the comment to be included in said human-readable format. Stuffing it in the 1.st description is Ok, but still somewhat sub-optimal. Oh well, "Ok" will do - I'll add this to the description when re-spinning.
I do appreciate your help and feedback (as always!).
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! ~~
Linus Walleij
maintainerRe: [PATCH 2/8] dt-bindings: mfd: ROHM BD73800 PMIC
In reply to Matti VaittinenHi Matti,
thanks for your patch!
I have some inevitable pin control nitpicks!
Documentation/devicetree/bindings/mfd/rohm,bd73800-pmic.yaml line 42
Quoted 2 lines · Matti Vaittinen
Documentation/devicetree/bindings/mfd/rohm,bd73800-pmic.yaml new file +2
-0+ # The GPIO1, CLKOUT (GPIO2), FAULT_B and EXTEN_OUT pins can be + # configured to interrupt pins by OTP.
Maybe move this helpful comment into the top description: instead? It's kind of generic helpful info.
Quoted 21 lines
Documentation/devicetree/bindings/mfd/rohm,bd73800-pmic.yaml new file +21
-0+# The GPIO1, CLKOUT, FAULT_B and EXTEN_OUT pins may be configured for a +# specific purpose (like ADC input, 32.768 clk output, fault indicator or +# delivering power sequence to a companion PMIC when multiple PMICs are +# used) - but also to be either a GPO or GPI. (When used as a GPI the pin +# can also be used as an IRQ source). The pin purpose is determined by +# OTP (One Time Programmable memory), typically during device manufacturing. +# The OTP can't be read at runtime so device-tree should describe the pins. + rohm,pin-gpio1: + $ref: /schemas/types.yaml#/definitions/string + description: + Indicate if the GPIO1 pin has been set to GPI or GPO at manufacturing. + enum: [gpi, gpo] + + rohm,pin-clkout: + $ref: /schemas/types.yaml#/definitions/string + description: + Indicate if the CLKOUT pin has been set to GPI or GPO at manufacturing. + enum: [gpi, gpo] + + rohm,pin-fault-b: + $ref: /schemas/types.yaml#/definitions/string
Documentation/devicetree/bindings/mfd/rohm,bd73800-pmic.yaml line 87
Quoted 10 lines
Documentation/devicetree/bindings/mfd/rohm,bd73800-pmic.yaml new file +10
-0+ description: + Indicate if the FAULT_B pin has been set to GPI or GPO at manufacturing. + enum: [gpi, gpo] + + rohm,pin-exten: + $ref: /schemas/types.yaml#/definitions/string + description: + Indicate if the EXTEN_OUT pin has been set to GPI or GPO at + manufacturing. + enum: [gpi, gpo]
Can we explain what "GPI" and "GPO" means in this context?
I read it as "general purpose input" and "general purpose output", but... you just describe the exact purpose? So what is "general purpose" about them in that case?
I would re-use "input-enable" and "output-enable" from:Documentation/devicetree/bindings/pinctrl/pincfg-node.yaml (I mean don't $rf that, just use these strings).
I suppose:
enum: [input-enable, output-enable]
Documentation/devicetree/bindings/mfd/rohm,bd73800-pmic.yaml line 105
Quoted 5 lines
Documentation/devicetree/bindings/mfd/rohm,bd73800-pmic.yaml new file +5
-0+ rohm,clkout-open-drain: + description: clk32kout mode. Set to 1 for "open-drain" or 0 for "cmos". + $ref: /schemas/types.yaml#/definitions/uint32 + minimum: 0 + maximum: 1
Here I would also reuse the generic pinconf properties, something like;
rohm,clkout-drive-type:
enum: [drive-push-pull, drive-open-drain]
(Push-pull is what is colloquially referred to as "cmos".)
Documentation/devicetree/bindings/mfd/rohm,bd73800-pmic.yaml line 142
Quoted 2 lines
Documentation/devicetree/bindings/mfd/rohm,bd73800-pmic.yaml new file +2
-0+ rohm,pin-gpio1 = "gpo"; + rohm,pin-exten = "gpi";
If you instead use nodes with properties you can do this:
rohm,pin-clkout {
output-enable;
drive-push-pull;
};This collects the clkout config in one place and make it obvious what is going on. But I don't know what the DT maintainers think about this idea.
Yours,
Linus Walleij
Matti Vaittinen
maintainerRe: [PATCH 2/8] dt-bindings: mfd: ROHM BD73800 PMIC
pe 3.7.2026 klo 23.46 Linus Walleij ([email protected]) kirjoitti:
Quoted 4 lines
Hi Matti,
thanks for your patch!
Thank you for the review!
Quoted 1 line
I have some inevitable pin control nitpicks!
Great! That's what the v1 is sent for, right? ;)
Quoted 9 lines
Documentation/devicetree/bindings/mfd/rohm,bd73800-pmic.yaml line 42
Quoted 2 lines · Matti Vaittinen
Documentation/devicetree/bindings/mfd/rohm,bd73800-pmic.yaml new file +2
-0+ # The GPIO1, CLKOUT (GPIO2), FAULT_B and EXTEN_OUT pins can be + # configured to interrupt pins by OTP.Maybe move this helpful comment into the top description: instead? It's kind of generic helpful info.
Sure. I believe Krzk asked for that too.
Quoted 35 lines
Quoted 22 lines
Documentation/devicetree/bindings/mfd/rohm,bd73800-pmic.yaml new file +21
-0+# The GPIO1, CLKOUT, FAULT_B and EXTEN_OUT pins may be configured for a +# specific purpose (like ADC input, 32.768 clk output, fault indicator or +# delivering power sequence to a companion PMIC when multiple PMICs are +# used) - but also to be either a GPO or GPI. (When used as a GPI the pin +# can also be used as an IRQ source). The pin purpose is determined by +# OTP (One Time Programmable memory), typically during device manufacturing. +# The OTP can't be read at runtime so device-tree should describe the pins. + rohm,pin-gpio1: + $ref: /schemas/types.yaml#/definitions/string + description: + Indicate if the GPIO1 pin has been set to GPI or GPO at manufacturing. + enum: [gpi, gpo] + + rohm,pin-clkout: + $ref: /schemas/types.yaml#/definitions/string + description: + Indicate if the CLKOUT pin has been set to GPI or GPO at manufacturing. + enum: [gpi, gpo] + + rohm,pin-fault-b: + $ref: /schemas/types.yaml#/definitions/stringDocumentation/devicetree/bindings/mfd/rohm,bd73800-pmic.yaml line 87
Quoted 10 lines
Documentation/devicetree/bindings/mfd/rohm,bd73800-pmic.yaml new file +10
-0+ description: + Indicate if the FAULT_B pin has been set to GPI or GPO at manufacturing. + enum: [gpi, gpo] + + rohm,pin-exten: + $ref: /schemas/types.yaml#/definitions/string + description: + Indicate if the EXTEN_OUT pin has been set to GPI or GPO at + manufacturing. + enum: [gpi, gpo]Can we explain what "GPI" and "GPO" means in this context?
Quoted 3 lines
I read it as "general purpose input" and "general purpose output", but... you just describe the exact purpose? So what is "general purpose" about them in that case?
I see I could improve the description. These properties aren't really configuring the pins, but telling the SW how they have been set at the manufacturing. For example the CLKOUT pin's "usual" purpose is to be the RTC CLK output. If this is what has been set to OTP, then the GP(IO) registers have no relation to the pin and they shouldn't be used. However, it is possible to configure the OTP so that the CLKOUT pin is not outputting the RTC CLK, but is a GPO. (Eg, is an output which HIGH/LOW state can be set by the software). In this case it truly is a general purpose output. With another OTP config the pin can be an input, and state can be read from a register.
So, these properties are intended to describe the hardware for the GPIO driver.
Quoted 7 lines
I would re-use "input-enable" and "output-enable" from:
Documentation/devicetree/bindings/pinctrl/pincfg-node.yaml(I mean don't $rf that, just use these strings).I suppose:
enum: [input-enable, output-enable]
These sound like control properties to me. To me this sounds like a request to enable input/output - and this is something we can't do with this IC. But I think you still have a valid point regarding re-use. I will check this when I rework the series, but I believe the BD72720 does already use these same properties. I might be able to do a common binding for these and $ref them from this and BD72720 bindings. (But I will check this when I am back at the business).
Quoted 20 lines
Documentation/devicetree/bindings/mfd/rohm,bd73800-pmic.yaml line 105
Quoted 6 lines
Documentation/devicetree/bindings/mfd/rohm,bd73800-pmic.yaml new file +5
-0+ rohm,clkout-open-drain: + description: clk32kout mode. Set to 1 for "open-drain" or 0 for "cmos". + $ref: /schemas/types.yaml#/definitions/uint32 + minimum: 0 + maximum: 1Here I would also reuse the generic pinconf properties, something like;
rohm,clkout-drive-type:
enum: [drive-push-pull, drive-open-drain](Push-pull is what is colloquially referred to as "cmos".)
Documentation/devicetree/bindings/mfd/rohm,bd73800-pmic.yaml line 142
Quoted 2 lines
Documentation/devicetree/bindings/mfd/rohm,bd73800-pmic.yaml new file +2
-0+ rohm,pin-gpio1 = "gpo"; + rohm,pin-exten = "gpi";If you instead use nodes with properties you can do this:
Quoted 8 lines
rohm,pin-clkout { output-enable; drive-push-pull; };This collects the clkout config in one place and make it obvious what is going on. But I don't know what the DT maintainers think about this idea.
I will take a better look at this when I am back. Still, the "rohm,clkout-open-drain" is also already used by rohm,bd71815-pmic.yaml, rohm,bd71828-pmic.yaml and rohm,bd72720-pmic.yaml so I am a bit reluctant to changing it as it'd require me to either ask people to change their dt-entries (asking for a nose bleed) or support both old and new properties in the same driver (asking for a nose bleed). :)
Yours,
-- Matti
Signature · 8 lines
Matti Vaittinen Linux kernel developer at ROHM Semiconductors Oulu Finland ~~ When things go utterly wrong vim users can always type :help! ~~ Discuss - Estimate - Plan - Report and finally accomplish this: void do_work(int time) __attribute__ ((const));
Matti Vaittinen
maintainerRe: [PATCH 2/8] dt-bindings: mfd: ROHM BD73800 PMIC
In reply to Linus WalleijHi dee Ho Linus,
The way too short summer holiday is now gone, so I am back at this :) Thanks again for the comments, I am trying to improve for v2 ;)
Quoted 43 lines · Linus Walleij
Documentation/devicetree/bindings/mfd/rohm,bd73800-pmic.yaml line 42
Quoted 2 lines · Matti Vaittinen
Documentation/devicetree/bindings/mfd/rohm,bd73800-pmic.yaml new file +2
-0+ # The GPIO1, CLKOUT (GPIO2), FAULT_B and EXTEN_OUT pins can be + # configured to interrupt pins by OTP.Maybe move this helpful comment into the top description: instead? It's kind of generic helpful info.
Quoted 21 lines
Documentation/devicetree/bindings/mfd/rohm,bd73800-pmic.yaml new file +21
-0+# The GPIO1, CLKOUT, FAULT_B and EXTEN_OUT pins may be configured for a +# specific purpose (like ADC input, 32.768 clk output, fault indicator or +# delivering power sequence to a companion PMIC when multiple PMICs are +# used) - but also to be either a GPO or GPI. (When used as a GPI the pin +# can also be used as an IRQ source). The pin purpose is determined by +# OTP (One Time Programmable memory), typically during device manufacturing. +# The OTP can't be read at runtime so device-tree should describe the pins. + rohm,pin-gpio1: + $ref: /schemas/types.yaml#/definitions/string + description: + Indicate if the GPIO1 pin has been set to GPI or GPO at manufacturing. + enum: [gpi, gpo] + + rohm,pin-clkout: + $ref: /schemas/types.yaml#/definitions/string + description: + Indicate if the CLKOUT pin has been set to GPI or GPO at manufacturing. + enum: [gpi, gpo] + + rohm,pin-fault-b: + $ref: /schemas/types.yaml#/definitions/stringDocumentation/devicetree/bindings/mfd/rohm,bd73800-pmic.yaml line 87
Quoted 10 lines
Documentation/devicetree/bindings/mfd/rohm,bd73800-pmic.yaml new file +10
-0+ description: + Indicate if the FAULT_B pin has been set to GPI or GPO at manufacturing. + enum: [gpi, gpo] + + rohm,pin-exten: + $ref: /schemas/types.yaml#/definitions/string + description: + Indicate if the EXTEN_OUT pin has been set to GPI or GPO at + manufacturing. + enum: [gpi, gpo]Can we explain what "GPI" and "GPO" means in this context?
Quoted 3 lines
I read it as "general purpose input" and "general purpose output", but... you just describe the exact purpose? So what is "general purpose" about them in that case?
These property names (pin-gpio1, pin-clkout, pin-fault-b, pin-exten) do not define the purpose of the pin, but they match the pin name in the data-sheet. The idea is indeed to be able to say "the fault-b -pin is not a fault signal, but a general purpose input" - if the IC we are describing here has OTP configuration enabling this.
I am re-using the approach from the BD72720 here. I think I will add a common binding file with these, which can then be referred by multiple rohm ICs (in same fashion I added the Documentation/devicetree/bindings/regulator/rohm,pmic-states.yaml for commonly used ROHM regulator properties). I'll see if it looks Ok (to me), and send it in v2 :)
Quoted 13 lines
I would re-use "input-enable" and "output-enable" from:
Documentation/devicetree/bindings/pinctrl/pincfg-node.yaml(I mean don't $rf that, just use these strings).I suppose:
enum: [input-enable, output-enable]Documentation/devicetree/bindings/mfd/rohm,bd73800-pmic.yaml line 105
Quoted 5 lines
Documentation/devicetree/bindings/mfd/rohm,bd73800-pmic.yaml new file +5
-0+ rohm,clkout-open-drain: + description: clk32kout mode. Set to 1 for "open-drain" or 0 for "cmos". + $ref: /schemas/types.yaml#/definitions/uint32 + minimum: 0 + maximum: 1
Quoted 5 lines
Here I would also reuse the generic pinconf properties, something like;
rohm,clkout-drive-type:
enum: [drive-push-pull, drive-open-drain]
As I mentioned in my very hasty original reply, this is also an existing binding used in quite a few PMIC device-trees. Changing it now sounds like asking for problems, for (in my opinion) little benefit. Yet, since it is used by a few PMICs, I could perhaps put it in a common rohm binding file as well. Then it would be more obvious it is an existing property if new models re-use this.
Quoted 1 line
(Push-pull is what is colloquially referred to as "cmos".)
I will at least add a.k.a "push-pull" to the description :)
Quoted 6 lines
Documentation/devicetree/bindings/mfd/rohm,bd73800-pmic.yaml line 142
Quoted 3 lines
Documentation/devicetree/bindings/mfd/rohm,bd73800-pmic.yaml new file +2
-0+ rohm,pin-gpio1 = "gpo"; + rohm,pin-exten = "gpi";If you instead use nodes with properties you can do this:
Quoted 8 lines
rohm,pin-clkout { output-enable; drive-push-pull; };This collects the clkout config in one place and make it obvious what is going on. But I don't know what the DT maintainers think about this idea.
I believe you mean I could translate:
rohm,pin-clkout = "gpo";
rohm,clkout-open-drain = <0>;
to
rohm,pin-clkout {
output-enable;
drive-push-pull;
};right?
I am actually not sure if this would work. The data-sheet made me to assume it might not. There is separate "OUT32K" register, which controls the clock gate. This, as far as I understand, is not usable when the OTP variant sets the CLKOUT -pin to GPO. The mode (open-drain / cmos) configuration resides in this clock gate register.
[Just to complete picture, when OTP is set to GPO, the pin output is controlled by GPIO_OUT register instead. When OTP has set the pin to clk output (or to GPI), then the GPIO_OUT register writes have no impact.]
Thus, in case of the BD73800, the:
rohm,pin-clkout = "gpo";
rohm,clkout-open-drain = <0>;
might actually be contradicting.
...
Now, I will make a side-note... The data-sheet front page says:
Quoted 4 lines
4 GPIOs
- OTP Option for GPIOs instead of I/F signals:EXTEN_OUT,FAULT_B, CLKOUT, GPIO1
- GPO Supports Open Drain and CMOS Output
I, however, see no register control for the GPO output types. I _assume_ the output type (when pins are used for GPO) depends on OTP again. I will see if I can clarify this.
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! ~~
PATCH 3/8 mfd: Support for ROHM BD73800 PMIC core
In reply to Matti VaittinenFrom: Matti Vaittinen <[email protected]>
The BD73800 integrates regulators, ADC (intended for accumulating current / voltage / power values), a real-time clock (RTC), clock gate and GPIOs.
Add core support for ROHM BD73800 Power Management IC.
--- drivers/mfd/Kconfig | 15 +- drivers/mfd/rohm-bd71828.c | 145 ++++++++++++++- include/linux/mfd/rohm-bd73800.h | 307 +++++++++++++++++++++++++++++++ include/linux/mfd/rohm-generic.h | 1 + 4 files changed, 461 insertions(+), 7 deletions(-) create mode 100644 include/linux/mfd/rohm-bd73800.h
drivers/mfd/Kconfig +9 -6
@@ -2222,7 +2222,7 @@ config MFD_ROHM_BD718XX and emergency shut down as well as 32,768KHz clock output. config MFD_ROHM_BD71828 - tristate "ROHM BD718[15/28/79], BD72720 and BD73900 PMICs" + tristate "ROHM BD718[15/28/79], BD72720 and BD73[8/9]00 PMICs" depends on I2C=y depends on OF select REGMAP_I2C
@@ -2230,14 +2230,17 @@ config MFD_ROHM_BD71828 select MFD_CORE help Select this option to get support for the ROHM BD71815, BD71828, - BD71879, BD72720 and BD73900 Power Management ICs (PMICs). These are - single-chip Power Management ICs (PMIC), mainly for battery-powered - portable devices. + BD71879, BD72720, BD73800 and BD73900 Power Management ICs (PMICs). + These are single-chip Power Management ICs (PMIC), mainly for + battery-powered portable devices. The BD71815 has 5 bucks, 7 LDOs, and a boost for driving LEDs. The BD718[28/79] have 7 buck converters and 7 LDOs. The BD72720 and the BD73900 have 10 bucks and 11 LDOs. - All ICs provide a single-cell linear charger, a Coulomb counter, - a Real-Time Clock (RTC), GPIOs and a 32.768 kHz clock gate. + All the above ICs provide a single-cell linear charger, and a Coulomb + counter. + The BD73800 has 8 bucks, 4 LDOs and ADC for power/current + accumulation but no charging logic. All these PMICs integrate also a + Real-Time Clock (RTC), GPIOs and a 32.768 kHz clock gate. config MFD_ROHM_BD957XMUF tristate "ROHM BD9576MUF and BD9573MUF Power Management ICs"
drivers/mfd/rohm-bd71828.c +144 -1
211 lines not on this page · raw message
include/linux/mfd/rohm-bd73800.h new file +307 -0
307 lines not on this page · raw message
include/linux/mfd/rohm-generic.h +1 -0
@@ -17,6 +17,7 @@ enum rohm_chip_type {ROHM_CHIP_TYPE_BD71837 ,ROHM_CHIP_TYPE_BD71847 ,ROHM_CHIP_TYPE_BD72720 , +ROHM_CHIP_TYPE_BD73800 ,ROHM_CHIP_TYPE_BD96801 ,ROHM_CHIP_TYPE_BD96802 , ROHM_CHIP_TYPE_BD96805,
Signature · 1 line
2.54.0
Lee Jones
maintainerRe: [PATCH 3/8] mfd: Support for ROHM BD73800 PMIC core
/* Sashiko Automation: Reviewed (0 Findings) */
Quoted 21 lines · Matti Vaittinen
From: Matti Vaittinen <[email protected]>
The BD73800 integrates regulators, ADC (intended for accumulating current / voltage / power values), a real-time clock (RTC), clock gate and GPIOs.
Add core support for ROHM BD73800 Power Management IC.
Signed-off-by Matti Vaittinen <[email protected]>--- drivers/mfd/Kconfig | 15 +- drivers/mfd/rohm-bd71828.c | 145 ++++++++++++++- include/linux/mfd/rohm-bd73800.h | 307 +++++++++++++++++++++++++++++++ include/linux/mfd/rohm-generic.h | 1 + 4 files changed, 461 insertions(+), 7 deletions(-) create mode 100644 include/linux/mfd/rohm-bd73800.hdrivers/mfd/rohm-bd71828.c +0
-0
drivers/mfd/rohm-bd71828.c line 4
Quoted 3 lines
drivers/mfd/rohm-bd71828.c +0
-0@@ -2,7 +2,7 @@/* * Copyright (C) 2019 ROHM Semiconductors *
You should consider updating this.
Quoted 9 lines
drivers/mfd/rohm-bd71828.c +1
-1-* ROHM BD718[15/28/79] and BD72720 PMIC driver +* ROHM BD718[15/28/79], BD72720 and BD73[8/9]00 PMIC driver */ #include <linux/gpio_keys.h> @@ -249,6 +256,17 @@ static const struct mfd_cell bd72720_mfd_cells[] = { }, };
drivers/mfd/rohm-bd71828.c static const struct mfd_cell bd72720_mfd_cells[] = { · line 268
Quoted 10 lines
drivers/mfd/rohm-bd71828.c +10
-0+static const struct mfd_cell bd73800_mfd_cells[] = { + { .name ="bd73800-pmic" , }, + { .name ="bd73800-clk" , }, + { .name ="bd73800-gpio" , }, + { + .name ="bd73800-rtc" , + .num_resources =ARRAY_SIZE (bd73800_rtc_irqs), + .resources = &bd73800_rtc_irqs[0 ], + }, +};
'bd73800_rtc_irqs'?
drivers/mfd/rohm-bd71828.c static const struct regmap_access_table bd72720_volatile_regs_4c = { · line 416
Quoted 10 lines
drivers/mfd/rohm-bd71828.c +3
-0+static const struct regmap_range bd71815_volatile_ranges[] = {regmap_reg_range (BD71815_REG_SEC ,BD71815_REG_YEAR ),regmap_reg_range (BD71815_REG_CONF ,BD71815_REG_BAT_TEMP ),@@ -383,6 +412,24 @@ static const struct regmap_access_table bd72720_volatile_regs_4c = { .n_yes_ranges = ARRAY_SIZE(bd72720_volatile_ranges_4c), }; +static const struct regmap_access_table bd73800_volatile_regs = { + .yes_ranges = &bd73800_volatile_ranges[0 ],
'bd73800_volatile_ranges'?
drivers/mfd/rohm-bd71828.c static const struct regmap_access_table bd72720_volatile_regs_4c = { · line 429
Quoted 13 lines
drivers/mfd/rohm-bd71828.c +13
-0+ .n_yes_ranges = ARRAY_SIZE(bd73800_volatile_ranges), +}; + +static const struct regmap_range bd73800_read_only_ranges[] = { +regmap_reg_range (BD73800_REG_PRODUCT_ID ,BD73800_REG_NVMVERSION ), +regmap_reg_range (BD73800_REG_POW_STATE ,BD73800_REG_POW_STATE ), +regmap_reg_range (BD73800_REG_ADC_ACCUM_CNT2 ,BD73800_REG_ADC_TEMP_VAL0 ), +regmap_reg_range (BD73800_REG_INT_MAIN_STAT ,BD73800_REG_INT_MAIN_STAT ), +regmap_reg_range (BD73800_REG_INT_MAIN_SRC ,BD73800_REG_INT_5_SRC ), +}; + +static const struct regmap_access_table bd73800_ro_regs = { + .no_ranges = &bd73800_read_only_ranges[0 ],
Etc.
Quoted 7 lines
drivers/mfd/rohm-bd71828.c +3
-0+ .n_no_ranges = ARRAY_SIZE(bd73800_read_only_ranges), +}; +static const struct regmap_config bd71815_regmap = { .reg_bits =8 , .val_bits =8 ,
drivers/mfd/rohm-bd71828.c static const struct regmap_irq_chip bd72720_irq_chip = { · line 968
Quoted 7 lines
drivers/mfd/rohm-bd71828.c +4
-0@@ -852,6 +962,25 @@ static const struct regmap_irq_chip bd72720_irq_chip = { .irq_reg_stride = 1, }; +static const struct regmap_irq_chip bd73800_irq_chip = { + .name ="bd73800_irq" , + .main_status =BD73800_REG_INT_MAIN_STAT , + .irqs = &bd73800_irqs[0 ],
Here too.
Quoted 24 lines
drivers/mfd/rohm-bd71828.c +15
-0+ .num_irqs = ARRAY_SIZE(bd73800_irqs), + .status_base = BD73800_REG_INT_1_STAT, + .unmask_base = BD73800_REG_INT_1_EN, + .ack_base = BD73800_REG_INT_1_STAT, + .init_ack_masked = true, + .num_regs = 5, + .num_main_regs = 1, +/* +* Ignore mirrored bits [7:5]. They are handled as part of normal INT_4 +* handling. +*/ + .num_main_status_bits = 5, + .irq_reg_stride = 1, +}; +static int set_clk_mode (struct device *dev,struct regmap *regmap,int clkmode_reg) {include/linux/mfd/rohm-bd73800.h new file +0
-0
include/linux/mfd/rohm-bd73800.h line 4
Quoted 4 lines
include/linux/mfd/rohm-bd73800.h new file +4
-0@@ -0,0 +1,307 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ +/* +* Copyright 2024 ROHM Semiconductors. +*
This is new to use. Please update this too.
Quoted 8 lines
include/linux/mfd/rohm-bd73800.h new file +8
-0+* Author: Matti Vaittinen <[email protected]> +*/ + +#ifndef _MFD_BD73800_H +#define _MFD_BD73800_H + +#include <linux/regmap.h> +
Matti Vaittinen
maintainerRe: [PATCH 3/8] mfd: Support for ROHM BD73800 PMIC core
to 9.7.2026 klo 13.48 Lee Jones ([email protected]) kirjoitti:
Quoted 21 lines
/* Sashiko Automation: Reviewed (0 Findings) */
Quoted 16 lines · Matti Vaittinen
From: Matti Vaittinen <[email protected]>
The BD73800 integrates regulators, ADC (intended for accumulating current / voltage / power values), a real-time clock (RTC), clock gate and GPIOs.
Add core support for ROHM BD73800 Power Management IC.
Signed-off-by Matti Vaittinen <[email protected]>--- drivers/mfd/Kconfig | 15 +- drivers/mfd/rohm-bd71828.c | 145 ++++++++++++++- include/linux/mfd/rohm-bd73800.h | 307 +++++++++++++++++++++++++++++++ include/linux/mfd/rohm-generic.h | 1 + 4 files changed, 461 insertions(+), 7 deletions(-) create mode 100644 include/linux/mfd/rohm-bd73800.h
Thank you Lee for review. I agree with your suggestions. I'll re-spin this probably at early August.
Yours.
-- Matti
Signature · 8 lines
Matti Vaittinen Linux kernel developer at ROHM Semiconductors Oulu Finland ~~ When things go utterly wrong vim users can always type :help! ~~ Discuss - Estimate - Plan - Report and finally accomplish this: void do_work(int time) __attribute__ ((const));
PATCH 4/8 rtc: bd70528: Support RTC on ROHM BD73800
In reply to Matti VaittinenFrom: Matti Vaittinen <[email protected]>
BD73800 contains similar RTC block as BD71828 and BD71815. Only the address offsets seem different. Support also BD73800 RTC using the rtc-bd70528.
--- drivers/rtc/rtc-bd70528.c | 8 ++++++++ 1 file changed, 8 insertions(+)
drivers/rtc/rtc-bd70528.c +8 -0
@@ -8,6 +8,7 @@#include <linux/mfd/rohm-bd71815.h> #include <linux/mfd/rohm-bd71828.h> #include <linux/mfd/rohm-bd72720.h> +#include <linux/mfd/rohm-bd73800.h> #include <linux/module.h> #include <linux/of.h> #include <linux/platform_device.h>
@@ -284,6 +285,12 @@ static int bd70528_probe(struct platform_device *pdev) bd_rtc->bd718xx_alm_block_start =BD72720_REG_RTC_ALM_START ; hour_reg =BD72720_REG_RTC_HOUR ;break ; +case ROHM_CHIP_TYPE_BD73800 : + bd_rtc->reg_time_start =BD73800_REG_RTC_START ; + bd_rtc->bd718xx_alm_block_start =BD73800_REG_RTC_ALM_START ; + hour_reg =BD73800_REG_RTC_HOUR ; +break ; +default :dev_err (&pdev->dev,"Unknown chip\n" );return -ENOENT ;
@@ -344,6 +351,7 @@ static const struct platform_device_id bd718x7_rtc_id[] = { { .name = "bd71828-rtc", .driver_data = ROHM_CHIP_TYPE_BD71828 }, { .name = "bd71815-rtc", .driver_data = ROHM_CHIP_TYPE_BD71815 }, { .name = "bd72720-rtc", .driver_data = ROHM_CHIP_TYPE_BD72720 }, + { .name = "bd73800-rtc", .driver_data = ROHM_CHIP_TYPE_BD73800 }, { } };MODULE_DEVICE_TABLE (platform, bd718x7_rtc_id);
Signature · 1 line
2.54.0
Re: [PATCH 4/8] rtc: bd70528: Support RTC on ROHM BD73800
Quoted 6 lines · Matti Vaittinen
From: Matti Vaittinen <[email protected]>
BD73800 contains similar RTC block as BD71828 and BD71815. Only the address offsets seem different. Support also BD73800 RTC using the rtc-bd70528.
Signed-off-by Matti Vaittinen <[email protected]>
Quoted 40 lines
--- drivers/rtc/rtc-bd70528.c | 8 ++++++++ 1 file changed, 8 insertions(+)drivers/rtc/rtc-bd70528.c +8
-0@@ -8,6 +8,7 @@#include <linux/mfd/rohm-bd71815.h> #include <linux/mfd/rohm-bd71828.h> #include <linux/mfd/rohm-bd72720.h> +#include <linux/mfd/rohm-bd73800.h> #include <linux/module.h> #include <linux/of.h> #include <linux/platform_device.h> @@ -284,6 +285,12 @@ static int bd70528_probe(struct platform_device *pdev) bd_rtc->bd718xx_alm_block_start =BD72720_REG_RTC_ALM_START ; hour_reg =BD72720_REG_RTC_HOUR ;break ; +case ROHM_CHIP_TYPE_BD73800 : + bd_rtc->reg_time_start =BD73800_REG_RTC_START ; + bd_rtc->bd718xx_alm_block_start =BD73800_REG_RTC_ALM_START ; + hour_reg =BD73800_REG_RTC_HOUR ; +break ; +default :dev_err (&pdev->dev,"Unknown chip\n" );return -ENOENT ;@@ -344,6 +351,7 @@ static const struct platform_device_id bd718x7_rtc_id[] = { { .name = "bd71828-rtc", .driver_data = ROHM_CHIP_TYPE_BD71828 }, { .name = "bd71815-rtc", .driver_data = ROHM_CHIP_TYPE_BD71815 }, { .name = "bd72720-rtc", .driver_data = ROHM_CHIP_TYPE_BD72720 }, + { .name = "bd73800-rtc", .driver_data = ROHM_CHIP_TYPE_BD73800 }, { } };MODULE_DEVICE_TABLE (platform, bd718x7_rtc_id);Signature · 1 line
2.54.0
Signature · 3 lines
Alexandre Belloni, co-owner and COO, Bootlin Embedded Linux and Kernel engineering https://bootlin.com
PATCH 5/8 regulator: bd71828: Support ROHM BD73800
In reply to Matti VaittinenFrom: Matti Vaittinen <[email protected]>
The ROHM BD73800 is a power management IC which integrates 8 BUCKs and 4 LDOs. The PMIC has internal state-machine and it can support transitions to RUN, SUSPEND and IDLE states. The LDOs 1 and 3 have two different voltage range configurations that can be set at the manufacturing phase by OTP. By default driver assumes low voltage ranges to be used because the data-sheet indicates the higher voltage ranges to be an 'OTP option'. The high voltage range can be indicated via device-tree property.
--- drivers/regulator/Kconfig | 4 +- drivers/regulator/bd71828-regulator.c | 555 +++++++++++++++++++++++++- 2 files changed, 556 insertions(+), 3 deletions(-)
drivers/regulator/Kconfig +2 -2
@@ -241,12 +241,12 @@ config REGULATOR_BD71815 will be called bd71815-regulator. config REGULATOR_BD71828 - tristate "ROHM BD71828, BD72720 and BD73900 Power Regulators" + tristate "ROHM BD71828, BD72720 and BD73[8/9]00 Power Regulators" depends on MFD_ROHM_BD71828 select REGULATOR_ROHM help This driver supports voltage regulators on ROHM BD71828, - BD71879, BD72720 and BD73900 PMICs. This will enable + BD71879, BD72720 and BD73[8/9]00 PMICs. 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
drivers/regulator/bd71828-regulator.c +554 -1
609 lines not on this page · raw message
Signature · 1 line
2.54.0
Mark Brown
maintainerRe: [PATCH 5/8] regulator: bd71828: Support ROHM BD73800
Quoted 5 lines · Matti Vaittinen
From: Matti Vaittinen <[email protected]>
drivers/regulator/bd71828-regulator.c +3
-0+ nproot =of_get_child_by_name (nproot,"regulators" ); +if (!nproot) { +dev_err (dev,"failed to find regulators node\n" );
drivers/regulator/bd71828-regulator.c static int bd72720_dt_parse(struct device *dev, · line 2141
Quoted 10 lines
drivers/regulator/bd71828-regulator.c +10
-0+return -ENODEV ; + } +for_each_child_of_node (nproot, np) { +if (of_node_name_eq (np,LDO1_NODE_NAME )) + ldo1_use_high_range =of_property_read_bool (np, +"rohm,ldo-range-high" ); +if (of_node_name_eq (np,LDO3_NODE_NAME )) + ldo3_use_high_range =of_property_read_bool (np, +"rohm,ldo-range-high" ); + }
Why do we iterate over all nodes rather than doing additional of_get_child_by_name()s?
drivers/regulator/bd71828-regulator.c static int bd72720_dt_parse(struct device *dev, · line 2153
Quoted 10 lines
drivers/regulator/bd71828-regulator.c +10
-0+if (ldo1_use_high_range) { + d[BD73800_LDO1 ].desc.linear_ranges = bd73800_ldo13_high_volts; + d[BD73800_LDO1 ].desc.n_linear_ranges = +ARRAY_SIZE (bd73800_ldo13_high_volts); + } +if (ldo3_use_high_range) { + d[BD73800_LDO3 ].desc.linear_ranges = bd73800_ldo13_high_volts; + d[BD73800_LDO3 ].desc.n_linear_ranges = +ARRAY_SIZE (bd73800_ldo13_high_volts); + }
You could just do these updates without the intermediate variables.
Matti Vaittinen
maintainerRe: [PATCH 5/8] regulator: bd71828: Support ROHM BD73800
Quoted 19 lines · Mark Brown
Quoted 5 lines · Matti Vaittinen
From: Matti Vaittinen <[email protected]>
drivers/regulator/bd71828-regulator.c +3
-0+ nproot =of_get_child_by_name (nproot,"regulators" ); +if (!nproot) { +dev_err (dev,"failed to find regulators node\n" );drivers/regulator/bd71828-regulator.c static int bd72720_dt_parse(struct device *dev, · line 2141
Quoted 10 lines
drivers/regulator/bd71828-regulator.c +10
-0+return -ENODEV ; + } +for_each_child_of_node (nproot, np) { +if (of_node_name_eq (np,LDO1_NODE_NAME )) + ldo1_use_high_range =of_property_read_bool (np, +"rohm,ldo-range-high" ); +if (of_node_name_eq (np,LDO3_NODE_NAME )) + ldo3_use_high_range =of_property_read_bool (np, +"rohm,ldo-range-high" ); + }Why do we iterate over all nodes rather than doing additional of_get_child_by_name()s?
This series has been sitting in my "TODO" -folder for quite a while - so I am not anymore 100% sure as to why. I believe I've thought that the of_get_child_by_name() does (internally) iterate all the child nodes, so using it twice would cause code to loop through the nodes twice. So, looping through all child nodes in a single loop probably felt like the right thing to do. Furthermore, I've probably written the first version before I found out the cleanup.h...
But yes. I think you're right. This can be made much leaner.
Quoted 4 lines
Quoted 4 lines
drivers/regulator/bd71828-regulator.c +4
-0+if (ldo1_use_high_range) { + d[BD73800_LDO1 ].desc.linear_ranges = bd73800_ldo13_high_volts; + d[BD73800_LDO1 ].desc.n_linear_ranges = +ARRAY_SIZE (bd73800_ldo13_high_volts);
Quoted 8 lines
drivers/regulator/bd71828-regulator.c static int bd72720_dt_parse(struct device *dev, · line 2153
Quoted 6 lines
drivers/regulator/bd71828-regulator.c +6
-0+ } +if (ldo3_use_high_range) { + d[BD73800_LDO3 ].desc.linear_ranges = bd73800_ldo13_high_volts; + d[BD73800_LDO3 ].desc.n_linear_ranges = +ARRAY_SIZE (bd73800_ldo13_high_volts); + }You could just do these updates without the intermediate variables.
Yes.
Thanks for the suggestions! I will fix these for the v2, but it will probably be out only during August.
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! ~~
PATCH 6/8 clk: bd718x7: Support ROHM BD73800
In reply to Matti VaittinenFrom: Matti Vaittinen <[email protected]>
The ROHM BD73800 PMIC has a 32.768 kHz clock gate. Add support for controlling this clock.
NOTE: The CLKOUT pin can be muxed by an OTP option. On some OTP configurations the CLKOUT is not outputting the clk signal.
--- drivers/clk/clk-bd718x7.c | 8 ++++++++ 1 file changed, 8 insertions(+)
drivers/clk/clk-bd718x7.c +8 -0
@@ -21,6 +21,9 @@#define BD718XX_REG_OUT32K 0x2E/* BD72720 */ #define BD72720_REG_OUT32K 0x9a +/* BD73800 */ +#define BD73800_REG_OUT32K 0x50 +/* * BD71837, BD71847, and BD71828 all use bit [0] to clk output control */
@@ -123,6 +126,10 @@ static int bd71837_clk_probe(struct platform_device *pdev) c->reg =BD72720_REG_OUT32K ; c->mask =CLK_OUT_EN_MASK ;break ; +case ROHM_CHIP_TYPE_BD73800 : + c->reg =BD73800_REG_OUT32K ; + c->mask =CLK_OUT_EN_MASK ; +break ;default :dev_err (&pdev->dev,"Unknown clk chip\n" );return -EINVAL ;
@@ -152,6 +159,7 @@ static const struct platform_device_id bd718x7_clk_id[] = { { "bd71828-clk", ROHM_CHIP_TYPE_BD71828 }, { "bd71815-clk", ROHM_CHIP_TYPE_BD71815 }, { "bd72720-clk", ROHM_CHIP_TYPE_BD72720 }, + { "bd73800-clk", ROHM_CHIP_TYPE_BD73800 }, { }, };MODULE_DEVICE_TABLE (platform, bd718x7_clk_id);
Signature · 1 line
2.54.0
PATCH 7/8 gpio: bd73800: Support ROHM BD73800 PMIC GPIOs
In reply to Matti VaittinenFrom: Matti Vaittinen <[email protected]>
The ROHM BD73800 PMIC has 4 pins (named GPIO1, CLKOUT, FAULT_B and EXTEN_OUT) which might have been set to operate as a GPI or GPO when OTP (One Time Programmable memory) is written at device manufacturing. Support the GPI/GPO use-case via GPIO framework.
The default OTP for these pins is to not use any of them as GPI or GPO. (The GPIO1 defaults as an ADC input regardless the naming). Hence the driver assumes none of these pins is a GPI/GPO unless explicitly pointed as GPI or GPO via device tree.
Furthermore, pin's direction can't be changed after OTP configuration is done. Also the default drive type for a GPO (CMOS / Open Drain) is set by the OTP configuration. The BD73800 has a set of undocumented test registers which should allow changing the drive type. Access to the test register area or the test registers aren't documented and so this driver does not support configuring the drive type even though it might be doable.
--- drivers/gpio/Kconfig | 11 ++ drivers/gpio/Makefile | 1 + drivers/gpio/gpio-bd73800.c | 234 ++++++++++++++++++++++++++++++++++++ 3 files changed, 246 insertions(+) create mode 100644 drivers/gpio/gpio-bd73800.c
drivers/gpio/Kconfig +11 -0
@@ -1363,6 +1363,17 @@ config GPIO_BD72720 be configured to GPO on the ROHM PMIC. The pin configuration is done on OTP at manufacturing. +config GPIO_BD73800 + tristate "ROHM BD73800 GPIO support" + depends on MFD_ROHM_BD71828 + help + Support for GPIOs on ROHM BD73800 PMIC. There can be up to 4 + GPI or GPO pins available on the PMIC in total. The purpose of + the pins is decided at the device manufacturing by OTP + configuration and can't be reconfigured later. Enable this + if your PMIC has pins set as GPIs or GPOs and if you wish to + control the pins via the GPIO framework. + config GPIO_BD9571MWV tristate "ROHM BD9571 GPIO support" depends on MFD_BD9571MWV
drivers/gpio/Makefile +1 -0
@@ -45,6 +45,7 @@ obj-$(CONFIG_GPIO_BCM_XGS_IPROC) += gpio-xgs-iproc.o obj-$(CONFIG_GPIO_BD71815) += gpio-bd71815.o obj-$(CONFIG_GPIO_BD71828) += gpio-bd71828.o obj-$(CONFIG_GPIO_BD72720) += gpio-bd72720.o +obj-$(CONFIG_GPIO_BD73800) += gpio-bd73800.o obj-$(CONFIG_GPIO_BD9571MWV) += gpio-bd9571mwv.o obj-$(CONFIG_GPIO_BLZP1600) += gpio-blzp1600.o obj-$(CONFIG_GPIO_BRCMSTB) += gpio-brcmstb.o
drivers/gpio/gpio-bd73800.c new file +234 -0
234 lines not on this page · raw message
Signature · 1 line
2.54.0
Bartosz Golaszewski
maintainerRe: [PATCH 7/8] gpio: bd73800: Support ROHM BD73800 PMIC GPIOs
Quoted 134 lines · Matti Vaittinen
From: Matti Vaittinen <[email protected]>
The ROHM BD73800 PMIC has 4 pins (named GPIO1, CLKOUT,
FAULT_BandEXTEN_OUT) which might have been set to operate as a GPI or GPO when OTP (One Time Programmable memory) is written at device manufacturing. Support the GPI/GPO use-case via GPIO framework.The default OTP for these pins is to not use any of them as GPI or GPO. (The GPIO1 defaults as an ADC input regardless the naming). Hence the driver assumes none of these pins is a GPI/GPO unless explicitly pointed as GPI or GPO via device tree.
Furthermore, pin's direction can't be changed after OTP configuration is done. Also the default drive type for a GPO (CMOS / Open Drain) is set by the OTP configuration. The BD73800 has a set of undocumented test registers which should allow changing the drive type. Access to the test register area or the test registers aren't documented and so this driver does not support configuring the drive type even though it might be doable.
Signed-off-by Matti Vaittinen <[email protected]>--- drivers/gpio/Kconfig | 11 ++ drivers/gpio/Makefile | 1 + drivers/gpio/gpio-bd73800.c | 234 ++++++++++++++++++++++++++++++++++++ 3 files changed, 246 insertions(+) create mode 100644 drivers/gpio/gpio-bd73800.cdrivers/gpio/Kconfig +11
-0@@ -1363,6 +1363,17 @@ config GPIO_BD72720 be configured to GPO on the ROHM PMIC. The pin configuration is done on OTP at manufacturing. +config GPIO_BD73800 + tristate "ROHM BD73800 GPIO support" + depends on MFD_ROHM_BD71828 + help + Support for GPIOs on ROHM BD73800 PMIC. There can be up to 4 + GPI or GPO pins available on the PMIC in total. The purpose of + the pins is decided at the device manufacturing by OTP + configuration and can't be reconfigured later. Enable this + if your PMIC has pins set as GPIs or GPOs and if you wish to + control the pins via the GPIO framework. + config GPIO_BD9571MWV tristate "ROHM BD9571 GPIO support" depends on MFD_BD9571MWVdrivers/gpio/Makefile +1
-0@@ -45,6 +45,7 @@ obj-$(CONFIG_GPIO_BCM_XGS_IPROC) += gpio-xgs-iproc.o obj-$(CONFIG_GPIO_BD71815) += gpio-bd71815.o obj-$(CONFIG_GPIO_BD71828) += gpio-bd71828.o obj-$(CONFIG_GPIO_BD72720) += gpio-bd72720.o +obj-$(CONFIG_GPIO_BD73800) += gpio-bd73800.o obj-$(CONFIG_GPIO_BD9571MWV) += gpio-bd9571mwv.o obj-$(CONFIG_GPIO_BLZP1600) += gpio-blzp1600.o obj-$(CONFIG_GPIO_BRCMSTB) += gpio-brcmstb.odrivers/gpio/gpio-bd73800.c new file +66
-0@@ -0,0 +1,234 @@ +// SPDX-License-Identifier: GPL-2.0 +/* +* Support to GPIOs on ROHM BD73800 +* Copyright 2024 ROHM Semiconductors. +* Author: Matti Vaittinen <[email protected]> +*/ + +#include <linux/gpio/driver.h> +#include <linux/init.h> +#include <linux/irq.h> +#include <linux/module.h> +#include <linux/of.h> +#include <linux/platform_device.h> +#include <linux/mfd/rohm-bd73800.h> + +#define BD73800_GPIO_MAX_PINS 4 +/* +* The BD73800 has several "one time programmable" (OTP) configurations which +* can be set at manufacturing phase. Some of these options allow using +* individual pins as GPI or GPO (not both at the same time). The OTP +* configuration can't be read at run-time, so drivers rely on device-tree to +* advertise the OTP programmed in manufacturing. +* +* The pins which can be used as GPIO are: +* GPIO1, CLKOUT (GPIO2), FAULT_B, EXTEN_OUT. +* +* The OTP options 2 and 3 state for all the pins: +* - OTP2: GPI (also IRQ source) +* - OTP3: GPO (NOTE: This is actually 2 different OTP options. Either a +* register controllable output or a power-sequence controlled output. +* The "gpo" referred here means only the register controllable output. +* The datasheet refers to this as: "<pin> output is controlled by +* GPIO<N>_OUT or power on/off sequencer to control external VRs. ON/OFF +* sequence timing is configurable." +* +* The data-sheet further says that the GPI/GPO is not a default OTP +* configuration for any of the pins. Hence the GPIO driver defaults to a pin +* not being a GPI or GPO, but requires the pin to be explicitly marked as a +* GPI or GPO in the device-tree. +* +* DT properties: +* "rohm,pin-gpio1", "rohm,pin-clkout", "rohm,pin-fault-b", "rohm,pin-exten" +* can be set to one of the values "gpi" or "gpo" to enable them to be used as +* GPIO. +*/ + +enum bd73800_gpio_state { +BD73800_PIN_UNKNOWN , +BD73800_PIN_GPI , +BD73800_PIN_GPO , +}; + +struct bd73800_gpio_pin_cfg { +enum bd73800_gpio_state state; +int mask;/* GPIO_OUT and INT_SRC have same bit offsets for GPIO */ +}; + +struct bd73800_gpio { +/* chip.parent points the MFD which provides DT node and regmap */ +struct gpio_chip chip; +struct bd73800_gpio_pin_cfg pin[BD73800_GPIO_MAX_PINS ]; +int num_pins; +/* dev points to the platform device for devm and prints */ +struct device *dev; +struct regmap *regmap; +};
drivers/gpio/gpio-bd73800.c line 76
Quoted 10 lines
drivers/gpio/gpio-bd73800.c new file +10
-0+ +static int bd73800_gpio_get_pins (struct bd73800_gpio *g) +{ +static const char *const properties[] = {"rohm,pin-gpio1" , +"rohm,pin-clkout" ,"rohm,pin-fault-b" ,"rohm,pin-exten" }; +const char *val; +int i, ret; + +for (i =0 ; i <ARRAY_SIZE (properties); i++) { + ret = fwnode_property_read_string(dev_fwnode(g->dev->parent),
It would be cleaner with device_property_read_string(g->dev->parent, ...)
Quoted 89 lines
drivers/gpio/gpio-bd73800.c new file +89
-0+ properties[i], &val); + +if (ret) { +if (ret == -EINVAL ) +continue ; + +return dev_err_probe (g->dev, ret, +"pin %d (%s), bad configuration\n" , i, + properties[i]); + } + +if (strcmp (val,"gpi" ) ==0 ) { + g->pin[g->num_pins].state =BD73800_PIN_GPI ; + g->pin[g->num_pins].mask =BIT (i); + g->num_pins++; + }else if (strcmp (val,"gpo" ) ==0 ) { + g->pin[g->num_pins].state =BD73800_PIN_GPO ; + g->pin[g->num_pins].mask =BIT (i); + g->num_pins++; + } + } + +return 0 ; +} + +static int bd73800gpio_get (struct gpio_chip *chip,unsigned int offset) +{ +struct bd73800_gpio *bdgpio =gpiochip_get_data (chip); +struct bd73800_gpio_pin_cfg *pin = &bdgpio->pin[offset]; +int ret, val; + +/* Only pins configured as GPI via OTP can have their status read */ +if (pin->state !=BD73800_PIN_GPI ) { +dev_dbg (bdgpio->dev,"pin %d (%x) not input. State %d\n" , + offset, pin->mask, pin->state); +return -EINVAL ; + } + + ret =regmap_read (bdgpio->regmap,BD73800_REG_INT_5_SRC , &val); +if (ret) +return ret; + +return val & pin->mask; +} + +static int bd73800gpo_set (struct gpio_chip *chip,unsigned int offset, +int value) +{ +struct bd73800_gpio *bdgpio =gpiochip_get_data (chip); +struct bd73800_gpio_pin_cfg *pin = &bdgpio->pin[offset]; + +if (pin->state !=BD73800_PIN_GPO ) { +dev_dbg (bdgpio->dev,"pin %d (%d) not output. State %d\n" , + offset, pin->mask, pin->state); + +return -EINVAL ; + } + +if (value) +return regmap_set_bits (bdgpio->regmap,BD73800_REG_GPO_OUT , + pin->mask); + +return regmap_clear_bits (bdgpio->regmap,BD73800_REG_GPO_OUT , pin->mask); +} + +static int bd73800gpio_direction_get (struct gpio_chip *chip, +unsigned int offset) +{ +struct bd73800_gpio *bdgpio =gpiochip_get_data (chip); + +if (bdgpio->pin[offset].state ==BD73800_PIN_GPO ) +return GPIO_LINE_DIRECTION_OUT ; + +return GPIO_LINE_DIRECTION_IN ; +} + +/* +* Template for GPIO chip. The BD73800 GPO supports both CMOS and open drain +* configurations. The default however depends on the OTP. The runtime config +* can be done via undocumented test registers - but at the moment there is no +* support for this. +* +* NOTE: When the BD73800 GPIO pins are used as IRQ source, the users are +* expected to request them directly from the regmap_irq IRQ-chip (implemented +* in the MFD driver). This way we don't need to populate another IRQ-chip +* here. +*/ +static const struct gpio_chip bd73800gpio_chip = { + .label ="bd73800" ,
drivers/gpio/gpio-bd73800.c line 175
Quoted 10 lines
drivers/gpio/gpio-bd73800.c new file +10
-0+ .owner = THIS_MODULE, + .get = bd73800gpio_get, + .get_direction = bd73800gpio_direction_get, + .set = bd73800gpo_set, + .can_sleep = true, +}; + +static int gpo_bd73800_probe (struct platform_device *pdev) +{ +struct bd73800_gpio *g;
May I suggest a slightly more descriptive name for driver data? Maybe at the very least... "data"? :)
drivers/gpio/gpio-bd73800.c line 182
Quoted 7 lines
drivers/gpio/gpio-bd73800.c new file +7
-0+struct device *parent, *dev; +int ret; + +/* +* Bind devm lifetime to this platform device => use dev for devm. +* also the prints should originate from this device. +*/
Why would you need to comment on it though? It's very much the standard approach, isn't it?
Quoted 16 lines
drivers/gpio/gpio-bd73800.c new file +16
-0+ dev = &pdev->dev; +/* The device-tree and regmap come from MFD => use parent for that */ + parent = dev->parent; + + g =devm_kzalloc (dev,sizeof (*g),GFP_KERNEL ); +if (!g) +return -ENOMEM ; + + g->chip = bd73800gpio_chip; + g->chip.base =-1 ; + g->chip.parent = parent; + g->regmap =dev_get_regmap (parent,NULL ); + g->dev = dev; + + ret =bd73800_gpio_get_pins (g); +if (ret)
drivers/gpio/gpio-bd73800.c line 208
Quoted 10 lines
drivers/gpio/gpio-bd73800.c new file +10
-0+return ret; + +if (!g->num_pins) { +/* +* The BD73800 may or may not have pins allocated for GPIO +* depending on the OTP used at manufacturing. Free the memory +* and go out if there is no pins as then we have nothing to do +*/ +dev_dbg (dev,"no GPIO pins\n" ); +devm_kfree (dev, g);
No need for that, because...
drivers/gpio/gpio-bd73800.c line 209
Quoted 1 line
drivers/gpio/gpio-bd73800.c new file +1
-0+return 0 ;
... this will still leave a bound device in the system, I'm not sure we want it? The correct error code in this case is -ENODEV.
Quoted 26 lines
drivers/gpio/gpio-bd73800.c new file +25
-1+ } + g->chip.ngpio = g->num_pins; + +return devm_gpiochip_add_data (dev, &g->chip, g); +} + +static const struct platform_device_id bd73800_gpio_id[] = { + {"bd73800-gpio" }, + { }, +}; +MODULE_DEVICE_TABLE (platform, bd73800_gpio_id); + +static struct platform_driver gpo_bd73800_driver = { + .driver = { + .name ="bd73800-gpio" , + .probe_type =PROBE_PREFER_ASYNCHRONOUS , + }, + .probe = gpo_bd73800_probe, + .id_table = bd73800_gpio_id, +}; +module_platform_driver (gpo_bd73800_driver); + +MODULE_AUTHOR ("Matti Vaittinen <[email protected]>" ); +MODULE_DESCRIPTION ("GPIO interface for BD73800" ); +MODULE_LICENSE ("GPL" ); --
Quoted 3 lines
2.54.0
Bart
Matti Vaittinen
maintainerRe: [PATCH 7/8] gpio: bd73800: Support ROHM BD73800 PMIC GPIOs
pe 3.7.2026 klo 16.11 Bartosz Golaszewski ([email protected]) kirjoitti:
Quoted 23 lines
Quoted 20 lines · Matti Vaittinen
From: Matti Vaittinen <[email protected]>
The ROHM BD73800 PMIC has 4 pins (named GPIO1, CLKOUT,
FAULT_BandEXTEN_OUT) which might have been set to operate as a GPI or GPO when OTP (One Time Programmable memory) is written at device manufacturing. Support the GPI/GPO use-case via GPIO framework.The default OTP for these pins is to not use any of them as GPI or GPO. (The GPIO1 defaults as an ADC input regardless the naming). Hence the driver assumes none of these pins is a GPI/GPO unless explicitly pointed as GPI or GPO via device tree.
Furthermore, pin's direction can't be changed after OTP configuration is done. Also the default drive type for a GPO (CMOS / Open Drain) is set by the OTP configuration. The BD73800 has a set of undocumented test registers which should allow changing the drive type. Access to the test register area or the test registers aren't documented and so this driver does not support configuring the drive type even though it might be doable.
Quoted 2 lines
Quoted 2 lines
Signed-off-by Matti Vaittinen <[email protected]>---
Thanks for the review! I appreciate it!
Quoted 11 lines
drivers/gpio/gpio-bd73800.c line 76
Quoted 9 lines
drivers/gpio/gpio-bd73800.c new file +9
-0+static int bd73800_gpio_get_pins (struct bd73800_gpio *g) +{ +static const char *const properties[] = {"rohm,pin-gpio1" , +"rohm,pin-clkout" ,"rohm,pin-fault-b" ,"rohm,pin-exten" }; +const char *val; +int i, ret; + +for (i =0 ; i <ARRAY_SIZE (properties); i++) { + ret = fwnode_property_read_string(dev_fwnode(g->dev->parent),It would be cleaner with
device_property_read_string(g->dev->parent, ...)
True.
Quoted 7 lines
drivers/gpio/gpio-bd73800.c line 175
Quoted 4 lines
drivers/gpio/gpio-bd73800.c new file +4
-0+ +static int gpo_bd73800_probe (struct platform_device *pdev) +{ +struct bd73800_gpio *g;May I suggest a slightly more descriptive name for driver data? Maybe at the very least... "data"? :)
Ok.
Quoted 10 lines
drivers/gpio/gpio-bd73800.c line 182
Quoted 7 lines
drivers/gpio/gpio-bd73800.c new file +7
-0+struct device *parent, *dev; +int ret; + +/* +* Bind devm lifetime to this platform device => use dev for devm. +* also the prints should originate from this device. +*/ Why would you need to comment on it though? It's very much the standard approach, isn't it?
Sure. I might have had this comment combined with the one below. Idea has probably been to explain why we use both this device and the parent. Can't bind lifetime to parent while needing it for regmap and dt. Well, I agree that this device's comment is really not required. I'll keep the comment about parent while removing this. Thanks.
Quoted 29 lines
Quoted 16 lines
drivers/gpio/gpio-bd73800.c new file +16
-0+ dev = &pdev->dev; +/* The device-tree and regmap come from MFD => use parent for that */ + parent = dev->parent; + + g =devm_kzalloc (dev,sizeof (*g),GFP_KERNEL ); +if (!g) +return -ENOMEM ; + + g->chip = bd73800gpio_chip; + g->chip.base =-1 ; + g->chip.parent = parent; + g->regmap =dev_get_regmap (parent,NULL ); + g->dev = dev; + + ret =bd73800_gpio_get_pins (g); +if (ret)drivers/gpio/gpio-bd73800.c line 208
Quoted 10 lines
drivers/gpio/gpio-bd73800.c new file +10
-0+return ret; + +if (!g->num_pins) { +/* +* The BD73800 may or may not have pins allocated for GPIO +* depending on the OTP used at manufacturing. Free the memory +* and go out if there is no pins as then we have nothing to do +*/ +dev_dbg (dev,"no GPIO pins\n" ); +devm_kfree (dev, g);No need for that, because...
Quoted 4 lines
Quoted 1 line
+ return 0;
... this will still leave a bound device in the system, I'm not sure we want it? The correct error code in this case is
-ENODEV.
I am a bit uncertain. This isn't really an error. It should be very much Ok to configure the support for PMICs with GPIOs to be compiled - and also very much Ok to have a PMIC with no GPIOs. Returning an error doesn't feel right. Furthermore, I am afraid that returning an error might hurt the system start-up? Do you see some really problematic consequences if we return Ok without registering the GPIOs. I'd assume that wastes some bytes but I don't see other really severe consequences.
As noted when sending - I am mostly offline during July so my replies may arrive a bit late and next version is unlikely to be sent before August.
Yours,
-- Matti
Signature · 8 lines
Matti Vaittinen Linux kernel developer at ROHM Semiconductors Oulu Finland ~~ When things go utterly wrong vim users can always type :help! ~~ Discuss - Estimate - Plan - Report and finally accomplish this: void do_work(int time) __attribute__ ((const));
Bartosz Golaszewski
maintainerRe: [PATCH 7/8] gpio: bd73800: Support ROHM BD73800 PMIC GPIOs
Quoted 18 lines · Matti Vaittinen
pe 3.7.2026 klo 16.11 Bartosz Golaszewski ([email protected]) kirjoitti:
Quoted 10 lines
drivers/gpio/gpio-bd73800.c line 208
Quoted 9 lines
drivers/gpio/gpio-bd73800.c new file +9
-0+ +if (!g->num_pins) { +/* +* The BD73800 may or may not have pins allocated for GPIO +* depending on the OTP used at manufacturing. Free the memory +* and go out if there is no pins as then we have nothing to do +*/ +dev_dbg (dev,"no GPIO pins\n" ); +devm_kfree (dev, g);Quoted 6 lines
No need for that, because...
Quoted 1 line
+ return 0;
... this will still leave a bound device in the system, I'm not sure we want it? The correct error code in this case is
-ENODEV.
Quoted 8 lines
I am a bit uncertain. This isn't really an error. It should be very much Ok to configure the support for PMICs with GPIOs to be compiled - and also very much Ok to have a PMIC with no GPIOs. Returning an error doesn't feel right. Furthermore, I am afraid that returning an error might hurt the system start-up? Do you see some really problematic consequences if we return Ok without registering the GPIOs. I'd assume that wastes some bytes but I don't see other really severe consequences.
But -ENODEV/-ENXIO error codes are meant to do exactly that - tell the driver core to assume this device legitimately cannot be enabled on this system. There will be no error splat in the kernel log and the probe will not be deferred.
This really isn't the first device to need this behavior. :)
Bart
Matti Vaittinen
maintainerRe: [PATCH 7/8] gpio: bd73800: Support ROHM BD73800 PMIC GPIOs
ma 13.7.2026 klo 11.16 Bartosz Golaszewski ([email protected]) kirjoitti:
Quoted 30 lines
Quoted 18 lines · Matti Vaittinen
pe 3.7.2026 klo 16.11 Bartosz Golaszewski ([email protected]) kirjoitti:
Quoted 10 lines
drivers/gpio/gpio-bd73800.c line 208
Quoted 9 lines
drivers/gpio/gpio-bd73800.c new file +9
-0+ +if (!g->num_pins) { +/* +* The BD73800 may or may not have pins allocated for GPIO +* depending on the OTP used at manufacturing. Free the memory +* and go out if there is no pins as then we have nothing to do +*/ +dev_dbg (dev,"no GPIO pins\n" ); +devm_kfree (dev, g);Quoted 6 lines
No need for that, because...
Quoted 1 line
+ return 0;
... this will still leave a bound device in the system, I'm not sure we want it? The correct error code in this case is
-ENODEV.Quoted 8 lines
I am a bit uncertain. This isn't really an error. It should be very much Ok to configure the support for PMICs with GPIOs to be compiled - and also very much Ok to have a PMIC with no GPIOs. Returning an error doesn't feel right. Furthermore, I am afraid that returning an error might hurt the system start-up? Do you see some really problematic consequences if we return Ok without registering the GPIOs. I'd assume that wastes some bytes but I don't see other really severe consequences.
Quoted 3 lines
But -ENODEV/-ENXIO error codes are meant to do exactly that - tell the driver core to assume this device legitimately cannot be enabled on this system. There will be no error splat in the kernel log and the probe will not be deferred.
Oh, thanks for the explanation. I didn't know this. The -ENODEV not causing error splat makes sense. The fact that -ENXIO does that too is quite surptizing to me. I thought the -ENXIO is used to indicate unexpected failure in bus communication.
I'll go with -ENODEV in the next version.
Yours,
-- Matti
Signature · 8 lines
Matti Vaittinen Linux kernel developer at ROHM Semiconductors Oulu Finland ~~ When things go utterly wrong vim users can always type :help! ~~ Discuss - Estimate - Plan - Report and finally accomplish this: void do_work(int time) __attribute__ ((const));
PATCH 8/8 MAINTAINERS: Add ROHM BD73800 PMIC files
In reply to Matti VaittinenFrom: Matti Vaittinen <[email protected]>
Add the undersigned as a maintainer for the ROHM BD73800 PMIC related files.
--- MAINTAINERS | 2 ++ 1 file changed, 2 insertions(+)
MAINTAINERS +2 -0
@@ -23539,6 +23539,7 @@ F: drivers/clk/clk-bd718x7.c F: drivers/gpio/gpio-bd71815.c F: drivers/gpio/gpio-bd71828.c F: drivers/gpio/gpio-bd72720.c +F: drivers/gpio/gpio-bd73800.c F: drivers/mfd/rohm-bd71828.c F: drivers/mfd/rohm-bd718x7.c F: drivers/mfd/rohm-bd9576.c
@@ -23556,6 +23557,7 @@ 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-bd72720.h +F: include/linux/mfd/rohm-bd73800.h F: include/linux/mfd/rohm-bd957x.h F: include/linux/mfd/rohm-bd96801.h F: include/linux/mfd/rohm-bd96802.h
Signature · 1 line
2.54.0