1a9caca6aSWojciech A. Koszek /*-
2*4d846d26SWarner Losh * SPDX-License-Identifier: BSD-2-Clause
3af3dc4a7SPedro 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 */
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/param.h>
39a9caca6aSWojciech A. Koszek #include <sys/systm.h>
40a9caca6aSWojciech A. Koszek #include <sys/bus.h>
4130b72b68SRuslan Bukin #include <sys/devmap.h>
42a9caca6aSWojciech A. Koszek
43a9caca6aSWojciech A. Koszek #include <vm/vm.h>
44a9caca6aSWojciech A. Koszek #include <vm/pmap.h>
45a9caca6aSWojciech A. Koszek
46a9caca6aSWojciech A. Koszek #include <machine/bus.h>
47a9caca6aSWojciech A. Koszek #include <machine/machdep.h>
4827521ff8SAndrew Turner #include <machine/platform.h>
49dc59c854SAndrew Turner #include <machine/platformvar.h>
50a9caca6aSWojciech A. Koszek
513185adf0SAndrew Turner #include <arm/xilinx/zy7_machdep.h>
52a9caca6aSWojciech A. Koszek #include <arm/xilinx/zy7_reg.h>
53a9caca6aSWojciech A. Koszek
54dc59c854SAndrew Turner #include "platform_if.h"
5575f48c23SAndrew Turner #include "platform_pl310_if.h"
56dc59c854SAndrew Turner
57a9caca6aSWojciech A. Koszek void (*zynq7_cpu_reset)(void);
58a9caca6aSWojciech A. Koszek
59a9caca6aSWojciech A. Koszek /*
604c053598SIan Lepore * Set up static device mappings. Not strictly necessary -- simplebus will
614c053598SIan Lepore * dynamically establish mappings as needed -- but doing it this way gets us
624c053598SIan Lepore * nice efficient 1MB section mappings.
63a9caca6aSWojciech A. Koszek */
64dc59c854SAndrew Turner static int
zynq7_devmap_init(platform_t plat)65dc59c854SAndrew Turner zynq7_devmap_init(platform_t plat)
66a9caca6aSWojciech A. Koszek {
67a9caca6aSWojciech A. Koszek
6830b72b68SRuslan Bukin devmap_add_entry(ZYNQ7_PSIO_HWBASE, ZYNQ7_PSIO_SIZE);
6930b72b68SRuslan Bukin devmap_add_entry(ZYNQ7_PSCTL_HWBASE, ZYNQ7_PSCTL_SIZE);
70a9caca6aSWojciech A. Koszek
71a9caca6aSWojciech A. Koszek return (0);
72a9caca6aSWojciech A. Koszek }
73a9caca6aSWojciech A. Koszek
74dc59c854SAndrew Turner static void
zynq7_do_cpu_reset(platform_t plat)75dc59c854SAndrew Turner zynq7_do_cpu_reset(platform_t plat)
76a9caca6aSWojciech A. Koszek {
77a9caca6aSWojciech A. Koszek if (zynq7_cpu_reset != NULL)
78a9caca6aSWojciech A. Koszek (*zynq7_cpu_reset)();
79a9caca6aSWojciech A. Koszek
80a9caca6aSWojciech A. Koszek printf("cpu_reset: no platform cpu_reset. hanging.\n");
81a9caca6aSWojciech A. Koszek for (;;)
82a9caca6aSWojciech A. Koszek ;
83a9caca6aSWojciech A. Koszek }
84dc59c854SAndrew Turner
85dc59c854SAndrew Turner static platform_method_t zynq7_methods[] = {
86dc59c854SAndrew Turner PLATFORMMETHOD(platform_devmap_init, zynq7_devmap_init),
87dc59c854SAndrew Turner PLATFORMMETHOD(platform_cpu_reset, zynq7_do_cpu_reset),
88dc59c854SAndrew Turner
89dc59c854SAndrew Turner #ifdef SMP
90dc59c854SAndrew Turner PLATFORMMETHOD(platform_mp_setmaxid, zynq7_mp_setmaxid),
91dc59c854SAndrew Turner PLATFORMMETHOD(platform_mp_start_ap, zynq7_mp_start_ap),
92dc59c854SAndrew Turner #endif
93dc59c854SAndrew Turner
9475f48c23SAndrew Turner PLATFORMMETHOD(platform_pl310_init, zynq7_pl310_init),
9575f48c23SAndrew Turner
96dc59c854SAndrew Turner PLATFORMMETHOD_END,
97dc59c854SAndrew Turner };
98dc59c854SAndrew Turner
9957521c21SAndrew Turner FDT_PLATFORM_DEF(zynq7, "zynq7", 0, "xlnx,zynq-7000", 200);
100