realview_eb.c 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468
  1. /*
  2. * linux/arch/arm/mach-realview/realview_eb.c
  3. *
  4. * Copyright (C) 2004 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/platform_device.h>
  23. #include <linux/sysdev.h>
  24. #include <linux/amba/bus.h>
  25. #include <linux/amba/pl061.h>
  26. #include <linux/amba/mmci.h>
  27. #include <linux/io.h>
  28. #include <mach/hardware.h>
  29. #include <asm/irq.h>
  30. #include <asm/leds.h>
  31. #include <asm/mach-types.h>
  32. #include <asm/pmu.h>
  33. #include <asm/hardware/gic.h>
  34. #include <asm/hardware/cache-l2x0.h>
  35. #include <asm/localtimer.h>
  36. #include <asm/mach/arch.h>
  37. #include <asm/mach/map.h>
  38. #include <asm/mach/time.h>
  39. #include <mach/board-eb.h>
  40. #include <mach/irqs.h>
  41. #include "core.h"
  42. static struct map_desc realview_eb_io_desc[] __initdata = {
  43. {
  44. .virtual = IO_ADDRESS(REALVIEW_SYS_BASE),
  45. .pfn = __phys_to_pfn(REALVIEW_SYS_BASE),
  46. .length = SZ_4K,
  47. .type = MT_DEVICE,
  48. }, {
  49. .virtual = IO_ADDRESS(REALVIEW_EB_GIC_CPU_BASE),
  50. .pfn = __phys_to_pfn(REALVIEW_EB_GIC_CPU_BASE),
  51. .length = SZ_4K,
  52. .type = MT_DEVICE,
  53. }, {
  54. .virtual = IO_ADDRESS(REALVIEW_EB_GIC_DIST_BASE),
  55. .pfn = __phys_to_pfn(REALVIEW_EB_GIC_DIST_BASE),
  56. .length = SZ_4K,
  57. .type = MT_DEVICE,
  58. }, {
  59. .virtual = IO_ADDRESS(REALVIEW_SCTL_BASE),
  60. .pfn = __phys_to_pfn(REALVIEW_SCTL_BASE),
  61. .length = SZ_4K,
  62. .type = MT_DEVICE,
  63. }, {
  64. .virtual = IO_ADDRESS(REALVIEW_EB_TIMER0_1_BASE),
  65. .pfn = __phys_to_pfn(REALVIEW_EB_TIMER0_1_BASE),
  66. .length = SZ_4K,
  67. .type = MT_DEVICE,
  68. }, {
  69. .virtual = IO_ADDRESS(REALVIEW_EB_TIMER2_3_BASE),
  70. .pfn = __phys_to_pfn(REALVIEW_EB_TIMER2_3_BASE),
  71. .length = SZ_4K,
  72. .type = MT_DEVICE,
  73. },
  74. #ifdef CONFIG_DEBUG_LL
  75. {
  76. .virtual = IO_ADDRESS(REALVIEW_EB_UART0_BASE),
  77. .pfn = __phys_to_pfn(REALVIEW_EB_UART0_BASE),
  78. .length = SZ_4K,
  79. .type = MT_DEVICE,
  80. }
  81. #endif
  82. };
  83. static struct map_desc realview_eb11mp_io_desc[] __initdata = {
  84. {
  85. .virtual = IO_ADDRESS(REALVIEW_EB11MP_GIC_CPU_BASE),
  86. .pfn = __phys_to_pfn(REALVIEW_EB11MP_GIC_CPU_BASE),
  87. .length = SZ_4K,
  88. .type = MT_DEVICE,
  89. }, {
  90. .virtual = IO_ADDRESS(REALVIEW_EB11MP_GIC_DIST_BASE),
  91. .pfn = __phys_to_pfn(REALVIEW_EB11MP_GIC_DIST_BASE),
  92. .length = SZ_4K,
  93. .type = MT_DEVICE,
  94. }, {
  95. .virtual = IO_ADDRESS(REALVIEW_EB11MP_L220_BASE),
  96. .pfn = __phys_to_pfn(REALVIEW_EB11MP_L220_BASE),
  97. .length = SZ_8K,
  98. .type = MT_DEVICE,
  99. }
  100. };
  101. static void __init realview_eb_map_io(void)
  102. {
  103. iotable_init(realview_eb_io_desc, ARRAY_SIZE(realview_eb_io_desc));
  104. if (core_tile_eb11mp() || core_tile_a9mp())
  105. iotable_init(realview_eb11mp_io_desc, ARRAY_SIZE(realview_eb11mp_io_desc));
  106. }
  107. static struct pl061_platform_data gpio0_plat_data = {
  108. .gpio_base = 0,
  109. .irq_base = -1,
  110. };
  111. static struct pl061_platform_data gpio1_plat_data = {
  112. .gpio_base = 8,
  113. .irq_base = -1,
  114. };
  115. static struct pl061_platform_data gpio2_plat_data = {
  116. .gpio_base = 16,
  117. .irq_base = -1,
  118. };
  119. /*
  120. * RealView EB AMBA devices
  121. */
  122. /*
  123. * These devices are connected via the core APB bridge
  124. */
  125. #define GPIO2_IRQ { IRQ_EB_GPIO2, NO_IRQ }
  126. #define GPIO2_DMA { 0, 0 }
  127. #define GPIO3_IRQ { IRQ_EB_GPIO3, NO_IRQ }
  128. #define GPIO3_DMA { 0, 0 }
  129. #define AACI_IRQ { IRQ_EB_AACI, NO_IRQ }
  130. #define AACI_DMA { 0x80, 0x81 }
  131. #define MMCI0_IRQ { IRQ_EB_MMCI0A, IRQ_EB_MMCI0B }
  132. #define MMCI0_DMA { 0x84, 0 }
  133. #define KMI0_IRQ { IRQ_EB_KMI0, NO_IRQ }
  134. #define KMI0_DMA { 0, 0 }
  135. #define KMI1_IRQ { IRQ_EB_KMI1, NO_IRQ }
  136. #define KMI1_DMA { 0, 0 }
  137. /*
  138. * These devices are connected directly to the multi-layer AHB switch
  139. */
  140. #define EB_SMC_IRQ { NO_IRQ, NO_IRQ }
  141. #define EB_SMC_DMA { 0, 0 }
  142. #define MPMC_IRQ { NO_IRQ, NO_IRQ }
  143. #define MPMC_DMA { 0, 0 }
  144. #define EB_CLCD_IRQ { IRQ_EB_CLCD, NO_IRQ }
  145. #define EB_CLCD_DMA { 0, 0 }
  146. #define DMAC_IRQ { IRQ_EB_DMA, NO_IRQ }
  147. #define DMAC_DMA { 0, 0 }
  148. /*
  149. * These devices are connected via the core APB bridge
  150. */
  151. #define SCTL_IRQ { NO_IRQ, NO_IRQ }
  152. #define SCTL_DMA { 0, 0 }
  153. #define EB_WATCHDOG_IRQ { IRQ_EB_WDOG, NO_IRQ }
  154. #define EB_WATCHDOG_DMA { 0, 0 }
  155. #define EB_GPIO0_IRQ { IRQ_EB_GPIO0, NO_IRQ }
  156. #define EB_GPIO0_DMA { 0, 0 }
  157. #define GPIO1_IRQ { IRQ_EB_GPIO1, NO_IRQ }
  158. #define GPIO1_DMA { 0, 0 }
  159. #define EB_RTC_IRQ { IRQ_EB_RTC, NO_IRQ }
  160. #define EB_RTC_DMA { 0, 0 }
  161. /*
  162. * These devices are connected via the DMA APB bridge
  163. */
  164. #define SCI_IRQ { IRQ_EB_SCI, NO_IRQ }
  165. #define SCI_DMA { 7, 6 }
  166. #define EB_UART0_IRQ { IRQ_EB_UART0, NO_IRQ }
  167. #define EB_UART0_DMA { 15, 14 }
  168. #define EB_UART1_IRQ { IRQ_EB_UART1, NO_IRQ }
  169. #define EB_UART1_DMA { 13, 12 }
  170. #define EB_UART2_IRQ { IRQ_EB_UART2, NO_IRQ }
  171. #define EB_UART2_DMA { 11, 10 }
  172. #define EB_UART3_IRQ { IRQ_EB_UART3, NO_IRQ }
  173. #define EB_UART3_DMA { 0x86, 0x87 }
  174. #define EB_SSP_IRQ { IRQ_EB_SSP, NO_IRQ }
  175. #define EB_SSP_DMA { 9, 8 }
  176. /* FPGA Primecells */
  177. AMBA_DEVICE(aaci, "fpga:aaci", AACI, NULL);
  178. AMBA_DEVICE(mmc0, "fpga:mmc0", MMCI0, &realview_mmc0_plat_data);
  179. AMBA_DEVICE(kmi0, "fpga:kmi0", KMI0, NULL);
  180. AMBA_DEVICE(kmi1, "fpga:kmi1", KMI1, NULL);
  181. AMBA_DEVICE(uart3, "fpga:uart3", EB_UART3, NULL);
  182. /* DevChip Primecells */
  183. AMBA_DEVICE(smc, "dev:smc", EB_SMC, NULL);
  184. AMBA_DEVICE(clcd, "dev:clcd", EB_CLCD, &clcd_plat_data);
  185. AMBA_DEVICE(dmac, "dev:dmac", DMAC, NULL);
  186. AMBA_DEVICE(sctl, "dev:sctl", SCTL, NULL);
  187. AMBA_DEVICE(wdog, "dev:wdog", EB_WATCHDOG, NULL);
  188. AMBA_DEVICE(gpio0, "dev:gpio0", EB_GPIO0, &gpio0_plat_data);
  189. AMBA_DEVICE(gpio1, "dev:gpio1", GPIO1, &gpio1_plat_data);
  190. AMBA_DEVICE(gpio2, "dev:gpio2", GPIO2, &gpio2_plat_data);
  191. AMBA_DEVICE(rtc, "dev:rtc", EB_RTC, NULL);
  192. AMBA_DEVICE(sci0, "dev:sci0", SCI, NULL);
  193. AMBA_DEVICE(uart0, "dev:uart0", EB_UART0, NULL);
  194. AMBA_DEVICE(uart1, "dev:uart1", EB_UART1, NULL);
  195. AMBA_DEVICE(uart2, "dev:uart2", EB_UART2, NULL);
  196. AMBA_DEVICE(ssp0, "dev:ssp0", EB_SSP, NULL);
  197. static struct amba_device *amba_devs[] __initdata = {
  198. &dmac_device,
  199. &uart0_device,
  200. &uart1_device,
  201. &uart2_device,
  202. &uart3_device,
  203. &smc_device,
  204. &clcd_device,
  205. &sctl_device,
  206. &wdog_device,
  207. &gpio0_device,
  208. &gpio1_device,
  209. &gpio2_device,
  210. &rtc_device,
  211. &sci0_device,
  212. &ssp0_device,
  213. &aaci_device,
  214. &mmc0_device,
  215. &kmi0_device,
  216. &kmi1_device,
  217. };
  218. /*
  219. * RealView EB platform devices
  220. */
  221. static struct resource realview_eb_flash_resource = {
  222. .start = REALVIEW_EB_FLASH_BASE,
  223. .end = REALVIEW_EB_FLASH_BASE + REALVIEW_EB_FLASH_SIZE - 1,
  224. .flags = IORESOURCE_MEM,
  225. };
  226. static struct resource realview_eb_eth_resources[] = {
  227. [0] = {
  228. .start = REALVIEW_EB_ETH_BASE,
  229. .end = REALVIEW_EB_ETH_BASE + SZ_64K - 1,
  230. .flags = IORESOURCE_MEM,
  231. },
  232. [1] = {
  233. .start = IRQ_EB_ETH,
  234. .end = IRQ_EB_ETH,
  235. .flags = IORESOURCE_IRQ,
  236. },
  237. };
  238. /*
  239. * Detect and register the correct Ethernet device. RealView/EB rev D
  240. * platforms use the newer SMSC LAN9118 Ethernet chip
  241. */
  242. static int eth_device_register(void)
  243. {
  244. void __iomem *eth_addr = ioremap(REALVIEW_EB_ETH_BASE, SZ_4K);
  245. const char *name = NULL;
  246. u32 idrev;
  247. if (!eth_addr)
  248. return -ENOMEM;
  249. idrev = readl(eth_addr + 0x50);
  250. if ((idrev & 0xFFFF0000) != 0x01180000)
  251. /* SMSC LAN9118 not present, use LAN91C111 instead */
  252. name = "smc91x";
  253. iounmap(eth_addr);
  254. return realview_eth_register(name, realview_eb_eth_resources);
  255. }
  256. static struct resource realview_eb_isp1761_resources[] = {
  257. [0] = {
  258. .start = REALVIEW_EB_USB_BASE,
  259. .end = REALVIEW_EB_USB_BASE + SZ_128K - 1,
  260. .flags = IORESOURCE_MEM,
  261. },
  262. [1] = {
  263. .start = IRQ_EB_USB,
  264. .end = IRQ_EB_USB,
  265. .flags = IORESOURCE_IRQ,
  266. },
  267. };
  268. static struct resource pmu_resources[] = {
  269. [0] = {
  270. .start = IRQ_EB11MP_PMU_CPU0,
  271. .end = IRQ_EB11MP_PMU_CPU0,
  272. .flags = IORESOURCE_IRQ,
  273. },
  274. [1] = {
  275. .start = IRQ_EB11MP_PMU_CPU1,
  276. .end = IRQ_EB11MP_PMU_CPU1,
  277. .flags = IORESOURCE_IRQ,
  278. },
  279. [2] = {
  280. .start = IRQ_EB11MP_PMU_CPU2,
  281. .end = IRQ_EB11MP_PMU_CPU2,
  282. .flags = IORESOURCE_IRQ,
  283. },
  284. [3] = {
  285. .start = IRQ_EB11MP_PMU_CPU3,
  286. .end = IRQ_EB11MP_PMU_CPU3,
  287. .flags = IORESOURCE_IRQ,
  288. },
  289. };
  290. static struct platform_device pmu_device = {
  291. .name = "arm-pmu",
  292. .id = ARM_PMU_DEVICE_CPU,
  293. .num_resources = ARRAY_SIZE(pmu_resources),
  294. .resource = pmu_resources,
  295. };
  296. static void __init gic_init_irq(void)
  297. {
  298. if (core_tile_eb11mp() || core_tile_a9mp()) {
  299. unsigned int pldctrl;
  300. /* new irq mode */
  301. writel(0x0000a05f, __io_address(REALVIEW_SYS_LOCK));
  302. pldctrl = readl(__io_address(REALVIEW_SYS_BASE) + REALVIEW_EB11MP_SYS_PLD_CTRL1);
  303. pldctrl |= 0x00800000;
  304. writel(pldctrl, __io_address(REALVIEW_SYS_BASE) + REALVIEW_EB11MP_SYS_PLD_CTRL1);
  305. writel(0x00000000, __io_address(REALVIEW_SYS_LOCK));
  306. /* core tile GIC, primary */
  307. gic_cpu_base_addr = __io_address(REALVIEW_EB11MP_GIC_CPU_BASE);
  308. gic_dist_init(0, __io_address(REALVIEW_EB11MP_GIC_DIST_BASE), 29);
  309. gic_cpu_init(0, gic_cpu_base_addr);
  310. #ifndef CONFIG_REALVIEW_EB_ARM11MP_REVB
  311. /* board GIC, secondary */
  312. gic_dist_init(1, __io_address(REALVIEW_EB_GIC_DIST_BASE), 64);
  313. gic_cpu_init(1, __io_address(REALVIEW_EB_GIC_CPU_BASE));
  314. gic_cascade_irq(1, IRQ_EB11MP_EB_IRQ1);
  315. #endif
  316. } else {
  317. /* board GIC, primary */
  318. gic_cpu_base_addr = __io_address(REALVIEW_EB_GIC_CPU_BASE);
  319. gic_dist_init(0, __io_address(REALVIEW_EB_GIC_DIST_BASE), 29);
  320. gic_cpu_init(0, gic_cpu_base_addr);
  321. }
  322. }
  323. /*
  324. * Fix up the IRQ numbers for the RealView EB/ARM11MPCore tile
  325. */
  326. static void realview_eb11mp_fixup(void)
  327. {
  328. /* AMBA devices */
  329. dmac_device.irq[0] = IRQ_EB11MP_DMA;
  330. uart0_device.irq[0] = IRQ_EB11MP_UART0;
  331. uart1_device.irq[0] = IRQ_EB11MP_UART1;
  332. uart2_device.irq[0] = IRQ_EB11MP_UART2;
  333. uart3_device.irq[0] = IRQ_EB11MP_UART3;
  334. clcd_device.irq[0] = IRQ_EB11MP_CLCD;
  335. wdog_device.irq[0] = IRQ_EB11MP_WDOG;
  336. gpio0_device.irq[0] = IRQ_EB11MP_GPIO0;
  337. gpio1_device.irq[0] = IRQ_EB11MP_GPIO1;
  338. gpio2_device.irq[0] = IRQ_EB11MP_GPIO2;
  339. rtc_device.irq[0] = IRQ_EB11MP_RTC;
  340. sci0_device.irq[0] = IRQ_EB11MP_SCI;
  341. ssp0_device.irq[0] = IRQ_EB11MP_SSP;
  342. aaci_device.irq[0] = IRQ_EB11MP_AACI;
  343. mmc0_device.irq[0] = IRQ_EB11MP_MMCI0A;
  344. mmc0_device.irq[1] = IRQ_EB11MP_MMCI0B;
  345. kmi0_device.irq[0] = IRQ_EB11MP_KMI0;
  346. kmi1_device.irq[0] = IRQ_EB11MP_KMI1;
  347. /* platform devices */
  348. realview_eb_eth_resources[1].start = IRQ_EB11MP_ETH;
  349. realview_eb_eth_resources[1].end = IRQ_EB11MP_ETH;
  350. realview_eb_isp1761_resources[1].start = IRQ_EB11MP_USB;
  351. realview_eb_isp1761_resources[1].end = IRQ_EB11MP_USB;
  352. }
  353. static void __init realview_eb_timer_init(void)
  354. {
  355. unsigned int timer_irq;
  356. timer0_va_base = __io_address(REALVIEW_EB_TIMER0_1_BASE);
  357. timer1_va_base = __io_address(REALVIEW_EB_TIMER0_1_BASE) + 0x20;
  358. timer2_va_base = __io_address(REALVIEW_EB_TIMER2_3_BASE);
  359. timer3_va_base = __io_address(REALVIEW_EB_TIMER2_3_BASE) + 0x20;
  360. if (core_tile_eb11mp() || core_tile_a9mp()) {
  361. #ifdef CONFIG_LOCAL_TIMERS
  362. twd_base = __io_address(REALVIEW_EB11MP_TWD_BASE);
  363. #endif
  364. timer_irq = IRQ_EB11MP_TIMER0_1;
  365. } else
  366. timer_irq = IRQ_EB_TIMER0_1;
  367. realview_timer_init(timer_irq);
  368. }
  369. static struct sys_timer realview_eb_timer = {
  370. .init = realview_eb_timer_init,
  371. };
  372. static void realview_eb_reset(char mode)
  373. {
  374. void __iomem *reset_ctrl = __io_address(REALVIEW_SYS_RESETCTL);
  375. void __iomem *lock_ctrl = __io_address(REALVIEW_SYS_LOCK);
  376. /*
  377. * To reset, we hit the on-board reset register
  378. * in the system FPGA
  379. */
  380. __raw_writel(REALVIEW_SYS_LOCK_VAL, lock_ctrl);
  381. if (core_tile_eb11mp())
  382. __raw_writel(0x0008, reset_ctrl);
  383. }
  384. static void __init realview_eb_init(void)
  385. {
  386. int i;
  387. if (core_tile_eb11mp() || core_tile_a9mp()) {
  388. realview_eb11mp_fixup();
  389. #ifdef CONFIG_CACHE_L2X0
  390. /* 1MB (128KB/way), 8-way associativity, evmon/parity/share enabled
  391. * Bits: .... ...0 0111 1001 0000 .... .... .... */
  392. l2x0_init(__io_address(REALVIEW_EB11MP_L220_BASE), 0x00790000, 0xfe000fff);
  393. #endif
  394. platform_device_register(&pmu_device);
  395. }
  396. realview_flash_register(&realview_eb_flash_resource, 1);
  397. platform_device_register(&realview_i2c_device);
  398. eth_device_register();
  399. realview_usb_register(realview_eb_isp1761_resources);
  400. for (i = 0; i < ARRAY_SIZE(amba_devs); i++) {
  401. struct amba_device *d = amba_devs[i];
  402. amba_device_register(d, &iomem_resource);
  403. }
  404. #ifdef CONFIG_LEDS
  405. leds_event = realview_leds_event;
  406. #endif
  407. realview_reset = realview_eb_reset;
  408. }
  409. MACHINE_START(REALVIEW_EB, "ARM-RealView EB")
  410. /* Maintainer: ARM Ltd/Deep Blue Solutions Ltd */
  411. .phys_io = REALVIEW_EB_UART0_BASE,
  412. .io_pg_offst = (IO_ADDRESS(REALVIEW_EB_UART0_BASE) >> 18) & 0xfffc,
  413. .boot_params = PHYS_OFFSET + 0x00000100,
  414. .fixup = realview_fixup,
  415. .map_io = realview_eb_map_io,
  416. .init_irq = gic_init_irq,
  417. .timer = &realview_eb_timer,
  418. .init_machine = realview_eb_init,
  419. MACHINE_END