colibri-pxa270.c 8.0 KB

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