1// SPDX-License-Identifier: GPL-2.0
2/dts-v1/;
3
4#include "jz4740.dtsi"
5
6#include <dt-bindings/gpio/gpio.h>
7#include <dt-bindings/iio/adc/ingenic,adc.h>
8#include <dt-bindings/clock/ingenic,tcu.h>
9#include <dt-bindings/input/input.h>
10
11#define KEY_QI_QI	KEY_F13
12#define KEY_QI_UPRED	KEY_RIGHTALT
13#define KEY_QI_VOLUP	KEY_VOLUMEUP
14#define KEY_QI_VOLDOWN	KEY_VOLUMEDOWN
15#define KEY_QI_FN	KEY_LEFTCTRL
16
17/ {
18	compatible = "qi,lb60", "ingenic,jz4740";
19	model = "Ben Nanonote";
20
21	memory {
22		device_type = "memory";
23		reg = <0x0 0x2000000>;
24	};
25
26	chosen {
27		stdout-path = &uart0;
28	};
29
30	vcc: regulator@0 {
31		compatible = "regulator-fixed";
32		regulator-name = "vcc";
33
34		regulator-min-microvolt = <3300000>;
35		regulator-max-microvolt = <3300000>;
36		regulator-always-on;
37	};
38
39	mmc_power: regulator@1 {
40		compatible = "regulator-fixed";
41		regulator-name = "mmc_vcc";
42		gpio = <&gpd 2 0>;
43
44		regulator-min-microvolt = <3300000>;
45		regulator-max-microvolt = <3300000>;
46	};
47
48	amp_supply: regulator@2 {
49		compatible = "regulator-fixed";
50		regulator-name = "amp_supply";
51		gpio = <&gpd 4 0>;
52		enable-active-high;
53
54		regulator-min-microvolt = <3300000>;
55		regulator-max-microvolt = <3300000>;
56	};
57
58	amp: analog-amplifier {
59		compatible = "simple-audio-amplifier";
60		enable-gpios = <&gpb 29 GPIO_ACTIVE_HIGH>;
61		VCC-supply = <&amp_supply>;
62	};
63
64	sound {
65		compatible = "simple-audio-card";
66
67		simple-audio-card,name = "QI LB60";
68		simple-audio-card,format = "i2s";
69
70		simple-audio-card,widgets =
71			"Speaker", "Speaker",
72			"Microphone", "Mic";
73		simple-audio-card,routing =
74			"MIC", "Mic",
75			"Speaker", "OUTL",
76			"Speaker", "OUTR",
77			"INL", "LOUT",
78			"INR", "ROUT";
79
80		simple-audio-card,aux-devs = <&amp>;
81
82		simple-audio-card,bitclock-master = <&dai_codec>;
83		simple-audio-card,frame-master = <&dai_codec>;
84
85		dai_cpu: simple-audio-card,cpu {
86			sound-dai = <&aic>;
87		};
88
89		dai_codec: simple-audio-card,codec {
90			sound-dai = <&codec>;
91		};
92	};
93
94	keys {
95		compatible = "gpio-keys";
96
97		key {
98			label = "Power";
99			wakeup-source;
100			linux,code = <KEY_POWER>;
101			gpios = <&gpd 29 GPIO_ACTIVE_LOW>;
102		};
103	};
104
105	keyboard {
106		compatible = "gpio-matrix-keypad";
107
108		col-scan-delay-us = <10>;
109		debounce-delay-ms = <10>;
110		wakeup-source;
111
112		row-gpios = <&gpd 18 0>, <&gpd 19 0>, <&gpd 20 0>, <&gpd 21 0>,
113			    <&gpd 22 0>, <&gpd 23 0>, <&gpd 24 0>, <&gpd 26 0>;
114		col-gpios = <&gpc 10 0>, <&gpc 11 0>, <&gpc 12 0>, <&gpc 13 0>,
115			    <&gpc 14 0>, <&gpc 15 0>, <&gpc 16 0>, <&gpc 17 0>;
116		gpio-activelow;
117
118		linux,keymap =
119			<MATRIX_KEY(0, 0, KEY_F1)>,	/* S2 */
120			<MATRIX_KEY(0, 1, KEY_F2)>,	/* S3 */
121			<MATRIX_KEY(0, 2, KEY_F3)>,	/* S4 */
122			<MATRIX_KEY(0, 3, KEY_F4)>,	/* S5 */
123			<MATRIX_KEY(0, 4, KEY_F5)>,	/* S6 */
124			<MATRIX_KEY(0, 5, KEY_F6)>,	/* S7 */
125			<MATRIX_KEY(0, 6, KEY_F7)>,	/* S8 */
126
127			<MATRIX_KEY(1, 0, KEY_Q)>,	/* S10 */
128			<MATRIX_KEY(1, 1, KEY_W)>,	/* S11 */
129			<MATRIX_KEY(1, 2, KEY_E)>,	/* S12 */
130			<MATRIX_KEY(1, 3, KEY_R)>,	/* S13 */
131			<MATRIX_KEY(1, 4, KEY_T)>,	/* S14 */
132			<MATRIX_KEY(1, 5, KEY_Y)>,	/* S15 */
133			<MATRIX_KEY(1, 6, KEY_U)>,	/* S16 */
134			<MATRIX_KEY(1, 7, KEY_I)>,	/* S17 */
135			<MATRIX_KEY(2, 0, KEY_A)>,	/* S18 */
136			<MATRIX_KEY(2, 1, KEY_S)>,	/* S19 */
137			<MATRIX_KEY(2, 2, KEY_D)>,	/* S20 */
138			<MATRIX_KEY(2, 3, KEY_F)>,	/* S21 */
139			<MATRIX_KEY(2, 4, KEY_G)>,	/* S22 */
140			<MATRIX_KEY(2, 5, KEY_H)>,	/* S23 */
141			<MATRIX_KEY(2, 6, KEY_J)>,	/* S24 */
142			<MATRIX_KEY(2, 7, KEY_K)>,	/* S25 */
143			<MATRIX_KEY(3, 0, KEY_ESC)>,	/* S26 */
144			<MATRIX_KEY(3, 1, KEY_Z)>,	/* S27 */
145			<MATRIX_KEY(3, 2, KEY_X)>,	/* S28 */
146			<MATRIX_KEY(3, 3, KEY_C)>,	/* S29 */
147			<MATRIX_KEY(3, 4, KEY_V)>,	/* S30 */
148			<MATRIX_KEY(3, 5, KEY_B)>,	/* S31 */
149			<MATRIX_KEY(3, 6, KEY_N)>,	/* S32 */
150			<MATRIX_KEY(3, 7, KEY_M)>,	/* S33 */
151			<MATRIX_KEY(4, 0, KEY_TAB)>,	/* S34 */
152			<MATRIX_KEY(4, 1, KEY_CAPSLOCK)>,	/* S35 */
153			<MATRIX_KEY(4, 2, KEY_BACKSLASH)>,	/* S36 */
154			<MATRIX_KEY(4, 3, KEY_APOSTROPHE)>,	/* S37 */
155			<MATRIX_KEY(4, 4, KEY_COMMA)>,	/* S38 */
156			<MATRIX_KEY(4, 5, KEY_DOT)>,	/* S39 */
157			<MATRIX_KEY(4, 6, KEY_SLASH)>,	/* S40 */
158			<MATRIX_KEY(4, 7, KEY_UP)>,	/* S41 */
159			<MATRIX_KEY(5, 0, KEY_O)>,	/* S42 */
160			<MATRIX_KEY(5, 1, KEY_L)>,	/* S43 */
161			<MATRIX_KEY(5, 2, KEY_EQUAL)>,	/* S44 */
162			<MATRIX_KEY(5, 3, KEY_QI_UPRED)>,	/* S45 */
163			<MATRIX_KEY(5, 4, KEY_SPACE)>,	/* S46 */
164			<MATRIX_KEY(5, 5, KEY_QI_QI)>,	/* S47 */
165			<MATRIX_KEY(5, 6, KEY_RIGHTCTRL)>,	/* S48 */
166			<MATRIX_KEY(5, 7, KEY_LEFT)>,	/* S49 */
167			<MATRIX_KEY(6, 0, KEY_F8)>,	/* S50 */
168			<MATRIX_KEY(6, 1, KEY_P)>,	/* S51 */
169			<MATRIX_KEY(6, 2, KEY_BACKSPACE)>,/* S52 */
170			<MATRIX_KEY(6, 3, KEY_ENTER)>,	/* S53 */
171			<MATRIX_KEY(6, 4, KEY_QI_VOLUP)>,	/* S54 */
172			<MATRIX_KEY(6, 5, KEY_QI_VOLDOWN)>,	/* S55 */
173			<MATRIX_KEY(6, 6, KEY_DOWN)>,	/* S56 */
174			<MATRIX_KEY(6, 7, KEY_RIGHT)>,	/* S57 */
175
176			<MATRIX_KEY(7, 0, KEY_LEFTSHIFT)>,	/* S58 */
177			<MATRIX_KEY(7, 1, KEY_LEFTALT)>, /* S59 */
178			<MATRIX_KEY(7, 2, KEY_QI_FN)>;	/* S60 */
179	};
180
181	spi {
182		compatible = "spi-gpio";
183		#address-cells = <1>;
184		#size-cells = <0>;
185
186		sck-gpios = <&gpc 23 GPIO_ACTIVE_HIGH>;
187		mosi-gpios = <&gpc 22 GPIO_ACTIVE_HIGH>;
188		cs-gpios = <&gpc 21 GPIO_ACTIVE_LOW>;
189		num-chipselects = <1>;
190	};
191
192	usb_charger: charger {
193		compatible = "gpio-charger";
194		charger-type = "usb-sdp";
195		gpios = <&gpd 28 GPIO_ACTIVE_LOW>;
196		status-gpios = <&gpc 27 GPIO_ACTIVE_LOW>;
197	};
198
199	simple_battery: battery {
200		compatible = "simple-battery";
201		voltage-min-design-microvolt = <3600000>;
202		voltage-max-design-microvolt = <4200000>;
203	};
204
205	pmu {
206		compatible = "ingenic,jz4740-battery";
207		io-channels = <&adc INGENIC_ADC_BATTERY>;
208		io-channel-names = "battery";
209		power-supplies = <&usb_charger>;
210		monitored-battery = <&simple_battery>;
211	};
212
213	hwmon {
214		compatible = "iio-hwmon";
215		io-channels = <&adc INGENIC_ADC_AUX>;
216	};
217
218	panel: panel {
219		compatible = "giantplus,gpm940b0";
220
221		power-supply = <&vcc>;
222
223		port {
224			panel_input: endpoint {
225				remote-endpoint = <&panel_output>;
226			};
227		};
228	};
229
230	usb_phy: usb-phy {
231		compatible = "usb-nop-xceiv";
232		#phy-cells = <0>;
233
234		vcc-supply = <&vcc>;
235	};
236};
237
238&ext {
239	clock-frequency = <12000000>;
240};
241
242&rtc_dev {
243	system-power-controller;
244};
245
246&uart0 {
247	pinctrl-names = "default";
248	pinctrl-0 = <&pins_uart0>;
249};
250
251&uart1 {
252	status = "disabled";
253};
254
255&nemc {
256	nandc: nand-controller@1 {
257		compatible = "ingenic,jz4740-nand";
258		reg = <1 0 0x4000000>;
259
260		#address-cells = <1>;
261		#size-cells = <0>;
262
263		ecc-engine = <&ecc>;
264
265		pinctrl-names = "default";
266		pinctrl-0 = <&pins_nemc>;
267
268		rb-gpios = <&gpc 30 GPIO_ACTIVE_HIGH>;
269
270		nand@1 {
271			reg = <1>;
272
273			nand-ecc-step-size = <512>;
274			nand-ecc-strength = <4>;
275			nand-ecc-mode = "hw";
276			nand-is-boot-medium;
277			nand-on-flash-bbt;
278
279			partitions {
280				compatible = "fixed-partitions";
281				#address-cells = <1>;
282				#size-cells = <1>;
283
284				partition@0 {
285					label = "boot";
286					reg = <0x0 0x400000>;
287				};
288
289				partition@400000 {
290					label = "kernel";
291					reg = <0x400000 0x400000>;
292				};
293
294				partition@800000 {
295					label = "rootfs";
296					reg = <0x800000 0x0>;
297				};
298			};
299		};
300	};
301};
302
303&lcd {
304	pinctrl-names = "default";
305	pinctrl-0 = <&pins_lcd>;
306
307	port {
308		panel_output: endpoint {
309			remote-endpoint = <&panel_input>;
310		};
311	};
312};
313
314&udc {
315	phys = <&usb_phy>;
316};
317
318&pinctrl {
319	pins_lcd: lcd {
320		function = "lcd";
321		groups = "lcd-8bit";
322	};
323
324	pins_nemc: nemc {
325		function = "nand";
326		groups = "nand-fre-fwe", "nand-cs1";
327	};
328
329	pins_uart0: uart0 {
330		function = "uart0";
331		groups = "uart0-data";
332		bias-disable;
333	};
334
335	pins_mmc: mmc {
336		mmc {
337			function = "mmc";
338			groups = "mmc-1bit", "mmc-4bit";
339			bias-disable;
340		};
341
342		mmc-gpios {
343			pins = "PD0", "PD2";
344			bias-disable;
345		};
346	};
347};
348
349&mmc {
350	bus-width = <4>;
351	max-frequency = <24000000>;
352	cd-gpios = <&gpd 0 GPIO_ACTIVE_HIGH>;
353	vmmc-supply = <&mmc_power>;
354
355	pinctrl-names = "default";
356	pinctrl-0 = <&pins_mmc>;
357};
358
359&tcu {
360	/* 750 kHz for the system timer and clocksource */
361	assigned-clocks = <&tcu TCU_CLK_TIMER0>, <&tcu TCU_CLK_TIMER1>;
362	assigned-clock-rates = <750000>, <750000>;
363};
364