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: stable/11/sys/arm/allwinner/a10_common.c 314506 2017-03-01 19:55:04Z ian $"); 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 41298068Sandrew#ifndef INTRNG 42294698Sandrew 43245450Sganboldstatic int 44245450Sganboldfdt_aintc_decode_ic(phandle_t node, pcell_t *intr, int *interrupt, int *trig, 45245450Sganbold int *pol) 46245450Sganbold{ 47254056Sganbold int offset; 48254056Sganbold 49295464Sandrew if (fdt_is_compatible(node, "allwinner,sun4i-a10-ic")) 50254056Sganbold offset = 0; 51254056Sganbold else if (fdt_is_compatible(node, "arm,gic")) 52254056Sganbold offset = 32; 53254056Sganbold else 54245450Sganbold return (ENXIO); 55245450Sganbold 56254056Sganbold *interrupt = fdt32_to_cpu(intr[0]) + offset; 57245450Sganbold *trig = INTR_TRIGGER_CONFORM; 58245450Sganbold *pol = INTR_POLARITY_CONFORM; 59245450Sganbold 60245450Sganbold return (0); 61245450Sganbold} 62245450Sganbold 63245450Sganboldfdt_pic_decode_t fdt_pic_table[] = { 64245450Sganbold &fdt_aintc_decode_ic, 65245450Sganbold NULL 66245450Sganbold}; 67294698Sandrew 68298068Sandrew#endif /* INTRNG */ 69