xref: /freebsd/sys/arm/xilinx/zy7_machdep.c (revision 75f48c23ea1d421d50f31ce7629553eb4191ced8)
1a9caca6aSWojciech A. Koszek /*-
240713190SWojciech A. Koszek  * Copyright (c) 2013 Thomas Skibo
3a9caca6aSWojciech A. Koszek  * All rights reserved.
4a9caca6aSWojciech A. Koszek  *
5a9caca6aSWojciech A. Koszek  * Redistribution and use in source and binary forms, with or without
640713190SWojciech A. Koszek  * modification, are permitted provided that the following conditions
740713190SWojciech A. Koszek  * are met:
840713190SWojciech A. Koszek  * 1. Redistributions of source code must retain the above copyright
9a9caca6aSWojciech A. Koszek  *    notice, this list of conditions and the following disclaimer.
1040713190SWojciech A. Koszek  * 2. Redistributions in binary form must reproduce the above copyright
11a9caca6aSWojciech A. Koszek  *    notice, this list of conditions and the following disclaimer in the
12a9caca6aSWojciech A. Koszek  *    documentation and/or other materials provided with the distribution.
13a9caca6aSWojciech A. Koszek  *
1440713190SWojciech A. Koszek  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
1540713190SWojciech A. Koszek  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16a9caca6aSWojciech A. Koszek  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
1740713190SWojciech A. Koszek  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
1840713190SWojciech A. Koszek  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
1940713190SWojciech A. Koszek  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
2040713190SWojciech A. Koszek  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
2140713190SWojciech A. Koszek  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22a9caca6aSWojciech A. Koszek  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2340713190SWojciech A. Koszek  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2440713190SWojciech A. Koszek  * SUCH DAMAGE.
25a9caca6aSWojciech A. Koszek  *
2640713190SWojciech A. Koszek  * $FreeBSD$
27a9caca6aSWojciech A. Koszek  */
28a9caca6aSWojciech A. Koszek 
2940713190SWojciech A. Koszek /*
3040713190SWojciech A. Koszek  * Machine dependent code for Xilinx Zynq-7000 Soc.
31a9caca6aSWojciech A. Koszek  *
32a9caca6aSWojciech A. Koszek  * Reference: Zynq-7000 All Programmable SoC Technical Reference Manual.
33a9caca6aSWojciech A. Koszek  * (v1.4) November 16, 2012.  Xilinx doc UG585.
34a9caca6aSWojciech A. Koszek  */
35a9caca6aSWojciech A. Koszek 
36dc59c854SAndrew Turner #include "opt_platform.h"
37dc59c854SAndrew Turner 
38a9caca6aSWojciech A. Koszek #include <sys/cdefs.h>
39a9caca6aSWojciech A. Koszek __FBSDID("$FreeBSD$");
40a9caca6aSWojciech A. Koszek 
41a9caca6aSWojciech A. Koszek #include <sys/param.h>
42a9caca6aSWojciech A. Koszek #include <sys/systm.h>
43a9caca6aSWojciech A. Koszek #include <sys/bus.h>
4430b72b68SRuslan Bukin #include <sys/devmap.h>
45a9caca6aSWojciech A. Koszek 
46a9caca6aSWojciech A. Koszek #include <vm/vm.h>
47a9caca6aSWojciech A. Koszek #include <vm/pmap.h>
48a9caca6aSWojciech A. Koszek 
49a9caca6aSWojciech A. Koszek #include <machine/bus.h>
50a9caca6aSWojciech A. Koszek #include <machine/machdep.h>
5127521ff8SAndrew Turner #include <machine/platform.h>
52dc59c854SAndrew Turner #include <machine/platformvar.h>
53a9caca6aSWojciech A. Koszek 
543185adf0SAndrew Turner #include <arm/xilinx/zy7_machdep.h>
55a9caca6aSWojciech A. Koszek #include <arm/xilinx/zy7_reg.h>
56a9caca6aSWojciech A. Koszek 
57dc59c854SAndrew Turner #include "platform_if.h"
58*75f48c23SAndrew Turner #include "platform_pl310_if.h"
59dc59c854SAndrew Turner 
60a9caca6aSWojciech A. Koszek void (*zynq7_cpu_reset)(void);
61a9caca6aSWojciech A. Koszek 
62a9caca6aSWojciech A. Koszek /*
634c053598SIan Lepore  * Set up static device mappings.  Not strictly necessary -- simplebus will
644c053598SIan Lepore  * dynamically establish mappings as needed -- but doing it this way gets us
654c053598SIan Lepore  * nice efficient 1MB section mappings.
66a9caca6aSWojciech A. Koszek  */
67dc59c854SAndrew Turner static int
68dc59c854SAndrew Turner zynq7_devmap_init(platform_t plat)
69a9caca6aSWojciech A. Koszek {
70a9caca6aSWojciech A. Koszek 
7130b72b68SRuslan Bukin 	devmap_add_entry(ZYNQ7_PSIO_HWBASE, ZYNQ7_PSIO_SIZE);
7230b72b68SRuslan Bukin 	devmap_add_entry(ZYNQ7_PSCTL_HWBASE, ZYNQ7_PSCTL_SIZE);
73a9caca6aSWojciech A. Koszek 
74a9caca6aSWojciech A. Koszek 	return (0);
75a9caca6aSWojciech A. Koszek }
76a9caca6aSWojciech A. Koszek 
77dc59c854SAndrew Turner static void
78dc59c854SAndrew Turner zynq7_do_cpu_reset(platform_t plat)
79a9caca6aSWojciech A. Koszek {
80a9caca6aSWojciech A. Koszek 	if (zynq7_cpu_reset != NULL)
81a9caca6aSWojciech A. Koszek 		(*zynq7_cpu_reset)();
82a9caca6aSWojciech A. Koszek 
83a9caca6aSWojciech A. Koszek 	printf("cpu_reset: no platform cpu_reset.  hanging.\n");
84a9caca6aSWojciech A. Koszek 	for (;;)
85a9caca6aSWojciech A. Koszek 		;
86a9caca6aSWojciech A. Koszek }
87dc59c854SAndrew Turner 
88dc59c854SAndrew Turner static platform_method_t zynq7_methods[] = {
89dc59c854SAndrew Turner 	PLATFORMMETHOD(platform_devmap_init,	zynq7_devmap_init),
90dc59c854SAndrew Turner 	PLATFORMMETHOD(platform_cpu_reset,	zynq7_do_cpu_reset),
91dc59c854SAndrew Turner 
92dc59c854SAndrew Turner #ifdef SMP
93dc59c854SAndrew Turner 	PLATFORMMETHOD(platform_mp_setmaxid,	zynq7_mp_setmaxid),
94dc59c854SAndrew Turner 	PLATFORMMETHOD(platform_mp_start_ap,	zynq7_mp_start_ap),
95dc59c854SAndrew Turner #endif
96dc59c854SAndrew Turner 
97*75f48c23SAndrew Turner 	PLATFORMMETHOD(platform_pl310_init,	zynq7_pl310_init),
98*75f48c23SAndrew Turner 
99dc59c854SAndrew Turner 	PLATFORMMETHOD_END,
100dc59c854SAndrew Turner };
101dc59c854SAndrew Turner 
10257521c21SAndrew Turner FDT_PLATFORM_DEF(zynq7, "zynq7", 0, "xlnx,zynq-7000", 200);
103