realview_pbx.c 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418
  1. /*
  2. * arch/arm/mach-realview/realview_pbx.c
  3. *
  4. * Copyright (C) 2009 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 version 2 as
  9. * published by the Free Software Foundation.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program; if not, write to the Free Software
  18. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  19. */
  20. #include <linux/init.h>
  21. #include <linux/platform_device.h>
  22. #include <linux/device.h>
  23. #include <linux/amba/bus.h>
  24. #include <linux/amba/pl061.h>
  25. #include <linux/amba/mmci.h>
  26. #include <linux/amba/pl022.h>
  27. #include <linux/io.h>
  28. #include <asm/irq.h>
  29. #include <asm/leds.h>
  30. #include <asm/mach-types.h>
  31. #include <asm/pmu.h>
  32. #include <asm/smp_twd.h>
  33. #include <asm/pgtable.h>
  34. #include <asm/hardware/gic.h>
  35. #include <asm/hardware/cache-l2x0.h>
  36. #include <asm/mach/arch.h>
  37. #include <asm/mach/map.h>
  38. #include <asm/mach/time.h>
  39. #include <mach/hardware.h>
  40. #include <mach/board-pbx.h>
  41. #include <mach/irqs.h>
  42. #include "core.h"
  43. static struct map_desc realview_pbx_io_desc[] __initdata = {
  44. {
  45. .virtual = IO_ADDRESS(REALVIEW_SYS_BASE),
  46. .pfn = __phys_to_pfn(REALVIEW_SYS_BASE),
  47. .length = SZ_4K,
  48. .type = MT_DEVICE,
  49. }, {
  50. .virtual = IO_ADDRESS(REALVIEW_PBX_GIC_CPU_BASE),
  51. .pfn = __phys_to_pfn(REALVIEW_PBX_GIC_CPU_BASE),
  52. .length = SZ_4K,
  53. .type = MT_DEVICE,
  54. }, {
  55. .virtual = IO_ADDRESS(REALVIEW_PBX_GIC_DIST_BASE),
  56. .pfn = __phys_to_pfn(REALVIEW_PBX_GIC_DIST_BASE),
  57. .length = SZ_4K,
  58. .type = MT_DEVICE,
  59. }, {
  60. .virtual = IO_ADDRESS(REALVIEW_SCTL_BASE),
  61. .pfn = __phys_to_pfn(REALVIEW_SCTL_BASE),
  62. .length = SZ_4K,
  63. .type = MT_DEVICE,
  64. }, {
  65. .virtual = IO_ADDRESS(REALVIEW_PBX_TIMER0_1_BASE),
  66. .pfn = __phys_to_pfn(REALVIEW_PBX_TIMER0_1_BASE),
  67. .length = SZ_4K,
  68. .type = MT_DEVICE,
  69. }, {
  70. .virtual = IO_ADDRESS(REALVIEW_PBX_TIMER2_3_BASE),
  71. .pfn = __phys_to_pfn(REALVIEW_PBX_TIMER2_3_BASE),
  72. .length = SZ_4K,
  73. .type = MT_DEVICE,
  74. },
  75. #ifdef CONFIG_PCI
  76. {
  77. .virtual = PCIX_UNIT_BASE,
  78. .pfn = __phys_to_pfn(REALVIEW_PBX_PCI_BASE),
  79. .length = REALVIEW_PBX_PCI_BASE_SIZE,
  80. .type = MT_DEVICE,
  81. },
  82. #endif
  83. #ifdef CONFIG_DEBUG_LL
  84. {
  85. .virtual = IO_ADDRESS(REALVIEW_PBX_UART0_BASE),
  86. .pfn = __phys_to_pfn(REALVIEW_PBX_UART0_BASE),
  87. .length = SZ_4K,
  88. .type = MT_DEVICE,
  89. },
  90. #endif
  91. };
  92. static struct map_desc realview_local_io_desc[] __initdata = {
  93. {
  94. .virtual = IO_ADDRESS(REALVIEW_PBX_TILE_SCU_BASE),
  95. .pfn = __phys_to_pfn(REALVIEW_PBX_TILE_SCU_BASE),
  96. .length = SZ_4K,
  97. .type = MT_DEVICE,
  98. }, {
  99. .virtual = IO_ADDRESS(REALVIEW_PBX_TILE_GIC_DIST_BASE),
  100. .pfn = __phys_to_pfn(REALVIEW_PBX_TILE_GIC_DIST_BASE),
  101. .length = SZ_4K,
  102. .type = MT_DEVICE,
  103. }, {
  104. .virtual = IO_ADDRESS(REALVIEW_PBX_TILE_L220_BASE),
  105. .pfn = __phys_to_pfn(REALVIEW_PBX_TILE_L220_BASE),
  106. .length = SZ_8K,
  107. .type = MT_DEVICE,
  108. }
  109. };
  110. static void __init realview_pbx_map_io(void)
  111. {
  112. iotable_init(realview_pbx_io_desc, ARRAY_SIZE(realview_pbx_io_desc));
  113. if (core_tile_pbx11mp() || core_tile_pbxa9mp())
  114. iotable_init(realview_local_io_desc, ARRAY_SIZE(realview_local_io_desc));
  115. }
  116. static struct pl061_platform_data gpio0_plat_data = {
  117. .gpio_base = 0,
  118. };
  119. static struct pl061_platform_data gpio1_plat_data = {
  120. .gpio_base = 8,
  121. };
  122. static struct pl061_platform_data gpio2_plat_data = {
  123. .gpio_base = 16,
  124. };
  125. static struct pl022_ssp_controller ssp0_plat_data = {
  126. .bus_id = 0,
  127. .enable_dma = 0,
  128. .num_chipselect = 1,
  129. };
  130. /*
  131. * RealView PBXCore AMBA devices
  132. */
  133. #define GPIO2_IRQ { IRQ_PBX_GPIO2 }
  134. #define GPIO3_IRQ { IRQ_PBX_GPIO3 }
  135. #define AACI_IRQ { IRQ_PBX_AACI }
  136. #define MMCI0_IRQ { IRQ_PBX_MMCI0A, IRQ_PBX_MMCI0B }
  137. #define KMI0_IRQ { IRQ_PBX_KMI0 }
  138. #define KMI1_IRQ { IRQ_PBX_KMI1 }
  139. #define PBX_SMC_IRQ { }
  140. #define MPMC_IRQ { }
  141. #define PBX_CLCD_IRQ { IRQ_PBX_CLCD }
  142. #define DMAC_IRQ { IRQ_PBX_DMAC }
  143. #define SCTL_IRQ { }
  144. #define PBX_WATCHDOG_IRQ { IRQ_PBX_WATCHDOG }
  145. #define PBX_GPIO0_IRQ { IRQ_PBX_GPIO0 }
  146. #define GPIO1_IRQ { IRQ_PBX_GPIO1 }
  147. #define PBX_RTC_IRQ { IRQ_PBX_RTC }
  148. #define SCI_IRQ { IRQ_PBX_SCI }
  149. #define PBX_UART0_IRQ { IRQ_PBX_UART0 }
  150. #define PBX_UART1_IRQ { IRQ_PBX_UART1 }
  151. #define PBX_UART2_IRQ { IRQ_PBX_UART2 }
  152. #define PBX_UART3_IRQ { IRQ_PBX_UART3 }
  153. #define PBX_SSP_IRQ { IRQ_PBX_SSP }
  154. /* FPGA Primecells */
  155. APB_DEVICE(aaci, "fpga:aaci", AACI, NULL);
  156. APB_DEVICE(mmc0, "fpga:mmc0", MMCI0, &realview_mmc0_plat_data);
  157. APB_DEVICE(kmi0, "fpga:kmi0", KMI0, NULL);
  158. APB_DEVICE(kmi1, "fpga:kmi1", KMI1, NULL);
  159. APB_DEVICE(uart3, "fpga:uart3", PBX_UART3, NULL);
  160. /* DevChip Primecells */
  161. AHB_DEVICE(smc, "dev:smc", PBX_SMC, NULL);
  162. AHB_DEVICE(sctl, "dev:sctl", SCTL, NULL);
  163. APB_DEVICE(wdog, "dev:wdog", PBX_WATCHDOG, NULL);
  164. APB_DEVICE(gpio0, "dev:gpio0", PBX_GPIO0, &gpio0_plat_data);
  165. APB_DEVICE(gpio1, "dev:gpio1", GPIO1, &gpio1_plat_data);
  166. APB_DEVICE(gpio2, "dev:gpio2", GPIO2, &gpio2_plat_data);
  167. APB_DEVICE(rtc, "dev:rtc", PBX_RTC, NULL);
  168. APB_DEVICE(sci0, "dev:sci0", SCI, NULL);
  169. APB_DEVICE(uart0, "dev:uart0", PBX_UART0, NULL);
  170. APB_DEVICE(uart1, "dev:uart1", PBX_UART1, NULL);
  171. APB_DEVICE(uart2, "dev:uart2", PBX_UART2, NULL);
  172. APB_DEVICE(ssp0, "dev:ssp0", PBX_SSP, &ssp0_plat_data);
  173. /* Primecells on the NEC ISSP chip */
  174. AHB_DEVICE(clcd, "issp:clcd", PBX_CLCD, &clcd_plat_data);
  175. AHB_DEVICE(dmac, "issp:dmac", DMAC, NULL);
  176. static struct amba_device *amba_devs[] __initdata = {
  177. &dmac_device,
  178. &uart0_device,
  179. &uart1_device,
  180. &uart2_device,
  181. &uart3_device,
  182. &smc_device,
  183. &clcd_device,
  184. &sctl_device,
  185. &wdog_device,
  186. &gpio0_device,
  187. &gpio1_device,
  188. &gpio2_device,
  189. &rtc_device,
  190. &sci0_device,
  191. &ssp0_device,
  192. &aaci_device,
  193. &mmc0_device,
  194. &kmi0_device,
  195. &kmi1_device,
  196. };
  197. /*
  198. * RealView PB-X platform devices
  199. */
  200. static struct resource realview_pbx_flash_resources[] = {
  201. [0] = {
  202. .start = REALVIEW_PBX_FLASH0_BASE,
  203. .end = REALVIEW_PBX_FLASH0_BASE + REALVIEW_PBX_FLASH0_SIZE - 1,
  204. .flags = IORESOURCE_MEM,
  205. },
  206. [1] = {
  207. .start = REALVIEW_PBX_FLASH1_BASE,
  208. .end = REALVIEW_PBX_FLASH1_BASE + REALVIEW_PBX_FLASH1_SIZE - 1,
  209. .flags = IORESOURCE_MEM,
  210. },
  211. };
  212. static struct resource realview_pbx_smsc911x_resources[] = {
  213. [0] = {
  214. .start = REALVIEW_PBX_ETH_BASE,
  215. .end = REALVIEW_PBX_ETH_BASE + SZ_64K - 1,
  216. .flags = IORESOURCE_MEM,
  217. },
  218. [1] = {
  219. .start = IRQ_PBX_ETH,
  220. .end = IRQ_PBX_ETH,
  221. .flags = IORESOURCE_IRQ,
  222. },
  223. };
  224. static struct resource realview_pbx_isp1761_resources[] = {
  225. [0] = {
  226. .start = REALVIEW_PBX_USB_BASE,
  227. .end = REALVIEW_PBX_USB_BASE + SZ_128K - 1,
  228. .flags = IORESOURCE_MEM,
  229. },
  230. [1] = {
  231. .start = IRQ_PBX_USB,
  232. .end = IRQ_PBX_USB,
  233. .flags = IORESOURCE_IRQ,
  234. },
  235. };
  236. static struct resource pmu_resources[] = {
  237. [0] = {
  238. .start = IRQ_PBX_PMU_CPU0,
  239. .end = IRQ_PBX_PMU_CPU0,
  240. .flags = IORESOURCE_IRQ,
  241. },
  242. [1] = {
  243. .start = IRQ_PBX_PMU_CPU1,
  244. .end = IRQ_PBX_PMU_CPU1,
  245. .flags = IORESOURCE_IRQ,
  246. },
  247. [2] = {
  248. .start = IRQ_PBX_PMU_CPU2,
  249. .end = IRQ_PBX_PMU_CPU2,
  250. .flags = IORESOURCE_IRQ,
  251. },
  252. [3] = {
  253. .start = IRQ_PBX_PMU_CPU3,
  254. .end = IRQ_PBX_PMU_CPU3,
  255. .flags = IORESOURCE_IRQ,
  256. },
  257. };
  258. static struct platform_device pmu_device = {
  259. .name = "arm-pmu",
  260. .id = ARM_PMU_DEVICE_CPU,
  261. .num_resources = ARRAY_SIZE(pmu_resources),
  262. .resource = pmu_resources,
  263. };
  264. static void __init gic_init_irq(void)
  265. {
  266. /* ARM PBX on-board GIC */
  267. if (core_tile_pbx11mp() || core_tile_pbxa9mp()) {
  268. gic_init(0, 29, __io_address(REALVIEW_PBX_TILE_GIC_DIST_BASE),
  269. __io_address(REALVIEW_PBX_TILE_GIC_CPU_BASE));
  270. } else {
  271. gic_init(0, IRQ_PBX_GIC_START,
  272. __io_address(REALVIEW_PBX_GIC_DIST_BASE),
  273. __io_address(REALVIEW_PBX_GIC_CPU_BASE));
  274. }
  275. }
  276. #ifdef CONFIG_HAVE_ARM_TWD
  277. static DEFINE_TWD_LOCAL_TIMER(twd_local_timer,
  278. REALVIEW_PBX_TILE_TWD_BASE,
  279. IRQ_LOCALTIMER);
  280. static void __init realview_pbx_twd_init(void)
  281. {
  282. int err = twd_local_timer_register(&twd_local_timer);
  283. if (err)
  284. pr_err("twd_local_timer_register failed %d\n", err);
  285. }
  286. #else
  287. #define realview_pbx_twd_init() do { } while(0)
  288. #endif
  289. static void __init realview_pbx_timer_init(void)
  290. {
  291. timer0_va_base = __io_address(REALVIEW_PBX_TIMER0_1_BASE);
  292. timer1_va_base = __io_address(REALVIEW_PBX_TIMER0_1_BASE) + 0x20;
  293. timer2_va_base = __io_address(REALVIEW_PBX_TIMER2_3_BASE);
  294. timer3_va_base = __io_address(REALVIEW_PBX_TIMER2_3_BASE) + 0x20;
  295. realview_timer_init(IRQ_PBX_TIMER0_1);
  296. realview_pbx_twd_init();
  297. }
  298. static struct sys_timer realview_pbx_timer = {
  299. .init = realview_pbx_timer_init,
  300. };
  301. static void realview_pbx_fixup(struct tag *tags, char **from,
  302. struct meminfo *meminfo)
  303. {
  304. #ifdef CONFIG_SPARSEMEM
  305. /*
  306. * Memory configuration with SPARSEMEM enabled on RealView PBX (see
  307. * asm/mach/memory.h for more information).
  308. */
  309. meminfo->bank[0].start = 0;
  310. meminfo->bank[0].size = SZ_256M;
  311. meminfo->bank[1].start = 0x20000000;
  312. meminfo->bank[1].size = SZ_512M;
  313. meminfo->bank[2].start = 0x80000000;
  314. meminfo->bank[2].size = SZ_256M;
  315. meminfo->nr_banks = 3;
  316. #else
  317. realview_fixup(tags, from, meminfo);
  318. #endif
  319. }
  320. static void realview_pbx_restart(char mode, const char *cmd)
  321. {
  322. void __iomem *reset_ctrl = __io_address(REALVIEW_SYS_RESETCTL);
  323. void __iomem *lock_ctrl = __io_address(REALVIEW_SYS_LOCK);
  324. /*
  325. * To reset, we hit the on-board reset register
  326. * in the system FPGA
  327. */
  328. __raw_writel(REALVIEW_SYS_LOCK_VAL, lock_ctrl);
  329. __raw_writel(0x00F0, reset_ctrl);
  330. __raw_writel(0x00F4, reset_ctrl);
  331. dsb();
  332. }
  333. static void __init realview_pbx_init(void)
  334. {
  335. int i;
  336. #ifdef CONFIG_CACHE_L2X0
  337. if (core_tile_pbxa9mp()) {
  338. void __iomem *l2x0_base =
  339. __io_address(REALVIEW_PBX_TILE_L220_BASE);
  340. /* set RAM latencies to 1 cycle for eASIC */
  341. writel(0, l2x0_base + L2X0_TAG_LATENCY_CTRL);
  342. writel(0, l2x0_base + L2X0_DATA_LATENCY_CTRL);
  343. /* 16KB way size, 8-way associativity, parity disabled
  344. * Bits: .. 0 0 0 0 1 00 1 0 1 001 0 000 0 .... .... .... */
  345. l2x0_init(l2x0_base, 0x02520000, 0xc0000fff);
  346. platform_device_register(&pmu_device);
  347. }
  348. #endif
  349. realview_flash_register(realview_pbx_flash_resources,
  350. ARRAY_SIZE(realview_pbx_flash_resources));
  351. realview_eth_register(NULL, realview_pbx_smsc911x_resources);
  352. platform_device_register(&realview_i2c_device);
  353. platform_device_register(&realview_cf_device);
  354. realview_usb_register(realview_pbx_isp1761_resources);
  355. for (i = 0; i < ARRAY_SIZE(amba_devs); i++) {
  356. struct amba_device *d = amba_devs[i];
  357. amba_device_register(d, &iomem_resource);
  358. }
  359. #ifdef CONFIG_LEDS
  360. leds_event = realview_leds_event;
  361. #endif
  362. }
  363. MACHINE_START(REALVIEW_PBX, "ARM-RealView PBX")
  364. /* Maintainer: ARM Ltd/Deep Blue Solutions Ltd */
  365. .atag_offset = 0x100,
  366. .fixup = realview_pbx_fixup,
  367. .map_io = realview_pbx_map_io,
  368. .init_early = realview_init_early,
  369. .init_irq = gic_init_irq,
  370. .timer = &realview_pbx_timer,
  371. .handle_irq = gic_handle_irq,
  372. .init_machine = realview_pbx_init,
  373. #ifdef CONFIG_ZONE_DMA
  374. .dma_zone_size = SZ_256M,
  375. #endif
  376. .restart = realview_pbx_restart,
  377. MACHINE_END