Skip to contentSkip to conversation

powerpc: Nintendo Wii U support

PATCH Superseded Ash Logan 9 participants 85 messages Mar 2, 2022 – Feb 20, 2024

Subsystems (4)
lore
Share & tools
lore

Ash Logan

author
#0 lore raw

cover powerpc: Nintendo Wii U support

The following patches add basic support for the Nintendo Wii U video game console, a PowerPC system somewhat similar to the GameCube and Wii.

This includes:
- devicetree source
- bootwrapper support
- udbg console to bootloader
- early udbg console
- interrupt controllers
- platform support
- recognition of the Espresso processor
- workaround for the discontiguous RAM blocks

This is enough to boot on hardware. dmesg pics (with a small hack to udbg-immortal, not included):

Some of the design choices (new platform > embedded6xx) were discussed previously:

Turns out even less changes were needed than previously anticipated for discontiguous memory, and KUAP is yet to give trouble. Thanks to those who helped and discussed this.

Ash Logan (11):
dt-bindings: wiiu: Document the Nintendo Wii U devicetree
powerpc: wiiu: device tree
powerpc: wiiu: bootwrapper support
powerpc: wiiu: introduce wiiu platform
powerpc: wiiu: declare as non-coherent
powerpc: wiiu: udbg support for latteipc
powerpc: wiiu: espresso interrupt controller support
powerpc: wiiu: latte interrupt controller support
powerpc: wiiu: platform support
powerpc: wiiu: don't enforce flat memory
powerpc: wiiu: Add minimal default config

Roberto Van Eeden (1):
powerpc: espresso processor support

 .../bindings/powerpc/nintendo/wiiu.yaml       |  28 ++
 .../powerpc/nintendo/wiiu/espresso-pic.yaml   |  42 +++
 .../bindings/powerpc/nintendo/wiiu/gpu7.yaml  |  41 +++
 .../powerpc/nintendo/wiiu/latte-ahci.yaml     |  43 +++
 .../powerpc/nintendo/wiiu/latte-dsp.yaml      |  35 ++
 .../powerpc/nintendo/wiiu/latte-pic.yaml      |  46 +++
 .../powerpc/nintendo/wiiu/latte-sdhci.yaml    |  40 +++
 .../bindings/powerpc/nintendo/wiiu/latte.yaml |  25 ++
 arch/powerpc/Kconfig.debug                    |   9 +
 arch/powerpc/boot/Makefile                    |   4 +
 arch/powerpc/boot/dts/wiiu.dts                | 327 ++++++++++++++++++
 arch/powerpc/boot/wiiu-head.S                 | 103 ++++++
 arch/powerpc/boot/wiiu.c                      |  73 ++++
 arch/powerpc/boot/wrapper                     |   4 +
 arch/powerpc/configs/wiiu_defconfig           |   7 +
 arch/powerpc/include/asm/udbg.h               |   1 +
 arch/powerpc/kernel/cputable.c                |  16 +
 arch/powerpc/kernel/head_book3s_32.S          |  20 ++
 arch/powerpc/kernel/udbg.c                    |   3 +
 arch/powerpc/mm/init_32.c                     |   4 +-
 arch/powerpc/platforms/Kconfig                |   1 +
 arch/powerpc/platforms/Kconfig.cputype        |   2 +-
 arch/powerpc/platforms/Makefile               |   1 +
 arch/powerpc/platforms/wiiu/Kconfig           |  19 +
 arch/powerpc/platforms/wiiu/Makefile          |   4 +
 arch/powerpc/platforms/wiiu/espresso-pic.c    | 183 ++++++++++
 arch/powerpc/platforms/wiiu/espresso-pic.h    |  59 ++++
 arch/powerpc/platforms/wiiu/latte-pic.c       | 259 ++++++++++++++
 arch/powerpc/platforms/wiiu/latte-pic.h       |  23 ++
 arch/powerpc/platforms/wiiu/setup.c           |  67 ++++
 arch/powerpc/platforms/wiiu/udbg_latteipc.c   | 122 +++++++
 arch/powerpc/platforms/wiiu/udbg_latteipc.h   |  27 ++
 32 files changed, 1635 insertions(+), 3 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/powerpc/nintendo/wiiu.yaml
 create mode 100644 Documentation/devicetree/bindings/powerpc/nintendo/wiiu/espresso-pic.yaml
 create mode 100644 Documentation/devicetree/bindings/powerpc/nintendo/wiiu/gpu7.yaml
 create mode 100644 Documentation/devicetree/bindings/powerpc/nintendo/wiiu/latte-ahci.yaml
 create mode 100644 Documentation/devicetree/bindings/powerpc/nintendo/wiiu/latte-dsp.yaml
 create mode 100644 Documentation/devicetree/bindings/powerpc/nintendo/wiiu/latte-pic.yaml
 create mode 100644 Documentation/devicetree/bindings/powerpc/nintendo/wiiu/latte-sdhci.yaml
 create mode 100644 Documentation/devicetree/bindings/powerpc/nintendo/wiiu/latte.yaml
 create mode 100644 arch/powerpc/boot/dts/wiiu.dts
 create mode 100644 arch/powerpc/boot/wiiu-head.S
 create mode 100644 arch/powerpc/boot/wiiu.c
 create mode 100644 arch/powerpc/configs/wiiu_defconfig
 create mode 100644 arch/powerpc/platforms/wiiu/Kconfig
 create mode 100644 arch/powerpc/platforms/wiiu/Makefile
 create mode 100644 arch/powerpc/platforms/wiiu/espresso-pic.c
 create mode 100644 arch/powerpc/platforms/wiiu/espresso-pic.h
 create mode 100644 arch/powerpc/platforms/wiiu/latte-pic.c
 create mode 100644 arch/powerpc/platforms/wiiu/latte-pic.h
 create mode 100644 arch/powerpc/platforms/wiiu/setup.c
 create mode 100644 arch/powerpc/platforms/wiiu/udbg_latteipc.c
 create mode 100644 arch/powerpc/platforms/wiiu/udbg_latteipc.h

base-commit: df0cc57e057f18e44dac8e6c18aba47ab53202f9

Signature · 1 line
2.35.1
author
#1 lore raw

PATCH 1/12 dt-bindings: wiiu: Document the Nintendo Wii U devicetree

Adds schema for the various Wii U devicetree nodes used.

---
 .../bindings/powerpc/nintendo/wiiu.yaml       | 28 +++++++++++
 .../powerpc/nintendo/wiiu/espresso-pic.yaml   | 42 +++++++++++++++++
 .../bindings/powerpc/nintendo/wiiu/gpu7.yaml  | 41 +++++++++++++++++
 .../powerpc/nintendo/wiiu/latte-ahci.yaml     | 43 +++++++++++++++++
 .../powerpc/nintendo/wiiu/latte-dsp.yaml      | 35 ++++++++++++++
 .../powerpc/nintendo/wiiu/latte-pic.yaml      | 46 +++++++++++++++++++
 .../powerpc/nintendo/wiiu/latte-sdhci.yaml    | 40 ++++++++++++++++
 .../bindings/powerpc/nintendo/wiiu/latte.yaml | 25 ++++++++++
 8 files changed, 300 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/powerpc/nintendo/wiiu.yaml
 create mode 100644 Documentation/devicetree/bindings/powerpc/nintendo/wiiu/espresso-pic.yaml
 create mode 100644 Documentation/devicetree/bindings/powerpc/nintendo/wiiu/gpu7.yaml
 create mode 100644 Documentation/devicetree/bindings/powerpc/nintendo/wiiu/latte-ahci.yaml
 create mode 100644 Documentation/devicetree/bindings/powerpc/nintendo/wiiu/latte-dsp.yaml
 create mode 100644 Documentation/devicetree/bindings/powerpc/nintendo/wiiu/latte-pic.yaml
 create mode 100644 Documentation/devicetree/bindings/powerpc/nintendo/wiiu/latte-sdhci.yaml
 create mode 100644 Documentation/devicetree/bindings/powerpc/nintendo/wiiu/latte.yaml
Documentation/devicetree/bindings/powerpc/nintendo/wiiu.yaml new file +28 -0
new file mode 100644
index 000000000000..5824b07928f5
@@ -0,0 +1,28 @@
+# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause
+%YAML 1.2
+---
+
+$id: http://devicetree.org/schemas/powerpc/nintendo/wiiu.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Nintendo Wii U bindings
+
+maintainers:
+  - Ash Logan <[email protected]>
+  - Emmanuel Gil Peyrot <[email protected]>
+
+description: |
+  Nintendo Wii U video game console binding.
+
+properties:
+  $nodename:
+    const: "/"
+  compatible:
+    oneOf:
+      - description: Nintendo Wii U video game console
+        items:
+          - const: nintendo,wiiu
+
+additionalProperties: true
+
+...
Documentation/devicetree/bindings/powerpc/nintendo/wiiu/espresso-pic.yaml new file +42 -0

42 lines not on this page · raw message

Documentation/devicetree/bindings/powerpc/nintendo/wiiu/gpu7.yaml new file +41 -0

41 lines not on this page · raw message

Documentation/devicetree/bindings/powerpc/nintendo/wiiu/latte-ahci.yaml new file +43 -0

43 lines not on this page · raw message

Documentation/devicetree/bindings/powerpc/nintendo/wiiu/latte-dsp.yaml new file +35 -0
new file mode 100644
index 000000000000..ed0b4c28ce48
@@ -0,0 +1,35 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/powerpc/nintendo/wiiu/latte-dsp.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Nintendo Wii U Latte DSP
+
+maintainers:
+  - Ash Logan <[email protected]>
+  - Emmanuel Gil Peyrot <[email protected]>
+
+description: |
+  Nintendo Wii U digital signal processor, as found in the Latte chip.
+
+properties:
+  compatible:
+    oneOf:
+      - description: Nintendo Wii U Latte DSP
+        items:
+          - const: nintendo,latte-dsp
+  reg:
+    items:
+      - description: DSP registers
+
+# Once more is known about this device more properties will likely be added
+additionalProperties: true
+
+examples:
+  - |
+    latte_dsp: dsp@c005000 {
+         compatible = "nintendo,latte-dsp";
+         reg = <0x0c005000 0x200>;
+    };
+...
Documentation/devicetree/bindings/powerpc/nintendo/wiiu/latte-pic.yaml new file +46 -0

46 lines not on this page · raw message

Documentation/devicetree/bindings/powerpc/nintendo/wiiu/latte-sdhci.yaml new file +40 -0
new file mode 100644
index 000000000000..4b9b0820edc1
@@ -0,0 +1,40 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/powerpc/nintendo/wiiu/latte-sdhci.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Nintendo Wii U Latte SD Host controller
+
+maintainers:
+  - Ash Logan <[email protected]>
+  - Emmanuel Gil Peyrot <[email protected]>
+
+description: |
+  SDHCI hosts found on the Nintendo Wii U's Latte SoC for SD cards and SDIO devices.
+
+properties:
+  compatible:
+    oneOf:
+      - description: Nintendo Wii U Latte SDHCI
+        items:
+          - const: nintendo,latte-sdhci
+          - const: sdhci
+  reg:
+    items:
+      - description: Core registers
+  interrupts:
+    items:
+      - description: SDHCI interrupt
+
+additionalProperties: false
+
+examples:
+  - |
+    sdcard_0: sdhci@d070000 {
+          compatible = "nintendo,latte-sdhci","sdhci";
+          reg = <0x0d070000 0x200>;
+          interrupts = <7>;
+          interrupt-parent = <&latte_pic>;
+    };
+...
Documentation/devicetree/bindings/powerpc/nintendo/wiiu/latte.yaml new file +25 -0
new file mode 100644
index 000000000000..6ae86d198fa3
@@ -0,0 +1,25 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/powerpc/nintendo/wiiu/latte.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Latte system bus
+
+maintainers:
+  - Ash Logan <[email protected]>
+  - Emmanuel Gil Peyrot <[email protected]>
+
+description: |
+  Latte multi-function SoC, containing many of the devices found on the Nintendo Wii U.
+
+properties:
+  compatible:
+    oneOf:
+      - description: Nintendo Wii U "Latte" SoC
+        items:
+          - const: nintendo,latte
+
+additionalProperties: true
+
+...
Signature · 1 line
2.35.1
#2 lore raw

Re: [PATCH 01/12] dt-bindings: wiiu: Document the Nintendo Wii U devicetree

Quoted 2 lines · Ash Logan

Adds schema for the various Wii U devicetree nodes used.

Please resend to the DT list if you want this reviewed and so that checks run.

Quoted 372 lines
---
 .../bindings/powerpc/nintendo/wiiu.yaml       | 28 +++++++++++
 .../powerpc/nintendo/wiiu/espresso-pic.yaml   | 42 +++++++++++++++++
 .../bindings/powerpc/nintendo/wiiu/gpu7.yaml  | 41 +++++++++++++++++
 .../powerpc/nintendo/wiiu/latte-ahci.yaml     | 43 +++++++++++++++++
 .../powerpc/nintendo/wiiu/latte-dsp.yaml      | 35 ++++++++++++++
 .../powerpc/nintendo/wiiu/latte-pic.yaml      | 46 +++++++++++++++++++
 .../powerpc/nintendo/wiiu/latte-sdhci.yaml    | 40 ++++++++++++++++
 .../bindings/powerpc/nintendo/wiiu/latte.yaml | 25 ++++++++++
 8 files changed, 300 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/powerpc/nintendo/wiiu.yaml
 create mode 100644 Documentation/devicetree/bindings/powerpc/nintendo/wiiu/espresso-pic.yaml
 create mode 100644 Documentation/devicetree/bindings/powerpc/nintendo/wiiu/gpu7.yaml
 create mode 100644 Documentation/devicetree/bindings/powerpc/nintendo/wiiu/latte-ahci.yaml
 create mode 100644 Documentation/devicetree/bindings/powerpc/nintendo/wiiu/latte-dsp.yaml
 create mode 100644 Documentation/devicetree/bindings/powerpc/nintendo/wiiu/latte-pic.yaml
 create mode 100644 Documentation/devicetree/bindings/powerpc/nintendo/wiiu/latte-sdhci.yaml
 create mode 100644 Documentation/devicetree/bindings/powerpc/nintendo/wiiu/latte.yaml
Documentation/devicetree/bindings/powerpc/nintendo/wiiu.yaml new file +28 -0
new file mode 100644
index 000000000000..5824b07928f5
@@ -0,0 +1,28 @@
+# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause
+%YAML 1.2
+---
+
+$id: http://devicetree.org/schemas/powerpc/nintendo/wiiu.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Nintendo Wii U bindings
+
+maintainers:
+  - Ash Logan <[email protected]>
+  - Emmanuel Gil Peyrot <[email protected]>
+
+description: |
+  Nintendo Wii U video game console binding.
+
+properties:
+  $nodename:
+    const: "/"
+  compatible:
+    oneOf:
+      - description: Nintendo Wii U video game console
+        items:
+          - const: nintendo,wiiu
+
+additionalProperties: true
+
+...
Documentation/devicetree/bindings/powerpc/nintendo/wiiu/espresso-pic.yaml new file +42 -0
new file mode 100644
index 000000000000..878a81595f5f
@@ -0,0 +1,42 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/powerpc/nintendo/wiiu/espresso-pic.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Nintendo Wii U "Espresso" interrupt controller
+
+maintainers:
+  - Ash Logan <[email protected]>
+  - Emmanuel Gil Peyrot <[email protected]>
+
+description: |
+  Interrupt controller found on the Nintendo Wii U for the "Espresso" processor.
+
+properties:
+  compatible:
+    oneOf:
+      - description: Nintendo Wii U "Espresso" interrupt controller
+        items:
+          - const: nintendo,espresso-pic
+  '#interrupt-cells':
+    # Interrupt numbers 0-32 in one cell
+    const: 1
+  interrupt-controller: true
+  reg:
+    items:
+      - description: Core registers
+
+additionalProperties: false
+
+examples:
+  - |
+    espresso_pic: pic@c000078 {
+            #interrupt-cells = <1>;
+            interrupt-controller;
+
+            compatible = "nintendo,espresso-pic";
+            reg = <0x0c000078 0x18>;
+    };
+
+...
Documentation/devicetree/bindings/powerpc/nintendo/wiiu/gpu7.yaml new file +41 -0
new file mode 100644
index 000000000000..e54d49015f36
@@ -0,0 +1,41 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/powerpc/nintendo/wiiu/gpu7.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Nintendo Wii U Latte "GPU7" graphics processor
+
+maintainers:
+  - Ash Logan <[email protected]>
+  - Emmanuel Gil Peyrot <[email protected]>
+
+description: |
+  GPU7 graphics processor, also known as "GX2", found in the Latte multifunction chip of the
+  Nintendo Wii U.
+
+properties:
+  compatible:
+    oneOf:
+      - description: Nintendo Wii U Latte "GPU7" graphics processor
+        items:
+          - const: nintendo,latte-gpu7
+  reg:
+    items:
+      - description: GpuF0MMReg registers
+  interrupts:
+    items:
+      - description: Main interrupt, connected via Espresso PIC
+
+# This will likely get bound to the Radeon driver one day, which will neccesitate extra properties
+additionalProperties: true
+
+examples:
+  - |
+    gpu7@c200000 {
+            compatible = "nintendo,latte-gpu7";
+            reg = <0x0c200000 0x80000>;
+            interrupts = <2>;
+            interrupt-parent = <&espresso_pic>;
+    };
+...
Documentation/devicetree/bindings/powerpc/nintendo/wiiu/latte-ahci.yaml new file +43 -0
new file mode 100644
index 000000000000..7b9de4effcb0
@@ -0,0 +1,43 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/powerpc/nintendo/wiiu/latte-ahci.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Nintendo Wii U Latte AHCI controller
+
+maintainers:
+  - Ash Logan <[email protected]>
+  - Emmanuel Gil Peyrot <[email protected]>
+
+description: |
+  Nintendo Wii U AHCI SATA controller, as found in the Latte chip.
+
+properties:
+  compatible:
+    oneOf:
+      - description: Nintendo Wii U Latte AHCI controller
+        items:
+          - const: nintendo,latte-ahci
+  reg:
+    items:
+      - description: |
+          HBA memory registers. Note that unlike the spec, space for only 6 ports exist, with 2 vendor
+          registers afterwards, thus register space should be 0x408 long (0x100+0x80*6+0x8).
+  interrupts:
+    items:
+      - description: Main HBA interrupt
+      - description: Vendor debugging interrupt
+
+additionalProperties: false
+
+examples:
+  - |
+    sata: ahci@d160400 {
+          compatible = "nintendo,latte-ahci";
+          reg = <0x0d160400 0x408>;
+
+          interrupt-parent = <&latte_pic>;
+          interrupts = <38>, <28>;
+    };
+...
Documentation/devicetree/bindings/powerpc/nintendo/wiiu/latte-dsp.yaml new file +35 -0
new file mode 100644
index 000000000000..ed0b4c28ce48
@@ -0,0 +1,35 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/powerpc/nintendo/wiiu/latte-dsp.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Nintendo Wii U Latte DSP
+
+maintainers:
+  - Ash Logan <[email protected]>
+  - Emmanuel Gil Peyrot <[email protected]>
+
+description: |
+  Nintendo Wii U digital signal processor, as found in the Latte chip.
+
+properties:
+  compatible:
+    oneOf:
+      - description: Nintendo Wii U Latte DSP
+        items:
+          - const: nintendo,latte-dsp
+  reg:
+    items:
+      - description: DSP registers
+
+# Once more is known about this device more properties will likely be added
+additionalProperties: true
+
+examples:
+  - |
+    latte_dsp: dsp@c005000 {
+         compatible = "nintendo,latte-dsp";
+         reg = <0x0c005000 0x200>;
+    };
+...
Documentation/devicetree/bindings/powerpc/nintendo/wiiu/latte-pic.yaml new file +46 -0
new file mode 100644
index 000000000000..a2df71fb9964
@@ -0,0 +1,46 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/powerpc/nintendo/wiiu/latte-pic.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Nintendo Wii U Latte interrupt controller
+
+maintainers:
+  - Ash Logan <[email protected]>
+  - Emmanuel Gil Peyrot <[email protected]>
+
+description: |
+  Interrupt controller found on the Nintendo Wii U for the "Latte" devices.
+
+properties:
+  compatible:
+    oneOf:
+      - description: Nintendo Wii U Latte interrupt controller
+        items:
+          - const: nintendo,latte-pic
+  '#interrupt-cells':
+    # Interrupt numbers 0-64 in one cell.
+    const: 1
+  interrupt-controller: true
+  reg:
+    items:
+      - description: Core registers
+  interrupts:
+    items:
+      - description: Cascade interrupt for Espresso PIC
+
+additionalProperties: false
+
+examples:
+  - |
+    latte_pic: pic@d800440 {
+         #interrupt-cells = <1>;
+         interrupt-controller;
+
+         compatible = "nintendo,latte-pic";
+         reg = <0x0d800440 0x30>;
+         interrupt-parent = <&espresso_pic>;
+         interrupts = <24>;
+    };
+...
Documentation/devicetree/bindings/powerpc/nintendo/wiiu/latte-sdhci.yaml new file +40 -0
new file mode 100644
index 000000000000..4b9b0820edc1
@@ -0,0 +1,40 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/powerpc/nintendo/wiiu/latte-sdhci.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Nintendo Wii U Latte SD Host controller
+
+maintainers:
+  - Ash Logan <[email protected]>
+  - Emmanuel Gil Peyrot <[email protected]>
+
+description: |
+  SDHCI hosts found on the Nintendo Wii U's Latte SoC for SD cards and SDIO devices.
+
+properties:
+  compatible:
+    oneOf:
+      - description: Nintendo Wii U Latte SDHCI
+        items:
+          - const: nintendo,latte-sdhci
+          - const: sdhci
+  reg:
+    items:
+      - description: Core registers
+  interrupts:
+    items:
+      - description: SDHCI interrupt
+
+additionalProperties: false
+
+examples:
+  - |
+    sdcard_0: sdhci@d070000 {
+          compatible = "nintendo,latte-sdhci","sdhci";
+          reg = <0x0d070000 0x200>;
+          interrupts = <7>;
+          interrupt-parent = <&latte_pic>;
+    };
+...
Documentation/devicetree/bindings/powerpc/nintendo/wiiu/latte.yaml new file +25 -1
new file mode 100644
index 000000000000..6ae86d198fa3
@@ -0,0 +1,25 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/powerpc/nintendo/wiiu/latte.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Latte system bus
+
+maintainers:
+  - Ash Logan <[email protected]>
+  - Emmanuel Gil Peyrot <[email protected]>
+
+description: |
+  Latte multi-function SoC, containing many of the devices found on the Nintendo Wii U.
+
+properties:
+  compatible:
+    oneOf:
+      - description: Nintendo Wii U "Latte" SoC
+        items:
+          - const: nintendo,latte
+
+additionalProperties: true
+
+...
--

2.35.1

author
#3 lore raw

PATCH 2/12 powerpc: wiiu: device tree

In reply to Ash Logan

Add a device tree source file for the Nintendo Wii U video game console.

---
 arch/powerpc/boot/dts/wiiu.dts | 327 +++++++++++++++++++++++++++++++++
 1 file changed, 327 insertions(+)
 create mode 100644 arch/powerpc/boot/dts/wiiu.dts
arch/powerpc/boot/dts/wiiu.dts new file +327 -0
new file mode 100644
index 000000000000..aaf264963f61
@@ -0,0 +1,327 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Nintendo Wii U Device Tree Source
+ *
+ * Copyright (C) 2022 The linux-wiiu Team
+ */
+
+/dts-v1/;
+#include <dt-bindings/gpio/gpio.h>
+#include <dt-bindings/input/input.h>
+
+/ {
+	model = "nintendo,wiiu";
+	compatible = "nintendo,wiiu";
+
+	#address-cells = <1>;
+	#size-cells = <1>;
+
+	chosen {
+		bootargs = "root=/dev/sda1 rootwait";
+	};
+
+	memory {
+		device_type = "memory";
+		reg = <0x00000000 0x02000000	/* MEM1 - 32MiB */
+		       0x08000000 0x00300000	/* MEM0 - 3MiB  */
+		       0x10000000 0x80000000>;	/* MEM2 - 2GiB  */
+	};
+
+	cpus {
+		#address-cells = <1>;
+		#size-cells = <0>;
+
+		/* TODO: Add SMP */
+		PowerPC,espresso@0 {
+			device_type = "cpu";
+			reg = <0>;
+			clock-frequency = <1243125000>;		/* 1.243125GHz */
+			bus-frequency = <248625000>;		/* 248.625MHz core-to-bus 5x */
+			timebase-frequency = <62156250>;	/* 1/4 of the bus clock */
+			i-cache-size = <32768>; /* 32K icache */
+			i-cache-line-size = <32>;
+			i-cache-block-size = <32>;
+			i-cache-sets = <128>;
+			d-cache-size = <32768>; /* 32K dcache */
+			d-cache-line-size = <32>;
+			d-cache-block-size = <32>;
+			d-cache-sets = <128>;
+			next-level-cache = <&L2_0>;
+			L2_0:l2-cache {
+				compatible = "cache";
+				cache-level = <2>;
+				cache-unified;
+				cache-size = <0x80000>; /* 512KB L2 */
+				cache-line-size = <64>;
+				cache-block-size = <32>;
+				cache-sets = <2048>;
+			};
+		};
+	};
+
+	latte {
+		#address-cells = <1>;
+		#size-cells = <1>;
+		compatible = "nintendo,latte";
+		ranges = <0x0c000000 0x0c000000 0x00400000	/* Espresso-only registers */
+			  0x0d000000 0x0d000000 0x00200000	/* Latte AHB deivces */
+			  0x0d800000 0x0d800000 0x00800000>;	/* Latte SoC registers */
+
+		gpu7@c200000 {
+			compatible = "nintendo,latte-gpu7";
+			reg = <0x0c200000 0x80000>;
+			interrupts = <2>;
+			interrupt-parent = <&espresso_pic>;
+		};
+
+		espresso_pic: pic@c000078 {
+			#interrupt-cells = <1>;
+			interrupt-controller;
+
+			compatible = "nintendo,espresso-pic";
+			reg = <0x0c000078 0x18>;
+		};
+
+		latte_dsp: dsp@c005000 {
+			compatible = "nintendo,latte-dsp";
+			reg = <0x0c005000 0x200>;
+		};
+
+		ehci_0: usb@d040000 {
+			compatible = "nintendo,latte-usb-ehci", "usb-ehci";
+			reg = <0x0d040000 0x100>;
+			interrupts = <4>;
+			interrupt-parent = <&latte_pic>;
+			big-endian-regs;
+		};
+
+		ohci_0_0: usb@d050000 {
+			compatible = "nintendo,latte-usb-ohci";
+			reg = <0x0d050000 0x100>;
+			interrupts = <5>;
+			interrupt-parent = <&latte_pic>;
+
+			big-endian-regs;
+		};
+
+		ohci_0_1: usb@d060000 {
+			compatible = "nintendo,latte-usb-ohci";
+			reg = <0x0d060000 0x100>;
+			interrupts = <6>;
+			interrupt-parent = <&latte_pic>;
+
+			big-endian-regs;
+		};
+
+		ehci_1: usb@d120000 {
+			compatible = "nintendo,latte-usb-ehci", "usb-ehci";
+			reg = <0x0d120000 0x100>;
+			interrupts = <16>;
+			interrupt-parent = <&latte_pic>;
+			big-endian-regs;
+		};
+
+		ohci_1_0: usb@d130000 {
+			compatible = "nintendo,latte-usb-ohci";
+			reg = <0x0d130000 0x100>;
+			interrupts = <35>;
+			interrupt-parent = <&latte_pic>;
+
+			big-endian-regs;
+		};
+
+		ehci_2: usb@d140000 {
+			compatible = "nintendo,latte-usb-ehci", "usb-ehci";
+			reg = <0x0d140000 0x100>;
+			interrupts = <36>;
+			interrupt-parent = <&latte_pic>;
+			big-endian-regs;
+		};
+
+		ohci_2_0: usb@d150000 {
+			compatible = "nintendo,latte-usb-ohci";
+			reg = <0x0d150000 0x100>;
+			interrupts = <37>;
+			interrupt-parent = <&latte_pic>;
+
+			big-endian-regs;
+		};
+
+		sdcard_0: sdhci@d070000 {
+			compatible = "nintendo,latte-sdhci","sdhci";
+			reg = <0x0d070000 0x200>;
+			interrupts = <7>;
+			interrupt-parent = <&latte_pic>;
+		};
+
+		wifi_0: sdhci@d080000 {
+			compatible = "nintendo,latte-sdhci","sdhci";
+			reg = <0x0d080000 0x200>;
+			interrupts = <8>;
+			interrupt-parent = <&latte_pic>;
+		};
+
+		legacy_ipc: ipc@d800000 {
+			compatible = "nintendo,latte-ipc","nintendo,hollywood-ipc";
+			reg = <0x0d800000 0x10>;
+			interrupts = <30 31>;
+			interrupt-parent = <&latte_pic>;
+		};
+
+		latte_otp: otp@d8001ec {
+			compatible = "nintendo,latte-otp";
+			reg = <0x0d8001ec 0x8>;
+		};
+
+		sata: ahci@d160400 {
+			compatible = "nintendo,latte-ahci";
+			reg = <0x0d160400 0x808>;
+
+			interrupt-parent = <&latte_pic>;
+			interrupts = <38 28>;
+		};
+
+		latte_pic: pic@d800440 {
+			#interrupt-cells = <1>;
+			interrupt-controller;
+
+			compatible = "nintendo,latte-pic";
+			reg = <0x0d800440 0x30>;
+			interrupt-parent = <&espresso_pic>;
+			interrupts = <24>;
+		};
+
+		gpio: gpio@d8000c0 {
+			#gpio-cells = <2>;
+			compatible = "nintendo,latte-gpio", "nintendo,hollywood-gpio";
+
+			reg = <0x0d8000c0 0x40>;
+			gpio-controller;
+			/* TODO: There are actually 31 AHBALL GPIOs */
+			ngpios = <24>;
+
+			gpio-line-names =
+				"POWER", "DWIFI", "FAN", "DC_DC",
+				"", "Esp10WorkAround", "", "",
+				"PADPD", "", "EEP_CS", "EEP_CLK",
+				"EEP_MOSI", "EEP_MISO", "AVE_SCL", "AVE_SDA",
+				"DEBUG0", "DEBUG1", "DEBUG2", "DEBUG3",
+				"DEBUG4", "DEBUG5", "DEBUG6", "DEBUG7";
+
+			interrupt-controller;
+			#interrupt-cells = <2>;
+			interrupts = <10>;
+			interrupt-parent = <&latte_pic>;
+		};
+
+		spi_gpio: spi-gpio {
+			compatible = "spi-gpio";
+			#address-cells = <1>;
+			#size-cells = <0>;
+			status = "okay";
+
+			cs-gpios = <&gpio 10 GPIO_ACTIVE_HIGH>;
+			gpio-sck = <&gpio 11 GPIO_ACTIVE_HIGH>;
+			gpio-mosi = <&gpio 12 GPIO_ACTIVE_HIGH>;
+			gpio-miso = <&gpio 13 GPIO_ACTIVE_HIGH>;
+			num-chipselects = <1>;
+
+			seeprom@0 {
+				compatible = "atmel,at93c66";
+				reg = <0>;
+				spi-max-frequency = <1000000>;
+				spi-cs-high;
+				/* TODO: wiiubrew says this is 16-bit, but I only get the correct
+				 * values in 8-bit...
+				 */
+				data-size = <8>;
+				read-only;
+
+				#address-cells = <1>;
+				#size-cells = <1>;
+
+				/* https://wiiubrew.org/wiki/Hardware/SEEPROM */
+				rng_seed: rng@12 { reg = <0x012 8>; };
+				ppc_pvr: pvr@20 { reg = <0x020 4>; };
+				seeprom_ver_str: sver-str@24 { reg = <0x024 6>; };
+				seeprom_ver: sver@2a { reg = <0x02A 2>; };
+				otp_ver: over@2c { reg = <0x02C 2>; };
+				otp_rev: orev@2e { reg = <0x02E 2>; };
+				otp_ver_str: over-str@30 { reg = <0x030 8>; };
+
+				bc_crc: bc-crc@38 { reg = <0x038 4>; };
+				bc_sz: bc-sz@3c { reg = <0x03C 2>; };
+				bc_ver: bc-ver@3e { reg = <0x03E 2>; };
+				bc_boardtype: boardtype@42 { reg = <0x042 2>; };
+				bc_boardrev: boardrev@44 { reg = <0x044 2>; };
+				bc_bootsource: bootsource@46 { reg = <0x046 2>; };
+				bc_ddr3size: ddr3size@48 { reg = <0x048 2>; };
+				bc_ddr3speed: ddr3speed@4a { reg = <0x04A 2>; };
+				bc_ppcclockmul: ppcclockmul@4c { reg = <0x04C 2>; };
+				bc_iopclockmul: iopclockmul@46 { reg = <0x04E 2>; };
+				bc_video1080p: video1080p@50 { reg = <0x050 2>; };
+				bc_ddr3vendor: ddr3vendor@52 { reg = <0x052 2>; };
+				bc_movpassivereset: movpassivereset@54 { reg = <0x054 2>; };
+				bc_syspllspd: syspllspd@56 { reg = <0x056 2>; };
+				bc_satadevice: satadevice@58 { reg = <0x058 2>; };
+				bc_consoletype: consoletype@5a { reg = <0x05A 2>; };
+				bc_deviceprescence: deviceprescence@5c { reg = <0x05C 2>; };
+
+				drive_key: drvkey@80 { reg = <0x080 16>; };
+				factory_key: fackey@90 { reg = <0x090 16>; };
+				shdd_key: shddkey@a0 { reg = <0x0A0 16>; };
+				usb_key_seed: usbkeyseed@b0 { reg = <0x0B0 16>; };
+				drive_key_flag: drvkeyf@c0 { reg = <0x0C0 2>; };
+				usb_key_flag: udbkeyf@c2 { reg = <0x0C2 2>; };
+				shdd_key_flag: shddkeyf@c4 { reg = <0x0C4 2>; };
+
+				sysprod_version: sp_ver@140 { reg = <0x140 4>; };
+				sysprod_eeprom_version: sp_ee_ver@144 { reg = <0x144 4>; };
+				sysprod_product_area: sp_parea@148 { reg = <0x148 4>; };
+				sysprod_game_region: sp_region@14c { reg = <0x14C 4>; };
+				sysprod_ntsc_pal: sp_ntscpal@150 { reg = <0x150 4>; };
+				sysprod_5ghz_country: sp_5ghz_c@154 { reg = <0x154 2>; };
+				sysprod_5ghz_country_rev: sp_5ghz_crev@156 { reg = <0x156 2>; };
+				sysprod_code: sp_code@158 { reg = <0x158 8>; };
+				sysprod_serial: sp_serial@160 { reg = <0x160 16>; };
+				sysprod_model: sp_model@170 { reg = <0x170 16>; };
+
+				prod_year: pyear@188 { reg = <0x188 2>; };
+				prod_date: pdate@18a { reg = <0x18A 2>; };
+				prod_time: ptime@18c { reg = <0x18C 2>; };
+
+				boot_params: boot_params@1c0 { reg = <0x1C0 48>; };
+			};
+		};
+
+		/* TODO make this gpio-keyed once hollywood-gpio supports interrupts */
+		gpio-keys-polled {
+			poll-interval = <50>;
+			compatible = "gpio-keys-polled";
+
+			power {
+				label = "Power Button";
+				gpios = <&gpio 0 GPIO_ACTIVE_HIGH>;
+				linux,code = <KEY_POWER>;
+			};
+		};
+
+		gpio2: gpio2@d8000c0 {
+			#gpio-cells = <2>;
+			compatible = "nintendo,latte-gpio", "nintendo,hollywood-gpio";
+
+			reg = <0x0d800520 0x40>;
+			gpio-controller;
+			ngpios = <7>;
+
+			gpio-line-names =
+				"FANSPEED", "SMC_SCL", "SMC_SDA", "DC_DC2",
+				"AVE_INT", "", "AVE_RESET";
+
+			interrupt-controller;
+			#interrupt-cells = <2>;
+			interrupts = <10>;
+			interrupt-parent = <&latte_pic>;
+		};
+	};
+};
Signature · 1 line
2.35.1
#4 lore raw

Re: [PATCH 02/12] powerpc: wiiu: device tree

Quoted 2 lines · Ash Logan

Add a device tree source file for the Nintendo Wii U video game console.

Test this with 'make W=1 dtbs_checks'.

Quoted 17 lines
---
 arch/powerpc/boot/dts/wiiu.dts | 327 +++++++++++++++++++++++++++++++++
 1 file changed, 327 insertions(+)
 create mode 100644 arch/powerpc/boot/dts/wiiu.dts
arch/powerpc/boot/dts/wiiu.dts new file +0 -0
new file mode 100644
index 000000000000..aaf264963f61

arch/powerpc/boot/dts/wiiu.dts line 1

Quoted 1 line
arch/powerpc/boot/dts/wiiu.dts new file +1 -0
@@ -0,0 +1,327 @@
+// SPDX-License-Identifier: GPL-2.0

What about non-GPL environments?

Quoted 59 lines
arch/powerpc/boot/dts/wiiu.dts new file +59 -0
+/*
+ * Nintendo Wii U Device Tree Source
+ *
+ * Copyright (C) 2022 The linux-wiiu Team
+ */
+
+/dts-v1/;
+#include <dt-bindings/gpio/gpio.h>
+#include <dt-bindings/input/input.h>
+
+/ {
+       model = "nintendo,wiiu";
+       compatible = "nintendo,wiiu";
+
+       #address-cells = <1>;
+       #size-cells = <1>;
+
+       chosen {
+               bootargs = "root=/dev/sda1 rootwait";
+       };
+
+       memory {
+               device_type = "memory";
+               reg = <0x00000000 0x02000000    /* MEM1 - 32MiB */
+                      0x08000000 0x00300000    /* MEM0 - 3MiB  */
+                      0x10000000 0x80000000>;  /* MEM2 - 2GiB  */
+       };
+
+       cpus {
+               #address-cells = <1>;
+               #size-cells = <0>;
+
+               /* TODO: Add SMP */
+               PowerPC,espresso@0 {
+                       device_type = "cpu";
+                       reg = <0>;
+                       clock-frequency = <1243125000>;         /* 1.243125GHz */
+                       bus-frequency = <248625000>;            /* 248.625MHz core-to-bus 5x */
+                       timebase-frequency = <62156250>;        /* 1/4 of the bus clock */
+                       i-cache-size = <32768>; /* 32K icache */
+                       i-cache-line-size = <32>;
+                       i-cache-block-size = <32>;
+                       i-cache-sets = <128>;
+                       d-cache-size = <32768>; /* 32K dcache */
+                       d-cache-line-size = <32>;
+                       d-cache-block-size = <32>;
+                       d-cache-sets = <128>;
+                       next-level-cache = <&L2_0>;
+                       L2_0:l2-cache {
+                               compatible = "cache";
+                               cache-level = <2>;
+                               cache-unified;
+                               cache-size = <0x80000>; /* 512KB L2 */
+                               cache-line-size = <64>;
+                               cache-block-size = <32>;
+                               cache-sets = <2048>;
+                       };
+               };
+       };

arch/powerpc/boot/dts/wiiu.dts line 70

Quoted 10 lines
arch/powerpc/boot/dts/wiiu.dts new file +10 -0
+
+       latte {
+               #address-cells = <1>;
+               #size-cells = <1>;
+               compatible = "nintendo,latte";
+               ranges = <0x0c000000 0x0c000000 0x00400000      /* Espresso-only registers */
+                         0x0d000000 0x0d000000 0x00200000      /* Latte AHB deivces */
+                         0x0d800000 0x0d800000 0x00800000>;    /* Latte SoC registers */
+
+               gpu7@c200000 {

gpu@...

Quoted 85 lines
arch/powerpc/boot/dts/wiiu.dts new file +85 -0
+                       compatible = "nintendo,latte-gpu7";
+                       reg = <0x0c200000 0x80000>;
+                       interrupts = <2>;
+                       interrupt-parent = <&espresso_pic>;
+               };
+
+               espresso_pic: pic@c000078 {
+                       #interrupt-cells = <1>;
+                       interrupt-controller;
+
+                       compatible = "nintendo,espresso-pic";
+                       reg = <0x0c000078 0x18>;
+               };
+
+               latte_dsp: dsp@c005000 {
+                       compatible = "nintendo,latte-dsp";
+                       reg = <0x0c005000 0x200>;
+               };
+
+               ehci_0: usb@d040000 {
+                       compatible = "nintendo,latte-usb-ehci", "usb-ehci";
+                       reg = <0x0d040000 0x100>;
+                       interrupts = <4>;
+                       interrupt-parent = <&latte_pic>;
+                       big-endian-regs;
+               };
+
+               ohci_0_0: usb@d050000 {
+                       compatible = "nintendo,latte-usb-ohci";
+                       reg = <0x0d050000 0x100>;
+                       interrupts = <5>;
+                       interrupt-parent = <&latte_pic>;
+
+                       big-endian-regs;
+               };
+
+               ohci_0_1: usb@d060000 {
+                       compatible = "nintendo,latte-usb-ohci";
+                       reg = <0x0d060000 0x100>;
+                       interrupts = <6>;
+                       interrupt-parent = <&latte_pic>;
+
+                       big-endian-regs;
+               };
+
+               ehci_1: usb@d120000 {
+                       compatible = "nintendo,latte-usb-ehci", "usb-ehci";
+                       reg = <0x0d120000 0x100>;
+                       interrupts = <16>;
+                       interrupt-parent = <&latte_pic>;
+                       big-endian-regs;
+               };
+
+               ohci_1_0: usb@d130000 {
+                       compatible = "nintendo,latte-usb-ohci";
+                       reg = <0x0d130000 0x100>;
+                       interrupts = <35>;
+                       interrupt-parent = <&latte_pic>;
+
+                       big-endian-regs;
+               };
+
+               ehci_2: usb@d140000 {
+                       compatible = "nintendo,latte-usb-ehci", "usb-ehci";
+                       reg = <0x0d140000 0x100>;
+                       interrupts = <36>;
+                       interrupt-parent = <&latte_pic>;
+                       big-endian-regs;
+               };
+
+               ohci_2_0: usb@d150000 {
+                       compatible = "nintendo,latte-usb-ohci";
+                       reg = <0x0d150000 0x100>;
+                       interrupts = <37>;
+                       interrupt-parent = <&latte_pic>;
+
+                       big-endian-regs;
+               };
+
+               sdcard_0: sdhci@d070000 {
+                       compatible = "nintendo,latte-sdhci","sdhci";
+                       reg = <0x0d070000 0x200>;
+                       interrupts = <7>;
+                       interrupt-parent = <&latte_pic>;
+               };

arch/powerpc/boot/dts/wiiu.dts line 165

Quoted 10 lines
arch/powerpc/boot/dts/wiiu.dts new file +10 -0
+
+               wifi_0: sdhci@d080000 {
+                       compatible = "nintendo,latte-sdhci","sdhci";
+                       reg = <0x0d080000 0x200>;
+                       interrupts = <8>;
+                       interrupt-parent = <&latte_pic>;
+               };
+
+               legacy_ipc: ipc@d800000 {
+                       compatible = "nintendo,latte-ipc","nintendo,hollywood-ipc";

space between compatibles needed.

Quoted 42 lines
arch/powerpc/boot/dts/wiiu.dts new file +42 -0
+                       reg = <0x0d800000 0x10>;
+                       interrupts = <30 31>;
+                       interrupt-parent = <&latte_pic>;
+               };
+
+               latte_otp: otp@d8001ec {
+                       compatible = "nintendo,latte-otp";
+                       reg = <0x0d8001ec 0x8>;
+               };
+
+               sata: ahci@d160400 {
+                       compatible = "nintendo,latte-ahci";
+                       reg = <0x0d160400 0x808>;
+
+                       interrupt-parent = <&latte_pic>;
+                       interrupts = <38 28>;
+               };
+
+               latte_pic: pic@d800440 {
+                       #interrupt-cells = <1>;
+                       interrupt-controller;
+
+                       compatible = "nintendo,latte-pic";
+                       reg = <0x0d800440 0x30>;
+                       interrupt-parent = <&espresso_pic>;
+                       interrupts = <24>;
+               };
+
+               gpio: gpio@d8000c0 {
+                       #gpio-cells = <2>;
+                       compatible = "nintendo,latte-gpio", "nintendo,hollywood-gpio";
+
+                       reg = <0x0d8000c0 0x40>;
+                       gpio-controller;
+                       /* TODO: There are actually 31 AHBALL GPIOs */
+                       ngpios = <24>;
+
+                       gpio-line-names =
+                               "POWER", "DWIFI", "FAN", "DC_DC",
+                               "", "Esp10WorkAround", "", "",
+                               "PADPD", "", "EEP_CS", "EEP_CLK",
+                               "EEP_MOSI", "EEP_MISO", "AVE_SCL", "AVE_SDA",

arch/powerpc/boot/dts/wiiu.dts line 217

Quoted 10 lines
arch/powerpc/boot/dts/wiiu.dts new file +10 -0
+                               "DEBUG0", "DEBUG1", "DEBUG2", "DEBUG3",
+                               "DEBUG4", "DEBUG5", "DEBUG6", "DEBUG7";
+
+                       interrupt-controller;
+                       #interrupt-cells = <2>;
+                       interrupts = <10>;
+                       interrupt-parent = <&latte_pic>;
+               };
+
+               spi_gpio: spi-gpio {

Move this to root level. It's not on the 'latte' bus.

arch/powerpc/boot/dts/wiiu.dts line 221

Quoted 4 lines
arch/powerpc/boot/dts/wiiu.dts new file +4 -0
+                       compatible = "spi-gpio";
+                       #address-cells = <1>;
+                       #size-cells = <0>;
+                       status = "okay";

Not needed, that's the default.

arch/powerpc/boot/dts/wiiu.dts line 229

Quoted 8 lines
arch/powerpc/boot/dts/wiiu.dts new file +8 -0
+
+                       cs-gpios = <&gpio 10 GPIO_ACTIVE_HIGH>;
+                       gpio-sck = <&gpio 11 GPIO_ACTIVE_HIGH>;
+                       gpio-mosi = <&gpio 12 GPIO_ACTIVE_HIGH>;
+                       gpio-miso = <&gpio 13 GPIO_ACTIVE_HIGH>;
+                       num-chipselects = <1>;
+
+                       seeprom@0 {

eeprom@0

Quoted 59 lines
arch/powerpc/boot/dts/wiiu.dts new file +59 -0
+                               compatible = "atmel,at93c66";
+                               reg = <0>;
+                               spi-max-frequency = <1000000>;
+                               spi-cs-high;
+                               /* TODO: wiiubrew says this is 16-bit, but I only get the correct
+                                * values in 8-bit...
+                                */
+                               data-size = <8>;
+                               read-only;
+
+                               #address-cells = <1>;
+                               #size-cells = <1>;
+
+                               /* https://wiiubrew.org/wiki/Hardware/SEEPROM */
+                               rng_seed: rng@12 { reg = <0x012 8>; };
+                               ppc_pvr: pvr@20 { reg = <0x020 4>; };
+                               seeprom_ver_str: sver-str@24 { reg = <0x024 6>; };
+                               seeprom_ver: sver@2a { reg = <0x02A 2>; };
+                               otp_ver: over@2c { reg = <0x02C 2>; };
+                               otp_rev: orev@2e { reg = <0x02E 2>; };
+                               otp_ver_str: over-str@30 { reg = <0x030 8>; };
+
+                               bc_crc: bc-crc@38 { reg = <0x038 4>; };
+                               bc_sz: bc-sz@3c { reg = <0x03C 2>; };
+                               bc_ver: bc-ver@3e { reg = <0x03E 2>; };
+                               bc_boardtype: boardtype@42 { reg = <0x042 2>; };
+                               bc_boardrev: boardrev@44 { reg = <0x044 2>; };
+                               bc_bootsource: bootsource@46 { reg = <0x046 2>; };
+                               bc_ddr3size: ddr3size@48 { reg = <0x048 2>; };
+                               bc_ddr3speed: ddr3speed@4a { reg = <0x04A 2>; };
+                               bc_ppcclockmul: ppcclockmul@4c { reg = <0x04C 2>; };
+                               bc_iopclockmul: iopclockmul@46 { reg = <0x04E 2>; };
+                               bc_video1080p: video1080p@50 { reg = <0x050 2>; };
+                               bc_ddr3vendor: ddr3vendor@52 { reg = <0x052 2>; };
+                               bc_movpassivereset: movpassivereset@54 { reg = <0x054 2>; };
+                               bc_syspllspd: syspllspd@56 { reg = <0x056 2>; };
+                               bc_satadevice: satadevice@58 { reg = <0x058 2>; };
+                               bc_consoletype: consoletype@5a { reg = <0x05A 2>; };
+                               bc_deviceprescence: deviceprescence@5c { reg = <0x05C 2>; };
+
+                               drive_key: drvkey@80 { reg = <0x080 16>; };
+                               factory_key: fackey@90 { reg = <0x090 16>; };
+                               shdd_key: shddkey@a0 { reg = <0x0A0 16>; };
+                               usb_key_seed: usbkeyseed@b0 { reg = <0x0B0 16>; };
+                               drive_key_flag: drvkeyf@c0 { reg = <0x0C0 2>; };
+                               usb_key_flag: udbkeyf@c2 { reg = <0x0C2 2>; };
+                               shdd_key_flag: shddkeyf@c4 { reg = <0x0C4 2>; };
+
+                               sysprod_version: sp_ver@140 { reg = <0x140 4>; };
+                               sysprod_eeprom_version: sp_ee_ver@144 { reg = <0x144 4>; };
+                               sysprod_product_area: sp_parea@148 { reg = <0x148 4>; };
+                               sysprod_game_region: sp_region@14c { reg = <0x14C 4>; };
+                               sysprod_ntsc_pal: sp_ntscpal@150 { reg = <0x150 4>; };
+                               sysprod_5ghz_country: sp_5ghz_c@154 { reg = <0x154 2>; };
+                               sysprod_5ghz_country_rev: sp_5ghz_crev@156 { reg = <0x156 2>; };
+                               sysprod_code: sp_code@158 { reg = <0x158 8>; };
+                               sysprod_serial: sp_serial@160 { reg = <0x160 16>; };
+                               sysprod_model: sp_model@170 { reg = <0x170 16>; };
+

arch/powerpc/boot/dts/wiiu.dts line 298

Quoted 10 lines
arch/powerpc/boot/dts/wiiu.dts new file +10 -0
+                               prod_year: pyear@188 { reg = <0x188 2>; };
+                               prod_date: pdate@18a { reg = <0x18A 2>; };
+                               prod_time: ptime@18c { reg = <0x18C 2>; };
+
+                               boot_params: boot_params@1c0 { reg = <0x1C0 48>; };
+                       };
+               };
+
+               /* TODO make this gpio-keyed once hollywood-gpio supports interrupts */
+               gpio-keys-polled {

This too.

arch/powerpc/boot/dts/wiiu.dts line 309

Quoted 11 lines
arch/powerpc/boot/dts/wiiu.dts new file +11 -0
+                       poll-interval = <50>;
+                       compatible = "gpio-keys-polled";
+
+                       power {
+                               label = "Power Button";
+                               gpios = <&gpio 0 GPIO_ACTIVE_HIGH>;
+                               linux,code = <KEY_POWER>;
+                       };
+               };
+
+               gpio2: gpio2@d8000c0 {

gpio@d800520

Quoted 21 lines
arch/powerpc/boot/dts/wiiu.dts new file +18 -1
+                       #gpio-cells = <2>;
+                       compatible = "nintendo,latte-gpio", "nintendo,hollywood-gpio";
+
+                       reg = <0x0d800520 0x40>;
+                       gpio-controller;
+                       ngpios = <7>;
+
+                       gpio-line-names =
+                               "FANSPEED", "SMC_SCL", "SMC_SDA", "DC_DC2",
+                               "AVE_INT", "", "AVE_RESET";
+
+                       interrupt-controller;
+                       #interrupt-cells = <2>;
+                       interrupts = <10>;
+                       interrupt-parent = <&latte_pic>;
+               };
+       };
+};
--

2.35.1

author
#5 lore raw

Re: [PATCH 02/12] powerpc: wiiu: device tree

Hi Rob,
Thanks for the review.

Quoted 5 lines · Rob Herring
Quoted 2 lines · Ash Logan

Add a device tree source file for the Nintendo Wii U video game console.

Test this with 'make W=1 dtbs_checks'.

Does make W=1 ARCH=powerpc wiiu_defconfig dtbs_check seem reasonable? I ran it, and saw LINT/CHKDT/UPD/SCHEMA/COPY steps, but if I put garbage in the .dts it gives no warnings.

Quoted 11 lines
Quoted 11 lines
---
  arch/powerpc/boot/dts/wiiu.dts | 327 +++++++++++++++++++++++++++++++++
  1 file changed, 327 insertions(+)

create mode 100644 arch/powerpc/boot/dts/wiiu.dts

Quoted 9 lines

arch/powerpc/boot/dts/wiiu.dts line 1

Quoted 7 lines
arch/powerpc/boot/dts/wiiu.dts new file +1 -0
new file mode 100644
index 000000000000..aaf264963f61
@@ -0,0 +1,327 @@
+// SPDX-License-Identifier: GPL-2.0

What about non-GPL environments?

The other powerpc dts files are all GPL-2.0(-or-later), is there a preferred license for devicetrees?

Quoted 342 lines
Quoted 59 lines
arch/powerpc/boot/dts/wiiu.dts new file +59 -0
+/*
+ * Nintendo Wii U Device Tree Source
+ *
+ * Copyright (C) 2022 The linux-wiiu Team
+ */
+
+/dts-v1/;
+#include <dt-bindings/gpio/gpio.h>
+#include <dt-bindings/input/input.h>
+
+/ {
+       model = "nintendo,wiiu";
+       compatible = "nintendo,wiiu";
+
+       #address-cells = <1>;
+       #size-cells = <1>;
+
+       chosen {
+               bootargs = "root=/dev/sda1 rootwait";
+       };
+
+       memory {
+               device_type = "memory";
+               reg = <0x00000000 0x02000000    /* MEM1 - 32MiB */
+                      0x08000000 0x00300000    /* MEM0 - 3MiB  */
+                      0x10000000 0x80000000>;  /* MEM2 - 2GiB  */
+       };
+
+       cpus {
+               #address-cells = <1>;
+               #size-cells = <0>;
+
+               /* TODO: Add SMP */
+               PowerPC,espresso@0 {
+                       device_type = "cpu";
+                       reg = <0>;
+                       clock-frequency = <1243125000>;         /* 1.243125GHz */
+                       bus-frequency = <248625000>;            /* 248.625MHz core-to-bus 5x */
+                       timebase-frequency = <62156250>;        /* 1/4 of the bus clock */
+                       i-cache-size = <32768>; /* 32K icache */
+                       i-cache-line-size = <32>;
+                       i-cache-block-size = <32>;
+                       i-cache-sets = <128>;
+                       d-cache-size = <32768>; /* 32K dcache */
+                       d-cache-line-size = <32>;
+                       d-cache-block-size = <32>;
+                       d-cache-sets = <128>;
+                       next-level-cache = <&L2_0>;
+                       L2_0:l2-cache {
+                               compatible = "cache";
+                               cache-level = <2>;
+                               cache-unified;
+                               cache-size = <0x80000>; /* 512KB L2 */
+                               cache-line-size = <64>;
+                               cache-block-size = <32>;
+                               cache-sets = <2048>;
+                       };
+               };
+       };

arch/powerpc/boot/dts/wiiu.dts line 70

Quoted 10 lines
arch/powerpc/boot/dts/wiiu.dts new file +10 -0
+
+       latte {
+               #address-cells = <1>;
+               #size-cells = <1>;
+               compatible = "nintendo,latte";
+               ranges = <0x0c000000 0x0c000000 0x00400000      /* Espresso-only registers */
+                         0x0d000000 0x0d000000 0x00200000      /* Latte AHB deivces */
+                         0x0d800000 0x0d800000 0x00800000>;    /* Latte SoC registers */
+
+               gpu7@c200000 {

gpu@...

Quoted 85 lines
arch/powerpc/boot/dts/wiiu.dts new file +85 -0
+                       compatible = "nintendo,latte-gpu7";
+                       reg = <0x0c200000 0x80000>;
+                       interrupts = <2>;
+                       interrupt-parent = <&espresso_pic>;
+               };
+
+               espresso_pic: pic@c000078 {
+                       #interrupt-cells = <1>;
+                       interrupt-controller;
+
+                       compatible = "nintendo,espresso-pic";
+                       reg = <0x0c000078 0x18>;
+               };
+
+               latte_dsp: dsp@c005000 {
+                       compatible = "nintendo,latte-dsp";
+                       reg = <0x0c005000 0x200>;
+               };
+
+               ehci_0: usb@d040000 {
+                       compatible = "nintendo,latte-usb-ehci", "usb-ehci";
+                       reg = <0x0d040000 0x100>;
+                       interrupts = <4>;
+                       interrupt-parent = <&latte_pic>;
+                       big-endian-regs;
+               };
+
+               ohci_0_0: usb@d050000 {
+                       compatible = "nintendo,latte-usb-ohci";
+                       reg = <0x0d050000 0x100>;
+                       interrupts = <5>;
+                       interrupt-parent = <&latte_pic>;
+
+                       big-endian-regs;
+               };
+
+               ohci_0_1: usb@d060000 {
+                       compatible = "nintendo,latte-usb-ohci";
+                       reg = <0x0d060000 0x100>;
+                       interrupts = <6>;
+                       interrupt-parent = <&latte_pic>;
+
+                       big-endian-regs;
+               };
+
+               ehci_1: usb@d120000 {
+                       compatible = "nintendo,latte-usb-ehci", "usb-ehci";
+                       reg = <0x0d120000 0x100>;
+                       interrupts = <16>;
+                       interrupt-parent = <&latte_pic>;
+                       big-endian-regs;
+               };
+
+               ohci_1_0: usb@d130000 {
+                       compatible = "nintendo,latte-usb-ohci";
+                       reg = <0x0d130000 0x100>;
+                       interrupts = <35>;
+                       interrupt-parent = <&latte_pic>;
+
+                       big-endian-regs;
+               };
+
+               ehci_2: usb@d140000 {
+                       compatible = "nintendo,latte-usb-ehci", "usb-ehci";
+                       reg = <0x0d140000 0x100>;
+                       interrupts = <36>;
+                       interrupt-parent = <&latte_pic>;
+                       big-endian-regs;
+               };
+
+               ohci_2_0: usb@d150000 {
+                       compatible = "nintendo,latte-usb-ohci";
+                       reg = <0x0d150000 0x100>;
+                       interrupts = <37>;
+                       interrupt-parent = <&latte_pic>;
+
+                       big-endian-regs;
+               };
+
+               sdcard_0: sdhci@d070000 {
+                       compatible = "nintendo,latte-sdhci","sdhci";
+                       reg = <0x0d070000 0x200>;
+                       interrupts = <7>;
+                       interrupt-parent = <&latte_pic>;
+               };

arch/powerpc/boot/dts/wiiu.dts line 165

Quoted 10 lines
arch/powerpc/boot/dts/wiiu.dts new file +10 -0
+
+               wifi_0: sdhci@d080000 {
+                       compatible = "nintendo,latte-sdhci","sdhci";
+                       reg = <0x0d080000 0x200>;
+                       interrupts = <8>;
+                       interrupt-parent = <&latte_pic>;
+               };
+
+               legacy_ipc: ipc@d800000 {
+                       compatible = "nintendo,latte-ipc","nintendo,hollywood-ipc";

space between compatibles needed.

Quoted 42 lines
arch/powerpc/boot/dts/wiiu.dts new file +42 -0
+                       reg = <0x0d800000 0x10>;
+                       interrupts = <30 31>;
+                       interrupt-parent = <&latte_pic>;
+               };
+
+               latte_otp: otp@d8001ec {
+                       compatible = "nintendo,latte-otp";
+                       reg = <0x0d8001ec 0x8>;
+               };
+
+               sata: ahci@d160400 {
+                       compatible = "nintendo,latte-ahci";
+                       reg = <0x0d160400 0x808>;
+
+                       interrupt-parent = <&latte_pic>;
+                       interrupts = <38 28>;
+               };
+
+               latte_pic: pic@d800440 {
+                       #interrupt-cells = <1>;
+                       interrupt-controller;
+
+                       compatible = "nintendo,latte-pic";
+                       reg = <0x0d800440 0x30>;
+                       interrupt-parent = <&espresso_pic>;
+                       interrupts = <24>;
+               };
+
+               gpio: gpio@d8000c0 {
+                       #gpio-cells = <2>;
+                       compatible = "nintendo,latte-gpio", "nintendo,hollywood-gpio";
+
+                       reg = <0x0d8000c0 0x40>;
+                       gpio-controller;
+                       /* TODO: There are actually 31 AHBALL GPIOs */
+                       ngpios = <24>;
+
+                       gpio-line-names =
+                               "POWER", "DWIFI", "FAN", "DC_DC",
+                               "", "Esp10WorkAround", "", "",
+                               "PADPD", "", "EEP_CS", "EEP_CLK",
+                               "EEP_MOSI", "EEP_MISO", "AVE_SCL", "AVE_SDA",

arch/powerpc/boot/dts/wiiu.dts line 217

Quoted 10 lines
arch/powerpc/boot/dts/wiiu.dts new file +10 -0
+                               "DEBUG0", "DEBUG1", "DEBUG2", "DEBUG3",
+                               "DEBUG4", "DEBUG5", "DEBUG6", "DEBUG7";
+
+                       interrupt-controller;
+                       #interrupt-cells = <2>;
+                       interrupts = <10>;
+                       interrupt-parent = <&latte_pic>;
+               };
+
+               spi_gpio: spi-gpio {

Move this to root level. It's not on the 'latte' bus.

arch/powerpc/boot/dts/wiiu.dts line 221

Quoted 4 lines
arch/powerpc/boot/dts/wiiu.dts new file +4 -0
+                       compatible = "spi-gpio";
+                       #address-cells = <1>;
+                       #size-cells = <0>;
+                       status = "okay";

Not needed, that's the default.

arch/powerpc/boot/dts/wiiu.dts line 229

Quoted 8 lines
arch/powerpc/boot/dts/wiiu.dts new file +8 -0
+
+                       cs-gpios = <&gpio 10 GPIO_ACTIVE_HIGH>;
+                       gpio-sck = <&gpio 11 GPIO_ACTIVE_HIGH>;
+                       gpio-mosi = <&gpio 12 GPIO_ACTIVE_HIGH>;
+                       gpio-miso = <&gpio 13 GPIO_ACTIVE_HIGH>;
+                       num-chipselects = <1>;
+
+                       seeprom@0 {

eeprom@0

Quoted 59 lines
arch/powerpc/boot/dts/wiiu.dts new file +59 -0
+                               compatible = "atmel,at93c66";
+                               reg = <0>;
+                               spi-max-frequency = <1000000>;
+                               spi-cs-high;
+                               /* TODO: wiiubrew says this is 16-bit, but I only get the correct
+                                * values in 8-bit...
+                                */
+                               data-size = <8>;
+                               read-only;
+
+                               #address-cells = <1>;
+                               #size-cells = <1>;
+
+                               /* https://wiiubrew.org/wiki/Hardware/SEEPROM */
+                               rng_seed: rng@12 { reg = <0x012 8>; };
+                               ppc_pvr: pvr@20 { reg = <0x020 4>; };
+                               seeprom_ver_str: sver-str@24 { reg = <0x024 6>; };
+                               seeprom_ver: sver@2a { reg = <0x02A 2>; };
+                               otp_ver: over@2c { reg = <0x02C 2>; };
+                               otp_rev: orev@2e { reg = <0x02E 2>; };
+                               otp_ver_str: over-str@30 { reg = <0x030 8>; };
+
+                               bc_crc: bc-crc@38 { reg = <0x038 4>; };
+                               bc_sz: bc-sz@3c { reg = <0x03C 2>; };
+                               bc_ver: bc-ver@3e { reg = <0x03E 2>; };
+                               bc_boardtype: boardtype@42 { reg = <0x042 2>; };
+                               bc_boardrev: boardrev@44 { reg = <0x044 2>; };
+                               bc_bootsource: bootsource@46 { reg = <0x046 2>; };
+                               bc_ddr3size: ddr3size@48 { reg = <0x048 2>; };
+                               bc_ddr3speed: ddr3speed@4a { reg = <0x04A 2>; };
+                               bc_ppcclockmul: ppcclockmul@4c { reg = <0x04C 2>; };
+                               bc_iopclockmul: iopclockmul@46 { reg = <0x04E 2>; };
+                               bc_video1080p: video1080p@50 { reg = <0x050 2>; };
+                               bc_ddr3vendor: ddr3vendor@52 { reg = <0x052 2>; };
+                               bc_movpassivereset: movpassivereset@54 { reg = <0x054 2>; };
+                               bc_syspllspd: syspllspd@56 { reg = <0x056 2>; };
+                               bc_satadevice: satadevice@58 { reg = <0x058 2>; };
+                               bc_consoletype: consoletype@5a { reg = <0x05A 2>; };
+                               bc_deviceprescence: deviceprescence@5c { reg = <0x05C 2>; };
+
+                               drive_key: drvkey@80 { reg = <0x080 16>; };
+                               factory_key: fackey@90 { reg = <0x090 16>; };
+                               shdd_key: shddkey@a0 { reg = <0x0A0 16>; };
+                               usb_key_seed: usbkeyseed@b0 { reg = <0x0B0 16>; };
+                               drive_key_flag: drvkeyf@c0 { reg = <0x0C0 2>; };
+                               usb_key_flag: udbkeyf@c2 { reg = <0x0C2 2>; };
+                               shdd_key_flag: shddkeyf@c4 { reg = <0x0C4 2>; };
+
+                               sysprod_version: sp_ver@140 { reg = <0x140 4>; };
+                               sysprod_eeprom_version: sp_ee_ver@144 { reg = <0x144 4>; };
+                               sysprod_product_area: sp_parea@148 { reg = <0x148 4>; };
+                               sysprod_game_region: sp_region@14c { reg = <0x14C 4>; };
+                               sysprod_ntsc_pal: sp_ntscpal@150 { reg = <0x150 4>; };
+                               sysprod_5ghz_country: sp_5ghz_c@154 { reg = <0x154 2>; };
+                               sysprod_5ghz_country_rev: sp_5ghz_crev@156 { reg = <0x156 2>; };
+                               sysprod_code: sp_code@158 { reg = <0x158 8>; };
+                               sysprod_serial: sp_serial@160 { reg = <0x160 16>; };
+                               sysprod_model: sp_model@170 { reg = <0x170 16>; };
+

arch/powerpc/boot/dts/wiiu.dts line 298

Quoted 10 lines
arch/powerpc/boot/dts/wiiu.dts new file +10 -0
+                               prod_year: pyear@188 { reg = <0x188 2>; };
+                               prod_date: pdate@18a { reg = <0x18A 2>; };
+                               prod_time: ptime@18c { reg = <0x18C 2>; };
+
+                               boot_params: boot_params@1c0 { reg = <0x1C0 48>; };
+                       };
+               };
+
+               /* TODO make this gpio-keyed once hollywood-gpio supports interrupts */
+               gpio-keys-polled {

This too.

arch/powerpc/boot/dts/wiiu.dts line 309

Quoted 11 lines
arch/powerpc/boot/dts/wiiu.dts new file +11 -0
+                       poll-interval = <50>;
+                       compatible = "gpio-keys-polled";
+
+                       power {
+                               label = "Power Button";
+                               gpios = <&gpio 0 GPIO_ACTIVE_HIGH>;
+                               linux,code = <KEY_POWER>;
+                       };
+               };
+
+               gpio2: gpio2@d8000c0 {

gpio@d800520

Quoted 13 lines
arch/powerpc/boot/dts/wiiu.dts new file +13 -0
+                       #gpio-cells = <2>;
+                       compatible = "nintendo,latte-gpio", "nintendo,hollywood-gpio";
+
+                       reg = <0x0d800520 0x40>;
+                       gpio-controller;
+                       ngpios = <7>;
+
+                       gpio-line-names =
+                               "FANSPEED", "SMC_SCL", "SMC_SDA", "DC_DC2",
+                               "AVE_INT", "", "AVE_RESET";
+
+                       interrupt-controller;
+                       #interrupt-cells = <2>;
Quoted 8 lines
Quoted 8 lines
arch/powerpc/boot/dts/wiiu.dts new file +5 -1
+                       interrupts = <10>;
+                       interrupt-parent = <&latte_pic>;
+               };
+       };
+};
--

2.35.1

Will do in v2.

Thanks,
Ash

author
#6 lore raw

PATCH 3/12 powerpc: wiiu: bootwrapper support

In reply to Ash Logan

Add support for the Nintendo Wii U game console to the powerpc bootwrapper.

---
 arch/powerpc/boot/Makefile    |   4 ++
 arch/powerpc/boot/wiiu-head.S | 103 ++++++++++++++++++++++++++++++++++
 arch/powerpc/boot/wiiu.c      |  73 ++++++++++++++++++++++++
 arch/powerpc/boot/wrapper     |   4 ++
 4 files changed, 184 insertions(+)
 create mode 100644 arch/powerpc/boot/wiiu-head.S
 create mode 100644 arch/powerpc/boot/wiiu.c
arch/powerpc/boot/Makefile +4 -0
index 9993c6256ad2..4e31bb648f4d 100644
@@ -155,6 +155,7 @@ src-plat-$(CONFIG_EMBEDDED6xx) += cuboot-pq2.c cuboot-mpc7448hpc2.c \
 					gamecube-head.S gamecube.c \
 					wii-head.S wii.c holly.c \
 					fixed-head.S mvme5100.c
+src-plat-$(CONFIG_WIIU) += wiiu-head.S wiiu.c
 src-plat-$(CONFIG_AMIGAONE) += cuboot-amigaone.c
 src-plat-$(CONFIG_PPC_PS3) += ps3-head.S ps3-hvcall.S ps3.c
 src-plat-$(CONFIG_EPAPR_BOOT) += epapr.c epapr-wrapper.c
@@ -353,6 +354,9 @@ image-$(CONFIG_GAMECUBE)		+= dtbImage.gamecube
 image-$(CONFIG_WII)			+= dtbImage.wii
 image-$(CONFIG_MVME5100)		+= dtbImage.mvme5100
 
+# Board port in arch/powerpc/platform/wiiu/Kconfig
+image-$(CONFIG_WIIU)			+= dtbImage.wiiu
+
 # Board port in arch/powerpc/platform/amigaone/Kconfig
 image-$(CONFIG_AMIGAONE)		+= cuImage.amigaone
 
arch/powerpc/boot/wiiu-head.S new file +103 -0

103 lines not on this page · raw message

arch/powerpc/boot/wiiu.c new file +73 -0

73 lines not on this page · raw message

arch/powerpc/boot/wrapper +4 -0
index 9184eda780fd..f42abe4ebde2 100755
@@ -344,6 +344,10 @@ gamecube|wii)
     link_address='0x600000'
     platformo="$object/$platform-head.o $object/$platform.o"
     ;;
+wiiu)
+    link_address='0x600000'
+    platformo="$object/wiiu-head.o $object/$platform.o"
+    ;;
 microwatt)
     link_address='0x500000'
     platformo="$object/fixed-head.o $object/$platform.o"
Signature · 1 line
2.35.1
author
#7 lore raw

PATCH 4/12 powerpc: wiiu: introduce wiiu platform

In reply to Ash Logan

Add empty platforms/wiiu for Nintendo Wii U console.

---
 arch/powerpc/platforms/Kconfig       | 1 +
 arch/powerpc/platforms/Makefile      | 1 +
 arch/powerpc/platforms/wiiu/Kconfig  | 5 +++++
 arch/powerpc/platforms/wiiu/Makefile | 1 +
 4 files changed, 8 insertions(+)
 create mode 100644 arch/powerpc/platforms/wiiu/Kconfig
 create mode 100644 arch/powerpc/platforms/wiiu/Makefile
arch/powerpc/platforms/Kconfig +1 -0
index e02d29a9d12f..7ea25ea369b4 100644
@@ -22,6 +22,7 @@ source "arch/powerpc/platforms/40x/Kconfig"
 source "arch/powerpc/platforms/amigaone/Kconfig"
 source "arch/powerpc/platforms/book3s/Kconfig"
 source "arch/powerpc/platforms/microwatt/Kconfig"
+source "arch/powerpc/platforms/wiiu/Kconfig"
 
 config KVM_GUEST
 	bool "KVM Guest support"
arch/powerpc/platforms/Makefile +1 -0
index 94470fb27c99..944ddd938711 100644
@@ -24,3 +24,4 @@ obj-$(CONFIG_EMBEDDED6xx)	+= embedded6xx/
 obj-$(CONFIG_AMIGAONE)		+= amigaone/
 obj-$(CONFIG_PPC_BOOK3S)	+= book3s/
 obj-$(CONFIG_PPC_MICROWATT)	+= microwatt/
+obj-$(CONFIG_WIIU)		+= wiiu/
arch/powerpc/platforms/wiiu/Kconfig new file +5 -0
new file mode 100644
index 000000000000..e5513205da3c
@@ -0,0 +1,5 @@
+# SPDX-License-Identifier: GPL-2.0
+
+config WIIU
+	bool "Nintendo Wii U"
+	depends on PPC_BOOK3S_32
arch/powerpc/platforms/wiiu/Makefile new file +1 -0
new file mode 100644
index 000000000000..f66554cd5c45
@@ -0,0 +1 @@
+# SPDX-License-Identifier: GPL-2.0
Signature · 1 line
2.35.1
author
#8 lore raw

PATCH 5/12 powerpc: wiiu: declare as non-coherent

In reply to Ash Logan

The Nintendo Wii U requires explicit cache handling when interfacing with DMA devices.

---
 arch/powerpc/platforms/Kconfig.cputype | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/powerpc/platforms/Kconfig.cputype +1 -1
index a208997ade88..bec8293a7985 100644
@@ -485,7 +485,7 @@ config NR_CPUS
 config NOT_COHERENT_CACHE
 	bool
 	depends on 4xx || PPC_8xx || PPC_MPC512x || \
-		GAMECUBE_COMMON || AMIGAONE
+		GAMECUBE_COMMON || AMIGAONE || WIIU
 	select ARCH_HAS_DMA_PREP_COHERENT
 	select ARCH_HAS_SYNC_DMA_FOR_DEVICE
 	select ARCH_HAS_SYNC_DMA_FOR_CPU
Signature · 1 line
2.35.1
author
#9 lore raw

PATCH 6/12 powerpc: wiiu: udbg support for latteipc

In reply to Ash Logan

Add support for using the Latte chipset IPC for udbg on the Nintendo Wii U console.
These messages can then be received by a special firmware running on the "Starbuck" coprocessor.

---
 arch/powerpc/Kconfig.debug                  |   9 ++
 arch/powerpc/include/asm/udbg.h             |   1 +
 arch/powerpc/kernel/head_book3s_32.S        |  20 ++++
 arch/powerpc/kernel/udbg.c                  |   3 +
 arch/powerpc/platforms/wiiu/Kconfig         |  13 +++
 arch/powerpc/platforms/wiiu/Makefile        |   2 +
 arch/powerpc/platforms/wiiu/udbg_latteipc.c | 122 ++++++++++++++++++++
 arch/powerpc/platforms/wiiu/udbg_latteipc.h |  27 +++++
 8 files changed, 197 insertions(+)
 create mode 100644 arch/powerpc/platforms/wiiu/udbg_latteipc.c
 create mode 100644 arch/powerpc/platforms/wiiu/udbg_latteipc.h
arch/powerpc/Kconfig.debug +9 -0
index 192f0ed0097f..15c7fa7c040a 100644
@@ -254,6 +254,15 @@ config PPC_EARLY_DEBUG_USBGECKO
 	  Select this to enable early debugging for Nintendo GameCube/Wii
 	  consoles via an external USB Gecko adapter.
 
+config PPC_EARLY_DEBUG_LATTEIPC
+	bool "Early debugging through Latte chipset IPC"
+	depends on WIIU
+	select LATTEIPC_UDBG
+	help
+	  Select this to enable early debugging for Nintendo Wii U consoles via
+	  chipset IPC to the security coprocessor. This assumes a firmware is
+	  running on the coprocessor to receive messages.
+
 config PPC_EARLY_DEBUG_PS3GELIC
 	bool "Early debugging through the PS3 Ethernet port"
 	depends on PPC_PS3
arch/powerpc/include/asm/udbg.h +1 -0
index 0ea9e70ed78b..82858c0283ac 100644
@@ -53,6 +53,7 @@ extern void __init udbg_init_ehv_bc(void);
 extern void __init udbg_init_ps3gelic(void);
 extern void __init udbg_init_debug_opal_raw(void);
 extern void __init udbg_init_debug_opal_hvsi(void);
+extern void __init udbg_init_latteipc(void);
 
 #endif /* __KERNEL__ */
 #endif /* _ASM_POWERPC_UDBG_H */
arch/powerpc/kernel/head_book3s_32.S +20 -0
index 68e5c0a7e99d..f159e500342c 100644
@@ -167,6 +167,9 @@ __after_mmu_off:
 #ifdef CONFIG_PPC_EARLY_DEBUG_USBGECKO
 	bl	setup_usbgecko_bat
 #endif
+#ifdef CONFIG_PPC_EARLY_DEBUG_LATTEIPC
+	bl	setup_latteipc_bat
+#endif
 
 /*
  * Call setup_cpu for CPU 0 and initialize 6xx Idle
@@ -1206,4 +1209,21 @@ setup_usbgecko_bat:
 	blr
 #endif
 
+#ifdef CONFIG_PPC_EARLY_DEBUG_LATTEIPC
+setup_latteipc_bat:
+	/* prepare a BAT for early io */
+	lis	r8, 0x0d80
+
+	/*
+	 * The virtual address used must match the virtual address
+	 * associated to the fixmap entry FIX_EARLY_DEBUG_BASE.
+	 */
+	lis	r11, 0xfffe	/* top 128K */
+	ori	r8, r8, 0x002a	/* uncached, guarded ,rw */
+	ori	r11, r11, 0x2	/* 128K, Vs=1, Vp=0 */
+	mtspr	SPRN_DBAT1L, r8
+	mtspr	SPRN_DBAT1U, r11
+	blr
+#endif
+
 	.data
arch/powerpc/kernel/udbg.c +3 -0
index b1544b2f6321..84eae25c195e 100644
@@ -67,6 +67,9 @@ void __init udbg_early_init(void)
 	udbg_init_debug_opal_raw();
 #elif defined(CONFIG_PPC_EARLY_DEBUG_OPAL_HVSI)
 	udbg_init_debug_opal_hvsi();
+#elif defined(CONFIG_PPC_EARLY_DEBUG_LATTEIPC)
+	/* For use on Nintendo Wii U */
+	udbg_init_latteipc();
 #endif
 
 #ifdef CONFIG_PPC_EARLY_DEBUG
arch/powerpc/platforms/wiiu/Kconfig +13 -0
index e5513205da3c..fa86cbc33d5e 100644
@@ -3,3 +3,16 @@
 config WIIU
 	bool "Nintendo Wii U"
 	depends on PPC_BOOK3S_32
+
+config LATTEIPC_UDBG
+	bool "Chipset IPC udbg console for the Nintendo Wii U"
+	depends on WIIU
+	help
+	  If you say yes to this option, support will be included for the
+	  Wii U's chipset IPC as a udbg console.
+	  These IPC messages can be received by a firmware running on the
+	  console's "Starbuck" security coprocessor.
+
+	  This driver bypasses the IPC layer completely.
+
+	  If in doubt, say N here.
arch/powerpc/platforms/wiiu/Makefile +2 -0
index f66554cd5c45..b1e0e1307f6e 100644
@@ -1 +1,3 @@
 # SPDX-License-Identifier: GPL-2.0
+
+obj-$(CONFIG_LATTEIPC_UDBG) += udbg_latteipc.o
arch/powerpc/platforms/wiiu/udbg_latteipc.c new file +122 -0

122 lines not on this page · raw message

arch/powerpc/platforms/wiiu/udbg_latteipc.h new file +27 -0
new file mode 100644
index 000000000000..ca6d34e49158
@@ -0,0 +1,27 @@
+/* SPDX-License-Identifier: GPL-2.0-or-later */
+/*
+ * Nintendo Wii U udbg support (to Starbuck coprocessor, via chipset IPC)
+ *
+ * Copyright (C) 2022 The linux-wiiu Team
+ *
+ * Based on arch/powerpc/platforms/embedded6xx/udbgecko_udbg.h
+ * Copyright (C) 2008-2009 The GameCube Linux Team
+ * Copyright (C) 2008-2009 Albert Herranz
+ */
+
+#ifndef __LATTEIPC_UDBG_H
+#define __LATTEIPC_UDBG_H
+
+#ifdef CONFIG_LATTEIPC_UDBG
+
+void __init latteipc_udbg_init(void);
+
+#else
+
+static inline void __init latteipc_udbg_init(void)
+{
+}
+
+#endif /* CONFIG_LATTEIPC_UDBG */
+
+#endif /* __LATTEIPC_UDBG_H */
Signature · 1 line
2.35.1
author
#10 lore raw

PATCH 7/12 powerpc: wiiu: espresso interrupt controller support

In reply to Ash Logan

Add support for the "Espresso" interrupt controller in the Nintendo Wii U.

---
 arch/powerpc/platforms/wiiu/Makefile       |   1 +
 arch/powerpc/platforms/wiiu/espresso-pic.c | 183 +++++++++++++++++++++
 arch/powerpc/platforms/wiiu/espresso-pic.h |  59 +++++++
 3 files changed, 243 insertions(+)
 create mode 100644 arch/powerpc/platforms/wiiu/espresso-pic.c
 create mode 100644 arch/powerpc/platforms/wiiu/espresso-pic.h
arch/powerpc/platforms/wiiu/Makefile +1 -0
index b1e0e1307f6e..aabf4b43e806 100644
@@ -1,3 +1,4 @@
 # SPDX-License-Identifier: GPL-2.0
 
+obj-$(CONFIG_WIIU) += espresso-pic.o
 obj-$(CONFIG_LATTEIPC_UDBG) += udbg_latteipc.o
arch/powerpc/platforms/wiiu/espresso-pic.c new file +183 -0

183 lines not on this page · raw message

arch/powerpc/platforms/wiiu/espresso-pic.h new file +59 -0

59 lines not on this page · raw message

Signature · 1 line
2.35.1
author
#11 lore raw

PATCH 8/12 powerpc: wiiu: latte interrupt controller support

In reply to Ash Logan

Add support for the "Latte" interrupt controller in the Nintendo Wii U. This controller is used for the entire SoC and is wired to a cascade interrupt on the Espresso controller.

---
 arch/powerpc/platforms/wiiu/Kconfig     |   1 +
 arch/powerpc/platforms/wiiu/Makefile    |   2 +-
 arch/powerpc/platforms/wiiu/latte-pic.c | 259 ++++++++++++++++++++++++
 arch/powerpc/platforms/wiiu/latte-pic.h |  23 +++
 4 files changed, 284 insertions(+), 1 deletion(-)
 create mode 100644 arch/powerpc/platforms/wiiu/latte-pic.c
 create mode 100644 arch/powerpc/platforms/wiiu/latte-pic.h
arch/powerpc/platforms/wiiu/Kconfig +1 -0
index fa86cbc33d5e..5e062536ca58 100644
@@ -3,6 +3,7 @@
 config WIIU
 	bool "Nintendo Wii U"
 	depends on PPC_BOOK3S_32
+	select IRQ_DOMAIN_HIERARCHY
 
 config LATTEIPC_UDBG
 	bool "Chipset IPC udbg console for the Nintendo Wii U"
arch/powerpc/platforms/wiiu/Makefile +1 -1
index aabf4b43e806..fa16c60261e6 100644
@@ -1,4 +1,4 @@
 # SPDX-License-Identifier: GPL-2.0
 
-obj-$(CONFIG_WIIU) += espresso-pic.o
+obj-$(CONFIG_WIIU) += espresso-pic.o latte-pic.o
 obj-$(CONFIG_LATTEIPC_UDBG) += udbg_latteipc.o
arch/powerpc/platforms/wiiu/latte-pic.c new file +259 -0

259 lines not on this page · raw message

arch/powerpc/platforms/wiiu/latte-pic.h new file +23 -0
new file mode 100644
index 000000000000..7021d9497d35
@@ -0,0 +1,23 @@
+/* SPDX-License-Identifier: GPL-2.0-or-later */
+/*
+ * Nintendo Wii U "Latte" interrupt controller support
+ *
+ * Copyright (C) 2022 The linux-wiiu Team
+ */
+
+#ifndef __LATTE_PIC_H
+#define __LATTE_PIC_H
+
+struct lt_pic {
+	__be32 ahball_icr;	/* Triggered AHB IRQs (all) */
+	__be32 ahblt_icr;	/* Triggered AHB IRQs (latte only) */
+	__be32 ahball_imr;	/* Allowed AHB IRQs (all) */
+	__be32 ahblt_imr;	/* Allowed AHB IRQs (latte only) */
+} __packed;
+
+#define LATTE_AHBALL_NR_IRQS    32
+#define LATTE_AHBLT_NR_IRQS     32
+
+void latte_pic_init(void);
+
+#endif
Signature · 1 line
2.35.1
author
#12 lore raw

PATCH 9/12 powerpc: espresso processor support

In reply to Ash Logan

From: Roberto Van Eeden <[email protected]>

Adds a cputable entry for the "Espresso" processor found on the Nintendo Wii U, which has a PVR unrelated to other 750CL-like chips. Only this revision has been seen in the wild.

---
 arch/powerpc/kernel/cputable.c | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)
arch/powerpc/kernel/cputable.c +16 -0
index ae0fdef0ac11..b575f5570485 100644
@@ -718,6 +718,22 @@ static struct cpu_spec __initdata cpu_specs[] = {
 		.platform		= "ppc750",
 		.oprofile_cpu_type      = "ppc/750",
 	},
+	{	/* "Espresso" (750CL-like) */
+		.pvr_mask		= 0xffffffff,
+		.pvr_value		= 0x70010201,
+		.cpu_name		= "Espresso",
+		.cpu_features		= CPU_FTRS_750CL,
+		.cpu_user_features	= COMMON_USER | PPC_FEATURE_PPC_LE,
+		.mmu_features		= MMU_FTR_HPTE_TABLE | MMU_FTR_USE_HIGH_BATS,
+		.icache_bsize		= 32,
+		.dcache_bsize		= 32,
+		.num_pmcs		= 4,
+		.pmc_type		= PPC_PMC_IBM,
+		.cpu_setup		= __setup_cpu_750,
+		.machine_check		= machine_check_generic,
+		.platform		= "ppc750",
+		.oprofile_cpu_type      = "ppc/750",
+	},
 	{	/* 745/755 */
 		.pvr_mask		= 0xfffff000,
 		.pvr_value		= 0x00083000,
Signature · 1 line
2.35.1
author
#13 lore raw

PATCH 10/12 powerpc: wiiu: platform support

In reply to Ash Logan

Add platform support for the Nintendo Wii U console.

---
 arch/powerpc/platforms/wiiu/Makefile |  2 +-
 arch/powerpc/platforms/wiiu/setup.c  | 67 ++++++++++++++++++++++++++++
 2 files changed, 68 insertions(+), 1 deletion(-)
 create mode 100644 arch/powerpc/platforms/wiiu/setup.c
arch/powerpc/platforms/wiiu/Makefile +1 -1
index fa16c60261e6..abcb7a1beebf 100644
@@ -1,4 +1,4 @@
 # SPDX-License-Identifier: GPL-2.0
 
-obj-$(CONFIG_WIIU) += espresso-pic.o latte-pic.o
+obj-$(CONFIG_WIIU) += setup.o espresso-pic.o latte-pic.o
 obj-$(CONFIG_LATTEIPC_UDBG) += udbg_latteipc.o
arch/powerpc/platforms/wiiu/setup.c new file +67 -0

67 lines not on this page · raw message

Signature · 1 line
2.35.1
author
#14 lore raw

PATCH 11/12 powerpc: wiiu: don't enforce flat memory

In reply to Ash Logan

pgtable_32.c:mapin_ram loops over each valid memory range, which means non-contiguous memory just works.

---
 arch/powerpc/mm/init_32.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
arch/powerpc/mm/init_32.c +2 -2
index 3d690be48e84..59a84629d9a0 100644
@@ -125,10 +125,10 @@ void __init MMU_init(void)
 	 * lowmem_end_addr is initialized below.
 	 */
 	if (memblock.memory.cnt > 1) {
-#ifndef CONFIG_WII
+#if !defined(CONFIG_WII) && !defined(CONFIG_WIIU)
 		memblock_enforce_memory_limit(memblock.memory.regions[0].size);
 		pr_warn("Only using first contiguous memory region\n");
-#else
+#elif defined(CONFIG_WII)
 		wii_memory_fixups();
 #endif
 	}
Signature · 1 line
2.35.1
#15 lore raw

Re: [PATCH 11/12] powerpc: wiiu: don't enforce flat memory

Quoted 2 lines · On Wednesday 02 March 2022 15:44:05 Ash Logan wrote:

pgtable_32.c:mapin_ram loops over each valid memory range, which means non-contiguous memory just works.

Hello! Does it mean that non-contiguous memory works for any 32-bit powerpc platform, and not only for wiiu? If yes, should not be non-contiguous memory support enabled for all 32-bit ppc boards then?

Quoted 25 lines
---
 arch/powerpc/mm/init_32.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
arch/powerpc/mm/init_32.c +2 -2
index 3d690be48e84..59a84629d9a0 100644
@@ -125,10 +125,10 @@ void __init MMU_init(void)
 	 * lowmem_end_addr is initialized below.
 	 */
 	if (memblock.memory.cnt > 1) {
-#ifndef CONFIG_WII
+#if !defined(CONFIG_WII) && !defined(CONFIG_WIIU)
 		memblock_enforce_memory_limit(memblock.memory.regions[0].size);
 		pr_warn("Only using first contiguous memory region\n");
-#else
+#elif defined(CONFIG_WII)
 		wii_memory_fixups();
 #endif
 	}
Signature · 1 line
2.35.1
author
#16 lore raw

Re: [PATCH 11/12] powerpc: wiiu: don't enforce flat memory

Quoted 7 lines · Pali Rohár
Quoted 2 lines · On Wednesday 02 March 2022 15:44:05 Ash Logan wrote:

pgtable_32.c:mapin_ram loops over each valid memory range, which means non-contiguous memory just works.

Hello! Does it mean that non-contiguous memory works for any 32-bit powerpc platform, and not only for wiiu? If yes, should not be non-contiguous memory support enabled for all 32-bit ppc boards then?

Hi! Sorry for my delayed response. As best I can tell, it does indeed Just Work, but I have only been able to test on wiiu which is missing a lot of features other boards have (like PCI) - so it's possible there's still an assumption elsewhere in the kernel that I haven't hit.

As best I can tell, the Wii and Wii U are the only 32-bit powerpc boards out there where it's even possible to have non-contiguous memory.

Quoted 25 lines
Quoted 25 lines
---
 arch/powerpc/mm/init_32.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
arch/powerpc/mm/init_32.c +2 -2
index 3d690be48e84..59a84629d9a0 100644
@@ -125,10 +125,10 @@ void __init MMU_init(void)
 	 * lowmem_end_addr is initialized below.
 	 */
 	if (memblock.memory.cnt > 1) {
-#ifndef CONFIG_WII
+#if !defined(CONFIG_WII) && !defined(CONFIG_WIIU)
 		memblock_enforce_memory_limit(memblock.memory.regions[0].size);
 		pr_warn("Only using first contiguous memory region\n");
-#else
+#elif defined(CONFIG_WII)
 		wii_memory_fixups();
 #endif
 	}
Signature · 1 line
2.35.1
#17 lore raw

Re: [PATCH 11/12] powerpc: wiiu: don't enforce flat memory

Quoted 9 lines · On Friday 20 May 2022 13:41:04 Ash Logan wrote:
Quoted 7 lines · Pali Rohár
Quoted 2 lines · On Wednesday 02 March 2022 15:44:05 Ash Logan wrote:

pgtable_32.c:mapin_ram loops over each valid memory range, which means non-contiguous memory just works.

Hello! Does it mean that non-contiguous memory works for any 32-bit powerpc platform, and not only for wiiu? If yes, should not be non-contiguous memory support enabled for all 32-bit ppc boards then?

Quoted 7 lines

Hi! Sorry for my delayed response. As best I can tell, it does indeed Just Work, but I have only been able to test on wiiu which is missing a lot of features other boards have (like PCI) - so it's possible there's still an assumption elsewhere in the kernel that I haven't hit.

As best I can tell, the Wii and Wii U are the only 32-bit powerpc boards out there where it's even possible to have non-contiguous memory.

What is the reason that those two boards are the **only**? Is there some specific requirement from bootloader or hardware to "enable" non-contiguous memory support?

I'm interested in enabling non-contiguous memory support for P2020-based board as it has gaps in its 32-bit memory layout and which could be used for RAM mapping when 4GB DDR3 module is plugged in (default is 2GB).

Quoted 25 lines
Quoted 25 lines
Quoted 25 lines
---
 arch/powerpc/mm/init_32.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
arch/powerpc/mm/init_32.c +2 -2
index 3d690be48e84..59a84629d9a0 100644
@@ -125,10 +125,10 @@ void __init MMU_init(void)
 	 * lowmem_end_addr is initialized below.
 	 */
 	if (memblock.memory.cnt > 1) {
-#ifndef CONFIG_WII
+#if !defined(CONFIG_WII) && !defined(CONFIG_WIIU)
 		memblock_enforce_memory_limit(memblock.memory.regions[0].size);
 		pr_warn("Only using first contiguous memory region\n");
-#else
+#elif defined(CONFIG_WII)
 		wii_memory_fixups();
 #endif
 	}
Signature · 1 line
2.35.1
author
#18 lore raw

Re: [PATCH 11/12] powerpc: wiiu: don't enforce flat memory

Quoted 15 lines · Pali Rohár
Quoted 14 lines · On Friday 20 May 2022 13:41:04 Ash Logan wrote:
Quoted 7 lines · Pali Rohár
Quoted 2 lines · On Wednesday 02 March 2022 15:44:05 Ash Logan wrote:

pgtable_32.c:mapin_ram loops over each valid memory range, which means non-contiguous memory just works.

Hello! Does it mean that non-contiguous memory works for any 32-bit powerpc platform, and not only for wiiu? If yes, should not be non-contiguous memory support enabled for all 32-bit ppc boards then?

Hi! Sorry for my delayed response. As best I can tell, it does indeed Just Work, but I have only been able to test on wiiu which is missing a lot of features other boards have (like PCI) - so it's possible there's still an assumption elsewhere in the kernel that I haven't hit.

Quoted 6 lines
Quoted 2 lines

As best I can tell, the Wii and Wii U are the only 32-bit powerpc boards out there where it's even possible to have non-contiguous memory.

What is the reason that those two boards are the **only**? Is there some specific requirement from bootloader or hardware to "enable" non-contiguous memory support?

Not that I know of, I was just saying that I was only aware of those two boards where the memory map isn't contiguous, and that is the only place where it has been tested. Evidently you know of another board!

Quoted 3 lines

I'm interested in enabling non-contiguous memory support for P2020-based board as it has gaps in its 32-bit memory layout and which could be used for RAM mapping when 4GB DDR3 module is plugged in (default is 2GB).

If it's like the Wii or Wii U (some memory at 0, a gap for MMIO or whatever, then more memory at a higher address) then you should try a patch along these lines, because barring the unknowns I mentioned before it should work. At least as far as I'm aware ;)

Quoted 25 lines
Quoted 25 lines
Quoted 25 lines
Quoted 25 lines
---
 arch/powerpc/mm/init_32.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
arch/powerpc/mm/init_32.c +2 -2
index 3d690be48e84..59a84629d9a0 100644
@@ -125,10 +125,10 @@ void __init MMU_init(void)
 	 * lowmem_end_addr is initialized below.
 	 */
 	if (memblock.memory.cnt > 1) {
-#ifndef CONFIG_WII
+#if !defined(CONFIG_WII) && !defined(CONFIG_WIIU)
 		memblock_enforce_memory_limit(memblock.memory.regions[0].size);
 		pr_warn("Only using first contiguous memory region\n");
-#else
+#elif defined(CONFIG_WII)
 		wii_memory_fixups();
 #endif
 	}
Signature · 1 line
2.35.1
#19 lore raw

Re: [PATCH 11/12] powerpc: wiiu: don't enforce flat memory

+ linux-mm

Do you know what are requirements for kernel to support non-contiguous memory support and what is needed to enable it for 32-bit powerpc?

Currently powerpc arch code does not support "memblock.memory.cnt > 1" except for WII which seems like a hack... See below.

Quoted 61 lines · On Friday 20 May 2022 20:44:04 Ash Logan wrote:
Quoted 15 lines · Pali Rohár
Quoted 14 lines · On Friday 20 May 2022 13:41:04 Ash Logan wrote:
Quoted 7 lines · Pali Rohár
Quoted 2 lines · On Wednesday 02 March 2022 15:44:05 Ash Logan wrote:

pgtable_32.c:mapin_ram loops over each valid memory range, which means non-contiguous memory just works.

Hello! Does it mean that non-contiguous memory works for any 32-bit powerpc platform, and not only for wiiu? If yes, should not be non-contiguous memory support enabled for all 32-bit ppc boards then?

Hi! Sorry for my delayed response. As best I can tell, it does indeed Just Work, but I have only been able to test on wiiu which is missing a lot of features other boards have (like PCI) - so it's possible there's still an assumption elsewhere in the kernel that I haven't hit.

Quoted 6 lines
Quoted 2 lines

As best I can tell, the Wii and Wii U are the only 32-bit powerpc boards out there where it's even possible to have non-contiguous memory.

What is the reason that those two boards are the **only**? Is there some specific requirement from bootloader or hardware to "enable" non-contiguous memory support?

Not that I know of, I was just saying that I was only aware of those two boards where the memory map isn't contiguous, and that is the only place where it has been tested. Evidently you know of another board!

Quoted 3 lines

I'm interested in enabling non-contiguous memory support for P2020-based board as it has gaps in its 32-bit memory layout and which could be used for RAM mapping when 4GB DDR3 module is plugged in (default is 2GB).

If it's like the Wii or Wii U (some memory at 0, a gap for MMIO or whatever, then more memory at a higher address) then you should try a patch along these lines, because barring the unknowns I mentioned before it should work. At least as far as I'm aware ;)

Quoted 25 lines
Quoted 25 lines
Quoted 25 lines
Quoted 25 lines
---
 arch/powerpc/mm/init_32.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
arch/powerpc/mm/init_32.c +2 -2
index 3d690be48e84..59a84629d9a0 100644
@@ -125,10 +125,10 @@ void __init MMU_init(void)
 	 * lowmem_end_addr is initialized below.
 	 */
 	if (memblock.memory.cnt > 1) {
-#ifndef CONFIG_WII
+#if !defined(CONFIG_WII) && !defined(CONFIG_WIIU)
 		memblock_enforce_memory_limit(memblock.memory.regions[0].size);
 		pr_warn("Only using first contiguous memory region\n");
-#else
+#elif defined(CONFIG_WII)
 		wii_memory_fixups();
 #endif
 	}
Signature · 1 line
2.35.1
#20 lore raw

Re: [PATCH 11/12] powerpc: wiiu: don't enforce flat memory

Quoted 4 lines · On Friday 20 May 2022 14:30:02 Pali Rohár wrote:

+ linux-mm

Do you know what are requirements for kernel to support non-contiguous memory support and what is needed to enable it for 32-bit powerpc?

Any hints?

Quoted 65 lines

Currently powerpc arch code does not support "memblock.memory.cnt > 1" except for WII which seems like a hack... See below.

Quoted 61 lines · On Friday 20 May 2022 20:44:04 Ash Logan wrote:
Quoted 15 lines · Pali Rohár
Quoted 14 lines · On Friday 20 May 2022 13:41:04 Ash Logan wrote:
Quoted 7 lines · Pali Rohár
Quoted 2 lines · On Wednesday 02 March 2022 15:44:05 Ash Logan wrote:

pgtable_32.c:mapin_ram loops over each valid memory range, which means non-contiguous memory just works.

Hello! Does it mean that non-contiguous memory works for any 32-bit powerpc platform, and not only for wiiu? If yes, should not be non-contiguous memory support enabled for all 32-bit ppc boards then?

Hi! Sorry for my delayed response. As best I can tell, it does indeed Just Work, but I have only been able to test on wiiu which is missing a lot of features other boards have (like PCI) - so it's possible there's still an assumption elsewhere in the kernel that I haven't hit.

Quoted 6 lines
Quoted 2 lines

As best I can tell, the Wii and Wii U are the only 32-bit powerpc boards out there where it's even possible to have non-contiguous memory.

What is the reason that those two boards are the **only**? Is there some specific requirement from bootloader or hardware to "enable" non-contiguous memory support?

Not that I know of, I was just saying that I was only aware of those two boards where the memory map isn't contiguous, and that is the only place where it has been tested. Evidently you know of another board!

Quoted 3 lines

I'm interested in enabling non-contiguous memory support for P2020-based board as it has gaps in its 32-bit memory layout and which could be used for RAM mapping when 4GB DDR3 module is plugged in (default is 2GB).

If it's like the Wii or Wii U (some memory at 0, a gap for MMIO or whatever, then more memory at a higher address) then you should try a patch along these lines, because barring the unknowns I mentioned before it should work. At least as far as I'm aware ;)

Quoted 25 lines
Quoted 25 lines
Quoted 25 lines
Quoted 25 lines
---
 arch/powerpc/mm/init_32.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
arch/powerpc/mm/init_32.c +2 -2
index 3d690be48e84..59a84629d9a0 100644
@@ -125,10 +125,10 @@ void __init MMU_init(void)
 	 * lowmem_end_addr is initialized below.
 	 */
 	if (memblock.memory.cnt > 1) {
-#ifndef CONFIG_WII
+#if !defined(CONFIG_WII) && !defined(CONFIG_WIIU)
 		memblock_enforce_memory_limit(memblock.memory.regions[0].size);
 		pr_warn("Only using first contiguous memory region\n");
-#else
+#elif defined(CONFIG_WII)
 		wii_memory_fixups();
 #endif
 	}
Signature · 1 line
2.35.1
#21 lore raw

Re: [PATCH 11/12] powerpc: wiiu: don't enforce flat memory

Quoted 7 lines · On Friday 10 June 2022 00:24:20 Pali Rohár wrote:
Quoted 4 lines · On Friday 20 May 2022 14:30:02 Pali Rohár wrote:

+ linux-mm

Do you know what are requirements for kernel to support non-contiguous memory support and what is needed to enable it for 32-bit powerpc?

Any hints?

PING?

Quoted 65 lines
Quoted 65 lines

Currently powerpc arch code does not support "memblock.memory.cnt > 1" except for WII which seems like a hack... See below.

Quoted 61 lines · On Friday 20 May 2022 20:44:04 Ash Logan wrote:
Quoted 15 lines · Pali Rohár
Quoted 14 lines · On Friday 20 May 2022 13:41:04 Ash Logan wrote:
Quoted 7 lines · Pali Rohár
Quoted 2 lines · On Wednesday 02 March 2022 15:44:05 Ash Logan wrote:

pgtable_32.c:mapin_ram loops over each valid memory range, which means non-contiguous memory just works.

Hello! Does it mean that non-contiguous memory works for any 32-bit powerpc platform, and not only for wiiu? If yes, should not be non-contiguous memory support enabled for all 32-bit ppc boards then?

Hi! Sorry for my delayed response. As best I can tell, it does indeed Just Work, but I have only been able to test on wiiu which is missing a lot of features other boards have (like PCI) - so it's possible there's still an assumption elsewhere in the kernel that I haven't hit.

Quoted 6 lines
Quoted 2 lines

As best I can tell, the Wii and Wii U are the only 32-bit powerpc boards out there where it's even possible to have non-contiguous memory.

What is the reason that those two boards are the **only**? Is there some specific requirement from bootloader or hardware to "enable" non-contiguous memory support?

Not that I know of, I was just saying that I was only aware of those two boards where the memory map isn't contiguous, and that is the only place where it has been tested. Evidently you know of another board!

Quoted 3 lines

I'm interested in enabling non-contiguous memory support for P2020-based board as it has gaps in its 32-bit memory layout and which could be used for RAM mapping when 4GB DDR3 module is plugged in (default is 2GB).

If it's like the Wii or Wii U (some memory at 0, a gap for MMIO or whatever, then more memory at a higher address) then you should try a patch along these lines, because barring the unknowns I mentioned before it should work. At least as far as I'm aware ;)

Quoted 25 lines
Quoted 25 lines
Quoted 25 lines
Quoted 25 lines
---
 arch/powerpc/mm/init_32.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
arch/powerpc/mm/init_32.c +2 -2
index 3d690be48e84..59a84629d9a0 100644
@@ -125,10 +125,10 @@ void __init MMU_init(void)
 	 * lowmem_end_addr is initialized below.
 	 */
 	if (memblock.memory.cnt > 1) {
-#ifndef CONFIG_WII
+#if !defined(CONFIG_WII) && !defined(CONFIG_WIIU)
 		memblock_enforce_memory_limit(memblock.memory.regions[0].size);
 		pr_warn("Only using first contiguous memory region\n");
-#else
+#elif defined(CONFIG_WII)
 		wii_memory_fixups();
 #endif
 	}
Signature · 1 line
2.35.1
#22 lore raw

Re: [PATCH 11/12] powerpc: wiiu: don't enforce flat memory

Le 08/08/2022 à 20:40, Pali Rohár a écrit :

Quoted 11 lines · On Friday 10 June 2022 00:24:20 Pali Rohár wrote:
Quoted 7 lines · On Friday 20 May 2022 14:30:02 Pali Rohár wrote:
Quoted 4 lines

+ linux-mm

Do you know what are requirements for kernel to support non-contiguous memory support and what is needed to enable it for 32-bit powerpc?

Any hints?

PING?

The tree following patches landed in powerpc/next branch, so they should soon be visible in linux-next too:

fc06755e2562 ("powerpc/32: Drop a stale comment about reservation of gigantic pages")
b0e0d68b1c52 ("powerpc/32: Allow fragmented physical memory") 0115953dcebe ("powerpc/32: Remove wii_memory_fixups()")

#23 lore raw

Re: [PATCH 11/12] powerpc: wiiu: don't enforce flat memory

Quoted 13 lines · On Thursday 08 September 2022 15:25:14 Christophe Leroy wrote:

Le 08/08/2022 à 20:40, Pali Rohár a écrit :

Quoted 11 lines · On Friday 10 June 2022 00:24:20 Pali Rohár wrote:
Quoted 7 lines · On Friday 20 May 2022 14:30:02 Pali Rohár wrote:
Quoted 4 lines

+ linux-mm

Do you know what are requirements for kernel to support non-contiguous memory support and what is needed to enable it for 32-bit powerpc?

Any hints?

PING?

Quoted 7 lines

The tree following patches landed in powerpc/next branch, so they should soon be visible in linux-next too:

fc06755e2562 ("powerpc/32: Drop a stale comment about reservation of gigantic pages")
b0e0d68b1c52 ("powerpc/32: Allow fragmented physical memory") 0115953dcebe ("powerpc/32: Remove wii_memory_fixups()")

Ou, nice! I will try to test it if it allows me to access more than 2GB of RAM from 4GB DDR3 module with 32-bit addressing mode on P2020 CPU.

#24 lore raw

Fragmented physical memory on powerpc/32

Quoted 17 lines · On Thursday 08 September 2022 17:35:11 Pali Rohár wrote:
Quoted 16 lines · On Thursday 08 September 2022 15:25:14 Christophe Leroy wrote:

Le 08/08/2022 à 20:40, Pali Rohár a écrit :

Quoted 11 lines · On Friday 10 June 2022 00:24:20 Pali Rohár wrote:
Quoted 7 lines · On Friday 20 May 2022 14:30:02 Pali Rohár wrote:
Quoted 4 lines

+ linux-mm

Do you know what are requirements for kernel to support non-contiguous memory support and what is needed to enable it for 32-bit powerpc?

Any hints?

PING?

The tree following patches landed in powerpc/next branch, so they should soon be visible in linux-next too:

Quoted 7 lines
Quoted 4 lines

fc06755e2562 ("powerpc/32: Drop a stale comment about reservation of gigantic pages")
b0e0d68b1c52 ("powerpc/32: Allow fragmented physical memory") 0115953dcebe ("powerpc/32: Remove wii_memory_fixups()")

Ou, nice! I will try to test it if it allows me to access more than 2GB of RAM from 4GB DDR3 module with 32-bit addressing mode on P2020 CPU.

Hello! Ok, I have tried it from powerpc/next branch, but seems it does not work. I'm getting just early kernel crash.

[    0.000000] CPU maps initialized for 1 thread per core
[    0.000000]  (thread shift is 0)
[    0.000000] -----------------------------------------------------
[    0.000000] phys_mem_size     = 0xbe500000
[    0.000000] dcache_bsize      = 0x20
[    0.000000] icache_bsize      = 0x20
[    0.000000] cpu_features      = 0x0000000010010108
[    0.000000]   possible        = 0x0000000010010108
[    0.000000]   always          = 0x0000000010010108
[    0.000000] cpu_user_features = 0x84e08000 0x08000000
[    0.000000] mmu_features      = 0x00020010
[    0.000000] -----------------------------------------------------
mpc85xx_rdb_setup_arch()
[    0.000000] ioremap() called early from of_iomap+0x48/0x80. Use early_ioremap() instead
[    0.000000] MPC85xx RDB board from Freescale Semiconductor
[    0.000000] barrier-nospec: using isync; sync as speculation barrier
[    0.000000] barrier-nospec: patched 182 locations
[    0.000000] Top of RAM: 0xff700000, Total RAM: 0xbe500000
[    0.000000] Memory hole size: 1042MB
[    0.000000] Zone ranges:
[    0.000000]   Normal   [mem 0x0000000000000000-0x000000002fffffff]
[    0.000000]   HighMem  [mem 0x0000000030000000-0x00000000ff6fffff]
[    0.000000] Movable zone start for each node
[    0.000000] Early memory node ranges
[    0.000000]   node   0: [mem 0x0000000000000000-0x000000007fffffff]
[    0.000000]   node   0: [mem 0x00000000c0200000-0x00000000eeffffff]
[    0.000000]   node   0: [mem 0x00000000f0000000-0x00000000ff6fffff]
[    0.000000] Initmem setup node 0 [mem 0x0000000000000000-0x00000000ff6fffff]
[    0.000000] MMU: Allocated 1088 bytes of context maps for 255 contexts
[    0.000000] percpu: Embedded 11 pages/cpu s14196 r8192 d22668 u45056
[    0.000000] pcpu-alloc: s14196 r8192 d22668 u45056 alloc=11*4096
[    0.000000] pcpu-alloc: [0] 0 [0] 1
[    0.000000] Built 1 zonelists, mobility grouping on.  Total pages: 777792
[    0.000000] Kernel command line: root=ubi0:rootfs rootfstype=ubifs ubi.mtd=rootfs,2048 rootflags=chk_data_crc rw console=ttyS0,115200
[    0.000000] Dentry cache hash table entries: 131072 (order: 7, 524288 bytes, linear)
[    0.000000] Inode-cache hash table entries: 65536 (order: 6, 262144 bytes, linear)
[    0.000000] mem auto-init: stack:off, heap alloc:off, heap free:off
[    0.000000] Kernel attempted to read user page (7df58) - exploit attempt? (uid: 0)
[    0.000000] BUG: Unable to handle kernel data access on read at 0x0007df58
[    0.000000] Faulting instruction address: 0xc01c8348
[    0.000000] Oops: Kernel access of bad area, sig: 11 [#1]
[    0.000000] BE PAGE_SIZE=4K SMP NR_CPUS=2 P2020RDB-PC
[    0.000000] Modules linked in:
[    0.000000] CPU: 0 PID: 0 Comm: swapper Not tainted 6.0.0-rc2-0caacb197b677410bdac81bc34f05235+ #121
[    0.000000] NIP:  c01c8348 LR: c01cb2bc CTR: 0000000a
[    0.000000] REGS: c10d7e20 TRAP: 0300   Not tainted  (6.0.0-rc2-0caacb197b677410bdac81bc34f05235+)
[    0.000000] MSR:  00021000 <CE,ME>  CR: 48044224  XER: 00000000
[    0.000000] DEAR: 0007df58 ESR: 00000000
[    0.000000] GPR00: c01cb294 c10d7f10 c1045340 00000001 00000004 c112bcc0 00000015 eedf1000
[    0.000000] GPR08: 00000003 0007df58 00000000 f0000000 28044228 00000200 00000000 00000000
[    0.000000] GPR16: 00000000 00000000 00000000 0275cb7a c0000000 00000001 0000075f 00000000
[    0.000000] GPR24: c1031004 00000000 00000000 00000001 c10f0000 eedf1000 00080000 00080000
[    0.000000] NIP [c01c8348] free_unref_page_prepare.part.93+0x48/0x60
[    0.000000] LR [c01cb2bc] free_unref_page+0x84/0x4b8
[    0.000000] Call Trace:
[    0.000000] [c10d7f10] [eedf1000] 0xeedf1000 (unreliable)
[    0.000000] [c10d7f20] [c01cb294] free_unref_page+0x5c/0x4b8
[    0.000000] [c10d7f70] [c1007644] mem_init+0xd0/0x194
[    0.000000] [c10d7fa0] [c1000e4c] start_kernel+0x4c0/0x6d0
[    0.000000] [c10d7ff0] [c00003e0] set_ivor+0x13c/0x178
[    0.000000] Instruction dump:
[    0.000000] 552817be 5509103a 7d294214 55293830 7d4a4a14 812a003c 814a0038 5529002a
[    0.000000] 7c892050 5484c23a 5489eafa 548406fe <7d2a482e> 7d242430 5484077e 90870010
[    0.000000] ---[ end trace 0000000000000000 ]---
[    0.000000]
[    0.000000] Kernel panic - not syncing: Fatal exception
[    0.000000] Rebooting in 1 seconds..
[    0.000000] System Halted, OK to turn off power

4GB DDR3 SODIMM module is set via Freescale LBC to the whole 4 GB address range. And on ranges:
0x0000_0000 - 0x7fff_ffff
0xc020_0000 - 0xeeff_ffff
0xf000_0000 - 0xff6f_ffff
there is no peripheral device, they are free for DRAM. Between these physical ranges are mapped peripheral devices (PCIe and NOR).

Any idea if I'm doing something wrong or there can be a bug in memory code?

Quite suspicious is that "Initmem setup node 0" prints one range where are also peripherals, not just DRAM. Crash is on address 0xc01c8348 which belongs to PCIe.

#25 lore raw

Re: Fragmented physical memory on powerpc/32

+ Adding Mike who might help if the problem is around memblock.

Le 08/09/2022 à 22:17, Pali Rohár a écrit :

Quoted 106 lines · On Thursday 08 September 2022 17:35:11 Pali Rohár wrote:
Quoted 17 lines · On Thursday 08 September 2022 15:25:14 Christophe Leroy wrote:
Quoted 16 lines

Le 08/08/2022 à 20:40, Pali Rohár a écrit :

Quoted 11 lines · On Friday 10 June 2022 00:24:20 Pali Rohár wrote:
Quoted 7 lines · On Friday 20 May 2022 14:30:02 Pali Rohár wrote:
Quoted 4 lines

+ linux-mm

Do you know what are requirements for kernel to support non-contiguous memory support and what is needed to enable it for 32-bit powerpc?

Any hints?

PING?

The tree following patches landed in powerpc/next branch, so they should soon be visible in linux-next too:

Quoted 7 lines
Quoted 4 lines

fc06755e2562 ("powerpc/32: Drop a stale comment about reservation of gigantic pages")
b0e0d68b1c52 ("powerpc/32: Allow fragmented physical memory") 0115953dcebe ("powerpc/32: Remove wii_memory_fixups()")

Ou, nice! I will try to test it if it allows me to access more than 2GB of RAM from 4GB DDR3 module with 32-bit addressing mode on P2020 CPU.

Hello! Ok, I have tried it from powerpc/next branch, but seems it does not work. I'm getting just early kernel crash.

[    0.000000] CPU maps initialized for 1 thread per core
[    0.000000]  (thread shift is 0)
[    0.000000] -----------------------------------------------------
[    0.000000] phys_mem_size     = 0xbe500000
[    0.000000] dcache_bsize      = 0x20
[    0.000000] icache_bsize      = 0x20
[    0.000000] cpu_features      = 0x0000000010010108
[    0.000000]   possible        = 0x0000000010010108
[    0.000000]   always          = 0x0000000010010108
[    0.000000] cpu_user_features = 0x84e08000 0x08000000
[    0.000000] mmu_features      = 0x00020010
[    0.000000] -----------------------------------------------------
mpc85xx_rdb_setup_arch()
[    0.000000] ioremap() called early from of_iomap+0x48/0x80. Use early_ioremap() instead
[    0.000000] MPC85xx RDB board from Freescale Semiconductor
[    0.000000] barrier-nospec: using isync; sync as speculation barrier
[    0.000000] barrier-nospec: patched 182 locations
[    0.000000] Top of RAM: 0xff700000, Total RAM: 0xbe500000
[    0.000000] Memory hole size: 1042MB
[    0.000000] Zone ranges:
[    0.000000]   Normal   [mem 0x0000000000000000-0x000000002fffffff]
[    0.000000]   HighMem  [mem 0x0000000030000000-0x00000000ff6fffff]
[    0.000000] Movable zone start for each node
[    0.000000] Early memory node ranges
[    0.000000]   node   0: [mem 0x0000000000000000-0x000000007fffffff]
[    0.000000]   node   0: [mem 0x00000000c0200000-0x00000000eeffffff]
[    0.000000]   node   0: [mem 0x00000000f0000000-0x00000000ff6fffff]
[    0.000000] Initmem setup node 0 [mem 0x0000000000000000-0x00000000ff6fffff]
[    0.000000] MMU: Allocated 1088 bytes of context maps for 255 contexts
[    0.000000] percpu: Embedded 11 pages/cpu s14196 r8192 d22668 u45056
[    0.000000] pcpu-alloc: s14196 r8192 d22668 u45056 alloc=11*4096
[    0.000000] pcpu-alloc: [0] 0 [0] 1
[    0.000000] Built 1 zonelists, mobility grouping on.  Total pages: 777792
[    0.000000] Kernel command line: root=ubi0:rootfs rootfstype=ubifs ubi.mtd=rootfs,2048 rootflags=chk_data_crc rw console=ttyS0,115200
[    0.000000] Dentry cache hash table entries: 131072 (order: 7, 524288 bytes, linear)
[    0.000000] Inode-cache hash table entries: 65536 (order: 6, 262144 bytes, linear)
[    0.000000] mem auto-init: stack:off, heap alloc:off, heap free:off
[    0.000000] Kernel attempted to read user page (7df58) - exploit attempt? (uid: 0)
[    0.000000] BUG: Unable to handle kernel data access on read at 0x0007df58
[    0.000000] Faulting instruction address: 0xc01c8348
[    0.000000] Oops: Kernel access of bad area, sig: 11 [#1]
[    0.000000] BE PAGE_SIZE=4K SMP NR_CPUS=2 P2020RDB-PC
[    0.000000] Modules linked in:
[    0.000000] CPU: 0 PID: 0 Comm: swapper Not tainted 6.0.0-rc2-0caacb197b677410bdac81bc34f05235+ #121
[    0.000000] NIP:  c01c8348 LR: c01cb2bc CTR: 0000000a
[    0.000000] REGS: c10d7e20 TRAP: 0300   Not tainted  (6.0.0-rc2-0caacb197b677410bdac81bc34f05235+)
[    0.000000] MSR:  00021000 <CE,ME>  CR: 48044224  XER: 00000000
[    0.000000] DEAR: 0007df58 ESR: 00000000
[    0.000000] GPR00: c01cb294 c10d7f10 c1045340 00000001 00000004 c112bcc0 00000015 eedf1000
[    0.000000] GPR08: 00000003 0007df58 00000000 f0000000 28044228 00000200 00000000 00000000
[    0.000000] GPR16: 00000000 00000000 00000000 0275cb7a c0000000 00000001 0000075f 00000000
[    0.000000] GPR24: c1031004 00000000 00000000 00000001 c10f0000 eedf1000 00080000 00080000
[    0.000000] NIP [c01c8348] free_unref_page_prepare.part.93+0x48/0x60
[    0.000000] LR [c01cb2bc] free_unref_page+0x84/0x4b8
[    0.000000] Call Trace:
[    0.000000] [c10d7f10] [eedf1000] 0xeedf1000 (unreliable)
[    0.000000] [c10d7f20] [c01cb294] free_unref_page+0x5c/0x4b8
[    0.000000] [c10d7f70] [c1007644] mem_init+0xd0/0x194
[    0.000000] [c10d7fa0] [c1000e4c] start_kernel+0x4c0/0x6d0
[    0.000000] [c10d7ff0] [c00003e0] set_ivor+0x13c/0x178
[    0.000000] Instruction dump:
[    0.000000] 552817be 5509103a 7d294214 55293830 7d4a4a14 812a003c 814a0038 5529002a
[    0.000000] 7c892050 5484c23a 5489eafa 548406fe <7d2a482e> 7d242430 5484077e 90870010
[    0.000000] ---[ end trace 0000000000000000 ]---
[    0.000000]
[    0.000000] Kernel panic - not syncing: Fatal exception
[    0.000000] Rebooting in 1 seconds..
[    0.000000] System Halted, OK to turn off power

4GB DDR3 SODIMM module is set via Freescale LBC to the whole 4 GB address range. And on ranges:
0x0000_0000 - 0x7fff_ffff
0xc020_0000 - 0xeeff_ffff
0xf000_0000 - 0xff6f_ffff
there is no peripheral device, they are free for DRAM. Between these physical ranges are mapped peripheral devices (PCIe and NOR).

Quoted 6 lines

Any idea if I'm doing something wrong or there can be a bug in memory code?

Quite suspicious is that "Initmem setup node 0" prints one range where are also peripherals, not just DRAM. Crash is on address 0xc01c8348 which belongs to PCIe.

Yes I also find that "Initmem setup node 0" suspicious.

However the crash address 0xc01c8348 is valid kernel address. That's a virtual address, not a physical address, so that's not PCIe. That's kernel linear mapping, so that's likely physical address 0x001c8348 offseted by PAGE_OFFSET which is 0xc0000000.

Do you have a way to reproduce this problem under QEMU ?

Thanks
Christophe

#26 lore raw

Re: Fragmented physical memory on powerpc/32

Quoted 116 lines · Christophe Leroy

+ Adding Mike who might help if the problem is around memblock.

Le 08/09/2022 à 22:17, Pali Rohár a écrit :

Quoted 106 lines · On Thursday 08 September 2022 17:35:11 Pali Rohár wrote:
Quoted 17 lines · On Thursday 08 September 2022 15:25:14 Christophe Leroy wrote:
Quoted 16 lines

Le 08/08/2022 à 20:40, Pali Rohár a écrit :

Quoted 11 lines · On Friday 10 June 2022 00:24:20 Pali Rohár wrote:
Quoted 7 lines · On Friday 20 May 2022 14:30:02 Pali Rohár wrote:
Quoted 4 lines

+ linux-mm

Do you know what are requirements for kernel to support non-contiguous memory support and what is needed to enable it for 32-bit powerpc?

Any hints?

PING?

The tree following patches landed in powerpc/next branch, so they should soon be visible in linux-next too:

Quoted 7 lines
Quoted 4 lines

fc06755e2562 ("powerpc/32: Drop a stale comment about reservation of gigantic pages")
b0e0d68b1c52 ("powerpc/32: Allow fragmented physical memory") 0115953dcebe ("powerpc/32: Remove wii_memory_fixups()")

Ou, nice! I will try to test it if it allows me to access more than 2GB of RAM from 4GB DDR3 module with 32-bit addressing mode on P2020 CPU.

Hello! Ok, I have tried it from powerpc/next branch, but seems it does not work. I'm getting just early kernel crash.

[    0.000000] CPU maps initialized for 1 thread per core
[    0.000000]  (thread shift is 0)
[    0.000000] -----------------------------------------------------
[    0.000000] phys_mem_size     = 0xbe500000
[    0.000000] dcache_bsize      = 0x20
[    0.000000] icache_bsize      = 0x20
[    0.000000] cpu_features      = 0x0000000010010108
[    0.000000]   possible        = 0x0000000010010108
[    0.000000]   always          = 0x0000000010010108
[    0.000000] cpu_user_features = 0x84e08000 0x08000000
[    0.000000] mmu_features      = 0x00020010
[    0.000000] -----------------------------------------------------
mpc85xx_rdb_setup_arch()
[    0.000000] ioremap() called early from of_iomap+0x48/0x80. Use early_ioremap() instead
[    0.000000] MPC85xx RDB board from Freescale Semiconductor
[    0.000000] barrier-nospec: using isync; sync as speculation barrier
[    0.000000] barrier-nospec: patched 182 locations
[    0.000000] Top of RAM: 0xff700000, Total RAM: 0xbe500000
[    0.000000] Memory hole size: 1042MB
[    0.000000] Zone ranges:
[    0.000000]   Normal   [mem 0x0000000000000000-0x000000002fffffff]
[    0.000000]   HighMem  [mem 0x0000000030000000-0x00000000ff6fffff]
[    0.000000] Movable zone start for each node
[    0.000000] Early memory node ranges
[    0.000000]   node   0: [mem 0x0000000000000000-0x000000007fffffff]
[    0.000000]   node   0: [mem 0x00000000c0200000-0x00000000eeffffff]
[    0.000000]   node   0: [mem 0x00000000f0000000-0x00000000ff6fffff]
[    0.000000] Initmem setup node 0 [mem 0x0000000000000000-0x00000000ff6fffff]
[    0.000000] MMU: Allocated 1088 bytes of context maps for 255 contexts
[    0.000000] percpu: Embedded 11 pages/cpu s14196 r8192 d22668 u45056
[    0.000000] pcpu-alloc: s14196 r8192 d22668 u45056 alloc=11*4096
[    0.000000] pcpu-alloc: [0] 0 [0] 1
[    0.000000] Built 1 zonelists, mobility grouping on.  Total pages: 777792
[    0.000000] Kernel command line: root=ubi0:rootfs rootfstype=ubifs ubi.mtd=rootfs,2048 rootflags=chk_data_crc rw console=ttyS0,115200
[    0.000000] Dentry cache hash table entries: 131072 (order: 7, 524288 bytes, linear)
[    0.000000] Inode-cache hash table entries: 65536 (order: 6, 262144 bytes, linear)
[    0.000000] mem auto-init: stack:off, heap alloc:off, heap free:off
[    0.000000] Kernel attempted to read user page (7df58) - exploit attempt? (uid: 0)
[    0.000000] BUG: Unable to handle kernel data access on read at 0x0007df58
[    0.000000] Faulting instruction address: 0xc01c8348
[    0.000000] Oops: Kernel access of bad area, sig: 11 [#1]
[    0.000000] BE PAGE_SIZE=4K SMP NR_CPUS=2 P2020RDB-PC
[    0.000000] Modules linked in:
[    0.000000] CPU: 0 PID: 0 Comm: swapper Not tainted 6.0.0-rc2-0caacb197b677410bdac81bc34f05235+ #121
[    0.000000] NIP:  c01c8348 LR: c01cb2bc CTR: 0000000a
[    0.000000] REGS: c10d7e20 TRAP: 0300   Not tainted  (6.0.0-rc2-0caacb197b677410bdac81bc34f05235+)
[    0.000000] MSR:  00021000 <CE,ME>  CR: 48044224  XER: 00000000
[    0.000000] DEAR: 0007df58 ESR: 00000000
[    0.000000] GPR00: c01cb294 c10d7f10 c1045340 00000001 00000004 c112bcc0 00000015 eedf1000
[    0.000000] GPR08: 00000003 0007df58 00000000 f0000000 28044228 00000200 00000000 00000000
[    0.000000] GPR16: 00000000 00000000 00000000 0275cb7a c0000000 00000001 0000075f 00000000
[    0.000000] GPR24: c1031004 00000000 00000000 00000001 c10f0000 eedf1000 00080000 00080000
[    0.000000] NIP [c01c8348] free_unref_page_prepare.part.93+0x48/0x60
[    0.000000] LR [c01cb2bc] free_unref_page+0x84/0x4b8
[    0.000000] Call Trace:
[    0.000000] [c10d7f10] [eedf1000] 0xeedf1000 (unreliable)
[    0.000000] [c10d7f20] [c01cb294] free_unref_page+0x5c/0x4b8
[    0.000000] [c10d7f70] [c1007644] mem_init+0xd0/0x194
[    0.000000] [c10d7fa0] [c1000e4c] start_kernel+0x4c0/0x6d0
[    0.000000] [c10d7ff0] [c00003e0] set_ivor+0x13c/0x178
[    0.000000] Instruction dump:
[    0.000000] 552817be 5509103a 7d294214 55293830 7d4a4a14 812a003c 814a0038 5529002a
[    0.000000] 7c892050 5484c23a 5489eafa 548406fe <7d2a482e> 7d242430 5484077e 90870010
[    0.000000] ---[ end trace 0000000000000000 ]---
[    0.000000]
[    0.000000] Kernel panic - not syncing: Fatal exception
[    0.000000] Rebooting in 1 seconds..
[    0.000000] System Halted, OK to turn off power

4GB DDR3 SODIMM module is set via Freescale LBC to the whole 4 GB address range. And on ranges:
0x0000_0000 - 0x7fff_ffff
0xc020_0000 - 0xeeff_ffff
0xf000_0000 - 0xff6f_ffff
there is no peripheral device, they are free for DRAM. Between these physical ranges are mapped peripheral devices (PCIe and NOR).

Quoted 6 lines

Any idea if I'm doing something wrong or there can be a bug in memory code?

Quite suspicious is that "Initmem setup node 0" prints one range where are also peripherals, not just DRAM. Crash is on address 0xc01c8348 which belongs to PCIe.

Quoted 6 lines

Yes I also find that "Initmem setup node 0" suspicious.

However the crash address 0xc01c8348 is valid kernel address. That's a virtual address, not a physical address, so that's not PCIe. That's kernel linear mapping, so that's likely physical address 0x001c8348 offseted by PAGE_OFFSET which is 0xc0000000.

If I read the dump correctly, 0xc01c8348 is the PC of the instruction that crashed and the access was to 0x0007df58 which seem to well inside 0x0000_0000 - 0x7fff_ffff range.

And the "Early memory node ranges" look consistent with the memory layout above.

My guess would be that something went wrong in the linear map setup, but it won't hurt running with "memblock=debug" added to the kernel command line to see if there is anything suspicious there.

Quoted 4 lines

Do you have a way to reproduce this problem under QEMU ?

Thanks
Christophe

Signature · 2 lines
Sincerely yours,
Mike.
#27 lore raw

Re: Fragmented physical memory on powerpc/32

Quoted 119 lines · On Monday 12 September 2022 15:48:05 Mike Rapoport wrote:
Quoted 118 lines · Christophe Leroy

+ Adding Mike who might help if the problem is around memblock.

Le 08/09/2022 à 22:17, Pali Rohár a écrit :

Quoted 106 lines · On Thursday 08 September 2022 17:35:11 Pali Rohár wrote:
Quoted 17 lines · On Thursday 08 September 2022 15:25:14 Christophe Leroy wrote:
Quoted 16 lines

Le 08/08/2022 à 20:40, Pali Rohár a écrit :

Quoted 11 lines · On Friday 10 June 2022 00:24:20 Pali Rohár wrote:
Quoted 7 lines · On Friday 20 May 2022 14:30:02 Pali Rohár wrote:
Quoted 4 lines

+ linux-mm

Do you know what are requirements for kernel to support non-contiguous memory support and what is needed to enable it for 32-bit powerpc?

Any hints?

PING?

The tree following patches landed in powerpc/next branch, so they should soon be visible in linux-next too:

Quoted 7 lines
Quoted 4 lines

fc06755e2562 ("powerpc/32: Drop a stale comment about reservation of gigantic pages")
b0e0d68b1c52 ("powerpc/32: Allow fragmented physical memory") 0115953dcebe ("powerpc/32: Remove wii_memory_fixups()")

Ou, nice! I will try to test it if it allows me to access more than 2GB of RAM from 4GB DDR3 module with 32-bit addressing mode on P2020 CPU.

Hello! Ok, I have tried it from powerpc/next branch, but seems it does not work. I'm getting just early kernel crash.

[    0.000000] CPU maps initialized for 1 thread per core
[    0.000000]  (thread shift is 0)
[    0.000000] -----------------------------------------------------
[    0.000000] phys_mem_size     = 0xbe500000
[    0.000000] dcache_bsize      = 0x20
[    0.000000] icache_bsize      = 0x20
[    0.000000] cpu_features      = 0x0000000010010108
[    0.000000]   possible        = 0x0000000010010108
[    0.000000]   always          = 0x0000000010010108
[    0.000000] cpu_user_features = 0x84e08000 0x08000000
[    0.000000] mmu_features      = 0x00020010
[    0.000000] -----------------------------------------------------
mpc85xx_rdb_setup_arch()
[    0.000000] ioremap() called early from of_iomap+0x48/0x80. Use early_ioremap() instead
[    0.000000] MPC85xx RDB board from Freescale Semiconductor
[    0.000000] barrier-nospec: using isync; sync as speculation barrier
[    0.000000] barrier-nospec: patched 182 locations
[    0.000000] Top of RAM: 0xff700000, Total RAM: 0xbe500000
[    0.000000] Memory hole size: 1042MB
[    0.000000] Zone ranges:
[    0.000000]   Normal   [mem 0x0000000000000000-0x000000002fffffff]
[    0.000000]   HighMem  [mem 0x0000000030000000-0x00000000ff6fffff]
[    0.000000] Movable zone start for each node
[    0.000000] Early memory node ranges
[    0.000000]   node   0: [mem 0x0000000000000000-0x000000007fffffff]
[    0.000000]   node   0: [mem 0x00000000c0200000-0x00000000eeffffff]
[    0.000000]   node   0: [mem 0x00000000f0000000-0x00000000ff6fffff]
[    0.000000] Initmem setup node 0 [mem 0x0000000000000000-0x00000000ff6fffff]
[    0.000000] MMU: Allocated 1088 bytes of context maps for 255 contexts
[    0.000000] percpu: Embedded 11 pages/cpu s14196 r8192 d22668 u45056
[    0.000000] pcpu-alloc: s14196 r8192 d22668 u45056 alloc=11*4096
[    0.000000] pcpu-alloc: [0] 0 [0] 1
[    0.000000] Built 1 zonelists, mobility grouping on.  Total pages: 777792
[    0.000000] Kernel command line: root=ubi0:rootfs rootfstype=ubifs ubi.mtd=rootfs,2048 rootflags=chk_data_crc rw console=ttyS0,115200
[    0.000000] Dentry cache hash table entries: 131072 (order: 7, 524288 bytes, linear)
[    0.000000] Inode-cache hash table entries: 65536 (order: 6, 262144 bytes, linear)
[    0.000000] mem auto-init: stack:off, heap alloc:off, heap free:off
[    0.000000] Kernel attempted to read user page (7df58) - exploit attempt? (uid: 0)
[    0.000000] BUG: Unable to handle kernel data access on read at 0x0007df58
[    0.000000] Faulting instruction address: 0xc01c8348
[    0.000000] Oops: Kernel access of bad area, sig: 11 [#1]
[    0.000000] BE PAGE_SIZE=4K SMP NR_CPUS=2 P2020RDB-PC
[    0.000000] Modules linked in:
[    0.000000] CPU: 0 PID: 0 Comm: swapper Not tainted 6.0.0-rc2-0caacb197b677410bdac81bc34f05235+ #121
[    0.000000] NIP:  c01c8348 LR: c01cb2bc CTR: 0000000a
[    0.000000] REGS: c10d7e20 TRAP: 0300   Not tainted  (6.0.0-rc2-0caacb197b677410bdac81bc34f05235+)
[    0.000000] MSR:  00021000 <CE,ME>  CR: 48044224  XER: 00000000
[    0.000000] DEAR: 0007df58 ESR: 00000000
[    0.000000] GPR00: c01cb294 c10d7f10 c1045340 00000001 00000004 c112bcc0 00000015 eedf1000
[    0.000000] GPR08: 00000003 0007df58 00000000 f0000000 28044228 00000200 00000000 00000000
[    0.000000] GPR16: 00000000 00000000 00000000 0275cb7a c0000000 00000001 0000075f 00000000
[    0.000000] GPR24: c1031004 00000000 00000000 00000001 c10f0000 eedf1000 00080000 00080000
[    0.000000] NIP [c01c8348] free_unref_page_prepare.part.93+0x48/0x60
[    0.000000] LR [c01cb2bc] free_unref_page+0x84/0x4b8
[    0.000000] Call Trace:
[    0.000000] [c10d7f10] [eedf1000] 0xeedf1000 (unreliable)
[    0.000000] [c10d7f20] [c01cb294] free_unref_page+0x5c/0x4b8
[    0.000000] [c10d7f70] [c1007644] mem_init+0xd0/0x194
[    0.000000] [c10d7fa0] [c1000e4c] start_kernel+0x4c0/0x6d0
[    0.000000] [c10d7ff0] [c00003e0] set_ivor+0x13c/0x178
[    0.000000] Instruction dump:
[    0.000000] 552817be 5509103a 7d294214 55293830 7d4a4a14 812a003c 814a0038 5529002a
[    0.000000] 7c892050 5484c23a 5489eafa 548406fe <7d2a482e> 7d242430 5484077e 90870010
[    0.000000] ---[ end trace 0000000000000000 ]---
[    0.000000]
[    0.000000] Kernel panic - not syncing: Fatal exception
[    0.000000] Rebooting in 1 seconds..
[    0.000000] System Halted, OK to turn off power

4GB DDR3 SODIMM module is set via Freescale LBC to the whole 4 GB address range. And on ranges:
0x0000_0000 - 0x7fff_ffff
0xc020_0000 - 0xeeff_ffff
0xf000_0000 - 0xff6f_ffff
there is no peripheral device, they are free for DRAM. Between these physical ranges are mapped peripheral devices (PCIe and NOR).

Quoted 6 lines

Any idea if I'm doing something wrong or there can be a bug in memory code?

Quite suspicious is that "Initmem setup node 0" prints one range where are also peripherals, not just DRAM. Crash is on address 0xc01c8348 which belongs to PCIe.

Yes I also find that "Initmem setup node 0" suspicious.

Quoted 8 lines
Quoted 4 lines

However the crash address 0xc01c8348 is valid kernel address. That's a virtual address, not a physical address, so that's not PCIe. That's kernel linear mapping, so that's likely physical address 0x001c8348 offseted by PAGE_OFFSET which is 0xc0000000.

If I read the dump correctly, 0xc01c8348 is the PC of the instruction that crashed and the access was to 0x0007df58 which seem to well inside 0x0000_0000 - 0x7fff_ffff range.

I have tried to read and write memory at address 0x0007df58 in U-Boot and it works fine without any crash.

I repeated that boot and it always failed with same errors at same address. I have also tried to use different 4GB DDR module (just in case if it is non-functional) but it failed on the same error on the same address.

Quoted 6 lines

And the "Early memory node ranges" look consistent with the memory layout above.

My guess would be that something went wrong in the linear map setup, but it won't hurt running with "memblock=debug" added to the kernel command line to see if there is anything suspicious there.

Here is boot log on serial console with memblock=debug command line:

[    0.000000] memblock_alloc_try_nid: 8 bytes align=0x4 nid=-1 from=0x00000000 max_addr=0x00000000 smp_setup_cpu_maps+0x40/0x2b4
[    0.000000] memblock_reserve: [0x2fff5d74-0x2fff5d7b] memblock_alloc_range_nid+0xe8/0x1b0
[    0.000000] CPU maps initialized for 1 thread per core
[    0.000000]  (thread shift is 0)
[    0.000000] memblock_phys_free: [0x2fff5d74-0x2fff5d7b] setup_arch+0x1bc/0x318
[    0.000000] -----------------------------------------------------
[    0.000000] phys_mem_size     = 0xbe500000
[    0.000000] dcache_bsize      = 0x20
[    0.000000] icache_bsize      = 0x20
[    0.000000] cpu_features      = 0x0000000010010108
[    0.000000]   possible        = 0x0000000010010108
[    0.000000]   always          = 0x0000000010010108
[    0.000000] cpu_user_features = 0x84e08000 0x08000000
[    0.000000] mmu_features      = 0x00020010
[    0.000000] -----------------------------------------------------
[    0.000000] memblock_alloc_try_nid: 8192 bytes align=0x2000 nid=-1 from=0x00000000 max_addr=0x00000000 alloc_stack+0x2c/0x60
[    0.000000] memblock_reserve: [0x2fff2000-0x2fff3fff] memblock_alloc_range_nid+0xe8/0x1b0
[    0.000000] memblock_alloc_try_nid: 8192 bytes align=0x2000 nid=-1 from=0x00000000 max_addr=0x00000000 alloc_stack+0x2c/0x60
[    0.000000] memblock_reserve: [0x2fff0000-0x2fff1fff] memblock_alloc_range_nid+0xe8/0x1b0
[    0.000000] memblock_alloc_try_nid: 8192 bytes align=0x2000 nid=-1 from=0x00000000 max_addr=0x00000000 alloc_stack+0x2c/0x60
[    0.000000] memblock_reserve: [0x2ffee000-0x2ffeffff] memblock_alloc_range_nid+0xe8/0x1b0
[    0.000000] memblock_alloc_try_nid: 8192 bytes align=0x2000 nid=-1 from=0x00000000 max_addr=0x00000000 alloc_stack+0x2c/0x60
[    0.000000] memblock_reserve: [0x2ffec000-0x2ffedfff] memblock_alloc_range_nid+0xe8/0x1b0
[    0.000000] memblock_alloc_try_nid: 8192 bytes align=0x2000 nid=-1 from=0x00000000 max_addr=0x00000000 alloc_stack+0x2c/0x60
[    0.000000] memblock_reserve: [0x2ffea000-0x2ffebfff] memblock_alloc_range_nid+0xe8/0x1b0
[    0.000000] memblock_alloc_try_nid: 8192 bytes align=0x2000 nid=-1 from=0x00000000 max_addr=0x00000000 alloc_stack+0x2c/0x60
[    0.000000] memblock_reserve: [0x2ffe8000-0x2ffe9fff] memblock_alloc_range_nid+0xe8/0x1b0
[    0.000000] memblock_alloc_try_nid: 8192 bytes align=0x2000 nid=-1 from=0x00000000 max_addr=0x00000000 alloc_stack+0x2c/0x60
[    0.000000] memblock_reserve: [0x2ffe6000-0x2ffe7fff] memblock_alloc_range_nid+0xe8/0x1b0
[    0.000000] memblock_alloc_try_nid: 8192 bytes align=0x2000 nid=-1 from=0x00000000 max_addr=0x00000000 alloc_stack+0x2c/0x60
[    0.000000] memblock_reserve: [0x2ffe4000-0x2ffe5fff] memblock_alloc_range_nid+0xe8/0x1b0
[    0.000000] memblock_alloc_try_nid: 8192 bytes align=0x2000 nid=-1 from=0x00000000 max_addr=0x00000000 alloc_stack+0x2c/0x60
[    0.000000] memblock_reserve: [0x2ffe2000-0x2ffe3fff] memblock_alloc_range_nid+0xe8/0x1b0
[    0.000000] memblock_alloc_try_nid: 8192 bytes align=0x2000 nid=-1 from=0x00000000 max_addr=0x00000000 alloc_stack+0x2c/0x60
[    0.000000] memblock_reserve: [0x2ffe0000-0x2ffe1fff] memblock_alloc_range_nid+0xe8/0x1b0
mpc85xx_rdb_setup_arch()
[    0.000000] ioremap() called early from of_iomap+0x48/0x80. Use early_ioremap() instead
[    0.000000] memblock_alloc_try_nid: 4096 bytes align=0x1000 nid=-1 from=0x00000000 max_addr=0x00000000 early_pte_alloc_kernel+0x3c/0x90
[    0.000000] memblock_reserve: [0x2fff4000-0x2fff4fff] memblock_alloc_range_nid+0xe8/0x1b0
[    0.000000] MPC85xx RDB board from Freescale Semiconductor
[    0.000000] barrier-nospec: using isync; sync as speculation barrier
[    0.000000] barrier-nospec: patched 182 locations
[    0.000000] memblock_alloc_try_nid: 4096 bytes align=0x1000 nid=-1 from=0x00000000 max_addr=0x00000000 early_pte_alloc_kernel+0x3c/0x90
[    0.000000] memblock_reserve: [0x2ffdf000-0x2ffdffff] memblock_alloc_range_nid+0xe8/0x1b0
[    0.000000] Top of RAM: 0xff700000, Total RAM: 0xbe500000
[    0.000000] Memory hole size: 1042MB
[    0.000000] Zone ranges:
[    0.000000]   Normal   [mem 0x0000000000000000-0x000000002fffffff]
[    0.000000]   HighMem  [mem 0x0000000030000000-0x00000000ff6fffff]
[    0.000000] Movable zone start for each node
[    0.000000] Early memory node ranges
[    0.000000]   node   0: [mem 0x0000000000000000-0x000000007fffffff]
[    0.000000]   node   0: [mem 0x00000000c0200000-0x00000000eeffffff]
[    0.000000]   node   0: [mem 0x00000000f0000000-0x00000000ff6fffff]
[    0.000000] Initmem setup node 0 [mem 0x0000000000000000-0x00000000ff6fffff]
[    0.000000] memblock_alloc_try_nid_raw: 37675008 bytes align=0x20 nid=0 from=0x00000000 max_addr=0x00000000 free_area_init+0x890/0xc94
[    0.000000] memblock_reserve: [0x2dbf1000-0x2ffdefff] memblock_alloc_range_nid+0xe8/0x1b0
[    0.000000] memblock_alloc_try_nid: 96 bytes align=0x20 nid=0 from=0x00000000 max_addr=0x00000000 setup_usemap+0x60/0xa0
[    0.000000] memblock_reserve: [0x2fff5d00-0x2fff5d5f] memblock_alloc_range_nid+0xe8/0x1b0
[    0.000000] memblock_alloc_try_nid: 416 bytes align=0x20 nid=0 from=0x00000000 max_addr=0x00000000 setup_usemap+0x60/0xa0
[    0.000000] memblock_reserve: [0x2fff5b60-0x2fff5cff] memblock_alloc_range_nid+0xe8/0x1b0
[    0.000000] memblock_alloc_try_nid: 32 bytes align=0x20 nid=-1 from=0x00000000 max_addr=0x00000000 mmu_context_init+0x38/0x154
[    0.000000] memblock_reserve: [0x2fff5b40-0x2fff5b5f] memblock_alloc_range_nid+0xe8/0x1b0
[    0.000000] memblock_alloc_try_nid: 1024 bytes align=0x20 nid=-1 from=0x00000000 max_addr=0x00000000 mmu_context_init+0x7c/0x154
[    0.000000] memblock_reserve: [0x2fff5740-0x2fff5b3f] memblock_alloc_range_nid+0xe8/0x1b0
[    0.000000] memblock_alloc_try_nid: 32 bytes align=0x20 nid=-1 from=0x00000000 max_addr=0x00000000 mmu_context_init+0xc4/0x154
[    0.000000] memblock_reserve: [0x2fff5720-0x2fff573f] memblock_alloc_range_nid+0xe8/0x1b0
[    0.000000] MMU: Allocated 1088 bytes of context maps for 255 contexts
[    0.000000] memblock_alloc_try_nid: 116 bytes align=0x20 nid=-1 from=0x00000000 max_addr=0x00000000 start_kernel+0x194/0x6d0
[    0.000000] memblock_reserve: [0x2fff56a0-0x2fff5713] memblock_alloc_range_nid+0xe8/0x1b0
[    0.000000] memblock_alloc_try_nid: 116 bytes align=0x20 nid=-1 from=0x00000000 max_addr=0x00000000 start_kernel+0x1c0/0x6d0
[    0.000000] memblock_reserve: [0x2fff5620-0x2fff5693] memblock_alloc_range_nid+0xe8/0x1b0
[    0.000000] memblock_alloc_try_nid: 4096 bytes align=0x1000 nid=-1 from=0x00000000 max_addr=0x00000000 pcpu_embed_first_chunk+0x314/0x7b4
[    0.000000] memblock_reserve: [0x2dbf0000-0x2dbf0fff] memblock_alloc_range_nid+0xe8/0x1b0
[    0.000000] memblock_alloc_try_nid: 4096 bytes align=0x20 nid=-1 from=0x00000000 max_addr=0x00000000 pcpu_embed_first_chunk+0x4d4/0x7b4
[    0.000000] memblock_reserve: [0x2dbef000-0x2dbeffff] memblock_alloc_range_nid+0xe8/0x1b0
[    0.000000] memblock_alloc_try_nid: 90112 bytes align=0x1000 nid=-1 from=0x3fffffff max_addr=0x00000000 pcpu_embed_first_chunk+0x564/0x7b4
[    0.000000] memblock_reserve: [0x2dbd9000-0x2dbeefff] memblock_alloc_range_nid+0xe8/0x1b0
[    0.000000] memblock_phys_free: [0x2dbe4000-0x2dbe3fff] pcpu_embed_first_chunk+0x680/0x7b4
[    0.000000] memblock_phys_free: [0x2dbef000-0x2dbeefff] pcpu_embed_first_chunk+0x680/0x7b4
[    0.000000] percpu: Embedded 11 pages/cpu s14196 r8192 d22668 u45056
[    0.000000] memblock_alloc_try_nid: 4 bytes align=0x20 nid=-1 from=0x00000000 max_addr=0x00000000 pcpu_setup_first_chunk+0x37c/0x924
[    0.000000] memblock_reserve: [0x2fff5d60-0x2fff5d63] memblock_alloc_range_nid+0xe8/0x1b0
[    0.000000] memblock_alloc_try_nid: 4 bytes align=0x20 nid=-1 from=0x00000000 max_addr=0x00000000 pcpu_setup_first_chunk+0x3a4/0x924
[    0.000000] memblock_reserve: [0x2fff5600-0x2fff5603] memblock_alloc_range_nid+0xe8/0x1b0
[    0.000000] memblock_alloc_try_nid: 8 bytes align=0x20 nid=-1 from=0x00000000 max_addr=0x00000000 pcpu_setup_first_chunk+0x3cc/0x924
[    0.000000] memblock_reserve: [0x2fff55e0-0x2fff55e7] memblock_alloc_range_nid+0xe8/0x1b0
[    0.000000] memblock_alloc_try_nid: 8 bytes align=0x20 nid=-1 from=0x00000000 max_addr=0x00000000 pcpu_setup_first_chunk+0x3f4/0x924
[    0.000000] memblock_reserve: [0x2fff55c0-0x2fff55c7] memblock_alloc_range_nid+0xe8/0x1b0
[    0.000000] pcpu-alloc: s14196 r8192 d22668 u45056 alloc=11*4096
[    0.000000] pcpu-alloc: [0] 0 [0] 1 
[    0.000000] memblock_alloc_try_nid: 136 bytes align=0x20 nid=-1 from=0x00000000 max_addr=0x00000000 pcpu_setup_first_chunk+0x7fc/0x924
[    0.000000] memblock_reserve: [0x2fff5520-0x2fff55a7] memblock_alloc_range_nid+0xe8/0x1b0
[    0.000000] memblock_alloc_try_nid: 96 bytes align=0x20 nid=-1 from=0x00000000 max_addr=0x00000000 pcpu_alloc_first_chunk+0x64/0x2e0
[    0.000000] memblock_reserve: [0x2fff54c0-0x2fff551f] memblock_alloc_range_nid+0xe8/0x1b0
[    0.000000] memblock_alloc_try_nid: 384 bytes align=0x20 nid=-1 from=0x00000000 max_addr=0x00000000 pcpu_alloc_first_chunk+0xc4/0x2e0
[    0.000000] memblock_reserve: [0x2fff5340-0x2fff54bf] memblock_alloc_range_nid+0xe8/0x1b0
[    0.000000] memblock_alloc_try_nid: 388 bytes align=0x20 nid=-1 from=0x00000000 max_addr=0x00000000 pcpu_alloc_first_chunk+0xf0/0x2e0
[    0.000000] memblock_reserve: [0x2fff51a0-0x2fff5323] memblock_alloc_range_nid+0xe8/0x1b0
[    0.000000] memblock_alloc_try_nid: 96 bytes align=0x20 nid=-1 from=0x00000000 max_addr=0x00000000 pcpu_alloc_first_chunk+0x11c/0x2e0
[    0.000000] memblock_reserve: [0x2fff5140-0x2fff519f] memblock_alloc_range_nid+0xe8/0x1b0
[    0.000000] memblock_alloc_try_nid: 96 bytes align=0x20 nid=-1 from=0x00000000 max_addr=0x00000000 pcpu_alloc_first_chunk+0x64/0x2e0
[    0.000000] memblock_reserve: [0x2fff50e0-0x2fff513f] memblock_alloc_range_nid+0xe8/0x1b0
[    0.000000] memblock_alloc_try_nid: 768 bytes align=0x20 nid=-1 from=0x00000000 max_addr=0x00000000 pcpu_alloc_first_chunk+0xc4/0x2e0
[    0.000000] memblock_reserve: [0x2dbd8d00-0x2dbd8fff] memblock_alloc_range_nid+0xe8/0x1b0
[    0.000000] memblock_alloc_try_nid: 772 bytes align=0x20 nid=-1 from=0x00000000 max_addr=0x00000000 pcpu_alloc_first_chunk+0xf0/0x2e0
[    0.000000] memblock_reserve: [0x2dbd89e0-0x2dbd8ce3] memblock_alloc_range_nid+0xe8/0x1b0
[    0.000000] memblock_alloc_try_nid: 192 bytes align=0x20 nid=-1 from=0x00000000 max_addr=0x00000000 pcpu_alloc_first_chunk+0x11c/0x2e0
[    0.000000] memblock_reserve: [0x2fff5020-0x2fff50df] memblock_alloc_range_nid+0xe8/0x1b0
[    0.000000] memblock_phys_free: [0x2dbf0000-0x2dbf0fff] pcpu_embed_first_chunk+0x744/0x7b4
[    0.000000] memblock_phys_free: [0x2dbef000-0x2dbeffff] pcpu_embed_first_chunk+0x754/0x7b4
[    0.000000] Built 1 zonelists, mobility grouping on.  Total pages: 777792
[    0.000000] Kernel command line: root=ubi0:rootfs rootfstype=ubifs ubi.mtd=rootfs,2048 rootflags=chk_data_crc rw console=ttyS0,115200 memblock=debug
[    0.000000] memblock_alloc_try_nid: 524288 bytes align=0x20 nid=-1 from=0x00000000 max_addr=0x00000000 alloc_large_system_hash+0x1a4/0x2ec
[    0.000000] memblock_reserve: [0x2db589e0-0x2dbd89df] memblock_alloc_range_nid+0xe8/0x1b0
[    0.000000] Dentry cache hash table entries: 131072 (order: 7, 524288 bytes, linear)
[    0.000000] memblock_alloc_try_nid: 262144 bytes align=0x20 nid=-1 from=0x00000000 max_addr=0x00000000 alloc_large_system_hash+0x1a4/0x2ec
[    0.000000] memblock_reserve: [0x2db189e0-0x2db589df] memblock_alloc_range_nid+0xe8/0x1b0
[    0.000000] Inode-cache hash table entries: 65536 (order: 6, 262144 bytes, linear)
[    0.000000] mem auto-init: stack:off, heap alloc:off, heap free:off
[    0.000000] Kernel attempted to read user page (7df58) - exploit attempt? (uid: 0)
[    0.000000] BUG: Unable to handle kernel data access on read at 0x0007df58
[    0.000000] Faulting instruction address: 0xc01c8348
[    0.000000] Oops: Kernel access of bad area, sig: 11 [#1]
[    0.000000] BE PAGE_SIZE=4K SMP NR_CPUS=2 P2020RDB-PC
[    0.000000] Modules linked in:
[    0.000000] CPU: 0 PID: 0 Comm: swapper Not tainted 6.0.0-rc2-0caacb197b677410bdac81bc34f05235+ #121
[    0.000000] NIP:  c01c8348 LR: c01cb2bc CTR: 0000000a
[    0.000000] REGS: c10d7e20 TRAP: 0300   Not tainted  (6.0.0-rc2-0caacb197b677410bdac81bc34f05235+)
[    0.000000] MSR:  00021000 <CE,ME>  CR: 48044224  XER: 00000000
[    0.000000] DEAR: 0007df58 ESR: 00000000
[    0.000000] GPR00: c01cb294 c10d7f10 c1045340 00000001 00000004 c112bcc0 00000015 eedf1000
[    0.000000] GPR08: 00000003 0007df58 00000000 f0000000 28044228 00000200 00000000 00000000
[    0.000000] GPR16: 00000000 00000000 00000000 0275cb7a c0000000 00000001 0000075f 00000000
[    0.000000] GPR24: c1031004 00000000 00000000 00000001 c10f0000 eedf1000 00080000 00080000
[    0.000000] NIP [c01c8348] free_unref_page_prepare.part.93+0x48/0x60
[    0.000000] LR [c01cb2bc] free_unref_page+0x84/0x4b8
[    0.000000] Call Trace:
[    0.000000] [c10d7f10] [eedf1000] 0xeedf1000 (unreliable)
[    0.000000] [c10d7f20] [c01cb294] free_unref_page+0x5c/0x4b8
[    0.000000] [c10d7f70] [c1007644] mem_init+0xd0/0x194
[    0.000000] [c10d7fa0] [c1000e4c] start_kernel+0x4c0/0x6d0
[    0.000000] [c10d7ff0] [c00003e0] set_ivor+0x13c/0x178
[    0.000000] Instruction dump:
[    0.000000] 552817be 5509103a 7d294214 55293830 7d4a4a14 812a003c 814a0038 5529002a
[    0.000000] 7c892050 5484c23a 5489eafa 548406fe <7d2a482e> 7d242430 5484077e 90870010
[    0.000000] ---[ end trace 0000000000000000 ]---
[    0.000000]
[    0.000000] Kernel panic - not syncing: Fatal exception
[    0.000000] Rebooting in 1 seconds..
[    0.000000] System Halted, OK to turn off power

Do you need something more for debug?

Quoted 1 line
Quoted 1 line

Do you have a way to reproduce this problem under QEMU ?

Well, I really do not know how to run it in QEMU. IIRC QEMU does not have support for P2020 processor. Is there any guidance?

Quoted 6 lines
Quoted 2 lines

Thanks
Christophe

Signature · 2 lines
Sincerely yours,
Mike.
#28 lore raw

Re: Fragmented physical memory on powerpc/32

Le 12/09/2022 à 23:16, Pali Rohár a écrit :

Quoted 125 lines · On Monday 12 September 2022 15:48:05 Mike Rapoport wrote:
Quoted 124 lines · Christophe Leroy
Quoted 122 lines

+ Adding Mike who might help if the problem is around memblock.

Le 08/09/2022 à 22:17, Pali Rohár a écrit :

Quoted 106 lines · On Thursday 08 September 2022 17:35:11 Pali Rohár wrote:
Quoted 17 lines · On Thursday 08 September 2022 15:25:14 Christophe Leroy wrote:
Quoted 16 lines

Le 08/08/2022 à 20:40, Pali Rohár a écrit :

Quoted 11 lines · On Friday 10 June 2022 00:24:20 Pali Rohár wrote:
Quoted 7 lines · On Friday 20 May 2022 14:30:02 Pali Rohár wrote:
Quoted 4 lines

+ linux-mm

Do you know what are requirements for kernel to support non-contiguous memory support and what is needed to enable it for 32-bit powerpc?

Any hints?

PING?

The tree following patches landed in powerpc/next branch, so they should soon be visible in linux-next too:

Quoted 7 lines
Quoted 4 lines

fc06755e2562 ("powerpc/32: Drop a stale comment about reservation of gigantic pages")
b0e0d68b1c52 ("powerpc/32: Allow fragmented physical memory") 0115953dcebe ("powerpc/32: Remove wii_memory_fixups()")

Ou, nice! I will try to test it if it allows me to access more than 2GB of RAM from 4GB DDR3 module with 32-bit addressing mode on P2020 CPU.

Hello! Ok, I have tried it from powerpc/next branch, but seems it does not work. I'm getting just early kernel crash.

[    0.000000] CPU maps initialized for 1 thread per core
[    0.000000]  (thread shift is 0)
[    0.000000] -----------------------------------------------------
[    0.000000] phys_mem_size     = 0xbe500000
[    0.000000] dcache_bsize      = 0x20
[    0.000000] icache_bsize      = 0x20
[    0.000000] cpu_features      = 0x0000000010010108
[    0.000000]   possible        = 0x0000000010010108
[    0.000000]   always          = 0x0000000010010108
[    0.000000] cpu_user_features = 0x84e08000 0x08000000
[    0.000000] mmu_features      = 0x00020010
[    0.000000] -----------------------------------------------------
mpc85xx_rdb_setup_arch()
[    0.000000] ioremap() called early from of_iomap+0x48/0x80. Use early_ioremap() instead
[    0.000000] MPC85xx RDB board from Freescale Semiconductor
[    0.000000] barrier-nospec: using isync; sync as speculation barrier
[    0.000000] barrier-nospec: patched 182 locations
[    0.000000] Top of RAM: 0xff700000, Total RAM: 0xbe500000
[    0.000000] Memory hole size: 1042MB
[    0.000000] Zone ranges:
[    0.000000]   Normal   [mem 0x0000000000000000-0x000000002fffffff]
[    0.000000]   HighMem  [mem 0x0000000030000000-0x00000000ff6fffff]
[    0.000000] Movable zone start for each node
[    0.000000] Early memory node ranges
[    0.000000]   node   0: [mem 0x0000000000000000-0x000000007fffffff]
[    0.000000]   node   0: [mem 0x00000000c0200000-0x00000000eeffffff]
[    0.000000]   node   0: [mem 0x00000000f0000000-0x00000000ff6fffff]
[    0.000000] Initmem setup node 0 [mem 0x0000000000000000-0x00000000ff6fffff]
[    0.000000] MMU: Allocated 1088 bytes of context maps for 255 contexts
[    0.000000] percpu: Embedded 11 pages/cpu s14196 r8192 d22668 u45056
[    0.000000] pcpu-alloc: s14196 r8192 d22668 u45056 alloc=11*4096
[    0.000000] pcpu-alloc: [0] 0 [0] 1
[    0.000000] Built 1 zonelists, mobility grouping on.  Total pages: 777792
[    0.000000] Kernel command line: root=ubi0:rootfs rootfstype=ubifs ubi.mtd=rootfs,2048 rootflags=chk_data_crc rw console=ttyS0,115200
[    0.000000] Dentry cache hash table entries: 131072 (order: 7, 524288 bytes, linear)
[    0.000000] Inode-cache hash table entries: 65536 (order: 6, 262144 bytes, linear)
[    0.000000] mem auto-init: stack:off, heap alloc:off, heap free:off
[    0.000000] Kernel attempted to read user page (7df58) - exploit attempt? (uid: 0)
[    0.000000] BUG: Unable to handle kernel data access on read at 0x0007df58
[    0.000000] Faulting instruction address: 0xc01c8348
[    0.000000] Oops: Kernel access of bad area, sig: 11 [#1]
[    0.000000] BE PAGE_SIZE=4K SMP NR_CPUS=2 P2020RDB-PC
[    0.000000] Modules linked in:
[    0.000000] CPU: 0 PID: 0 Comm: swapper Not tainted 6.0.0-rc2-0caacb197b677410bdac81bc34f05235+ #121
[    0.000000] NIP:  c01c8348 LR: c01cb2bc CTR: 0000000a
[    0.000000] REGS: c10d7e20 TRAP: 0300   Not tainted  (6.0.0-rc2-0caacb197b677410bdac81bc34f05235+)
[    0.000000] MSR:  00021000 <CE,ME>  CR: 48044224  XER: 00000000
[    0.000000] DEAR: 0007df58 ESR: 00000000
[    0.000000] GPR00: c01cb294 c10d7f10 c1045340 00000001 00000004 c112bcc0 00000015 eedf1000
[    0.000000] GPR08: 00000003 0007df58 00000000 f0000000 28044228 00000200 00000000 00000000
[    0.000000] GPR16: 00000000 00000000 00000000 0275cb7a c0000000 00000001 0000075f 00000000
[    0.000000] GPR24: c1031004 00000000 00000000 00000001 c10f0000 eedf1000 00080000 00080000
[    0.000000] NIP [c01c8348] free_unref_page_prepare.part.93+0x48/0x60
[    0.000000] LR [c01cb2bc] free_unref_page+0x84/0x4b8
[    0.000000] Call Trace:
[    0.000000] [c10d7f10] [eedf1000] 0xeedf1000 (unreliable)
[    0.000000] [c10d7f20] [c01cb294] free_unref_page+0x5c/0x4b8
[    0.000000] [c10d7f70] [c1007644] mem_init+0xd0/0x194
[    0.000000] [c10d7fa0] [c1000e4c] start_kernel+0x4c0/0x6d0
[    0.000000] [c10d7ff0] [c00003e0] set_ivor+0x13c/0x178
[    0.000000] Instruction dump:
[    0.000000] 552817be 5509103a 7d294214 55293830 7d4a4a14 812a003c 814a0038 5529002a
[    0.000000] 7c892050 5484c23a 5489eafa 548406fe <7d2a482e> 7d242430 5484077e 90870010
[    0.000000] ---[ end trace 0000000000000000 ]---
[    0.000000]
[    0.000000] Kernel panic - not syncing: Fatal exception
[    0.000000] Rebooting in 1 seconds..
[    0.000000] System Halted, OK to turn off power

4GB DDR3 SODIMM module is set via Freescale LBC to the whole 4 GB address range. And on ranges:
0x0000_0000 - 0x7fff_ffff
0xc020_0000 - 0xeeff_ffff
0xf000_0000 - 0xff6f_ffff
there is no peripheral device, they are free for DRAM. Between these physical ranges are mapped peripheral devices (PCIe and NOR).

Quoted 6 lines

Any idea if I'm doing something wrong or there can be a bug in memory code?

Quite suspicious is that "Initmem setup node 0" prints one range where are also peripherals, not just DRAM. Crash is on address 0xc01c8348 which belongs to PCIe.

Yes I also find that "Initmem setup node 0" suspicious.

However the crash address 0xc01c8348 is valid kernel address. That's a virtual address, not a physical address, so that's not PCIe. That's kernel linear mapping, so that's likely physical address 0x001c8348 offseted by PAGE_OFFSET which is 0xc0000000.

Quoted 6 lines
Quoted 3 lines

If I read the dump correctly, 0xc01c8348 is the PC of the instruction that crashed and the access was to 0x0007df58 which seem to well inside 0x0000_0000 - 0x7fff_ffff range.

I have tried to read and write memory at address 0x0007df58 in U-Boot and it works fine without any crash.

You are mixing physical and virtual addresses.

With Uboot, you checked the Physical address. That corresponds to address 0xc007df58 in Linux.

The Oops happens at virtual address 0x7df58 which is definitely invalid as it is below 0xc0000000.

Quoted 15 lines

I repeated that boot and it always failed with same errors at same address. I have also tried to use different 4GB DDR module (just in case if it is non-functional) but it failed on the same error on the same address.

Quoted 6 lines

And the "Early memory node ranges" look consistent with the memory layout above.

My guess would be that something went wrong in the linear map setup, but it won't hurt running with "memblock=debug" added to the kernel command line to see if there is anything suspicious there.

Here is boot log on serial console with memblock=debug command line:

...

Quoted 2 lines

Do you need something more for debug?

Can you send me the 'vmlinux' used to generate the above Oops so that I can see exactly where we are in function mem_init().

And could you also try without CONFIG_HIGHMEM just in case.

Quoted 6 lines
Quoted 2 lines
Quoted 2 lines

Do you have a way to reproduce this problem under QEMU ?

Well, I really do not know how to run it in QEMU. IIRC QEMU does not have support for P2020 processor. Is there any guidance?

I don't know. I guess there might be the same problem with any e500. But as far as I can see, the 8544 emulation on QEMU has a limit of 3GB and provides memory as a single block.

Christophe

#29 lore raw

Re: Fragmented physical memory on powerpc/32

Le 13/09/2022 à 08:11, Christophe Leroy a écrit :

Quoted 10 lines

Le 12/09/2022 à 23:16, Pali Rohár a écrit :

Quoted 7 lines
Quoted 4 lines

My guess would be that something went wrong in the linear map setup, but it won't hurt running with "memblock=debug" added to the kernel command line to see if there is anything suspicious there.

Here is boot log on serial console with memblock=debug command line:

Quoted 8 lines

...

Quoted 2 lines

Do you need something more for debug?

Can you send me the 'vmlinux' used to generate the above Oops so that I can see exactly where we are in function mem_init().

And could you also try without CONFIG_HIGHMEM just in case.

I looked at the vmlinux you sent me, the problem is in the loop for highmem in mem_init(). It crashes in the call to free_highmem_page()

#ifdef CONFIG_HIGHMEM
	{
		unsigned long pfn, highmem_mapnr;

		highmem_mapnr = lowmem_end_addr >> PAGE_SHIFT;
		for (pfn = highmem_mapnr; pfn < max_mapnr; ++pfn) {
			phys_addr_t paddr = (phys_addr_t)pfn << PAGE_SHIFT;
			struct page *page = pfn_to_page(pfn);
			if (!memblock_is_reserved(paddr))
				free_highmem_page(page);
		}
	}

#endif /* CONFIG_HIGHMEM */

As far as I can see in the memblock debug lines, the holes don't seem to be marked as reserved by memblock. So it is above valid ? Other architectures seem to do differently.

Can you try by replacing !memblock_is_reserved(paddr) by memblock_is_memory(paddr) ?

Thanks
Christophe

#30 lore raw

Re: Fragmented physical memory on powerpc/32

Quoted 43 lines · Christophe Leroy

Le 13/09/2022 à 08:11, Christophe Leroy a écrit :

Quoted 12 lines

Le 12/09/2022 à 23:16, Pali Rohár a écrit :

Quoted 9 lines
Quoted 6 lines

My guess would be that something went wrong in the linear map setup, but it
won't hurt running with "memblock=debug" added to the kernel command line
to see if there is anything suspicious there.

Here is boot log on serial console with memblock=debug command line:

Quoted 9 lines

...

Quoted 2 lines

Do you need something more for debug?

Can you send me the 'vmlinux' used to generate the above Oops so that I can see exactly where we are in function mem_init().

And could you also try without CONFIG_HIGHMEM just in case.

I looked at the vmlinux you sent me, the problem is in the loop for highmem in mem_init(). It crashes in the call to free_highmem_page()

#ifdef CONFIG_HIGHMEM
	{
		unsigned long pfn, highmem_mapnr;

		highmem_mapnr = lowmem_end_addr >> PAGE_SHIFT;
		for (pfn = highmem_mapnr; pfn < max_mapnr; ++pfn) {
			phys_addr_t paddr = (phys_addr_t)pfn << PAGE_SHIFT;
			struct page *page = pfn_to_page(pfn);
			if (!memblock_is_reserved(paddr))
				free_highmem_page(page);
		}
	}

#endif /* CONFIG_HIGHMEM */

Quoted 6 lines

As far as I can see in the memblock debug lines, the holes don't seem to be marked as reserved by memblock. So it is above valid ? Other architectures seem to do differently.

Can you try by replacing !memblock_is_reserved(paddr) by memblock_is_memory(paddr) ?

The holes should not be marked as reserved, we just need to loop over the memory ranges rather than over pfns. Then the holes will be taken into account.

I believe arm and xtensa got this right:

(from arch/arm/mm/init.c)

static void __init free_highpages(void)
{

#ifdef CONFIG_HIGHMEM
	unsigned long max_low = max_low_pfn;
	phys_addr_t range_start, range_end;
	u64 i;

	/* set highmem page free */
	for_each_free_mem_range(i, NUMA_NO_NODE, MEMBLOCK_NONE,
				&range_start, &range_end, NULL) {
		unsigned long start = PFN_UP(range_start);
		unsigned long end = PFN_DOWN(range_end);

		/* Ignore complete lowmem entries */
		if (end <= max_low)
			continue;

		/* Truncate partial highmem entries */
		if (start < max_low)
			start = max_low;

		for (; start < end; start++)
			free_highmem_page(pfn_to_page(start));
	}

#endif
}

Quoted 3 lines

Thanks
Christophe

Signature · 2 lines
Sincerely yours,
Mike.
#31 lore raw

Re: Fragmented physical memory on powerpc/32

Le 14/09/2022 à 11:32, Mike Rapoport a écrit :

Quoted 83 lines · Christophe Leroy
Quoted 43 lines

Le 13/09/2022 à 08:11, Christophe Leroy a écrit :

Quoted 12 lines

Le 12/09/2022 à 23:16, Pali Rohár a écrit :

Quoted 9 lines
Quoted 6 lines

My guess would be that something went wrong in the linear map setup, but it
won't hurt running with "memblock=debug" added to the kernel command line
to see if there is anything suspicious there.

Here is boot log on serial console with memblock=debug command line:

Quoted 9 lines

...

Quoted 2 lines

Do you need something more for debug?

Can you send me the 'vmlinux' used to generate the above Oops so that I can see exactly where we are in function mem_init().

And could you also try without CONFIG_HIGHMEM just in case.

I looked at the vmlinux you sent me, the problem is in the loop for highmem in mem_init(). It crashes in the call to free_highmem_page()

#ifdef CONFIG_HIGHMEM
	{
		unsigned long pfn, highmem_mapnr;

		highmem_mapnr = lowmem_end_addr >> PAGE_SHIFT;
		for (pfn = highmem_mapnr; pfn < max_mapnr; ++pfn) {
			phys_addr_t paddr = (phys_addr_t)pfn << PAGE_SHIFT;
			struct page *page = pfn_to_page(pfn);
			if (!memblock_is_reserved(paddr))
				free_highmem_page(page);
		}
	}

#endif /* CONFIG_HIGHMEM */

Quoted 6 lines

As far as I can see in the memblock debug lines, the holes don't seem to be marked as reserved by memblock. So it is above valid ? Other architectures seem to do differently.

Can you try by replacing !memblock_is_reserved(paddr) by memblock_is_memory(paddr) ?

The holes should not be marked as reserved, we just need to loop over the memory ranges rather than over pfns. Then the holes will be taken into account.

I believe arm and xtensa got this right:

(from arch/arm/mm/init.c)

static void __init free_highpages(void)
{

#ifdef CONFIG_HIGHMEM
	unsigned long max_low = max_low_pfn;
	phys_addr_t range_start, range_end;
	u64 i;

	/* set highmem page free */
	for_each_free_mem_range(i, NUMA_NO_NODE, MEMBLOCK_NONE,
				&range_start, &range_end, NULL) {
		unsigned long start = PFN_UP(range_start);
		unsigned long end = PFN_DOWN(range_end);

		/* Ignore complete lowmem entries */
		if (end <= max_low)
			continue;

		/* Truncate partial highmem entries */
		if (start < max_low)
			start = max_low;

		for (; start < end; start++)
			free_highmem_page(pfn_to_page(start));
	}
Quoted 3 lines

#endif
}

And what about the way MIPS does it ?

static inline void __init mem_init_free_highmem(void) {

#ifdef CONFIG_HIGHMEM
	unsigned long tmp;

	if (cpu_has_dc_aliases)
		return;

	for (tmp = highstart_pfn; tmp < highend_pfn; tmp++) {
		struct page *page = pfn_to_page(tmp);

		if (!memblock_is_memory(PFN_PHYS(tmp)))
			SetPageReserved(page);
		else
			free_highmem_page(page);
	}

#endif
}

Christophe

#32 lore raw

Re: Fragmented physical memory on powerpc/32

Quoted 109 lines · Christophe Leroy

Le 14/09/2022 à 11:32, Mike Rapoport a écrit :

Quoted 83 lines · Christophe Leroy
Quoted 43 lines

Le 13/09/2022 à 08:11, Christophe Leroy a écrit :

Quoted 12 lines

Le 12/09/2022 à 23:16, Pali Rohár a écrit :

Quoted 9 lines
Quoted 6 lines

My guess would be that something went wrong in the linear map setup, but it
won't hurt running with "memblock=debug" added to the kernel command line
to see if there is anything suspicious there.

Here is boot log on serial console with memblock=debug command line:

Quoted 9 lines

...

Quoted 2 lines

Do you need something more for debug?

Can you send me the 'vmlinux' used to generate the above Oops so that I can see exactly where we are in function mem_init().

And could you also try without CONFIG_HIGHMEM just in case.

I looked at the vmlinux you sent me, the problem is in the loop for highmem in mem_init(). It crashes in the call to free_highmem_page()

#ifdef CONFIG_HIGHMEM
	{
		unsigned long pfn, highmem_mapnr;

		highmem_mapnr = lowmem_end_addr >> PAGE_SHIFT;
		for (pfn = highmem_mapnr; pfn < max_mapnr; ++pfn) {
			phys_addr_t paddr = (phys_addr_t)pfn << PAGE_SHIFT;
			struct page *page = pfn_to_page(pfn);
			if (!memblock_is_reserved(paddr))
				free_highmem_page(page);
		}
	}

#endif /* CONFIG_HIGHMEM */

Quoted 6 lines

As far as I can see in the memblock debug lines, the holes don't seem to be marked as reserved by memblock. So it is above valid ? Other architectures seem to do differently.

Can you try by replacing !memblock_is_reserved(paddr) by memblock_is_memory(paddr) ?

The holes should not be marked as reserved, we just need to loop over the memory ranges rather than over pfns. Then the holes will be taken into account.

I believe arm and xtensa got this right:

(from arch/arm/mm/init.c)

static void __init free_highpages(void)
{

#ifdef CONFIG_HIGHMEM
	unsigned long max_low = max_low_pfn;
	phys_addr_t range_start, range_end;
	u64 i;

	/* set highmem page free */
	for_each_free_mem_range(i, NUMA_NO_NODE, MEMBLOCK_NONE,
				&range_start, &range_end, NULL) {
		unsigned long start = PFN_UP(range_start);
		unsigned long end = PFN_DOWN(range_end);

		/* Ignore complete lowmem entries */
		if (end <= max_low)
			continue;

		/* Truncate partial highmem entries */
		if (start < max_low)
			start = max_low;

		for (; start < end; start++)
			free_highmem_page(pfn_to_page(start));
	}
Quoted 3 lines

#endif
}

And what about the way MIPS does it ?

static inline void __init mem_init_free_highmem(void) {

#ifdef CONFIG_HIGHMEM
	unsigned long tmp;

	if (cpu_has_dc_aliases)
		return;

	for (tmp = highstart_pfn; tmp < highend_pfn; tmp++) {
		struct page *page = pfn_to_page(tmp);

		if (!memblock_is_memory(PFN_PHYS(tmp)))
			SetPageReserved(page);
		else
			free_highmem_page(page);
	}
Quoted 2 lines

#endif
}

This iterates over all PFNs in the highmem range and skips those in holes. for_each_free_mem_range() skips the holes altogether.

Largely, I think we need to move, say, arm's version to mm/ and use it everywhere, except, perhaps, x86.

Quoted 1 line

Christophe

Signature · 2 lines
Sincerely yours,
Mike
#33 lore raw

Re: Fragmented physical memory on powerpc/32

Quoted 20 lines · On Wednesday 14 September 2022 16:55:04 Mike Rapoport wrote:
Quoted 19 lines · Christophe Leroy

Le 14/09/2022 à 11:32, Mike Rapoport a écrit :

Quoted 16 lines · Christophe Leroy
Quoted 15 lines

Le 13/09/2022 à 08:11, Christophe Leroy a écrit :

Quoted 12 lines

Le 12/09/2022 à 23:16, Pali Rohár a écrit :

Quoted 9 lines
Quoted 6 lines

My guess would be that something went wrong in the linear map setup, but it
won't hurt running with "memblock=debug" added to the kernel command line
to see if there is anything suspicious there.

Here is boot log on serial console with memblock=debug command line:

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

...

Quoted 2 lines

Do you need something more for debug?

Can you send me the 'vmlinux' used to generate the above Oops so that I can see exactly where we are in function mem_init().

And could you also try without CONFIG_HIGHMEM just in case.

Hello! I disabled CONFIG_HIGHMEM and there is no crash anymore. But kernel see only 761160 kB of RAM, which is less than 3GB. I guess this is expected.

Quoted 20 lines
Quoted 20 lines
Quoted 20 lines
Quoted 20 lines
Quoted 1 line

I looked at the vmlinux you sent me, the problem is in the loop for highmem in mem_init(). It crashes in the call to free_highmem_page()

#ifdef CONFIG_HIGHMEM
	{
		unsigned long pfn, highmem_mapnr;

		highmem_mapnr = lowmem_end_addr >> PAGE_SHIFT;
		for (pfn = highmem_mapnr; pfn < max_mapnr; ++pfn) {
			phys_addr_t paddr = (phys_addr_t)pfn << PAGE_SHIFT;
			struct page *page = pfn_to_page(pfn);
			if (!memblock_is_reserved(paddr))
				free_highmem_page(page);
		}
	}

#endif /* CONFIG_HIGHMEM */

Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines

As far as I can see in the memblock debug lines, the holes don't seem to be marked as reserved by memblock. So it is above valid ? Other architectures seem to do differently.

Can you try by replacing !memblock_is_reserved(paddr) by memblock_is_memory(paddr) ?

I enabled CONFIG_HIGHMEM again, applied this change and kernel does not crash too anymore. And it sees 3062896 kB of memory (in 'free' output).

So seems that this change fixed it.

I tried simple C program for allocating memory via malloc() and it successfully allocated 2800 MB. If it tried to request/allocate more then kernel started OOM killer which killed that program gracefully. No kernel or HW crash.

Here is bootlog:

[    0.000000] memblock_alloc_try_nid: 8 bytes align=0x4 nid=-1 from=0x00000000 max_addr=0x00000000 smp_setup_cpu_maps+0x40/0x2b4
[    0.000000] memblock_reserve: [0x2fff5d74-0x2fff5d7b] memblock_alloc_range_nid+0xe8/0x1b0
[    0.000000] CPU maps initialized for 1 thread per core
[    0.000000]  (thread shift is 0)
[    0.000000] memblock_phys_free: [0x2fff5d74-0x2fff5d7b] setup_arch+0x1bc/0x318
[    0.000000] -----------------------------------------------------
[    0.000000] phys_mem_size     = 0xbe500000
[    0.000000] dcache_bsize      = 0x20
[    0.000000] icache_bsize      = 0x20
[    0.000000] cpu_features      = 0x0000000010010108
[    0.000000]   possible        = 0x0000000010010108
[    0.000000]   always          = 0x0000000010010108
[    0.000000] cpu_user_features = 0x84e08000 0x08000000
[    0.000000] mmu_features      = 0x00020010
[    0.000000] -----------------------------------------------------
[    0.000000] memblock_alloc_try_nid: 8192 bytes align=0x2000 nid=-1 from=0x00000000 max_addr=0x00000000 alloc_stack+0x2c/0x60
[    0.000000] memblock_reserve: [0x2fff2000-0x2fff3fff] memblock_alloc_range_nid+0xe8/0x1b0
[    0.000000] memblock_alloc_try_nid: 8192 bytes align=0x2000 nid=-1 from=0x00000000 max_addr=0x00000000 alloc_stack+0x2c/0x60
[    0.000000] memblock_reserve: [0x2fff0000-0x2fff1fff] memblock_alloc_range_nid+0xe8/0x1b0
[    0.000000] memblock_alloc_try_nid: 8192 bytes align=0x2000 nid=-1 from=0x00000000 max_addr=0x00000000 alloc_stack+0x2c/0x60
[    0.000000] memblock_reserve: [0x2ffee000-0x2ffeffff] memblock_alloc_range_nid+0xe8/0x1b0
[    0.000000] memblock_alloc_try_nid: 8192 bytes align=0x2000 nid=-1 from=0x00000000 max_addr=0x00000000 alloc_stack+0x2c/0x60
[    0.000000] memblock_reserve: [0x2ffec000-0x2ffedfff] memblock_alloc_range_nid+0xe8/0x1b0
[    0.000000] memblock_alloc_try_nid: 8192 bytes align=0x2000 nid=-1 from=0x00000000 max_addr=0x00000000 alloc_stack+0x2c/0x60
[    0.000000] memblock_reserve: [0x2ffea000-0x2ffebfff] memblock_alloc_range_nid+0xe8/0x1b0
[    0.000000] memblock_alloc_try_nid: 8192 bytes align=0x2000 nid=-1 from=0x00000000 max_addr=0x00000000 alloc_stack+0x2c/0x60
[    0.000000] memblock_reserve: [0x2ffe8000-0x2ffe9fff] memblock_alloc_range_nid+0xe8/0x1b0
[    0.000000] memblock_alloc_try_nid: 8192 bytes align=0x2000 nid=-1 from=0x00000000 max_addr=0x00000000 alloc_stack+0x2c/0x60
[    0.000000] memblock_reserve: [0x2ffe6000-0x2ffe7fff] memblock_alloc_range_nid+0xe8/0x1b0
[    0.000000] memblock_alloc_try_nid: 8192 bytes align=0x2000 nid=-1 from=0x00000000 max_addr=0x00000000 alloc_stack+0x2c/0x60
[    0.000000] memblock_reserve: [0x2ffe4000-0x2ffe5fff] memblock_alloc_range_nid+0xe8/0x1b0
[    0.000000] memblock_alloc_try_nid: 8192 bytes align=0x2000 nid=-1 from=0x00000000 max_addr=0x00000000 alloc_stack+0x2c/0x60
[    0.000000] memblock_reserve: [0x2ffe2000-0x2ffe3fff] memblock_alloc_range_nid+0xe8/0x1b0
[    0.000000] memblock_alloc_try_nid: 8192 bytes align=0x2000 nid=-1 from=0x00000000 max_addr=0x00000000 alloc_stack+0x2c/0x60
[    0.000000] memblock_reserve: [0x2ffe0000-0x2ffe1fff] memblock_alloc_range_nid+0xe8/0x1b0
mpc85xx_rdb_setup_arch()
[    0.000000] ioremap() called early from of_iomap+0x48/0x80. Use early_ioremap() instead
[    0.000000] memblock_alloc_try_nid: 4096 bytes align=0x1000 nid=-1 from=0x00000000 max_addr=0x00000000 early_pte_alloc_kernel+0x3c/0x90
[    0.000000] memblock_reserve: [0x2fff4000-0x2fff4fff] memblock_alloc_range_nid+0xe8/0x1b0
[    0.000000] MPC85xx RDB board from Freescale Semiconductor
[    0.000000] barrier-nospec: using isync; sync as speculation barrier
[    0.000000] barrier-nospec: patched 182 locations
[    0.000000] memblock_alloc_try_nid: 4096 bytes align=0x1000 nid=-1 from=0x00000000 max_addr=0x00000000 early_pte_alloc_kernel+0x3c/0x90
[    0.000000] memblock_reserve: [0x2ffdf000-0x2ffdffff] memblock_alloc_range_nid+0xe8/0x1b0
[    0.000000] Top of RAM: 0xff700000, Total RAM: 0xbe500000
[    0.000000] Memory hole size: 1042MB
[    0.000000] Zone ranges:
[    0.000000]   Normal   [mem 0x0000000000000000-0x000000002fffffff]
[    0.000000]   HighMem  [mem 0x0000000030000000-0x00000000ff6fffff]
[    0.000000] Movable zone start for each node
[    0.000000] Early memory node ranges
[    0.000000]   node   0: [mem 0x0000000000000000-0x000000007fffffff]
[    0.000000]   node   0: [mem 0x00000000c0200000-0x00000000eeffffff]
[    0.000000]   node   0: [mem 0x00000000f0000000-0x00000000ff6fffff]
[    0.000000] Initmem setup node 0 [mem 0x0000000000000000-0x00000000ff6fffff]
[    0.000000] memblock_alloc_try_nid_raw: 37675008 bytes align=0x20 nid=0 from=0x00000000 max_addr=0x00000000 free_area_init+0x890/0xc94
[    0.000000] memblock_reserve: [0x2dbf1000-0x2ffdefff] memblock_alloc_range_nid+0xe8/0x1b0
[    0.000000] memblock_alloc_try_nid: 96 bytes align=0x20 nid=0 from=0x00000000 max_addr=0x00000000 setup_usemap+0x60/0xa0
[    0.000000] memblock_reserve: [0x2fff5d00-0x2fff5d5f] memblock_alloc_range_nid+0xe8/0x1b0
[    0.000000] memblock_alloc_try_nid: 416 bytes align=0x20 nid=0 from=0x00000000 max_addr=0x00000000 setup_usemap+0x60/0xa0
[    0.000000] memblock_reserve: [0x2fff5b60-0x2fff5cff] memblock_alloc_range_nid+0xe8/0x1b0
[    0.000000] memblock_alloc_try_nid: 32 bytes align=0x20 nid=-1 from=0x00000000 max_addr=0x00000000 mmu_context_init+0x38/0x154
[    0.000000] memblock_reserve: [0x2fff5b40-0x2fff5b5f] memblock_alloc_range_nid+0xe8/0x1b0
[    0.000000] memblock_alloc_try_nid: 1024 bytes align=0x20 nid=-1 from=0x00000000 max_addr=0x00000000 mmu_context_init+0x7c/0x154
[    0.000000] memblock_reserve: [0x2fff5740-0x2fff5b3f] memblock_alloc_range_nid+0xe8/0x1b0
[    0.000000] memblock_alloc_try_nid: 32 bytes align=0x20 nid=-1 from=0x00000000 max_addr=0x00000000 mmu_context_init+0xc4/0x154
[    0.000000] memblock_reserve: [0x2fff5720-0x2fff573f] memblock_alloc_range_nid+0xe8/0x1b0
[    0.000000] MMU: Allocated 1088 bytes of context maps for 255 contexts
[    0.000000] memblock_alloc_try_nid: 111 bytes align=0x20 nid=-1 from=0x00000000 max_addr=0x00000000 start_kernel+0x194/0x6d0
[    0.000000] memblock_reserve: [0x2fff56a0-0x2fff570e] memblock_alloc_range_nid+0xe8/0x1b0
[    0.000000] memblock_alloc_try_nid: 111 bytes align=0x20 nid=-1 from=0x00000000 max_addr=0x00000000 start_kernel+0x1c0/0x6d0
[    0.000000] memblock_reserve: [0x2fff5620-0x2fff568e] memblock_alloc_range_nid+0xe8/0x1b0
[    0.000000] memblock_alloc_try_nid: 4096 bytes align=0x1000 nid=-1 from=0x00000000 max_addr=0x00000000 pcpu_embed_first_chunk+0x314/0x7b4
[    0.000000] memblock_reserve: [0x2dbf0000-0x2dbf0fff] memblock_alloc_range_nid+0xe8/0x1b0
[    0.000000] memblock_alloc_try_nid: 4096 bytes align=0x20 nid=-1 from=0x00000000 max_addr=0x00000000 pcpu_embed_first_chunk+0x4d4/0x7b4
[    0.000000] memblock_reserve: [0x2dbef000-0x2dbeffff] memblock_alloc_range_nid+0xe8/0x1b0
[    0.000000] memblock_alloc_try_nid: 90112 bytes align=0x1000 nid=-1 from=0x3fffffff max_addr=0x00000000 pcpu_embed_first_chunk+0x564/0x7b4
[    0.000000] memblock_reserve: [0x2dbd9000-0x2dbeefff] memblock_alloc_range_nid+0xe8/0x1b0
[    0.000000] memblock_phys_free: [0x2dbe4000-0x2dbe3fff] pcpu_embed_first_chunk+0x680/0x7b4
[    0.000000] memblock_phys_free: [0x2dbef000-0x2dbeefff] pcpu_embed_first_chunk+0x680/0x7b4
[    0.000000] percpu: Embedded 11 pages/cpu s14196 r8192 d22668 u45056
[    0.000000] memblock_alloc_try_nid: 4 bytes align=0x20 nid=-1 from=0x00000000 max_addr=0x00000000 pcpu_setup_first_chunk+0x37c/0x924
[    0.000000] memblock_reserve: [0x2fff5d60-0x2fff5d63] memblock_alloc_range_nid+0xe8/0x1b0
[    0.000000] memblock_alloc_try_nid: 4 bytes align=0x20 nid=-1 from=0x00000000 max_addr=0x00000000 pcpu_setup_first_chunk+0x3a4/0x924
[    0.000000] memblock_reserve: [0x2fff5600-0x2fff5603] memblock_alloc_range_nid+0xe8/0x1b0
[    0.000000] memblock_alloc_try_nid: 8 bytes align=0x20 nid=-1 from=0x00000000 max_addr=0x00000000 pcpu_setup_first_chunk+0x3cc/0x924
[    0.000000] memblock_reserve: [0x2fff55e0-0x2fff55e7] memblock_alloc_range_nid+0xe8/0x1b0
[    0.000000] memblock_alloc_try_nid: 8 bytes align=0x20 nid=-1 from=0x00000000 max_addr=0x00000000 pcpu_setup_first_chunk+0x3f4/0x924
[    0.000000] memblock_reserve: [0x2fff55c0-0x2fff55c7] memblock_alloc_range_nid+0xe8/0x1b0
[    0.000000] pcpu-alloc: s14196 r8192 d22668 u45056 alloc=11*4096
[    0.000000] pcpu-alloc: [0] 0 [0] 1 
[    0.000000] memblock_alloc_try_nid: 136 bytes align=0x20 nid=-1 from=0x00000000 max_addr=0x00000000 pcpu_setup_first_chunk+0x7fc/0x924
[    0.000000] memblock_reserve: [0x2fff5520-0x2fff55a7] memblock_alloc_range_nid+0xe8/0x1b0
[    0.000000] memblock_alloc_try_nid: 96 bytes align=0x20 nid=-1 from=0x00000000 max_addr=0x00000000 pcpu_alloc_first_chunk+0x64/0x2e0
[    0.000000] memblock_reserve: [0x2fff54c0-0x2fff551f] memblock_alloc_range_nid+0xe8/0x1b0
[    0.000000] memblock_alloc_try_nid: 384 bytes align=0x20 nid=-1 from=0x00000000 max_addr=0x00000000 pcpu_alloc_first_chunk+0xc4/0x2e0
[    0.000000] memblock_reserve: [0x2fff5340-0x2fff54bf] memblock_alloc_range_nid+0xe8/0x1b0
[    0.000000] memblock_alloc_try_nid: 388 bytes align=0x20 nid=-1 from=0x00000000 max_addr=0x00000000 pcpu_alloc_first_chunk+0xf0/0x2e0
[    0.000000] memblock_reserve: [0x2fff51a0-0x2fff5323] memblock_alloc_range_nid+0xe8/0x1b0
[    0.000000] memblock_alloc_try_nid: 96 bytes align=0x20 nid=-1 from=0x00000000 max_addr=0x00000000 pcpu_alloc_first_chunk+0x11c/0x2e0
[    0.000000] memblock_reserve: [0x2fff5140-0x2fff519f] memblock_alloc_range_nid+0xe8/0x1b0
[    0.000000] memblock_alloc_try_nid: 96 bytes align=0x20 nid=-1 from=0x00000000 max_addr=0x00000000 pcpu_alloc_first_chunk+0x64/0x2e0
[    0.000000] memblock_reserve: [0x2fff50e0-0x2fff513f] memblock_alloc_range_nid+0xe8/0x1b0
[    0.000000] memblock_alloc_try_nid: 768 bytes align=0x20 nid=-1 from=0x00000000 max_addr=0x00000000 pcpu_alloc_first_chunk+0xc4/0x2e0
[    0.000000] memblock_reserve: [0x2dbd8d00-0x2dbd8fff] memblock_alloc_range_nid+0xe8/0x1b0
[    0.000000] memblock_alloc_try_nid: 772 bytes align=0x20 nid=-1 from=0x00000000 max_addr=0x00000000 pcpu_alloc_first_chunk+0xf0/0x2e0
[    0.000000] memblock_reserve: [0x2dbd89e0-0x2dbd8ce3] memblock_alloc_range_nid+0xe8/0x1b0
[    0.000000] memblock_alloc_try_nid: 192 bytes align=0x20 nid=-1 from=0x00000000 max_addr=0x00000000 pcpu_alloc_first_chunk+0x11c/0x2e0
[    0.000000] memblock_reserve: [0x2fff5020-0x2fff50df] memblock_alloc_range_nid+0xe8/0x1b0
[    0.000000] memblock_phys_free: [0x2dbf0000-0x2dbf0fff] pcpu_embed_first_chunk+0x744/0x7b4
[    0.000000] memblock_phys_free: [0x2dbef000-0x2dbeffff] pcpu_embed_first_chunk+0x754/0x7b4
[    0.000000] Built 1 zonelists, mobility grouping on.  Total pages: 777792
[    0.000000] Kernel command line: root=ubi0:rootfs rootfstype=ubifs ubi.mtd=rootfs rootflags=chk_data_crc rw console=ttyS0,115200 memblock=debug
[    0.000000] memblock_alloc_try_nid: 524288 bytes align=0x20 nid=-1 from=0x00000000 max_addr=0x00000000 alloc_large_system_hash+0x1a4/0x2ec
[    0.000000] memblock_reserve: [0x2db589e0-0x2dbd89df] memblock_alloc_range_nid+0xe8/0x1b0
[    0.000000] Dentry cache hash table entries: 131072 (order: 7, 524288 bytes, linear)
[    0.000000] memblock_alloc_try_nid: 262144 bytes align=0x20 nid=-1 from=0x00000000 max_addr=0x00000000 alloc_large_system_hash+0x1a4/0x2ec
[    0.000000] memblock_reserve: [0x2db189e0-0x2db589df] memblock_alloc_range_nid+0xe8/0x1b0
[    0.000000] Inode-cache hash table entries: 65536 (order: 6, 262144 bytes, linear)
[    0.000000] mem auto-init: stack:off, heap alloc:off, heap free:off
[    0.000000] Kernel virtual memory layout:
[    0.000000]   * 0xffbbf000..0xfffff000  : fixmap
[    0.000000]   * 0xff400000..0xff800000  : highmem PTEs
[    0.000000]   * 0xff3fe000..0xff400000  : early ioremap
[    0.000000]   * 0xf1000000..0xff3fe000  : vmalloc & ioremap
[    0.000000] Memory: 3062620K/3118080K available (10732K kernel code, 712K rwdata, 2044K rodata, 276K init, 287K bss, 55460K reserved, 0K cma-reserved, 2331648K highmem)
[    0.000000] SLUB: HWalign=32, Order=0-3, MinObjects=0, CPUs=2, Nodes=1
Quoted 59 lines
Quoted 56 lines
Quoted 33 lines

The holes should not be marked as reserved, we just need to loop over the memory ranges rather than over pfns. Then the holes will be taken into account.

I believe arm and xtensa got this right:

(from arch/arm/mm/init.c)

static void __init free_highpages(void)
{

#ifdef CONFIG_HIGHMEM
	unsigned long max_low = max_low_pfn;
	phys_addr_t range_start, range_end;
	u64 i;

	/* set highmem page free */
	for_each_free_mem_range(i, NUMA_NO_NODE, MEMBLOCK_NONE,
				&range_start, &range_end, NULL) {
		unsigned long start = PFN_UP(range_start);
		unsigned long end = PFN_DOWN(range_end);

		/* Ignore complete lowmem entries */
		if (end <= max_low)
			continue;

		/* Truncate partial highmem entries */
		if (start < max_low)
			start = max_low;

		for (; start < end; start++)
			free_highmem_page(pfn_to_page(start));
	}
Quoted 3 lines

#endif
}

And what about the way MIPS does it ?

static inline void __init mem_init_free_highmem(void) {

#ifdef CONFIG_HIGHMEM
	unsigned long tmp;

	if (cpu_has_dc_aliases)
		return;

	for (tmp = highstart_pfn; tmp < highend_pfn; tmp++) {
		struct page *page = pfn_to_page(tmp);

		if (!memblock_is_memory(PFN_PHYS(tmp)))
			SetPageReserved(page);
		else
			free_highmem_page(page);
	}
Quoted 2 lines

#endif
}

Quoted 4 lines

This iterates over all PFNs in the highmem range and skips those in holes. for_each_free_mem_range() skips the holes altogether.

Largely, I think we need to move, say, arm's version to mm/ and use it everywhere, except, perhaps, x86.

I tried to replace quoted powerpc CONFIG_HIGHMEM code by above arm code and it worked fine too! No kernel crash anymore. But 'free' see only 3062888 kB of total memory. Which is less then with the first workaround.

Here is bootlog:

[    0.000000] memblock_alloc_try_nid: 8 bytes align=0x4 nid=-1 from=0x00000000 max_addr=0x00000000 smp_setup_cpu_maps+0x40/0x2b4
[    0.000000] memblock_reserve: [0x2fff5d74-0x2fff5d7b] memblock_alloc_range_nid+0xe8/0x1b0
[    0.000000] CPU maps initialized for 1 thread per core
[    0.000000]  (thread shift is 0)
[    0.000000] memblock_phys_free: [0x2fff5d74-0x2fff5d7b] setup_arch+0x1bc/0x318
[    0.000000] -----------------------------------------------------
[    0.000000] phys_mem_size     = 0xbe500000
[    0.000000] dcache_bsize      = 0x20
[    0.000000] icache_bsize      = 0x20
[    0.000000] cpu_features      = 0x0000000010010108
[    0.000000]   possible        = 0x0000000010010108
[    0.000000]   always          = 0x0000000010010108
[    0.000000] cpu_user_features = 0x84e08000 0x08000000
[    0.000000] mmu_features      = 0x00020010
[    0.000000] -----------------------------------------------------
[    0.000000] memblock_alloc_try_nid: 8192 bytes align=0x2000 nid=-1 from=0x00000000 max_addr=0x00000000 alloc_stack+0x2c/0x60
[    0.000000] memblock_reserve: [0x2fff2000-0x2fff3fff] memblock_alloc_range_nid+0xe8/0x1b0
[    0.000000] memblock_alloc_try_nid: 8192 bytes align=0x2000 nid=-1 from=0x00000000 max_addr=0x00000000 alloc_stack+0x2c/0x60
[    0.000000] memblock_reserve: [0x2fff0000-0x2fff1fff] memblock_alloc_range_nid+0xe8/0x1b0
[    0.000000] memblock_alloc_try_nid: 8192 bytes align=0x2000 nid=-1 from=0x00000000 max_addr=0x00000000 alloc_stack+0x2c/0x60
[    0.000000] memblock_reserve: [0x2ffee000-0x2ffeffff] memblock_alloc_range_nid+0xe8/0x1b0
[    0.000000] memblock_alloc_try_nid: 8192 bytes align=0x2000 nid=-1 from=0x00000000 max_addr=0x00000000 alloc_stack+0x2c/0x60
[    0.000000] memblock_reserve: [0x2ffec000-0x2ffedfff] memblock_alloc_range_nid+0xe8/0x1b0
[    0.000000] memblock_alloc_try_nid: 8192 bytes align=0x2000 nid=-1 from=0x00000000 max_addr=0x00000000 alloc_stack+0x2c/0x60
[    0.000000] memblock_reserve: [0x2ffea000-0x2ffebfff] memblock_alloc_range_nid+0xe8/0x1b0
[    0.000000] memblock_alloc_try_nid: 8192 bytes align=0x2000 nid=-1 from=0x00000000 max_addr=0x00000000 alloc_stack+0x2c/0x60
[    0.000000] memblock_reserve: [0x2ffe8000-0x2ffe9fff] memblock_alloc_range_nid+0xe8/0x1b0
[    0.000000] memblock_alloc_try_nid: 8192 bytes align=0x2000 nid=-1 from=0x00000000 max_addr=0x00000000 alloc_stack+0x2c/0x60
[    0.000000] memblock_reserve: [0x2ffe6000-0x2ffe7fff] memblock_alloc_range_nid+0xe8/0x1b0
[    0.000000] memblock_alloc_try_nid: 8192 bytes align=0x2000 nid=-1 from=0x00000000 max_addr=0x00000000 alloc_stack+0x2c/0x60
[    0.000000] memblock_reserve: [0x2ffe4000-0x2ffe5fff] memblock_alloc_range_nid+0xe8/0x1b0
[    0.000000] memblock_alloc_try_nid: 8192 bytes align=0x2000 nid=-1 from=0x00000000 max_addr=0x00000000 alloc_stack+0x2c/0x60
[    0.000000] memblock_reserve: [0x2ffe2000-0x2ffe3fff] memblock_alloc_range_nid+0xe8/0x1b0
[    0.000000] memblock_alloc_try_nid: 8192 bytes align=0x2000 nid=-1 from=0x00000000 max_addr=0x00000000 alloc_stack+0x2c/0x60
[    0.000000] memblock_reserve: [0x2ffe0000-0x2ffe1fff] memblock_alloc_range_nid+0xe8/0x1b0
mpc85xx_rdb_setup_arch()
[    0.000000] ioremap() called early from of_iomap+0x48/0x80. Use early_ioremap() instead
[    0.000000] memblock_alloc_try_nid: 4096 bytes align=0x1000 nid=-1 from=0x00000000 max_addr=0x00000000 early_pte_alloc_kernel+0x3c/0x90
[    0.000000] memblock_reserve: [0x2fff4000-0x2fff4fff] memblock_alloc_range_nid+0xe8/0x1b0
[    0.000000] MPC85xx RDB board from Freescale Semiconductor
[    0.000000] barrier-nospec: using isync; sync as speculation barrier
[    0.000000] barrier-nospec: patched 182 locations
[    0.000000] memblock_alloc_try_nid: 4096 bytes align=0x1000 nid=-1 from=0x00000000 max_addr=0x00000000 early_pte_alloc_kernel+0x3c/0x90
[    0.000000] memblock_reserve: [0x2ffdf000-0x2ffdffff] memblock_alloc_range_nid+0xe8/0x1b0
[    0.000000] Top of RAM: 0xff700000, Total RAM: 0xbe500000
[    0.000000] Memory hole size: 1042MB
[    0.000000] Zone ranges:
[    0.000000]   Normal   [mem 0x0000000000000000-0x000000002fffffff]
[    0.000000]   HighMem  [mem 0x0000000030000000-0x00000000ff6fffff]
[    0.000000] Movable zone start for each node
[    0.000000] Early memory node ranges
[    0.000000]   node   0: [mem 0x0000000000000000-0x000000007fffffff]
[    0.000000]   node   0: [mem 0x00000000c0200000-0x00000000eeffffff]
[    0.000000]   node   0: [mem 0x00000000f0000000-0x00000000ff6fffff]
[    0.000000] Initmem setup node 0 [mem 0x0000000000000000-0x00000000ff6fffff]
[    0.000000] memblock_alloc_try_nid_raw: 37675008 bytes align=0x20 nid=0 from=0x00000000 max_addr=0x00000000 free_area_init+0x890/0xc94
[    0.000000] memblock_reserve: [0x2dbf1000-0x2ffdefff] memblock_alloc_range_nid+0xe8/0x1b0
[    0.000000] memblock_alloc_try_nid: 96 bytes align=0x20 nid=0 from=0x00000000 max_addr=0x00000000 setup_usemap+0x60/0xa0
[    0.000000] memblock_reserve: [0x2fff5d00-0x2fff5d5f] memblock_alloc_range_nid+0xe8/0x1b0
[    0.000000] memblock_alloc_try_nid: 416 bytes align=0x20 nid=0 from=0x00000000 max_addr=0x00000000 setup_usemap+0x60/0xa0
[    0.000000] memblock_reserve: [0x2fff5b60-0x2fff5cff] memblock_alloc_range_nid+0xe8/0x1b0
[    0.000000] memblock_alloc_try_nid: 32 bytes align=0x20 nid=-1 from=0x00000000 max_addr=0x00000000 mmu_context_init+0x38/0x154
[    0.000000] memblock_reserve: [0x2fff5b40-0x2fff5b5f] memblock_alloc_range_nid+0xe8/0x1b0
[    0.000000] memblock_alloc_try_nid: 1024 bytes align=0x20 nid=-1 from=0x00000000 max_addr=0x00000000 mmu_context_init+0x7c/0x154
[    0.000000] memblock_reserve: [0x2fff5740-0x2fff5b3f] memblock_alloc_range_nid+0xe8/0x1b0
[    0.000000] memblock_alloc_try_nid: 32 bytes align=0x20 nid=-1 from=0x00000000 max_addr=0x00000000 mmu_context_init+0xc4/0x154
[    0.000000] memblock_reserve: [0x2fff5720-0x2fff573f] memblock_alloc_range_nid+0xe8/0x1b0
[    0.000000] MMU: Allocated 1088 bytes of context maps for 255 contexts
[    0.000000] memblock_alloc_try_nid: 111 bytes align=0x20 nid=-1 from=0x00000000 max_addr=0x00000000 start_kernel+0x194/0x6d0
[    0.000000] memblock_reserve: [0x2fff56a0-0x2fff570e] memblock_alloc_range_nid+0xe8/0x1b0
[    0.000000] memblock_alloc_try_nid: 111 bytes align=0x20 nid=-1 from=0x00000000 max_addr=0x00000000 start_kernel+0x1c0/0x6d0
[    0.000000] memblock_reserve: [0x2fff5620-0x2fff568e] memblock_alloc_range_nid+0xe8/0x1b0
[    0.000000] memblock_alloc_try_nid: 4096 bytes align=0x1000 nid=-1 from=0x00000000 max_addr=0x00000000 pcpu_embed_first_chunk+0x314/0x7b4
[    0.000000] memblock_reserve: [0x2dbf0000-0x2dbf0fff] memblock_alloc_range_nid+0xe8/0x1b0
[    0.000000] memblock_alloc_try_nid: 4096 bytes align=0x20 nid=-1 from=0x00000000 max_addr=0x00000000 pcpu_embed_first_chunk+0x4d4/0x7b4
[    0.000000] memblock_reserve: [0x2dbef000-0x2dbeffff] memblock_alloc_range_nid+0xe8/0x1b0
[    0.000000] memblock_alloc_try_nid: 90112 bytes align=0x1000 nid=-1 from=0x3fffffff max_addr=0x00000000 pcpu_embed_first_chunk+0x564/0x7b4
[    0.000000] memblock_reserve: [0x2dbd9000-0x2dbeefff] memblock_alloc_range_nid+0xe8/0x1b0
[    0.000000] memblock_phys_free: [0x2dbe4000-0x2dbe3fff] pcpu_embed_first_chunk+0x680/0x7b4
[    0.000000] memblock_phys_free: [0x2dbef000-0x2dbeefff] pcpu_embed_first_chunk+0x680/0x7b4
[    0.000000] percpu: Embedded 11 pages/cpu s14196 r8192 d22668 u45056
[    0.000000] memblock_alloc_try_nid: 4 bytes align=0x20 nid=-1 from=0x00000000 max_addr=0x00000000 pcpu_setup_first_chunk+0x37c/0x924
[    0.000000] memblock_reserve: [0x2fff5d60-0x2fff5d63] memblock_alloc_range_nid+0xe8/0x1b0
[    0.000000] memblock_alloc_try_nid: 4 bytes align=0x20 nid=-1 from=0x00000000 max_addr=0x00000000 pcpu_setup_first_chunk+0x3a4/0x924
[    0.000000] memblock_reserve: [0x2fff5600-0x2fff5603] memblock_alloc_range_nid+0xe8/0x1b0
[    0.000000] memblock_alloc_try_nid: 8 bytes align=0x20 nid=-1 from=0x00000000 max_addr=0x00000000 pcpu_setup_first_chunk+0x3cc/0x924
[    0.000000] memblock_reserve: [0x2fff55e0-0x2fff55e7] memblock_alloc_range_nid+0xe8/0x1b0
[    0.000000] memblock_alloc_try_nid: 8 bytes align=0x20 nid=-1 from=0x00000000 max_addr=0x00000000 pcpu_setup_first_chunk+0x3f4/0x924
[    0.000000] memblock_reserve: [0x2fff55c0-0x2fff55c7] memblock_alloc_range_nid+0xe8/0x1b0
[    0.000000] pcpu-alloc: s14196 r8192 d22668 u45056 alloc=11*4096
[    0.000000] pcpu-alloc: [0] 0 [0] 1 
[    0.000000] memblock_alloc_try_nid: 136 bytes align=0x20 nid=-1 from=0x00000000 max_addr=0x00000000 pcpu_setup_first_chunk+0x7fc/0x924
[    0.000000] memblock_reserve: [0x2fff5520-0x2fff55a7] memblock_alloc_range_nid+0xe8/0x1b0
[    0.000000] memblock_alloc_try_nid: 96 bytes align=0x20 nid=-1 from=0x00000000 max_addr=0x00000000 pcpu_alloc_first_chunk+0x64/0x2e0
[    0.000000] memblock_reserve: [0x2fff54c0-0x2fff551f] memblock_alloc_range_nid+0xe8/0x1b0
[    0.000000] memblock_alloc_try_nid: 384 bytes align=0x20 nid=-1 from=0x00000000 max_addr=0x00000000 pcpu_alloc_first_chunk+0xc4/0x2e0
[    0.000000] memblock_reserve: [0x2fff5340-0x2fff54bf] memblock_alloc_range_nid+0xe8/0x1b0
[    0.000000] memblock_alloc_try_nid: 388 bytes align=0x20 nid=-1 from=0x00000000 max_addr=0x00000000 pcpu_alloc_first_chunk+0xf0/0x2e0
[    0.000000] memblock_reserve: [0x2fff51a0-0x2fff5323] memblock_alloc_range_nid+0xe8/0x1b0
[    0.000000] memblock_alloc_try_nid: 96 bytes align=0x20 nid=-1 from=0x00000000 max_addr=0x00000000 pcpu_alloc_first_chunk+0x11c/0x2e0
[    0.000000] memblock_reserve: [0x2fff5140-0x2fff519f] memblock_alloc_range_nid+0xe8/0x1b0
[    0.000000] memblock_alloc_try_nid: 96 bytes align=0x20 nid=-1 from=0x00000000 max_addr=0x00000000 pcpu_alloc_first_chunk+0x64/0x2e0
[    0.000000] memblock_reserve: [0x2fff50e0-0x2fff513f] memblock_alloc_range_nid+0xe8/0x1b0
[    0.000000] memblock_alloc_try_nid: 768 bytes align=0x20 nid=-1 from=0x00000000 max_addr=0x00000000 pcpu_alloc_first_chunk+0xc4/0x2e0
[    0.000000] memblock_reserve: [0x2dbd8d00-0x2dbd8fff] memblock_alloc_range_nid+0xe8/0x1b0
[    0.000000] memblock_alloc_try_nid: 772 bytes align=0x20 nid=-1 from=0x00000000 max_addr=0x00000000 pcpu_alloc_first_chunk+0xf0/0x2e0
[    0.000000] memblock_reserve: [0x2dbd89e0-0x2dbd8ce3] memblock_alloc_range_nid+0xe8/0x1b0
[    0.000000] memblock_alloc_try_nid: 192 bytes align=0x20 nid=-1 from=0x00000000 max_addr=0x00000000 pcpu_alloc_first_chunk+0x11c/0x2e0
[    0.000000] memblock_reserve: [0x2fff5020-0x2fff50df] memblock_alloc_range_nid+0xe8/0x1b0
[    0.000000] memblock_phys_free: [0x2dbf0000-0x2dbf0fff] pcpu_embed_first_chunk+0x744/0x7b4
[    0.000000] memblock_phys_free: [0x2dbef000-0x2dbeffff] pcpu_embed_first_chunk+0x754/0x7b4
[    0.000000] Built 1 zonelists, mobility grouping on.  Total pages: 777792
[    0.000000] Kernel command line: root=ubi0:rootfs rootfstype=ubifs ubi.mtd=rootfs rootflags=chk_data_crc rw console=ttyS0,115200 memblock=debug
[    0.000000] memblock_alloc_try_nid: 524288 bytes align=0x20 nid=-1 from=0x00000000 max_addr=0x00000000 alloc_large_system_hash+0x1a4/0x2ec
[    0.000000] memblock_reserve: [0x2db589e0-0x2dbd89df] memblock_alloc_range_nid+0xe8/0x1b0
[    0.000000] Dentry cache hash table entries: 131072 (order: 7, 524288 bytes, linear)
[    0.000000] memblock_alloc_try_nid: 262144 bytes align=0x20 nid=-1 from=0x00000000 max_addr=0x00000000 alloc_large_system_hash+0x1a4/0x2ec
[    0.000000] memblock_reserve: [0x2db189e0-0x2db589df] memblock_alloc_range_nid+0xe8/0x1b0
[    0.000000] Inode-cache hash table entries: 65536 (order: 6, 262144 bytes, linear)
[    0.000000] mem auto-init: stack:off, heap alloc:off, heap free:off
[    0.000000] Kernel virtual memory layout:
[    0.000000]   * 0xffbbf000..0xfffff000  : fixmap
[    0.000000]   * 0xff400000..0xff800000  : highmem PTEs
[    0.000000]   * 0xff3fe000..0xff400000  : early ioremap
[    0.000000]   * 0xf1000000..0xff3fe000  : vmalloc & ioremap
[    0.000000] Memory: 3062612K/3118080K available (10732K kernel code, 712K rwdata, 2044K rodata, 276K init, 287K bss, 55468K reserved, 0K cma-reserved, 2331640K highmem)
[    0.000000] SLUB: HWalign=32, Order=0-3, MinObjects=0, CPUs=2, Nodes=1
Quoted 4 lines
Quoted 1 line

Christophe

Signature · 2 lines
Sincerely yours,
Mike
author
#34 lore raw

PATCH 12/12 powerpc: wiiu: Add minimal default config

In reply to Ash Logan

Add a bare-minimum config to get a kernel compiled. Will need some more interesting options once a storage device to boot from is added.

---
 arch/powerpc/configs/wiiu_defconfig | 7 +++++++
 1 file changed, 7 insertions(+)
 create mode 100644 arch/powerpc/configs/wiiu_defconfig
arch/powerpc/configs/wiiu_defconfig new file +7 -0
new file mode 100644
index 000000000000..a761ebcdd9f2
@@ -0,0 +1,7 @@
+# CONFIG_PPC_CHRP is not set
+# CONFIG_PPC_PMAC is not set
+CONFIG_WIIU=y
+# CONFIG_PPC_OF_BOOT_TRAMPOLINE is not set
+CONFIG_HIGHMEM=y
+CONFIG_STRICT_KERNEL_RWX=y
+CONFIG_PPC_EARLY_DEBUG=y
Signature · 1 line
2.35.1
author
#35 lore raw

v2 cover powerpc: Nintendo Wii U support

In reply to Ash Logan

The following patches add basic support for the Nintendo Wii U video game console, a PowerPC system somewhat similar to the GameCube and Wii.

This includes:
- devicetree source
- bootwrapper support
- udbg console to bootloader
- early udbg console
- interrupt controllers
- platform support
- recognition of the Espresso processor
- workaround for the discontiguous RAM blocks

This is enough to boot on hardware. dmesg pics (with a small hack to udbg-immortal, not included):

For those who have hardware and would like to try these patches, some modification is required to the stock OS to allow Linux. For info:
https://wiki.linux-wiiu.org/wiki/AdvancedSetup

Some of the design choices (new platform > embedded6xx) were discussed previously:

Turns out even less changes were needed than previously anticipated for discontiguous memory, and KUAP is yet to give trouble. Thanks to those who helped and discussed this.

Changes since v1:
- Style and formatting tweaks to the devicetree, thanks Rob Herring for the review.

Ash Logan (12):
dt-bindings: wiiu: Document the Nintendo Wii U devicetree
powerpc: wiiu: device tree
powerpc: wiiu: bootwrapper support
powerpc: wiiu: introduce wiiu platform
powerpc: wiiu: declare as non-coherent
powerpc: wiiu: udbg support for latteipc
powerpc: wiiu: espresso interrupt controller support
powerpc: wiiu: latte interrupt controller support
powerpc: espresso processor support
powerpc: wiiu: platform support
powerpc: wiiu: don't enforce flat memory
powerpc: wiiu: Add minimal default config

 .../bindings/powerpc/nintendo/wiiu.yaml       |  28 ++
 .../powerpc/nintendo/wiiu/espresso-pic.yaml   |  42 +++
 .../bindings/powerpc/nintendo/wiiu/gpu7.yaml  |  41 +++
 .../powerpc/nintendo/wiiu/latte-ahci.yaml     |  43 +++
 .../powerpc/nintendo/wiiu/latte-dsp.yaml      |  35 ++
 .../powerpc/nintendo/wiiu/latte-pic.yaml      |  46 +++
 .../powerpc/nintendo/wiiu/latte-sdhci.yaml    |  40 +++
 .../bindings/powerpc/nintendo/wiiu/latte.yaml |  25 ++
 arch/powerpc/Kconfig.debug                    |   9 +
 arch/powerpc/boot/Makefile                    |   4 +
 arch/powerpc/boot/dts/wiiu.dts                | 322 ++++++++++++++++++
 arch/powerpc/boot/wiiu-head.S                 | 103 ++++++
 arch/powerpc/boot/wiiu.c                      |  73 ++++
 arch/powerpc/boot/wrapper                     |   4 +
 arch/powerpc/configs/wiiu_defconfig           |   7 +
 arch/powerpc/include/asm/udbg.h               |   1 +
 arch/powerpc/kernel/cputable.c                |  16 +
 arch/powerpc/kernel/head_book3s_32.S          |  20 ++
 arch/powerpc/kernel/udbg.c                    |   3 +
 arch/powerpc/mm/init_32.c                     |   4 +-
 arch/powerpc/platforms/Kconfig                |   1 +
 arch/powerpc/platforms/Kconfig.cputype        |   2 +-
 arch/powerpc/platforms/Makefile               |   1 +
 arch/powerpc/platforms/wiiu/Kconfig           |  19 ++
 arch/powerpc/platforms/wiiu/Makefile          |   4 +
 arch/powerpc/platforms/wiiu/espresso-pic.c    | 183 ++++++++++
 arch/powerpc/platforms/wiiu/espresso-pic.h    |  59 ++++
 arch/powerpc/platforms/wiiu/latte-pic.c       | 259 ++++++++++++++
 arch/powerpc/platforms/wiiu/latte-pic.h       |  23 ++
 arch/powerpc/platforms/wiiu/setup.c           |  67 ++++
 arch/powerpc/platforms/wiiu/udbg_latteipc.c   | 122 +++++++
 arch/powerpc/platforms/wiiu/udbg_latteipc.h   |  27 ++
 32 files changed, 1630 insertions(+), 3 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/powerpc/nintendo/wiiu.yaml
 create mode 100644 Documentation/devicetree/bindings/powerpc/nintendo/wiiu/espresso-pic.yaml
 create mode 100644 Documentation/devicetree/bindings/powerpc/nintendo/wiiu/gpu7.yaml
 create mode 100644 Documentation/devicetree/bindings/powerpc/nintendo/wiiu/latte-ahci.yaml
 create mode 100644 Documentation/devicetree/bindings/powerpc/nintendo/wiiu/latte-dsp.yaml
 create mode 100644 Documentation/devicetree/bindings/powerpc/nintendo/wiiu/latte-pic.yaml
 create mode 100644 Documentation/devicetree/bindings/powerpc/nintendo/wiiu/latte-sdhci.yaml
 create mode 100644 Documentation/devicetree/bindings/powerpc/nintendo/wiiu/latte.yaml
 create mode 100644 arch/powerpc/boot/dts/wiiu.dts
 create mode 100644 arch/powerpc/boot/wiiu-head.S
 create mode 100644 arch/powerpc/boot/wiiu.c
 create mode 100644 arch/powerpc/configs/wiiu_defconfig
 create mode 100644 arch/powerpc/platforms/wiiu/Kconfig
 create mode 100644 arch/powerpc/platforms/wiiu/Makefile
 create mode 100644 arch/powerpc/platforms/wiiu/espresso-pic.c
 create mode 100644 arch/powerpc/platforms/wiiu/espresso-pic.h
 create mode 100644 arch/powerpc/platforms/wiiu/latte-pic.c
 create mode 100644 arch/powerpc/platforms/wiiu/latte-pic.h
 create mode 100644 arch/powerpc/platforms/wiiu/setup.c
 create mode 100644 arch/powerpc/platforms/wiiu/udbg_latteipc.c
 create mode 100644 arch/powerpc/platforms/wiiu/udbg_latteipc.h

base-commit: 4b0986a3613c92f4ec1bdc7f60ec66fea135991f

Signature · 1 line
2.36.1
author
#36 lore raw

PATCH v2 1/12 dt-bindings: wiiu: Document the Nintendo Wii U devicetree

Adds schema for the various Wii U devicetree nodes used.

---
 .../bindings/powerpc/nintendo/wiiu.yaml       | 28 +++++++++++
 .../powerpc/nintendo/wiiu/espresso-pic.yaml   | 42 +++++++++++++++++
 .../bindings/powerpc/nintendo/wiiu/gpu7.yaml  | 41 +++++++++++++++++
 .../powerpc/nintendo/wiiu/latte-ahci.yaml     | 43 +++++++++++++++++
 .../powerpc/nintendo/wiiu/latte-dsp.yaml      | 35 ++++++++++++++
 .../powerpc/nintendo/wiiu/latte-pic.yaml      | 46 +++++++++++++++++++
 .../powerpc/nintendo/wiiu/latte-sdhci.yaml    | 40 ++++++++++++++++
 .../bindings/powerpc/nintendo/wiiu/latte.yaml | 25 ++++++++++
 8 files changed, 300 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/powerpc/nintendo/wiiu.yaml
 create mode 100644 Documentation/devicetree/bindings/powerpc/nintendo/wiiu/espresso-pic.yaml
 create mode 100644 Documentation/devicetree/bindings/powerpc/nintendo/wiiu/gpu7.yaml
 create mode 100644 Documentation/devicetree/bindings/powerpc/nintendo/wiiu/latte-ahci.yaml
 create mode 100644 Documentation/devicetree/bindings/powerpc/nintendo/wiiu/latte-dsp.yaml
 create mode 100644 Documentation/devicetree/bindings/powerpc/nintendo/wiiu/latte-pic.yaml
 create mode 100644 Documentation/devicetree/bindings/powerpc/nintendo/wiiu/latte-sdhci.yaml
 create mode 100644 Documentation/devicetree/bindings/powerpc/nintendo/wiiu/latte.yaml
Documentation/devicetree/bindings/powerpc/nintendo/wiiu.yaml new file +28 -0
new file mode 100644
index 000000000000..5824b07928f5
@@ -0,0 +1,28 @@
+# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause
+%YAML 1.2
+---
+
+$id: http://devicetree.org/schemas/powerpc/nintendo/wiiu.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Nintendo Wii U bindings
+
+maintainers:
+  - Ash Logan <[email protected]>
+  - Emmanuel Gil Peyrot <[email protected]>
+
+description: |
+  Nintendo Wii U video game console binding.
+
+properties:
+  $nodename:
+    const: "/"
+  compatible:
+    oneOf:
+      - description: Nintendo Wii U video game console
+        items:
+          - const: nintendo,wiiu
+
+additionalProperties: true
+
+...
Documentation/devicetree/bindings/powerpc/nintendo/wiiu/espresso-pic.yaml new file +42 -0

42 lines not on this page · raw message

Documentation/devicetree/bindings/powerpc/nintendo/wiiu/gpu7.yaml new file +41 -0

41 lines not on this page · raw message

Documentation/devicetree/bindings/powerpc/nintendo/wiiu/latte-ahci.yaml new file +43 -0

43 lines not on this page · raw message

Documentation/devicetree/bindings/powerpc/nintendo/wiiu/latte-dsp.yaml new file +35 -0
new file mode 100644
index 000000000000..ed0b4c28ce48
@@ -0,0 +1,35 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/powerpc/nintendo/wiiu/latte-dsp.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Nintendo Wii U Latte DSP
+
+maintainers:
+  - Ash Logan <[email protected]>
+  - Emmanuel Gil Peyrot <[email protected]>
+
+description: |
+  Nintendo Wii U digital signal processor, as found in the Latte chip.
+
+properties:
+  compatible:
+    oneOf:
+      - description: Nintendo Wii U Latte DSP
+        items:
+          - const: nintendo,latte-dsp
+  reg:
+    items:
+      - description: DSP registers
+
+# Once more is known about this device more properties will likely be added
+additionalProperties: true
+
+examples:
+  - |
+    latte_dsp: dsp@c005000 {
+         compatible = "nintendo,latte-dsp";
+         reg = <0x0c005000 0x200>;
+    };
+...
Documentation/devicetree/bindings/powerpc/nintendo/wiiu/latte-pic.yaml new file +46 -0

46 lines not on this page · raw message

Documentation/devicetree/bindings/powerpc/nintendo/wiiu/latte-sdhci.yaml new file +40 -0
new file mode 100644
index 000000000000..4b9b0820edc1
@@ -0,0 +1,40 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/powerpc/nintendo/wiiu/latte-sdhci.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Nintendo Wii U Latte SD Host controller
+
+maintainers:
+  - Ash Logan <[email protected]>
+  - Emmanuel Gil Peyrot <[email protected]>
+
+description: |
+  SDHCI hosts found on the Nintendo Wii U's Latte SoC for SD cards and SDIO devices.
+
+properties:
+  compatible:
+    oneOf:
+      - description: Nintendo Wii U Latte SDHCI
+        items:
+          - const: nintendo,latte-sdhci
+          - const: sdhci
+  reg:
+    items:
+      - description: Core registers
+  interrupts:
+    items:
+      - description: SDHCI interrupt
+
+additionalProperties: false
+
+examples:
+  - |
+    sdcard_0: sdhci@d070000 {
+          compatible = "nintendo,latte-sdhci","sdhci";
+          reg = <0x0d070000 0x200>;
+          interrupts = <7>;
+          interrupt-parent = <&latte_pic>;
+    };
+...
Documentation/devicetree/bindings/powerpc/nintendo/wiiu/latte.yaml new file +25 -0
new file mode 100644
index 000000000000..6ae86d198fa3
@@ -0,0 +1,25 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/powerpc/nintendo/wiiu/latte.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Latte system bus
+
+maintainers:
+  - Ash Logan <[email protected]>
+  - Emmanuel Gil Peyrot <[email protected]>
+
+description: |
+  Latte multi-function SoC, containing many of the devices found on the Nintendo Wii U.
+
+properties:
+  compatible:
+    oneOf:
+      - description: Nintendo Wii U "Latte" SoC
+        items:
+          - const: nintendo,latte
+
+additionalProperties: true
+
+...
Signature · 1 line
2.36.1
author
#37 lore raw

PATCH v2 2/12 powerpc: wiiu: device tree

In reply to Ash Logan

Add a device tree source file for the Nintendo Wii U video game console.

---
v1->v2: Style and formatting changes suggested by Rob Herring. License remains GPL-2.0 as the other powerpc dtses are the same, happy to change if there is a different preferred default.

 arch/powerpc/boot/dts/wiiu.dts | 322 +++++++++++++++++++++++++++++++++
 1 file changed, 322 insertions(+)
 create mode 100644 arch/powerpc/boot/dts/wiiu.dts
arch/powerpc/boot/dts/wiiu.dts new file +322 -0
new file mode 100644
index 000000000000..def648d4362d
@@ -0,0 +1,322 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Nintendo Wii U Device Tree Source
+ *
+ * Copyright (C) 2022 The linux-wiiu Team
+ */
+
+/dts-v1/;
+#include <dt-bindings/gpio/gpio.h>
+#include <dt-bindings/input/input.h>
+
+/ {
+	model = "nintendo,wiiu";
+	compatible = "nintendo,wiiu";
+
+	#address-cells = <1>;
+	#size-cells = <1>;
+
+	chosen {
+		bootargs = "root=/dev/sda1 rootwait";
+	};
+
+	memory {
+		device_type = "memory";
+		reg = <0x00000000 0x02000000	/* MEM1 - 32MiB */
+		       0x08000000 0x00300000	/* MEM0 - 3MiB  */
+		       0x10000000 0x80000000>;	/* MEM2 - 2GiB  */
+	};
+
+	cpus {
+		#address-cells = <1>;
+		#size-cells = <0>;
+
+		/* TODO: Add SMP */
+		PowerPC,espresso@0 {
+			device_type = "cpu";
+			reg = <0>;
+			clock-frequency = <1243125000>;		/* 1.243125GHz */
+			bus-frequency = <248625000>;		/* 248.625MHz core-to-bus 5x */
+			timebase-frequency = <62156250>;	/* 1/4 of the bus clock */
+			i-cache-size = <32768>; /* 32K icache */
+			i-cache-line-size = <32>;
+			i-cache-block-size = <32>;
+			i-cache-sets = <128>;
+			d-cache-size = <32768>; /* 32K dcache */
+			d-cache-line-size = <32>;
+			d-cache-block-size = <32>;
+			d-cache-sets = <128>;
+			next-level-cache = <&L2_0>;
+			L2_0:l2-cache {
+				compatible = "cache";
+				cache-level = <2>;
+				cache-unified;
+				cache-size = <0x80000>; /* 512KB L2 */
+				cache-line-size = <64>;
+				cache-block-size = <32>;
+				cache-sets = <2048>;
+			};
+		};
+	};
+
+	latte {
+		#address-cells = <1>;
+		#size-cells = <1>;
+		compatible = "nintendo,latte";
+		ranges = <0x0c000000 0x0c000000 0x00400000	/* Espresso-only registers */
+			  0x0d000000 0x0d000000 0x00200000	/* Latte AHB deivces */
+			  0x0d800000 0x0d800000 0x00800000>;	/* Latte SoC registers */
+
+		gpu@c200000 {
+			compatible = "nintendo,latte-gpu7";
+			reg = <0x0c200000 0x80000>;
+			interrupts = <2>;
+			interrupt-parent = <&espresso_pic>;
+		};
+
+		espresso_pic: pic@c000078 {
+			#interrupt-cells = <1>;
+			interrupt-controller;
+
+			compatible = "nintendo,espresso-pic";
+			reg = <0x0c000078 0x18>;
+		};
+
+		latte_dsp: dsp@c005000 {
+			compatible = "nintendo,latte-dsp";
+			reg = <0x0c005000 0x200>;
+		};
+
+		ehci_0: usb@d040000 {
+			compatible = "nintendo,latte-usb-ehci", "usb-ehci";
+			reg = <0x0d040000 0x100>;
+			interrupts = <4>;
+			interrupt-parent = <&latte_pic>;
+			big-endian-regs;
+		};
+
+		ohci_0_0: usb@d050000 {
+			compatible = "nintendo,latte-usb-ohci";
+			reg = <0x0d050000 0x100>;
+			interrupts = <5>;
+			interrupt-parent = <&latte_pic>;
+
+			big-endian-regs;
+		};
+
+		ohci_0_1: usb@d060000 {
+			compatible = "nintendo,latte-usb-ohci";
+			reg = <0x0d060000 0x100>;
+			interrupts = <6>;
+			interrupt-parent = <&latte_pic>;
+
+			big-endian-regs;
+		};
+
+		ehci_1: usb@d120000 {
+			compatible = "nintendo,latte-usb-ehci", "usb-ehci";
+			reg = <0x0d120000 0x100>;
+			interrupts = <16>;
+			interrupt-parent = <&latte_pic>;
+			big-endian-regs;
+		};
+
+		ohci_1_0: usb@d130000 {
+			compatible = "nintendo,latte-usb-ohci";
+			reg = <0x0d130000 0x100>;
+			interrupts = <35>;
+			interrupt-parent = <&latte_pic>;
+
+			big-endian-regs;
+		};
+
+		ehci_2: usb@d140000 {
+			compatible = "nintendo,latte-usb-ehci", "usb-ehci";
+			reg = <0x0d140000 0x100>;
+			interrupts = <36>;
+			interrupt-parent = <&latte_pic>;
+			big-endian-regs;
+		};
+
+		ohci_2_0: usb@d150000 {
+			compatible = "nintendo,latte-usb-ohci";
+			reg = <0x0d150000 0x100>;
+			interrupts = <37>;
+			interrupt-parent = <&latte_pic>;
+
+			big-endian-regs;
+		};
+
+		sdcard_0: sdhci@d070000 {
+			compatible = "nintendo,latte-sdhci","sdhci";
+			reg = <0x0d070000 0x200>;
+			interrupts = <7>;
+			interrupt-parent = <&latte_pic>;
+		};
+
+		wifi_0: sdhci@d080000 {
+			compatible = "nintendo,latte-sdhci","sdhci";
+			reg = <0x0d080000 0x200>;
+			interrupts = <8>;
+			interrupt-parent = <&latte_pic>;
+		};
+
+		legacy_ipc: ipc@d800000 {
+			compatible = "nintendo,latte-ipc", "nintendo,hollywood-ipc";
+			reg = <0x0d800000 0x10>;
+			interrupts = <30 31>;
+			interrupt-parent = <&latte_pic>;
+		};
+
+		latte_otp: otp@d8001ec {
+			compatible = "nintendo,latte-otp";
+			reg = <0x0d8001ec 0x8>;
+		};
+
+		sata: ahci@d160400 {
+			compatible = "nintendo,latte-ahci";
+			reg = <0x0d160400 0x808>;
+
+			interrupt-parent = <&latte_pic>;
+			interrupts = <38 28>;
+		};
+
+		latte_pic: pic@d800440 {
+			#interrupt-cells = <1>;
+			interrupt-controller;
+
+			compatible = "nintendo,latte-pic";
+			reg = <0x0d800440 0x30>;
+			interrupt-parent = <&espresso_pic>;
+			interrupts = <24>;
+		};
+
+		gpio: gpio@d8000c0 {
+			#gpio-cells = <2>;
+			compatible = "nintendo,latte-gpio", "nintendo,hollywood-gpio";
+
+			reg = <0x0d8000c0 0x40>;
+			gpio-controller;
+			/* TODO: There are actually 31 AHBALL GPIOs */
+			ngpios = <24>;
+
+			gpio-line-names =
+				"POWER", "DWIFI", "FAN", "DC_DC",
+				"", "Esp10WorkAround", "", "",
+				"PADPD", "", "EEP_CS", "EEP_CLK",
+				"EEP_MOSI", "EEP_MISO", "AVE_SCL", "AVE_SDA",
+				"DEBUG0", "DEBUG1", "DEBUG2", "DEBUG3",
+				"DEBUG4", "DEBUG5", "DEBUG6", "DEBUG7";
+
+			interrupt-controller;
+			#interrupt-cells = <2>;
+			interrupts = <10>;
+			interrupt-parent = <&latte_pic>;
+		};
+
+		gpio2: gpio@d800520 {
+			#gpio-cells = <2>;
+			compatible = "nintendo,latte-gpio", "nintendo,hollywood-gpio";
+
+			reg = <0x0d800520 0x40>;
+			gpio-controller;
+			ngpios = <7>;
+
+			gpio-line-names =
+				"FANSPEED", "SMC_SCL", "SMC_SDA", "DC_DC2",
+				"AVE_INT", "", "AVE_RESET";
+
+			interrupt-controller;
+			#interrupt-cells = <2>;
+			interrupts = <10>;
+			interrupt-parent = <&latte_pic>;
+		};
+	};
+
+	spi_gpio: spi-gpio {
+		cs-gpios = <&gpio 10 GPIO_ACTIVE_HIGH>;
+		gpio-sck = <&gpio 11 GPIO_ACTIVE_HIGH>;
+		gpio-mosi = <&gpio 12 GPIO_ACTIVE_HIGH>;
+		gpio-miso = <&gpio 13 GPIO_ACTIVE_HIGH>;
+		num-chipselects = <1>;
+
+		eeprom@0 {
+			compatible = "atmel,at93c66";
+			reg = <0>;
+			spi-max-frequency = <1000000>;
+			spi-cs-high;
+			/* TODO: wiiubrew says this is 16-bit, but I only get the correct
+			 * values in 8-bit...
+			 */
+			data-size = <8>;
+			read-only;
+
+			#address-cells = <1>;
+			#size-cells = <1>;
+
+			/* https://wiiubrew.org/wiki/Hardware/SEEPROM */
+			rng_seed: rng@12 { reg = <0x012 8>; };
+			ppc_pvr: pvr@20 { reg = <0x020 4>; };
+			seeprom_ver_str: sver-str@24 { reg = <0x024 6>; };
+			seeprom_ver: sver@2a { reg = <0x02A 2>; };
+			otp_ver: over@2c { reg = <0x02C 2>; };
+			otp_rev: orev@2e { reg = <0x02E 2>; };
+			otp_ver_str: over-str@30 { reg = <0x030 8>; };
+
+			bc_crc: bc-crc@38 { reg = <0x038 4>; };
+			bc_sz: bc-sz@3c { reg = <0x03C 2>; };
+			bc_ver: bc-ver@3e { reg = <0x03E 2>; };
+			bc_boardtype: boardtype@42 { reg = <0x042 2>; };
+			bc_boardrev: boardrev@44 { reg = <0x044 2>; };
+			bc_bootsource: bootsource@46 { reg = <0x046 2>; };
+			bc_ddr3size: ddr3size@48 { reg = <0x048 2>; };
+			bc_ddr3speed: ddr3speed@4a { reg = <0x04A 2>; };
+			bc_ppcclockmul: ppcclockmul@4c { reg = <0x04C 2>; };
+			bc_iopclockmul: iopclockmul@46 { reg = <0x04E 2>; };
+			bc_video1080p: video1080p@50 { reg = <0x050 2>; };
+			bc_ddr3vendor: ddr3vendor@52 { reg = <0x052 2>; };
+			bc_movpassivereset: movpassivereset@54 { reg = <0x054 2>; };
+			bc_syspllspd: syspllspd@56 { reg = <0x056 2>; };
+			bc_satadevice: satadevice@58 { reg = <0x058 2>; };
+			bc_consoletype: consoletype@5a { reg = <0x05A 2>; };
+			bc_deviceprescence: deviceprescence@5c { reg = <0x05C 2>; };
+
+			drive_key: drvkey@80 { reg = <0x080 16>; };
+			factory_key: fackey@90 { reg = <0x090 16>; };
+			shdd_key: shddkey@a0 { reg = <0x0A0 16>; };
+			usb_key_seed: usbkeyseed@b0 { reg = <0x0B0 16>; };
+			drive_key_flag: drvkeyf@c0 { reg = <0x0C0 2>; };
+			usb_key_flag: udbkeyf@c2 { reg = <0x0C2 2>; };
+			shdd_key_flag: shddkeyf@c4 { reg = <0x0C4 2>; };
+
+			sysprod_version: sp_ver@140 { reg = <0x140 4>; };
+			sysprod_eeprom_version: sp_ee_ver@144 { reg = <0x144 4>; };
+			sysprod_product_area: sp_parea@148 { reg = <0x148 4>; };
+			sysprod_game_region: sp_region@14c { reg = <0x14C 4>; };
+			sysprod_ntsc_pal: sp_ntscpal@150 { reg = <0x150 4>; };
+			sysprod_5ghz_country: sp_5ghz_c@154 { reg = <0x154 2>; };
+			sysprod_5ghz_country_rev: sp_5ghz_crev@156 { reg = <0x156 2>; };
+			sysprod_code: sp_code@158 { reg = <0x158 8>; };
+			sysprod_serial: sp_serial@160 { reg = <0x160 16>; };
+			sysprod_model: sp_model@170 { reg = <0x170 16>; };
+
+			prod_year: pyear@188 { reg = <0x188 2>; };
+			prod_date: pdate@18a { reg = <0x18A 2>; };
+			prod_time: ptime@18c { reg = <0x18C 2>; };
+
+			boot_params: boot_params@1c0 { reg = <0x1C0 48>; };
+		};
+	};
+
+	/* TODO make this gpio-keyed once hollywood-gpio supports interrupts */
+	gpio-keys-polled {
+		poll-interval = <50>;
+		compatible = "gpio-keys-polled";
+
+		power {
+			label = "Power Button";
+			gpios = <&gpio 0 GPIO_ACTIVE_HIGH>;
+			linux,code = <KEY_POWER>;
+		};
+	};
+};
Signature · 1 line
2.36.1
author
#38 lore raw

PATCH v2 3/12 powerpc: wiiu: bootwrapper support

In reply to Ash Logan

Add support for the Nintendo Wii U game console to the powerpc bootwrapper.

---
 arch/powerpc/boot/Makefile    |   4 ++
 arch/powerpc/boot/wiiu-head.S | 103 ++++++++++++++++++++++++++++++++++
 arch/powerpc/boot/wiiu.c      |  73 ++++++++++++++++++++++++
 arch/powerpc/boot/wrapper     |   4 ++
 4 files changed, 184 insertions(+)
 create mode 100644 arch/powerpc/boot/wiiu-head.S
 create mode 100644 arch/powerpc/boot/wiiu.c
arch/powerpc/boot/Makefile +4 -0
index 4b4827c475c6..74e77f072e35 100644
@@ -155,6 +155,7 @@ src-plat-$(CONFIG_EMBEDDED6xx) += cuboot-pq2.c cuboot-mpc7448hpc2.c \
 					gamecube-head.S gamecube.c \
 					wii-head.S wii.c holly.c \
 					fixed-head.S mvme5100.c
+src-plat-$(CONFIG_WIIU) += wiiu-head.S wiiu.c
 src-plat-$(CONFIG_AMIGAONE) += cuboot-amigaone.c
 src-plat-$(CONFIG_PPC_PS3) += ps3-head.S ps3-hvcall.S ps3.c
 src-plat-$(CONFIG_EPAPR_BOOT) += epapr.c epapr-wrapper.c
@@ -353,6 +354,9 @@ image-$(CONFIG_GAMECUBE)		+= dtbImage.gamecube
 image-$(CONFIG_WII)			+= dtbImage.wii
 image-$(CONFIG_MVME5100)		+= dtbImage.mvme5100
 
+# Board port in arch/powerpc/platform/wiiu/Kconfig
+image-$(CONFIG_WIIU)			+= dtbImage.wiiu
+
 # Board port in arch/powerpc/platform/amigaone/Kconfig
 image-$(CONFIG_AMIGAONE)		+= cuImage.amigaone
 
arch/powerpc/boot/wiiu-head.S new file +103 -0

103 lines not on this page · raw message

arch/powerpc/boot/wiiu.c new file +73 -0

73 lines not on this page · raw message

arch/powerpc/boot/wrapper +4 -0
index 9184eda780fd..f42abe4ebde2 100755
@@ -344,6 +344,10 @@ gamecube|wii)
     link_address='0x600000'
     platformo="$object/$platform-head.o $object/$platform.o"
     ;;
+wiiu)
+    link_address='0x600000'
+    platformo="$object/wiiu-head.o $object/$platform.o"
+    ;;
 microwatt)
     link_address='0x500000'
     platformo="$object/fixed-head.o $object/$platform.o"
Signature · 1 line
2.36.1
author
#39 lore raw

PATCH v2 4/12 powerpc: wiiu: introduce wiiu platform

In reply to Ash Logan

Adds empty platforms/wiiu for Nintendo Wii U console

---
 arch/powerpc/platforms/Kconfig       | 1 +
 arch/powerpc/platforms/Makefile      | 1 +
 arch/powerpc/platforms/wiiu/Kconfig  | 5 +++++
 arch/powerpc/platforms/wiiu/Makefile | 1 +
 4 files changed, 8 insertions(+)
 create mode 100644 arch/powerpc/platforms/wiiu/Kconfig
 create mode 100644 arch/powerpc/platforms/wiiu/Makefile
arch/powerpc/platforms/Kconfig +1 -0
index d41dad227de8..c4a9c3c0b409 100644
@@ -22,6 +22,7 @@ source "arch/powerpc/platforms/40x/Kconfig"
 source "arch/powerpc/platforms/amigaone/Kconfig"
 source "arch/powerpc/platforms/book3s/Kconfig"
 source "arch/powerpc/platforms/microwatt/Kconfig"
+source "arch/powerpc/platforms/wiiu/Kconfig"
 
 config KVM_GUEST
 	bool "KVM Guest support"
arch/powerpc/platforms/Makefile +1 -0
index 94470fb27c99..944ddd938711 100644
@@ -24,3 +24,4 @@ obj-$(CONFIG_EMBEDDED6xx)	+= embedded6xx/
 obj-$(CONFIG_AMIGAONE)		+= amigaone/
 obj-$(CONFIG_PPC_BOOK3S)	+= book3s/
 obj-$(CONFIG_PPC_MICROWATT)	+= microwatt/
+obj-$(CONFIG_WIIU)		+= wiiu/
arch/powerpc/platforms/wiiu/Kconfig new file +5 -0
new file mode 100644
index 000000000000..e5513205da3c
@@ -0,0 +1,5 @@
+# SPDX-License-Identifier: GPL-2.0
+
+config WIIU
+	bool "Nintendo Wii U"
+	depends on PPC_BOOK3S_32
arch/powerpc/platforms/wiiu/Makefile new file +1 -0
new file mode 100644
index 000000000000..f66554cd5c45
@@ -0,0 +1 @@
+# SPDX-License-Identifier: GPL-2.0
Signature · 1 line
2.36.1
author
#40 lore raw

PATCH v2 5/12 powerpc: wiiu: declare as non-coherent

In reply to Ash Logan

The Nintendo Wii U requires explicit cache handling when interfacing with DMA devices.

---
 arch/powerpc/platforms/Kconfig.cputype | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/powerpc/platforms/Kconfig.cputype +1 -1
index e2e1fec91c6e..fd1e82603278 100644
@@ -504,7 +504,7 @@ config NR_CPUS
 config NOT_COHERENT_CACHE
 	bool
 	depends on 4xx || PPC_8xx || PPC_MPC512x || \
-		GAMECUBE_COMMON || AMIGAONE
+		GAMECUBE_COMMON || AMIGAONE || WIIU
 	select ARCH_HAS_DMA_PREP_COHERENT
 	select ARCH_HAS_SYNC_DMA_FOR_DEVICE
 	select ARCH_HAS_SYNC_DMA_FOR_CPU
Signature · 1 line
2.36.1
author
#41 lore raw

PATCH v2 6/12 powerpc: wiiu: udbg support for latteipc

In reply to Ash Logan

Add support for using the Latte chipset IPC for udbg on the Nintendo Wii U console.
These messages can then be received by a special firmware running on the "Starbuck" coprocessor.

---
 arch/powerpc/Kconfig.debug                  |   9 ++
 arch/powerpc/include/asm/udbg.h             |   1 +
 arch/powerpc/kernel/head_book3s_32.S        |  20 ++++
 arch/powerpc/kernel/udbg.c                  |   3 +
 arch/powerpc/platforms/wiiu/Kconfig         |  13 +++
 arch/powerpc/platforms/wiiu/Makefile        |   2 +
 arch/powerpc/platforms/wiiu/udbg_latteipc.c | 122 ++++++++++++++++++++
 arch/powerpc/platforms/wiiu/udbg_latteipc.h |  27 +++++
 8 files changed, 197 insertions(+)
 create mode 100644 arch/powerpc/platforms/wiiu/udbg_latteipc.c
 create mode 100644 arch/powerpc/platforms/wiiu/udbg_latteipc.h
arch/powerpc/Kconfig.debug +9 -0
index 192f0ed0097f..15c7fa7c040a 100644
@@ -254,6 +254,15 @@ config PPC_EARLY_DEBUG_USBGECKO
 	  Select this to enable early debugging for Nintendo GameCube/Wii
 	  consoles via an external USB Gecko adapter.
 
+config PPC_EARLY_DEBUG_LATTEIPC
+	bool "Early debugging through Latte chipset IPC"
+	depends on WIIU
+	select LATTEIPC_UDBG
+	help
+	  Select this to enable early debugging for Nintendo Wii U consoles via
+	  chipset IPC to the security coprocessor. This assumes a firmware is
+	  running on the coprocessor to receive messages.
+
 config PPC_EARLY_DEBUG_PS3GELIC
 	bool "Early debugging through the PS3 Ethernet port"
 	depends on PPC_PS3
arch/powerpc/include/asm/udbg.h +1 -0
index b4aa0d88ce2c..266b0e744ddc 100644
@@ -53,6 +53,7 @@ extern void __init udbg_init_ehv_bc(void);
 extern void __init udbg_init_ps3gelic(void);
 extern void __init udbg_init_debug_opal_raw(void);
 extern void __init udbg_init_debug_opal_hvsi(void);
+extern void __init udbg_init_latteipc(void);
 
 #endif /* __KERNEL__ */
 #endif /* _ASM_POWERPC_UDBG_H */
arch/powerpc/kernel/head_book3s_32.S +20 -0
index 6c739beb938c..48d487efb25c 100644
@@ -164,6 +164,9 @@ __after_mmu_off:
 #ifdef CONFIG_PPC_EARLY_DEBUG_USBGECKO
 	bl	setup_usbgecko_bat
 #endif
+#ifdef CONFIG_PPC_EARLY_DEBUG_LATTEIPC
+	bl	setup_latteipc_bat
+#endif
 
 /*
  * Call setup_cpu for CPU 0 and initialize 6xx Idle
@@ -1201,4 +1204,21 @@ setup_usbgecko_bat:
 	blr
 #endif
 
+#ifdef CONFIG_PPC_EARLY_DEBUG_LATTEIPC
+setup_latteipc_bat:
+	/* prepare a BAT for early io */
+	lis	r8, 0x0d80
+
+	/*
+	 * The virtual address used must match the virtual address
+	 * associated to the fixmap entry FIX_EARLY_DEBUG_BASE.
+	 */
+	lis	r11, 0xfffe	/* top 128K */
+	ori	r8, r8, 0x002a	/* uncached, guarded ,rw */
+	ori	r11, r11, 0x2	/* 128K, Vs=1, Vp=0 */
+	mtspr	SPRN_DBAT1L, r8
+	mtspr	SPRN_DBAT1U, r11
+	blr
+#endif
+
 	.data
arch/powerpc/kernel/udbg.c +3 -0
index b1544b2f6321..84eae25c195e 100644
@@ -67,6 +67,9 @@ void __init udbg_early_init(void)
 	udbg_init_debug_opal_raw();
 #elif defined(CONFIG_PPC_EARLY_DEBUG_OPAL_HVSI)
 	udbg_init_debug_opal_hvsi();
+#elif defined(CONFIG_PPC_EARLY_DEBUG_LATTEIPC)
+	/* For use on Nintendo Wii U */
+	udbg_init_latteipc();
 #endif
 
 #ifdef CONFIG_PPC_EARLY_DEBUG
arch/powerpc/platforms/wiiu/Kconfig +13 -0
index e5513205da3c..fa86cbc33d5e 100644
@@ -3,3 +3,16 @@
 config WIIU
 	bool "Nintendo Wii U"
 	depends on PPC_BOOK3S_32
+
+config LATTEIPC_UDBG
+	bool "Chipset IPC udbg console for the Nintendo Wii U"
+	depends on WIIU
+	help
+	  If you say yes to this option, support will be included for the
+	  Wii U's chipset IPC as a udbg console.
+	  These IPC messages can be received by a firmware running on the
+	  console's "Starbuck" security coprocessor.
+
+	  This driver bypasses the IPC layer completely.
+
+	  If in doubt, say N here.
arch/powerpc/platforms/wiiu/Makefile +2 -0
index f66554cd5c45..b1e0e1307f6e 100644
@@ -1 +1,3 @@
 # SPDX-License-Identifier: GPL-2.0
+
+obj-$(CONFIG_LATTEIPC_UDBG) += udbg_latteipc.o
arch/powerpc/platforms/wiiu/udbg_latteipc.c new file +122 -0

122 lines not on this page · raw message

arch/powerpc/platforms/wiiu/udbg_latteipc.h new file +27 -0
new file mode 100644
index 000000000000..ca6d34e49158
@@ -0,0 +1,27 @@
+/* SPDX-License-Identifier: GPL-2.0-or-later */
+/*
+ * Nintendo Wii U udbg support (to Starbuck coprocessor, via chipset IPC)
+ *
+ * Copyright (C) 2022 The linux-wiiu Team
+ *
+ * Based on arch/powerpc/platforms/embedded6xx/udbgecko_udbg.h
+ * Copyright (C) 2008-2009 The GameCube Linux Team
+ * Copyright (C) 2008-2009 Albert Herranz
+ */
+
+#ifndef __LATTEIPC_UDBG_H
+#define __LATTEIPC_UDBG_H
+
+#ifdef CONFIG_LATTEIPC_UDBG
+
+void __init latteipc_udbg_init(void);
+
+#else
+
+static inline void __init latteipc_udbg_init(void)
+{
+}
+
+#endif /* CONFIG_LATTEIPC_UDBG */
+
+#endif /* __LATTEIPC_UDBG_H */
Signature · 1 line
2.36.1
#42 lore raw

Re: [PATCH v2 06/12] powerpc: wiiu: udbg support for latteipc

Thank you for the patch! Perhaps something to improve:

Hi Ash,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on powerpc/next]
[also build test WARNING on robh/for-next linus/master v5.19-rc4 next-20220624] [cannot apply to mpe/next]
[If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/intel-lab-lkp/linux/commits/Ash-Logan/dt-bindings-wiiu-Document-the-Nintendo-Wii-U-devicetree/20220622-221056
base:   https://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux.git next
config: powerpc-randconfig-c003-20220626
compiler: clang version 15.0.0 (https://github.com/llvm/llvm-project b0d6dd3905db145853c7c744ac92d49b00b1fa20)

reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# install powerpc cross compiling tool for clang build
# apt-get install binutils-powerpc-linux-gnu
# https://github.com/intel-lab-lkp/linux/commit/acc3ab8f224a93f1a41267aeb09dee3d2ec810fb
git remote add linux-review https://github.com/intel-lab-lkp/linux
git fetch --no-tags linux-review Ash-Logan/dt-bindings-wiiu-Document-the-Nintendo-Wii-U-devicetree/20220622-221056
git checkout acc3ab8f224a93f1a41267aeb09dee3d2ec810fb
# save the config file
mkdir build_dir && cp config build_dir/.config
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=powerpc SHELL=/bin/bash arch/powerpc/platforms/wiiu/ drivers/usb/misc/

If you fix the issue, kindly add following tag where applicable

All warnings (new ones prefixed by >>):

>> arch/powerpc/platforms/wiiu/udbg_latteipc.c:65:13: warning: no previous prototype for function 'latteipc_udbg_init' [-Wmissing-prototypes]
   void __init latteipc_udbg_init(void)
               ^

arch/powerpc/platforms/wiiu/udbg_latteipc.c:65:1: note: declare 'static' if the function is not intended to be used outside of this translation unit void __init latteipc_udbg_init(void)
^
static
1 warning generated.

vim +/latteipc_udbg_init +65 arch/powerpc/platforms/wiiu/udbg_latteipc.c

    61	
    62	/*
    63	 * Latte IPC udbg support initialization.
    64	 */
  > 65	void __init latteipc_udbg_init(void)
    66	{
    67		struct device_node *np;
    68		void __iomem *ipc_io_base;
    69	
    70		if (latteipc_io_base)
    71			udbg_printf("%s: early -> final\n", __func__);
    72	
    73		np = of_find_compatible_node(NULL, NULL, "nintendo,latte-ipc");
    74		if (!np) {
    75			udbg_printf("%s: IPC node not found\n", __func__);
    76			goto out;
    77		}
    78	
    79		ipc_io_base = latteipc_udbg_setup_ipc_io_base(np);
    80		if (!ipc_io_base) {
    81			udbg_printf("%s: failed to setup IPC io base\n", __func__);
    82			goto done;
    83		}
    84	
    85		udbg_putc = latteipc_udbg_putc;
    86		udbg_printf("latteipc_udbg: ready\n");
    87	
    88	done:
    89		of_node_put(np);
    90	out:
    91		return;
    92	}
    93	
Signature · 2 lines
0-DAY CI Kernel Test Service
https://01.org/lkp
author
#43 lore raw

PATCH v2 7/12 powerpc: wiiu: espresso interrupt controller support

In reply to Ash Logan

Add support for the "Espresso" interrupt controller in the Nintendo Wii U.

---
 arch/powerpc/platforms/wiiu/Makefile       |   1 +
 arch/powerpc/platforms/wiiu/espresso-pic.c | 183 +++++++++++++++++++++
 arch/powerpc/platforms/wiiu/espresso-pic.h |  59 +++++++
 3 files changed, 243 insertions(+)
 create mode 100644 arch/powerpc/platforms/wiiu/espresso-pic.c
 create mode 100644 arch/powerpc/platforms/wiiu/espresso-pic.h
arch/powerpc/platforms/wiiu/Makefile +1 -0
index b1e0e1307f6e..aabf4b43e806 100644
@@ -1,3 +1,4 @@
 # SPDX-License-Identifier: GPL-2.0
 
+obj-$(CONFIG_WIIU) += espresso-pic.o
 obj-$(CONFIG_LATTEIPC_UDBG) += udbg_latteipc.o
arch/powerpc/platforms/wiiu/espresso-pic.c new file +183 -0

183 lines not on this page · raw message

arch/powerpc/platforms/wiiu/espresso-pic.h new file +59 -0

59 lines not on this page · raw message

Signature · 1 line
2.36.1
author
#44 lore raw

PATCH v2 8/12 powerpc: wiiu: latte interrupt controller support

In reply to Ash Logan

Add support for the "Latte" interrupt controller in the Nintendo Wii U. This controller is used for the entire SoC and is wired to a cascade interrupt on the Espresso controller.

---
 arch/powerpc/platforms/wiiu/Kconfig     |   1 +
 arch/powerpc/platforms/wiiu/Makefile    |   2 +-
 arch/powerpc/platforms/wiiu/latte-pic.c | 259 ++++++++++++++++++++++++
 arch/powerpc/platforms/wiiu/latte-pic.h |  23 +++
 4 files changed, 284 insertions(+), 1 deletion(-)
 create mode 100644 arch/powerpc/platforms/wiiu/latte-pic.c
 create mode 100644 arch/powerpc/platforms/wiiu/latte-pic.h
arch/powerpc/platforms/wiiu/Kconfig +1 -0
index fa86cbc33d5e..5e062536ca58 100644
@@ -3,6 +3,7 @@
 config WIIU
 	bool "Nintendo Wii U"
 	depends on PPC_BOOK3S_32
+	select IRQ_DOMAIN_HIERARCHY
 
 config LATTEIPC_UDBG
 	bool "Chipset IPC udbg console for the Nintendo Wii U"
arch/powerpc/platforms/wiiu/Makefile +1 -1
index aabf4b43e806..fa16c60261e6 100644
@@ -1,4 +1,4 @@
 # SPDX-License-Identifier: GPL-2.0
 
-obj-$(CONFIG_WIIU) += espresso-pic.o
+obj-$(CONFIG_WIIU) += espresso-pic.o latte-pic.o
 obj-$(CONFIG_LATTEIPC_UDBG) += udbg_latteipc.o
arch/powerpc/platforms/wiiu/latte-pic.c new file +259 -0

259 lines not on this page · raw message

arch/powerpc/platforms/wiiu/latte-pic.h new file +23 -0
new file mode 100644
index 000000000000..7021d9497d35
@@ -0,0 +1,23 @@
+/* SPDX-License-Identifier: GPL-2.0-or-later */
+/*
+ * Nintendo Wii U "Latte" interrupt controller support
+ *
+ * Copyright (C) 2022 The linux-wiiu Team
+ */
+
+#ifndef __LATTE_PIC_H
+#define __LATTE_PIC_H
+
+struct lt_pic {
+	__be32 ahball_icr;	/* Triggered AHB IRQs (all) */
+	__be32 ahblt_icr;	/* Triggered AHB IRQs (latte only) */
+	__be32 ahball_imr;	/* Allowed AHB IRQs (all) */
+	__be32 ahblt_imr;	/* Allowed AHB IRQs (latte only) */
+} __packed;
+
+#define LATTE_AHBALL_NR_IRQS    32
+#define LATTE_AHBLT_NR_IRQS     32
+
+void latte_pic_init(void);
+
+#endif
Signature · 1 line
2.36.1
#45 lore raw

Re: [PATCH v2 08/12] powerpc: wiiu: latte interrupt controller support

Thank you for the patch! Perhaps something to improve:

Hi Ash,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on powerpc/next]
[also build test WARNING on robh/for-next]
[cannot apply to mpe/next]
[If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/intel-lab-lkp/linux/commits/Ash-Logan/dt-bindings-wiiu-Document-the-Nintendo-Wii-U-devicetree/20220622-221056
base:   https://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux.git next
config: powerpc-randconfig-c003-20220626 (https://download.01.org/0day-ci/archive/20220627/[email protected]/config)
compiler: clang version 15.0.0 (https://github.com/llvm/llvm-project b0d6dd3905db145853c7c744ac92d49b00b1fa20)

reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# install powerpc cross compiling tool for clang build
# apt-get install binutils-powerpc-linux-gnu
# https://github.com/intel-lab-lkp/linux/commit/533a7cf49cc00c4eaafd2afee5ecd9e23bac99f2
git remote add linux-review https://github.com/intel-lab-lkp/linux
git fetch --no-tags linux-review Ash-Logan/dt-bindings-wiiu-Document-the-Nintendo-Wii-U-devicetree/20220622-221056
git checkout 533a7cf49cc00c4eaafd2afee5ecd9e23bac99f2
# save the config file
mkdir build_dir && cp config build_dir/.config
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=powerpc SHELL=/bin/bash arch/powerpc/platforms/wiiu/ drivers/usb/misc/

If you fix the issue, kindly add following tag where applicable

All warnings (new ones prefixed by >>):

>> arch/powerpc/platforms/wiiu/latte-pic.c:155:14: warning: no previous prototype for function 'latte_pic_get_irq' [-Wmissing-prototypes]
   unsigned int latte_pic_get_irq(struct irq_domain *h)
                ^

arch/powerpc/platforms/wiiu/latte-pic.c:155:1: note: declare 'static' if the function is not intended to be used outside of this translation unit unsigned int latte_pic_get_irq(struct irq_domain *h)
^
static
1 warning generated.

vim +/latte_pic_get_irq +155 arch/powerpc/platforms/wiiu/latte-pic.c

150
151 /*
152 * Determinate if there are interrupts pending
153 * Checks AHBALL (0-32) and AHBLT (32-64)
154 */

 > 155	unsigned int latte_pic_get_irq(struct irq_domain *h)

156 {
157 struct lt_pic *pic = *this_cpu_ptr(&lt_pic_cpu);
158 u32 irq_status, irq;
159
160 /* Check AHBALL first */
161 irq_status = in_be32(&pic->ahball_icr) & in_be32(&pic->ahball_imr);
162
163 if (irq_status == 0) {
164 /* Try AHBLT */
165 irq_status =
166 in_be32(&pic->ahblt_icr) & in_be32(&pic->ahblt_imr);
167 if (irq_status == 0)
168 return 0; /* No IRQs pending */
169
170 /* AHBLT is mapped above 32 (LATTE_AHBALL_NR_IRQS) */
171 irq = __ffs(irq_status) + LATTE_AHBALL_NR_IRQS;
172 return irq_linear_revmap(h, irq);
173 }
174
175 irq = __ffs(irq_status);
176 return irq_linear_revmap(h, irq);
177 }
178

Signature · 2 lines
0-DAY CI Kernel Test Service
https://01.org/lkp
author
#46 lore raw

PATCH v2 9/12 powerpc: espresso processor support

In reply to Ash Logan

Adds a cputable entry for the "Espresso" processor found on the Nintendo Wii U, which has a PVR unrelated to other 750CL-like chips. Only this revision has been seen in the wild.

---
 arch/powerpc/kernel/cputable.c | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)
arch/powerpc/kernel/cputable.c +16 -0
index ae0fdef0ac11..b575f5570485 100644
@@ -718,6 +718,22 @@ static struct cpu_spec __initdata cpu_specs[] = {
 		.platform		= "ppc750",
 		.oprofile_cpu_type      = "ppc/750",
 	},
+	{	/* "Espresso" (750CL-like) */
+		.pvr_mask		= 0xffffffff,
+		.pvr_value		= 0x70010201,
+		.cpu_name		= "Espresso",
+		.cpu_features		= CPU_FTRS_750CL,
+		.cpu_user_features	= COMMON_USER | PPC_FEATURE_PPC_LE,
+		.mmu_features		= MMU_FTR_HPTE_TABLE | MMU_FTR_USE_HIGH_BATS,
+		.icache_bsize		= 32,
+		.dcache_bsize		= 32,
+		.num_pmcs		= 4,
+		.pmc_type		= PPC_PMC_IBM,
+		.cpu_setup		= __setup_cpu_750,
+		.machine_check		= machine_check_generic,
+		.platform		= "ppc750",
+		.oprofile_cpu_type      = "ppc/750",
+	},
 	{	/* 745/755 */
 		.pvr_mask		= 0xfffff000,
 		.pvr_value		= 0x00083000,
Signature · 1 line
2.36.1
author
#47 lore raw

PATCH v2 10/12 powerpc: wiiu: platform support

In reply to Ash Logan

Add platform support for the Nintendo Wii U console.

---
 arch/powerpc/platforms/wiiu/Makefile |  2 +-
 arch/powerpc/platforms/wiiu/setup.c  | 67 ++++++++++++++++++++++++++++
 2 files changed, 68 insertions(+), 1 deletion(-)
 create mode 100644 arch/powerpc/platforms/wiiu/setup.c
arch/powerpc/platforms/wiiu/Makefile +1 -1
index fa16c60261e6..abcb7a1beebf 100644
@@ -1,4 +1,4 @@
 # SPDX-License-Identifier: GPL-2.0
 
-obj-$(CONFIG_WIIU) += espresso-pic.o latte-pic.o
+obj-$(CONFIG_WIIU) += setup.o espresso-pic.o latte-pic.o
 obj-$(CONFIG_LATTEIPC_UDBG) += udbg_latteipc.o
arch/powerpc/platforms/wiiu/setup.c new file +67 -0

67 lines not on this page · raw message

Signature · 1 line
2.36.1
author
#48 lore raw

PATCH v2 11/12 powerpc: wiiu: don't enforce flat memory

In reply to Ash Logan

pgtable_32.c:mapin_ram loops over each valid memory range, which means non-contiguous memory just works.

---
 arch/powerpc/mm/init_32.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
arch/powerpc/mm/init_32.c +2 -2
index 3d690be48e84..59a84629d9a0 100644
@@ -125,10 +125,10 @@ void __init MMU_init(void)
 	 * lowmem_end_addr is initialized below.
 	 */
 	if (memblock.memory.cnt > 1) {
-#ifndef CONFIG_WII
+#if !defined(CONFIG_WII) && !defined(CONFIG_WIIU)
 		memblock_enforce_memory_limit(memblock.memory.regions[0].size);
 		pr_warn("Only using first contiguous memory region\n");
-#else
+#elif defined(CONFIG_WII)
 		wii_memory_fixups();
 #endif
 	}
Signature · 1 line
2.36.1
author
#49 lore raw

PATCH v2 12/12 powerpc: wiiu: Add minimal default config

In reply to Ash Logan

Adds a bare-minimum config to get a kernel compiled. Will need some more interesting options once a storage device to boot from is added.

---
 arch/powerpc/configs/wiiu_defconfig | 7 +++++++
 1 file changed, 7 insertions(+)
 create mode 100644 arch/powerpc/configs/wiiu_defconfig
arch/powerpc/configs/wiiu_defconfig new file +7 -0
new file mode 100644
index 000000000000..a761ebcdd9f2
@@ -0,0 +1,7 @@
+# CONFIG_PPC_CHRP is not set
+# CONFIG_PPC_PMAC is not set
+CONFIG_WIIU=y
+# CONFIG_PPC_OF_BOOT_TRAMPOLINE is not set
+CONFIG_HIGHMEM=y
+CONFIG_STRICT_KERNEL_RWX=y
+CONFIG_PPC_EARLY_DEBUG=y
Signature · 1 line
2.36.1
author
#50 lore raw

v3 cover powerpc: Nintendo Wii U support

In reply to Ash Logan

The following patches add basic support for the Nintendo Wii U video game console, a PowerPC system somewhat similar to the GameCube and Wii.

This includes:
- devicetree source
- bootwrapper support
- udbg console to bootloader
- early udbg console
- interrupt controllers
- platform support
- recognition of the Espresso processor
- workaround for the discontiguous RAM blocks

This is enough to boot on hardware. dmesg pics (with a small hack to udbg-immortal, not included):

For those who have hardware and would like to try these patches, some modification is required to the stock OS to allow Linux. For info:
https://wiki.linux-wiiu.org/wiki/AdvancedSetup

Some of the design choices (new platform > embedded6xx) were discussed previously:

Turns out even less changes were needed than previously anticipated for discontiguous memory, and KUAP is yet to give trouble. Thanks to those who helped and discussed this.

Changes since v2:
- Fixed some overzealous deleting in the devicetree, oops.
- Fixed missing declarations for some functions (thanks robots)
- Fixed some checkpatch warnings.
- Mark latte as a simple-bus and use of_platform_default_populate.
Changes since v1:
- Style and formatting tweaks to the devicetree, thanks Rob Herring for the review.

Ash Logan (12):
dt-bindings: wiiu: Document the Nintendo Wii U devicetree
powerpc: wiiu: device tree
powerpc: wiiu: bootwrapper support
powerpc: wiiu: introduce wiiu platform
powerpc: wiiu: declare as non-coherent
powerpc: wiiu: udbg support for latteipc
powerpc: wiiu: espresso interrupt controller support
powerpc: wiiu: latte interrupt controller support
powerpc: espresso processor support
powerpc: wiiu: platform support
powerpc: wiiu: don't enforce flat memory
powerpc: wiiu: add minimal default config

 .../bindings/powerpc/nintendo/wiiu.yaml       |  28 ++
 .../powerpc/nintendo/wiiu/espresso-pic.yaml   |  42 +++
 .../bindings/powerpc/nintendo/wiiu/gpu7.yaml  |  41 +++
 .../powerpc/nintendo/wiiu/latte-ahci.yaml     |  43 +++
 .../powerpc/nintendo/wiiu/latte-dsp.yaml      |  35 ++
 .../powerpc/nintendo/wiiu/latte-pic.yaml      |  46 +++
 .../powerpc/nintendo/wiiu/latte-sdhci.yaml    |  40 +++
 .../bindings/powerpc/nintendo/wiiu/latte.yaml |  25 ++
 arch/powerpc/Kconfig.debug                    |   9 +
 arch/powerpc/boot/Makefile                    |   4 +
 arch/powerpc/boot/dts/wiiu.dts                | 326 ++++++++++++++++++
 arch/powerpc/boot/wiiu-head.S                 | 103 ++++++
 arch/powerpc/boot/wiiu.c                      |  73 ++++
 arch/powerpc/boot/wrapper                     |   4 +
 arch/powerpc/configs/wiiu_defconfig           |   7 +
 arch/powerpc/include/asm/udbg.h               |   1 +
 arch/powerpc/kernel/cputable.c                |  16 +
 arch/powerpc/kernel/head_book3s_32.S          |  20 ++
 arch/powerpc/kernel/udbg.c                    |   3 +
 arch/powerpc/mm/init_32.c                     |   4 +-
 arch/powerpc/platforms/Kconfig                |   1 +
 arch/powerpc/platforms/Kconfig.cputype        |   2 +-
 arch/powerpc/platforms/Makefile               |   1 +
 arch/powerpc/platforms/wiiu/Kconfig           |  22 ++
 arch/powerpc/platforms/wiiu/Makefile          |   4 +
 arch/powerpc/platforms/wiiu/espresso-pic.c    | 183 ++++++++++
 arch/powerpc/platforms/wiiu/espresso-pic.h    |  59 ++++
 arch/powerpc/platforms/wiiu/latte-pic.c       | 259 ++++++++++++++
 arch/powerpc/platforms/wiiu/latte-pic.h       |  23 ++
 arch/powerpc/platforms/wiiu/setup.c           |  60 ++++
 arch/powerpc/platforms/wiiu/udbg_latteipc.c   | 124 +++++++
 arch/powerpc/platforms/wiiu/udbg_latteipc.h   |  27 ++
 32 files changed, 1632 insertions(+), 3 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/powerpc/nintendo/wiiu.yaml
 create mode 100644 Documentation/devicetree/bindings/powerpc/nintendo/wiiu/espresso-pic.yaml
 create mode 100644 Documentation/devicetree/bindings/powerpc/nintendo/wiiu/gpu7.yaml
 create mode 100644 Documentation/devicetree/bindings/powerpc/nintendo/wiiu/latte-ahci.yaml
 create mode 100644 Documentation/devicetree/bindings/powerpc/nintendo/wiiu/latte-dsp.yaml
 create mode 100644 Documentation/devicetree/bindings/powerpc/nintendo/wiiu/latte-pic.yaml
 create mode 100644 Documentation/devicetree/bindings/powerpc/nintendo/wiiu/latte-sdhci.yaml
 create mode 100644 Documentation/devicetree/bindings/powerpc/nintendo/wiiu/latte.yaml
 create mode 100644 arch/powerpc/boot/dts/wiiu.dts
 create mode 100644 arch/powerpc/boot/wiiu-head.S
 create mode 100644 arch/powerpc/boot/wiiu.c
 create mode 100644 arch/powerpc/configs/wiiu_defconfig
 create mode 100644 arch/powerpc/platforms/wiiu/Kconfig
 create mode 100644 arch/powerpc/platforms/wiiu/Makefile
 create mode 100644 arch/powerpc/platforms/wiiu/espresso-pic.c
 create mode 100644 arch/powerpc/platforms/wiiu/espresso-pic.h
 create mode 100644 arch/powerpc/platforms/wiiu/latte-pic.c
 create mode 100644 arch/powerpc/platforms/wiiu/latte-pic.h
 create mode 100644 arch/powerpc/platforms/wiiu/setup.c
 create mode 100644 arch/powerpc/platforms/wiiu/udbg_latteipc.c
 create mode 100644 arch/powerpc/platforms/wiiu/udbg_latteipc.h

base-commit: 03c765b0e3b4cb5063276b086c76f7a612856a9a

Signature · 1 line
2.36.1
author
#51 lore raw

PATCH v3 1/12 dt-bindings: wiiu: Document the Nintendo Wii U devicetree

Adds schema for the various Wii U devicetree nodes used.

---
 .../bindings/powerpc/nintendo/wiiu.yaml       | 28 +++++++++++
 .../powerpc/nintendo/wiiu/espresso-pic.yaml   | 42 +++++++++++++++++
 .../bindings/powerpc/nintendo/wiiu/gpu7.yaml  | 41 +++++++++++++++++
 .../powerpc/nintendo/wiiu/latte-ahci.yaml     | 43 +++++++++++++++++
 .../powerpc/nintendo/wiiu/latte-dsp.yaml      | 35 ++++++++++++++
 .../powerpc/nintendo/wiiu/latte-pic.yaml      | 46 +++++++++++++++++++
 .../powerpc/nintendo/wiiu/latte-sdhci.yaml    | 40 ++++++++++++++++
 .../bindings/powerpc/nintendo/wiiu/latte.yaml | 25 ++++++++++
 8 files changed, 300 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/powerpc/nintendo/wiiu.yaml
 create mode 100644 Documentation/devicetree/bindings/powerpc/nintendo/wiiu/espresso-pic.yaml
 create mode 100644 Documentation/devicetree/bindings/powerpc/nintendo/wiiu/gpu7.yaml
 create mode 100644 Documentation/devicetree/bindings/powerpc/nintendo/wiiu/latte-ahci.yaml
 create mode 100644 Documentation/devicetree/bindings/powerpc/nintendo/wiiu/latte-dsp.yaml
 create mode 100644 Documentation/devicetree/bindings/powerpc/nintendo/wiiu/latte-pic.yaml
 create mode 100644 Documentation/devicetree/bindings/powerpc/nintendo/wiiu/latte-sdhci.yaml
 create mode 100644 Documentation/devicetree/bindings/powerpc/nintendo/wiiu/latte.yaml
Documentation/devicetree/bindings/powerpc/nintendo/wiiu.yaml new file +28 -0
new file mode 100644
index 000000000000..5824b07928f5
@@ -0,0 +1,28 @@
+# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause
+%YAML 1.2
+---
+
+$id: http://devicetree.org/schemas/powerpc/nintendo/wiiu.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Nintendo Wii U bindings
+
+maintainers:
+  - Ash Logan <[email protected]>
+  - Emmanuel Gil Peyrot <[email protected]>
+
+description: |
+  Nintendo Wii U video game console binding.
+
+properties:
+  $nodename:
+    const: "/"
+  compatible:
+    oneOf:
+      - description: Nintendo Wii U video game console
+        items:
+          - const: nintendo,wiiu
+
+additionalProperties: true
+
+...
Documentation/devicetree/bindings/powerpc/nintendo/wiiu/espresso-pic.yaml new file +42 -0

42 lines not on this page · raw message

Documentation/devicetree/bindings/powerpc/nintendo/wiiu/gpu7.yaml new file +41 -0

41 lines not on this page · raw message

Documentation/devicetree/bindings/powerpc/nintendo/wiiu/latte-ahci.yaml new file +43 -0

43 lines not on this page · raw message

Documentation/devicetree/bindings/powerpc/nintendo/wiiu/latte-dsp.yaml new file +35 -0
new file mode 100644
index 000000000000..ed0b4c28ce48
@@ -0,0 +1,35 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/powerpc/nintendo/wiiu/latte-dsp.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Nintendo Wii U Latte DSP
+
+maintainers:
+  - Ash Logan <[email protected]>
+  - Emmanuel Gil Peyrot <[email protected]>
+
+description: |
+  Nintendo Wii U digital signal processor, as found in the Latte chip.
+
+properties:
+  compatible:
+    oneOf:
+      - description: Nintendo Wii U Latte DSP
+        items:
+          - const: nintendo,latte-dsp
+  reg:
+    items:
+      - description: DSP registers
+
+# Once more is known about this device more properties will likely be added
+additionalProperties: true
+
+examples:
+  - |
+    latte_dsp: dsp@c005000 {
+         compatible = "nintendo,latte-dsp";
+         reg = <0x0c005000 0x200>;
+    };
+...
Documentation/devicetree/bindings/powerpc/nintendo/wiiu/latte-pic.yaml new file +46 -0

46 lines not on this page · raw message

Documentation/devicetree/bindings/powerpc/nintendo/wiiu/latte-sdhci.yaml new file +40 -0
new file mode 100644
index 000000000000..4b9b0820edc1
@@ -0,0 +1,40 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/powerpc/nintendo/wiiu/latte-sdhci.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Nintendo Wii U Latte SD Host controller
+
+maintainers:
+  - Ash Logan <[email protected]>
+  - Emmanuel Gil Peyrot <[email protected]>
+
+description: |
+  SDHCI hosts found on the Nintendo Wii U's Latte SoC for SD cards and SDIO devices.
+
+properties:
+  compatible:
+    oneOf:
+      - description: Nintendo Wii U Latte SDHCI
+        items:
+          - const: nintendo,latte-sdhci
+          - const: sdhci
+  reg:
+    items:
+      - description: Core registers
+  interrupts:
+    items:
+      - description: SDHCI interrupt
+
+additionalProperties: false
+
+examples:
+  - |
+    sdcard_0: sdhci@d070000 {
+          compatible = "nintendo,latte-sdhci","sdhci";
+          reg = <0x0d070000 0x200>;
+          interrupts = <7>;
+          interrupt-parent = <&latte_pic>;
+    };
+...
Documentation/devicetree/bindings/powerpc/nintendo/wiiu/latte.yaml new file +25 -0
new file mode 100644
index 000000000000..6ae86d198fa3
@@ -0,0 +1,25 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/powerpc/nintendo/wiiu/latte.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Latte system bus
+
+maintainers:
+  - Ash Logan <[email protected]>
+  - Emmanuel Gil Peyrot <[email protected]>
+
+description: |
+  Latte multi-function SoC, containing many of the devices found on the Nintendo Wii U.
+
+properties:
+  compatible:
+    oneOf:
+      - description: Nintendo Wii U "Latte" SoC
+        items:
+          - const: nintendo,latte
+
+additionalProperties: true
+
+...
Signature · 1 line
2.36.1
#52 lore raw

Re: [PATCH v3 01/12] dt-bindings: wiiu: Document the Nintendo Wii U devicetree

Quoted 70 lines · Ash Logan

Adds schema for the various Wii U devicetree nodes used.

---
 .../bindings/powerpc/nintendo/wiiu.yaml       | 28 +++++++++++
 .../powerpc/nintendo/wiiu/espresso-pic.yaml   | 42 +++++++++++++++++
 .../bindings/powerpc/nintendo/wiiu/gpu7.yaml  | 41 +++++++++++++++++
 .../powerpc/nintendo/wiiu/latte-ahci.yaml     | 43 +++++++++++++++++
 .../powerpc/nintendo/wiiu/latte-dsp.yaml      | 35 ++++++++++++++
 .../powerpc/nintendo/wiiu/latte-pic.yaml      | 46 +++++++++++++++++++
 .../powerpc/nintendo/wiiu/latte-sdhci.yaml    | 40 ++++++++++++++++
 .../bindings/powerpc/nintendo/wiiu/latte.yaml | 25 ++++++++++
 8 files changed, 300 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/powerpc/nintendo/wiiu.yaml
 create mode 100644 Documentation/devicetree/bindings/powerpc/nintendo/wiiu/espresso-pic.yaml
 create mode 100644 Documentation/devicetree/bindings/powerpc/nintendo/wiiu/gpu7.yaml
 create mode 100644 Documentation/devicetree/bindings/powerpc/nintendo/wiiu/latte-ahci.yaml
 create mode 100644 Documentation/devicetree/bindings/powerpc/nintendo/wiiu/latte-dsp.yaml
 create mode 100644 Documentation/devicetree/bindings/powerpc/nintendo/wiiu/latte-pic.yaml
 create mode 100644 Documentation/devicetree/bindings/powerpc/nintendo/wiiu/latte-sdhci.yaml
 create mode 100644 Documentation/devicetree/bindings/powerpc/nintendo/wiiu/latte.yaml
Documentation/devicetree/bindings/powerpc/nintendo/wiiu.yaml new file +28 -0
new file mode 100644
index 000000000000..5824b07928f5
@@ -0,0 +1,28 @@
+# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause
+%YAML 1.2
+---
+
+$id: http://devicetree.org/schemas/powerpc/nintendo/wiiu.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Nintendo Wii U bindings
+
+maintainers:
+  - Ash Logan <[email protected]>
+  - Emmanuel Gil Peyrot <[email protected]>
+
+description: |
+  Nintendo Wii U video game console binding.
+
+properties:
+  $nodename:
+    const: "/"
+  compatible:
+    oneOf:
+      - description: Nintendo Wii U video game console
+        items:
+          - const: nintendo,wiiu
+
+additionalProperties: true
+
+...
Documentation/devicetree/bindings/powerpc/nintendo/wiiu/espresso-pic.yaml new file +8 -0
new file mode 100644
index 000000000000..878a81595f5f
@@ -0,0 +1,42 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/powerpc/nintendo/wiiu/espresso-pic.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Nintendo Wii U "Espresso" interrupt controller
+

Documentation/devicetree/bindings/powerpc/nintendo/wiiu/espresso-pic.yaml line 18

Quoted 10 lines
Documentation/devicetree/bindings/powerpc/nintendo/wiiu/espresso-pic.yaml new file +10 -0
+maintainers:
+  - Ash Logan <[email protected]>
+  - Emmanuel Gil Peyrot <[email protected]>
+
+description: |
+  Interrupt controller found on the Nintendo Wii U for the "Espresso" processor.
+
+properties:
+  compatible:
+    oneOf:

No need for oneOf, just const.

Documentation/devicetree/bindings/powerpc/nintendo/wiiu/espresso-pic.yaml line 19

Quoted 1 line
Documentation/devicetree/bindings/powerpc/nintendo/wiiu/espresso-pic.yaml new file +1 -0
+      - description: Nintendo Wii U "Espresso" interrupt controller

No need for description.

Documentation/devicetree/bindings/powerpc/nintendo/wiiu/espresso-pic.yaml line 24

Quoted 5 lines
Documentation/devicetree/bindings/powerpc/nintendo/wiiu/espresso-pic.yaml new file +5 -0
+        items:
+          - const: nintendo,espresso-pic
+  '#interrupt-cells':
+    # Interrupt numbers 0-32 in one cell
+    const: 1

Blank line between each property.

Documentation/devicetree/bindings/powerpc/nintendo/wiiu/espresso-pic.yaml line 28

Quoted 4 lines
Documentation/devicetree/bindings/powerpc/nintendo/wiiu/espresso-pic.yaml new file +4 -0
+  interrupt-controller: true
+  reg:
+    items:
+      - description: Core registers

Just maxItems:1. Description is not helpful.

Missing required properties.

Documentation/devicetree/bindings/powerpc/nintendo/wiiu/espresso-pic.yaml line 34

Quoted 6 lines
Documentation/devicetree/bindings/powerpc/nintendo/wiiu/espresso-pic.yaml new file +6 -0
+
+additionalProperties: false
+
+examples:
+  - |
+    espresso_pic: pic@c000078 {

Generic node name, so "interrupt-controller"

Documentation/devicetree/bindings/powerpc/nintendo/wiiu/espresso-pic.yaml line 39

Quoted 5 lines
Documentation/devicetree/bindings/powerpc/nintendo/wiiu/espresso-pic.yaml new file +5 -0
+            #interrupt-cells = <1>;
+            interrupt-controller;
+
+            compatible = "nintendo,espresso-pic";
+            reg = <0x0c000078 0x18>;

compatible and reg by convention go first in list of properties. This applies everywhere, also to your DTS.

Quoted 27 lines
Documentation/devicetree/bindings/powerpc/nintendo/wiiu/espresso-pic.yaml new file +3 -0
+    };
+
+...
Documentation/devicetree/bindings/powerpc/nintendo/wiiu/gpu7.yaml new file +18 -0
new file mode 100644
index 000000000000..e54d49015f36
@@ -0,0 +1,41 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/powerpc/nintendo/wiiu/gpu7.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Nintendo Wii U Latte "GPU7" graphics processor
+
+maintainers:
+  - Ash Logan <[email protected]>
+  - Emmanuel Gil Peyrot <[email protected]>
+
+description: |
+  GPU7 graphics processor, also known as "GX2", found in the Latte multifunction chip of the
+  Nintendo Wii U.
+
+properties:
+  compatible:

Documentation/devicetree/bindings/powerpc/nintendo/wiiu/gpu7.yaml line 28

Quoted 10 lines
Documentation/devicetree/bindings/powerpc/nintendo/wiiu/gpu7.yaml new file +10 -0
+    oneOf:
+      - description: Nintendo Wii U Latte "GPU7" graphics processor
+        items:
+          - const: nintendo,latte-gpu7
+  reg:
+    items:
+      - description: GpuF0MMReg registers
+  interrupts:
+    items:
+      - description: Main interrupt, connected via Espresso PIC

Same comments as your interrupt controller patch. I guess these comments apply everywhere here.

Missing required properties.

Documentation/devicetree/bindings/powerpc/nintendo/wiiu/gpu7.yaml line 31

Quoted 3 lines
Documentation/devicetree/bindings/powerpc/nintendo/wiiu/gpu7.yaml new file +3 -0
+
+# This will likely get bound to the Radeon driver one day, which will neccesitate extra properties
+additionalProperties: true

No, it must be false. It's okay to extend the binding later.

Documentation/devicetree/bindings/powerpc/nintendo/wiiu/gpu7.yaml line 35

Quoted 4 lines
Documentation/devicetree/bindings/powerpc/nintendo/wiiu/gpu7.yaml new file +4 -0
+
+examples:
+  - |
+    gpu7@c200000 {

Generic node name, so "gpu".

Documentation/devicetree/bindings/powerpc/nintendo/wiiu/gpu7.yaml line 36

Quoted 1 line
Documentation/devicetree/bindings/powerpc/nintendo/wiiu/gpu7.yaml new file +1 -0
+            compatible = "nintendo,latte-gpu7";

Wrong indentation. Use four spaces for DTS example.

Quoted 27 lines
Documentation/devicetree/bindings/powerpc/nintendo/wiiu/gpu7.yaml new file +5 -0
+            reg = <0x0c200000 0x80000>;
+            interrupts = <2>;
+            interrupt-parent = <&espresso_pic>;
+    };
+...
Documentation/devicetree/bindings/powerpc/nintendo/wiiu/latte-ahci.yaml new file +16 -0
new file mode 100644
index 000000000000..7b9de4effcb0
@@ -0,0 +1,43 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/powerpc/nintendo/wiiu/latte-ahci.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Nintendo Wii U Latte AHCI controller
+
+maintainers:
+  - Ash Logan <[email protected]>
+  - Emmanuel Gil Peyrot <[email protected]>
+
+description: |
+  Nintendo Wii U AHCI SATA controller, as found in the Latte chip.
+
+properties:

Documentation/devicetree/bindings/powerpc/nintendo/wiiu/latte-ahci.yaml line 26

Quoted 10 lines
Documentation/devicetree/bindings/powerpc/nintendo/wiiu/latte-ahci.yaml new file +10 -0
+  compatible:
+    oneOf:
+      - description: Nintendo Wii U Latte AHCI controller
+        items:
+          - const: nintendo,latte-ahci
+  reg:
+    items:
+      - description: |
+          HBA memory registers. Note that unlike the spec, space for only 6 ports exist, with 2 vendor
+          registers afterwards, thus register space should be 0x408 long (0x100+0x80*6+0x8).

Here description can stay, so no need for maxItems.

Documentation/devicetree/bindings/powerpc/nintendo/wiiu/latte-ahci.yaml line 31

Quoted 5 lines
Documentation/devicetree/bindings/powerpc/nintendo/wiiu/latte-ahci.yaml new file +5 -0
+  interrupts:
+    items:
+      - description: Main HBA interrupt
+      - description: Vendor debugging interrupt
+

This should also reference ahci schema (I think it is ready).

Documentation/devicetree/bindings/powerpc/nintendo/wiiu/latte-ahci.yaml line 38

Quoted 7 lines
Documentation/devicetree/bindings/powerpc/nintendo/wiiu/latte-ahci.yaml new file +7 -0
+additionalProperties: false
+
+examples:
+  - |
+    sata: ahci@d160400 {
+          compatible = "nintendo,latte-ahci";
+          reg = <0x0d160400 0x408>;

Fix indentation.

Quoted 28 lines
Documentation/devicetree/bindings/powerpc/nintendo/wiiu/latte-ahci.yaml new file +5 -0
+
+          interrupt-parent = <&latte_pic>;
+          interrupts = <38>, <28>;
+    };
+...
Documentation/devicetree/bindings/powerpc/nintendo/wiiu/latte-dsp.yaml new file +17 -0
new file mode 100644
index 000000000000..ed0b4c28ce48
@@ -0,0 +1,35 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/powerpc/nintendo/wiiu/latte-dsp.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Nintendo Wii U Latte DSP
+
+maintainers:
+  - Ash Logan <[email protected]>
+  - Emmanuel Gil Peyrot <[email protected]>
+
+description: |
+  Nintendo Wii U digital signal processor, as found in the Latte chip.
+
+properties:
+  compatible:

Documentation/devicetree/bindings/powerpc/nintendo/wiiu/latte-dsp.yaml line 27

Quoted 10 lines
Documentation/devicetree/bindings/powerpc/nintendo/wiiu/latte-dsp.yaml new file +10 -0
+    oneOf:
+      - description: Nintendo Wii U Latte DSP
+        items:
+          - const: nintendo,latte-dsp
+  reg:
+    items:
+      - description: DSP registers
+
+# Once more is known about this device more properties will likely be added
+additionalProperties: true

Again, no. All other comments also apply.

Quoted 41 lines
Documentation/devicetree/bindings/powerpc/nintendo/wiiu/latte-dsp.yaml new file +8 -0
+
+examples:
+  - |
+    latte_dsp: dsp@c005000 {
+         compatible = "nintendo,latte-dsp";
+         reg = <0x0c005000 0x200>;
+    };
+...
Documentation/devicetree/bindings/powerpc/nintendo/wiiu/latte-pic.yaml new file +27 -0
new file mode 100644
index 000000000000..a2df71fb9964
@@ -0,0 +1,46 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/powerpc/nintendo/wiiu/latte-pic.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Nintendo Wii U Latte interrupt controller
+
+maintainers:
+  - Ash Logan <[email protected]>
+  - Emmanuel Gil Peyrot <[email protected]>
+
+description: |
+  Interrupt controller found on the Nintendo Wii U for the "Latte" devices.
+
+properties:
+  compatible:
+    oneOf:
+      - description: Nintendo Wii U Latte interrupt controller
+        items:
+          - const: nintendo,latte-pic
+  '#interrupt-cells':
+    # Interrupt numbers 0-64 in one cell.
+    const: 1
+  interrupt-controller: true
+  reg:
+    items:

Documentation/devicetree/bindings/powerpc/nintendo/wiiu/latte-pic.yaml line 37

Quoted 10 lines
Documentation/devicetree/bindings/powerpc/nintendo/wiiu/latte-pic.yaml new file +10 -0
+      - description: Core registers
+  interrupts:
+    items:
+      - description: Cascade interrupt for Espresso PIC
+
+additionalProperties: false
+
+examples:
+  - |
+    latte_pic: pic@d800440 {

interrupt-controller.

All other comments apply.

Quoted 33 lines
Documentation/devicetree/bindings/powerpc/nintendo/wiiu/latte-pic.yaml new file +9 -0
+         #interrupt-cells = <1>;
+         interrupt-controller;
+
+         compatible = "nintendo,latte-pic";
+         reg = <0x0d800440 0x30>;
+         interrupt-parent = <&espresso_pic>;
+         interrupts = <24>;
+    };
+...
Documentation/devicetree/bindings/powerpc/nintendo/wiiu/latte-sdhci.yaml new file +18 -0
new file mode 100644
index 000000000000..4b9b0820edc1
@@ -0,0 +1,40 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/powerpc/nintendo/wiiu/latte-sdhci.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Nintendo Wii U Latte SD Host controller
+
+maintainers:
+  - Ash Logan <[email protected]>
+  - Emmanuel Gil Peyrot <[email protected]>
+
+description: |
+  SDHCI hosts found on the Nintendo Wii U's Latte SoC for SD cards and SDIO devices.
+
+properties:
+  compatible:
+    oneOf:

Documentation/devicetree/bindings/powerpc/nintendo/wiiu/latte-sdhci.yaml line 28

Quoted 10 lines
Documentation/devicetree/bindings/powerpc/nintendo/wiiu/latte-sdhci.yaml new file +10 -0
+      - description: Nintendo Wii U Latte SDHCI
+        items:
+          - const: nintendo,latte-sdhci
+          - const: sdhci
+  reg:
+    items:
+      - description: Core registers
+  interrupts:
+    items:
+      - description: SDHCI interrupt

You need to reference mmc-controller bindings in allOf.

Documentation/devicetree/bindings/powerpc/nintendo/wiiu/latte-sdhci.yaml line 34

Quoted 6 lines
Documentation/devicetree/bindings/powerpc/nintendo/wiiu/latte-sdhci.yaml new file +6 -0
+
+additionalProperties: false
+
+examples:
+  - |
+    sdcard_0: sdhci@d070000 {

Node name: mmc

The bindings look poor, several easy to fix mistakes. I suggest to open example-schema.yaml and start from there.

Best regards,
Krzysztof

author
#53 lore raw

PATCH v3 2/12 powerpc: wiiu: device tree

In reply to Ash Logan

Add a device tree source file for the Nintendo Wii U video game console.

---
v1->v2: Style and formatting changes suggested by Rob Herring.
License remains GPL-2.0 as the other powerpc dtses are the same, happy to change if there is a different preferred default.
v2->v3: Re-added address-cells accidentally removed in v2.
Marked latte as a simple-bus, since it is.

 arch/powerpc/boot/dts/wiiu.dts | 326 +++++++++++++++++++++++++++++++++
 1 file changed, 326 insertions(+)
 create mode 100644 arch/powerpc/boot/dts/wiiu.dts
arch/powerpc/boot/dts/wiiu.dts new file +326 -0
new file mode 100644
index 000000000000..44a5a1469095
@@ -0,0 +1,326 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Nintendo Wii U Device Tree Source
+ *
+ * Copyright (C) 2022 The linux-wiiu Team
+ */
+
+/dts-v1/;
+#include <dt-bindings/gpio/gpio.h>
+#include <dt-bindings/input/input.h>
+
+/ {
+	model = "nintendo,wiiu";
+	compatible = "nintendo,wiiu";
+
+	#address-cells = <1>;
+	#size-cells = <1>;
+
+	chosen {
+		bootargs = "root=/dev/sda1 rootwait";
+	};
+
+	memory {
+		device_type = "memory";
+		reg = <0x00000000 0x02000000	/* MEM1 - 32MiB */
+		       0x08000000 0x00300000	/* MEM0 - 3MiB  */
+		       0x10000000 0x80000000>;	/* MEM2 - 2GiB  */
+	};
+
+	cpus {
+		#address-cells = <1>;
+		#size-cells = <0>;
+
+		/* TODO: Add SMP */
+		PowerPC,espresso@0 {
+			device_type = "cpu";
+			reg = <0>;
+			clock-frequency = <1243125000>;		/* 1.243125GHz */
+			bus-frequency = <248625000>;		/* 248.625MHz core-to-bus 5x */
+			timebase-frequency = <62156250>;	/* 1/4 of the bus clock */
+			i-cache-size = <32768>; /* 32K icache */
+			i-cache-line-size = <32>;
+			i-cache-block-size = <32>;
+			i-cache-sets = <128>;
+			d-cache-size = <32768>; /* 32K dcache */
+			d-cache-line-size = <32>;
+			d-cache-block-size = <32>;
+			d-cache-sets = <128>;
+			next-level-cache = <&L2_0>;
+			L2_0:l2-cache {
+				compatible = "cache";
+				cache-level = <2>;
+				cache-unified;
+				cache-size = <0x80000>; /* 512KB L2 */
+				cache-line-size = <64>;
+				cache-block-size = <32>;
+				cache-sets = <2048>;
+			};
+		};
+	};
+
+	latte {
+		#address-cells = <1>;
+		#size-cells = <1>;
+		compatible = "nintendo,latte", "simple-bus";
+		ranges = <0x0c000000 0x0c000000 0x00400000	/* Espresso-only registers */
+			  0x0d000000 0x0d000000 0x00200000	/* Latte AHB deivces */
+			  0x0d800000 0x0d800000 0x00800000>;	/* Latte SoC registers */
+
+		latte_gpu: gpu@c200000 {
+			compatible = "nintendo,latte-gpu7";
+			reg = <0x0c200000 0x80000>;
+			interrupts = <2>;
+			interrupt-parent = <&espresso_pic>;
+		};
+
+		espresso_pic: pic@c000078 {
+			#interrupt-cells = <1>;
+			interrupt-controller;
+
+			compatible = "nintendo,espresso-pic";
+			reg = <0x0c000078 0x18>;
+		};
+
+		latte_dsp: dsp@c005000 {
+			compatible = "nintendo,latte-dsp";
+			reg = <0x0c005000 0x200>;
+		};
+
+		ehci_0: usb@d040000 {
+			compatible = "nintendo,latte-usb-ehci", "usb-ehci";
+			reg = <0x0d040000 0x100>;
+			interrupts = <4>;
+			interrupt-parent = <&latte_pic>;
+			big-endian-regs;
+		};
+
+		ohci_0_0: usb@d050000 {
+			compatible = "nintendo,latte-usb-ohci";
+			reg = <0x0d050000 0x100>;
+			interrupts = <5>;
+			interrupt-parent = <&latte_pic>;
+
+			big-endian-regs;
+		};
+
+		ohci_0_1: usb@d060000 {
+			compatible = "nintendo,latte-usb-ohci";
+			reg = <0x0d060000 0x100>;
+			interrupts = <6>;
+			interrupt-parent = <&latte_pic>;
+
+			big-endian-regs;
+		};
+
+		ehci_1: usb@d120000 {
+			compatible = "nintendo,latte-usb-ehci", "usb-ehci";
+			reg = <0x0d120000 0x100>;
+			interrupts = <16>;
+			interrupt-parent = <&latte_pic>;
+			big-endian-regs;
+		};
+
+		ohci_1_0: usb@d130000 {
+			compatible = "nintendo,latte-usb-ohci";
+			reg = <0x0d130000 0x100>;
+			interrupts = <35>;
+			interrupt-parent = <&latte_pic>;
+
+			big-endian-regs;
+		};
+
+		ehci_2: usb@d140000 {
+			compatible = "nintendo,latte-usb-ehci", "usb-ehci";
+			reg = <0x0d140000 0x100>;
+			interrupts = <36>;
+			interrupt-parent = <&latte_pic>;
+			big-endian-regs;
+		};
+
+		ohci_2_0: usb@d150000 {
+			compatible = "nintendo,latte-usb-ohci";
+			reg = <0x0d150000 0x100>;
+			interrupts = <37>;
+			interrupt-parent = <&latte_pic>;
+
+			big-endian-regs;
+		};
+
+		sdcard_0: sdhci@d070000 {
+			compatible = "nintendo,latte-sdhci","sdhci";
+			reg = <0x0d070000 0x200>;
+			interrupts = <7>;
+			interrupt-parent = <&latte_pic>;
+		};
+
+		wifi_0: sdhci@d080000 {
+			compatible = "nintendo,latte-sdhci","sdhci";
+			reg = <0x0d080000 0x200>;
+			interrupts = <8>;
+			interrupt-parent = <&latte_pic>;
+		};
+
+		legacy_ipc: ipc@d800000 {
+			compatible = "nintendo,latte-ipc", "nintendo,hollywood-ipc";
+			reg = <0x0d800000 0x10>;
+			interrupts = <30 31>;
+			interrupt-parent = <&latte_pic>;
+		};
+
+		latte_otp: otp@d8001ec {
+			compatible = "nintendo,latte-otp";
+			reg = <0x0d8001ec 0x8>;
+		};
+
+		sata: ahci@d160400 {
+			compatible = "nintendo,latte-ahci";
+			reg = <0x0d160400 0x808>;
+
+			interrupt-parent = <&latte_pic>;
+			interrupts = <38 28>;
+		};
+
+		latte_pic: pic@d800440 {
+			#interrupt-cells = <1>;
+			interrupt-controller;
+
+			compatible = "nintendo,latte-pic";
+			reg = <0x0d800440 0x30>;
+			interrupt-parent = <&espresso_pic>;
+			interrupts = <24>;
+		};
+
+		gpio: gpio@d8000c0 {
+			#gpio-cells = <2>;
+			compatible = "nintendo,latte-gpio", "nintendo,hollywood-gpio";
+
+			reg = <0x0d8000c0 0x40>;
+			gpio-controller;
+			/* TODO: There are actually 31 AHBALL GPIOs */
+			ngpios = <24>;
+
+			gpio-line-names =
+				"POWER", "DWIFI", "FAN", "DC_DC",
+				"", "Esp10WorkAround", "", "",
+				"PADPD", "", "EEP_CS", "EEP_CLK",
+				"EEP_MOSI", "EEP_MISO", "AVE_SCL", "AVE_SDA",
+				"DEBUG0", "DEBUG1", "DEBUG2", "DEBUG3",
+				"DEBUG4", "DEBUG5", "DEBUG6", "DEBUG7";
+
+			interrupt-controller;
+			#interrupt-cells = <2>;
+			interrupts = <10>;
+			interrupt-parent = <&latte_pic>;
+		};
+
+		gpio2: gpio@d800520 {
+			#gpio-cells = <2>;
+			compatible = "nintendo,latte-gpio", "nintendo,hollywood-gpio";
+
+			reg = <0x0d800520 0x40>;
+			gpio-controller;
+			ngpios = <7>;
+
+			gpio-line-names =
+				"FANSPEED", "SMC_SCL", "SMC_SDA", "DC_DC2",
+				"AVE_INT", "", "AVE_RESET";
+
+			interrupt-controller;
+			#interrupt-cells = <2>;
+			interrupts = <10>;
+			interrupt-parent = <&latte_pic>;
+		};
+	};
+
+	spi_gpio: spi-gpio {
+		compatible = "spi-gpio";
+		#address-cells = <1>;
+		#size-cells = <0>;
+
+		cs-gpios = <&gpio 10 GPIO_ACTIVE_HIGH>;
+		gpio-sck = <&gpio 11 GPIO_ACTIVE_HIGH>;
+		gpio-mosi = <&gpio 12 GPIO_ACTIVE_HIGH>;
+		gpio-miso = <&gpio 13 GPIO_ACTIVE_HIGH>;
+		num-chipselects = <1>;
+
+		eeprom@0 {
+			compatible = "atmel,at93c66";
+			reg = <0>;
+			spi-max-frequency = <1000000>;
+			spi-cs-high;
+			/* TODO: wiiubrew says this is 16-bit, but I only get the correct
+			 * values in 8-bit...
+			 */
+			data-size = <8>;
+			read-only;
+
+			#address-cells = <1>;
+			#size-cells = <1>;
+
+			/* https://wiiubrew.org/wiki/Hardware/SEEPROM */
+			rng_seed: rng@12 { reg = <0x012 8>; };
+			ppc_pvr: pvr@20 { reg = <0x020 4>; };
+			seeprom_ver_str: sver-str@24 { reg = <0x024 6>; };
+			seeprom_ver: sver@2a { reg = <0x02A 2>; };
+			otp_ver: over@2c { reg = <0x02C 2>; };
+			otp_rev: orev@2e { reg = <0x02E 2>; };
+			otp_ver_str: over-str@30 { reg = <0x030 8>; };
+
+			bc_crc: bc-crc@38 { reg = <0x038 4>; };
+			bc_sz: bc-sz@3c { reg = <0x03C 2>; };
+			bc_ver: bc-ver@3e { reg = <0x03E 2>; };
+			bc_boardtype: boardtype@42 { reg = <0x042 2>; };
+			bc_boardrev: boardrev@44 { reg = <0x044 2>; };
+			bc_bootsource: bootsource@46 { reg = <0x046 2>; };
+			bc_ddr3size: ddr3size@48 { reg = <0x048 2>; };
+			bc_ddr3speed: ddr3speed@4a { reg = <0x04A 2>; };
+			bc_ppcclockmul: ppcclockmul@4c { reg = <0x04C 2>; };
+			bc_iopclockmul: iopclockmul@46 { reg = <0x04E 2>; };
+			bc_video1080p: video1080p@50 { reg = <0x050 2>; };
+			bc_ddr3vendor: ddr3vendor@52 { reg = <0x052 2>; };
+			bc_movpassivereset: movpassivereset@54 { reg = <0x054 2>; };
+			bc_syspllspd: syspllspd@56 { reg = <0x056 2>; };
+			bc_satadevice: satadevice@58 { reg = <0x058 2>; };
+			bc_consoletype: consoletype@5a { reg = <0x05A 2>; };
+			bc_deviceprescence: deviceprescence@5c { reg = <0x05C 2>; };
+
+			drive_key: drvkey@80 { reg = <0x080 16>; };
+			factory_key: fackey@90 { reg = <0x090 16>; };
+			shdd_key: shddkey@a0 { reg = <0x0A0 16>; };
+			usb_key_seed: usbkeyseed@b0 { reg = <0x0B0 16>; };
+			drive_key_flag: drvkeyf@c0 { reg = <0x0C0 2>; };
+			usb_key_flag: udbkeyf@c2 { reg = <0x0C2 2>; };
+			shdd_key_flag: shddkeyf@c4 { reg = <0x0C4 2>; };
+
+			sysprod_version: sp_ver@140 { reg = <0x140 4>; };
+			sysprod_eeprom_version: sp_ee_ver@144 { reg = <0x144 4>; };
+			sysprod_product_area: sp_parea@148 { reg = <0x148 4>; };
+			sysprod_game_region: sp_region@14c { reg = <0x14C 4>; };
+			sysprod_ntsc_pal: sp_ntscpal@150 { reg = <0x150 4>; };
+			sysprod_5ghz_country: sp_5ghz_c@154 { reg = <0x154 2>; };
+			sysprod_5ghz_country_rev: sp_5ghz_crev@156 { reg = <0x156 2>; };
+			sysprod_code: sp_code@158 { reg = <0x158 8>; };
+			sysprod_serial: sp_serial@160 { reg = <0x160 16>; };
+			sysprod_model: sp_model@170 { reg = <0x170 16>; };
+
+			prod_year: pyear@188 { reg = <0x188 2>; };
+			prod_date: pdate@18a { reg = <0x18A 2>; };
+			prod_time: ptime@18c { reg = <0x18C 2>; };
+
+			boot_params: boot_params@1c0 { reg = <0x1C0 48>; };
+		};
+	};
+
+	/* TODO make this gpio-keyed once hollywood-gpio supports interrupts */
+	gpio-keys-polled {
+		poll-interval = <50>;
+		compatible = "gpio-keys-polled";
+
+		power {
+			label = "Power Button";
+			gpios = <&gpio 0 GPIO_ACTIVE_HIGH>;
+			linux,code = <KEY_POWER>;
+		};
+	};
+};
Signature · 1 line
2.36.1
#54 lore raw

Re: [PATCH v3 02/12] powerpc: wiiu: device tree

Quoted 7 lines · Ash Logan

Add a device tree source file for the Nintendo Wii U video game console.

Quoted 6 lines

---
v1->v2: Style and formatting changes suggested by Rob Herring.
License remains GPL-2.0 as the other powerpc dtses are the same, happy to change if there is a different preferred default.
v2->v3: Re-added address-cells accidentally removed in v2.
Marked latte as a simple-bus, since it is.

Thank you for your patch. There is something to discuss/improve.

Quoted 14 lines
 arch/powerpc/boot/dts/wiiu.dts | 326 +++++++++++++++++++++++++++++++++
 1 file changed, 326 insertions(+)
 create mode 100644 arch/powerpc/boot/dts/wiiu.dts
arch/powerpc/boot/dts/wiiu.dts new file +3 -0
new file mode 100644
index 000000000000..44a5a1469095
@@ -0,0 +1,326 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Nintendo Wii U Device Tree Source

arch/powerpc/boot/dts/wiiu.dts line 13

Quoted 10 lines
arch/powerpc/boot/dts/wiiu.dts new file +10 -0
+ *
+ * Copyright (C) 2022 The linux-wiiu Team
+ */
+
+/dts-v1/;
+#include <dt-bindings/gpio/gpio.h>
+#include <dt-bindings/input/input.h>
+
+/ {
+	model = "nintendo,wiiu";

It's not compatible, but user-visible string, e.g. "Nintendo Wii U"

arch/powerpc/boot/dts/wiiu.dts line 20

Quoted 7 lines
arch/powerpc/boot/dts/wiiu.dts new file +7 -0
+	compatible = "nintendo,wiiu";
+
+	#address-cells = <1>;
+	#size-cells = <1>;
+
+	chosen {
+		bootargs = "root=/dev/sda1 rootwait";

This does not belong to shared DTS. No bootargs.

Quoted 5 lines
arch/powerpc/boot/dts/wiiu.dts new file +5 -0
+	};
+
+	memory {
+		device_type = "memory";
+		reg = <0x00000000 0x02000000	/* MEM1 - 32MiB */

arch/powerpc/boot/dts/wiiu.dts line 35

Quoted 10 lines
arch/powerpc/boot/dts/wiiu.dts new file +10 -0
+		       0x08000000 0x00300000	/* MEM0 - 3MiB  */
+		       0x10000000 0x80000000>;	/* MEM2 - 2GiB  */
+	};
+
+	cpus {
+		#address-cells = <1>;
+		#size-cells = <0>;
+
+		/* TODO: Add SMP */
+		PowerPC,espresso@0 {

Node name should be generic, so "cpu". Unless something needs the specific node name?

Quoted 17 lines
arch/powerpc/boot/dts/wiiu.dts new file +17 -0
+			device_type = "cpu";
+			reg = <0>;
+			clock-frequency = <1243125000>;		/* 1.243125GHz */
+			bus-frequency = <248625000>;		/* 248.625MHz core-to-bus 5x */
+			timebase-frequency = <62156250>;	/* 1/4 of the bus clock */
+			i-cache-size = <32768>; /* 32K icache */
+			i-cache-line-size = <32>;
+			i-cache-block-size = <32>;
+			i-cache-sets = <128>;
+			d-cache-size = <32768>; /* 32K dcache */
+			d-cache-line-size = <32>;
+			d-cache-block-size = <32>;
+			d-cache-sets = <128>;
+			next-level-cache = <&L2_0>;
+			L2_0:l2-cache {
+				compatible = "cache";
+				cache-level = <2>;

arch/powerpc/boot/dts/wiiu.dts line 62

Quoted 10 lines
arch/powerpc/boot/dts/wiiu.dts new file +10 -0
+				cache-unified;
+				cache-size = <0x80000>; /* 512KB L2 */
+				cache-line-size = <64>;
+				cache-block-size = <32>;
+				cache-sets = <2048>;
+			};
+		};
+	};
+
+	latte {

Generic node names.

Quoted 5 lines
arch/powerpc/boot/dts/wiiu.dts new file +5 -0
+		#address-cells = <1>;
+		#size-cells = <1>;
+		compatible = "nintendo,latte", "simple-bus";
+		ranges = <0x0c000000 0x0c000000 0x00400000	/* Espresso-only registers */
+			  0x0d000000 0x0d000000 0x00200000	/* Latte AHB deivces */

arch/powerpc/boot/dts/wiiu.dts line 77

Quoted 10 lines
arch/powerpc/boot/dts/wiiu.dts new file +10 -0
+			  0x0d800000 0x0d800000 0x00800000>;	/* Latte SoC registers */
+
+		latte_gpu: gpu@c200000 {
+			compatible = "nintendo,latte-gpu7";
+			reg = <0x0c200000 0x80000>;
+			interrupts = <2>;
+			interrupt-parent = <&espresso_pic>;
+		};
+
+		espresso_pic: pic@c000078 {

interrupt-controller

Quoted 63 lines
arch/powerpc/boot/dts/wiiu.dts new file +63 -0
+			#interrupt-cells = <1>;
+			interrupt-controller;
+
+			compatible = "nintendo,espresso-pic";
+			reg = <0x0c000078 0x18>;
+		};
+
+		latte_dsp: dsp@c005000 {
+			compatible = "nintendo,latte-dsp";
+			reg = <0x0c005000 0x200>;
+		};
+
+		ehci_0: usb@d040000 {
+			compatible = "nintendo,latte-usb-ehci", "usb-ehci";
+			reg = <0x0d040000 0x100>;
+			interrupts = <4>;
+			interrupt-parent = <&latte_pic>;
+			big-endian-regs;
+		};
+
+		ohci_0_0: usb@d050000 {
+			compatible = "nintendo,latte-usb-ohci";
+			reg = <0x0d050000 0x100>;
+			interrupts = <5>;
+			interrupt-parent = <&latte_pic>;
+
+			big-endian-regs;
+		};
+
+		ohci_0_1: usb@d060000 {
+			compatible = "nintendo,latte-usb-ohci";
+			reg = <0x0d060000 0x100>;
+			interrupts = <6>;
+			interrupt-parent = <&latte_pic>;
+
+			big-endian-regs;
+		};
+
+		ehci_1: usb@d120000 {
+			compatible = "nintendo,latte-usb-ehci", "usb-ehci";
+			reg = <0x0d120000 0x100>;
+			interrupts = <16>;
+			interrupt-parent = <&latte_pic>;
+			big-endian-regs;
+		};
+
+		ohci_1_0: usb@d130000 {
+			compatible = "nintendo,latte-usb-ohci";
+			reg = <0x0d130000 0x100>;
+			interrupts = <35>;
+			interrupt-parent = <&latte_pic>;
+
+			big-endian-regs;
+		};
+
+		ehci_2: usb@d140000 {
+			compatible = "nintendo,latte-usb-ehci", "usb-ehci";
+			reg = <0x0d140000 0x100>;
+			interrupts = <36>;
+			interrupt-parent = <&latte_pic>;
+			big-endian-regs;
+		};
+

arch/powerpc/boot/dts/wiiu.dts line 150

Quoted 10 lines
arch/powerpc/boot/dts/wiiu.dts new file +10 -0
+		ohci_2_0: usb@d150000 {
+			compatible = "nintendo,latte-usb-ohci";
+			reg = <0x0d150000 0x100>;
+			interrupts = <37>;
+			interrupt-parent = <&latte_pic>;
+
+			big-endian-regs;
+		};
+
+		sdcard_0: sdhci@d070000 {

mmc

arch/powerpc/boot/dts/wiiu.dts line 157

Quoted 7 lines
arch/powerpc/boot/dts/wiiu.dts new file +7 -0
+			compatible = "nintendo,latte-sdhci","sdhci";
+			reg = <0x0d070000 0x200>;
+			interrupts = <7>;
+			interrupt-parent = <&latte_pic>;
+		};
+
+		wifi_0: sdhci@d080000 {

mmc

Quoted 17 lines
arch/powerpc/boot/dts/wiiu.dts new file +17 -0
+			compatible = "nintendo,latte-sdhci","sdhci";
+			reg = <0x0d080000 0x200>;
+			interrupts = <8>;
+			interrupt-parent = <&latte_pic>;
+		};
+
+		legacy_ipc: ipc@d800000 {
+			compatible = "nintendo,latte-ipc", "nintendo,hollywood-ipc";
+			reg = <0x0d800000 0x10>;
+			interrupts = <30 31>;
+			interrupt-parent = <&latte_pic>;
+		};
+
+		latte_otp: otp@d8001ec {
+			compatible = "nintendo,latte-otp";
+			reg = <0x0d8001ec 0x8>;
+		};

arch/powerpc/boot/dts/wiiu.dts line 184

Quoted 10 lines
arch/powerpc/boot/dts/wiiu.dts new file +10 -0
+
+		sata: ahci@d160400 {
+			compatible = "nintendo,latte-ahci";
+			reg = <0x0d160400 0x808>;
+
+			interrupt-parent = <&latte_pic>;
+			interrupts = <38 28>;
+		};
+
+		latte_pic: pic@d800440 {

interrupt-controller

Quoted 122 lines
arch/powerpc/boot/dts/wiiu.dts new file +122 -0
+			#interrupt-cells = <1>;
+			interrupt-controller;
+
+			compatible = "nintendo,latte-pic";
+			reg = <0x0d800440 0x30>;
+			interrupt-parent = <&espresso_pic>;
+			interrupts = <24>;
+		};
+
+		gpio: gpio@d8000c0 {
+			#gpio-cells = <2>;
+			compatible = "nintendo,latte-gpio", "nintendo,hollywood-gpio";
+
+			reg = <0x0d8000c0 0x40>;
+			gpio-controller;
+			/* TODO: There are actually 31 AHBALL GPIOs */
+			ngpios = <24>;
+
+			gpio-line-names =
+				"POWER", "DWIFI", "FAN", "DC_DC",
+				"", "Esp10WorkAround", "", "",
+				"PADPD", "", "EEP_CS", "EEP_CLK",
+				"EEP_MOSI", "EEP_MISO", "AVE_SCL", "AVE_SDA",
+				"DEBUG0", "DEBUG1", "DEBUG2", "DEBUG3",
+				"DEBUG4", "DEBUG5", "DEBUG6", "DEBUG7";
+
+			interrupt-controller;
+			#interrupt-cells = <2>;
+			interrupts = <10>;
+			interrupt-parent = <&latte_pic>;
+		};
+
+		gpio2: gpio@d800520 {
+			#gpio-cells = <2>;
+			compatible = "nintendo,latte-gpio", "nintendo,hollywood-gpio";
+
+			reg = <0x0d800520 0x40>;
+			gpio-controller;
+			ngpios = <7>;
+
+			gpio-line-names =
+				"FANSPEED", "SMC_SCL", "SMC_SDA", "DC_DC2",
+				"AVE_INT", "", "AVE_RESET";
+
+			interrupt-controller;
+			#interrupt-cells = <2>;
+			interrupts = <10>;
+			interrupt-parent = <&latte_pic>;
+		};
+	};
+
+	spi_gpio: spi-gpio {
+		compatible = "spi-gpio";
+		#address-cells = <1>;
+		#size-cells = <0>;
+
+		cs-gpios = <&gpio 10 GPIO_ACTIVE_HIGH>;
+		gpio-sck = <&gpio 11 GPIO_ACTIVE_HIGH>;
+		gpio-mosi = <&gpio 12 GPIO_ACTIVE_HIGH>;
+		gpio-miso = <&gpio 13 GPIO_ACTIVE_HIGH>;
+		num-chipselects = <1>;
+
+		eeprom@0 {
+			compatible = "atmel,at93c66";
+			reg = <0>;
+			spi-max-frequency = <1000000>;
+			spi-cs-high;
+			/* TODO: wiiubrew says this is 16-bit, but I only get the correct
+			 * values in 8-bit...
+			 */
+			data-size = <8>;
+			read-only;
+
+			#address-cells = <1>;
+			#size-cells = <1>;
+
+			/* https://wiiubrew.org/wiki/Hardware/SEEPROM */
+			rng_seed: rng@12 { reg = <0x012 8>; };
+			ppc_pvr: pvr@20 { reg = <0x020 4>; };
+			seeprom_ver_str: sver-str@24 { reg = <0x024 6>; };
+			seeprom_ver: sver@2a { reg = <0x02A 2>; };
+			otp_ver: over@2c { reg = <0x02C 2>; };
+			otp_rev: orev@2e { reg = <0x02E 2>; };
+			otp_ver_str: over-str@30 { reg = <0x030 8>; };
+
+			bc_crc: bc-crc@38 { reg = <0x038 4>; };
+			bc_sz: bc-sz@3c { reg = <0x03C 2>; };
+			bc_ver: bc-ver@3e { reg = <0x03E 2>; };
+			bc_boardtype: boardtype@42 { reg = <0x042 2>; };
+			bc_boardrev: boardrev@44 { reg = <0x044 2>; };
+			bc_bootsource: bootsource@46 { reg = <0x046 2>; };
+			bc_ddr3size: ddr3size@48 { reg = <0x048 2>; };
+			bc_ddr3speed: ddr3speed@4a { reg = <0x04A 2>; };
+			bc_ppcclockmul: ppcclockmul@4c { reg = <0x04C 2>; };
+			bc_iopclockmul: iopclockmul@46 { reg = <0x04E 2>; };
+			bc_video1080p: video1080p@50 { reg = <0x050 2>; };
+			bc_ddr3vendor: ddr3vendor@52 { reg = <0x052 2>; };
+			bc_movpassivereset: movpassivereset@54 { reg = <0x054 2>; };
+			bc_syspllspd: syspllspd@56 { reg = <0x056 2>; };
+			bc_satadevice: satadevice@58 { reg = <0x058 2>; };
+			bc_consoletype: consoletype@5a { reg = <0x05A 2>; };
+			bc_deviceprescence: deviceprescence@5c { reg = <0x05C 2>; };
+
+			drive_key: drvkey@80 { reg = <0x080 16>; };
+			factory_key: fackey@90 { reg = <0x090 16>; };
+			shdd_key: shddkey@a0 { reg = <0x0A0 16>; };
+			usb_key_seed: usbkeyseed@b0 { reg = <0x0B0 16>; };
+			drive_key_flag: drvkeyf@c0 { reg = <0x0C0 2>; };
+			usb_key_flag: udbkeyf@c2 { reg = <0x0C2 2>; };
+			shdd_key_flag: shddkeyf@c4 { reg = <0x0C4 2>; };
+
+			sysprod_version: sp_ver@140 { reg = <0x140 4>; };
+			sysprod_eeprom_version: sp_ee_ver@144 { reg = <0x144 4>; };
+			sysprod_product_area: sp_parea@148 { reg = <0x148 4>; };
+			sysprod_game_region: sp_region@14c { reg = <0x14C 4>; };
+			sysprod_ntsc_pal: sp_ntscpal@150 { reg = <0x150 4>; };
+			sysprod_5ghz_country: sp_5ghz_c@154 { reg = <0x154 2>; };
+			sysprod_5ghz_country_rev: sp_5ghz_crev@156 { reg = <0x156 2>; };
+			sysprod_code: sp_code@158 { reg = <0x158 8>; };
+			sysprod_serial: sp_serial@160 { reg = <0x160 16>; };
+			sysprod_model: sp_model@170 { reg = <0x170 16>; };
+

arch/powerpc/boot/dts/wiiu.dts line 316

Quoted 10 lines
arch/powerpc/boot/dts/wiiu.dts new file +10 -0
+			prod_year: pyear@188 { reg = <0x188 2>; };
+			prod_date: pdate@18a { reg = <0x18A 2>; };
+			prod_time: ptime@18c { reg = <0x18C 2>; };
+
+			boot_params: boot_params@1c0 { reg = <0x1C0 48>; };
+		};
+	};
+
+	/* TODO make this gpio-keyed once hollywood-gpio supports interrupts */
+	gpio-keys-polled {

gpio-keys

arch/powerpc/boot/dts/wiiu.dts line 320

Quoted 4 lines
arch/powerpc/boot/dts/wiiu.dts new file +4 -0
+		poll-interval = <50>;
+		compatible = "gpio-keys-polled";
+
+		power {

key-power
(will be enforced by schema)

arch/powerpc/boot/dts/wiiu.dts line 326

Quoted 6 lines
arch/powerpc/boot/dts/wiiu.dts new file +6 -0
+			label = "Power Button";
+			gpios = <&gpio 0 GPIO_ACTIVE_HIGH>;
+			linux,code = <KEY_POWER>;
+		};
+	};
+};

Best regards,
Krzysztof

#55 lore raw

Re: [PATCH v3 02/12] powerpc: wiiu: device tree

Quoted 4 lines · Krzysztof Kozlowski

arch/powerpc/boot/dts/wiiu.dts line 13

Quoted 1 line · Ash Logan
arch/powerpc/boot/dts/wiiu.dts new file +1 -0
+	model = "nintendo,wiiu";

It's not compatible, but user-visible string, e.g. "Nintendo Wii U"

The "model" property in OF is documented as:

---
“model” S
Standard property name to define a manufacturer’s model number.

prop-encoded-array:
Text string, encoded with encode-string.
A manufacturer-dependent string that generally specifies the model name and number (including revision level) for this device. The format of the text string is arbitrary, although in conventional usage the string begins with the name of the device’s manufacturer as with the “name” property.
Although there is no standard interpretation for the value of the “model” property, a specific device driver might use it to learn, for instance, the revision level of its particular device.

See also: property, model.

Used as: " XYZCO,1416-02" encode-string " model" property
---

Quoted 9 lines

arch/powerpc/boot/dts/wiiu.dts line 35

Quoted 6 lines
arch/powerpc/boot/dts/wiiu.dts new file +6 -0
+	cpus {
+		#address-cells = <1>;
+		#size-cells = <0>;
+
+		/* TODO: Add SMP */
+		PowerPC,espresso@0 {

Node name should be generic, so "cpu". Unless something needs the specific node name?

This is how most other PowerPC firmwares do it. The PowerPC processor binding is older than the generic naming practice, so CPU nodes have device_type "cpu" instead. This is a required property btw, with that value. (There is no requirement on the names of the CPU nodes).

There is no added value in generic naming for CPU nodes anyway, since you just find them as the children of the "/cpus" node :-)

Segher

#56 lore raw

Re: [PATCH v3 02/12] powerpc: wiiu: device tree

Quoted 23 lines · Segher Boessenkool
Quoted 4 lines · Krzysztof Kozlowski

arch/powerpc/boot/dts/wiiu.dts line 13

Quoted 1 line · Ash Logan
arch/powerpc/boot/dts/wiiu.dts new file +1 -0
+	model = "nintendo,wiiu";

It's not compatible, but user-visible string, e.g. "Nintendo Wii U"

The "model" property in OF is documented as:

---
“model” S
Standard property name to define a manufacturer’s model number.

prop-encoded-array:
Text string, encoded with encode-string.
A manufacturer-dependent string that generally specifies the model name and number (including revision level) for this device. The format of the text string is arbitrary, although in conventional usage the string begins with the name of the device’s manufacturer as with the “name” property.
Although there is no standard interpretation for the value of the “model” property, a specific device driver might use it to learn, for instance, the revision level of its particular device.

Quoted 3 lines

See also: property, model.

Used as: " XYZCO,1416-02" encode-string " model" property

Hm, surprising to duplicate the compatible, but OK.

Quoted 12 lines

---

Quoted 9 lines

arch/powerpc/boot/dts/wiiu.dts line 35

Quoted 6 lines
arch/powerpc/boot/dts/wiiu.dts new file +6 -0
+	cpus {
+		#address-cells = <1>;
+		#size-cells = <0>;
+
+		/* TODO: Add SMP */
+		PowerPC,espresso@0 {

Node name should be generic, so "cpu". Unless something needs the specific node name?

Quoted 3 lines

This is how most other PowerPC firmwares do it. The PowerPC processor binding is older than the generic naming practice, so CPU nodes have device_type "cpu" instead.

ePAPR 1.0 from 2008 explicitly asks for generic node names. So 4 years before Nintento Wii U. Maybe earlier ePAPR-s were also asking for this, no clue, don't have them.

Quoted 2 lines

This is a required property btw, with that
value. (There is no requirement on the names of the CPU nodes).

That's fine, I am not talking about property.

Quoted 2 lines

There is no added value in generic naming for CPU nodes anyway, since you just find them as the children of the "/cpus" node :-)

There is because you might have there caches. It also makes code easier to read.

Best regards,
Krzysztof

#57 lore raw

Re: [PATCH v3 02/12] powerpc: wiiu: device tree

Quoted 8 lines · Krzysztof Kozlowski
Quoted 7 lines · Segher Boessenkool
Quoted 5 lines · Krzysztof Kozlowski

arch/powerpc/boot/dts/wiiu.dts line 35

Quoted 2 lines
arch/powerpc/boot/dts/wiiu.dts new file +2 -0
+		/* TODO: Add SMP */
+		PowerPC,espresso@0 {

Node name should be generic, so "cpu". Unless something needs the specific node name?

Quoted 7 lines
Quoted 3 lines

This is how most other PowerPC firmwares do it. The PowerPC processor binding is older than the generic naming practice, so CPU nodes have device_type "cpu" instead.

ePAPR 1.0 from 2008 explicitly asks for generic node names. So 4 years before Nintento Wii U. Maybe earlier ePAPR-s were also asking for this, no clue, don't have them.

The majority of PowerPC 750 systems long predate that. Many *current* systems implement the PowerPC Processor Binding, too (not the epapr thing, which is incompatible with the older standards!)

Quoted 5 lines
Quoted 2 lines

There is no added value in generic naming for CPU nodes anyway, since you just find them as the children of the "/cpus" node :-)

There is because you might have there caches. It also makes code easier to read.

In the processor binding the cache nodes were subnodes of cpu nodes or other cache nodes. But in some server products you can have cache that is enabled while the corresponding core is disabled; and also, not all cache belongs to only one higher level anyway. This was modelled pretty uncleanly, yup (cleaner would have been to have a /caches node as well as /cpus, for example).

But on 750 you just have "l2-cache" subnodes, and all nodes in /cpus are CPUs :-)

Segher

author
#58 lore raw

PATCH v3 3/12 powerpc: wiiu: bootwrapper support

In reply to Ash Logan

Add support for the Nintendo Wii U game console to the powerpc bootwrapper.

---
 arch/powerpc/boot/Makefile    |   4 ++
 arch/powerpc/boot/wiiu-head.S | 103 ++++++++++++++++++++++++++++++++++
 arch/powerpc/boot/wiiu.c      |  73 ++++++++++++++++++++++++
 arch/powerpc/boot/wrapper     |   4 ++
 4 files changed, 184 insertions(+)
 create mode 100644 arch/powerpc/boot/wiiu-head.S
 create mode 100644 arch/powerpc/boot/wiiu.c
arch/powerpc/boot/Makefile +4 -0
index a9cd2ea4a861..6694f578c447 100644
@@ -161,6 +161,7 @@ src-plat-$(CONFIG_EMBEDDED6xx) += cuboot-pq2.c cuboot-mpc7448hpc2.c \
 					gamecube-head.S gamecube.c \
 					wii-head.S wii.c holly.c \
 					fixed-head.S mvme5100.c
+src-plat-$(CONFIG_WIIU) += wiiu-head.S wiiu.c
 src-plat-$(CONFIG_AMIGAONE) += cuboot-amigaone.c
 src-plat-$(CONFIG_PPC_PS3) += ps3-head.S ps3-hvcall.S ps3.c
 src-plat-$(CONFIG_EPAPR_BOOT) += epapr.c epapr-wrapper.c
@@ -359,6 +360,9 @@ image-$(CONFIG_GAMECUBE)		+= dtbImage.gamecube
 image-$(CONFIG_WII)			+= dtbImage.wii
 image-$(CONFIG_MVME5100)		+= dtbImage.mvme5100
 
+# Board port in arch/powerpc/platform/wiiu/Kconfig
+image-$(CONFIG_WIIU)			+= dtbImage.wiiu
+
 # Board port in arch/powerpc/platform/amigaone/Kconfig
 image-$(CONFIG_AMIGAONE)		+= cuImage.amigaone
 
arch/powerpc/boot/wiiu-head.S new file +103 -0

103 lines not on this page · raw message

arch/powerpc/boot/wiiu.c new file +73 -0

73 lines not on this page · raw message

arch/powerpc/boot/wrapper +4 -0
index 55978f32fa77..83b74ffaae2b 100755
@@ -344,6 +344,10 @@ gamecube|wii)
     link_address='0x600000'
     platformo="$object/$platform-head.o $object/$platform.o"
     ;;
+wiiu)
+    link_address='0x600000'
+    platformo="$object/wiiu-head.o $object/$platform.o"
+    ;;
 microwatt)
     link_address='0x500000'
     platformo="$object/fixed-head.o $object/$platform.o"
Signature · 1 line
2.36.1
author
#59 lore raw

PATCH v3 4/12 powerpc: wiiu: introduce wiiu platform

In reply to Ash Logan

Adds empty platforms/wiiu for Nintendo Wii U console

---
v2->v3: Add help text for CONFIG_WIIU.

 arch/powerpc/platforms/Kconfig       | 1 +
 arch/powerpc/platforms/Makefile      | 1 +
 arch/powerpc/platforms/wiiu/Kconfig  | 8 ++++++++
 arch/powerpc/platforms/wiiu/Makefile | 1 +
 4 files changed, 11 insertions(+)
 create mode 100644 arch/powerpc/platforms/wiiu/Kconfig
 create mode 100644 arch/powerpc/platforms/wiiu/Makefile
arch/powerpc/platforms/Kconfig +1 -0
index d41dad227de8..c4a9c3c0b409 100644
@@ -22,6 +22,7 @@ source "arch/powerpc/platforms/40x/Kconfig"
 source "arch/powerpc/platforms/amigaone/Kconfig"
 source "arch/powerpc/platforms/book3s/Kconfig"
 source "arch/powerpc/platforms/microwatt/Kconfig"
+source "arch/powerpc/platforms/wiiu/Kconfig"
 
 config KVM_GUEST
 	bool "KVM Guest support"
arch/powerpc/platforms/Makefile +1 -0
index 94470fb27c99..944ddd938711 100644
@@ -24,3 +24,4 @@ obj-$(CONFIG_EMBEDDED6xx)	+= embedded6xx/
 obj-$(CONFIG_AMIGAONE)		+= amigaone/
 obj-$(CONFIG_PPC_BOOK3S)	+= book3s/
 obj-$(CONFIG_PPC_MICROWATT)	+= microwatt/
+obj-$(CONFIG_WIIU)		+= wiiu/
arch/powerpc/platforms/wiiu/Kconfig new file +8 -0
new file mode 100644
index 000000000000..3834834c6bd7
@@ -0,0 +1,8 @@
+# SPDX-License-Identifier: GPL-2.0
+
+config WIIU
+	bool "Nintendo Wii U"
+	depends on PPC_BOOK3S_32
+	help
+	  Select WIIU if configuring for the Nintendo Wii U.
+	  More information at: <https://linux-wiiu.org/>
arch/powerpc/platforms/wiiu/Makefile new file +1 -0
new file mode 100644
index 000000000000..f66554cd5c45
@@ -0,0 +1 @@
+# SPDX-License-Identifier: GPL-2.0
Signature · 1 line
2.36.1
author
#60 lore raw

PATCH v3 5/12 powerpc: wiiu: declare as non-coherent

In reply to Ash Logan

The Nintendo Wii U requires explicit cache handling when interfacing with DMA devices.

---
 arch/powerpc/platforms/Kconfig.cputype | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/powerpc/platforms/Kconfig.cputype +1 -1
index 9e2df4b66478..20eef6595a60 100644
@@ -501,7 +501,7 @@ config NR_CPUS
 config NOT_COHERENT_CACHE
 	bool
 	depends on 4xx || PPC_8xx || PPC_MPC512x || \
-		GAMECUBE_COMMON || AMIGAONE
+		GAMECUBE_COMMON || AMIGAONE || WIIU
 	select ARCH_HAS_DMA_PREP_COHERENT
 	select ARCH_HAS_SYNC_DMA_FOR_DEVICE
 	select ARCH_HAS_SYNC_DMA_FOR_CPU
Signature · 1 line
2.36.1
author
#61 lore raw

PATCH v3 6/12 powerpc: wiiu: udbg support for latteipc

In reply to Ash Logan

Add support for using the Latte chipset IPC for udbg on the Nintendo Wii U console.
These messages can then be received by a special firmware running on the "Starbuck" coprocessor.

---
v2->v3: Fix a missing declaration issue by including latteipc_udbg.h.

 arch/powerpc/Kconfig.debug                  |   9 ++
 arch/powerpc/include/asm/udbg.h             |   1 +
 arch/powerpc/kernel/head_book3s_32.S        |  20 ++++
 arch/powerpc/kernel/udbg.c                  |   3 +
 arch/powerpc/platforms/wiiu/Kconfig         |  13 ++
 arch/powerpc/platforms/wiiu/Makefile        |   2 +
 arch/powerpc/platforms/wiiu/udbg_latteipc.c | 124 ++++++++++++++++++++
 arch/powerpc/platforms/wiiu/udbg_latteipc.h |  27 +++++
 8 files changed, 199 insertions(+)
 create mode 100644 arch/powerpc/platforms/wiiu/udbg_latteipc.c
 create mode 100644 arch/powerpc/platforms/wiiu/udbg_latteipc.h
arch/powerpc/Kconfig.debug +9 -0
index 9f363c143d86..cee97d21f5fb 100644
@@ -254,6 +254,15 @@ config PPC_EARLY_DEBUG_USBGECKO
 	  Select this to enable early debugging for Nintendo GameCube/Wii
 	  consoles via an external USB Gecko adapter.
 
+config PPC_EARLY_DEBUG_LATTEIPC
+	bool "Early debugging through Latte chipset IPC"
+	depends on WIIU
+	select LATTEIPC_UDBG
+	help
+	  Select this to enable early debugging for Nintendo Wii U consoles via
+	  chipset IPC to the security coprocessor. This assumes a firmware is
+	  running on the coprocessor to receive messages.
+
 config PPC_EARLY_DEBUG_PS3GELIC
 	bool "Early debugging through the PS3 Ethernet port"
 	depends on PPC_PS3
arch/powerpc/include/asm/udbg.h +1 -0
index b4aa0d88ce2c..266b0e744ddc 100644
@@ -53,6 +53,7 @@ extern void __init udbg_init_ehv_bc(void);
 extern void __init udbg_init_ps3gelic(void);
 extern void __init udbg_init_debug_opal_raw(void);
 extern void __init udbg_init_debug_opal_hvsi(void);
+extern void __init udbg_init_latteipc(void);
 
 #endif /* __KERNEL__ */
 #endif /* _ASM_POWERPC_UDBG_H */
arch/powerpc/kernel/head_book3s_32.S +20 -0
index 6c739beb938c..48d487efb25c 100644
@@ -164,6 +164,9 @@ __after_mmu_off:
 #ifdef CONFIG_PPC_EARLY_DEBUG_USBGECKO
 	bl	setup_usbgecko_bat
 #endif
+#ifdef CONFIG_PPC_EARLY_DEBUG_LATTEIPC
+	bl	setup_latteipc_bat
+#endif
 
 /*
  * Call setup_cpu for CPU 0 and initialize 6xx Idle
@@ -1201,4 +1204,21 @@ setup_usbgecko_bat:
 	blr
 #endif
 
+#ifdef CONFIG_PPC_EARLY_DEBUG_LATTEIPC
+setup_latteipc_bat:
+	/* prepare a BAT for early io */
+	lis	r8, 0x0d80
+
+	/*
+	 * The virtual address used must match the virtual address
+	 * associated to the fixmap entry FIX_EARLY_DEBUG_BASE.
+	 */
+	lis	r11, 0xfffe	/* top 128K */
+	ori	r8, r8, 0x002a	/* uncached, guarded ,rw */
+	ori	r11, r11, 0x2	/* 128K, Vs=1, Vp=0 */
+	mtspr	SPRN_DBAT1L, r8
+	mtspr	SPRN_DBAT1U, r11
+	blr
+#endif
+
 	.data
arch/powerpc/kernel/udbg.c +3 -0
index b1544b2f6321..84eae25c195e 100644
@@ -67,6 +67,9 @@ void __init udbg_early_init(void)
 	udbg_init_debug_opal_raw();
 #elif defined(CONFIG_PPC_EARLY_DEBUG_OPAL_HVSI)
 	udbg_init_debug_opal_hvsi();
+#elif defined(CONFIG_PPC_EARLY_DEBUG_LATTEIPC)
+	/* For use on Nintendo Wii U */
+	udbg_init_latteipc();
 #endif
 
 #ifdef CONFIG_PPC_EARLY_DEBUG
arch/powerpc/platforms/wiiu/Kconfig +13 -0
index 3834834c6bd7..8dfd6ac8774d 100644
@@ -6,3 +6,16 @@ config WIIU
 	help
 	  Select WIIU if configuring for the Nintendo Wii U.
 	  More information at: <https://linux-wiiu.org/>
+
+config LATTEIPC_UDBG
+	bool "Chipset IPC udbg console for the Nintendo Wii U"
+	depends on WIIU
+	help
+	  If you say yes to this option, support will be included for the
+	  Wii U's chipset IPC as a udbg console.
+	  These IPC messages can be received by a firmware running on the
+	  console's "Starbuck" security coprocessor.
+
+	  This driver bypasses the IPC layer completely.
+
+	  If in doubt, say N here.
arch/powerpc/platforms/wiiu/Makefile +2 -0
index f66554cd5c45..b1e0e1307f6e 100644
@@ -1 +1,3 @@
 # SPDX-License-Identifier: GPL-2.0
+
+obj-$(CONFIG_LATTEIPC_UDBG) += udbg_latteipc.o
arch/powerpc/platforms/wiiu/udbg_latteipc.c new file +124 -0

124 lines not on this page · raw message

arch/powerpc/platforms/wiiu/udbg_latteipc.h new file +27 -0
new file mode 100644
index 000000000000..ca6d34e49158
@@ -0,0 +1,27 @@
+/* SPDX-License-Identifier: GPL-2.0-or-later */
+/*
+ * Nintendo Wii U udbg support (to Starbuck coprocessor, via chipset IPC)
+ *
+ * Copyright (C) 2022 The linux-wiiu Team
+ *
+ * Based on arch/powerpc/platforms/embedded6xx/udbgecko_udbg.h
+ * Copyright (C) 2008-2009 The GameCube Linux Team
+ * Copyright (C) 2008-2009 Albert Herranz
+ */
+
+#ifndef __LATTEIPC_UDBG_H
+#define __LATTEIPC_UDBG_H
+
+#ifdef CONFIG_LATTEIPC_UDBG
+
+void __init latteipc_udbg_init(void);
+
+#else
+
+static inline void __init latteipc_udbg_init(void)
+{
+}
+
+#endif /* CONFIG_LATTEIPC_UDBG */
+
+#endif /* __LATTEIPC_UDBG_H */
Signature · 1 line
2.36.1
author
#62 lore raw

PATCH v3 7/12 powerpc: wiiu: espresso interrupt controller support

In reply to Ash Logan

Add support for the "Espresso" interrupt controller in the Nintendo Wii U.

---
 arch/powerpc/platforms/wiiu/Makefile       |   1 +
 arch/powerpc/platforms/wiiu/espresso-pic.c | 183 +++++++++++++++++++++
 arch/powerpc/platforms/wiiu/espresso-pic.h |  59 +++++++
 3 files changed, 243 insertions(+)
 create mode 100644 arch/powerpc/platforms/wiiu/espresso-pic.c
 create mode 100644 arch/powerpc/platforms/wiiu/espresso-pic.h
arch/powerpc/platforms/wiiu/Makefile +1 -0
index b1e0e1307f6e..aabf4b43e806 100644
@@ -1,3 +1,4 @@
 # SPDX-License-Identifier: GPL-2.0
 
+obj-$(CONFIG_WIIU) += espresso-pic.o
 obj-$(CONFIG_LATTEIPC_UDBG) += udbg_latteipc.o
arch/powerpc/platforms/wiiu/espresso-pic.c new file +183 -0

183 lines not on this page · raw message

arch/powerpc/platforms/wiiu/espresso-pic.h new file +59 -0

59 lines not on this page · raw message

Signature · 1 line
2.36.1
author
#63 lore raw

PATCH v3 8/12 powerpc: wiiu: latte interrupt controller support

In reply to Ash Logan

Add support for the "Latte" interrupt controller in the Nintendo Wii U. This controller is used for the entire SoC and is wired to a cascade interrupt on the Espresso controller.

---
v2->v3: Make latte_pic_get_irq static.

 arch/powerpc/platforms/wiiu/Kconfig     |   1 +
 arch/powerpc/platforms/wiiu/Makefile    |   2 +-
 arch/powerpc/platforms/wiiu/latte-pic.c | 259 ++++++++++++++++++++++++
 arch/powerpc/platforms/wiiu/latte-pic.h |  23 +++
 4 files changed, 284 insertions(+), 1 deletion(-)
 create mode 100644 arch/powerpc/platforms/wiiu/latte-pic.c
 create mode 100644 arch/powerpc/platforms/wiiu/latte-pic.h
arch/powerpc/platforms/wiiu/Kconfig +1 -0
index 8dfd6ac8774d..40ecba8396a7 100644
@@ -3,6 +3,7 @@
 config WIIU
 	bool "Nintendo Wii U"
 	depends on PPC_BOOK3S_32
+	select IRQ_DOMAIN_HIERARCHY
 	help
 	  Select WIIU if configuring for the Nintendo Wii U.
 	  More information at: <https://linux-wiiu.org/>
arch/powerpc/platforms/wiiu/Makefile +1 -1
index aabf4b43e806..fa16c60261e6 100644
@@ -1,4 +1,4 @@
 # SPDX-License-Identifier: GPL-2.0
 
-obj-$(CONFIG_WIIU) += espresso-pic.o
+obj-$(CONFIG_WIIU) += espresso-pic.o latte-pic.o
 obj-$(CONFIG_LATTEIPC_UDBG) += udbg_latteipc.o
arch/powerpc/platforms/wiiu/latte-pic.c new file +259 -0

259 lines not on this page · raw message

arch/powerpc/platforms/wiiu/latte-pic.h new file +23 -0
new file mode 100644
index 000000000000..7021d9497d35
@@ -0,0 +1,23 @@
+/* SPDX-License-Identifier: GPL-2.0-or-later */
+/*
+ * Nintendo Wii U "Latte" interrupt controller support
+ *
+ * Copyright (C) 2022 The linux-wiiu Team
+ */
+
+#ifndef __LATTE_PIC_H
+#define __LATTE_PIC_H
+
+struct lt_pic {
+	__be32 ahball_icr;	/* Triggered AHB IRQs (all) */
+	__be32 ahblt_icr;	/* Triggered AHB IRQs (latte only) */
+	__be32 ahball_imr;	/* Allowed AHB IRQs (all) */
+	__be32 ahblt_imr;	/* Allowed AHB IRQs (latte only) */
+} __packed;
+
+#define LATTE_AHBALL_NR_IRQS    32
+#define LATTE_AHBLT_NR_IRQS     32
+
+void latte_pic_init(void);
+
+#endif
Signature · 1 line
2.36.1
author
#64 lore raw

PATCH v3 9/12 powerpc: espresso processor support

In reply to Ash Logan

Adds a cputable entry for the "Espresso" processor found on the Nintendo Wii U, which has a PVR unrelated to other 750CL-like chips. Only this revision has been seen in the wild.

---
 arch/powerpc/kernel/cputable.c | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)
arch/powerpc/kernel/cputable.c +16 -0
index a5dbfccd2047..3a4e84d1f674 100644
@@ -736,6 +736,22 @@ static struct cpu_spec __initdata cpu_specs[] = {
 		.platform		= "ppc750",
 		.oprofile_cpu_type      = "ppc/750",
 	},
+	{	/* "Espresso" (750CL-like) */
+		.pvr_mask		= 0xffffffff,
+		.pvr_value		= 0x70010201,
+		.cpu_name		= "Espresso",
+		.cpu_features		= CPU_FTRS_750CL,
+		.cpu_user_features	= COMMON_USER | PPC_FEATURE_PPC_LE,
+		.mmu_features		= MMU_FTR_HPTE_TABLE | MMU_FTR_USE_HIGH_BATS,
+		.icache_bsize		= 32,
+		.dcache_bsize		= 32,
+		.num_pmcs		= 4,
+		.pmc_type		= PPC_PMC_IBM,
+		.cpu_setup		= __setup_cpu_750,
+		.machine_check		= machine_check_generic,
+		.platform		= "ppc750",
+		.oprofile_cpu_type      = "ppc/750",
+	},
 	{	/* 745/755 */
 		.pvr_mask		= 0xfffff000,
 		.pvr_value		= 0x00083000,
Signature · 1 line
2.36.1
author
#65 lore raw

PATCH v3 10/12 powerpc: wiiu: platform support

In reply to Ash Logan

Add platform support for the Nintendo Wii U console.

---
v2->v3: Use of_platform_default_populate instead of a custom match table.

 arch/powerpc/platforms/wiiu/Makefile |  2 +-
 arch/powerpc/platforms/wiiu/setup.c  | 60 ++++++++++++++++++++++++++++
 2 files changed, 61 insertions(+), 1 deletion(-)
 create mode 100644 arch/powerpc/platforms/wiiu/setup.c
arch/powerpc/platforms/wiiu/Makefile +1 -1
index fa16c60261e6..abcb7a1beebf 100644
@@ -1,4 +1,4 @@
 # SPDX-License-Identifier: GPL-2.0
 
-obj-$(CONFIG_WIIU) += espresso-pic.o latte-pic.o
+obj-$(CONFIG_WIIU) += setup.o espresso-pic.o latte-pic.o
 obj-$(CONFIG_LATTEIPC_UDBG) += udbg_latteipc.o
arch/powerpc/platforms/wiiu/setup.c new file +60 -0

60 lines not on this page · raw message

Signature · 1 line
2.36.1
author
#66 lore raw

PATCH v3 11/12 powerpc: wiiu: don't enforce flat memory

In reply to Ash Logan

pgtable_32.c:mapin_ram loops over each valid memory range, which means non-contiguous memory just works.

---
 arch/powerpc/mm/init_32.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
arch/powerpc/mm/init_32.c +2 -2
index 693a3a7a9463..6cdb561c05c5 100644
@@ -124,10 +124,10 @@ void __init MMU_init(void)
 	 * lowmem_end_addr is initialized below.
 	 */
 	if (memblock.memory.cnt > 1) {
-#ifndef CONFIG_WII
+#if !defined(CONFIG_WII) && !defined(CONFIG_WIIU)
 		memblock_enforce_memory_limit(memblock.memory.regions[0].size);
 		pr_warn("Only using first contiguous memory region\n");
-#else
+#elif defined(CONFIG_WII)
 		wii_memory_fixups();
 #endif
 	}
Signature · 1 line
2.36.1
author
#67 lore raw

PATCH v3 12/12 powerpc: wiiu: add minimal default config

In reply to Ash Logan

Adds a bare-minimum config to get a kernel compiled. Will need some more interesting options once a storage device to boot from is added.

---
 arch/powerpc/configs/wiiu_defconfig | 7 +++++++
 1 file changed, 7 insertions(+)
 create mode 100644 arch/powerpc/configs/wiiu_defconfig
arch/powerpc/configs/wiiu_defconfig new file +7 -0
new file mode 100644
index 000000000000..a761ebcdd9f2
@@ -0,0 +1,7 @@
+# CONFIG_PPC_CHRP is not set
+# CONFIG_PPC_PMAC is not set
+CONFIG_WIIU=y
+# CONFIG_PPC_OF_BOOT_TRAMPOLINE is not set
+CONFIG_HIGHMEM=y
+CONFIG_STRICT_KERNEL_RWX=y
+CONFIG_PPC_EARLY_DEBUG=y
Signature · 1 line
2.36.1
#68 lore raw
In reply to Ash Logan

Hi,

Your series doesn't apply anymore, can you rebase ?

Thanks
Christophe

Le 28/06/2022 à 15:31, Ash Logan a écrit :

Quoted 111 lines

The following patches add basic support for the Nintendo Wii U video game console, a PowerPC system somewhat similar to the GameCube and Wii.

This includes:
- devicetree source
- bootwrapper support
- udbg console to bootloader
- early udbg console
- interrupt controllers
- platform support
- recognition of the Espresso processor
- workaround for the discontiguous RAM blocks

This is enough to boot on hardware. dmesg pics (with a small hack to udbg-immortal, not included):

For those who have hardware and would like to try these patches, some modification is required to the stock OS to allow Linux. For info:
https://wiki.linux-wiiu.org/wiki/AdvancedSetup

Some of the design choices (new platform > embedded6xx) were discussed previously:

Turns out even less changes were needed than previously anticipated for discontiguous memory, and KUAP is yet to give trouble. Thanks to those who helped and discussed this.

Changes since v2:
- Fixed some overzealous deleting in the devicetree, oops.
- Fixed missing declarations for some functions (thanks robots)
- Fixed some checkpatch warnings.
- Mark latte as a simple-bus and use of_platform_default_populate.
Changes since v1:
- Style and formatting tweaks to the devicetree, thanks Rob Herring for the review.

Ash Logan (12):
dt-bindings: wiiu: Document the Nintendo Wii U devicetree
powerpc: wiiu: device tree
powerpc: wiiu: bootwrapper support
powerpc: wiiu: introduce wiiu platform
powerpc: wiiu: declare as non-coherent
powerpc: wiiu: udbg support for latteipc
powerpc: wiiu: espresso interrupt controller support
powerpc: wiiu: latte interrupt controller support
powerpc: espresso processor support
powerpc: wiiu: platform support
powerpc: wiiu: don't enforce flat memory
powerpc: wiiu: add minimal default config

  .../bindings/powerpc/nintendo/wiiu.yaml       |  28 ++
  .../powerpc/nintendo/wiiu/espresso-pic.yaml   |  42 +++
  .../bindings/powerpc/nintendo/wiiu/gpu7.yaml  |  41 +++
  .../powerpc/nintendo/wiiu/latte-ahci.yaml     |  43 +++
  .../powerpc/nintendo/wiiu/latte-dsp.yaml      |  35 ++
  .../powerpc/nintendo/wiiu/latte-pic.yaml      |  46 +++
  .../powerpc/nintendo/wiiu/latte-sdhci.yaml    |  40 +++
  .../bindings/powerpc/nintendo/wiiu/latte.yaml |  25 ++
  arch/powerpc/Kconfig.debug                    |   9 +
  arch/powerpc/boot/Makefile                    |   4 +
  arch/powerpc/boot/dts/wiiu.dts                | 326 ++++++++++++++++++
  arch/powerpc/boot/wiiu-head.S                 | 103 ++++++
  arch/powerpc/boot/wiiu.c                      |  73 ++++
  arch/powerpc/boot/wrapper                     |   4 +
  arch/powerpc/configs/wiiu_defconfig           |   7 +
  arch/powerpc/include/asm/udbg.h               |   1 +
  arch/powerpc/kernel/cputable.c                |  16 +
  arch/powerpc/kernel/head_book3s_32.S          |  20 ++
  arch/powerpc/kernel/udbg.c                    |   3 +
  arch/powerpc/mm/init_32.c                     |   4 +-
  arch/powerpc/platforms/Kconfig                |   1 +
  arch/powerpc/platforms/Kconfig.cputype        |   2 +-
  arch/powerpc/platforms/Makefile               |   1 +
  arch/powerpc/platforms/wiiu/Kconfig           |  22 ++
  arch/powerpc/platforms/wiiu/Makefile          |   4 +
  arch/powerpc/platforms/wiiu/espresso-pic.c    | 183 ++++++++++
  arch/powerpc/platforms/wiiu/espresso-pic.h    |  59 ++++
  arch/powerpc/platforms/wiiu/latte-pic.c       | 259 ++++++++++++++
  arch/powerpc/platforms/wiiu/latte-pic.h       |  23 ++
  arch/powerpc/platforms/wiiu/setup.c           |  60 ++++
  arch/powerpc/platforms/wiiu/udbg_latteipc.c   | 124 +++++++
  arch/powerpc/platforms/wiiu/udbg_latteipc.h   |  27 ++
  32 files changed, 1632 insertions(+), 3 deletions(-)

create mode 100644 Documentation/devicetree/bindings/powerpc/nintendo/wiiu.yaml create mode 100644 Documentation/devicetree/bindings/powerpc/nintendo/wiiu/espresso-pic.yaml create mode 100644 Documentation/devicetree/bindings/powerpc/nintendo/wiiu/gpu7.yaml create mode 100644 Documentation/devicetree/bindings/powerpc/nintendo/wiiu/latte-ahci.yaml create mode 100644 Documentation/devicetree/bindings/powerpc/nintendo/wiiu/latte-dsp.yaml create mode 100644 Documentation/devicetree/bindings/powerpc/nintendo/wiiu/latte-pic.yaml create mode 100644 Documentation/devicetree/bindings/powerpc/nintendo/wiiu/latte-sdhci.yaml create mode 100644 Documentation/devicetree/bindings/powerpc/nintendo/wiiu/latte.yaml create mode 100644 arch/powerpc/boot/dts/wiiu.dts
create mode 100644 arch/powerpc/boot/wiiu-head.S
create mode 100644 arch/powerpc/boot/wiiu.c
create mode 100644 arch/powerpc/configs/wiiu_defconfig
create mode 100644 arch/powerpc/platforms/wiiu/Kconfig
create mode 100644 arch/powerpc/platforms/wiiu/Makefile
create mode 100644 arch/powerpc/platforms/wiiu/espresso-pic.c
create mode 100644 arch/powerpc/platforms/wiiu/espresso-pic.h
create mode 100644 arch/powerpc/platforms/wiiu/latte-pic.c
create mode 100644 arch/powerpc/platforms/wiiu/latte-pic.h
create mode 100644 arch/powerpc/platforms/wiiu/setup.c
create mode 100644 arch/powerpc/platforms/wiiu/udbg_latteipc.c
create mode 100644 arch/powerpc/platforms/wiiu/udbg_latteipc.h

base-commit: 03c765b0e3b4cb5063276b086c76f7a612856a9a

author
#69 lore raw

v4 cover powerpc: Nintendo Wii U support

In reply to Ash Logan

The following patches add basic support for the Nintendo Wii U video game console, a PowerPC system somewhat similar to the GameCube and Wii.

This includes:
- devicetree source
- bootwrapper support
- udbg console to bootloader
- early udbg console
- interrupt controllers
- platform support
- recognition of the Espresso processor

This is enough to boot on hardware. dmesg pics (with a small hack to udbg-immortal, not included):

For those who have hardware and would like to try these patches, some modification is required to the stock OS to allow Linux. For info:
https://wiki.linux-wiiu.org/wiki/AdvancedSetup

Some of the design choices (new platform > embedded6xx) were discussed previously:

Turns out even less changes were needed than previously anticipated for discontiguous memory, and KUAP is yet to give trouble. Thanks to those who helped and discussed this.

Changes since v3:
- Reworked devicetree bindings - thanks Krzysztof Kozlowski for the review.
- Update devicetree source to match.
- Fixes to ensure patches apply to current source.
Changes since v2:
- Fixed some overzealous deleting in the devicetree, oops.
- Fixed missing declarations for some functions (thanks robots)
- Fixed some checkpatch warnings.
- Mark latte as a simple-bus and use of_platform_default_populate.
Changes since v1:
- Style and formatting tweaks to the devicetree, thanks Rob Herring for the review.

Ash Logan (11):
dt-bindings: wiiu: Document the Nintendo Wii U devicetree
powerpc: wiiu: device tree
powerpc: wiiu: bootwrapper support
powerpc: wiiu: introduce wiiu platform
powerpc: wiiu: declare as non-coherent
powerpc: wiiu: udbg support for latteipc
powerpc: wiiu: espresso interrupt controller support
powerpc: wiiu: latte interrupt controller support
powerpc: espresso processor support
powerpc: wiiu: platform support
powerpc: wiiu: add minimal default config

 .../bindings/powerpc/nintendo/wiiu.yaml       |  25 ++
 .../powerpc/nintendo/wiiu/espresso-pic.yaml   |  48 +++
 .../bindings/powerpc/nintendo/wiiu/gpu7.yaml  |  42 +++
 .../powerpc/nintendo/wiiu/latte-ahci.yaml     |  50 +++
 .../powerpc/nintendo/wiiu/latte-dsp.yaml      |  35 ++
 .../powerpc/nintendo/wiiu/latte-pic.yaml      |  55 +++
 .../powerpc/nintendo/wiiu/latte-sdhci.yaml    |  46 +++
 .../bindings/powerpc/nintendo/wiiu/latte.yaml |  31 ++
 .../devicetree/bindings/usb/generic-ehci.yaml |   1 +
 arch/powerpc/Kconfig.debug                    |   9 +
 arch/powerpc/boot/Makefile                    |   4 +
 arch/powerpc/boot/dts/wiiu.dts                | 319 ++++++++++++++++++
 arch/powerpc/boot/wiiu-head.S                 | 103 ++++++
 arch/powerpc/boot/wiiu.c                      |  73 ++++
 arch/powerpc/boot/wrapper                     |   4 +
 arch/powerpc/configs/wiiu_defconfig           |   7 +
 arch/powerpc/include/asm/udbg.h               |   1 +
 arch/powerpc/kernel/cpu_specs_book3s_32.h     |  15 +
 arch/powerpc/kernel/head_book3s_32.S          |  20 ++
 arch/powerpc/kernel/udbg.c                    |   3 +
 arch/powerpc/platforms/Kconfig                |   1 +
 arch/powerpc/platforms/Kconfig.cputype        |   2 +-
 arch/powerpc/platforms/Makefile               |   1 +
 arch/powerpc/platforms/wiiu/Kconfig           |  22 ++
 arch/powerpc/platforms/wiiu/Makefile          |   4 +
 arch/powerpc/platforms/wiiu/espresso-pic.c    | 183 ++++++++++
 arch/powerpc/platforms/wiiu/espresso-pic.h    |  59 ++++
 arch/powerpc/platforms/wiiu/latte-pic.c       | 259 ++++++++++++++
 arch/powerpc/platforms/wiiu/latte-pic.h       |  23 ++
 arch/powerpc/platforms/wiiu/setup.c           |  60 ++++
 arch/powerpc/platforms/wiiu/udbg_latteipc.c   | 126 +++++++
 arch/powerpc/platforms/wiiu/udbg_latteipc.h   |  27 ++
 32 files changed, 1657 insertions(+), 1 deletion(-)
 create mode 100644 Documentation/devicetree/bindings/powerpc/nintendo/wiiu.yaml
 create mode 100644 Documentation/devicetree/bindings/powerpc/nintendo/wiiu/espresso-pic.yaml
 create mode 100644 Documentation/devicetree/bindings/powerpc/nintendo/wiiu/gpu7.yaml
 create mode 100644 Documentation/devicetree/bindings/powerpc/nintendo/wiiu/latte-ahci.yaml
 create mode 100644 Documentation/devicetree/bindings/powerpc/nintendo/wiiu/latte-dsp.yaml
 create mode 100644 Documentation/devicetree/bindings/powerpc/nintendo/wiiu/latte-pic.yaml
 create mode 100644 Documentation/devicetree/bindings/powerpc/nintendo/wiiu/latte-sdhci.yaml
 create mode 100644 Documentation/devicetree/bindings/powerpc/nintendo/wiiu/latte.yaml
 create mode 100644 arch/powerpc/boot/dts/wiiu.dts
 create mode 100644 arch/powerpc/boot/wiiu-head.S
 create mode 100644 arch/powerpc/boot/wiiu.c
 create mode 100644 arch/powerpc/configs/wiiu_defconfig
 create mode 100644 arch/powerpc/platforms/wiiu/Kconfig
 create mode 100644 arch/powerpc/platforms/wiiu/Makefile
 create mode 100644 arch/powerpc/platforms/wiiu/espresso-pic.c
 create mode 100644 arch/powerpc/platforms/wiiu/espresso-pic.h
 create mode 100644 arch/powerpc/platforms/wiiu/latte-pic.c
 create mode 100644 arch/powerpc/platforms/wiiu/latte-pic.h
 create mode 100644 arch/powerpc/platforms/wiiu/setup.c
 create mode 100644 arch/powerpc/platforms/wiiu/udbg_latteipc.c
 create mode 100644 arch/powerpc/platforms/wiiu/udbg_latteipc.h

base-commit: 094226ad94f471a9f19e8f8e7140a09c2625abaa

Signature · 1 line
2.38.1
author
#70 lore raw

PATCH v4 1/11 dt-bindings: wiiu: Document the Nintendo Wii U devicetree

Adds schema for the various Wii U devicetree nodes used.

---
v3->v4: Rework to match expected style and conciceness.

 .../bindings/powerpc/nintendo/wiiu.yaml       | 25 +++++++++
 .../powerpc/nintendo/wiiu/espresso-pic.yaml   | 48 ++++++++++++++++
 .../bindings/powerpc/nintendo/wiiu/gpu7.yaml  | 42 ++++++++++++++
 .../powerpc/nintendo/wiiu/latte-ahci.yaml     | 50 +++++++++++++++++
 .../powerpc/nintendo/wiiu/latte-dsp.yaml      | 35 ++++++++++++
 .../powerpc/nintendo/wiiu/latte-pic.yaml      | 55 +++++++++++++++++++
 .../powerpc/nintendo/wiiu/latte-sdhci.yaml    | 46 ++++++++++++++++
 .../bindings/powerpc/nintendo/wiiu/latte.yaml | 31 +++++++++++
 .../devicetree/bindings/usb/generic-ehci.yaml |  1 +
 9 files changed, 333 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/powerpc/nintendo/wiiu.yaml
 create mode 100644 Documentation/devicetree/bindings/powerpc/nintendo/wiiu/espresso-pic.yaml
 create mode 100644 Documentation/devicetree/bindings/powerpc/nintendo/wiiu/gpu7.yaml
 create mode 100644 Documentation/devicetree/bindings/powerpc/nintendo/wiiu/latte-ahci.yaml
 create mode 100644 Documentation/devicetree/bindings/powerpc/nintendo/wiiu/latte-dsp.yaml
 create mode 100644 Documentation/devicetree/bindings/powerpc/nintendo/wiiu/latte-pic.yaml
 create mode 100644 Documentation/devicetree/bindings/powerpc/nintendo/wiiu/latte-sdhci.yaml
 create mode 100644 Documentation/devicetree/bindings/powerpc/nintendo/wiiu/latte.yaml
Documentation/devicetree/bindings/powerpc/nintendo/wiiu.yaml new file +25 -0
new file mode 100644
index 000000000000..23703b1052d0
@@ -0,0 +1,25 @@
+# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/powerpc/nintendo/wiiu.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Nintendo Wii U bindings
+
+maintainers:
+  - Ash Logan <[email protected]>
+  - Emmanuel Gil Peyrot <[email protected]>
+
+description: |
+  Nintendo Wii U video game console binding.
+
+properties:
+  $nodename:
+    const: "/"
+
+  compatible:
+    const: nintendo,wiiu
+
+additionalProperties: true
+
+...
Documentation/devicetree/bindings/powerpc/nintendo/wiiu/espresso-pic.yaml new file +48 -0

48 lines not on this page · raw message

Documentation/devicetree/bindings/powerpc/nintendo/wiiu/gpu7.yaml new file +42 -0

42 lines not on this page · raw message

Documentation/devicetree/bindings/powerpc/nintendo/wiiu/latte-ahci.yaml new file +50 -0

50 lines not on this page · raw message

Documentation/devicetree/bindings/powerpc/nintendo/wiiu/latte-dsp.yaml new file +35 -0
new file mode 100644
index 000000000000..772afe0c298c
@@ -0,0 +1,35 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/powerpc/nintendo/wiiu/latte-dsp.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Nintendo Wii U Latte DSP
+
+maintainers:
+  - Ash Logan <[email protected]>
+  - Emmanuel Gil Peyrot <[email protected]>
+
+description: |
+  Nintendo Wii U digital signal processor, as found in the Latte chip.
+
+properties:
+  compatible:
+    const: nintendo,latte-dsp
+
+  reg:
+    maxItems: 1
+
+required:
+  - compatible
+  - reg
+
+additionalProperties: false
+
+examples:
+  - |
+    dsp@c005000 {
+        compatible = "nintendo,latte-dsp";
+        reg = <0x0c005000 0x200>;
+    };
+...
Documentation/devicetree/bindings/powerpc/nintendo/wiiu/latte-pic.yaml new file +55 -0

55 lines not on this page · raw message

Documentation/devicetree/bindings/powerpc/nintendo/wiiu/latte-sdhci.yaml new file +46 -0

46 lines not on this page · raw message

Documentation/devicetree/bindings/powerpc/nintendo/wiiu/latte.yaml new file +31 -0
new file mode 100644
index 000000000000..6fdf93622fcc
@@ -0,0 +1,31 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/powerpc/nintendo/wiiu/latte.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Latte system bus
+
+maintainers:
+  - Ash Logan <[email protected]>
+  - Emmanuel Gil Peyrot <[email protected]>
+
+description: |
+  Latte multi-function SoC, containing many of the devices found on the Nintendo Wii U.
+
+allOf:
+  - $ref: "/schemas/simple-bus.yaml#"
+
+properties:
+  compatible:
+    items:
+      - const: nintendo,latte
+      - const: simple-bus
+
+
+required:
+  - compatible
+
+additionalProperties: true
+
+...
Documentation/devicetree/bindings/usb/generic-ehci.yaml +1 -0
index c5f629c5bc61..9f69b5ab21ff 100644
@@ -69,6 +69,7 @@ properties:
               - ibm,usb-ehci-440epx
               - ibm,usb-ehci-460ex
               - nintendo,hollywood-usb-ehci
+              - nintendo,latte-ehci
               - st,spear600-ehci
           - const: usb-ehci
       - enum:
Signature · 1 line
2.38.1
maintainer
#71 lore raw

Re: [PATCH v4 01/11] dt-bindings: wiiu: Document the Nintendo Wii U devicetree

Quoted 16 lines · Ash Logan

Adds schema for the various Wii U devicetree nodes used.

---
v3->v4: Rework to match expected style and conciceness.

 .../bindings/powerpc/nintendo/wiiu.yaml       | 25 +++++++++
 .../powerpc/nintendo/wiiu/espresso-pic.yaml   | 48 ++++++++++++++++
 .../bindings/powerpc/nintendo/wiiu/gpu7.yaml  | 42 ++++++++++++++
 .../powerpc/nintendo/wiiu/latte-ahci.yaml     | 50 +++++++++++++++++
 .../powerpc/nintendo/wiiu/latte-dsp.yaml      | 35 ++++++++++++
 .../powerpc/nintendo/wiiu/latte-pic.yaml      | 55 +++++++++++++++++++
 .../powerpc/nintendo/wiiu/latte-sdhci.yaml    | 46 ++++++++++++++++
 .../bindings/powerpc/nintendo/wiiu/latte.yaml | 31 +++++++++++
 .../devicetree/bindings/usb/generic-ehci.yaml |  1 +
 9 files changed, 333 insertions(+)
Quoted 9 lines
 create mode 100644 Documentation/devicetree/bindings/powerpc/nintendo/wiiu.yaml
 create mode 100644 Documentation/devicetree/bindings/powerpc/nintendo/wiiu/espresso-pic.yaml
 create mode 100644 Documentation/devicetree/bindings/powerpc/nintendo/wiiu/gpu7.yaml
 create mode 100644 Documentation/devicetree/bindings/powerpc/nintendo/wiiu/latte-ahci.yaml
 create mode 100644 Documentation/devicetree/bindings/powerpc/nintendo/wiiu/latte-dsp.yaml
 create mode 100644 Documentation/devicetree/bindings/powerpc/nintendo/wiiu/latte-pic.yaml
 create mode 100644 Documentation/devicetree/bindings/powerpc/nintendo/wiiu/latte-sdhci.yaml
 create mode 100644 Documentation/devicetree/bindings/powerpc/nintendo/wiiu/latte.yaml

My bot found errors running 'make DT_CHECKER_FLAGS=-m dt_binding_check' on your patch (DT_CHECKER_FLAGS is new in v5.13):

yamllint warnings/errors:

dtschema/dtc warnings/errors:
/builds/robherring/dt-review-ci/linux/Documentation/devicetree/bindings/bus/fsl,spba-bus.example.dtb: spba-bus@30000000: compatible:0: 'nintendo,latte' was expected
From schema: /builds/robherring/dt-review-ci/linux/Documentation/devicetree/bindings/powerpc/nintendo/wiiu/latte.yaml
/builds/robherring/dt-review-ci/linux/Documentation/devicetree/bindings/bus/arm,integrator-ap-lm.example.dtb: bus@c0000000: compatible:0: 'nintendo,latte' was expected
From schema: /builds/robherring/dt-review-ci/linux/Documentation/devicetree/bindings/powerpc/nintendo/wiiu/latte.yaml
/builds/robherring/dt-review-ci/linux/Documentation/devicetree/bindings/bus/arm,integrator-ap-lm.example.dtb: bus@c0000000: compatible: ['simple-bus'] is too short
From schema: /builds/robherring/dt-review-ci/linux/Documentation/devicetree/bindings/powerpc/nintendo/wiiu/latte.yaml
/builds/robherring/dt-review-ci/linux/Documentation/devicetree/bindings/bus/baikal,bt1-apb.example.dtb: bus@1f059000: compatible:0: 'nintendo,latte' was expected
From schema: /builds/robherring/dt-review-ci/linux/Documentation/devicetree/bindings/powerpc/nintendo/wiiu/latte.yaml
/builds/robherring/dt-review-ci/linux/Documentation/devicetree/bindings/bus/baikal,bt1-axi.example.dtb: bus@1f05a000: compatible:0: 'nintendo,latte' was expected
From schema: /builds/robherring/dt-review-ci/linux/Documentation/devicetree/bindings/powerpc/nintendo/wiiu/latte.yaml
/builds/robherring/dt-review-ci/linux/Documentation/devicetree/bindings/remoteproc/ti,k3-dsp-rproc.example.dtb: bus@100000: compatible:0: 'nintendo,latte' was expected
From schema: /builds/robherring/dt-review-ci/linux/Documentation/devicetree/bindings/powerpc/nintendo/wiiu/latte.yaml
/builds/robherring/dt-review-ci/linux/Documentation/devicetree/bindings/remoteproc/ti,k3-dsp-rproc.example.dtb: bus@100000: compatible: ['simple-bus'] is too short
From schema: /builds/robherring/dt-review-ci/linux/Documentation/devicetree/bindings/powerpc/nintendo/wiiu/latte.yaml
/builds/robherring/dt-review-ci/linux/Documentation/devicetree/bindings/remoteproc/ti,k3-r5f-rproc.example.dtb: bus@100000: compatible:0: 'nintendo,latte' was expected
From schema: /builds/robherring/dt-review-ci/linux/Documentation/devicetree/bindings/powerpc/nintendo/wiiu/latte.yaml
/builds/robherring/dt-review-ci/linux/Documentation/devicetree/bindings/remoteproc/ti,k3-r5f-rproc.example.dtb: bus@100000: compatible: ['simple-bus'] is too short
From schema: /builds/robherring/dt-review-ci/linux/Documentation/devicetree/bindings/powerpc/nintendo/wiiu/latte.yaml
/builds/robherring/dt-review-ci/linux/Documentation/devicetree/bindings/remoteproc/ti,k3-r5f-rproc.example.dtb: bus@28380000: compatible:0: 'nintendo,latte' was expected
From schema: /builds/robherring/dt-review-ci/linux/Documentation/devicetree/bindings/powerpc/nintendo/wiiu/latte.yaml
/builds/robherring/dt-review-ci/linux/Documentation/devicetree/bindings/remoteproc/ti,k3-r5f-rproc.example.dtb: bus@28380000: compatible: ['simple-bus'] is too short
From schema: /builds/robherring/dt-review-ci/linux/Documentation/devicetree/bindings/powerpc/nintendo/wiiu/latte.yaml
/builds/robherring/dt-review-ci/linux/Documentation/devicetree/bindings/iio/dac/fsl,vf610-dac.example.dtb: bus@40000000: compatible:0: 'nintendo,latte' was expected
From schema: /builds/robherring/dt-review-ci/linux/Documentation/devicetree/bindings/powerpc/nintendo/wiiu/latte.yaml
/builds/robherring/dt-review-ci/linux/Documentation/devicetree/bindings/arm/stm32/st,mlahb.example.dtb: ahb@38000000: compatible:0: 'nintendo,latte' was expected
From schema: /builds/robherring/dt-review-ci/linux/Documentation/devicetree/bindings/powerpc/nintendo/wiiu/latte.yaml
/builds/robherring/dt-review-ci/linux/Documentation/devicetree/bindings/soc/imx/fsl,aips-bus.example.dtb: bus@30000000: compatible:0: 'nintendo,latte' was expected
From schema: /builds/robherring/dt-review-ci/linux/Documentation/devicetree/bindings/powerpc/nintendo/wiiu/latte.yaml
/builds/robherring/dt-review-ci/linux/Documentation/devicetree/bindings/soc/imx/imx8m-soc.example.dtb: soc@0: compatible:0: 'nintendo,latte' was expected
From schema: /builds/robherring/dt-review-ci/linux/Documentation/devicetree/bindings/powerpc/nintendo/wiiu/latte.yaml
/builds/robherring/dt-review-ci/linux/Documentation/devicetree/bindings/soc/intel/intel,hps-copy-engine.example.dtb: bus@80000000: compatible:0: 'nintendo,latte' was expected
From schema: /builds/robherring/dt-review-ci/linux/Documentation/devicetree/bindings/powerpc/nintendo/wiiu/latte.yaml
/builds/robherring/dt-review-ci/linux/Documentation/devicetree/bindings/soc/intel/intel,hps-copy-engine.example.dtb: bus@80000000: compatible: ['simple-bus'] is too short
From schema: /builds/robherring/dt-review-ci/linux/Documentation/devicetree/bindings/powerpc/nintendo/wiiu/latte.yaml

doc reference errors (make refcheckdocs):

See https://patchwork.ozlabs.org/project/devicetree-bindings/patch/[email protected]

This check can fail if there are any dependencies. The base for a patch series is generally the most recent rc1.

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.

maintainer
#72 lore raw

Re: [PATCH v4 01/11] dt-bindings: wiiu: Document the Nintendo Wii U devicetree

In reply to Ash Logan
Quoted 31 lines · Ash Logan

Adds schema for the various Wii U devicetree nodes used.

---
v3->v4: Rework to match expected style and conciceness.

 .../bindings/powerpc/nintendo/wiiu.yaml       | 25 +++++++++
 .../powerpc/nintendo/wiiu/espresso-pic.yaml   | 48 ++++++++++++++++
 .../bindings/powerpc/nintendo/wiiu/gpu7.yaml  | 42 ++++++++++++++
 .../powerpc/nintendo/wiiu/latte-ahci.yaml     | 50 +++++++++++++++++
 .../powerpc/nintendo/wiiu/latte-dsp.yaml      | 35 ++++++++++++
 .../powerpc/nintendo/wiiu/latte-pic.yaml      | 55 +++++++++++++++++++
 .../powerpc/nintendo/wiiu/latte-sdhci.yaml    | 46 ++++++++++++++++
 .../bindings/powerpc/nintendo/wiiu/latte.yaml | 31 +++++++++++
 .../devicetree/bindings/usb/generic-ehci.yaml |  1 +
 9 files changed, 333 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/powerpc/nintendo/wiiu.yaml
 create mode 100644 Documentation/devicetree/bindings/powerpc/nintendo/wiiu/espresso-pic.yaml
 create mode 100644 Documentation/devicetree/bindings/powerpc/nintendo/wiiu/gpu7.yaml
 create mode 100644 Documentation/devicetree/bindings/powerpc/nintendo/wiiu/latte-ahci.yaml
 create mode 100644 Documentation/devicetree/bindings/powerpc/nintendo/wiiu/latte-dsp.yaml
 create mode 100644 Documentation/devicetree/bindings/powerpc/nintendo/wiiu/latte-pic.yaml
 create mode 100644 Documentation/devicetree/bindings/powerpc/nintendo/wiiu/latte-sdhci.yaml
 create mode 100644 Documentation/devicetree/bindings/powerpc/nintendo/wiiu/latte.yaml
Documentation/devicetree/bindings/powerpc/nintendo/wiiu.yaml new file +0 -0
new file mode 100644
index 000000000000..23703b1052d0

Documentation/devicetree/bindings/powerpc/nintendo/wiiu.yaml line 7

Quoted 7 lines
Documentation/devicetree/bindings/powerpc/nintendo/wiiu.yaml new file +7 -0
@@ -0,0 +1,25 @@
+# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/powerpc/nintendo/wiiu.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Nintendo Wii U bindings

Everything is a binding, so drop 'bindings'.

Documentation/devicetree/bindings/powerpc/nintendo/wiiu.yaml line 13

Quoted 6 lines
Documentation/devicetree/bindings/powerpc/nintendo/wiiu.yaml new file +6 -0
+
+maintainers:
+  - Ash Logan <[email protected]>
+  - Emmanuel Gil Peyrot <[email protected]>
+
+description: |

Don't need '|' if no formatting.

Quoted 25 lines
Documentation/devicetree/bindings/powerpc/nintendo/wiiu.yaml new file +12 -0
+  Nintendo Wii U video game console binding.
+
+properties:
+  $nodename:
+    const: "/"
+
+  compatible:
+    const: nintendo,wiiu
+
+additionalProperties: true
+
+...
Documentation/devicetree/bindings/powerpc/nintendo/wiiu/espresso-pic.yaml new file +7 -0
new file mode 100644
index 000000000000..476a8ccda7a1
@@ -0,0 +1,48 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/powerpc/nintendo/wiiu/espresso-pic.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Nintendo Wii U "Espresso" interrupt controller

Documentation/devicetree/bindings/powerpc/nintendo/wiiu/espresso-pic.yaml line 17

Quoted 10 lines
Documentation/devicetree/bindings/powerpc/nintendo/wiiu/espresso-pic.yaml new file +10 -0
+
+maintainers:
+  - Ash Logan <[email protected]>
+  - Emmanuel Gil Peyrot <[email protected]>
+
+description: |
+  Interrupt controller found on the Nintendo Wii U for the "Espresso" processor.
+
+allOf:
+  - $ref: "/schemas/interrupt-controller.yaml#"

Drop quotes.

Quoted 41 lines
Documentation/devicetree/bindings/powerpc/nintendo/wiiu/espresso-pic.yaml new file +31 -0
+
+properties:
+  compatible:
+    const: nintendo,espresso-pic
+
+  '#interrupt-cells':
+    # Interrupt numbers 0-32 in one cell
+    const: 1
+
+  interrupt-controller: true
+
+  reg:
+    maxItems: 1
+
+required:
+  - compatible
+  - '#interrupt-cells'
+  - interrupt-controller
+  - reg
+
+additionalProperties: false
+
+examples:
+  - |
+    interrupt-controller@c000078 {
+        compatible = "nintendo,espresso-pic";
+        reg = <0x0c000078 0x18>;
+        #interrupt-cells = <1>;
+        interrupt-controller;
+    };
+...
Documentation/devicetree/bindings/powerpc/nintendo/wiiu/gpu7.yaml new file +4 -0
new file mode 100644
index 000000000000..d44ebe0d866c
@@ -0,0 +1,42 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/powerpc/nintendo/wiiu/gpu7.yaml#

Documentation/devicetree/bindings/powerpc/nintendo/wiiu/gpu7.yaml line 14

Quoted 10 lines
Documentation/devicetree/bindings/powerpc/nintendo/wiiu/gpu7.yaml new file +10 -0
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Nintendo Wii U Latte "GPU7" graphics processor
+
+maintainers:
+  - Ash Logan <[email protected]>
+  - Emmanuel Gil Peyrot <[email protected]>
+
+description: |
+  GPU7 graphics processor, also known as "GX2", found in the Latte multifunction chip of the

Wrap lines at 80 unless some advantage to 100.

Quoted 205 lines
Documentation/devicetree/bindings/powerpc/nintendo/wiiu/gpu7.yaml new file +28 -0
+  Nintendo Wii U.
+
+properties:
+  compatible:
+    const: nintendo,latte-gpu7
+
+  reg:
+    maxItems: 1
+
+  interrupts:
+    maxItems: 1
+
+required:
+  - compatible
+  - reg
+  - interrupts
+
+additionalProperties: false
+
+examples:
+  - |
+    gpu@c200000 {
+        compatible = "nintendo,latte-gpu7";
+        reg = <0x0c200000 0x80000>;
+        interrupts = <2>;
+        interrupt-parent = <&espresso_pic>;
+    };
+...
Documentation/devicetree/bindings/powerpc/nintendo/wiiu/latte-ahci.yaml new file +50 -0
new file mode 100644
index 000000000000..a53971a11e89
@@ -0,0 +1,50 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/powerpc/nintendo/wiiu/latte-ahci.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Nintendo Wii U Latte AHCI controller
+
+maintainers:
+  - Ash Logan <[email protected]>
+  - Emmanuel Gil Peyrot <[email protected]>
+
+description: |
+  Nintendo Wii U AHCI SATA controller, as found in the Latte chip.
+
+allOf:
+  - $ref: "/schemas/ata/ahci-common.yaml#"
+
+properties:
+  compatible:
+    const: nintendo,latte-ahci
+
+  reg:
+    items:
+      - description: |
+          HBA memory registers. Note that unlike the spec, space for only 6 ports exist, with 2 vendor
+          registers afterwards, thus register space should be 0x408 long (0x100+0x80*6+0x8).
+
+  interrupts:
+    items:
+      - description: Main HBA interrupt
+      - description: Vendor debugging interrupt
+
+required:
+  - compatible
+  - reg
+  - interrupts
+
+additionalProperties: false
+
+examples:
+  - |
+    sata@d160400 {
+        compatible = "nintendo,latte-ahci";
+        reg = <0x0d160400 0x408>;
+
+        interrupt-parent = <&latte_pic>;
+        interrupts = <38>, <28>;
+    };
+...
Documentation/devicetree/bindings/powerpc/nintendo/wiiu/latte-dsp.yaml new file +35 -0
new file mode 100644
index 000000000000..772afe0c298c
@@ -0,0 +1,35 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/powerpc/nintendo/wiiu/latte-dsp.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Nintendo Wii U Latte DSP
+
+maintainers:
+  - Ash Logan <[email protected]>
+  - Emmanuel Gil Peyrot <[email protected]>
+
+description: |
+  Nintendo Wii U digital signal processor, as found in the Latte chip.
+
+properties:
+  compatible:
+    const: nintendo,latte-dsp
+
+  reg:
+    maxItems: 1
+
+required:
+  - compatible
+  - reg
+
+additionalProperties: false
+
+examples:
+  - |
+    dsp@c005000 {
+        compatible = "nintendo,latte-dsp";
+        reg = <0x0c005000 0x200>;
+    };
+...
Documentation/devicetree/bindings/powerpc/nintendo/wiiu/latte-pic.yaml new file +55 -0
new file mode 100644
index 000000000000..4b71d6b9b14d
@@ -0,0 +1,55 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/powerpc/nintendo/wiiu/latte-pic.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Nintendo Wii U Latte interrupt controller
+
+maintainers:
+  - Ash Logan <[email protected]>
+  - Emmanuel Gil Peyrot <[email protected]>
+
+description: |
+  Interrupt controller found on the Nintendo Wii U for the "Latte" devices.
+
+allOf:
+  - $ref: "/schemas/interrupt-controller.yaml#"
+
+properties:
+  compatible:
+    const: nintendo,latte-pic
+
+  '#interrupt-cells':
+    # Interrupt numbers 0-64 in one cell.
+    const: 1
+
+  interrupt-controller: true
+
+  reg:
+    maxItems: 1
+
+  interrupts:
+    items:
+      - description: Cascade interrupt for Espresso PIC
+
+required:
+  - compatible
+  - '#interrupt-cells'
+  - interrupt-controller
+  - reg
+
+additionalProperties: false
+
+examples:
+  - |
+    interrupt-controller@d800440 {
+        compatible = "nintendo,latte-pic";
+        #interrupt-cells = <1>;
+        interrupt-controller;
+        reg = <0x0d800440 0x30>;
+
+        interrupt-parent = <&espresso_pic>;
+        interrupts = <24>;
+    };
+...
Documentation/devicetree/bindings/powerpc/nintendo/wiiu/latte-sdhci.yaml new file +13 -0
new file mode 100644
index 000000000000..25d474fca679
@@ -0,0 +1,46 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/powerpc/nintendo/wiiu/latte-sdhci.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Nintendo Wii U Latte SD Host controller
+
+maintainers:
+  - Ash Logan <[email protected]>
+  - Emmanuel Gil Peyrot <[email protected]>
+
+description: |

Documentation/devicetree/bindings/powerpc/nintendo/wiiu/latte-sdhci.yaml line 23

Quoted 10 lines
Documentation/devicetree/bindings/powerpc/nintendo/wiiu/latte-sdhci.yaml new file +10 -0
+  SDHCI hosts found on the Nintendo Wii U's Latte SoC for SD cards and SDIO devices.
+
+allOf:
+  - $ref: "/schemas/mmc/mmc-controller.yaml#"
+
+properties:
+  compatible:
+    items:
+      - const: nintendo,latte-sdhci
+      - const: sdhci

Just 'sdhci' is not too useful. *All* SDHCI controllers have quirks.

Quoted 42 lines
Documentation/devicetree/bindings/powerpc/nintendo/wiiu/latte-sdhci.yaml new file +23 -0
+
+  reg:
+    maxItems: 1
+
+  interrupts:
+    maxItems: 1
+
+required:
+  - compatible
+  - reg
+  - interrupts
+
+additionalProperties: false
+
+examples:
+  - |
+    mmc@d070000 {
+        compatible = "nintendo,latte-sdhci", "sdhci";
+        reg = <0x0d070000 0x200>;
+        interrupts = <7>;
+        interrupt-parent = <&latte_pic>;
+    };
+...
Documentation/devicetree/bindings/powerpc/nintendo/wiiu/latte.yaml new file +13 -0
new file mode 100644
index 000000000000..6fdf93622fcc
@@ -0,0 +1,31 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/powerpc/nintendo/wiiu/latte.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Latte system bus
+
+maintainers:
+  - Ash Logan <[email protected]>
+  - Emmanuel Gil Peyrot <[email protected]>
+
+description: |

Documentation/devicetree/bindings/powerpc/nintendo/wiiu/latte.yaml line 23

Quoted 10 lines
Documentation/devicetree/bindings/powerpc/nintendo/wiiu/latte.yaml new file +10 -0
+  Latte multi-function SoC, containing many of the devices found on the Nintendo Wii U.
+
+allOf:
+  - $ref: "/schemas/simple-bus.yaml#"
+
+properties:
+  compatible:
+    items:
+      - const: nintendo,latte
+      - const: simple-bus

If truly 'simple', then you don't need 'nintendo,latte'.

Otherwise, you need a custom 'select' schema to not select all cases of 'simple-bus'.

Documentation/devicetree/bindings/powerpc/nintendo/wiiu/latte.yaml line 25

Quoted 2 lines
Documentation/devicetree/bindings/powerpc/nintendo/wiiu/latte.yaml new file +2 -0
+
+

one blank line

Quoted 22 lines
Documentation/devicetree/bindings/powerpc/nintendo/wiiu/latte.yaml new file +6 -0
+required:
+  - compatible
+
+additionalProperties: true
+
+...
Documentation/devicetree/bindings/usb/generic-ehci.yaml +1 -0
index c5f629c5bc61..9f69b5ab21ff 100644
@@ -69,6 +69,7 @@ properties:
               - ibm,usb-ehci-440epx
               - ibm,usb-ehci-460ex
               - nintendo,hollywood-usb-ehci
+              - nintendo,latte-ehci
               - st,spear600-ehci
           - const: usb-ehci
       - enum:
Signature · 1 line
2.38.1
#73 lore raw

Re: [PATCH v4 01/11] dt-bindings: wiiu: Document the Nintendo Wii U devicetree

In reply to Ash Logan

Michael,

Le 19/11/2022 à 12:30, Ash Logan a écrit :

Quoted 3 lines

Adds schema for the various Wii U devicetree nodes used.

There's an issue at https://github.com/linuxppc/issues/issues/410 with kernel v6.4 as a target to merging thing, any plan ?

It still applies without rebase (with git am -3).

Christophe

Quoted 414 lines

---
v3->v4: Rework to match expected style and conciceness.

  .../bindings/powerpc/nintendo/wiiu.yaml       | 25 +++++++++
  .../powerpc/nintendo/wiiu/espresso-pic.yaml   | 48 ++++++++++++++++
  .../bindings/powerpc/nintendo/wiiu/gpu7.yaml  | 42 ++++++++++++++
  .../powerpc/nintendo/wiiu/latte-ahci.yaml     | 50 +++++++++++++++++
  .../powerpc/nintendo/wiiu/latte-dsp.yaml      | 35 ++++++++++++
  .../powerpc/nintendo/wiiu/latte-pic.yaml      | 55 +++++++++++++++++++
  .../powerpc/nintendo/wiiu/latte-sdhci.yaml    | 46 ++++++++++++++++
  .../bindings/powerpc/nintendo/wiiu/latte.yaml | 31 +++++++++++
  .../devicetree/bindings/usb/generic-ehci.yaml |  1 +
  9 files changed, 333 insertions(+)

create mode 100644 Documentation/devicetree/bindings/powerpc/nintendo/wiiu.yaml create mode 100644 Documentation/devicetree/bindings/powerpc/nintendo/wiiu/espresso-pic.yaml create mode 100644 Documentation/devicetree/bindings/powerpc/nintendo/wiiu/gpu7.yaml create mode 100644 Documentation/devicetree/bindings/powerpc/nintendo/wiiu/latte-ahci.yaml create mode 100644 Documentation/devicetree/bindings/powerpc/nintendo/wiiu/latte-dsp.yaml create mode 100644 Documentation/devicetree/bindings/powerpc/nintendo/wiiu/latte-pic.yaml create mode 100644 Documentation/devicetree/bindings/powerpc/nintendo/wiiu/latte-sdhci.yaml create mode 100644 Documentation/devicetree/bindings/powerpc/nintendo/wiiu/latte.yaml

Documentation/devicetree/bindings/powerpc/nintendo/wiiu.yaml new file +25 -0
new file mode 100644
index 000000000000..23703b1052d0
@@ -0,0 +1,25 @@
+# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/powerpc/nintendo/wiiu.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Nintendo Wii U bindings
+
+maintainers:
+  - Ash Logan <[email protected]>
+  - Emmanuel Gil Peyrot <[email protected]>
+
+description: |
+  Nintendo Wii U video game console binding.
+
+properties:
+  $nodename:
+    const: "/"
+
+  compatible:
+    const: nintendo,wiiu
+
+additionalProperties: true
+
+...
Documentation/devicetree/bindings/powerpc/nintendo/wiiu/espresso-pic.yaml new file +48 -0
new file mode 100644
index 000000000000..476a8ccda7a1
@@ -0,0 +1,48 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/powerpc/nintendo/wiiu/espresso-pic.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Nintendo Wii U "Espresso" interrupt controller
+
+maintainers:
+  - Ash Logan <[email protected]>
+  - Emmanuel Gil Peyrot <[email protected]>
+
+description: |
+  Interrupt controller found on the Nintendo Wii U for the "Espresso" processor.
+
+allOf:
+  - $ref: "/schemas/interrupt-controller.yaml#"
+
+properties:
+  compatible:
+    const: nintendo,espresso-pic
+
+  '#interrupt-cells':
+    # Interrupt numbers 0-32 in one cell
+    const: 1
+
+  interrupt-controller: true
+
+  reg:
+    maxItems: 1
+
+required:
+  - compatible
+  - '#interrupt-cells'
+  - interrupt-controller
+  - reg
+
+additionalProperties: false
+
+examples:
+  - |
+    interrupt-controller@c000078 {
+        compatible = "nintendo,espresso-pic";
+        reg = <0x0c000078 0x18>;
+        #interrupt-cells = <1>;
+        interrupt-controller;
+    };
+...
Documentation/devicetree/bindings/powerpc/nintendo/wiiu/gpu7.yaml new file +42 -0
new file mode 100644
index 000000000000..d44ebe0d866c
@@ -0,0 +1,42 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/powerpc/nintendo/wiiu/gpu7.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Nintendo Wii U Latte "GPU7" graphics processor
+
+maintainers:
+  - Ash Logan <[email protected]>
+  - Emmanuel Gil Peyrot <[email protected]>
+
+description: |
+  GPU7 graphics processor, also known as "GX2", found in the Latte multifunction chip of the
+  Nintendo Wii U.
+
+properties:
+  compatible:
+    const: nintendo,latte-gpu7
+
+  reg:
+    maxItems: 1
+
+  interrupts:
+    maxItems: 1
+
+required:
+  - compatible
+  - reg
+  - interrupts
+
+additionalProperties: false
+
+examples:
+  - |
+    gpu@c200000 {
+        compatible = "nintendo,latte-gpu7";
+        reg = <0x0c200000 0x80000>;
+        interrupts = <2>;
+        interrupt-parent = <&espresso_pic>;
+    };
+...
Documentation/devicetree/bindings/powerpc/nintendo/wiiu/latte-ahci.yaml new file +50 -0
new file mode 100644
index 000000000000..a53971a11e89
@@ -0,0 +1,50 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/powerpc/nintendo/wiiu/latte-ahci.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Nintendo Wii U Latte AHCI controller
+
+maintainers:
+  - Ash Logan <[email protected]>
+  - Emmanuel Gil Peyrot <[email protected]>
+
+description: |
+  Nintendo Wii U AHCI SATA controller, as found in the Latte chip.
+
+allOf:
+  - $ref: "/schemas/ata/ahci-common.yaml#"
+
+properties:
+  compatible:
+    const: nintendo,latte-ahci
+
+  reg:
+    items:
+      - description: |
+          HBA memory registers. Note that unlike the spec, space for only 6 ports exist, with 2 vendor
+          registers afterwards, thus register space should be 0x408 long (0x100+0x80*6+0x8).
+
+  interrupts:
+    items:
+      - description: Main HBA interrupt
+      - description: Vendor debugging interrupt
+
+required:
+  - compatible
+  - reg
+  - interrupts
+
+additionalProperties: false
+
+examples:
+  - |
+    sata@d160400 {
+        compatible = "nintendo,latte-ahci";
+        reg = <0x0d160400 0x408>;
+
+        interrupt-parent = <&latte_pic>;
+        interrupts = <38>, <28>;
+    };
+...
Documentation/devicetree/bindings/powerpc/nintendo/wiiu/latte-dsp.yaml new file +35 -0
new file mode 100644
index 000000000000..772afe0c298c
@@ -0,0 +1,35 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/powerpc/nintendo/wiiu/latte-dsp.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Nintendo Wii U Latte DSP
+
+maintainers:
+  - Ash Logan <[email protected]>
+  - Emmanuel Gil Peyrot <[email protected]>
+
+description: |
+  Nintendo Wii U digital signal processor, as found in the Latte chip.
+
+properties:
+  compatible:
+    const: nintendo,latte-dsp
+
+  reg:
+    maxItems: 1
+
+required:
+  - compatible
+  - reg
+
+additionalProperties: false
+
+examples:
+  - |
+    dsp@c005000 {
+        compatible = "nintendo,latte-dsp";
+        reg = <0x0c005000 0x200>;
+    };
+...
Documentation/devicetree/bindings/powerpc/nintendo/wiiu/latte-pic.yaml new file +55 -0
new file mode 100644
index 000000000000..4b71d6b9b14d
@@ -0,0 +1,55 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/powerpc/nintendo/wiiu/latte-pic.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Nintendo Wii U Latte interrupt controller
+
+maintainers:
+  - Ash Logan <[email protected]>
+  - Emmanuel Gil Peyrot <[email protected]>
+
+description: |
+  Interrupt controller found on the Nintendo Wii U for the "Latte" devices.
+
+allOf:
+  - $ref: "/schemas/interrupt-controller.yaml#"
+
+properties:
+  compatible:
+    const: nintendo,latte-pic
+
+  '#interrupt-cells':
+    # Interrupt numbers 0-64 in one cell.
+    const: 1
+
+  interrupt-controller: true
+
+  reg:
+    maxItems: 1
+
+  interrupts:
+    items:
+      - description: Cascade interrupt for Espresso PIC
+
+required:
+  - compatible
+  - '#interrupt-cells'
+  - interrupt-controller
+  - reg
+
+additionalProperties: false
+
+examples:
+  - |
+    interrupt-controller@d800440 {
+        compatible = "nintendo,latte-pic";
+        #interrupt-cells = <1>;
+        interrupt-controller;
+        reg = <0x0d800440 0x30>;
+
+        interrupt-parent = <&espresso_pic>;
+        interrupts = <24>;
+    };
+...
Documentation/devicetree/bindings/powerpc/nintendo/wiiu/latte-sdhci.yaml new file +46 -0
new file mode 100644
index 000000000000..25d474fca679
@@ -0,0 +1,46 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/powerpc/nintendo/wiiu/latte-sdhci.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Nintendo Wii U Latte SD Host controller
+
+maintainers:
+  - Ash Logan <[email protected]>
+  - Emmanuel Gil Peyrot <[email protected]>
+
+description: |
+  SDHCI hosts found on the Nintendo Wii U's Latte SoC for SD cards and SDIO devices.
+
+allOf:
+  - $ref: "/schemas/mmc/mmc-controller.yaml#"
+
+properties:
+  compatible:
+    items:
+      - const: nintendo,latte-sdhci
+      - const: sdhci
+
+  reg:
+    maxItems: 1
+
+  interrupts:
+    maxItems: 1
+
+required:
+  - compatible
+  - reg
+  - interrupts
+
+additionalProperties: false
+
+examples:
+  - |
+    mmc@d070000 {
+        compatible = "nintendo,latte-sdhci", "sdhci";
+        reg = <0x0d070000 0x200>;
+        interrupts = <7>;
+        interrupt-parent = <&latte_pic>;
+    };
+...
Documentation/devicetree/bindings/powerpc/nintendo/wiiu/latte.yaml new file +31 -0
new file mode 100644
index 000000000000..6fdf93622fcc
@@ -0,0 +1,31 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/powerpc/nintendo/wiiu/latte.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Latte system bus
+
+maintainers:
+  - Ash Logan <[email protected]>
+  - Emmanuel Gil Peyrot <[email protected]>
+
+description: |
+  Latte multi-function SoC, containing many of the devices found on the Nintendo Wii U.
+
+allOf:
+  - $ref: "/schemas/simple-bus.yaml#"
+
+properties:
+  compatible:
+    items:
+      - const: nintendo,latte
+      - const: simple-bus
+
+
+required:
+  - compatible
+
+additionalProperties: true
+
+...
Documentation/devicetree/bindings/usb/generic-ehci.yaml +1 -0
index c5f629c5bc61..9f69b5ab21ff 100644
@@ -69,6 +69,7 @@ properties:
                - ibm,usb-ehci-440epx
                - ibm,usb-ehci-460ex
                - nintendo,hollywood-usb-ehci
+              - nintendo,latte-ehci
                - st,spear600-ehci
            - const: usb-ehci
        - enum:
#74 lore raw

Re: [PATCH v4 01/11] dt-bindings: wiiu: Document the Nintendo Wii U devicetree

Quoted 11 lines · Christophe Leroy

Michael,

Le 19/11/2022 à 12:30, Ash Logan a écrit :

Quoted 3 lines

Adds schema for the various Wii U devicetree nodes used.

There's an issue at https://github.com/linuxppc/issues/issues/410 with kernel v6.4 as a target to merging thing, any plan ?

It still applies without rebase (with git am -3).

No, it should not be merged, because it was never tested and fails in several places.

Best regards,
Krzysztof

author
#75 lore raw

PATCH v4 2/11 powerpc: wiiu: device tree

In reply to Ash Logan

Add a device tree source file for the Nintendo Wii U video game console.

---
v1->v2: Style and formatting changes suggested by Rob Herring.
License remains GPL-2.0 as the other powerpc dtses are the same, happy to change if there is a different preferred default.
v2->v3: Re-added address-cells accidentally removed in v2.
Marked latte as a simple-bus, since it is.
v3->v4: Updated to match devicetree bindings. Model also changed to
wup-101 in preparation for potentially different devices in future (cat-dev etc.) Chosen node removed.

 arch/powerpc/boot/dts/wiiu.dts | 319 +++++++++++++++++++++++++++++++++
 1 file changed, 319 insertions(+)
 create mode 100644 arch/powerpc/boot/dts/wiiu.dts
arch/powerpc/boot/dts/wiiu.dts new file +319 -0
new file mode 100644
index 000000000000..ee25b0855374
@@ -0,0 +1,319 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Nintendo Wii U Device Tree Source
+ *
+ * Copyright (C) 2022 The linux-wiiu Team
+ */
+
+/dts-v1/;
+#include <dt-bindings/gpio/gpio.h>
+#include <dt-bindings/input/input.h>
+
+/ {
+	model = "nintendo,wup-101";
+	compatible = "nintendo,wiiu";
+
+	#address-cells = <1>;
+	#size-cells = <1>;
+
+	memory@0 {
+		device_type = "memory";
+		reg = <0x00000000 0x02000000	/* MEM1 - 32MiB */
+		       0x08000000 0x00300000	/* MEM0 - 3MiB  */
+		       0x10000000 0x80000000>;	/* MEM2 - 2GiB  */
+	};
+
+	cpus {
+		#address-cells = <1>;
+		#size-cells = <0>;
+
+		/* TODO: Add SMP */
+		PowerPC,espresso@0 {
+			device_type = "cpu";
+			reg = <0>;
+			clock-frequency = <1243125000>;		/* 1.243125GHz */
+			bus-frequency = <248625000>;		/* 248.625MHz core-to-bus 5x */
+			timebase-frequency = <62156250>;	/* 1/4 of the bus clock */
+			i-cache-size = <32768>; /* 32K icache */
+			i-cache-line-size = <32>;
+			i-cache-block-size = <32>;
+			i-cache-sets = <128>;
+			d-cache-size = <32768>; /* 32K dcache */
+			d-cache-line-size = <32>;
+			d-cache-block-size = <32>;
+			d-cache-sets = <128>;
+			next-level-cache = <&L2_0>;
+			L2_0:l2-cache {
+				compatible = "cache";
+				cache-level = <2>;
+				cache-unified;
+				cache-size = <0x80000>; /* 512KB L2 */
+				cache-line-size = <64>;
+				cache-block-size = <32>;
+				cache-sets = <2048>;
+			};
+		};
+	};
+
+	soc {
+		compatible = "nintendo,latte", "simple-bus";
+		ranges = <0x0c000000 0x0c000000 0x00400000	/* Espresso-only registers */
+			  0x0d000000 0x0d000000 0x00200000	/* Latte AHB deivces */
+			  0x0d800000 0x0d800000 0x00800000>;	/* Latte SoC registers */
+
+		#address-cells = <1>;
+		#size-cells = <1>;
+
+		latte_gpu: gpu@c200000 {
+			compatible = "nintendo,latte-gpu7";
+			reg = <0x0c200000 0x80000>;
+			interrupts = <2>;
+			interrupt-parent = <&espresso_pic>;
+		};
+
+		espresso_pic: interrupt-controller@c000078 {
+			compatible = "nintendo,espresso-pic";
+			reg = <0x0c000078 0x18>;
+			#interrupt-cells = <1>;
+			interrupt-controller;
+		};
+
+		latte_dsp: dsp@c005000 {
+			compatible = "nintendo,latte-dsp";
+			reg = <0x0c005000 0x200>;
+		};
+
+		ehci_0: usb@d040000 {
+			compatible = "nintendo,latte-ehci", "usb-ehci";
+			reg = <0x0d040000 0x100>;
+			interrupts = <4>;
+			interrupt-parent = <&latte_pic>;
+			big-endian-regs;
+		};
+
+		ohci_0_0: usb@d050000 {
+			compatible = "nintendo,latte-ohci";
+			reg = <0x0d050000 0x100>;
+			interrupts = <5>;
+			interrupt-parent = <&latte_pic>;
+			big-endian-regs;
+		};
+
+		ohci_0_1: usb@d060000 {
+			compatible = "nintendo,latte-ohci";
+			reg = <0x0d060000 0x100>;
+			interrupts = <6>;
+			interrupt-parent = <&latte_pic>;
+			big-endian-regs;
+		};
+
+		ehci_1: usb@d120000 {
+			compatible = "nintendo,latte-ehci", "usb-ehci";
+			reg = <0x0d120000 0x100>;
+			interrupts = <16>;
+			interrupt-parent = <&latte_pic>;
+			big-endian-regs;
+		};
+
+		ohci_1_0: usb@d130000 {
+			compatible = "nintendo,latte-ohci";
+			reg = <0x0d130000 0x100>;
+			interrupts = <35>;
+			interrupt-parent = <&latte_pic>;
+			big-endian-regs;
+		};
+
+		ehci_2: usb@d140000 {
+			compatible = "nintendo,latte-ehci", "usb-ehci";
+			reg = <0x0d140000 0x100>;
+			interrupts = <36>;
+			interrupt-parent = <&latte_pic>;
+			big-endian-regs;
+		};
+
+		ohci_2_0: usb@d150000 {
+			compatible = "nintendo,latte-ohci";
+			reg = <0x0d150000 0x100>;
+			interrupts = <37>;
+			interrupt-parent = <&latte_pic>;
+
+			big-endian-regs;
+		};
+
+		sdcard_0: mmc@d070000 {
+			compatible = "nintendo,latte-sdhci","sdhci";
+			reg = <0x0d070000 0x200>;
+			interrupts = <7>;
+			interrupt-parent = <&latte_pic>;
+		};
+
+		wifi_0: mmc@d080000 {
+			compatible = "nintendo,latte-sdhci","sdhci";
+			reg = <0x0d080000 0x200>;
+			interrupts = <8>;
+			interrupt-parent = <&latte_pic>;
+		};
+
+		legacy_ipc: ipc@d800000 {
+			compatible = "nintendo,latte-ipc", "nintendo,hollywood-ipc";
+			reg = <0x0d800000 0x10>;
+			interrupts = <30 31>;
+			interrupt-parent = <&latte_pic>;
+		};
+
+		latte_otp: otp@d8001ec {
+			compatible = "nintendo,latte-otp";
+			reg = <0x0d8001ec 0x8>;
+		};
+
+		sata@d160400 {
+			compatible = "nintendo,latte-ahci";
+			reg = <0x0d160400 0x808>;
+
+			interrupt-parent = <&latte_pic>;
+			interrupts = <38 28>;
+		};
+
+		latte_pic: interrupt-controller@d800440 {
+			#interrupt-cells = <1>;
+			interrupt-controller;
+
+			compatible = "nintendo,latte-pic";
+			reg = <0x0d800440 0x30>;
+			interrupt-parent = <&espresso_pic>;
+			interrupts = <24>;
+		};
+
+		gpio: gpio@d8000c0 {
+			#gpio-cells = <2>;
+			compatible = "nintendo,latte-gpio", "nintendo,hollywood-gpio";
+
+			reg = <0x0d8000c0 0x40>;
+			gpio-controller;
+			/* TODO: There are actually 31 AHBALL GPIOs */
+			ngpios = <24>;
+
+			gpio-line-names =
+				"POWER", "DWIFI", "FAN", "DC_DC",
+				"", "Esp10WorkAround", "", "",
+				"PADPD", "", "EEP_CS", "EEP_CLK",
+				"EEP_MOSI", "EEP_MISO", "AVE_SCL", "AVE_SDA",
+				"DEBUG0", "DEBUG1", "DEBUG2", "DEBUG3",
+				"DEBUG4", "DEBUG5", "DEBUG6", "DEBUG7";
+
+			interrupt-controller;
+			#interrupt-cells = <2>;
+			interrupts = <10>;
+			interrupt-parent = <&latte_pic>;
+		};
+
+		gpio2: gpio@d800520 {
+			#gpio-cells = <2>;
+			compatible = "nintendo,latte-gpio", "nintendo,hollywood-gpio";
+
+			reg = <0x0d800520 0x40>;
+			gpio-controller;
+			ngpios = <7>;
+
+			gpio-line-names =
+				"FANSPEED", "SMC_SCL", "SMC_SDA", "DC_DC2",
+				"AVE_INT", "", "AVE_RESET";
+
+			interrupt-controller;
+			#interrupt-cells = <2>;
+			interrupts = <10>;
+			interrupt-parent = <&latte_pic>;
+		};
+	};
+
+	spi_gpio: spi {
+		compatible = "spi-gpio";
+		#address-cells = <1>;
+		#size-cells = <0>;
+
+		cs-gpios = <&gpio 10 GPIO_ACTIVE_HIGH>;
+		sck-gpios = <&gpio 11 GPIO_ACTIVE_HIGH>;
+		mosi-gpios = <&gpio 12 GPIO_ACTIVE_HIGH>;
+		miso-gpios = <&gpio 13 GPIO_ACTIVE_HIGH>;
+		num-chipselects = <1>;
+
+		eeprom@0 {
+			compatible = "atmel,at93c66";
+			reg = <0>;
+			spi-max-frequency = <1000000>;
+			spi-cs-high;
+			/* TODO: wiiubrew says this is 16-bit, but I only get the correct
+			 * values in 8-bit...
+			 */
+			data-size = <8>;
+			read-only;
+
+			#address-cells = <1>;
+			#size-cells = <1>;
+
+			/* https://wiiubrew.org/wiki/Hardware/SEEPROM */
+			rng_seed: rng@12 { reg = <0x012 8>; };
+			ppc_pvr: pvr@20 { reg = <0x020 4>; };
+			seeprom_ver_str: sver-str@24 { reg = <0x024 6>; };
+			seeprom_ver: sver@2a { reg = <0x02A 2>; };
+			otp_ver: over@2c { reg = <0x02C 2>; };
+			otp_rev: orev@2e { reg = <0x02E 2>; };
+			otp_ver_str: over-str@30 { reg = <0x030 8>; };
+
+			bc_crc: bc-crc@38 { reg = <0x038 4>; };
+			bc_sz: bc-sz@3c { reg = <0x03C 2>; };
+			bc_ver: bc-ver@3e { reg = <0x03E 2>; };
+			bc_boardtype: boardtype@42 { reg = <0x042 2>; };
+			bc_boardrev: boardrev@44 { reg = <0x044 2>; };
+			bc_bootsource: bootsource@46 { reg = <0x046 2>; };
+			bc_ddr3size: ddr3size@48 { reg = <0x048 2>; };
+			bc_ddr3speed: ddr3speed@4a { reg = <0x04A 2>; };
+			bc_ppcclockmul: ppcclockmul@4c { reg = <0x04C 2>; };
+			bc_iopclockmul: iopclockmul@46 { reg = <0x04E 2>; };
+			bc_video1080p: video1080p@50 { reg = <0x050 2>; };
+			bc_ddr3vendor: ddr3vendor@52 { reg = <0x052 2>; };
+			bc_movpassivereset: movpassivereset@54 { reg = <0x054 2>; };
+			bc_syspllspd: syspllspd@56 { reg = <0x056 2>; };
+			bc_satadevice: satadevice@58 { reg = <0x058 2>; };
+			bc_consoletype: consoletype@5a { reg = <0x05A 2>; };
+			bc_deviceprescence: deviceprescence@5c { reg = <0x05C 2>; };
+
+			drive_key: drvkey@80 { reg = <0x080 16>; };
+			factory_key: fackey@90 { reg = <0x090 16>; };
+			shdd_key: shddkey@a0 { reg = <0x0A0 16>; };
+			usb_key_seed: usbkeyseed@b0 { reg = <0x0B0 16>; };
+			drive_key_flag: drvkeyf@c0 { reg = <0x0C0 2>; };
+			usb_key_flag: udbkeyf@c2 { reg = <0x0C2 2>; };
+			shdd_key_flag: shddkeyf@c4 { reg = <0x0C4 2>; };
+
+			sysprod_version: sp_ver@140 { reg = <0x140 4>; };
+			sysprod_eeprom_version: sp_ee_ver@144 { reg = <0x144 4>; };
+			sysprod_product_area: sp_parea@148 { reg = <0x148 4>; };
+			sysprod_game_region: sp_region@14c { reg = <0x14C 4>; };
+			sysprod_ntsc_pal: sp_ntscpal@150 { reg = <0x150 4>; };
+			sysprod_5ghz_country: sp_5ghz_c@154 { reg = <0x154 2>; };
+			sysprod_5ghz_country_rev: sp_5ghz_crev@156 { reg = <0x156 2>; };
+			sysprod_code: sp_code@158 { reg = <0x158 8>; };
+			sysprod_serial: sp_serial@160 { reg = <0x160 16>; };
+			sysprod_model: sp_model@170 { reg = <0x170 16>; };
+
+			prod_year: pyear@188 { reg = <0x188 2>; };
+			prod_date: pdate@18a { reg = <0x18A 2>; };
+			prod_time: ptime@18c { reg = <0x18C 2>; };
+
+			boot_params: boot_params@1c0 { reg = <0x1C0 48>; };
+		};
+	};
+
+	/* TODO make this gpio-keyed once hollywood-gpio supports interrupts */
+	gpio-keys {
+		poll-interval = <50>;
+		compatible = "gpio-keys-polled";
+
+		key-power {
+			label = "Power Button";
+			gpios = <&gpio 0 GPIO_ACTIVE_HIGH>;
+			linux,code = <KEY_POWER>;
+		};
+	};
+};
Signature · 1 line
2.38.1
author
#76 lore raw

PATCH v4 3/11 powerpc: wiiu: bootwrapper support

In reply to Ash Logan

Add support for the Nintendo Wii U game console to the powerpc bootwrapper.

---
 arch/powerpc/boot/Makefile    |   4 ++
 arch/powerpc/boot/wiiu-head.S | 103 ++++++++++++++++++++++++++++++++++
 arch/powerpc/boot/wiiu.c      |  73 ++++++++++++++++++++++++
 arch/powerpc/boot/wrapper     |   4 ++
 4 files changed, 184 insertions(+)
 create mode 100644 arch/powerpc/boot/wiiu-head.S
 create mode 100644 arch/powerpc/boot/wiiu.c
arch/powerpc/boot/Makefile +4 -0
index d32d95aea5d6..42f622945b4a 100644
@@ -162,6 +162,7 @@ src-plat-$(CONFIG_EMBEDDED6xx) += cuboot-pq2.c cuboot-mpc7448hpc2.c \
 					gamecube-head.S gamecube.c \
 					wii-head.S wii.c holly.c \
 					fixed-head.S mvme5100.c
+src-plat-$(CONFIG_WIIU) += wiiu-head.S wiiu.c
 src-plat-$(CONFIG_AMIGAONE) += cuboot-amigaone.c
 src-plat-$(CONFIG_PPC_PS3) += ps3-head.S ps3-hvcall.S ps3.c
 src-plat-$(CONFIG_EPAPR_BOOT) += epapr.c epapr-wrapper.c
@@ -360,6 +361,9 @@ image-$(CONFIG_GAMECUBE)		+= dtbImage.gamecube
 image-$(CONFIG_WII)			+= dtbImage.wii
 image-$(CONFIG_MVME5100)		+= dtbImage.mvme5100
 
+# Board port in arch/powerpc/platform/wiiu/Kconfig
+image-$(CONFIG_WIIU)			+= dtbImage.wiiu
+
 # Board port in arch/powerpc/platform/amigaone/Kconfig
 image-$(CONFIG_AMIGAONE)		+= cuImage.amigaone
 
arch/powerpc/boot/wiiu-head.S new file +103 -0

103 lines not on this page · raw message

arch/powerpc/boot/wiiu.c new file +73 -0

73 lines not on this page · raw message

arch/powerpc/boot/wrapper +4 -0
index 5bdd4dd20bbb..25fd60770659 100755
@@ -344,6 +344,10 @@ gamecube|wii)
     link_address='0x600000'
     platformo="$object/$platform-head.o $object/$platform.o"
     ;;
+wiiu)
+    link_address='0x600000'
+    platformo="$object/wiiu-head.o $object/$platform.o"
+    ;;
 microwatt)
     link_address='0x500000'
     platformo="$object/fixed-head.o $object/$platform.o"
Signature · 1 line
2.38.1
author
#77 lore raw

PATCH v4 4/11 powerpc: wiiu: introduce wiiu platform

In reply to Ash Logan

Adds empty platforms/wiiu for Nintendo Wii U console

---
v2->v3: Add help text for CONFIG_WIIU.

 arch/powerpc/platforms/Kconfig       | 1 +
 arch/powerpc/platforms/Makefile      | 1 +
 arch/powerpc/platforms/wiiu/Kconfig  | 8 ++++++++
 arch/powerpc/platforms/wiiu/Makefile | 1 +
 4 files changed, 11 insertions(+)
 create mode 100644 arch/powerpc/platforms/wiiu/Kconfig
 create mode 100644 arch/powerpc/platforms/wiiu/Makefile
arch/powerpc/platforms/Kconfig +1 -0
index d41dad227de8..c4a9c3c0b409 100644
@@ -22,6 +22,7 @@ source "arch/powerpc/platforms/40x/Kconfig"
 source "arch/powerpc/platforms/amigaone/Kconfig"
 source "arch/powerpc/platforms/book3s/Kconfig"
 source "arch/powerpc/platforms/microwatt/Kconfig"
+source "arch/powerpc/platforms/wiiu/Kconfig"
 
 config KVM_GUEST
 	bool "KVM Guest support"
arch/powerpc/platforms/Makefile +1 -0
index 94470fb27c99..944ddd938711 100644
@@ -24,3 +24,4 @@ obj-$(CONFIG_EMBEDDED6xx)	+= embedded6xx/
 obj-$(CONFIG_AMIGAONE)		+= amigaone/
 obj-$(CONFIG_PPC_BOOK3S)	+= book3s/
 obj-$(CONFIG_PPC_MICROWATT)	+= microwatt/
+obj-$(CONFIG_WIIU)		+= wiiu/
arch/powerpc/platforms/wiiu/Kconfig new file +8 -0
new file mode 100644
index 000000000000..3834834c6bd7
@@ -0,0 +1,8 @@
+# SPDX-License-Identifier: GPL-2.0
+
+config WIIU
+	bool "Nintendo Wii U"
+	depends on PPC_BOOK3S_32
+	help
+	  Select WIIU if configuring for the Nintendo Wii U.
+	  More information at: <https://linux-wiiu.org/>
arch/powerpc/platforms/wiiu/Makefile new file +1 -0
new file mode 100644
index 000000000000..f66554cd5c45
@@ -0,0 +1 @@
+# SPDX-License-Identifier: GPL-2.0
Signature · 1 line
2.38.1
author
#78 lore raw

PATCH v4 5/11 powerpc: wiiu: declare as non-coherent

In reply to Ash Logan

The Nintendo Wii U requires explicit cache handling when interfacing with DMA devices.

---
 arch/powerpc/platforms/Kconfig.cputype | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/powerpc/platforms/Kconfig.cputype +1 -1
index 0c4eed9aea80..ae1ee77705ea 100644
@@ -522,7 +522,7 @@ config NR_CPUS
 config NOT_COHERENT_CACHE
 	bool
 	depends on 4xx || PPC_8xx || PPC_MPC512x || \
-		GAMECUBE_COMMON || AMIGAONE
+		GAMECUBE_COMMON || AMIGAONE || WIIU
 	select ARCH_HAS_DMA_PREP_COHERENT
 	select ARCH_HAS_SYNC_DMA_FOR_DEVICE
 	select ARCH_HAS_SYNC_DMA_FOR_CPU
Signature · 1 line
2.38.1
author
#79 lore raw

PATCH v4 6/11 powerpc: wiiu: udbg support for latteipc

In reply to Ash Logan

Add support for using the Latte chipset IPC for udbg on the Nintendo Wii U console.
These messages can then be received by a special firmware running on the "Starbuck" coprocessor.

---
v2->v3: Fix a missing declaration issue by including latteipc_udbg.h. v3->v4: Add missing of.h includes.

 arch/powerpc/Kconfig.debug                  |   9 ++
 arch/powerpc/include/asm/udbg.h             |   1 +
 arch/powerpc/kernel/head_book3s_32.S        |  20 ++++
 arch/powerpc/kernel/udbg.c                  |   3 +
 arch/powerpc/platforms/wiiu/Kconfig         |  13 ++
 arch/powerpc/platforms/wiiu/Makefile        |   2 +
 arch/powerpc/platforms/wiiu/udbg_latteipc.c | 126 ++++++++++++++++++++
 arch/powerpc/platforms/wiiu/udbg_latteipc.h |  27 +++++
 8 files changed, 201 insertions(+)
 create mode 100644 arch/powerpc/platforms/wiiu/udbg_latteipc.c
 create mode 100644 arch/powerpc/platforms/wiiu/udbg_latteipc.h
arch/powerpc/Kconfig.debug +9 -0
index 6aaf8dc60610..b87343b0d1b4 100644
@@ -254,6 +254,15 @@ config PPC_EARLY_DEBUG_USBGECKO
 	  Select this to enable early debugging for Nintendo GameCube/Wii
 	  consoles via an external USB Gecko adapter.
 
+config PPC_EARLY_DEBUG_LATTEIPC
+	bool "Early debugging through Latte chipset IPC"
+	depends on WIIU
+	select LATTEIPC_UDBG
+	help
+	  Select this to enable early debugging for Nintendo Wii U consoles via
+	  chipset IPC to the security coprocessor. This assumes a firmware is
+	  running on the coprocessor to receive messages.
+
 config PPC_EARLY_DEBUG_PS3GELIC
 	bool "Early debugging through the PS3 Ethernet port"
 	depends on PPC_PS3
arch/powerpc/include/asm/udbg.h +1 -0
index b1f094728b35..ef1367f146fd 100644
@@ -53,6 +53,7 @@ void __init udbg_init_ps3gelic(void);
 void __init udbg_init_debug_opal_raw(void);
 void __init udbg_init_debug_opal_hvsi(void);
 void __init udbg_init_debug_16550(void);
+void __init udbg_init_latteipc(void);
 
 #endif /* __KERNEL__ */
 #endif /* _ASM_POWERPC_UDBG_H */
arch/powerpc/kernel/head_book3s_32.S +20 -0
index 519b60695167..5b3b1c971feb 100644
@@ -164,6 +164,9 @@ __after_mmu_off:
 #ifdef CONFIG_PPC_EARLY_DEBUG_USBGECKO
 	bl	setup_usbgecko_bat
 #endif
+#ifdef CONFIG_PPC_EARLY_DEBUG_LATTEIPC
+	bl	setup_latteipc_bat
+#endif
 
 /*
  * Call setup_cpu for CPU 0 and initialize 6xx Idle
@@ -1201,4 +1204,21 @@ setup_usbgecko_bat:
 	blr
 #endif
 
+#ifdef CONFIG_PPC_EARLY_DEBUG_LATTEIPC
+setup_latteipc_bat:
+	/* prepare a BAT for early io */
+	lis	r8, 0x0d80
+
+	/*
+	 * The virtual address used must match the virtual address
+	 * associated to the fixmap entry FIX_EARLY_DEBUG_BASE.
+	 */
+	lis	r11, 0xfffe	/* top 128K */
+	ori	r8, r8, 0x002a	/* uncached, guarded ,rw */
+	ori	r11, r11, 0x2	/* 128K, Vs=1, Vp=0 */
+	mtspr	SPRN_DBAT1L, r8
+	mtspr	SPRN_DBAT1U, r11
+	blr
+#endif
+
 	.data
arch/powerpc/kernel/udbg.c +3 -0
index 92b3fc258d11..b2ec88ef3cc1 100644
@@ -69,6 +69,9 @@ void __init udbg_early_init(void)
 	udbg_init_debug_opal_hvsi();
 #elif defined(CONFIG_PPC_EARLY_DEBUG_16550)
 	udbg_init_debug_16550();
+#elif defined(CONFIG_PPC_EARLY_DEBUG_LATTEIPC)
+	/* For use on Nintendo Wii U */
+	udbg_init_latteipc();
 #endif
 
 #ifdef CONFIG_PPC_EARLY_DEBUG
arch/powerpc/platforms/wiiu/Kconfig +13 -0
index 3834834c6bd7..8dfd6ac8774d 100644
@@ -6,3 +6,16 @@ config WIIU
 	help
 	  Select WIIU if configuring for the Nintendo Wii U.
 	  More information at: <https://linux-wiiu.org/>
+
+config LATTEIPC_UDBG
+	bool "Chipset IPC udbg console for the Nintendo Wii U"
+	depends on WIIU
+	help
+	  If you say yes to this option, support will be included for the
+	  Wii U's chipset IPC as a udbg console.
+	  These IPC messages can be received by a firmware running on the
+	  console's "Starbuck" security coprocessor.
+
+	  This driver bypasses the IPC layer completely.
+
+	  If in doubt, say N here.
arch/powerpc/platforms/wiiu/Makefile +2 -0
index f66554cd5c45..b1e0e1307f6e 100644
@@ -1 +1,3 @@
 # SPDX-License-Identifier: GPL-2.0
+
+obj-$(CONFIG_LATTEIPC_UDBG) += udbg_latteipc.o
arch/powerpc/platforms/wiiu/udbg_latteipc.c new file +126 -0

126 lines not on this page · raw message

arch/powerpc/platforms/wiiu/udbg_latteipc.h new file +27 -0
new file mode 100644
index 000000000000..ca6d34e49158
@@ -0,0 +1,27 @@
+/* SPDX-License-Identifier: GPL-2.0-or-later */
+/*
+ * Nintendo Wii U udbg support (to Starbuck coprocessor, via chipset IPC)
+ *
+ * Copyright (C) 2022 The linux-wiiu Team
+ *
+ * Based on arch/powerpc/platforms/embedded6xx/udbgecko_udbg.h
+ * Copyright (C) 2008-2009 The GameCube Linux Team
+ * Copyright (C) 2008-2009 Albert Herranz
+ */
+
+#ifndef __LATTEIPC_UDBG_H
+#define __LATTEIPC_UDBG_H
+
+#ifdef CONFIG_LATTEIPC_UDBG
+
+void __init latteipc_udbg_init(void);
+
+#else
+
+static inline void __init latteipc_udbg_init(void)
+{
+}
+
+#endif /* CONFIG_LATTEIPC_UDBG */
+
+#endif /* __LATTEIPC_UDBG_H */
Signature · 1 line
2.38.1
author
#80 lore raw

PATCH v4 7/11 powerpc: wiiu: espresso interrupt controller support

In reply to Ash Logan

Add support for the "Espresso" interrupt controller in the Nintendo Wii U.

---
 arch/powerpc/platforms/wiiu/Makefile       |   1 +
 arch/powerpc/platforms/wiiu/espresso-pic.c | 183 +++++++++++++++++++++
 arch/powerpc/platforms/wiiu/espresso-pic.h |  59 +++++++
 3 files changed, 243 insertions(+)
 create mode 100644 arch/powerpc/platforms/wiiu/espresso-pic.c
 create mode 100644 arch/powerpc/platforms/wiiu/espresso-pic.h
arch/powerpc/platforms/wiiu/Makefile +1 -0
index b1e0e1307f6e..aabf4b43e806 100644
@@ -1,3 +1,4 @@
 # SPDX-License-Identifier: GPL-2.0
 
+obj-$(CONFIG_WIIU) += espresso-pic.o
 obj-$(CONFIG_LATTEIPC_UDBG) += udbg_latteipc.o
arch/powerpc/platforms/wiiu/espresso-pic.c new file +183 -0

183 lines not on this page · raw message

arch/powerpc/platforms/wiiu/espresso-pic.h new file +59 -0

59 lines not on this page · raw message

Signature · 1 line
2.38.1
author
#81 lore raw

PATCH v4 8/11 powerpc: wiiu: latte interrupt controller support

In reply to Ash Logan

Add support for the "Latte" interrupt controller in the Nintendo Wii U. This controller is used for the entire SoC and is wired to a cascade interrupt on the Espresso controller.

---
v2->v3: Make latte_pic_get_irq static.

 arch/powerpc/platforms/wiiu/Kconfig     |   1 +
 arch/powerpc/platforms/wiiu/Makefile    |   2 +-
 arch/powerpc/platforms/wiiu/latte-pic.c | 259 ++++++++++++++++++++++++
 arch/powerpc/platforms/wiiu/latte-pic.h |  23 +++
 4 files changed, 284 insertions(+), 1 deletion(-)
 create mode 100644 arch/powerpc/platforms/wiiu/latte-pic.c
 create mode 100644 arch/powerpc/platforms/wiiu/latte-pic.h
arch/powerpc/platforms/wiiu/Kconfig +1 -0
index 8dfd6ac8774d..40ecba8396a7 100644
@@ -3,6 +3,7 @@
 config WIIU
 	bool "Nintendo Wii U"
 	depends on PPC_BOOK3S_32
+	select IRQ_DOMAIN_HIERARCHY
 	help
 	  Select WIIU if configuring for the Nintendo Wii U.
 	  More information at: <https://linux-wiiu.org/>
arch/powerpc/platforms/wiiu/Makefile +1 -1
index aabf4b43e806..fa16c60261e6 100644
@@ -1,4 +1,4 @@
 # SPDX-License-Identifier: GPL-2.0
 
-obj-$(CONFIG_WIIU) += espresso-pic.o
+obj-$(CONFIG_WIIU) += espresso-pic.o latte-pic.o
 obj-$(CONFIG_LATTEIPC_UDBG) += udbg_latteipc.o
arch/powerpc/platforms/wiiu/latte-pic.c new file +259 -0

259 lines not on this page · raw message

arch/powerpc/platforms/wiiu/latte-pic.h new file +23 -0
new file mode 100644
index 000000000000..7021d9497d35
@@ -0,0 +1,23 @@
+/* SPDX-License-Identifier: GPL-2.0-or-later */
+/*
+ * Nintendo Wii U "Latte" interrupt controller support
+ *
+ * Copyright (C) 2022 The linux-wiiu Team
+ */
+
+#ifndef __LATTE_PIC_H
+#define __LATTE_PIC_H
+
+struct lt_pic {
+	__be32 ahball_icr;	/* Triggered AHB IRQs (all) */
+	__be32 ahblt_icr;	/* Triggered AHB IRQs (latte only) */
+	__be32 ahball_imr;	/* Allowed AHB IRQs (all) */
+	__be32 ahblt_imr;	/* Allowed AHB IRQs (latte only) */
+} __packed;
+
+#define LATTE_AHBALL_NR_IRQS    32
+#define LATTE_AHBLT_NR_IRQS     32
+
+void latte_pic_init(void);
+
+#endif
Signature · 1 line
2.38.1
author
#82 lore raw

PATCH v4 9/11 powerpc: espresso processor support

In reply to Ash Logan

Adds a cputable entry for the "Espresso" processor found on the Nintendo Wii U, which has a PVR unrelated to other 750CL-like chips. Only this revision has been seen in the wild.

---
v3->v4: Move to new cpu_specs_*.h file.

 arch/powerpc/kernel/cpu_specs_book3s_32.h | 15 +++++++++++++++
 1 file changed, 15 insertions(+)
arch/powerpc/kernel/cpu_specs_book3s_32.h +15 -0
index 3714634d194a..c3cc0a019ba8 100644
@@ -275,6 +275,21 @@ static struct cpu_spec cpu_specs[] __initdata = {
 		.machine_check		= machine_check_generic,
 		.platform		= "ppc750",
 	},
+	{	/* "Espresso" (750CL-like) */
+		.pvr_mask		= 0xffffffff,
+		.pvr_value		= 0x70010201,
+		.cpu_name		= "Espresso",
+		.cpu_features		= CPU_FTRS_750CL,
+		.cpu_user_features	= COMMON_USER | PPC_FEATURE_PPC_LE,
+		.mmu_features		= MMU_FTR_HPTE_TABLE | MMU_FTR_USE_HIGH_BATS,
+		.icache_bsize		= 32,
+		.dcache_bsize		= 32,
+		.num_pmcs		= 4,
+		.pmc_type		= PPC_PMC_IBM,
+		.cpu_setup		= __setup_cpu_750,
+		.machine_check		= machine_check_generic,
+		.platform		= "ppc750",
+	},
 	{	/* 745/755 */
 		.pvr_mask		= 0xfffff000,
 		.pvr_value		= 0x00083000,
Signature · 1 line
2.38.1
author
#83 lore raw

PATCH v4 10/11 powerpc: wiiu: platform support

In reply to Ash Logan

Add platform support for the Nintendo Wii U console.

---
v2->v3: Use of_platform_default_populate instead of a custom match table.

 arch/powerpc/platforms/wiiu/Makefile |  2 +-
 arch/powerpc/platforms/wiiu/setup.c  | 60 ++++++++++++++++++++++++++++
 2 files changed, 61 insertions(+), 1 deletion(-)
 create mode 100644 arch/powerpc/platforms/wiiu/setup.c
arch/powerpc/platforms/wiiu/Makefile +1 -1
index fa16c60261e6..abcb7a1beebf 100644
@@ -1,4 +1,4 @@
 # SPDX-License-Identifier: GPL-2.0
 
-obj-$(CONFIG_WIIU) += espresso-pic.o latte-pic.o
+obj-$(CONFIG_WIIU) += setup.o espresso-pic.o latte-pic.o
 obj-$(CONFIG_LATTEIPC_UDBG) += udbg_latteipc.o
arch/powerpc/platforms/wiiu/setup.c new file +60 -0

60 lines not on this page · raw message

Signature · 1 line
2.38.1
author
#84 lore raw

PATCH v4 11/11 powerpc: wiiu: add minimal default config

In reply to Ash Logan

Adds a bare-minimum config to get a kernel compiled. Will need some more interesting options once a storage device to boot from is added.

---
 arch/powerpc/configs/wiiu_defconfig | 7 +++++++
 1 file changed, 7 insertions(+)
 create mode 100644 arch/powerpc/configs/wiiu_defconfig
arch/powerpc/configs/wiiu_defconfig new file +7 -0
new file mode 100644
index 000000000000..a761ebcdd9f2
@@ -0,0 +1,7 @@
+# CONFIG_PPC_CHRP is not set
+# CONFIG_PPC_PMAC is not set
+CONFIG_WIIU=y
+# CONFIG_PPC_OF_BOOT_TRAMPOLINE is not set
+CONFIG_HIGHMEM=y
+CONFIG_STRICT_KERNEL_RWX=y
+CONFIG_PPC_EARLY_DEBUG=y
Signature · 1 line
2.38.1