1245450Sganbold/*- 2266337Sian * 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$"); 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/fdt.h> 40245450Sganbold#include <machine/vmparam.h> 41245450Sganbold 42245450Sganboldstruct fdt_fixup_entry fdt_fixup_table[] = { 43245450Sganbold { NULL, NULL } 44245450Sganbold}; 45245450Sganbold 46245450Sganboldstatic int 47245450Sganboldfdt_aintc_decode_ic(phandle_t node, pcell_t *intr, int *interrupt, int *trig, 48245450Sganbold int *pol) 49245450Sganbold{ 50254056Sganbold int offset; 51254056Sganbold 52254056Sganbold if (fdt_is_compatible(node, "allwinner,sun4i-ic")) 53254056Sganbold offset = 0; 54254056Sganbold else if (fdt_is_compatible(node, "arm,gic")) 55254056Sganbold offset = 32; 56254056Sganbold else 57245450Sganbold return (ENXIO); 58245450Sganbold 59254056Sganbold *interrupt = fdt32_to_cpu(intr[0]) + offset; 60245450Sganbold *trig = INTR_TRIGGER_CONFORM; 61245450Sganbold *pol = INTR_POLARITY_CONFORM; 62245450Sganbold 63245450Sganbold return (0); 64245450Sganbold} 65245450Sganbold 66245450Sganboldfdt_pic_decode_t fdt_pic_table[] = { 67245450Sganbold &fdt_aintc_decode_ic, 68245450Sganbold NULL 69245450Sganbold}; 70