Thomas Gleixner | d2912cb | 2019-06-04 10:11:33 +0200 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0-only |
Daniel Mack | bac07ec | 2009-03-23 02:04:18 +0100 | [diff] [blame] | 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> |
Daniel Mack | bac07ec | 2009-03-23 02:04:18 +0100 | [diff] [blame] | 9 | */ |
| 10 | |
| 11 | #include <linux/init.h> |
| 12 | #include <linux/kernel.h> |
| 13 | #include <linux/platform_device.h> |
Linus Walleij | fdabc46 | 2020-01-23 16:50:13 +0100 | [diff] [blame] | 14 | #include <linux/gpio/machine.h> |
Daniel Mack | bac07ec | 2009-03-23 02:04:18 +0100 | [diff] [blame] | 15 | #include <linux/gpio.h> |
Daniel Mack | 8a28b10 | 2009-04-02 08:33:15 +0200 | [diff] [blame] | 16 | #include <linux/interrupt.h> |
Daniel Mack | bac07ec | 2009-03-23 02:04:18 +0100 | [diff] [blame] | 17 | |
| 18 | #include <asm/mach-types.h> |
Masahiro Yamada | 87dfb31 | 2019-05-14 15:46:51 -0700 | [diff] [blame] | 19 | #include <linux/sizes.h> |
Daniel Mack | bac07ec | 2009-03-23 02:04:18 +0100 | [diff] [blame] | 20 | #include <asm/mach/arch.h> |
| 21 | #include <asm/mach/irq.h> |
| 22 | |
Arnd Bergmann | 4c25c5d | 2015-01-30 10:45:33 +0100 | [diff] [blame] | 23 | #include "pxa320.h" |
| 24 | #include "colibri.h" |
Arnd Bergmann | 293b2da | 2012-08-24 15:16:48 +0200 | [diff] [blame] | 25 | #include <linux/platform_data/video-pxafb.h> |
| 26 | #include <linux/platform_data/usb-ohci-pxa27x.h> |
Marek Vasut | 15f593c | 2009-11-08 03:05:11 +0100 | [diff] [blame] | 27 | #include <mach/audio.h> |
Arnd Bergmann | 4c25c5d | 2015-01-30 10:45:33 +0100 | [diff] [blame] | 28 | #include "pxa27x-udc.h" |
| 29 | #include "udc.h" |
Daniel Mack | bac07ec | 2009-03-23 02:04:18 +0100 | [diff] [blame] | 30 | |
| 31 | #include "generic.h" |
| 32 | #include "devices.h" |
| 33 | |
Marek Vasut | a3172e5 | 2010-08-12 01:45:05 +0200 | [diff] [blame] | 34 | #ifdef CONFIG_MACH_COLIBRI_EVALBOARD |
Marek Vasut | 9b6956f | 2010-08-12 01:18:38 +0200 | [diff] [blame] | 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, |
Marek Vasut | 072e1ae | 2010-08-12 01:30:39 +0200 | [diff] [blame] | 68 | |
| 69 | /* I2C */ |
| 70 | GPIO32_I2C_SCL, |
| 71 | GPIO33_I2C_SDA, |
Marek Vasut | fd62999 | 2010-08-11 05:04:53 +0200 | [diff] [blame] | 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 */ |
Marek Vasut | 9b6956f | 2010-08-12 01:18:38 +0200 | [diff] [blame] | 93 | }; |
| 94 | #else |
| 95 | static mfp_cfg_t colibri_pxa320_evalboard_pin_config[] __initdata = {}; |
| 96 | #endif |
| 97 | |
Daniel Mack | bac07ec | 2009-03-23 02:04:18 +0100 | [diff] [blame] | 98 | #if defined(CONFIG_AX88796) |
| 99 | #define COLIBRI_ETH_IRQ_GPIO mfp_to_gpio(GPIO36_GPIO) |
Daniel Mack | bac07ec | 2009-03-23 02:04:18 +0100 | [diff] [blame] | 100 | /* |
| 101 | * Asix AX88796 Ethernet |
| 102 | */ |
| 103 | static struct ax_plat_data colibri_asix_platdata = { |
Daniel Mack | 22a0200 | 2009-04-02 08:33:14 +0200 | [diff] [blame] | 104 | .flags = 0, /* defined later */ |
| 105 | .wordlength = 2, |
Daniel Mack | bac07ec | 2009-03-23 02:04:18 +0100 | [diff] [blame] | 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] = { |
Haojian Zhuang | 4929f5a | 2011-10-10 16:03:51 +0800 | [diff] [blame] | 115 | .start = PXA_GPIO_TO_IRQ(COLIBRI_ETH_IRQ_GPIO), |
| 116 | .end = PXA_GPIO_TO_IRQ(COLIBRI_ETH_IRQ_GPIO), |
Daniel Mack | 8a28b10 | 2009-04-02 08:33:15 +0200 | [diff] [blame] | 117 | .flags = IORESOURCE_IRQ | IRQF_TRIGGER_FALLING, |
Daniel Mack | bac07ec | 2009-03-23 02:04:18 +0100 | [diff] [blame] | 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 | { |
Daniel Mack | 22a0200 | 2009-04-02 08:33:14 +0200 | [diff] [blame] | 138 | colibri_pxa3xx_init_eth(&colibri_asix_platdata); |
Daniel Mack | bac07ec | 2009-03-23 02:04:18 +0100 | [diff] [blame] | 139 | pxa3xx_mfp_config(ARRAY_AND_SIZE(colibri_pxa320_eth_pin_config)); |
Daniel Mack | bac07ec | 2009-03-23 02:04:18 +0100 | [diff] [blame] | 140 | platform_device_register(&asix_device); |
| 141 | } |
| 142 | #else |
| 143 | static inline void __init colibri_pxa320_init_eth(void) {} |
| 144 | #endif /* CONFIG_AX88796 */ |
| 145 | |
Haojian Zhuang | c0a3915 | 2011-11-10 07:13:07 +0800 | [diff] [blame] | 146 | #if defined(CONFIG_USB_PXA27X)||defined(CONFIG_USB_PXA27X_MODULE) |
Linus Walleij | fdabc46 | 2020-01-23 16:50:13 +0100 | [diff] [blame] | 147 | static struct gpiod_lookup_table gpio_vbus_gpiod_table = { |
| 148 | .dev_id = "gpio-vbus", |
| 149 | .table = { |
| 150 | GPIO_LOOKUP("gpio-pxa", MFP_PIN_GPIO96, |
| 151 | "vbus", GPIO_ACTIVE_HIGH), |
| 152 | { }, |
| 153 | }, |
Marek Vasut | 11dd2d9 | 2010-06-24 16:02:10 +0200 | [diff] [blame] | 154 | }; |
| 155 | |
| 156 | static struct platform_device colibri_pxa320_gpio_vbus = { |
| 157 | .name = "gpio-vbus", |
| 158 | .id = -1, |
Marek Vasut | 11dd2d9 | 2010-06-24 16:02:10 +0200 | [diff] [blame] | 159 | }; |
| 160 | |
| 161 | static void colibri_pxa320_udc_command(int cmd) |
| 162 | { |
| 163 | if (cmd == PXA2XX_UDC_CMD_CONNECT) |
| 164 | UP2OCR = UP2OCR_HXOE | UP2OCR_DPPUE; |
| 165 | else if (cmd == PXA2XX_UDC_CMD_DISCONNECT) |
| 166 | UP2OCR = UP2OCR_HXOE; |
| 167 | } |
| 168 | |
| 169 | static struct pxa2xx_udc_mach_info colibri_pxa320_udc_info __initdata = { |
| 170 | .udc_command = colibri_pxa320_udc_command, |
| 171 | .gpio_pullup = -1, |
| 172 | }; |
| 173 | |
| 174 | static void __init colibri_pxa320_init_udc(void) |
| 175 | { |
| 176 | pxa_set_udc_info(&colibri_pxa320_udc_info); |
Linus Walleij | fdabc46 | 2020-01-23 16:50:13 +0100 | [diff] [blame] | 177 | gpiod_add_lookup_table(&gpio_vbus_gpiod_table); |
Marek Vasut | 11dd2d9 | 2010-06-24 16:02:10 +0200 | [diff] [blame] | 178 | platform_device_register(&colibri_pxa320_gpio_vbus); |
| 179 | } |
| 180 | #else |
| 181 | static inline void colibri_pxa320_init_udc(void) {} |
| 182 | #endif |
| 183 | |
Daniel Mack | 91fcfb9 | 2009-03-23 02:04:19 +0100 | [diff] [blame] | 184 | #if defined(CONFIG_FB_PXA) || defined(CONFIG_FB_PXA_MODULE) |
| 185 | static mfp_cfg_t colibri_pxa320_lcd_pin_config[] __initdata = { |
| 186 | GPIO6_2_LCD_LDD_0, |
| 187 | GPIO7_2_LCD_LDD_1, |
| 188 | GPIO8_2_LCD_LDD_2, |
| 189 | GPIO9_2_LCD_LDD_3, |
| 190 | GPIO10_2_LCD_LDD_4, |
| 191 | GPIO11_2_LCD_LDD_5, |
| 192 | GPIO12_2_LCD_LDD_6, |
| 193 | GPIO13_2_LCD_LDD_7, |
| 194 | GPIO63_LCD_LDD_8, |
| 195 | GPIO64_LCD_LDD_9, |
| 196 | GPIO65_LCD_LDD_10, |
| 197 | GPIO66_LCD_LDD_11, |
| 198 | GPIO67_LCD_LDD_12, |
| 199 | GPIO68_LCD_LDD_13, |
| 200 | GPIO69_LCD_LDD_14, |
| 201 | GPIO70_LCD_LDD_15, |
| 202 | GPIO71_LCD_LDD_16, |
| 203 | GPIO72_LCD_LDD_17, |
| 204 | GPIO73_LCD_CS_N, |
| 205 | GPIO74_LCD_VSYNC, |
| 206 | GPIO14_2_LCD_FCLK, |
| 207 | GPIO15_2_LCD_LCLK, |
| 208 | GPIO16_2_LCD_PCLK, |
| 209 | GPIO17_2_LCD_BIAS, |
| 210 | }; |
| 211 | |
| 212 | static void __init colibri_pxa320_init_lcd(void) |
| 213 | { |
| 214 | pxa3xx_mfp_config(ARRAY_AND_SIZE(colibri_pxa320_lcd_pin_config)); |
| 215 | } |
| 216 | #else |
| 217 | static inline void colibri_pxa320_init_lcd(void) {} |
| 218 | #endif |
| 219 | |
Marek Vasut | 15f593c | 2009-11-08 03:05:11 +0100 | [diff] [blame] | 220 | #if defined(CONFIG_SND_AC97_CODEC) || \ |
| 221 | defined(CONFIG_SND_AC97_CODEC_MODULE) |
Daniel Mack | e2bb5be | 2009-03-23 02:04:20 +0100 | [diff] [blame] | 222 | static mfp_cfg_t colibri_pxa320_ac97_pin_config[] __initdata = { |
| 223 | GPIO34_AC97_SYSCLK, |
| 224 | GPIO35_AC97_SDATA_IN_0, |
| 225 | GPIO37_AC97_SDATA_OUT, |
| 226 | GPIO38_AC97_SYNC, |
| 227 | GPIO39_AC97_BITCLK, |
| 228 | GPIO40_AC97_nACRESET |
| 229 | }; |
| 230 | |
| 231 | static inline void __init colibri_pxa320_init_ac97(void) |
| 232 | { |
| 233 | pxa3xx_mfp_config(ARRAY_AND_SIZE(colibri_pxa320_ac97_pin_config)); |
| 234 | pxa_set_ac97_info(NULL); |
| 235 | } |
| 236 | #else |
| 237 | static inline void colibri_pxa320_init_ac97(void) {} |
| 238 | #endif |
| 239 | |
Daniel Mack | bac07ec | 2009-03-23 02:04:18 +0100 | [diff] [blame] | 240 | void __init colibri_pxa320_init(void) |
| 241 | { |
| 242 | colibri_pxa320_init_eth(); |
Daniel Mack | 53740df | 2009-06-17 10:32:54 +0200 | [diff] [blame] | 243 | colibri_pxa3xx_init_nand(); |
Daniel Mack | 91fcfb9 | 2009-03-23 02:04:19 +0100 | [diff] [blame] | 244 | colibri_pxa320_init_lcd(); |
Daniel Mack | c9b7818 | 2009-03-27 22:00:09 +0100 | [diff] [blame] | 245 | colibri_pxa3xx_init_lcd(mfp_to_gpio(GPIO49_GPIO)); |
Daniel Mack | e2bb5be | 2009-03-23 02:04:20 +0100 | [diff] [blame] | 246 | colibri_pxa320_init_ac97(); |
Marek Vasut | 11dd2d9 | 2010-06-24 16:02:10 +0200 | [diff] [blame] | 247 | colibri_pxa320_init_udc(); |
Marek Vasut | 9b6956f | 2010-08-12 01:18:38 +0200 | [diff] [blame] | 248 | |
| 249 | /* Evalboard init */ |
| 250 | pxa3xx_mfp_config(ARRAY_AND_SIZE(colibri_pxa320_evalboard_pin_config)); |
Marek Vasut | a3172e5 | 2010-08-12 01:45:05 +0200 | [diff] [blame] | 251 | colibri_evalboard_init(); |
Daniel Mack | bac07ec | 2009-03-23 02:04:18 +0100 | [diff] [blame] | 252 | } |
| 253 | |
| 254 | MACHINE_START(COLIBRI320, "Toradex Colibri PXA320") |
Nicolas Pitre | 7375aba | 2011-07-05 22:38:15 -0400 | [diff] [blame] | 255 | .atag_offset = 0x100, |
Daniel Mack | bac07ec | 2009-03-23 02:04:18 +0100 | [diff] [blame] | 256 | .init_machine = colibri_pxa320_init, |
Marek Vasut | 851982c | 2010-10-11 02:20:19 +0200 | [diff] [blame] | 257 | .map_io = pxa3xx_map_io, |
Rob Herring | 4e61109 | 2012-01-03 16:53:48 -0600 | [diff] [blame] | 258 | .nr_irqs = PXA_NR_IRQS, |
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, |
Stephen Warren | 6bb27d7 | 2012-11-08 12:40:59 -0700 | [diff] [blame] | 261 | .init_time = pxa_timer_init, |
Russell King | 271a74f | 2011-11-04 14:15:53 +0000 | [diff] [blame] | 262 | .restart = pxa_restart, |
Daniel Mack | bac07ec | 2009-03-23 02:04:18 +0100 | [diff] [blame] | 263 | MACHINE_END |
| 264 | |