1239281Sgonzo/*-
2239281Sgonzo * Copyright (c) 1994-1998 Mark Brinicombe.
3239281Sgonzo * Copyright (c) 1994 Brini.
4239281Sgonzo * All rights reserved.
5239281Sgonzo *
6239281Sgonzo * This code is derived from software written for Brini by Mark Brinicombe
7239281Sgonzo *
8239281Sgonzo * Redistribution and use in source and binary forms, with or without
9239281Sgonzo * modification, are permitted provided that the following conditions
10239281Sgonzo * are met:
11239281Sgonzo * 1. Redistributions of source code must retain the above copyright
12239281Sgonzo *    notice, this list of conditions and the following disclaimer.
13239281Sgonzo * 2. Redistributions in binary form must reproduce the above copyright
14239281Sgonzo *    notice, this list of conditions and the following disclaimer in the
15239281Sgonzo *    documentation and/or other materials provided with the distribution.
16239281Sgonzo * 3. All advertising materials mentioning features or use of this software
17239281Sgonzo *    must display the following acknowledgement:
18239281Sgonzo *      This product includes software developed by Brini.
19239281Sgonzo * 4. The name of the company nor the name of the author may be used to
20239281Sgonzo *    endorse or promote products derived from this software without specific
21239281Sgonzo *    prior written permission.
22239281Sgonzo *
23239281Sgonzo * THIS SOFTWARE IS PROVIDED BY BRINI ``AS IS'' AND ANY EXPRESS OR IMPLIED
24239281Sgonzo * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
25239281Sgonzo * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
26239281Sgonzo * IN NO EVENT SHALL BRINI OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
27239281Sgonzo * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
28239281Sgonzo * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
29239281Sgonzo * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30239281Sgonzo * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31239281Sgonzo * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
32239281Sgonzo * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
33239281Sgonzo * SUCH DAMAGE.
34239281Sgonzo *
35239281Sgonzo * from: FreeBSD: //depot/projects/arm/src/sys/arm/at91/kb920x_machdep.c, rev 45
36239281Sgonzo */
37239281Sgonzo
38239281Sgonzo#include "opt_platform.h"
39239281Sgonzo
40239281Sgonzo#include <sys/cdefs.h>
41239281Sgonzo__FBSDID("$FreeBSD: stable/11/sys/arm/ti/ti_machdep.c 331907 2018-04-03 06:06:39Z gonzo $");
42239281Sgonzo
43239281Sgonzo#include <sys/param.h>
44239281Sgonzo#include <sys/systm.h>
45239281Sgonzo#include <sys/bus.h>
46298627Sbr#include <sys/devmap.h>
47239281Sgonzo
48239281Sgonzo#include <vm/vm.h>
49239281Sgonzo#include <vm/pmap.h>
50242531Sandrew
51242531Sandrew#include <machine/bus.h>
52242531Sandrew#include <machine/machdep.h>
53266334Sandrew#include <machine/platformvar.h>
54239281Sgonzo
55239281Sgonzo#include <arm/ti/omap4/omap4_reg.h>
56239281Sgonzo
57266334Sandrew#include "platform_if.h"
58266334Sandrew
59260292Sianvoid (*ti_cpu_reset)(void) = NULL;
60239281Sgonzo
61266334Sandrewstatic vm_offset_t
62266334Sandrewti_lastaddr(platform_t plat)
63240846Sandrew{
64240846Sandrew
65298627Sbr	return (devmap_lastaddr());
66240846Sandrew}
67240846Sandrew
68239281Sgonzo/*
69260292Sian * Construct static devmap entries to map out the most frequently used
70260292Sian * peripherals using 1mb section mappings.
71239281Sgonzo */
72266334Sandrew#if defined(SOC_OMAP4)
73266334Sandrewstatic int
74266334Sandrewti_omap4_devmap_init(platform_t plat)
75239281Sgonzo{
76298627Sbr	devmap_add_entry(0x48000000, 0x01000000); /*16mb L4_PER devices */
77298627Sbr	devmap_add_entry(0x4A000000, 0x01000000); /*16mb L4_CFG devices */
78266334Sandrew	return (0);
79266334Sandrew}
80266334Sandrew#endif
81266334Sandrew
82266334Sandrew#if defined(SOC_TI_AM335X)
83266334Sandrewstatic int
84266334Sandrewti_am335x_devmap_init(platform_t plat)
85266334Sandrew{
86266334Sandrew
87298627Sbr	devmap_add_entry(0x44C00000, 0x00400000); /* 4mb L4_WKUP devices*/
88298627Sbr	devmap_add_entry(0x47400000, 0x00100000); /* 1mb USB            */
89298627Sbr	devmap_add_entry(0x47800000, 0x00100000); /* 1mb mmchs2         */
90298627Sbr	devmap_add_entry(0x48000000, 0x01000000); /*16mb L4_PER devices */
91298627Sbr	devmap_add_entry(0x49000000, 0x00100000); /* 1mb edma3          */
92298627Sbr	devmap_add_entry(0x49800000, 0x00300000); /* 3mb edma3          */
93298627Sbr	devmap_add_entry(0x4A000000, 0x01000000); /*16mb L4_FAST devices*/
94239281Sgonzo	return (0);
95239281Sgonzo}
96266334Sandrew#endif
97239281Sgonzo
98331893Sgonzostatic void
99331893Sgonzoti_plat_cpu_reset(platform_t plat)
100239281Sgonzo{
101239281Sgonzo	if (ti_cpu_reset)
102239281Sgonzo		(*ti_cpu_reset)();
103239281Sgonzo	else
104239281Sgonzo		printf("no cpu_reset implementation\n");
105239281Sgonzo}
106266334Sandrew
107266334Sandrew#if defined(SOC_OMAP4)
108266334Sandrewstatic platform_method_t omap4_methods[] = {
109266334Sandrew	PLATFORMMETHOD(platform_devmap_init,	ti_omap4_devmap_init),
110266334Sandrew	PLATFORMMETHOD(platform_lastaddr,	ti_lastaddr),
111331893Sgonzo	PLATFORMMETHOD(platform_cpu_reset,	ti_plat_cpu_reset),
112266334Sandrew
113266334Sandrew	PLATFORMMETHOD_END,
114266334Sandrew};
115298854SandrewFDT_PLATFORM_DEF(omap4, "omap4", 0, "ti,omap4430", 0);
116266334Sandrew#endif
117266334Sandrew
118266334Sandrew#if defined(SOC_TI_AM335X)
119266334Sandrewstatic platform_method_t am335x_methods[] = {
120266334Sandrew	PLATFORMMETHOD(platform_devmap_init,	ti_am335x_devmap_init),
121266334Sandrew	PLATFORMMETHOD(platform_lastaddr,	ti_lastaddr),
122331893Sgonzo	PLATFORMMETHOD(platform_cpu_reset,	ti_plat_cpu_reset),
123266334Sandrew
124266334Sandrew	PLATFORMMETHOD_END,
125266334Sandrew};
126266334Sandrew
127331907SgonzoFDT_PLATFORM_DEF(am335x, "am335x", 0, "ti,am33xx", 200);
128266334Sandrew#endif
129