Skip to contentSkip to conversation

Add support for BCM2712 SD card controller

PATCH NAK Andrea della Porta 8 participants 39 messages Apr 13, 2024 – May 2, 2024

Subsystems (8)
lore
Share & tools
lore
#0 lore raw

cover Add support for BCM2712 SD card controller

Hi,

This patchset adds support for the SDHCI controller on Broadcom BCM2712 SoC in order to make it possible to boot (particularly) Raspberry Pi 5 from SD card. This work is heavily based on downstream contributions.

Patch #1 and 2: introduce the dt binding definitions for, respectively, the new pin cfg/mux controller and the SD host controller as a preparatory step for the upcoming dts.

Patch #3: add a somewhat reasonable (*almost* bare-minimum) dts to be used to boot Rpi5 boards. Since till now there was no support at all for any 2712 based chipset, both the SoC and board dts plus definitions for the new Pin and SD host controller have been added.

Patch #4: the driver supporting the pin controller. Based on [1] and successive fix commits.

Patch #5: add SDHCI support. Based on [2] and the next 2 fix commits. Drop the SD Express implementation for now, that will be added by patch #6.

Patch #6: this patch offers SD Express support and can be considered totally optional. The callback plumbing is slightly different w.r.t. the downstream approach (see [3]), as explained in the patch comment. Not sure what is the best, any comment is highly appreciated.

Tested succesfully on Raspberry Pi 5 using an SDxC card as the boot device.

Still untested:
- SD Express due to the lack of an Express capable card. Also, it will need PCIe support first.
- card detection pin, since the sd was the booting and root fs device.

Many thanks,
Andrea

Links:
[1] - https://github.com/raspberrypi/linux/commit/d9b655314a826724538867bf9b6c229d04c25d84
[2] - https://github.com/raspberrypi/linux/commit/e3aa070496e840e72a4dc384718690ea4125fa6a
[3] - https://github.com/raspberrypi/linux/commit/eb1df34db2a9a5b752eba40ee298c4ae87e26e87

Andrea della Porta (6):
dt-bindings: pinctrl: Add support for BCM2712 pin controller
dt-bindings: mmc: Add support for BCM2712 SD host controller
arm64: dts: broadcom: Add support for BCM2712
pinctrl: bcm: Add pinconf/pinmux controller driver for BCM2712
mmc: sdhci-brcmstb: Add BCM2712 support
mmc: sdhci-brcmstb: Add BCM2712 SD Express support

 .../bindings/mmc/brcm,sdhci-brcmstb.yaml      |   51 +-
 .../pinctrl/brcm,bcm2712-pinctrl.yaml         |   99 ++
 arch/arm64/boot/dts/broadcom/Makefile         |    1 +
 .../boot/dts/broadcom/bcm2712-rpi-5-b.dts     |  313 +++++
 arch/arm64/boot/dts/broadcom/bcm2712-rpi.dtsi |   81 ++
 arch/arm64/boot/dts/broadcom/bcm2712.dtsi     |  841 +++++++++++
 drivers/mmc/host/Kconfig                      |    1 +
 drivers/mmc/host/sdhci-brcmstb.c              |  275 ++++
 drivers/pinctrl/bcm/Kconfig                   |    9 +
 drivers/pinctrl/bcm/Makefile                  |    1 +
 drivers/pinctrl/bcm/pinctrl-bcm2712.c         | 1247 +++++++++++++++++
 11 files changed, 2918 insertions(+), 1 deletion(-)
 create mode 100644 Documentation/devicetree/bindings/pinctrl/brcm,bcm2712-pinctrl.yaml
 create mode 100644 arch/arm64/boot/dts/broadcom/bcm2712-rpi-5-b.dts
 create mode 100644 arch/arm64/boot/dts/broadcom/bcm2712-rpi.dtsi
 create mode 100644 arch/arm64/boot/dts/broadcom/bcm2712.dtsi
 create mode 100644 drivers/pinctrl/bcm/pinctrl-bcm2712.c
Signature · 1 line
2.35.3
#1 lore raw

PATCH 1/6 dt-bindings: pinctrl: Add support for BCM2712 pin controller

---
 .../pinctrl/brcm,bcm2712-pinctrl.yaml         | 99 +++++++++++++++++++
 1 file changed, 99 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/pinctrl/brcm,bcm2712-pinctrl.yaml
Documentation/devicetree/bindings/pinctrl/brcm,bcm2712-pinctrl.yaml new file +99 -0
new file mode 100644
index 000000000000..2908dfe99f3e
@@ -0,0 +1,99 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/pinctrl/brcm,bcm2712-pinctrl.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Broadcom BCM2712 pin controller
+
+maintainers:
+  - Andrea della Porta <[email protected]>
+
+description:
+  Bindings for Broadcom's BCM2712 memory-mapped pin controller.
+
+properties:
+  compatible:
+    enum:
+      - brcm,bcm2712-pinctrl
+      - brcm,bcm2712-aon-pinctrl
+      - brcm,bcm2712c0-pinctrl
+      - brcm,bcm2712c0-aon-pinctrl
+      - brcm,bcm2712d0-pinctrl
+      - brcm,bcm2712d0-aon-pinctrl
+
+  reg:
+    items:
+      - description: pin control registers
+
+allOf:
+  - $ref: pinctrl.yaml#
+
+required:
+  - compatible
+  - reg
+
+additionalProperties:
+  anyOf:
+    - type: object  
+      allOf:
+        - $ref: pincfg-node.yaml#
+        - $ref: pinmux-node.yaml#
+
+      properties:
+        function: 
+          enum: [ gpio, alt1, alt2, alt3, alt4, alt5, alt6, alt7, alt8,
+                 aon_cpu_standbyb, aon_fp_4sec_resetb, aon_gpclk, aon_pwm,
+                 arm_jtag, aud_fs_clk0, avs_pmu_bsc, bsc_m0, bsc_m1, bsc_m2,
+                 bsc_m3, clk_observe, ctl_hdmi_5v, enet0, enet0_mii,
+                 enet0_rgmii, ext_sc_clk, fl0, fl1, gpclk0, gpclk1, gpclk2,
+                 hdmi_tx0_auto_i2c, hdmi_tx0_bsc, hdmi_tx1_auto_i2c,
+                 hdmi_tx1_bsc, i2s_in, i2s_out, ir_in, mtsif, mtsif_alt,
+                 mtsif_alt1, pdm, pkt, pm_led_out, sc0, sd0, sd2, sd_card_a,
+                 sd_card_b, sd_card_c, sd_card_d, sd_card_e, sd_card_f,
+                 sd_card_g, spdif_out, spi_m, spi_s, sr_edm_sense, te0, te1,
+                 tsio, uart0, uart1, uart2, usb_pwr, usb_vbus, uui, vc_i2c0,
+                 vc_i2c3, vc_i2c4, vc_i2c5, vc_i2csl, vc_pcm, vc_pwm0,
+                 vc_pwm1, vc_spi0, vc_spi3, vc_spi4, vc_spi5, vc_uart0,
+                 vc_uart2, vc_uart3, vc_uart4 ]
+
+        pins:
+          items:
+            pattern: "^((aon_)?s?gpio[0-6]?[0-9])|(emmc_(clk|cmd|dat[0-7]|ds))$"
+
+        bias-disable: true
+        bias-pull-down: true
+        bias-pull-up: true
+      additionalProperties: false
+
+    - type: object
+      additionalProperties:
+        $ref: "#/additionalProperties/anyOf/0"
+
+examples:
+  - |
+    pinctrl: pinctrl@7d504100 {
+      compatible = "brcm,bcm2712-pinctrl";
+        reg = <0x7d504100 0x30>;
+
+        uarta_24_pins: uarta_24_pins {
+          pin_rts {
+            function = "uart0";
+            pins = "gpio24";
+            bias-disable;
+        };
+
+        pin_cts {
+            function = "uart0";
+            pins = "gpio25";
+            bias-pull-up;
+        };
+      };
+
+      spi10_gpio2: spi10_gpio2 {
+        function = "vc_spi0";
+        pins = "gpio2", "gpio3", "gpio4";
+        bias-disable;
+      };
+    };
+...
Signature · 1 line
2.35.3
maintainer
#2 lore raw

Re: [PATCH 1/6] dt-bindings: pinctrl: Add support for BCM2712 pin controller

Quoted 6 lines · Andrea della Porta
---
 .../pinctrl/brcm,bcm2712-pinctrl.yaml         | 99 +++++++++++++++++++
 1 file changed, 99 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/pinctrl/brcm,bcm2712-pinctrl.yaml

My bot found errors running 'make dt_binding_check' on your patch:

yamllint warnings/errors:
./Documentation/devicetree/bindings/pinctrl/brcm,bcm2712-pinctrl.yaml:46:18: [warning] wrong indentation: expected 18 but found 17 (indentation) ./Documentation/devicetree/bindings/pinctrl/brcm,bcm2712-pinctrl.yaml:47:18: [warning] wrong indentation: expected 18 but found 17 (indentation) ./Documentation/devicetree/bindings/pinctrl/brcm,bcm2712-pinctrl.yaml:48:18: [warning] wrong indentation: expected 18 but found 17 (indentation) ./Documentation/devicetree/bindings/pinctrl/brcm,bcm2712-pinctrl.yaml:49:18: [warning] wrong indentation: expected 18 but found 17 (indentation) ./Documentation/devicetree/bindings/pinctrl/brcm,bcm2712-pinctrl.yaml:50:18: [warning] wrong indentation: expected 18 but found 17 (indentation) ./Documentation/devicetree/bindings/pinctrl/brcm,bcm2712-pinctrl.yaml:51:18: [warning] wrong indentation: expected 18 but found 17 (indentation) ./Documentation/devicetree/bindings/pinctrl/brcm,bcm2712-pinctrl.yaml:52:18: [warning] wrong indentation: expected 18 but found 17 (indentation) ./Documentation/devicetree/bindings/pinctrl/brcm,bcm2712-pinctrl.yaml:53:18: [warning] wrong indentation: expected 18 but found 17 (indentation) ./Documentation/devicetree/bindings/pinctrl/brcm,bcm2712-pinctrl.yaml:54:18: [warning] wrong indentation: expected 18 but found 17 (indentation) ./Documentation/devicetree/bindings/pinctrl/brcm,bcm2712-pinctrl.yaml:55:18: [warning] wrong indentation: expected 18 but found 17 (indentation) ./Documentation/devicetree/bindings/pinctrl/brcm,bcm2712-pinctrl.yaml:56:18: [warning] wrong indentation: expected 18 but found 17 (indentation) ./Documentation/devicetree/bindings/pinctrl/brcm,bcm2712-pinctrl.yaml:57:18: [warning] wrong indentation: expected 18 but found 17 (indentation) ./Documentation/devicetree/bindings/pinctrl/brcm,bcm2712-pinctrl.yaml:58:18: [warning] wrong indentation: expected 18 but found 17 (indentation)

dtschema/dtc warnings/errors:

doc reference errors (make refcheckdocs):

See https://patchwork.ozlabs.org/project/devicetree-bindings/patch/2d1272cad92ad618297a6683e9264e31b8f2df73.1713036964.git.andrea.porta@suse.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.

#3 lore raw

Re: [PATCH 1/6] dt-bindings: pinctrl: Add support for BCM2712 pin controller

In reply to Andrea della Porta
Quoted 1 line · Andrea della Porta

Missing commit msg. We can't take empty commits. You have entire commit msg to describe the hardware, why not doing this?

Plus, this wasn't even tested...

Quoted 14 lines
---
 .../pinctrl/brcm,bcm2712-pinctrl.yaml         | 99 +++++++++++++++++++
 1 file changed, 99 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/pinctrl/brcm,bcm2712-pinctrl.yaml
Documentation/devicetree/bindings/pinctrl/brcm,bcm2712-pinctrl.yaml new file +3 -0
new file mode 100644
index 000000000000..2908dfe99f3e
@@ -0,0 +1,99 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---

Documentation/devicetree/bindings/pinctrl/brcm,bcm2712-pinctrl.yaml line 13

Quoted 10 lines
Documentation/devicetree/bindings/pinctrl/brcm,bcm2712-pinctrl.yaml new file +10 -0
+$id: http://devicetree.org/schemas/pinctrl/brcm,bcm2712-pinctrl.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Broadcom BCM2712 pin controller
+
+maintainers:
+  - Andrea della Porta <[email protected]>
+
+description:
+  Bindings for Broadcom's BCM2712 memory-mapped pin controller.

Drop "Bindings for" and describe hardware. Bindings do not have to tell they are bindings, it's obvious. They cannot be anything else.

Quoted 56 lines
Documentation/devicetree/bindings/pinctrl/brcm,bcm2712-pinctrl.yaml new file +56 -0
+
+properties:
+  compatible:
+    enum:
+      - brcm,bcm2712-pinctrl
+      - brcm,bcm2712-aon-pinctrl
+      - brcm,bcm2712c0-pinctrl
+      - brcm,bcm2712c0-aon-pinctrl
+      - brcm,bcm2712d0-pinctrl
+      - brcm,bcm2712d0-aon-pinctrl
+
+  reg:
+    items:
+      - description: pin control registers
+
+allOf:
+  - $ref: pinctrl.yaml#
+
+required:
+  - compatible
+  - reg
+
+additionalProperties:
+  anyOf:
+    - type: object  
+      allOf:
+        - $ref: pincfg-node.yaml#
+        - $ref: pinmux-node.yaml#
+
+      properties:
+        function: 
+          enum: [ gpio, alt1, alt2, alt3, alt4, alt5, alt6, alt7, alt8,
+                 aon_cpu_standbyb, aon_fp_4sec_resetb, aon_gpclk, aon_pwm,
+                 arm_jtag, aud_fs_clk0, avs_pmu_bsc, bsc_m0, bsc_m1, bsc_m2,
+                 bsc_m3, clk_observe, ctl_hdmi_5v, enet0, enet0_mii,
+                 enet0_rgmii, ext_sc_clk, fl0, fl1, gpclk0, gpclk1, gpclk2,
+                 hdmi_tx0_auto_i2c, hdmi_tx0_bsc, hdmi_tx1_auto_i2c,
+                 hdmi_tx1_bsc, i2s_in, i2s_out, ir_in, mtsif, mtsif_alt,
+                 mtsif_alt1, pdm, pkt, pm_led_out, sc0, sd0, sd2, sd_card_a,
+                 sd_card_b, sd_card_c, sd_card_d, sd_card_e, sd_card_f,
+                 sd_card_g, spdif_out, spi_m, spi_s, sr_edm_sense, te0, te1,
+                 tsio, uart0, uart1, uart2, usb_pwr, usb_vbus, uui, vc_i2c0,
+                 vc_i2c3, vc_i2c4, vc_i2c5, vc_i2csl, vc_pcm, vc_pwm0,
+                 vc_pwm1, vc_spi0, vc_spi3, vc_spi4, vc_spi5, vc_uart0,
+                 vc_uart2, vc_uart3, vc_uart4 ]
+
+        pins:
+          items:
+            pattern: "^((aon_)?s?gpio[0-6]?[0-9])|(emmc_(clk|cmd|dat[0-7]|ds))$"
+
+        bias-disable: true
+        bias-pull-down: true
+        bias-pull-up: true
+      additionalProperties: false
+
+    - type: object

Documentation/devicetree/bindings/pinctrl/brcm,bcm2712-pinctrl.yaml line 79

Quoted 10 lines
Documentation/devicetree/bindings/pinctrl/brcm,bcm2712-pinctrl.yaml new file +10 -0
+      additionalProperties:
+        $ref: "#/additionalProperties/anyOf/0"
+
+examples:
+  - |
+    pinctrl: pinctrl@7d504100 {
+      compatible = "brcm,bcm2712-pinctrl";
+        reg = <0x7d504100 0x30>;
+
+        uarta_24_pins: uarta_24_pins {

Underscores are not allowed. Please observe the rules of DTS coding style (see docs).

Quoted 6 lines
Documentation/devicetree/bindings/pinctrl/brcm,bcm2712-pinctrl.yaml new file +6 -0
+          pin_rts {
+            function = "uart0";
+            pins = "gpio24";
+            bias-disable;
+        };
+

Documentation/devicetree/bindings/pinctrl/brcm,bcm2712-pinctrl.yaml line 95

Quoted 10 lines
Documentation/devicetree/bindings/pinctrl/brcm,bcm2712-pinctrl.yaml new file +10 -0
+        pin_cts {
+            function = "uart0";
+            pins = "gpio25";
+            bias-pull-up;
+        };
+      };
+
+      spi10_gpio2: spi10_gpio2 {
+        function = "vc_spi0";
+        pins = "gpio2", "gpio3", "gpio4";

Messed indentation. Keep 4 space.

Documentation/devicetree/bindings/pinctrl/brcm,bcm2712-pinctrl.yaml line 99

Quoted 4 lines
Documentation/devicetree/bindings/pinctrl/brcm,bcm2712-pinctrl.yaml new file +4 -0
+        bias-disable;
+      };
+    };
+...

Best regards,
Krzysztof

maintainer
#4 lore raw

Re: [PATCH 1/6] dt-bindings: pinctrl: Add support for BCM2712 pin controller

In reply to Andrea della Porta
Quoted 12 lines · Andrea della Porta
---
  .../pinctrl/brcm,bcm2712-pinctrl.yaml         | 99 +++++++++++++++++++
  1 file changed, 99 insertions(+)

create mode 100644 Documentation/devicetree/bindings/pinctrl/brcm,bcm2712-pinctrl.yaml

Documentation/devicetree/bindings/pinctrl/brcm,bcm2712-pinctrl.yaml new file +0 -0
new file mode 100644
index 000000000000..2908dfe99f3e

Documentation/devicetree/bindings/pinctrl/brcm,bcm2712-pinctrl.yaml line 7

Quoted 7 lines
Documentation/devicetree/bindings/pinctrl/brcm,bcm2712-pinctrl.yaml new file +7 -0
@@ -0,0 +1,99 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/pinctrl/brcm,bcm2712-pinctrl.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Broadcom BCM2712 pin controller

This is not strictly speaking BCM2712 specific, the pin controller you describe is a Broadcom STB product line pin controller.

Please describe it as such as and make BCM2712 a specific instance of the chip using that pin controller, see more comments on patch #4.

Signature · 1 line
Florian
#5 lore raw

Re: [PATCH 1/6] dt-bindings: pinctrl: Add support for BCM2712 pin controller

Quoted 4 lines · Florian Fainelli
Quoted 3 lines · Andrea della Porta

+++ b/Documentation/devicetree/bindings/pinctrl/brcm,bcm2712-pinctrl.yaml

(...)

Quoted 1 line
Quoted 1 line

+$id: http://devicetree.org/schemas/pinctrl/brcm,bcm2712-pinctrl.yaml#

(...)

Quoted 7 lines
Quoted 1 line

+title: Broadcom BCM2712 pin controller

This is not strictly speaking BCM2712 specific, the pin controller you describe is a Broadcom STB product line pin controller.

Please describe it as such as and make BCM2712 a specific instance of the chip using that pin controller, see more comments on patch #4.

So also the name of the bindings namespace should not be this one controller IMO but the name of the family, bcm-stb-pinctrl.yaml or so.

Yours,
Linus Walleij

#6 lore raw

Re: [PATCH 1/6] dt-bindings: pinctrl: Add support for BCM2712 pin controller

In reply to Florian Fainelli
Quoted 26 lines · Florian Fainelli
Quoted 12 lines · Andrea della Porta
---
  .../pinctrl/brcm,bcm2712-pinctrl.yaml         | 99 +++++++++++++++++++
  1 file changed, 99 insertions(+)

create mode 100644 Documentation/devicetree/bindings/pinctrl/brcm,bcm2712-pinctrl.yaml

Documentation/devicetree/bindings/pinctrl/brcm,bcm2712-pinctrl.yaml new file +0 -0
new file mode 100644
index 000000000000..2908dfe99f3e

Documentation/devicetree/bindings/pinctrl/brcm,bcm2712-pinctrl.yaml line 7

Quoted 7 lines
Documentation/devicetree/bindings/pinctrl/brcm,bcm2712-pinctrl.yaml new file +7 -0
@@ -0,0 +1,99 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/pinctrl/brcm,bcm2712-pinctrl.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Broadcom BCM2712 pin controller

This is not strictly speaking BCM2712 specific, the pin controller you describe is a Broadcom STB product line pin controller.

Quoted 2 lines

Please describe it as such as and make BCM2712 a specific instance of the chip using that pin controller, see more comments on patch #4.

Ack. It turned out that the pin controller is not strictly need for a bare minimum support of sd card booting, so it will be drop in patchset V2. A future patchset will re-introduce it when needed.

Many thanks,
Andrea

Quoted 2 lines
Signature · 1 line
Florian
#7 lore raw

PATCH 2/6 dt-bindings: mmc: Add support for BCM2712 SD host controller

In reply to Andrea della Porta
---
 .../bindings/mmc/brcm,sdhci-brcmstb.yaml      | 51 ++++++++++++++++++-
 1 file changed, 50 insertions(+), 1 deletion(-)
Documentation/devicetree/bindings/mmc/brcm,sdhci-brcmstb.yaml +50 -1
index cbd3d6c6c77f..6aa137d78e4f 100644
@@ -13,6 +13,7 @@ maintainers:
 properties:
   compatible:
     oneOf:
+      - const: brcm,bcm2712-sdhci
       - items:
           - enum:
               - brcm,bcm7216-sdhci
@@ -26,12 +27,16 @@ properties:
           - const: brcm,sdhci-brcmstb
 
   reg:
-    maxItems: 2
+    minItems: 2
+    maxItems: 4
 
   reg-names:
+    minItems: 2
     items:
       - const: host
       - const: cfg
+      - const: busisol
+      - const: lcpll
 
   interrupts:
     maxItems: 1
@@ -60,6 +65,7 @@ properties:
     description: Specifies that controller should use auto CMD12
 
 allOf:
+  - $ref: sdhci-common.yaml
   - $ref: mmc-controller.yaml#
   - if:
       properties:
@@ -71,6 +77,28 @@ allOf:
       required:
         - clock-frequency
 
+  - if:
+      properties:
+        compatible:
+          contains:
+            const: brcm,bcm2712-sdhci
+
+    then:
+      properties:
+        reg:
+          maxItems: 4
+        clock-names:
+         const: "sw_sdio"
+
+    else:
+      properties:
+        reg:
+          minItems: 2
+          maxItems: 2
+        reg-names:
+          minItems: 2
+          maxItems: 2
+
 required:
   - compatible
   - reg
@@ -114,3 +142,24 @@ examples:
       clocks = <&scmi_clk 245>;
       clock-names = "sw_sdio";
     };
+
+  - |
+    soc {
+      #address-cells = <2>;
+      #size-cells = <2>;
+
+      mmc@fff000 {
+        compatible = "brcm,bcm2712-sdhci";
+        reg = <0x10 0x00fff000  0x0 0x260>,
+              <0x10 0x00fff400  0x0 0x200>,
+              <0x10 0x015040b0  0x0 0x4>,  // Bus isolation control
+              <0x10 0x015200f0  0x0 0x24>; // LCPLL control misc0-8
+        reg-names = "host", "cfg", "busisol", "lcpll";
+        interrupts = <0x0 0x111 0x4>;
+        clocks = <&clk_emmc2>;
+        sdhci-caps-mask = <0x0000C000 0x0>;
+        sdhci-caps = <0x0 0x0>;
+        mmc-ddr-3_3v;
+        clock-names = "sw_sdio";
+      };
+    };
Signature · 1 line
2.35.3
maintainer
#8 lore raw

Re: [PATCH 2/6] dt-bindings: mmc: Add support for BCM2712 SD host controller

Quoted 5 lines · Andrea della Porta
---
 .../bindings/mmc/brcm,sdhci-brcmstb.yaml      | 51 ++++++++++++++++++-
 1 file changed, 50 insertions(+), 1 deletion(-)

My bot found errors running 'make dt_binding_check' on your patch:

yamllint warnings/errors:
./Documentation/devicetree/bindings/mmc/brcm,sdhci-brcmstb.yaml:91:10: [warning] wrong indentation: expected 10 but found 9 (indentation) ./Documentation/devicetree/bindings/mmc/brcm,sdhci-brcmstb.yaml:91:17: [error] string value is redundantly quoted with any quotes (quoted-strings)

dtschema/dtc warnings/errors:

doc reference errors (make refcheckdocs):

See https://patchwork.ozlabs.org/project/devicetree-bindings/patch/ad96fff723675c2d65a5e3328da9b09f2781cbcd.1713036964.git.andrea.porta@suse.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.

#9 lore raw

Re: [PATCH 2/6] dt-bindings: mmc: Add support for BCM2712 SD host controller

In reply to Andrea della Porta
Quoted 1 line · Andrea della Porta

? And what is being done here and why?

Quoted 35 lines
---
 .../bindings/mmc/brcm,sdhci-brcmstb.yaml      | 51 ++++++++++++++++++-
 1 file changed, 50 insertions(+), 1 deletion(-)
Documentation/devicetree/bindings/mmc/brcm,sdhci-brcmstb.yaml +6 -1
index cbd3d6c6c77f..6aa137d78e4f 100644
@@ -13,6 +13,7 @@ maintainers:
 properties:
   compatible:
     oneOf:
+      - const: brcm,bcm2712-sdhci
       - items:
           - enum:
               - brcm,bcm7216-sdhci
@@ -26,12 +27,16 @@ properties:
           - const: brcm,sdhci-brcmstb
 
   reg:
-    maxItems: 2
+    minItems: 2
+    maxItems: 4
 
   reg-names:
+    minItems: 2
     items:
       - const: host
       - const: cfg
+      - const: busisol
+      - const: lcpll
 
   interrupts:
     maxItems: 1

Documentation/devicetree/bindings/mmc/brcm,sdhci-brcmstb.yaml properties: · line 69

Quoted 5 lines
Documentation/devicetree/bindings/mmc/brcm,sdhci-brcmstb.yaml +1 -0
@@ -60,6 +65,7 @@ properties:
     description: Specifies that controller should use auto CMD12
 
 allOf:
+  - $ref: sdhci-common.yaml
   - $ref: mmc-controller.yaml#

Why? Anyway, this replaces mmc-controller, doesn't it?

Quoted 8 lines
Documentation/devicetree/bindings/mmc/brcm,sdhci-brcmstb.yaml +2 -0
   - if:
       properties:
@@ -71,6 +77,28 @@ allOf:
       required:
         - clock-frequency
 
+  - if:
+      properties:

Documentation/devicetree/bindings/mmc/brcm,sdhci-brcmstb.yaml allOf: · line 91

Quoted 10 lines
Documentation/devicetree/bindings/mmc/brcm,sdhci-brcmstb.yaml +10 -0
+        compatible:
+          contains:
+            const: brcm,bcm2712-sdhci
+
+    then:
+      properties:
+        reg:
+          maxItems: 4
+        clock-names:
+         const: "sw_sdio"

Not tested.

Quoted 21 lines
Documentation/devicetree/bindings/mmc/brcm,sdhci-brcmstb.yaml +14 -0
+
+    else:
+      properties:
+        reg:
+          minItems: 2
+          maxItems: 2
+        reg-names:
+          minItems: 2
+          maxItems: 2
+
 required:
   - compatible
   - reg
@@ -114,3 +142,24 @@ examples:
       clocks = <&scmi_clk 245>;
       clock-names = "sw_sdio";
     };
+
+  - |
+    soc {
+      #address-cells = <2>;

Documentation/devicetree/bindings/mmc/brcm,sdhci-brcmstb.yaml examples: · line 158

Quoted 10 lines
Documentation/devicetree/bindings/mmc/brcm,sdhci-brcmstb.yaml +10 -0
+      #size-cells = <2>;
+
+      mmc@fff000 {
+        compatible = "brcm,bcm2712-sdhci";
+        reg = <0x10 0x00fff000  0x0 0x260>,
+              <0x10 0x00fff400  0x0 0x200>,
+              <0x10 0x015040b0  0x0 0x4>,  // Bus isolation control
+              <0x10 0x015200f0  0x0 0x24>; // LCPLL control misc0-8
+        reg-names = "host", "cfg", "busisol", "lcpll";
+        interrupts = <0x0 0x111 0x4>;

Use proper defines.

Documentation/devicetree/bindings/mmc/brcm,sdhci-brcmstb.yaml examples: · line 163

Quoted 5 lines
Documentation/devicetree/bindings/mmc/brcm,sdhci-brcmstb.yaml +5 -0
+        clocks = <&clk_emmc2>;
+        sdhci-caps-mask = <0x0000C000 0x0>;
+        sdhci-caps = <0x0 0x0>;
+        mmc-ddr-3_3v;
+        clock-names = "sw_sdio";

names *always* follow property. In every DTS. Please fix youro DTS.

Best regards,
Krzysztof

maintainer
#10 lore raw

Re: [PATCH 2/6] dt-bindings: mmc: Add support for BCM2712 SD host controller

In reply to Andrea della Porta
Quoted 77 lines · Andrea della Porta
---
  .../bindings/mmc/brcm,sdhci-brcmstb.yaml      | 51 ++++++++++++++++++-
  1 file changed, 50 insertions(+), 1 deletion(-)
Documentation/devicetree/bindings/mmc/brcm,sdhci-brcmstb.yaml +30 -1
index cbd3d6c6c77f..6aa137d78e4f 100644
@@ -13,6 +13,7 @@ maintainers:
  properties:
    compatible:
      oneOf:
+      - const: brcm,bcm2712-sdhci
        - items:
            - enum:
                - brcm,bcm7216-sdhci
@@ -26,12 +27,16 @@ properties:
            - const: brcm,sdhci-brcmstb
 
    reg:
-    maxItems: 2
+    minItems: 2
+    maxItems: 4
 
    reg-names:
+    minItems: 2
      items:
        - const: host
        - const: cfg
+      - const: busisol
+      - const: lcpll
 
    interrupts:
      maxItems: 1
@@ -60,6 +65,7 @@ properties:
      description: Specifies that controller should use auto CMD12
 
  allOf:
+  - $ref: sdhci-common.yaml
    - $ref: mmc-controller.yaml#
    - if:
        properties:
@@ -71,6 +77,28 @@ allOf:
        required:
          - clock-frequency
 
+  - if:
+      properties:
+        compatible:
+          contains:
+            const: brcm,bcm2712-sdhci
+
+    then:
+      properties:
+        reg:
+          maxItems: 4
+        clock-names:
+         const: "sw_sdio"
+
+    else:
+      properties:
+        reg:
+          minItems: 2
+          maxItems: 2
+        reg-names:
+          minItems: 2
+          maxItems: 2
+
  required:
    - compatible
    - reg
@@ -114,3 +142,24 @@ examples:
        clocks = <&scmi_clk 245>;
        clock-names = "sw_sdio";
      };
+

Documentation/devicetree/bindings/mmc/brcm,sdhci-brcmstb.yaml examples: · line 155

Quoted 10 lines
Documentation/devicetree/bindings/mmc/brcm,sdhci-brcmstb.yaml +10 -0
+  - |
+    soc {
+      #address-cells = <2>;
+      #size-cells = <2>;
+
+      mmc@fff000 {
+        compatible = "brcm,bcm2712-sdhci";
+        reg = <0x10 0x00fff000  0x0 0x260>,
+              <0x10 0x00fff400  0x0 0x200>,
+              <0x10 0x015040b0  0x0 0x4>,  // Bus isolation control

That should be a syscon, not under direct management of the driver because there are other bits in that register that are relevant here.

Documentation/devicetree/bindings/mmc/brcm,sdhci-brcmstb.yaml examples: · line 156

Quoted 1 line
Documentation/devicetree/bindings/mmc/brcm,sdhci-brcmstb.yaml +1 -0
+              <0x10 0x015200f0  0x0 0x24>; // LCPLL control misc0-8

And likewise, this should be a clock provider, or the firmware could add support for configuring the LCPLL since there are other things going on there.

Signature · 1 line
Florian
#11 lore raw

PATCH 3/6 arm64: dts: broadcom: Add support for BCM2712

In reply to Andrea della Porta
---
 arch/arm64/boot/dts/broadcom/Makefile         |   1 +
 .../boot/dts/broadcom/bcm2712-rpi-5-b.dts     | 313 +++++++
 arch/arm64/boot/dts/broadcom/bcm2712-rpi.dtsi |  81 ++
 arch/arm64/boot/dts/broadcom/bcm2712.dtsi     | 841 ++++++++++++++++++
 4 files changed, 1236 insertions(+)
 create mode 100644 arch/arm64/boot/dts/broadcom/bcm2712-rpi-5-b.dts
 create mode 100644 arch/arm64/boot/dts/broadcom/bcm2712-rpi.dtsi
 create mode 100644 arch/arm64/boot/dts/broadcom/bcm2712.dtsi
arch/arm64/boot/dts/broadcom/Makefile +1 -0
index 8b4591ddd27c..92565e9781ad 100644
@@ -6,6 +6,7 @@ DTC_FLAGS := -@
 dtb-$(CONFIG_ARCH_BCM2835) += bcm2711-rpi-400.dtb \
 			      bcm2711-rpi-4-b.dtb \
 			      bcm2711-rpi-cm4-io.dtb \
+			      bcm2712-rpi-5-b.dtb \
 			      bcm2837-rpi-3-a-plus.dtb \
 			      bcm2837-rpi-3-b.dtb \
 			      bcm2837-rpi-3-b-plus.dtb \
arch/arm64/boot/dts/broadcom/bcm2712-rpi-5-b.dts new file +313 -0

313 lines not on this page · raw message

arch/arm64/boot/dts/broadcom/bcm2712-rpi.dtsi new file +81 -0

81 lines not on this page · raw message

arch/arm64/boot/dts/broadcom/bcm2712.dtsi new file +841 -0

841 lines not on this page · raw message

Signature · 1 line
2.35.3
#12 lore raw

Re: [PATCH 3/6] arm64: dts: broadcom: Add support for BCM2712

Quoted 37 lines · Andrea della Porta
---
 arch/arm64/boot/dts/broadcom/Makefile         |   1 +
 .../boot/dts/broadcom/bcm2712-rpi-5-b.dts     | 313 +++++++
 arch/arm64/boot/dts/broadcom/bcm2712-rpi.dtsi |  81 ++
 arch/arm64/boot/dts/broadcom/bcm2712.dtsi     | 841 ++++++++++++++++++
 4 files changed, 1236 insertions(+)
 create mode 100644 arch/arm64/boot/dts/broadcom/bcm2712-rpi-5-b.dts
 create mode 100644 arch/arm64/boot/dts/broadcom/bcm2712-rpi.dtsi
 create mode 100644 arch/arm64/boot/dts/broadcom/bcm2712.dtsi
arch/arm64/boot/dts/broadcom/Makefile +1 -0
index 8b4591ddd27c..92565e9781ad 100644
@@ -6,6 +6,7 @@ DTC_FLAGS := -@
 dtb-$(CONFIG_ARCH_BCM2835) += bcm2711-rpi-400.dtb \
 			      bcm2711-rpi-4-b.dtb \
 			      bcm2711-rpi-cm4-io.dtb \
+			      bcm2712-rpi-5-b.dtb \
 			      bcm2837-rpi-3-a-plus.dtb \
 			      bcm2837-rpi-3-b.dtb \
 			      bcm2837-rpi-3-b-plus.dtb \
arch/arm64/boot/dts/broadcom/bcm2712-rpi-5-b.dts new file +8 -0
new file mode 100644
index 000000000000..2ce180a54e5b
@@ -0,0 +1,313 @@
+// SPDX-License-Identifier: GPL-2.0
+/dts-v1/;
+
+#include <dt-bindings/gpio/gpio.h>
+#include <dt-bindings/interrupt-controller/irq.h>
+#include <dt-bindings/pwm/pwm.h>
+#include <dt-bindings/reset/raspberrypi,firmware-reset.h>
+

arch/arm64/boot/dts/broadcom/bcm2712-rpi-5-b.dts line 18

Quoted 10 lines
arch/arm64/boot/dts/broadcom/bcm2712-rpi-5-b.dts new file +10 -0
+#define spi0 _spi0
+#define uart0 _uart0
+
+#include "bcm2712.dtsi"
+
+#undef spi0
+#undef uart0
+
+/ {
+	compatible = "raspberrypi,5-model-b", "brcm,bcm2712";

This patch did not pass basic tests. Like checkpatch.

Please run scripts/checkpatch.pl and fix reported warnings. Then please run scripts/checkpatch.pl --strict and (probably) fix more warnings. Some warnings can be ignored, especially from --strict run, but the code here looks like it needs a fix. Feel free to get in touch if the warning is not clear.

It does not look like you tested the DTS against bindings. Please run make dtbs_check W=1 (see Documentation/devicetree/bindings/writing-schema.rst or
https://www.linaro.org/blog/tips-and-tricks-for-validating-devicetree-sources-with-the-devicetree-schema/
for instructions).

Quoted 10 lines
arch/arm64/boot/dts/broadcom/bcm2712-rpi-5-b.dts new file +10 -0
+	model = "Raspberry Pi 5";
+
+	/* Will be filled by the bootloader */
+	memory@0 {
+		device_type = "memory";
+		reg = <0 0 0x28000000>;
+	};
+
+	leds: leds {
+		compatible = "gpio-leds";

arch/arm64/boot/dts/broadcom/bcm2712-rpi-5-b.dts line 38

Quoted 10 lines
arch/arm64/boot/dts/broadcom/bcm2712-rpi-5-b.dts new file +10 -0
+
+		led_act: led-act {
+			label = "ACT";
+			gpios = <&gio_aon 9 GPIO_ACTIVE_LOW>;
+			default-state = "off";
+			linux,default-trigger = "mmc0";
+		};
+	};
+
+	sd_io_1v8_reg: sd_io_1v8_reg {

Don't push to us downstream code. Please fix it first and adjust to match DTS coding style. Underscores are not allowed in node names.

arch/arm64/boot/dts/broadcom/bcm2712-rpi-5-b.dts line 48

Quoted 10 lines
arch/arm64/boot/dts/broadcom/bcm2712-rpi-5-b.dts new file +10 -0
+		compatible = "regulator-gpio";
+		regulator-name = "vdd-sd-io";
+		regulator-min-microvolt = <1800000>;
+		regulator-max-microvolt = <3300000>;
+		regulator-boot-on;
+		regulator-always-on;
+		regulator-settling-time-us = <5000>;
+		gpios = <&gio_aon 3 GPIO_ACTIVE_HIGH>;
+		states = <1800000 0x1
+			  3300000 0x0>;

Aren't these two tupples?

arch/arm64/boot/dts/broadcom/bcm2712-rpi-5-b.dts line 49

Quoted 1 line
arch/arm64/boot/dts/broadcom/bcm2712-rpi-5-b.dts new file +1 -0
+		status = "okay";

Why? Where is it disabled?

arch/arm64/boot/dts/broadcom/bcm2712-rpi-5-b.dts line 52

Quoted 3 lines
arch/arm64/boot/dts/broadcom/bcm2712-rpi-5-b.dts new file +3 -0
+	};
+
+	sd_vcc_reg: sd_vcc_reg {

Underscores...

arch/arm64/boot/dts/broadcom/bcm2712-rpi-5-b.dts line 60

Quoted 8 lines
arch/arm64/boot/dts/broadcom/bcm2712-rpi-5-b.dts new file +8 -0
+		compatible = "regulator-fixed";
+		regulator-name = "vcc-sd";
+		regulator-min-microvolt = <3300000>;
+		regulator-max-microvolt = <3300000>;
+		regulator-boot-on;
+		enable-active-high;
+		gpios = <&gio_aon 4 GPIO_ACTIVE_HIGH>;
+		status = "okay";

Why?

Quoted 8 lines
arch/arm64/boot/dts/broadcom/bcm2712-rpi-5-b.dts new file +8 -0
+	};
+
+	wl_on_reg: wl_on_reg {
+		compatible = "regulator-fixed";
+		regulator-name = "wl-on-regulator";
+		regulator-min-microvolt = <3300000>;
+		regulator-max-microvolt = <3300000>;
+		pinctrl-0 = <&wl_on_pins>;

arch/arm64/boot/dts/broadcom/bcm2712-rpi-5-b.dts line 78

Quoted 10 lines
arch/arm64/boot/dts/broadcom/bcm2712-rpi-5-b.dts new file +10 -0
+		pinctrl-names = "default";
+
+		gpio = <&gio 28 GPIO_ACTIVE_HIGH>;
+
+		startup-delay-us = <150000>;
+		enable-active-high;
+	};
+
+	clocks: clocks {
+	};

Drop, useless.

arch/arm64/boot/dts/broadcom/bcm2712-rpi-5-b.dts line 87

Quoted 9 lines
arch/arm64/boot/dts/broadcom/bcm2712-rpi-5-b.dts new file +9 -0
+};
+
+// Add some labels to 2712 device
+
+// The system UART
+uart10: &_uart0 { status = "okay"; };
+
+// The system SPI for the bootloader EEPROM
+spi10: &_spi0 { status = "okay"; };

Use standard coding style. Look at other recent platforms how it is done.

&spi {
	foo;
};

arch/arm64/boot/dts/broadcom/bcm2712-rpi-5-b.dts line 89

Quoted 2 lines
arch/arm64/boot/dts/broadcom/bcm2712-rpi-5-b.dts new file +2 -0
+
+#include "bcm2712-rpi.dtsi"

This goes to the top.

I must say this DTS is terrible to read.

arch/arm64/boot/dts/broadcom/bcm2712-rpi-5-b.dts line 102

Quoted 13 lines
arch/arm64/boot/dts/broadcom/bcm2712-rpi-5-b.dts new file +13 -0
+
+/* SDIO1 is used to drive the SD card */
+&sdio1 {
+	pinctrl-0 = <&emmc_sd_pulls>, <&emmc_aon_cd_pins>;
+	pinctrl-names = "default";
+	vqmmc-supply = <&sd_io_1v8_reg>;
+	vmmc-supply = <&sd_vcc_reg>;
+	bus-width = <4>;
+	sd-uhs-sdr50;
+	sd-uhs-ddr50;
+	sd-uhs-sdr104;
+	cd-gpios = <&gio_aon 5 GPIO_ACTIVE_LOW>;
+	//no-1-8-v;

Do not add dead code to the kernel.

arch/arm64/boot/dts/broadcom/bcm2712-rpi-5-b.dts line 107

Quoted 5 lines
arch/arm64/boot/dts/broadcom/bcm2712-rpi-5-b.dts new file +5 -0
+	status = "okay";
+};
+
+&pinctrl_aon {
+	emmc_aon_cd_pins: emmc_aon_cd_pins {

Again, no underscores.

Quoted 26 lines
arch/arm64/boot/dts/broadcom/bcm2712-rpi-5-b.dts new file +26 -0
+		function = "sd_card_g";
+		pins = "aon_gpio5";
+		bias-pull-up;
+	};
+
+	/* Slight hack - only one PWM pin (status LED) is usable */
+	aon_pwm_1pin: aon_pwm_1pin {
+		function = "aon_pwm";
+		pins = "aon_gpio9";
+	};
+};
+
+&pinctrl {
+	pwr_button_pins: pwr_button_pins {
+		function = "gpio";
+		pins = "gpio20";
+		bias-pull-up;
+	};
+
+	wl_on_pins: wl_on_pins {
+		function = "gpio";
+		pins = "gpio28";
+	};
+
+	bt_shutdown_pins: bt_shutdown_pins {
+		function = "gpio";

arch/arm64/boot/dts/broadcom/bcm2712-rpi-5-b.dts line 143

Quoted 10 lines
arch/arm64/boot/dts/broadcom/bcm2712-rpi-5-b.dts new file +10 -0
+		pins = "gpio29";
+	};
+
+	emmc_sd_pulls: emmc_sd_pulls {
+		pins = "emmc_cmd", "emmc_dat0", "emmc_dat1", "emmc_dat2", "emmc_dat3";
+		bias-pull-up;
+	};
+};
+
+/ {

Why the heck this appears in the middle? This is top level section. I am sorry, but this DTS looks really poor and not like existing coding style. Please do not introduce some entirely different coding styles.

arch/arm64/boot/dts/broadcom/bcm2712-rpi-5-b.dts line 145

Quoted 2 lines
arch/arm64/boot/dts/broadcom/bcm2712-rpi-5-b.dts new file +2 -0
+	chosen: chosen {
+		bootargs = "reboot=w coherent_pool=1M 8250.nr_uarts=1 pci=pcie_bus_safe snd_bcm2835.enable_compat_alsa=0 snd_bcm2835.enable_hdmi=1";

Not a DTS properties. Drop entire bootargs.

arch/arm64/boot/dts/broadcom/bcm2712-rpi-5-b.dts line 149

Quoted 4 lines
arch/arm64/boot/dts/broadcom/bcm2712-rpi-5-b.dts new file +4 -0
+		stdout-path = "serial10:115200n8";
+	};
+
+	pwr_button {

Srsly...

arch/arm64/boot/dts/broadcom/bcm2712-rpi-5-b.dts line 154

Quoted 5 lines
arch/arm64/boot/dts/broadcom/bcm2712-rpi-5-b.dts new file +5 -0
+		compatible = "gpio-keys";
+
+		pinctrl-names = "default";
+		pinctrl-0 = <&pwr_button_pins>;
+		status = "okay";

???

arch/arm64/boot/dts/broadcom/bcm2712-rpi-5-b.dts line 156

Quoted 2 lines
arch/arm64/boot/dts/broadcom/bcm2712-rpi-5-b.dts new file +2 -0
+
+		pwr_key: pwr {

OK, you definitely did not test it. The code looks worse and worse I keep looking, so I will stop.

This did not pass basic internal review, checkpatch, basic tests.

...

Quoted 4 lines
arch/arm64/boot/dts/broadcom/bcm2712-rpi-5-b.dts new file +4 -0
+
+		// Pad bank0 out to 32 entries
+		"", "", "", "", "", "", "", "", "", "", "", "", "", "", "",
+

arch/arm64/boot/dts/broadcom/bcm2712-rpi-5-b.dts line 291

Quoted 10 lines
arch/arm64/boot/dts/broadcom/bcm2712-rpi-5-b.dts new file +10 -0
+		"HDMI0_SCL", // AON_SGPIO_00
+		"HDMI0_SDA", // AON_SGPIO_01
+		"HDMI1_SCL", // AON_SGPIO_02
+		"HDMI1_SDA", // AON_SGPIO_03
+		"PMIC_SCL", // AON_SGPIO_04
+		"PMIC_SDA"; // AON_SGPIO_05
+};
+
+/ {
+	aliases {

OK, now you are trolling us. It is third top-level node!

Limited review follows.

Quoted 4 lines
arch/arm64/boot/dts/broadcom/bcm2712-rpi-5-b.dts new file +4 -0
+		blconfig = &blconfig;
+		blpubkey = &blpubkey;
+		console = &uart10;
+		mailbox = &mailbox;

arch/arm64/boot/dts/broadcom/bcm2712-rpi-5-b.dts line 305

Quoted 10 lines
arch/arm64/boot/dts/broadcom/bcm2712-rpi-5-b.dts new file +10 -0
+		mmc0 = &sdio1;
+		uart10 = &uart10;
+		serial10 = &uart10;
+		gpio1 = &gio;
+		gpio2 = &gio_aon;
+		gpio3 = &pinctrl;
+		gpio4 = &pinctrl_aon;
+	};
+
+	__overrides__ {

?

Drop

arch/arm64/boot/dts/broadcom/bcm2712-rpi.dtsi

Quoted 13 lines
arch/arm64/boot/dts/broadcom/bcm2712-rpi-5-b.dts new file +8 -0
+		button_debounce = <&pwr_key>, "debounce-interval:0";
+		random = <&random>, "status";
+		sd_cqe = <&sdio1>, "supports-cqe?";
+		suspend = <&pwr_key>, "linux,code:0=205";
+		act_led_activelow = <&led_act>,"gpios:8";
+		act_led_trigger = <&led_act>, "linux,default-trigger";
+	};
+};
arch/arm64/boot/dts/broadcom/bcm2712-rpi.dtsi new file +0 -0
new file mode 100644
index 000000000000..d04e39b9c0b6

What is this file for?

Quoted 25 lines
arch/arm64/boot/dts/broadcom/bcm2712-rpi.dtsi new file +22 -0
@@ -0,0 +1,81 @@
+// SPDX-License-Identifier: GPL-2.0
+
+#include <dt-bindings/power/raspberrypi-power.h>
+
+&soc {
+	firmware: firmware {
+		compatible = "raspberrypi,bcm2835-firmware", "simple-mfd";
 
 
+		#address-cells = <1>;
+		#size-cells = <1>;
+
+		mboxes = <&mailbox>;
+		dma-ranges;
+
+		firmware_clocks: clocks {
+			compatible = "raspberrypi,firmware-clocks";
+			#clock-cells = <1>;
+		};
+
+		reset: reset {
+			compatible = "raspberrypi,firmware-reset";
+			#reset-cells = <1>;
+		};

arch/arm64/boot/dts/broadcom/bcm2712-rpi.dtsi line 32

Quoted 10 lines
arch/arm64/boot/dts/broadcom/bcm2712-rpi.dtsi new file +10 -0
+	};
+
+	power: power {
+		compatible = "raspberrypi,bcm2835-power";
+		firmware = <&firmware>;
+		#power-domain-cells = <1>;
+	};
+
+	/* Define these notional regulators for use by overlays, etc. */
+	vdd_3v3_reg: fixedregulator_3v3 {

W=2 warnings.

arch/arm64/boot/dts/broadcom/bcm2712-rpi.dtsi line 40

Quoted 8 lines
arch/arm64/boot/dts/broadcom/bcm2712-rpi.dtsi new file +8 -0
+		compatible = "regulator-fixed";
+		regulator-always-on;
+		regulator-max-microvolt = <3300000>;
+		regulator-min-microvolt = <3300000>;
+		regulator-name = "3v3";
+	};
+
+	vdd_5v0_reg: fixedregulator_5v0 {

W=2 warnings.

arch/arm64/boot/dts/broadcom/bcm2712-rpi.dtsi line 51

Quoted 11 lines
arch/arm64/boot/dts/broadcom/bcm2712-rpi.dtsi new file +11 -0
+		compatible = "regulator-fixed";
+		regulator-always-on;
+		regulator-max-microvolt = <5000000>;
+		regulator-min-microvolt = <5000000>;
+		regulator-name = "5v0";
+	};
+};
+
+/ {
+	__overrides__ {
+		arm_freq;

NAK, drop.

Quoted 36 lines
arch/arm64/boot/dts/broadcom/bcm2712-rpi.dtsi new file +30 -0
+	};
+};
+
+&rmem {
+	/*
+	 * RPi5's co-processor will copy the board's bootloader configuration
+	 * into memory for the OS to consume. It'll also update this node with
+	 * its placement information.
+	 */
+	blconfig: nvram@0 {
+		compatible = "raspberrypi,bootloader-config", "nvmem-rmem";
+		#address-cells = <1>;
+		#size-cells = <1>;
+		reg = <0x0 0x0 0x0>;
+		no-map;
+		status = "disabled";
+	};
+	/*
+	 * RPi5 will copy the binary public key blob (if present) from the bootloader
+	 * into memory for use by the OS.
+	 */
+	blpubkey: nvram@1 {
+		compatible = "raspberrypi,bootloader-public-key", "nvmem-rmem";
+		#address-cells = <1>;
+		#size-cells = <1>;
+		reg = <0x0 0x0 0x0>;
+		no-map;
+		status = "disabled";
+	};
+};
arch/arm64/boot/dts/broadcom/bcm2712.dtsi new file +0 -0
new file mode 100644
index 000000000000..fd5a19f68b49

arch/arm64/boot/dts/broadcom/bcm2712.dtsi line 7

Quoted 7 lines
arch/arm64/boot/dts/broadcom/bcm2712.dtsi new file +7 -0
@@ -0,0 +1,841 @@
+// SPDX-License-Identifier: GPL-2.0
+#include <dt-bindings/interrupt-controller/arm-gic.h>
+#include <dt-bindings/soc/bcm2835-pm.h>
+#include <dt-bindings/phy/phy.h>
+
+/ {
+	compatible = "brcm,bcm2712", "brcm,bcm2711";

Please run scripts/checkpatch.pl and fix reported warnings. Then please run scripts/checkpatch.pl --strict and (probably) fix more warnings. Some warnings can be ignored, especially from --strict run, but the code here looks like it needs a fix. Feel free to get in touch if the warning is not clear.

arch/arm64/boot/dts/broadcom/bcm2712.dtsi line 8

Quoted 1 line
arch/arm64/boot/dts/broadcom/bcm2712.dtsi new file +1 -0
+	model = "BCM2712";

Drop

arch/arm64/boot/dts/broadcom/bcm2712.dtsi line 61

Quoted 2 lines
arch/arm64/boot/dts/broadcom/bcm2712.dtsi new file +2 -0
+
+	clk_27MHz: clk-27M {

No upperscore letters.

Quoted 52 lines
arch/arm64/boot/dts/broadcom/bcm2712.dtsi new file +52 -0
+		#clock-cells = <0>;
+		compatible = "fixed-clock";
+		clock-frequency = <27000000>;
+		clock-output-names = "27MHz-clock";
+	};
+
+	clk_108MHz: clk-108M {
+		#clock-cells = <0>;
+		compatible = "fixed-clock";
+		clock-frequency = <108000000>;
+		clock-output-names = "108MHz-clock";
+	};
+
+	soc: soc {
+		compatible = "simple-bus";
+		#address-cells = <1>;
+		#size-cells = <1>;
+
+		ranges     = <0x7c000000  0x10 0x7c000000  0x04000000>;
+		/* Emulate a contiguous 30-bit address range for DMA */
+		dma-ranges = <0xc0000000  0x00 0x00000000  0x40000000>,
+			     <0x7c000000  0x10 0x7c000000  0x04000000>;
+
+		system_timer: timer@7c003000 {
+			compatible = "brcm,bcm2835-system-timer";
+			reg = <0x7c003000 0x1000>;
+			interrupts = <GIC_SPI 64 IRQ_TYPE_LEVEL_HIGH>,
+				     <GIC_SPI 65 IRQ_TYPE_LEVEL_HIGH>,
+		     		     <GIC_SPI 66 IRQ_TYPE_LEVEL_HIGH>,
+		     		     <GIC_SPI 67 IRQ_TYPE_LEVEL_HIGH>;
+			clock-frequency = <1000000>;
+		};
+
+		mailbox: mailbox@7c013880 {
+			compatible = "brcm,bcm2835-mbox";
+			reg = <0x7c013880 0x40>;
+			interrupts = <GIC_SPI 33 IRQ_TYPE_LEVEL_HIGH>;
+			#mbox-cells = <0>;
+		};
+
+		disp_intr: interrupt-controller@7c502000 {
+			compatible = "brcm,bcm2711-l2-intc", "brcm,l2-intc";
+			reg = <0x7c502000 0x30>;
+			interrupts = <GIC_SPI 97 IRQ_TYPE_LEVEL_HIGH>;
+			interrupt-controller;
+			#interrupt-cells = <1>;
+			status = "disabled";
+		};
+
+		dvp: clock@7c700000 {
+			compatible = "brcm,brcm2711-dvp";
+			reg = <0x7c700000 0x10>;

arch/arm64/boot/dts/broadcom/bcm2712.dtsi line 123

Quoted 10 lines
arch/arm64/boot/dts/broadcom/bcm2712.dtsi new file +10 -0
+			clocks = <&clk_108MHz>;
+			#clock-cells = <1>;
+			#reset-cells = <1>;
+		};
+
+		/*
+		 * This node is the provider for the enable-method for
+		 * bringing up secondary cores.
+		 */
+		local_intc: local_intc@7cd00000 {

You really need to clean this up...

Quoted 31 lines
arch/arm64/boot/dts/broadcom/bcm2712.dtsi new file +31 -0
+			compatible = "brcm,bcm2836-l1-intc";
+			reg = <0x7cd00000 0x100>;
+		};
+
+		uart0: serial@7d001000 {
+			compatible = "arm,pl011", "arm,primecell";
+			reg = <0x7d001000 0x200>;
+			interrupts = <GIC_SPI 121 IRQ_TYPE_LEVEL_HIGH>;
+			clocks = <&clk_uart>,
+				 <&clk_vpu>;
+			clock-names = "uartclk", "apb_pclk";
+			arm,primecell-periphid = <0x00241011>;
+			status = "disabled";
+		};
+
+		uart2: serial@7d001400 {
+			compatible = "arm,pl011", "arm,primecell";
+			reg = <0x7d001400 0x200>;
+			interrupts = <GIC_SPI 121 IRQ_TYPE_LEVEL_HIGH>;
+			clocks = <&clk_uart>,
+				 <&clk_vpu>;
+			clock-names = "uartclk", "apb_pclk";
+			arm,primecell-periphid = <0x00241011>;
+			status = "disabled";
+		};
+
+		uart5: serial@7d001a00 {
+			compatible = "arm,pl011", "arm,primecell";
+			reg = <0x7d001a00 0x200>;
+			interrupts = <GIC_SPI 121 IRQ_TYPE_LEVEL_HIGH>;
+			clocks = <&clk_uart>,

arch/arm64/boot/dts/broadcom/bcm2712.dtsi line 164

Quoted 10 lines
arch/arm64/boot/dts/broadcom/bcm2712.dtsi new file +10 -0
+				 <&clk_vpu>;
+			clock-names = "uartclk", "apb_pclk";
+			arm,primecell-periphid = <0x00241011>;
+			status = "disabled";
+		};
+
+		sdhost: mmc@7d002000 {
+			compatible = "brcm,bcm2835-sdhost";
+			reg = <0x7d002000 0x100>;
+			//interrupts = <GIC_SPI 120 IRQ_TYPE_LEVEL_HIGH>;

No dead code.

...

arch/arm64/boot/dts/broadcom/bcm2712.dtsi line 319

Quoted 5 lines
arch/arm64/boot/dts/broadcom/bcm2712.dtsi new file +5 -0
+
+		random: rng@7d208000 {
+			compatible = "brcm,bcm2711-rng200";
+			reg = <0x7d208000 0x28>;
+			status = "okay";

Drop.

I just ignored the rest. Quality does not improve. This DTS is in very poor shape and not suitable for mainline submission.

Please very carefully read DTS coding style and send DTS only after fixing all automation errors (all! so checkpatch, W=1, dtbs_check W=1) and after aligning this in 100% to DTS coding style.

Best regards,
Krzysztof

#14 lore raw

Re: [PATCH 3/6] arm64: dts: broadcom: Add support for BCM2712

Quoted 6 lines · Florian Fainelli
Quoted 1 line · Andrea della Porta

No commit message given the amount of lines changed?

Ack. Patchset V2 will have a commit message.

Quoted 3 lines

Please split this patch into multiple series that add basic 2712 support to the mainline kernel.

Please, can you elaborate a bit further on this?

Many thanks,
Andrea

Quoted 2 lines
Signature · 1 line
Florian
#15 lore raw

Re: [PATCH 3/6] arm64: dts: broadcom: Add support for BCM2712

In reply to Andrea della Porta

Hi Phil,

Am 14.04.24 um 00:14 schrieb Andrea della Porta:

Quoted 40 lines
---
  arch/arm64/boot/dts/broadcom/Makefile         |   1 +
  .../boot/dts/broadcom/bcm2712-rpi-5-b.dts     | 313 +++++++
  arch/arm64/boot/dts/broadcom/bcm2712-rpi.dtsi |  81 ++
  arch/arm64/boot/dts/broadcom/bcm2712.dtsi     | 841 ++++++++++++++++++
  4 files changed, 1236 insertions(+)

create mode 100644 arch/arm64/boot/dts/broadcom/bcm2712-rpi-5-b.dts create mode 100644 arch/arm64/boot/dts/broadcom/bcm2712-rpi.dtsi create mode 100644 arch/arm64/boot/dts/broadcom/bcm2712.dtsi

arch/arm64/boot/dts/broadcom/Makefile +1 -0
index 8b4591ddd27c..92565e9781ad 100644
@@ -6,6 +6,7 @@ DTC_FLAGS := -@
  dtb-$(CONFIG_ARCH_BCM2835) += bcm2711-rpi-400.dtb \
  			      bcm2711-rpi-4-b.dtb \
  			      bcm2711-rpi-cm4-io.dtb \
+			      bcm2712-rpi-5-b.dtb \
  			      bcm2837-rpi-3-a-plus.dtb \
  			      bcm2837-rpi-3-b.dtb \
  			      bcm2837-rpi-3-b-plus.dtb \
arch/arm64/boot/dts/broadcom/bcm2712-rpi-5-b.dts new file +10 -0
new file mode 100644
index 000000000000..2ce180a54e5b
@@ -0,0 +1,313 @@
+// SPDX-License-Identifier: GPL-2.0
+/dts-v1/;
+
+#include <dt-bindings/gpio/gpio.h>
+#include <dt-bindings/interrupt-controller/irq.h>
+#include <dt-bindings/pwm/pwm.h>
+#include <dt-bindings/reset/raspberrypi,firmware-reset.h>
+
+#define spi0 _spi0
+#define uart0 _uart0

arch/arm64/boot/dts/broadcom/bcm2712-rpi-5-b.dts line 20

Quoted 10 lines
arch/arm64/boot/dts/broadcom/bcm2712-rpi-5-b.dts new file +10 -0
+
+#include "bcm2712.dtsi"
+
+#undef spi0
+#undef uart0
+
+/ {
+	compatible = "raspberrypi,5-model-b", "brcm,bcm2712";
+	model = "Raspberry Pi 5";
+

according to this downstream commit [1] it's just called "Raspberry Pi 5" without Model B, but the filename and the compatible says something different. Is there still a chance to get this consistent or is it too late because the firmware expect the compatible?

[1] -
https://github.com/raspberrypi/linux/commit/99e359d2f2da2c820fd2a30b1ad08b32c9549adb

#16 lore raw

Re: [PATCH 3/6] arm64: dts: broadcom: Add support for BCM2712

Stefan,

Quoted 59 lines · Stefan Wahren

Hi Phil,

Am 14.04.24 um 00:14 schrieb Andrea della Porta:

Quoted 40 lines
---
  arch/arm64/boot/dts/broadcom/Makefile         |   1 +
  .../boot/dts/broadcom/bcm2712-rpi-5-b.dts     | 313 +++++++
  arch/arm64/boot/dts/broadcom/bcm2712-rpi.dtsi |  81 ++
  arch/arm64/boot/dts/broadcom/bcm2712.dtsi     | 841 ++++++++++++++++++
  4 files changed, 1236 insertions(+)

create mode 100644 arch/arm64/boot/dts/broadcom/bcm2712-rpi-5-b.dts create mode 100644 arch/arm64/boot/dts/broadcom/bcm2712-rpi.dtsi create mode 100644 arch/arm64/boot/dts/broadcom/bcm2712.dtsi

arch/arm64/boot/dts/broadcom/Makefile +1 -0
index 8b4591ddd27c..92565e9781ad 100644
@@ -6,6 +6,7 @@ DTC_FLAGS := -@
  dtb-$(CONFIG_ARCH_BCM2835) += bcm2711-rpi-400.dtb \
                            bcm2711-rpi-4-b.dtb \
                            bcm2711-rpi-cm4-io.dtb \
+                           bcm2712-rpi-5-b.dtb \
                            bcm2837-rpi-3-a-plus.dtb \
                            bcm2837-rpi-3-b.dtb \
                            bcm2837-rpi-3-b-plus.dtb \
arch/arm64/boot/dts/broadcom/bcm2712-rpi-5-b.dts new file +10 -0
new file mode 100644
index 000000000000..2ce180a54e5b
@@ -0,0 +1,313 @@
+// SPDX-License-Identifier: GPL-2.0
+/dts-v1/;
+
+#include <dt-bindings/gpio/gpio.h>
+#include <dt-bindings/interrupt-controller/irq.h>
+#include <dt-bindings/pwm/pwm.h>
+#include <dt-bindings/reset/raspberrypi,firmware-reset.h>
+
+#define spi0 _spi0
+#define uart0 _uart0

arch/arm64/boot/dts/broadcom/bcm2712-rpi-5-b.dts line 20

Quoted 10 lines
arch/arm64/boot/dts/broadcom/bcm2712-rpi-5-b.dts new file +10 -0
+
+#include "bcm2712.dtsi"
+
+#undef spi0
+#undef uart0
+
+/ {
+     compatible = "raspberrypi,5-model-b", "brcm,bcm2712";
+     model = "Raspberry Pi 5";
+

according to this downstream commit [1] it's just called "Raspberry Pi 5" without Model B, but the filename and the compatible says something different. Is there still a chance to get this consistent or is it too late because the firmware expect the compatible?

Quoted 2 lines

[1] -
https://github.com/raspberrypi/linux/commit/99e359d2f2da2c820fd2a30b1ad08b32c9549adb

Nothing cares about the compatible string, but the product name was changed too late for the firmware, which expects the current DTB file name. I'm happy with the naming as it stands, since we use Pi 4 to refer to all the BCM2711-based devices, and Pi 5 can include CM5.

Phil

#17 lore raw

Re: [PATCH 3/6] arm64: dts: broadcom: Add support for BCM2712

Hi Phil,

Am 15.04.24 um 10:52 schrieb Phil Elwell:

Quoted 62 lines

Stefan,

Quoted 58 lines · Stefan Wahren

Hi Phil,

Am 14.04.24 um 00:14 schrieb Andrea della Porta:

Quoted 40 lines
---
   arch/arm64/boot/dts/broadcom/Makefile         |   1 +
   .../boot/dts/broadcom/bcm2712-rpi-5-b.dts     | 313 +++++++
   arch/arm64/boot/dts/broadcom/bcm2712-rpi.dtsi |  81 ++
   arch/arm64/boot/dts/broadcom/bcm2712.dtsi     | 841 ++++++++++++++++++
   4 files changed, 1236 insertions(+)

create mode 100644 arch/arm64/boot/dts/broadcom/bcm2712-rpi-5-b.dts create mode 100644 arch/arm64/boot/dts/broadcom/bcm2712-rpi.dtsi create mode 100644 arch/arm64/boot/dts/broadcom/bcm2712.dtsi

arch/arm64/boot/dts/broadcom/Makefile +1 -0
index 8b4591ddd27c..92565e9781ad 100644
@@ -6,6 +6,7 @@ DTC_FLAGS := -@
   dtb-$(CONFIG_ARCH_BCM2835) += bcm2711-rpi-400.dtb \
                             bcm2711-rpi-4-b.dtb \
                             bcm2711-rpi-cm4-io.dtb \
+                           bcm2712-rpi-5-b.dtb \
                             bcm2837-rpi-3-a-plus.dtb \
                             bcm2837-rpi-3-b.dtb \
                             bcm2837-rpi-3-b-plus.dtb \
arch/arm64/boot/dts/broadcom/bcm2712-rpi-5-b.dts new file +10 -0
new file mode 100644
index 000000000000..2ce180a54e5b
@@ -0,0 +1,313 @@
+// SPDX-License-Identifier: GPL-2.0
+/dts-v1/;
+
+#include <dt-bindings/gpio/gpio.h>
+#include <dt-bindings/interrupt-controller/irq.h>
+#include <dt-bindings/pwm/pwm.h>
+#include <dt-bindings/reset/raspberrypi,firmware-reset.h>
+
+#define spi0 _spi0
+#define uart0 _uart0

arch/arm64/boot/dts/broadcom/bcm2712-rpi-5-b.dts line 20

Quoted 10 lines
arch/arm64/boot/dts/broadcom/bcm2712-rpi-5-b.dts new file +10 -0
+
+#include "bcm2712.dtsi"
+
+#undef spi0
+#undef uart0
+
+/ {
+     compatible = "raspberrypi,5-model-b", "brcm,bcm2712";
+     model = "Raspberry Pi 5";
+

according to this downstream commit [1] it's just called "Raspberry Pi 5" without Model B, but the filename and the compatible says something different. Is there still a chance to get this consistent or is it too late because the firmware expect the compatible?

Quoted 5 lines
Quoted 2 lines

[1] -
https://github.com/raspberrypi/linux/commit/99e359d2f2da2c820fd2a30b1ad08b32c9549adb

Nothing cares about the compatible string, but the product name was changed too late for the firmware, which expects the current DTB file name.

should i send a pull request to address the compatible? This would avoid a little bit confusion in the upstreaming process, because devicetree/bindings/arm/bcm/bcm2835.yaml needs to be updated as well.

Best regards

Quoted 4 lines

I'm happy with the naming as it stands, since we use Pi 4 to
refer to all the BCM2711-based devices, and Pi 5 can include CM5.

Phil

#18 lore raw

Re: [PATCH 3/6] arm64: dts: broadcom: Add support for BCM2712

Stefan,

Quoted 66 lines · Stefan Wahren

Hi Phil,

Am 15.04.24 um 10:52 schrieb Phil Elwell:

Quoted 62 lines

Stefan,

Quoted 58 lines · Stefan Wahren

Hi Phil,

Am 14.04.24 um 00:14 schrieb Andrea della Porta:

Quoted 40 lines
---
   arch/arm64/boot/dts/broadcom/Makefile         |   1 +
   .../boot/dts/broadcom/bcm2712-rpi-5-b.dts     | 313 +++++++
   arch/arm64/boot/dts/broadcom/bcm2712-rpi.dtsi |  81 ++
   arch/arm64/boot/dts/broadcom/bcm2712.dtsi     | 841 ++++++++++++++++++
   4 files changed, 1236 insertions(+)

create mode 100644 arch/arm64/boot/dts/broadcom/bcm2712-rpi-5-b.dts create mode 100644 arch/arm64/boot/dts/broadcom/bcm2712-rpi.dtsi create mode 100644 arch/arm64/boot/dts/broadcom/bcm2712.dtsi

arch/arm64/boot/dts/broadcom/Makefile +1 -0
index 8b4591ddd27c..92565e9781ad 100644
@@ -6,6 +6,7 @@ DTC_FLAGS := -@
   dtb-$(CONFIG_ARCH_BCM2835) += bcm2711-rpi-400.dtb \
                             bcm2711-rpi-4-b.dtb \
                             bcm2711-rpi-cm4-io.dtb \
+                           bcm2712-rpi-5-b.dtb \
                             bcm2837-rpi-3-a-plus.dtb \
                             bcm2837-rpi-3-b.dtb \
                             bcm2837-rpi-3-b-plus.dtb \
arch/arm64/boot/dts/broadcom/bcm2712-rpi-5-b.dts new file +10 -0
new file mode 100644
index 000000000000..2ce180a54e5b
@@ -0,0 +1,313 @@
+// SPDX-License-Identifier: GPL-2.0
+/dts-v1/;
+
+#include <dt-bindings/gpio/gpio.h>
+#include <dt-bindings/interrupt-controller/irq.h>
+#include <dt-bindings/pwm/pwm.h>
+#include <dt-bindings/reset/raspberrypi,firmware-reset.h>
+
+#define spi0 _spi0
+#define uart0 _uart0

arch/arm64/boot/dts/broadcom/bcm2712-rpi-5-b.dts line 20

Quoted 10 lines
arch/arm64/boot/dts/broadcom/bcm2712-rpi-5-b.dts new file +10 -0
+
+#include "bcm2712.dtsi"
+
+#undef spi0
+#undef uart0
+
+/ {
+     compatible = "raspberrypi,5-model-b", "brcm,bcm2712";
+     model = "Raspberry Pi 5";
+

according to this downstream commit [1] it's just called "Raspberry Pi 5" without Model B, but the filename and the compatible says something different. Is there still a chance to get this consistent or is it too late because the firmware expect the compatible?

Quoted 8 lines
Quoted 5 lines
Quoted 2 lines

[1] -
https://github.com/raspberrypi/linux/commit/99e359d2f2da2c820fd2a30b1ad08b32c9549adb

Nothing cares about the compatible string, but the product name was changed too late for the firmware, which expects the current DTB file name.

should i send a pull request to address the compatible? This would avoid a little bit confusion in the upstreaming process, because devicetree/bindings/arm/bcm/bcm2835.yaml needs to be updated as well.

You think it is better to have the compatible string different to the file name, rather than just the human-readable model string being different? I don't agree.

Phil

#19 lore raw

PATCH 4/6 pinctrl: bcm: Add pinconf/pinmux controller driver for BCM2712

In reply to Andrea della Porta

Add a pincontrol driver for BCM2712. BCM2712 allows muxing GPIOs and setting configuration on pads.

---
 drivers/pinctrl/bcm/Kconfig           |    9 +
 drivers/pinctrl/bcm/Makefile          |    1 +
 drivers/pinctrl/bcm/pinctrl-bcm2712.c | 1247 +++++++++++++++++++++++++
 3 files changed, 1257 insertions(+)
 create mode 100644 drivers/pinctrl/bcm/pinctrl-bcm2712.c
drivers/pinctrl/bcm/Kconfig +9 -0
index 35b51ce4298e..62ede44460bc 100644
@@ -3,6 +3,15 @@
 # Broadcom pinctrl drivers
 #
 
+config PINCTRL_BCM2712
+	bool "Broadcom BCM2712 PINCONF driver"
+	depends on OF && (ARCH_BCM2835 || ARCH_BRCMSTB || COMPILE_TEST)
+	select PINMUX
+	select PINCONF
+	select GENERIC_PINCONF
+	help
+	  Say Y here to enable the Broadcom BCM2712 PINCONF driver.
+
 config PINCTRL_BCM281XX
 	bool "Broadcom BCM281xx pinctrl driver"
 	depends on OF && (ARCH_BCM_MOBILE || COMPILE_TEST)
drivers/pinctrl/bcm/Makefile +1 -0
index 82b868ec1471..d298e4785829 100644
@@ -1,6 +1,7 @@
 # SPDX-License-Identifier: GPL-2.0
 # Broadcom pinctrl support
 
+obj-$(CONFIG_PINCTRL_BCM2712)		+= pinctrl-bcm2712.o
 obj-$(CONFIG_PINCTRL_BCM281XX)		+= pinctrl-bcm281xx.o
 obj-$(CONFIG_PINCTRL_BCM2835)		+= pinctrl-bcm2835.o
 obj-$(CONFIG_PINCTRL_BCM4908)		+= pinctrl-bcm4908.o
drivers/pinctrl/bcm/pinctrl-bcm2712.c new file +1247 -0

1,247 lines not on this page · raw message

Signature · 1 line
2.35.3
#20 lore raw

Re: [PATCH 4/6] pinctrl: bcm: Add pinconf/pinmux controller driver for BCM2712

Le 14/04/2024 à 00:14, Andrea della Porta a écrit :

Quoted 12 lines

Add a pincontrol driver for BCM2712. BCM2712 allows muxing GPIOs and setting configuration on pads.

---
  drivers/pinctrl/bcm/Kconfig           |    9 +
  drivers/pinctrl/bcm/Makefile          |    1 +
  drivers/pinctrl/bcm/pinctrl-bcm2712.c | 1247 +++++++++++++++++++++++++
  3 files changed, 1257 insertions(+)

create mode 100644 drivers/pinctrl/bcm/pinctrl-bcm2712.c

...

drivers/pinctrl/bcm/pinctrl-bcm2712.c line 922

Quoted 6 lines
drivers/pinctrl/bcm/pinctrl-bcm2712.c new file +6 -0
+static int bcm2712_pmx_get_function_groups(struct pinctrl_dev *pctldev,
+		unsigned selector,
+		const char * const **groups,
+		unsigned * const num_groups)
+{
+	struct bcm2712_pinctrl *pc = pinctrl_dev_get_drvdata(pctldev);

Missing empty new line.

Quoted 6 lines
drivers/pinctrl/bcm/pinctrl-bcm2712.c new file +6 -0
+	/* every pin can do every function */
+	*groups = pc->gpio_groups;
+	*num_groups = pc->pctl_desc.npins;
+
+	return 0;
+}

...

Quoted 14 lines
drivers/pinctrl/bcm/pinctrl-bcm2712.c new file +14 -0
+static int bcm2712_pinconf_get(struct pinctrl_dev *pctldev,
+			unsigned pin, unsigned long *config)
+{
+	struct bcm2712_pinctrl *pc = pinctrl_dev_get_drvdata(pctldev);
+	enum pin_config_param param = pinconf_to_config_param(*config);
+	u32 arg;
+
+	switch (param) {
+	case PIN_CONFIG_BIAS_DISABLE:
+		arg = (bcm2712_pull_config_get(pc, pin) == BCM2712_PULL_NONE);
+		break;
+	case PIN_CONFIG_BIAS_PULL_DOWN:
+		arg = (bcm2712_pull_config_get(pc, pin) == BCM2712_PULL_DOWN);
+		break;

drivers/pinctrl/bcm/pinctrl-bcm2712.c line 1032

Quoted 10 lines
drivers/pinctrl/bcm/pinctrl-bcm2712.c new file +10 -0
+	case PIN_CONFIG_BIAS_PULL_UP:
+		arg = (bcm2712_pull_config_get(pc, pin) == BCM2712_PULL_UP);
+		break;
+	default:
+		return -ENOTSUPP;
+	}
+
+	*config = pinconf_to_config_packed(param, arg);
+
+	return -ENOTSUPP;

Strange.

	return 0;

?

Quoted 18 lines
drivers/pinctrl/bcm/pinctrl-bcm2712.c new file +18 -0
+}
+
+static int bcm2712_pinconf_set(struct pinctrl_dev *pctldev,
+			       unsigned int pin, unsigned long *configs,
+			       unsigned int num_configs)
+{
+	struct bcm2712_pinctrl *pc = pinctrl_dev_get_drvdata(pctldev);
+	u32 param, arg;
+	int i;
+
+	for (i = 0; i < num_configs; i++) {
+		param = pinconf_to_config_param(configs[i]);
+		arg = pinconf_to_config_argument(configs[i]);
+
+		switch (param) {
+		case PIN_CONFIG_BIAS_DISABLE:
+			bcm2712_pull_config_set(pc, pin, BCM2712_PULL_NONE);
+			break;

drivers/pinctrl/bcm/pinctrl-bcm2712.c line 1060

Quoted 10 lines
drivers/pinctrl/bcm/pinctrl-bcm2712.c new file +10 -0
+		case PIN_CONFIG_BIAS_PULL_DOWN:
+			bcm2712_pull_config_set(pc, pin, BCM2712_PULL_DOWN);
+			break;
+		case PIN_CONFIG_BIAS_PULL_UP:
+			bcm2712_pull_config_set(pc, pin, BCM2712_PULL_UP);
+			break;
+		default:
+			return -ENOTSUPP;
+		}
+	} /* for each config */

This comment is not really usefull, IMHO.

Quoted 3 lines
drivers/pinctrl/bcm/pinctrl-bcm2712.c new file +3 -0
+
+	return 0;
+}

...

Quoted 13 lines
drivers/pinctrl/bcm/pinctrl-bcm2712.c new file +13 -0
+static int bcm2712_pinctrl_probe(struct platform_device *pdev)
+{
+	struct device *dev = &pdev->dev;
+	//struct device_node *np = dev->of_node;
+	const struct bcm_plat_data *pdata;
+	//const struct of_device_id *match;
+	struct bcm2712_pinctrl *pc;
+	const char **names;
+	int num_pins, i;
+
+	pdata = device_get_match_data(&pdev->dev);
+	if (!pdata)
+		return -EINVAL;

drivers/pinctrl/bcm/pinctrl-bcm2712.c line 1211

Quoted 10 lines
drivers/pinctrl/bcm/pinctrl-bcm2712.c new file +10 -0
+
+	pc = devm_kzalloc(dev, sizeof(*pc), GFP_KERNEL);
+	if (!pc)
+		return -ENOMEM;
+
+	platform_set_drvdata(pdev, pc);
+	pc->dev = dev;
+	spin_lock_init(&pc->lock);
+
+	//pc->base = devm_of_iomap(dev, np, 0, NULL);

Any use for this commented code? (and variable declarations above)

CJ

Quoted 16 lines
drivers/pinctrl/bcm/pinctrl-bcm2712.c new file +16 -0
+	pc->base = devm_platform_ioremap_resource(pdev, 0);
+	if (WARN_ON(IS_ERR(pc->base))) {
+		//dev_err(dev, "could not get IO memory\n");
+		return PTR_ERR(pc->base);
+	}
+
+	pc->pctl_desc = *pdata->pctl_desc;
+	num_pins = pc->pctl_desc.npins;
+	names = devm_kmalloc_array(dev, num_pins, sizeof(const char *),
+				   GFP_KERNEL);
+	if (!names)
+		return -ENOMEM;
+	for (i = 0; i < num_pins; i++)
+		names[i] = pc->pctl_desc.pins[i].name;
+	pc->gpio_groups = names;
+	pc->pin_regs = pdata->pin_regs;

drivers/pinctrl/bcm/pinctrl-bcm2712.c line 1237

Quoted 10 lines
drivers/pinctrl/bcm/pinctrl-bcm2712.c new file +10 -0
+	pc->pin_funcs = pdata->pin_funcs;
+	pc->pctl_dev = devm_pinctrl_register(dev, &pc->pctl_desc, pc);
+	if (IS_ERR(pc->pctl_dev))
+		return PTR_ERR(pc->pctl_dev);
+
+	pc->gpio_range = *pdata->gpio_range;
+	pinctrl_add_gpio_range(pc->pctl_dev, &pc->gpio_range);
+
+	return 0;
+}

...

_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

#21 lore raw

Re: [PATCH 4/6] pinctrl: bcm: Add pinconf/pinmux controller driver for BCM2712

Quoted 86 lines · Christophe JAILLET

Le 14/04/2024 à 00:14, Andrea della Porta a écrit :

Quoted 12 lines

Add a pincontrol driver for BCM2712. BCM2712 allows muxing GPIOs and setting configuration on pads.

---
  drivers/pinctrl/bcm/Kconfig           |    9 +
  drivers/pinctrl/bcm/Makefile          |    1 +
  drivers/pinctrl/bcm/pinctrl-bcm2712.c | 1247 +++++++++++++++++++++++++
  3 files changed, 1257 insertions(+)

create mode 100644 drivers/pinctrl/bcm/pinctrl-bcm2712.c

...

drivers/pinctrl/bcm/pinctrl-bcm2712.c line 922

Quoted 6 lines
drivers/pinctrl/bcm/pinctrl-bcm2712.c new file +6 -0
+static int bcm2712_pmx_get_function_groups(struct pinctrl_dev *pctldev,
+		unsigned selector,
+		const char * const **groups,
+		unsigned * const num_groups)
+{
+	struct bcm2712_pinctrl *pc = pinctrl_dev_get_drvdata(pctldev);

Missing empty new line.

Quoted 6 lines
drivers/pinctrl/bcm/pinctrl-bcm2712.c new file +6 -0
+	/* every pin can do every function */
+	*groups = pc->gpio_groups;
+	*num_groups = pc->pctl_desc.npins;
+
+	return 0;
+}

...

Quoted 14 lines
drivers/pinctrl/bcm/pinctrl-bcm2712.c new file +14 -0
+static int bcm2712_pinconf_get(struct pinctrl_dev *pctldev,
+			unsigned pin, unsigned long *config)
+{
+	struct bcm2712_pinctrl *pc = pinctrl_dev_get_drvdata(pctldev);
+	enum pin_config_param param = pinconf_to_config_param(*config);
+	u32 arg;
+
+	switch (param) {
+	case PIN_CONFIG_BIAS_DISABLE:
+		arg = (bcm2712_pull_config_get(pc, pin) == BCM2712_PULL_NONE);
+		break;
+	case PIN_CONFIG_BIAS_PULL_DOWN:
+		arg = (bcm2712_pull_config_get(pc, pin) == BCM2712_PULL_DOWN);
+		break;

drivers/pinctrl/bcm/pinctrl-bcm2712.c line 1032

Quoted 10 lines
drivers/pinctrl/bcm/pinctrl-bcm2712.c new file +10 -0
+	case PIN_CONFIG_BIAS_PULL_UP:
+		arg = (bcm2712_pull_config_get(pc, pin) == BCM2712_PULL_UP);
+		break;
+	default:
+		return -ENOTSUPP;
+	}
+
+	*config = pinconf_to_config_packed(param, arg);
+
+	return -ENOTSUPP;

Strange.

	return 0;

?

Quoted 22 lines
drivers/pinctrl/bcm/pinctrl-bcm2712.c new file +22 -0
+}
+
+static int bcm2712_pinconf_set(struct pinctrl_dev *pctldev,
+			       unsigned int pin, unsigned long *configs,
+			       unsigned int num_configs)
+{
+	struct bcm2712_pinctrl *pc = pinctrl_dev_get_drvdata(pctldev);
+	u32 param, arg;
+	int i;
+
+	for (i = 0; i < num_configs; i++) {
+		param = pinconf_to_config_param(configs[i]);
+		arg = pinconf_to_config_argument(configs[i]);
+
+		switch (param) {
+		case PIN_CONFIG_BIAS_DISABLE:
+			bcm2712_pull_config_set(pc, pin, BCM2712_PULL_NONE);
+			break;
+		case PIN_CONFIG_BIAS_PULL_DOWN:
+			bcm2712_pull_config_set(pc, pin, BCM2712_PULL_DOWN);
+			break;
+		case PIN_CONFIG_BIAS_PULL_UP:
Quoted 8 lines

drivers/pinctrl/bcm/pinctrl-bcm2712.c line 1060

Quoted 6 lines
drivers/pinctrl/bcm/pinctrl-bcm2712.c new file +6 -0
+			bcm2712_pull_config_set(pc, pin, BCM2712_PULL_UP);
+			break;
+		default:
+			return -ENOTSUPP;
+		}
+	} /* for each config */

This comment is not really usefull, IMHO.

Agreed. Dropped in V2.

Quoted 24 lines
Quoted 4 lines
drivers/pinctrl/bcm/pinctrl-bcm2712.c new file +3 -0
+
+	return 0;
+}

...

Quoted 17 lines
drivers/pinctrl/bcm/pinctrl-bcm2712.c new file +17 -0
+static int bcm2712_pinctrl_probe(struct platform_device *pdev)
+{
+	struct device *dev = &pdev->dev;
+	//struct device_node *np = dev->of_node;
+	const struct bcm_plat_data *pdata;
+	//const struct of_device_id *match;
+	struct bcm2712_pinctrl *pc;
+	const char **names;
+	int num_pins, i;
+
+	pdata = device_get_match_data(&pdev->dev);
+	if (!pdata)
+		return -EINVAL;
+
+	pc = devm_kzalloc(dev, sizeof(*pc), GFP_KERNEL);
+	if (!pc)
+		return -ENOMEM;
Quoted 8 lines

drivers/pinctrl/bcm/pinctrl-bcm2712.c line 1211

Quoted 6 lines
drivers/pinctrl/bcm/pinctrl-bcm2712.c new file +6 -0
+
+	platform_set_drvdata(pdev, pc);
+	pc->dev = dev;
+	spin_lock_init(&pc->lock);
+
+	//pc->base = devm_of_iomap(dev, np, 0, NULL);

Any use for this commented code? (and variable declarations above)

No, I just forgot to drop the comment. Removed in V2.

Many thanks,
Andrea

Quoted 32 lines

CJ

Quoted 26 lines
drivers/pinctrl/bcm/pinctrl-bcm2712.c new file +26 -0
+	pc->base = devm_platform_ioremap_resource(pdev, 0);
+	if (WARN_ON(IS_ERR(pc->base))) {
+		//dev_err(dev, "could not get IO memory\n");
+		return PTR_ERR(pc->base);
+	}
+
+	pc->pctl_desc = *pdata->pctl_desc;
+	num_pins = pc->pctl_desc.npins;
+	names = devm_kmalloc_array(dev, num_pins, sizeof(const char *),
+				   GFP_KERNEL);
+	if (!names)
+		return -ENOMEM;
+	for (i = 0; i < num_pins; i++)
+		names[i] = pc->pctl_desc.pins[i].name;
+	pc->gpio_groups = names;
+	pc->pin_regs = pdata->pin_regs;
+	pc->pin_funcs = pdata->pin_funcs;
+	pc->pctl_dev = devm_pinctrl_register(dev, &pc->pctl_desc, pc);
+	if (IS_ERR(pc->pctl_dev))
+		return PTR_ERR(pc->pctl_dev);
+
+	pc->gpio_range = *pdata->gpio_range;
+	pinctrl_add_gpio_range(pc->pctl_dev, &pc->gpio_range);
+
+	return 0;
+}

...

maintainer
#22 lore raw

Re: [PATCH 4/6] pinctrl: bcm: Add pinconf/pinmux controller driver for BCM2712

In reply to Andrea della Porta
Quoted 5 lines · Andrea della Porta

Add a pincontrol driver for BCM2712. BCM2712 allows muxing GPIOs and setting configuration on pads.

Is that a new tag in a comment message? Signed-off-by maybe?

Quoted 2 lines

---

Was not pinctrl-single usable somehow that we had to go through a dedicated pinctrl driver?

Quoted 11 lines
  drivers/pinctrl/bcm/Kconfig           |    9 +
  drivers/pinctrl/bcm/Makefile          |    1 +
  drivers/pinctrl/bcm/pinctrl-bcm2712.c | 1247 +++++++++++++++++++++++++
  3 files changed, 1257 insertions(+)

create mode 100644 drivers/pinctrl/bcm/pinctrl-bcm2712.c

drivers/pinctrl/bcm/Kconfig +0 -0
index 35b51ce4298e..62ede44460bc 100644

drivers/pinctrl/bcm/Kconfig line 11

Quoted 9 lines
drivers/pinctrl/bcm/Kconfig +6 -0
@@ -3,6 +3,15 @@
  # Broadcom pinctrl drivers
  #
 
+config PINCTRL_BCM2712
+	bool "Broadcom BCM2712 PINCONF driver"
+	depends on OF && (ARCH_BCM2835 || ARCH_BRCMSTB || COMPILE_TEST)
+	select PINMUX
+	select PINCONF
+	select GENERIC_PINCONF

Rename to PINCTRL_BRCMSTB sicne this is not BCM2712 specific at all.

Quoted 11 lines
drivers/pinctrl/bcm/Kconfig +3 -0
+	help
+	  Say Y here to enable the Broadcom BCM2712 PINCONF driver.
+
  config PINCTRL_BCM281XX
  	bool "Broadcom BCM281xx pinctrl driver"
  	depends on OF && (ARCH_BCM_MOBILE || COMPILE_TEST)
drivers/pinctrl/bcm/Makefile +0 -0
index 82b868ec1471..d298e4785829 100644

drivers/pinctrl/bcm/Makefile line 4

Quoted 4 lines
drivers/pinctrl/bcm/Makefile +1 -0
@@ -1,6 +1,7 @@
  # SPDX-License-Identifier: GPL-2.0
  # Broadcom pinctrl support
 
+obj-$(CONFIG_PINCTRL_BCM2712)		+= pinctrl-bcm2712.o

Likewise.

Quoted 100 lines
drivers/pinctrl/bcm/Makefile +0 -0
  obj-$(CONFIG_PINCTRL_BCM281XX)		+= pinctrl-bcm281xx.o
  obj-$(CONFIG_PINCTRL_BCM2835)		+= pinctrl-bcm2835.o
  obj-$(CONFIG_PINCTRL_BCM4908)		+= pinctrl-bcm4908.o
drivers/pinctrl/bcm/pinctrl-bcm2712.c new file +91 -0
new file mode 100644
index 000000000000..f9359e9eff14
@@ -0,0 +1,1247 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Driver for Broadcom BCM2712 GPIO units (pinctrl only)
+ *
+ * Copyright (C) 2021-3 Raspberry Pi Ltd.
+ * Copyright (C) 2012 Chris Boot, Simon Arlott, Stephen Warren
+ *
+ * Based heavily on the BCM2835 GPIO & pinctrl driver, which was inspired by:
+ * pinctrl-nomadik.c, please see original file for copyright information
+ * pinctrl-tegra.c, please see original file for copyright information
+ */
+
+#include <linux/bitmap.h>
+#include <linux/bug.h>
+#include <linux/delay.h>
+#include <linux/device.h>
+#include <linux/err.h>
+#include <linux/io.h>
+#include <linux/init.h>
+#include <linux/interrupt.h>
+#include <linux/of_address.h>
+#include <linux/of.h>
+#include <linux/pinctrl/consumer.h>
+#include <linux/pinctrl/machine.h>
+#include <linux/pinctrl/pinconf.h>
+#include <linux/pinctrl/pinctrl.h>
+#include <linux/pinctrl/pinmux.h>
+#include <linux/pinctrl/pinconf-generic.h>
+#include <linux/platform_device.h>
+#include <linux/seq_file.h>
+#include <linux/slab.h>
+#include <linux/spinlock.h>
+#include <linux/types.h>
+
+#define MODULE_NAME "pinctrl-bcm2712"
+
+/* Register offsets */
+
+#define BCM2712_PULL_NONE	0
+#define BCM2712_PULL_DOWN	1
+#define BCM2712_PULL_UP		2
+#define BCM2712_PULL_MASK	0x3
+
+#define BCM2712_FSEL_COUNT 9
+#define BCM2712_FSEL_MASK  0xf
+
+#define FUNC(f) \
+	[func_##f] = #f
+#define PIN(i, f1, f2, f3, f4, f5, f6, f7, f8) \
+	[i] = { \
+		.funcs = { \
+			func_##f1, \
+			func_##f2, \
+			func_##f3, \
+			func_##f4, \
+			func_##f5, \
+			func_##f6, \
+			func_##f7, \
+			func_##f8, \
+		}, \
+	}
+
+#define MUX_BIT_VALID	0x8000
+#define REG_BIT_INVALID	0xffff
+
+#define BIT_TO_REG(b) (((b) >> 5) << 2)
+#define BIT_TO_SHIFT(b) ((b) & 0x1f)
+
+#define MUX_BIT(mr, mb) (MUX_BIT_VALID + ((mr)*4)*8 + (mb)*4)
+#define GPIO_REGS(n, mr, mb, pr, pb) \
+	[n] = { MUX_BIT(mr, mb), ((pr)*4)*8 + (pb)*2 }
+
+#define EMMC_REGS(n, pr, pb) \
+	[n] = { 0, ((pr)*4)*8 + (pb)*2 }
+
+#define AGPIO_REGS(n, mr, mb, pr, pb) \
+	[n] = { MUX_BIT(mr, mb), ((pr)*4)*8 + (pb)*2 }
+
+#define SGPIO_REGS(n, mr, mb) \
+	[n+32] = { MUX_BIT(mr, mb), REG_BIT_INVALID }
+
+#define GPIO_PIN(a) PINCTRL_PIN(a, "gpio" #a)
+#define AGPIO_PIN(a) PINCTRL_PIN(a, "aon_gpio" #a)
+#define SGPIO_PIN(a) PINCTRL_PIN(a+32, "aon_sgpio" #a)
+
+struct pin_regs {
+	u16 mux_bit;
+	u16 pad_bit;
+};
+
+struct bcm2712_pinctrl {

drivers/pinctrl/bcm/pinctrl-bcm2712.c line 101

Quoted 10 lines
drivers/pinctrl/bcm/pinctrl-bcm2712.c new file +10 -0
+	struct device *dev;
+	void __iomem *base;
+	struct pinctrl_dev *pctl_dev;
+	struct pinctrl_desc pctl_desc;
+	const struct pin_regs *pin_regs;
+	const struct bcm2712_pin_funcs *pin_funcs;
+	const char *const *gpio_groups;
+	struct pinctrl_gpio_range gpio_range;
+	spinlock_t lock;
+};

Please s/bcm2712/brcmstb/ throughout the driver's structures and any declaration that is not inherently 2712 specific and just make 2712 the first instance using this driver.

Quoted 12 lines
drivers/pinctrl/bcm/pinctrl-bcm2712.c new file +12 -0
+
+struct bcm_plat_data {
+	const struct pinctrl_desc *pctl_desc;
+	const struct pinctrl_gpio_range *gpio_range;
+	const struct pin_regs *pin_regs;
+	const struct bcm2712_pin_funcs *pin_funcs;
+};
+
+struct bcm2712_pin_funcs {
+	u8 funcs[BCM2712_FSEL_COUNT - 1];
+};
+

[snip]

Quoted 13 lines
drivers/pinctrl/bcm/pinctrl-bcm2712.c new file +13 -0
+static int bcm2712_pinctrl_probe(struct platform_device *pdev)
+{
+	struct device *dev = &pdev->dev;
+	//struct device_node *np = dev->of_node;
+	const struct bcm_plat_data *pdata;
+	//const struct of_device_id *match;
+	struct bcm2712_pinctrl *pc;
+	const char **names;
+	int num_pins, i;
+
+	pdata = device_get_match_data(&pdev->dev);
+	if (!pdata)
+		return -EINVAL;

drivers/pinctrl/bcm/pinctrl-bcm2712.c line 1211

Quoted 10 lines
drivers/pinctrl/bcm/pinctrl-bcm2712.c new file +10 -0
+
+	pc = devm_kzalloc(dev, sizeof(*pc), GFP_KERNEL);
+	if (!pc)
+		return -ENOMEM;
+
+	platform_set_drvdata(pdev, pc);
+	pc->dev = dev;
+	spin_lock_init(&pc->lock);
+
+	//pc->base = devm_of_iomap(dev, np, 0, NULL);

Remove stray commented lines.

Quoted 26 lines
drivers/pinctrl/bcm/pinctrl-bcm2712.c new file +26 -0
+	pc->base = devm_platform_ioremap_resource(pdev, 0);
+	if (WARN_ON(IS_ERR(pc->base))) {
+		//dev_err(dev, "could not get IO memory\n");
+		return PTR_ERR(pc->base);
+	}
+
+	pc->pctl_desc = *pdata->pctl_desc;
+	num_pins = pc->pctl_desc.npins;
+	names = devm_kmalloc_array(dev, num_pins, sizeof(const char *),
+				   GFP_KERNEL);
+	if (!names)
+		return -ENOMEM;
+	for (i = 0; i < num_pins; i++)
+		names[i] = pc->pctl_desc.pins[i].name;
+	pc->gpio_groups = names;
+	pc->pin_regs = pdata->pin_regs;
+	pc->pin_funcs = pdata->pin_funcs;
+	pc->pctl_dev = devm_pinctrl_register(dev, &pc->pctl_desc, pc);
+	if (IS_ERR(pc->pctl_dev))
+		return PTR_ERR(pc->pctl_dev);
+
+	pc->gpio_range = *pdata->gpio_range;
+	pinctrl_add_gpio_range(pc->pctl_dev, &pc->gpio_range);
+
+	return 0;
+}

drivers/pinctrl/bcm/pinctrl-bcm2712.c line 1247

Quoted 10 lines
drivers/pinctrl/bcm/pinctrl-bcm2712.c new file +10 -0
+
+static struct platform_driver bcm2712_pinctrl_driver = {
+	.probe = bcm2712_pinctrl_probe,
+	.driver = {
+		.name = MODULE_NAME,
+		.of_match_table = bcm2712_pinctrl_match,
+		.suppress_bind_attrs = true,
+	},
+};
+builtin_platform_driver(bcm2712_pinctrl_driver);

There is no MODULE_LICENSE(), MODULE_AUTHOR() or MODULE_DESCRIPTION(), please provide some.

Signature · 1 line
Florian
#23 lore raw

Re: [PATCH 4/6] pinctrl: bcm: Add pinconf/pinmux controller driver for BCM2712

Quoted 9 lines · Florian Fainelli
Quoted 5 lines · Andrea della Porta

Add a pincontrol driver for BCM2712. BCM2712 allows muxing GPIOs and setting configuration on pads.

Quoted 8 lines

Is that a new tag in a comment message? Signed-off-by maybe?

Quoted 2 lines

---

Was not pinctrl-single usable somehow that we had to go through a dedicated pinctrl driver?

I'm taking a look on this. In V2 though, the pin controller will not be present since it's not strictly necessary tobe able to boot from sd card.

Quoted 236 lines
Quoted 11 lines
  drivers/pinctrl/bcm/Kconfig           |    9 +
  drivers/pinctrl/bcm/Makefile          |    1 +
  drivers/pinctrl/bcm/pinctrl-bcm2712.c | 1247 +++++++++++++++++++++++++
  3 files changed, 1257 insertions(+)

create mode 100644 drivers/pinctrl/bcm/pinctrl-bcm2712.c

drivers/pinctrl/bcm/Kconfig +0 -0
index 35b51ce4298e..62ede44460bc 100644

drivers/pinctrl/bcm/Kconfig line 10

Quoted 8 lines
drivers/pinctrl/bcm/Kconfig +6 -0
@@ -3,6 +3,15 @@
  # Broadcom pinctrl drivers
  #
+config PINCTRL_BCM2712
+	bool "Broadcom BCM2712 PINCONF driver"
+	depends on OF && (ARCH_BCM2835 || ARCH_BRCMSTB || COMPILE_TEST)
+	select PINMUX
+	select PINCONF
+	select GENERIC_PINCONF

Rename to PINCTRL_BRCMSTB sicne this is not BCM2712 specific at all.

Quoted 11 lines
drivers/pinctrl/bcm/Kconfig +3 -0
+	help
+	  Say Y here to enable the Broadcom BCM2712 PINCONF driver.
+
  config PINCTRL_BCM281XX
  	bool "Broadcom BCM281xx pinctrl driver"
  	depends on OF && (ARCH_BCM_MOBILE || COMPILE_TEST)
drivers/pinctrl/bcm/Makefile +0 -0
index 82b868ec1471..d298e4785829 100644

drivers/pinctrl/bcm/Makefile line 3

Quoted 3 lines
drivers/pinctrl/bcm/Makefile +1 -0
@@ -1,6 +1,7 @@
  # SPDX-License-Identifier: GPL-2.0
  # Broadcom pinctrl support
+obj-$(CONFIG_PINCTRL_BCM2712)		+= pinctrl-bcm2712.o

Likewise.

Quoted 100 lines
drivers/pinctrl/bcm/Makefile +0 -0
  obj-$(CONFIG_PINCTRL_BCM281XX)		+= pinctrl-bcm281xx.o
  obj-$(CONFIG_PINCTRL_BCM2835)		+= pinctrl-bcm2835.o
  obj-$(CONFIG_PINCTRL_BCM4908)		+= pinctrl-bcm4908.o
drivers/pinctrl/bcm/pinctrl-bcm2712.c new file +91 -0
new file mode 100644
index 000000000000..f9359e9eff14
@@ -0,0 +1,1247 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Driver for Broadcom BCM2712 GPIO units (pinctrl only)
+ *
+ * Copyright (C) 2021-3 Raspberry Pi Ltd.
+ * Copyright (C) 2012 Chris Boot, Simon Arlott, Stephen Warren
+ *
+ * Based heavily on the BCM2835 GPIO & pinctrl driver, which was inspired by:
+ * pinctrl-nomadik.c, please see original file for copyright information
+ * pinctrl-tegra.c, please see original file for copyright information
+ */
+
+#include <linux/bitmap.h>
+#include <linux/bug.h>
+#include <linux/delay.h>
+#include <linux/device.h>
+#include <linux/err.h>
+#include <linux/io.h>
+#include <linux/init.h>
+#include <linux/interrupt.h>
+#include <linux/of_address.h>
+#include <linux/of.h>
+#include <linux/pinctrl/consumer.h>
+#include <linux/pinctrl/machine.h>
+#include <linux/pinctrl/pinconf.h>
+#include <linux/pinctrl/pinctrl.h>
+#include <linux/pinctrl/pinmux.h>
+#include <linux/pinctrl/pinconf-generic.h>
+#include <linux/platform_device.h>
+#include <linux/seq_file.h>
+#include <linux/slab.h>
+#include <linux/spinlock.h>
+#include <linux/types.h>
+
+#define MODULE_NAME "pinctrl-bcm2712"
+
+/* Register offsets */
+
+#define BCM2712_PULL_NONE	0
+#define BCM2712_PULL_DOWN	1
+#define BCM2712_PULL_UP		2
+#define BCM2712_PULL_MASK	0x3
+
+#define BCM2712_FSEL_COUNT 9
+#define BCM2712_FSEL_MASK  0xf
+
+#define FUNC(f) \
+	[func_##f] = #f
+#define PIN(i, f1, f2, f3, f4, f5, f6, f7, f8) \
+	[i] = { \
+		.funcs = { \
+			func_##f1, \
+			func_##f2, \
+			func_##f3, \
+			func_##f4, \
+			func_##f5, \
+			func_##f6, \
+			func_##f7, \
+			func_##f8, \
+		}, \
+	}
+
+#define MUX_BIT_VALID	0x8000
+#define REG_BIT_INVALID	0xffff
+
+#define BIT_TO_REG(b) (((b) >> 5) << 2)
+#define BIT_TO_SHIFT(b) ((b) & 0x1f)
+
+#define MUX_BIT(mr, mb) (MUX_BIT_VALID + ((mr)*4)*8 + (mb)*4)
+#define GPIO_REGS(n, mr, mb, pr, pb) \
+	[n] = { MUX_BIT(mr, mb), ((pr)*4)*8 + (pb)*2 }
+
+#define EMMC_REGS(n, pr, pb) \
+	[n] = { 0, ((pr)*4)*8 + (pb)*2 }
+
+#define AGPIO_REGS(n, mr, mb, pr, pb) \
+	[n] = { MUX_BIT(mr, mb), ((pr)*4)*8 + (pb)*2 }
+
+#define SGPIO_REGS(n, mr, mb) \
+	[n+32] = { MUX_BIT(mr, mb), REG_BIT_INVALID }
+
+#define GPIO_PIN(a) PINCTRL_PIN(a, "gpio" #a)
+#define AGPIO_PIN(a) PINCTRL_PIN(a, "aon_gpio" #a)
+#define SGPIO_PIN(a) PINCTRL_PIN(a+32, "aon_sgpio" #a)
+
+struct pin_regs {
+	u16 mux_bit;
+	u16 pad_bit;
+};
+
+struct bcm2712_pinctrl {

drivers/pinctrl/bcm/pinctrl-bcm2712.c line 101

Quoted 10 lines
drivers/pinctrl/bcm/pinctrl-bcm2712.c new file +10 -0
+	struct device *dev;
+	void __iomem *base;
+	struct pinctrl_dev *pctl_dev;
+	struct pinctrl_desc pctl_desc;
+	const struct pin_regs *pin_regs;
+	const struct bcm2712_pin_funcs *pin_funcs;
+	const char *const *gpio_groups;
+	struct pinctrl_gpio_range gpio_range;
+	spinlock_t lock;
+};

Please s/bcm2712/brcmstb/ throughout the driver's structures and any declaration that is not inherently 2712 specific and just make 2712 the first instance using this driver.

Quoted 12 lines
drivers/pinctrl/bcm/pinctrl-bcm2712.c new file +12 -0
+
+struct bcm_plat_data {
+	const struct pinctrl_desc *pctl_desc;
+	const struct pinctrl_gpio_range *gpio_range;
+	const struct pin_regs *pin_regs;
+	const struct bcm2712_pin_funcs *pin_funcs;
+};
+
+struct bcm2712_pin_funcs {
+	u8 funcs[BCM2712_FSEL_COUNT - 1];
+};
+

[snip]

Quoted 13 lines
drivers/pinctrl/bcm/pinctrl-bcm2712.c new file +13 -0
+static int bcm2712_pinctrl_probe(struct platform_device *pdev)
+{
+	struct device *dev = &pdev->dev;
+	//struct device_node *np = dev->of_node;
+	const struct bcm_plat_data *pdata;
+	//const struct of_device_id *match;
+	struct bcm2712_pinctrl *pc;
+	const char **names;
+	int num_pins, i;
+
+	pdata = device_get_match_data(&pdev->dev);
+	if (!pdata)
+		return -EINVAL;

drivers/pinctrl/bcm/pinctrl-bcm2712.c line 1211

Quoted 10 lines
drivers/pinctrl/bcm/pinctrl-bcm2712.c new file +10 -0
+
+	pc = devm_kzalloc(dev, sizeof(*pc), GFP_KERNEL);
+	if (!pc)
+		return -ENOMEM;
+
+	platform_set_drvdata(pdev, pc);
+	pc->dev = dev;
+	spin_lock_init(&pc->lock);
+
+	//pc->base = devm_of_iomap(dev, np, 0, NULL);

Remove stray commented lines.

Quoted 26 lines
drivers/pinctrl/bcm/pinctrl-bcm2712.c new file +26 -0
+	pc->base = devm_platform_ioremap_resource(pdev, 0);
+	if (WARN_ON(IS_ERR(pc->base))) {
+		//dev_err(dev, "could not get IO memory\n");
+		return PTR_ERR(pc->base);
+	}
+
+	pc->pctl_desc = *pdata->pctl_desc;
+	num_pins = pc->pctl_desc.npins;
+	names = devm_kmalloc_array(dev, num_pins, sizeof(const char *),
+				   GFP_KERNEL);
+	if (!names)
+		return -ENOMEM;
+	for (i = 0; i < num_pins; i++)
+		names[i] = pc->pctl_desc.pins[i].name;
+	pc->gpio_groups = names;
+	pc->pin_regs = pdata->pin_regs;
+	pc->pin_funcs = pdata->pin_funcs;
+	pc->pctl_dev = devm_pinctrl_register(dev, &pc->pctl_desc, pc);
+	if (IS_ERR(pc->pctl_dev))
+		return PTR_ERR(pc->pctl_dev);
+
+	pc->gpio_range = *pdata->gpio_range;
+	pinctrl_add_gpio_range(pc->pctl_dev, &pc->gpio_range);
+
+	return 0;
+}

drivers/pinctrl/bcm/pinctrl-bcm2712.c line 1247

Quoted 10 lines
drivers/pinctrl/bcm/pinctrl-bcm2712.c new file +10 -0
+
+static struct platform_driver bcm2712_pinctrl_driver = {
+	.probe = bcm2712_pinctrl_probe,
+	.driver = {
+		.name = MODULE_NAME,
+		.of_match_table = bcm2712_pinctrl_match,
+		.suppress_bind_attrs = true,
+	},
+};
+builtin_platform_driver(bcm2712_pinctrl_driver);

There is no MODULE_LICENSE(), MODULE_AUTHOR() or MODULE_DESCRIPTION(), please provide some.

Signature · 1 line
Florian
#24 lore raw

Re: [PATCH 4/6] pinctrl: bcm: Add pinconf/pinmux controller driver for BCM2712

In reply to Andrea della Porta

Hi Andrea,

thanks for your patch!

Some comments apart from was said already.

drivers/pinctrl/bcm/pinctrl-bcm2712.c line 24

Quoted 2 lines · Andrea della Porta
drivers/pinctrl/bcm/pinctrl-bcm2712.c new file +2 -0
+#include <linux/pinctrl/consumer.h>
+#include <linux/pinctrl/machine.h>

Really? Why?

drivers/pinctrl/bcm/pinctrl-bcm2712.c line 28

Quoted 4 lines
drivers/pinctrl/bcm/pinctrl-bcm2712.c new file +4 -0
+#include <linux/pinctrl/pinconf.h>
+#include <linux/pinctrl/pinctrl.h>
+#include <linux/pinctrl/pinmux.h>
+#include <linux/pinctrl/pinconf-generic.h>

I would just expect these.

drivers/pinctrl/bcm/pinctrl-bcm2712.c line 1194

Quoted 6 lines
drivers/pinctrl/bcm/pinctrl-bcm2712.c new file +6 -0
+static int bcm2712_pinctrl_probe(struct platform_device *pdev)
+{
+       struct device *dev = &pdev->dev;
+       //struct device_node *np = dev->of_node;
+       const struct bcm_plat_data *pdata;
+       //const struct of_device_id *match;

I don't know if others commented on it but drop all commented-out code or make use of it.

Yours,
Linus Walleij

#25 lore raw

Re: [PATCH 4/6] pinctrl: bcm: Add pinconf/pinmux controller driver for BCM2712

Quoted 21 lines · Linus Walleij

Hi Andrea,

thanks for your patch!

Some comments apart from was said already.

drivers/pinctrl/bcm/pinctrl-bcm2712.c line 24

Quoted 2 lines · Andrea della Porta
drivers/pinctrl/bcm/pinctrl-bcm2712.c new file +2 -0
+#include <linux/pinctrl/consumer.h>
+#include <linux/pinctrl/machine.h>

Really? Why?

drivers/pinctrl/bcm/pinctrl-bcm2712.c line 28

Quoted 4 lines
drivers/pinctrl/bcm/pinctrl-bcm2712.c new file +4 -0
+#include <linux/pinctrl/pinconf.h>
+#include <linux/pinctrl/pinctrl.h>
+#include <linux/pinctrl/pinmux.h>
+#include <linux/pinctrl/pinconf-generic.h>

I would just expect these.

Quoted 9 lines

drivers/pinctrl/bcm/pinctrl-bcm2712.c line 1194

Quoted 6 lines
drivers/pinctrl/bcm/pinctrl-bcm2712.c new file +6 -0
+static int bcm2712_pinctrl_probe(struct platform_device *pdev)
+{
+       struct device *dev = &pdev->dev;
+       //struct device_node *np = dev->of_node;
+       const struct bcm_plat_data *pdata;
+       //const struct of_device_id *match;

I don't know if others commented on it but drop all commented-out code or make use of it.

Forgot to remove those lines. Will ve dropped in a future patch since the pin controller driver will not be included in V2 since it's not strictly needed to support SD boot.

Many thanks,
Andrea

Quoted 3 lines

Yours,
Linus Walleij

#26 lore raw

PATCH 5/6 mmc: sdhci-brcmstb: Add BCM2712 support

In reply to Andrea della Porta

Broadcom BCM2712 SoC has an SDHCI card controller using the SDIO CFG register block present on other STB chips. Add support for BCM2712 SD capabilities of this chipset.
The silicon is SD Express capable but this driver port does not currently include that feature yet.
Based on downstream driver by raspberry foundation maintained kernel.

---
 drivers/mmc/host/sdhci-brcmstb.c | 130 +++++++++++++++++++++++++++++++
 1 file changed, 130 insertions(+)
drivers/mmc/host/sdhci-brcmstb.c +130 -0
index 9053526fa212..907a4947abe5 100644
@@ -12,6 +12,8 @@
 #include <linux/of.h>
 #include <linux/bitops.h>
 #include <linux/delay.h>
+#include <linux/pinctrl/consumer.h>
+#include <linux/regulator/consumer.h>
 
 #include "sdhci-cqhci.h"
 #include "sdhci-pltfm.h"
@@ -30,15 +32,31 @@
 
 #define SDHCI_ARASAN_CQE_BASE_ADDR		0x200
 
+#define SDIO_CFG_CTRL				0x0
+#define  SDIO_CFG_CTRL_SDCD_N_TEST_EN		BIT(31)
+#define  SDIO_CFG_CTRL_SDCD_N_TEST_LEV		BIT(30)
+
+#define SDIO_CFG_SD_PIN_SEL			0x44
+#define  SDIO_CFG_SD_PIN_SEL_MASK		0x3
+#define  SDIO_CFG_SD_PIN_SEL_SD			BIT(1)
+#define  SDIO_CFG_SD_PIN_SEL_MMC		BIT(0)
+
+#define SDIO_CFG_MAX_50MHZ_MODE			0x1ac
+#define  SDIO_CFG_MAX_50MHZ_MODE_STRAP_OVERRIDE	BIT(31)
+#define  SDIO_CFG_MAX_50MHZ_MODE_ENABLE		BIT(0)
+
 struct sdhci_brcmstb_priv {
 	void __iomem *cfg_regs;
 	unsigned int flags;
 	struct clk *base_clk;
 	u32 base_freq_hz;
+	struct pinctrl *pinctrl;
+	struct pinctrl_state *pins_default;
 };
 
 struct brcmstb_match_priv {
 	void (*hs400es)(struct mmc_host *mmc, struct mmc_ios *ios);
+	void (*cfginit)(struct sdhci_host *host);
 	struct sdhci_ops *ops;
 	const unsigned int flags;
 };
@@ -124,6 +142,42 @@ static void sdhci_brcmstb_hs400es(struct mmc_host *mmc, struct mmc_ios *ios)
 	writel(reg, host->ioaddr + SDHCI_VENDOR);
 }
 
+static void sdhci_bcm2712_set_clock(struct sdhci_host *host, unsigned int clock)
+{
+	u16 clk;
+	u32 reg;
+	bool is_emmc_rate = false;
+	struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host);
+	struct sdhci_brcmstb_priv *brcmstb_priv = sdhci_pltfm_priv(pltfm_host);
+
+	host->mmc->actual_clock = 0;
+
+	sdhci_writew(host, 0, SDHCI_CLOCK_CONTROL);
+
+	switch (host->mmc->ios.timing) {
+	case MMC_TIMING_MMC_HS400:
+	case MMC_TIMING_MMC_HS200:
+	case MMC_TIMING_MMC_DDR52:
+	case MMC_TIMING_MMC_HS:
+	is_emmc_rate = true;
+	break;
+	}
+
+	reg = readl(brcmstb_priv->cfg_regs + SDIO_CFG_SD_PIN_SEL);
+	reg &= ~SDIO_CFG_SD_PIN_SEL_MASK;
+	if (is_emmc_rate)
+		reg |= SDIO_CFG_SD_PIN_SEL_MMC;
+	else
+		reg |= SDIO_CFG_SD_PIN_SEL_SD;
+	writel(reg, brcmstb_priv->cfg_regs + SDIO_CFG_SD_PIN_SEL);
+
+	if (clock == 0)
+		return;
+
+	clk = sdhci_calc_clk(host, clock, &host->mmc->actual_clock);
+	sdhci_enable_clk(host, clk);
+}
+
 static void sdhci_brcmstb_set_clock(struct sdhci_host *host, unsigned int clock)
 {
 	u16 clk;
@@ -139,6 +193,17 @@ static void sdhci_brcmstb_set_clock(struct sdhci_host *host, unsigned int clock)
 	sdhci_enable_clk(host, clk);
 }
 
+static void sdhci_brcmstb_set_power(struct sdhci_host *host, unsigned char mode,
+				  unsigned short vdd)
+{
+	if (!IS_ERR(host->mmc->supply.vmmc)) {
+		struct mmc_host *mmc = host->mmc;
+
+		mmc_regulator_set_ocr(mmc, mmc->supply.vmmc, vdd);
+	}
+	sdhci_set_power_noreg(host, mode, vdd);
+}
+
 static void sdhci_brcmstb_set_uhs_signaling(struct sdhci_host *host,
 					    unsigned int timing)
 {
@@ -168,6 +233,36 @@ static void sdhci_brcmstb_set_uhs_signaling(struct sdhci_host *host,
 	sdhci_writew(host, ctrl_2, SDHCI_HOST_CONTROL2);
 }
 
+static void sdhci_brcmstb_cfginit_2712(struct sdhci_host *host)
+{
+	struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host);
+	struct sdhci_brcmstb_priv *brcmstb_priv = sdhci_pltfm_priv(pltfm_host);
+	u32 uhs_mask = (MMC_CAP_UHS_SDR50 | MMC_CAP_UHS_SDR104);
+	u32 hsemmc_mask = (MMC_CAP2_HS200_1_8V_SDR | MMC_CAP2_HS200_1_2V_SDR |
+			   MMC_CAP2_HS400_1_8V | MMC_CAP2_HS400_1_2V);
+	u32 reg;
+
+	/*
+	* If we support a speed that requires tuning,
+	* then select the delay line PHY as the clock source.
+	*/
+	if ((host->mmc->caps & uhs_mask) || (host->mmc->caps2 & hsemmc_mask)) {
+		reg = readl(brcmstb_priv->cfg_regs + SDIO_CFG_MAX_50MHZ_MODE);
+		reg &= ~SDIO_CFG_MAX_50MHZ_MODE_ENABLE;
+		reg |= SDIO_CFG_MAX_50MHZ_MODE_STRAP_OVERRIDE;
+		writel(reg, brcmstb_priv->cfg_regs + SDIO_CFG_MAX_50MHZ_MODE);
+	}
+
+	if ((host->mmc->caps & MMC_CAP_NONREMOVABLE) ||
+	    (host->mmc->caps & MMC_CAP_NEEDS_POLL)) {
+		/* Force presence */
+		reg = readl(brcmstb_priv->cfg_regs + SDIO_CFG_CTRL);
+		reg &= ~SDIO_CFG_CTRL_SDCD_N_TEST_LEV;
+		reg |= SDIO_CFG_CTRL_SDCD_N_TEST_EN;
+		writel(reg, brcmstb_priv->cfg_regs + SDIO_CFG_CTRL);
+	}
+}
+
 static void sdhci_brcmstb_dumpregs(struct mmc_host *mmc)
 {
 	sdhci_dumpregs(mmc_priv(mmc));
@@ -200,6 +295,14 @@ static struct sdhci_ops sdhci_brcmstb_ops = {
 	.set_uhs_signaling = sdhci_set_uhs_signaling,
 };
 
+static struct sdhci_ops sdhci_brcmstb_ops_2712 = {
+	.set_clock = sdhci_bcm2712_set_clock,
+	.set_power = sdhci_brcmstb_set_power,
+	.set_bus_width = sdhci_set_bus_width,
+	.reset = sdhci_reset,
+	.set_uhs_signaling = sdhci_set_uhs_signaling,
+};
+
 static struct sdhci_ops sdhci_brcmstb_ops_7216 = {
 	.set_clock = sdhci_brcmstb_set_clock,
 	.set_bus_width = sdhci_set_bus_width,
@@ -237,7 +340,13 @@ static struct brcmstb_match_priv match_priv_74165b0 = {
 	.ops = &sdhci_brcmstb_ops_74165b0,
 };
 
+static const struct brcmstb_match_priv match_priv_2712 = {
+	.cfginit = sdhci_brcmstb_cfginit_2712,
+	.ops = &sdhci_brcmstb_ops_2712,
+};
+
 static const struct of_device_id __maybe_unused sdhci_brcm_of_match[] = {
+	{ .compatible = "brcm,bcm2712-sdhci", .data = &match_priv_2712 },
 	{ .compatible = "brcm,bcm7425-sdhci", .data = &match_priv_7425 },
 	{ .compatible = "brcm,bcm7445-sdhci", .data = &match_priv_7445 },
 	{ .compatible = "brcm,bcm7216-sdhci", .data = &match_priv_7216 },
@@ -314,11 +423,16 @@ static int sdhci_brcmstb_probe(struct platform_device *pdev)
 	struct sdhci_brcmstb_priv *priv;
 	u32 actual_clock_mhz;
 	struct sdhci_host *host;
+	bool no_pinctrl = false;
 	struct clk *clk;
 	struct clk *base_clk = NULL;
 	int res;
 
 	match = of_match_node(sdhci_brcm_of_match, pdev->dev.of_node);
+	if (!match) {
+		dev_err(&pdev->dev, "fail to get matching of_match struct\n");
+		return -EINVAL;
+	}
 	match_priv = match->data;
 
 	dev_dbg(&pdev->dev, "Probe found match for %s\n",  match->compatible);
@@ -354,6 +468,19 @@ static int sdhci_brcmstb_probe(struct platform_device *pdev)
 	if (res)
 		goto err;
 
+	priv->pinctrl = devm_pinctrl_get(&pdev->dev);
+	if (IS_ERR(priv->pinctrl)) {
+			no_pinctrl = true;
+	}
+	priv->pins_default = pinctrl_lookup_state(priv->pinctrl, "default");
+	if (IS_ERR(priv->pins_default)) {
+			dev_dbg(&pdev->dev, "No pinctrl default state\n");
+			no_pinctrl = true;
+	}
+
+	if (no_pinctrl )
+		priv->pinctrl = NULL;
+
 	/*
 	 * Automatic clock gating does not work for SD cards that may
 	 * voltage switch so only enable it for non-removable devices.
@@ -370,6 +497,9 @@ static int sdhci_brcmstb_probe(struct platform_device *pdev)
 	    (host->mmc->caps2 & MMC_CAP2_HS400_ES))
 		host->mmc_host_ops.hs400_enhanced_strobe = match_priv->hs400es;
 
+	if(match_priv->cfginit)
+		match_priv->cfginit(host);
+
 	/*
 	 * Supply the existing CAPS, but clear the UHS modes. This
 	 * will allow these modes to be specified by device tree
Signature · 1 line
2.35.3
#27 lore raw

Re: [PATCH 5/6] mmc: sdhci-brcmstb: Add BCM2712 support

Quoted 6 lines · Andrea della Porta

Broadcom BCM2712 SoC has an SDHCI card controller using the SDIO CFG register block present on other STB chips. Add support for BCM2712 SD capabilities of this chipset.
The silicon is SD Express capable but this driver port does not currently include that feature yet.
Based on downstream driver by raspberry foundation maintained kernel.

DTS and parts of this code look like you just send to us downstream code. Upstreaming does not work like this. Please consult your folks in Suse to explain you more how upstreaming process looks like.

Quoted 65 lines
---
 drivers/mmc/host/sdhci-brcmstb.c | 130 +++++++++++++++++++++++++++++++
 1 file changed, 130 insertions(+)
drivers/mmc/host/sdhci-brcmstb.c +28 -0
index 9053526fa212..907a4947abe5 100644
@@ -12,6 +12,8 @@
 #include <linux/of.h>
 #include <linux/bitops.h>
 #include <linux/delay.h>
+#include <linux/pinctrl/consumer.h>
+#include <linux/regulator/consumer.h>
 
 #include "sdhci-cqhci.h"
 #include "sdhci-pltfm.h"
@@ -30,15 +32,31 @@
 
 #define SDHCI_ARASAN_CQE_BASE_ADDR		0x200
 
+#define SDIO_CFG_CTRL				0x0
+#define  SDIO_CFG_CTRL_SDCD_N_TEST_EN		BIT(31)
+#define  SDIO_CFG_CTRL_SDCD_N_TEST_LEV		BIT(30)
+
+#define SDIO_CFG_SD_PIN_SEL			0x44
+#define  SDIO_CFG_SD_PIN_SEL_MASK		0x3
+#define  SDIO_CFG_SD_PIN_SEL_SD			BIT(1)
+#define  SDIO_CFG_SD_PIN_SEL_MMC		BIT(0)
+
+#define SDIO_CFG_MAX_50MHZ_MODE			0x1ac
+#define  SDIO_CFG_MAX_50MHZ_MODE_STRAP_OVERRIDE	BIT(31)
+#define  SDIO_CFG_MAX_50MHZ_MODE_ENABLE		BIT(0)
+
 struct sdhci_brcmstb_priv {
 	void __iomem *cfg_regs;
 	unsigned int flags;
 	struct clk *base_clk;
 	u32 base_freq_hz;
+	struct pinctrl *pinctrl;
+	struct pinctrl_state *pins_default;
 };
 
 struct brcmstb_match_priv {
 	void (*hs400es)(struct mmc_host *mmc, struct mmc_ios *ios);
+	void (*cfginit)(struct sdhci_host *host);
 	struct sdhci_ops *ops;
 	const unsigned int flags;
 };
@@ -124,6 +142,42 @@ static void sdhci_brcmstb_hs400es(struct mmc_host *mmc, struct mmc_ios *ios)
 	writel(reg, host->ioaddr + SDHCI_VENDOR);
 }
 
+static void sdhci_bcm2712_set_clock(struct sdhci_host *host, unsigned int clock)
+{
+	u16 clk;
+	u32 reg;
+	bool is_emmc_rate = false;
+	struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host);
+	struct sdhci_brcmstb_priv *brcmstb_priv = sdhci_pltfm_priv(pltfm_host);
+
+	host->mmc->actual_clock = 0;
+

drivers/mmc/host/sdhci-brcmstb.c static void sdhci_brcmstb_hs400es(struct mmc_host *mmc, struct mmc_ios *ios) · line 164

Quoted 10 lines
drivers/mmc/host/sdhci-brcmstb.c +10 -0
+	sdhci_writew(host, 0, SDHCI_CLOCK_CONTROL);
+
+	switch (host->mmc->ios.timing) {
+	case MMC_TIMING_MMC_HS400:
+	case MMC_TIMING_MMC_HS200:
+	case MMC_TIMING_MMC_DDR52:
+	case MMC_TIMING_MMC_HS:
+	is_emmc_rate = true;
+	break;
+	}

That's not indented correctly.

Quoted 104 lines
drivers/mmc/host/sdhci-brcmstb.c +71 -0
+
+	reg = readl(brcmstb_priv->cfg_regs + SDIO_CFG_SD_PIN_SEL);
+	reg &= ~SDIO_CFG_SD_PIN_SEL_MASK;
+	if (is_emmc_rate)
+		reg |= SDIO_CFG_SD_PIN_SEL_MMC;
+	else
+		reg |= SDIO_CFG_SD_PIN_SEL_SD;
+	writel(reg, brcmstb_priv->cfg_regs + SDIO_CFG_SD_PIN_SEL);
+
+	if (clock == 0)
+		return;
+
+	clk = sdhci_calc_clk(host, clock, &host->mmc->actual_clock);
+	sdhci_enable_clk(host, clk);
+}
+
 static void sdhci_brcmstb_set_clock(struct sdhci_host *host, unsigned int clock)
 {
 	u16 clk;
@@ -139,6 +193,17 @@ static void sdhci_brcmstb_set_clock(struct sdhci_host *host, unsigned int clock)
 	sdhci_enable_clk(host, clk);
 }
 
+static void sdhci_brcmstb_set_power(struct sdhci_host *host, unsigned char mode,
+				  unsigned short vdd)
+{
+	if (!IS_ERR(host->mmc->supply.vmmc)) {
+		struct mmc_host *mmc = host->mmc;
+
+		mmc_regulator_set_ocr(mmc, mmc->supply.vmmc, vdd);
+	}
+	sdhci_set_power_noreg(host, mode, vdd);
+}
+
 static void sdhci_brcmstb_set_uhs_signaling(struct sdhci_host *host,
 					    unsigned int timing)
 {
@@ -168,6 +233,36 @@ static void sdhci_brcmstb_set_uhs_signaling(struct sdhci_host *host,
 	sdhci_writew(host, ctrl_2, SDHCI_HOST_CONTROL2);
 }
 
+static void sdhci_brcmstb_cfginit_2712(struct sdhci_host *host)
+{
+	struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host);
+	struct sdhci_brcmstb_priv *brcmstb_priv = sdhci_pltfm_priv(pltfm_host);
+	u32 uhs_mask = (MMC_CAP_UHS_SDR50 | MMC_CAP_UHS_SDR104);
+	u32 hsemmc_mask = (MMC_CAP2_HS200_1_8V_SDR | MMC_CAP2_HS200_1_2V_SDR |
+			   MMC_CAP2_HS400_1_8V | MMC_CAP2_HS400_1_2V);
+	u32 reg;
+
+	/*
+	* If we support a speed that requires tuning,
+	* then select the delay line PHY as the clock source.
+	*/
+	if ((host->mmc->caps & uhs_mask) || (host->mmc->caps2 & hsemmc_mask)) {
+		reg = readl(brcmstb_priv->cfg_regs + SDIO_CFG_MAX_50MHZ_MODE);
+		reg &= ~SDIO_CFG_MAX_50MHZ_MODE_ENABLE;
+		reg |= SDIO_CFG_MAX_50MHZ_MODE_STRAP_OVERRIDE;
+		writel(reg, brcmstb_priv->cfg_regs + SDIO_CFG_MAX_50MHZ_MODE);
+	}
+
+	if ((host->mmc->caps & MMC_CAP_NONREMOVABLE) ||
+	    (host->mmc->caps & MMC_CAP_NEEDS_POLL)) {
+		/* Force presence */
+		reg = readl(brcmstb_priv->cfg_regs + SDIO_CFG_CTRL);
+		reg &= ~SDIO_CFG_CTRL_SDCD_N_TEST_LEV;
+		reg |= SDIO_CFG_CTRL_SDCD_N_TEST_EN;
+		writel(reg, brcmstb_priv->cfg_regs + SDIO_CFG_CTRL);
+	}
+}
+
 static void sdhci_brcmstb_dumpregs(struct mmc_host *mmc)
 {
 	sdhci_dumpregs(mmc_priv(mmc));
@@ -200,6 +295,14 @@ static struct sdhci_ops sdhci_brcmstb_ops = {
 	.set_uhs_signaling = sdhci_set_uhs_signaling,
 };
 
+static struct sdhci_ops sdhci_brcmstb_ops_2712 = {
+	.set_clock = sdhci_bcm2712_set_clock,
+	.set_power = sdhci_brcmstb_set_power,
+	.set_bus_width = sdhci_set_bus_width,
+	.reset = sdhci_reset,
+	.set_uhs_signaling = sdhci_set_uhs_signaling,
+};
+
 static struct sdhci_ops sdhci_brcmstb_ops_7216 = {
 	.set_clock = sdhci_brcmstb_set_clock,
 	.set_bus_width = sdhci_set_bus_width,
@@ -237,7 +340,13 @@ static struct brcmstb_match_priv match_priv_74165b0 = {
 	.ops = &sdhci_brcmstb_ops_74165b0,
 };
 
+static const struct brcmstb_match_priv match_priv_2712 = {
+	.cfginit = sdhci_brcmstb_cfginit_2712,
+	.ops = &sdhci_brcmstb_ops_2712,
+};
+
 static const struct of_device_id __maybe_unused sdhci_brcm_of_match[] = {
+	{ .compatible = "brcm,bcm2712-sdhci", .data = &match_priv_2712 },
 	{ .compatible = "brcm,bcm7425-sdhci", .data = &match_priv_7425 },
 	{ .compatible = "brcm,bcm7445-sdhci", .data = &match_priv_7445 },
 	{ .compatible = "brcm,bcm7216-sdhci", .data = &match_priv_7216 },

drivers/mmc/host/sdhci-brcmstb.c static int sdhci_brcmstb_probe(struct platform_device *pdev) · line 432

Quoted 10 lines
drivers/mmc/host/sdhci-brcmstb.c +2 -0
@@ -314,11 +423,16 @@ static int sdhci_brcmstb_probe(struct platform_device *pdev)
 	struct sdhci_brcmstb_priv *priv;
 	u32 actual_clock_mhz;
 	struct sdhci_host *host;
+	bool no_pinctrl = false;
 	struct clk *clk;
 	struct clk *base_clk = NULL;
 	int res;
 
 	match = of_match_node(sdhci_brcm_of_match, pdev->dev.of_node);
+	if (!match) {

Why? This is not explained. Please do not add random pieces of code, just because downstream code makes mistakes. This should go otherway - downstream should be fixed, not upstream get downstream mistakes.

Quoted 27 lines
drivers/mmc/host/sdhci-brcmstb.c +16 -0
+		dev_err(&pdev->dev, "fail to get matching of_match struct\n");
+		return -EINVAL;
+	}
 	match_priv = match->data;
 
 	dev_dbg(&pdev->dev, "Probe found match for %s\n",  match->compatible);
@@ -354,6 +468,19 @@ static int sdhci_brcmstb_probe(struct platform_device *pdev)
 	if (res)
 		goto err;
 
+	priv->pinctrl = devm_pinctrl_get(&pdev->dev);
+	if (IS_ERR(priv->pinctrl)) {
+			no_pinctrl = true;
+	}
+	priv->pins_default = pinctrl_lookup_state(priv->pinctrl, "default");
+	if (IS_ERR(priv->pins_default)) {
+			dev_dbg(&pdev->dev, "No pinctrl default state\n");
+			no_pinctrl = true;
+	}
+
+	if (no_pinctrl )
+		priv->pinctrl = NULL;
+
 	/*
 	 * Automatic clock gating does not work for SD cards that may
 	 * voltage switch so only enable it for non-removable devices.

drivers/mmc/host/sdhci-brcmstb.c static int sdhci_brcmstb_probe(struct platform_device *pdev) · line 500

Quoted 4 lines
drivers/mmc/host/sdhci-brcmstb.c +1 -0
@@ -370,6 +497,9 @@ static int sdhci_brcmstb_probe(struct platform_device *pdev)
 	    (host->mmc->caps2 & MMC_CAP2_HS400_ES))
 		host->mmc_host_ops.hs400_enhanced_strobe = match_priv->hs400es;
 
+	if(match_priv->cfginit)

Not conforming to Linux coding style.

Best regards,
Krzysztof

#28 lore raw

Re: [PATCH 5/6] mmc: sdhci-brcmstb: Add BCM2712 support

In reply to Andrea della Porta

Le 14/04/2024 à 00:14, Andrea della Porta a écrit :

Quoted 11 lines

Broadcom BCM2712 SoC has an SDHCI card controller using the SDIO CFG register block present on other STB chips. Add support for BCM2712 SD capabilities of this chipset.
The silicon is SD Express capable but this driver port does not currently include that feature yet.
Based on downstream driver by raspberry foundation maintained kernel.

---
  drivers/mmc/host/sdhci-brcmstb.c | 130 +++++++++++++++++++++++++++++++
  1 file changed, 130 insertions(+)

...

drivers/mmc/host/sdhci-brcmstb.c static void sdhci_brcmstb_set_clock(struct sdhci_host *host, unsigned int clock) · line 200

Quoted 5 lines
drivers/mmc/host/sdhci-brcmstb.c +5 -0
+static void sdhci_brcmstb_set_power(struct sdhci_host *host, unsigned char mode,
+				  unsigned short vdd)
+{
+	if (!IS_ERR(host->mmc->supply.vmmc)) {
+		struct mmc_host *mmc = host->mmc;

This would look nicer if mmc was defined at the beginning of the function and used in the if (!IS_ERR()) test.

Quoted 12 lines
drivers/mmc/host/sdhci-brcmstb.c +6 -0
+
+		mmc_regulator_set_ocr(mmc, mmc->supply.vmmc, vdd);
+	}
+	sdhci_set_power_noreg(host, mode, vdd);
+}
+
  static void sdhci_brcmstb_set_uhs_signaling(struct sdhci_host *host,
  					    unsigned int timing)
  {
@@ -168,6 +233,36 @@ static void sdhci_brcmstb_set_uhs_signaling(struct sdhci_host *host,
  	sdhci_writew(host, ctrl_2, SDHCI_HOST_CONTROL2);
  }

...

drivers/mmc/host/sdhci-brcmstb.c static int sdhci_brcmstb_probe(struct platform_device *pdev) · line 474

Quoted 8 lines
drivers/mmc/host/sdhci-brcmstb.c +4 -0
@@ -354,6 +468,19 @@ static int sdhci_brcmstb_probe(struct platform_device *pdev)
  	if (res)
  		goto err;
 
+	priv->pinctrl = devm_pinctrl_get(&pdev->dev);
+	if (IS_ERR(priv->pinctrl)) {
+			no_pinctrl = true;
+	}

Indentation looks to large here.
No need to { }

drivers/mmc/host/sdhci-brcmstb.c static int sdhci_brcmstb_probe(struct platform_device *pdev) · line 478

Quoted 4 lines
drivers/mmc/host/sdhci-brcmstb.c +4 -0
+	priv->pins_default = pinctrl_lookup_state(priv->pinctrl, "default");
+	if (IS_ERR(priv->pins_default)) {
+			dev_dbg(&pdev->dev, "No pinctrl default state\n");
+			no_pinctrl = true;

Indentation looks to large here.

Quoted 8 lines
drivers/mmc/host/sdhci-brcmstb.c +5 -0
+	}
+
+	if (no_pinctrl )
+		priv->pinctrl = NULL;
+
  	/*
  	 * Automatic clock gating does not work for SD cards that may
  	 * voltage switch so only enable it for non-removable devices.

...

maintainer
#29 lore raw

Re: [PATCH 5/6] mmc: sdhci-brcmstb: Add BCM2712 support

In reply to Andrea della Porta
Quoted 58 lines · Andrea della Porta

Broadcom BCM2712 SoC has an SDHCI card controller using the SDIO CFG register block present on other STB chips. Add support for BCM2712 SD capabilities of this chipset.
The silicon is SD Express capable but this driver port does not currently include that feature yet.
Based on downstream driver by raspberry foundation maintained kernel.

---
  drivers/mmc/host/sdhci-brcmstb.c | 130 +++++++++++++++++++++++++++++++
  1 file changed, 130 insertions(+)
drivers/mmc/host/sdhci-brcmstb.c +18 -0
index 9053526fa212..907a4947abe5 100644
@@ -12,6 +12,8 @@
  #include <linux/of.h>
  #include <linux/bitops.h>
  #include <linux/delay.h>
+#include <linux/pinctrl/consumer.h>
+#include <linux/regulator/consumer.h>
 
  #include "sdhci-cqhci.h"
  #include "sdhci-pltfm.h"
@@ -30,15 +32,31 @@
 
  #define SDHCI_ARASAN_CQE_BASE_ADDR		0x200
 
+#define SDIO_CFG_CTRL				0x0
+#define  SDIO_CFG_CTRL_SDCD_N_TEST_EN		BIT(31)
+#define  SDIO_CFG_CTRL_SDCD_N_TEST_LEV		BIT(30)
+
+#define SDIO_CFG_SD_PIN_SEL			0x44
+#define  SDIO_CFG_SD_PIN_SEL_MASK		0x3
+#define  SDIO_CFG_SD_PIN_SEL_SD			BIT(1)
+#define  SDIO_CFG_SD_PIN_SEL_MMC		BIT(0)
+
+#define SDIO_CFG_MAX_50MHZ_MODE			0x1ac
+#define  SDIO_CFG_MAX_50MHZ_MODE_STRAP_OVERRIDE	BIT(31)
+#define  SDIO_CFG_MAX_50MHZ_MODE_ENABLE		BIT(0)
+
  struct sdhci_brcmstb_priv {
  	void __iomem *cfg_regs;
  	unsigned int flags;
  	struct clk *base_clk;
  	u32 base_freq_hz;
+	struct pinctrl *pinctrl;
+	struct pinctrl_state *pins_default;
  };
 
  struct brcmstb_match_priv {
  	void (*hs400es)(struct mmc_host *mmc, struct mmc_ios *ios);
+	void (*cfginit)(struct sdhci_host *host);
  	struct sdhci_ops *ops;
  	const unsigned int flags;
  };

drivers/mmc/host/sdhci-brcmstb.c static void sdhci_brcmstb_hs400es(struct mmc_host *mmc, struct mmc_ios *ios) · line 151

Quoted 10 lines
drivers/mmc/host/sdhci-brcmstb.c +7 -0
@@ -124,6 +142,42 @@ static void sdhci_brcmstb_hs400es(struct mmc_host *mmc, struct mmc_ios *ios)
  	writel(reg, host->ioaddr + SDHCI_VENDOR);
  }
 
+static void sdhci_bcm2712_set_clock(struct sdhci_host *host, unsigned int clock)
+{
+	u16 clk;
+	u32 reg;
+	bool is_emmc_rate = false;
+	struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host);
+	struct sdhci_brcmstb_priv *brcmstb_priv = sdhci_pltfm_priv(pltfm_host);

Reverse christmas tree declaration please, longest lines first and shortest lines next.

drivers/mmc/host/sdhci-brcmstb.c static void sdhci_brcmstb_hs400es(struct mmc_host *mmc, struct mmc_ios *ios) · line 163

Quoted 12 lines
drivers/mmc/host/sdhci-brcmstb.c +12 -0
+
+	host->mmc->actual_clock = 0;
+
+	sdhci_writew(host, 0, SDHCI_CLOCK_CONTROL);
+
+	switch (host->mmc->ios.timing) {
+	case MMC_TIMING_MMC_HS400:
+	case MMC_TIMING_MMC_HS200:
+	case MMC_TIMING_MMC_DDR52:
+	case MMC_TIMING_MMC_HS:
+	is_emmc_rate = true;
+	break;

Both lines are mis-aligned and requiren an additional tab.

Quoted 122 lines
drivers/mmc/host/sdhci-brcmstb.c +77 -0
+	}
+
+	reg = readl(brcmstb_priv->cfg_regs + SDIO_CFG_SD_PIN_SEL);
+	reg &= ~SDIO_CFG_SD_PIN_SEL_MASK;
+	if (is_emmc_rate)
+		reg |= SDIO_CFG_SD_PIN_SEL_MMC;
+	else
+		reg |= SDIO_CFG_SD_PIN_SEL_SD;
+	writel(reg, brcmstb_priv->cfg_regs + SDIO_CFG_SD_PIN_SEL);
+
+	if (clock == 0)
+		return;
+
+	clk = sdhci_calc_clk(host, clock, &host->mmc->actual_clock);
+	sdhci_enable_clk(host, clk);
+}
+
  static void sdhci_brcmstb_set_clock(struct sdhci_host *host, unsigned int clock)
  {
  	u16 clk;
@@ -139,6 +193,17 @@ static void sdhci_brcmstb_set_clock(struct sdhci_host *host, unsigned int clock)
  	sdhci_enable_clk(host, clk);
  }
 
+static void sdhci_brcmstb_set_power(struct sdhci_host *host, unsigned char mode,
+				  unsigned short vdd)
+{
+	if (!IS_ERR(host->mmc->supply.vmmc)) {
+		struct mmc_host *mmc = host->mmc;
+
+		mmc_regulator_set_ocr(mmc, mmc->supply.vmmc, vdd);
+	}
+	sdhci_set_power_noreg(host, mode, vdd);
+}
+
  static void sdhci_brcmstb_set_uhs_signaling(struct sdhci_host *host,
  					    unsigned int timing)
  {
@@ -168,6 +233,36 @@ static void sdhci_brcmstb_set_uhs_signaling(struct sdhci_host *host,
  	sdhci_writew(host, ctrl_2, SDHCI_HOST_CONTROL2);
  }
 
+static void sdhci_brcmstb_cfginit_2712(struct sdhci_host *host)
+{
+	struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host);
+	struct sdhci_brcmstb_priv *brcmstb_priv = sdhci_pltfm_priv(pltfm_host);
+	u32 uhs_mask = (MMC_CAP_UHS_SDR50 | MMC_CAP_UHS_SDR104);
+	u32 hsemmc_mask = (MMC_CAP2_HS200_1_8V_SDR | MMC_CAP2_HS200_1_2V_SDR |
+			   MMC_CAP2_HS400_1_8V | MMC_CAP2_HS400_1_2V);
+	u32 reg;
+
+	/*
+	* If we support a speed that requires tuning,
+	* then select the delay line PHY as the clock source.
+	*/
+	if ((host->mmc->caps & uhs_mask) || (host->mmc->caps2 & hsemmc_mask)) {
+		reg = readl(brcmstb_priv->cfg_regs + SDIO_CFG_MAX_50MHZ_MODE);
+		reg &= ~SDIO_CFG_MAX_50MHZ_MODE_ENABLE;
+		reg |= SDIO_CFG_MAX_50MHZ_MODE_STRAP_OVERRIDE;
+		writel(reg, brcmstb_priv->cfg_regs + SDIO_CFG_MAX_50MHZ_MODE);
+	}
+
+	if ((host->mmc->caps & MMC_CAP_NONREMOVABLE) ||
+	    (host->mmc->caps & MMC_CAP_NEEDS_POLL)) {
+		/* Force presence */
+		reg = readl(brcmstb_priv->cfg_regs + SDIO_CFG_CTRL);
+		reg &= ~SDIO_CFG_CTRL_SDCD_N_TEST_LEV;
+		reg |= SDIO_CFG_CTRL_SDCD_N_TEST_EN;
+		writel(reg, brcmstb_priv->cfg_regs + SDIO_CFG_CTRL);
+	}
+}
+
  static void sdhci_brcmstb_dumpregs(struct mmc_host *mmc)
  {
  	sdhci_dumpregs(mmc_priv(mmc));
@@ -200,6 +295,14 @@ static struct sdhci_ops sdhci_brcmstb_ops = {
  	.set_uhs_signaling = sdhci_set_uhs_signaling,
  };
 
+static struct sdhci_ops sdhci_brcmstb_ops_2712 = {
+	.set_clock = sdhci_bcm2712_set_clock,
+	.set_power = sdhci_brcmstb_set_power,
+	.set_bus_width = sdhci_set_bus_width,
+	.reset = sdhci_reset,
+	.set_uhs_signaling = sdhci_set_uhs_signaling,
+};
+
  static struct sdhci_ops sdhci_brcmstb_ops_7216 = {
  	.set_clock = sdhci_brcmstb_set_clock,
  	.set_bus_width = sdhci_set_bus_width,
@@ -237,7 +340,13 @@ static struct brcmstb_match_priv match_priv_74165b0 = {
  	.ops = &sdhci_brcmstb_ops_74165b0,
  };
 
+static const struct brcmstb_match_priv match_priv_2712 = {
+	.cfginit = sdhci_brcmstb_cfginit_2712,
+	.ops = &sdhci_brcmstb_ops_2712,
+};
+
  static const struct of_device_id __maybe_unused sdhci_brcm_of_match[] = {
+	{ .compatible = "brcm,bcm2712-sdhci", .data = &match_priv_2712 },
  	{ .compatible = "brcm,bcm7425-sdhci", .data = &match_priv_7425 },
  	{ .compatible = "brcm,bcm7445-sdhci", .data = &match_priv_7445 },
  	{ .compatible = "brcm,bcm7216-sdhci", .data = &match_priv_7216 },
@@ -314,11 +423,16 @@ static int sdhci_brcmstb_probe(struct platform_device *pdev)
  	struct sdhci_brcmstb_priv *priv;
  	u32 actual_clock_mhz;
  	struct sdhci_host *host;
+	bool no_pinctrl = false;
  	struct clk *clk;
  	struct clk *base_clk = NULL;
  	int res;
 
  	match = of_match_node(sdhci_brcm_of_match, pdev->dev.of_node);
+	if (!match) {
+		dev_err(&pdev->dev, "fail to get matching of_match struct\n");
+		return -EINVAL;
+	}
  	match_priv = match->data;
 
  	dev_dbg(&pdev->dev, "Probe found match for %s\n",  match->compatible);

drivers/mmc/host/sdhci-brcmstb.c static int sdhci_brcmstb_probe(struct platform_device *pdev) · line 473

Quoted 6 lines
drivers/mmc/host/sdhci-brcmstb.c +3 -0
@@ -354,6 +468,19 @@ static int sdhci_brcmstb_probe(struct platform_device *pdev)
  	if (res)
  		goto err;
 
+	priv->pinctrl = devm_pinctrl_get(&pdev->dev);
+	if (IS_ERR(priv->pinctrl)) {
+			no_pinctrl = true;

One too many tabs here.

drivers/mmc/host/sdhci-brcmstb.c static int sdhci_brcmstb_probe(struct platform_device *pdev) · line 478

Quoted 5 lines
drivers/mmc/host/sdhci-brcmstb.c +5 -0
+	}
+	priv->pins_default = pinctrl_lookup_state(priv->pinctrl, "default");
+	if (IS_ERR(priv->pins_default)) {
+			dev_dbg(&pdev->dev, "No pinctrl default state\n");
+			no_pinctrl = true;

One too many tabs here.

Please just run checkpatch on your patches, thanks.

Signature · 1 line
Florian
#30 lore raw

PATCH 6/6 mmc: sdhci-brcmstb: Add BCM2712 SD Express support

In reply to Andrea della Porta

Broadcom BCM2712 SDHCI controller is SD Express capable. Add support for sde capability where the implementation is based on downstream driver, diverging from it in the way that init_sd_express callback is invoked:
in downstream the sdhci_ops structure has been augmented with a new function ptr 'init_sd_express' that just propagate the call to the driver specific callback so that the callstack from a structure standpoint is mmc_host_ops -> sdhci_ops. The drawback here is in the added level of indirection (the newly added init_sd_express is redundant) and the sdhci_ops structure declaration has to be changed. To overcome this the presented approach consist in patching the mmc_host_ops init_sd_express callback to point directly to the custom function defined in this driver (see struct brcmstb_match_priv).

---
 drivers/mmc/host/Kconfig         |   1 +
 drivers/mmc/host/sdhci-brcmstb.c | 147 ++++++++++++++++++++++++++++++-
 2 files changed, 147 insertions(+), 1 deletion(-)
drivers/mmc/host/Kconfig +1 -0
index aebc587f77a7..343ccac1a4e4 100644
@@ -1018,6 +1018,7 @@ config MMC_SDHCI_BRCMSTB
 	depends on ARCH_BRCMSTB || BMIPS_GENERIC || COMPILE_TEST
 	depends on MMC_SDHCI_PLTFM
 	select MMC_CQHCI
+	select OF_DYNAMIC
 	default ARCH_BRCMSTB || BMIPS_GENERIC
 	help
 	  This selects support for the SDIO/SD/MMC Host Controller on
drivers/mmc/host/sdhci-brcmstb.c +146 -1

209 lines not on this page · raw message

Signature · 1 line
2.35.3
#31 lore raw

Re: [PATCH 6/6] mmc: sdhci-brcmstb: Add BCM2712 SD Express support

Le 14/04/2024 à 00:14, Andrea della Porta a écrit :

Quoted 18 lines

Broadcom BCM2712 SDHCI controller is SD Express capable. Add support for sde capability where the implementation is based on downstream driver, diverging from it in the way that init_sd_express callback is invoked:
in downstream the sdhci_ops structure has been augmented with a new function ptr 'init_sd_express' that just propagate the call to the driver specific callback so that the callstack from a structure standpoint is mmc_host_ops -> sdhci_ops. The drawback here is in the added level of indirection (the newly added init_sd_express is redundant) and the sdhci_ops structure declaration has to be changed. To overcome this the presented approach consist in patching the mmc_host_ops init_sd_express callback to point directly to the custom function defined in this driver (see struct brcmstb_match_priv).

---
  drivers/mmc/host/Kconfig         |   1 +
  drivers/mmc/host/sdhci-brcmstb.c | 147 ++++++++++++++++++++++++++++++-
  2 files changed, 147 insertions(+), 1 deletion(-)

...

Quoted 12 lines
drivers/mmc/host/sdhci-brcmstb.c +12 -0
+	if (brcmstb_priv->sde_pcie) {
+		struct of_changeset changeset;
+		static struct property okay_property = {
+			.name = "status",
+			.value = "okay",
+			.length = 5,
+		};
+
+		/* Enable the pcie controller */
+		of_changeset_init(&changeset);
+		ret = of_changeset_update_property(&changeset,
+						   brcmstb_priv->sde_pcie,

drivers/mmc/host/sdhci-brcmstb.c static void sdhci_brcmstb_cfginit_2712(struct sdhci_host *host) · line 368

Quoted 10 lines
drivers/mmc/host/sdhci-brcmstb.c +10 -0
+						   &okay_property);
+		if (ret) {
+			dev_err(dev, "%s: failed to update property - %d\n", __func__,
+			       ret);
+			return -ENODEV;
+		}
+		ret = of_changeset_apply(&changeset);
+	}
+
+	dev_dbg(dev, "%s -> %d\n", __func__, ret);

Is this really useful?

Quoted 3 lines
drivers/mmc/host/sdhci-brcmstb.c +3 -0
+	return ret;
+}
+

...

Quoted 10 lines
drivers/mmc/host/sdhci-brcmstb.c +6 -0
@@ -468,6 +581,24 @@ static int sdhci_brcmstb_probe(struct platform_device *pdev)
  	if (res)
  		goto err;
 
+	priv->sde_1v8 = devm_regulator_get_optional(&pdev->dev, "sde-1v8");
+	if (IS_ERR(priv->sde_1v8))
+		priv->flags &= ~BRCMSTB_PRIV_FLAGS_HAS_SD_EXPRESS;
+
+	iomem = platform_get_resource(pdev, IORESOURCE_MEM, 2);
+	if (iomem) {

drivers/mmc/host/sdhci-brcmstb.c static int sdhci_brcmstb_probe(struct platform_device *pdev) · line 599

Quoted 10 lines
drivers/mmc/host/sdhci-brcmstb.c +10 -0
+		priv->sde_ioaddr = devm_ioremap_resource(&pdev->dev, iomem);
+		if (IS_ERR(priv->sde_ioaddr))
+			priv->sde_ioaddr = NULL;
+	}
+
+	iomem = platform_get_resource(pdev, IORESOURCE_MEM, 3);
+	if (iomem) {
+		priv->sde_ioaddr2 = devm_ioremap_resource(&pdev->dev, iomem);
+		if (IS_ERR(priv->sde_ioaddr2))
+			priv->sde_ioaddr = NULL;

sde_ioaddr2 ?

Quoted 6 lines
drivers/mmc/host/sdhci-brcmstb.c +2 -0
+	}
+
  	priv->pinctrl = devm_pinctrl_get(&pdev->dev);
  	if (IS_ERR(priv->pinctrl)) {
  			no_pinctrl = true;

drivers/mmc/host/sdhci-brcmstb.c static int sdhci_brcmstb_probe(struct platform_device *pdev) · line 615

Quoted 8 lines
drivers/mmc/host/sdhci-brcmstb.c +4 -1
@@ -478,8 +609,16 @@ static int sdhci_brcmstb_probe(struct platform_device *pdev)
  			no_pinctrl = true;
  	}
 
-	if (no_pinctrl )
+	priv->pins_sdex = pinctrl_lookup_state(priv->pinctrl, "sd-express");
+	if (IS_ERR(priv->pins_sdex)) {
+			dev_dbg(&pdev->dev, "No pinctrl sd-express state\n");
+			no_pinctrl = true;

Indentation looks too large.

Quoted 9 lines
drivers/mmc/host/sdhci-brcmstb.c +5 -0
+	}
+
+	if (no_pinctrl || !priv->sde_ioaddr || !priv->sde_ioaddr2) {
  		priv->pinctrl = NULL;
+		priv->flags &= ~BRCMSTB_PRIV_FLAGS_HAS_SD_EXPRESS;
+	}
 
  	/*
  	 * Automatic clock gating does not work for SD cards that may

...

#32 lore raw

Re: [PATCH 6/6] mmc: sdhci-brcmstb: Add BCM2712 SD Express support

Quoted 38 lines · Christophe JAILLET

Le 14/04/2024 à 00:14, Andrea della Porta a écrit :

Quoted 18 lines

Broadcom BCM2712 SDHCI controller is SD Express capable. Add support for sde capability where the implementation is based on downstream driver, diverging from it in the way that init_sd_express callback is invoked:
in downstream the sdhci_ops structure has been augmented with a new function ptr 'init_sd_express' that just propagate the call to the driver specific callback so that the callstack from a structure standpoint is mmc_host_ops -> sdhci_ops. The drawback here is in the added level of indirection (the newly added init_sd_express is redundant) and the sdhci_ops structure declaration has to be changed. To overcome this the presented approach consist in patching the mmc_host_ops init_sd_express callback to point directly to the custom function defined in this driver (see struct brcmstb_match_priv).

---
  drivers/mmc/host/Kconfig         |   1 +
  drivers/mmc/host/sdhci-brcmstb.c | 147 ++++++++++++++++++++++++++++++-
  2 files changed, 147 insertions(+), 1 deletion(-)

...

Quoted 16 lines
drivers/mmc/host/sdhci-brcmstb.c +16 -0
+	if (brcmstb_priv->sde_pcie) {
+		struct of_changeset changeset;
+		static struct property okay_property = {
+			.name = "status",
+			.value = "okay",
+			.length = 5,
+		};
+
+		/* Enable the pcie controller */
+		of_changeset_init(&changeset);
+		ret = of_changeset_update_property(&changeset,
+						   brcmstb_priv->sde_pcie,
+						   &okay_property);
+		if (ret) {
+			dev_err(dev, "%s: failed to update property - %d\n", __func__,
+			       ret);
Quoted 8 lines

drivers/mmc/host/sdhci-brcmstb.c static void sdhci_brcmstb_cfginit_2712(struct sdhci_host *host) · line 368

Quoted 6 lines
drivers/mmc/host/sdhci-brcmstb.c +6 -0
+			return -ENODEV;
+		}
+		ret = of_changeset_apply(&changeset);
+	}
+
+	dev_dbg(dev, "%s -> %d\n", __func__, ret);

Is this really useful?

Not really. Removed.

Quoted 29 lines
Quoted 4 lines
drivers/mmc/host/sdhci-brcmstb.c +3 -0
+	return ret;
+}
+

...

Quoted 9 lines
drivers/mmc/host/sdhci-brcmstb.c +6 -0
@@ -468,6 +581,24 @@ static int sdhci_brcmstb_probe(struct platform_device *pdev)
  	if (res)
  		goto err;
+	priv->sde_1v8 = devm_regulator_get_optional(&pdev->dev, "sde-1v8");
+	if (IS_ERR(priv->sde_1v8))
+		priv->flags &= ~BRCMSTB_PRIV_FLAGS_HAS_SD_EXPRESS;
+
+	iomem = platform_get_resource(pdev, IORESOURCE_MEM, 2);
+	if (iomem) {

drivers/mmc/host/sdhci-brcmstb.c static int sdhci_brcmstb_probe(struct platform_device *pdev) · line 598

Quoted 10 lines
drivers/mmc/host/sdhci-brcmstb.c +10 -0
+		priv->sde_ioaddr = devm_ioremap_resource(&pdev->dev, iomem);
+		if (IS_ERR(priv->sde_ioaddr))
+			priv->sde_ioaddr = NULL;
+	}
+
+	iomem = platform_get_resource(pdev, IORESOURCE_MEM, 3);
+	if (iomem) {
+		priv->sde_ioaddr2 = devm_ioremap_resource(&pdev->dev, iomem);
+		if (IS_ERR(priv->sde_ioaddr2))
+			priv->sde_ioaddr = NULL;

sde_ioaddr2 ?

Quoted 15 lines

drivers/mmc/host/sdhci-brcmstb.c static int sdhci_brcmstb_probe(struct platform_device *pdev) · line 614

Quoted 13 lines
drivers/mmc/host/sdhci-brcmstb.c +6 -1
+	}
+
  	priv->pinctrl = devm_pinctrl_get(&pdev->dev);
  	if (IS_ERR(priv->pinctrl)) {
  			no_pinctrl = true;
@@ -478,8 +609,16 @@ static int sdhci_brcmstb_probe(struct platform_device *pdev)
  			no_pinctrl = true;
  	}
-	if (no_pinctrl )
+	priv->pins_sdex = pinctrl_lookup_state(priv->pinctrl, "sd-express");
+	if (IS_ERR(priv->pins_sdex)) {
+			dev_dbg(&pdev->dev, "No pinctrl sd-express state\n");
+			no_pinctrl = true;

Indentation looks too large.

Ack.

Quoted 12 lines
Quoted 9 lines
drivers/mmc/host/sdhci-brcmstb.c +5 -0
+	}
+
+	if (no_pinctrl || !priv->sde_ioaddr || !priv->sde_ioaddr2) {
  		priv->pinctrl = NULL;
+		priv->flags &= ~BRCMSTB_PRIV_FLAGS_HAS_SD_EXPRESS;
+	}
  	/*
  	 * Automatic clock gating does not work for SD cards that may

...

In general I'll drop SD express patch for now, it will be re-introduced in a future patch.

Best regards,
Andrea

maintainer
#33 lore raw

Re: [PATCH 6/6] mmc: sdhci-brcmstb: Add BCM2712 SD Express support

In reply to Andrea della Porta
Quoted 84 lines · Andrea della Porta

Broadcom BCM2712 SDHCI controller is SD Express capable. Add support for sde capability where the implementation is based on downstream driver, diverging from it in the way that init_sd_express callback is invoked:
in downstream the sdhci_ops structure has been augmented with a new function ptr 'init_sd_express' that just propagate the call to the driver specific callback so that the callstack from a structure standpoint is mmc_host_ops -> sdhci_ops. The drawback here is in the added level of indirection (the newly added init_sd_express is redundant) and the sdhci_ops structure declaration has to be changed. To overcome this the presented approach consist in patching the mmc_host_ops init_sd_express callback to point directly to the custom function defined in this driver (see struct brcmstb_match_priv).

---
  drivers/mmc/host/Kconfig         |   1 +
  drivers/mmc/host/sdhci-brcmstb.c | 147 ++++++++++++++++++++++++++++++-
  2 files changed, 147 insertions(+), 1 deletion(-)
drivers/mmc/host/Kconfig +1 -0
index aebc587f77a7..343ccac1a4e4 100644
@@ -1018,6 +1018,7 @@ config MMC_SDHCI_BRCMSTB
  	depends on ARCH_BRCMSTB || BMIPS_GENERIC || COMPILE_TEST
  	depends on MMC_SDHCI_PLTFM
  	select MMC_CQHCI
+	select OF_DYNAMIC
  	default ARCH_BRCMSTB || BMIPS_GENERIC
  	help
  	  This selects support for the SDIO/SD/MMC Host Controller on
drivers/mmc/host/sdhci-brcmstb.c +24 -0
index 907a4947abe5..56fb34a75ec2 100644
@@ -29,6 +29,7 @@
 
  #define BRCMSTB_PRIV_FLAGS_HAS_CQE		BIT(0)
  #define BRCMSTB_PRIV_FLAGS_GATE_CLOCK		BIT(1)
+#define BRCMSTB_PRIV_FLAGS_HAS_SD_EXPRESS	BIT(2)
 
  #define SDHCI_ARASAN_CQE_BASE_ADDR		0x200
 
@@ -50,13 +51,19 @@ struct sdhci_brcmstb_priv {
  	unsigned int flags;
  	struct clk *base_clk;
  	u32 base_freq_hz;
+	struct regulator *sde_1v8;
+	struct device_node *sde_pcie;
+	void *__iomem sde_ioaddr;
+	void *__iomem sde_ioaddr2;
  	struct pinctrl *pinctrl;
  	struct pinctrl_state *pins_default;
+	struct pinctrl_state *pins_sdex;
  };
 
  struct brcmstb_match_priv {
  	void (*hs400es)(struct mmc_host *mmc, struct mmc_ios *ios);
  	void (*cfginit)(struct sdhci_host *host);
+	int (*init_sd_express)(struct mmc_host *mmc, struct mmc_ios *ios);
  	struct sdhci_ops *ops;
  	const unsigned int flags;
  };
@@ -263,6 +270,105 @@ static void sdhci_brcmstb_cfginit_2712(struct sdhci_host *host)
  	}
  }
 
+static int bcm2712_init_sd_express(struct mmc_host *mmc, struct mmc_ios *ios)
+{
+	struct sdhci_host *host = mmc_priv(mmc);
+	struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host);
+	struct sdhci_brcmstb_priv *brcmstb_priv = sdhci_pltfm_priv(pltfm_host);
+	struct device *dev = host->mmc->parent;
+	u32 ctrl_val;
+	u32 present_state;
+	int ret;
+
+	if (!brcmstb_priv->sde_ioaddr || !brcmstb_priv->sde_ioaddr2)
+		return -EINVAL;
+
+	if (!brcmstb_priv->pinctrl)
+		return -EINVAL;
+
+	/* Turn off the SD clock first */

drivers/mmc/host/sdhci-brcmstb.c static void sdhci_brcmstb_cfginit_2712(struct sdhci_host *host) · line 299

Quoted 10 lines
drivers/mmc/host/sdhci-brcmstb.c +10 -0
+	sdhci_set_clock(host, 0);
+
+	/* Disable SD DAT0-3 pulls */
+	pinctrl_select_state(brcmstb_priv->pinctrl, brcmstb_priv->pins_sdex);
+
+	ctrl_val = readl(brcmstb_priv->sde_ioaddr);
+	dev_dbg(dev, "ctrl_val 1 %08x\n", ctrl_val);
+
+	/* Tri-state the SD pins */
+	ctrl_val |= 0x1ff8;

No magic values please.

drivers/mmc/host/sdhci-brcmstb.c static void sdhci_brcmstb_cfginit_2712(struct sdhci_host *host) · line 303

Quoted 4 lines
drivers/mmc/host/sdhci-brcmstb.c +4 -0
+	writel(ctrl_val, brcmstb_priv->sde_ioaddr);
+	dev_dbg(dev, "ctrl_val 1->%08x (%08x)\n", ctrl_val, readl(brcmstb_priv->sde_ioaddr));
+	/* Let voltages settle */
+	udelay(100);

Why not usleep_range()?

drivers/mmc/host/sdhci-brcmstb.c static void sdhci_brcmstb_cfginit_2712(struct sdhci_host *host) · line 306

Quoted 3 lines
drivers/mmc/host/sdhci-brcmstb.c +3 -0
+
+	/* Enable the PCIe sideband pins */
+	ctrl_val &= ~0x6000;

No magic values please.

drivers/mmc/host/sdhci-brcmstb.c static void sdhci_brcmstb_cfginit_2712(struct sdhci_host *host) · line 303

Quoted 4 lines
drivers/mmc/host/sdhci-brcmstb.c +4 -0
+	writel(ctrl_val, brcmstb_priv->sde_ioaddr);
+	dev_dbg(dev, "ctrl_val 1->%08x (%08x)\n", ctrl_val, readl(brcmstb_priv->sde_ioaddr));
+	/* Let voltages settle */
+	udelay(100);

Likewise.

Quoted 5 lines
drivers/mmc/host/sdhci-brcmstb.c +5 -0
+
+	/* Turn on the 1v8 VDD2 regulator */
+	ret = regulator_enable(brcmstb_priv->sde_1v8);
+	if (ret)
+		return ret;

drivers/mmc/host/sdhci-brcmstb.c static void sdhci_brcmstb_cfginit_2712(struct sdhci_host *host) · line 325

Quoted 10 lines
drivers/mmc/host/sdhci-brcmstb.c +10 -0
+
+	/* Wait for Tpvcrl */
+	msleep(1);
+
+	/* Sample DAT2 (CLKREQ#) - if low, card is in PCIe mode */
+	present_state = sdhci_readl(host, SDHCI_PRESENT_STATE);
+	present_state = (present_state & SDHCI_DATA_LVL_MASK) >> SDHCI_DATA_LVL_SHIFT;
+	dev_dbg(dev, "state = 0x%08x\n", present_state);
+
+	if (present_state & BIT(2)) {

Likewise, replace with constant.

Quoted 31 lines
drivers/mmc/host/sdhci-brcmstb.c +31 -0
+		dev_err(dev, "DAT2 still high, abandoning SDex switch\n");
+		return -ENODEV;
+	}
+
+	/* Turn on the LCPLL PTEST mux */
+	ctrl_val = readl(brcmstb_priv->sde_ioaddr2 + 20); // misc5
+	ctrl_val &= ~(0x7 << 7);
+	ctrl_val |= 3 << 7;
+	writel(ctrl_val, brcmstb_priv->sde_ioaddr2 + 20);
+	dev_dbg(dev, "misc 5->%08x (%08x)\n", ctrl_val, readl(brcmstb_priv->sde_ioaddr2 + 20));
+
+	/* PTEST diff driver enable */
+	ctrl_val = readl(brcmstb_priv->sde_ioaddr2);
+	ctrl_val |= BIT(21);
+	writel(ctrl_val, brcmstb_priv->sde_ioaddr2);
+
+	dev_dbg(dev, "misc 0->%08x (%08x)\n", ctrl_val, readl(brcmstb_priv->sde_ioaddr2));
+
+	/* Wait for more than the minimum Tpvpgl time */
+	msleep(100);
+
+	if (brcmstb_priv->sde_pcie) {
+		struct of_changeset changeset;
+		static struct property okay_property = {
+			.name = "status",
+			.value = "okay",
+			.length = 5,
+		};
+
+		/* Enable the pcie controller */
+		of_changeset_init(&changeset);

drivers/mmc/host/sdhci-brcmstb.c static void sdhci_brcmstb_cfginit_2712(struct sdhci_host *host) · line 366

Quoted 10 lines
drivers/mmc/host/sdhci-brcmstb.c +10 -0
+		ret = of_changeset_update_property(&changeset,
+						   brcmstb_priv->sde_pcie,
+						   &okay_property);
+		if (ret) {
+			dev_err(dev, "%s: failed to update property - %d\n", __func__,
+			       ret);
+			return -ENODEV;
+		}
+		ret = of_changeset_apply(&changeset);
+	}

Why are you doing this? Cannot the firmware enable/disable the node according to the boot mode or something else?

This is not going to fly for upstream, sorry.

Signature · 1 line
Florian
#34 lore raw

Re: [PATCH 6/6] mmc: sdhci-brcmstb: Add BCM2712 SD Express support

Quoted 86 lines · Florian Fainelli
Quoted 83 lines · Andrea della Porta

Broadcom BCM2712 SDHCI controller is SD Express capable. Add support for sde capability where the implementation is based on downstream driver, diverging from it in the way that init_sd_express callback is invoked:
in downstream the sdhci_ops structure has been augmented with a new function ptr 'init_sd_express' that just propagate the call to the driver specific callback so that the callstack from a structure standpoint is mmc_host_ops -> sdhci_ops. The drawback here is in the added level of indirection (the newly added init_sd_express is redundant) and the sdhci_ops structure declaration has to be changed. To overcome this the presented approach consist in patching the mmc_host_ops init_sd_express callback to point directly to the custom function defined in this driver (see struct brcmstb_match_priv).

---
  drivers/mmc/host/Kconfig         |   1 +
  drivers/mmc/host/sdhci-brcmstb.c | 147 ++++++++++++++++++++++++++++++-
  2 files changed, 147 insertions(+), 1 deletion(-)
drivers/mmc/host/Kconfig +1 -0
index aebc587f77a7..343ccac1a4e4 100644
@@ -1018,6 +1018,7 @@ config MMC_SDHCI_BRCMSTB
  	depends on ARCH_BRCMSTB || BMIPS_GENERIC || COMPILE_TEST
  	depends on MMC_SDHCI_PLTFM
  	select MMC_CQHCI
+	select OF_DYNAMIC
  	default ARCH_BRCMSTB || BMIPS_GENERIC
  	help
  	  This selects support for the SDIO/SD/MMC Host Controller on
drivers/mmc/host/sdhci-brcmstb.c +28 -0
index 907a4947abe5..56fb34a75ec2 100644
@@ -29,6 +29,7 @@
  #define BRCMSTB_PRIV_FLAGS_HAS_CQE		BIT(0)
  #define BRCMSTB_PRIV_FLAGS_GATE_CLOCK		BIT(1)
+#define BRCMSTB_PRIV_FLAGS_HAS_SD_EXPRESS	BIT(2)
  #define SDHCI_ARASAN_CQE_BASE_ADDR		0x200
@@ -50,13 +51,19 @@ struct sdhci_brcmstb_priv {
  	unsigned int flags;
  	struct clk *base_clk;
  	u32 base_freq_hz;
+	struct regulator *sde_1v8;
+	struct device_node *sde_pcie;
+	void *__iomem sde_ioaddr;
+	void *__iomem sde_ioaddr2;
  	struct pinctrl *pinctrl;
  	struct pinctrl_state *pins_default;
+	struct pinctrl_state *pins_sdex;
  };
  struct brcmstb_match_priv {
  	void (*hs400es)(struct mmc_host *mmc, struct mmc_ios *ios);
  	void (*cfginit)(struct sdhci_host *host);
+	int (*init_sd_express)(struct mmc_host *mmc, struct mmc_ios *ios);
  	struct sdhci_ops *ops;
  	const unsigned int flags;
  };
@@ -263,6 +270,105 @@ static void sdhci_brcmstb_cfginit_2712(struct sdhci_host *host)
  	}
  }
+static int bcm2712_init_sd_express(struct mmc_host *mmc, struct mmc_ios *ios)
+{
+	struct sdhci_host *host = mmc_priv(mmc);
+	struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host);
+	struct sdhci_brcmstb_priv *brcmstb_priv = sdhci_pltfm_priv(pltfm_host);
+	struct device *dev = host->mmc->parent;
+	u32 ctrl_val;
+	u32 present_state;
+	int ret;
+
+	if (!brcmstb_priv->sde_ioaddr || !brcmstb_priv->sde_ioaddr2)
+		return -EINVAL;
+
+	if (!brcmstb_priv->pinctrl)
+		return -EINVAL;
+
+	/* Turn off the SD clock first */
+	sdhci_set_clock(host, 0);
+
+	/* Disable SD DAT0-3 pulls */
+	pinctrl_select_state(brcmstb_priv->pinctrl, brcmstb_priv->pins_sdex);
Quoted 8 lines

drivers/mmc/host/sdhci-brcmstb.c static void sdhci_brcmstb_cfginit_2712(struct sdhci_host *host) · line 299

Quoted 6 lines
drivers/mmc/host/sdhci-brcmstb.c +6 -0
+
+	ctrl_val = readl(brcmstb_priv->sde_ioaddr);
+	dev_dbg(dev, "ctrl_val 1 %08x\n", ctrl_val);
+
+	/* Tri-state the SD pins */
+	ctrl_val |= 0x1ff8;

No magic values please.

Ack.

Quoted 7 lines

drivers/mmc/host/sdhci-brcmstb.c static void sdhci_brcmstb_cfginit_2712(struct sdhci_host *host) · line 303

Quoted 5 lines
drivers/mmc/host/sdhci-brcmstb.c +4 -0
+	writel(ctrl_val, brcmstb_priv->sde_ioaddr);
+	dev_dbg(dev, "ctrl_val 1->%08x (%08x)\n", ctrl_val, readl(brcmstb_priv->sde_ioaddr));
+	/* Let voltages settle */
+	udelay(100);

Why not usleep_range()?

No real reason. I assume only the lower boundary is critical so I can use usleep_range instead. Will be fixed in a future patch, the SD express support will be drpped in V2 since nto strictly necessary.

Quoted 7 lines

drivers/mmc/host/sdhci-brcmstb.c static void sdhci_brcmstb_cfginit_2712(struct sdhci_host *host) · line 306

Quoted 4 lines
drivers/mmc/host/sdhci-brcmstb.c +3 -0
+
+	/* Enable the PCIe sideband pins */
+	ctrl_val &= ~0x6000;

No magic values please.

Quoted 6 lines

drivers/mmc/host/sdhci-brcmstb.c static void sdhci_brcmstb_cfginit_2712(struct sdhci_host *host) · line 303

Quoted 4 lines
drivers/mmc/host/sdhci-brcmstb.c +4 -0
+	writel(ctrl_val, brcmstb_priv->sde_ioaddr);
+	dev_dbg(dev, "ctrl_val 1->%08x (%08x)\n", ctrl_val, readl(brcmstb_priv->sde_ioaddr));
+	/* Let voltages settle */
+	udelay(100);

Likewise.

Ditto.

Quoted 10 lines
Quoted 10 lines
drivers/mmc/host/sdhci-brcmstb.c +9 -0
+
+	/* Turn on the 1v8 VDD2 regulator */
+	ret = regulator_enable(brcmstb_priv->sde_1v8);
+	if (ret)
+		return ret;
+
+	/* Wait for Tpvcrl */
+	msleep(1);
+
Quoted 8 lines

drivers/mmc/host/sdhci-brcmstb.c static void sdhci_brcmstb_cfginit_2712(struct sdhci_host *host) · line 325

Quoted 6 lines
drivers/mmc/host/sdhci-brcmstb.c +6 -0
+	/* Sample DAT2 (CLKREQ#) - if low, card is in PCIe mode */
+	present_state = sdhci_readl(host, SDHCI_PRESENT_STATE);
+	present_state = (present_state & SDHCI_DATA_LVL_MASK) >> SDHCI_DATA_LVL_SHIFT;
+	dev_dbg(dev, "state = 0x%08x\n", present_state);
+
+	if (present_state & BIT(2)) {

Likewise, replace with constant.

Ack.

Quoted 49 lines
Quoted 32 lines
drivers/mmc/host/sdhci-brcmstb.c +31 -0
+		dev_err(dev, "DAT2 still high, abandoning SDex switch\n");
+		return -ENODEV;
+	}
+
+	/* Turn on the LCPLL PTEST mux */
+	ctrl_val = readl(brcmstb_priv->sde_ioaddr2 + 20); // misc5
+	ctrl_val &= ~(0x7 << 7);
+	ctrl_val |= 3 << 7;
+	writel(ctrl_val, brcmstb_priv->sde_ioaddr2 + 20);
+	dev_dbg(dev, "misc 5->%08x (%08x)\n", ctrl_val, readl(brcmstb_priv->sde_ioaddr2 + 20));
+
+	/* PTEST diff driver enable */
+	ctrl_val = readl(brcmstb_priv->sde_ioaddr2);
+	ctrl_val |= BIT(21);
+	writel(ctrl_val, brcmstb_priv->sde_ioaddr2);
+
+	dev_dbg(dev, "misc 0->%08x (%08x)\n", ctrl_val, readl(brcmstb_priv->sde_ioaddr2));
+
+	/* Wait for more than the minimum Tpvpgl time */
+	msleep(100);
+
+	if (brcmstb_priv->sde_pcie) {
+		struct of_changeset changeset;
+		static struct property okay_property = {
+			.name = "status",
+			.value = "okay",
+			.length = 5,
+		};
+
+		/* Enable the pcie controller */
+		of_changeset_init(&changeset);

drivers/mmc/host/sdhci-brcmstb.c static void sdhci_brcmstb_cfginit_2712(struct sdhci_host *host) · line 366

Quoted 10 lines
drivers/mmc/host/sdhci-brcmstb.c +10 -0
+		ret = of_changeset_update_property(&changeset,
+						   brcmstb_priv->sde_pcie,
+						   &okay_property);
+		if (ret) {
+			dev_err(dev, "%s: failed to update property - %d\n", __func__,
+			       ret);
+			return -ENODEV;
+		}
+		ret = of_changeset_apply(&changeset);
+	}

Why are you doing this? Cannot the firmware enable/disable the node according to the boot mode or something else?

This is not going to fly for upstream, sorry.

Signature · 1 line
Florian
#35 lore raw
In reply to Andrea della Porta

Hi Andrea,

Am 14.04.24 um 00:14 schrieb Andrea della Porta:

Quoted 5 lines

Hi,

This patchset adds support for the SDHCI controller on Broadcom BCM2712 SoC in order to make it possible to boot (particularly) Raspberry Pi 5 from SD card. This work is heavily based on downstream contributions.

since your goal is minimal Raspberry Pi 5 support, i suggest to use this as the subject for this patch.

Quoted 8 lines

Patch #1 and 2: introduce the dt binding definitions for, respectively, the new pin cfg/mux controller and the SD host controller as a preparatory step for the upcoming dts.

Patch #3: add a somewhat reasonable (*almost* bare-minimum) dts to be used to boot Rpi5 boards. Since till now there was no support at all for any 2712 based chipset, both the SoC and board dts plus definitions for the new Pin and SD host controller have been added.

The patch still seems to contain a lot unnecessary stuff (Wifi, BT, SPI), please try to remove as much as possible for the minimal support (just boot via debug UART & SD card) in order to make review easier. Btw this patch must be after pinctrl & SDHCI support.

Quoted 11 lines

Patch #4: the driver supporting the pin controller. Based on [1] and successive fix commits.

Patch #5: add SDHCI support. Based on [2] and the next 2 fix commits. Drop the SD Express implementation for now, that will be added by patch #6.

Patch #6: this patch offers SD Express support and can be considered totally optional. The callback plumbing is slightly different w.r.t. the downstream approach (see [3]), as explained in the patch comment. Not sure what is the best, any comment is highly appreciated.

I don't think this should be necessary for minimal Raspberry Pi 5 support. Maybe this should be addressed later.

More important would be an additional patch which enables the necessary drivers in arm64/defconfig.

Quoted 42 lines

Tested succesfully on Raspberry Pi 5 using an SDxC card as the boot device.

Still untested:
- SD Express due to the lack of an Express capable card. Also, it will need PCIe support first.
- card detection pin, since the sd was the booting and root fs device.

Many thanks,
Andrea

Links:
[1] - https://github.com/raspberrypi/linux/commit/d9b655314a826724538867bf9b6c229d04c25d84
[2] - https://github.com/raspberrypi/linux/commit/e3aa070496e840e72a4dc384718690ea4125fa6a
[3] - https://github.com/raspberrypi/linux/commit/eb1df34db2a9a5b752eba40ee298c4ae87e26e87

Andrea della Porta (6):
dt-bindings: pinctrl: Add support for BCM2712 pin controller
dt-bindings: mmc: Add support for BCM2712 SD host controller
arm64: dts: broadcom: Add support for BCM2712
pinctrl: bcm: Add pinconf/pinmux controller driver for BCM2712
mmc: sdhci-brcmstb: Add BCM2712 support
mmc: sdhci-brcmstb: Add BCM2712 SD Express support

  .../bindings/mmc/brcm,sdhci-brcmstb.yaml      |   51 +-
  .../pinctrl/brcm,bcm2712-pinctrl.yaml         |   99 ++
  arch/arm64/boot/dts/broadcom/Makefile         |    1 +
  .../boot/dts/broadcom/bcm2712-rpi-5-b.dts     |  313 +++++
  arch/arm64/boot/dts/broadcom/bcm2712-rpi.dtsi |   81 ++
  arch/arm64/boot/dts/broadcom/bcm2712.dtsi     |  841 +++++++++++
  drivers/mmc/host/Kconfig                      |    1 +
  drivers/mmc/host/sdhci-brcmstb.c              |  275 ++++
  drivers/pinctrl/bcm/Kconfig                   |    9 +
  drivers/pinctrl/bcm/Makefile                  |    1 +
  drivers/pinctrl/bcm/pinctrl-bcm2712.c         | 1247 +++++++++++++++++
  11 files changed, 2918 insertions(+), 1 deletion(-)

create mode 100644 Documentation/devicetree/bindings/pinctrl/brcm,bcm2712-pinctrl.yaml create mode 100644 arch/arm64/boot/dts/broadcom/bcm2712-rpi-5-b.dts create mode 100644 arch/arm64/boot/dts/broadcom/bcm2712-rpi.dtsi
create mode 100644 arch/arm64/boot/dts/broadcom/bcm2712.dtsi
create mode 100644 drivers/pinctrl/bcm/pinctrl-bcm2712.c

#36 lore raw
Quoted 29 lines · Stefan Wahren

Hi Andrea,

Am 14.04.24 um 00:14 schrieb Andrea della Porta:

Quoted 5 lines

Hi,

This patchset adds support for the SDHCI controller on Broadcom BCM2712 SoC in order to make it possible to boot (particularly) Raspberry Pi 5 from SD card. This work is heavily based on downstream contributions.

since your goal is minimal Raspberry Pi 5 support, i suggest to use this as the subject for this patch.

Quoted 8 lines

Patch #1 and 2: introduce the dt binding definitions for, respectively, the new pin cfg/mux controller and the SD host controller as a preparatory step for the upcoming dts.

Patch #3: add a somewhat reasonable (*almost* bare-minimum) dts to be used to boot Rpi5 boards. Since till now there was no support at all for any 2712 based chipset, both the SoC and board dts plus definitions for the new Pin and SD host controller have been added.

The patch still seems to contain a lot unnecessary stuff (Wifi, BT, SPI), please try to remove as much as possible for the minimal support (just boot via debug UART & SD card) in order to make review easier. Btw this patch must be after pinctrl & SDHCI support.

Quoted 7 lines

Patch #4: the driver supporting the pin controller. Based on [1] and successive fix commits.

Patch #5: add SDHCI support. Based on [2] and the next 2 fix commits. Drop the SD Express implementation for now, that will be added by patch #6.

Quoted 6 lines
Quoted 4 lines

Patch #6: this patch offers SD Express support and can be considered totally optional. The callback plumbing is slightly different w.r.t. the downstream approach (see [3]), as explained in the patch comment. Not sure what is the best, any comment is highly appreciated.

I don't think this should be necessary for minimal Raspberry Pi 5 support. Maybe this should be addressed later.

Thanks for all the feedback. Just a quick note to let you know that I'm working on V2 patchset that will fix all coding-style and dts/binding issues. The new patchset will be significantly smaller and I managed to remove everything that is not strictly needed in order to be able to boot an rpi5 from sd card.

Best regards,
Andrea

maintainer
#37 lore raw
In reply to Andrea della Porta

Andrea,

Quoted 22 lines · Andrea della Porta

Hi,

This patchset adds support for the SDHCI controller on Broadcom BCM2712 SoC in order to make it possible to boot (particularly) Raspberry Pi 5 from SD card. This work is heavily based on downstream contributions.

Patch #1 and 2: introduce the dt binding definitions for, respectively, the new pin cfg/mux controller and the SD host controller as a preparatory step for the upcoming dts.

Patch #3: add a somewhat reasonable (*almost* bare-minimum) dts to be used to boot Rpi5 boards. Since till now there was no support at all for any 2712 based chipset, both the SoC and board dts plus definitions for the new Pin and SD host controller have been added.

Patch #4: the driver supporting the pin controller. Based on [1] and successive fix commits.

Patch #5: add SDHCI support. Based on [2] and the next 2 fix commits. Drop the SD Express implementation for now, that will be added by patch #6.

Quoted 6 lines

Patch #6: this patch offers SD Express support and can be considered totally optional. The callback plumbing is slightly different w.r.t. the downstream approach (see [3]), as explained in the patch comment. Not sure what is the best, any comment is highly appreciated.

Tested succesfully on Raspberry Pi 5 using an SDxC card as the boot device.

You really need to improve upon the quality of the patches you are submitting, they are not passing checkpatch.pl for coding style and this is seriously concerning.

It sounds like these patches are sent out just to tick a box that an effort has been made to upstream them, that is not how upstream works, so please send some quality time on getting them in tip top shape. Thank you.

Signature · 1 line
Florian
maintainer
#38 lore raw
In reply to Andrea della Porta
Quoted 68 lines · Andrea della Porta

Hi,

This patchset adds support for the SDHCI controller on Broadcom BCM2712 SoC in order to make it possible to boot (particularly) Raspberry Pi 5 from SD card. This work is heavily based on downstream contributions.

Patch #1 and 2: introduce the dt binding definitions for, respectively, the new pin cfg/mux controller and the SD host controller as a preparatory step for the upcoming dts.

Patch #3: add a somewhat reasonable (*almost* bare-minimum) dts to be used to boot Rpi5 boards. Since till now there was no support at all for any 2712 based chipset, both the SoC and board dts plus definitions for the new Pin and SD host controller have been added.

Patch #4: the driver supporting the pin controller. Based on [1] and successive fix commits.

Patch #5: add SDHCI support. Based on [2] and the next 2 fix commits. Drop the SD Express implementation for now, that will be added by patch #6.

Patch #6: this patch offers SD Express support and can be considered totally optional. The callback plumbing is slightly different w.r.t. the downstream approach (see [3]), as explained in the patch comment. Not sure what is the best, any comment is highly appreciated.

Tested succesfully on Raspberry Pi 5 using an SDxC card as the boot device.

Still untested:
- SD Express due to the lack of an Express capable card. Also, it will need PCIe support first.
- card detection pin, since the sd was the booting and root fs device.

Many thanks,
Andrea

Links:
[1] - https://github.com/raspberrypi/linux/commit/d9b655314a826724538867bf9b6c229d04c25d84
[2] - https://github.com/raspberrypi/linux/commit/e3aa070496e840e72a4dc384718690ea4125fa6a
[3] - https://github.com/raspberrypi/linux/commit/eb1df34db2a9a5b752eba40ee298c4ae87e26e87

Andrea della Porta (6):
dt-bindings: pinctrl: Add support for BCM2712 pin controller
dt-bindings: mmc: Add support for BCM2712 SD host controller
arm64: dts: broadcom: Add support for BCM2712
pinctrl: bcm: Add pinconf/pinmux controller driver for BCM2712
mmc: sdhci-brcmstb: Add BCM2712 support
mmc: sdhci-brcmstb: Add BCM2712 SD Express support

 .../bindings/mmc/brcm,sdhci-brcmstb.yaml      |   51 +-
 .../pinctrl/brcm,bcm2712-pinctrl.yaml         |   99 ++
 arch/arm64/boot/dts/broadcom/Makefile         |    1 +
 .../boot/dts/broadcom/bcm2712-rpi-5-b.dts     |  313 +++++
 arch/arm64/boot/dts/broadcom/bcm2712-rpi.dtsi |   81 ++
 arch/arm64/boot/dts/broadcom/bcm2712.dtsi     |  841 +++++++++++
 drivers/mmc/host/Kconfig                      |    1 +
 drivers/mmc/host/sdhci-brcmstb.c              |  275 ++++
 drivers/pinctrl/bcm/Kconfig                   |    9 +
 drivers/pinctrl/bcm/Makefile                  |    1 +
 drivers/pinctrl/bcm/pinctrl-bcm2712.c         | 1247 +++++++++++++++++
 11 files changed, 2918 insertions(+), 1 deletion(-)
 create mode 100644 Documentation/devicetree/bindings/pinctrl/brcm,bcm2712-pinctrl.yaml
 create mode 100644 arch/arm64/boot/dts/broadcom/bcm2712-rpi-5-b.dts
 create mode 100644 arch/arm64/boot/dts/broadcom/bcm2712-rpi.dtsi
 create mode 100644 arch/arm64/boot/dts/broadcom/bcm2712.dtsi
 create mode 100644 drivers/pinctrl/bcm/pinctrl-bcm2712.c
Quoted 5 lines

--
2.35.3

My bot found new DTB warnings on the .dts files added or changed in this series.

Some warnings may be from an existing SoC .dtsi. Or perhaps the warnings are fixed by another series. Ultimately, it is up to the platform maintainer whether these warnings are acceptable or not. No need to reply unless the platform maintainer has comments.

If you already ran DT checks and didn't see these error(s), then make sure dt-schema is up to date:

  pip3 install dtschema --upgrade

New warnings running 'make CHECK_DTBS=y broadcom/bcm2712-rpi-5-b.dtb' for [email protected]:

arch/arm64/boot/dts/broadcom/bcm2712.dtsi:554.26-565.5: Warning (interrupt_provider): /soc/gpio@7d517c00: '#interrupt-cells' found, but node is not an interrupt provider
also defined at arch/arm64/boot/dts/broadcom/bcm2712-rpi-5-b.dts:201.10-206.3
also defined at arch/arm64/boot/dts/broadcom/bcm2712-rpi-5-b.dts:259.10-288.3
arch/arm64/boot/dts/broadcom/bcm2712-rpi-5-b.dtb: Warning (interrupt_map): Failed prerequisite 'interrupt_provider'
arch/arm64/boot/dts/broadcom/bcm2712-rpi-5-b.dtb: /: failed to match any schema with compatible: ['raspberrypi,5-model-b', 'brcm,bcm2712']
arch/arm64/boot/dts/broadcom/bcm2712-rpi-5-b.dtb: /: failed to match any schema with compatible: ['raspberrypi,5-model-b', 'brcm,bcm2712']
arch/arm64/boot/dts/broadcom/bcm2712-rpi-5-b.dtb: thermal-zones: cpu-thermal:trips:phandle: [[43]] is not of type 'object'
from schema $id: http://devicetree.org/schemas/thermal/thermal-zones.yaml#
arch/arm64/boot/dts/broadcom/bcm2712-rpi-5-b.dtb: soc: firmware: {'compatible': ['raspberrypi,bcm2835-firmware', 'simple-mfd'], '#address-cells': [[1]], '#size-cells': [[1]], 'mboxes': [[15]], 'dma-ranges': True, 'phandle': [[16]], 'clocks': {'compatible': ['raspberrypi,firmware-clocks'], '#clock-cells': [[1]], 'phandle': [[95]]}, 'reset': {'compatible': ['raspberrypi,firmware-reset'], '#reset-cells': [[1]], 'phandle': [[96]]}} should not be valid under {'type': 'object'}
from schema $id: http://devicetree.org/schemas/simple-bus.yaml#
arch/arm64/boot/dts/broadcom/bcm2712-rpi-5-b.dtb: soc: power: {'compatible': ['raspberrypi,bcm2835-power'], 'firmware': [[16]], '#power-domain-cells': [[1]], 'phandle': [[97]]} should not be valid under {'type': 'object'}
from schema $id: http://devicetree.org/schemas/simple-bus.yaml#
arch/arm64/boot/dts/broadcom/bcm2712-rpi-5-b.dtb: soc: fixedregulator_3v3: {'compatible': ['regulator-fixed'], 'regulator-always-on': True, 'regulator-max-microvolt': [[3300000]], 'regulator-min-microvolt': [[3300000]], 'regulator-name': ['3v3'], 'phandle': [[98]]} should not be valid under {'type': 'object'}
from schema $id: http://devicetree.org/schemas/simple-bus.yaml#
arch/arm64/boot/dts/broadcom/bcm2712-rpi-5-b.dtb: soc: fixedregulator_5v0: {'compatible': ['regulator-fixed'], 'regulator-always-on': True, 'regulator-max-microvolt': [[5000000]], 'regulator-min-microvolt': [[5000000]], 'regulator-name': ['5v0'], 'phandle': [[99]]} should not be valid under {'type': 'object'}
from schema $id: http://devicetree.org/schemas/simple-bus.yaml#
arch/arm64/boot/dts/broadcom/bcm2712-rpi-5-b.dtb: /soc/timer@7c003000: failed to match any schema with compatible: ['brcm,bcm2835-system-timer']
arch/arm64/boot/dts/broadcom/bcm2712-rpi-5-b.dtb: /soc/local_intc@7cd00000: failed to match any schema with compatible: ['brcm,bcm2836-l1-intc']
arch/arm64/boot/dts/broadcom/bcm2712-rpi-5-b.dtb: /soc/i2s@7d003000: failed to match any schema with compatible: ['brcm,bcm2835-i2s']
arch/arm64/boot/dts/broadcom/bcm2712-rpi-5-b.dtb: /soc/spi@7d004000: failed to match any schema with compatible: ['brcm,bcm2835-spi']
arch/arm64/boot/dts/broadcom/bcm2712-rpi-5-b.dtb: /soc/spi@7d004000/spidev@0: failed to match any schema with compatible: ['spidev']
arch/arm64/boot/dts/broadcom/bcm2712-rpi-5-b.dtb: /soc/spi@7d004600: failed to match any schema with compatible: ['brcm,bcm2835-spi']
arch/arm64/boot/dts/broadcom/bcm2712-rpi-5-b.dtb: /soc/spi@7d004800: failed to match any schema with compatible: ['brcm,bcm2835-spi']
arch/arm64/boot/dts/broadcom/bcm2712-rpi-5-b.dtb: /soc/spi@7d004a00: failed to match any schema with compatible: ['brcm,bcm2835-spi']
arch/arm64/boot/dts/broadcom/bcm2712-rpi-5-b.dtb: /soc/spi@7d004c00: failed to match any schema with compatible: ['brcm,bcm2835-spi']
arch/arm64/boot/dts/broadcom/bcm2712-rpi-5-b.dtb: pwm@7d00c000: 'assigned-clocks' is a dependency of 'assigned-clock-rates'
from schema $id: http://devicetree.org/schemas/clock/clock.yaml#
arch/arm64/boot/dts/broadcom/bcm2712-rpi-5-b.dtb: pwm@7d00c800: 'assigned-clocks' is a dependency of 'assigned-clock-rates'
from schema $id: http://devicetree.org/schemas/clock/clock.yaml#
arch/arm64/boot/dts/broadcom/bcm2712-rpi-5-b.dtb: /soc/cprman@7d202000: failed to match any schema with compatible: ['brcm,bcm2711-cprman']
arch/arm64/boot/dts/broadcom/bcm2712-rpi-5-b.dtb: intc@7d503000: $nodename:0: 'intc@7d503000' does not match '^interrupt-controller(@[0-9a-f,]+)*$'
from schema $id: http://devicetree.org/schemas/interrupt-controller/brcm,l2-intc.yaml#
arch/arm64/boot/dts/broadcom/bcm2712-rpi-5-b.dtb: intc@7d508380: $nodename:0: 'intc@7d508380' does not match '^interrupt-controller(@[0-9a-f,]+)*$'
from schema $id: http://devicetree.org/schemas/interrupt-controller/brcm,l2-intc.yaml#
arch/arm64/boot/dts/broadcom/bcm2712-rpi-5-b.dtb: intc@7d508400: $nodename:0: 'intc@7d508400' does not match '^interrupt-controller(@[0-9a-f,]+)*$'
from schema $id: http://devicetree.org/schemas/interrupt-controller/brcm,l2-intc.yaml#
arch/arm64/boot/dts/broadcom/bcm2712-rpi-5-b.dtb: gpio@7d508500: compatible:0: 'brcm,brcmstb-gpio' is not one of ['brcm,bcm7445-gpio']
from schema $id: http://devicetree.org/schemas/gpio/brcm,brcmstb-gpio.yaml#
arch/arm64/boot/dts/broadcom/bcm2712-rpi-5-b.dtb: gpio@7d508500: compatible: ['brcm,brcmstb-gpio'] is too short
from schema $id: http://devicetree.org/schemas/gpio/brcm,brcmstb-gpio.yaml#
arch/arm64/boot/dts/broadcom/bcm2712-rpi-5-b.dtb: gpio@7d508500: 'brcm,gpio-direct', 'gpio-line-names' do not match any of the regexes: 'pinctrl-[0-9]+'
from schema $id: http://devicetree.org/schemas/gpio/brcm,brcmstb-gpio.yaml#
arch/arm64/boot/dts/broadcom/bcm2712-rpi-5-b.dtb: intc@7d517000: $nodename:0: 'intc@7d517000' does not match '^interrupt-controller(@[0-9a-f,]+)*$'
from schema $id: http://devicetree.org/schemas/interrupt-controller/brcm,l2-intc.yaml#
arch/arm64/boot/dts/broadcom/bcm2712-rpi-5-b.dtb: pwm@7d517a80: #pwm-cells:0:0: 2 was expected
from schema $id: http://devicetree.org/schemas/pwm/brcm,bcm7038-pwm.yaml#
arch/arm64/boot/dts/broadcom/bcm2712-rpi-5-b.dtb: intc@7d517ac0: $nodename:0: 'intc@7d517ac0' does not match '^interrupt-controller(@[0-9a-f,]+)*$'
from schema $id: http://devicetree.org/schemas/interrupt-controller/brcm,l2-intc.yaml#
arch/arm64/boot/dts/broadcom/bcm2712-rpi-5-b.dtb: intc@7d517b00: $nodename:0: 'intc@7d517b00' does not match '^interrupt-controller(@[0-9a-f,]+)*$'
from schema $id: http://devicetree.org/schemas/interrupt-controller/brcm,l2-intc.yaml#
arch/arm64/boot/dts/broadcom/bcm2712-rpi-5-b.dtb: gpio@7d517c00: compatible:0: 'brcm,brcmstb-gpio' is not one of ['brcm,bcm7445-gpio']
from schema $id: http://devicetree.org/schemas/gpio/brcm,brcmstb-gpio.yaml#
arch/arm64/boot/dts/broadcom/bcm2712-rpi-5-b.dtb: gpio@7d517c00: compatible: ['brcm,brcmstb-gpio'] is too short
from schema $id: http://devicetree.org/schemas/gpio/brcm,brcmstb-gpio.yaml#
arch/arm64/boot/dts/broadcom/bcm2712-rpi-5-b.dtb: gpio@7d517c00: 'brcm,gpio-direct', 'gpio-line-names' do not match any of the regexes: 'pinctrl-[0-9]+'
from schema $id: http://devicetree.org/schemas/gpio/brcm,brcmstb-gpio.yaml#
arch/arm64/boot/dts/broadcom/bcm2712-rpi-5-b.dtb: /soc/avs-monitor@7d542000: failed to match any schema with compatible: ['brcm,bcm2711-avs-monitor', 'syscon', 'simple-mfd']
arch/arm64/boot/dts/broadcom/bcm2712-rpi-5-b.dtb: firmware: '#address-cells', '#size-cells', 'dma-ranges' do not match any of the regexes: 'pinctrl-[0-9]+'
from schema $id: http://devicetree.org/schemas/arm/bcm/raspberrypi,bcm2835-firmware.yaml#
arch/arm64/boot/dts/broadcom/bcm2712-rpi-5-b.dtb: /soc/power: failed to match any schema with compatible: ['raspberrypi,bcm2835-power']
arch/arm64/boot/dts/broadcom/bcm2712-rpi-5-b.dtb: l3-cache: 'cache-unified' is a dependency of 'cache-size'
from schema $id: http://devicetree.org/schemas/cache.yaml#
arch/arm64/boot/dts/broadcom/bcm2712-rpi-5-b.dtb: l3-cache: 'cache-unified' is a dependency of 'cache-sets'
from schema $id: http://devicetree.org/schemas/cache.yaml#
arch/arm64/boot/dts/broadcom/bcm2712-rpi-5-b.dtb: l3-cache: 'cache-unified' is a dependency of 'cache-line-size'
from schema $id: http://devicetree.org/schemas/cache.yaml#
arch/arm64/boot/dts/broadcom/bcm2712-rpi-5-b.dtb: l3-cache: 'cache-unified' is a required property
from schema $id: http://devicetree.org/schemas/cache.yaml#
arch/arm64/boot/dts/broadcom/bcm2712-rpi-5-b.dtb: l3-cache: Unevaluated properties are not allowed ('cache-level', 'cache-line-size', 'cache-sets', 'cache-size' were unexpected)
from schema $id: http://devicetree.org/schemas/cache.yaml#
arch/arm64/boot/dts/broadcom/bcm2712-rpi-5-b.dtb: pwr_button: 'pwr' does not match any of the regexes: '^(button|event|key|switch|(button|event|key|switch)-[a-z0-9-]+|[a-z0-9-]+-(button|event|key|switch))$', 'pinctrl-[0-9]+'
from schema $id: http://devicetree.org/schemas/input/gpio-keys.yaml#