ath79: add support for Teltonika RUT955
[oweals/openwrt.git] / target / linux / ath79 / dts / ar9344_teltonika_rut955.dts
1 // SPDX-License-Identifier: GPL-2.0-or-later OR MIT
2 /dts-v1/;
3
4 #include <dt-bindings/gpio/gpio.h>
5 #include <dt-bindings/input/input.h>
6
7 #include "ar9344.dtsi"
8
9 / {
10         model = "Teltonika RUT955";
11         compatible = "teltonika,rut955", "qca,ar9344";
12
13         aliases {
14                 serial0 = &uart;
15                 serial1 = &hs_uart;
16                 led-boot = &led_system_green;
17                 led-failsafe = &led_system_red;
18                 led-running = &led_system_green;
19                 led-upgrade = &led_system_red;
20                 label-mac-device = &eth1;
21         };
22
23         i2c {
24                 compatible = "i2c-gpio";
25                 scl-gpios = <&gpio 16 (GPIO_ACTIVE_HIGH|GPIO_OPEN_DRAIN)>;
26                 sda-gpios = <&gpio 17 (GPIO_ACTIVE_HIGH|GPIO_OPEN_DRAIN)>;
27                 #address-cells = <1>;
28                 #size-cells = <0>;
29
30                 hwmon@4d {
31                         compatible = "microchip,mcp3221";
32                         reg = <0x4d>;
33                 };
34         };
35
36         leds {
37                 compatible = "gpio-leds";
38
39                 signal1 {
40                         label = "rut955:green:signal1";
41                         gpios = <&gpio_ext 0 GPIO_ACTIVE_HIGH>;
42                 };
43
44                 signal2 {
45                         label = "rut955:green:signal2";
46                         gpios = <&gpio_ext 1 GPIO_ACTIVE_HIGH>;
47                 };
48
49                 signal3 {
50                         label = "rut955:green:signal3";
51                         gpios = <&gpio_ext 2 GPIO_ACTIVE_HIGH>;
52                 };
53
54                 signal4 {
55                         label = "rut955:green:signal4";
56                         gpios = <&gpio_ext 3 GPIO_ACTIVE_HIGH>;
57                 };
58
59                 signal5 {
60                         label = "rut955:green:signal5";
61                         gpios = <&gpio_ext 4 GPIO_ACTIVE_HIGH>;
62                 };
63
64                 led_system_red: system_red {
65                         label = "rut955:red:system";
66                         gpios = <&gpio_ext 5 GPIO_ACTIVE_HIGH>;
67                 };
68
69                 led_system_green: system_green {
70                         label = "rut955:green:system";
71                         gpios = <&gpio_ext 6 GPIO_ACTIVE_HIGH>;
72                         default-state = "on";
73                 };
74         };
75
76         keys {
77                 compatible = "gpio-keys";
78
79                 reset {
80                         label = "reset";
81                         linux,code = <KEY_RESTART>;
82                         gpios = <&gpio 15 GPIO_ACTIVE_LOW>;
83                         debounce-interval = <60>;
84                 };
85         };
86 };
87
88 &gpio {
89         pinctrl-names = "default";
90         pinctrl-0 = <&jtag_disable_pins>;
91
92         gpio-line-names = "RS485_D", "led_wan", "DIN3", "mmc_cs",
93                 "ext_sck", "", "", "",
94                 "", "", "", "",
95                 "ext_mosi", "led_lan2", "led_lan1", "",
96                 "i2c_scl", "i2c_sda", "", "DIN2",
97                 "ext_cs", "DIN1", "led_lan3", "",
98                 "", "", "", "",
99                 "", "", "", "";
100
101         ext_sck {
102                 gpio-hog;
103                 gpios = <4 GPIO_ACTIVE_HIGH>;
104                 output-high;
105                 line-name = "rut955:ext:sck";
106         };
107
108         ext_mosi {
109                 gpio-hog;
110                 gpios = <12 GPIO_ACTIVE_HIGH>;
111                 output-high;
112                 line-name = "rut955:ext:mosi";
113         };
114
115         ext_cs {
116                 gpio-hog;
117                 gpios = <20 GPIO_ACTIVE_HIGH>;
118                 output-low;
119                 line-name = "rut955:ext:cs";
120         };
121
122         mmc_cs {
123                 gpio-hog;
124                 gpios = <3 GPIO_ACTIVE_HIGH>;
125                 output-high;
126                 line-name = "rut955:mmc:cs";
127         };
128
129         uart1_td {
130                 gpio-hog;
131                 gpios = <18 GPIO_ACTIVE_HIGH>;
132                 output-high;
133                 line-name = "rut955:uart1:td";
134         };
135
136         uart1_rd {
137                 gpio-hog;
138                 gpios = <11 GPIO_ACTIVE_LOW>;
139                 input;
140                 line-name = "rut955:uart1:rd";
141         };
142
143         led_wan {
144                 gpio-hog;
145                 gpios = <1 GPIO_ACTIVE_HIGH>;
146                 output-high;
147                 line-name = "rut955:led:wan";
148         };
149
150         led_lan2 {
151                 gpio-hog;
152                 gpios = <13 GPIO_ACTIVE_HIGH>;
153                 output-high;
154                 line-name = "rut955:led:lan2";
155         };
156
157         led_lan1 {
158                 gpio-hog;
159                 gpios = <14 GPIO_ACTIVE_HIGH>;
160                 output-high;
161                 line-name = "rut955:led:lan1";
162         };
163
164         led_lan3 {
165                 gpio-hog;
166                 gpios = <22 GPIO_ACTIVE_HIGH>;
167                 output-high;
168                 line-name = "rut955:led:lan3";
169         };
170 };
171
172 &ref {
173         clock-frequency = <40000000>;
174 };
175
176 &uart {
177         status = "okay";
178 };
179
180 &hs_uart {
181         status = "okay";
182
183         pinctrl-names = "default";
184         pinctrl-0 = <&pmx_uart2>;
185
186         rts-gpios = <&gpio 0 GPIO_ACTIVE_HIGH>;
187         rs485-rts-active-low;
188         linux,rs485-enabled-at-boot-time;
189 };
190
191 &spi {
192         status = "okay";
193
194         num-cs = <3>;
195         pinctrl-names = "default";
196         pinctrl-0 = <&pmx_spi>;
197
198         flash@0 {
199                 compatible = "jedec,spi-nor";
200                 reg = <0>;
201                 spi-max-frequency = <25000000>;
202
203                 partitions {
204                         compatible = "fixed-partitions";
205                         #address-cells = <1>;
206                         #size-cells = <1>;
207
208                         partition@0 {
209                                 label = "u-boot";
210                                 reg = <0x0 0x20000>;
211                                 read-only;
212                         };
213
214                         config: partition@20000 {
215                                 label = "config";
216                                 reg = <0x20000 0x10000>;
217                                 read-only;
218                         };
219
220                         art: partition@30000 {
221                                 label = "art";
222                                 reg = <0x30000 0x10000>;
223                                 read-only;
224                         };
225
226                         partition@40000 {
227                                 label = "firmware";
228                                 reg = <0x40000 0xf30000>;
229                                 compatible = "tplink,firmware";
230                         };
231
232                         partition@f70000 {
233                                 label = "event-log";
234                                 reg = <0xf70000 0x90000>;
235                                 read-only;
236                         };
237                 };
238         };
239
240         microsd@1 {
241                 status = "disabled";
242
243                 compatible = "mmc-spi-slot";
244                 spi-max-frequency = <25000000>;
245                 reg = <1>;
246                 voltage-ranges = <3200 3400>;
247                 broken-cd;
248         };
249
250         gpio_ext: gpio_ext@2 {
251                 compatible = "fairchild,74hc595";
252                 reg = <2>;
253                 gpio-controller;
254                 #gpio-cells = <2>;
255                 registers-number = <2>;
256                 spi-max-frequency = <10000000>;
257                 gpio-line-names = "led_signal_bar1", "led_signal_bar2", "led_signal_bar3", "led_signal_bar4",
258                         "led_signal_bar5", "led_status_red", "led_status_green", "sim_sel",
259                         "DOUT1", "DOUT2", "modem_vbus", "modem_rst",
260                         "DOUT3", "RS485_R", "SDCS", "HWRST";
261         };
262 };
263
264 &usb {
265         #address-cells = <1>;
266         #size-cells = <0>;
267         status = "okay";
268
269         port@1 {
270                 #address-cells = <1>;
271                 #size-cells = <0>;
272                 reg = <1>;
273
274                 port@1 {
275                         compatible = "usb-a-connector";
276                         reg = <1>;
277                 };
278
279                 port@3 {
280                         label = "RS-232 serial adapter";
281                         reg = <3>;
282                 };
283
284                 port@4 {
285                         label = "internal wwan modem";
286                         reg = <4>;
287                 };
288         };
289 };
290
291 &usb_phy {
292         status = "okay";
293 };
294
295 &wmac {
296         status = "okay";
297
298         mtd-cal-data = <&art 0x1000>;
299         mtd-mac-address = <&config 0x0>;
300         mtd-mac-address-increment = <2>;
301 };
302
303 &eth0 {
304         status = "okay";
305
306         phy-handle = <&swphy4>;
307
308         mtd-mac-address = <&config 0x0>;
309         mtd-mac-address-increment = <1>;
310 };
311
312 &eth1 {
313         status = "okay";
314
315         mtd-mac-address = <&config 0x0>;
316 };
317
318 &builtin_switch {
319         pinctrl-names = "default";
320         pinctrl-0 = <&pmx_leds_switch>;
321 };
322
323 &pinmux {
324         pmx_spi: spi {
325                 // SPI_CS1 on GPIO 3, 2nd SCK on GPIO 4
326                 // 2nd MOSI on GPIO 12, SPI_CS2 on GPIO 20
327                 pinctrl-single,bits = <0x0 0x07000000 0xff000000>,
328                                         <0x4 0x0a 0xff>,
329                                         <0xc 0x0b 0xff>,
330                                         <0x14 0x08 0xff>;
331         };
332
333         pmx_leds_switch: leds_switch {
334                 // switch port LEDs on GPIO 1, GPIO 13, GPIO 14 and GPIO 22
335                 pinctrl-single,bits =  <0x0 0x00002d00 0x0000ff00>,
336                                         <0xc 0x002c2b00 0x00ffff00>,
337                                         <0x14 0x002a0000 0x00ff0000>;
338         };
339
340         pmx_uart2: uart2 {
341                 // UART1_DTR on GPIO 0, UART1_RD on GPIO 11, UART1_TD on GPIO 18
342                 pinctrl-single,bits = <0x0 0x0 0xff>,
343                                 <0x10 0x4f000000 0xff000000>,
344                                 <0x3c 0x000b0000 0x00ff0000>;
345         };
346 };