2 * Copyright (c) 2014-2017 Ruslan Bukin <br@bsdpad.com>
5 * This software was developed by SRI International and the University of
6 * Cambridge Computer Laboratory under DARPA/AFRL contract (FA8750-10-C-0237)
7 * ("CTSRD"), as part of the DARPA CRASH research programme.
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions
12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 * 2. Redistributions in binary form must reproduce the above copyright
15 * notice, this list of conditions and the following disclaimer in the
16 * documentation and/or other materials provided with the distribution.
18 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
19 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
22 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
24 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
26 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
27 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 #include "opt_platform.h"
33 #include <sys/cdefs.h>
34 __FBSDID("$FreeBSD$");
36 #include <sys/param.h>
37 #include <sys/systm.h>
39 #include <sys/devmap.h>
43 #include <dev/ofw/openfirm.h>
45 #include <machine/armreg.h>
46 #include <machine/bus.h>
47 #include <machine/fdt.h>
48 #include <machine/machdep.h>
49 #include <machine/platform.h>
50 #include <machine/platformvar.h>
52 #include <arm/altera/socfpga/socfpga_mp.h>
53 #include <arm/altera/socfpga/socfpga_rstmgr.h>
55 #include "platform_if.h"
57 #if defined(SOC_ALTERA_CYCLONE5)
59 socfpga_devmap_init(platform_t plat)
63 devmap_add_entry(0xffc00000, 0x100000);
68 * We use static device map for USB due to some bug in the Altera
69 * which throws Translation Fault (P) exception on high load.
70 * It might be caused due to some power save options being turned
71 * on or something else.
73 devmap_add_entry(0xffb00000, 0x100000);
76 devmap_add_entry(0xff700000, 0x100000);
79 devmap_add_entry(0xfff00000, 0x100000);
81 /* FPGA memory window, 256MB */
82 devmap_add_entry(0xd0000000, 0x10000000);
88 #if defined(SOC_ALTERA_ARRIA10)
90 socfpga_a10_devmap_init(platform_t plat)
94 devmap_add_entry(0xffc00000, 0x100000);
97 devmap_add_entry(0xffb00000, 0x100000);
100 devmap_add_entry(0xff800000, 0x100000);
103 devmap_add_entry(0xfff00000, 0x100000);
110 _socfpga_cpu_reset(bus_size_t reg)
116 if (rstmgr_warmreset(reg) == 0)
119 node = OF_finddevice("/soc/rstmgr");
123 if ((OF_getencprop(node, "reg", &paddr, sizeof(paddr))) > 0) {
124 if (bus_space_map(fdtbus_bs_tag, paddr, 0x8, 0, &vaddr) == 0) {
125 bus_space_write_4(fdtbus_bs_tag, vaddr,
126 reg, CTRL_SWWARMRSTREQ);
134 #if defined(SOC_ALTERA_CYCLONE5)
136 socfpga_cpu_reset(platform_t plat)
139 _socfpga_cpu_reset(RSTMGR_CTRL);
143 #if defined(SOC_ALTERA_ARRIA10)
145 socfpga_a10_cpu_reset(platform_t plat)
148 _socfpga_cpu_reset(RSTMGR_A10_CTRL);
152 #if defined(SOC_ALTERA_CYCLONE5)
153 static platform_method_t socfpga_methods[] = {
154 PLATFORMMETHOD(platform_devmap_init, socfpga_devmap_init),
155 PLATFORMMETHOD(platform_cpu_reset, socfpga_cpu_reset),
157 PLATFORMMETHOD(platform_mp_setmaxid, socfpga_mp_setmaxid),
158 PLATFORMMETHOD(platform_mp_start_ap, socfpga_mp_start_ap),
162 FDT_PLATFORM_DEF(socfpga, "socfpga", 0, "altr,socfpga-cyclone5", 200);
165 #if defined(SOC_ALTERA_ARRIA10)
166 static platform_method_t socfpga_a10_methods[] = {
167 PLATFORMMETHOD(platform_devmap_init, socfpga_a10_devmap_init),
168 PLATFORMMETHOD(platform_cpu_reset, socfpga_a10_cpu_reset),
170 PLATFORMMETHOD(platform_mp_setmaxid, socfpga_mp_setmaxid),
171 PLATFORMMETHOD(platform_mp_start_ap, socfpga_a10_mp_start_ap),
175 FDT_PLATFORM_DEF(socfpga_a10, "socfpga", 0, "altr,socfpga-arria10", 200);