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