From patchwork Wed Mar 2 04:43:55 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ash Logan X-Patchwork-Id: 1599593 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.ozlabs.org (client-ip=2404:9400:2:0:216:3eff:fee1:b9f1; helo=lists.ozlabs.org; envelope-from=linuxppc-dev-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org; receiver=) Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2404:9400:2:0:216:3eff:fee1:b9f1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4K7hP71rHJz9s09 for ; Wed, 2 Mar 2022 15:44:59 +1100 (AEDT) Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4K7hP61bC7z3cFD for ; Wed, 2 Mar 2022 15:44:58 +1100 (AEDT) X-Original-To: linuxppc-dev@lists.ozlabs.org Delivered-To: linuxppc-dev@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=heyquark.com (client-ip=217.70.178.231; helo=relay11.mail.gandi.net; envelope-from=ash@heyquark.com; receiver=) Received: from relay11.mail.gandi.net (relay11.mail.gandi.net [217.70.178.231]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4K7hNX0VTMz30Hp for ; Wed, 2 Mar 2022 15:44:24 +1100 (AEDT) Received: (Authenticated sender: ash@heyquark.com) by mail.gandi.net (Postfix) with ESMTPSA id 01027100002; Wed, 2 Mar 2022 04:44:16 +0000 (UTC) From: Ash Logan To: paulus@samba.org, mpe@ellerman.id.au, christophe.leroy@csgroup.eu, robh+dt@kernel.org, benh@kernel.crashing.org Subject: [PATCH 01/12] dt-bindings: wiiu: Document the Nintendo Wii U devicetree Date: Wed, 2 Mar 2022 15:43:55 +1100 Message-Id: <20220302044406.63401-2-ash@heyquark.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220302044406.63401-1-ash@heyquark.com> References: <20220302044406.63401-1-ash@heyquark.com> MIME-Version: 1.0 X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org, j.ne@posteo.net Errors-To: linuxppc-dev-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Linuxppc-dev" Adds schema for the various Wii U devicetree nodes used. Signed-off-by: Ash Logan --- .../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 diff --git a/Documentation/devicetree/bindings/powerpc/nintendo/wiiu.yaml b/Documentation/devicetree/bindings/powerpc/nintendo/wiiu.yaml new file mode 100644 index 000000000000..5824b07928f5 --- /dev/null +++ b/Documentation/devicetree/bindings/powerpc/nintendo/wiiu.yaml @@ -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 + - Emmanuel Gil Peyrot + +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 + +... diff --git a/Documentation/devicetree/bindings/powerpc/nintendo/wiiu/espresso-pic.yaml b/Documentation/devicetree/bindings/powerpc/nintendo/wiiu/espresso-pic.yaml new file mode 100644 index 000000000000..878a81595f5f --- /dev/null +++ b/Documentation/devicetree/bindings/powerpc/nintendo/wiiu/espresso-pic.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/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" 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>; + }; + +... diff --git a/Documentation/devicetree/bindings/powerpc/nintendo/wiiu/gpu7.yaml b/Documentation/devicetree/bindings/powerpc/nintendo/wiiu/gpu7.yaml new file mode 100644 index 000000000000..e54d49015f36 --- /dev/null +++ b/Documentation/devicetree/bindings/powerpc/nintendo/wiiu/gpu7.yaml @@ -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 + - Emmanuel Gil Peyrot + +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>; + }; +... diff --git a/Documentation/devicetree/bindings/powerpc/nintendo/wiiu/latte-ahci.yaml b/Documentation/devicetree/bindings/powerpc/nintendo/wiiu/latte-ahci.yaml new file mode 100644 index 000000000000..7b9de4effcb0 --- /dev/null +++ b/Documentation/devicetree/bindings/powerpc/nintendo/wiiu/latte-ahci.yaml @@ -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 + - Emmanuel Gil Peyrot + +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>; + }; +... diff --git a/Documentation/devicetree/bindings/powerpc/nintendo/wiiu/latte-dsp.yaml b/Documentation/devicetree/bindings/powerpc/nintendo/wiiu/latte-dsp.yaml new file mode 100644 index 000000000000..ed0b4c28ce48 --- /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: + 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>; + }; +... diff --git a/Documentation/devicetree/bindings/powerpc/nintendo/wiiu/latte-pic.yaml b/Documentation/devicetree/bindings/powerpc/nintendo/wiiu/latte-pic.yaml new file mode 100644 index 000000000000..a2df71fb9964 --- /dev/null +++ b/Documentation/devicetree/bindings/powerpc/nintendo/wiiu/latte-pic.yaml @@ -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 + - Emmanuel Gil Peyrot + +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>; + }; +... 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..4b9b0820edc1 --- /dev/null +++ b/Documentation/devicetree/bindings/powerpc/nintendo/wiiu/latte-sdhci.yaml @@ -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 + - Emmanuel Gil Peyrot + +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>; + }; +... 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..6ae86d198fa3 --- /dev/null +++ b/Documentation/devicetree/bindings/powerpc/nintendo/wiiu/latte.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/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 Nintendo Wii U. + +properties: + compatible: + oneOf: + - description: Nintendo Wii U "Latte" SoC + items: + - const: nintendo,latte + +additionalProperties: true + +... From patchwork Wed Mar 2 04:43:56 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ash Logan X-Patchwork-Id: 1599594 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.ozlabs.org (client-ip=2404:9400:2:0:216:3eff:fee1:b9f1; helo=lists.ozlabs.org; envelope-from=linuxppc-dev-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org; receiver=) Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2404:9400:2:0:216:3eff:fee1:b9f1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4K7hPW5jqsz9s09 for ; Wed, 2 Mar 2022 15:45:19 +1100 (AEDT) Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4K7hPV6FjPz3chq for ; Wed, 2 Mar 2022 15:45:18 +1100 (AEDT) X-Original-To: linuxppc-dev@lists.ozlabs.org Delivered-To: linuxppc-dev@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=heyquark.com (client-ip=2001:4b98:dc4:8::231; helo=relay11.mail.gandi.net; envelope-from=ash@heyquark.com; receiver=) Received: from relay11.mail.gandi.net (relay11.mail.gandi.net [IPv6:2001:4b98:dc4:8::231]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4K7hNY0vp9z30Hp for ; Wed, 2 Mar 2022 15:44:28 +1100 (AEDT) Received: (Authenticated sender: ash@heyquark.com) by mail.gandi.net (Postfix) with ESMTPSA id 2C260100007; Wed, 2 Mar 2022 04:44:21 +0000 (UTC) From: Ash Logan To: paulus@samba.org, mpe@ellerman.id.au, christophe.leroy@csgroup.eu, robh+dt@kernel.org, benh@kernel.crashing.org Subject: [PATCH 02/12] powerpc: wiiu: device tree Date: Wed, 2 Mar 2022 15:43:56 +1100 Message-Id: <20220302044406.63401-3-ash@heyquark.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220302044406.63401-1-ash@heyquark.com> References: <20220302044406.63401-1-ash@heyquark.com> MIME-Version: 1.0 X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Emmanuel Gil Peyrot , linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org, Roberto Van Eeden , j.ne@posteo.net Errors-To: linuxppc-dev-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Linuxppc-dev" 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 --- arch/powerpc/boot/dts/wiiu.dts | 327 +++++++++++++++++++++++++++++++++ 1 file changed, 327 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..aaf264963f61 --- /dev/null +++ b/arch/powerpc/boot/dts/wiiu.dts @@ -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 +#include + +/ { + 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 = ; + }; + }; + + 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>; + }; + }; +}; From patchwork Wed Mar 2 04:43:57 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ash Logan X-Patchwork-Id: 1599595 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.ozlabs.org (client-ip=112.213.38.117; helo=lists.ozlabs.org; envelope-from=linuxppc-dev-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org; receiver=) Received: from lists.ozlabs.org (lists.ozlabs.org [112.213.38.117]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4K7hQ473xTz9sFN for ; Wed, 2 Mar 2022 15:45:48 +1100 (AEDT) Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4K7hQ373Fxz3drP for ; Wed, 2 Mar 2022 15:45:47 +1100 (AEDT) X-Original-To: linuxppc-dev@lists.ozlabs.org Delivered-To: linuxppc-dev@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=heyquark.com (client-ip=217.70.178.231; helo=relay11.mail.gandi.net; envelope-from=ash@heyquark.com; receiver=) Received: from relay11.mail.gandi.net (relay11.mail.gandi.net [217.70.178.231]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4K7hNf4dVtz3bqZ for ; Wed, 2 Mar 2022 15:44:34 +1100 (AEDT) Received: (Authenticated sender: ash@heyquark.com) by mail.gandi.net (Postfix) with ESMTPSA id 05AAA100003; Wed, 2 Mar 2022 04:44:27 +0000 (UTC) From: Ash Logan To: paulus@samba.org, mpe@ellerman.id.au, christophe.leroy@csgroup.eu, robh+dt@kernel.org, benh@kernel.crashing.org Subject: [PATCH 03/12] powerpc: wiiu: bootwrapper support Date: Wed, 2 Mar 2022 15:43:57 +1100 Message-Id: <20220302044406.63401-4-ash@heyquark.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220302044406.63401-1-ash@heyquark.com> References: <20220302044406.63401-1-ash@heyquark.com> MIME-Version: 1.0 X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Emmanuel Gil Peyrot , linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org, j.ne@posteo.net Errors-To: linuxppc-dev-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Linuxppc-dev" 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 9993c6256ad2..4e31bb648f4d 100644 --- a/arch/powerpc/boot/Makefile +++ b/arch/powerpc/boot/Makefile @@ -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 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, which 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 = 0; + + for (i = 0; i + 2 < len; i += 3) { + int msg = 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 = 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 = wiiu_write_ipc; + printf("wiiu: bootwrapper ok\n"); + + heapsize = 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 9184eda780fd..f42abe4ebde2 100755 --- a/arch/powerpc/boot/wrapper +++ b/arch/powerpc/boot/wrapper @@ -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" From patchwork Wed Mar 2 04:43:58 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ash Logan X-Patchwork-Id: 1599596 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.ozlabs.org (client-ip=2404:9400:2:0:216:3eff:fee1:b9f1; helo=lists.ozlabs.org; envelope-from=linuxppc-dev-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org; receiver=) Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2404:9400:2:0:216:3eff:fee1:b9f1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4K7hQV2bCDz9sFN for ; Wed, 2 Mar 2022 15:46:10 +1100 (AEDT) Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4K7hQT2mHTz3dxn for ; Wed, 2 Mar 2022 15:46:09 +1100 (AEDT) X-Original-To: linuxppc-dev@lists.ozlabs.org Delivered-To: linuxppc-dev@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=heyquark.com (client-ip=2001:4b98:dc4:8::231; helo=relay11.mail.gandi.net; envelope-from=ash@heyquark.com; receiver=) Received: from relay11.mail.gandi.net (relay11.mail.gandi.net [IPv6:2001:4b98:dc4:8::231]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4K7hNl2R5Cz3bpc for ; Wed, 2 Mar 2022 15:44:39 +1100 (AEDT) Received: (Authenticated sender: ash@heyquark.com) by mail.gandi.net (Postfix) with ESMTPSA id 6B41F100002; Wed, 2 Mar 2022 04:44:32 +0000 (UTC) From: Ash Logan To: paulus@samba.org, mpe@ellerman.id.au, christophe.leroy@csgroup.eu, robh+dt@kernel.org, benh@kernel.crashing.org Subject: [PATCH 04/12] powerpc: wiiu: introduce wiiu platform Date: Wed, 2 Mar 2022 15:43:58 +1100 Message-Id: <20220302044406.63401-5-ash@heyquark.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220302044406.63401-1-ash@heyquark.com> References: <20220302044406.63401-1-ash@heyquark.com> MIME-Version: 1.0 X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org, j.ne@posteo.net Errors-To: linuxppc-dev-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Linuxppc-dev" Add empty platforms/wiiu for Nintendo Wii U console. Signed-off-by: Ash Logan --- 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 diff --git a/arch/powerpc/platforms/Kconfig b/arch/powerpc/platforms/Kconfig index e02d29a9d12f..7ea25ea369b4 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" config KVM_GUEST bool "KVM Guest support" diff --git a/arch/powerpc/platforms/Makefile b/arch/powerpc/platforms/Makefile index 94470fb27c99..944ddd938711 100644 --- a/arch/powerpc/platforms/Makefile +++ b/arch/powerpc/platforms/Makefile @@ -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/ diff --git a/arch/powerpc/platforms/wiiu/Kconfig b/arch/powerpc/platforms/wiiu/Kconfig new file mode 100644 index 000000000000..e5513205da3c --- /dev/null +++ b/arch/powerpc/platforms/wiiu/Kconfig @@ -0,0 +1,5 @@ +# SPDX-License-Identifier: GPL-2.0 + +config WIIU + bool "Nintendo Wii U" + depends on PPC_BOOK3S_32 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 From patchwork Wed Mar 2 04:43:59 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ash Logan X-Patchwork-Id: 1599597 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.ozlabs.org (client-ip=112.213.38.117; helo=lists.ozlabs.org; envelope-from=linuxppc-dev-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org; receiver=) Received: from lists.ozlabs.org (lists.ozlabs.org [112.213.38.117]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4K7hQv6RMKz9sFN for ; Wed, 2 Mar 2022 15:46:31 +1100 (AEDT) Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4K7hQt6bmkz3cYd for ; Wed, 2 Mar 2022 15:46:30 +1100 (AEDT) X-Original-To: linuxppc-dev@lists.ozlabs.org Delivered-To: linuxppc-dev@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=heyquark.com (client-ip=217.70.178.231; helo=relay11.mail.gandi.net; envelope-from=ash@heyquark.com; receiver=) Received: from relay11.mail.gandi.net (relay11.mail.gandi.net [217.70.178.231]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4K7hNr3HwPz3byG for ; Wed, 2 Mar 2022 15:44:44 +1100 (AEDT) Received: (Authenticated sender: ash@heyquark.com) by mail.gandi.net (Postfix) with ESMTPSA id 4E1BD100006; Wed, 2 Mar 2022 04:44:37 +0000 (UTC) From: Ash Logan To: paulus@samba.org, mpe@ellerman.id.au, christophe.leroy@csgroup.eu, robh+dt@kernel.org, benh@kernel.crashing.org Subject: [PATCH 05/12] powerpc: wiiu: declare as non-coherent Date: Wed, 2 Mar 2022 15:43:59 +1100 Message-Id: <20220302044406.63401-6-ash@heyquark.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220302044406.63401-1-ash@heyquark.com> References: <20220302044406.63401-1-ash@heyquark.com> MIME-Version: 1.0 X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org, j.ne@posteo.net Errors-To: linuxppc-dev-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Linuxppc-dev" 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/platforms/Kconfig.cputype index a208997ade88..bec8293a7985 100644 --- a/arch/powerpc/platforms/Kconfig.cputype +++ b/arch/powerpc/platforms/Kconfig.cputype @@ -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 From patchwork Wed Mar 2 04:44:00 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ash Logan X-Patchwork-Id: 1599598 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.ozlabs.org (client-ip=112.213.38.117; helo=lists.ozlabs.org; envelope-from=linuxppc-dev-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org; receiver=) Received: from lists.ozlabs.org (lists.ozlabs.org [112.213.38.117]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4K7hRK40dgz9sFN for ; Wed, 2 Mar 2022 15:46:53 +1100 (AEDT) Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4K7hRJ42Brz3f9W for ; Wed, 2 Mar 2022 15:46:52 +1100 (AEDT) X-Original-To: linuxppc-dev@lists.ozlabs.org Delivered-To: linuxppc-dev@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=heyquark.com (client-ip=217.70.178.231; helo=relay11.mail.gandi.net; envelope-from=ash@heyquark.com; receiver=) Received: from relay11.mail.gandi.net (relay11.mail.gandi.net [217.70.178.231]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4K7hNx2WLnz3c1x for ; Wed, 2 Mar 2022 15:44:49 +1100 (AEDT) Received: (Authenticated sender: ash@heyquark.com) by mail.gandi.net (Postfix) with ESMTPSA id 348B3100005; Wed, 2 Mar 2022 04:44:42 +0000 (UTC) From: Ash Logan To: paulus@samba.org, mpe@ellerman.id.au, christophe.leroy@csgroup.eu, robh+dt@kernel.org, benh@kernel.crashing.org Subject: [PATCH 06/12] powerpc: wiiu: udbg support for latteipc Date: Wed, 2 Mar 2022 15:44:00 +1100 Message-Id: <20220302044406.63401-7-ash@heyquark.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220302044406.63401-1-ash@heyquark.com> References: <20220302044406.63401-1-ash@heyquark.com> MIME-Version: 1.0 X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org, j.ne@posteo.net Errors-To: linuxppc-dev-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Linuxppc-dev" 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 --- 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 diff --git a/arch/powerpc/Kconfig.debug b/arch/powerpc/Kconfig.debug index 192f0ed0097f..15c7fa7c040a 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. +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/udbg.h index 0ea9e70ed78b..82858c0283ac 100644 --- a/arch/powerpc/include/asm/udbg.h +++ b/arch/powerpc/include/asm/udbg.h @@ -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 */ diff --git a/arch/powerpc/kernel/head_book3s_32.S b/arch/powerpc/kernel/head_book3s_32.S index 68e5c0a7e99d..f159e500342c 100644 --- a/arch/powerpc/kernel/head_book3s_32.S +++ b/arch/powerpc/kernel/head_book3s_32.S @@ -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 diff --git a/arch/powerpc/kernel/udbg.c b/arch/powerpc/kernel/udbg.c index b1544b2f6321..84eae25c195e 100644 --- a/arch/powerpc/kernel/udbg.c +++ b/arch/powerpc/kernel/udbg.c @@ -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 diff --git a/arch/powerpc/platforms/wiiu/Kconfig b/arch/powerpc/platforms/wiiu/Kconfig index e5513205da3c..fa86cbc33d5e 100644 --- a/arch/powerpc/platforms/wiiu/Kconfig +++ b/arch/powerpc/platforms/wiiu/Kconfig @@ -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. 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) += udbg_latteipc.o diff --git a/arch/powerpc/platforms/wiiu/udbg_latteipc.c b/arch/powerpc/platforms/wiiu/udbg_latteipc.c new file mode 100644 index 000000000000..d546b3ba9bab --- /dev/null +++ b/arch/powerpc/platforms/wiiu/udbg_latteipc.c @@ -0,0 +1,122 @@ +// 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 + +#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 = latteipc_io_base + LT_IPC_PPCMSG; + void __iomem *ppcctrl_reg = 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 hardware. + */ +static void __iomem *latteipc_udbg_setup_ipc_io_base(struct device_node *np) +{ + void __iomem *ipc_io_base = NULL; + phys_addr_t paddr; + const unsigned int *reg; + + reg = of_get_property(np, "reg", NULL); + if (reg) { + paddr = of_translate_address(np, reg); + if (paddr) + ipc_io_base = 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 = 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 = 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 = 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 = (void __iomem *)__fix_to_virt(FIX_EARLY_DEBUG_BASE); + + /* Assume a firmware is present, add hooks */ + udbg_putc = 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/platforms/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 */ From patchwork Wed Mar 2 04:44:01 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ash Logan X-Patchwork-Id: 1599599 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.ozlabs.org (client-ip=2404:9400:2:0:216:3eff:fee1:b9f1; helo=lists.ozlabs.org; envelope-from=linuxppc-dev-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org; receiver=) Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2404:9400:2:0:216:3eff:fee1:b9f1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4K7hRl4k71z9sFN for ; Wed, 2 Mar 2022 15:47:15 +1100 (AEDT) Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4K7hRk4p16z3fGm for ; Wed, 2 Mar 2022 15:47:14 +1100 (AEDT) X-Original-To: linuxppc-dev@lists.ozlabs.org Delivered-To: linuxppc-dev@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=heyquark.com (client-ip=217.70.178.231; helo=relay11.mail.gandi.net; envelope-from=ash@heyquark.com; receiver=) Received: from relay11.mail.gandi.net (relay11.mail.gandi.net [217.70.178.231]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4K7hP25BvFz3c4H for ; Wed, 2 Mar 2022 15:44:54 +1100 (AEDT) Received: (Authenticated sender: ash@heyquark.com) by mail.gandi.net (Postfix) with ESMTPSA id 1528D100002; Wed, 2 Mar 2022 04:44:47 +0000 (UTC) From: Ash Logan To: paulus@samba.org, mpe@ellerman.id.au, christophe.leroy@csgroup.eu, robh+dt@kernel.org, benh@kernel.crashing.org Subject: [PATCH 07/12] powerpc: wiiu: espresso interrupt controller support Date: Wed, 2 Mar 2022 15:44:01 +1100 Message-Id: <20220302044406.63401-8-ash@heyquark.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220302044406.63401-1-ash@heyquark.com> References: <20220302044406.63401-1-ash@heyquark.com> MIME-Version: 1.0 X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org, Roberto Van Eeden , j.ne@posteo.net Errors-To: linuxppc-dev-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Linuxppc-dev" 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 +obj-$(CONFIG_WIIU) += espresso-pic.o obj-$(CONFIG_LATTEIPC_UDBG) += udbg_latteipc.o diff --git a/arch/powerpc/platforms/wiiu/espresso-pic.c b/arch/powerpc/platforms/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 = *this_cpu_ptr(&espresso_pic_cpu); + u32 mask = 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 = *this_cpu_ptr(&espresso_pic_cpu); + u32 mask = 1 << irqd_to_hwirq(d); + + out_be32(&pic->icr, mask); +} + +static void espresso_pic_mask(struct irq_data *d) +{ + struct espresso_pic *pic = *this_cpu_ptr(&espresso_pic_cpu); + u32 mask = 1 << irqd_to_hwirq(d); + + clrbits32(&pic->imr, mask); +} + +static void espresso_pic_unmask(struct irq_data *d) +{ + struct espresso_pic *pic = *this_cpu_ptr(&espresso_pic_cpu); + u32 mask = 1 << irqd_to_hwirq(d); + + setbits32(&pic->imr, mask); +} + +static struct irq_chip espresso_pic_chip = { + .name = "espresso-pic", + .irq_ack = espresso_pic_ack, + .irq_mask_ack = espresso_pic_mask_and_ack, + .irq_mask = espresso_pic_mask, + .irq_unmask = espresso_pic_unmask, +}; + +/* + * Domain Ops + */ + +static int espresso_pic_match(struct irq_domain *h, struct device_node *node, + enum irq_domain_bus_token bus_token) +{ + if (h->fwnode == &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 = arg; + irq_hw_number_t hwirq = fwspec->param[0]; + + for (i = 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 = { + .match = espresso_pic_match, + .alloc = espresso_pic_alloc, + .free = espresso_pic_free, +}; + +/* Store irq domain for espresso_pic_get_irq (the function gets no arguments) */ +static struct irq_domain *espresso_irq_domain; + +unsigned int espresso_pic_get_irq(void) +{ + struct espresso_pic *pic = *this_cpu_ptr(&espresso_pic_cpu); + u32 irq_status, irq; + + irq_status = in_be32(&pic->icr) & in_be32(&pic->imr); + + if (irq_status == 0) + return 0; /* No IRQs pending */ + + /* Return first IRQ */ + irq = __ffs(irq_status); + return irq_linear_revmap(espresso_irq_domain, irq); +} + +void __init espresso_pic_init(void) +{ + struct device_node *np = + 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) != 0) { + pr_err("could not find resource address\n"); + goto out; + } + + regbase = 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 = per_cpu_ptr(&espresso_pic_cpu, cpu); + + /* Compute pic address */ + *pic = regbase + (sizeof(struct espresso_pic) * cpu); + + /* Mask and Ack all IRQs */ + out_be32(&(*pic)->imr, 0); + out_be32(&(*pic)->icr, 0xFFFFFFFF); + } + + host = 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 = host; + + irq_set_default_host(host); + +out: + of_node_put(np); +} diff --git a/arch/powerpc/platforms/wiiu/espresso-pic.h b/arch/powerpc/platforms/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 used: + * + * 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 From patchwork Wed Mar 2 04:44:02 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ash Logan X-Patchwork-Id: 1599600 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.ozlabs.org (client-ip=2404:9400:2:0:216:3eff:fee1:b9f1; helo=lists.ozlabs.org; envelope-from=linuxppc-dev-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org; receiver=) Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2404:9400:2:0:216:3eff:fee1:b9f1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4K7hSJ4T27z9sFN for ; Wed, 2 Mar 2022 15:47:44 +1100 (AEDT) Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4K7hSH4hfZz3fNL for ; Wed, 2 Mar 2022 15:47:43 +1100 (AEDT) X-Original-To: linuxppc-dev@lists.ozlabs.org Delivered-To: linuxppc-dev@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=heyquark.com (client-ip=217.70.178.231; helo=relay11.mail.gandi.net; envelope-from=ash@heyquark.com; receiver=) Received: from relay11.mail.gandi.net (relay11.mail.gandi.net [217.70.178.231]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4K7hP81LXkz3cG6 for ; Wed, 2 Mar 2022 15:44:59 +1100 (AEDT) Received: (Authenticated sender: ash@heyquark.com) by mail.gandi.net (Postfix) with ESMTPSA id 7366A100007; Wed, 2 Mar 2022 04:44:53 +0000 (UTC) From: Ash Logan To: paulus@samba.org, mpe@ellerman.id.au, christophe.leroy@csgroup.eu, robh+dt@kernel.org, benh@kernel.crashing.org Subject: [PATCH 08/12] powerpc: wiiu: latte interrupt controller support Date: Wed, 2 Mar 2022 15:44:02 +1100 Message-Id: <20220302044406.63401-9-ash@heyquark.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220302044406.63401-1-ash@heyquark.com> References: <20220302044406.63401-1-ash@heyquark.com> MIME-Version: 1.0 X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org, Roberto Van Eeden , j.ne@posteo.net Errors-To: linuxppc-dev-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Linuxppc-dev" 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 --- 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/wiiu/Kconfig index fa86cbc33d5e..5e062536ca58 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 config LATTEIPC_UDBG bool "Chipset IPC udbg console for the Nintendo Wii U" 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 -obj-$(CONFIG_WIIU) += espresso-pic.o +obj-$(CONFIG_WIIU) += espresso-pic.o latte-pic.o obj-$(CONFIG_LATTEIPC_UDBG) += udbg_latteipc.o diff --git a/arch/powerpc/platforms/wiiu/latte-pic.c b/arch/powerpc/platforms/wiiu/latte-pic.c new file mode 100644 index 000000000000..d16e0c2de2b0 --- /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 interrupt 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 = *this_cpu_ptr(<_pic_cpu); + u32 irq = irqd_to_hwirq(d); + + if (irq < LATTE_AHBALL_NR_IRQS) { + u32 mask = 1 << irq; + + out_be32(&pic->ahball_icr, mask); + clrbits32(&pic->ahball_imr, mask); + } else { + u32 mask = 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 = *this_cpu_ptr(<_pic_cpu); + u32 irq = irqd_to_hwirq(d); + + if (irq < LATTE_AHBALL_NR_IRQS) { + u32 mask = 1 << irq; + + out_be32(&pic->ahball_icr, mask); + } else { + u32 mask = 1 << (irq - 32); + + out_be32(&pic->ahblt_icr, mask); + } +} + +static void latte_pic_mask(struct irq_data *d) +{ + struct lt_pic *pic = *this_cpu_ptr(<_pic_cpu); + u32 irq = irqd_to_hwirq(d); + + if (irq < LATTE_AHBALL_NR_IRQS) { + u32 mask = 1 << irq; + + clrbits32(&pic->ahball_imr, mask); + } else { + u32 mask = 1 << (irq - 32); + + clrbits32(&pic->ahblt_imr, mask); + } +} + +static void latte_pic_unmask(struct irq_data *d) +{ + struct lt_pic *pic = *this_cpu_ptr(<_pic_cpu); + u32 irq = irqd_to_hwirq(d); + + if (irq < LATTE_AHBALL_NR_IRQS) { + u32 mask = 1 << irq; + + setbits32(&pic->ahball_imr, mask); + } else { + u32 mask = 1 << (irq - 32); + + setbits32(&pic->ahblt_imr, mask); + } +} + +static struct irq_chip latte_pic = { + .name = "latte-pic", + .irq_ack = latte_pic_ack, + .irq_mask_ack = latte_pic_mask_and_ack, + .irq_mask = latte_pic_mask, + .irq_unmask = 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 == &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 = arg; + irq_hw_number_t hwirq = fwspec->param[0]; + + for (i = 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 = { + .match = latte_pic_match, + .alloc = latte_pic_alloc, + .free = latte_pic_free, +}; + +/* + * Determinate if there are interrupts pending + * Checks AHBALL (0-32) and AHBLT (32-64) + */ +unsigned int latte_pic_get_irq(struct irq_domain *h) +{ + struct lt_pic *pic = *this_cpu_ptr(<_pic_cpu); + u32 irq_status, irq; + + /* Check AHBALL first */ + irq_status = in_be32(&pic->ahball_icr) & in_be32(&pic->ahball_imr); + + if (irq_status == 0) { + /* Try AHBLT */ + irq_status = + in_be32(&pic->ahblt_icr) & in_be32(&pic->ahblt_imr); + if (irq_status == 0) + return 0; /* No IRQs pending */ + + /* AHBLT is mapped above 32 (LATTE_AHBALL_NR_IRQS) */ + irq = __ffs(irq_status) + LATTE_AHBALL_NR_IRQS; + return irq_linear_revmap(h, irq); + } + + irq = __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 = irq_desc_get_handler_data(desc); + struct irq_chip *chip = 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 = 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 = + 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 = 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 = per_cpu_ptr(<_pic_cpu, cpu); + + /* Compute pic address */ + *pic = regbase + (sizeof(struct lt_pic) * cpu); + + /* Mask and Ack CPU IRQs */ + out_be32(&(*pic)->ahball_imr, 0); + out_be32(&(*pic)->ahball_icr, 0xFFFFFFFF); + } + + host = 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 = 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/platforms/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 From patchwork Wed Mar 2 04:44:03 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ash Logan X-Patchwork-Id: 1599601 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.ozlabs.org (client-ip=112.213.38.117; helo=lists.ozlabs.org; envelope-from=linuxppc-dev-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org; receiver=) Received: from lists.ozlabs.org (lists.ozlabs.org [112.213.38.117]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4K7hSl18Clz9sFN for ; Wed, 2 Mar 2022 15:48:07 +1100 (AEDT) Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4K7hSj56ZMz3fTZ for ; Wed, 2 Mar 2022 15:48:05 +1100 (AEDT) X-Original-To: linuxppc-dev@lists.ozlabs.org Delivered-To: linuxppc-dev@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=heyquark.com (client-ip=2001:4b98:dc4:8::231; helo=relay11.mail.gandi.net; envelope-from=ash@heyquark.com; receiver=) Received: from relay11.mail.gandi.net (relay11.mail.gandi.net [IPv6:2001:4b98:dc4:8::231]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4K7hPF2f9yz3cdx for ; Wed, 2 Mar 2022 15:45:05 +1100 (AEDT) Received: (Authenticated sender: ash@heyquark.com) by mail.gandi.net (Postfix) with ESMTPSA id E77C8100006; Wed, 2 Mar 2022 04:44:58 +0000 (UTC) From: Ash Logan To: paulus@samba.org, mpe@ellerman.id.au, christophe.leroy@csgroup.eu, robh+dt@kernel.org, benh@kernel.crashing.org Subject: [PATCH 09/12] powerpc: espresso processor support Date: Wed, 2 Mar 2022 15:44:03 +1100 Message-Id: <20220302044406.63401-10-ash@heyquark.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220302044406.63401-1-ash@heyquark.com> References: <20220302044406.63401-1-ash@heyquark.com> MIME-Version: 1.0 X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org, Roberto Van Eeden , j.ne@posteo.net Errors-To: linuxppc-dev-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Linuxppc-dev" From: Roberto Van Eeden 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 --- arch/powerpc/kernel/cputable.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/arch/powerpc/kernel/cputable.c b/arch/powerpc/kernel/cputable.c index ae0fdef0ac11..b575f5570485 100644 --- a/arch/powerpc/kernel/cputable.c +++ b/arch/powerpc/kernel/cputable.c @@ -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, From patchwork Wed Mar 2 04:44:04 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ash Logan X-Patchwork-Id: 1599602 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.ozlabs.org (client-ip=2404:9400:2:0:216:3eff:fee1:b9f1; helo=lists.ozlabs.org; envelope-from=linuxppc-dev-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org; receiver=) Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2404:9400:2:0:216:3eff:fee1:b9f1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4K7hT84B6rz9sFN for ; Wed, 2 Mar 2022 15:48:28 +1100 (AEDT) Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4K7hT74frrz3fZy for ; Wed, 2 Mar 2022 15:48:27 +1100 (AEDT) X-Original-To: linuxppc-dev@lists.ozlabs.org Delivered-To: linuxppc-dev@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=heyquark.com (client-ip=217.70.178.231; helo=relay11.mail.gandi.net; envelope-from=ash@heyquark.com; receiver=) Received: from relay11.mail.gandi.net (relay11.mail.gandi.net [217.70.178.231]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4K7hPM3Zy1z3cgR for ; Wed, 2 Mar 2022 15:45:11 +1100 (AEDT) Received: (Authenticated sender: ash@heyquark.com) by mail.gandi.net (Postfix) with ESMTPSA id 7DA90100005; Wed, 2 Mar 2022 04:45:03 +0000 (UTC) From: Ash Logan To: paulus@samba.org, mpe@ellerman.id.au, christophe.leroy@csgroup.eu, robh+dt@kernel.org, benh@kernel.crashing.org Subject: [PATCH 10/12] powerpc: wiiu: platform support Date: Wed, 2 Mar 2022 15:44:04 +1100 Message-Id: <20220302044406.63401-11-ash@heyquark.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220302044406.63401-1-ash@heyquark.com> References: <20220302044406.63401-1-ash@heyquark.com> MIME-Version: 1.0 X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Emmanuel Gil Peyrot , linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org, Roberto Van Eeden , j.ne@posteo.net Errors-To: linuxppc-dev-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Linuxppc-dev" 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 --- 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 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 -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 diff --git a/arch/powerpc/platforms/wiiu/setup.c b/arch/powerpc/platforms/wiiu/setup.c new file mode 100644 index 000000000000..279fa899a296 --- /dev/null +++ b/arch/powerpc/platforms/wiiu/setup.c @@ -0,0 +1,67 @@ +// 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 const struct of_device_id wiiu_of_bus[] = { + { + .compatible = "nintendo,latte", + }, + {}, +}; + +static int __init wiiu_device_probe(void) +{ + if (!machine_is(wiiu)) + return 0; + + of_platform_populate(NULL, wiiu_of_bus, NULL, NULL); + return 0; +} +device_initcall(wiiu_device_probe); + +define_machine(wiiu) { + .name = "wiiu", + .probe = wiiu_probe, + .halt = wiiu_halt, + .progress = udbg_progress, + .calibrate_decr = generic_calibrate_decr, + .init_IRQ = wiiu_init_irq, + .get_irq = espresso_pic_get_irq, +}; From patchwork Wed Mar 2 04:44:05 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ash Logan X-Patchwork-Id: 1599603 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.ozlabs.org (client-ip=112.213.38.117; helo=lists.ozlabs.org; envelope-from=linuxppc-dev-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org; receiver=) Received: from lists.ozlabs.org (lists.ozlabs.org [112.213.38.117]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4K7hTZ3H57z9sFN for ; Wed, 2 Mar 2022 15:48:50 +1100 (AEDT) Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4K7hTY3RP8z3fgN for ; Wed, 2 Mar 2022 15:48:49 +1100 (AEDT) X-Original-To: linuxppc-dev@lists.ozlabs.org Delivered-To: linuxppc-dev@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=heyquark.com (client-ip=2001:4b98:dc4:8::231; helo=relay11.mail.gandi.net; envelope-from=ash@heyquark.com; receiver=) Received: from relay11.mail.gandi.net (relay11.mail.gandi.net [IPv6:2001:4b98:dc4:8::231]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4K7hPS11TVz3chn for ; Wed, 2 Mar 2022 15:45:15 +1100 (AEDT) Received: (Authenticated sender: ash@heyquark.com) by mail.gandi.net (Postfix) with ESMTPSA id 379B3100006; Wed, 2 Mar 2022 04:45:09 +0000 (UTC) From: Ash Logan To: paulus@samba.org, mpe@ellerman.id.au, christophe.leroy@csgroup.eu, robh+dt@kernel.org, benh@kernel.crashing.org Subject: [PATCH 11/12] powerpc: wiiu: don't enforce flat memory Date: Wed, 2 Mar 2022 15:44:05 +1100 Message-Id: <20220302044406.63401-12-ash@heyquark.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220302044406.63401-1-ash@heyquark.com> References: <20220302044406.63401-1-ash@heyquark.com> MIME-Version: 1.0 X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org, j.ne@posteo.net Errors-To: linuxppc-dev-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Linuxppc-dev" pgtable_32.c:mapin_ram loops over each valid memory range, which means non-contiguous memory just works. Signed-off-by: Ash Logan --- arch/powerpc/mm/init_32.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/arch/powerpc/mm/init_32.c b/arch/powerpc/mm/init_32.c index 3d690be48e84..59a84629d9a0 100644 --- a/arch/powerpc/mm/init_32.c +++ b/arch/powerpc/mm/init_32.c @@ -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 } From patchwork Wed Mar 2 04:44:06 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ash Logan X-Patchwork-Id: 1599604 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.ozlabs.org (client-ip=2404:9400:2:0:216:3eff:fee1:b9f1; helo=lists.ozlabs.org; envelope-from=linuxppc-dev-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org; receiver=) Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2404:9400:2:0:216:3eff:fee1:b9f1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4K7hTz5Q0Lz9sFN for ; Wed, 2 Mar 2022 15:49:11 +1100 (AEDT) Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4K7hTy5TMYz3fnq for ; Wed, 2 Mar 2022 15:49:10 +1100 (AEDT) X-Original-To: linuxppc-dev@lists.ozlabs.org Delivered-To: linuxppc-dev@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=heyquark.com (client-ip=2001:4b98:dc4:8::231; helo=relay11.mail.gandi.net; envelope-from=ash@heyquark.com; receiver=) Received: from relay11.mail.gandi.net (relay11.mail.gandi.net [IPv6:2001:4b98:dc4:8::231]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4K7hPX73kTz3cjL for ; Wed, 2 Mar 2022 15:45:20 +1100 (AEDT) Received: (Authenticated sender: ash@heyquark.com) by mail.gandi.net (Postfix) with ESMTPSA id 2722E100009; Wed, 2 Mar 2022 04:45:14 +0000 (UTC) From: Ash Logan To: paulus@samba.org, mpe@ellerman.id.au, christophe.leroy@csgroup.eu, robh+dt@kernel.org, benh@kernel.crashing.org Subject: [PATCH 12/12] powerpc: wiiu: Add minimal default config Date: Wed, 2 Mar 2022 15:44:06 +1100 Message-Id: <20220302044406.63401-13-ash@heyquark.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220302044406.63401-1-ash@heyquark.com> References: <20220302044406.63401-1-ash@heyquark.com> MIME-Version: 1.0 X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org, j.ne@posteo.net Errors-To: linuxppc-dev-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Linuxppc-dev" 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. 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/wiiu_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=y +# CONFIG_PPC_OF_BOOT_TRAMPOLINE is not set +CONFIG_HIGHMEM=y +CONFIG_STRICT_KERNEL_RWX=y +CONFIG_PPC_EARLY_DEBUG=y