// SPDX-License-Identifier: GPL-2.0-or-later
/*
 * arch/powerpc/boot/dts/wii.dts
 *
 * Nintendo Wii platform device tree source
 * Copyright (C) 2008-2009 The GameCube Linux Team
 * Copyright (C) 2008,2009 Albert Herranz
 */

/dts-v1/;
#include <dt-bindings/gpio/gpio.h>
#include <dt-bindings/input/input.h>

/*
 * This is commented-out for now.
 * Until a later patch is merged, the kernel can use only the first
 * contiguous RAM range and will BUG() if the memreserve is outside
 * that range.
 */
/*/memreserve/ 0x10000000 0x0004000;*/	/* DSP RAM */

/ {
	model = "nintendo,wii";
	compatible = "nintendo,wii";
	#address-cells = <1>;
	#size-cells = <1>;

	chosen {
		bootargs = "root=/dev/mmcblk0p2 rootwait udbg-immortal";
	};

	memory {
		device_type = "memory";
		reg = <0x00000000 0x01800000	/* MEM1 24MB 1T-SRAM */
		       0x10000000 0x04000000>;	/* MEM2 64MB GDDR3 */
	};

	cpus {
		#address-cells = <1>;
		#size-cells = <0>;

		PowerPC,broadway@0 {
			device_type = "cpu";
			reg = <0>;
			clock-frequency = <729000000>; /* 729MHz */
			bus-frequency = <243000000>; /* 243MHz core-to-bus 3x */
			timebase-frequency = <60750000>; /* 243MHz / 4 */
			i-cache-line-size = <32>;
			d-cache-line-size = <32>;
			i-cache-size = <32768>;
			d-cache-size = <32768>;
		};
	};

	/* devices contained in the hollywood chipset */
	hollywood {
		#address-cells = <1>;
		#size-cells = <1>;
		compatible = "nintendo,hollywood";
                ranges = <0x0c000000 0x0c000000 0x01000000
			  0x0d000000 0x0d000000 0x00800000
			  0x0d800000 0x0d800000 0x00800000>;
		interrupt-parent = <&PIC0>;

		video@c002000 {
			compatible = "nintendo,hollywood-vi",
					"nintendo,flipper-vi";
			reg = <0x0c002000 0x100>;
			interrupts = <8>;
		};

		processor-interface@c003000 {
			compatible = "nintendo,hollywood-pi",
					"nintendo,flipper-pi";
			reg = <0x0c003000 0x100>;

			PIC0: pic0 {
				#interrupt-cells = <1>;
				compatible = "nintendo,flipper-pic";
				interrupt-controller;
			};
		};

		dsp@c005000 {
			#address-cells = <1>;
			#size-cells = <1>;
			compatible = "nintendo,hollywood-dsp",
					"nintendo,flipper-dsp";
			reg = <0x0c005000 0x200>;
			interrupts = <6>;
		};

		gamepad-controller@d006400 {
			compatible = "nintendo,hollywood-si",
					"nintendo,flipper-si";
			reg = <0x0d006400 0x100>;
			interrupts = <3>;
		};

		audio@c006c00 {
			compatible = "nintendo,hollywood-ai",
					"nintendo,flipper-ai";
			reg = <0x0d006c00 0x20>;
			interrupts = <6>;
		};

		/* External Interface bus */
		exi@d006800 {
			compatible = "nintendo,hollywood-exi",
					"nintendo,flipper-exi";
			reg = <0x0d006800 0x40>;
			virtual-reg = <0x0d006800>;
			interrupts = <4>;
		};

		usb@d040000 {
			compatible = "nintendo,hollywood-usb-ehci",
					"usb-ehci";
			reg = <0x0d040000 0x100>;
			interrupts = <4>;
			interrupt-parent = <&PIC1>;
		};

		usb@d050000 {
			compatible = "nintendo,hollywood-usb-ohci",
					"usb-ohci";
			reg = <0x0d050000 0x100>;
			interrupts = <5>;
			interrupt-parent = <&PIC1>;
		};

		usb@d060000 {
			compatible = "nintendo,hollywood-usb-ohci",
					"usb-ohci";
			reg = <0x0d060000 0x100>;
			interrupts = <6>;
			interrupt-parent = <&PIC1>;
		};

		sd@d070000 {
			compatible = "nintendo,hollywood-sdhci",
					"sdhci";
			reg = <0x0d070000 0x200>;
			interrupts = <7>;
			interrupt-parent = <&PIC1>;
		};

		sdio@d080000 {
			compatible = "nintendo,hollywood-sdhci",
					"sdhci";
			reg = <0x0d080000 0x200>;
			interrupts = <8>;
			interrupt-parent = <&PIC1>;
		};

		ipc@d000000 {
			compatible = "nintendo,hollywood-ipc";
			reg = <0x0d000000 0x10>;
			interrupts = <30>;
			interrupt-parent = <&PIC1>;
		};

		PIC1: pic1@d800030 {
			#interrupt-cells = <1>;
			compatible = "nintendo,hollywood-pic";
			reg = <0x0d800030 0x10>;
			interrupt-controller;
			interrupts = <14>;
		};

		srnprot@d800060 {
			compatible = "nintendo,hollywood-srnprot";
			reg = <0x0d800060 0x4>;
		};

		GPIO: gpio@d8000c0 {
			#gpio-cells = <2>;
			compatible = "nintendo,hollywood-gpio";
			reg = <0x0d8000c0 0x40>;
			gpio-controller;
			ngpios = <24>;

			gpio-line-names =
				"POWER", "SHUTDOWN", "FAN", "DC_DC",
				"DI_SPIN", "SLOT_LED", "EJECT_BTN", "SLOT_IN",
				"SENSOR_BAR", "DO_EJECT", "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 = <&PIC1>;

			/*
			 * This is commented out while a standard binding
			 * for i2c over gpio is defined.
			 */
			/*
			i2c-video {
				#address-cells = <1>;
				#size-cells = <0>;
			        compatible = "i2c-gpio";

			        gpios = <&GPIO 15 0
			                 &GPIO 14 0>;
			        clock-frequency = <250000>;
				no-clock-stretching;
			        scl-is-open-drain;
			        sda-is-open-drain;
			        sda-enforce-dir;

			        AVE: audio-video-encoder@70 {
			                compatible = "nintendo,wii-audio-video-encoder";
			                reg = <0x70>;
			        };
			};
			*/
		};

		control@d800100 {
			compatible = "nintendo,hollywood-control";
			/*
			 * Both the address and length are wrong, according to
			 * Wiibrew this should be <0x0d800000 0x400>, but it
			 * requires refactoring the PIC1, GPIO and OTP nodes
			 * before changing that.
			 */
			reg = <0x0d800100 0xa0>;
		};

		otp@d8001ec {
			compatible = "nintendo,hollywood-otp";
			reg = <0x0d8001ec 0x8>;
		};

		disk@d806000 {
			compatible = "nintendo,hollywood-di";
			reg = <0x0d806000 0x40>;
			interrupts = <2>;
		};
	};

	gpio-leds {
		compatible = "gpio-leds";

		/* This is the blue LED in the disk drive slot */
		drive-slot {
			label = "wii:blue:drive_slot";
			gpios = <&GPIO 5 GPIO_ACTIVE_HIGH>;
			panic-indicator;
		};
	};

	gpio-keys {
		compatible = "gpio-keys";

		power {
			label = "Power Button";
			gpios = <&GPIO 0 GPIO_ACTIVE_HIGH>;
			linux,code = <KEY_POWER>;
		};

		eject {
			label = "Eject Button";
			gpios = <&GPIO 6 GPIO_ACTIVE_HIGH>;
			linux,code = <KEY_EJECTCD>;
		};
	};
};