1*224c3776SAndrew Turner#- 2*224c3776SAndrew Turner# Copyright (c) 2016 The FreeBSD Foundation 3*224c3776SAndrew Turner# 4*224c3776SAndrew Turner# This software was developed by Andrew Turner under 5*224c3776SAndrew Turner# sponsorship from the FreeBSD Foundation. 6*224c3776SAndrew Turner# 7*224c3776SAndrew Turner# Redistribution and use in source and binary forms, with or without 8*224c3776SAndrew Turner# modification, are permitted provided that the following conditions 9*224c3776SAndrew Turner# are met: 10*224c3776SAndrew Turner# 1. Redistributions of source code must retain the above copyright 11*224c3776SAndrew Turner# notice, this list of conditions and the following disclaimer. 12*224c3776SAndrew Turner# 2. Redistributions in binary form must reproduce the above copyright 13*224c3776SAndrew Turner# notice, this list of conditions and the following disclaimer in the 14*224c3776SAndrew Turner# documentation and/or other materials provided with the distribution. 15*224c3776SAndrew Turner# 16*224c3776SAndrew Turner# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 17*224c3776SAndrew Turner# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18*224c3776SAndrew Turner# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19*224c3776SAndrew Turner# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 20*224c3776SAndrew Turner# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 21*224c3776SAndrew Turner# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 22*224c3776SAndrew Turner# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 23*224c3776SAndrew Turner# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 24*224c3776SAndrew Turner# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 25*224c3776SAndrew Turner# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 26*224c3776SAndrew Turner# SUCH DAMAGE. 27*224c3776SAndrew Turner# 28*224c3776SAndrew Turner 29*224c3776SAndrew Turner#include <sys/types.h> 30*224c3776SAndrew Turner#include <sys/systm.h> 31*224c3776SAndrew Turner#include <sys/bus.h> 32*224c3776SAndrew Turner 33*224c3776SAndrew TurnerINTERFACE acpi_bus; 34*224c3776SAndrew Turner 35*224c3776SAndrew TurnerCODE { 36*224c3776SAndrew Turner static acpi_bus_map_intr_t acpi_bus_default_map_intr; 37*224c3776SAndrew Turner 38*224c3776SAndrew Turner int 39*224c3776SAndrew Turner acpi_bus_default_map_intr(device_t bus, device_t dev, u_int irq, 40*224c3776SAndrew Turner int trig, int pol) 41*224c3776SAndrew Turner { 42*224c3776SAndrew Turner device_t parent; 43*224c3776SAndrew Turner 44*224c3776SAndrew Turner /* Pass up the hierarchy */ 45*224c3776SAndrew Turner parent = device_get_parent(bus); 46*224c3776SAndrew Turner if (parent != NULL) 47*224c3776SAndrew Turner return (ACPI_BUS_MAP_INTR(parent, dev, irq, trig, pol)); 48*224c3776SAndrew Turner 49*224c3776SAndrew Turner panic("Unable to map interrupt %u", irq); 50*224c3776SAndrew Turner } 51*224c3776SAndrew Turner}; 52*224c3776SAndrew Turner 53*224c3776SAndrew Turner# Map an interrupt from ACPI space to the FreeBSD IRQ space. Note that 54*224c3776SAndrew Turner# both of these may be different than the pysical interrupt space as this 55*224c3776SAndrew Turner# may be local to each interrupt controller. 56*224c3776SAndrew Turner# 57*224c3776SAndrew Turner# This method also associates interrupt metadata with the interrupt, 58*224c3776SAndrew Turner# removing the need for a post hoc configure step. 59*224c3776SAndrew TurnerMETHOD int map_intr { 60*224c3776SAndrew Turner device_t bus; 61*224c3776SAndrew Turner device_t dev; 62*224c3776SAndrew Turner u_int irq; 63*224c3776SAndrew Turner int trig; 64*224c3776SAndrew Turner int pol; 65*224c3776SAndrew Turner} DEFAULT acpi_bus_default_map_intr; 66