1// SPDX-License-Identifier: (GPL-2.0+ OR MIT)
2/*
3 * Copyright (C) 2025 Lukas Schmid <lukas.schmid@netcube.li>
4 */
5
6/dts-v1/;
7#include "sun8i-v3s.dtsi"
8
9#include <dt-bindings/input/input.h>
10#include <dt-bindings/leds/common.h>
11#include <dt-bindings/gpio/gpio.h>
12
13/{
14	model = "NetCube Systems Kumquat";
15	compatible = "netcube,kumquat", "allwinner,sun8i-v3s";
16
17	aliases {
18		serial0 = &uart0;
19		ethernet0 = &emac;
20		rtc0 = &ds3232;
21		rtc1 = &rtc; /* not battery backed */
22	};
23
24	chosen {
25		stdout-path = "serial0:115200n8";
26	};
27
28	/* 40 MHz Crystal Oscillator on PCB */
29	clk_can0: clock-can0 {
30		compatible = "fixed-clock";
31		#clock-cells = <0>;
32		clock-frequency  = <40000000>;
33	};
34
35	gpio-keys {
36		compatible = "gpio-keys";
37		autorepeat;
38
39		key-user {
40			label = "GPIO Key User";
41			linux,code = <KEY_PROG1>;
42			gpios = <&pio 1 2 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)>; /* PB2 */
43		};
44	};
45
46	leds {
47		compatible = "gpio-leds";
48
49		led-heartbeat {
50			gpios = <&pio 4 4 GPIO_ACTIVE_HIGH>; /* PE4 */
51			linux,default-trigger = "heartbeat";
52			color = <LED_COLOR_ID_GREEN>;
53			function = LED_FUNCTION_HEARTBEAT;
54		};
55
56		led-mmc0-act {
57			gpios = <&pio 5 6 GPIO_ACTIVE_HIGH>; /* PF6 */
58			linux,default-trigger = "mmc0";
59			color = <LED_COLOR_ID_GREEN>;
60			function = LED_FUNCTION_DISK;
61		};
62	};
63
64	/* EA3036C Switching 3 Channel Regulator - Channel 2 */
65	reg_vcc3v3: regulator-3v3 {
66		compatible = "regulator-fixed";
67		regulator-name = "vcc3v3";
68		regulator-min-microvolt = <3300000>;
69		regulator-max-microvolt = <3300000>;
70		vin-supply = <&reg_vcc5v0>;
71	};
72
73	/* K7805-1000R3 Switching Regulator supplied from main 12/24V terminal block */
74	reg_vcc5v0: regulator-5v0 {
75		compatible = "regulator-fixed";
76		regulator-name = "vcc5v0";
77		regulator-min-microvolt = <5000000>;
78		regulator-max-microvolt = <5000000>;
79	};
80};
81
82&codec {
83	allwinner,audio-routing =
84		"Headphone", "HP",
85		"Headphone", "HPCOM",
86		"MIC1", "Mic",
87		"Mic", "HBIAS";
88	status = "okay";
89};
90
91&ehci {
92	status = "okay";
93};
94
95&emac {
96	allwinner,leds-active-low;
97	nvmem-cells = <&eth0_macaddress>;
98	nvmem-cell-names = "mac-address";
99	status = "okay";
100};
101
102&i2c0 {
103	status = "okay";
104
105	eeprom0: eeprom@50 {
106		compatible = "atmel,24c02";		/* actually it's a 24AA02E48 */
107		reg = <0x50>;
108		pagesize = <16>;
109		read-only;
110		vcc-supply = <&reg_vcc3v3>;
111
112		#address-cells = <1>;
113		#size-cells = <1>;
114
115		eth0_macaddress: macaddress@fa {
116			reg = <0xfa 0x06>;
117		};
118	};
119
120	tusb320: typec@60 {
121		compatible = "ti,tusb320";
122		reg = <0x60>;
123		interrupts-extended = <&pio 1 5 IRQ_TYPE_LEVEL_LOW>;  /* PB5 */
124	};
125
126	ds3232: rtc@68 {
127		compatible = "dallas,ds3232";
128		reg = <0x68>;
129	};
130};
131
132/* Exposed as the Flash/SD Header on the board */
133&mmc0 {
134	vmmc-supply = <&reg_vcc3v3>;
135	bus-width = <4>;
136	broken-cd;
137	status = "okay";
138};
139
140/* Connected to the on-board ESP32 */
141&mmc1 {
142	vmmc-supply = <&reg_vcc3v3>;
143	bus-width = <4>;
144	broken-cd;
145	status = "okay";
146};
147
148&ohci {
149	status = "okay";
150};
151
152/* Disable external 32k osc as it is broken on current revision */
153&osc32k {
154	status = "disabled";
155};
156
157&pio {
158	vcc-pb-supply = <&reg_vcc3v3>;
159	vcc-pc-supply = <&reg_vcc3v3>;
160	vcc-pe-supply = <&reg_vcc3v3>;
161	vcc-pf-supply = <&reg_vcc3v3>;
162	vcc-pg-supply = <&reg_vcc3v3>;
163
164	gpio-line-names = "", "", "", "", // PA
165			  "", "", "", "",
166			  "", "", "", "",
167			  "", "", "", "",
168			  "", "", "", "",
169			  "", "", "", "",
170			  "", "", "", "",
171			  "", "", "", "",
172			  "CAN_nCS", "CAN_nINT", "USER_SW", "PB3", // PB
173			  "USB_ID", "USBC_nINT", "I2C0_SCL", "I2C0_SDA",
174			  "UART0_TX", "UART0_RX", "", "",
175			  "", "", "", "",
176			  "", "", "", "",
177			  "", "", "", "",
178			  "", "", "", "",
179			  "", "", "", "",
180			  "SPI_MISO", "SPI_SCK", "FLASH_nCS", "SPI_MOSI", // PC
181			  "", "", "", "",
182			  "", "", "", "",
183			  "", "", "", "",
184			  "", "", "", "",
185			  "", "", "", "",
186			  "", "", "", "",
187			  "", "", "", "",
188			  "", "", "", "", // PD
189			  "", "", "", "",
190			  "", "", "", "",
191			  "", "", "", "",
192			  "", "", "", "",
193			  "", "", "", "",
194			  "", "", "", "",
195			  "", "", "", "",
196			  "Q12", "Q11", "Q10", "Q9", // PE
197			  "LED_SYS0", "I1", "Q1", "Q2",
198			  "I2", "I3", "Q3", "Q4",
199			  "I4", "I5", "Q5", "Q6",
200			  "I6", "I7", "Q7", "Q8",
201			  "I8", "UART1_TXD", "UART1_RXD", "ESP_nRST",
202			  "ESP_nBOOT", "", "", "",
203			  "", "", "", "",
204			  "SD_D1", "SD_D0", "SD_CLK", "SD_CMD", // PF
205			  "SD_D3", "SD_D2", "LED_SYS1", "",
206			  "", "", "", "",
207			  "", "", "", "",
208			  "", "", "", "",
209			  "", "", "", "",
210			  "", "", "", "",
211			  "", "", "", "",
212			  "ESP_CLK", "ESP_CMD", "ESP_D0", "ESP_D1", // PG
213			  "ESP_D2", "ESP_D3", "", "",
214			  "", "", "", "",
215			  "", "", "", "",
216			  "", "", "", "",
217			  "", "", "", "",
218			  "", "", "", "",
219			  "", "", "", "";
220};
221
222/* Disable external 32k osc as it is broken on current revision */
223&rtc {
224	/delete-property/ clocks;
225};
226
227/* Exposed as a USB-C connector with USB-Serial converter */
228&uart0 {
229	pinctrl-0 = <&uart0_pb_pins>;
230	pinctrl-names = "default";
231	status = "okay";
232};
233
234/* Connected to the Bootloader/Console of the ESP32 */
235&uart1 {
236	pinctrl-0 = <&uart1_pe_pins>;
237	pinctrl-names = "default";
238	status = "okay";
239};
240
241&usb_otg {
242	extcon = <&tusb320 0>;
243	dr_mode = "otg";
244	status = "okay";
245};
246
247&usbphy {
248	usb0_id_det-gpios = <&pio 1 4 GPIO_ACTIVE_HIGH>; /* PB4 */
249	status = "okay";
250};
251
252&spi0 {
253	#address-cells = <1>;
254	#size-cells = <0>;
255	cs-gpios = <0>, <&pio 1 0 GPIO_ACTIVE_LOW>; /* PB0 */
256	status = "okay";
257
258	flash@0 {
259		compatible = "jedec,spi-nor";
260		reg = <0>;
261		#address-cells = <1>;
262		#size-cells = <1>;
263		label = "firmware";
264		spi-max-frequency = <40000000>;
265	};
266
267	can@1 {
268		compatible = "microchip,mcp2518fd";
269		reg = <1>;
270		clocks = <&clk_can0>;
271		interrupts-extended = <&pio 1 1 IRQ_TYPE_LEVEL_LOW>;  /* PB1 */
272		spi-max-frequency = <20000000>;
273		vdd-supply = <&reg_vcc3v3>;
274		xceiver-supply = <&reg_vcc3v3>;
275	};
276};
277