a10_common.c revision 298068
1245450Sganbold/*-
2263711Sganbold * Copyright (c) 2012 Ganbold Tsagaankhuu <ganbold@freebsd.org>
3245450Sganbold * All rights reserved.
4245450Sganbold *
5245450Sganbold * Redistribution and use in source and binary forms, with or without
6245450Sganbold * modification, are permitted provided that the following conditions
7245450Sganbold * are met:
8245450Sganbold * 1. Redistributions of source code must retain the above copyright
9245450Sganbold *    notice, this list of conditions and the following disclaimer.
10245450Sganbold * 2. Redistributions in binary form must reproduce the above copyright
11245450Sganbold *    notice, this list of conditions and the following disclaimer in the
12245450Sganbold *    documentation and/or other materials provided with the distribution.
13245450Sganbold *
14245450Sganbold * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15245450Sganbold * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16245450Sganbold * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17245454Sganbold * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18245450Sganbold * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19245450Sganbold * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20245450Sganbold * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21245450Sganbold * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22245450Sganbold * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23245450Sganbold * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24245450Sganbold * SUCH DAMAGE.
25245450Sganbold */
26245450Sganbold
27245450Sganbold#include <sys/cdefs.h>
28245450Sganbold__FBSDID("$FreeBSD: head/sys/arm/allwinner/a10_common.c 298068 2016-04-15 16:05:41Z andrew $");
29245450Sganbold
30245450Sganbold#include <sys/param.h>
31245450Sganbold#include <sys/systm.h>
32245450Sganbold#include <sys/bus.h>
33245450Sganbold#include <sys/kernel.h>
34245450Sganbold
35245450Sganbold#include <dev/fdt/fdt_common.h>
36245450Sganbold#include <dev/ofw/openfirm.h>
37245450Sganbold
38245450Sganbold#include <machine/bus.h>
39245450Sganbold#include <machine/vmparam.h>
40245450Sganbold
41245450Sganboldstruct fdt_fixup_entry fdt_fixup_table[] = {
42245450Sganbold	{ NULL, NULL }
43245450Sganbold};
44245450Sganbold
45298068Sandrew#ifndef INTRNG
46294698Sandrew
47245450Sganboldstatic int
48245450Sganboldfdt_aintc_decode_ic(phandle_t node, pcell_t *intr, int *interrupt, int *trig,
49245450Sganbold    int *pol)
50245450Sganbold{
51254056Sganbold	int offset;
52254056Sganbold
53295464Sandrew	if (fdt_is_compatible(node, "allwinner,sun4i-a10-ic"))
54254056Sganbold		offset = 0;
55254056Sganbold	else if (fdt_is_compatible(node, "arm,gic"))
56254056Sganbold		offset = 32;
57254056Sganbold	else
58245450Sganbold		return (ENXIO);
59245450Sganbold
60254056Sganbold	*interrupt = fdt32_to_cpu(intr[0]) + offset;
61245450Sganbold	*trig = INTR_TRIGGER_CONFORM;
62245450Sganbold	*pol = INTR_POLARITY_CONFORM;
63245450Sganbold
64245450Sganbold	return (0);
65245450Sganbold}
66245450Sganbold
67245450Sganboldfdt_pic_decode_t fdt_pic_table[] = {
68245450Sganbold	&fdt_aintc_decode_ic,
69245450Sganbold	NULL
70245450Sganbold};
71294698Sandrew
72298068Sandrew#endif /* INTRNG */
73