From cecf51f245e3c17f269560826d713b7b37e8fc49 Mon Sep 17 00:00:00 2001 From: Hector Martin Date: Mon, 15 Mar 2021 02:26:31 +0900 Subject: [PATCH] dts: Update with current kernel devicetree, improve build Now uses the same devicetree source as the kernel, verbatim, with the required subset of kernel dt includes. Signed-off-by: Hector Martin --- Makefile | 11 +- dts/apple-j274.dts | 138 ------------------ .../interrupt-controller/apple-aic.h | 15 ++ dts/dt-bindings/interrupt-controller/irq.h | 20 +++ dts/t8103-j274.dts | 45 ++++++ dts/t8103.dtsi | 135 +++++++++++++++++ 6 files changed, 223 insertions(+), 141 deletions(-) delete mode 100644 dts/apple-j274.dts create mode 100644 dts/dt-bindings/interrupt-controller/apple-aic.h create mode 100644 dts/dt-bindings/interrupt-controller/irq.h create mode 100644 dts/t8103-j274.dts create mode 100644 dts/t8103.dtsi diff --git a/Makefile b/Makefile index 5c7a6fd9..c1f4edcd 100644 --- a/Makefile +++ b/Makefile @@ -40,7 +40,7 @@ OBJECTS := adt.o bootlogo_128.o bootlogo_256.o chickens.o exception.o exception_ string.o uart.o uartproxy.o utils.o utils_asm.o vsprintf.o wdt.o $(MINILZLIB_OBJECTS) \ $(TINF_OBJECTS) $(DLMALLOC_OBJECTS) $(LIBFDT_OBJECTS) -DTS := apple-j274.dts +DTS := t8103-j274.dts BUILD_OBJS := $(patsubst %,build/%,$(OBJECTS)) DTBS := $(patsubst %.dts,build/dtb/%.dtb,$(DTS)) @@ -57,10 +57,15 @@ clean: format: clang-format -i src/*.c src/*.h sysinc/*.h -build/dtb/%.dtb: dts/%.dts +build/dtb/%.dts: dts/%.dts + @echo " DTCPP $@" + @mkdir -p "$(dir $@)" + @$(CC) -E -nostdinc -I dts -x assembler-with-cpp -o $@ $< + +build/dtb/%.dtb: build/dtb/%.dts @echo " DTC $@" @mkdir -p "$(dir $@)" - @dtc -I dts $< >$@ + @dtc -I dts -i dts $< -o $@ build/%.o: src/%.S @echo " AS $@" diff --git a/dts/apple-j274.dts b/dts/apple-j274.dts deleted file mode 100644 index 6acc0d68..00000000 --- a/dts/apple-j274.dts +++ /dev/null @@ -1,138 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0+ - -/dts-v1/; - -/ { - model = "Apple Mac Mini M1 2020"; - compatible = "AAPL,j274", "AAPL,arm-platform"; - #address-cells = <2>; - #size-cells = <2>; - - chosen { - #address-cells = <2>; - #size-cells = <2>; - ranges; - - bootargs = "earlycon debug"; - stdout-path = "serial0:1500000"; - - framebuffer0: framebuffer@0 { - compatible = "simple-framebuffer"; - reg = <0 0 0 0>; // To be filled by loader - status = "disabled"; - }; - }; - - memory@800000000 { - device_type = "memory"; - reg = <0 0 0 0>; // To be filled by loader - }; - - aliases { - serial0 = &serial0; - }; - - cpus { - #address-cells = <2>; - #size-cells = <0>; - - cpu0: cpu@0 { - compatible = "AAPL,icestorm"; - device_type = "cpu"; - reg = <0x0 0x0>; - enable-method = "spin-table"; - cpu-release-addr = <0 0>; // To be filled by loader - }; - cpu1: cpu@1 { - compatible = "AAPL,icestorm"; - device_type = "cpu"; - reg = <0x0 0x1>; - enable-method = "spin-table"; - cpu-release-addr = <0 0>; // To be filled by loader - }; - cpu2: cpu@2 { - compatible = "AAPL,icestorm"; - device_type = "cpu"; - reg = <0x0 0x2>; - enable-method = "spin-table"; - cpu-release-addr = <0 0>; // To be filled by loader - }; - cpu3: cpu@3 { - compatible = "AAPL,icestorm"; - device_type = "cpu"; - reg = <0x0 0x3>; - enable-method = "spin-table"; - cpu-release-addr = <0 0>; // To be filled by loader - }; - cpu4: cpu@10100 { - compatible = "AAPL,firestorm"; - device_type = "cpu"; - reg = <0x0 0x10100>; - enable-method = "spin-table"; - cpu-release-addr = <0 0>; // To be filled by loader - }; - cpu5: cpu@10101 { - compatible = "AAPL,firestorm"; - device_type = "cpu"; - reg = <0x0 0x10101>; - enable-method = "spin-table"; - cpu-release-addr = <0 0>; // To be filled by loader - }; - cpu6: cpu@10102 { - compatible = "AAPL,firestorm"; - device_type = "cpu"; - reg = <0x0 0x10102>; - enable-method = "spin-table"; - cpu-release-addr = <0 0>; // To be filled by loader - }; - cpu7: cpu@10103 { - compatible = "AAPL,firestorm"; - device_type = "cpu"; - reg = <0x0 0x10103>; - enable-method = "spin-table"; - cpu-release-addr = <0 0>; // To be filled by loader - }; - }; - - timer { - compatible = "arm,armv8-timer"; - interrupt-parent = <&aic>; - interrupts = <1 0 4>, - <1 0 4>, - <1 1 4>, - <1 0 4>; - }; - - clk24: clk24 { - compatible = "fixed-clock"; - #clock-cells = <0>; - clock-frequency = <24000000>; - clock-output-names = "clk24"; - }; - - soc { - compatible = "simple-bus"; - #address-cells = <2>; - #size-cells = <2>; - ranges; - - aic: interrupt-controller@23b100000 { - compatible = "AAPL,m1-aic", "AAPL,aic"; - #interrupt-cells = <3>; - interrupt-controller; - reg = <0x2 0x3b100000 0x0 0x8000>; - }; - - serial0: serial@235200000 { - compatible = "AAPL,s5l-uart"; - reg = <0x2 0x35200000 0x0 0x1000>; - reg-shift = <2>; - reg-io-width = <4>; - interrupt-parent = <&aic>; - interrupts = <0 605 4>; - clocks = <&clk24>, <&clk24>; - clock-names = "uart", "clk_uart_baud0"; - }; - - }; -}; diff --git a/dts/dt-bindings/interrupt-controller/apple-aic.h b/dts/dt-bindings/interrupt-controller/apple-aic.h new file mode 100644 index 00000000..604f2bb3 --- /dev/null +++ b/dts/dt-bindings/interrupt-controller/apple-aic.h @@ -0,0 +1,15 @@ +/* SPDX-License-Identifier: GPL-2.0+ OR MIT */ +#ifndef _DT_BINDINGS_INTERRUPT_CONTROLLER_APPLE_AIC_H +#define _DT_BINDINGS_INTERRUPT_CONTROLLER_APPLE_AIC_H + +#include + +#define AIC_IRQ 0 +#define AIC_FIQ 1 + +#define AIC_TMR_HV_PHYS 0 +#define AIC_TMR_HV_VIRT 1 +#define AIC_TMR_GUEST_PHYS 2 +#define AIC_TMR_GUEST_VIRT 3 + +#endif diff --git a/dts/dt-bindings/interrupt-controller/irq.h b/dts/dt-bindings/interrupt-controller/irq.h new file mode 100644 index 00000000..9e3d183e --- /dev/null +++ b/dts/dt-bindings/interrupt-controller/irq.h @@ -0,0 +1,20 @@ +/* SPDX-License-Identifier: GPL-2.0 OR MIT */ +/* + * This header provides constants for most IRQ bindings. + * + * Most IRQ bindings include a flags cell as part of the IRQ specifier. + * In most cases, the format of the flags cell uses the standard values + * defined in this header. + */ + +#ifndef _DT_BINDINGS_INTERRUPT_CONTROLLER_IRQ_H +#define _DT_BINDINGS_INTERRUPT_CONTROLLER_IRQ_H + +#define IRQ_TYPE_NONE 0 +#define IRQ_TYPE_EDGE_RISING 1 +#define IRQ_TYPE_EDGE_FALLING 2 +#define IRQ_TYPE_EDGE_BOTH (IRQ_TYPE_EDGE_FALLING | IRQ_TYPE_EDGE_RISING) +#define IRQ_TYPE_LEVEL_HIGH 4 +#define IRQ_TYPE_LEVEL_LOW 8 + +#endif diff --git a/dts/t8103-j274.dts b/dts/t8103-j274.dts new file mode 100644 index 00000000..e0f6775b --- /dev/null +++ b/dts/t8103-j274.dts @@ -0,0 +1,45 @@ +// SPDX-License-Identifier: GPL-2.0+ OR MIT +/* + * Apple Mac mini (M1, 2020) + * + * target-type: J274 + * + * Copyright The Asahi Linux Contributors + */ + +/dts-v1/; + +#include "t8103.dtsi" + +/ { + compatible = "apple,j274", "apple,t8103", "apple,arm-platform"; + model = "Apple Mac mini (M1, 2020)"; + + aliases { + serial0 = &serial0; + }; + + chosen { + #address-cells = <2>; + #size-cells = <2>; + ranges; + + stdout-path = "serial0"; + + framebuffer0: framebuffer@0 { + compatible = "apple,simple-framebuffer", "simple-framebuffer"; + reg = <0 0 0 0>; /* To be filled by loader */ + /* Format properties will be added by loader */ + status = "disabled"; + }; + }; + + memory@800000000 { + device_type = "memory"; + reg = <0x8 0 0x2 0>; /* To be filled by loader */ + }; +}; + +&serial0 { + status = "okay"; +}; diff --git a/dts/t8103.dtsi b/dts/t8103.dtsi new file mode 100644 index 00000000..aac9e4e6 --- /dev/null +++ b/dts/t8103.dtsi @@ -0,0 +1,135 @@ +// SPDX-License-Identifier: GPL-2.0+ OR MIT +/* + * Apple T8103 "M1" SoC + * + * Other names: H13G, "Tonga" + * + * Copyright The Asahi Linux Contributors + */ + +#include +#include + +/ { + compatible = "apple,t8103", "apple,arm-platform"; + + #address-cells = <2>; + #size-cells = <2>; + + cpus { + #address-cells = <2>; + #size-cells = <0>; + + cpu0: cpu@0 { + compatible = "apple,icestorm"; + device_type = "cpu"; + reg = <0x0 0x0>; + enable-method = "spin-table"; + cpu-release-addr = <0 0>; /* To be filled by loader */ + }; + + cpu1: cpu@1 { + compatible = "apple,icestorm"; + device_type = "cpu"; + reg = <0x0 0x1>; + enable-method = "spin-table"; + cpu-release-addr = <0 0>; /* To be filled by loader */ + }; + + cpu2: cpu@2 { + compatible = "apple,icestorm"; + device_type = "cpu"; + reg = <0x0 0x2>; + enable-method = "spin-table"; + cpu-release-addr = <0 0>; /* To be filled by loader */ + }; + + cpu3: cpu@3 { + compatible = "apple,icestorm"; + device_type = "cpu"; + reg = <0x0 0x3>; + enable-method = "spin-table"; + cpu-release-addr = <0 0>; /* To be filled by loader */ + }; + + cpu4: cpu@10100 { + compatible = "apple,firestorm"; + device_type = "cpu"; + reg = <0x0 0x10100>; + enable-method = "spin-table"; + cpu-release-addr = <0 0>; /* To be filled by loader */ + }; + + cpu5: cpu@10101 { + compatible = "apple,firestorm"; + device_type = "cpu"; + reg = <0x0 0x10101>; + enable-method = "spin-table"; + cpu-release-addr = <0 0>; /* To be filled by loader */ + }; + + cpu6: cpu@10102 { + compatible = "apple,firestorm"; + device_type = "cpu"; + reg = <0x0 0x10102>; + enable-method = "spin-table"; + cpu-release-addr = <0 0>; /* To be filled by loader */ + }; + + cpu7: cpu@10103 { + compatible = "apple,firestorm"; + device_type = "cpu"; + reg = <0x0 0x10103>; + enable-method = "spin-table"; + cpu-release-addr = <0 0>; /* To be filled by loader */ + }; + }; + + timer { + compatible = "arm,armv8-timer"; + interrupt-parent = <&aic>; + interrupt-names = "hyp-phys", "hyp-virt", "phys", "virt"; + interrupts = , + , + , + ; + }; + + clk24: clock-24m { + compatible = "fixed-clock"; + #clock-cells = <0>; + clock-frequency = <24000000>; + clock-output-names = "clk24"; + }; + + soc { + compatible = "simple-bus"; + #address-cells = <2>; + #size-cells = <2>; + + ranges; + nonposted-mmio; + + aic: interrupt-controller@23b100000 { + compatible = "apple,t8103-aic", "apple,aic"; + #interrupt-cells = <3>; + interrupt-controller; + reg = <0x2 0x3b100000 0x0 0x8000>; + }; + + serial0: serial@235200000 { + compatible = "apple,s5l-uart"; + reg = <0x2 0x35200000 0x0 0x1000>; + reg-io-width = <4>; + interrupt-parent = <&aic>; + interrupts = ; + /* + * TODO: figure out the clocking properly, there may + * be a third selectable clock. + */ + clocks = <&clk24>, <&clk24>; + clock-names = "uart", "clk_uart_baud0"; + status = "disabled"; + }; + }; +};