xref: /linux/arch/arm/mach-zynq/common.c (revision 46f5b96085b03f9e71a0134de77efc6a1f9d84c3)
1b85a3ef4SJohn Linn /*
2b85a3ef4SJohn Linn  * This file contains common code that is intended to be used across
3b85a3ef4SJohn Linn  * boards so that it's not replicated.
4b85a3ef4SJohn Linn  *
5b85a3ef4SJohn Linn  *  Copyright (C) 2011 Xilinx
6b85a3ef4SJohn Linn  *
7b85a3ef4SJohn Linn  * This software is licensed under the terms of the GNU General Public
8b85a3ef4SJohn Linn  * License version 2, as published by the Free Software Foundation, and
9b85a3ef4SJohn Linn  * may be copied, distributed, and modified under those terms.
10b85a3ef4SJohn Linn  *
11b85a3ef4SJohn Linn  * This program is distributed in the hope that it will be useful,
12b85a3ef4SJohn Linn  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13b85a3ef4SJohn Linn  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14b85a3ef4SJohn Linn  * GNU General Public License for more details.
15b85a3ef4SJohn Linn  */
16b85a3ef4SJohn Linn 
17b85a3ef4SJohn Linn #include <linux/init.h>
18b85a3ef4SJohn Linn #include <linux/kernel.h>
19b85a3ef4SJohn Linn #include <linux/cpumask.h>
20b85a3ef4SJohn Linn #include <linux/platform_device.h>
21b85a3ef4SJohn Linn #include <linux/clk.h>
220f586fbfSJosh Cartwright #include <linux/clk/zynq.h>
23e932900aSMichal Simek #include <linux/clocksource.h>
240f586fbfSJosh Cartwright #include <linux/of_address.h>
25b85a3ef4SJohn Linn #include <linux/of_irq.h>
26b85a3ef4SJohn Linn #include <linux/of_platform.h>
273d64b449SArnd Bergmann #include <linux/of.h>
28*46f5b960SMichal Simek #include <linux/memblock.h>
299f4f5d26SSoren Brinkmann #include <linux/irqchip.h>
309f4f5d26SSoren Brinkmann #include <linux/irqchip/arm-gic.h>
31b85a3ef4SJohn Linn 
323d64b449SArnd Bergmann #include <asm/mach/arch.h>
33b85a3ef4SJohn Linn #include <asm/mach/map.h>
3403e07595SJosh Cartwright #include <asm/mach/time.h>
353d64b449SArnd Bergmann #include <asm/mach-types.h>
36b85a3ef4SJohn Linn #include <asm/page.h>
379a45eb69SJosh Cartwright #include <asm/pgtable.h>
38732078c3SMichal Simek #include <asm/smp_scu.h>
39b85a3ef4SJohn Linn #include <asm/hardware/cache-l2x0.h>
40b85a3ef4SJohn Linn 
41b85a3ef4SJohn Linn #include "common.h"
42b85a3ef4SJohn Linn 
43732078c3SMichal Simek void __iomem *zynq_scu_base;
44732078c3SMichal Simek 
45*46f5b960SMichal Simek /**
46*46f5b960SMichal Simek  * zynq_memory_init - Initialize special memory
47*46f5b960SMichal Simek  *
48*46f5b960SMichal Simek  * We need to stop things allocating the low memory as DMA can't work in
49*46f5b960SMichal Simek  * the 1st 512K of memory.
50*46f5b960SMichal Simek  */
51*46f5b960SMichal Simek static void __init zynq_memory_init(void)
52*46f5b960SMichal Simek {
53*46f5b960SMichal Simek 	if (!__pa(PAGE_OFFSET))
54*46f5b960SMichal Simek 		memblock_reserve(__pa(PAGE_OFFSET), __pa(swapper_pg_dir));
55*46f5b960SMichal Simek }
56*46f5b960SMichal Simek 
573e8ceca6SDaniel Lezcano static struct platform_device zynq_cpuidle_device = {
583e8ceca6SDaniel Lezcano 	.name = "cpuidle-zynq",
593e8ceca6SDaniel Lezcano };
603e8ceca6SDaniel Lezcano 
61b85a3ef4SJohn Linn /**
62889faa88SMichal Simek  * zynq_init_machine - System specific initialization, intended to be
63b85a3ef4SJohn Linn  *		       called from board specific initialization.
64b85a3ef4SJohn Linn  */
65889faa88SMichal Simek static void __init zynq_init_machine(void)
66b85a3ef4SJohn Linn {
67b85a3ef4SJohn Linn 	/*
68b85a3ef4SJohn Linn 	 * 64KB way size, 8-way associativity, parity disabled
69b85a3ef4SJohn Linn 	 */
700fcfdbcaSJosh Cartwright 	l2x0_of_init(0x02060000, 0xF0F0FFFF);
71b85a3ef4SJohn Linn 
72f4d5d7b7SSoren Brinkmann 	of_platform_populate(NULL, of_default_bus_match_table, NULL, NULL);
733e8ceca6SDaniel Lezcano 
743e8ceca6SDaniel Lezcano 	platform_device_register(&zynq_cpuidle_device);
75b85a3ef4SJohn Linn }
76b85a3ef4SJohn Linn 
77889faa88SMichal Simek static void __init zynq_timer_init(void)
7803e07595SJosh Cartwright {
7964b889b3SMichal Simek 	zynq_slcr_init();
80c5263bb8SMichal Simek 	clocksource_of_init();
8103e07595SJosh Cartwright }
8203e07595SJosh Cartwright 
83732078c3SMichal Simek static struct map_desc zynq_cortex_a9_scu_map __initdata = {
84732078c3SMichal Simek 	.length	= SZ_256,
85732078c3SMichal Simek 	.type	= MT_DEVICE,
86732078c3SMichal Simek };
87732078c3SMichal Simek 
88732078c3SMichal Simek static void __init zynq_scu_map_io(void)
89732078c3SMichal Simek {
90732078c3SMichal Simek 	unsigned long base;
91732078c3SMichal Simek 
92732078c3SMichal Simek 	base = scu_a9_get_base();
93732078c3SMichal Simek 	zynq_cortex_a9_scu_map.pfn = __phys_to_pfn(base);
94732078c3SMichal Simek 	/* Expected address is in vmalloc area that's why simple assign here */
95732078c3SMichal Simek 	zynq_cortex_a9_scu_map.virtual = base;
96732078c3SMichal Simek 	iotable_init(&zynq_cortex_a9_scu_map, 1);
97732078c3SMichal Simek 	zynq_scu_base = (void __iomem *)base;
98732078c3SMichal Simek 	BUG_ON(!zynq_scu_base);
99732078c3SMichal Simek }
100732078c3SMichal Simek 
101b85a3ef4SJohn Linn /**
102889faa88SMichal Simek  * zynq_map_io - Create memory mappings needed for early I/O.
103b85a3ef4SJohn Linn  */
104889faa88SMichal Simek static void __init zynq_map_io(void)
105b85a3ef4SJohn Linn {
106385f02b1SJosh Cartwright 	debug_ll_io_init();
107732078c3SMichal Simek 	zynq_scu_map_io();
108b85a3ef4SJohn Linn }
1093d64b449SArnd Bergmann 
1109f4f5d26SSoren Brinkmann static void __init zynq_irq_init(void)
1119f4f5d26SSoren Brinkmann {
1129f4f5d26SSoren Brinkmann 	gic_arch_extn.flags = IRQCHIP_SKIP_SET_WAKE | IRQCHIP_MASK_ON_SUSPEND;
1139f4f5d26SSoren Brinkmann 	irqchip_init();
1149f4f5d26SSoren Brinkmann }
1159f4f5d26SSoren Brinkmann 
116fe08bf9fSVincent Stehlé static void zynq_system_reset(enum reboot_mode mode, const char *cmd)
11796790f0aSMichal Simek {
11896790f0aSMichal Simek 	zynq_slcr_system_reset();
11996790f0aSMichal Simek }
12096790f0aSMichal Simek 
121889faa88SMichal Simek static const char * const zynq_dt_match[] = {
122e06f1a9eSJosh Cartwright 	"xlnx,zynq-7000",
1233d64b449SArnd Bergmann 	NULL
1243d64b449SArnd Bergmann };
1253d64b449SArnd Bergmann 
126514a5908SArnd Bergmann DT_MACHINE_START(XILINX_EP107, "Xilinx Zynq Platform")
127aa7eb2bbSMichal Simek 	.smp		= smp_ops(zynq_smp_ops),
128889faa88SMichal Simek 	.map_io		= zynq_map_io,
1299f4f5d26SSoren Brinkmann 	.init_irq	= zynq_irq_init,
130889faa88SMichal Simek 	.init_machine	= zynq_init_machine,
131889faa88SMichal Simek 	.init_time	= zynq_timer_init,
132889faa88SMichal Simek 	.dt_compat	= zynq_dt_match,
133*46f5b960SMichal Simek 	.reserve	= zynq_memory_init,
13496790f0aSMichal Simek 	.restart	= zynq_system_reset,
1353d64b449SArnd Bergmann MACHINE_END
136