colibri-pxa320.c 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242
  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. /* I2C */
  64. GPIO32_I2C_SCL,
  65. GPIO33_I2C_SDA,
  66. };
  67. #else
  68. static mfp_cfg_t colibri_pxa320_evalboard_pin_config[] __initdata = {};
  69. #endif
  70. #if defined(CONFIG_AX88796)
  71. #define COLIBRI_ETH_IRQ_GPIO mfp_to_gpio(GPIO36_GPIO)
  72. /*
  73. * Asix AX88796 Ethernet
  74. */
  75. static struct ax_plat_data colibri_asix_platdata = {
  76. .flags = 0, /* defined later */
  77. .wordlength = 2,
  78. };
  79. static struct resource colibri_asix_resource[] = {
  80. [0] = {
  81. .start = PXA3xx_CS2_PHYS,
  82. .end = PXA3xx_CS2_PHYS + (0x20 * 2) - 1,
  83. .flags = IORESOURCE_MEM,
  84. },
  85. [1] = {
  86. .start = gpio_to_irq(COLIBRI_ETH_IRQ_GPIO),
  87. .end = gpio_to_irq(COLIBRI_ETH_IRQ_GPIO),
  88. .flags = IORESOURCE_IRQ | IRQF_TRIGGER_FALLING,
  89. }
  90. };
  91. static struct platform_device asix_device = {
  92. .name = "ax88796",
  93. .id = 0,
  94. .num_resources = ARRAY_SIZE(colibri_asix_resource),
  95. .resource = colibri_asix_resource,
  96. .dev = {
  97. .platform_data = &colibri_asix_platdata
  98. }
  99. };
  100. static mfp_cfg_t colibri_pxa320_eth_pin_config[] __initdata = {
  101. GPIO3_nCS2, /* AX88796 chip select */
  102. GPIO36_GPIO | MFP_PULL_HIGH /* AX88796 IRQ */
  103. };
  104. static void __init colibri_pxa320_init_eth(void)
  105. {
  106. colibri_pxa3xx_init_eth(&colibri_asix_platdata);
  107. pxa3xx_mfp_config(ARRAY_AND_SIZE(colibri_pxa320_eth_pin_config));
  108. platform_device_register(&asix_device);
  109. }
  110. #else
  111. static inline void __init colibri_pxa320_init_eth(void) {}
  112. #endif /* CONFIG_AX88796 */
  113. #if defined(CONFIG_USB_GADGET_PXA27X)||defined(CONFIG_USB_GADGET_PXA27X_MODULE)
  114. static struct gpio_vbus_mach_info colibri_pxa320_gpio_vbus_info = {
  115. .gpio_vbus = mfp_to_gpio(MFP_PIN_GPIO96),
  116. .gpio_pullup = -1,
  117. };
  118. static struct platform_device colibri_pxa320_gpio_vbus = {
  119. .name = "gpio-vbus",
  120. .id = -1,
  121. .dev = {
  122. .platform_data = &colibri_pxa320_gpio_vbus_info,
  123. },
  124. };
  125. static void colibri_pxa320_udc_command(int cmd)
  126. {
  127. if (cmd == PXA2XX_UDC_CMD_CONNECT)
  128. UP2OCR = UP2OCR_HXOE | UP2OCR_DPPUE;
  129. else if (cmd == PXA2XX_UDC_CMD_DISCONNECT)
  130. UP2OCR = UP2OCR_HXOE;
  131. }
  132. static struct pxa2xx_udc_mach_info colibri_pxa320_udc_info __initdata = {
  133. .udc_command = colibri_pxa320_udc_command,
  134. .gpio_pullup = -1,
  135. };
  136. static void __init colibri_pxa320_init_udc(void)
  137. {
  138. pxa_set_udc_info(&colibri_pxa320_udc_info);
  139. platform_device_register(&colibri_pxa320_gpio_vbus);
  140. }
  141. #else
  142. static inline void colibri_pxa320_init_udc(void) {}
  143. #endif
  144. #if defined(CONFIG_FB_PXA) || defined(CONFIG_FB_PXA_MODULE)
  145. static mfp_cfg_t colibri_pxa320_lcd_pin_config[] __initdata = {
  146. GPIO6_2_LCD_LDD_0,
  147. GPIO7_2_LCD_LDD_1,
  148. GPIO8_2_LCD_LDD_2,
  149. GPIO9_2_LCD_LDD_3,
  150. GPIO10_2_LCD_LDD_4,
  151. GPIO11_2_LCD_LDD_5,
  152. GPIO12_2_LCD_LDD_6,
  153. GPIO13_2_LCD_LDD_7,
  154. GPIO63_LCD_LDD_8,
  155. GPIO64_LCD_LDD_9,
  156. GPIO65_LCD_LDD_10,
  157. GPIO66_LCD_LDD_11,
  158. GPIO67_LCD_LDD_12,
  159. GPIO68_LCD_LDD_13,
  160. GPIO69_LCD_LDD_14,
  161. GPIO70_LCD_LDD_15,
  162. GPIO71_LCD_LDD_16,
  163. GPIO72_LCD_LDD_17,
  164. GPIO73_LCD_CS_N,
  165. GPIO74_LCD_VSYNC,
  166. GPIO14_2_LCD_FCLK,
  167. GPIO15_2_LCD_LCLK,
  168. GPIO16_2_LCD_PCLK,
  169. GPIO17_2_LCD_BIAS,
  170. };
  171. static void __init colibri_pxa320_init_lcd(void)
  172. {
  173. pxa3xx_mfp_config(ARRAY_AND_SIZE(colibri_pxa320_lcd_pin_config));
  174. }
  175. #else
  176. static inline void colibri_pxa320_init_lcd(void) {}
  177. #endif
  178. #if defined(CONFIG_SND_AC97_CODEC) || \
  179. defined(CONFIG_SND_AC97_CODEC_MODULE)
  180. static mfp_cfg_t colibri_pxa320_ac97_pin_config[] __initdata = {
  181. GPIO34_AC97_SYSCLK,
  182. GPIO35_AC97_SDATA_IN_0,
  183. GPIO37_AC97_SDATA_OUT,
  184. GPIO38_AC97_SYNC,
  185. GPIO39_AC97_BITCLK,
  186. GPIO40_AC97_nACRESET
  187. };
  188. static inline void __init colibri_pxa320_init_ac97(void)
  189. {
  190. pxa3xx_mfp_config(ARRAY_AND_SIZE(colibri_pxa320_ac97_pin_config));
  191. pxa_set_ac97_info(NULL);
  192. }
  193. #else
  194. static inline void colibri_pxa320_init_ac97(void) {}
  195. #endif
  196. void __init colibri_pxa320_init(void)
  197. {
  198. colibri_pxa320_init_eth();
  199. colibri_pxa3xx_init_nand();
  200. colibri_pxa320_init_lcd();
  201. colibri_pxa3xx_init_lcd(mfp_to_gpio(GPIO49_GPIO));
  202. colibri_pxa320_init_ac97();
  203. colibri_pxa320_init_udc();
  204. /* Evalboard init */
  205. pxa3xx_mfp_config(ARRAY_AND_SIZE(colibri_pxa320_evalboard_pin_config));
  206. colibri_pxa270_evalboard_init();
  207. }
  208. MACHINE_START(COLIBRI320, "Toradex Colibri PXA320")
  209. .boot_params = COLIBRI_SDRAM_BASE + 0x100,
  210. .init_machine = colibri_pxa320_init,
  211. .map_io = pxa3xx_map_io,
  212. .init_irq = pxa3xx_init_irq,
  213. .timer = &pxa_timer,
  214. MACHINE_END