Pull the common FDT interrupt values into a new header rather than be magic
numbers. Sponsored by: DARPA, AFRL
This commit is contained in:
parent
1d290950b2
commit
0c5434ae58
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=307965
@ -62,6 +62,7 @@ __FBSDID("$FreeBSD$");
|
||||
#include <machine/smp.h>
|
||||
|
||||
#include <dev/fdt/fdt_common.h>
|
||||
#include <dev/fdt/fdt_intr.h>
|
||||
#include <dev/ofw/ofw_bus_subr.h>
|
||||
|
||||
#include <arm/arm/gic.h>
|
||||
@ -821,13 +822,15 @@ gic_map_fdt(device_t dev, u_int ncells, pcell_t *cells, u_int *irqp,
|
||||
}
|
||||
|
||||
tripol = cells[2] & 0xff;
|
||||
if (tripol & 0xf0 || (tripol & 0x0a && cells[0] == 0))
|
||||
if (tripol & 0xf0 || (tripol & FDT_INTR_LOW_MASK &&
|
||||
cells[0] == 0))
|
||||
device_printf(dev, "unsupported trigger/polarity "
|
||||
"configuration 0x%02x\n", tripol);
|
||||
|
||||
*irqp = irq;
|
||||
*polp = INTR_POLARITY_CONFORM;
|
||||
*trigp = tripol & 0x03 ? INTR_TRIGGER_EDGE : INTR_TRIGGER_LEVEL;
|
||||
*trigp = tripol & FDT_INTR_EDGE_MASK ?
|
||||
INTR_TRIGGER_EDGE : INTR_TRIGGER_LEVEL;
|
||||
return (0);
|
||||
}
|
||||
return (EINVAL);
|
||||
|
@ -59,6 +59,7 @@ __FBSDID("$FreeBSD$");
|
||||
#include <machine/intr.h>
|
||||
|
||||
#ifdef FDT
|
||||
#include <dev/fdt/fdt_intr.h>
|
||||
#include <dev/ofw/ofw_bus_subr.h>
|
||||
#endif
|
||||
|
||||
@ -470,20 +471,20 @@ gic_map_fdt(device_t dev, u_int ncells, pcell_t *cells, u_int *irqp,
|
||||
return (EINVAL);
|
||||
}
|
||||
|
||||
switch (cells[2] & 0xf) {
|
||||
case 1:
|
||||
switch (cells[2] & FDT_INTR_MASK) {
|
||||
case FDT_INTR_EDGE_RISING:
|
||||
*trigp = INTR_TRIGGER_EDGE;
|
||||
*polp = INTR_POLARITY_HIGH;
|
||||
break;
|
||||
case 2:
|
||||
case FDT_INTR_EDGE_FALLING:
|
||||
*trigp = INTR_TRIGGER_EDGE;
|
||||
*polp = INTR_POLARITY_LOW;
|
||||
break;
|
||||
case 4:
|
||||
case FDT_INTR_LEVEL_HIGH:
|
||||
*trigp = INTR_TRIGGER_LEVEL;
|
||||
*polp = INTR_POLARITY_HIGH;
|
||||
break;
|
||||
case 8:
|
||||
case FDT_INTR_LEVEL_LOW:
|
||||
*trigp = INTR_TRIGGER_LEVEL;
|
||||
*polp = INTR_POLARITY_LOW;
|
||||
break;
|
||||
|
44
sys/dev/fdt/fdt_intr.h
Normal file
44
sys/dev/fdt/fdt_intr.h
Normal file
@ -0,0 +1,44 @@
|
||||
/*-
|
||||
* Copyright (c) 2016 Andrew Turner <andrew@FreeBSD.org>
|
||||
* All rights reserved.
|
||||
*
|
||||
* This software was developed by SRI International and the University of
|
||||
* Cambridge Computer Laboratory under DARPA/AFRL contract FA8750-10-C-0237
|
||||
* ("CTSRD"), as part of the DARPA CRASH research programme.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $FreeBSD$
|
||||
*/
|
||||
|
||||
#ifndef _FDT_INTR_H_
|
||||
#define _FDT_INTR_H_
|
||||
|
||||
#define FDT_INTR_EDGE_RISING 1
|
||||
#define FDT_INTR_EDGE_FALLING 2
|
||||
#define FDT_INTR_LEVEL_HIGH 4
|
||||
#define FDT_INTR_LEVEL_LOW 8
|
||||
#define FDT_INTR_LOW_MASK (FDT_INTR_EDGE_FALLING | FDT_INTR_LEVEL_LOW)
|
||||
#define FDT_INTR_EDGE_MASK (FDT_INTR_EDGE_RISING | FDT_INTR_EDGE_FALLING)
|
||||
#define FDT_INTR_MASK 0xf
|
||||
|
||||
#endif /* _FDT_INTR_H_ */
|
Loading…
Reference in New Issue
Block a user