colibri-pxa320.c 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238
  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. #ifdef CONFIG_MACH_COLIBRI_PXA270_EVALBOARD
  34. static mfp_cfg_t colibri_pxa320_evalboard_pin_config[] __initdata = {
  35. /* MMC */
  36. GPIO22_MMC1_CLK,
  37. GPIO23_MMC1_CMD,
  38. GPIO18_MMC1_DAT0,
  39. GPIO19_MMC1_DAT1,
  40. GPIO20_MMC1_DAT2,
  41. GPIO21_MMC1_DAT3,
  42. GPIO28_GPIO, /* SD detect */
  43. /* UART 1 configuration (may be set by bootloader) */
  44. GPIO99_UART1_CTS,
  45. GPIO104_UART1_RTS,
  46. GPIO97_UART1_RXD,
  47. GPIO98_UART1_TXD,
  48. GPIO101_UART1_DTR,
  49. GPIO103_UART1_DSR,
  50. GPIO100_UART1_DCD,
  51. GPIO102_UART1_RI,
  52. /* UART 2 configuration */
  53. GPIO109_UART2_CTS,
  54. GPIO112_UART2_RTS,
  55. GPIO110_UART2_RXD,
  56. GPIO111_UART2_TXD,
  57. /* UART 3 configuration */
  58. GPIO30_UART3_RXD,
  59. GPIO31_UART3_TXD,
  60. /* UHC */
  61. GPIO2_2_USBH_PEN,
  62. GPIO3_2_USBH_PWR,
  63. };
  64. #else
  65. static mfp_cfg_t colibri_pxa320_evalboard_pin_config[] __initdata = {};
  66. #endif
  67. #if defined(CONFIG_AX88796)
  68. #define COLIBRI_ETH_IRQ_GPIO mfp_to_gpio(GPIO36_GPIO)
  69. /*
  70. * Asix AX88796 Ethernet
  71. */
  72. static struct ax_plat_data colibri_asix_platdata = {
  73. .flags = 0, /* defined later */
  74. .wordlength = 2,
  75. };
  76. static struct resource colibri_asix_resource[] = {
  77. [0] = {
  78. .start = PXA3xx_CS2_PHYS,
  79. .end = PXA3xx_CS2_PHYS + (0x20 * 2) - 1,
  80. .flags = IORESOURCE_MEM,
  81. },
  82. [1] = {
  83. .start = gpio_to_irq(COLIBRI_ETH_IRQ_GPIO),
  84. .end = gpio_to_irq(COLIBRI_ETH_IRQ_GPIO),
  85. .flags = IORESOURCE_IRQ | IRQF_TRIGGER_FALLING,
  86. }
  87. };
  88. static struct platform_device asix_device = {
  89. .name = "ax88796",
  90. .id = 0,
  91. .num_resources = ARRAY_SIZE(colibri_asix_resource),
  92. .resource = colibri_asix_resource,
  93. .dev = {
  94. .platform_data = &colibri_asix_platdata
  95. }
  96. };
  97. static mfp_cfg_t colibri_pxa320_eth_pin_config[] __initdata = {
  98. GPIO3_nCS2, /* AX88796 chip select */
  99. GPIO36_GPIO | MFP_PULL_HIGH /* AX88796 IRQ */
  100. };
  101. static void __init colibri_pxa320_init_eth(void)
  102. {
  103. colibri_pxa3xx_init_eth(&colibri_asix_platdata);
  104. pxa3xx_mfp_config(ARRAY_AND_SIZE(colibri_pxa320_eth_pin_config));
  105. platform_device_register(&asix_device);
  106. }
  107. #else
  108. static inline void __init colibri_pxa320_init_eth(void) {}
  109. #endif /* CONFIG_AX88796 */
  110. #if defined(CONFIG_USB_GADGET_PXA27X)||defined(CONFIG_USB_GADGET_PXA27X_MODULE)
  111. static struct gpio_vbus_mach_info colibri_pxa320_gpio_vbus_info = {
  112. .gpio_vbus = mfp_to_gpio(MFP_PIN_GPIO96),
  113. .gpio_pullup = -1,
  114. };
  115. static struct platform_device colibri_pxa320_gpio_vbus = {
  116. .name = "gpio-vbus",
  117. .id = -1,
  118. .dev = {
  119. .platform_data = &colibri_pxa320_gpio_vbus_info,
  120. },
  121. };
  122. static void colibri_pxa320_udc_command(int cmd)
  123. {
  124. if (cmd == PXA2XX_UDC_CMD_CONNECT)
  125. UP2OCR = UP2OCR_HXOE | UP2OCR_DPPUE;
  126. else if (cmd == PXA2XX_UDC_CMD_DISCONNECT)
  127. UP2OCR = UP2OCR_HXOE;
  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. static void __init colibri_pxa320_init_udc(void)
  134. {
  135. pxa_set_udc_info(&colibri_pxa320_udc_info);
  136. platform_device_register(&colibri_pxa320_gpio_vbus);
  137. }
  138. #else
  139. static inline void colibri_pxa320_init_udc(void) {}
  140. #endif
  141. #if defined(CONFIG_FB_PXA) || defined(CONFIG_FB_PXA_MODULE)
  142. static mfp_cfg_t colibri_pxa320_lcd_pin_config[] __initdata = {
  143. GPIO6_2_LCD_LDD_0,
  144. GPIO7_2_LCD_LDD_1,
  145. GPIO8_2_LCD_LDD_2,
  146. GPIO9_2_LCD_LDD_3,
  147. GPIO10_2_LCD_LDD_4,
  148. GPIO11_2_LCD_LDD_5,
  149. GPIO12_2_LCD_LDD_6,
  150. GPIO13_2_LCD_LDD_7,
  151. GPIO63_LCD_LDD_8,
  152. GPIO64_LCD_LDD_9,
  153. GPIO65_LCD_LDD_10,
  154. GPIO66_LCD_LDD_11,
  155. GPIO67_LCD_LDD_12,
  156. GPIO68_LCD_LDD_13,
  157. GPIO69_LCD_LDD_14,
  158. GPIO70_LCD_LDD_15,
  159. GPIO71_LCD_LDD_16,
  160. GPIO72_LCD_LDD_17,
  161. GPIO73_LCD_CS_N,
  162. GPIO74_LCD_VSYNC,
  163. GPIO14_2_LCD_FCLK,
  164. GPIO15_2_LCD_LCLK,
  165. GPIO16_2_LCD_PCLK,
  166. GPIO17_2_LCD_BIAS,
  167. };
  168. static void __init colibri_pxa320_init_lcd(void)
  169. {
  170. pxa3xx_mfp_config(ARRAY_AND_SIZE(colibri_pxa320_lcd_pin_config));
  171. }
  172. #else
  173. static inline void colibri_pxa320_init_lcd(void) {}
  174. #endif
  175. #if defined(CONFIG_SND_AC97_CODEC) || \
  176. defined(CONFIG_SND_AC97_CODEC_MODULE)
  177. static mfp_cfg_t colibri_pxa320_ac97_pin_config[] __initdata = {
  178. GPIO34_AC97_SYSCLK,
  179. GPIO35_AC97_SDATA_IN_0,
  180. GPIO37_AC97_SDATA_OUT,
  181. GPIO38_AC97_SYNC,
  182. GPIO39_AC97_BITCLK,
  183. GPIO40_AC97_nACRESET
  184. };
  185. static inline void __init colibri_pxa320_init_ac97(void)
  186. {
  187. pxa3xx_mfp_config(ARRAY_AND_SIZE(colibri_pxa320_ac97_pin_config));
  188. pxa_set_ac97_info(NULL);
  189. }
  190. #else
  191. static inline void colibri_pxa320_init_ac97(void) {}
  192. #endif
  193. void __init colibri_pxa320_init(void)
  194. {
  195. colibri_pxa320_init_eth();
  196. colibri_pxa3xx_init_nand();
  197. colibri_pxa320_init_lcd();
  198. colibri_pxa3xx_init_lcd(mfp_to_gpio(GPIO49_GPIO));
  199. colibri_pxa320_init_ac97();
  200. colibri_pxa320_init_udc();
  201. /* Evalboard init */
  202. pxa3xx_mfp_config(ARRAY_AND_SIZE(colibri_pxa320_evalboard_pin_config));
  203. colibri_pxa270_evalboard_init();
  204. }
  205. MACHINE_START(COLIBRI320, "Toradex Colibri PXA320")
  206. .boot_params = COLIBRI_SDRAM_BASE + 0x100,
  207. .init_machine = colibri_pxa320_init,
  208. .map_io = pxa3xx_map_io,
  209. .init_irq = pxa3xx_init_irq,
  210. .timer = &pxa_timer,
  211. MACHINE_END