* [PATCH v3 1/7] dt-bindings: mfd: brcm,bcm59056: Convert to YAML
2025-01-31 18:13 [PATCH v3 0/7] mfd: bcm590xx: Add support for BCM59054 Artur Weber
@ 2025-01-31 18:13 ` Artur Weber
2025-02-02 9:56 ` Stanislav Jakubek
2025-02-02 13:27 ` Krzysztof Kozlowski
2025-01-31 18:13 ` [PATCH v3 2/7] dt-bindings: mfd: brcm,bcm59056: Add compatible for BCM59054 Artur Weber
` (5 subsequent siblings)
6 siblings, 2 replies; 19+ messages in thread
From: Artur Weber @ 2025-01-31 18:13 UTC (permalink / raw)
To: Lee Jones, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
Liam Girdwood, Mark Brown, Florian Fainelli, Ray Jui,
Scott Branden, Broadcom internal kernel review list
Cc: Stanislav Jakubek, devicetree, linux-kernel, linux-arm-kernel,
~postmarketos/upstreaming, Artur Weber
Convert devicetree bindings for the Broadcom BCM59056 PMU MFD from
TXT to YAML format. This patch does not change any functionality;
the bindings remain the same.
The bindings have been split into two parts: the MFD binding and
a separate binding for the regulator node, to simplify the addition
of other models later (which have different regulators).
Signed-off-by: Artur Weber <aweber.kernel@gmail.com>
---
Changes in v3:
- Moved regulator node to separate binding
- Removed quotes around compatibles/vbus property
- Style fixes for example
---
.../devicetree/bindings/mfd/brcm,bcm59056.txt | 39 ---------------
.../devicetree/bindings/mfd/brcm,bcm59056.yaml | 54 ++++++++++++++++++++
.../bindings/regulator/brcm,bcm59056.yaml | 58 ++++++++++++++++++++++
3 files changed, 112 insertions(+), 39 deletions(-)
diff --git a/Documentation/devicetree/bindings/mfd/brcm,bcm59056.txt b/Documentation/devicetree/bindings/mfd/brcm,bcm59056.txt
deleted file mode 100644
index be51a15e05f926913b3a473648d977b25f1a2fbc..0000000000000000000000000000000000000000
--- a/Documentation/devicetree/bindings/mfd/brcm,bcm59056.txt
+++ /dev/null
@@ -1,39 +0,0 @@
--------------------------------
-BCM590xx Power Management Units
--------------------------------
-
-Required properties:
-- compatible: "brcm,bcm59056"
-- reg: I2C slave address
-- interrupts: interrupt for the PMU. Generic interrupt client node bindings
- are described in interrupt-controller/interrupts.txt
-
-------------------
-Voltage Regulators
-------------------
-
-Optional child nodes:
-- regulators: container node for regulators following the generic
- regulator binding in regulator/regulator.txt
-
- The valid regulator node names for BCM59056 are:
- rfldo, camldo1, camldo2, simldo1, simldo2, sdldo, sdxldo,
- mmcldo1, mmcldo2, audldo, micldo, usbldo, vibldo,
- csr, iosr1, iosr2, msr, sdsr1, sdsr2, vsr,
- gpldo1, gpldo2, gpldo3, gpldo4, gpldo5, gpldo6,
- vbus
-
-Example:
- pmu: bcm59056@8 {
- compatible = "brcm,bcm59056";
- reg = <0x08>;
- interrupts = <GIC_SPI 215 IRQ_TYPE_LEVEL_HIGH>;
- regulators {
- rfldo_reg: rfldo {
- regulator-min-microvolt = <1200000>;
- regulator-max-microvolt = <3300000>;
- };
-
- ...
- };
- };
diff --git a/Documentation/devicetree/bindings/mfd/brcm,bcm59056.yaml b/Documentation/devicetree/bindings/mfd/brcm,bcm59056.yaml
new file mode 100644
index 0000000000000000000000000000000000000000..3296799eb452fca2a4b03699fcb5aa27005a8e8d
--- /dev/null
+++ b/Documentation/devicetree/bindings/mfd/brcm,bcm59056.yaml
@@ -0,0 +1,54 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/mfd/brcm,bcm59056.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Broadcom BCM590xx Power Management IC
+
+maintainers:
+ - Artur Weber <aweber.kernel@gmail.com>
+
+properties:
+ compatible:
+ const: brcm,bcm59056
+
+ reg:
+ maxItems: 1
+
+ interrupts:
+ maxItems: 1
+
+ regulators:
+ type: object
+ description: Container node for regulators.
+ $ref: ../regulator/brcm,bcm59056.yaml
+
+required:
+ - compatible
+ - reg
+ - interrupts
+
+additionalProperties: false
+
+examples:
+ - |
+ #include <dt-bindings/interrupt-controller/arm-gic.h>
+
+ i2c {
+ #address-cells = <1>;
+ #size-cells = <0>;
+
+ pmic: bcm59056@8 {
+ compatible = "brcm,bcm59056";
+ reg = <0x08>;
+ interrupts = <GIC_SPI 215 IRQ_TYPE_LEVEL_HIGH>;
+
+ regulators {
+ rfldo_reg: rfldo {
+ regulator-min-microvolt = <1200000>;
+ regulator-max-microvolt = <3300000>;
+ };
+ };
+ };
+ };
diff --git a/Documentation/devicetree/bindings/regulator/brcm,bcm59056.yaml b/Documentation/devicetree/bindings/regulator/brcm,bcm59056.yaml
new file mode 100644
index 0000000000000000000000000000000000000000..8939004d5a3f079c05d313bed4a2f07fbc473bac
--- /dev/null
+++ b/Documentation/devicetree/bindings/regulator/brcm,bcm59056.yaml
@@ -0,0 +1,58 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/regulator/brcm,bcm59056.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Broadcom BCM59056 Power Management IC regulators
+
+description: |
+ This is a part of device tree bindings for the BCM590XX family of power
+ management ICs.
+
+ See also Documentation/devicetree/bindings/mfd/brcm,bcm59056.yaml for
+ additional information and example.
+
+maintainers:
+ - Artur Weber <aweber.kernel@gmail.com>
+
+# The valid regulator node names for BCM59056 are:
+# rfldo, camldo1, camldo2, simldo1, simldo2, sdldo, sdxldo,
+# mmcldo1, mmcldo2, audldo, micldo, usbldo, vibldo,
+# csr, iosr1, iosr2, msr, sdsr1, sdsr2, vsr,
+# gpldo1, gpldo2, gpldo3, gpldo4, gpldo5, gpldo6,
+# vbus
+
+patternProperties:
+ "^(cam|sim|mmc)ldo[1-2]$":
+ type: object
+ $ref: /schemas/regulator/regulator.yaml#
+ unevaluatedProperties: false
+
+ "^(rf|sd|sdx|aud|mic|usb|vib)ldo$":
+ type: object
+ $ref: /schemas/regulator/regulator.yaml#
+ unevaluatedProperties: false
+
+ "^(c|m|v)sr$":
+ type: object
+ $ref: /schemas/regulator/regulator.yaml#
+ unevaluatedProperties: false
+
+ "^(io|sd)sr[1-2]$":
+ type: object
+ $ref: /schemas/regulator/regulator.yaml#
+ unevaluatedProperties: false
+
+ "^gpldo[1-6]$":
+ type: object
+ $ref: /schemas/regulator/regulator.yaml#
+ unevaluatedProperties: false
+
+properties:
+ vbus:
+ type: object
+ $ref: /schemas/regulator/regulator.yaml#
+ unevaluatedProperties: false
+
+additionalProperties: false
--
2.48.1
^ permalink raw reply related [flat|nested] 19+ messages in thread* Re: [PATCH v3 1/7] dt-bindings: mfd: brcm,bcm59056: Convert to YAML
2025-01-31 18:13 ` [PATCH v3 1/7] dt-bindings: mfd: brcm,bcm59056: Convert to YAML Artur Weber
@ 2025-02-02 9:56 ` Stanislav Jakubek
2025-02-02 13:27 ` Krzysztof Kozlowski
1 sibling, 0 replies; 19+ messages in thread
From: Stanislav Jakubek @ 2025-02-02 9:56 UTC (permalink / raw)
To: Artur Weber
Cc: Lee Jones, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
Liam Girdwood, Mark Brown, Florian Fainelli, Ray Jui,
Scott Branden, Broadcom internal kernel review list, devicetree,
linux-kernel, linux-arm-kernel, ~postmarketos/upstreaming
On Fri, Jan 31, 2025 at 07:13:49PM +0100, Artur Weber wrote:
> Convert devicetree bindings for the Broadcom BCM59056 PMU MFD from
> TXT to YAML format. This patch does not change any functionality;
> the bindings remain the same.
>
> The bindings have been split into two parts: the MFD binding and
> a separate binding for the regulator node, to simplify the addition
> of other models later (which have different regulators).
>
> Signed-off-by: Artur Weber <aweber.kernel@gmail.com>
[snip]
> + regulators:
> + type: object
> + description: Container node for regulators.
> + $ref: ../regulator/brcm,bcm59056.yaml
Use the full path, so /schemas/regulator/brcm,bcm59056.yaml#
The description seems unnecessary, you can drop it.
> +
> +required:
> + - compatible
> + - reg
> + - interrupts
> +
> +additionalProperties: false
> +
> +examples:
> + - |
> + #include <dt-bindings/interrupt-controller/arm-gic.h>
> +
> + i2c {
> + #address-cells = <1>;
> + #size-cells = <0>;
> +
> + pmic: bcm59056@8 {
Node names should be generic. And drop unused label.
Should just look like this:
pmic@8 {
> + compatible = "brcm,bcm59056";
> + reg = <0x08>;
> + interrupts = <GIC_SPI 215 IRQ_TYPE_LEVEL_HIGH>;
#include <dt-bindings/interrupt-controller/irq.h> ?
V2 seems to have it, not sure why you dropped this.
> +
> + regulators {
> + rfldo_reg: rfldo {
Unused label, drop.
> + regulator-min-microvolt = <1200000>;
> + regulator-max-microvolt = <3300000>;
> + };
> + };
> + };
> + };
> diff --git a/Documentation/devicetree/bindings/regulator/brcm,bcm59056.yaml b/Documentation/devicetree/bindings/regulator/brcm,bcm59056.yaml
> new file mode 100644
> index 0000000000000000000000000000000000000000..8939004d5a3f079c05d313bed4a2f07fbc473bac
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/regulator/brcm,bcm59056.yaml
> @@ -0,0 +1,58 @@
> +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
> +%YAML 1.2
> +---
> +$id: http://devicetree.org/schemas/regulator/brcm,bcm59056.yaml#
> +$schema: http://devicetree.org/meta-schemas/core.yaml#
> +
> +title: Broadcom BCM59056 Power Management IC regulators
> +
> +description: |
> + This is a part of device tree bindings for the BCM590XX family of power
> + management ICs.
This doesn't really say anything. Also AFAIK these are only part of BCM59056,
not the entire BCM590XX family.
Maybe say here something like:
"The BCM59056 PMIC integrates X regulators, their valid names are
lorem, ipsum, etc.
> +
> + See also Documentation/devicetree/bindings/mfd/brcm,bcm59056.yaml for
> + additional information and example.
> +
> +maintainers:
> + - Artur Weber <aweber.kernel@gmail.com>
> +
> +# The valid regulator node names for BCM59056 are:
> +# rfldo, camldo1, camldo2, simldo1, simldo2, sdldo, sdxldo,
> +# mmcldo1, mmcldo2, audldo, micldo, usbldo, vibldo,
> +# csr, iosr1, iosr2, msr, sdsr1, sdsr2, vsr,
> +# gpldo1, gpldo2, gpldo3, gpldo4, gpldo5, gpldo6,
> +# vbus
This should probably be a part of the description, not just a comment.
Could be argued to drop it since it's also described below in
patternProperties, but this is easier to read, so IMO would be better to keep.
Regards,
Stanislav
^ permalink raw reply [flat|nested] 19+ messages in thread* Re: [PATCH v3 1/7] dt-bindings: mfd: brcm,bcm59056: Convert to YAML
2025-01-31 18:13 ` [PATCH v3 1/7] dt-bindings: mfd: brcm,bcm59056: Convert to YAML Artur Weber
2025-02-02 9:56 ` Stanislav Jakubek
@ 2025-02-02 13:27 ` Krzysztof Kozlowski
2025-02-04 18:33 ` Artur Weber
1 sibling, 1 reply; 19+ messages in thread
From: Krzysztof Kozlowski @ 2025-02-02 13:27 UTC (permalink / raw)
To: Artur Weber
Cc: Lee Jones, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
Liam Girdwood, Mark Brown, Florian Fainelli, Ray Jui,
Scott Branden, Broadcom internal kernel review list,
Stanislav Jakubek, devicetree, linux-kernel, linux-arm-kernel,
~postmarketos/upstreaming
On Fri, Jan 31, 2025 at 07:13:49PM +0100, Artur Weber wrote:
> +$id: http://devicetree.org/schemas/mfd/brcm,bcm59056.yaml#
> +$schema: http://devicetree.org/meta-schemas/core.yaml#
> +
> +title: Broadcom BCM590xx Power Management IC
> +
> +maintainers:
> + - Artur Weber <aweber.kernel@gmail.com>
> +
> +properties:
> + compatible:
> + const: brcm,bcm59056
> +
> + reg:
> + maxItems: 1
> +
> + interrupts:
> + maxItems: 1
> +
> + regulators:
> + type: object
> + description: Container node for regulators.
> + $ref: ../regulator/brcm,bcm59056.yaml
Does this device have any other function? RTC? Charger? If not, maybe
just put everything in one binding in regulator dir.
> +
> +required:
> + - compatible
> + - reg
> + - interrupts
> +
> +additionalProperties: false
> +
> +examples:
> + - |
> + #include <dt-bindings/interrupt-controller/arm-gic.h>
> +
> + i2c {
> + #address-cells = <1>;
> + #size-cells = <0>;
> +
> + pmic: bcm59056@8 {
Node names should be generic. See also an explanation and list of
examples (not exhaustive) in DT specification:
https://devicetree-specification.readthedocs.io/en/latest/chapter2-devicetree-basics.html#generic-names-recommendation
> + compatible = "brcm,bcm59056";
> + reg = <0x08>;
> + interrupts = <GIC_SPI 215 IRQ_TYPE_LEVEL_HIGH>;
> +
> + regulators {
> + rfldo_reg: rfldo {
> + regulator-min-microvolt = <1200000>;
> + regulator-max-microvolt = <3300000>;
> + };
> + };
> + };
> + };
> diff --git a/Documentation/devicetree/bindings/regulator/brcm,bcm59056.yaml b/Documentation/devicetree/bindings/regulator/brcm,bcm59056.yaml
> new file mode 100644
> index 0000000000000000000000000000000000000000..8939004d5a3f079c05d313bed4a2f07fbc473bac
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/regulator/brcm,bcm59056.yaml
> @@ -0,0 +1,58 @@
> +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
> +%YAML 1.2
> +---
> +$id: http://devicetree.org/schemas/regulator/brcm,bcm59056.yaml#
> +$schema: http://devicetree.org/meta-schemas/core.yaml#
> +
> +title: Broadcom BCM59056 Power Management IC regulators
> +
> +description: |
> + This is a part of device tree bindings for the BCM590XX family of power
> + management ICs.
> +
> + See also Documentation/devicetree/bindings/mfd/brcm,bcm59056.yaml for
> + additional information and example.
> +
> +maintainers:
> + - Artur Weber <aweber.kernel@gmail.com>
> +
> +# The valid regulator node names for BCM59056 are:
> +# rfldo, camldo1, camldo2, simldo1, simldo2, sdldo, sdxldo,
> +# mmcldo1, mmcldo2, audldo, micldo, usbldo, vibldo,
> +# csr, iosr1, iosr2, msr, sdsr1, sdsr2, vsr,
> +# gpldo1, gpldo2, gpldo3, gpldo4, gpldo5, gpldo6,
> +# vbus
patternProperties should define this. No need to repeat schema in
freeform text.
Best regards,
Krzysztof
^ permalink raw reply [flat|nested] 19+ messages in thread* Re: [PATCH v3 1/7] dt-bindings: mfd: brcm,bcm59056: Convert to YAML
2025-02-02 13:27 ` Krzysztof Kozlowski
@ 2025-02-04 18:33 ` Artur Weber
0 siblings, 0 replies; 19+ messages in thread
From: Artur Weber @ 2025-02-04 18:33 UTC (permalink / raw)
To: Krzysztof Kozlowski
Cc: Lee Jones, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
Liam Girdwood, Mark Brown, Florian Fainelli, Ray Jui,
Scott Branden, Broadcom internal kernel review list,
Stanislav Jakubek, devicetree, linux-kernel, linux-arm-kernel,
~postmarketos/upstreaming
On 2.02.2025 14:27, Krzysztof Kozlowski wrote:
> On Fri, Jan 31, 2025 at 07:13:49PM +0100, Artur Weber wrote:
>> +$id: http://devicetree.org/schemas/mfd/brcm,bcm59056.yaml#
>> +$schema: http://devicetree.org/meta-schemas/core.yaml#
>> +
>> +title: Broadcom BCM590xx Power Management IC
>> +
>> +maintainers:
>> + - Artur Weber <aweber.kernel@gmail.com>
>> +
>> +properties:
>> + compatible:
>> + const: brcm,bcm59056
>> +
>> + reg:
>> + maxItems: 1
>> +
>> + interrupts:
>> + maxItems: 1
>> +
>> + regulators:
>> + type: object
>> + description: Container node for regulators.
>> + $ref: ../regulator/brcm,bcm59056.yaml
>
> Does this device have any other function? RTC? Charger? If not, maybe
> just put everything in one binding in regulator dir.
>
Yes, the BCM590xx PMICs have multiple other functions: power-on key,
RTC, charger/fuel gauge and some USB/audio related controls. I am
planning to extend the driver to support all of these features in the
near future; when the time comes, the DT bindings will have to be
updated as well.
>> +
>> +required:
>> + - compatible
>> + - reg
>> + - interrupts
>> +
>> +additionalProperties: false
>> +
>> +examples:
>> + - |
>> + #include <dt-bindings/interrupt-controller/arm-gic.h>
>> +
>> + i2c {
>> + #address-cells = <1>;
>> + #size-cells = <0>;
>> +
>> + pmic: bcm59056@8 {
>
> Node names should be generic. See also an explanation and list of
> examples (not exhaustive) in DT specification:
> https://devicetree-specification.readthedocs.io/en/latest/chapter2-devicetree-basics.html#generic-names-recommendation
>
I will fix this in the next version.
>> + compatible = "brcm,bcm59056";
>> + reg = <0x08>;
>> + interrupts = <GIC_SPI 215 IRQ_TYPE_LEVEL_HIGH>;
>> +
>> + regulators {
>> + rfldo_reg: rfldo {
>> + regulator-min-microvolt = <1200000>;
>> + regulator-max-microvolt = <3300000>;
>> + };
>> + };
>> + };
>> + };
>> diff --git a/Documentation/devicetree/bindings/regulator/brcm,bcm59056.yaml b/Documentation/devicetree/bindings/regulator/brcm,bcm59056.yaml
>> new file mode 100644
>> index 0000000000000000000000000000000000000000..8939004d5a3f079c05d313bed4a2f07fbc473bac
>> --- /dev/null
>> +++ b/Documentation/devicetree/bindings/regulator/brcm,bcm59056.yaml
>> @@ -0,0 +1,58 @@
>> +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
>> +%YAML 1.2
>> +---
>> +$id: http://devicetree.org/schemas/regulator/brcm,bcm59056.yaml#
>> +$schema: http://devicetree.org/meta-schemas/core.yaml#
>> +
>> +title: Broadcom BCM59056 Power Management IC regulators
>> +
>> +description: |
>> + This is a part of device tree bindings for the BCM590XX family of power
>> + management ICs.
>> +
>> + See also Documentation/devicetree/bindings/mfd/brcm,bcm59056.yaml for
>> + additional information and example.
>> +
>> +maintainers:
>> + - Artur Weber <aweber.kernel@gmail.com>
>> +
>> +# The valid regulator node names for BCM59056 are:
>> +# rfldo, camldo1, camldo2, simldo1, simldo2, sdldo, sdxldo,
>> +# mmcldo1, mmcldo2, audldo, micldo, usbldo, vibldo,
>> +# csr, iosr1, iosr2, msr, sdsr1, sdsr2, vsr,
>> +# gpldo1, gpldo2, gpldo3, gpldo4, gpldo5, gpldo6,
>> +# vbus
>
> patternProperties should define this. No need to repeat schema in
> freeform text.
IMO a full list is a bit easier to read than the regexes (another
suggestion was to move the list to the description [1]), but I don't
mind dropping it. For the most part, it's a carryover from the TXT
binding.
Best regards
Artur
[1] https://lore.kernel.org/lkml/Z59BQB_cBgTDm4ie@standask-GA-A55M-S2HP/
^ permalink raw reply [flat|nested] 19+ messages in thread
* [PATCH v3 2/7] dt-bindings: mfd: brcm,bcm59056: Add compatible for BCM59054
2025-01-31 18:13 [PATCH v3 0/7] mfd: bcm590xx: Add support for BCM59054 Artur Weber
2025-01-31 18:13 ` [PATCH v3 1/7] dt-bindings: mfd: brcm,bcm59056: Convert to YAML Artur Weber
@ 2025-01-31 18:13 ` Artur Weber
2025-01-31 19:41 ` Rob Herring (Arm)
` (2 more replies)
2025-01-31 18:13 ` [PATCH v3 3/7] ARM: dts: Drop DTS for BCM59056 PMIC Artur Weber
` (4 subsequent siblings)
6 siblings, 3 replies; 19+ messages in thread
From: Artur Weber @ 2025-01-31 18:13 UTC (permalink / raw)
To: Lee Jones, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
Liam Girdwood, Mark Brown, Florian Fainelli, Ray Jui,
Scott Branden, Broadcom internal kernel review list
Cc: Stanislav Jakubek, devicetree, linux-kernel, linux-arm-kernel,
~postmarketos/upstreaming, Artur Weber
The BCM59054 MFD is fairly similar to the BCM59056, and will use
the same driver. Add compatible and specify the allowed regulator
nodes.
Signed-off-by: Artur Weber <aweber.kernel@gmail.com>
---
Changes in v3:
- Split regulator node into separate file
- Removed quotes around compatible
---
.../devicetree/bindings/mfd/brcm,bcm59056.yaml | 26 +++++++++-
.../bindings/regulator/brcm,bcm59054.yaml | 55 ++++++++++++++++++++++
2 files changed, 79 insertions(+), 2 deletions(-)
diff --git a/Documentation/devicetree/bindings/mfd/brcm,bcm59056.yaml b/Documentation/devicetree/bindings/mfd/brcm,bcm59056.yaml
index 3296799eb452fca2a4b03699fcb5aa27005a8e8d..87d663416ed9e7f5ec4aa25c1aa2d9e650c42e2c 100644
--- a/Documentation/devicetree/bindings/mfd/brcm,bcm59056.yaml
+++ b/Documentation/devicetree/bindings/mfd/brcm,bcm59056.yaml
@@ -11,7 +11,9 @@ maintainers:
properties:
compatible:
- const: brcm,bcm59056
+ enum:
+ - brcm,bcm59054
+ - brcm,bcm59056
reg:
maxItems: 1
@@ -22,7 +24,6 @@ properties:
regulators:
type: object
description: Container node for regulators.
- $ref: ../regulator/brcm,bcm59056.yaml
required:
- compatible
@@ -31,6 +32,27 @@ required:
additionalProperties: false
+allOf:
+ - if:
+ properties:
+ compatible:
+ contains:
+ const: brcm,bcm59054
+ then:
+ properties:
+ regulators:
+ $ref: ../regulator/brcm,bcm59054.yaml
+
+ - if:
+ properties:
+ compatible:
+ contains:
+ const: brcm,bcm59056
+ then:
+ properties:
+ regulators:
+ $ref: ../regulator/brcm,bcm59056.yaml
+
examples:
- |
#include <dt-bindings/interrupt-controller/arm-gic.h>
diff --git a/Documentation/devicetree/bindings/regulator/brcm,bcm59054.yaml b/Documentation/devicetree/bindings/regulator/brcm,bcm59054.yaml
new file mode 100644
index 0000000000000000000000000000000000000000..719621c7f0e71cd9368f4d7243c79aaa97ca7255
--- /dev/null
+++ b/Documentation/devicetree/bindings/regulator/brcm,bcm59054.yaml
@@ -0,0 +1,55 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/regulator/brcm,bcm59054.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Broadcom BCM59054 Power Management IC regulators
+
+description: |
+ This is a part of device tree bindings for the BCM590XX family of power
+ management ICs.
+
+ See also Documentation/devicetree/bindings/mfd/brcm,bcm59056.yaml for
+ additional information and example.
+
+maintainers:
+ - Artur Weber <aweber.kernel@gmail.com>
+
+# The valid regulator node names for BCM59054 are:
+# rfldo, camldo1, camldo2, simldo1, simldo2, sdldo, sdxldo,
+# mmcldo1, mmcldo2, audldo, micldo, usbldo, vibldo,
+# csr, iosr1, iosr2, mmsr, sdsr1, sdsr2, vsr,
+# gpldo1, gpldo2, gpldo3, tcxldo, lvldo1, lvldo2
+
+patternProperties:
+ "^(cam|sim|mmc)ldo[1-2]$":
+ type: object
+ $ref: /schemas/regulator/regulator.yaml#
+
+ "^(rf|sd|sdx|aud|mic|usb|vib|tcx)ldo$":
+ type: object
+ $ref: /schemas/regulator/regulator.yaml#
+
+ "^(c|mm|v)sr$":
+ type: object
+ $ref: /schemas/regulator/regulator.yaml#
+
+ "^(io|sd)sr[1-2]$":
+ type: object
+ $ref: /schemas/regulator/regulator.yaml#
+
+ "^gpldo[1-3]$":
+ type: object
+ $ref: /schemas/regulator/regulator.yaml#
+
+ "^lvldo[1-2]$":
+ type: object
+ $ref: /schemas/regulator/regulator.yaml#
+
+properties:
+ "vbus":
+ type: object
+ $ref: /schemas/regulator/regulator.yaml#
+
+additionalProperties: false
--
2.48.1
^ permalink raw reply related [flat|nested] 19+ messages in thread* Re: [PATCH v3 2/7] dt-bindings: mfd: brcm,bcm59056: Add compatible for BCM59054
2025-01-31 18:13 ` [PATCH v3 2/7] dt-bindings: mfd: brcm,bcm59056: Add compatible for BCM59054 Artur Weber
@ 2025-01-31 19:41 ` Rob Herring (Arm)
2025-02-02 10:08 ` Stanislav Jakubek
2025-02-02 13:24 ` Krzysztof Kozlowski
2 siblings, 0 replies; 19+ messages in thread
From: Rob Herring (Arm) @ 2025-01-31 19:41 UTC (permalink / raw)
To: Artur Weber
Cc: Broadcom internal kernel review list, Liam Girdwood,
linux-arm-kernel, devicetree, Ray Jui, Conor Dooley,
Florian Fainelli, Scott Branden, linux-kernel,
~postmarketos/upstreaming, Mark Brown, Lee Jones,
Krzysztof Kozlowski, Stanislav Jakubek
On Fri, 31 Jan 2025 19:13:50 +0100, Artur Weber wrote:
> The BCM59054 MFD is fairly similar to the BCM59056, and will use
> the same driver. Add compatible and specify the allowed regulator
> nodes.
>
> Signed-off-by: Artur Weber <aweber.kernel@gmail.com>
> ---
> Changes in v3:
> - Split regulator node into separate file
> - Removed quotes around compatible
> ---
> .../devicetree/bindings/mfd/brcm,bcm59056.yaml | 26 +++++++++-
> .../bindings/regulator/brcm,bcm59054.yaml | 55 ++++++++++++++++++++++
> 2 files changed, 79 insertions(+), 2 deletions(-)
>
My bot found errors running 'make dt_binding_check' on your patch:
yamllint warnings/errors:
dtschema/dtc warnings/errors:
/builds/robherring/dt-review-ci/linux/Documentation/devicetree/bindings/regulator/brcm,bcm59054.yaml: ^(cam|sim|mmc)ldo[1-2]$: Missing additionalProperties/unevaluatedProperties constraint
/builds/robherring/dt-review-ci/linux/Documentation/devicetree/bindings/regulator/brcm,bcm59054.yaml: ^(rf|sd|sdx|aud|mic|usb|vib|tcx)ldo$: Missing additionalProperties/unevaluatedProperties constraint
/builds/robherring/dt-review-ci/linux/Documentation/devicetree/bindings/regulator/brcm,bcm59054.yaml: ^(c|mm|v)sr$: Missing additionalProperties/unevaluatedProperties constraint
/builds/robherring/dt-review-ci/linux/Documentation/devicetree/bindings/regulator/brcm,bcm59054.yaml: ^(io|sd)sr[1-2]$: Missing additionalProperties/unevaluatedProperties constraint
/builds/robherring/dt-review-ci/linux/Documentation/devicetree/bindings/regulator/brcm,bcm59054.yaml: ^gpldo[1-3]$: Missing additionalProperties/unevaluatedProperties constraint
/builds/robherring/dt-review-ci/linux/Documentation/devicetree/bindings/regulator/brcm,bcm59054.yaml: ^lvldo[1-2]$: Missing additionalProperties/unevaluatedProperties constraint
/builds/robherring/dt-review-ci/linux/Documentation/devicetree/bindings/regulator/brcm,bcm59054.yaml: vbus: Missing additionalProperties/unevaluatedProperties constraint
doc reference errors (make refcheckdocs):
See https://patchwork.ozlabs.org/project/devicetree-bindings/patch/20250131-bcm59054-v3-2-bbac52a84787@gmail.com
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.
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [PATCH v3 2/7] dt-bindings: mfd: brcm,bcm59056: Add compatible for BCM59054
2025-01-31 18:13 ` [PATCH v3 2/7] dt-bindings: mfd: brcm,bcm59056: Add compatible for BCM59054 Artur Weber
2025-01-31 19:41 ` Rob Herring (Arm)
@ 2025-02-02 10:08 ` Stanislav Jakubek
2025-02-02 13:24 ` Krzysztof Kozlowski
2 siblings, 0 replies; 19+ messages in thread
From: Stanislav Jakubek @ 2025-02-02 10:08 UTC (permalink / raw)
To: Artur Weber
Cc: Lee Jones, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
Liam Girdwood, Mark Brown, Florian Fainelli, Ray Jui,
Scott Branden, Broadcom internal kernel review list, devicetree,
linux-kernel, linux-arm-kernel, ~postmarketos/upstreaming
On Fri, Jan 31, 2025 at 07:13:50PM +0100, Artur Weber wrote:
> The BCM59054 MFD is fairly similar to the BCM59056, and will use
> the same driver. Add compatible and specify the allowed regulator
> nodes.
>
> Signed-off-by: Artur Weber <aweber.kernel@gmail.com>
[snip]
> +allOf:
> + - if:
> + properties:
> + compatible:
> + contains:
> + const: brcm,bcm59054
> + then:
> + properties:
> + regulators:
> + $ref: ../regulator/brcm,bcm59054.yaml
Full path.
> +
> + - if:
> + properties:
> + compatible:
> + contains:
> + const: brcm,bcm59056
> + then:
> + properties:
> + regulators:
> + $ref: ../regulator/brcm,bcm59056.yaml
Full path.
> +
> examples:
> - |
> #include <dt-bindings/interrupt-controller/arm-gic.h>
> diff --git a/Documentation/devicetree/bindings/regulator/brcm,bcm59054.yaml b/Documentation/devicetree/bindings/regulator/brcm,bcm59054.yaml
> new file mode 100644
> index 0000000000000000000000000000000000000000..719621c7f0e71cd9368f4d7243c79aaa97ca7255
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/regulator/brcm,bcm59054.yaml
> @@ -0,0 +1,55 @@
> +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
> +%YAML 1.2
> +---
> +$id: http://devicetree.org/schemas/regulator/brcm,bcm59054.yaml#
> +$schema: http://devicetree.org/meta-schemas/core.yaml#
> +
> +title: Broadcom BCM59054 Power Management IC regulators
> +
> +description: |
> + This is a part of device tree bindings for the BCM590XX family of power
> + management ICs.
Same comment as patch 1.
> +
> + See also Documentation/devicetree/bindings/mfd/brcm,bcm59056.yaml for
> + additional information and example.
> +
> +maintainers:
> + - Artur Weber <aweber.kernel@gmail.com>
> +
> +# The valid regulator node names for BCM59054 are:
> +# rfldo, camldo1, camldo2, simldo1, simldo2, sdldo, sdxldo,
> +# mmcldo1, mmcldo2, audldo, micldo, usbldo, vibldo,
> +# csr, iosr1, iosr2, mmsr, sdsr1, sdsr2, vsr,
> +# gpldo1, gpldo2, gpldo3, tcxldo, lvldo1, lvldo2
Same comment as patch 1.
> +
> +patternProperties:
> + "^(cam|sim|mmc)ldo[1-2]$":
> + type: object
> + $ref: /schemas/regulator/regulator.yaml#
As Rob's bot pointed out, you're missing unevaluatedProperties: false in
all of these.
Regards,
Stanislav
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [PATCH v3 2/7] dt-bindings: mfd: brcm,bcm59056: Add compatible for BCM59054
2025-01-31 18:13 ` [PATCH v3 2/7] dt-bindings: mfd: brcm,bcm59056: Add compatible for BCM59054 Artur Weber
2025-01-31 19:41 ` Rob Herring (Arm)
2025-02-02 10:08 ` Stanislav Jakubek
@ 2025-02-02 13:24 ` Krzysztof Kozlowski
2025-02-05 17:58 ` Artur Weber
2 siblings, 1 reply; 19+ messages in thread
From: Krzysztof Kozlowski @ 2025-02-02 13:24 UTC (permalink / raw)
To: Artur Weber
Cc: Lee Jones, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
Liam Girdwood, Mark Brown, Florian Fainelli, Ray Jui,
Scott Branden, Broadcom internal kernel review list,
Stanislav Jakubek, devicetree, linux-kernel, linux-arm-kernel,
~postmarketos/upstreaming
On Fri, Jan 31, 2025 at 07:13:50PM +0100, Artur Weber wrote:
> The BCM59054 MFD is fairly similar to the BCM59056, and will use
> the same driver. Add compatible and specify the allowed regulator
> nodes.
>
> Signed-off-by: Artur Weber <aweber.kernel@gmail.com>
> ---
> Changes in v3:
> - Split regulator node into separate file
> - Removed quotes around compatible
> ---
> .../devicetree/bindings/mfd/brcm,bcm59056.yaml | 26 +++++++++-
> .../bindings/regulator/brcm,bcm59054.yaml | 55 ++++++++++++++++++++++
> 2 files changed, 79 insertions(+), 2 deletions(-)
>
> diff --git a/Documentation/devicetree/bindings/mfd/brcm,bcm59056.yaml b/Documentation/devicetree/bindings/mfd/brcm,bcm59056.yaml
> index 3296799eb452fca2a4b03699fcb5aa27005a8e8d..87d663416ed9e7f5ec4aa25c1aa2d9e650c42e2c 100644
> --- a/Documentation/devicetree/bindings/mfd/brcm,bcm59056.yaml
> +++ b/Documentation/devicetree/bindings/mfd/brcm,bcm59056.yaml
> @@ -11,7 +11,9 @@ maintainers:
>
> properties:
> compatible:
> - const: brcm,bcm59056
> + enum:
> + - brcm,bcm59054
> + - brcm,bcm59056
>
> reg:
> maxItems: 1
> @@ -22,7 +24,6 @@ properties:
> regulators:
> type: object
> description: Container node for regulators.
> - $ref: ../regulator/brcm,bcm59056.yaml
Refs should rather stay here, so I don't think keeping these devices in
one binding makes it simpler.
Simpler - drop ref and add properties compatible with enum for your
regulator compatibles.
...
> +$id: http://devicetree.org/schemas/regulator/brcm,bcm59054.yaml#
> +$schema: http://devicetree.org/meta-schemas/core.yaml#
> +
> +title: Broadcom BCM59054 Power Management IC regulators
> +
> +description: |
> + This is a part of device tree bindings for the BCM590XX family of power
> + management ICs.
> +
> + See also Documentation/devicetree/bindings/mfd/brcm,bcm59056.yaml for
> + additional information and example.
> +
> +maintainers:
> + - Artur Weber <aweber.kernel@gmail.com>
> +
> +# The valid regulator node names for BCM59054 are:
> +# rfldo, camldo1, camldo2, simldo1, simldo2, sdldo, sdxldo,
> +# mmcldo1, mmcldo2, audldo, micldo, usbldo, vibldo,
> +# csr, iosr1, iosr2, mmsr, sdsr1, sdsr2, vsr,
> +# gpldo1, gpldo2, gpldo3, tcxldo, lvldo1, lvldo2
> +
> +patternProperties:
> + "^(cam|sim|mmc)ldo[1-2]$":
> + type: object
Missin unevaluatedProperties everywhere. Look how other bindings do it.
> + $ref: /schemas/regulator/regulator.yaml#
> +
> + "^(rf|sd|sdx|aud|mic|usb|vib|tcx)ldo$":
> + type: object
> + $ref: /schemas/regulator/regulator.yaml#
> +
> + "^(c|mm|v)sr$":
> + type: object
> + $ref: /schemas/regulator/regulator.yaml#
> +
> + "^(io|sd)sr[1-2]$":
> + type: object
> + $ref: /schemas/regulator/regulator.yaml#
> +
> + "^gpldo[1-3]$":
> + type: object
> + $ref: /schemas/regulator/regulator.yaml#
> +
> + "^lvldo[1-2]$":
> + type: object
> + $ref: /schemas/regulator/regulator.yaml#
> +
> +properties:
> + "vbus":
No quotes.
Best regards,
Krzysztof
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [PATCH v3 2/7] dt-bindings: mfd: brcm,bcm59056: Add compatible for BCM59054
2025-02-02 13:24 ` Krzysztof Kozlowski
@ 2025-02-05 17:58 ` Artur Weber
0 siblings, 0 replies; 19+ messages in thread
From: Artur Weber @ 2025-02-05 17:58 UTC (permalink / raw)
To: Krzysztof Kozlowski
Cc: Lee Jones, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
Liam Girdwood, Mark Brown, Florian Fainelli, Ray Jui,
Scott Branden, Broadcom internal kernel review list,
Stanislav Jakubek, devicetree, linux-kernel, linux-arm-kernel,
~postmarketos/upstreaming
On 2.02.2025 14:24, Krzysztof Kozlowski wrote:
> On Fri, Jan 31, 2025 at 07:13:50PM +0100, Artur Weber wrote:
>> ...
>> @@ -22,7 +24,6 @@ properties:
>> regulators:
>> type: object
>> description: Container node for regulators.
>> - $ref: ../regulator/brcm,bcm59056.yaml
>
> Refs should rather stay here, so I don't think keeping these devices in
> one binding makes it simpler.
>
> Simpler - drop ref and add properties compatible with enum for your
> regulator compatibles.
>
The only problem with that is that the regulator nodes have no
compatibles. I see two ways out of it: either we add a compatible then
use the compatible enum (might break existing users who don't have the
compatible, unless we make the driver ignore it), or if we just want to
simplify but not add compatibles, list all the refs under an oneOf
condition (like it's done in
Documentation/devicetree/bindings/mfd/qcom,spmi-pmic.yaml[1]).
Personally I'm in favor of keeping this as-is, though, for the benefit
of the DT linter preventing accidental mixing of bindings for different
device types (e.g. BCM59056 MFD node with BCM59054 regulators). There's
at least some precedent for this method[2]. But if making it simple is
what's considered better, I'll go with one of the aforementioned
options.
Best regards
Artur
[1] https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/tree/Documentation/devicetree/bindings/mfd/qcom,spmi-pmic.yaml#n147
[2] https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/tree/Documentation/devicetree/bindings/mfd/samsung,s2mps11.yaml#n69
^ permalink raw reply [flat|nested] 19+ messages in thread
* [PATCH v3 3/7] ARM: dts: Drop DTS for BCM59056 PMIC
2025-01-31 18:13 [PATCH v3 0/7] mfd: bcm590xx: Add support for BCM59054 Artur Weber
2025-01-31 18:13 ` [PATCH v3 1/7] dt-bindings: mfd: brcm,bcm59056: Convert to YAML Artur Weber
2025-01-31 18:13 ` [PATCH v3 2/7] dt-bindings: mfd: brcm,bcm59056: Add compatible for BCM59054 Artur Weber
@ 2025-01-31 18:13 ` Artur Weber
2025-01-31 18:13 ` [PATCH v3 4/7] mfd: bcm590xx: Add compatible for BCM59054 Artur Weber
` (3 subsequent siblings)
6 siblings, 0 replies; 19+ messages in thread
From: Artur Weber @ 2025-01-31 18:13 UTC (permalink / raw)
To: Lee Jones, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
Liam Girdwood, Mark Brown, Florian Fainelli, Ray Jui,
Scott Branden, Broadcom internal kernel review list
Cc: Stanislav Jakubek, devicetree, linux-kernel, linux-arm-kernel,
~postmarketos/upstreaming, Artur Weber
The BCM59056 PMIC has its own separate DTSI, meant to be included
in a DTS file after defining the pmu node on some I2C bus.
This seems rather unintuitive; drop the DTS in favor of adding the
BCM59056 PMIC node directly into the device DTS files.
Signed-off-by: Artur Weber <aweber.kernel@gmail.com>
---
arch/arm/boot/dts/broadcom/bcm28155-ap.dts | 68 +++++++++++-----------
arch/arm/boot/dts/broadcom/bcm59056.dtsi | 91 ------------------------------
2 files changed, 32 insertions(+), 127 deletions(-)
diff --git a/arch/arm/boot/dts/broadcom/bcm28155-ap.dts b/arch/arm/boot/dts/broadcom/bcm28155-ap.dts
index 2f3634545e64978888cd0b47fd5647a5e2eb8e07..cefaa9a3c45c9c90bffc08f739161d8ea21d98dd 100644
--- a/arch/arm/boot/dts/broadcom/bcm28155-ap.dts
+++ b/arch/arm/boot/dts/broadcom/bcm28155-ap.dts
@@ -37,7 +37,39 @@ &pmu_bsc {
status = "okay";
pmu: pmu@8 {
+ compatible = "brcm,bcm59056";
+ interrupts = <GIC_SPI 215 IRQ_TYPE_LEVEL_HIGH>;
reg = <0x08>;
+
+ regulators {
+ camldo1_reg: camldo1 {
+ regulator-min-microvolt = <3300000>;
+ regulator-max-microvolt = <3300000>;
+ regulator-always-on;
+ };
+
+ sdldo_reg: sdldo {
+ regulator-min-microvolt = <3000000>;
+ regulator-max-microvolt = <3000000>;
+ };
+
+ sdxldo_reg: sdxldo {
+ regulator-min-microvolt = <2700000>;
+ regulator-max-microvolt = <3300000>;
+ };
+
+ usbldo_reg: usbldo {
+ regulator-min-microvolt = <3300000>;
+ regulator-max-microvolt = <3300000>;
+ regulator-always-on;
+ };
+
+ iosr1_reg: iosr1 {
+ regulator-min-microvolt = <1800000>;
+ regulator-max-microvolt = <1800000>;
+ regulator-always-on;
+ };
+ };
};
};
@@ -74,39 +106,3 @@ &usbotg {
&usbphy {
status = "okay";
};
-
-#include "bcm59056.dtsi"
-
-&pmu {
- compatible = "brcm,bcm59056";
- interrupts = <GIC_SPI 215 IRQ_TYPE_LEVEL_HIGH>;
- regulators {
- camldo1_reg: camldo1 {
- regulator-min-microvolt = <3300000>;
- regulator-max-microvolt = <3300000>;
- regulator-always-on;
- };
-
- sdldo_reg: sdldo {
- regulator-min-microvolt = <3000000>;
- regulator-max-microvolt = <3000000>;
- };
-
- sdxldo_reg: sdxldo {
- regulator-min-microvolt = <2700000>;
- regulator-max-microvolt = <3300000>;
- };
-
- usbldo_reg: usbldo {
- regulator-min-microvolt = <3300000>;
- regulator-max-microvolt = <3300000>;
- regulator-always-on;
- };
-
- iosr1_reg: iosr1 {
- regulator-min-microvolt = <1800000>;
- regulator-max-microvolt = <1800000>;
- regulator-always-on;
- };
- };
-};
diff --git a/arch/arm/boot/dts/broadcom/bcm59056.dtsi b/arch/arm/boot/dts/broadcom/bcm59056.dtsi
deleted file mode 100644
index a9bb7ad81378d88811c4473763c579d3d2c006a1..0000000000000000000000000000000000000000
--- a/arch/arm/boot/dts/broadcom/bcm59056.dtsi
+++ /dev/null
@@ -1,91 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0-or-later
-/*
-* Copyright 2014 Linaro Limited
-* Author: Matt Porter <mporter@linaro.org>
-*/
-
-&pmu {
- compatible = "brcm,bcm59056";
- regulators {
- rfldo_reg: rfldo {
- };
-
- camldo1_reg: camldo1 {
- };
-
- camldo2_reg: camldo2 {
- };
-
- simldo1_reg: simldo1 {
- };
-
- simldo2_reg: simldo2 {
- };
-
- sdldo_reg: sdldo {
- };
-
- sdxldo_reg: sdxldo {
- };
-
- mmcldo1_reg: mmcldo1 {
- };
-
- mmcldo2_reg: mmcldo2 {
- };
-
- audldo_reg: audldo {
- };
-
- micldo_reg: micldo {
- };
-
- usbldo_reg: usbldo {
- };
-
- vibldo_reg: vibldo {
- };
-
- csr_reg: csr {
- };
-
- iosr1_reg: iosr1 {
- };
-
- iosr2_reg: iosr2 {
- };
-
- msr_reg: msr {
- };
-
- sdsr1_reg: sdsr1 {
- };
-
- sdsr2_reg: sdsr2 {
- };
-
- vsr_reg: vsr {
- };
-
- gpldo1_reg: gpldo1 {
- };
-
- gpldo2_reg: gpldo2 {
- };
-
- gpldo3_reg: gpldo3 {
- };
-
- gpldo4_reg: gpldo4 {
- };
-
- gpldo5_reg: gpldo5 {
- };
-
- gpldo6_reg: gpldo6 {
- };
-
- vbus_reg: vbus {
- };
- };
-};
--
2.48.1
^ permalink raw reply related [flat|nested] 19+ messages in thread* [PATCH v3 4/7] mfd: bcm590xx: Add compatible for BCM59054
2025-01-31 18:13 [PATCH v3 0/7] mfd: bcm590xx: Add support for BCM59054 Artur Weber
` (2 preceding siblings ...)
2025-01-31 18:13 ` [PATCH v3 3/7] ARM: dts: Drop DTS for BCM59056 PMIC Artur Weber
@ 2025-01-31 18:13 ` Artur Weber
2025-02-07 8:48 ` Lee Jones
2025-01-31 18:13 ` [PATCH v3 5/7] regulator: bcm590xx: Store regulator descriptions in table Artur Weber
` (2 subsequent siblings)
6 siblings, 1 reply; 19+ messages in thread
From: Artur Weber @ 2025-01-31 18:13 UTC (permalink / raw)
To: Lee Jones, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
Liam Girdwood, Mark Brown, Florian Fainelli, Ray Jui,
Scott Branden, Broadcom internal kernel review list
Cc: Stanislav Jakubek, devicetree, linux-kernel, linux-arm-kernel,
~postmarketos/upstreaming, Artur Weber
The BCM59056 supported by the bcm590xx driver is similar to the
BCM59054 MFD. Add a compatible for it in the driver, in preparation
for extending support of this chip in the bcm590xx regulator driver.
Signed-off-by: Artur Weber <aweber.kernel@gmail.com>
---
Changes in v3:
- Fix compilation warning about device_type pointer cast type
- Name the device types enum and use it as the type in the MFD struct
---
drivers/mfd/bcm590xx.c | 6 +++++-
include/linux/mfd/bcm590xx.h | 7 +++++++
2 files changed, 12 insertions(+), 1 deletion(-)
diff --git a/drivers/mfd/bcm590xx.c b/drivers/mfd/bcm590xx.c
index 8b56786d85d0182acf91da203b5f943556c08422..23036157480e0116301bfa93932c92f5a80010ea 100644
--- a/drivers/mfd/bcm590xx.c
+++ b/drivers/mfd/bcm590xx.c
@@ -50,6 +50,9 @@ static int bcm590xx_i2c_probe(struct i2c_client *i2c_pri)
bcm590xx->dev = &i2c_pri->dev;
bcm590xx->i2c_pri = i2c_pri;
+ bcm590xx->device_type = \
+ (uintptr_t) of_device_get_match_data(bcm590xx->dev);
+
bcm590xx->regmap_pri = devm_regmap_init_i2c(i2c_pri,
&bcm590xx_regmap_config_pri);
if (IS_ERR(bcm590xx->regmap_pri)) {
@@ -91,7 +94,8 @@ static int bcm590xx_i2c_probe(struct i2c_client *i2c_pri)
}
static const struct of_device_id bcm590xx_of_match[] = {
- { .compatible = "brcm,bcm59056" },
+ { .compatible = "brcm,bcm59054", .data = (void *)BCM59054_TYPE },
+ { .compatible = "brcm,bcm59056", .data = (void *)BCM59056_TYPE },
{ }
};
MODULE_DEVICE_TABLE(of, bcm590xx_of_match);
diff --git a/include/linux/mfd/bcm590xx.h b/include/linux/mfd/bcm590xx.h
index 6b8791da6119b22514447bf1572238b71c8b0e97..b76fb57bf0dd17d51580e93db58ece4a4d6dc5e4 100644
--- a/include/linux/mfd/bcm590xx.h
+++ b/include/linux/mfd/bcm590xx.h
@@ -13,12 +13,19 @@
#include <linux/i2c.h>
#include <linux/regmap.h>
+/* device types */
+enum bcm590xx_device_type {
+ BCM59054_TYPE,
+ BCM59056_TYPE,
+};
+
/* max register address */
#define BCM590XX_MAX_REGISTER_PRI 0xe7
#define BCM590XX_MAX_REGISTER_SEC 0xf0
struct bcm590xx {
struct device *dev;
+ enum bcm590xx_device_type device_type;
struct i2c_client *i2c_pri;
struct i2c_client *i2c_sec;
struct regmap *regmap_pri;
--
2.48.1
^ permalink raw reply related [flat|nested] 19+ messages in thread* Re: [PATCH v3 4/7] mfd: bcm590xx: Add compatible for BCM59054
2025-01-31 18:13 ` [PATCH v3 4/7] mfd: bcm590xx: Add compatible for BCM59054 Artur Weber
@ 2025-02-07 8:48 ` Lee Jones
2025-02-07 13:06 ` Artur Weber
0 siblings, 1 reply; 19+ messages in thread
From: Lee Jones @ 2025-02-07 8:48 UTC (permalink / raw)
To: Artur Weber
Cc: Rob Herring, Krzysztof Kozlowski, Conor Dooley, Liam Girdwood,
Mark Brown, Florian Fainelli, Ray Jui, Scott Branden,
Broadcom internal kernel review list, Stanislav Jakubek,
devicetree, linux-kernel, linux-arm-kernel,
~postmarketos/upstreaming
On Fri, 31 Jan 2025, Artur Weber wrote:
> The BCM59056 supported by the bcm590xx driver is similar to the
> BCM59054 MFD. Add a compatible for it in the driver, in preparation
> for extending support of this chip in the bcm590xx regulator driver.
>
> Signed-off-by: Artur Weber <aweber.kernel@gmail.com>
> ---
> Changes in v3:
> - Fix compilation warning about device_type pointer cast type
> - Name the device types enum and use it as the type in the MFD struct
> ---
> drivers/mfd/bcm590xx.c | 6 +++++-
> include/linux/mfd/bcm590xx.h | 7 +++++++
> 2 files changed, 12 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/mfd/bcm590xx.c b/drivers/mfd/bcm590xx.c
> index 8b56786d85d0182acf91da203b5f943556c08422..23036157480e0116301bfa93932c92f5a80010ea 100644
> --- a/drivers/mfd/bcm590xx.c
> +++ b/drivers/mfd/bcm590xx.c
> @@ -50,6 +50,9 @@ static int bcm590xx_i2c_probe(struct i2c_client *i2c_pri)
> bcm590xx->dev = &i2c_pri->dev;
> bcm590xx->i2c_pri = i2c_pri;
>
> + bcm590xx->device_type = \
> + (uintptr_t) of_device_get_match_data(bcm590xx->dev);
Why are you dividing pointers with each other?
> bcm590xx->regmap_pri = devm_regmap_init_i2c(i2c_pri,
> &bcm590xx_regmap_config_pri);
> if (IS_ERR(bcm590xx->regmap_pri)) {
> @@ -91,7 +94,8 @@ static int bcm590xx_i2c_probe(struct i2c_client *i2c_pri)
> }
>
> static const struct of_device_id bcm590xx_of_match[] = {
> - { .compatible = "brcm,bcm59056" },
> + { .compatible = "brcm,bcm59054", .data = (void *)BCM59054_TYPE },
> + { .compatible = "brcm,bcm59056", .data = (void *)BCM59056_TYPE },
> { }
> };
> MODULE_DEVICE_TABLE(of, bcm590xx_of_match);
> diff --git a/include/linux/mfd/bcm590xx.h b/include/linux/mfd/bcm590xx.h
> index 6b8791da6119b22514447bf1572238b71c8b0e97..b76fb57bf0dd17d51580e93db58ece4a4d6dc5e4 100644
> --- a/include/linux/mfd/bcm590xx.h
> +++ b/include/linux/mfd/bcm590xx.h
> @@ -13,12 +13,19 @@
> #include <linux/i2c.h>
> #include <linux/regmap.h>
>
> +/* device types */
> +enum bcm590xx_device_type {
> + BCM59054_TYPE,
> + BCM59056_TYPE,
> +};
> +
> /* max register address */
> #define BCM590XX_MAX_REGISTER_PRI 0xe7
> #define BCM590XX_MAX_REGISTER_SEC 0xf0
>
> struct bcm590xx {
> struct device *dev;
> + enum bcm590xx_device_type device_type;
> struct i2c_client *i2c_pri;
> struct i2c_client *i2c_sec;
> struct regmap *regmap_pri;
>
> --
> 2.48.1
>
--
Lee Jones [李琼斯]
^ permalink raw reply [flat|nested] 19+ messages in thread* Re: [PATCH v3 4/7] mfd: bcm590xx: Add compatible for BCM59054
2025-02-07 8:48 ` Lee Jones
@ 2025-02-07 13:06 ` Artur Weber
2025-02-10 16:33 ` Lee Jones
0 siblings, 1 reply; 19+ messages in thread
From: Artur Weber @ 2025-02-07 13:06 UTC (permalink / raw)
To: Lee Jones
Cc: Rob Herring, Krzysztof Kozlowski, Conor Dooley, Liam Girdwood,
Mark Brown, Florian Fainelli, Ray Jui, Scott Branden,
Broadcom internal kernel review list, Stanislav Jakubek,
devicetree, linux-kernel, linux-arm-kernel,
~postmarketos/upstreaming
On 7.02.2025 09:48, Lee Jones wrote:
> On Fri, 31 Jan 2025, Artur Weber wrote:
>
>> The BCM59056 supported by the bcm590xx driver is similar to the
>> BCM59054 MFD. Add a compatible for it in the driver, in preparation
>> for extending support of this chip in the bcm590xx regulator driver.
>>
>> Signed-off-by: Artur Weber <aweber.kernel@gmail.com>
>> ---
>> Changes in v3:
>> - Fix compilation warning about device_type pointer cast type
>> - Name the device types enum and use it as the type in the MFD struct
>> ---
>> drivers/mfd/bcm590xx.c | 6 +++++-
>> include/linux/mfd/bcm590xx.h | 7 +++++++
>> 2 files changed, 12 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/mfd/bcm590xx.c b/drivers/mfd/bcm590xx.c
>> index 8b56786d85d0182acf91da203b5f943556c08422..23036157480e0116301bfa93932c92f5a80010ea 100644
>> --- a/drivers/mfd/bcm590xx.c
>> +++ b/drivers/mfd/bcm590xx.c
>> @@ -50,6 +50,9 @@ static int bcm590xx_i2c_probe(struct i2c_client *i2c_pri)
>> bcm590xx->dev = &i2c_pri->dev;
>> bcm590xx->i2c_pri = i2c_pri;
>>
>> + bcm590xx->device_type = \
>> + (uintptr_t) of_device_get_match_data(bcm590xx->dev);
>
> Why are you dividing pointers with each other?
That's not division, it's a line continuation (note the space before
"\") - had to insert it for the line to fit in 80 characters. Though
admittedly, there's probably a better way to do this than to force it
with "\"...
I will clean this up in the next version.
Best regards
Artur
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [PATCH v3 4/7] mfd: bcm590xx: Add compatible for BCM59054
2025-02-07 13:06 ` Artur Weber
@ 2025-02-10 16:33 ` Lee Jones
0 siblings, 0 replies; 19+ messages in thread
From: Lee Jones @ 2025-02-10 16:33 UTC (permalink / raw)
To: Artur Weber
Cc: Rob Herring, Krzysztof Kozlowski, Conor Dooley, Liam Girdwood,
Mark Brown, Florian Fainelli, Ray Jui, Scott Branden,
Broadcom internal kernel review list, Stanislav Jakubek,
devicetree, linux-kernel, linux-arm-kernel,
~postmarketos/upstreaming
On Fri, 07 Feb 2025, Artur Weber wrote:
> On 7.02.2025 09:48, Lee Jones wrote:
> > On Fri, 31 Jan 2025, Artur Weber wrote:
> >
> > > The BCM59056 supported by the bcm590xx driver is similar to the
> > > BCM59054 MFD. Add a compatible for it in the driver, in preparation
> > > for extending support of this chip in the bcm590xx regulator driver.
> > >
> > > Signed-off-by: Artur Weber <aweber.kernel@gmail.com>
> > > ---
> > > Changes in v3:
> > > - Fix compilation warning about device_type pointer cast type
> > > - Name the device types enum and use it as the type in the MFD struct
> > > ---
> > > drivers/mfd/bcm590xx.c | 6 +++++-
> > > include/linux/mfd/bcm590xx.h | 7 +++++++
> > > 2 files changed, 12 insertions(+), 1 deletion(-)
> > >
> > > diff --git a/drivers/mfd/bcm590xx.c b/drivers/mfd/bcm590xx.c
> > > index 8b56786d85d0182acf91da203b5f943556c08422..23036157480e0116301bfa93932c92f5a80010ea 100644
> > > --- a/drivers/mfd/bcm590xx.c
> > > +++ b/drivers/mfd/bcm590xx.c
> > > @@ -50,6 +50,9 @@ static int bcm590xx_i2c_probe(struct i2c_client *i2c_pri)
> > > bcm590xx->dev = &i2c_pri->dev;
> > > bcm590xx->i2c_pri = i2c_pri;
> > > + bcm590xx->device_type = \
> > > + (uintptr_t) of_device_get_match_data(bcm590xx->dev);
> >
> > Why are you dividing pointers with each other?
>
> That's not division, it's a line continuation (note the space before
The space is irrelevant in C.
> "\") - had to insert it for the line to fit in 80 characters. Though
> admittedly, there's probably a better way to do this than to force it
> with "\"...
You do not need to escape the line break in C-functions.
> I will clean this up in the next version.
You can use up to 100-chars these days, so you don't need the break at
all. However, if you insist on keeping to the old 80-char rule, you can
just omit the escape char.
--
Lee Jones [李琼斯]
^ permalink raw reply [flat|nested] 19+ messages in thread
* [PATCH v3 5/7] regulator: bcm590xx: Store regulator descriptions in table
2025-01-31 18:13 [PATCH v3 0/7] mfd: bcm590xx: Add support for BCM59054 Artur Weber
` (3 preceding siblings ...)
2025-01-31 18:13 ` [PATCH v3 4/7] mfd: bcm590xx: Add compatible for BCM59054 Artur Weber
@ 2025-01-31 18:13 ` Artur Weber
2025-01-31 18:13 ` [PATCH v3 6/7] regulator: bcm590xx: Rename BCM59056-specific data as such Artur Weber
2025-01-31 18:13 ` [PATCH v3 7/7] regulator: bcm590xx: Add support for BCM59054 regulators Artur Weber
6 siblings, 0 replies; 19+ messages in thread
From: Artur Weber @ 2025-01-31 18:13 UTC (permalink / raw)
To: Lee Jones, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
Liam Girdwood, Mark Brown, Florian Fainelli, Ray Jui,
Scott Branden, Broadcom internal kernel review list
Cc: Stanislav Jakubek, devicetree, linux-kernel, linux-arm-kernel,
~postmarketos/upstreaming, Artur Weber
Instead of filling in the regulator description programatically,
store the data in a struct. This will make it a bit nicer to
introduce support for other BCM590xx chips besides the BCM59056.
To do this, add a new struct type, bcm590xx_reg_info, to store
all of the necessary information. Drop the old IS_LDO, IS_GPLDO...
macros in favor of the "type" field in this struct. Adapt the
old bcm590xx_reg struct to the new types.
Signed-off-by: Artur Weber <aweber.kernel@gmail.com>
---
Changes in v3:
- Added this commit
---
drivers/regulator/bcm590xx-regulator.c | 472 ++++++++++++++++++++++-----------
1 file changed, 316 insertions(+), 156 deletions(-)
diff --git a/drivers/regulator/bcm590xx-regulator.c b/drivers/regulator/bcm590xx-regulator.c
index 9f0cda46b01506080ae5fa709104a8df4d174a8d..6548653a6fb7207a5aa8e006a005553bfb7b1d69 100644
--- a/drivers/regulator/bcm590xx-regulator.c
+++ b/drivers/regulator/bcm590xx-regulator.c
@@ -20,6 +20,18 @@
/* I2C slave 0 registers */
#define BCM590XX_RFLDOPMCTRL1 0x60
+#define BCM590XX_CAMLDO1PMCTRL1 0x62
+#define BCM590XX_CAMLDO2PMCTRL1 0x64
+#define BCM590XX_SIMLDO1PMCTRL1 0x66
+#define BCM590XX_SIMLDO2PMCTRL1 0x68
+#define BCM590XX_SDLDOPMCTRL1 0x6a
+#define BCM590XX_SDXLDOPMCTRL1 0x6c
+#define BCM590XX_MMCLDO1PMCTRL1 0x6e
+#define BCM590XX_MMCLDO2PMCTRL1 0x70
+#define BCM590XX_AUDLDOPMCTRL1 0x72
+#define BCM590XX_MICLDOPMCTRL1 0x74
+#define BCM590XX_USBLDOPMCTRL1 0x76
+#define BCM590XX_VIBLDOPMCTRL1 0x78
#define BCM590XX_IOSR1PMCTRL1 0x7a
#define BCM590XX_IOSR2PMCTRL1 0x7c
#define BCM590XX_CSRPMCTRL1 0x7e
@@ -28,7 +40,25 @@
#define BCM590XX_MSRPMCTRL1 0x8a
#define BCM590XX_VSRPMCTRL1 0x8e
#define BCM590XX_RFLDOCTRL 0x96
+#define BCM590XX_CAMLDO1CTRL 0x97
+#define BCM590XX_CAMLDO2CTRL 0x98
+#define BCM590XX_SIMLDO1CTRL 0x99
+#define BCM590XX_SIMLDO2CTRL 0x9a
+#define BCM590XX_SDLDOCTRL 0x9b
+#define BCM590XX_SDXLDOCTRL 0x9c
+#define BCM590XX_MMCLDO1CTRL 0x9d
+#define BCM590XX_MMCLDO2CTRL 0x9e
+#define BCM590XX_AUDLDOCTRL 0x9f
+#define BCM590XX_MICLDOCTRL 0xa0
+#define BCM590XX_USBLDOCTRL 0xa1
+#define BCM590XX_VIBLDOCTRL 0xa2
#define BCM590XX_CSRVOUT1 0xc0
+#define BCM590XX_IOSR1VOUT1 0xc3
+#define BCM590XX_IOSR2VOUT1 0xc6
+#define BCM590XX_MSRVOUT1 0xc9
+#define BCM590XX_SDSR1VOUT1 0xcc
+#define BCM590XX_SDSR2VOUT1 0xcf
+#define BCM590XX_VSRVOUT1 0xd2
/* I2C slave 1 registers */
#define BCM590XX_GPLDO5PMCTRL1 0x16
@@ -94,11 +124,6 @@
#define BCM590XX_NUM_REGS 27
-#define BCM590XX_REG_IS_LDO(n) (n < BCM590XX_REG_CSR)
-#define BCM590XX_REG_IS_GPLDO(n) \
- ((n > BCM590XX_REG_VSR) && (n < BCM590XX_REG_VBUS))
-#define BCM590XX_REG_IS_VBUS(n) (n == BCM590XX_REG_VBUS)
-
/* LDO group A: supported voltages in microvolts */
static const unsigned int ldo_a_table[] = {
1200000, 1800000, 2500000, 2700000, 2800000,
@@ -111,10 +136,6 @@ static const unsigned int ldo_c_table[] = {
2900000, 3000000, 3300000,
};
-static const unsigned int ldo_vbus[] = {
- 5000000,
-};
-
/* DCDC group CSR: supported voltages in microvolts */
static const struct linear_range dcdc_csr_ranges[] = {
REGULATOR_LINEAR_RANGE(860000, 2, 50, 10000),
@@ -137,115 +158,30 @@ static const struct linear_range dcdc_sdsr1_ranges[] = {
REGULATOR_LINEAR_RANGE(900000, 52, 63, 0),
};
-struct bcm590xx_info {
- const char *name;
- const char *vin_name;
- u8 n_voltages;
- const unsigned int *volt_table;
- u8 n_linear_ranges;
- const struct linear_range *linear_ranges;
+enum bcm590xx_reg_type {
+ BCM590XX_REG_TYPE_LDO,
+ BCM590XX_REG_TYPE_GPLDO,
+ BCM590XX_REG_TYPE_SR,
+ BCM590XX_REG_TYPE_VBUS
};
-#define BCM590XX_REG_TABLE(_name, _table) \
- { \
- .name = #_name, \
- .n_voltages = ARRAY_SIZE(_table), \
- .volt_table = _table, \
- }
-
-#define BCM590XX_REG_RANGES(_name, _ranges) \
- { \
- .name = #_name, \
- .n_voltages = 64, \
- .n_linear_ranges = ARRAY_SIZE(_ranges), \
- .linear_ranges = _ranges, \
- }
+enum bcm590xx_reg_regmap {
+ BCM590XX_REG_REGMAP_PRI,
+ BCM590XX_REG_REGMAP_SEC,
+};
-static struct bcm590xx_info bcm590xx_regs[] = {
- BCM590XX_REG_TABLE(rfldo, ldo_a_table),
- BCM590XX_REG_TABLE(camldo1, ldo_c_table),
- BCM590XX_REG_TABLE(camldo2, ldo_c_table),
- BCM590XX_REG_TABLE(simldo1, ldo_a_table),
- BCM590XX_REG_TABLE(simldo2, ldo_a_table),
- BCM590XX_REG_TABLE(sdldo, ldo_c_table),
- BCM590XX_REG_TABLE(sdxldo, ldo_a_table),
- BCM590XX_REG_TABLE(mmcldo1, ldo_a_table),
- BCM590XX_REG_TABLE(mmcldo2, ldo_a_table),
- BCM590XX_REG_TABLE(audldo, ldo_a_table),
- BCM590XX_REG_TABLE(micldo, ldo_a_table),
- BCM590XX_REG_TABLE(usbldo, ldo_a_table),
- BCM590XX_REG_TABLE(vibldo, ldo_c_table),
- BCM590XX_REG_RANGES(csr, dcdc_csr_ranges),
- BCM590XX_REG_RANGES(iosr1, dcdc_iosr1_ranges),
- BCM590XX_REG_RANGES(iosr2, dcdc_iosr1_ranges),
- BCM590XX_REG_RANGES(msr, dcdc_iosr1_ranges),
- BCM590XX_REG_RANGES(sdsr1, dcdc_sdsr1_ranges),
- BCM590XX_REG_RANGES(sdsr2, dcdc_iosr1_ranges),
- BCM590XX_REG_RANGES(vsr, dcdc_iosr1_ranges),
- BCM590XX_REG_TABLE(gpldo1, ldo_a_table),
- BCM590XX_REG_TABLE(gpldo2, ldo_a_table),
- BCM590XX_REG_TABLE(gpldo3, ldo_a_table),
- BCM590XX_REG_TABLE(gpldo4, ldo_a_table),
- BCM590XX_REG_TABLE(gpldo5, ldo_a_table),
- BCM590XX_REG_TABLE(gpldo6, ldo_a_table),
- BCM590XX_REG_TABLE(vbus, ldo_vbus),
+struct bcm590xx_reg_info {
+ enum bcm590xx_reg_type type;
+ enum bcm590xx_reg_regmap regmap;
+ const struct regulator_desc desc;
};
struct bcm590xx_reg {
- struct regulator_desc *desc;
struct bcm590xx *mfd;
+ unsigned int n_regulators;
+ const struct bcm590xx_reg_info *regs;
};
-static int bcm590xx_get_vsel_register(int id)
-{
- if (BCM590XX_REG_IS_LDO(id))
- return BCM590XX_RFLDOCTRL + id;
- else if (BCM590XX_REG_IS_GPLDO(id))
- return BCM590XX_GPLDO1CTRL + id;
- else
- return BCM590XX_CSRVOUT1 + (id - BCM590XX_REG_CSR) * 3;
-}
-
-static int bcm590xx_get_enable_register(int id)
-{
- int reg = 0;
-
- if (BCM590XX_REG_IS_LDO(id))
- reg = BCM590XX_RFLDOPMCTRL1 + id * 2;
- else if (BCM590XX_REG_IS_GPLDO(id))
- reg = BCM590XX_GPLDO1PMCTRL1 + id * 2;
- else
- switch (id) {
- case BCM590XX_REG_CSR:
- reg = BCM590XX_CSRPMCTRL1;
- break;
- case BCM590XX_REG_IOSR1:
- reg = BCM590XX_IOSR1PMCTRL1;
- break;
- case BCM590XX_REG_IOSR2:
- reg = BCM590XX_IOSR2PMCTRL1;
- break;
- case BCM590XX_REG_MSR:
- reg = BCM590XX_MSRPMCTRL1;
- break;
- case BCM590XX_REG_SDSR1:
- reg = BCM590XX_SDSR1PMCTRL1;
- break;
- case BCM590XX_REG_SDSR2:
- reg = BCM590XX_SDSR2PMCTRL1;
- break;
- case BCM590XX_REG_VSR:
- reg = BCM590XX_VSRPMCTRL1;
- break;
- case BCM590XX_REG_VBUS:
- reg = BCM590XX_OTG_CTRL;
- break;
- }
-
-
- return reg;
-}
-
static const struct regulator_ops bcm590xx_ops_ldo = {
.is_enabled = regulator_is_enabled_regmap,
.enable = regulator_enable_regmap,
@@ -272,73 +208,297 @@ static const struct regulator_ops bcm590xx_ops_vbus = {
.disable = regulator_disable_regmap,
};
+#define BCM590XX_REG_DESC(_name, _name_lower) \
+ .id = BCM590XX_REG_##_name, \
+ .name = #_name_lower, \
+ .of_match = of_match_ptr(#_name_lower), \
+ .regulators_node = of_match_ptr("regulators"), \
+ .type = REGULATOR_VOLTAGE, \
+ .owner = THIS_MODULE \
+
+#define BCM590XX_LDO_DESC(_name, _name_lower, _table) \
+ BCM590XX_REG_DESC(_name, _name_lower), \
+ .ops = &bcm590xx_ops_ldo, \
+ .n_voltages = ARRAY_SIZE(_table), \
+ .volt_table = _table, \
+ .vsel_reg = BCM590XX_##_name##CTRL, \
+ .vsel_mask = BCM590XX_LDO_VSEL_MASK, \
+ .enable_reg = BCM590XX_##_name##PMCTRL1, \
+ .enable_mask = BCM590XX_REG_ENABLE, \
+ .enable_is_inverted = true
+
+#define BCM590XX_SR_DESC(_name, _name_lower, _ranges) \
+ BCM590XX_REG_DESC(_name, _name_lower), \
+ .ops = &bcm590xx_ops_dcdc, \
+ .n_voltages = 64, \
+ .linear_ranges = _ranges, \
+ .n_linear_ranges = ARRAY_SIZE(_ranges), \
+ .vsel_reg = BCM590XX_##_name##VOUT1, \
+ .vsel_mask = BCM590XX_SR_VSEL_MASK, \
+ .enable_reg = BCM590XX_##_name##PMCTRL1, \
+ .enable_mask = BCM590XX_REG_ENABLE, \
+ .enable_is_inverted = true
+
+static const struct bcm590xx_reg_info bcm590xx_regs[BCM590XX_NUM_REGS] = {
+ {
+ .type = BCM590XX_REG_TYPE_LDO,
+ .regmap = BCM590XX_REG_REGMAP_PRI,
+ .desc = {
+ BCM590XX_LDO_DESC(RFLDO, rfldo, ldo_a_table),
+ },
+ },
+
+ {
+ .type = BCM590XX_REG_TYPE_LDO,
+ .regmap = BCM590XX_REG_REGMAP_PRI,
+ .desc = {
+ BCM590XX_LDO_DESC(CAMLDO1, camldo1, ldo_c_table),
+ },
+ },
+
+ {
+ .type = BCM590XX_REG_TYPE_LDO,
+ .regmap = BCM590XX_REG_REGMAP_PRI,
+ .desc = {
+ BCM590XX_LDO_DESC(CAMLDO2, camldo2, ldo_c_table),
+ },
+ },
+
+ {
+ .type = BCM590XX_REG_TYPE_LDO,
+ .regmap = BCM590XX_REG_REGMAP_PRI,
+ .desc = {
+ BCM590XX_LDO_DESC(SIMLDO1, simldo1, ldo_a_table),
+ },
+ },
+
+ {
+ .type = BCM590XX_REG_TYPE_LDO,
+ .regmap = BCM590XX_REG_REGMAP_PRI,
+ .desc = {
+ BCM590XX_LDO_DESC(SIMLDO2, simldo2, ldo_a_table),
+ },
+ },
+
+ {
+ .type = BCM590XX_REG_TYPE_LDO,
+ .regmap = BCM590XX_REG_REGMAP_PRI,
+ .desc = {
+ BCM590XX_LDO_DESC(SDLDO, sdldo, ldo_c_table),
+ },
+ },
+
+ {
+ .type = BCM590XX_REG_TYPE_LDO,
+ .regmap = BCM590XX_REG_REGMAP_PRI,
+ .desc = {
+ BCM590XX_LDO_DESC(SDXLDO, sdxldo, ldo_a_table),
+ },
+ },
+
+ {
+ .type = BCM590XX_REG_TYPE_LDO,
+ .regmap = BCM590XX_REG_REGMAP_PRI,
+ .desc = {
+ BCM590XX_LDO_DESC(MMCLDO1, mmcldo1, ldo_a_table),
+ },
+ },
+
+ {
+ .type = BCM590XX_REG_TYPE_LDO,
+ .regmap = BCM590XX_REG_REGMAP_PRI,
+ .desc = {
+ BCM590XX_LDO_DESC(MMCLDO2, mmcldo2, ldo_a_table),
+ },
+ },
+
+ {
+ .type = BCM590XX_REG_TYPE_LDO,
+ .regmap = BCM590XX_REG_REGMAP_PRI,
+ .desc = {
+ BCM590XX_LDO_DESC(AUDLDO, audldo, ldo_a_table),
+ },
+ },
+
+ {
+ .type = BCM590XX_REG_TYPE_LDO,
+ .regmap = BCM590XX_REG_REGMAP_PRI,
+ .desc = {
+ BCM590XX_LDO_DESC(MICLDO, micldo, ldo_a_table),
+ },
+ },
+
+ {
+ .type = BCM590XX_REG_TYPE_LDO,
+ .regmap = BCM590XX_REG_REGMAP_PRI,
+ .desc = {
+ BCM590XX_LDO_DESC(USBLDO, usbldo, ldo_a_table),
+ },
+ },
+
+ {
+ .type = BCM590XX_REG_TYPE_LDO,
+ .regmap = BCM590XX_REG_REGMAP_PRI,
+ .desc = {
+ BCM590XX_LDO_DESC(VIBLDO, vibldo, ldo_c_table),
+ },
+ },
+
+ {
+ .type = BCM590XX_REG_TYPE_SR,
+ .regmap = BCM590XX_REG_REGMAP_PRI,
+ .desc = {
+ BCM590XX_SR_DESC(CSR, csr, dcdc_csr_ranges),
+ },
+ },
+
+ {
+ .type = BCM590XX_REG_TYPE_SR,
+ .regmap = BCM590XX_REG_REGMAP_PRI,
+ .desc = {
+ BCM590XX_SR_DESC(IOSR1, iosr1, dcdc_iosr1_ranges),
+ },
+ },
+
+ {
+ .type = BCM590XX_REG_TYPE_SR,
+ .regmap = BCM590XX_REG_REGMAP_PRI,
+ .desc = {
+ BCM590XX_SR_DESC(IOSR2, iosr2, dcdc_iosr1_ranges),
+ },
+ },
+
+ {
+ .type = BCM590XX_REG_TYPE_SR,
+ .regmap = BCM590XX_REG_REGMAP_PRI,
+ .desc = {
+ BCM590XX_SR_DESC(MSR, msr, dcdc_iosr1_ranges),
+ },
+ },
+
+ {
+ .type = BCM590XX_REG_TYPE_SR,
+ .regmap = BCM590XX_REG_REGMAP_PRI,
+ .desc = {
+ BCM590XX_SR_DESC(SDSR1, sdsr1, dcdc_sdsr1_ranges),
+ },
+ },
+
+ {
+ .type = BCM590XX_REG_TYPE_SR,
+ .regmap = BCM590XX_REG_REGMAP_PRI,
+ .desc = {
+ BCM590XX_SR_DESC(SDSR2, sdsr2, dcdc_iosr1_ranges),
+ },
+ },
+
+ {
+ .type = BCM590XX_REG_TYPE_SR,
+ .regmap = BCM590XX_REG_REGMAP_PRI,
+ .desc = {
+ BCM590XX_SR_DESC(VSR, vsr, dcdc_iosr1_ranges),
+ },
+ },
+
+ {
+ .type = BCM590XX_REG_TYPE_GPLDO,
+ .regmap = BCM590XX_REG_REGMAP_SEC,
+ .desc = {
+ BCM590XX_LDO_DESC(GPLDO1, gpldo1, ldo_a_table),
+ },
+ },
+
+ {
+ .type = BCM590XX_REG_TYPE_GPLDO,
+ .regmap = BCM590XX_REG_REGMAP_SEC,
+ .desc = {
+ BCM590XX_LDO_DESC(GPLDO2, gpldo2, ldo_a_table),
+ },
+ },
+
+ {
+ .type = BCM590XX_REG_TYPE_GPLDO,
+ .regmap = BCM590XX_REG_REGMAP_SEC,
+ .desc = {
+ BCM590XX_LDO_DESC(GPLDO3, gpldo3, ldo_a_table),
+ },
+ },
+
+ {
+ .type = BCM590XX_REG_TYPE_GPLDO,
+ .regmap = BCM590XX_REG_REGMAP_SEC,
+ .desc = {
+ BCM590XX_LDO_DESC(GPLDO4, gpldo4, ldo_a_table),
+ },
+ },
+
+ {
+ .type = BCM590XX_REG_TYPE_GPLDO,
+ .regmap = BCM590XX_REG_REGMAP_SEC,
+ .desc = {
+ BCM590XX_LDO_DESC(GPLDO5, gpldo5, ldo_a_table),
+ },
+ },
+
+ {
+ .type = BCM590XX_REG_TYPE_GPLDO,
+ .regmap = BCM590XX_REG_REGMAP_SEC,
+ .desc = {
+ BCM590XX_LDO_DESC(GPLDO6, gpldo6, ldo_a_table),
+ },
+ },
+
+ {
+ .type = BCM590XX_REG_TYPE_VBUS,
+ .regmap = BCM590XX_REG_REGMAP_SEC,
+ .desc = {
+ BCM590XX_REG_DESC(VBUS, vbus),
+ .ops = &bcm590xx_ops_vbus,
+ .n_voltages = 1,
+ .fixed_uV = 5000000,
+ .enable_reg = BCM590XX_OTG_CTRL,
+ .enable_mask = BCM590XX_VBUS_ENABLE,
+ },
+ },
+};
+
static int bcm590xx_probe(struct platform_device *pdev)
{
struct bcm590xx *bcm590xx = dev_get_drvdata(pdev->dev.parent);
struct bcm590xx_reg *pmu;
+ const struct bcm590xx_reg_info *info;
struct regulator_config config = { };
- struct bcm590xx_info *info;
struct regulator_dev *rdev;
- int i;
+ unsigned int i;
pmu = devm_kzalloc(&pdev->dev, sizeof(*pmu), GFP_KERNEL);
if (!pmu)
return -ENOMEM;
pmu->mfd = bcm590xx;
+ pmu->n_regulators = BCM590XX_NUM_REGS;
+ pmu->regs = bcm590xx_regs;
platform_set_drvdata(pdev, pmu);
- pmu->desc = devm_kcalloc(&pdev->dev,
- BCM590XX_NUM_REGS,
- sizeof(struct regulator_desc),
- GFP_KERNEL);
- if (!pmu->desc)
- return -ENOMEM;
-
- info = bcm590xx_regs;
-
- for (i = 0; i < BCM590XX_NUM_REGS; i++, info++) {
- /* Register the regulators */
- pmu->desc[i].name = info->name;
- pmu->desc[i].of_match = of_match_ptr(info->name);
- pmu->desc[i].regulators_node = of_match_ptr("regulators");
- pmu->desc[i].supply_name = info->vin_name;
- pmu->desc[i].id = i;
- pmu->desc[i].volt_table = info->volt_table;
- pmu->desc[i].n_voltages = info->n_voltages;
- pmu->desc[i].linear_ranges = info->linear_ranges;
- pmu->desc[i].n_linear_ranges = info->n_linear_ranges;
-
- if ((BCM590XX_REG_IS_LDO(i)) || (BCM590XX_REG_IS_GPLDO(i))) {
- pmu->desc[i].ops = &bcm590xx_ops_ldo;
- pmu->desc[i].vsel_mask = BCM590XX_LDO_VSEL_MASK;
- } else if (BCM590XX_REG_IS_VBUS(i))
- pmu->desc[i].ops = &bcm590xx_ops_vbus;
- else {
- pmu->desc[i].ops = &bcm590xx_ops_dcdc;
- pmu->desc[i].vsel_mask = BCM590XX_SR_VSEL_MASK;
- }
-
- if (BCM590XX_REG_IS_VBUS(i))
- pmu->desc[i].enable_mask = BCM590XX_VBUS_ENABLE;
- else {
- pmu->desc[i].vsel_reg = bcm590xx_get_vsel_register(i);
- pmu->desc[i].enable_is_inverted = true;
- pmu->desc[i].enable_mask = BCM590XX_REG_ENABLE;
- }
- pmu->desc[i].enable_reg = bcm590xx_get_enable_register(i);
- pmu->desc[i].type = REGULATOR_VOLTAGE;
- pmu->desc[i].owner = THIS_MODULE;
+ /* Register the regulators */
+ for (i = 0; i < pmu->n_regulators; i++) {
+ info = &pmu->regs[i];
config.dev = bcm590xx->dev;
config.driver_data = pmu;
- if (BCM590XX_REG_IS_GPLDO(i) || BCM590XX_REG_IS_VBUS(i))
- config.regmap = bcm590xx->regmap_sec;
- else
+ if (info->regmap == BCM590XX_REG_REGMAP_PRI) {
config.regmap = bcm590xx->regmap_pri;
+ } else if (info->regmap == BCM590XX_REG_REGMAP_SEC) {
+ config.regmap = bcm590xx->regmap_sec;
+ } else {
+ dev_err(bcm590xx->dev,
+ "invalid regmap for %s regulator\n",
+ pdev->name);
+ return PTR_ERR(rdev);
+ }
- rdev = devm_regulator_register(&pdev->dev, &pmu->desc[i],
+ rdev = devm_regulator_register(&pdev->dev, &info->desc,
&config);
if (IS_ERR(rdev)) {
dev_err(bcm590xx->dev,
--
2.48.1
^ permalink raw reply related [flat|nested] 19+ messages in thread* [PATCH v3 6/7] regulator: bcm590xx: Rename BCM59056-specific data as such
2025-01-31 18:13 [PATCH v3 0/7] mfd: bcm590xx: Add support for BCM59054 Artur Weber
` (4 preceding siblings ...)
2025-01-31 18:13 ` [PATCH v3 5/7] regulator: bcm590xx: Store regulator descriptions in table Artur Weber
@ 2025-01-31 18:13 ` Artur Weber
2025-01-31 18:13 ` [PATCH v3 7/7] regulator: bcm590xx: Add support for BCM59054 regulators Artur Weber
6 siblings, 0 replies; 19+ messages in thread
From: Artur Weber @ 2025-01-31 18:13 UTC (permalink / raw)
To: Lee Jones, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
Liam Girdwood, Mark Brown, Florian Fainelli, Ray Jui,
Scott Branden, Broadcom internal kernel review list
Cc: Stanislav Jakubek, devicetree, linux-kernel, linux-arm-kernel,
~postmarketos/upstreaming, Artur Weber
Previously, the driver used the BCM590XX prefix for register data
specific to the BCM59056. As we will be introducing other regulators
to this driver as well, make the BCM59056-specific values use the
BCM59056 prefix.
Signed-off-by: Artur Weber <aweber.kernel@gmail.com>
---
Changes in v3:
- Added this commit
---
drivers/regulator/bcm590xx-regulator.c | 369 +++++++++++++++++----------------
1 file changed, 190 insertions(+), 179 deletions(-)
diff --git a/drivers/regulator/bcm590xx-regulator.c b/drivers/regulator/bcm590xx-regulator.c
index 6548653a6fb7207a5aa8e006a005553bfb7b1d69..1cc46b32572beae24890ede9edbf0fb460bf31cd 100644
--- a/drivers/regulator/bcm590xx-regulator.c
+++ b/drivers/regulator/bcm590xx-regulator.c
@@ -18,146 +18,13 @@
#include <linux/regulator/of_regulator.h>
#include <linux/slab.h>
-/* I2C slave 0 registers */
-#define BCM590XX_RFLDOPMCTRL1 0x60
-#define BCM590XX_CAMLDO1PMCTRL1 0x62
-#define BCM590XX_CAMLDO2PMCTRL1 0x64
-#define BCM590XX_SIMLDO1PMCTRL1 0x66
-#define BCM590XX_SIMLDO2PMCTRL1 0x68
-#define BCM590XX_SDLDOPMCTRL1 0x6a
-#define BCM590XX_SDXLDOPMCTRL1 0x6c
-#define BCM590XX_MMCLDO1PMCTRL1 0x6e
-#define BCM590XX_MMCLDO2PMCTRL1 0x70
-#define BCM590XX_AUDLDOPMCTRL1 0x72
-#define BCM590XX_MICLDOPMCTRL1 0x74
-#define BCM590XX_USBLDOPMCTRL1 0x76
-#define BCM590XX_VIBLDOPMCTRL1 0x78
-#define BCM590XX_IOSR1PMCTRL1 0x7a
-#define BCM590XX_IOSR2PMCTRL1 0x7c
-#define BCM590XX_CSRPMCTRL1 0x7e
-#define BCM590XX_SDSR1PMCTRL1 0x82
-#define BCM590XX_SDSR2PMCTRL1 0x86
-#define BCM590XX_MSRPMCTRL1 0x8a
-#define BCM590XX_VSRPMCTRL1 0x8e
-#define BCM590XX_RFLDOCTRL 0x96
-#define BCM590XX_CAMLDO1CTRL 0x97
-#define BCM590XX_CAMLDO2CTRL 0x98
-#define BCM590XX_SIMLDO1CTRL 0x99
-#define BCM590XX_SIMLDO2CTRL 0x9a
-#define BCM590XX_SDLDOCTRL 0x9b
-#define BCM590XX_SDXLDOCTRL 0x9c
-#define BCM590XX_MMCLDO1CTRL 0x9d
-#define BCM590XX_MMCLDO2CTRL 0x9e
-#define BCM590XX_AUDLDOCTRL 0x9f
-#define BCM590XX_MICLDOCTRL 0xa0
-#define BCM590XX_USBLDOCTRL 0xa1
-#define BCM590XX_VIBLDOCTRL 0xa2
-#define BCM590XX_CSRVOUT1 0xc0
-#define BCM590XX_IOSR1VOUT1 0xc3
-#define BCM590XX_IOSR2VOUT1 0xc6
-#define BCM590XX_MSRVOUT1 0xc9
-#define BCM590XX_SDSR1VOUT1 0xcc
-#define BCM590XX_SDSR2VOUT1 0xcf
-#define BCM590XX_VSRVOUT1 0xd2
-
-/* I2C slave 1 registers */
-#define BCM590XX_GPLDO5PMCTRL1 0x16
-#define BCM590XX_GPLDO6PMCTRL1 0x18
-#define BCM590XX_GPLDO1CTRL 0x1a
-#define BCM590XX_GPLDO2CTRL 0x1b
-#define BCM590XX_GPLDO3CTRL 0x1c
-#define BCM590XX_GPLDO4CTRL 0x1d
-#define BCM590XX_GPLDO5CTRL 0x1e
-#define BCM590XX_GPLDO6CTRL 0x1f
-#define BCM590XX_OTG_CTRL 0x40
-#define BCM590XX_GPLDO1PMCTRL1 0x57
-#define BCM590XX_GPLDO2PMCTRL1 0x59
-#define BCM590XX_GPLDO3PMCTRL1 0x5b
-#define BCM590XX_GPLDO4PMCTRL1 0x5d
+#define BCM590XX_MAX_NUM_REGS 27
#define BCM590XX_REG_ENABLE BIT(7)
#define BCM590XX_VBUS_ENABLE BIT(2)
#define BCM590XX_LDO_VSEL_MASK GENMASK(5, 3)
#define BCM590XX_SR_VSEL_MASK GENMASK(5, 0)
-/*
- * RFLDO to VSR regulators are
- * accessed via I2C slave 0
- */
-
-/* LDO regulator IDs */
-#define BCM590XX_REG_RFLDO 0
-#define BCM590XX_REG_CAMLDO1 1
-#define BCM590XX_REG_CAMLDO2 2
-#define BCM590XX_REG_SIMLDO1 3
-#define BCM590XX_REG_SIMLDO2 4
-#define BCM590XX_REG_SDLDO 5
-#define BCM590XX_REG_SDXLDO 6
-#define BCM590XX_REG_MMCLDO1 7
-#define BCM590XX_REG_MMCLDO2 8
-#define BCM590XX_REG_AUDLDO 9
-#define BCM590XX_REG_MICLDO 10
-#define BCM590XX_REG_USBLDO 11
-#define BCM590XX_REG_VIBLDO 12
-
-/* DCDC regulator IDs */
-#define BCM590XX_REG_CSR 13
-#define BCM590XX_REG_IOSR1 14
-#define BCM590XX_REG_IOSR2 15
-#define BCM590XX_REG_MSR 16
-#define BCM590XX_REG_SDSR1 17
-#define BCM590XX_REG_SDSR2 18
-#define BCM590XX_REG_VSR 19
-
-/*
- * GPLDO1 to VBUS regulators are
- * accessed via I2C slave 1
- */
-
-#define BCM590XX_REG_GPLDO1 20
-#define BCM590XX_REG_GPLDO2 21
-#define BCM590XX_REG_GPLDO3 22
-#define BCM590XX_REG_GPLDO4 23
-#define BCM590XX_REG_GPLDO5 24
-#define BCM590XX_REG_GPLDO6 25
-#define BCM590XX_REG_VBUS 26
-
-#define BCM590XX_NUM_REGS 27
-
-/* LDO group A: supported voltages in microvolts */
-static const unsigned int ldo_a_table[] = {
- 1200000, 1800000, 2500000, 2700000, 2800000,
- 2900000, 3000000, 3300000,
-};
-
-/* LDO group C: supported voltages in microvolts */
-static const unsigned int ldo_c_table[] = {
- 3100000, 1800000, 2500000, 2700000, 2800000,
- 2900000, 3000000, 3300000,
-};
-
-/* DCDC group CSR: supported voltages in microvolts */
-static const struct linear_range dcdc_csr_ranges[] = {
- REGULATOR_LINEAR_RANGE(860000, 2, 50, 10000),
- REGULATOR_LINEAR_RANGE(1360000, 51, 55, 20000),
- REGULATOR_LINEAR_RANGE(900000, 56, 63, 0),
-};
-
-/* DCDC group IOSR1: supported voltages in microvolts */
-static const struct linear_range dcdc_iosr1_ranges[] = {
- REGULATOR_LINEAR_RANGE(860000, 2, 51, 10000),
- REGULATOR_LINEAR_RANGE(1500000, 52, 52, 0),
- REGULATOR_LINEAR_RANGE(1800000, 53, 53, 0),
- REGULATOR_LINEAR_RANGE(900000, 54, 63, 0),
-};
-
-/* DCDC group SDSR1: supported voltages in microvolts */
-static const struct linear_range dcdc_sdsr1_ranges[] = {
- REGULATOR_LINEAR_RANGE(860000, 2, 50, 10000),
- REGULATOR_LINEAR_RANGE(1340000, 51, 51, 0),
- REGULATOR_LINEAR_RANGE(900000, 52, 63, 0),
-};
-
enum bcm590xx_reg_type {
BCM590XX_REG_TYPE_LDO,
BCM590XX_REG_TYPE_GPLDO,
@@ -208,43 +75,187 @@ static const struct regulator_ops bcm590xx_ops_vbus = {
.disable = regulator_disable_regmap,
};
-#define BCM590XX_REG_DESC(_name, _name_lower) \
- .id = BCM590XX_REG_##_name, \
+#define BCM590XX_REG_DESC(_model, _name, _name_lower) \
+ .id = _model##_REG_##_name, \
.name = #_name_lower, \
.of_match = of_match_ptr(#_name_lower), \
.regulators_node = of_match_ptr("regulators"), \
.type = REGULATOR_VOLTAGE, \
.owner = THIS_MODULE \
-#define BCM590XX_LDO_DESC(_name, _name_lower, _table) \
- BCM590XX_REG_DESC(_name, _name_lower), \
+#define BCM590XX_LDO_DESC(_model, _model_lower, _name, _name_lower, _table) \
+ BCM590XX_REG_DESC(_model, _name, _name_lower), \
.ops = &bcm590xx_ops_ldo, \
- .n_voltages = ARRAY_SIZE(_table), \
- .volt_table = _table, \
- .vsel_reg = BCM590XX_##_name##CTRL, \
+ .n_voltages = ARRAY_SIZE(_model_lower##_##_table), \
+ .volt_table = _model_lower##_##_table, \
+ .vsel_reg = _model##_##_name##CTRL, \
.vsel_mask = BCM590XX_LDO_VSEL_MASK, \
- .enable_reg = BCM590XX_##_name##PMCTRL1, \
+ .enable_reg = _model##_##_name##PMCTRL1, \
.enable_mask = BCM590XX_REG_ENABLE, \
.enable_is_inverted = true
-#define BCM590XX_SR_DESC(_name, _name_lower, _ranges) \
- BCM590XX_REG_DESC(_name, _name_lower), \
+#define BCM590XX_SR_DESC(_model, _model_lower, _name, _name_lower, _ranges) \
+ BCM590XX_REG_DESC(_model, _name, _name_lower), \
.ops = &bcm590xx_ops_dcdc, \
.n_voltages = 64, \
- .linear_ranges = _ranges, \
- .n_linear_ranges = ARRAY_SIZE(_ranges), \
- .vsel_reg = BCM590XX_##_name##VOUT1, \
+ .linear_ranges = _model_lower##_##_ranges, \
+ .n_linear_ranges = ARRAY_SIZE(_model_lower##_##_ranges), \
+ .vsel_reg = _model##_##_name##VOUT1, \
.vsel_mask = BCM590XX_SR_VSEL_MASK, \
- .enable_reg = BCM590XX_##_name##PMCTRL1, \
+ .enable_reg = _model##_##_name##PMCTRL1, \
.enable_mask = BCM590XX_REG_ENABLE, \
.enable_is_inverted = true
-static const struct bcm590xx_reg_info bcm590xx_regs[BCM590XX_NUM_REGS] = {
+#define BCM59056_REG_DESC(_name, _name_lower) \
+ BCM590XX_REG_DESC(BCM59056, _name, _name_lower)
+#define BCM59056_LDO_DESC(_name, _name_lower, _table) \
+ BCM590XX_LDO_DESC(BCM59056, bcm59056, _name, _name_lower, _table)
+#define BCM59056_SR_DESC(_name, _name_lower, _ranges) \
+ BCM590XX_SR_DESC(BCM59056, bcm59056, _name, _name_lower, _ranges)
+
+/* BCM59056 data */
+
+/* I2C slave 0 registers */
+#define BCM59056_RFLDOPMCTRL1 0x60
+#define BCM59056_CAMLDO1PMCTRL1 0x62
+#define BCM59056_CAMLDO2PMCTRL1 0x64
+#define BCM59056_SIMLDO1PMCTRL1 0x66
+#define BCM59056_SIMLDO2PMCTRL1 0x68
+#define BCM59056_SDLDOPMCTRL1 0x6a
+#define BCM59056_SDXLDOPMCTRL1 0x6c
+#define BCM59056_MMCLDO1PMCTRL1 0x6e
+#define BCM59056_MMCLDO2PMCTRL1 0x70
+#define BCM59056_AUDLDOPMCTRL1 0x72
+#define BCM59056_MICLDOPMCTRL1 0x74
+#define BCM59056_USBLDOPMCTRL1 0x76
+#define BCM59056_VIBLDOPMCTRL1 0x78
+#define BCM59056_IOSR1PMCTRL1 0x7a
+#define BCM59056_IOSR2PMCTRL1 0x7c
+#define BCM59056_CSRPMCTRL1 0x7e
+#define BCM59056_SDSR1PMCTRL1 0x82
+#define BCM59056_SDSR2PMCTRL1 0x86
+#define BCM59056_MSRPMCTRL1 0x8a
+#define BCM59056_VSRPMCTRL1 0x8e
+#define BCM59056_RFLDOCTRL 0x96
+#define BCM59056_CAMLDO1CTRL 0x97
+#define BCM59056_CAMLDO2CTRL 0x98
+#define BCM59056_SIMLDO1CTRL 0x99
+#define BCM59056_SIMLDO2CTRL 0x9a
+#define BCM59056_SDLDOCTRL 0x9b
+#define BCM59056_SDXLDOCTRL 0x9c
+#define BCM59056_MMCLDO1CTRL 0x9d
+#define BCM59056_MMCLDO2CTRL 0x9e
+#define BCM59056_AUDLDOCTRL 0x9f
+#define BCM59056_MICLDOCTRL 0xa0
+#define BCM59056_USBLDOCTRL 0xa1
+#define BCM59056_VIBLDOCTRL 0xa2
+#define BCM59056_CSRVOUT1 0xc0
+#define BCM59056_IOSR1VOUT1 0xc3
+#define BCM59056_IOSR2VOUT1 0xc6
+#define BCM59056_MSRVOUT1 0xc9
+#define BCM59056_SDSR1VOUT1 0xcc
+#define BCM59056_SDSR2VOUT1 0xcf
+#define BCM59056_VSRVOUT1 0xd2
+
+/* I2C slave 1 registers */
+#define BCM59056_GPLDO5PMCTRL1 0x16
+#define BCM59056_GPLDO6PMCTRL1 0x18
+#define BCM59056_GPLDO1CTRL 0x1a
+#define BCM59056_GPLDO2CTRL 0x1b
+#define BCM59056_GPLDO3CTRL 0x1c
+#define BCM59056_GPLDO4CTRL 0x1d
+#define BCM59056_GPLDO5CTRL 0x1e
+#define BCM59056_GPLDO6CTRL 0x1f
+#define BCM59056_OTG_CTRL 0x40
+#define BCM59056_GPLDO1PMCTRL1 0x57
+#define BCM59056_GPLDO2PMCTRL1 0x59
+#define BCM59056_GPLDO3PMCTRL1 0x5b
+#define BCM59056_GPLDO4PMCTRL1 0x5d
+
+/*
+ * RFLDO to VSR regulators are
+ * accessed via I2C slave 0
+ */
+
+/* LDO regulator IDs */
+#define BCM59056_REG_RFLDO 0
+#define BCM59056_REG_CAMLDO1 1
+#define BCM59056_REG_CAMLDO2 2
+#define BCM59056_REG_SIMLDO1 3
+#define BCM59056_REG_SIMLDO2 4
+#define BCM59056_REG_SDLDO 5
+#define BCM59056_REG_SDXLDO 6
+#define BCM59056_REG_MMCLDO1 7
+#define BCM59056_REG_MMCLDO2 8
+#define BCM59056_REG_AUDLDO 9
+#define BCM59056_REG_MICLDO 10
+#define BCM59056_REG_USBLDO 11
+#define BCM59056_REG_VIBLDO 12
+
+/* DCDC regulator IDs */
+#define BCM59056_REG_CSR 13
+#define BCM59056_REG_IOSR1 14
+#define BCM59056_REG_IOSR2 15
+#define BCM59056_REG_MSR 16
+#define BCM59056_REG_SDSR1 17
+#define BCM59056_REG_SDSR2 18
+#define BCM59056_REG_VSR 19
+
+/*
+ * GPLDO1 to VBUS regulators are
+ * accessed via I2C slave 1
+ */
+
+#define BCM59056_REG_GPLDO1 20
+#define BCM59056_REG_GPLDO2 21
+#define BCM59056_REG_GPLDO3 22
+#define BCM59056_REG_GPLDO4 23
+#define BCM59056_REG_GPLDO5 24
+#define BCM59056_REG_GPLDO6 25
+#define BCM59056_REG_VBUS 26
+
+#define BCM59056_NUM_REGS 27
+
+/* LDO group A: supported voltages in microvolts */
+static const unsigned int bcm59056_ldo_a_table[] = {
+ 1200000, 1800000, 2500000, 2700000, 2800000,
+ 2900000, 3000000, 3300000,
+};
+
+/* LDO group C: supported voltages in microvolts */
+static const unsigned int bcm59056_ldo_c_table[] = {
+ 3100000, 1800000, 2500000, 2700000, 2800000,
+ 2900000, 3000000, 3300000,
+};
+
+/* DCDC group CSR: supported voltages in microvolts */
+static const struct linear_range bcm59056_dcdc_csr_ranges[] = {
+ REGULATOR_LINEAR_RANGE(860000, 2, 50, 10000),
+ REGULATOR_LINEAR_RANGE(1360000, 51, 55, 20000),
+ REGULATOR_LINEAR_RANGE(900000, 56, 63, 0),
+};
+
+/* DCDC group IOSR1: supported voltages in microvolts */
+static const struct linear_range bcm59056_dcdc_iosr1_ranges[] = {
+ REGULATOR_LINEAR_RANGE(860000, 2, 51, 10000),
+ REGULATOR_LINEAR_RANGE(1500000, 52, 52, 0),
+ REGULATOR_LINEAR_RANGE(1800000, 53, 53, 0),
+ REGULATOR_LINEAR_RANGE(900000, 54, 63, 0),
+};
+
+/* DCDC group SDSR1: supported voltages in microvolts */
+static const struct linear_range bcm59056_dcdc_sdsr1_ranges[] = {
+ REGULATOR_LINEAR_RANGE(860000, 2, 50, 10000),
+ REGULATOR_LINEAR_RANGE(1340000, 51, 51, 0),
+ REGULATOR_LINEAR_RANGE(900000, 52, 63, 0),
+};
+
+static const struct bcm590xx_reg_info bcm59056_regs[BCM59056_NUM_REGS] = {
{
.type = BCM590XX_REG_TYPE_LDO,
.regmap = BCM590XX_REG_REGMAP_PRI,
.desc = {
- BCM590XX_LDO_DESC(RFLDO, rfldo, ldo_a_table),
+ BCM59056_LDO_DESC(RFLDO, rfldo, ldo_a_table),
},
},
@@ -252,7 +263,7 @@ static const struct bcm590xx_reg_info bcm590xx_regs[BCM590XX_NUM_REGS] = {
.type = BCM590XX_REG_TYPE_LDO,
.regmap = BCM590XX_REG_REGMAP_PRI,
.desc = {
- BCM590XX_LDO_DESC(CAMLDO1, camldo1, ldo_c_table),
+ BCM59056_LDO_DESC(CAMLDO1, camldo1, ldo_c_table),
},
},
@@ -260,7 +271,7 @@ static const struct bcm590xx_reg_info bcm590xx_regs[BCM590XX_NUM_REGS] = {
.type = BCM590XX_REG_TYPE_LDO,
.regmap = BCM590XX_REG_REGMAP_PRI,
.desc = {
- BCM590XX_LDO_DESC(CAMLDO2, camldo2, ldo_c_table),
+ BCM59056_LDO_DESC(CAMLDO2, camldo2, ldo_c_table),
},
},
@@ -268,7 +279,7 @@ static const struct bcm590xx_reg_info bcm590xx_regs[BCM590XX_NUM_REGS] = {
.type = BCM590XX_REG_TYPE_LDO,
.regmap = BCM590XX_REG_REGMAP_PRI,
.desc = {
- BCM590XX_LDO_DESC(SIMLDO1, simldo1, ldo_a_table),
+ BCM59056_LDO_DESC(SIMLDO1, simldo1, ldo_a_table),
},
},
@@ -276,7 +287,7 @@ static const struct bcm590xx_reg_info bcm590xx_regs[BCM590XX_NUM_REGS] = {
.type = BCM590XX_REG_TYPE_LDO,
.regmap = BCM590XX_REG_REGMAP_PRI,
.desc = {
- BCM590XX_LDO_DESC(SIMLDO2, simldo2, ldo_a_table),
+ BCM59056_LDO_DESC(SIMLDO2, simldo2, ldo_a_table),
},
},
@@ -284,7 +295,7 @@ static const struct bcm590xx_reg_info bcm590xx_regs[BCM590XX_NUM_REGS] = {
.type = BCM590XX_REG_TYPE_LDO,
.regmap = BCM590XX_REG_REGMAP_PRI,
.desc = {
- BCM590XX_LDO_DESC(SDLDO, sdldo, ldo_c_table),
+ BCM59056_LDO_DESC(SDLDO, sdldo, ldo_c_table),
},
},
@@ -292,7 +303,7 @@ static const struct bcm590xx_reg_info bcm590xx_regs[BCM590XX_NUM_REGS] = {
.type = BCM590XX_REG_TYPE_LDO,
.regmap = BCM590XX_REG_REGMAP_PRI,
.desc = {
- BCM590XX_LDO_DESC(SDXLDO, sdxldo, ldo_a_table),
+ BCM59056_LDO_DESC(SDXLDO, sdxldo, ldo_a_table),
},
},
@@ -300,7 +311,7 @@ static const struct bcm590xx_reg_info bcm590xx_regs[BCM590XX_NUM_REGS] = {
.type = BCM590XX_REG_TYPE_LDO,
.regmap = BCM590XX_REG_REGMAP_PRI,
.desc = {
- BCM590XX_LDO_DESC(MMCLDO1, mmcldo1, ldo_a_table),
+ BCM59056_LDO_DESC(MMCLDO1, mmcldo1, ldo_a_table),
},
},
@@ -308,7 +319,7 @@ static const struct bcm590xx_reg_info bcm590xx_regs[BCM590XX_NUM_REGS] = {
.type = BCM590XX_REG_TYPE_LDO,
.regmap = BCM590XX_REG_REGMAP_PRI,
.desc = {
- BCM590XX_LDO_DESC(MMCLDO2, mmcldo2, ldo_a_table),
+ BCM59056_LDO_DESC(MMCLDO2, mmcldo2, ldo_a_table),
},
},
@@ -316,7 +327,7 @@ static const struct bcm590xx_reg_info bcm590xx_regs[BCM590XX_NUM_REGS] = {
.type = BCM590XX_REG_TYPE_LDO,
.regmap = BCM590XX_REG_REGMAP_PRI,
.desc = {
- BCM590XX_LDO_DESC(AUDLDO, audldo, ldo_a_table),
+ BCM59056_LDO_DESC(AUDLDO, audldo, ldo_a_table),
},
},
@@ -324,7 +335,7 @@ static const struct bcm590xx_reg_info bcm590xx_regs[BCM590XX_NUM_REGS] = {
.type = BCM590XX_REG_TYPE_LDO,
.regmap = BCM590XX_REG_REGMAP_PRI,
.desc = {
- BCM590XX_LDO_DESC(MICLDO, micldo, ldo_a_table),
+ BCM59056_LDO_DESC(MICLDO, micldo, ldo_a_table),
},
},
@@ -332,7 +343,7 @@ static const struct bcm590xx_reg_info bcm590xx_regs[BCM590XX_NUM_REGS] = {
.type = BCM590XX_REG_TYPE_LDO,
.regmap = BCM590XX_REG_REGMAP_PRI,
.desc = {
- BCM590XX_LDO_DESC(USBLDO, usbldo, ldo_a_table),
+ BCM59056_LDO_DESC(USBLDO, usbldo, ldo_a_table),
},
},
@@ -340,7 +351,7 @@ static const struct bcm590xx_reg_info bcm590xx_regs[BCM590XX_NUM_REGS] = {
.type = BCM590XX_REG_TYPE_LDO,
.regmap = BCM590XX_REG_REGMAP_PRI,
.desc = {
- BCM590XX_LDO_DESC(VIBLDO, vibldo, ldo_c_table),
+ BCM59056_LDO_DESC(VIBLDO, vibldo, ldo_c_table),
},
},
@@ -348,7 +359,7 @@ static const struct bcm590xx_reg_info bcm590xx_regs[BCM590XX_NUM_REGS] = {
.type = BCM590XX_REG_TYPE_SR,
.regmap = BCM590XX_REG_REGMAP_PRI,
.desc = {
- BCM590XX_SR_DESC(CSR, csr, dcdc_csr_ranges),
+ BCM59056_SR_DESC(CSR, csr, dcdc_csr_ranges),
},
},
@@ -356,7 +367,7 @@ static const struct bcm590xx_reg_info bcm590xx_regs[BCM590XX_NUM_REGS] = {
.type = BCM590XX_REG_TYPE_SR,
.regmap = BCM590XX_REG_REGMAP_PRI,
.desc = {
- BCM590XX_SR_DESC(IOSR1, iosr1, dcdc_iosr1_ranges),
+ BCM59056_SR_DESC(IOSR1, iosr1, dcdc_iosr1_ranges),
},
},
@@ -364,7 +375,7 @@ static const struct bcm590xx_reg_info bcm590xx_regs[BCM590XX_NUM_REGS] = {
.type = BCM590XX_REG_TYPE_SR,
.regmap = BCM590XX_REG_REGMAP_PRI,
.desc = {
- BCM590XX_SR_DESC(IOSR2, iosr2, dcdc_iosr1_ranges),
+ BCM59056_SR_DESC(IOSR2, iosr2, dcdc_iosr1_ranges),
},
},
@@ -372,7 +383,7 @@ static const struct bcm590xx_reg_info bcm590xx_regs[BCM590XX_NUM_REGS] = {
.type = BCM590XX_REG_TYPE_SR,
.regmap = BCM590XX_REG_REGMAP_PRI,
.desc = {
- BCM590XX_SR_DESC(MSR, msr, dcdc_iosr1_ranges),
+ BCM59056_SR_DESC(MSR, msr, dcdc_iosr1_ranges),
},
},
@@ -380,7 +391,7 @@ static const struct bcm590xx_reg_info bcm590xx_regs[BCM590XX_NUM_REGS] = {
.type = BCM590XX_REG_TYPE_SR,
.regmap = BCM590XX_REG_REGMAP_PRI,
.desc = {
- BCM590XX_SR_DESC(SDSR1, sdsr1, dcdc_sdsr1_ranges),
+ BCM59056_SR_DESC(SDSR1, sdsr1, dcdc_sdsr1_ranges),
},
},
@@ -388,7 +399,7 @@ static const struct bcm590xx_reg_info bcm590xx_regs[BCM590XX_NUM_REGS] = {
.type = BCM590XX_REG_TYPE_SR,
.regmap = BCM590XX_REG_REGMAP_PRI,
.desc = {
- BCM590XX_SR_DESC(SDSR2, sdsr2, dcdc_iosr1_ranges),
+ BCM59056_SR_DESC(SDSR2, sdsr2, dcdc_iosr1_ranges),
},
},
@@ -396,7 +407,7 @@ static const struct bcm590xx_reg_info bcm590xx_regs[BCM590XX_NUM_REGS] = {
.type = BCM590XX_REG_TYPE_SR,
.regmap = BCM590XX_REG_REGMAP_PRI,
.desc = {
- BCM590XX_SR_DESC(VSR, vsr, dcdc_iosr1_ranges),
+ BCM59056_SR_DESC(VSR, vsr, dcdc_iosr1_ranges),
},
},
@@ -404,7 +415,7 @@ static const struct bcm590xx_reg_info bcm590xx_regs[BCM590XX_NUM_REGS] = {
.type = BCM590XX_REG_TYPE_GPLDO,
.regmap = BCM590XX_REG_REGMAP_SEC,
.desc = {
- BCM590XX_LDO_DESC(GPLDO1, gpldo1, ldo_a_table),
+ BCM59056_LDO_DESC(GPLDO1, gpldo1, ldo_a_table),
},
},
@@ -412,7 +423,7 @@ static const struct bcm590xx_reg_info bcm590xx_regs[BCM590XX_NUM_REGS] = {
.type = BCM590XX_REG_TYPE_GPLDO,
.regmap = BCM590XX_REG_REGMAP_SEC,
.desc = {
- BCM590XX_LDO_DESC(GPLDO2, gpldo2, ldo_a_table),
+ BCM59056_LDO_DESC(GPLDO2, gpldo2, ldo_a_table),
},
},
@@ -420,7 +431,7 @@ static const struct bcm590xx_reg_info bcm590xx_regs[BCM590XX_NUM_REGS] = {
.type = BCM590XX_REG_TYPE_GPLDO,
.regmap = BCM590XX_REG_REGMAP_SEC,
.desc = {
- BCM590XX_LDO_DESC(GPLDO3, gpldo3, ldo_a_table),
+ BCM59056_LDO_DESC(GPLDO3, gpldo3, ldo_a_table),
},
},
@@ -428,7 +439,7 @@ static const struct bcm590xx_reg_info bcm590xx_regs[BCM590XX_NUM_REGS] = {
.type = BCM590XX_REG_TYPE_GPLDO,
.regmap = BCM590XX_REG_REGMAP_SEC,
.desc = {
- BCM590XX_LDO_DESC(GPLDO4, gpldo4, ldo_a_table),
+ BCM59056_LDO_DESC(GPLDO4, gpldo4, ldo_a_table),
},
},
@@ -436,7 +447,7 @@ static const struct bcm590xx_reg_info bcm590xx_regs[BCM590XX_NUM_REGS] = {
.type = BCM590XX_REG_TYPE_GPLDO,
.regmap = BCM590XX_REG_REGMAP_SEC,
.desc = {
- BCM590XX_LDO_DESC(GPLDO5, gpldo5, ldo_a_table),
+ BCM59056_LDO_DESC(GPLDO5, gpldo5, ldo_a_table),
},
},
@@ -444,7 +455,7 @@ static const struct bcm590xx_reg_info bcm590xx_regs[BCM590XX_NUM_REGS] = {
.type = BCM590XX_REG_TYPE_GPLDO,
.regmap = BCM590XX_REG_REGMAP_SEC,
.desc = {
- BCM590XX_LDO_DESC(GPLDO6, gpldo6, ldo_a_table),
+ BCM59056_LDO_DESC(GPLDO6, gpldo6, ldo_a_table),
},
},
@@ -452,11 +463,11 @@ static const struct bcm590xx_reg_info bcm590xx_regs[BCM590XX_NUM_REGS] = {
.type = BCM590XX_REG_TYPE_VBUS,
.regmap = BCM590XX_REG_REGMAP_SEC,
.desc = {
- BCM590XX_REG_DESC(VBUS, vbus),
+ BCM59056_REG_DESC(VBUS, vbus),
.ops = &bcm590xx_ops_vbus,
.n_voltages = 1,
.fixed_uV = 5000000,
- .enable_reg = BCM590XX_OTG_CTRL,
+ .enable_reg = BCM59056_OTG_CTRL,
.enable_mask = BCM590XX_VBUS_ENABLE,
},
},
@@ -476,8 +487,8 @@ static int bcm590xx_probe(struct platform_device *pdev)
return -ENOMEM;
pmu->mfd = bcm590xx;
- pmu->n_regulators = BCM590XX_NUM_REGS;
- pmu->regs = bcm590xx_regs;
+ pmu->n_regulators = BCM59056_NUM_REGS;
+ pmu->regs = bcm59056_regs;
platform_set_drvdata(pdev, pmu);
--
2.48.1
^ permalink raw reply related [flat|nested] 19+ messages in thread* [PATCH v3 7/7] regulator: bcm590xx: Add support for BCM59054 regulators
2025-01-31 18:13 [PATCH v3 0/7] mfd: bcm590xx: Add support for BCM59054 Artur Weber
` (5 preceding siblings ...)
2025-01-31 18:13 ` [PATCH v3 6/7] regulator: bcm590xx: Rename BCM59056-specific data as such Artur Weber
@ 2025-01-31 18:13 ` Artur Weber
2025-02-05 19:12 ` Stanislav Jakubek
6 siblings, 1 reply; 19+ messages in thread
From: Artur Weber @ 2025-01-31 18:13 UTC (permalink / raw)
To: Lee Jones, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
Liam Girdwood, Mark Brown, Florian Fainelli, Ray Jui,
Scott Branden, Broadcom internal kernel review list
Cc: Stanislav Jakubek, devicetree, linux-kernel, linux-arm-kernel,
~postmarketos/upstreaming, Artur Weber
The BCM59056 and BCM59054 are very similar in terms of regulators. Add
the register definitions for the BCM59054 and enable support for it in
the driver.
Signed-off-by: Artur Weber <aweber.kernel@gmail.com>
---
Changes in v3:
- Adapt to regulator info being moved to tables
---
drivers/regulator/bcm590xx-regulator.c | 394 ++++++++++++++++++++++++++++++++-
1 file changed, 392 insertions(+), 2 deletions(-)
diff --git a/drivers/regulator/bcm590xx-regulator.c b/drivers/regulator/bcm590xx-regulator.c
index 1cc46b32572beae24890ede9edbf0fb460bf31cd..73219fdb3c92948e8796f5765ba429878d84d69d 100644
--- a/drivers/regulator/bcm590xx-regulator.c
+++ b/drivers/regulator/bcm590xx-regulator.c
@@ -113,6 +113,13 @@ static const struct regulator_ops bcm590xx_ops_vbus = {
#define BCM59056_SR_DESC(_name, _name_lower, _ranges) \
BCM590XX_SR_DESC(BCM59056, bcm59056, _name, _name_lower, _ranges)
+#define BCM59054_REG_DESC(_name, _name_lower) \
+ BCM590XX_REG_DESC(BCM59054, _name, _name_lower)
+#define BCM59054_LDO_DESC(_name, _name_lower, _table) \
+ BCM590XX_LDO_DESC(BCM59054, bcm59054, _name, _name_lower, _table)
+#define BCM59054_SR_DESC(_name, _name_lower, _ranges) \
+ BCM590XX_SR_DESC(BCM59054, bcm59054, _name, _name_lower, _ranges)
+
/* BCM59056 data */
/* I2C slave 0 registers */
@@ -473,6 +480,376 @@ static const struct bcm590xx_reg_info bcm59056_regs[BCM59056_NUM_REGS] = {
},
};
+/* BCM59054 data */
+
+/* I2C slave 0 registers */
+#define BCM59054_RFLDOPMCTRL1 0x60
+#define BCM59054_CAMLDO1PMCTRL1 0x62
+#define BCM59054_CAMLDO2PMCTRL1 0x64
+#define BCM59054_SIMLDO1PMCTRL1 0x66
+#define BCM59054_SIMLDO2PMCTRL1 0x68
+#define BCM59054_SDLDOPMCTRL1 0x6a
+#define BCM59054_SDXLDOPMCTRL1 0x6c
+#define BCM59054_MMCLDO1PMCTRL1 0x6e
+#define BCM59054_MMCLDO2PMCTRL1 0x70
+#define BCM59054_AUDLDOPMCTRL1 0x72
+#define BCM59054_MICLDOPMCTRL1 0x74
+#define BCM59054_USBLDOPMCTRL1 0x76
+#define BCM59054_VIBLDOPMCTRL1 0x78
+#define BCM59054_IOSR1PMCTRL1 0x7a
+#define BCM59054_IOSR2PMCTRL1 0x7c
+#define BCM59054_CSRPMCTRL1 0x7e
+#define BCM59054_SDSR1PMCTRL1 0x82
+#define BCM59054_SDSR2PMCTRL1 0x86
+#define BCM59054_MMSRPMCTRL1 0x8a
+#define BCM59054_VSRPMCTRL1 0x8e
+#define BCM59054_RFLDOCTRL 0x96
+#define BCM59054_CAMLDO1CTRL 0x97
+#define BCM59054_CAMLDO2CTRL 0x98
+#define BCM59054_SIMLDO1CTRL 0x99
+#define BCM59054_SIMLDO2CTRL 0x9a
+#define BCM59054_SDLDOCTRL 0x9b
+#define BCM59054_SDXLDOCTRL 0x9c
+#define BCM59054_MMCLDO1CTRL 0x9d
+#define BCM59054_MMCLDO2CTRL 0x9e
+#define BCM59054_AUDLDOCTRL 0x9f
+#define BCM59054_MICLDOCTRL 0xa0
+#define BCM59054_USBLDOCTRL 0xa1
+#define BCM59054_VIBLDOCTRL 0xa2
+#define BCM59054_CSRVOUT1 0xc0
+#define BCM59054_IOSR1VOUT1 0xc3
+#define BCM59054_IOSR2VOUT1 0xc6
+#define BCM59054_MMSRVOUT1 0xc9
+#define BCM59054_SDSR1VOUT1 0xcc
+#define BCM59054_SDSR2VOUT1 0xcf
+#define BCM59054_VSRVOUT1 0xd2
+
+/* I2C slave 1 registers */
+#define BCM59054_LVLDO1PMCTRL1 0x16
+#define BCM59054_LVLDO2PMCTRL1 0x18
+#define BCM59054_GPLDO1CTRL 0x1a
+#define BCM59054_GPLDO2CTRL 0x1b
+#define BCM59054_GPLDO3CTRL 0x1c
+#define BCM59054_TCXLDOCTRL 0x1d
+#define BCM59054_LVLDO1CTRL 0x1e
+#define BCM59054_LVLDO2CTRL 0x1f
+#define BCM59054_OTG_CTRL 0x40
+#define BCM59054_GPLDO1PMCTRL1 0x57
+#define BCM59054_GPLDO2PMCTRL1 0x59
+#define BCM59054_GPLDO3PMCTRL1 0x5b
+#define BCM59054_TCXLDOPMCTRL1 0x5d
+
+/*
+ * RFLDO to VSR regulators are
+ * accessed via I2C slave 0
+ */
+
+/* LDO regulator IDs */
+#define BCM59054_REG_RFLDO 0
+#define BCM59054_REG_CAMLDO1 1
+#define BCM59054_REG_CAMLDO2 2
+#define BCM59054_REG_SIMLDO1 3
+#define BCM59054_REG_SIMLDO2 4
+#define BCM59054_REG_SDLDO 5
+#define BCM59054_REG_SDXLDO 6
+#define BCM59054_REG_MMCLDO1 7
+#define BCM59054_REG_MMCLDO2 8
+#define BCM59054_REG_AUDLDO 9
+#define BCM59054_REG_MICLDO 10
+#define BCM59054_REG_USBLDO 11
+#define BCM59054_REG_VIBLDO 12
+
+/* DCDC regulator IDs */
+#define BCM59054_REG_CSR 13
+#define BCM59054_REG_IOSR1 14
+#define BCM59054_REG_IOSR2 15
+#define BCM59054_REG_MMSR 16
+#define BCM59054_REG_SDSR1 17
+#define BCM59054_REG_SDSR2 18
+#define BCM59054_REG_VSR 19
+
+/*
+ * GPLDO1 to VBUS regulators are
+ * accessed via I2C slave 1
+ */
+
+#define BCM59054_REG_GPLDO1 20
+#define BCM59054_REG_GPLDO2 21
+#define BCM59054_REG_GPLDO3 22
+#define BCM59054_REG_TCXLDO 23
+#define BCM59054_REG_LVLDO1 24
+#define BCM59054_REG_LVLDO2 25
+#define BCM59054_REG_VBUS 26
+
+#define BCM59054_NUM_REGS 27
+
+/* LDO group 1: supported voltages in microvolts */
+static const unsigned int bcm59054_ldo_1_table[] = {
+ 1200000, 1800000, 2500000, 2700000, 2800000,
+ 2900000, 3000000, 3300000,
+};
+
+/* LDO group 2: supported voltages in microvolts */
+static const unsigned int bcm59054_ldo_2_table[] = {
+ 3100000, 1800000, 2500000, 2700000, 2800000,
+ 2900000, 3000000, 3300000,
+};
+
+/* LDO group 3: supported voltages in microvolts */
+static const unsigned int bcm59054_ldo_3_table[] = {
+ 1000000, 1107000, 1143000, 1214000, 1250000,
+ 1464000, 1500000, 1786000,
+};
+
+/* DCDC group SR: supported voltages in microvolts */
+static const struct linear_range bcm59054_dcdc_sr_ranges[] = {
+ REGULATOR_LINEAR_RANGE(0, 0, 1, 0),
+ REGULATOR_LINEAR_RANGE(860000, 2, 60, 10000),
+ REGULATOR_LINEAR_RANGE(1500000, 61, 61, 0),
+ REGULATOR_LINEAR_RANGE(1800000, 62, 62, 0),
+ REGULATOR_LINEAR_RANGE(900000, 63, 63, 0),
+};
+
+/* DCDC group VSR: supported voltages in microvolts */
+static const struct linear_range bcm59054_dcdc_vsr_ranges[] = {
+ REGULATOR_LINEAR_RANGE(0, 0, 1, 0),
+ REGULATOR_LINEAR_RANGE(860000, 2, 59, 10000),
+ REGULATOR_LINEAR_RANGE(1700000, 60, 60, 0),
+ REGULATOR_LINEAR_RANGE(1500000, 61, 61, 0),
+ REGULATOR_LINEAR_RANGE(1800000, 62, 62, 0),
+ REGULATOR_LINEAR_RANGE(1600000, 63, 63, 0),
+};
+
+/* DCDC group CSR: supported voltages in microvolts */
+static const struct linear_range bcm59054_dcdc_csr_ranges[] = {
+ REGULATOR_LINEAR_RANGE(700000, 0, 1, 100000),
+ REGULATOR_LINEAR_RANGE(860000, 2, 60, 10000),
+ REGULATOR_LINEAR_RANGE(900000, 61, 63, 0),
+};
+
+static const struct bcm590xx_reg_info bcm59054_regs[BCM59054_NUM_REGS] = {
+ {
+ .type = BCM590XX_REG_TYPE_LDO,
+ .regmap = BCM590XX_REG_REGMAP_PRI,
+ .desc = {
+ BCM59054_LDO_DESC(RFLDO, rfldo, ldo_1_table),
+ },
+ },
+
+ {
+ .type = BCM590XX_REG_TYPE_LDO,
+ .regmap = BCM590XX_REG_REGMAP_PRI,
+ .desc = {
+ BCM59054_LDO_DESC(CAMLDO1, camldo1, ldo_2_table),
+ },
+ },
+
+ {
+ .type = BCM590XX_REG_TYPE_LDO,
+ .regmap = BCM590XX_REG_REGMAP_PRI,
+ .desc = {
+ BCM59054_LDO_DESC(CAMLDO2, camldo2, ldo_2_table),
+ },
+ },
+
+ {
+ .type = BCM590XX_REG_TYPE_LDO,
+ .regmap = BCM590XX_REG_REGMAP_PRI,
+ .desc = {
+ BCM59054_LDO_DESC(SIMLDO1, simldo1, ldo_1_table),
+ },
+ },
+
+ {
+ .type = BCM590XX_REG_TYPE_LDO,
+ .regmap = BCM590XX_REG_REGMAP_PRI,
+ .desc = {
+ BCM59054_LDO_DESC(SIMLDO2, simldo2, ldo_1_table),
+ },
+ },
+
+ {
+ .type = BCM590XX_REG_TYPE_LDO,
+ .regmap = BCM590XX_REG_REGMAP_PRI,
+ .desc = {
+ BCM59054_LDO_DESC(SDLDO, sdldo, ldo_2_table),
+ },
+ },
+
+ {
+ .type = BCM590XX_REG_TYPE_LDO,
+ .regmap = BCM590XX_REG_REGMAP_PRI,
+ .desc = {
+ BCM59054_LDO_DESC(SDXLDO, sdxldo, ldo_1_table),
+ },
+ },
+
+ {
+ .type = BCM590XX_REG_TYPE_LDO,
+ .regmap = BCM590XX_REG_REGMAP_PRI,
+ .desc = {
+ BCM59054_LDO_DESC(MMCLDO1, mmcldo1, ldo_1_table),
+ },
+ },
+
+ {
+ .type = BCM590XX_REG_TYPE_LDO,
+ .regmap = BCM590XX_REG_REGMAP_PRI,
+ .desc = {
+ BCM59054_LDO_DESC(MMCLDO2, mmcldo2, ldo_1_table),
+ },
+ },
+
+ {
+ .type = BCM590XX_REG_TYPE_LDO,
+ .regmap = BCM590XX_REG_REGMAP_PRI,
+ .desc = {
+ BCM59054_LDO_DESC(AUDLDO, audldo, ldo_1_table),
+ },
+ },
+
+ {
+ .type = BCM590XX_REG_TYPE_LDO,
+ .regmap = BCM590XX_REG_REGMAP_PRI,
+ .desc = {
+ BCM59054_LDO_DESC(MICLDO, micldo, ldo_1_table),
+ },
+ },
+
+ {
+ .type = BCM590XX_REG_TYPE_LDO,
+ .regmap = BCM590XX_REG_REGMAP_PRI,
+ .desc = {
+ BCM59054_LDO_DESC(USBLDO, usbldo, ldo_1_table),
+ },
+ },
+
+ {
+ .type = BCM590XX_REG_TYPE_LDO,
+ .regmap = BCM590XX_REG_REGMAP_PRI,
+ .desc = {
+ BCM59054_LDO_DESC(VIBLDO, vibldo, ldo_2_table),
+ },
+ },
+
+ {
+ .type = BCM590XX_REG_TYPE_SR,
+ .regmap = BCM590XX_REG_REGMAP_PRI,
+ .desc = {
+ BCM59054_SR_DESC(CSR, csr, dcdc_csr_ranges),
+ },
+ },
+
+ {
+ .type = BCM590XX_REG_TYPE_SR,
+ .regmap = BCM590XX_REG_REGMAP_PRI,
+ .desc = {
+ BCM59054_SR_DESC(IOSR1, iosr1, dcdc_sr_ranges),
+ },
+ },
+
+ {
+ .type = BCM590XX_REG_TYPE_SR,
+ .regmap = BCM590XX_REG_REGMAP_PRI,
+ .desc = {
+ BCM59054_SR_DESC(IOSR2, iosr2, dcdc_sr_ranges),
+ },
+ },
+
+ {
+ .type = BCM590XX_REG_TYPE_SR,
+ .regmap = BCM590XX_REG_REGMAP_PRI,
+ .desc = {
+ BCM59054_SR_DESC(MMSR, mmsr, dcdc_sr_ranges),
+ },
+ },
+
+ {
+ .type = BCM590XX_REG_TYPE_SR,
+ .regmap = BCM590XX_REG_REGMAP_PRI,
+ .desc = {
+ BCM59054_SR_DESC(SDSR1, sdsr1, dcdc_sr_ranges),
+ },
+ },
+
+ {
+ .type = BCM590XX_REG_TYPE_SR,
+ .regmap = BCM590XX_REG_REGMAP_PRI,
+ .desc = {
+ BCM59054_SR_DESC(SDSR2, sdsr2, dcdc_sr_ranges),
+ },
+ },
+
+ {
+ .type = BCM590XX_REG_TYPE_SR,
+ .regmap = BCM590XX_REG_REGMAP_PRI,
+ .desc = {
+ BCM59054_SR_DESC(VSR, vsr, dcdc_vsr_ranges),
+ },
+ },
+
+ {
+ .type = BCM590XX_REG_TYPE_GPLDO,
+ .regmap = BCM590XX_REG_REGMAP_SEC,
+ .desc = {
+ BCM59054_LDO_DESC(GPLDO1, gpldo1, ldo_1_table),
+ },
+ },
+
+ {
+ .type = BCM590XX_REG_TYPE_GPLDO,
+ .regmap = BCM590XX_REG_REGMAP_SEC,
+ .desc = {
+ BCM59054_LDO_DESC(GPLDO2, gpldo2, ldo_1_table),
+ },
+ },
+
+ {
+ .type = BCM590XX_REG_TYPE_GPLDO,
+ .regmap = BCM590XX_REG_REGMAP_SEC,
+ .desc = {
+ BCM59054_LDO_DESC(GPLDO3, gpldo3, ldo_1_table),
+ },
+ },
+
+ {
+ .type = BCM590XX_REG_TYPE_GPLDO,
+ .regmap = BCM590XX_REG_REGMAP_SEC,
+ .desc = {
+ BCM59054_LDO_DESC(TCXLDO, tcxldo, ldo_1_table),
+ },
+ },
+
+ {
+ .type = BCM590XX_REG_TYPE_GPLDO,
+ .regmap = BCM590XX_REG_REGMAP_SEC,
+ .desc = {
+ BCM59054_LDO_DESC(LVLDO1, lvldo1, ldo_1_table),
+ },
+ },
+
+ {
+ .type = BCM590XX_REG_TYPE_GPLDO,
+ .regmap = BCM590XX_REG_REGMAP_SEC,
+ .desc = {
+ BCM59054_LDO_DESC(LVLDO2, lvldo2, ldo_3_table),
+ },
+ },
+
+ {
+ .type = BCM590XX_REG_TYPE_VBUS,
+ .regmap = BCM590XX_REG_REGMAP_SEC,
+ .desc = {
+ BCM59054_REG_DESC(VBUS, vbus),
+ .ops = &bcm590xx_ops_vbus,
+ .n_voltages = 1,
+ .fixed_uV = 5000000,
+ .enable_reg = BCM59054_OTG_CTRL,
+ .enable_mask = BCM590XX_VBUS_ENABLE,
+ },
+ },
+};
+
static int bcm590xx_probe(struct platform_device *pdev)
{
struct bcm590xx *bcm590xx = dev_get_drvdata(pdev->dev.parent);
@@ -487,8 +864,21 @@ static int bcm590xx_probe(struct platform_device *pdev)
return -ENOMEM;
pmu->mfd = bcm590xx;
- pmu->n_regulators = BCM59056_NUM_REGS;
- pmu->regs = bcm59056_regs;
+
+ switch (pmu->mfd->device_type) {
+ case BCM59054_TYPE:
+ pmu->n_regulators = BCM59054_NUM_REGS;
+ pmu->regs = bcm59054_regs;
+ break;
+ case BCM59056_TYPE:
+ pmu->n_regulators = BCM59056_NUM_REGS;
+ pmu->regs = bcm59056_regs;
+ break;
+ default:
+ dev_err(bcm590xx->dev,
+ "unknown device type, could not initialize");
+ return -EINVAL;
+ }
platform_set_drvdata(pdev, pmu);
--
2.48.1
^ permalink raw reply related [flat|nested] 19+ messages in thread* Re: [PATCH v3 7/7] regulator: bcm590xx: Add support for BCM59054 regulators
2025-01-31 18:13 ` [PATCH v3 7/7] regulator: bcm590xx: Add support for BCM59054 regulators Artur Weber
@ 2025-02-05 19:12 ` Stanislav Jakubek
0 siblings, 0 replies; 19+ messages in thread
From: Stanislav Jakubek @ 2025-02-05 19:12 UTC (permalink / raw)
To: Artur Weber
Cc: Lee Jones, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
Liam Girdwood, Mark Brown, Florian Fainelli, Ray Jui,
Scott Branden, Broadcom internal kernel review list, devicetree,
linux-kernel, linux-arm-kernel, ~postmarketos/upstreaming
Hi Artur,
some notes below.
On Fri, Jan 31, 2025 at 07:13:55PM +0100, Artur Weber wrote:
> The BCM59056 and BCM59054 are very similar in terms of regulators. Add
> the register definitions for the BCM59054 and enable support for it in
> the driver.
>
> Signed-off-by: Artur Weber <aweber.kernel@gmail.com>
> ---
[snip]
> + {
> + .type = BCM590XX_REG_TYPE_LDO,
> + .regmap = BCM590XX_REG_REGMAP_PRI,
> + .desc = {
> + BCM59054_LDO_DESC(MICLDO, micldo, ldo_1_table),
> + },
> + },
Downstream has MICLDO fixed at 1.8V.
Not sure if that isn't just some vendor hack though :/
https://github.com/Samsung-KYLEPROXX/android_kernel_samsung_kyleproxx/blob/cm-13.0/drivers/regulator/bcmpmu-rgltr-bcm59xxx.c#L83
> +
> + {
> + .type = BCM590XX_REG_TYPE_LDO,
> + .regmap = BCM590XX_REG_REGMAP_PRI,
> + .desc = {
> + BCM59054_LDO_DESC(USBLDO, usbldo, ldo_1_table),
> + },
> + },
> +
> + {
> + .type = BCM590XX_REG_TYPE_LDO,
> + .regmap = BCM590XX_REG_REGMAP_PRI,
> + .desc = {
> + BCM59054_LDO_DESC(VIBLDO, vibldo, ldo_2_table),
> + },
> + },
> +
> + {
> + .type = BCM590XX_REG_TYPE_SR,
> + .regmap = BCM590XX_REG_REGMAP_PRI,
> + .desc = {
> + BCM59054_SR_DESC(CSR, csr, dcdc_csr_ranges),
> + },
> + },
> +
> + {
> + .type = BCM590XX_REG_TYPE_SR,
> + .regmap = BCM590XX_REG_REGMAP_PRI,
> + .desc = {
> + BCM59054_SR_DESC(IOSR1, iosr1, dcdc_sr_ranges),
> + },
> + },
> +
> + {
> + .type = BCM590XX_REG_TYPE_SR,
> + .regmap = BCM590XX_REG_REGMAP_PRI,
> + .desc = {
> + BCM59054_SR_DESC(IOSR2, iosr2, dcdc_sr_ranges),
> + },
> + },
> +
> + {
> + .type = BCM590XX_REG_TYPE_SR,
> + .regmap = BCM590XX_REG_REGMAP_PRI,
> + .desc = {
> + BCM59054_SR_DESC(MMSR, mmsr, dcdc_sr_ranges),
> + },
> + },
> +
> + {
> + .type = BCM590XX_REG_TYPE_SR,
> + .regmap = BCM590XX_REG_REGMAP_PRI,
> + .desc = {
> + BCM59054_SR_DESC(SDSR1, sdsr1, dcdc_sr_ranges),
> + },
> + },
> +
> + {
> + .type = BCM590XX_REG_TYPE_SR,
> + .regmap = BCM590XX_REG_REGMAP_PRI,
> + .desc = {
> + BCM59054_SR_DESC(SDSR2, sdsr2, dcdc_sr_ranges),
> + },
> + },
> +
> + {
> + .type = BCM590XX_REG_TYPE_SR,
> + .regmap = BCM590XX_REG_REGMAP_PRI,
> + .desc = {
> + BCM59054_SR_DESC(VSR, vsr, dcdc_vsr_ranges),
> + },
> + },
VSR seems to be different between BCM59054(A0?) and BCM59054A1.
These are the A1 ranges.
Should we differentiate between the two versions, same as downstream?
https://github.com/Samsung-KYLEPROXX/android_kernel_samsung_kyleproxx/blob/cm-13.0/drivers/regulator/bcmpmu-rgltr-bcm59xxx.c#L736
> +
> + {
> + .type = BCM590XX_REG_TYPE_GPLDO,
> + .regmap = BCM590XX_REG_REGMAP_SEC,
> + .desc = {
> + BCM59054_LDO_DESC(GPLDO1, gpldo1, ldo_1_table),
> + },
> + },
> +
> + {
> + .type = BCM590XX_REG_TYPE_GPLDO,
> + .regmap = BCM590XX_REG_REGMAP_SEC,
> + .desc = {
> + BCM59054_LDO_DESC(GPLDO2, gpldo2, ldo_1_table),
> + },
> + },
> +
> + {
> + .type = BCM590XX_REG_TYPE_GPLDO,
> + .regmap = BCM590XX_REG_REGMAP_SEC,
> + .desc = {
> + BCM59054_LDO_DESC(GPLDO3, gpldo3, ldo_1_table),
> + },
> + },
> +
> + {
> + .type = BCM590XX_REG_TYPE_GPLDO,
> + .regmap = BCM590XX_REG_REGMAP_SEC,
> + .desc = {
> + BCM59054_LDO_DESC(TCXLDO, tcxldo, ldo_1_table),
> + },
> + },
> +
> + {
> + .type = BCM590XX_REG_TYPE_GPLDO,
> + .regmap = BCM590XX_REG_REGMAP_SEC,
> + .desc = {
> + BCM59054_LDO_DESC(LVLDO1, lvldo1, ldo_1_table),
According to downstream, this should be ldo_3_table.
https://github.com/Samsung-KYLEPROXX/android_kernel_samsung_kyleproxx/blob/cm-13.0/drivers/regulator/bcmpmu-rgltr-bcm59xxx.c#L683
> + },
> + },
> +
> + {
> + .type = BCM590XX_REG_TYPE_GPLDO,
> + .regmap = BCM590XX_REG_REGMAP_SEC,
> + .desc = {
> + BCM59054_LDO_DESC(LVLDO2, lvldo2, ldo_3_table),
> + },
> + },
> +
> + {
> + .type = BCM590XX_REG_TYPE_VBUS,
> + .regmap = BCM590XX_REG_REGMAP_SEC,
> + .desc = {
> + BCM59054_REG_DESC(VBUS, vbus),
> + .ops = &bcm590xx_ops_vbus,
> + .n_voltages = 1,
> + .fixed_uV = 5000000,
> + .enable_reg = BCM59054_OTG_CTRL,
> + .enable_mask = BCM590XX_VBUS_ENABLE,
> + },
> + },
> +};
> +
> static int bcm590xx_probe(struct platform_device *pdev)
> {
> struct bcm590xx *bcm590xx = dev_get_drvdata(pdev->dev.parent);
> @@ -487,8 +864,21 @@ static int bcm590xx_probe(struct platform_device *pdev)
> return -ENOMEM;
>
> pmu->mfd = bcm590xx;
> - pmu->n_regulators = BCM59056_NUM_REGS;
> - pmu->regs = bcm59056_regs;
> +
> + switch (pmu->mfd->device_type) {
> + case BCM59054_TYPE:
> + pmu->n_regulators = BCM59054_NUM_REGS;
> + pmu->regs = bcm59054_regs;
> + break;
> + case BCM59056_TYPE:
> + pmu->n_regulators = BCM59056_NUM_REGS;
> + pmu->regs = bcm59056_regs;
> + break;
> + default:
> + dev_err(bcm590xx->dev,
> + "unknown device type, could not initialize");
> + return -EINVAL;
Missing a '\n' in the error message.
Could use dev_err_probe as well. Maybe in other places in the driver too.
Regards,
Stanislav
> + }
>
> platform_set_drvdata(pdev, pmu);
>
>
> --
> 2.48.1
>
^ permalink raw reply [flat|nested] 19+ messages in thread