colibri-pxa270.c 7.8 KB

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