2 * Copyright (c) 2012 Ganbold Tsagaankhuu <ganbold@freebsd.org>
3 * Copyright (c) 2015-2016 Emmanuel Vadot <manu@bidouilliste.com>
6 * This code is derived from software written for Brini by Mark Brinicombe
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
18 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
21 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 * from: FreeBSD: //depot/projects/arm/src/sys/arm/ti/ti_machdep.c
33 #include "opt_platform.h"
35 #include <sys/cdefs.h>
36 __FBSDID("$FreeBSD$");
38 #define _ARM32_BUS_DMA_PRIVATE
39 #include <sys/param.h>
40 #include <sys/systm.h>
46 #include <machine/bus.h>
47 #include <machine/devmap.h>
48 #include <machine/machdep.h>
49 #include <machine/platformvar.h>
51 #include <dev/fdt/fdt_common.h>
53 #include <arm/allwinner/a10_wdog.h>
54 #include <arm/allwinner/allwinner_machdep.h>
56 #include "platform_if.h"
58 static u_int soc_type;
59 static u_int soc_family;
62 a10_attach(platform_t plat)
64 soc_type = ALLWINNERSOC_A10;
65 soc_family = ALLWINNERSOC_SUN4I;
70 a20_attach(platform_t plat)
72 soc_type = ALLWINNERSOC_A20;
73 soc_family = ALLWINNERSOC_SUN7I;
80 allwinner_lastaddr(platform_t plat)
83 return (arm_devmap_lastaddr());
87 * Set up static device mappings.
89 * This covers all the on-chip device with 1MB section mappings, which is good
90 * for performance (uses fewer TLB entries for device access).
92 * XXX It also covers a block of SRAM and some GPU (mali400) stuff that maybe
93 * shouldn't be device-mapped. The original code mapped a 4MB block, but
94 * perhaps a 1MB block would be more appropriate.
97 allwinner_devmap_init(platform_t plat)
100 arm_devmap_add_entry(0x01C00000, 0x00400000); /* 4MB */
105 struct arm32_dma_range *
106 bus_dma_get_range(void)
112 bus_dma_get_range_nb(void)
120 a10wd_watchdog_reset();
121 printf("Reset failed!\n");
125 static platform_method_t a10_methods[] = {
126 PLATFORMMETHOD(platform_attach, a10_attach),
127 PLATFORMMETHOD(platform_lastaddr, allwinner_lastaddr),
128 PLATFORMMETHOD(platform_devmap_init, allwinner_devmap_init),
133 static platform_method_t a20_methods[] = {
134 PLATFORMMETHOD(platform_attach, a20_attach),
135 PLATFORMMETHOD(platform_lastaddr, allwinner_lastaddr),
136 PLATFORMMETHOD(platform_devmap_init, allwinner_devmap_init),
142 allwinner_soc_type(void)
148 allwinner_soc_family(void)
153 FDT_PLATFORM_DEF(a10, "a10", 0, "allwinner,sun4i-a10");
154 FDT_PLATFORM_DEF(a20, "a20", 0, "allwinner,sun7i-a20");