mach-kzm_arm11_01.c 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301
  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 <linux/regulator/machine.h>
  27. #include <linux/regulator/fixed.h>
  28. #include <asm/irq.h>
  29. #include <asm/mach-types.h>
  30. #include <asm/memory.h>
  31. #include <asm/setup.h>
  32. #include <asm/mach/arch.h>
  33. #include <asm/mach/irq.h>
  34. #include <asm/mach/map.h>
  35. #include <asm/mach/time.h>
  36. #include "common.h"
  37. #include "devices-imx31.h"
  38. #include "hardware.h"
  39. #include "iomux-mx3.h"
  40. #define KZM_ARM11_IO_ADDRESS(x) (IOMEM( \
  41. IMX_IO_P2V_MODULE(x, MX31_CS4) ?: \
  42. IMX_IO_P2V_MODULE(x, MX31_CS5)) ?: \
  43. MX31_IO_ADDRESS(x))
  44. /*
  45. * KZM-ARM11-01 Board Control Registers on FPGA
  46. */
  47. #define KZM_ARM11_CTL1 (MX31_CS4_BASE_ADDR + 0x1000)
  48. #define KZM_ARM11_CTL2 (MX31_CS4_BASE_ADDR + 0x1001)
  49. #define KZM_ARM11_RSW1 (MX31_CS4_BASE_ADDR + 0x1002)
  50. #define KZM_ARM11_BACK_LIGHT (MX31_CS4_BASE_ADDR + 0x1004)
  51. #define KZM_ARM11_FPGA_REV (MX31_CS4_BASE_ADDR + 0x1008)
  52. #define KZM_ARM11_7SEG_LED (MX31_CS4_BASE_ADDR + 0x1010)
  53. #define KZM_ARM11_LEDS (MX31_CS4_BASE_ADDR + 0x1020)
  54. #define KZM_ARM11_DIPSW2 (MX31_CS4_BASE_ADDR + 0x1003)
  55. /*
  56. * External UART for touch panel on FPGA
  57. */
  58. #define KZM_ARM11_16550 (MX31_CS4_BASE_ADDR + 0x1050)
  59. #if IS_ENABLED(CONFIG_SERIAL_8250)
  60. /*
  61. * KZM-ARM11-01 has an external UART on FPGA
  62. */
  63. static struct plat_serial8250_port serial_platform_data[] = {
  64. {
  65. .membase = KZM_ARM11_IO_ADDRESS(KZM_ARM11_16550),
  66. .mapbase = KZM_ARM11_16550,
  67. /* irq number is run-time assigned */
  68. .irqflags = IRQ_TYPE_EDGE_RISING,
  69. .uartclk = 14745600,
  70. .regshift = 0,
  71. .iotype = UPIO_MEM,
  72. .flags = UPF_BOOT_AUTOCONF | UPF_SKIP_TEST |
  73. UPF_BUGGY_UART,
  74. },
  75. {},
  76. };
  77. static struct resource serial8250_resources[] = {
  78. {
  79. .start = KZM_ARM11_16550,
  80. .end = KZM_ARM11_16550 + 0x10,
  81. .flags = IORESOURCE_MEM,
  82. },
  83. {
  84. /* irq number is run-time assigned */
  85. .flags = IORESOURCE_IRQ,
  86. },
  87. };
  88. static struct platform_device serial_device = {
  89. .name = "serial8250",
  90. .id = PLAT8250_DEV_PLATFORM,
  91. .dev = {
  92. .platform_data = serial_platform_data,
  93. },
  94. .num_resources = ARRAY_SIZE(serial8250_resources),
  95. .resource = serial8250_resources,
  96. };
  97. static int __init kzm_init_ext_uart(void)
  98. {
  99. u8 tmp;
  100. /*
  101. * GPIO 1-1: external UART interrupt line
  102. */
  103. mxc_iomux_mode(IOMUX_MODE(MX31_PIN_GPIO1_1, IOMUX_CONFIG_GPIO));
  104. gpio_request(IOMUX_TO_GPIO(MX31_PIN_GPIO1_1), "ext-uart-int");
  105. gpio_direction_input(IOMUX_TO_GPIO(MX31_PIN_GPIO1_1));
  106. /*
  107. * Unmask UART interrupt
  108. */
  109. tmp = __raw_readb(KZM_ARM11_IO_ADDRESS(KZM_ARM11_CTL1));
  110. tmp |= 0x2;
  111. __raw_writeb(tmp, KZM_ARM11_IO_ADDRESS(KZM_ARM11_CTL1));
  112. serial_platform_data[0].irq =
  113. gpio_to_irq(IOMUX_TO_GPIO(MX31_PIN_GPIO1_1));
  114. serial8250_resources[1].start =
  115. gpio_to_irq(IOMUX_TO_GPIO(MX31_PIN_GPIO1_1));
  116. serial8250_resources[1].end =
  117. gpio_to_irq(IOMUX_TO_GPIO(MX31_PIN_GPIO1_1));
  118. return platform_device_register(&serial_device);
  119. }
  120. #else
  121. static inline int kzm_init_ext_uart(void)
  122. {
  123. return 0;
  124. }
  125. #endif
  126. /*
  127. * SMSC LAN9118
  128. */
  129. #if IS_ENABLED(CONFIG_SMSC911X)
  130. static struct smsc911x_platform_config kzm_smsc9118_config = {
  131. .phy_interface = PHY_INTERFACE_MODE_MII,
  132. .irq_polarity = SMSC911X_IRQ_POLARITY_ACTIVE_HIGH,
  133. .irq_type = SMSC911X_IRQ_TYPE_PUSH_PULL,
  134. .flags = SMSC911X_USE_32BIT | SMSC911X_SAVE_MAC_ADDRESS,
  135. };
  136. static struct resource kzm_smsc9118_resources[] = {
  137. {
  138. .start = MX31_CS5_BASE_ADDR,
  139. .end = MX31_CS5_BASE_ADDR + SZ_128K - 1,
  140. .flags = IORESOURCE_MEM,
  141. },
  142. {
  143. /* irq number is run-time assigned */
  144. .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHEDGE,
  145. },
  146. };
  147. static struct platform_device kzm_smsc9118_device = {
  148. .name = "smsc911x",
  149. .id = -1,
  150. .num_resources = ARRAY_SIZE(kzm_smsc9118_resources),
  151. .resource = kzm_smsc9118_resources,
  152. .dev = {
  153. .platform_data = &kzm_smsc9118_config,
  154. },
  155. };
  156. static struct regulator_consumer_supply dummy_supplies[] = {
  157. REGULATOR_SUPPLY("vdd33a", "smsc911x"),
  158. REGULATOR_SUPPLY("vddvario", "smsc911x"),
  159. };
  160. static int __init kzm_init_smsc9118(void)
  161. {
  162. /*
  163. * GPIO 1-2: SMSC9118 interrupt line
  164. */
  165. mxc_iomux_mode(IOMUX_MODE(MX31_PIN_GPIO1_2, IOMUX_CONFIG_GPIO));
  166. gpio_request(IOMUX_TO_GPIO(MX31_PIN_GPIO1_2), "smsc9118-int");
  167. gpio_direction_input(IOMUX_TO_GPIO(MX31_PIN_GPIO1_2));
  168. regulator_register_fixed(0, dummy_supplies, ARRAY_SIZE(dummy_supplies));
  169. kzm_smsc9118_resources[1].start =
  170. gpio_to_irq(IOMUX_TO_GPIO(MX31_PIN_GPIO1_2));
  171. kzm_smsc9118_resources[1].end =
  172. gpio_to_irq(IOMUX_TO_GPIO(MX31_PIN_GPIO1_2));
  173. return platform_device_register(&kzm_smsc9118_device);
  174. }
  175. #else
  176. static inline int kzm_init_smsc9118(void)
  177. {
  178. return 0;
  179. }
  180. #endif
  181. #if IS_ENABLED(CONFIG_SERIAL_IMX)
  182. static const struct imxuart_platform_data uart_pdata __initconst = {
  183. .flags = IMXUART_HAVE_RTSCTS,
  184. };
  185. static void __init kzm_init_imx_uart(void)
  186. {
  187. imx31_add_imx_uart0(&uart_pdata);
  188. imx31_add_imx_uart1(&uart_pdata);
  189. }
  190. #else
  191. static inline void kzm_init_imx_uart(void)
  192. {
  193. }
  194. #endif
  195. static int kzm_pins[] __initdata = {
  196. MX31_PIN_CTS1__CTS1,
  197. MX31_PIN_RTS1__RTS1,
  198. MX31_PIN_TXD1__TXD1,
  199. MX31_PIN_RXD1__RXD1,
  200. MX31_PIN_DCD_DCE1__DCD_DCE1,
  201. MX31_PIN_RI_DCE1__RI_DCE1,
  202. MX31_PIN_DSR_DCE1__DSR_DCE1,
  203. MX31_PIN_DTR_DCE1__DTR_DCE1,
  204. MX31_PIN_CTS2__CTS2,
  205. MX31_PIN_RTS2__RTS2,
  206. MX31_PIN_TXD2__TXD2,
  207. MX31_PIN_RXD2__RXD2,
  208. MX31_PIN_DCD_DTE1__DCD_DTE2,
  209. MX31_PIN_RI_DTE1__RI_DTE2,
  210. MX31_PIN_DSR_DTE1__DSR_DTE2,
  211. MX31_PIN_DTR_DTE1__DTR_DTE2,
  212. };
  213. /*
  214. * Board specific initialization.
  215. */
  216. static void __init kzm_board_init(void)
  217. {
  218. imx31_soc_init();
  219. mxc_iomux_setup_multiple_pins(kzm_pins,
  220. ARRAY_SIZE(kzm_pins), "kzm");
  221. kzm_init_imx_uart();
  222. pr_info("Clock input source is 26MHz\n");
  223. }
  224. static void __init kzm_late_init(void)
  225. {
  226. kzm_init_ext_uart();
  227. kzm_init_smsc9118();
  228. }
  229. /*
  230. * This structure defines static mappings for the kzm-arm11-01 board.
  231. */
  232. static struct map_desc kzm_io_desc[] __initdata = {
  233. {
  234. .virtual = (unsigned long)MX31_CS4_BASE_ADDR_VIRT,
  235. .pfn = __phys_to_pfn(MX31_CS4_BASE_ADDR),
  236. .length = MX31_CS4_SIZE,
  237. .type = MT_DEVICE
  238. },
  239. {
  240. .virtual = (unsigned long)MX31_CS5_BASE_ADDR_VIRT,
  241. .pfn = __phys_to_pfn(MX31_CS5_BASE_ADDR),
  242. .length = MX31_CS5_SIZE,
  243. .type = MT_DEVICE
  244. },
  245. };
  246. /*
  247. * Set up static virtual mappings.
  248. */
  249. static void __init kzm_map_io(void)
  250. {
  251. mx31_map_io();
  252. iotable_init(kzm_io_desc, ARRAY_SIZE(kzm_io_desc));
  253. }
  254. static void __init kzm_timer_init(void)
  255. {
  256. mx31_clocks_init(26000000);
  257. }
  258. MACHINE_START(KZM_ARM11_01, "Kyoto Microcomputer Co., Ltd. KZM-ARM11-01")
  259. .atag_offset = 0x100,
  260. .map_io = kzm_map_io,
  261. .init_early = imx31_init_early,
  262. .init_irq = mx31_init_irq,
  263. .init_time = kzm_timer_init,
  264. .init_machine = kzm_board_init,
  265. .init_late = kzm_late_init,
  266. .restart = mxc_restart,
  267. MACHINE_END