1// SPDX-License-Identifier: GPL-2.0-only
2/*
3 * Copyright (c) 2022, Collabora Ltd
4 * Author: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
5 */
6
7/dts-v1/;
8#include <dt-bindings/gpio/gpio.h>
9#include "mt6795.dtsi"
10#include "mt6331.dtsi"
11
12/ {
13	model = "Sony Xperia M5";
14	compatible = "sony,xperia-m5", "mediatek,mt6795";
15	chassis-type = "handset";
16
17	aliases {
18		mmc0 = &mmc0;
19		mmc1 = &mmc1;
20		mmc2 = &mmc2;
21		serial0 = &uart0;
22		serial1 = &uart1;
23	};
24
25	memory@40000000 {
26		device_type = "memory";
27		reg = <0 0x40000000 0 0x1e800000>;
28	};
29
30	reserved_memory: reserved-memory {
31		#address-cells = <2>;
32		#size-cells = <2>;
33		ranges;
34
35		/* 128 KiB reserved for ARM Trusted Firmware (BL31) */
36		bl31_secmon_reserved: secmon@43000000 {
37			reg = <0 0x43000000 0 0x30000>;
38			no-map;
39		};
40
41		/* preloader and bootloader regions cannot be touched */
42		preloader-region@44800000 {
43			reg = <0 0x44800000 0 0x100000>;
44			no-map;
45		};
46
47		bootloader-region@46000000 {
48			reg = <0 0x46000000 0 0x400000>;
49			no-map;
50		};
51	};
52};
53
54&fhctl {
55	clocks = <&apmixedsys CLK_APMIXED_MAINPLL>, <&apmixedsys CLK_APMIXED_MPLL>,
56		 <&apmixedsys CLK_APMIXED_MSDCPLL>;
57	mediatek,hopping-ssc-percent = <8>, <5>, <8>;
58	status = "okay";
59};
60
61&i2c0 {
62	pinctrl-names = "default";
63	pinctrl-0 = <&i2c0_pins>;
64	status = "okay";
65};
66
67&i2c1 {
68	pinctrl-names = "default";
69	pinctrl-0 = <&i2c1_pins>;
70	status = "okay";
71
72	accelerometer@10 {
73		compatible = "bosch,bma255";
74		reg = <0x10>;
75		pinctrl-names = "default";
76		pinctrl-0 = <&accel_pins>;
77	};
78
79	magnetometer@12 {
80		compatible = "bosch,bmm150";
81		reg = <0x12>;
82	};
83};
84
85&i2c2 {
86	pinctrl-names = "default";
87	pinctrl-0 = <&i2c2_pins>;
88	status = "okay";
89
90	touchscreen@20 {
91		compatible = "syna,rmi4-i2c";
92		reg = <0x20>;
93		#address-cells = <1>;
94		#size-cells = <0>;
95		interrupts-extended = <&pio 6 IRQ_TYPE_EDGE_FALLING>;
96		pinctrl-names = "default";
97		pinctrl-0 = <&ts_pins>;
98		syna,startup-delay-ms = <160>;
99		syna,reset-delay-ms = <90>;
100
101		rmi4-f01@1 {
102			reg = <0x1>;
103			syna,nosleep-mode = <1>;
104		};
105
106		rmi4-f12@12 {
107			reg = <0x12>;
108			syna,sensor-type = <1>;
109		};
110	};
111};
112
113&i2c3 {
114	pinctrl-names = "default";
115	pinctrl-0 = <&i2c3_pins>;
116	status = "okay";
117
118	pn547: nfc@28 {
119		compatible = "nxp,pn544-i2c";
120		reg = <0x28>;
121		interrupts-extended = <&pio 3 IRQ_TYPE_EDGE_RISING>;
122		pinctrl-names = "default";
123		pinctrl-0 = <&nfc_pins>;
124		enable-gpios = <&pio 149 GPIO_ACTIVE_HIGH>;
125		firmware-gpios = <&pio 94 GPIO_ACTIVE_HIGH>;
126	};
127
128	proximity@48 {
129		compatible = "sensortek,stk3310";
130		reg = <0x48>;
131		interrupts-extended = <&pio 8 IRQ_TYPE_EDGE_FALLING>;
132		pinctrl-names = "default";
133		pinctrl-0 = <&proximity_pins>;
134	};
135};
136
137&mmc0 {
138	/* eMMC controller */
139	mediatek,latch-ck = <0x14>; /* hs400 */
140	mediatek,hs200-cmd-int-delay = <1>;
141	mediatek,hs400-cmd-int-delay = <1>;
142	mediatek,hs400-ds-dly3 = <0x1a>;
143	non-removable;
144	pinctrl-names = "default", "state_uhs";
145	pinctrl-0 = <&mmc0_pins_default>;
146	pinctrl-1 = <&mmc0_pins_uhs>;
147	vmmc-supply = <&mt6331_vemc33_reg>;
148	vqmmc-supply = <&mt6331_vio18_reg>;
149	status = "okay";
150};
151
152&mmc1 {
153	/* MicroSD card slot */
154	vmmc-supply = <&mt6331_vmc_reg>;
155	vqmmc-supply = <&mt6331_vmch_reg>;
156	status = "okay";
157};
158
159&mmc2 {
160	/* SDIO WiFi on MMC2 */
161	vmmc-supply = <&mt6331_vmc_reg>;
162	vqmmc-supply = <&mt6331_vmch_reg>;
163	status = "okay";
164};
165
166&pio {
167	mmc0_pins_default: emmc-sdr-pins {
168		pins-cmd-dat {
169			pinmux = <PINMUX_GPIO154__FUNC_MSDC0_DAT0>,
170				 <PINMUX_GPIO155__FUNC_MSDC0_DAT1>,
171				 <PINMUX_GPIO156__FUNC_MSDC0_DAT2>,
172				 <PINMUX_GPIO157__FUNC_MSDC0_DAT3>,
173				 <PINMUX_GPIO158__FUNC_MSDC0_DAT4>,
174				 <PINMUX_GPIO159__FUNC_MSDC0_DAT5>,
175				 <PINMUX_GPIO160__FUNC_MSDC0_DAT6>,
176				 <PINMUX_GPIO161__FUNC_MSDC0_DAT7>,
177				 <PINMUX_GPIO162__FUNC_MSDC0_CMD>;
178			input-enable;
179			bias-pull-up = <MTK_PUPD_SET_R1R0_01>;
180		};
181
182		pins-clk {
183			pinmux = <PINMUX_GPIO163__FUNC_MSDC0_CLK>;
184			bias-pull-down = <MTK_PUPD_SET_R1R0_10>;
185		};
186
187		pins-rst {
188			pinmux = <PINMUX_GPIO165__FUNC_MSDC0_RSTB>;
189			bias-pull-up = <MTK_PUPD_SET_R1R0_10>;
190		};
191	};
192
193	mmc0_pins_uhs: emmc-uhs-pins {
194		pins-cmd-dat {
195			pinmux = <PINMUX_GPIO154__FUNC_MSDC0_DAT0>,
196				 <PINMUX_GPIO155__FUNC_MSDC0_DAT1>,
197				 <PINMUX_GPIO156__FUNC_MSDC0_DAT2>,
198				 <PINMUX_GPIO157__FUNC_MSDC0_DAT3>,
199				 <PINMUX_GPIO158__FUNC_MSDC0_DAT4>,
200				 <PINMUX_GPIO159__FUNC_MSDC0_DAT5>,
201				 <PINMUX_GPIO160__FUNC_MSDC0_DAT6>,
202				 <PINMUX_GPIO161__FUNC_MSDC0_DAT7>,
203				 <PINMUX_GPIO162__FUNC_MSDC0_CMD>;
204			input-enable;
205			drive-strength = <MTK_DRIVE_6mA>;
206			bias-pull-up = <MTK_PUPD_SET_R1R0_01>;
207		};
208
209		pins-clk {
210			pinmux = <PINMUX_GPIO163__FUNC_MSDC0_CLK>;
211			drive-strength = <MTK_DRIVE_6mA>;
212			bias-pull-down = <MTK_PUPD_SET_R1R0_10>;
213		};
214
215		pins-rst {
216			pinmux = <PINMUX_GPIO165__FUNC_MSDC0_RSTB>;
217			drive-strength = <MTK_DRIVE_6mA>;
218			bias-pull-up = <MTK_PUPD_SET_R1R0_10>;
219		};
220
221		pins-ds {
222			pinmux = <PINMUX_GPIO164__FUNC_MSDC0_DSL>;
223			drive-strength = <MTK_DRIVE_6mA>;
224			bias-pull-down = <MTK_PUPD_SET_R1R0_10>;
225		};
226	};
227
228	nfc_pins: nfc-pins {
229		pins-irq {
230			pinmux = <PINMUX_GPIO3__FUNC_GPIO3>;
231			bias-pull-down;
232			input-enable;
233		};
234
235		pins-fw-ven {
236			pinmux = <PINMUX_GPIO94__FUNC_GPIO94>,
237				 <PINMUX_GPIO149__FUNC_GPIO149>;
238		};
239	};
240
241	ts_pins: touchscreen-pins {
242		pins-irq {
243			pinmux = <PINMUX_GPIO6__FUNC_GPIO6>;
244			bias-pull-up;
245			input-enable;
246		};
247
248		pins-rst {
249			pinmux = <PINMUX_GPIO102__FUNC_GPIO102>;
250			output-high;
251		};
252	};
253
254	proximity_pins: proximity-pins {
255		pins-irq {
256			pinmux = <PINMUX_GPIO8__FUNC_GPIO8>;
257			bias-pull-up;
258			input-enable;
259		};
260	};
261
262	accel_pins: accelerometer-pins {
263		pins-irq {
264			pinmux = <PINMUX_GPIO12__FUNC_GPIO12>;
265			bias-pull-up;
266			input-enable;
267		};
268	};
269
270	i2c0_pins: i2c0-pins {
271		pins-bus {
272			pinmux = <PINMUX_GPIO45__FUNC_SDA0>,
273				 <PINMUX_GPIO46__FUNC_SCL0>;
274			input-enable;
275		};
276	};
277
278	i2c1_pins: i2c1-pins {
279		pins-bus {
280			pinmux = <PINMUX_GPIO125__FUNC_SDA1>,
281				 <PINMUX_GPIO126__FUNC_SCL1>;
282			bias-disable;
283		};
284	};
285
286	i2c2_pins: i2c2-pins {
287		pins-bus {
288			pinmux = <PINMUX_GPIO43__FUNC_SDA2>,
289				 <PINMUX_GPIO44__FUNC_SCL2>;
290			bias-disable;
291		};
292	};
293
294	i2c3_pins: i2c3-pins {
295		pins-bus {
296			pinmux = <PINMUX_GPIO136__FUNC_SDA3>,
297				 <PINMUX_GPIO137__FUNC_SCL3>;
298			bias-disable;
299		};
300	};
301
302	i2c4_pins: i2c4-pins {
303		pins-bus {
304			pinmux = <PINMUX_GPIO100__FUNC_SDA4>,
305				 <PINMUX_GPIO101__FUNC_SCL4>;
306			bias-disable;
307		};
308	};
309
310	uart0_pins: uart0-pins {
311		pins-rx {
312			pinmux = <PINMUX_GPIO113__FUNC_URXD0>;
313			bias-pull-up;
314			input-enable;
315		};
316		pins-tx {
317			pinmux = <PINMUX_GPIO114__FUNC_UTXD0>;
318			output-high;
319		};
320	};
321
322	uart2_pins: uart2-pins {
323		pins-rx {
324			pinmux = <PINMUX_GPIO31__FUNC_URXD2>;
325			bias-pull-up;
326			input-enable;
327		};
328		pins-tx {
329			pinmux = <PINMUX_GPIO32__FUNC_UTXD2>;
330		};
331	};
332};
333
334&pmic {
335	/*
336	 * Smartphones, including the Xperia M5, are equipped with a companion
337	 * MT6332 PMIC: when this is present, the main MT6331 PMIC will fire
338	 * an interrupt on the companion, so we use the MT6332 IRQ GPIO.
339	 */
340	interrupts = <GIC_SPI 160 IRQ_TYPE_LEVEL_HIGH>;
341};
342
343&uart0 {
344	status = "okay";
345
346	pinctrl-names = "default";
347	pinctrl-0 = <&uart0_pins>;
348};
349
350&uart2 {
351	status = "okay";
352
353	pinctrl-names = "default";
354	pinctrl-0 = <&uart2_pins>;
355};
356