From nobody Tue Dec 23 14:13:02 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id DBE42C4332F for ; Sat, 19 Nov 2022 11:31:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232804AbiKSLbT (ORCPT ); Sat, 19 Nov 2022 06:31:19 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54752 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232528AbiKSLbJ (ORCPT ); Sat, 19 Nov 2022 06:31:09 -0500 Received: from relay9-d.mail.gandi.net (relay9-d.mail.gandi.net [217.70.183.199]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C16C517A82; Sat, 19 Nov 2022 03:31:06 -0800 (PST) Received: (Authenticated sender: ash@heyquark.com) by mail.gandi.net (Postfix) with ESMTPSA id E9449FF807; Sat, 19 Nov 2022 11:30:55 +0000 (UTC) From: Ash Logan To: krzysztof.kozlowski+dt@linaro.org, paulus@samba.org, mpe@ellerman.id.au, christophe.leroy@csgroup.eu, robh+dt@kernel.org, benh@kernel.crashing.org, segher@kernel.crashing.org, pali@kernel.org Cc: linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, j.ne@posteo.net, linkmauve@linkmauve.fr, rw-r-r-0644@protonmail.com, devicetree@vger.kernel.org, joel@jms.id.au Subject: [PATCH v4 01/11] dt-bindings: wiiu: Document the Nintendo Wii U devicetree Date: Sat, 19 Nov 2022 22:30:31 +1100 Message-Id: <20221119113041.284419-2-ash@heyquark.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221119113041.284419-1-ash@heyquark.com> References: <20220628133144.142185-1-ash@heyquark.com> <20221119113041.284419-1-ash@heyquark.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Adds schema for the various Wii U devicetree nodes used. Signed-off-by: Ash Logan --- 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 diff --git a/Documentation/devicetree/bindings/powerpc/nintendo/wiiu.yaml b= /Documentation/devicetree/bindings/powerpc/nintendo/wiiu.yaml new file mode 100644 index 000000000000..23703b1052d0 --- /dev/null +++ b/Documentation/devicetree/bindings/powerpc/nintendo/wiiu.yaml @@ -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 + - Emmanuel Gil Peyrot + +description: | + Nintendo Wii U video game console binding. + +properties: + $nodename: + const: "/" + + compatible: + const: nintendo,wiiu + +additionalProperties: true + +... diff --git a/Documentation/devicetree/bindings/powerpc/nintendo/wiiu/espres= so-pic.yaml b/Documentation/devicetree/bindings/powerpc/nintendo/wiiu/espre= sso-pic.yaml new file mode 100644 index 000000000000..476a8ccda7a1 --- /dev/null +++ b/Documentation/devicetree/bindings/powerpc/nintendo/wiiu/espresso-pic.= yaml @@ -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 + - Emmanuel Gil Peyrot + +description: | + Interrupt controller found on the Nintendo Wii U for the "Espresso" proc= essor. + +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 =3D "nintendo,espresso-pic"; + reg =3D <0x0c000078 0x18>; + #interrupt-cells =3D <1>; + interrupt-controller; + }; +... diff --git a/Documentation/devicetree/bindings/powerpc/nintendo/wiiu/gpu7.y= aml b/Documentation/devicetree/bindings/powerpc/nintendo/wiiu/gpu7.yaml new file mode 100644 index 000000000000..d44ebe0d866c --- /dev/null +++ b/Documentation/devicetree/bindings/powerpc/nintendo/wiiu/gpu7.yaml @@ -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 + - Emmanuel Gil Peyrot + +description: | + GPU7 graphics processor, also known as "GX2", found in the Latte multifu= nction 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 =3D "nintendo,latte-gpu7"; + reg =3D <0x0c200000 0x80000>; + interrupts =3D <2>; + interrupt-parent =3D <&espresso_pic>; + }; +... diff --git a/Documentation/devicetree/bindings/powerpc/nintendo/wiiu/latte-= ahci.yaml b/Documentation/devicetree/bindings/powerpc/nintendo/wiiu/latte-a= hci.yaml new file mode 100644 index 000000000000..a53971a11e89 --- /dev/null +++ b/Documentation/devicetree/bindings/powerpc/nintendo/wiiu/latte-ahci.ya= ml @@ -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 + - Emmanuel Gil Peyrot + +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 =3D "nintendo,latte-ahci"; + reg =3D <0x0d160400 0x408>; + + interrupt-parent =3D <&latte_pic>; + interrupts =3D <38>, <28>; + }; +... diff --git a/Documentation/devicetree/bindings/powerpc/nintendo/wiiu/latte-= dsp.yaml b/Documentation/devicetree/bindings/powerpc/nintendo/wiiu/latte-ds= p.yaml new file mode 100644 index 000000000000..772afe0c298c --- /dev/null +++ b/Documentation/devicetree/bindings/powerpc/nintendo/wiiu/latte-dsp.yaml @@ -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 + - Emmanuel Gil Peyrot + +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 =3D "nintendo,latte-dsp"; + reg =3D <0x0c005000 0x200>; + }; +... diff --git a/Documentation/devicetree/bindings/powerpc/nintendo/wiiu/latte-= pic.yaml b/Documentation/devicetree/bindings/powerpc/nintendo/wiiu/latte-pi= c.yaml new file mode 100644 index 000000000000..4b71d6b9b14d --- /dev/null +++ b/Documentation/devicetree/bindings/powerpc/nintendo/wiiu/latte-pic.yaml @@ -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 + - Emmanuel Gil Peyrot + +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 =3D "nintendo,latte-pic"; + #interrupt-cells =3D <1>; + interrupt-controller; + reg =3D <0x0d800440 0x30>; + + interrupt-parent =3D <&espresso_pic>; + interrupts =3D <24>; + }; +... diff --git a/Documentation/devicetree/bindings/powerpc/nintendo/wiiu/latte-= sdhci.yaml b/Documentation/devicetree/bindings/powerpc/nintendo/wiiu/latte-= sdhci.yaml new file mode 100644 index 000000000000..25d474fca679 --- /dev/null +++ b/Documentation/devicetree/bindings/powerpc/nintendo/wiiu/latte-sdhci.y= aml @@ -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 + - Emmanuel Gil Peyrot + +description: | + SDHCI hosts found on the Nintendo Wii U's Latte SoC for SD cards and SDI= O 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 =3D "nintendo,latte-sdhci", "sdhci"; + reg =3D <0x0d070000 0x200>; + interrupts =3D <7>; + interrupt-parent =3D <&latte_pic>; + }; +... diff --git a/Documentation/devicetree/bindings/powerpc/nintendo/wiiu/latte.= yaml b/Documentation/devicetree/bindings/powerpc/nintendo/wiiu/latte.yaml new file mode 100644 index 000000000000..6fdf93622fcc --- /dev/null +++ b/Documentation/devicetree/bindings/powerpc/nintendo/wiiu/latte.yaml @@ -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 + - Emmanuel Gil Peyrot + +description: | + Latte multi-function SoC, containing many of the devices found on the Ni= ntendo Wii U. + +allOf: + - $ref: "/schemas/simple-bus.yaml#" + +properties: + compatible: + items: + - const: nintendo,latte + - const: simple-bus + + +required: + - compatible + +additionalProperties: true + +... diff --git a/Documentation/devicetree/bindings/usb/generic-ehci.yaml b/Docu= mentation/devicetree/bindings/usb/generic-ehci.yaml index c5f629c5bc61..9f69b5ab21ff 100644 --- a/Documentation/devicetree/bindings/usb/generic-ehci.yaml +++ b/Documentation/devicetree/bindings/usb/generic-ehci.yaml @@ -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: --=20 2.38.1 From nobody Tue Dec 23 14:13:02 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3EC4DC4332F for ; Sat, 19 Nov 2022 11:31:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233069AbiKSLb0 (ORCPT ); Sat, 19 Nov 2022 06:31:26 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54876 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232895AbiKSLbQ (ORCPT ); Sat, 19 Nov 2022 06:31:16 -0500 Received: from relay9-d.mail.gandi.net (relay9-d.mail.gandi.net [217.70.183.199]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E30E822280; Sat, 19 Nov 2022 03:31:12 -0800 (PST) Received: (Authenticated sender: ash@heyquark.com) by mail.gandi.net (Postfix) with ESMTPSA id 65874FF804; Sat, 19 Nov 2022 11:31:03 +0000 (UTC) From: Ash Logan To: krzysztof.kozlowski+dt@linaro.org, paulus@samba.org, mpe@ellerman.id.au, christophe.leroy@csgroup.eu, robh+dt@kernel.org, benh@kernel.crashing.org, segher@kernel.crashing.org, pali@kernel.org Cc: linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, j.ne@posteo.net, linkmauve@linkmauve.fr, rw-r-r-0644@protonmail.com, devicetree@vger.kernel.org, joel@jms.id.au Subject: [PATCH v4 02/11] powerpc: wiiu: device tree Date: Sat, 19 Nov 2022 22:30:32 +1100 Message-Id: <20221119113041.284419-3-ash@heyquark.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221119113041.284419-1-ash@heyquark.com> References: <20220628133144.142185-1-ash@heyquark.com> <20221119113041.284419-1-ash@heyquark.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Add a device tree source file for the Nintendo Wii U video game console. Signed-off-by: Ash Logan Co-developed-by: Roberto Van Eeden Signed-off-by: Roberto Van Eeden Co-developed-by: Emmanuel Gil Peyrot Signed-off-by: Emmanuel Gil Peyrot --- 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 diff --git a/arch/powerpc/boot/dts/wiiu.dts b/arch/powerpc/boot/dts/wiiu.dts new file mode 100644 index 000000000000..ee25b0855374 --- /dev/null +++ b/arch/powerpc/boot/dts/wiiu.dts @@ -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 +#include + +/ { + model =3D "nintendo,wup-101"; + compatible =3D "nintendo,wiiu"; + + #address-cells =3D <1>; + #size-cells =3D <1>; + + memory@0 { + device_type =3D "memory"; + reg =3D <0x00000000 0x02000000 /* MEM1 - 32MiB */ + 0x08000000 0x00300000 /* MEM0 - 3MiB */ + 0x10000000 0x80000000>; /* MEM2 - 2GiB */ + }; + + cpus { + #address-cells =3D <1>; + #size-cells =3D <0>; + + /* TODO: Add SMP */ + PowerPC,espresso@0 { + device_type =3D "cpu"; + reg =3D <0>; + clock-frequency =3D <1243125000>; /* 1.243125GHz */ + bus-frequency =3D <248625000>; /* 248.625MHz core-to-bus 5x */ + timebase-frequency =3D <62156250>; /* 1/4 of the bus clock */ + i-cache-size =3D <32768>; /* 32K icache */ + i-cache-line-size =3D <32>; + i-cache-block-size =3D <32>; + i-cache-sets =3D <128>; + d-cache-size =3D <32768>; /* 32K dcache */ + d-cache-line-size =3D <32>; + d-cache-block-size =3D <32>; + d-cache-sets =3D <128>; + next-level-cache =3D <&L2_0>; + L2_0:l2-cache { + compatible =3D "cache"; + cache-level =3D <2>; + cache-unified; + cache-size =3D <0x80000>; /* 512KB L2 */ + cache-line-size =3D <64>; + cache-block-size =3D <32>; + cache-sets =3D <2048>; + }; + }; + }; + + soc { + compatible =3D "nintendo,latte", "simple-bus"; + ranges =3D <0x0c000000 0x0c000000 0x00400000 /* Espresso-only registers = */ + 0x0d000000 0x0d000000 0x00200000 /* Latte AHB deivces */ + 0x0d800000 0x0d800000 0x00800000>; /* Latte SoC registers */ + + #address-cells =3D <1>; + #size-cells =3D <1>; + + latte_gpu: gpu@c200000 { + compatible =3D "nintendo,latte-gpu7"; + reg =3D <0x0c200000 0x80000>; + interrupts =3D <2>; + interrupt-parent =3D <&espresso_pic>; + }; + + espresso_pic: interrupt-controller@c000078 { + compatible =3D "nintendo,espresso-pic"; + reg =3D <0x0c000078 0x18>; + #interrupt-cells =3D <1>; + interrupt-controller; + }; + + latte_dsp: dsp@c005000 { + compatible =3D "nintendo,latte-dsp"; + reg =3D <0x0c005000 0x200>; + }; + + ehci_0: usb@d040000 { + compatible =3D "nintendo,latte-ehci", "usb-ehci"; + reg =3D <0x0d040000 0x100>; + interrupts =3D <4>; + interrupt-parent =3D <&latte_pic>; + big-endian-regs; + }; + + ohci_0_0: usb@d050000 { + compatible =3D "nintendo,latte-ohci"; + reg =3D <0x0d050000 0x100>; + interrupts =3D <5>; + interrupt-parent =3D <&latte_pic>; + big-endian-regs; + }; + + ohci_0_1: usb@d060000 { + compatible =3D "nintendo,latte-ohci"; + reg =3D <0x0d060000 0x100>; + interrupts =3D <6>; + interrupt-parent =3D <&latte_pic>; + big-endian-regs; + }; + + ehci_1: usb@d120000 { + compatible =3D "nintendo,latte-ehci", "usb-ehci"; + reg =3D <0x0d120000 0x100>; + interrupts =3D <16>; + interrupt-parent =3D <&latte_pic>; + big-endian-regs; + }; + + ohci_1_0: usb@d130000 { + compatible =3D "nintendo,latte-ohci"; + reg =3D <0x0d130000 0x100>; + interrupts =3D <35>; + interrupt-parent =3D <&latte_pic>; + big-endian-regs; + }; + + ehci_2: usb@d140000 { + compatible =3D "nintendo,latte-ehci", "usb-ehci"; + reg =3D <0x0d140000 0x100>; + interrupts =3D <36>; + interrupt-parent =3D <&latte_pic>; + big-endian-regs; + }; + + ohci_2_0: usb@d150000 { + compatible =3D "nintendo,latte-ohci"; + reg =3D <0x0d150000 0x100>; + interrupts =3D <37>; + interrupt-parent =3D <&latte_pic>; + + big-endian-regs; + }; + + sdcard_0: mmc@d070000 { + compatible =3D "nintendo,latte-sdhci","sdhci"; + reg =3D <0x0d070000 0x200>; + interrupts =3D <7>; + interrupt-parent =3D <&latte_pic>; + }; + + wifi_0: mmc@d080000 { + compatible =3D "nintendo,latte-sdhci","sdhci"; + reg =3D <0x0d080000 0x200>; + interrupts =3D <8>; + interrupt-parent =3D <&latte_pic>; + }; + + legacy_ipc: ipc@d800000 { + compatible =3D "nintendo,latte-ipc", "nintendo,hollywood-ipc"; + reg =3D <0x0d800000 0x10>; + interrupts =3D <30 31>; + interrupt-parent =3D <&latte_pic>; + }; + + latte_otp: otp@d8001ec { + compatible =3D "nintendo,latte-otp"; + reg =3D <0x0d8001ec 0x8>; + }; + + sata@d160400 { + compatible =3D "nintendo,latte-ahci"; + reg =3D <0x0d160400 0x808>; + + interrupt-parent =3D <&latte_pic>; + interrupts =3D <38 28>; + }; + + latte_pic: interrupt-controller@d800440 { + #interrupt-cells =3D <1>; + interrupt-controller; + + compatible =3D "nintendo,latte-pic"; + reg =3D <0x0d800440 0x30>; + interrupt-parent =3D <&espresso_pic>; + interrupts =3D <24>; + }; + + gpio: gpio@d8000c0 { + #gpio-cells =3D <2>; + compatible =3D "nintendo,latte-gpio", "nintendo,hollywood-gpio"; + + reg =3D <0x0d8000c0 0x40>; + gpio-controller; + /* TODO: There are actually 31 AHBALL GPIOs */ + ngpios =3D <24>; + + gpio-line-names =3D + "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 =3D <2>; + interrupts =3D <10>; + interrupt-parent =3D <&latte_pic>; + }; + + gpio2: gpio@d800520 { + #gpio-cells =3D <2>; + compatible =3D "nintendo,latte-gpio", "nintendo,hollywood-gpio"; + + reg =3D <0x0d800520 0x40>; + gpio-controller; + ngpios =3D <7>; + + gpio-line-names =3D + "FANSPEED", "SMC_SCL", "SMC_SDA", "DC_DC2", + "AVE_INT", "", "AVE_RESET"; + + interrupt-controller; + #interrupt-cells =3D <2>; + interrupts =3D <10>; + interrupt-parent =3D <&latte_pic>; + }; + }; + + spi_gpio: spi { + compatible =3D "spi-gpio"; + #address-cells =3D <1>; + #size-cells =3D <0>; + + cs-gpios =3D <&gpio 10 GPIO_ACTIVE_HIGH>; + sck-gpios =3D <&gpio 11 GPIO_ACTIVE_HIGH>; + mosi-gpios =3D <&gpio 12 GPIO_ACTIVE_HIGH>; + miso-gpios =3D <&gpio 13 GPIO_ACTIVE_HIGH>; + num-chipselects =3D <1>; + + eeprom@0 { + compatible =3D "atmel,at93c66"; + reg =3D <0>; + spi-max-frequency =3D <1000000>; + spi-cs-high; + /* TODO: wiiubrew says this is 16-bit, but I only get the correct + * values in 8-bit... + */ + data-size =3D <8>; + read-only; + + #address-cells =3D <1>; + #size-cells =3D <1>; + + /* https://wiiubrew.org/wiki/Hardware/SEEPROM */ + rng_seed: rng@12 { reg =3D <0x012 8>; }; + ppc_pvr: pvr@20 { reg =3D <0x020 4>; }; + seeprom_ver_str: sver-str@24 { reg =3D <0x024 6>; }; + seeprom_ver: sver@2a { reg =3D <0x02A 2>; }; + otp_ver: over@2c { reg =3D <0x02C 2>; }; + otp_rev: orev@2e { reg =3D <0x02E 2>; }; + otp_ver_str: over-str@30 { reg =3D <0x030 8>; }; + + bc_crc: bc-crc@38 { reg =3D <0x038 4>; }; + bc_sz: bc-sz@3c { reg =3D <0x03C 2>; }; + bc_ver: bc-ver@3e { reg =3D <0x03E 2>; }; + bc_boardtype: boardtype@42 { reg =3D <0x042 2>; }; + bc_boardrev: boardrev@44 { reg =3D <0x044 2>; }; + bc_bootsource: bootsource@46 { reg =3D <0x046 2>; }; + bc_ddr3size: ddr3size@48 { reg =3D <0x048 2>; }; + bc_ddr3speed: ddr3speed@4a { reg =3D <0x04A 2>; }; + bc_ppcclockmul: ppcclockmul@4c { reg =3D <0x04C 2>; }; + bc_iopclockmul: iopclockmul@46 { reg =3D <0x04E 2>; }; + bc_video1080p: video1080p@50 { reg =3D <0x050 2>; }; + bc_ddr3vendor: ddr3vendor@52 { reg =3D <0x052 2>; }; + bc_movpassivereset: movpassivereset@54 { reg =3D <0x054 2>; }; + bc_syspllspd: syspllspd@56 { reg =3D <0x056 2>; }; + bc_satadevice: satadevice@58 { reg =3D <0x058 2>; }; + bc_consoletype: consoletype@5a { reg =3D <0x05A 2>; }; + bc_deviceprescence: deviceprescence@5c { reg =3D <0x05C 2>; }; + + drive_key: drvkey@80 { reg =3D <0x080 16>; }; + factory_key: fackey@90 { reg =3D <0x090 16>; }; + shdd_key: shddkey@a0 { reg =3D <0x0A0 16>; }; + usb_key_seed: usbkeyseed@b0 { reg =3D <0x0B0 16>; }; + drive_key_flag: drvkeyf@c0 { reg =3D <0x0C0 2>; }; + usb_key_flag: udbkeyf@c2 { reg =3D <0x0C2 2>; }; + shdd_key_flag: shddkeyf@c4 { reg =3D <0x0C4 2>; }; + + sysprod_version: sp_ver@140 { reg =3D <0x140 4>; }; + sysprod_eeprom_version: sp_ee_ver@144 { reg =3D <0x144 4>; }; + sysprod_product_area: sp_parea@148 { reg =3D <0x148 4>; }; + sysprod_game_region: sp_region@14c { reg =3D <0x14C 4>; }; + sysprod_ntsc_pal: sp_ntscpal@150 { reg =3D <0x150 4>; }; + sysprod_5ghz_country: sp_5ghz_c@154 { reg =3D <0x154 2>; }; + sysprod_5ghz_country_rev: sp_5ghz_crev@156 { reg =3D <0x156 2>; }; + sysprod_code: sp_code@158 { reg =3D <0x158 8>; }; + sysprod_serial: sp_serial@160 { reg =3D <0x160 16>; }; + sysprod_model: sp_model@170 { reg =3D <0x170 16>; }; + + prod_year: pyear@188 { reg =3D <0x188 2>; }; + prod_date: pdate@18a { reg =3D <0x18A 2>; }; + prod_time: ptime@18c { reg =3D <0x18C 2>; }; + + boot_params: boot_params@1c0 { reg =3D <0x1C0 48>; }; + }; + }; + + /* TODO make this gpio-keyed once hollywood-gpio supports interrupts */ + gpio-keys { + poll-interval =3D <50>; + compatible =3D "gpio-keys-polled"; + + key-power { + label =3D "Power Button"; + gpios =3D <&gpio 0 GPIO_ACTIVE_HIGH>; + linux,code =3D ; + }; + }; +}; --=20 2.38.1 From nobody Tue Dec 23 14:13:02 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id F3A41C433FE for ; Sat, 19 Nov 2022 11:31:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233034AbiKSLba (ORCPT ); Sat, 19 Nov 2022 06:31:30 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54890 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232670AbiKSLbW (ORCPT ); Sat, 19 Nov 2022 06:31:22 -0500 Received: from relay9-d.mail.gandi.net (relay9-d.mail.gandi.net [217.70.183.199]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EF60C13D1D; Sat, 19 Nov 2022 03:31:20 -0800 (PST) Received: (Authenticated sender: ash@heyquark.com) by mail.gandi.net (Postfix) with ESMTPSA id 7255EFF80B; Sat, 19 Nov 2022 11:31:12 +0000 (UTC) From: Ash Logan To: krzysztof.kozlowski+dt@linaro.org, paulus@samba.org, mpe@ellerman.id.au, christophe.leroy@csgroup.eu, robh+dt@kernel.org, benh@kernel.crashing.org, segher@kernel.crashing.org, pali@kernel.org Cc: linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, j.ne@posteo.net, linkmauve@linkmauve.fr, rw-r-r-0644@protonmail.com, devicetree@vger.kernel.org, joel@jms.id.au Subject: [PATCH v4 03/11] powerpc: wiiu: bootwrapper support Date: Sat, 19 Nov 2022 22:30:33 +1100 Message-Id: <20221119113041.284419-4-ash@heyquark.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221119113041.284419-1-ash@heyquark.com> References: <20220628133144.142185-1-ash@heyquark.com> <20221119113041.284419-1-ash@heyquark.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Add support for the Nintendo Wii U game console to the powerpc bootwrapper. Signed-off-by: Ash Logan Co-developed-by: Emmanuel Gil Peyrot Signed-off-by: Emmanuel Gil Peyrot --- 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 diff --git a/arch/powerpc/boot/Makefile b/arch/powerpc/boot/Makefile index d32d95aea5d6..42f622945b4a 100644 --- a/arch/powerpc/boot/Makefile +++ b/arch/powerpc/boot/Makefile @@ -162,6 +162,7 @@ src-plat-$(CONFIG_EMBEDDED6xx) +=3D 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) +=3D wiiu-head.S wiiu.c src-plat-$(CONFIG_AMIGAONE) +=3D cuboot-amigaone.c src-plat-$(CONFIG_PPC_PS3) +=3D ps3-head.S ps3-hvcall.S ps3.c src-plat-$(CONFIG_EPAPR_BOOT) +=3D epapr.c epapr-wrapper.c @@ -360,6 +361,9 @@ image-$(CONFIG_GAMECUBE) +=3D dtbImage.gamecube image-$(CONFIG_WII) +=3D dtbImage.wii image-$(CONFIG_MVME5100) +=3D dtbImage.mvme5100 =20 +# Board port in arch/powerpc/platform/wiiu/Kconfig +image-$(CONFIG_WIIU) +=3D dtbImage.wiiu + # Board port in arch/powerpc/platform/amigaone/Kconfig image-$(CONFIG_AMIGAONE) +=3D cuImage.amigaone =20 diff --git a/arch/powerpc/boot/wiiu-head.S b/arch/powerpc/boot/wiiu-head.S new file mode 100644 index 000000000000..8586e2e992d5 --- /dev/null +++ b/arch/powerpc/boot/wiiu-head.S @@ -0,0 +1,103 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * Entrypoint head asm + * This code expects to be called directly after the Espresso BootROM, whi= ch implies certain MSR + * states. + * + * Nintendo Wii U bootwrapper support + * Copyright (C) 2022 The linux-wiiu Team + */ + +#include "ppc_asm.h" + +.text +.global _zimage_start +_zimage_start: + /* Clear out all BATs. MMU is already off. */ + li r8, 0 + + mtspr 0x210, r8 /* IBAT0U */ + mtspr 0x212, r8 /* IBAT1U */ + mtspr 0x214, r8 /* IBAT2U */ + mtspr 0x216, r8 /* IBAT3U */ + mtspr 0x218, r8 /* DBAT0U */ + mtspr 0x21a, r8 /* DBAT1U */ + mtspr 0x21c, r8 /* DBAT2U */ + mtspr 0x21e, r8 /* DBAT3U */ + + mtspr 0x230, r8 /* IBAT4U */ + mtspr 0x232, r8 /* IBAT5U */ + mtspr 0x234, r8 /* IBAT6U */ + mtspr 0x236, r8 /* IBAT7U */ + mtspr 0x238, r8 /* DBAT4U */ + mtspr 0x23a, r8 /* DBAT5U */ + mtspr 0x23c, r8 /* DBAT6U */ + mtspr 0x23e, r8 /* DBAT7U */ + + /* MEM1 */ + /* 32MB, starting at 0x00000000... */ + li r8, 0x000003ff@l + mtspr 0x21a, r8 /* DBAT1U */ + mtspr 0x212, r8 /* IBAT1U */ + + /* mapped into phys 0x00000000; read-write; normal caching. */ + li r8, 0x00000002@l + mtspr 0x21b, r8 /* DBAT1L */ + mtspr 0x213, r8 /* IBAT1L */ + + /* Latte MMIO area */ + /* 64MB, starting at 0x0d800000... */ + lis r8, 0x0d8007ff@h + ori r8, r8,0x0d800007ff@l + mtspr 0x21c, r8 /* DBAT2U */ + + /* mapped into phys 0x0d800000; read-write; writethrough/nocache/guard*/ + lis r8, 0x0d80006A@h + ori r8, r8,0x0d80006A@l + mtspr 0x21d, r8 /* DBAT2L */ + + /* Bootloader comms area (actually 0x89200000) */ + /* 128MiB, starting at 0x88000000... */ + lis r8, 0x88000fff@h + ori r8, r8, 0x88000fff@l + mtspr 0x21e, r8 /* DBAT3U */ + + /* mapped into phys 0x88000000; read-write; normal caching. */ + lis r8, 0x88000002@h + ori r8, r8, 0x88000002@l + mtspr 0x21f, r8 /* DBAT3L */ + + /* Turn on BAT 4 through 7, configure CPU */ + mfspr r8, 0x3f3 /* HID4 */ + oris r8, r8, 0x3200 /* L2FM: 64-byte fetch, BPD: max depth is 4, SBE */ + mtspr 0x3f3, r8 + + /* Turn on and invalidate caches */ + mfspr r8, 0x3f0 /* HID0 */ + /* HID0_ICE | HID0_ICFI | HID0_DCE | HID0_DCFI */ + ori r8, r8, (1 << 15) | (1 << 11) | (1 << 14) | (1 << 10) + mtspr 0x3f0, r8 + isync + + li r3, 0 + li r4, 0 + li r5, 0 + + bl get_lr +get_lr: + mflr r8 + /* Get absolute address of done */ + addi r8, r8, done - get_lr + + /* Set up MSR */ + /* MSR_DR | MSR_IR | MSR_FP */ + /* Data/instruction MMUs, FPU because why not */ + ori r9, r3, (1 << 4) | (1 << 5) | (1 << 13) + + /* Apply our new MSR, starting execution at "done" */ + mtsrr0 r8 + mtsrr1 r9 + sync + rfi +done: + b _zimage_start_lib diff --git a/arch/powerpc/boot/wiiu.c b/arch/powerpc/boot/wiiu.c new file mode 100644 index 000000000000..fe88eb2c42ae --- /dev/null +++ b/arch/powerpc/boot/wiiu.c @@ -0,0 +1,73 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Platform support and IPC debug console to linux-loader (on Starbuck) + * + * Nintendo Wii U bootwrapper support + * Copyright (C) 2022 The linux-wiiu Team + */ + +#include +#include "string.h" +#include "stdio.h" +#include "types.h" +#include "io.h" +#include "ops.h" + +BSS_STACK(8192); + +// Volatile is used here since the io.h routines require it +#define LT_IPC_PPCMSG ((volatile u32 *)0x0d800000) +#define LT_IPC_PPCCTRL ((volatile u32 *)0x0d800004) +#define LT_IPC_PPCCTRL_X1 0x1 + +#define WIIU_LOADER_CMD_PRINT 0x01000000 + +static void wiiu_ipc_sendmsg(int msg) +{ + out_be32(LT_IPC_PPCMSG, msg); + out_be32(LT_IPC_PPCCTRL, LT_IPC_PPCCTRL_X1); + while (in_be32(LT_IPC_PPCCTRL) & LT_IPC_PPCCTRL_X1) + barrier(); +} + +/* + * Send logging string out over IPC to linux-loader for early printing. + * Packs 3 chars at a time where possible. + */ +static void wiiu_write_ipc(const char *buf, int len) +{ + int i =3D 0; + + for (i =3D 0; i + 2 < len; i +=3D 3) { + int msg =3D WIIU_LOADER_CMD_PRINT | (buf[i + 0] << 16) | + (buf[i + 1] << 8) | buf[i + 2]; + + wiiu_ipc_sendmsg(msg); + } + + if (i < len) { + for (; i < len; i++) { + int msg =3D WIIU_LOADER_CMD_PRINT | (buf[i] << 16); + + wiiu_ipc_sendmsg(msg); + } + } +} + +/* + * Note 32MiB heap - not ideal but seems fine for the bootwrapper + */ +void platform_init(unsigned int r3, unsigned int r4, unsigned int r5) +{ + u32 heapsize; + + console_ops.write =3D wiiu_write_ipc; + printf("wiiu: bootwrapper ok\n"); + + heapsize =3D 32 * 1024 * 1024 - (u32)_end; + simple_alloc_init(_end, heapsize, 32, 64); + printf("wiiu: heap ok\n"); + + fdt_init(_dtb_start); + printf("wiiu: dtb ok\n"); +} diff --git a/arch/powerpc/boot/wrapper b/arch/powerpc/boot/wrapper index 5bdd4dd20bbb..25fd60770659 100755 --- a/arch/powerpc/boot/wrapper +++ b/arch/powerpc/boot/wrapper @@ -344,6 +344,10 @@ gamecube|wii) link_address=3D'0x600000' platformo=3D"$object/$platform-head.o $object/$platform.o" ;; +wiiu) + link_address=3D'0x600000' + platformo=3D"$object/wiiu-head.o $object/$platform.o" + ;; microwatt) link_address=3D'0x500000' platformo=3D"$object/fixed-head.o $object/$platform.o" --=20 2.38.1 From nobody Tue Dec 23 14:13:02 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 15DE3C433FE for ; Sat, 19 Nov 2022 11:31:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233522AbiKSLbu (ORCPT ); Sat, 19 Nov 2022 06:31:50 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55000 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233122AbiKSLbm (ORCPT ); Sat, 19 Nov 2022 06:31:42 -0500 Received: from relay9-d.mail.gandi.net (relay9-d.mail.gandi.net [217.70.183.199]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 55C1B922F1; Sat, 19 Nov 2022 03:31:31 -0800 (PST) Received: (Authenticated sender: ash@heyquark.com) by mail.gandi.net (Postfix) with ESMTPSA id 7F523FF805; Sat, 19 Nov 2022 11:31:20 +0000 (UTC) From: Ash Logan To: krzysztof.kozlowski+dt@linaro.org, paulus@samba.org, mpe@ellerman.id.au, christophe.leroy@csgroup.eu, robh+dt@kernel.org, benh@kernel.crashing.org, segher@kernel.crashing.org, pali@kernel.org Cc: linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, j.ne@posteo.net, linkmauve@linkmauve.fr, rw-r-r-0644@protonmail.com, devicetree@vger.kernel.org, joel@jms.id.au Subject: [PATCH v4 04/11] powerpc: wiiu: introduce wiiu platform Date: Sat, 19 Nov 2022 22:30:34 +1100 Message-Id: <20221119113041.284419-5-ash@heyquark.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221119113041.284419-1-ash@heyquark.com> References: <20220628133144.142185-1-ash@heyquark.com> <20221119113041.284419-1-ash@heyquark.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Adds empty platforms/wiiu for Nintendo Wii U console Signed-off-by: Ash Logan --- 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 diff --git a/arch/powerpc/platforms/Kconfig b/arch/powerpc/platforms/Kconfig index d41dad227de8..c4a9c3c0b409 100644 --- a/arch/powerpc/platforms/Kconfig +++ b/arch/powerpc/platforms/Kconfig @@ -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" =20 config KVM_GUEST bool "KVM Guest support" diff --git a/arch/powerpc/platforms/Makefile b/arch/powerpc/platforms/Makef= ile index 94470fb27c99..944ddd938711 100644 --- a/arch/powerpc/platforms/Makefile +++ b/arch/powerpc/platforms/Makefile @@ -24,3 +24,4 @@ obj-$(CONFIG_EMBEDDED6xx) +=3D embedded6xx/ obj-$(CONFIG_AMIGAONE) +=3D amigaone/ obj-$(CONFIG_PPC_BOOK3S) +=3D book3s/ obj-$(CONFIG_PPC_MICROWATT) +=3D microwatt/ +obj-$(CONFIG_WIIU) +=3D wiiu/ diff --git a/arch/powerpc/platforms/wiiu/Kconfig b/arch/powerpc/platforms/w= iiu/Kconfig new file mode 100644 index 000000000000..3834834c6bd7 --- /dev/null +++ b/arch/powerpc/platforms/wiiu/Kconfig @@ -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: diff --git a/arch/powerpc/platforms/wiiu/Makefile b/arch/powerpc/platforms/= wiiu/Makefile new file mode 100644 index 000000000000..f66554cd5c45 --- /dev/null +++ b/arch/powerpc/platforms/wiiu/Makefile @@ -0,0 +1 @@ +# SPDX-License-Identifier: GPL-2.0 --=20 2.38.1 From nobody Tue Dec 23 14:13:02 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id AEC2EC433FE for ; Sat, 19 Nov 2022 11:32:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233339AbiKSLcI (ORCPT ); Sat, 19 Nov 2022 06:32:08 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55000 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232705AbiKSLbr (ORCPT ); Sat, 19 Nov 2022 06:31:47 -0500 Received: from relay9-d.mail.gandi.net (relay9-d.mail.gandi.net [217.70.183.199]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EE77E14036; Sat, 19 Nov 2022 03:31:40 -0800 (PST) Received: (Authenticated sender: ash@heyquark.com) by mail.gandi.net (Postfix) with ESMTPSA id A8A86FF807; Sat, 19 Nov 2022 11:31:28 +0000 (UTC) From: Ash Logan To: krzysztof.kozlowski+dt@linaro.org, paulus@samba.org, mpe@ellerman.id.au, christophe.leroy@csgroup.eu, robh+dt@kernel.org, benh@kernel.crashing.org, segher@kernel.crashing.org, pali@kernel.org Cc: linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, j.ne@posteo.net, linkmauve@linkmauve.fr, rw-r-r-0644@protonmail.com, devicetree@vger.kernel.org, joel@jms.id.au Subject: [PATCH v4 05/11] powerpc: wiiu: declare as non-coherent Date: Sat, 19 Nov 2022 22:30:35 +1100 Message-Id: <20221119113041.284419-6-ash@heyquark.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221119113041.284419-1-ash@heyquark.com> References: <20220628133144.142185-1-ash@heyquark.com> <20221119113041.284419-1-ash@heyquark.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" The Nintendo Wii U requires explicit cache handling when interfacing with DMA devices. Signed-off-by: Ash Logan --- arch/powerpc/platforms/Kconfig.cputype | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/powerpc/platforms/Kconfig.cputype b/arch/powerpc/platform= s/Kconfig.cputype index 0c4eed9aea80..ae1ee77705ea 100644 --- a/arch/powerpc/platforms/Kconfig.cputype +++ b/arch/powerpc/platforms/Kconfig.cputype @@ -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 --=20 2.38.1 From nobody Tue Dec 23 14:13:02 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2883FC4332F for ; Sat, 19 Nov 2022 11:32:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234063AbiKSLcT (ORCPT ); Sat, 19 Nov 2022 06:32:19 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55674 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233943AbiKSLbu (ORCPT ); Sat, 19 Nov 2022 06:31:50 -0500 Received: from relay9-d.mail.gandi.net (relay9-d.mail.gandi.net [217.70.183.199]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2486A1C900; Sat, 19 Nov 2022 03:31:47 -0800 (PST) Received: (Authenticated sender: ash@heyquark.com) by mail.gandi.net (Postfix) with ESMTPSA id 92C19FF809; Sat, 19 Nov 2022 11:31:36 +0000 (UTC) From: Ash Logan To: krzysztof.kozlowski+dt@linaro.org, paulus@samba.org, mpe@ellerman.id.au, christophe.leroy@csgroup.eu, robh+dt@kernel.org, benh@kernel.crashing.org, segher@kernel.crashing.org, pali@kernel.org Cc: linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, j.ne@posteo.net, linkmauve@linkmauve.fr, rw-r-r-0644@protonmail.com, devicetree@vger.kernel.org, joel@jms.id.au Subject: [PATCH v4 06/11] powerpc: wiiu: udbg support for latteipc Date: Sat, 19 Nov 2022 22:30:36 +1100 Message-Id: <20221119113041.284419-7-ash@heyquark.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221119113041.284419-1-ash@heyquark.com> References: <20220628133144.142185-1-ash@heyquark.com> <20221119113041.284419-1-ash@heyquark.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" 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. Signed-off-by: Ash Logan --- 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 diff --git a/arch/powerpc/Kconfig.debug b/arch/powerpc/Kconfig.debug index 6aaf8dc60610..b87343b0d1b4 100644 --- a/arch/powerpc/Kconfig.debug +++ b/arch/powerpc/Kconfig.debug @@ -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. =20 +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 diff --git a/arch/powerpc/include/asm/udbg.h b/arch/powerpc/include/asm/udb= g.h index b1f094728b35..ef1367f146fd 100644 --- a/arch/powerpc/include/asm/udbg.h +++ b/arch/powerpc/include/asm/udbg.h @@ -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); =20 #endif /* __KERNEL__ */ #endif /* _ASM_POWERPC_UDBG_H */ diff --git a/arch/powerpc/kernel/head_book3s_32.S b/arch/powerpc/kernel/hea= d_book3s_32.S index 519b60695167..5b3b1c971feb 100644 --- a/arch/powerpc/kernel/head_book3s_32.S +++ b/arch/powerpc/kernel/head_book3s_32.S @@ -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 =20 /* * Call setup_cpu for CPU 0 and initialize 6xx Idle @@ -1201,4 +1204,21 @@ setup_usbgecko_bat: blr #endif =20 +#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=3D1, Vp=3D0 */ + mtspr SPRN_DBAT1L, r8 + mtspr SPRN_DBAT1U, r11 + blr +#endif + .data diff --git a/arch/powerpc/kernel/udbg.c b/arch/powerpc/kernel/udbg.c index 92b3fc258d11..b2ec88ef3cc1 100644 --- a/arch/powerpc/kernel/udbg.c +++ b/arch/powerpc/kernel/udbg.c @@ -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 =20 #ifdef CONFIG_PPC_EARLY_DEBUG diff --git a/arch/powerpc/platforms/wiiu/Kconfig b/arch/powerpc/platforms/w= iiu/Kconfig index 3834834c6bd7..8dfd6ac8774d 100644 --- a/arch/powerpc/platforms/wiiu/Kconfig +++ b/arch/powerpc/platforms/wiiu/Kconfig @@ -6,3 +6,16 @@ config WIIU help Select WIIU if configuring for the Nintendo Wii U. More information at: + +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. diff --git a/arch/powerpc/platforms/wiiu/Makefile b/arch/powerpc/platforms/= wiiu/Makefile index f66554cd5c45..b1e0e1307f6e 100644 --- a/arch/powerpc/platforms/wiiu/Makefile +++ b/arch/powerpc/platforms/wiiu/Makefile @@ -1 +1,3 @@ # SPDX-License-Identifier: GPL-2.0 + +obj-$(CONFIG_LATTEIPC_UDBG) +=3D udbg_latteipc.o diff --git a/arch/powerpc/platforms/wiiu/udbg_latteipc.c b/arch/powerpc/pla= tforms/wiiu/udbg_latteipc.c new file mode 100644 index 000000000000..9f46a0d19e81 --- /dev/null +++ b/arch/powerpc/platforms/wiiu/udbg_latteipc.c @@ -0,0 +1,126 @@ +// 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.c + * Copyright (C) 2008-2009 The GameCube Linux Team + * Copyright (C) 2008-2009 Albert Herranz + */ + +#include + +#include +#include +#include +#include +#include +#include + +#include "udbg_latteipc.h" + +#define LT_MMIO_BASE ((phys_addr_t)0x0d800000) +#define LT_IPC_PPCMSG 0x00 +#define LT_IPC_PPCCTRL 0x04 +#define LT_IPC_PPCCTRL_X1 0x01 + +#define WIIU_LOADER_CMD_PRINT 0x01000000 + +void __iomem *latteipc_io_base; + +/* + * Transmits a character. + * Sends over IPC to linux-loader for printing. + */ +static void latteipc_udbg_putc(char c) +{ + void __iomem *ppcmsg_reg =3D latteipc_io_base + LT_IPC_PPCMSG; + void __iomem *ppcctrl_reg =3D latteipc_io_base + LT_IPC_PPCCTRL; + + out_be32(ppcmsg_reg, WIIU_LOADER_CMD_PRINT | (c << 16)); + out_be32(ppcctrl_reg, LT_IPC_PPCCTRL_X1); + + while (in_be32(ppcctrl_reg) & LT_IPC_PPCCTRL_X1) + barrier(); +} + +/* + * Retrieves and prepares the virtual address needed to access the hardwar= e. + */ +static void __iomem *latteipc_udbg_setup_ipc_io_base(struct device_node *n= p) +{ + void __iomem *ipc_io_base =3D NULL; + phys_addr_t paddr; + const unsigned int *reg; + + reg =3D of_get_property(np, "reg", NULL); + if (reg) { + paddr =3D of_translate_address(np, reg); + if (paddr) + ipc_io_base =3D ioremap(paddr, reg[1]); + } + return ipc_io_base; +} + +/* + * Latte IPC udbg support initialization. + */ +void __init latteipc_udbg_init(void) +{ + struct device_node *np; + void __iomem *ipc_io_base; + + if (latteipc_io_base) + udbg_printf("%s: early -> final\n", __func__); + + np =3D of_find_compatible_node(NULL, NULL, "nintendo,latte-ipc"); + if (!np) { + udbg_printf("%s: IPC node not found\n", __func__); + goto out; + } + + ipc_io_base =3D latteipc_udbg_setup_ipc_io_base(np); + if (!ipc_io_base) { + udbg_printf("%s: failed to setup IPC io base\n", __func__); + goto done; + } + + udbg_putc =3D latteipc_udbg_putc; + udbg_printf("latteipc_udbg: ready\n"); + +done: + of_node_put(np); +out: + return; +} + +#ifdef CONFIG_PPC_EARLY_DEBUG_LATTEIPC + +void __init udbg_init_latteipc(void) +{ + /* + * At this point we have a BAT already setup that enables I/O + * to the IPC hardware. + * + * The BAT uses a virtual address range reserved at the fixmap. + * This must match the virtual address configured in + * head_32.S:setup_latteipc_bat(). + */ + latteipc_io_base =3D (void __iomem *)__fix_to_virt(FIX_EARLY_DEBUG_BASE); + + /* Assume a firmware is present, add hooks */ + udbg_putc =3D latteipc_udbg_putc; + + /* + * Prepare again the same BAT for MMU_init. + * This allows udbg I/O to continue working after the MMU is + * turned on for real. + * It is safe to continue using the same virtual address as it is + * a reserved fixmap area. + */ + setbat(1, (unsigned long)latteipc_io_base, LT_MMIO_BASE, 128 * 1024, + PAGE_KERNEL_NCG); +} + +#endif /* CONFIG_PPC_EARLY_DEBUG_LATTEIPC */ diff --git a/arch/powerpc/platforms/wiiu/udbg_latteipc.h b/arch/powerpc/pla= tforms/wiiu/udbg_latteipc.h new file mode 100644 index 000000000000..ca6d34e49158 --- /dev/null +++ b/arch/powerpc/platforms/wiiu/udbg_latteipc.h @@ -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 */ --=20 2.38.1 From nobody Tue Dec 23 14:13:02 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 55DD5C433FE for ; Sat, 19 Nov 2022 11:32:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233478AbiKSLcN (ORCPT ); Sat, 19 Nov 2022 06:32:13 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55554 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233485AbiKSLb4 (ORCPT ); Sat, 19 Nov 2022 06:31:56 -0500 Received: from relay9-d.mail.gandi.net (relay9-d.mail.gandi.net [217.70.183.199]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F2A6682BD0; Sat, 19 Nov 2022 03:31:54 -0800 (PST) Received: (Authenticated sender: ash@heyquark.com) by mail.gandi.net (Postfix) with ESMTPSA id ACDC3FF80B; Sat, 19 Nov 2022 11:31:44 +0000 (UTC) From: Ash Logan To: krzysztof.kozlowski+dt@linaro.org, paulus@samba.org, mpe@ellerman.id.au, christophe.leroy@csgroup.eu, robh+dt@kernel.org, benh@kernel.crashing.org, segher@kernel.crashing.org, pali@kernel.org Cc: linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, j.ne@posteo.net, linkmauve@linkmauve.fr, rw-r-r-0644@protonmail.com, devicetree@vger.kernel.org, joel@jms.id.au Subject: [PATCH v4 07/11] powerpc: wiiu: espresso interrupt controller support Date: Sat, 19 Nov 2022 22:30:37 +1100 Message-Id: <20221119113041.284419-8-ash@heyquark.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221119113041.284419-1-ash@heyquark.com> References: <20220628133144.142185-1-ash@heyquark.com> <20221119113041.284419-1-ash@heyquark.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Add support for the "Espresso" interrupt controller in the Nintendo Wii U. Signed-off-by: Ash Logan Co-developed-by: Roberto Van Eeden Signed-off-by: Roberto Van Eeden --- 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 diff --git a/arch/powerpc/platforms/wiiu/Makefile b/arch/powerpc/platforms/= wiiu/Makefile index b1e0e1307f6e..aabf4b43e806 100644 --- a/arch/powerpc/platforms/wiiu/Makefile +++ b/arch/powerpc/platforms/wiiu/Makefile @@ -1,3 +1,4 @@ # SPDX-License-Identifier: GPL-2.0 =20 +obj-$(CONFIG_WIIU) +=3D espresso-pic.o obj-$(CONFIG_LATTEIPC_UDBG) +=3D udbg_latteipc.o diff --git a/arch/powerpc/platforms/wiiu/espresso-pic.c b/arch/powerpc/plat= forms/wiiu/espresso-pic.c new file mode 100644 index 000000000000..1aa5d88002d5 --- /dev/null +++ b/arch/powerpc/platforms/wiiu/espresso-pic.c @@ -0,0 +1,183 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* + * Nintendo Wii U "Espresso" interrupt controller support + * Copyright (C) 2022 The linux-wiiu Team + * + * Based on flipper-pic.c + * Copyright (C) 2004-2009 The GameCube Linux Team + * Copyright (C) 2007-2009 Albert Herranz + */ + +#define DRV_MODULE_NAME "espresso-pic" +#define pr_fmt(fmt) DRV_MODULE_NAME ": " fmt + +#include +#include +#include +#include +#include +#include +#include +#include "espresso-pic.h" + +static DEFINE_PER_CPU(struct espresso_pic *, espresso_pic_cpu); + +/* + * IRQ chip operations + */ + +static void espresso_pic_mask_and_ack(struct irq_data *d) +{ + struct espresso_pic *pic =3D *this_cpu_ptr(&espresso_pic_cpu); + u32 mask =3D 1 << irqd_to_hwirq(d); + + out_be32(&pic->icr, mask); + clrbits32(&pic->imr, mask); +} + +static void espresso_pic_ack(struct irq_data *d) +{ + struct espresso_pic *pic =3D *this_cpu_ptr(&espresso_pic_cpu); + u32 mask =3D 1 << irqd_to_hwirq(d); + + out_be32(&pic->icr, mask); +} + +static void espresso_pic_mask(struct irq_data *d) +{ + struct espresso_pic *pic =3D *this_cpu_ptr(&espresso_pic_cpu); + u32 mask =3D 1 << irqd_to_hwirq(d); + + clrbits32(&pic->imr, mask); +} + +static void espresso_pic_unmask(struct irq_data *d) +{ + struct espresso_pic *pic =3D *this_cpu_ptr(&espresso_pic_cpu); + u32 mask =3D 1 << irqd_to_hwirq(d); + + setbits32(&pic->imr, mask); +} + +static struct irq_chip espresso_pic_chip =3D { + .name =3D "espresso-pic", + .irq_ack =3D espresso_pic_ack, + .irq_mask_ack =3D espresso_pic_mask_and_ack, + .irq_mask =3D espresso_pic_mask, + .irq_unmask =3D espresso_pic_unmask, +}; + +/* + * Domain Ops + */ + +static int espresso_pic_match(struct irq_domain *h, struct device_node *no= de, + enum irq_domain_bus_token bus_token) +{ + if (h->fwnode =3D=3D &node->fwnode) { + pr_debug("espresso-pic: %s IRQ matches with this driver\n", + node->name); + return 1; + } + return 0; +} + +static int espresso_pic_alloc(struct irq_domain *h, unsigned int virq, + unsigned int nr_irqs, void *arg) +{ + unsigned int i; + struct irq_fwspec *fwspec =3D arg; + irq_hw_number_t hwirq =3D fwspec->param[0]; + + for (i =3D 0; i < nr_irqs; i++) { + irq_set_chip_data(virq + i, h->host_data); + irq_set_status_flags(virq + i, IRQ_LEVEL); + irq_set_chip_and_handler(virq + i, &espresso_pic_chip, + handle_level_irq); + irq_domain_set_hwirq_and_chip(h, virq + i, hwirq + i, + &espresso_pic_chip, h->host_data); + } + return 0; +} + +static void espresso_pic_free(struct irq_domain *h, unsigned int virq, + unsigned int nr_irqs) +{ + pr_debug("free\n"); +} + +const struct irq_domain_ops espresso_pic_ops =3D { + .match =3D espresso_pic_match, + .alloc =3D espresso_pic_alloc, + .free =3D espresso_pic_free, +}; + +/* Store irq domain for espresso_pic_get_irq (the function gets no argumen= ts) */ +static struct irq_domain *espresso_irq_domain; + +unsigned int espresso_pic_get_irq(void) +{ + struct espresso_pic *pic =3D *this_cpu_ptr(&espresso_pic_cpu); + u32 irq_status, irq; + + irq_status =3D in_be32(&pic->icr) & in_be32(&pic->imr); + + if (irq_status =3D=3D 0) + return 0; /* No IRQs pending */ + + /* Return first IRQ */ + irq =3D __ffs(irq_status); + return irq_linear_revmap(espresso_irq_domain, irq); +} + +void __init espresso_pic_init(void) +{ + struct device_node *np =3D + of_find_compatible_node(NULL, NULL, "nintendo,espresso-pic"); + struct irq_domain *host; + struct resource res; + void __iomem *regbase; + unsigned int cpu; + + if (!np) { + pr_err("could not find device node\n"); + return; + } + + if (of_address_to_resource(np, 0, &res) !=3D 0) { + pr_err("could not find resource address\n"); + goto out; + } + + regbase =3D ioremap(res.start, resource_size(&res)); + if (IS_ERR(regbase)) { + pr_err("could not map controller\n"); + goto out; + } + + for_each_present_cpu(cpu) { + struct espresso_pic **pic =3D per_cpu_ptr(&espresso_pic_cpu, cpu); + + /* Compute pic address */ + *pic =3D regbase + (sizeof(struct espresso_pic) * cpu); + + /* Mask and Ack all IRQs */ + out_be32(&(*pic)->imr, 0); + out_be32(&(*pic)->icr, 0xFFFFFFFF); + } + + host =3D irq_domain_add_linear(np, ESPRESSO_NR_IRQS, &espresso_pic_ops, + NULL); + if (!host) { + pr_err("failed to allocate irq_domain\n"); + goto out; + } + + /* Save irq domain for espresso_pic_get_irq */ + espresso_irq_domain =3D host; + + irq_set_default_host(host); + +out: + of_node_put(np); +} diff --git a/arch/powerpc/platforms/wiiu/espresso-pic.h b/arch/powerpc/plat= forms/wiiu/espresso-pic.h new file mode 100644 index 000000000000..b5b4e44ad60e --- /dev/null +++ b/arch/powerpc/platforms/wiiu/espresso-pic.h @@ -0,0 +1,59 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ +/* + * Nintendo Wii U "Espresso" interrupt controller support + * Copyright (C) 2022 The linux-wiiu Team + */ + +#ifndef __ESPRESSO_PIC_H +#define __ESPRESSO_PIC_H + +/* + * Instead of using COS custom IRQ remapping, the normal IRQ mapping is us= ed: + * + * IRQ Description + * ------------------------------------------- + * 0 Error + * 1 Unused + * 2 Unused + * 3 Audio Interface (TV) + * 4 Unused + * 5 DSP Accelerator + * 6 DSP + * 7 DSP DMA + * 8 Unused + * 9 Unused + * 10 GPIPPC (?) + * 11 Unused + * 12 Audio Interface (Gamepad) + * 13 I2C + * 14 Unused + * 15 Unused + * 16 Unused + * 17 Unused + * 18 Unused + * 19 Unused + * 20 Unused + * 21 Unused + * 22 Unused + * 23 GX2 + * 24 Latte IRQ Controller + * 25 Unused + * 26 IPC (CPU2) + * 27 Unused + * 28 IPC (CPU1) + * 29 Unused + * 30 IPC (CPU0) + * 31 Unused + */ + +struct espresso_pic { + __be32 icr; /* Triggered IRQs */ + __be32 imr; /* Allowed IRQs */ +} __packed; + +#define ESPRESSO_NR_IRQS 32 + +unsigned int espresso_pic_get_irq(void); +void espresso_pic_init(void); + +#endif --=20 2.38.1 From nobody Tue Dec 23 14:13:02 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B0118C433FE for ; Sat, 19 Nov 2022 11:32:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231891AbiKSLca (ORCPT ); Sat, 19 Nov 2022 06:32:30 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55462 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233670AbiKSLcD (ORCPT ); Sat, 19 Nov 2022 06:32:03 -0500 X-Greylist: delayed 65 seconds by postgrey-1.37 at lindbergh.monkeyblade.net; Sat, 19 Nov 2022 03:32:01 PST Received: from relay9-d.mail.gandi.net (relay9-d.mail.gandi.net [IPv6:2001:4b98:dc4:8::229]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8C65C9371C; Sat, 19 Nov 2022 03:32:01 -0800 (PST) Received: (Authenticated sender: ash@heyquark.com) by mail.gandi.net (Postfix) with ESMTPSA id A0B42FF803; Sat, 19 Nov 2022 11:31:52 +0000 (UTC) From: Ash Logan To: krzysztof.kozlowski+dt@linaro.org, paulus@samba.org, mpe@ellerman.id.au, christophe.leroy@csgroup.eu, robh+dt@kernel.org, benh@kernel.crashing.org, segher@kernel.crashing.org, pali@kernel.org Cc: linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, j.ne@posteo.net, linkmauve@linkmauve.fr, rw-r-r-0644@protonmail.com, devicetree@vger.kernel.org, joel@jms.id.au Subject: [PATCH v4 08/11] powerpc: wiiu: latte interrupt controller support Date: Sat, 19 Nov 2022 22:30:38 +1100 Message-Id: <20221119113041.284419-9-ash@heyquark.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221119113041.284419-1-ash@heyquark.com> References: <20220628133144.142185-1-ash@heyquark.com> <20221119113041.284419-1-ash@heyquark.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" 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. Signed-off-by: Ash Logan Co-developed-by: Roberto Van Eeden Signed-off-by: Roberto Van Eeden --- 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 diff --git a/arch/powerpc/platforms/wiiu/Kconfig b/arch/powerpc/platforms/w= iiu/Kconfig index 8dfd6ac8774d..40ecba8396a7 100644 --- a/arch/powerpc/platforms/wiiu/Kconfig +++ b/arch/powerpc/platforms/wiiu/Kconfig @@ -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: diff --git a/arch/powerpc/platforms/wiiu/Makefile b/arch/powerpc/platforms/= wiiu/Makefile index aabf4b43e806..fa16c60261e6 100644 --- a/arch/powerpc/platforms/wiiu/Makefile +++ b/arch/powerpc/platforms/wiiu/Makefile @@ -1,4 +1,4 @@ # SPDX-License-Identifier: GPL-2.0 =20 -obj-$(CONFIG_WIIU) +=3D espresso-pic.o +obj-$(CONFIG_WIIU) +=3D espresso-pic.o latte-pic.o obj-$(CONFIG_LATTEIPC_UDBG) +=3D udbg_latteipc.o diff --git a/arch/powerpc/platforms/wiiu/latte-pic.c b/arch/powerpc/platfor= ms/wiiu/latte-pic.c new file mode 100644 index 000000000000..7e3f49844166 --- /dev/null +++ b/arch/powerpc/platforms/wiiu/latte-pic.c @@ -0,0 +1,259 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* + * Nintendo Wii U "Latte" interrupt controller support. + * This is the controller for all the SoC devices, and has a cascade inter= rupt for the Espresso + * CPU interrupt controller. + * + * Copyright (C) 2022 The linux-wiiu Team + * + * Based on hlwd-pic.c + * Copyright (C) 2009 The GameCube Linux Team + * Copyright (C) 2009 Albert Herranz + */ + +#define DRV_MODULE_NAME "latte-pic" +#define pr_fmt(fmt) DRV_MODULE_NAME ": " fmt + +#include +#include +#include +#include +#include +#include +#include +#include "latte-pic.h" + +static DEFINE_PER_CPU(struct lt_pic *, lt_pic_cpu); + +/* + * IRQ chip operations + * These handle both AHBALL and AHBLT IRQs, with AHBLT mapped above 32 + */ + +static void latte_pic_mask_and_ack(struct irq_data *d) +{ + struct lt_pic *pic =3D *this_cpu_ptr(<_pic_cpu); + u32 irq =3D irqd_to_hwirq(d); + + if (irq < LATTE_AHBALL_NR_IRQS) { + u32 mask =3D 1 << irq; + + out_be32(&pic->ahball_icr, mask); + clrbits32(&pic->ahball_imr, mask); + } else { + u32 mask =3D 1 << (irq - 32); + + out_be32(&pic->ahblt_icr, mask); + clrbits32(&pic->ahblt_imr, mask); + } +} + +static void latte_pic_ack(struct irq_data *d) +{ + struct lt_pic *pic =3D *this_cpu_ptr(<_pic_cpu); + u32 irq =3D irqd_to_hwirq(d); + + if (irq < LATTE_AHBALL_NR_IRQS) { + u32 mask =3D 1 << irq; + + out_be32(&pic->ahball_icr, mask); + } else { + u32 mask =3D 1 << (irq - 32); + + out_be32(&pic->ahblt_icr, mask); + } +} + +static void latte_pic_mask(struct irq_data *d) +{ + struct lt_pic *pic =3D *this_cpu_ptr(<_pic_cpu); + u32 irq =3D irqd_to_hwirq(d); + + if (irq < LATTE_AHBALL_NR_IRQS) { + u32 mask =3D 1 << irq; + + clrbits32(&pic->ahball_imr, mask); + } else { + u32 mask =3D 1 << (irq - 32); + + clrbits32(&pic->ahblt_imr, mask); + } +} + +static void latte_pic_unmask(struct irq_data *d) +{ + struct lt_pic *pic =3D *this_cpu_ptr(<_pic_cpu); + u32 irq =3D irqd_to_hwirq(d); + + if (irq < LATTE_AHBALL_NR_IRQS) { + u32 mask =3D 1 << irq; + + setbits32(&pic->ahball_imr, mask); + } else { + u32 mask =3D 1 << (irq - 32); + + setbits32(&pic->ahblt_imr, mask); + } +} + +static struct irq_chip latte_pic =3D { + .name =3D "latte-pic", + .irq_ack =3D latte_pic_ack, + .irq_mask_ack =3D latte_pic_mask_and_ack, + .irq_mask =3D latte_pic_mask, + .irq_unmask =3D latte_pic_unmask, +}; + +/* + * Domain ops + */ + +static int latte_pic_match(struct irq_domain *h, struct device_node *node, + enum irq_domain_bus_token bus_token) +{ + if (h->fwnode =3D=3D &node->fwnode) { + pr_debug("%s IRQ matches with this driver\n", node->name); + return 1; + } + return 0; +} + +static int latte_pic_alloc(struct irq_domain *h, unsigned int virq, + unsigned int nr_irqs, void *arg) +{ + unsigned int i; + struct irq_fwspec *fwspec =3D arg; + irq_hw_number_t hwirq =3D fwspec->param[0]; + + for (i =3D 0; i < nr_irqs; i++) { + irq_set_chip_data(virq + i, h->host_data); + irq_set_status_flags(virq + i, IRQ_LEVEL); + irq_set_chip_and_handler(virq + i, &latte_pic, + handle_level_irq); + irq_domain_set_hwirq_and_chip(h, virq + i, hwirq + i, + &latte_pic, h->host_data); + } + return 0; +} + +static void latte_pic_free(struct irq_domain *h, unsigned int virq, + unsigned int nr_irqs) +{ + pr_debug("free\n"); +} + +const struct irq_domain_ops latte_pic_ops =3D { + .match =3D latte_pic_match, + .alloc =3D latte_pic_alloc, + .free =3D latte_pic_free, +}; + +/* + * Determinate if there are interrupts pending + * Checks AHBALL (0-32) and AHBLT (32-64) + */ +static unsigned int latte_pic_get_irq(struct irq_domain *h) +{ + struct lt_pic *pic =3D *this_cpu_ptr(<_pic_cpu); + u32 irq_status, irq; + + /* Check AHBALL first */ + irq_status =3D in_be32(&pic->ahball_icr) & in_be32(&pic->ahball_imr); + + if (irq_status =3D=3D 0) { + /* Try AHBLT */ + irq_status =3D + in_be32(&pic->ahblt_icr) & in_be32(&pic->ahblt_imr); + if (irq_status =3D=3D 0) + return 0; /* No IRQs pending */ + + /* AHBLT is mapped above 32 (LATTE_AHBALL_NR_IRQS) */ + irq =3D __ffs(irq_status) + LATTE_AHBALL_NR_IRQS; + return irq_linear_revmap(h, irq); + } + + irq =3D __ffs(irq_status); + return irq_linear_revmap(h, irq); +} + +/* + * Cascade IRQ handler + */ +static void latte_irq_cascade(struct irq_desc *desc) +{ + struct irq_domain *irq_domain =3D irq_desc_get_handler_data(desc); + struct irq_chip *chip =3D irq_desc_get_chip(desc); + unsigned int virq; + + raw_spin_lock(&desc->lock); + chip->irq_mask(&desc->irq_data); /* IRQ_LEVEL */ + raw_spin_unlock(&desc->lock); + + virq =3D latte_pic_get_irq(irq_domain); + if (virq) + generic_handle_irq(virq); + else + pr_err("spurious interrupt!\n"); + + raw_spin_lock(&desc->lock); + chip->irq_ack(&desc->irq_data); /* IRQ_LEVEL */ + if (!irqd_irq_disabled(&desc->irq_data) && chip->irq_unmask) + chip->irq_unmask(&desc->irq_data); + raw_spin_unlock(&desc->lock); +} + +void __init latte_pic_init(void) +{ + struct device_node *np =3D + of_find_compatible_node(NULL, NULL, "nintendo,latte-pic"); + struct irq_domain *host; + struct resource res; + int irq_cascade; + void __iomem *regbase; + unsigned int cpu; + + if (!np) { + pr_err("could not find device node\n"); + return; + } + if (!of_get_property(np, "interrupts", NULL)) { + pr_err("could not find cascade interrupt!\n"); + goto out; + } + + if (of_address_to_resource(np, 0, &res)) { + pr_err("could not find resource address\n"); + goto out; + } + + regbase =3D ioremap(res.start, resource_size(&res)); + if (IS_ERR(regbase)) { + pr_err("could not map controller\n"); + goto out; + } + + for_each_present_cpu(cpu) { + struct lt_pic **pic =3D per_cpu_ptr(<_pic_cpu, cpu); + + /* Compute pic address */ + *pic =3D regbase + (sizeof(struct lt_pic) * cpu); + + /* Mask and Ack CPU IRQs */ + out_be32(&(*pic)->ahball_imr, 0); + out_be32(&(*pic)->ahball_icr, 0xFFFFFFFF); + } + + host =3D irq_domain_add_linear(np, + LATTE_AHBALL_NR_IRQS + LATTE_AHBLT_NR_IRQS, + &latte_pic_ops, NULL); + if (!host) { + pr_err("failed to allocate irq_domain\n"); + goto out; + } + + irq_cascade =3D irq_of_parse_and_map(np, 0); + irq_set_chained_handler_and_data(irq_cascade, latte_irq_cascade, host); + +out: + of_node_put(np); +} diff --git a/arch/powerpc/platforms/wiiu/latte-pic.h b/arch/powerpc/platfor= ms/wiiu/latte-pic.h new file mode 100644 index 000000000000..7021d9497d35 --- /dev/null +++ b/arch/powerpc/platforms/wiiu/latte-pic.h @@ -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 --=20 2.38.1 From nobody Tue Dec 23 14:13:02 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1C430C433FE for ; Sat, 19 Nov 2022 11:32:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234182AbiKSLcg (ORCPT ); Sat, 19 Nov 2022 06:32:36 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55558 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231598AbiKSLcM (ORCPT ); Sat, 19 Nov 2022 06:32:12 -0500 Received: from relay9-d.mail.gandi.net (relay9-d.mail.gandi.net [217.70.183.199]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 312A21C900; Sat, 19 Nov 2022 03:32:09 -0800 (PST) Received: (Authenticated sender: ash@heyquark.com) by mail.gandi.net (Postfix) with ESMTPSA id A7057FF805; Sat, 19 Nov 2022 11:32:00 +0000 (UTC) From: Ash Logan To: krzysztof.kozlowski+dt@linaro.org, paulus@samba.org, mpe@ellerman.id.au, christophe.leroy@csgroup.eu, robh+dt@kernel.org, benh@kernel.crashing.org, segher@kernel.crashing.org, pali@kernel.org Cc: linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, j.ne@posteo.net, linkmauve@linkmauve.fr, rw-r-r-0644@protonmail.com, devicetree@vger.kernel.org, joel@jms.id.au Subject: [PATCH v4 09/11] powerpc: espresso processor support Date: Sat, 19 Nov 2022 22:30:39 +1100 Message-Id: <20221119113041.284419-10-ash@heyquark.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221119113041.284419-1-ash@heyquark.com> References: <20220628133144.142185-1-ash@heyquark.com> <20221119113041.284419-1-ash@heyquark.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" 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. Signed-off-by: Roberto Van Eeden Signed-off-by: Ash Logan --- v3->v4: Move to new cpu_specs_*.h file. arch/powerpc/kernel/cpu_specs_book3s_32.h | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/arch/powerpc/kernel/cpu_specs_book3s_32.h b/arch/powerpc/kerne= l/cpu_specs_book3s_32.h index 3714634d194a..c3cc0a019ba8 100644 --- a/arch/powerpc/kernel/cpu_specs_book3s_32.h +++ b/arch/powerpc/kernel/cpu_specs_book3s_32.h @@ -275,6 +275,21 @@ static struct cpu_spec cpu_specs[] __initdata =3D { .machine_check =3D machine_check_generic, .platform =3D "ppc750", }, + { /* "Espresso" (750CL-like) */ + .pvr_mask =3D 0xffffffff, + .pvr_value =3D 0x70010201, + .cpu_name =3D "Espresso", + .cpu_features =3D CPU_FTRS_750CL, + .cpu_user_features =3D COMMON_USER | PPC_FEATURE_PPC_LE, + .mmu_features =3D MMU_FTR_HPTE_TABLE | MMU_FTR_USE_HIGH_BATS, + .icache_bsize =3D 32, + .dcache_bsize =3D 32, + .num_pmcs =3D 4, + .pmc_type =3D PPC_PMC_IBM, + .cpu_setup =3D __setup_cpu_750, + .machine_check =3D machine_check_generic, + .platform =3D "ppc750", + }, { /* 745/755 */ .pvr_mask =3D 0xfffff000, .pvr_value =3D 0x00083000, --=20 2.38.1 From nobody Tue Dec 23 14:13:02 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 83390C433FE for ; Sat, 19 Nov 2022 11:32:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229925AbiKSLcw (ORCPT ); Sat, 19 Nov 2022 06:32:52 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56168 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233941AbiKSLcS (ORCPT ); Sat, 19 Nov 2022 06:32:18 -0500 Received: from relay9-d.mail.gandi.net (relay9-d.mail.gandi.net [217.70.183.199]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2A4B7950D2; Sat, 19 Nov 2022 03:32:17 -0800 (PST) Received: (Authenticated sender: ash@heyquark.com) by mail.gandi.net (Postfix) with ESMTPSA id BCE59FF802; Sat, 19 Nov 2022 11:32:08 +0000 (UTC) From: Ash Logan To: krzysztof.kozlowski+dt@linaro.org, paulus@samba.org, mpe@ellerman.id.au, christophe.leroy@csgroup.eu, robh+dt@kernel.org, benh@kernel.crashing.org, segher@kernel.crashing.org, pali@kernel.org Cc: linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, j.ne@posteo.net, linkmauve@linkmauve.fr, rw-r-r-0644@protonmail.com, devicetree@vger.kernel.org, joel@jms.id.au Subject: [PATCH v4 10/11] powerpc: wiiu: platform support Date: Sat, 19 Nov 2022 22:30:40 +1100 Message-Id: <20221119113041.284419-11-ash@heyquark.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221119113041.284419-1-ash@heyquark.com> References: <20220628133144.142185-1-ash@heyquark.com> <20221119113041.284419-1-ash@heyquark.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Add platform support for the Nintendo Wii U console. Signed-off-by: Ash Logan Co-developed-by: Roberto Van Eeden Signed-off-by: Roberto Van Eeden Co-developed-by: Emmanuel Gil Peyrot Signed-off-by: Emmanuel Gil Peyrot --- 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 diff --git a/arch/powerpc/platforms/wiiu/Makefile b/arch/powerpc/platforms/= wiiu/Makefile index fa16c60261e6..abcb7a1beebf 100644 --- a/arch/powerpc/platforms/wiiu/Makefile +++ b/arch/powerpc/platforms/wiiu/Makefile @@ -1,4 +1,4 @@ # SPDX-License-Identifier: GPL-2.0 =20 -obj-$(CONFIG_WIIU) +=3D espresso-pic.o latte-pic.o +obj-$(CONFIG_WIIU) +=3D setup.o espresso-pic.o latte-pic.o obj-$(CONFIG_LATTEIPC_UDBG) +=3D udbg_latteipc.o diff --git a/arch/powerpc/platforms/wiiu/setup.c b/arch/powerpc/platforms/w= iiu/setup.c new file mode 100644 index 000000000000..e3f07ce65cad --- /dev/null +++ b/arch/powerpc/platforms/wiiu/setup.c @@ -0,0 +1,60 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* + * Nintendo Wii U board-specific support + * + * Copyright (C) 2022 The linux-wiiu Team + */ +#define DRV_MODULE_NAME "wiiu" +#define pr_fmt(fmt) DRV_MODULE_NAME ": " fmt + +#include +#include + +#include +#include + +#include "espresso-pic.h" +#include "latte-pic.h" +#include "udbg_latteipc.h" + +static int __init wiiu_probe(void) +{ + if (!of_machine_is_compatible("nintendo,wiiu")) + return 0; + + latteipc_udbg_init(); + + return 1; +} + +static void __noreturn wiiu_halt(void) +{ + for (;;) + cpu_relax(); +} + +static void __init wiiu_init_irq(void) +{ + espresso_pic_init(); + latte_pic_init(); +} + +static int __init wiiu_device_probe(void) +{ + if (!machine_is(wiiu)) + return 0; + + of_platform_default_populate(NULL, NULL, NULL); + return 0; +} +device_initcall(wiiu_device_probe); + +define_machine(wiiu) { + .name =3D "wiiu", + .probe =3D wiiu_probe, + .halt =3D wiiu_halt, + .progress =3D udbg_progress, + .calibrate_decr =3D generic_calibrate_decr, + .init_IRQ =3D wiiu_init_irq, + .get_irq =3D espresso_pic_get_irq, +}; --=20 2.38.1 From nobody Tue Dec 23 14:13:02 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 76C18C433FE for ; Sat, 19 Nov 2022 11:33:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233867AbiKSLc7 (ORCPT ); Sat, 19 Nov 2022 06:32:59 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56352 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232565AbiKSLc1 (ORCPT ); Sat, 19 Nov 2022 06:32:27 -0500 Received: from relay9-d.mail.gandi.net (relay9-d.mail.gandi.net [217.70.183.199]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2F75C976D0; Sat, 19 Nov 2022 03:32:25 -0800 (PST) Received: (Authenticated sender: ash@heyquark.com) by mail.gandi.net (Postfix) with ESMTPSA id B1936FF803; Sat, 19 Nov 2022 11:32:16 +0000 (UTC) From: Ash Logan To: krzysztof.kozlowski+dt@linaro.org, paulus@samba.org, mpe@ellerman.id.au, christophe.leroy@csgroup.eu, robh+dt@kernel.org, benh@kernel.crashing.org, segher@kernel.crashing.org, pali@kernel.org Cc: linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, j.ne@posteo.net, linkmauve@linkmauve.fr, rw-r-r-0644@protonmail.com, devicetree@vger.kernel.org, joel@jms.id.au Subject: [PATCH v4 11/11] powerpc: wiiu: add minimal default config Date: Sat, 19 Nov 2022 22:30:41 +1100 Message-Id: <20221119113041.284419-12-ash@heyquark.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221119113041.284419-1-ash@heyquark.com> References: <20220628133144.142185-1-ash@heyquark.com> <20221119113041.284419-1-ash@heyquark.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" 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. Signed-off-by: Ash Logan --- arch/powerpc/configs/wiiu_defconfig | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 arch/powerpc/configs/wiiu_defconfig diff --git a/arch/powerpc/configs/wiiu_defconfig b/arch/powerpc/configs/wii= u_defconfig new file mode 100644 index 000000000000..a761ebcdd9f2 --- /dev/null +++ b/arch/powerpc/configs/wiiu_defconfig @@ -0,0 +1,7 @@ +# CONFIG_PPC_CHRP is not set +# CONFIG_PPC_PMAC is not set +CONFIG_WIIU=3Dy +# CONFIG_PPC_OF_BOOT_TRAMPOLINE is not set +CONFIG_HIGHMEM=3Dy +CONFIG_STRICT_KERNEL_RWX=3Dy +CONFIG_PPC_EARLY_DEBUG=3Dy --=20 2.38.1