colibri-pxa270.c 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324
  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/interrupt.h>
  14. #include <linux/kernel.h>
  15. #include <linux/mtd/mtd.h>
  16. #include <linux/mtd/partitions.h>
  17. #include <linux/mtd/physmap.h>
  18. #include <linux/platform_device.h>
  19. #include <linux/sysdev.h>
  20. #include <linux/ucb1400.h>
  21. #include <asm/mach/arch.h>
  22. #include <asm/mach/flash.h>
  23. #include <asm/mach-types.h>
  24. #include <asm/sizes.h>
  25. #include <mach/audio.h>
  26. #include <mach/colibri.h>
  27. #include <mach/pxa27x.h>
  28. #include "devices.h"
  29. #include "generic.h"
  30. /******************************************************************************
  31. * Evaluation board MFP
  32. ******************************************************************************/
  33. #ifdef CONFIG_MACH_COLIBRI_EVALBOARD
  34. static mfp_cfg_t colibri_pxa270_evalboard_pin_config[] __initdata = {
  35. /* MMC */
  36. GPIO32_MMC_CLK,
  37. GPIO92_MMC_DAT_0,
  38. GPIO109_MMC_DAT_1,
  39. GPIO110_MMC_DAT_2,
  40. GPIO111_MMC_DAT_3,
  41. GPIO112_MMC_CMD,
  42. GPIO0_GPIO, /* SD detect */
  43. /* FFUART */
  44. GPIO39_FFUART_TXD,
  45. GPIO34_FFUART_RXD,
  46. /* UHC */
  47. GPIO88_USBH1_PWR,
  48. GPIO89_USBH1_PEN,
  49. GPIO119_USBH2_PWR,
  50. GPIO120_USBH2_PEN,
  51. /* PCMCIA */
  52. GPIO85_nPCE_1,
  53. GPIO54_nPCE_2,
  54. GPIO55_nPREG,
  55. GPIO50_nPIOR,
  56. GPIO51_nPIOW,
  57. GPIO49_nPWE,
  58. GPIO48_nPOE,
  59. GPIO57_nIOIS16,
  60. GPIO56_nPWAIT,
  61. GPIO104_PSKTSEL,
  62. GPIO53_GPIO, /* RESET */
  63. GPIO83_GPIO, /* BVD1 */
  64. GPIO82_GPIO, /* BVD2 */
  65. GPIO1_GPIO, /* READY */
  66. GPIO84_GPIO, /* DETECT */
  67. GPIO107_GPIO, /* PPEN */
  68. /* I2C */
  69. GPIO117_I2C_SCL,
  70. GPIO118_I2C_SDA,
  71. };
  72. #else
  73. static mfp_cfg_t colibri_pxa270_evalboard_pin_config[] __initdata = {};
  74. #endif
  75. #ifdef CONFIG_MACH_COLIBRI_PXA270_INCOME
  76. static mfp_cfg_t income_pin_config[] __initdata = {
  77. /* MMC */
  78. GPIO32_MMC_CLK,
  79. GPIO92_MMC_DAT_0,
  80. GPIO109_MMC_DAT_1,
  81. GPIO110_MMC_DAT_2,
  82. GPIO111_MMC_DAT_3,
  83. GPIO112_MMC_CMD,
  84. GPIO0_GPIO, /* SD detect */
  85. GPIO1_GPIO, /* SD read-only */
  86. /* FFUART */
  87. GPIO39_FFUART_TXD,
  88. GPIO34_FFUART_RXD,
  89. /* BFUART */
  90. GPIO42_BTUART_RXD,
  91. GPIO43_BTUART_TXD,
  92. GPIO45_BTUART_RTS,
  93. /* STUART */
  94. GPIO46_STUART_RXD,
  95. GPIO47_STUART_TXD,
  96. /* UHC */
  97. GPIO88_USBH1_PWR,
  98. GPIO89_USBH1_PEN,
  99. /* LCD */
  100. GPIOxx_LCD_TFT_16BPP,
  101. /* PWM */
  102. GPIO16_PWM0_OUT,
  103. /* I2C */
  104. GPIO117_I2C_SCL,
  105. GPIO118_I2C_SDA,
  106. /* LED */
  107. GPIO54_GPIO, /* LED A */
  108. GPIO55_GPIO, /* LED B */
  109. };
  110. #else
  111. static mfp_cfg_t income_pin_config[] __initdata = {};
  112. #endif
  113. /******************************************************************************
  114. * Pin configuration
  115. ******************************************************************************/
  116. static mfp_cfg_t colibri_pxa270_pin_config[] __initdata = {
  117. /* Ethernet */
  118. GPIO78_nCS_2, /* Ethernet CS */
  119. GPIO114_GPIO, /* Ethernet IRQ */
  120. /* AC97 */
  121. GPIO28_AC97_BITCLK,
  122. GPIO29_AC97_SDATA_IN_0,
  123. GPIO30_AC97_SDATA_OUT,
  124. GPIO31_AC97_SYNC,
  125. GPIO95_AC97_nRESET,
  126. GPIO98_AC97_SYSCLK,
  127. GPIO113_GPIO, /* Touchscreen IRQ */
  128. };
  129. /******************************************************************************
  130. * NOR Flash
  131. ******************************************************************************/
  132. #if defined(CONFIG_MTD_PHYSMAP) || defined(CONFIG_MTD_PHYSMAP_MODULE)
  133. static struct mtd_partition colibri_partitions[] = {
  134. {
  135. .name = "Bootloader",
  136. .offset = 0x00000000,
  137. .size = 0x00040000,
  138. .mask_flags = MTD_WRITEABLE /* force read-only */
  139. }, {
  140. .name = "Kernel",
  141. .offset = 0x00040000,
  142. .size = 0x00400000,
  143. .mask_flags = 0
  144. }, {
  145. .name = "Rootfs",
  146. .offset = 0x00440000,
  147. .size = MTDPART_SIZ_FULL,
  148. .mask_flags = 0
  149. }
  150. };
  151. static struct physmap_flash_data colibri_flash_data[] = {
  152. {
  153. .width = 4, /* bankwidth in bytes */
  154. .parts = colibri_partitions,
  155. .nr_parts = ARRAY_SIZE(colibri_partitions)
  156. }
  157. };
  158. static struct resource colibri_pxa270_flash_resource = {
  159. .start = PXA_CS0_PHYS,
  160. .end = PXA_CS0_PHYS + SZ_32M - 1,
  161. .flags = IORESOURCE_MEM,
  162. };
  163. static struct platform_device colibri_pxa270_flash_device = {
  164. .name = "physmap-flash",
  165. .id = 0,
  166. .dev = {
  167. .platform_data = colibri_flash_data,
  168. },
  169. .resource = &colibri_pxa270_flash_resource,
  170. .num_resources = 1,
  171. };
  172. static void __init colibri_pxa270_nor_init(void)
  173. {
  174. platform_device_register(&colibri_pxa270_flash_device);
  175. }
  176. #else
  177. static inline void colibri_pxa270_nor_init(void) {}
  178. #endif
  179. /******************************************************************************
  180. * Ethernet
  181. ******************************************************************************/
  182. #if defined(CONFIG_DM9000) || defined(CONFIG_DM9000_MODULE)
  183. static struct resource colibri_pxa270_dm9000_resources[] = {
  184. {
  185. .start = PXA_CS2_PHYS,
  186. .end = PXA_CS2_PHYS + 3,
  187. .flags = IORESOURCE_MEM,
  188. },
  189. {
  190. .start = PXA_CS2_PHYS + 4,
  191. .end = PXA_CS2_PHYS + 4 + 500,
  192. .flags = IORESOURCE_MEM,
  193. },
  194. {
  195. .start = gpio_to_irq(GPIO114_COLIBRI_PXA270_ETH_IRQ),
  196. .end = gpio_to_irq(GPIO114_COLIBRI_PXA270_ETH_IRQ),
  197. .flags = IORESOURCE_IRQ | IRQF_TRIGGER_RISING,
  198. },
  199. };
  200. static struct platform_device colibri_pxa270_dm9000_device = {
  201. .name = "dm9000",
  202. .id = -1,
  203. .num_resources = ARRAY_SIZE(colibri_pxa270_dm9000_resources),
  204. .resource = colibri_pxa270_dm9000_resources,
  205. };
  206. static void __init colibri_pxa270_eth_init(void)
  207. {
  208. platform_device_register(&colibri_pxa270_dm9000_device);
  209. }
  210. #else
  211. static inline void colibri_pxa270_eth_init(void) {}
  212. #endif
  213. /******************************************************************************
  214. * Audio and Touchscreen
  215. ******************************************************************************/
  216. #if defined(CONFIG_TOUCHSCREEN_UCB1400) || \
  217. defined(CONFIG_TOUCHSCREEN_UCB1400_MODULE)
  218. static pxa2xx_audio_ops_t colibri_pxa270_ac97_pdata = {
  219. .reset_gpio = 95,
  220. };
  221. static struct ucb1400_pdata colibri_pxa270_ucb1400_pdata = {
  222. .irq = gpio_to_irq(GPIO113_COLIBRI_PXA270_TS_IRQ),
  223. };
  224. static struct platform_device colibri_pxa270_ucb1400_device = {
  225. .name = "ucb1400_core",
  226. .id = -1,
  227. .dev = {
  228. .platform_data = &colibri_pxa270_ucb1400_pdata,
  229. },
  230. };
  231. static void __init colibri_pxa270_tsc_init(void)
  232. {
  233. pxa_set_ac97_info(&colibri_pxa270_ac97_pdata);
  234. platform_device_register(&colibri_pxa270_ucb1400_device);
  235. }
  236. #else
  237. static inline void colibri_pxa270_tsc_init(void) {}
  238. #endif
  239. static int colibri_pxa270_baseboard;
  240. core_param(colibri_pxa270_baseboard, colibri_pxa270_baseboard, int, 0444);
  241. static void __init colibri_pxa270_init(void)
  242. {
  243. pxa2xx_mfp_config(ARRAY_AND_SIZE(colibri_pxa270_pin_config));
  244. colibri_pxa270_nor_init();
  245. colibri_pxa270_eth_init();
  246. colibri_pxa270_tsc_init();
  247. switch (colibri_pxa270_baseboard) {
  248. case COLIBRI_EVALBOARD:
  249. pxa2xx_mfp_config(ARRAY_AND_SIZE(
  250. colibri_pxa270_evalboard_pin_config));
  251. colibri_evalboard_init();
  252. break;
  253. case COLIBRI_PXA270_INCOME:
  254. pxa2xx_mfp_config(ARRAY_AND_SIZE(income_pin_config));
  255. colibri_pxa270_income_boardinit();
  256. break;
  257. default:
  258. printk(KERN_ERR "Illegal colibri_pxa270_baseboard type %d\n",
  259. colibri_pxa270_baseboard);
  260. }
  261. }
  262. /* The "Income s.r.o. SH-Dmaster PXA270 SBC" board can be booted either
  263. * with the INCOME mach type or with COLIBRI and the kernel parameter
  264. * "colibri_pxa270_baseboard=1"
  265. */
  266. static void __init colibri_pxa270_income_init(void)
  267. {
  268. colibri_pxa270_baseboard = COLIBRI_PXA270_INCOME;
  269. colibri_pxa270_init();
  270. }
  271. MACHINE_START(COLIBRI, "Toradex Colibri PXA270")
  272. .boot_params = COLIBRI_SDRAM_BASE + 0x100,
  273. .init_machine = colibri_pxa270_init,
  274. .map_io = pxa27x_map_io,
  275. .init_irq = pxa27x_init_irq,
  276. .timer = &pxa_timer,
  277. MACHINE_END
  278. MACHINE_START(INCOME, "Income s.r.o. SH-Dmaster PXA270 SBC")
  279. .boot_params = 0xa0000100,
  280. .init_machine = colibri_pxa270_income_init,
  281. .map_io = pxa27x_map_io,
  282. .init_irq = pxa27x_init_irq,
  283. .timer = &pxa_timer,
  284. MACHINE_END