colibri-pxa320.c 6.5 KB

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