xref: /linux/arch/arm/mach-zynq/common.c (revision 732078c369f0b6ad9fe75c1faff721e91260bc5d)
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>
28c0675617SMichal Simek #include <linux/irqchip.h>
29b85a3ef4SJohn Linn 
303d64b449SArnd Bergmann #include <asm/mach/arch.h>
31b85a3ef4SJohn Linn #include <asm/mach/map.h>
3203e07595SJosh Cartwright #include <asm/mach/time.h>
333d64b449SArnd Bergmann #include <asm/mach-types.h>
34b85a3ef4SJohn Linn #include <asm/page.h>
359a45eb69SJosh Cartwright #include <asm/pgtable.h>
36*732078c3SMichal Simek #include <asm/smp_scu.h>
37b85a3ef4SJohn Linn #include <asm/hardware/cache-l2x0.h>
38b85a3ef4SJohn Linn 
39b85a3ef4SJohn Linn #include "common.h"
40b85a3ef4SJohn Linn 
41*732078c3SMichal Simek void __iomem *zynq_scu_base;
42*732078c3SMichal Simek 
43b85a3ef4SJohn Linn static struct of_device_id zynq_of_bus_ids[] __initdata = {
44b85a3ef4SJohn Linn 	{ .compatible = "simple-bus", },
45b85a3ef4SJohn Linn 	{}
46b85a3ef4SJohn Linn };
47b85a3ef4SJohn Linn 
48b85a3ef4SJohn Linn /**
49b85a3ef4SJohn Linn  * xilinx_init_machine() - System specific initialization, intended to be
50b85a3ef4SJohn Linn  *			   called from board specific initialization.
51b85a3ef4SJohn Linn  */
523d64b449SArnd Bergmann static void __init xilinx_init_machine(void)
53b85a3ef4SJohn Linn {
54b85a3ef4SJohn Linn 	/*
55b85a3ef4SJohn Linn 	 * 64KB way size, 8-way associativity, parity disabled
56b85a3ef4SJohn Linn 	 */
570fcfdbcaSJosh Cartwright 	l2x0_of_init(0x02060000, 0xF0F0FFFF);
58b85a3ef4SJohn Linn 
59b85a3ef4SJohn Linn 	of_platform_bus_probe(NULL, zynq_of_bus_ids, NULL);
60b85a3ef4SJohn Linn }
61b85a3ef4SJohn Linn 
6203e07595SJosh Cartwright static void __init xilinx_zynq_timer_init(void)
6303e07595SJosh Cartwright {
640f586fbfSJosh Cartwright 	struct device_node *np;
650f586fbfSJosh Cartwright 	void __iomem *slcr;
660f586fbfSJosh Cartwright 
670f586fbfSJosh Cartwright 	np = of_find_compatible_node(NULL, NULL, "xlnx,zynq-slcr");
680f586fbfSJosh Cartwright 	slcr = of_iomap(np, 0);
690f586fbfSJosh Cartwright 	WARN_ON(!slcr);
700f586fbfSJosh Cartwright 
710f586fbfSJosh Cartwright 	xilinx_zynq_clocks_init(slcr);
720f586fbfSJosh Cartwright 
73c5263bb8SMichal Simek 	clocksource_of_init();
7403e07595SJosh Cartwright }
7503e07595SJosh Cartwright 
76*732078c3SMichal Simek static struct map_desc zynq_cortex_a9_scu_map __initdata = {
77*732078c3SMichal Simek 	.length	= SZ_256,
78*732078c3SMichal Simek 	.type	= MT_DEVICE,
79*732078c3SMichal Simek };
80*732078c3SMichal Simek 
81*732078c3SMichal Simek static void __init zynq_scu_map_io(void)
82*732078c3SMichal Simek {
83*732078c3SMichal Simek 	unsigned long base;
84*732078c3SMichal Simek 
85*732078c3SMichal Simek 	base = scu_a9_get_base();
86*732078c3SMichal Simek 	zynq_cortex_a9_scu_map.pfn = __phys_to_pfn(base);
87*732078c3SMichal Simek 	/* Expected address is in vmalloc area that's why simple assign here */
88*732078c3SMichal Simek 	zynq_cortex_a9_scu_map.virtual = base;
89*732078c3SMichal Simek 	iotable_init(&zynq_cortex_a9_scu_map, 1);
90*732078c3SMichal Simek 	zynq_scu_base = (void __iomem *)base;
91*732078c3SMichal Simek 	BUG_ON(!zynq_scu_base);
92*732078c3SMichal Simek }
93*732078c3SMichal Simek 
94b85a3ef4SJohn Linn /**
95b85a3ef4SJohn Linn  * xilinx_map_io() - Create memory mappings needed for early I/O.
96b85a3ef4SJohn Linn  */
973d64b449SArnd Bergmann static void __init xilinx_map_io(void)
98b85a3ef4SJohn Linn {
99385f02b1SJosh Cartwright 	debug_ll_io_init();
100*732078c3SMichal Simek 	zynq_scu_map_io();
101b85a3ef4SJohn Linn }
1023d64b449SArnd Bergmann 
1033d64b449SArnd Bergmann static const char *xilinx_dt_match[] = {
104e06f1a9eSJosh Cartwright 	"xlnx,zynq-zc702",
105e06f1a9eSJosh Cartwright 	"xlnx,zynq-7000",
1063d64b449SArnd Bergmann 	NULL
1073d64b449SArnd Bergmann };
1083d64b449SArnd Bergmann 
1093d64b449SArnd Bergmann MACHINE_START(XILINX_EP107, "Xilinx Zynq Platform")
1103d64b449SArnd Bergmann 	.map_io		= xilinx_map_io,
1110529e315SRob Herring 	.init_irq	= irqchip_init,
1123d64b449SArnd Bergmann 	.init_machine	= xilinx_init_machine,
1136bb27d73SStephen Warren 	.init_time	= xilinx_zynq_timer_init,
1143d64b449SArnd Bergmann 	.dt_compat	= xilinx_dt_match,
1153d64b449SArnd Bergmann MACHINE_END
116