[PATCH 031/111] leon,gpiolib: add mask/unmask interrupt support

Daniel Hellstrom daniel at gaisler.com
Thu Feb 26 16:38:33 UTC 2015


---
 c/src/lib/libbsp/sparc/shared/gpio/gpiolib.c    |   11 +++++++++++
 c/src/lib/libbsp/sparc/shared/gpio/grgpio.c     |   12 ++++++++++++
 c/src/lib/libbsp/sparc/shared/include/gpiolib.h |    4 ++++
 3 files changed, 27 insertions(+), 0 deletions(-)

diff --git a/c/src/lib/libbsp/sparc/shared/gpio/gpiolib.c b/c/src/lib/libbsp/sparc/shared/gpio/gpiolib.c
index 22f1baa..4eca013 100644
--- a/c/src/lib/libbsp/sparc/shared/gpio/gpiolib.c
+++ b/c/src/lib/libbsp/sparc/shared/gpio/gpiolib.c
@@ -251,6 +251,17 @@ int gpiolib_irq_disable(void *handle)
 	return gpiolib_irq_opts(handle, GPIOLIB_IRQ_DISABLE);
 }
 
+int gpiolib_irq_mask(void *handle)
+{
+	return gpiolib_irq_opts(handle, GPIOLIB_IRQ_MASK);
+}
+
+int gpiolib_irq_unmask(void *handle)
+{
+	return gpiolib_irq_opts(handle, GPIOLIB_IRQ_UNMASK);
+}
+
+
 /*** Initialization ***/
 int gpiolib_initialize(void)
 {
diff --git a/c/src/lib/libbsp/sparc/shared/gpio/grgpio.c b/c/src/lib/libbsp/sparc/shared/gpio/grgpio.c
index 92e9657..eab8ef9 100644
--- a/c/src/lib/libbsp/sparc/shared/gpio/grgpio.c
+++ b/c/src/lib/libbsp/sparc/shared/gpio/grgpio.c
@@ -262,6 +262,18 @@ int grgpio_grpiolib_irq_opts(void *handle, unsigned int options)
 			return -1;
 		}
 	}
+	if ( options & GPIOLIB_IRQ_MASK ) {
+		/* Mask (disable) interrupt at interrupt controller */
+		if ( drvmgr_interrupt_mask(priv->dev, portnr) ) {
+			return -1;
+		}
+	}
+	if ( options & GPIOLIB_IRQ_UNMASK ) {
+		/* Unmask (enable) interrupt at interrupt controller */
+		if ( drvmgr_interrupt_unmask(priv->dev, portnr) ) {
+			return -1;
+		}
+	}
 
 	return 0;
 }
diff --git a/c/src/lib/libbsp/sparc/shared/include/gpiolib.h b/c/src/lib/libbsp/sparc/shared/include/gpiolib.h
index 466a131..c8bfe0f 100644
--- a/c/src/lib/libbsp/sparc/shared/include/gpiolib.h
+++ b/c/src/lib/libbsp/sparc/shared/include/gpiolib.h
@@ -51,6 +51,8 @@ extern int gpiolib_get(void *handle, int *inval);
 extern int gpiolib_irq_clear(void *handle);
 extern int gpiolib_irq_enable(void *handle);
 extern int gpiolib_irq_disable(void *handle);
+extern int gpiolib_irq_mask(void *handle);
+extern int gpiolib_irq_unmask(void *handle);
 extern int gpiolib_irq_force(void *handle);
 extern int gpiolib_irq_register(void *handle, void *func, void *arg);
 
@@ -75,6 +77,8 @@ struct gpiolib_drv_ops {
 #define GPIOLIB_IRQ_DISABLE 0x02
 #define GPIOLIB_IRQ_CLEAR   0x04
 #define GPIOLIB_IRQ_FORCE   0x08
+#define GPIOLIB_IRQ_MASK    0x10
+#define GPIOLIB_IRQ_UNMASK  0x20
 
 struct gpiolib_drv {
 	struct gpiolib_drv_ops	*ops;
-- 
1.7.0.4



More information about the devel mailing list