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 | |
| 26 | #include <mach/pxa3xx-regs.h> |
| 27 | #include <mach/mfp-pxa320.h> |
| 28 | #include <mach/colibri.h> |
Daniel Mack | 91fcfb9 | 2009-03-23 02:04:19 +0100 | [diff] [blame] | 29 | #include <mach/pxafb.h> |
Daniel Mack | bac07ec | 2009-03-23 02:04:18 +0100 | [diff] [blame] | 30 | #include <mach/ohci.h> |
Marek Vasut | 15f593c | 2009-11-08 03:05:11 +0100 | [diff] [blame] | 31 | #include <mach/audio.h> |
Marek Vasut | 11dd2d9 | 2010-06-24 16:02:10 +0200 | [diff] [blame] | 32 | #include <mach/pxa27x-udc.h> |
| 33 | #include <mach/udc.h> |
Daniel Mack | bac07ec | 2009-03-23 02:04:18 +0100 | [diff] [blame] | 34 | |
| 35 | #include "generic.h" |
| 36 | #include "devices.h" |
| 37 | |
| 38 | #if defined(CONFIG_AX88796) |
| 39 | #define COLIBRI_ETH_IRQ_GPIO mfp_to_gpio(GPIO36_GPIO) |
| 40 | |
| 41 | /* |
| 42 | * Asix AX88796 Ethernet |
| 43 | */ |
| 44 | static struct ax_plat_data colibri_asix_platdata = { |
Daniel Mack | 22a0200 | 2009-04-02 08:33:14 +0200 | [diff] [blame] | 45 | .flags = 0, /* defined later */ |
| 46 | .wordlength = 2, |
Daniel Mack | bac07ec | 2009-03-23 02:04:18 +0100 | [diff] [blame] | 47 | }; |
| 48 | |
| 49 | static struct resource colibri_asix_resource[] = { |
| 50 | [0] = { |
| 51 | .start = PXA3xx_CS2_PHYS, |
| 52 | .end = PXA3xx_CS2_PHYS + (0x20 * 2) - 1, |
| 53 | .flags = IORESOURCE_MEM, |
| 54 | }, |
| 55 | [1] = { |
| 56 | .start = gpio_to_irq(COLIBRI_ETH_IRQ_GPIO), |
| 57 | .end = gpio_to_irq(COLIBRI_ETH_IRQ_GPIO), |
Daniel Mack | 8a28b10 | 2009-04-02 08:33:15 +0200 | [diff] [blame] | 58 | .flags = IORESOURCE_IRQ | IRQF_TRIGGER_FALLING, |
Daniel Mack | bac07ec | 2009-03-23 02:04:18 +0100 | [diff] [blame] | 59 | } |
| 60 | }; |
| 61 | |
| 62 | static struct platform_device asix_device = { |
| 63 | .name = "ax88796", |
| 64 | .id = 0, |
| 65 | .num_resources = ARRAY_SIZE(colibri_asix_resource), |
| 66 | .resource = colibri_asix_resource, |
| 67 | .dev = { |
| 68 | .platform_data = &colibri_asix_platdata |
| 69 | } |
| 70 | }; |
| 71 | |
| 72 | static mfp_cfg_t colibri_pxa320_eth_pin_config[] __initdata = { |
| 73 | GPIO3_nCS2, /* AX88796 chip select */ |
| 74 | GPIO36_GPIO | MFP_PULL_HIGH /* AX88796 IRQ */ |
| 75 | }; |
| 76 | |
| 77 | static void __init colibri_pxa320_init_eth(void) |
| 78 | { |
Daniel Mack | 22a0200 | 2009-04-02 08:33:14 +0200 | [diff] [blame] | 79 | colibri_pxa3xx_init_eth(&colibri_asix_platdata); |
Daniel Mack | bac07ec | 2009-03-23 02:04:18 +0100 | [diff] [blame] | 80 | pxa3xx_mfp_config(ARRAY_AND_SIZE(colibri_pxa320_eth_pin_config)); |
Daniel Mack | bac07ec | 2009-03-23 02:04:18 +0100 | [diff] [blame] | 81 | platform_device_register(&asix_device); |
| 82 | } |
| 83 | #else |
| 84 | static inline void __init colibri_pxa320_init_eth(void) {} |
| 85 | #endif /* CONFIG_AX88796 */ |
| 86 | |
| 87 | #if defined(CONFIG_USB_OHCI_HCD) || defined(CONFIG_USB_OHCI_HCD_MODULE) |
| 88 | static mfp_cfg_t colibri_pxa320_usb_pin_config[] __initdata = { |
| 89 | GPIO2_2_USBH_PEN, |
| 90 | GPIO3_2_USBH_PWR, |
| 91 | }; |
| 92 | |
| 93 | static struct pxaohci_platform_data colibri_pxa320_ohci_info = { |
| 94 | .port_mode = PMM_GLOBAL_MODE, |
| 95 | .flags = ENABLE_PORT1 | POWER_CONTROL_LOW | POWER_SENSE_LOW, |
| 96 | }; |
| 97 | |
| 98 | void __init colibri_pxa320_init_ohci(void) |
| 99 | { |
| 100 | pxa3xx_mfp_config(ARRAY_AND_SIZE(colibri_pxa320_usb_pin_config)); |
| 101 | pxa_set_ohci_info(&colibri_pxa320_ohci_info); |
| 102 | } |
| 103 | #else |
| 104 | static inline void colibri_pxa320_init_ohci(void) {} |
| 105 | #endif /* CONFIG_USB_OHCI_HCD || CONFIG_USB_OHCI_HCD_MODULE */ |
| 106 | |
Marek Vasut | 11dd2d9 | 2010-06-24 16:02:10 +0200 | [diff] [blame] | 107 | #if defined(CONFIG_USB_GADGET_PXA27X)||defined(CONFIG_USB_GADGET_PXA27X_MODULE) |
| 108 | static struct gpio_vbus_mach_info colibri_pxa320_gpio_vbus_info = { |
| 109 | .gpio_vbus = mfp_to_gpio(MFP_PIN_GPIO96), |
| 110 | .gpio_pullup = -1, |
| 111 | }; |
| 112 | |
| 113 | static struct platform_device colibri_pxa320_gpio_vbus = { |
| 114 | .name = "gpio-vbus", |
| 115 | .id = -1, |
| 116 | .dev = { |
| 117 | .platform_data = &colibri_pxa320_gpio_vbus_info, |
| 118 | }, |
| 119 | }; |
| 120 | |
| 121 | static void colibri_pxa320_udc_command(int cmd) |
| 122 | { |
| 123 | if (cmd == PXA2XX_UDC_CMD_CONNECT) |
| 124 | UP2OCR = UP2OCR_HXOE | UP2OCR_DPPUE; |
| 125 | else if (cmd == PXA2XX_UDC_CMD_DISCONNECT) |
| 126 | UP2OCR = UP2OCR_HXOE; |
| 127 | } |
| 128 | |
| 129 | static struct pxa2xx_udc_mach_info colibri_pxa320_udc_info __initdata = { |
| 130 | .udc_command = colibri_pxa320_udc_command, |
| 131 | .gpio_pullup = -1, |
| 132 | }; |
| 133 | |
| 134 | static void __init colibri_pxa320_init_udc(void) |
| 135 | { |
| 136 | pxa_set_udc_info(&colibri_pxa320_udc_info); |
| 137 | platform_device_register(&colibri_pxa320_gpio_vbus); |
| 138 | } |
| 139 | #else |
| 140 | static inline void colibri_pxa320_init_udc(void) {} |
| 141 | #endif |
| 142 | |
Daniel Mack | bac07ec | 2009-03-23 02:04:18 +0100 | [diff] [blame] | 143 | static mfp_cfg_t colibri_pxa320_mmc_pin_config[] __initdata = { |
| 144 | GPIO22_MMC1_CLK, |
| 145 | GPIO23_MMC1_CMD, |
| 146 | GPIO18_MMC1_DAT0, |
| 147 | GPIO19_MMC1_DAT1, |
| 148 | GPIO20_MMC1_DAT2, |
| 149 | GPIO21_MMC1_DAT3 |
| 150 | }; |
| 151 | |
Daniel Mack | 91fcfb9 | 2009-03-23 02:04:19 +0100 | [diff] [blame] | 152 | #if defined(CONFIG_FB_PXA) || defined(CONFIG_FB_PXA_MODULE) |
| 153 | static mfp_cfg_t colibri_pxa320_lcd_pin_config[] __initdata = { |
| 154 | GPIO6_2_LCD_LDD_0, |
| 155 | GPIO7_2_LCD_LDD_1, |
| 156 | GPIO8_2_LCD_LDD_2, |
| 157 | GPIO9_2_LCD_LDD_3, |
| 158 | GPIO10_2_LCD_LDD_4, |
| 159 | GPIO11_2_LCD_LDD_5, |
| 160 | GPIO12_2_LCD_LDD_6, |
| 161 | GPIO13_2_LCD_LDD_7, |
| 162 | GPIO63_LCD_LDD_8, |
| 163 | GPIO64_LCD_LDD_9, |
| 164 | GPIO65_LCD_LDD_10, |
| 165 | GPIO66_LCD_LDD_11, |
| 166 | GPIO67_LCD_LDD_12, |
| 167 | GPIO68_LCD_LDD_13, |
| 168 | GPIO69_LCD_LDD_14, |
| 169 | GPIO70_LCD_LDD_15, |
| 170 | GPIO71_LCD_LDD_16, |
| 171 | GPIO72_LCD_LDD_17, |
| 172 | GPIO73_LCD_CS_N, |
| 173 | GPIO74_LCD_VSYNC, |
| 174 | GPIO14_2_LCD_FCLK, |
| 175 | GPIO15_2_LCD_LCLK, |
| 176 | GPIO16_2_LCD_PCLK, |
| 177 | GPIO17_2_LCD_BIAS, |
| 178 | }; |
| 179 | |
| 180 | static void __init colibri_pxa320_init_lcd(void) |
| 181 | { |
| 182 | pxa3xx_mfp_config(ARRAY_AND_SIZE(colibri_pxa320_lcd_pin_config)); |
| 183 | } |
| 184 | #else |
| 185 | static inline void colibri_pxa320_init_lcd(void) {} |
| 186 | #endif |
| 187 | |
Marek Vasut | 15f593c | 2009-11-08 03:05:11 +0100 | [diff] [blame] | 188 | #if defined(CONFIG_SND_AC97_CODEC) || \ |
| 189 | defined(CONFIG_SND_AC97_CODEC_MODULE) |
Daniel Mack | e2bb5be | 2009-03-23 02:04:20 +0100 | [diff] [blame] | 190 | static mfp_cfg_t colibri_pxa320_ac97_pin_config[] __initdata = { |
| 191 | GPIO34_AC97_SYSCLK, |
| 192 | GPIO35_AC97_SDATA_IN_0, |
| 193 | GPIO37_AC97_SDATA_OUT, |
| 194 | GPIO38_AC97_SYNC, |
| 195 | GPIO39_AC97_BITCLK, |
| 196 | GPIO40_AC97_nACRESET |
| 197 | }; |
| 198 | |
| 199 | static inline void __init colibri_pxa320_init_ac97(void) |
| 200 | { |
| 201 | pxa3xx_mfp_config(ARRAY_AND_SIZE(colibri_pxa320_ac97_pin_config)); |
| 202 | pxa_set_ac97_info(NULL); |
| 203 | } |
| 204 | #else |
| 205 | static inline void colibri_pxa320_init_ac97(void) {} |
| 206 | #endif |
| 207 | |
Alex Roman | ecc85e1 | 2009-07-03 14:58:59 +0800 | [diff] [blame] | 208 | /* |
| 209 | * The following configuration is verified to work with the Toradex Orchid |
| 210 | * carrier board |
| 211 | */ |
| 212 | static mfp_cfg_t colibri_pxa320_uart_pin_config[] __initdata = { |
| 213 | /* UART 1 configuration (may be set by bootloader) */ |
| 214 | GPIO99_UART1_CTS, |
| 215 | GPIO104_UART1_RTS, |
| 216 | GPIO97_UART1_RXD, |
| 217 | GPIO98_UART1_TXD, |
| 218 | GPIO101_UART1_DTR, |
| 219 | GPIO103_UART1_DSR, |
| 220 | GPIO100_UART1_DCD, |
| 221 | GPIO102_UART1_RI, |
| 222 | |
| 223 | /* UART 2 configuration */ |
| 224 | GPIO109_UART2_CTS, |
| 225 | GPIO112_UART2_RTS, |
| 226 | GPIO110_UART2_RXD, |
| 227 | GPIO111_UART2_TXD, |
| 228 | |
| 229 | /* UART 3 configuration */ |
| 230 | GPIO30_UART3_RXD, |
| 231 | GPIO31_UART3_TXD, |
| 232 | }; |
| 233 | |
| 234 | static void __init colibri_pxa320_init_uart(void) |
| 235 | { |
| 236 | pxa3xx_mfp_config(ARRAY_AND_SIZE(colibri_pxa320_uart_pin_config)); |
| 237 | } |
| 238 | |
Daniel Mack | bac07ec | 2009-03-23 02:04:18 +0100 | [diff] [blame] | 239 | void __init colibri_pxa320_init(void) |
| 240 | { |
Russell King | cc155c6 | 2009-11-09 13:34:08 +0800 | [diff] [blame] | 241 | pxa_set_ffuart_info(NULL); |
| 242 | pxa_set_btuart_info(NULL); |
| 243 | pxa_set_stuart_info(NULL); |
| 244 | |
Daniel Mack | bac07ec | 2009-03-23 02:04:18 +0100 | [diff] [blame] | 245 | colibri_pxa320_init_eth(); |
| 246 | colibri_pxa320_init_ohci(); |
Daniel Mack | 53740df | 2009-06-17 10:32:54 +0200 | [diff] [blame] | 247 | colibri_pxa3xx_init_nand(); |
Daniel Mack | 91fcfb9 | 2009-03-23 02:04:19 +0100 | [diff] [blame] | 248 | colibri_pxa320_init_lcd(); |
Daniel Mack | c9b7818 | 2009-03-27 22:00:09 +0100 | [diff] [blame] | 249 | colibri_pxa3xx_init_lcd(mfp_to_gpio(GPIO49_GPIO)); |
Daniel Mack | e2bb5be | 2009-03-23 02:04:20 +0100 | [diff] [blame] | 250 | colibri_pxa320_init_ac97(); |
Daniel Mack | bac07ec | 2009-03-23 02:04:18 +0100 | [diff] [blame] | 251 | colibri_pxa3xx_init_mmc(ARRAY_AND_SIZE(colibri_pxa320_mmc_pin_config), |
| 252 | mfp_to_gpio(MFP_PIN_GPIO28)); |
Alex Roman | ecc85e1 | 2009-07-03 14:58:59 +0800 | [diff] [blame] | 253 | colibri_pxa320_init_uart(); |
Marek Vasut | 11dd2d9 | 2010-06-24 16:02:10 +0200 | [diff] [blame] | 254 | colibri_pxa320_init_udc(); |
Daniel Mack | bac07ec | 2009-03-23 02:04:18 +0100 | [diff] [blame] | 255 | } |
| 256 | |
| 257 | MACHINE_START(COLIBRI320, "Toradex Colibri PXA320") |
Daniel Mack | bac07ec | 2009-03-23 02:04:18 +0100 | [diff] [blame] | 258 | .boot_params = COLIBRI_SDRAM_BASE + 0x100, |
| 259 | .init_machine = colibri_pxa320_init, |
Marek Vasut | 851982c | 2010-10-11 02:20:19 +0200 | [diff] [blame^] | 260 | .map_io = pxa3xx_map_io, |
Daniel Mack | bac07ec | 2009-03-23 02:04:18 +0100 | [diff] [blame] | 261 | .init_irq = pxa3xx_init_irq, |
| 262 | .timer = &pxa_timer, |
| 263 | MACHINE_END |
| 264 | |