1 /*
2  * (C) Copyright 2015, Freescale Semiconductor, Inc.
3  *
4  * SPDX-License-Identifier:	GPL-2.0+
5  */
6 
7 #ifndef __ARCH_ARM_MACH_S32V234_SIUL_H__
8 #define __ARCH_ARM_MACH_S32V234_SIUL_H__
9 
10 #include "ddr.h"
11 
12 #define SIUL2_MIDR1				(SIUL2_BASE_ADDR + 0x00000004)
13 #define SIUL2_MIDR2				(SIUL2_BASE_ADDR + 0x00000008)
14 #define SIUL2_DISR0				(SIUL2_BASE_ADDR + 0x00000010)
15 #define SIUL2_DIRER0				(SIUL2_BASE_ADDR + 0x00000018)
16 #define SIUL2_DIRSR0				(SIUL2_BASE_ADDR + 0x00000020)
17 #define SIUL2_IREER0				(SIUL2_BASE_ADDR + 0x00000028)
18 #define SIUL2_IFEER0				(SIUL2_BASE_ADDR + 0x00000030)
19 #define SIUL2_IFER0				(SIUL2_BASE_ADDR + 0x00000038)
20 
21 #define SIUL2_IFMCR_BASE			(SIUL2_BASE_ADDR + 0x00000040)
22 #define SIUL2_IFMCRn(i)				(SIUL2_IFMCR_BASE + 4 * (i))
23 
24 #define SIUL2_IFCPR				(SIUL2_BASE_ADDR + 0x000000C0)
25 
26 /* SIUL2_MSCR specifications as stated in Reference Manual:
27  * 0 - 359 Output Multiplexed Signal Configuration Registers
28  * 512- 1023 Input Multiplexed Signal Configuration Registers */
29 #define SIUL2_MSCR_BASE				(SIUL2_BASE_ADDR + 0x00000240)
30 #define SIUL2_MSCRn(i)				(SIUL2_MSCR_BASE + 4 * (i))
31 
32 #define SIUL2_IMCR_BASE				(SIUL2_BASE_ADDR + 0x00000A40)
33 #define SIUL2_IMCRn(i)				(SIUL2_IMCR_BASE +  4 * (i))
34 
35 #define SIUL2_GPDO_BASE				(SIUL2_BASE_ADDR + 0x00001300)
36 #define SIUL2_GPDOn(i)				(SIUL2_GPDO_BASE + 4 * (i))
37 
38 #define SIUL2_GPDI_BASE				(SIUL2_BASE_ADDR + 0x00001500)
39 #define SIUL2_GPDIn(i)				(SIUL2_GPDI_BASE + 4 * (i))
40 
41 #define SIUL2_PGPDO_BASE			(SIUL2_BASE_ADDR + 0x00001700)
42 #define SIUL2_PGPDOn(i)				(SIUL2_PGPDO_BASE +  2 * (i))
43 
44 #define SIUL2_PGPDI_BASE			(SIUL2_BASE_ADDR + 0x00001740)
45 #define SIUL2_PGPDIn(i)				(SIUL2_PGPDI_BASE + 2 * (i))
46 
47 #define SIUL2_MPGPDO_BASE			(SIUL2_BASE_ADDR + 0x00001780)
48 #define SIUL2_MPGPDOn(i)			(SIUL2_MPGPDO_BASE + 4 * (i))
49 
50 /* SIUL2_MSCR masks */
51 #define SIUL2_MSCR_DDR_DO_TRIM(v)	((v) & 0xC0000000)
52 #define SIUL2_MSCR_DDR_DO_TRIM_MIN	(0 << 30)
53 #define SIUL2_MSCR_DDR_DO_TRIM_50PS	(1 << 30)
54 #define SIUL2_MSCR_DDR_DO_TRIM_100PS	(2 << 30)
55 #define SIUL2_MSCR_DDR_DO_TRIM_150PS	(3 << 30)
56 
57 #define SIUL2_MSCR_DDR_INPUT(v)		((v) & 0x20000000)
58 #define SIUL2_MSCR_DDR_INPUT_CMOS	(0 << 29)
59 #define SIUL2_MSCR_DDR_INPUT_DIFF_DDR	(1 << 29)
60 
61 #define SIUL2_MSCR_DDR_SEL(v)		((v) & 0x18000000)
62 #define SIUL2_MSCR_DDR_SEL_DDR3		(0 << 27)
63 #define SIUL2_MSCR_DDR_SEL_LPDDR2	(2 << 27)
64 
65 #define SIUL2_MSCR_DDR_ODT(v)		((v) & 0x07000000)
66 #define SIUL2_MSCR_DDR_ODT_120ohm	(1 << 24)
67 #define SIUL2_MSCR_DDR_ODT_60ohm	(2 << 24)
68 #define SIUL2_MSCR_DDR_ODT_40ohm	(3 << 24)
69 #define SIUL2_MSCR_DDR_ODT_30ohm	(4 << 24)
70 #define SIUL2_MSCR_DDR_ODT_24ohm	(5 << 24)
71 #define SIUL2_MSCR_DDR_ODT_20ohm	(6 << 24)
72 #define SIUL2_MSCR_DDR_ODT_17ohm	(7 << 24)
73 
74 #define SIUL2_MSCR_DCYCLE_TRIM(v)	((v) & 0x00C00000)
75 #define SIUL2_MSCR_DCYCLE_TRIM_NONE	(0 << 22)
76 #define SIUL2_MSCR_DCYCLE_TRIM_LEFT	(1 << 22)
77 #define SIUL2_MSCR_DCYCLE_TRIM_RIGHT	(2 << 22)
78 
79 #define SIUL2_MSCR_OBE(v)		((v) & 0x00200000)
80 #define SIUL2_MSCR_OBE_EN		(1 << 21)
81 
82 #define SIUL2_MSCR_ODE(v)		((v) & 0x00100000)
83 #define SIUL2_MSCR_ODE_EN		(1 << 20)
84 
85 #define SIUL2_MSCR_IBE(v)		((v) & 0x00010000)
86 #define SIUL2_MSCR_IBE_EN		(1 << 19)
87 
88 #define SIUL2_MSCR_HYS(v)		((v) & 0x00400000)
89 #define SIUL2_MSCR_HYS_EN		(1 << 18)
90 
91 #define SIUL2_MSCR_INV(v)		((v) & 0x00020000)
92 #define SIUL2_MSCR_INV_EN		(1 << 17)
93 
94 #define SIUL2_MSCR_PKE(v)		((v) & 0x00010000)
95 #define SIUL2_MSCR_PKE_EN		(1 << 16)
96 
97 #define SIUL2_MSCR_SRE(v)		((v) & 0x0000C000)
98 #define SIUL2_MSCR_SRE_SPEED_LOW_50	(0 << 14)
99 #define SIUL2_MSCR_SRE_SPEED_LOW_100	(1 << 14)
100 #define SIUL2_MSCR_SRE_SPEED_HIGH_100	(2 << 14)
101 #define SIUL2_MSCR_SRE_SPEED_HIGH_200	(3 << 14)
102 
103 #define SIUL2_MSCR_PUE(v)		((v) & 0x00002000)
104 #define SIUL2_MSCR_PUE_EN		(1 << 13)
105 
106 #define SIUL2_MSCR_PUS(v)		((v) & 0x00001800)
107 #define SIUL2_MSCR_PUS_100K_DOWN	(0 << 11)
108 #define SIUL2_MSCR_PUS_50K_DOWN		(1 << 11)
109 #define SIUL2_MSCR_PUS_100K_UP		(2 << 11)
110 #define SIUL2_MSCR_PUS_33K_UP		(3 << 11)
111 
112 #define SIUL2_MSCR_DSE(v)		((v) & 0x00000700)
113 #define SIUL2_MSCR_DSE_240ohm		(1 << 8)
114 #define SIUL2_MSCR_DSE_120ohm		(2 << 8)
115 #define SIUL2_MSCR_DSE_80ohm		(3 << 8)
116 #define SIUL2_MSCR_DSE_60ohm		(4 << 8)
117 #define SIUL2_MSCR_DSE_48ohm		(5 << 8)
118 #define SIUL2_MSCR_DSE_40ohm		(6 << 8)
119 #define SIUL2_MSCR_DSE_34ohm		(7 << 8)
120 
121 #define SIUL2_MSCR_CRPOINT_TRIM(v)	((v) & 0x000000C0)
122 #define SIUL2_MSCR_CRPOINT_TRIM_1	(1 << 6)
123 
124 #define SIUL2_MSCR_SMC(v)		((v) & 0x00000020)
125 #define SIUL2_MSCR_MUX_MODE(v)		((v) & 0x0000000f)
126 #define SIUL2_MSCR_MUX_MODE_ALT1	(0x1)
127 #define SIUL2_MSCR_MUX_MODE_ALT2	(0x2)
128 #define SIUL2_MSCR_MUX_MODE_ALT3	(0x3)
129 
130 /* UART settings */
131 #define SIUL2_UART0_TXD_PAD	12
132 #define SIUL2_UART_TXD		(SIUL2_MSCR_OBE_EN | SIUL2_MSCR_PUS_100K_UP | SIUL2_MSCR_DSE_60ohm |	\
133 				SIUL2_MSCR_SRE_SPEED_LOW_100 | SIUL2_MSCR_MUX_MODE_ALT1)
134 
135 #define SIUL2_UART0_MSCR_RXD_PAD	11
136 #define SIUL2_UART0_IMCR_RXD_PAD	200
137 
138 #define SIUL2_UART_MSCR_RXD	(SIUL2_MSCR_PUE_EN | SIUL2_MSCR_IBE_EN | SIUL2_MSCR_DCYCLE_TRIM_RIGHT)
139 #define SIUL2_UART_IMCR_RXD	(SIUL2_MSCR_MUX_MODE_ALT2)
140 
141 /* uSDHC settings */
142 #define SIUL2_USDHC_PAD_CTRL_BASE	(SIUL2_MSCR_SRE_SPEED_HIGH_200 | SIUL2_MSCR_OBE_EN |	\
143 						SIUL2_MSCR_DSE_34ohm | SIUL2_MSCR_PKE_EN | SIUL2_MSCR_IBE_EN |		\
144 						SIUL2_MSCR_PUS_100K_UP | SIUL2_MSCR_PUE_EN )
145 #define SIUL2_USDHC_PAD_CTRL_CMD	(SIUL2_USDHC_PAD_CTRL_BASE | SIUL2_MSCR_MUX_MODE_ALT1)
146 #define SIUL2_USDHC_PAD_CTRL_CLK	(SIUL2_USDHC_PAD_CTRL_BASE | SIUL2_MSCR_MUX_MODE_ALT2)
147 #define SIUL2_USDHC_PAD_CTRL_DAT0_3	(SIUL2_USDHC_PAD_CTRL_BASE | SIUL2_MSCR_MUX_MODE_ALT2)
148 #define SIUL2_USDHC_PAD_CTRL_DAT4_7	(SIUL2_USDHC_PAD_CTRL_BASE | SIUL2_MSCR_MUX_MODE_ALT3)
149 
150 #endif /*__ARCH_ARM_MACH_S32V234_SIUL_H__ */
151