Date: Wed, 26 Oct 2016 15:18:08 +0000 (UTC) From: Andrew Turner <andrew@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r307965 - in head/sys: arm/arm arm64/arm64 dev/fdt Message-ID: <201610261518.u9QFI8Ub082429@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: andrew Date: Wed Oct 26 15:18:08 2016 New Revision: 307965 URL: https://svnweb.freebsd.org/changeset/base/307965 Log: Pull the common FDT interrupt values into a new header rather than be magic numbers. Sponsored by: DARPA, AFRL Added: head/sys/dev/fdt/fdt_intr.h (contents, props changed) Modified: head/sys/arm/arm/gic.c head/sys/arm64/arm64/gic_v3.c Modified: head/sys/arm/arm/gic.c ============================================================================== --- head/sys/arm/arm/gic.c Wed Oct 26 14:26:45 2016 (r307964) +++ head/sys/arm/arm/gic.c Wed Oct 26 15:18:08 2016 (r307965) @@ -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, } 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); Modified: head/sys/arm64/arm64/gic_v3.c ============================================================================== --- head/sys/arm64/arm64/gic_v3.c Wed Oct 26 14:26:45 2016 (r307964) +++ head/sys/arm64/arm64/gic_v3.c Wed Oct 26 15:18:08 2016 (r307965) @@ -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, 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; Added: head/sys/dev/fdt/fdt_intr.h ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/sys/dev/fdt/fdt_intr.h Wed Oct 26 15:18:08 2016 (r307965) @@ -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_ */
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201610261518.u9QFI8Ub082429>