colibri-pxa270.c 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272
  1. /*
  2. * linux/arch/arm/mach-pxa/colibri-pxa270.c
  3. *
  4. * Support for Toradex PXA270 based Colibri module
  5. * Daniel Mack <daniel@caiaq.de>
  6. * Marek Vasut <marek.vasut@gmail.com>
  7. *
  8. * This program is free software; you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License version 2 as
  10. * published by the Free Software Foundation.
  11. */
  12. #include <linux/init.h>
  13. #include <linux/kernel.h>
  14. #include <linux/platform_device.h>
  15. #include <linux/sysdev.h>
  16. #include <linux/interrupt.h>
  17. #include <linux/bitops.h>
  18. #include <linux/ioport.h>
  19. #include <linux/delay.h>
  20. #include <linux/mtd/mtd.h>
  21. #include <linux/mtd/partitions.h>
  22. #include <linux/mtd/physmap.h>
  23. #include <linux/gpio.h>
  24. #include <linux/ucb1400.h>
  25. #include <asm/mach-types.h>
  26. #include <mach/hardware.h>
  27. #include <asm/irq.h>
  28. #include <asm/sizes.h>
  29. #include <asm/mach/arch.h>
  30. #include <asm/mach/map.h>
  31. #include <asm/mach/irq.h>
  32. #include <asm/mach/flash.h>
  33. #include <mach/audio.h>
  34. #include <mach/pxa27x.h>
  35. #include <mach/colibri.h>
  36. #include <mach/mmc.h>
  37. #include <mach/ohci.h>
  38. #include <mach/pxa27x-udc.h>
  39. #include "generic.h"
  40. #include "devices.h"
  41. /******************************************************************************
  42. * Pin configuration
  43. ******************************************************************************/
  44. static mfp_cfg_t colibri_pxa270_pin_config[] __initdata = {
  45. /* Ethernet */
  46. GPIO78_nCS_2, /* Ethernet CS */
  47. GPIO114_GPIO, /* Ethernet IRQ */
  48. /* MMC */
  49. GPIO32_MMC_CLK,
  50. GPIO92_MMC_DAT_0,
  51. GPIO109_MMC_DAT_1,
  52. GPIO110_MMC_DAT_2,
  53. GPIO111_MMC_DAT_3,
  54. GPIO112_MMC_CMD,
  55. GPIO0_GPIO, /* SD detect */
  56. /* FFUART */
  57. GPIO39_FFUART_TXD,
  58. GPIO34_FFUART_RXD,
  59. /* UHC */
  60. GPIO88_USBH1_PWR,
  61. GPIO89_USBH1_PEN,
  62. GPIO119_USBH2_PWR,
  63. GPIO120_USBH2_PEN,
  64. /* AC97 */
  65. GPIO28_AC97_BITCLK,
  66. GPIO29_AC97_SDATA_IN_0,
  67. GPIO30_AC97_SDATA_OUT,
  68. GPIO31_AC97_SYNC,
  69. GPIO95_AC97_nRESET,
  70. GPIO98_AC97_SYSCLK,
  71. GPIO113_GPIO, /* Touchscreen IRQ */
  72. };
  73. /******************************************************************************
  74. * NOR Flash
  75. ******************************************************************************/
  76. #if defined(CONFIG_MTD_PHYSMAP) || defined(CONFIG_MTD_PHYSMAP_MODULE)
  77. static struct mtd_partition colibri_partitions[] = {
  78. {
  79. .name = "Bootloader",
  80. .offset = 0x00000000,
  81. .size = 0x00040000,
  82. .mask_flags = MTD_WRITEABLE /* force read-only */
  83. }, {
  84. .name = "Kernel",
  85. .offset = 0x00040000,
  86. .size = 0x00400000,
  87. .mask_flags = 0
  88. }, {
  89. .name = "Rootfs",
  90. .offset = 0x00440000,
  91. .size = MTDPART_SIZ_FULL,
  92. .mask_flags = 0
  93. }
  94. };
  95. static struct physmap_flash_data colibri_flash_data[] = {
  96. {
  97. .width = 4, /* bankwidth in bytes */
  98. .parts = colibri_partitions,
  99. .nr_parts = ARRAY_SIZE(colibri_partitions)
  100. }
  101. };
  102. static struct resource colibri_pxa270_flash_resource = {
  103. .start = PXA_CS0_PHYS,
  104. .end = PXA_CS0_PHYS + SZ_32M - 1,
  105. .flags = IORESOURCE_MEM,
  106. };
  107. static struct platform_device colibri_pxa270_flash_device = {
  108. .name = "physmap-flash",
  109. .id = 0,
  110. .dev = {
  111. .platform_data = colibri_flash_data,
  112. },
  113. .resource = &colibri_pxa270_flash_resource,
  114. .num_resources = 1,
  115. };
  116. static void __init colibri_pxa270_nor_init(void)
  117. {
  118. platform_device_register(&colibri_pxa270_flash_device);
  119. }
  120. #else
  121. static inline void colibri_pxa270_nor_init(void) {}
  122. #endif
  123. /******************************************************************************
  124. * Ethernet
  125. ******************************************************************************/
  126. #if defined(CONFIG_DM9000) || defined(CONFIG_DM9000_MODULE)
  127. static struct resource colibri_pxa270_dm9000_resources[] = {
  128. [0] = {
  129. .start = PXA_CS2_PHYS,
  130. .end = PXA_CS2_PHYS + 3,
  131. .flags = IORESOURCE_MEM,
  132. },
  133. [1] = {
  134. .start = PXA_CS2_PHYS + 4,
  135. .end = PXA_CS2_PHYS + 4 + 500,
  136. .flags = IORESOURCE_MEM,
  137. },
  138. [2] = {
  139. .start = gpio_to_irq(GPIO114_COLIBRI_PXA270_ETH_IRQ),
  140. .end = gpio_to_irq(GPIO114_COLIBRI_PXA270_ETH_IRQ),
  141. .flags = IORESOURCE_IRQ | IRQF_TRIGGER_RISING,
  142. },
  143. };
  144. static struct platform_device colibri_pxa270_dm9000_device = {
  145. .name = "dm9000",
  146. .id = -1,
  147. .num_resources = ARRAY_SIZE(colibri_pxa270_dm9000_resources),
  148. .resource = colibri_pxa270_dm9000_resources,
  149. };
  150. static void __init colibri_pxa270_eth_init(void)
  151. {
  152. platform_device_register(&colibri_pxa270_dm9000_device);
  153. }
  154. #else
  155. static inline void colibri_pxa270_eth_init(void) {}
  156. #endif
  157. /******************************************************************************
  158. * SD/MMC card controller
  159. ******************************************************************************/
  160. #if defined(CONFIG_MMC_PXA) || defined(CONFIG_MMC_PXA_MODULE)
  161. static struct pxamci_platform_data colibri_pxa270_mci_platform_data = {
  162. .ocr_mask = MMC_VDD_32_33 | MMC_VDD_33_34,
  163. .gpio_power = -1,
  164. .gpio_card_detect = GPIO0_COLIBRI_PXA270_SD_DETECT,
  165. .gpio_card_ro = -1,
  166. .detect_delay_ms = 200,
  167. };
  168. static void __init colibri_pxa270_mmc_init(void)
  169. {
  170. pxa_set_mci_info(&colibri_pxa270_mci_platform_data);
  171. }
  172. #else
  173. static inline void colibri_pxa270_mmc_init(void) {}
  174. #endif
  175. /******************************************************************************
  176. * USB Host
  177. ******************************************************************************/
  178. #if defined(CONFIG_USB_OHCI_HCD) || defined(CONFIG_USB_OHCI_HCD_MODULE)
  179. static int colibri_pxa270_ohci_init(struct device *dev)
  180. {
  181. UP2OCR = UP2OCR_HXS | UP2OCR_HXOE | UP2OCR_DPPDE | UP2OCR_DMPDE;
  182. return 0;
  183. }
  184. static struct pxaohci_platform_data colibri_pxa270_ohci_info = {
  185. .port_mode = PMM_PERPORT_MODE,
  186. .flags = ENABLE_PORT1 | ENABLE_PORT2 |
  187. POWER_CONTROL_LOW | POWER_SENSE_LOW,
  188. .init = colibri_pxa270_ohci_init,
  189. };
  190. static void __init colibri_pxa270_uhc_init(void)
  191. {
  192. pxa_set_ohci_info(&colibri_pxa270_ohci_info);
  193. }
  194. #else
  195. static inline void colibri_pxa270_uhc_init(void) {}
  196. #endif
  197. /******************************************************************************
  198. * Audio and Touchscreen
  199. ******************************************************************************/
  200. #if defined(CONFIG_TOUCHSCREEN_UCB1400) || \
  201. defined(CONFIG_TOUCHSCREEN_UCB1400_MODULE)
  202. static pxa2xx_audio_ops_t colibri_pxa270_ac97_pdata = {
  203. .reset_gpio = 95,
  204. };
  205. static struct ucb1400_pdata colibri_pxa270_ucb1400_pdata = {
  206. .irq = gpio_to_irq(GPIO113_COLIBRI_PXA270_TS_IRQ),
  207. };
  208. static struct platform_device colibri_pxa270_ucb1400_device = {
  209. .name = "ucb1400_core",
  210. .id = -1,
  211. .dev = {
  212. .platform_data = &colibri_pxa270_ucb1400_pdata,
  213. },
  214. };
  215. static void __init colibri_pxa270_tsc_init(void)
  216. {
  217. pxa_set_ac97_info(&colibri_pxa270_ac97_pdata);
  218. platform_device_register(&colibri_pxa270_ucb1400_device);
  219. }
  220. #else
  221. static inline void colibri_pxa270_tsc_init(void) {}
  222. #endif
  223. static void __init colibri_pxa270_init(void)
  224. {
  225. pxa2xx_mfp_config(ARRAY_AND_SIZE(colibri_pxa270_pin_config));
  226. pxa_set_ffuart_info(NULL);
  227. pxa_set_btuart_info(NULL);
  228. pxa_set_stuart_info(NULL);
  229. colibri_pxa270_nor_init();
  230. colibri_pxa270_eth_init();
  231. colibri_pxa270_mmc_init();
  232. colibri_pxa270_uhc_init();
  233. colibri_pxa270_tsc_init();
  234. }
  235. MACHINE_START(COLIBRI, "Toradex Colibri PXA270")
  236. .phys_io = 0x40000000,
  237. .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc,
  238. .boot_params = COLIBRI_SDRAM_BASE + 0x100,
  239. .init_machine = colibri_pxa270_init,
  240. .map_io = pxa_map_io,
  241. .init_irq = pxa27x_init_irq,
  242. .timer = &pxa_timer,
  243. MACHINE_END