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