Support ROHM BD73800
Subsystems (7)
v3 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.
Revision history:
v2 => v3:
- Rebased on v7.3-rc1.
- gpio: Use gpio-regmap as was suggested by Linus W. More accurate change-log in individual patches.
v1 => v2:
- Rebased on regulator/for-7.3 as it carries dependency:
f29a8bf6fde1 ("regulator: dt-bindings: ROHM PMIC state-machine voltages")
- dt-bindings: Various fixes, split generic stuff to own files.
- gpio: Styling, return -ENODEV if no GPIOs found
- MFD: Styling
- regulator: Simplify dt-reading
More accurate change-log in individual patches.
---
Matti Vaittinen (10):
dt-bindings: mfd: common ROHM PMIC properties
dt-bindings: rohm,bd*: Ref common ROHM bindings
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,bd71815-pmic.yaml | 9 +- .../bindings/mfd/rohm,bd71828-pmic.yaml | 9 +- .../bindings/mfd/rohm,bd72720-pmic.yaml | 29 +- .../bindings/mfd/rohm,bd73800-pmic.yaml | 218 +++++++ .../bindings/mfd/rohm,pmic-pins.yaml | 72 +++ .../regulator/rohm,bd73800-regulator.yaml | 99 ++++ MAINTAINERS | 2 + drivers/clk/clk-bd718x7.c | 8 + drivers/gpio/Kconfig | 12 + drivers/gpio/Makefile | 1 + drivers/gpio/gpio-bd73800.c | 209 +++++++ drivers/mfd/Kconfig | 15 +- drivers/mfd/rohm-bd71828.c | 147 ++++- drivers/regulator/Kconfig | 4 +- drivers/regulator/bd71828-regulator.c | 558 +++++++++++++++++- drivers/rtc/rtc-bd70528.c | 8 + include/linux/mfd/rohm-bd73800.h | 307 ++++++++++ include/linux/mfd/rohm-generic.h | 1 + 18 files changed, 1662 insertions(+), 46 deletions(-) create mode 100644 Documentation/devicetree/bindings/mfd/rohm,bd73800-pmic.yaml create mode 100644 Documentation/devicetree/bindings/mfd/rohm,pmic-pins.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: cee9395acd8043be0644b25c34bfa86623f2b935
Signature · 1 line
2.55.0
PATCH v3 1/10 dt-bindings: mfd: common ROHM PMIC properties
From: Matti Vaittinen <[email protected]>
ROHM PMICs keep having similar functionalities from one generation to the next. Keeping the device-trees describing these functionalities similar helps users because:
1. They can re-use existing device-tree properties when switching from one project, using a ROHM PMIC, to next project using newer variant.
2. The users can find and re-use examples from old projects - even if they never worked with ROHM PMICs before.
Similarly, introducing new and different properties for same functionality previous variant had, will be adding confusion.
Sometimes the existing properties aren't 100% what reviewers would prefer. When issues are minor or just cosmetic, changing the existing properties is not feasible. Reviewers can't be expected to know which properties are new, and which are existing - and this can lead to unnecessary review discussion wasting time and energy from everyone.
Adding a common file for re-used ROHM PMIC properties should make it clearly visible that a property is re-used, when a new PMIC binding refers to this file instead of (re-)describing all the existing bindings. This will also help keeping the common properties identical across the variants.
Add new file listing commonly used ROHM PMIC properties.
---
Revision history:
v3:
- No changes
v2:
- New patch
--- .../bindings/mfd/rohm,pmic-pins.yaml | 72 +++++++++++++++++++ 1 file changed, 72 insertions(+) create mode 100644 Documentation/devicetree/bindings/mfd/rohm,pmic-pins.yaml
Documentation/devicetree/bindings/mfd/rohm,pmic-pins.yaml new file +72 -0
@@ -0,0 +1,72 @@ +# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/mfd/rohm,pmic-pins.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: ROHM PMICs' OTP configured pin descriptions + +maintainers: + - Matti Vaittinen <[email protected]> + +description: + Collection of properties which are commonly used to describe various + ROHM PMIC's pins. + +properties: + rohm,clkout-open-drain: + description: clk32kout mode. Set to 1 for "open-drain" or 0 for "cmos" + a.k.a "push-pull". + $ref: /schemas/types.yaml#/definitions/uint32 + maximum: 1 + + rohm,pin-clkout: + $ref: /schemas/types.yaml#/definitions/string + description: + The IC has different OTP options to use clkout-pin for different + purposes. Set this property to indicate the OTP variant. + + Many of the ROHM ICs have pins, which function can be defined in + OTP. Some of them provide no means to detect the pin configuration + at run-time, leaving software unaware of which features the IC + really has. These properties can be used to inform which pins + provide which functionality. IOW, these properties aren't used to + configure pin, they are used to tell what functionality pins on + this specific IC have. + + # Supported functionalities depend on the exact IC model. Following + # values are already defined: gpi, gpo. + # Please, re-use them when adding new ICs. + + rohm,pin-fault_b: + $ref: /schemas/types.yaml#/definitions/string + description: + The IC has different OTP options to use fault_b-pin for different + purposes. Set this property to indicate the OTP variant. + + # Supported functionalities depend on the exact IC model. Following + # values are already defined: gpi, gpo, faultb, readyind, pwrseq. + # Please, re-use them when adding new ICs. + +patternProperties: + "^rohm,pin-dvs[0-1]$": + $ref: /schemas/types.yaml#/definitions/string + description: + The IC has different OTP options to use dvs<X>-pins for different + purposes. Set this property to indicate the OTP variant. + # Supported functionalities depend on the exact IC model. Following + # values are already defined: dvs-input, gpi, gpo, pwrseq. + # Please, re-use them when adding new ICs. + + "^rohm,pin-exten([0-1])?$": + $ref: /schemas/types.yaml#/definitions/string + description: + The IC has an OTP option to use exten -pin(s) for different purposes. + Set this property to indicate the OTP variant. + # Supported functionalities depend on the exact IC model. Following + # values are already defined: gpi, gpo, pwrseq. + # Please, re-use them when adding new ICs. + +# The schema is expected to be reference by IC schemas, which may introduce +# other properties that must be allowed. +additionalProperties: true
Signature · 1 line
2.55.0
PATCH v3 2/10 dt-bindings: rohm,bd*: Ref common ROHM bindings
In reply to Matti VaittinenFrom: Matti Vaittinen <[email protected]>
The commonly used ROHM PMIC bindings were added into rohm,pmic-pins.yaml. Keeping commonly used properties in one file can ease both the maintaining the bindings and the reviewing process.
Reference the common bindings from rohm,pmic-pins.yaml, instead of declaring them from the scratch for every PMIC using them. Keep the PMIC variant specific information (like supported pin functions) in PMIC the specific files, so unsupported values won't be allowed.
---
Revision history:
v3:
- No changes
v2:
- New patch
--- .../bindings/mfd/rohm,bd71815-pmic.yaml | 9 +++--- .../bindings/mfd/rohm,bd71828-pmic.yaml | 9 +++--- .../bindings/mfd/rohm,bd72720-pmic.yaml | 29 +++---------------- 3 files changed, 12 insertions(+), 35 deletions(-)
Documentation/devicetree/bindings/mfd/rohm,bd71815-pmic.yaml +4 -5
@@ -15,6 +15,9 @@ description: | for LED and a 500 mA single-cell linear charger. Also included is a Coulomb counter, a real-time clock (RTC), and a 32.768 kHz clock gate and two GPOs. +allOf: + - $ref: rohm,pmic-pins.yaml# + properties: compatible: const: rohm,bd71815
@@ -44,11 +47,7 @@ properties: clock-output-names: const: bd71815-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 + rohm,clkout-open-drain: true rohm,charger-sense-resistor-micro-ohms: minimum: 10000
Documentation/devicetree/bindings/mfd/rohm,bd71828-pmic.yaml +4 -5
@@ -15,6 +15,9 @@ description: | single-cell linear charger. Also included is a Coulomb counter, a real-time clock (RTC), and a 32.768 kHz clock gate. +allOf: + - $ref: rohm,pmic-pins.yaml# + properties: compatible: oneOf:
@@ -49,11 +52,7 @@ properties: clock-output-names: const: bd71828-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 + rohm,clkout-open-drain: true rohm,charger-sense-resistor-micro-ohms: minimum: 10000
Documentation/devicetree/bindings/mfd/rohm,bd72720-pmic.yaml +4 -25
@@ -15,6 +15,9 @@ description: and a 3000 mA switching charger. ICs also include a Coulomb counter, a real-time clock (RTC), GPIOs and a 32.768 kHz clock gate. +allOf: + - $ref: rohm,pmic-pins.yaml# + # In addition to the properties found from the charger node, PMICs # use properties from a static battery node. Please see the: # Documentation/devicetree/bindings/power/supply/battery.yaml
@@ -80,10 +83,7 @@ properties: clock-output-names: const: bd71828-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 - maximum: 1 + rohm,clkout-open-drain: true rohm,charger-sense-resistor-micro-ohms: minimum: 10000
@@ -103,14 +103,6 @@ properties: $ref: /schemas/leds/rohm,bd71828-leds.yaml rohm,pin-fault_b: - $ref: /schemas/types.yaml#/definitions/string - description: - PMIC has an OTP option to use fault_b-pin for different - purposes. Set this property accordingly. OTP options are - OTP0 - bi-directional FAULT_B or READY indicator depending on a - 'sub option' - OTP1 - GPO - OTP2 - Power sequencer output. enum: - faultb - readyind
@@ -119,14 +111,6 @@ properties: patternProperties: "^rohm,pin-dvs[0-1]$": - $ref: /schemas/types.yaml#/definitions/string - description: - PMIC has 4 different OTP options to determine the use of dvs<X>-pins. - OTP0 - regulator RUN state control. - OTP1 - GPI. - OTP2 - GPO. - OTP3 - Power sequencer output. - This property specifies the use of the pin. enum: - dvs-input - gpi
@@ -134,11 +118,6 @@ patternProperties: - pwrseq "^rohm,pin-exten[0-1]$": - $ref: /schemas/types.yaml#/definitions/string - description: PMIC has an OTP option to use exten0-pin for different - purposes. Set this property accordingly. - OTP0 - GPO - OTP1 - Power sequencer output. enum: - gpo - pwrseq
Signature · 1 line
2.55.0
PATCH v3 3/10 dt-bindings: regulator: ROHM BD73800 regulators
In reply to Matti VaittinenFrom: 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.
---
Revision history:
v3:
- No changes
v1 => v2:
- Description of the state specific voltages moved to own file and referenced from it (because multiple PMIC bindings used them).
The dt checker's documentation reference checker warns about the link to the MFD binding - which will be introduced in next commit. These commits have kind of a chicken and egg issue as MFD is referencing regulator properties introduced in this patch.
I could squash these but IMO, this is clearer for the reviewers. AFAICS, Both MFD and regulator subsystems tend to be busy. I could also split adding the MFD comment reference to own patch which would be after the patch adding the MFD binding, but having own patch for just adding the comment is a bit meh.
So, I decided to live with the broken doc-link between these two patches.
--- .../regulator/rohm,bd73800-regulator.yaml | 99 +++++++++++++++++++ 1 file changed, 99 insertions(+) create mode 100644 Documentation/devicetree/bindings/regulator/rohm,bd73800-regulator.yaml
Documentation/devicetree/bindings/regulator/rohm,bd73800-regulator.yaml new file +99 -0
@@ -0,0 +1,99 @@ +# 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. + allOf: + - $ref: regulator.yaml# + - $ref: rohm,pmic-states.yaml# + + properties: + regulator-name: + pattern: "^buck[1-8]$" + description: + should be "buck1", ..., "buck8" + + rohm,dvs-run-voltage: + minimum: 0 + maximum: 3500000 + + rohm,dvs-idle-voltage: + minimum: 0 + maximum: 3500000 + + rohm,dvs-suspend-voltage: + 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. + allOf: + - $ref: regulator.yaml# + - $ref: rohm,pmic-states.yaml# + + properties: + regulator-name: + pattern: "^ldo[1-4]$" + description: + should be "ldo1", ..., "ldo4" + + rohm,dvs-run-voltage: + minimum: 0 + maximum: 1 + + rohm,dvs-idle-voltage: + minimum: 0 + maximum: 1 + + rohm,dvs-suspend-voltage: + 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.55.0
PATCH v3 4/10 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.
---
Revision history:
v3:
- No changes
v1 => v2:
- Reference commonly used ROHM bindings from a common binding file
- Simplify compatible list
- Move relevant comments to description so they can be shown in generated human-readable doc.
- Allow other clock-output-names besides "bd73800-32k-out"
--- .../bindings/mfd/rohm,bd73800-pmic.yaml | 218 ++++++++++++++++++ 1 file changed, 218 insertions(+) create mode 100644 Documentation/devicetree/bindings/mfd/rohm,bd73800-pmic.yaml
Documentation/devicetree/bindings/mfd/rohm,bd73800-pmic.yaml new file +218 -0
@@ -0,0 +1,218 @@ +# 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. + +allOf: + - $ref: rohm,pmic-pins.yaml# + +properties: + compatible: + oneOf: + - const: rohm,bd73800 + + - items: + - enum: + - rohm,bd71851 + - 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 + + rohm,pin-gpio1: + $ref: /schemas/types.yaml#/definitions/string + description: + Indicate if the GPIO1 pin has been set to GPI or GPO at manufacturing. + 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 GPIO pins. + enum: [gpi, gpo] + + rohm,pin-clkout: + enum: [gpi, gpo] + + rohm,pin-fault_b: + enum: [gpi, gpo] + + rohm,pin-exten: + enum: [gpi, gpo] + + clocks: + description: + The CLKOUT pin may have its purpose overridden by OTP configuration. It + is possible the BD73800 does not output a clock signal. Hence the clk + properties are optional. + maxItems: 1 + + "#clock-cells": + const: 0 + + clock-output-names: + maxItems: 1 + + rohm,clkout-open-drain: true + + 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.55.0
PATCH v3 5/10 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.
---
Revision history:
v3:
- Translated this:
https://lore.kernel.org/all/[email protected]/
to an ack. Please, let me know if this isn't ok.
v1 => v2:
- styling
- update copyright years
--- drivers/mfd/Kconfig | 15 +- drivers/mfd/rohm-bd71828.c | 147 ++++++++++++++- include/linux/mfd/rohm-bd73800.h | 307 +++++++++++++++++++++++++++++++ include/linux/mfd/rohm-generic.h | 1 + 4 files changed, 462 insertions(+), 8 deletions(-) create mode 100644 include/linux/mfd/rohm-bd73800.h
drivers/mfd/Kconfig +9 -6
@@ -2226,7 +2226,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
@@ -2235,14 +2235,17 @@ config MFD_ROHM_BD71828 select MFD_ROHM_PWRBUTTON 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 +145 -2
213 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.55.0
PATCH v3 6/10 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.
---
Revision history:
v1 => :
- No changes
--- 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.55.0
PATCH v3 7/10 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.
---
Revision history:
v3:
- No changes
v1 => v2:
- Simplified DT parsing as was suggested by Mark
- Fix buck5 vsel_mask
--- drivers/regulator/Kconfig | 4 +- drivers/regulator/bd71828-regulator.c | 558 +++++++++++++++++++++++++- 2 files changed, 559 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 +557 -1
612 lines not on this page · raw message
Signature · 1 line
2.55.0
PATCH v3 8/10 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.
---
Revision history:
v2 => v3:
- Use named initializers for platform_device_id
v1 => v2:
- No changes
--- 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[] = { { .name = "bd71828-clk", .driver_data = ROHM_CHIP_TYPE_BD71828 }, { .name = "bd71815-clk", .driver_data = ROHM_CHIP_TYPE_BD71815 }, { .name = "bd72720-clk", .driver_data = ROHM_CHIP_TYPE_BD72720 }, + { .name = "bd73800-clk", .driver_data = ROHM_CHIP_TYPE_BD73800 }, { } };MODULE_DEVICE_TABLE (platform, bd718x7_clk_id);
Signature · 1 line
2.55.0
PATCH v3 9/10 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.
---
Revision history:
v2 => v3:
- Use gpio-regmap as was suggested by Linus W.
v1 => v2:
- Return -ENODEV when no GPIO pins are found
- Drop useless comment
- Use 'data' instead of 'g' as a name of the private data struct. Do so consistently (change also the 'bdgpio' to 'data').
- Use device_property_... instead of the fwnode_property_...
- fix fault_b pin property name (re-use existing name)
--- drivers/gpio/Kconfig | 12 +++ drivers/gpio/Makefile | 1 + drivers/gpio/gpio-bd73800.c | 209 ++++++++++++++++++++++++++++++++++++ 3 files changed, 222 insertions(+) create mode 100644 drivers/gpio/gpio-bd73800.c
drivers/gpio/Kconfig +12 -0
@@ -1385,6 +1385,18 @@ 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 + select GPIO_REGMAP + 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 +209 -0
209 lines not on this page · raw message
Signature · 1 line
2.55.0
PATCH v3 10/10 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.
---
Revision history:
v1 => :
- No changes
--- MAINTAINERS | 2 ++ 1 file changed, 2 insertions(+)
MAINTAINERS +2 -0
@@ -23821,6 +23821,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
@@ -23840,6 +23841,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.55.0
Re: [PATCH v3 09/10] gpio: bd73800: Support ROHM BD73800 PMIC GPIOs
In reply to Matti VaittinenHi Matti,
thanks for your patch!
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 1 line
Signed-off-by Matti Vaittinen <[email protected]>
Pretty neat with gpio-regmap isn't it? :)
Yours,
Linus Walleij
Re: [PATCH v3 09/10] gpio: bd73800: Support ROHM BD73800 PMIC GPIOs
In reply to Matti VaittinenQuoted 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
Signed-off-by Matti Vaittinen <[email protected]>
Looks good, just a couple nits.
Quoted 115 lines
---
Revision history:
v2 => v3:
- Use gpio-regmap as was suggested by Linus W.
v1 => v2:
- Return-ENODEVwhen no GPIO pins are found
- Drop useless comment
- Use 'data' instead of 'g' as a name of the private data struct. Do so consistently (change also the 'bdgpio' to 'data').
- Usedevice_property_... instead of thefwnode_property_...
- fixfault_bpin property name (re-use existing name)--- drivers/gpio/Kconfig | 12 +++ drivers/gpio/Makefile | 1 + drivers/gpio/gpio-bd73800.c | 209 ++++++++++++++++++++++++++++++++++++ 3 files changed, 222 insertions(+) create mode 100644 drivers/gpio/gpio-bd73800.cdrivers/gpio/Kconfig +12
-0@@ -1385,6 +1385,18 @@ 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 + select GPIO_REGMAP + 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 +56
-0@@ -0,0 +1,209 @@ +// SPDX-License-Identifier: GPL-2.0 +/* +* Support to GPIOs on ROHM BD73800 +* Copyright 2024 ROHM Semiconductors. +* Author: Matti Vaittinen <[email protected]> +*/ + +#include <linux/bitmap.h> +#include <linux/bitops.h> +#include <linux/gpio/driver.h> +#include <linux/gpio/regmap.h> +#include <linux/init.h> +#include <linux/module.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. +* +* The amount of GPIO lines the chip exposes to the user-space (chip.ngpio) is +* always the same, regardless of the OTP variant in use. The lines which are +* not usable as GPIO on a given OTP variant are marked invalid via the GPIO +* valid_mask. This way the user-space always sees a constant amount of GPIO +* lines, where numbering (relative to the chip's base) stays also the same. +* Users can then use the valid_mask to find out which of the lines are usable. +*/ + +struct bd73800_gpio { +/* dev points to the platform device for devm and prints */
drivers/gpio/gpio-bd73800.c line 66
Quoted 10 lines
drivers/gpio/gpio-bd73800.c new file +10
-0+struct device *dev; +struct regmap *regmap; +/* Pins which have been OTP configured as GPI or GPO */ +DECLARE_BITMAP (valid_mask,BD73800_GPIO_MAX_PINS ); +/* Subset of valid_mask - pins which have been OTP configured as GPO */ +DECLARE_BITMAP (output_mask,BD73800_GPIO_MAX_PINS ); +}; + +static const char *const bd73800_gpio_properties[BD73800_GPIO_MAX_PINS ] = { +"rohm,pin-gpio1" ,"rohm,pin-clkout" ,"rohm,pin-fault_b" ,"rohm,pin-exten"
Can you put the properties on separate lines?
Quoted 112 lines
drivers/gpio/gpio-bd73800.c new file +112
-0+}; + +static int bd73800_gpio_get_pins (struct bd73800_gpio *data) +{ +struct device *parent = data->dev->parent; +const char *val; +int i, ret; + +for (i =0 ; i <BD73800_GPIO_MAX_PINS ; i++) { + ret =device_property_read_string (parent, + bd73800_gpio_properties[i], + &val); +if (ret) { +if (ret == -EINVAL ) +continue ; + +return dev_err_probe (data->dev, ret, +"pin %d (%s), bad configuration\n" , i, + bd73800_gpio_properties[i]); + } + +if (!strcmp (val,"gpi" )) { +__set_bit (i, data->valid_mask); + }else if (!strcmp (val,"gpo" )) { +__set_bit (i, data->valid_mask); +__set_bit (i, data->output_mask); + }else { +dev_warn (data->dev, +"pin %d (%s), unknown value '%s' ignored\n" , i, + bd73800_gpio_properties[i], val); + } + } + +return 0 ; +} + +static int bd73800_gpio_init_valid_mask (struct gpio_chip *gc, +unsigned long *valid_mask, +unsigned int ngpios) +{ +struct gpio_regmap *gpio =gpiochip_get_data (gc); +struct bd73800_gpio *data =gpio_regmap_get_drvdata (gpio); + +bitmap_copy (valid_mask, data->valid_mask, ngpios); + +return 0 ; +} + +/* +* The used register depends on OTP: +* - If OTP has set pin as GPO, only the GPO_OUT register is valid. +* - If OTP has set pin as GPI, only the INT_5_SRC register is valid. +*/ +static int bd73800_gpio_reg_mask_xlate (struct gpio_regmap *gpio, +enum gpio_regmap_operation op, +unsigned int base,unsigned int offset, +unsigned int *reg,unsigned int *mask) +{ +struct bd73800_gpio *data =gpio_regmap_get_drvdata (gpio); +bool is_output =test_bit (offset, data->output_mask); + +if (is_output) + *reg =BD73800_REG_GPO_OUT ; +else + *reg = base; + + *mask =BIT (offset); + +return 0 ; +} + +static int gpo_bd73800_probe (struct platform_device *pdev) +{ +struct gpio_regmap_config config = { }; +struct bd73800_gpio *data; +struct device *parent, *dev; +struct gpio_regmap *gpio; +int ret; + + dev = &pdev->dev; +/* The device-tree and regmap come from MFD => use parent for that */ + parent = dev->parent; + + data =devm_kzalloc (dev,sizeof (*data),GFP_KERNEL ); +if (!data) +return -ENOMEM ; + + data->dev = dev; + data->regmap =dev_get_regmap (parent,NULL ); +if (!data->regmap) +return dev_err_probe (dev, -ENODEV ,"no parent regmap\n" ); + + ret =bd73800_gpio_get_pins (data); +if (ret) +return ret; + +if (bitmap_empty (data->valid_mask,BD73800_GPIO_MAX_PINS )) { +/* +* The BD73800 may or may not have pins allocated for GPIO +* depending on the OTP used at manufacturing. +* If there are no pins, then we have nothing to do. +*/ +dev_dbg (dev,"no GPIO pins\n" ); +return -ENODEV ; + } + + config.parent = parent; + config.regmap = data->regmap; + config.label ="bd73800" ; + config.ngpio =BD73800_GPIO_MAX_PINS ; + config.reg_dat_base =BD73800_REG_INT_5_SRC ; + config.reg_set_base =BD73800_REG_GPO_OUT ;
drivers/gpio/gpio-bd73800.c line 188
Quoted 10 lines
drivers/gpio/gpio-bd73800.c new file +10
-0+ config.reg_mask_xlate = bd73800_gpio_reg_mask_xlate; + config.init_valid_mask = bd73800_gpio_init_valid_mask; +/* All pins that are valid GPIO lines also have a fixed direction */ + config.fixed_direction_mask = data->valid_mask; + config.fixed_direction_output = data->output_mask; + config.drvdata = data; + + gpio =devm_gpio_regmap_register (dev, &config); + +return PTR_ERR_OR_ZERO (gpio);
Why not return PTR_ERR_OR_ZERO(devm_gpio_regmap_register())?
Quoted 22 lines
drivers/gpio/gpio-bd73800.c new file +21
-1+} + +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.55.0
With that:
Re: [PATCH v3 05/10] mfd: Support for ROHM BD73800 PMIC core
In reply to Matti VaittinenQuoted 10 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]>Acked-by Lee Jones <[email protected]>
Matti Vaittinen
maintainerRe: [PATCH v3 09/10] gpio: bd73800: Support ROHM BD73800 PMIC GPIOs
In reply to Bartosz GolaszewskiHi dee Ho Bartosz,
Thanks for the reviews!
Quoted 22 lines · Bartosz Golaszewski
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]>
//snip
Quoted 5 lines
drivers/gpio/gpio-bd73800.c line 66
Quoted 3 lines
drivers/gpio/gpio-bd73800.c new file +3
-0+ +static const char *const bd73800_gpio_properties[BD73800_GPIO_MAX_PINS ] = { +"rohm,pin-gpio1" ,"rohm,pin-clkout" ,"rohm,pin-fault_b" ,"rohm,pin-exten" Can you put the properties on separate lines?
Sure, no problem, thanks. I just wonder if I should re-spin the whole series for this. I suppose I'll wait until the next week, to see if I'll get any other comments.
Quoted 2 lines
Review
Quoted 2 lines
(quoted diff) +2
-0+}; +
//snip
Quoted 46 lines
Quoted 46 lines
drivers/gpio/gpio-bd73800.c new file +46
-0+ +static int gpo_bd73800_probe (struct platform_device *pdev) +{ +struct gpio_regmap_config config = { }; +struct bd73800_gpio *data; +struct device *parent, *dev; +struct gpio_regmap *gpio; +int ret; + + dev = &pdev->dev; +/* The device-tree and regmap come from MFD => use parent for that */ + parent = dev->parent; + + data =devm_kzalloc (dev,sizeof (*data),GFP_KERNEL ); +if (!data) +return -ENOMEM ; + + data->dev = dev; + data->regmap =dev_get_regmap (parent,NULL ); +if (!data->regmap) +return dev_err_probe (dev, -ENODEV ,"no parent regmap\n" ); + + ret =bd73800_gpio_get_pins (data); +if (ret) +return ret; + +if (bitmap_empty (data->valid_mask,BD73800_GPIO_MAX_PINS )) { +/* +* The BD73800 may or may not have pins allocated for GPIO +* depending on the OTP used at manufacturing. +* If there are no pins, then we have nothing to do. +*/ +dev_dbg (dev,"no GPIO pins\n" ); +return -ENODEV ; + } + + config.parent = parent; + config.regmap = data->regmap; + config.label ="bd73800" ; + config.ngpio =BD73800_GPIO_MAX_PINS ; + config.reg_dat_base =BD73800_REG_INT_5_SRC ; + config.reg_set_base =BD73800_REG_GPO_OUT ; + config.reg_mask_xlate = bd73800_gpio_reg_mask_xlate; + config.init_valid_mask = bd73800_gpio_init_valid_mask; +/* All pins that are valid GPIO lines also have a fixed direction */ + config.fixed_direction_mask = data->valid_mask;
Quoted 8 lines
drivers/gpio/gpio-bd73800.c line 188
Quoted 6 lines
drivers/gpio/gpio-bd73800.c new file +6
-0+ config.fixed_direction_output = data->output_mask; + config.drvdata = data; + + gpio =devm_gpio_regmap_register (dev, &config); + +return PTR_ERR_OR_ZERO (gpio);Why not return PTR_ERR_OR_ZERO(devm_gpio_regmap_register())?
How strongly do you feel about it? It's not a big deal, but I always find it a bit harder to read when functions / macros are called inside a parameter list. Thus I'd rather keep it like this, just for the sake of my own eyes :)
Quoted 7 lines
Review
Quoted 2 lines
(quoted diff) +2
-0+} +With 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
maintainerRe: [PATCH v3 09/10] gpio: bd73800: Support ROHM BD73800 PMIC GPIOs
In reply to Linus WalleijQuoted 27 lines · Linus Walleij
Hi Matti,
thanks for your patch!
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 3 lines
Quoted 1 line
Signed-off-by Matti Vaittinen <[email protected]>Pretty neat with gpio-regmap isn't it? :)
Yep. I like the added flexibility now that it has got those callbacks a driver can register... ;)
Quoted 1 line
Reviewed-by Linus Walleij <[email protected]>
Thanks!
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! ~~
Bartosz Golaszewski
maintainerRe: [PATCH v3 09/10] gpio: bd73800: Support ROHM BD73800 PMIC GPIOs
In reply to Matti VaittinenQuoted 8 lines · Matti Vaittinen
Quoted 2 lines
Why not return PTR_ERR_OR_ZERO(devm_gpio_regmap_register())?
How strongly do you feel about it? It's not a big deal, but I always find it a bit harder to read when functions / macros are called inside a parameter list. Thus I'd rather keep it like this, just for the sake of my own eyes :)
If you need to respin, please change it, if not, I've given my Ack and LGTM. Same above.
Bart
Re: [PATCH v3 08/10] clk: bd718x7: Support ROHM BD73800
In reply to Matti VaittinenQuoted 10 lines · Matti Vaittinen
From: 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.
Signed-off-by Matti Vaittinen <[email protected]>
Re: [PATCH v3 04/10] dt-bindings: mfd: ROHM BD73800 PMIC
In reply to Matti VaittinenQuoted 26 lines · Matti Vaittinen
From: 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.
Signed-off-by Matti Vaittinen <[email protected]>---
Revision history:
v3:
- No changes
v1 => v2:
- Reference commonly used ROHM bindings from a common binding file
- Simplify compatible list
- Move relevant comments to description so they can be shown in generated human-readable doc.
- Allow other clock-output-names besides "bd73800-32k-out"
Quoted 4 lines
--- .../bindings/mfd/rohm,bd73800-pmic.yaml | 218 ++++++++++++++++++ 1 file changed, 218 insertions(+) create mode 100644 Documentation/devicetree/bindings/mfd/rohm,bd73800-pmic.yaml
Re: [PATCH v3 03/10] dt-bindings: regulator: ROHM BD73800 regulators
In reply to Matti VaittinenQuoted 31 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]>---
Revision history:
v3:
- No changes
v1 => v2:
- Description of the state specific voltages moved to own file and referenced from it (because multiple PMIC bindings used them).The dt checker's documentation reference checker warns about the link to the MFD binding - which will be introduced in next commit. These commits have kind of a chicken and egg issue as MFD is referencing regulator properties introduced in this patch.
I could squash these but IMO, this is clearer for the reviewers. AFAICS, Both MFD and regulator subsystems tend to be busy. I could also split adding the MFD comment reference to own patch which would be after the patch adding the MFD binding, but having own patch for just adding the comment is a bit meh.
Quoted 7 lines
So, I decided to live with the broken doc-link between these two patches.
--- .../regulator/rohm,bd73800-regulator.yaml | 99 +++++++++++++++++++ 1 file changed, 99 insertions(+) create mode 100644 Documentation/devicetree/bindings/regulator/rohm,bd73800-regulator.yaml
Re: [PATCH v3 10/10] MAINTAINERS: Add ROHM BD73800 PMIC files
In reply to Matti VaittinenQuoted 6 lines · Matti Vaittinen
From: Matti Vaittinen <[email protected]>
Add the undersigned as a maintainer for the ROHM BD73800 PMIC related files.
Signed-off-by Matti Vaittinen <[email protected]>
Quoted 28 lines
---
Revision history:
v1 => :
- No changes
---
MAINTAINERS | 2 ++1 file changed, 2 insertions(+)MAINTAINERS +0
-0@@ -23821,6 +23821,7 @@ F: drivers/clk/clk-bd718x7.cF:
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.cMAINTAINERS +0
-0@@ -23840,6 +23841,7 @@ F: include/linux/mfd/rohm-bd71815.hF:
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 · 3 lines
Alexander Sverdlin Siemens AG www.siemens.com
Re: [PATCH v3 08/10] clk: bd718x7: Support ROHM BD73800
In reply to Matti VaittinenQuoted 9 lines · Matti Vaittinen
From: 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.
Signed-off-by Matti Vaittinen <[email protected]>
Quoted 43 lines
---
Revision history:
v2 => v3:
- Use named initializers forplatform_device_id
v1 => v2:
- No changes
---
drivers/clk/clk-bd718x7.c | 8 ++++++++1 file changed, 8 insertions(+)drivers/clk/clk-bd718x7.c +7
-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;drivers/clk/clk-bd718x7.c +1
-0@@ -152,6 +159,7 @@ static const struct platform_device_id bd718x7_clk_id[] = { { .name = "bd71828-clk", .driver_data = ROHM_CHIP_TYPE_BD71828 }, { .name = "bd71815-clk", .driver_data = ROHM_CHIP_TYPE_BD71815 }, { .name = "bd72720-clk", .driver_data = ROHM_CHIP_TYPE_BD72720 }, + { .name = "bd73800-clk", .driver_data = ROHM_CHIP_TYPE_BD73800 }, { } }; MODULE_DEVICE_TABLE(platform, bd718x7_clk_id);
Signature · 3 lines
Alexander Sverdlin Siemens AG www.siemens.com
Lee Jones
maintainerQuoted 21 lines · Matti Vaittinen
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.
Revision history:
v2 => v3:
- Rebased on v7.3-rc1.
- gpio: Use gpio-regmap as was suggested by Linus W. More accurate change-log in individual patches.
Quoted 8 lines
v1 => v2:
- Rebased on regulator/for-7.3 as it carries dependency:
f29a8bf6fde1("regulator: dt-bindings: ROHM PMIC state-machine voltages")
- dt-bindings: Various fixes, split generic stuff to own files.
- gpio: Styling, return-ENODEVif no GPIOs found
- MFD: Styling
- regulator: Simplify dt-reading
More accurate change-log in individual patches.
I assume there will be one more revision?
Signature · 1 line
Lee Jones
Matti Vaittinen
maintainerQuoted 32 lines · Lee Jones
Quoted 21 lines · Matti Vaittinen
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.
Revision history:
v2 => v3:
- Rebased on v7.3-rc1.
- gpio: Use gpio-regmap as was suggested by Linus W. More accurate change-log in individual patches.Quoted 8 lines
v1 => v2:
- Rebased on regulator/for-7.3 as it carries dependency:
f29a8bf6fde1("regulator: dt-bindings: ROHM PMIC state-machine voltages")
- dt-bindings: Various fixes, split generic stuff to own files.
- gpio: Styling, return-ENODEVif no GPIOs found
- MFD: Styling
- regulator: Simplify dt-reading
More accurate change-log in individual patches.
Quoted 2 lines
I assume there will be one more revision?
Hi Lee,
I thought everything was acked and good to go?
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! ~~
Lee Jones
maintainerQuoted 33 lines · Matti Vaittinen
Quoted 32 lines · Lee Jones
Quoted 29 lines · Matti Vaittinen
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.
Revision history:
v2 => v3:
- Rebased on v7.3-rc1.
- gpio: Use gpio-regmap as was suggested by Linus W. More accurate change-log in individual patches.v1 => v2:
- Rebased on regulator/for-7.3 as it carries dependency:
f29a8bf6fde1("regulator: dt-bindings: ROHM PMIC state-machine voltages")
- dt-bindings: Various fixes, split generic stuff to own files.
- gpio: Styling, return-ENODEVif no GPIOs found
- MFD: Styling
- regulator: Simplify dt-reading
More accurate change-log in individual patches.
Quoted 6 lines
Quoted 2 lines
I assume there will be one more revision?
Hi Lee,
I thought everything was acked and good to go?
I just saw the nits and commented before the blessing.
However, you may as well fix them and submit. I'll apply the set when you do.
Signature · 1 line
Lee Jones