/dts-v1/;

#include <aarch64/gicv2.h>

/memreserve/	0x0000000000000000 0x0000000000001000;
/ {
	compatible = "raspberrypi,4-model-b", "brcm,bcm2711";
	model = "Raspberry Pi 4 Model B";
	#address-cells = <0x02>;
	#size-cells = <0x01>;
	interrupt-parent = <&gicv2>;

	aliases {
		serial0 = "/soc/serial@7e201000";
		serial1 = "/soc/serial@7e215040";
		blconfig = "/reserved-memory/nvram@0";
	};

	chosen {
		stdout-path = "serial1:115200n8";
	};

	reserved-memory {
		#address-cells = <0x02>;
		#size-cells = <0x01>;
		ranges;

		linux,cma {
			compatible = "shared-dma-pool";
			size = <0x4000000>;
			reusable;
			linux,cma-default;
			alloc-ranges = <0x00 0x00 0x40000000>;
		};

		nvram@0 {
			compatible = "raspberrypi,bootloader-config", "nvmem-rmem";
			#address-cells = <0x01>;
			#size-cells = <0x01>;
			reg = <0x00 0x00 0x00>;
			no-map;
			status = "disabled";
		};
	};

	soc {
		compatible = "simple-bus";
		#address-cells = <0x01>;
		#size-cells = <0x01>;
		ranges = <0x7e000000 0x00 0xfe000000 0x01800000>,
                 <0x7c000000 0x00 0xfc000000 0x02000000>,
                 <0x40000000 0x00 0xff800000 0x00800000>;
		dma-ranges = <0xc0000000 0x00 0x00 0x40000000>;

		timer@7e003000 {
			compatible = "brcm,bcm2835-system-timer";
			reg = <0x7e003000 0x1000>;
			interrupts = <GIC_SPI 64 IRQ_TYPE_LEVEL_HIGH>,
                         <GIC_SPI 65 IRQ_TYPE_LEVEL_HIGH>,
                         <GIC_SPI 66 IRQ_TYPE_LEVEL_HIGH>,
                         <GIC_SPI 67 IRQ_TYPE_LEVEL_HIGH>;
			clock-frequency = <0xf4240>;
		};

		txp@7e004000 {
			compatible = "brcm,bcm2835-txp";
			reg = <0x7e004000 0x20>;
			interrupts = <GIC_SPI 75 IRQ_TYPE_LEVEL_HIGH>;
		};

		dsi0: dsi@7e209000 {
			compatible = "brcm,bcm2835-dsi0";
			reg = <0x7e209000 0x78>;
			interrupts = <GIC_SPI 100 IRQ_TYPE_LEVEL_HIGH>;
			#address-cells = <0x01>;
			#size-cells = <0x00>;
			#clock-cells = <0x01>;
			clocks = <&cprman 0x20>,
                     <&cprman 0x2f>,
                     <&cprman 0x31>;
			clock-names = "phy", "escape", "pixel";
			clock-output-names = "dsi0_byte", "dsi0_ddr2", "dsi0_ddr";
			status = "disabled";
			power-domains = <&power 0x11>;
		};

        dsi1: dsi@7e700000 {
			compatible = "brcm,bcm2711-dsi1";
			reg = <0x7e700000 0x8c>;
			interrupts = <GIC_SPI 108 IRQ_TYPE_LEVEL_HIGH>;
			#address-cells = <0x01>;
			#size-cells = <0x00>;
			#clock-cells = <0x01>;
			clocks = <&cprman 0x23>,
                     <&cprman 0x30>,
                     <&cprman 0x32>;
			clock-names = "phy", "escape", "pixel";
			clock-output-names = "dsi1_byte", "dsi1_ddr2", "dsi1_ddr";
			status = "disabled";
			power-domains = <&power 0x12>;
		};

		cprman: cprman@7e101000 {
			compatible = "brcm,bcm2711-cprman";
			#clock-cells = <0x01>;
			reg = <0x7e101000 0x2000>;
			clocks = <&clk_osc>,
                     <&dsi0 0x00>,
                     <&dsi0 0x01>,
                     <&dsi0 0x02>,
                     <&dsi1 0x00>,
                     <&dsi1 0x01>,
                     <&dsi1 0x02>;
		};

		mbox: mailbox@7e00b880 {
			compatible = "brcm,bcm2835-mbox";
			reg = <0x7e00b880 0x40>;
			interrupts = <GIC_SPI 33 IRQ_TYPE_LEVEL_HIGH>;
			#mbox-cells = <0x00>;
		};

		gpio: gpio@7e200000 {
			compatible = "brcm,bcm2711-gpio";
			reg = <0x7e200000 0xb4>;
			interrupts = <GIC_SPI 113 IRQ_TYPE_LEVEL_HIGH>,
                         <GIC_SPI 114 IRQ_TYPE_LEVEL_HIGH>,
                         <GIC_SPI 115 IRQ_TYPE_LEVEL_HIGH>,
                         <GIC_SPI 116 IRQ_TYPE_LEVEL_HIGH>;
			gpio-controller;
			#gpio-cells = <0x02>;
			interrupt-controller;
			#interrupt-cells = <0x02>;
			pinctrl-names = "default";
			bootph-all;

            // UART
			uart0_ctsrts_gpio30: uart0_ctsrts_gpio30 {
				brcm,pins = <30>, <31>;
                brcm,pull = <2>, <0>;
				brcm,function = <7>;
			};
            uart0_gpio32: uart0_gpio32 {
                brcm,pins = <32>, <33>;
                brcm,pull = <0>, <2>;
                brcm,function = <8>;
            };
			uart1_gpio14: uart1_gpio14 {
				brcm,pins = <14>, <15>;
				brcm,function = <2>;
				bootph-all;
			};
			uart2_gpio: uart2_pins {
				brcm,pins = <0>, <1>;
				brcm,function = <3>;
				brcm,pull = <0>, <2>;
			};

            // I²C
            i2c0if_gpio0: i2c0if-gpio0 {
                brcm,pins = <0>, <1>;
                brcm,function = <4>;
            };
            i2c0if_gpio44: i2c0if-gpio44 {
                brcm,pins = <44>, <45>;
                brcm,function = <5>;
            };
			i2c1_gpio: i2c1 {
				brcm,pins = <2>, <3>;
				brcm,function = <4>;
				brcm,pull = <2>;
			};
			i2c3_gpio: i2c3 {
				brcm,pins = <4>, <5>;
				brcm,function = <2>;
				brcm,pull = <2>;
			};
			i2c4_gpio: i2c4 {
				brcm,pins = <8>, <9>;
				brcm,function = <2>;
				brcm,pull = <2>;
			};
			i2c5_gpio: i2c5 {
				brcm,pins = <12>, <13>;
				brcm,function = <2>;
				brcm,pull = <2>;
			};
			i2c6_gpio: i2c6 {
				brcm,pins = <22>, <23>;
				brcm,function = <2>;
				brcm,pull = <2>;
			};

            // SPI
            spi0_gpio: spi0_pins {
				brcm,pins = <9>, <10>, <11>;
				brcm,function = <4>;
			};
			spi0_cs_gpio: spi0_cs_pins {
				brcm,pins = <8>, <7>;
				brcm,function = <1>;
			};
		};

		uart0: serial@7e201000 {
			compatible = "arm,pl011", "arm,primecell";
			reg = <0x7e201000 0x200>;
			interrupts = <GIC_SPI 121 IRQ_TYPE_LEVEL_HIGH>;
			clocks = <&cprman 0x13>,
                     <&cprman 0x14>;
			clock-names = "uartclk",
                          "apb_pclk";
			arm,primecell-periphid = <0x241011>;
			pinctrl-names = "default";
			pinctrl-0 = <&uart0_ctsrts_gpio30>, <&uart0_gpio32>;
			uart-has-rtscts;
			status = "okay";
			skip-init;
			bootph-all;
		};

		aux: aux@7e215000 {
			compatible = "brcm,bcm2835-aux";
			#clock-cells = <0x01>;
			reg = <0x7e215000 0x08>;
			clocks = <&cprman 0x14>;
		};

		uart1: serial@7e215040 {
			compatible = "brcm,bcm2835-aux-uart";
			reg = <0x7e215040 0x40>;
			interrupts = <GIC_SPI 93 IRQ_TYPE_LEVEL_HIGH>;
			clocks = <&aux 0x00>;
			status = "okay";
			pinctrl-names = "default";
			pinctrl-0 = <&uart1_gpio14>;
			skip-init;
			bootph-all;
		};

        i2c0if: i2c@7e205000 {
			compatible = "brcm,bcm2711-i2c", "brcm,bcm2835-i2c";
			reg = <0x7e205000 0x200>;
			interrupts = <GIC_SPI 117 IRQ_TYPE_LEVEL_HIGH>;
			clocks = <&cprman 0x14>;
			#address-cells = <0x01>;
			#size-cells = <0x00>;
			status = "disabled";
			clock-frequency = <0x186a0>;
		};

        i2c0mux: i2c0mux {
            compatible = "i2c-mux-pinctrl";
            #address-cells = <0x01>;
            #size-cells = <0x00>;
            i2c-parent = <&i2c0if>;
            status = "disabled";
            pinctrl-names = "i2c0", "i2c_csi_dsi";
            pinctrl-0 = <&i2c0if_gpio0>;
            pinctrl-1 = <&i2c0if_gpio44>;

            i2c0: i2c@0 {
                reg = <0x00>;
                #address-cells = <0x01>;
                #size-cells = <0x00>;
            };

            i2c_csi_dsi: i2c@1 {
                reg = <0x01>;
                #address-cells = <0x01>;
                #size-cells = <0x00>;
            };
        };
		i2c1: i2c@7e804000 {
			compatible = "brcm,bcm2711-i2c", "brcm,bcm2835-i2c";
			reg = <0x7e804000 0x1000>;
			interrupts = <GIC_SPI 117 IRQ_TYPE_LEVEL_HIGH>;
			clocks = <&cprman 0x14>;
			#address-cells = <0x01>;
			#size-cells = <0x00>;
			status = "okay";
			pinctrl-names = "default";
			pinctrl-0 = <&i2c1_gpio>;
			clock-frequency = <0x186a0>;
		};
        // TODO: memory access crashes on qemu (not implemented?)
		i2c3: i2c@7e205600 {
			compatible = "brcm,bcm2711-i2c", "brcm,bcm2835-i2c";
			reg = <0x7e205600 0x200>;
			interrupts = <GIC_SPI 117 IRQ_TYPE_LEVEL_HIGH>;
			clocks = <&cprman 0x14>;
			#address-cells = <0x01>;
			#size-cells = <0x00>;
			status = "disabled";
			pinctrl-0 = <&i2c3_gpio>;
			pinctrl-names = "default";
		};
        // TODO: memory access crashes on qemu (not implemented?)
		i2c4: i2c@7e205800 {
			compatible = "brcm,bcm2711-i2c", "brcm,bcm2835-i2c";
			reg = <0x7e205800 0x200>;
			interrupts = <GIC_SPI 117 IRQ_TYPE_LEVEL_HIGH>;
			clocks = <&cprman 0x14>;
			#address-cells = <0x01>;
			#size-cells = <0x00>;
			status = "disabled";
			pinctrl-0 = <&i2c4_gpio>;
			pinctrl-names = "default";
		};
        // TODO: memory access crashes on qemu (not implemented?)
		i2c5: i2c@7e205a00 {
			compatible = "brcm,bcm2711-i2c", "brcm,bcm2835-i2c";
			reg = <0x7e205a00 0x200>;
			interrupts = <GIC_SPI 117 IRQ_TYPE_LEVEL_HIGH>;
			clocks = <&cprman 0x14>;
			#address-cells = <0x01>;
			#size-cells = <0x00>;
			status = "disabled";
			pinctrl-0 = <&i2c5_gpio>;
			pinctrl-names = "default";
		};
        // TODO: memory access crashes on qemu (not implemented?)
		i2c6: i2c@7e205c00 {
			compatible = "brcm,bcm2711-i2c", "brcm,bcm2835-i2c";
			reg = <0x7e205c00 0x200>;
			interrupts = <GIC_SPI 117 IRQ_TYPE_LEVEL_HIGH>;
			clocks = <&cprman 0x14>;
			#address-cells = <0x01>;
			#size-cells = <0x00>;
			status = "disabled";
			pinctrl-0 = <&i2c6_gpio>;
			pinctrl-names = "default";
		};

        spi0: spi@7e204000 {
			compatible = "brcm,bcm2835-spi";
			reg = <0x7e204000 0x200>;
			interrupts = <GIC_SPI 118 IRQ_TYPE_LEVEL_HIGH>;
			clocks = <&cprman 0x14>;
			#address-cells = <0x01>;
			#size-cells = <0x00>;
			status = "okay";
			dmas = <&dma 0x06>,
                   <&dma 0x07>;
			dma-names = "tx", "rx";
			pinctrl-names = "default";
			pinctrl-0 = <&spi0_gpio>, <&spi0_cs_gpio>;
			cs-gpios = <&gpio 8 1>, <&gpio 7 1>;

			spi0_0: spidev@0 {
				compatible = "spidev";
				reg = <0x00>;
				#address-cells = <0x01>;
				#size-cells = <0x00>;
				spi-max-frequency = <125000000>;
			};

			spi0_1: spidev@1 {
				compatible = "spidev";
				reg = <0x01>;
				#address-cells = <0x01>;
				#size-cells = <0x00>;
				spi-max-frequency = <125000000>;
			};
		};

		l1_intc: local_intc@40000000 {
			compatible = "brcm,bcm2836-l1-intc";
			reg = <0x40000000 0x100>;
		};

		gicv2: interrupt-controller@40041000 {
			interrupt-controller;
			#interrupt-cells = <0x03>;
			compatible = "arm,gic-400";
			reg = <0x40041000 0x1000>,
                  <0x40042000 0x2000>,
                  <0x40044000 0x2000>,
                  <0x40046000 0x2000>;
			interrupts = <GIC_PPI 9 (IRQ_TYPE_LEVEL_HIGH | GIC_CPU_MASK_SIMPLE(4))>;
		};

		avs_monitor: avs-monitor@7d5d2000 {
			compatible = "brcm,bcm2711-avs-monitor", "syscon", "simple-mfd";
			reg = <0x7d5d2000 0xf00>;
		};

		dma: dma@7e007000 {
			compatible = "brcm,bcm2835-dma";
			reg = <0x7e007000 0xb00>;
			interrupts = <GIC_SPI 80 IRQ_TYPE_LEVEL_HIGH>,
                         <GIC_SPI 81 IRQ_TYPE_LEVEL_HIGH>,
                         <GIC_SPI 82 IRQ_TYPE_LEVEL_HIGH>,
                         <GIC_SPI 83 IRQ_TYPE_LEVEL_HIGH>,
                         <GIC_SPI 84 IRQ_TYPE_LEVEL_HIGH>,
                         <GIC_SPI 85 IRQ_TYPE_LEVEL_HIGH>,
                         <GIC_SPI 86 IRQ_TYPE_LEVEL_HIGH>,
                         <GIC_SPI 87 IRQ_TYPE_LEVEL_HIGH>,
                         <GIC_SPI 87 IRQ_TYPE_LEVEL_HIGH>,
                         <GIC_SPI 88 IRQ_TYPE_LEVEL_HIGH>,
                         <GIC_SPI 88 IRQ_TYPE_LEVEL_HIGH>;
			interrupt-names = "dma0",
                              "dma1",
                              "dma2",
                              "dma3",
                              "dma4",
                              "dma5",
                              "dma6",
                              "dma7",
                              "dma8",
                              "dma9",
                              "dma10";
			#dma-cells = <0x01>;
			brcm,dma-channel-mask = <0x7f5>;
		};

		pm_wdt: watchdog@7e100000 {
			compatible = "brcm,bcm2835-pm", "brcm,bcm2835-pm-wdt";
			#power-domain-cells = <0x01>;
			#reset-cells = <0x01>;
			reg = <0x7e100000 0x114>,
                  <0x7e00a000 0x24>,
                  <0x7ec11000 0x20>;
			clocks = <&cprman 0x15>,
                     <&cprman 0x1d>,
                     <&cprman 0x17>,
                     <&cprman 0x16>;
			clock-names = "v3d", "peri_image", "h264", "isp";
			system-power-controller;
		};

		uart2: serial@7e201400 {
			compatible = "arm,pl011", "arm,primecell";
			reg = <0x7e201400 0x200>;
			interrupts = <GIC_SPI 121 IRQ_TYPE_LEVEL_HIGH>;
			clocks = <&cprman 0x13>,
                     <&cprman 0x14>;
			clock-names = "uartclk",
                          "apb_pclk";
			arm,primecell-periphid = <0x241011>;
			pinctrl-0 = <&uart2_gpio>;
			pinctrl-names = "default";
			status = "disabled";
		};

		uart3: serial@7e201600 {
			compatible = "arm,pl011", "arm,primecell";
			reg = <0x7e201600 0x200>;
			interrupts = <GIC_SPI 121 IRQ_TYPE_LEVEL_HIGH>;
			clocks = <&cprman 0x13>,
                     <&cprman 0x14>;
			clock-names = "uartclk", "apb_pclk";
			arm,primecell-periphid = <0x241011>;
			status = "disabled";
		};

		uart4: serial@7e201800 {
			compatible = "arm,pl011", "arm,primecell";
			reg = <0x7e201800 0x200>;
			interrupts = <GIC_SPI 121 IRQ_TYPE_LEVEL_HIGH>;
			clocks = <&cprman 0x13>,
                     <&cprman 0x14>;
			clock-names = "uartclk", "apb_pclk";
			arm,primecell-periphid = <0x241011>;
			status = "disabled";
		};

		uart5: serial@7e201a00 {
			compatible = "arm,pl011", "arm,primecell";
			reg = <0x7e201a00 0x200>;
			interrupts = <GIC_SPI 121 IRQ_TYPE_LEVEL_HIGH>;
			clocks = <&cprman 0x13>,
                     <&cprman 0x14>;
			clock-names = "uartclk", "apb_pclk";
			arm,primecell-periphid = <0x241011>;
			status = "disabled";
		};

		clk_dvp: clock@7ef00000 {
			compatible = "brcm,brcm2711-dvp";
			reg = <0x7ef00000 0x10>;
			clocks = <&clk_108m>;
			#clock-cells = <0x01>;
			#reset-cells = <0x01>;
		};

		l2_intc: interrupt-controller@7ef00100 {
			compatible = "brcm,bcm2711-l2-intc", "brcm,l2-intc";
			reg = <0x7ef00100 0x30>;
			interrupts = <GIC_SPI 96 IRQ_TYPE_LEVEL_HIGH>;
			interrupt-controller;
			#interrupt-cells = <0x01>;
		};

		firmware: firmware {
			compatible = "raspberrypi,bcm2835-firmware", "simple-mfd";
			#address-cells = <0x01>;
			#size-cells = <0x01>;
			mboxes = <&mbox>;
			dma-ranges;

			clk_firmware: clocks {
				compatible = "raspberrypi,firmware-clocks";
				#clock-cells = <0x01>;
			};

			gpio_firmware: gpio {
				compatible = "raspberrypi,firmware-gpio";
				gpio-controller;
				#gpio-cells = <0x02>;
				status = "okay";
				gpio-line-names = "BT_ON", "WL_ON", "PWR_LED_OFF", "GLOBAL_RESET", "VDD_SD_IO_SEL", "CAM_GPIO", "SD_PWR_ON", "";
			};

			firmware_reset: reset {
				compatible = "raspberrypi,firmware-reset";
				#reset-cells = <0x01>;
			};
		};

		power: power {
			compatible = "raspberrypi,bcm2835-power";
			firmware = <&firmware>;
			#power-domain-cells = <0x01>;
		};

		vchiq: mailbox@7e00b840 {
			compatible = "brcm,bcm2835-vchiq";
			reg = <0x7e00b840 0x3c>;
			interrupts = <GIC_SPI 34 IRQ_TYPE_LEVEL_HIGH>;
		};
	};

	clocks {
		clk_osc: clk-osc {
			compatible = "fixed-clock";
			#clock-cells = <0x00>;
			clock-output-names = "osc";
			clock-frequency = <54000000>;
		};

		clk_usb: clk-usb {
			compatible = "fixed-clock";
			#clock-cells = <0x00>;
			clock-output-names = "otg";
			clock-frequency = <480000000>;
		};
	};

	clk_27m: clk-27M {
		#clock-cells = <0x00>;
		compatible = "fixed-clock";
		clock-frequency = <27000000>;
		clock-output-names = "27MHz-clock";
	};

	clk_108m: clk-108M {
		#clock-cells = <0x00>;
		compatible = "fixed-clock";
		clock-frequency = <108000000>;
		clock-output-names = "108MHz-clock";
	};

	pmu: arm-pmu {
		compatible = "arm,cortex-a72-pmu", "arm,armv8-pmuv3";
		interrupts = <GIC_SPI 16 IRQ_TYPE_LEVEL_HIGH>,
                     <GIC_SPI 17 IRQ_TYPE_LEVEL_HIGH>,
                     <GIC_SPI 18 IRQ_TYPE_LEVEL_HIGH>,
                     <GIC_SPI 19 IRQ_TYPE_LEVEL_HIGH>;
		interrupt-affinity = <0x21>,
                             <0x22>,
                             <0x23>,
                             <0x24>;
	};

	arm_timer: timer {
		compatible = "arm,armv8-timer";
		interrupts = <GIC_PPI 13 (GIC_CPU_MASK_SIMPLE(4) | IRQ_TYPE_LEVEL_LOW)>,
                     <GIC_PPI 14 (GIC_CPU_MASK_SIMPLE(4) | IRQ_TYPE_LEVEL_LOW)>,
                     <GIC_PPI 15 (GIC_CPU_MASK_SIMPLE(4) | IRQ_TYPE_LEVEL_LOW)>,
                     <GIC_PPI 16 (GIC_CPU_MASK_SIMPLE(4) | IRQ_TYPE_LEVEL_LOW)>;
		arm,cpu-registers-not-fw-configured;
	};

	cpus {
		#address-cells = <0x01>;
		#size-cells = <0x00>;
		enable-method = "brcm,bcm2836-smp";

		cpu0: cpu@0 {
			device_type = "cpu";
			compatible = "arm,cortex-a72";
			reg = <0x00>;
			enable-method = "spin-table";
			cpu-release-addr = <0x00 0xd8>;
		};

		cpu1: cpu@1 {
			device_type = "cpu";
			compatible = "arm,cortex-a72";
			reg = <0x01>;
			enable-method = "spin-table";
			cpu-release-addr = <0x00 0xe0>;
		};

		cpu2: cpu@2 {
			device_type = "cpu";
			compatible = "arm,cortex-a72";
			reg = <0x02>;
			enable-method = "spin-table";
			cpu-release-addr = <0x00 0xe8>;
		};

		cpu3: cpu@3 {
			device_type = "cpu";
			compatible = "arm,cortex-a72";
			reg = <0x03>;
			enable-method = "spin-table";
			cpu-release-addr = <0x00 0xf0>;
		};
	};

	leds {
		compatible = "gpio-leds";

		led_act: led-act {
			label = "ACT";
			default-state = "keep";
			linux,default-trigger = "heartbeat";
			gpios = <&gpio 0x2a 0x00>;
		};

		led_pwr: led-pwr {
			label = "PWR";
			gpios = <&gpio_firmware 0x02 0x01>;
			default-state = "keep";
			linux,default-trigger = "default-on";
		};
	};

	memory@0 {
		device_type = "memory";
		reg = <0x00 0x00 0x00>;
	};

	sd_io_1v8_reg {
		compatible = "regulator-gpio";
		regulator-name = "vdd-sd-io";
		regulator-min-microvolt = <1800000>;
		regulator-max-microvolt = <3300000>;
		regulator-boot-on;
		regulator-always-on;
		regulator-settling-time-us = <0x1388>;
		gpios = <&gpio_firmware 0x04 0x00>;
		states = <3300000 0x01>,
                 <1800000 0x00>;
		status = "okay";
	};

	sd_vcc_reg {
		compatible = "regulator-fixed";
		regulator-name = "vcc-sd";
		regulator-min-microvolt = <3300000>;
		regulator-max-microvolt = <3300000>;
		regulator-boot-on;
		enable-active-high;
		gpio = <&gpio_firmware 0x06 0x00>;
	};
};