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