mach-kzm_arm11_01.c 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280
  1. /*
  2. * KZM-ARM11-01 support
  3. * Copyright (C) 2009 Yoichi Yuasa <yuasa@linux-mips.org>
  4. *
  5. * based on code for MX31ADS,
  6. * Copyright (C) 2000 Deep Blue Solutions Ltd
  7. * Copyright (C) 2002 Shane Nay (shane@minirl.com)
  8. * Copyright 2005-2007 Freescale Semiconductor, Inc. All Rights Reserved.
  9. *
  10. * This program is free software; you can redistribute it and/or modify
  11. * it under the terms of the GNU General Public License as published by
  12. * the Free Software Foundation; either version 2 of the License, or
  13. * (at your option) any later version.
  14. *
  15. * This program is distributed in the hope that it will be useful,
  16. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  18. * GNU General Public License for more details.
  19. */
  20. #include <linux/gpio.h>
  21. #include <linux/init.h>
  22. #include <linux/platform_device.h>
  23. #include <linux/serial_8250.h>
  24. #include <linux/smsc911x.h>
  25. #include <linux/types.h>
  26. #include <asm/irq.h>
  27. #include <asm/mach-types.h>
  28. #include <asm/memory.h>
  29. #include <asm/setup.h>
  30. #include <asm/mach/arch.h>
  31. #include <asm/mach/irq.h>
  32. #include <asm/mach/map.h>
  33. #include <asm/mach/time.h>
  34. #include <mach/clock.h>
  35. #include <mach/common.h>
  36. #include <mach/iomux-mx3.h>
  37. #include "devices-imx31.h"
  38. #define KZM_ARM11_IO_ADDRESS(x) (IOMEM( \
  39. IMX_IO_P2V_MODULE(x, MX31_CS4) ?: \
  40. IMX_IO_P2V_MODULE(x, MX31_CS5)) ?: \
  41. MX31_IO_ADDRESS(x))
  42. /*
  43. * KZM-ARM11-01 Board Control Registers on FPGA
  44. */
  45. #define KZM_ARM11_CTL1 (MX31_CS4_BASE_ADDR + 0x1000)
  46. #define KZM_ARM11_CTL2 (MX31_CS4_BASE_ADDR + 0x1001)
  47. #define KZM_ARM11_RSW1 (MX31_CS4_BASE_ADDR + 0x1002)
  48. #define KZM_ARM11_BACK_LIGHT (MX31_CS4_BASE_ADDR + 0x1004)
  49. #define KZM_ARM11_FPGA_REV (MX31_CS4_BASE_ADDR + 0x1008)
  50. #define KZM_ARM11_7SEG_LED (MX31_CS4_BASE_ADDR + 0x1010)
  51. #define KZM_ARM11_LEDS (MX31_CS4_BASE_ADDR + 0x1020)
  52. #define KZM_ARM11_DIPSW2 (MX31_CS4_BASE_ADDR + 0x1003)
  53. /*
  54. * External UART for touch panel on FPGA
  55. */
  56. #define KZM_ARM11_16550 (MX31_CS4_BASE_ADDR + 0x1050)
  57. #if defined(CONFIG_SERIAL_8250) || defined(CONFIG_SERIAL_8250_MODULE)
  58. /*
  59. * KZM-ARM11-01 has an external UART on FPGA
  60. */
  61. static struct plat_serial8250_port serial_platform_data[] = {
  62. {
  63. .membase = KZM_ARM11_IO_ADDRESS(KZM_ARM11_16550),
  64. .mapbase = KZM_ARM11_16550,
  65. .irq = IOMUX_TO_IRQ(MX31_PIN_GPIO1_1),
  66. .irqflags = IRQ_TYPE_EDGE_RISING,
  67. .uartclk = 14745600,
  68. .regshift = 0,
  69. .iotype = UPIO_MEM,
  70. .flags = UPF_BOOT_AUTOCONF | UPF_SKIP_TEST |
  71. UPF_BUGGY_UART,
  72. },
  73. {},
  74. };
  75. static struct resource serial8250_resources[] = {
  76. {
  77. .start = KZM_ARM11_16550,
  78. .end = KZM_ARM11_16550 + 0x10,
  79. .flags = IORESOURCE_MEM,
  80. },
  81. {
  82. .start = IOMUX_TO_IRQ(MX31_PIN_GPIO1_1),
  83. .end = IOMUX_TO_IRQ(MX31_PIN_GPIO1_1),
  84. .flags = IORESOURCE_IRQ,
  85. },
  86. };
  87. static struct platform_device serial_device = {
  88. .name = "serial8250",
  89. .id = PLAT8250_DEV_PLATFORM,
  90. .dev = {
  91. .platform_data = serial_platform_data,
  92. },
  93. .num_resources = ARRAY_SIZE(serial8250_resources),
  94. .resource = serial8250_resources,
  95. };
  96. static int __init kzm_init_ext_uart(void)
  97. {
  98. u8 tmp;
  99. /*
  100. * GPIO 1-1: external UART interrupt line
  101. */
  102. mxc_iomux_mode(IOMUX_MODE(MX31_PIN_GPIO1_1, IOMUX_CONFIG_GPIO));
  103. gpio_request(IOMUX_TO_GPIO(MX31_PIN_GPIO1_1), "ext-uart-int");
  104. gpio_direction_input(IOMUX_TO_GPIO(MX31_PIN_GPIO1_1));
  105. /*
  106. * Unmask UART interrupt
  107. */
  108. tmp = __raw_readb(KZM_ARM11_IO_ADDRESS(KZM_ARM11_CTL1));
  109. tmp |= 0x2;
  110. __raw_writeb(tmp, KZM_ARM11_IO_ADDRESS(KZM_ARM11_CTL1));
  111. return platform_device_register(&serial_device);
  112. }
  113. #else
  114. static inline int kzm_init_ext_uart(void)
  115. {
  116. return 0;
  117. }
  118. #endif
  119. /*
  120. * SMSC LAN9118
  121. */
  122. #if defined(CONFIG_SMSC911X) || defined(CONFIG_SMSC911X_MODULE)
  123. static struct smsc911x_platform_config kzm_smsc9118_config = {
  124. .phy_interface = PHY_INTERFACE_MODE_MII,
  125. .irq_polarity = SMSC911X_IRQ_POLARITY_ACTIVE_HIGH,
  126. .irq_type = SMSC911X_IRQ_TYPE_PUSH_PULL,
  127. .flags = SMSC911X_USE_32BIT | SMSC911X_SAVE_MAC_ADDRESS,
  128. };
  129. static struct resource kzm_smsc9118_resources[] = {
  130. {
  131. .start = MX31_CS5_BASE_ADDR,
  132. .end = MX31_CS5_BASE_ADDR + SZ_128K - 1,
  133. .flags = IORESOURCE_MEM,
  134. },
  135. {
  136. .start = IOMUX_TO_IRQ(MX31_PIN_GPIO1_2),
  137. .end = IOMUX_TO_IRQ(MX31_PIN_GPIO1_2),
  138. .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHEDGE,
  139. },
  140. };
  141. static struct platform_device kzm_smsc9118_device = {
  142. .name = "smsc911x",
  143. .id = -1,
  144. .num_resources = ARRAY_SIZE(kzm_smsc9118_resources),
  145. .resource = kzm_smsc9118_resources,
  146. .dev = {
  147. .platform_data = &kzm_smsc9118_config,
  148. },
  149. };
  150. static int __init kzm_init_smsc9118(void)
  151. {
  152. /*
  153. * GPIO 1-2: SMSC9118 interrupt line
  154. */
  155. mxc_iomux_mode(IOMUX_MODE(MX31_PIN_GPIO1_2, IOMUX_CONFIG_GPIO));
  156. gpio_request(IOMUX_TO_GPIO(MX31_PIN_GPIO1_2), "smsc9118-int");
  157. gpio_direction_input(IOMUX_TO_GPIO(MX31_PIN_GPIO1_2));
  158. return platform_device_register(&kzm_smsc9118_device);
  159. }
  160. #else
  161. static inline int kzm_init_smsc9118(void)
  162. {
  163. return 0;
  164. }
  165. #endif
  166. #if defined(CONFIG_SERIAL_IMX) || defined(CONFIG_SERIAL_IMX_MODULE)
  167. static const struct imxuart_platform_data uart_pdata __initconst = {
  168. .flags = IMXUART_HAVE_RTSCTS,
  169. };
  170. static void __init kzm_init_imx_uart(void)
  171. {
  172. imx31_add_imx_uart0(&uart_pdata);
  173. imx31_add_imx_uart1(&uart_pdata);
  174. }
  175. #else
  176. static inline void kzm_init_imx_uart(void)
  177. {
  178. }
  179. #endif
  180. static int kzm_pins[] __initdata = {
  181. MX31_PIN_CTS1__CTS1,
  182. MX31_PIN_RTS1__RTS1,
  183. MX31_PIN_TXD1__TXD1,
  184. MX31_PIN_RXD1__RXD1,
  185. MX31_PIN_DCD_DCE1__DCD_DCE1,
  186. MX31_PIN_RI_DCE1__RI_DCE1,
  187. MX31_PIN_DSR_DCE1__DSR_DCE1,
  188. MX31_PIN_DTR_DCE1__DTR_DCE1,
  189. MX31_PIN_CTS2__CTS2,
  190. MX31_PIN_RTS2__RTS2,
  191. MX31_PIN_TXD2__TXD2,
  192. MX31_PIN_RXD2__RXD2,
  193. MX31_PIN_DCD_DTE1__DCD_DTE2,
  194. MX31_PIN_RI_DTE1__RI_DTE2,
  195. MX31_PIN_DSR_DTE1__DSR_DTE2,
  196. MX31_PIN_DTR_DTE1__DTR_DTE2,
  197. };
  198. /*
  199. * Board specific initialization.
  200. */
  201. static void __init kzm_board_init(void)
  202. {
  203. imx31_soc_init();
  204. mxc_iomux_setup_multiple_pins(kzm_pins,
  205. ARRAY_SIZE(kzm_pins), "kzm");
  206. kzm_init_ext_uart();
  207. kzm_init_smsc9118();
  208. kzm_init_imx_uart();
  209. pr_info("Clock input source is 26MHz\n");
  210. }
  211. /*
  212. * This structure defines static mappings for the kzm-arm11-01 board.
  213. */
  214. static struct map_desc kzm_io_desc[] __initdata = {
  215. {
  216. .virtual = MX31_CS4_BASE_ADDR_VIRT,
  217. .pfn = __phys_to_pfn(MX31_CS4_BASE_ADDR),
  218. .length = MX31_CS4_SIZE,
  219. .type = MT_DEVICE
  220. },
  221. {
  222. .virtual = MX31_CS5_BASE_ADDR_VIRT,
  223. .pfn = __phys_to_pfn(MX31_CS5_BASE_ADDR),
  224. .length = MX31_CS5_SIZE,
  225. .type = MT_DEVICE
  226. },
  227. };
  228. /*
  229. * Set up static virtual mappings.
  230. */
  231. static void __init kzm_map_io(void)
  232. {
  233. mx31_map_io();
  234. iotable_init(kzm_io_desc, ARRAY_SIZE(kzm_io_desc));
  235. }
  236. static void __init kzm_timer_init(void)
  237. {
  238. mx31_clocks_init(26000000);
  239. }
  240. static struct sys_timer kzm_timer = {
  241. .init = kzm_timer_init,
  242. };
  243. MACHINE_START(KZM_ARM11_01, "Kyoto Microcomputer Co., Ltd. KZM-ARM11-01")
  244. .boot_params = MX3x_PHYS_OFFSET + 0x100,
  245. .map_io = kzm_map_io,
  246. .init_early = imx31_init_early,
  247. .init_irq = mx31_init_irq,
  248. .timer = &kzm_timer,
  249. .init_machine = kzm_board_init,
  250. MACHINE_END