analysisDataOperation.c 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300
  1. /*
  2. * linux/arch/arm/mach-versatile/core.c
  3. *
  4. * Copyright (C) 1999 - 2003 ARM Limited
  5. * Copyright (C) 2000 Deep Blue Solutions Ltd
  6. *
  7. * This program is free software; you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License as published by
  9. * the Free Software Foundation; either version 2 of the License, or
  10. * (at your option) any later version.
  11. *
  12. * This program is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with this program; if not, write to the Free Software
  19. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  20. */
  21. #include <linux/init.h>
  22. #include <linux/device.h>
  23. #include <linux/dma-mapping.h>
  24. #include <linux/platform_device.h>
  25. #include <linux/interrupt.h>
  26. #include <linux/irqdomain.h>
  27. #include <linux/of_address.h>
  28. #include <linux/of_platform.h>
  29. #include <linux/amba/bus.h>
  30. #include <linux/amba/clcd.h>
  31. #include <linux/amba/pl061.h>
  32. #include <linux/amba/mmci.h>
  33. #include <linux/amba/pl022.h>
  34. #include <linux/io.h>
  35. #include <linux/irqchip/versatile-fpga.h>
  36. #include <linux/gfp.h>
  37. #include <linux/clkdev.h>
  38. #include <linux/mtd/physmap.h>
  39. #include <linux/bitops.h>
  40. #include <asm/irq.h>
  41. #include <asm/hardware/arm_timer.h>
  42. #include <asm/hardware/icst.h>
  43. #include <asm/hardware/vic.h>
  44. #include <asm/mach-types.h>
  45. #include <asm/mach/arch.h>
  46. #include <asm/mach/irq.h>
  47. #include <asm/mach/time.h>
  48. #include <asm/mach/map.h>
  49. #include <mach/hardware.h>
  50. #include <mach/platform.h>
  51. #include <asm/hardware/timer-sp.h>
  52. #include <plat/clcd.h>
  53. #include <plat/sched_clock.h>
  54. #include "core.h"
  55. /*
  56. * All IO addresses are mapped onto VA 0xFFFx.xxxx, where x.xxxx
  57. * is the (PA >> 12).
  58. *
  59. * Setup a VA for the Versatile Vectored Interrupt Controller.
  60. */
  61. #define VA_VIC_BASE __io_address(VERSATILE_VIC_BASE)
  62. #define VA_SIC_BASE __io_address(VERSATILE_SIC_BASE)
  63. /* These PIC IRQs are valid in each configuration */
  64. #define PIC_VALID_ALL BIT(SIC_INT_KMI0) | BIT(SIC_INT_KMI1) | \
  65. BIT(SIC_INT_SCI3) | BIT(SIC_INT_UART3) | \
  66. BIT(SIC_INT_CLCD) | BIT(SIC_INT_TOUCH) | \
  67. BIT(SIC_INT_KEYPAD) | BIT(SIC_INT_DoC) | \
  68. BIT(SIC_INT_USB) | BIT(SIC_INT_PCI0) | \
  69. BIT(SIC_INT_PCI1) | BIT(SIC_INT_PCI2) | \
  70. BIT(SIC_INT_PCI3)
  71. #if 1
  72. #define IRQ_MMCI0A IRQ_VICSOURCE22
  73. #define IRQ_AACI IRQ_VICSOURCE24
  74. #define IRQ_ETH IRQ_VICSOURCE25
  75. #define PIC_MASK 0xFFD00000
  76. #define PIC_VALID PIC_VALID_ALL
  77. #else
  78. #define IRQ_MMCI0A IRQ_SIC_MMCI0A
  79. #define IRQ_AACI IRQ_SIC_AACI
  80. #define IRQ_ETH IRQ_SIC_ETH
  81. #define PIC_MASK 0
  82. #define PIC_VALID PIC_VALID_ALL | BIT(SIC_INT_MMCI0A) | \
  83. BIT(SIC_INT_MMCI1A) | BIT(SIC_INT_AACI) | \
  84. BIT(SIC_INT_ETH)
  85. #endif
  86. /* Lookup table for finding a DT node that represents the vic instance */
  87. static const struct of_device_id vic_of_match[] __initconst = {
  88. { .compatible = "arm,versatile-vic", },
  89. {}
  90. };
  91. static const struct of_device_id sic_of_match[] __initconst = {
  92. { .compatible = "arm,versatile-sic", },
  93. {}
  94. };
  95. void __init versatile_init_irq(void)
  96. {
  97. struct device_node *np;
  98. np = of_find_matching_node_by_address(NULL, vic_of_match,
  99. VERSATILE_VIC_BASE);
  100. __vic_init(VA_VIC_BASE, IRQ_VIC_START, ~0, 0, np);
  101. writel(~0, VA_SIC_BASE + SIC_IRQ_ENABLE_CLEAR);
  102. np = of_find_matching_node_by_address(NULL, sic_of_match,
  103. VERSATILE_SIC_BASE);
  104. fpga_irq_init(VA_SIC_BASE, "SIC", IRQ_SIC_START,
  105. IRQ_VICSOURCE31, PIC_VALID, np);
  106. /*
  107. * Interrupts on secondary controller from 0 to 8 are routed to
  108. * source 31 on PIC.
  109. * Interrupts from 21 to 31 are routed directly to the VIC on
  110. * the corresponding number on primary controller. This is controlled
  111. * by setting PIC_ENABLEx.
  112. */
  113. writel(PIC_MASK, VA_SIC_BASE + SIC_INT_PIC_ENABLE);
  114. }
  115. static struct map_desc versatile_io_desc[] __initdata = {
  116. {
  117. .virtual = IO_ADDRESS(VERSATILE_SYS_BASE),
  118. .pfn = __phys_to_pfn(VERSATILE_SYS_BASE),
  119. .length = SZ_4K,
  120. .type = MT_DEVICE
  121. }, {
  122. .virtual = IO_ADDRESS(VERSATILE_SIC_BASE),
  123. .pfn = __phys_to_pfn(VERSATILE_SIC_BASE),
  124. .length = SZ_4K,
  125. .type = MT_DEVICE
  126. }, {
  127. .virtual = IO_ADDRESS(VERSATILE_VIC_BASE),
  128. .pfn = __phys_to_pfn(VERSATILE_VIC_BASE),
  129. .length = SZ_4K,
  130. .type = MT_DEVICE
  131. }, {
  132. .virtual = IO_ADDRESS(VERSATILE_SCTL_BASE),
  133. .pfn = __phys_to_pfn(VERSATILE_SCTL_BASE),
  134. .length = SZ_4K * 9,
  135. .type = MT_DEVICE
  136. },
  137. #ifdef CONFIG_MACH_VERSATILE_AB
  138. {
  139. .virtual = IO_ADDRESS(VERSATILE_IB2_BASE),
  140. .pfn = __phys_to_pfn(VERSATILE_IB2_BASE),
  141. .length = SZ_64M,
  142. .type = MT_DEVICE
  143. },
  144. #endif
  145. #ifdef CONFIG_DEBUG_LL
  146. {
  147. .virtual = IO_ADDRESS(VERSATILE_UART0_BASE),
  148. .pfn = __phys_to_pfn(VERSATILE_UART0_BASE),
  149. .length = SZ_4K,
  150. .type = MT_DEVICE
  151. },
  152. #endif
  153. #ifdef CONFIG_PCI
  154. {
  155. .virtual = IO_ADDRESS(VERSATILE_PCI_CORE_BASE),
  156. .pfn = __phys_to_pfn(VERSATILE_PCI_CORE_BASE),
  157. .length = SZ_4K,
  158. .type = MT_DEVICE
  159. }, {
  160. .virtual = (unsigned long)VERSATILE_PCI_VIRT_BASE,
  161. .pfn = __phys_to_pfn(VERSATILE_PCI_BASE),
  162. .length = VERSATILE_PCI_BASE_SIZE,
  163. .type = MT_DEVICE
  164. }, {
  165. .virtual = (unsigned long)VERSATILE_PCI_CFG_VIRT_BASE,
  166. .pfn = __phys_to_pfn(VERSATILE_PCI_CFG_BASE),
  167. .length = VERSATILE_PCI_CFG_BASE_SIZE,
  168. .type = MT_DEVICE
  169. },
  170. #endif
  171. };
  172. void __init versatile_map_io(void)
  173. {
  174. iotable_init(versatile_io_desc, ARRAY_SIZE(versatile_io_desc));
  175. }
  176. #define VERSATILE_FLASHCTRL (__io_address(VERSATILE_SYS_BASE) + VERSATILE_SYS_FLASH_OFFSET)
  177. static void versatile_flash_set_vpp(struct platform_device *pdev, int on)
  178. {
  179. u32 val;
  180. val = __raw_readl(VERSATILE_FLASHCTRL);
  181. if (on)
  182. val |= VERSATILE_FLASHPROG_FLVPPEN;
  183. else
  184. val &= ~VERSATILE_FLASHPROG_FLVPPEN;
  185. __raw_writel(val, VERSATILE_FLASHCTRL);
  186. }
  187. static struct physmap_flash_data versatile_flash_data = {
  188. .width = 4,
  189. .set_vpp = versatile_flash_set_vpp,
  190. };
  191. static struct resource versatile_flash_resource = {
  192. .start = VERSATILE_FLASH_BASE,
  193. .end = VERSATILE_FLASH_BASE + VERSATILE_FLASH_SIZE - 1,
  194. .flags = IORESOURCE_MEM,
  195. };
  196. static struct platform_device versatile_flash_device = {
  197. .name = "physmap-flash",
  198. .id = 0,
  199. .dev = {
  200. .platform_data = &versatile_flash_data,
  201. },
  202. .num_resources = 1,
  203. .resource = &versatile_flash_resource,
  204. };
  205. static struct resource smc91x_resources[] = {
  206. [0] = {
  207. .start = VERSATILE_ETH_BASE,
  208. .end = VERSATILE_ETH_BASE + SZ_64K - 1,
  209. .flags = IORESOURCE_MEM,
  210. },
  211. [1] = {
  212. .start = IRQ_ETH,
  213. .end = IRQ_ETH,
  214. .flags = IORESOURCE_IRQ,
  215. },
  216. };
  217. static struct platform_device smc91x_device = {
  218. .name = "smc91x",
  219. .id = 0,
  220. .num_resources = ARRAY_SIZE(smc91x_resources),
  221. .resource = smc91x_resources,
  222. };
  223. static struct resource versatile_i2c_resource = {
  224. .start = VERSATILE_I2C_BASE,
  225. .end = VERSATILE_I2C_BASE + SZ_4K - 1,
  226. .flags = IORESOURCE_MEM,
  227. };
  228. static struct platform_device versatile_i2c_device = {
  229. .name = "versatile-i2c",
  230. .id = 0,
  231. .num_resources = 1,
  232. .resource = &versatile_i2c_resource,
  233. };
  234. static struct i2c_board_info versatile_i2c_board_info[] = {
  235. {
  236. I2C_BOARD_INFO("ds1338", 0xd0 >> 1),
  237. },
  238. };
  239. static int __init versatile_i2c_init(void)
  240. {
  241. return i2c_register_board_info(0, versatile_i2c_board_info,
  242. ARRAY_SIZE(versatile_i2c_board_info));
  243. }
  244. arch_initcall(versatile_i2c_init);
  245. #define VERSATILE_SYSMCI (__io_address(VERSATILE_SYS_BASE) + VERSATILE_SYS_MCI_OFFSET)
  246. unsigned int mmc_status(struct device *dev)
  247. {
  248. struct amba_device *adev = container_of(dev, struct amba_device, dev);
  249. u32 mask;
  250. if (adev->res.start == VERSATILE_MMCI0_BASE)
  251. mask = 1;
  252. else
  253. mask = 2;
  254. return readl(VERSATILE_SYSMCI) & mask;
  255. }
  256. static struct mmci_platform_data mmc0_plat_data = {
  257. .ocr_mask = MMC_VDD_32_33|MMC_VDD_33_34,
  258. .status = mmc_status,
  259. .gpio_wp = -1,
  260. .gpio_cd = -1,
  261. };
  262. static struct resource char_lcd_resources[] = {
  263. {
  264. .start = VERSATILE_CHAR_LCD_BASE,
  265. .end = (VERSATILE_CHAR_LCD_BASE + SZ_4K - 1),