/arch/arm/mach-pxa/colibri-pxa270.c

https://github.com/AICP/kernel_asus_grouper · C · 325 lines · 239 code · 40 blank · 46 comment · 4 complexity · d8256c4b5cd330b1e3935d7afd80c502 MD5 · raw file

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