]>
Commit | Line | Data |
---|---|---|
d2912cb1 | 1 | // SPDX-License-Identifier: GPL-2.0-only |
bac07ecd DM |
2 | /* |
3 | * arch/arm/mach-pxa/colibri-pxa320.c | |
4 | * | |
5 | * Support for Toradex PXA320/310 based Colibri module | |
6 | * | |
7 | * Daniel Mack <daniel@caiaq.de> | |
8 | * Matthias Meier <matthias.j.meier@gmx.net> | |
bac07ecd DM |
9 | */ |
10 | ||
11 | #include <linux/init.h> | |
12 | #include <linux/kernel.h> | |
13 | #include <linux/platform_device.h> | |
14 | #include <linux/gpio.h> | |
8a28b10e | 15 | #include <linux/interrupt.h> |
11dd2d9a | 16 | #include <linux/usb/gpio_vbus.h> |
bac07ecd DM |
17 | |
18 | #include <asm/mach-types.h> | |
87dfb311 | 19 | #include <linux/sizes.h> |
bac07ecd DM |
20 | #include <asm/mach/arch.h> |
21 | #include <asm/mach/irq.h> | |
22 | ||
4c25c5d2 AB |
23 | #include "pxa320.h" |
24 | #include "colibri.h" | |
293b2da1 AB |
25 | #include <linux/platform_data/video-pxafb.h> |
26 | #include <linux/platform_data/usb-ohci-pxa27x.h> | |
15f593cf | 27 | #include <mach/audio.h> |
4c25c5d2 AB |
28 | #include "pxa27x-udc.h" |
29 | #include "udc.h" | |
bac07ecd DM |
30 | |
31 | #include "generic.h" | |
32 | #include "devices.h" | |
33 | ||
a3172e54 | 34 | #ifdef CONFIG_MACH_COLIBRI_EVALBOARD |
9b6956f4 MV |
35 | static mfp_cfg_t colibri_pxa320_evalboard_pin_config[] __initdata = { |
36 | /* MMC */ | |
37 | GPIO22_MMC1_CLK, | |
38 | GPIO23_MMC1_CMD, | |
39 | GPIO18_MMC1_DAT0, | |
40 | GPIO19_MMC1_DAT1, | |
41 | GPIO20_MMC1_DAT2, | |
42 | GPIO21_MMC1_DAT3, | |
43 | GPIO28_GPIO, /* SD detect */ | |
44 | ||
45 | /* UART 1 configuration (may be set by bootloader) */ | |
46 | GPIO99_UART1_CTS, | |
47 | GPIO104_UART1_RTS, | |
48 | GPIO97_UART1_RXD, | |
49 | GPIO98_UART1_TXD, | |
50 | GPIO101_UART1_DTR, | |
51 | GPIO103_UART1_DSR, | |
52 | GPIO100_UART1_DCD, | |
53 | GPIO102_UART1_RI, | |
54 | ||
55 | /* UART 2 configuration */ | |
56 | GPIO109_UART2_CTS, | |
57 | GPIO112_UART2_RTS, | |
58 | GPIO110_UART2_RXD, | |
59 | GPIO111_UART2_TXD, | |
60 | ||
61 | /* UART 3 configuration */ | |
62 | GPIO30_UART3_RXD, | |
63 | GPIO31_UART3_TXD, | |
64 | ||
65 | /* UHC */ | |
66 | GPIO2_2_USBH_PEN, | |
67 | GPIO3_2_USBH_PWR, | |
072e1ae7 MV |
68 | |
69 | /* I2C */ | |
70 | GPIO32_I2C_SCL, | |
71 | GPIO33_I2C_SDA, | |
fd62999b MV |
72 | |
73 | /* PCMCIA */ | |
74 | MFP_CFG(GPIO59, AF7), /* PRST ; AF7 to tristate */ | |
75 | MFP_CFG(GPIO61, AF7), /* PCE1 ; AF7 to tristate */ | |
76 | MFP_CFG(GPIO60, AF7), /* PCE2 ; AF7 to tristate */ | |
77 | MFP_CFG(GPIO62, AF7), /* PCD ; AF7 to tristate */ | |
78 | MFP_CFG(GPIO56, AF7), /* PSKTSEL ; AF7 to tristate */ | |
79 | GPIO27_GPIO, /* RDnWR ; input/tristate */ | |
80 | GPIO50_GPIO, /* PREG ; input/tristate */ | |
81 | GPIO2_RDY, | |
82 | GPIO5_NPIOR, | |
83 | GPIO6_NPIOW, | |
84 | GPIO7_NPIOS16, | |
85 | GPIO8_NPWAIT, | |
86 | GPIO29_GPIO, /* PRDY (READY GPIO) */ | |
87 | GPIO57_GPIO, /* PPEN (POWER GPIO) */ | |
88 | GPIO81_GPIO, /* PCD (DETECT GPIO) */ | |
89 | GPIO77_GPIO, /* PRST (RESET GPIO) */ | |
90 | GPIO53_GPIO, /* PBVD1 */ | |
91 | GPIO79_GPIO, /* PBVD2 */ | |
92 | GPIO54_GPIO, /* POE */ | |
9b6956f4 MV |
93 | }; |
94 | #else | |
95 | static mfp_cfg_t colibri_pxa320_evalboard_pin_config[] __initdata = {}; | |
96 | #endif | |
97 | ||
bac07ecd DM |
98 | #if defined(CONFIG_AX88796) |
99 | #define COLIBRI_ETH_IRQ_GPIO mfp_to_gpio(GPIO36_GPIO) | |
bac07ecd DM |
100 | /* |
101 | * Asix AX88796 Ethernet | |
102 | */ | |
103 | static struct ax_plat_data colibri_asix_platdata = { | |
22a0200b DM |
104 | .flags = 0, /* defined later */ |
105 | .wordlength = 2, | |
bac07ecd DM |
106 | }; |
107 | ||
108 | static struct resource colibri_asix_resource[] = { | |
109 | [0] = { | |
110 | .start = PXA3xx_CS2_PHYS, | |
111 | .end = PXA3xx_CS2_PHYS + (0x20 * 2) - 1, | |
112 | .flags = IORESOURCE_MEM, | |
113 | }, | |
114 | [1] = { | |
4929f5a8 HZ |
115 | .start = PXA_GPIO_TO_IRQ(COLIBRI_ETH_IRQ_GPIO), |
116 | .end = PXA_GPIO_TO_IRQ(COLIBRI_ETH_IRQ_GPIO), | |
8a28b10e | 117 | .flags = IORESOURCE_IRQ | IRQF_TRIGGER_FALLING, |
bac07ecd DM |
118 | } |
119 | }; | |
120 | ||
121 | static struct platform_device asix_device = { | |
122 | .name = "ax88796", | |
123 | .id = 0, | |
124 | .num_resources = ARRAY_SIZE(colibri_asix_resource), | |
125 | .resource = colibri_asix_resource, | |
126 | .dev = { | |
127 | .platform_data = &colibri_asix_platdata | |
128 | } | |
129 | }; | |
130 | ||
131 | static mfp_cfg_t colibri_pxa320_eth_pin_config[] __initdata = { | |
132 | GPIO3_nCS2, /* AX88796 chip select */ | |
133 | GPIO36_GPIO | MFP_PULL_HIGH /* AX88796 IRQ */ | |
134 | }; | |
135 | ||
136 | static void __init colibri_pxa320_init_eth(void) | |
137 | { | |
22a0200b | 138 | colibri_pxa3xx_init_eth(&colibri_asix_platdata); |
bac07ecd | 139 | pxa3xx_mfp_config(ARRAY_AND_SIZE(colibri_pxa320_eth_pin_config)); |
bac07ecd DM |
140 | platform_device_register(&asix_device); |
141 | } | |
142 | #else | |
143 | static inline void __init colibri_pxa320_init_eth(void) {} | |
144 | #endif /* CONFIG_AX88796 */ | |
145 | ||
c0a39151 | 146 | #if defined(CONFIG_USB_PXA27X)||defined(CONFIG_USB_PXA27X_MODULE) |
11dd2d9a MV |
147 | static struct gpio_vbus_mach_info colibri_pxa320_gpio_vbus_info = { |
148 | .gpio_vbus = mfp_to_gpio(MFP_PIN_GPIO96), | |
149 | .gpio_pullup = -1, | |
150 | }; | |
151 | ||
152 | static struct platform_device colibri_pxa320_gpio_vbus = { | |
153 | .name = "gpio-vbus", | |
154 | .id = -1, | |
155 | .dev = { | |
156 | .platform_data = &colibri_pxa320_gpio_vbus_info, | |
157 | }, | |
158 | }; | |
159 | ||
160 | static void colibri_pxa320_udc_command(int cmd) | |
161 | { | |
162 | if (cmd == PXA2XX_UDC_CMD_CONNECT) | |
163 | UP2OCR = UP2OCR_HXOE | UP2OCR_DPPUE; | |
164 | else if (cmd == PXA2XX_UDC_CMD_DISCONNECT) | |
165 | UP2OCR = UP2OCR_HXOE; | |
166 | } | |
167 | ||
168 | static struct pxa2xx_udc_mach_info colibri_pxa320_udc_info __initdata = { | |
169 | .udc_command = colibri_pxa320_udc_command, | |
170 | .gpio_pullup = -1, | |
171 | }; | |
172 | ||
173 | static void __init colibri_pxa320_init_udc(void) | |
174 | { | |
175 | pxa_set_udc_info(&colibri_pxa320_udc_info); | |
176 | platform_device_register(&colibri_pxa320_gpio_vbus); | |
177 | } | |
178 | #else | |
179 | static inline void colibri_pxa320_init_udc(void) {} | |
180 | #endif | |
181 | ||
91fcfb90 DM |
182 | #if defined(CONFIG_FB_PXA) || defined(CONFIG_FB_PXA_MODULE) |
183 | static mfp_cfg_t colibri_pxa320_lcd_pin_config[] __initdata = { | |
184 | GPIO6_2_LCD_LDD_0, | |
185 | GPIO7_2_LCD_LDD_1, | |
186 | GPIO8_2_LCD_LDD_2, | |
187 | GPIO9_2_LCD_LDD_3, | |
188 | GPIO10_2_LCD_LDD_4, | |
189 | GPIO11_2_LCD_LDD_5, | |
190 | GPIO12_2_LCD_LDD_6, | |
191 | GPIO13_2_LCD_LDD_7, | |
192 | GPIO63_LCD_LDD_8, | |
193 | GPIO64_LCD_LDD_9, | |
194 | GPIO65_LCD_LDD_10, | |
195 | GPIO66_LCD_LDD_11, | |
196 | GPIO67_LCD_LDD_12, | |
197 | GPIO68_LCD_LDD_13, | |
198 | GPIO69_LCD_LDD_14, | |
199 | GPIO70_LCD_LDD_15, | |
200 | GPIO71_LCD_LDD_16, | |
201 | GPIO72_LCD_LDD_17, | |
202 | GPIO73_LCD_CS_N, | |
203 | GPIO74_LCD_VSYNC, | |
204 | GPIO14_2_LCD_FCLK, | |
205 | GPIO15_2_LCD_LCLK, | |
206 | GPIO16_2_LCD_PCLK, | |
207 | GPIO17_2_LCD_BIAS, | |
208 | }; | |
209 | ||
210 | static void __init colibri_pxa320_init_lcd(void) | |
211 | { | |
212 | pxa3xx_mfp_config(ARRAY_AND_SIZE(colibri_pxa320_lcd_pin_config)); | |
213 | } | |
214 | #else | |
215 | static inline void colibri_pxa320_init_lcd(void) {} | |
216 | #endif | |
217 | ||
15f593cf MV |
218 | #if defined(CONFIG_SND_AC97_CODEC) || \ |
219 | defined(CONFIG_SND_AC97_CODEC_MODULE) | |
e2bb5bef DM |
220 | static mfp_cfg_t colibri_pxa320_ac97_pin_config[] __initdata = { |
221 | GPIO34_AC97_SYSCLK, | |
222 | GPIO35_AC97_SDATA_IN_0, | |
223 | GPIO37_AC97_SDATA_OUT, | |
224 | GPIO38_AC97_SYNC, | |
225 | GPIO39_AC97_BITCLK, | |
226 | GPIO40_AC97_nACRESET | |
227 | }; | |
228 | ||
229 | static inline void __init colibri_pxa320_init_ac97(void) | |
230 | { | |
231 | pxa3xx_mfp_config(ARRAY_AND_SIZE(colibri_pxa320_ac97_pin_config)); | |
232 | pxa_set_ac97_info(NULL); | |
233 | } | |
234 | #else | |
235 | static inline void colibri_pxa320_init_ac97(void) {} | |
236 | #endif | |
237 | ||
bac07ecd DM |
238 | void __init colibri_pxa320_init(void) |
239 | { | |
240 | colibri_pxa320_init_eth(); | |
53740df1 | 241 | colibri_pxa3xx_init_nand(); |
91fcfb90 | 242 | colibri_pxa320_init_lcd(); |
c9b78189 | 243 | colibri_pxa3xx_init_lcd(mfp_to_gpio(GPIO49_GPIO)); |
e2bb5bef | 244 | colibri_pxa320_init_ac97(); |
11dd2d9a | 245 | colibri_pxa320_init_udc(); |
9b6956f4 MV |
246 | |
247 | /* Evalboard init */ | |
248 | pxa3xx_mfp_config(ARRAY_AND_SIZE(colibri_pxa320_evalboard_pin_config)); | |
a3172e54 | 249 | colibri_evalboard_init(); |
bac07ecd DM |
250 | } |
251 | ||
252 | MACHINE_START(COLIBRI320, "Toradex Colibri PXA320") | |
7375aba6 | 253 | .atag_offset = 0x100, |
bac07ecd | 254 | .init_machine = colibri_pxa320_init, |
851982c1 | 255 | .map_io = pxa3xx_map_io, |
4e611091 | 256 | .nr_irqs = PXA_NR_IRQS, |
bac07ecd | 257 | .init_irq = pxa3xx_init_irq, |
8a97ae2f | 258 | .handle_irq = pxa3xx_handle_irq, |
6bb27d73 | 259 | .init_time = pxa_timer_init, |
271a74fc | 260 | .restart = pxa_restart, |
bac07ecd DM |
261 | MACHINE_END |
262 |