1239280Sgonzo/*-
2239280Sgonzo * Copyright (c) 2011 The FreeBSD Foundation
3239280Sgonzo * All rights reserved.
4239280Sgonzo *
5239280Sgonzo * Developed by Damjan Marion <damjan.marion@gmail.com>
6239280Sgonzo *
7239280Sgonzo * Redistribution and use in source and binary forms, with or without
8239280Sgonzo * modification, are permitted provided that the following conditions
9239280Sgonzo * are met:
10239280Sgonzo * 1. Redistributions of source code must retain the above copyright
11239280Sgonzo *    notice, this list of conditions and the following disclaimer.
12239280Sgonzo * 2. Redistributions in binary form must reproduce the above copyright
13239280Sgonzo *    notice, this list of conditions and the following disclaimer in the
14239280Sgonzo *    documentation and/or other materials provided with the distribution.
15239280Sgonzo *
16239280Sgonzo * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
17239280Sgonzo * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18239280Sgonzo * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19239280Sgonzo * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
20239280Sgonzo * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21239280Sgonzo * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22239280Sgonzo * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23239280Sgonzo * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24239280Sgonzo * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25239280Sgonzo * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26239280Sgonzo * SUCH DAMAGE.
27239280Sgonzo */
28239280Sgonzo
29239280Sgonzo#include <sys/cdefs.h>
30239280Sgonzo__FBSDID("$FreeBSD$");
31239280Sgonzo
32239280Sgonzo#include <sys/param.h>
33239280Sgonzo#include <sys/systm.h>
34239280Sgonzo#include <sys/bus.h>
35239280Sgonzo#include <sys/kernel.h>
36239280Sgonzo
37239280Sgonzo#include <dev/fdt/fdt_common.h>
38239280Sgonzo#include <dev/ofw/openfirm.h>
39239280Sgonzo
40239280Sgonzo#include <machine/bus.h>
41239280Sgonzo#include <machine/fdt.h>
42239280Sgonzo
43239280Sgonzo/* FIXME move to header file */
44239280Sgonzo#define TEGRA2_CLK_RST_PA_BASE		0x60006000
45239280Sgonzo
46239280Sgonzovoid
47239280Sgonzocpu_reset(void)
48239280Sgonzo{
49239280Sgonzo	bus_space_handle_t bsh;
50240549Sandrew	printf("Resetting...\n");
51239280Sgonzo	bus_space_map(fdtbus_bs_tag,TEGRA2_CLK_RST_PA_BASE, 0x1000, 0, &bsh);
52239280Sgonzo	bus_space_write_4(fdtbus_bs_tag, bsh, 4, 4);
53240549Sandrew
54240549Sandrew	while(1);
55239280Sgonzo}
56239280Sgonzo
57239280Sgonzostruct fdt_fixup_entry fdt_fixup_table[] = {
58239280Sgonzo	{ NULL, NULL }
59239280Sgonzo};
60239280Sgonzo
61239280Sgonzostatic int
62239280Sgonzofdt_pic_decode_ic(phandle_t node, pcell_t *intr, int *interrupt, int *trig,
63239280Sgonzo    int *pol)
64239280Sgonzo{
65239280Sgonzo	if (!fdt_is_compatible(node, "arm,gic"))
66239280Sgonzo		return (ENXIO);
67239280Sgonzo
68239280Sgonzo	*interrupt = fdt32_to_cpu(intr[0]);
69239280Sgonzo	*trig = INTR_TRIGGER_CONFORM;
70239280Sgonzo	*pol = INTR_POLARITY_CONFORM;
71239280Sgonzo	return (0);
72239280Sgonzo}
73239280Sgonzo
74239280Sgonzofdt_pic_decode_t fdt_pic_table[] = {
75239280Sgonzo	&fdt_pic_decode_ic,
76239280Sgonzo	NULL
77239280Sgonzo};
78239280Sgonzo
79239280Sgonzo
80239280Sgonzo
81