diff options
| author | thorpej <thorpej@NetBSD.org> | 2019-01-26 14:38:29 +0000 |
|---|---|---|
| committer | thorpej <thorpej@NetBSD.org> | 2019-01-26 14:38:29 +0000 |
| commit | 28a4eb563aa5bbb18868436898ca46df873b6b2c (patch) | |
| tree | b0c8a6a8f37c5fec81c1419dd9e51ca433819582 | |
| parent | b3493680a2df58c6d31273379697a43968745800 (diff) | |
Define constants for representing the standard interrupt types
({pos,neg,double}-edge, {high,low}-level) from the FDT "interrupts"
bindings. Use these defined constants rather than magic numbers.
| -rw-r--r-- | sys/arch/arm/broadcom/bcm2835_gpio.c | 14 | ||||
| -rw-r--r-- | sys/arch/arm/fdt/gic_fdt.c | 7 | ||||
| -rw-r--r-- | sys/arch/arm/fdt/gicv3_fdt.c | 7 | ||||
| -rw-r--r-- | sys/arch/arm/nvidia/tegra_lic.c | 7 | ||||
| -rw-r--r-- | sys/arch/arm/sunxi/sunxi_gpio.c | 14 | ||||
| -rw-r--r-- | sys/dev/fdt/fdtvar.h | 10 |
6 files changed, 35 insertions, 24 deletions
diff --git a/sys/arch/arm/broadcom/bcm2835_gpio.c b/sys/arch/arm/broadcom/bcm2835_gpio.c index aba1c69c671..9b13f5a292b 100644 --- a/sys/arch/arm/broadcom/bcm2835_gpio.c +++ b/sys/arch/arm/broadcom/bcm2835_gpio.c @@ -1,4 +1,4 @@ -/* $NetBSD: bcm2835_gpio.c,v 1.8 2018/09/28 13:24:02 jmcneill Exp $ */ +/* $NetBSD: bcm2835_gpio.c,v 1.9 2019/01/26 14:38:29 thorpej Exp $ */ /*- * Copyright (c) 2013, 2014, 2017 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: bcm2835_gpio.c,v 1.8 2018/09/28 13:24:02 jmcneill Exp $"); +__KERNEL_RCSID(0, "$NetBSD: bcm2835_gpio.c,v 1.9 2019/01/26 14:38:29 thorpej Exp $"); /* * Driver for BCM2835 GPIO @@ -567,19 +567,19 @@ bcmgpio_fdt_intr_establish(device_t dev, u_int *specifier, int ipl, int flags, const u_int type = be32toh(specifier[1]) & 0xf; switch (type) { - case 0x1: + case FDT_INTR_TYPE_POS_EDGE: eint_flags |= BCMGPIO_INTR_POS_EDGE; break; - case 0x2: + case FDT_INTR_TYPE_NEG_EDGE: eint_flags |= BCMGPIO_INTR_NEG_EDGE; break; - case 0x3: + case FDT_INTR_TYPE_DOUBLE_EDGE: eint_flags |= BCMGPIO_INTR_POS_EDGE | BCMGPIO_INTR_NEG_EDGE; break; - case 0x4: + case FDT_INTR_TYPE_HIGH_LEVEL: eint_flags |= BCMGPIO_INTR_HIGH_LEVEL; break; - case 0x8: + case FDT_INTR_TYPE_LOW_LEVEL: eint_flags |= BCMGPIO_INTR_LOW_LEVEL; break; default: diff --git a/sys/arch/arm/fdt/gic_fdt.c b/sys/arch/arm/fdt/gic_fdt.c index 824edef7144..e7c39536648 100644 --- a/sys/arch/arm/fdt/gic_fdt.c +++ b/sys/arch/arm/fdt/gic_fdt.c @@ -1,4 +1,4 @@ -/* $NetBSD: gic_fdt.c,v 1.15 2018/11/12 12:41:03 jmcneill Exp $ */ +/* $NetBSD: gic_fdt.c,v 1.16 2019/01/26 14:43:46 thorpej Exp $ */ /*- * Copyright (c) 2015-2017 Jared McNeill <jmcneill@invisible.ca> @@ -29,7 +29,7 @@ #include "pci.h" #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: gic_fdt.c,v 1.15 2018/11/12 12:41:03 jmcneill Exp $"); +__KERNEL_RCSID(0, "$NetBSD: gic_fdt.c,v 1.16 2019/01/26 14:43:46 thorpej Exp $"); #include <sys/param.h> #include <sys/bus.h> @@ -249,7 +249,8 @@ gic_fdt_establish(device_t dev, u_int *specifier, int ipl, int flags, const u_int intr = be32toh(specifier[1]); const u_int irq = type == 0 ? IRQ_SPI(intr) : IRQ_PPI(intr); const u_int trig = be32toh(specifier[2]) & 0xf; - const u_int level = (trig & 0x3) ? IST_EDGE : IST_LEVEL; + const u_int level = (trig & FDT_INTR_TYPE_DOUBLE_EDGE) + ? IST_EDGE : IST_LEVEL; const u_int mpsafe = (flags & FDT_INTR_MPSAFE) ? IST_MPSAFE : 0; diff --git a/sys/arch/arm/fdt/gicv3_fdt.c b/sys/arch/arm/fdt/gicv3_fdt.c index b93fba8e71e..cf69a52b230 100644 --- a/sys/arch/arm/fdt/gicv3_fdt.c +++ b/sys/arch/arm/fdt/gicv3_fdt.c @@ -1,4 +1,4 @@ -/* $NetBSD: gicv3_fdt.c,v 1.6 2018/11/24 22:18:57 jakllsch Exp $ */ +/* $NetBSD: gicv3_fdt.c,v 1.7 2019/01/26 14:43:46 thorpej Exp $ */ /*- * Copyright (c) 2015-2018 Jared McNeill <jmcneill@invisible.ca> @@ -31,7 +31,7 @@ #define _INTR_PRIVATE #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: gicv3_fdt.c,v 1.6 2018/11/24 22:18:57 jakllsch Exp $"); +__KERNEL_RCSID(0, "$NetBSD: gicv3_fdt.c,v 1.7 2019/01/26 14:43:46 thorpej Exp $"); #include <sys/param.h> #include <sys/bus.h> @@ -280,7 +280,8 @@ gicv3_fdt_establish(device_t dev, u_int *specifier, int ipl, int flags, const u_int intr = be32toh(specifier[1]); const u_int irq = type == 0 ? IRQ_SPI(intr) : IRQ_PPI(intr); const u_int trig = be32toh(specifier[2]) & 0xf; - const u_int level = (trig & 0x3) ? IST_EDGE : IST_LEVEL; + const u_int level = (trig & FDT_INTR_TYPE_DOUBLE_EDGE) + ? IST_EDGE : IST_LEVEL; const u_int mpsafe = (flags & FDT_INTR_MPSAFE) ? IST_MPSAFE : 0; diff --git a/sys/arch/arm/nvidia/tegra_lic.c b/sys/arch/arm/nvidia/tegra_lic.c index e25b21ffa68..3961cf5505b 100644 --- a/sys/arch/arm/nvidia/tegra_lic.c +++ b/sys/arch/arm/nvidia/tegra_lic.c @@ -1,4 +1,4 @@ -/* $NetBSD: tegra_lic.c,v 1.5 2017/05/26 20:08:02 jmcneill Exp $ */ +/* $NetBSD: tegra_lic.c,v 1.6 2019/01/26 14:38:29 thorpej Exp $ */ /*- * Copyright (c) 2015 Jared D. McNeill <jmcneill@invisible.ca> @@ -27,7 +27,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: tegra_lic.c,v 1.5 2017/05/26 20:08:02 jmcneill Exp $"); +__KERNEL_RCSID(0, "$NetBSD: tegra_lic.c,v 1.6 2019/01/26 14:38:29 thorpej Exp $"); #include <sys/param.h> #include <sys/bus.h> @@ -142,7 +142,8 @@ tegra_lic_establish(device_t dev, u_int *specifier, int ipl, int flags, const u_int intr = be32toh(specifier[1]); const u_int irq = type == 0 ? IRQ_SPI(intr) : IRQ_PPI(intr); const u_int trig = be32toh(specifier[2]) & 0xf; - const u_int level = (trig & 0x3) ? IST_EDGE : IST_LEVEL; + const u_int level = (trig & FDT_INTR_TYPE_DOUBLE_EDGE) + ? IST_EDGE : IST_LEVEL; return intr_establish(irq, ipl, level | iflags, func, arg); } diff --git a/sys/arch/arm/sunxi/sunxi_gpio.c b/sys/arch/arm/sunxi/sunxi_gpio.c index bd2dae894b9..3dc405d320a 100644 --- a/sys/arch/arm/sunxi/sunxi_gpio.c +++ b/sys/arch/arm/sunxi/sunxi_gpio.c @@ -1,4 +1,4 @@ -/* $NetBSD: sunxi_gpio.c,v 1.22 2019/01/23 04:21:54 thorpej Exp $ */ +/* $NetBSD: sunxi_gpio.c,v 1.23 2019/01/26 14:38:30 thorpej Exp $ */ /*- * Copyright (c) 2017 Jared McNeill <jmcneill@invisible.ca> @@ -29,7 +29,7 @@ #include "opt_soc.h" #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: sunxi_gpio.c,v 1.22 2019/01/23 04:21:54 thorpej Exp $"); +__KERNEL_RCSID(0, "$NetBSD: sunxi_gpio.c,v 1.23 2019/01/26 14:38:30 thorpej Exp $"); #include <sys/param.h> #include <sys/bus.h> @@ -458,19 +458,19 @@ sunxi_gpio_establish(device_t dev, u_int *specifier, int ipl, int flags, const u_int type = be32toh(specifier[2]) & 0xf; switch (type) { - case 0x1: + case FDT_INTR_TYPE_POS_EDGE: mode = SUNXI_GPIO_INT_MODE_POS_EDGE; break; - case 0x2: + case FDT_INTR_TYPE_NEG_EDGE: mode = SUNXI_GPIO_INT_MODE_NEG_EDGE; break; - case 0x3: + case FDT_INTR_TYPE_DOUBLE_EDGE: mode = SUNXI_GPIO_INT_MODE_DOUBLE_EDGE; break; - case 0x4: + case FDT_INTR_TYPE_HIGH_LEVEL: mode = SUNXI_GPIO_INT_MODE_HIGH_LEVEL; break; - case 0x8: + case FDT_INTR_TYPE_LOW_LEVEL: mode = SUNXI_GPIO_INT_MODE_LOW_LEVEL; break; default: diff --git a/sys/dev/fdt/fdtvar.h b/sys/dev/fdt/fdtvar.h index 14219477db7..d5210e3d5c0 100644 --- a/sys/dev/fdt/fdtvar.h +++ b/sys/dev/fdt/fdtvar.h @@ -1,4 +1,4 @@ -/* $NetBSD: fdtvar.h,v 1.46 2019/01/23 04:21:55 thorpej Exp $ */ +/* $NetBSD: fdtvar.h,v 1.47 2019/01/26 14:38:30 thorpej Exp $ */ /*- * Copyright (c) 2015 Jared D. McNeill <jmcneill@invisible.ca> @@ -63,6 +63,14 @@ struct fdt_attach_args { /* flags for fdtbus_intr_establish */ #define FDT_INTR_MPSAFE __BIT(0) +/* Interrupt trigger types defined by the FDT "interrupts" bindings. */ +#define FDT_INTR_TYPE_POS_EDGE __BIT(0) +#define FDT_INTR_TYPE_NEG_EDGE __BIT(1) +#define FDT_INTR_TYPE_DOUBLE_EDGE (FDT_INTR_TYPE_POS_EDGE | \ + FDT_INTR_TYPE_NEG_EDGE) +#define FDT_INTR_TYPE_HIGH_LEVEL __BIT(2) +#define FDT_INTR_TYPE_LOW_LEVEL __BIT(3) + struct fdtbus_interrupt_controller_func { void * (*establish)(device_t, u_int *, int, int, int (*)(void *), void *); |
