realview_pbx.c 11 KB

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