1/*
2 * Copyright (c) 2021 Tokita, Hiroshi <tokita.hiroshi@gmail.com>
3 *
4 * SPDX-License-Identifier: Apache-2.0
5 */
6
7#include <zephyr/dt-bindings/input/input-event-codes.h>
8#include <zephyr/dt-bindings/mipi_dbi/mipi_dbi.h>
9
10/ {
11	chosen {
12		zephyr,console = &usart0;
13		zephyr,shell-uart = &usart0;
14		zephyr,sram = &sram0;
15		zephyr,flash = &flash0;
16		zephyr,display = &lcd0;
17		sdhc0 = &sdhc0;
18	};
19
20	leds {
21		compatible = "gpio-leds";
22		led_red: led_red {
23			gpios = <&gpioc 13 GPIO_ACTIVE_LOW>;
24			label = "LED_R";
25		};
26		led_green: led_green {
27			gpios = <&gpioa 1 GPIO_ACTIVE_LOW>;
28			label = "LED_G";
29		};
30		led_blue: led_blue {
31			gpios = <&gpioa 2 GPIO_ACTIVE_LOW>;
32			label = "LED_B";
33		};
34	};
35
36	gpio_keys {
37		compatible = "gpio-keys";
38		button_boot0: button_boot0 {
39			label = "BUTTON_BOOT0";
40			gpios = <&gpioa 8 GPIO_ACTIVE_HIGH>;
41			zephyr,code = <INPUT_KEY_0>;
42		};
43	};
44
45	pwmleds {
46		compatible = "pwm-leds";
47
48		/* NOTE: bridge TIMER1_CH1 and LED_GREEN (PA1) */
49		pwm_led_green: pwm_led_green {
50			pwms = <&pwm1 1 PWM_MSEC(20) PWM_POLARITY_NORMAL>;
51			label = "PWM_LED_G";
52		};
53		/* NOTE: bridge TIMER1_CH2 and LED_BLUE (PA2) */
54		pwm_led_blue: pwm_led_blue {
55			pwms = <&pwm1 2 PWM_MSEC(20) PWM_POLARITY_NORMAL>;
56			label = "PWM_LED_B";
57		};
58	};
59
60	aliases {
61		led0 = &led_red;
62		led1 = &led_green;
63		led2 = &led_blue;
64		pwm-led0 = &pwm_led_green;
65		pwm-led1 = &pwm_led_blue;
66		sw0 = &button_boot0;
67		watchdog0 = &fwdgt;
68	};
69
70	mipi_dbi {
71		compatible = "zephyr,mipi-dbi-spi";
72		reset-gpios = <&gpiob 1 GPIO_ACTIVE_LOW>;
73		dc-gpios = <&gpiob 0 GPIO_ACTIVE_HIGH>;
74		spi-dev = <&spi0>;
75		write-only;
76		#address-cells = <1>;
77		#size-cells = <0>;
78
79		/* longan nano has LCD with st7735s controller.
80		 * It can use with st7735r driver.
81		 */
82		lcd0: lcd@0 {
83			compatible = "sitronix,st7735r";
84			reg = <0>;
85			status = "okay";
86			width = <160>;
87			height = <80>;
88			inversion-on;
89			rgb-is-inverted;
90			x-offset = <1>;
91			y-offset = <26>;
92			pwctr1 = [62 02 04];
93			pwctr2 = [C0];
94			pwctr3 = [0D 00];
95			pwctr4 = [8D 6A];
96			pwctr5 = [8D EE];
97			invctr = <3>;
98			frmctr1 = [05 3A 3A];
99			frmctr2 = [05 3A 3A];
100			frmctr3 = [05 3A 3A 05 3A 3A];
101			vmctr1 = <14>;
102			gamctrp1 = [10 0E 02 03 0E 07 02 07 0A 12 27 37 00 0D 0E 10];
103			gamctrn1 = [10 0E 03 03 0F 06 02 08 0A 13 26 36 00 0D 0E 10];
104			colmod = <5>;
105			madctl = <120>;
106			caset = [00 01 00 a0];
107			raset = [00 1a 00 69];
108
109			mipi-mode = "MIPI_DBI_MODE_SPI_4WIRE";
110			mipi-max-frequency = <4000000>;
111		};
112	};
113};
114
115&gpioa {
116	status = "okay";
117};
118
119&gpiob {
120	status = "okay";
121};
122
123&gpioc {
124	status = "okay";
125};
126
127&usart0 {
128	status = "okay";
129	current-speed = <115200>;
130	pinctrl-0 = <&usart0_default>;
131	pinctrl-names = "default";
132};
133
134&timer1 {
135	status = "okay";
136	prescaler = <4096>;
137
138	pwm1: pwm {
139		status = "okay";
140		pinctrl-0 = <&pwm1_default>;
141		pinctrl-names = "default";
142	};
143};
144
145&dac {
146	status = "okay";
147	pinctrl-0 = <&dac_default>;
148	pinctrl-names = "default";
149};
150
151&spi0 {
152	status = "okay";
153	pinctrl-0 = <&spi0_default>;
154	pinctrl-names = "default";
155
156	cs-gpios = <&gpiob 2 GPIO_ACTIVE_LOW>;
157};
158
159&spi1 {
160	status = "okay";
161	pinctrl-0 = <&spi1_default>;
162	pinctrl-names = "default";
163
164	cs-gpios = <&gpiob 12 GPIO_ACTIVE_LOW>;
165
166	sdhc0: sdhc@0 {
167		compatible = "zephyr,sdhc-spi-slot";
168		reg = <0>;
169		status = "okay";
170		spi-max-frequency = <24000000>;
171		mmc {
172			compatible = "zephyr,sdmmc-disk";
173			disk-name = "SD";
174			status = "okay";
175		};
176	};
177};
178
179&adc0 {
180	status = "okay";
181	pinctrl-0 = <&adc0_default>;
182	pinctrl-names = "default";
183};
184
185&fwdgt {
186	status = "okay";
187};
188