2 * Copyright (c) 2011 Damjan Marion.
3 * Copyright (c) 1994-1998 Mark Brinicombe.
4 * Copyright (c) 1994 Brini.
7 * This code is derived from software written for Brini by Mark Brinicombe
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
30 * from: FreeBSD: //depot/projects/arm/src/sys/arm/mv/mv_machdep.c
34 #include "opt_platform.h"
36 #include <sys/cdefs.h>
37 __FBSDID("$FreeBSD$");
39 #define _ARM32_BUS_DMA_PRIVATE
40 #include <sys/param.h>
41 #include <sys/systm.h>
47 #include <machine/bus.h>
48 #include <machine/frame.h> /* For trapframe_t, used in <machine/machdep.h> */
49 #include <machine/machdep.h>
50 #include <machine/pmap.h>
52 #include <dev/fdt/fdt_common.h>
54 /* FIXME move to tegrareg.h */
55 #define TEGRA2_BASE 0xE0000000 /* KVM base for peripherials */
56 #define TEGRA2_UARTA_VA_BASE 0xE0006000
57 #define TEGRA2_UARTA_PA_BASE 0x70006000
59 #define TEGRA2_CLK_RST_PA_BASE 0x60006000
61 #define TEGRA2_CLK_RST_OSC_FREQ_DET_REG 0x58
62 #define TEGRA2_CLK_RST_OSC_FREQ_DET_STAT_REG 0x5C
63 #define OSC_FREQ_DET_TRIG (1<<31)
64 #define OSC_FREQ_DET_BUSY (1<<31)
68 tegra2_osc_freq_detect(void)
70 bus_space_handle_t bsh;
86 printf("Measuring...\n");
87 bus_space_map(fdtbus_bs_tag,TEGRA2_CLK_RST_PA_BASE, 0x1000, 0, &bsh);
89 bus_space_write_4(fdtbus_bs_tag, bsh, TEGRA2_CLK_RST_OSC_FREQ_DET_REG,
90 OSC_FREQ_DET_TRIG | 1 );
91 do {} while (bus_space_read_4(fdtbus_bs_tag, bsh,
92 TEGRA2_CLK_RST_OSC_FREQ_DET_STAT_REG) & OSC_FREQ_DET_BUSY);
94 c = bus_space_read_4(fdtbus_bs_tag, bsh, TEGRA2_CLK_RST_OSC_FREQ_DET_STAT_REG);
96 while (freq_det_cnts[i].val > 0) {
97 if (((freq_det_cnts[i].val - 3) < c) && (c < (freq_det_cnts[i].val + 3)))
98 r = freq_det_cnts[i].freq;
101 printf("c=%u r=%u\n",c,r );
102 bus_space_free(fdtbus_bs_tag, bsh, 0x1000);
108 initarm_lastaddr(void)
111 if (fdt_immr_addr(TEGRA2_BASE) != 0) /* FIXME ???? */
114 return (fdt_immr_va - ARM_NOCACHE_KVA_SIZE);
118 initarm_gpio_init(void)
123 initarm_late_init(void)
127 #define FDT_DEVMAP_MAX (1 + 2 + 1 + 1) /* FIXME */
128 static struct pmap_devmap fdt_devmap[FDT_DEVMAP_MAX] = {
133 * Construct pmap_devmap[] with DT-derived config data.
136 platform_devmap_init(void)
139 fdt_devmap[i].pd_va = 0xe0000000;
140 fdt_devmap[i].pd_pa = 0x70000000;
141 fdt_devmap[i].pd_size = 0x100000;
142 fdt_devmap[i].pd_prot = VM_PROT_READ | VM_PROT_WRITE;
143 fdt_devmap[i].pd_cache = PTE_NOCACHE;
146 pmap_devmap_bootstrap_table = &fdt_devmap[0];
150 struct arm32_dma_range *
151 bus_dma_get_range(void)
158 bus_dma_get_range_nb(void)