From patchwork Sat Nov 19 11:30:31 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ash Logan X-Patchwork-Id: 1706551 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.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 ECDSA (P-384)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4NDsL542vYz23nH for ; Sat, 19 Nov 2022 22:46:05 +1100 (AEDT) Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4NDsL535hrz3f6t for ; Sat, 19 Nov 2022 22:46: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::240; helo=mslow1.mail.gandi.net; envelope-from=ash@heyquark.com; receiver=) Received: from mslow1.mail.gandi.net (mslow1.mail.gandi.net [IPv6:2001:4b98:dc4:8::240]) (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 4NDsKH0BbQz3bY8 for ; Sat, 19 Nov 2022 22:45:22 +1100 (AEDT) Received: from relay9-d.mail.gandi.net (unknown [IPv6:2001:4b98:dc4:8::229]) by mslow1.mail.gandi.net (Postfix) with ESMTP id 189E1CD281 for ; Sat, 19 Nov 2022 11:31:12 +0000 (UTC) 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 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 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: devicetree@vger.kernel.org, linkmauve@linkmauve.fr, linux-kernel@vger.kernel.org, rw-r-r-0644@protonmail.com, joel@jms.id.au, linuxppc-dev@lists.ozlabs.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 --- 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/espresso-pic.yaml b/Documentation/devicetree/bindings/powerpc/nintendo/wiiu/espresso-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" processor. + +allOf: + - $ref: "/schemas/interrupt-controller.yaml#" + +properties: + compatible: + const: nintendo,espresso-pic + + '#interrupt-cells': + # Interrupt numbers 0-32 in one cell + const: 1 + + interrupt-controller: true + + reg: + maxItems: 1 + +required: + - compatible + - '#interrupt-cells' + - interrupt-controller + - reg + +additionalProperties: false + +examples: + - | + interrupt-controller@c000078 { + compatible = "nintendo,espresso-pic"; + reg = <0x0c000078 0x18>; + #interrupt-cells = <1>; + interrupt-controller; + }; +... 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..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 multifunction chip of the + Nintendo Wii U. + +properties: + compatible: + const: nintendo,latte-gpu7 + + reg: + maxItems: 1 + + interrupts: + maxItems: 1 + +required: + - compatible + - reg + - interrupts + +additionalProperties: false + +examples: + - | + gpu@c200000 { + compatible = "nintendo,latte-gpu7"; + reg = <0x0c200000 0x80000>; + interrupts = <2>; + interrupt-parent = <&espresso_pic>; + }; +... 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..a53971a11e89 --- /dev/null +++ b/Documentation/devicetree/bindings/powerpc/nintendo/wiiu/latte-ahci.yaml @@ -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 = "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..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 = "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..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 = "nintendo,latte-pic"; + #interrupt-cells = <1>; + interrupt-controller; + 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..25d474fca679 --- /dev/null +++ b/Documentation/devicetree/bindings/powerpc/nintendo/wiiu/latte-sdhci.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-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. + +allOf: + - $ref: "/schemas/mmc/mmc-controller.yaml#" + +properties: + compatible: + items: + - const: nintendo,latte-sdhci + - const: sdhci + + reg: + maxItems: 1 + + interrupts: + maxItems: 1 + +required: + - compatible + - reg + - interrupts + +additionalProperties: false + +examples: + - | + mmc@d070000 { + compatible = "nintendo,latte-sdhci", "sdhci"; + reg = <0x0d070000 0x200>; + interrupts = <7>; + interrupt-parent = <&latte_pic>; + }; +... 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 Nintendo 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/Documentation/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: From patchwork Sat Nov 19 11:30:32 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ash Logan X-Patchwork-Id: 1706553 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.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 ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4NDsMq0pY7z23nH for ; Sat, 19 Nov 2022 22:47:34 +1100 (AEDT) Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4NDsMp5RmNz3fHn for ; Sat, 19 Nov 2022 22:47:34 +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::240; helo=mslow1.mail.gandi.net; envelope-from=ash@heyquark.com; receiver=) Received: from mslow1.mail.gandi.net (mslow1.mail.gandi.net [IPv6:2001:4b98:dc4:8::240]) (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 4NDsKH0LBmz3bgC for ; Sat, 19 Nov 2022 22:45:22 +1100 (AEDT) Received: from relay9-d.mail.gandi.net (unknown [217.70.183.199]) by mslow1.mail.gandi.net (Postfix) with ESMTP id 3F2CDCD8E7 for ; Sat, 19 Nov 2022 11:31:18 +0000 (UTC) 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 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 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: devicetree@vger.kernel.org, linkmauve@linkmauve.fr, linux-kernel@vger.kernel.org, rw-r-r-0644@protonmail.com, joel@jms.id.au, linuxppc-dev@lists.ozlabs.org, 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 --- 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 = "nintendo,wup-101"; + compatible = "nintendo,wiiu"; + + #address-cells = <1>; + #size-cells = <1>; + + memory@0 { + device_type = "memory"; + reg = <0x00000000 0x02000000 /* MEM1 - 32MiB */ + 0x08000000 0x00300000 /* MEM0 - 3MiB */ + 0x10000000 0x80000000>; /* MEM2 - 2GiB */ + }; + + cpus { + #address-cells = <1>; + #size-cells = <0>; + + /* TODO: Add SMP */ + PowerPC,espresso@0 { + device_type = "cpu"; + reg = <0>; + clock-frequency = <1243125000>; /* 1.243125GHz */ + bus-frequency = <248625000>; /* 248.625MHz core-to-bus 5x */ + timebase-frequency = <62156250>; /* 1/4 of the bus clock */ + i-cache-size = <32768>; /* 32K icache */ + i-cache-line-size = <32>; + i-cache-block-size = <32>; + i-cache-sets = <128>; + d-cache-size = <32768>; /* 32K dcache */ + d-cache-line-size = <32>; + d-cache-block-size = <32>; + d-cache-sets = <128>; + next-level-cache = <&L2_0>; + L2_0:l2-cache { + compatible = "cache"; + cache-level = <2>; + cache-unified; + cache-size = <0x80000>; /* 512KB L2 */ + cache-line-size = <64>; + cache-block-size = <32>; + cache-sets = <2048>; + }; + }; + }; + + soc { + compatible = "nintendo,latte", "simple-bus"; + ranges = <0x0c000000 0x0c000000 0x00400000 /* Espresso-only registers */ + 0x0d000000 0x0d000000 0x00200000 /* Latte AHB deivces */ + 0x0d800000 0x0d800000 0x00800000>; /* Latte SoC registers */ + + #address-cells = <1>; + #size-cells = <1>; + + latte_gpu: gpu@c200000 { + compatible = "nintendo,latte-gpu7"; + reg = <0x0c200000 0x80000>; + interrupts = <2>; + interrupt-parent = <&espresso_pic>; + }; + + espresso_pic: interrupt-controller@c000078 { + compatible = "nintendo,espresso-pic"; + reg = <0x0c000078 0x18>; + #interrupt-cells = <1>; + interrupt-controller; + }; + + latte_dsp: dsp@c005000 { + compatible = "nintendo,latte-dsp"; + reg = <0x0c005000 0x200>; + }; + + ehci_0: usb@d040000 { + compatible = "nintendo,latte-ehci", "usb-ehci"; + reg = <0x0d040000 0x100>; + interrupts = <4>; + interrupt-parent = <&latte_pic>; + big-endian-regs; + }; + + ohci_0_0: usb@d050000 { + compatible = "nintendo,latte-ohci"; + reg = <0x0d050000 0x100>; + interrupts = <5>; + interrupt-parent = <&latte_pic>; + big-endian-regs; + }; + + ohci_0_1: usb@d060000 { + compatible = "nintendo,latte-ohci"; + reg = <0x0d060000 0x100>; + interrupts = <6>; + interrupt-parent = <&latte_pic>; + big-endian-regs; + }; + + ehci_1: usb@d120000 { + compatible = "nintendo,latte-ehci", "usb-ehci"; + reg = <0x0d120000 0x100>; + interrupts = <16>; + interrupt-parent = <&latte_pic>; + big-endian-regs; + }; + + ohci_1_0: usb@d130000 { + compatible = "nintendo,latte-ohci"; + reg = <0x0d130000 0x100>; + interrupts = <35>; + interrupt-parent = <&latte_pic>; + big-endian-regs; + }; + + ehci_2: usb@d140000 { + compatible = "nintendo,latte-ehci", "usb-ehci"; + reg = <0x0d140000 0x100>; + interrupts = <36>; + interrupt-parent = <&latte_pic>; + big-endian-regs; + }; + + ohci_2_0: usb@d150000 { + compatible = "nintendo,latte-ohci"; + reg = <0x0d150000 0x100>; + interrupts = <37>; + interrupt-parent = <&latte_pic>; + + big-endian-regs; + }; + + sdcard_0: mmc@d070000 { + compatible = "nintendo,latte-sdhci","sdhci"; + reg = <0x0d070000 0x200>; + interrupts = <7>; + interrupt-parent = <&latte_pic>; + }; + + wifi_0: mmc@d080000 { + compatible = "nintendo,latte-sdhci","sdhci"; + reg = <0x0d080000 0x200>; + interrupts = <8>; + interrupt-parent = <&latte_pic>; + }; + + legacy_ipc: ipc@d800000 { + compatible = "nintendo,latte-ipc", "nintendo,hollywood-ipc"; + reg = <0x0d800000 0x10>; + interrupts = <30 31>; + interrupt-parent = <&latte_pic>; + }; + + latte_otp: otp@d8001ec { + compatible = "nintendo,latte-otp"; + reg = <0x0d8001ec 0x8>; + }; + + sata@d160400 { + compatible = "nintendo,latte-ahci"; + reg = <0x0d160400 0x808>; + + interrupt-parent = <&latte_pic>; + interrupts = <38 28>; + }; + + latte_pic: interrupt-controller@d800440 { + #interrupt-cells = <1>; + interrupt-controller; + + compatible = "nintendo,latte-pic"; + reg = <0x0d800440 0x30>; + interrupt-parent = <&espresso_pic>; + interrupts = <24>; + }; + + gpio: gpio@d8000c0 { + #gpio-cells = <2>; + compatible = "nintendo,latte-gpio", "nintendo,hollywood-gpio"; + + reg = <0x0d8000c0 0x40>; + gpio-controller; + /* TODO: There are actually 31 AHBALL GPIOs */ + ngpios = <24>; + + gpio-line-names = + "POWER", "DWIFI", "FAN", "DC_DC", + "", "Esp10WorkAround", "", "", + "PADPD", "", "EEP_CS", "EEP_CLK", + "EEP_MOSI", "EEP_MISO", "AVE_SCL", "AVE_SDA", + "DEBUG0", "DEBUG1", "DEBUG2", "DEBUG3", + "DEBUG4", "DEBUG5", "DEBUG6", "DEBUG7"; + + interrupt-controller; + #interrupt-cells = <2>; + interrupts = <10>; + interrupt-parent = <&latte_pic>; + }; + + gpio2: gpio@d800520 { + #gpio-cells = <2>; + compatible = "nintendo,latte-gpio", "nintendo,hollywood-gpio"; + + reg = <0x0d800520 0x40>; + gpio-controller; + ngpios = <7>; + + gpio-line-names = + "FANSPEED", "SMC_SCL", "SMC_SDA", "DC_DC2", + "AVE_INT", "", "AVE_RESET"; + + interrupt-controller; + #interrupt-cells = <2>; + interrupts = <10>; + interrupt-parent = <&latte_pic>; + }; + }; + + spi_gpio: spi { + compatible = "spi-gpio"; + #address-cells = <1>; + #size-cells = <0>; + + cs-gpios = <&gpio 10 GPIO_ACTIVE_HIGH>; + sck-gpios = <&gpio 11 GPIO_ACTIVE_HIGH>; + mosi-gpios = <&gpio 12 GPIO_ACTIVE_HIGH>; + miso-gpios = <&gpio 13 GPIO_ACTIVE_HIGH>; + num-chipselects = <1>; + + eeprom@0 { + compatible = "atmel,at93c66"; + reg = <0>; + spi-max-frequency = <1000000>; + spi-cs-high; + /* TODO: wiiubrew says this is 16-bit, but I only get the correct + * values in 8-bit... + */ + data-size = <8>; + read-only; + + #address-cells = <1>; + #size-cells = <1>; + + /* https://wiiubrew.org/wiki/Hardware/SEEPROM */ + rng_seed: rng@12 { reg = <0x012 8>; }; + ppc_pvr: pvr@20 { reg = <0x020 4>; }; + seeprom_ver_str: sver-str@24 { reg = <0x024 6>; }; + seeprom_ver: sver@2a { reg = <0x02A 2>; }; + otp_ver: over@2c { reg = <0x02C 2>; }; + otp_rev: orev@2e { reg = <0x02E 2>; }; + otp_ver_str: over-str@30 { reg = <0x030 8>; }; + + bc_crc: bc-crc@38 { reg = <0x038 4>; }; + bc_sz: bc-sz@3c { reg = <0x03C 2>; }; + bc_ver: bc-ver@3e { reg = <0x03E 2>; }; + bc_boardtype: boardtype@42 { reg = <0x042 2>; }; + bc_boardrev: boardrev@44 { reg = <0x044 2>; }; + bc_bootsource: bootsource@46 { reg = <0x046 2>; }; + bc_ddr3size: ddr3size@48 { reg = <0x048 2>; }; + bc_ddr3speed: ddr3speed@4a { reg = <0x04A 2>; }; + bc_ppcclockmul: ppcclockmul@4c { reg = <0x04C 2>; }; + bc_iopclockmul: iopclockmul@46 { reg = <0x04E 2>; }; + bc_video1080p: video1080p@50 { reg = <0x050 2>; }; + bc_ddr3vendor: ddr3vendor@52 { reg = <0x052 2>; }; + bc_movpassivereset: movpassivereset@54 { reg = <0x054 2>; }; + bc_syspllspd: syspllspd@56 { reg = <0x056 2>; }; + bc_satadevice: satadevice@58 { reg = <0x058 2>; }; + bc_consoletype: consoletype@5a { reg = <0x05A 2>; }; + bc_deviceprescence: deviceprescence@5c { reg = <0x05C 2>; }; + + drive_key: drvkey@80 { reg = <0x080 16>; }; + factory_key: fackey@90 { reg = <0x090 16>; }; + shdd_key: shddkey@a0 { reg = <0x0A0 16>; }; + usb_key_seed: usbkeyseed@b0 { reg = <0x0B0 16>; }; + drive_key_flag: drvkeyf@c0 { reg = <0x0C0 2>; }; + usb_key_flag: udbkeyf@c2 { reg = <0x0C2 2>; }; + shdd_key_flag: shddkeyf@c4 { reg = <0x0C4 2>; }; + + sysprod_version: sp_ver@140 { reg = <0x140 4>; }; + sysprod_eeprom_version: sp_ee_ver@144 { reg = <0x144 4>; }; + sysprod_product_area: sp_parea@148 { reg = <0x148 4>; }; + sysprod_game_region: sp_region@14c { reg = <0x14C 4>; }; + sysprod_ntsc_pal: sp_ntscpal@150 { reg = <0x150 4>; }; + sysprod_5ghz_country: sp_5ghz_c@154 { reg = <0x154 2>; }; + sysprod_5ghz_country_rev: sp_5ghz_crev@156 { reg = <0x156 2>; }; + sysprod_code: sp_code@158 { reg = <0x158 8>; }; + sysprod_serial: sp_serial@160 { reg = <0x160 16>; }; + sysprod_model: sp_model@170 { reg = <0x170 16>; }; + + prod_year: pyear@188 { reg = <0x188 2>; }; + prod_date: pdate@18a { reg = <0x18A 2>; }; + prod_time: ptime@18c { reg = <0x18C 2>; }; + + boot_params: boot_params@1c0 { reg = <0x1C0 48>; }; + }; + }; + + /* TODO make this gpio-keyed once hollywood-gpio supports interrupts */ + gpio-keys { + poll-interval = <50>; + compatible = "gpio-keys-polled"; + + key-power { + label = "Power Button"; + gpios = <&gpio 0 GPIO_ACTIVE_HIGH>; + linux,code = ; + }; + }; +}; From patchwork Sat Nov 19 11:30:33 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ash Logan X-Patchwork-Id: 1706552 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.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 ECDSA (P-384)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4NDsLg1Jg3z23nH for ; Sat, 19 Nov 2022 22:46:35 +1100 (AEDT) Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4NDsLg0MXhz3f9t for ; Sat, 19 Nov 2022 22:46:35 +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::240; helo=mslow1.mail.gandi.net; envelope-from=ash@heyquark.com; receiver=) Received: from mslow1.mail.gandi.net (mslow1.mail.gandi.net [IPv6:2001:4b98:dc4:8::240]) (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 4NDsKH0JMVz3bdC for ; Sat, 19 Nov 2022 22:45:22 +1100 (AEDT) Received: from relay9-d.mail.gandi.net (unknown [217.70.183.199]) by mslow1.mail.gandi.net (Postfix) with ESMTP id 4D52FCD943 for ; Sat, 19 Nov 2022 11:31:26 +0000 (UTC) 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 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 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: devicetree@vger.kernel.org, linkmauve@linkmauve.fr, linux-kernel@vger.kernel.org, rw-r-r-0644@protonmail.com, joel@jms.id.au, linuxppc-dev@lists.ozlabs.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 d32d95aea5d6..42f622945b4a 100644 --- a/arch/powerpc/boot/Makefile +++ b/arch/powerpc/boot/Makefile @@ -162,6 +162,7 @@ src-plat-$(CONFIG_EMBEDDED6xx) += cuboot-pq2.c cuboot-mpc7448hpc2.c \ gamecube-head.S gamecube.c \ wii-head.S wii.c holly.c \ fixed-head.S mvme5100.c +src-plat-$(CONFIG_WIIU) += wiiu-head.S wiiu.c src-plat-$(CONFIG_AMIGAONE) += cuboot-amigaone.c src-plat-$(CONFIG_PPC_PS3) += ps3-head.S ps3-hvcall.S ps3.c src-plat-$(CONFIG_EPAPR_BOOT) += epapr.c epapr-wrapper.c @@ -360,6 +361,9 @@ image-$(CONFIG_GAMECUBE) += dtbImage.gamecube image-$(CONFIG_WII) += dtbImage.wii image-$(CONFIG_MVME5100) += dtbImage.mvme5100 +# Board port in arch/powerpc/platform/wiiu/Kconfig +image-$(CONFIG_WIIU) += dtbImage.wiiu + # Board port in arch/powerpc/platform/amigaone/Kconfig image-$(CONFIG_AMIGAONE) += cuImage.amigaone 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 5bdd4dd20bbb..25fd60770659 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 Sat Nov 19 11:30:34 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ash Logan X-Patchwork-Id: 1706550 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.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 ECDSA (P-384)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4NDsKY0ZYBz23nH for ; Sat, 19 Nov 2022 22:45:36 +1100 (AEDT) Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4NDsKX1lcnz3dty for ; Sat, 19 Nov 2022 22:45:36 +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::240; helo=mslow1.mail.gandi.net; envelope-from=ash@heyquark.com; receiver=) Received: from mslow1.mail.gandi.net (mslow1.mail.gandi.net [IPv6:2001:4b98:dc4:8::240]) (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 4NDsKG733tz3045 for ; Sat, 19 Nov 2022 22:45:22 +1100 (AEDT) Received: from relay9-d.mail.gandi.net (unknown [IPv6:2001:4b98:dc4:8::229]) by mslow1.mail.gandi.net (Postfix) with ESMTP id 7805FC0F8C for ; Sat, 19 Nov 2022 11:31:34 +0000 (UTC) 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 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 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: devicetree@vger.kernel.org, linkmauve@linkmauve.fr, linux-kernel@vger.kernel.org, rw-r-r-0644@protonmail.com, joel@jms.id.au, linuxppc-dev@lists.ozlabs.org, j.ne@posteo.net Errors-To: linuxppc-dev-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Linuxppc-dev" 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" 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..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 From patchwork Sat Nov 19 11:30:35 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ash Logan X-Patchwork-Id: 1706554 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.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 ECDSA (P-384)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4NDsNX3w5fz23nH for ; Sat, 19 Nov 2022 22:48:12 +1100 (AEDT) Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4NDsNX1Bynz3fLW for ; Sat, 19 Nov 2022 22:48:12 +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::240; helo=mslow1.mail.gandi.net; envelope-from=ash@heyquark.com; receiver=) Received: from mslow1.mail.gandi.net (mslow1.mail.gandi.net [IPv6:2001:4b98:dc4:8::240]) (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 4NDsKQ4C98z3dvj for ; Sat, 19 Nov 2022 22:45:30 +1100 (AEDT) Received: from relay9-d.mail.gandi.net (unknown [IPv6:2001:4b98:dc4:8::229]) by mslow1.mail.gandi.net (Postfix) with ESMTP id 6AFE9C1213 for ; Sat, 19 Nov 2022 11:31:42 +0000 (UTC) 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 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 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: devicetree@vger.kernel.org, linkmauve@linkmauve.fr, linux-kernel@vger.kernel.org, rw-r-r-0644@protonmail.com, joel@jms.id.au, linuxppc-dev@lists.ozlabs.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 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 From patchwork Sat Nov 19 11:30:36 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ash Logan X-Patchwork-Id: 1706555 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.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 ECDSA (P-384)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4NDsP54wvFz23nH for ; Sat, 19 Nov 2022 22:48:41 +1100 (AEDT) Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4NDsP544KXz3fQR for ; Sat, 19 Nov 2022 22:48:41 +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::240; helo=mslow1.mail.gandi.net; envelope-from=ash@heyquark.com; receiver=) Received: from mslow1.mail.gandi.net (mslow1.mail.gandi.net [IPv6:2001:4b98:dc4:8::240]) (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 4NDsKQ2Jr0z3dvQ for ; Sat, 19 Nov 2022 22:45:30 +1100 (AEDT) Received: from relay9-d.mail.gandi.net (unknown [217.70.183.199]) by mslow1.mail.gandi.net (Postfix) with ESMTP id 7B7E6C1757 for ; Sat, 19 Nov 2022 11:31:50 +0000 (UTC) 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 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 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: devicetree@vger.kernel.org, linkmauve@linkmauve.fr, linux-kernel@vger.kernel.org, rw-r-r-0644@protonmail.com, joel@jms.id.au, linuxppc-dev@lists.ozlabs.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 --- 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. +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 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); #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 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 /* * Call setup_cpu for CPU 0 and initialize 6xx Idle @@ -1201,4 +1204,21 @@ setup_usbgecko_bat: blr #endif +#ifdef CONFIG_PPC_EARLY_DEBUG_LATTEIPC +setup_latteipc_bat: + /* prepare a BAT for early io */ + lis r8, 0x0d80 + + /* + * The virtual address used must match the virtual address + * associated to the fixmap entry FIX_EARLY_DEBUG_BASE. + */ + lis r11, 0xfffe /* top 128K */ + ori r8, r8, 0x002a /* uncached, guarded ,rw */ + ori r11, r11, 0x2 /* 128K, Vs=1, Vp=0 */ + mtspr SPRN_DBAT1L, r8 + mtspr SPRN_DBAT1U, r11 + blr +#endif + .data 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 #ifdef CONFIG_PPC_EARLY_DEBUG diff --git a/arch/powerpc/platforms/wiiu/Kconfig b/arch/powerpc/platforms/wiiu/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) += 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..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 = 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 Sat Nov 19 11:30:37 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ash Logan X-Patchwork-Id: 1706557 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.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 ECDSA (P-384)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4NDsQF5dKyz23nH for ; Sat, 19 Nov 2022 22:49:41 +1100 (AEDT) Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4NDsQF1LVhz3f6T for ; Sat, 19 Nov 2022 22:49:41 +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::240; helo=mslow1.mail.gandi.net; envelope-from=ash@heyquark.com; receiver=) Received: from mslow1.mail.gandi.net (mslow1.mail.gandi.net [IPv6:2001:4b98:dc4:8::240]) (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 4NDsKQ4FFJz3dvk for ; Sat, 19 Nov 2022 22:45:30 +1100 (AEDT) Received: from relay9-d.mail.gandi.net (unknown [IPv6:2001:4b98:dc4:8::229]) by mslow1.mail.gandi.net (Postfix) with ESMTP id 6E92EC1C36 for ; Sat, 19 Nov 2022 11:31:58 +0000 (UTC) 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 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 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: devicetree@vger.kernel.org, linkmauve@linkmauve.fr, linux-kernel@vger.kernel.org, rw-r-r-0644@protonmail.com, joel@jms.id.au, linuxppc-dev@lists.ozlabs.org, 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 Sat Nov 19 11:30:38 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ash Logan X-Patchwork-Id: 1706556 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.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 ECDSA (P-384)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4NDsPg3DsYz23nH for ; Sat, 19 Nov 2022 22:49:11 +1100 (AEDT) Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4NDsPg2PxBz3fSN for ; Sat, 19 Nov 2022 22:49:11 +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::240; helo=mslow1.mail.gandi.net; envelope-from=ash@heyquark.com; receiver=) Received: from mslow1.mail.gandi.net (mslow1.mail.gandi.net [IPv6:2001:4b98:dc4:8::240]) (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 4NDsKQ4HCxz3dvm for ; Sat, 19 Nov 2022 22:45:30 +1100 (AEDT) Received: from relay9-d.mail.gandi.net (unknown [217.70.183.199]) by mslow1.mail.gandi.net (Postfix) with ESMTP id 185D8C2132 for ; Sat, 19 Nov 2022 11:32:08 +0000 (UTC) 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 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 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: devicetree@vger.kernel.org, linkmauve@linkmauve.fr, linux-kernel@vger.kernel.org, rw-r-r-0644@protonmail.com, joel@jms.id.au, linuxppc-dev@lists.ozlabs.org, 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 --- 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/wiiu/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 -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..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 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) + */ +static 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 Sat Nov 19 11:30:39 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ash Logan X-Patchwork-Id: 1706547 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.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 ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4NDs2N1Y55z23nH for ; Sat, 19 Nov 2022 22:32:27 +1100 (AEDT) Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4NDs2K3hf0z3dv9 for ; Sat, 19 Nov 2022 22:32:25 +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::229; helo=relay9-d.mail.gandi.net; envelope-from=ash@heyquark.com; receiver=) X-Greylist: delayed 64 seconds by postgrey-1.36 at boromir; Sat, 19 Nov 2022 22:32:10 AEDT Received: from relay9-d.mail.gandi.net (relay9-d.mail.gandi.net [IPv6:2001:4b98:dc4:8::229]) (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 4NDs224LX2z3bgC for ; Sat, 19 Nov 2022 22:32:10 +1100 (AEDT) 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 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 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: devicetree@vger.kernel.org, linkmauve@linkmauve.fr, linux-kernel@vger.kernel.org, rw-r-r-0644@protonmail.com, joel@jms.id.au, linuxppc-dev@lists.ozlabs.org, j.ne@posteo.net Errors-To: linuxppc-dev-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Linuxppc-dev" 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/kernel/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 = { .machine_check = machine_check_generic, .platform = "ppc750", }, + { /* "Espresso" (750CL-like) */ + .pvr_mask = 0xffffffff, + .pvr_value = 0x70010201, + .cpu_name = "Espresso", + .cpu_features = CPU_FTRS_750CL, + .cpu_user_features = COMMON_USER | PPC_FEATURE_PPC_LE, + .mmu_features = MMU_FTR_HPTE_TABLE | MMU_FTR_USE_HIGH_BATS, + .icache_bsize = 32, + .dcache_bsize = 32, + .num_pmcs = 4, + .pmc_type = PPC_PMC_IBM, + .cpu_setup = __setup_cpu_750, + .machine_check = machine_check_generic, + .platform = "ppc750", + }, { /* 745/755 */ .pvr_mask = 0xfffff000, .pvr_value = 0x00083000, From patchwork Sat Nov 19 11:30:40 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ash Logan X-Patchwork-Id: 1706548 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.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 ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4NDs2v41brz23nH for ; Sat, 19 Nov 2022 22:32:55 +1100 (AEDT) Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4NDs2v0H0Pz3f3P for ; Sat, 19 Nov 2022 22:32:55 +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::229; helo=relay9-d.mail.gandi.net; envelope-from=ash@heyquark.com; receiver=) Received: from relay9-d.mail.gandi.net (relay9-d.mail.gandi.net [IPv6:2001:4b98:dc4:8::229]) (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 4NDs2B40F7z3cf2 for ; Sat, 19 Nov 2022 22:32:18 +1100 (AEDT) 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 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 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: devicetree@vger.kernel.org, linkmauve@linkmauve.fr, linux-kernel@vger.kernel.org, rw-r-r-0644@protonmail.com, joel@jms.id.au, linuxppc-dev@lists.ozlabs.org, 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 --- 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 -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..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 = "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 Sat Nov 19 11:30:41 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ash Logan X-Patchwork-Id: 1706549 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.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 ECDSA (P-384)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4NDs3T5X3Jz23nH for ; Sat, 19 Nov 2022 22:33:24 +1100 (AEDT) Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4NDs3S4j8Qz3f9Z for ; Sat, 19 Nov 2022 22:33:24 +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.183.199; helo=relay9-d.mail.gandi.net; envelope-from=ash@heyquark.com; receiver=) X-Greylist: delayed 75 seconds by postgrey-1.36 at boromir; Sat, 19 Nov 2022 22:32:26 AEDT Received: from relay9-d.mail.gandi.net (relay9-d.mail.gandi.net [217.70.183.199]) (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 4NDs2L5sZJz3ccn for ; Sat, 19 Nov 2022 22:32:26 +1100 (AEDT) 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 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 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: devicetree@vger.kernel.org, linkmauve@linkmauve.fr, linux-kernel@vger.kernel.org, rw-r-r-0644@protonmail.com, joel@jms.id.au, linuxppc-dev@lists.ozlabs.org, j.ne@posteo.net Errors-To: linuxppc-dev-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Linuxppc-dev" 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/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