1// SPDX-License-Identifier: GPL-2.0-only
2/*
3 * Devicetree for the Samsung XCover 2 GT-S7710 also known as Skomer.
4 */
5
6/dts-v1/;
7#include "ste-db8500.dtsi"
8#include "ste-ab8505.dtsi"
9#include "ste-dbx5x0-pinctrl.dtsi"
10#include <dt-bindings/gpio/gpio.h>
11#include <dt-bindings/leds/common.h>
12#include <dt-bindings/input/input.h>
13#include <dt-bindings/interrupt-controller/irq.h>
14
15/ {
16	model = "Samsung XCover 2 (GT-S7710)";
17	compatible = "samsung,skomer", "st-ericsson,u8500";
18
19	chosen {
20		stdout-path = &serial2;
21	};
22
23	/* TI TXS0206 level translator for 2.9 V */
24	sd_level_translator: regulator-gpio {
25		compatible = "regulator-fixed";
26
27		/* GPIO87 EN */
28		gpios = <&gpio2 23 GPIO_ACTIVE_HIGH>;
29		enable-active-high;
30
31		regulator-name = "sd-level-translator";
32		regulator-min-microvolt = <2900000>;
33		regulator-max-microvolt = <2900000>;
34		regulator-type = "voltage";
35
36		startup-delay-us = <200>;
37
38		pinctrl-names = "default";
39		pinctrl-0 = <&sd_level_translator_default>;
40	};
41
42	/* External LDO MIC5366-3.3YMT for eMMC */
43	ldo_3v3_reg: regulator-gpio-ldo-3v3 {
44		compatible = "regulator-fixed";
45		regulator-name = "en-3v3-fixed-supply";
46		regulator-min-microvolt = <3300000>;
47		regulator-max-microvolt = <3300000>;
48		gpio = <&gpio6 31 GPIO_ACTIVE_HIGH>;
49		startup-delay-us = <5000>;
50		enable-active-high;
51		pinctrl-names = "default";
52		pinctrl-0 = <&emmc_ldo_en_default_mode>;
53	};
54
55	wlan_en: regulator-gpio-wlan-en {
56		compatible = "regulator-fixed";
57		regulator-name = "wl-reg-on";
58		regulator-min-microvolt = <3000000>;
59		regulator-max-microvolt = <3000000>;
60		startup-delay-us = <200000>;
61		/* GPIO215 WLAN_EN */
62		gpio = <&gpio6 23 GPIO_ACTIVE_HIGH>;
63		enable-active-high;
64		pinctrl-names = "default";
65		pinctrl-0 = <&wlan_en_default_mode>;
66	};
67
68	vibrator {
69		compatible = "gpio-vibrator";
70		enable-gpios = <&gpio6 3 GPIO_ACTIVE_HIGH>;
71		pinctrl-names = "default";
72		pinctrl-0 = <&vibrator_default>;
73	};
74
75	gpio-keys {
76		compatible = "gpio-keys";
77		pinctrl-names = "default";
78		pinctrl-0 = <&gpio_keys_default_mode>;
79
80		button-home {
81			linux,code = <KEY_HOME>;
82			label = "HOME";
83			/* GPIO91 */
84			gpios = <&gpio2 27 GPIO_ACTIVE_LOW>;
85		};
86		button-volup {
87			linux,code = <KEY_VOLUMEUP>;
88			label = "VOL+";
89			/* GPIO67 */
90			gpios = <&gpio2 3 GPIO_ACTIVE_LOW>;
91		};
92		button-voldown {
93			linux,code = <KEY_VOLUMEDOWN>;
94			label = "VOL-";
95			/* GPIO92 */
96			gpios = <&gpio2 28 GPIO_ACTIVE_LOW>;
97		};
98		button-menu {
99			linux,code = <KEY_MENU>;
100			label = "MENU";
101			/* GPIO204 */
102			gpios = <&gpio6 12 GPIO_ACTIVE_LOW>;
103		};
104		button-back {
105			linux,code = <KEY_BACK>;
106			label = "BACK";
107			/* GPIO205 */
108			gpios = <&gpio6 13 GPIO_ACTIVE_LOW>;
109		};
110	};
111
112	ktd253: backlight {
113		compatible = "kinetic,ktd253";
114		/* GPIO 69 */
115		enable-gpios = <&gpio2 5 GPIO_ACTIVE_HIGH>;
116		/* Default to 13/32 brightness */
117		default-brightness = <13>;
118		pinctrl-names = "default";
119		pinctrl-0 = <&gpio_backlight_default_mode>;
120	};
121
122	/* Richtek RT8515GQW Flash LED Driver IC */
123	flash {
124		compatible = "richtek,rt8515";
125		/* GPIO 140 */
126		enf-gpios = <&gpio4 12 GPIO_ACTIVE_HIGH>;
127		/* GPIO 141 */
128		ent-gpios = <&gpio4 13 GPIO_ACTIVE_HIGH>;
129		/*
130		 * RFS is 16 kOhm and RTS is 100 kOhm giving
131		 * the flash max current 343mA and torch max
132		 * current 55 mA.
133		 */
134		richtek,rfs-ohms = <16000>;
135		richtek,rts-ohms = <100000>;
136		pinctrl-names = "default";
137		pinctrl-0 = <&gpio_flash_default_mode>;
138
139		led {
140			function = LED_FUNCTION_FLASH;
141			color = <LED_COLOR_ID_WHITE>;
142			flash-max-timeout-us = <250000>;
143			flash-max-microamp = <343750>;
144			led-max-microamp = <55000>;
145		};
146	};
147
148	i2c-gpio-0 {
149		compatible = "i2c-gpio";
150		sda-gpios = <&gpio4 16 (GPIO_ACTIVE_HIGH|GPIO_OPEN_DRAIN)>;
151		scl-gpios = <&gpio4 15 (GPIO_ACTIVE_HIGH|GPIO_OPEN_DRAIN)>;
152		pinctrl-names = "default";
153		pinctrl-0 = <&i2c_gpio_0_default>;
154		#address-cells = <1>;
155		#size-cells = <0>;
156		/* TODO: this should be used by the NCP6914 Camera power management unit */
157	};
158
159	i2c-gpio-1 {
160		compatible = "i2c-gpio";
161		sda-gpios = <&gpio4 24 (GPIO_ACTIVE_HIGH|GPIO_OPEN_DRAIN)>;
162		scl-gpios = <&gpio4 23 (GPIO_ACTIVE_HIGH|GPIO_OPEN_DRAIN)>;
163		pinctrl-names = "default";
164		pinctrl-0 = <&i2c_gpio_1_default>;
165		#address-cells = <1>;
166		#size-cells = <0>;
167		magnetometer@c {
168			compatible = "alps,hscdtd008a";
169			reg = <0x0c>;
170			avdd-supply = <&ab8500_ldo_aux1_reg>;
171			dvdd-supply = <&ab8500_ldo_aux8_reg>;
172		};
173	};
174
175	soc {
176		// External Micro SD slot
177		mmc@80126000 {
178			arm,primecell-periphid = <0x10480180>;
179			max-frequency = <100000000>;
180			bus-width = <4>;
181			cap-sd-highspeed;
182			cap-mmc-highspeed;
183			/* All direction control is used */
184			st,sig-dir-cmd;
185			st,sig-dir-dat0;
186			st,sig-dir-dat2;
187			st,sig-dir-dat31;
188			st,sig-pin-fbclk;
189			full-pwr-cycle;
190			vmmc-supply = <&ab8500_ldo_aux3_reg>;
191			vqmmc-supply = <&sd_level_translator>;
192			pinctrl-names = "default", "sleep";
193			pinctrl-0 = <&mc0_a_1_default>;
194			pinctrl-1 = <&mc0_a_1_sleep>;
195			status = "okay";
196		};
197
198		// WLAN SDIO channel
199		mmc@80118000 {
200			arm,primecell-periphid = <0x10480180>;
201			max-frequency = <50000000>;
202			bus-width = <4>;
203			non-removable;
204			cap-sd-highspeed;
205			vmmc-supply = <&wlan_en>;
206			pinctrl-names = "default", "sleep";
207			pinctrl-0 = <&mc1_a_2_default>;
208			pinctrl-1 = <&mc1_a_2_sleep>;
209			status = "okay";
210			#address-cells = <1>;
211			#size-cells = <0>;
212
213			wifi@1 {
214				compatible = "brcm,bcm4334-fmac", "brcm,bcm4329-fmac";
215				reg = <1>;
216				/* GPIO216 WL_HOST_WAKE */
217				interrupt-parent = <&gpio6>;
218				interrupts = <24 IRQ_TYPE_EDGE_FALLING>;
219				interrupt-names = "host-wake";
220				pinctrl-names = "default";
221				pinctrl-0 = <&wlan_default_mode>;
222			};
223		};
224
225		// eMMC
226		mmc@80005000 {
227			arm,primecell-periphid = <0x10480180>;
228		        max-frequency = <100000000>;
229			bus-width = <8>;
230			non-removable;
231			cap-mmc-highspeed;
232			mmc-ddr-1_8v;
233			no-sdio;
234			no-sd;
235			vmmc-supply = <&ldo_3v3_reg>;
236			pinctrl-names = "default", "sleep";
237			pinctrl-0 = <&mc2_a_1_default>;
238			pinctrl-1 = <&mc2_a_1_sleep>;
239
240			status = "okay";
241		};
242
243		/* GBF (Bluetooth) UART */
244		uart@80120000 {
245			pinctrl-names = "default", "sleep";
246			pinctrl-0 = <&u0_a_1_default>;
247			pinctrl-1 = <&u0_a_1_sleep>;
248			status = "okay";
249
250			/* FIXME: not quite working yet, probably needs regulators */
251			bluetooth {
252				/* BCM4334B0 actually */
253				compatible = "brcm,bcm4330-bt";
254				shutdown-gpios = <&gpio6 30 GPIO_ACTIVE_HIGH>;
255				device-wakeup-gpios = <&gpio6 7 GPIO_ACTIVE_HIGH>;
256				host-wakeup-gpios = <&gpio3 1 GPIO_ACTIVE_HIGH>;
257				pinctrl-names = "default";
258				pinctrl-0 = <&bluetooth_default_mode>;
259			};
260		};
261
262		/* GPF UART */
263		uart@80121000 {
264			status = "okay";
265			pinctrl-names = "default", "sleep";
266			pinctrl-0 = <&u1rxtx_a_1_default &u1ctsrts_a_1_default>;
267			pinctrl-1 = <&u1rxtx_a_1_sleep &u1ctsrts_a_1_sleep>;
268		};
269
270		/* Debugging console UART connected to AB8505 USB */
271		uart@80007000 {
272			status = "okay";
273			pinctrl-names = "default", "sleep";
274			pinctrl-0 = <&u2rxtx_c_1_default>;
275			pinctrl-1 = <&u2rxtx_c_1_sleep>;
276		};
277
278		prcmu@80157000 {
279			ab8505 {
280				ab8500_usb {
281					pinctrl-names = "default", "sleep";
282					pinctrl-0 = <&usb_a_1_default>;
283					pinctrl-1 = <&usb_a_1_sleep>;
284				};
285
286				ab8505-regulators {
287					ab8500_ldo_aux1 {
288						/* Used for VDD for sensors */
289						regulator-name = "AUX1";
290						regulator-min-microvolt = <3000000>;
291						regulator-max-microvolt = <3300000>;
292					};
293
294					ab8500_ldo_aux2 {
295						/* Supplies the Cypress TMA140 touchscreen only with 3.3V */
296						regulator-name = "AUX2";
297						regulator-min-microvolt = <3300000>;
298						regulator-max-microvolt = <3300000>;
299					};
300
301					ab8500_ldo_aux3 {
302						/* Used for voltage for external MMC/SD card */
303						regulator-name = "AUX3";
304						regulator-min-microvolt = <1100000>;
305						regulator-max-microvolt = <3300000>;
306					};
307
308					ab8500_ldo_aux4 {
309						regulator-name = "AUX4";
310						/* Hammer to 3.0V for the display */
311						regulator-min-microvolt = <3000000>;
312						regulator-max-microvolt = <3000000>;
313					};
314
315					ab8500_ldo_aux5 {
316						regulator-name = "AUX5";
317						regulator-min-microvolt = <1050000>;
318						regulator-max-microvolt = <2790000>;
319						regulator-always-on;
320					};
321
322					ab8500_ldo_aux6 {
323						regulator-name = "AUX6";
324						/* Hammer to 1.8V for the display */
325						regulator-min-microvolt = <1800000>;
326						regulator-max-microvolt = <1800000>;
327					};
328
329					ab8500_ldo_aux8 {
330						/* Mostly VIO for sensors */
331						regulator-name = "AUX8";
332					};
333				};
334			};
335		};
336
337		/* I2C0 */
338		i2c@80004000 {
339			status = "okay";
340
341			pinctrl-names = "default", "sleep";
342			pinctrl-0 = <&i2c0_a_1_default>;
343			pinctrl-1 = <&i2c0_a_1_sleep>;
344
345			proximity@44 {
346				compatible = "sharp,gp2ap002s00f";
347				clock-frequency = <400000>;
348				reg = <0x44>;
349
350				interrupt-parent = <&gpio4>;
351				interrupts = <18 IRQ_TYPE_EDGE_FALLING>;
352				vdd-supply = <&ab8500_ldo_aux1_reg>;
353				vio-supply = <&ab8500_ldo_aux8_reg>;
354				pinctrl-names = "default";
355				pinctrl-0 = <&gp2ap002_skomer_default>;
356				sharp,proximity-far-hysteresis = /bits/ 8 <0x2f>;
357				sharp,proximity-close-hysteresis = /bits/ 8 <0x0f>;
358			};
359		};
360
361
362		/* I2C2 */
363		i2c@80128000 {
364			status = "okay";
365
366			pinctrl-names = "default", "sleep";
367			pinctrl-0 = <&i2c2_b_2_default>;
368			pinctrl-1 = <&i2c2_b_2_sleep>;
369
370			accel@18 {
371				compatible = "bosch,bma254";
372				clock-frequency = <400000>;
373				reg = <0x18>;
374
375				/* GPIO224 used as "smart alert" interrupt */
376				interrupt-parent = <&gpio7>;
377				interrupts = <0 IRQ_TYPE_EDGE_RISING>;
378
379				mount-matrix = "0", "-1", "0",
380					      "1", "0", "0",
381					       "0", "0", "1";
382				vdd-supply = <&ab8500_ldo_aux1_reg>;
383				vddio-supply = <&ab8500_ldo_aux8_reg>;
384				pinctrl-names = "default";
385				pinctrl-0 = <&bma254_skomer_default>;
386			};
387		};
388
389		/* I2C3 */
390		i2c@80110000 {
391			status = "okay";
392
393			pinctrl-names = "default", "sleep";
394			pinctrl-0 = <&i2c3_c_2_default>;
395			pinctrl-1 = <&i2c3_c_2_sleep>;
396
397			/* Cypress CY8CTMA140 touchscreen */
398			touchscreen@20 {
399				compatible = "cypress,cy8ctma140";
400				clock-frequency = <400000>;
401				reg = <0x20>;
402
403				touchscreen-size-x = <480>;
404				touchscreen-size-y = <800>;
405				touchscreen-max-pressure = <255>;
406
407				/* GPIO218 for IRQ */
408				interrupt-parent = <&gpio6>;
409				interrupts = <26 IRQ_TYPE_EDGE_FALLING>;
410
411				/* VDD is "digital supply" nominally 1.71-3.6V */
412				vdd-supply = <&ab8500_ldo_aux2_reg>;
413				/* VCPIN is "analog supply", 2.7-3.6 V */
414				vcpin-supply = <&ab8500_ldo_aux2_reg>;
415
416				pinctrl-names = "default";
417				pinctrl-0 = <&tma140_skomer_default>;
418			};
419		};
420
421		mcde@a0350000 {
422			status = "okay";
423			pinctrl-names = "default";
424			pinctrl-0 = <&dsi_default_mode>;
425
426			dsi@a0351000 {
427				panel {
428					/* NT35510-based Hydis HVA40WV1 */
429					compatible = "hydis,hva40wv1", "novatek,nt35510";
430					reg = <0>;
431					/* v_lcd_3v0 2.3-4.8V */
432					vdd-supply = <&ab8500_ldo_aux4_reg>;
433					/* v_lcd_1v8 1.65-3.3V */
434					vddi-supply = <&ab8500_ldo_aux6_reg>;
435					/* GPIO 139 */
436					reset-gpios = <&gpio4 11 GPIO_ACTIVE_LOW>;
437					pinctrl-names = "default";
438					pinctrl-0 = <&display_default_mode>;
439					backlight = <&ktd253>;
440				};
441			};
442		};
443	};
444};
445
446&pinctrl {
447	/*
448	 * This extends the MC0 default config to include DAT32DIR
449	 * which is used by this machine. If we don't do this the
450	 * SD card does not work.
451	 */
452	sdi0 {
453		mc0_a_1_default {
454			default_mux {
455				function = "mc0";
456				/* This machine uses the DAT31 pin */
457				groups = "mc0_a_1", "mc0dat31dir_a_1";
458			};
459			default_cfg5 {
460				pins = "GPIO21_AB3"; /* DAT31DIR */
461				ste,config = <&out_hi>;
462			};
463		};
464	};
465
466	/* The unused FBCLK needs to be pulled down on this machine */
467	sdi2 {
468		mc2_a_1_default {
469			default_cfg2 {
470				pins = "GPIO130_C8"; /* FBCLK */
471				ste,config = <&in_pd>;
472			};
473		};
474	};
475
476	mcde {
477		dsi_default_mode: dsi_default {
478			default_mux1 {
479				/* Mux in VSI0 used for DSI TE */
480				function = "lcd";
481				groups = "lcdvsi0_a_1"; /* VSI0 for LCD */
482			};
483			default_cfg1 {
484				pins = "GPIO68_E1"; /* VSI0 */
485				ste,config = <&in_nopull>;
486			};
487		};
488	};
489
490	/* Two GPIO lines used by the display */
491	display {
492		display_default_mode: display_default {
493			skomer_cfg1 {
494				/*
495				 * OLED DETECT or check_pba, this appears to be high
496				 * on "PBA" which I guess is "prototype board A".
497				 */
498				pins = "GPIO93_B7";
499				ste,config = <&gpio_in_nopull>;
500			};
501			skomer_cfg2 {
502				pins = "GPIO139_C9";
503				/*
504				 * MIPI_DSI0_RESET_N resets the display, leave high
505				 * (de-asserted) so we only assert reset explicitly
506				 * from the display driver.
507				 */
508				ste,config = <&gpio_out_hi>;
509			};
510		};
511	};
512	backlight {
513		gpio_backlight_default_mode: backlight_default {
514			skomer_cfg1 {
515				pins = "GPIO69_E2"; /* LCD_BL_CTRL */
516				ste,config = <&gpio_out_lo>;
517			};
518		};
519	};
520	flash {
521		gpio_flash_default_mode: flash_default {
522			skomer_cfg1 {
523				pins = "GPIO140_B11", "GPIO141_C12";
524				ste,config = <&gpio_out_lo>;
525			};
526		};
527	};
528	/* GPIO that enables the 2.9V SD card level translator */
529	sd-level-translator {
530		sd_level_translator_default: sd_level_translator_default {
531			/* level shifter on GPIO87 */
532			skomer_cfg1 {
533				pins = "GPIO87_B3";
534				ste,config = <&gpio_out_hi>;
535			};
536		};
537	};
538	/* GPIO that enables the LDO regulator for the eMMC */
539	emmc-ldo {
540		emmc_ldo_en_default_mode: emmc_ldo_default {
541			/* LDO enable on GPIO223 */
542			skomer_cfg1 {
543				pins = "GPIO223_AH9";
544				ste,config = <&gpio_out_hi>;
545			};
546		};
547	};
548	/* GPIO keys */
549	gpio-keys {
550		gpio_keys_default_mode: gpio_keys_default {
551			skomer_cfg1 {
552				pins = "GPIO67_G2", /* VOL UP */
553				       "GPIO91_B6", /* HOME */
554				       "GPIO92_D6", /* VOL DOWN */
555				       "GPIO204_AF23", /* MENU */
556				       "GPIO205_AG23"; /* BACK */
557					ste,config = <&gpio_in_pu>;
558			};
559		};
560	};
561	/* Interrupt line for BMA254 */
562	bma254 {
563		bma254_skomer_default: bma254_skomer {
564			skomer_cfg1 {
565				pins = "GPIO224_AG9";
566				ste,config = <&gpio_in_pd>;
567			};
568		};
569	};
570	/* Interrupt line for light/proximity sensor GP2AP002 */
571	gp2ap002 {
572		gp2ap002_skomer_default: gp2ap002_skomer {
573			skomer_cfg1 {
574				pins = "GPIO146_D13";
575				ste,config = <&gpio_in_nopull>;
576			};
577		};
578	};
579	/* GPIO-based I2C bus for NCP6914 */
580	i2c-gpio-0 {
581		i2c_gpio_0_default: i2c_gpio_0 {
582			skomer_cfg1 {
583				pins = "GPIO143_D12", "GPIO144_B13";
584				ste,config = <&gpio_in_nopull>;
585			};
586		};
587	};
588	/* GPIO-based I2C bus for ALPS HSCD compass */
589	i2c-gpio-1 {
590		i2c_gpio_1_default: i2c_gpio_1 {
591			skomer_cfg1 {
592				pins = "GPIO151_B17", "GPIO152_D16";
593				ste,config = <&gpio_in_nopull>;
594			};
595		};
596	};
597	wlan {
598		wlan_default_mode: wlan_default {
599			skomer_cfg1 {
600				pins = "GPIO216_AG12";
601				ste,config = <&gpio_in_pd>;
602			};
603		};
604		wlan_en_default_mode: wlan_en_default {
605			skomer_cfg2 {
606				pins = "GPIO215_AH13";
607				ste,config = <&gpio_out_lo>;
608			};
609		};
610	};
611	bluetooth {
612		bluetooth_default_mode: bluetooth_default {
613			skomer_cfg1 {
614				pins = "GPIO199_AH23", "GPIO222_AJ9";
615				ste,config = <&gpio_out_lo>;
616			};
617			skomer_cfg2 {
618				pins = "GPIO97_D9";
619				ste,config = <&gpio_in_nopull>;
620			};
621		};
622	};
623	vibrator {
624		vibrator_default: vibrator_default {
625			skomer_cfg1 {
626				pins = "GPIO195_AG28";	/* MOT_EN */
627				ste,config = <&gpio_out_lo>;
628			};
629		};
630	};
631	/* Interrupt line for the Cypress TMA140 touchscreen */
632	touchscreen {
633		tma140_skomer_default: tma140_skomer {
634			skomer_cfg1 {
635				pins = "GPIO218_AH11";
636				ste,config = <&gpio_in_nopull>;
637			};
638		};
639	};
640};
641
642&ab8505_gpio {
643	/* Hog a few default settings */
644	pinctrl-names = "default";
645	pinctrl-0 = <&gpio_default>;
646
647	gpio {
648		gpio_default: gpio_default {
649			skomer_mux {
650				/* Change unused pins to GPIO mode */
651				function = "gpio";
652				groups = "gpio3_a_1",	/* default: SysClkReq4 */
653					 "gpio14_a_1";	/* default: PWMOut1 */
654			};
655			skomer_cfg1 {
656				pins = "GPIO11_B17", "GPIO13_D17", "GPIO50_L4";
657				bias-disable;
658			};
659		};
660	};
661};
662