[PATCH 21/30] viafb: Add a simple interrupt management infrastructure

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Jonathan Corbet
Date: Wednesday, April 28, 2010 - 3:17 pm

The viafb device shares a single interrupt control register among several
distinct subunits.  This adds a simple layer for management of that
register.

Signed-off-by: Jonathan Corbet <corbet@lwn.net>
---
 drivers/video/via/via-core.c |   62 +++++++++++++++++++++++++++++++++++++++++-
 drivers/video/via/via-core.h |   44 +++++++++++++++++++++++++++++
 2 files changed, 105 insertions(+), 1 deletions(-)

diff --git a/drivers/video/via/via-core.c b/drivers/video/via/via-core.c
index c7ce006..432846e 100644
--- a/drivers/video/via/via-core.c
+++ b/drivers/video/via/via-core.c
@@ -35,6 +35,65 @@ static struct viafb_dev global_dev;
 
 
 /*
+ * Basic register access; spinlock required.
+ */
+static inline void viafb_mmio_write(int reg, u32 v)
+{
+	iowrite32(v, global_dev.engine_mmio + reg);
+}
+
+static inline int viafb_mmio_read(int reg)
+{
+	return ioread32(global_dev.engine_mmio + reg);
+}
+
+/* ---------------------------------------------------------------------- */
+/*
+ * Interrupt management.  We have a single IRQ line for a lot of
+ * different functions, so we need to share it.  The design here
+ * is that we don't want to reimplement the shared IRQ code here;
+ * we also want to avoid having contention for a single handler thread.
+ * So each subdev driver which needs interrupts just requests
+ * them directly from the kernel.  We just have what's needed for
+ * overall access to the interrupt control register.
+ */
+
+/*
+ * Which interrupts are enabled now?
+ */
+static u32 viafb_enabled_ints;
+
+static void viafb_int_init(void)
+{
+	viafb_enabled_ints = 0;
+
+	viafb_mmio_write(VDE_INTERRUPT, 0);
+}
+
+/*
+ * Allow subdevs to ask for specific interrupts to be enabled.  These
+ * functions must be called with reg_lock held
+ */
+void viafb_irq_enable(u32 mask)
+{
+	viafb_enabled_ints |= mask;
+	viafb_mmio_write(VDE_INTERRUPT, viafb_enabled_ints | VDE_I_ENABLE);
+}
+EXPORT_SYMBOL_GPL(viafb_irq_enable);
+
+void viafb_irq_disable(u32 mask)
+{
+	viafb_enabled_ints &= ~mask;
+	if (viafb_enabled_ints == 0)
+		viafb_mmio_write(VDE_INTERRUPT, 0);  /* Disable entirely */
+	else
+		viafb_mmio_write(VDE_INTERRUPT,
+				viafb_enabled_ints | VDE_I_ENABLE);
+}
+EXPORT_SYMBOL_GPL(viafb_irq_disable);
+
+
+/*
  * Figure out how big our framebuffer memory is.  Kind of ugly,
  * but evidently we can't trust the information found in the
  * fbdev configuration area.
@@ -273,7 +332,7 @@ static int __devinit via_pci_probe(struct pci_dev *pdev,
 	if (ret)
 		goto out_teardown;
 	/*
-	 * Set up subsidiary devices
+	 * Set up the framebuffer device
 	 */
 	ret = via_fb_pci_probe(&global_dev);
 	if (ret)
@@ -281,6 +340,7 @@ static int __devinit via_pci_probe(struct pci_dev *pdev,
 	/*
 	 * Create our subdevices.
 	 */
+	viafb_int_init();
 	via_setup_subdevs(&global_dev);
 	return 0;
 
diff --git a/drivers/video/via/via-core.h b/drivers/video/via/via-core.h
index ac89c2a..ba64b36 100644
--- a/drivers/video/via/via-core.h
+++ b/drivers/video/via/via-core.h
@@ -87,4 +87,48 @@ struct viafb_dev {
 
 };
 
+/*
+ * Interrupt management.
+ */
+
+void viafb_irq_enable(u32 mask);
+void viafb_irq_disable(u32 mask);
+
+/*
+ * The global interrupt control register and its bits.
+ */
+#define VDE_INTERRUPT	0x200	/* Video interrupt flags/masks */
+#define   VDE_I_DVISENSE  0x00000001  /* DVI sense int status */
+#define   VDE_I_VBLANK    0x00000002  /* Vertical blank status */
+#define   VDE_I_MCCFI	  0x00000004  /* MCE compl. frame int status */
+#define   VDE_I_VSYNC	  0x00000008  /* VGA VSYNC int status */
+#define   VDE_I_DMA0DDONE 0x00000010  /* DMA 0 descr done */
+#define   VDE_I_DMA0TDONE 0x00000020  /* DMA 0 transfer done */
+#define   VDE_I_DMA1DDONE 0x00000040  /* DMA 1 descr done */
+#define   VDE_I_DMA1TDONE 0x00000080  /* DMA 1 transfer done */
+#define   VDE_I_C1AV      0x00000100  /* Cap Eng 1 act vid end */
+#define   VDE_I_HQV0	  0x00000200  /* First HQV engine */
+#define   VDE_I_HQV1      0x00000400  /* Second HQV engine */
+#define   VDE_I_HQV1EN	  0x00000800  /* Second HQV engine enable */
+#define   VDE_I_C0AV      0x00001000  /* Cap Eng 0 act vid end */
+#define   VDE_I_C0VBI     0x00002000  /* Cap Eng 0 VBI end */
+#define   VDE_I_C1VBI     0x00004000  /* Cap Eng 1 VBI end */
+#define   VDE_I_VSYNC2    0x00008000  /* Sec. Disp. VSYNC */
+#define   VDE_I_DVISNSEN  0x00010000  /* DVI sense enable */
+#define   VDE_I_VSYNC2EN  0x00020000  /* Sec Disp VSYNC enable */
+#define   VDE_I_MCCFIEN	  0x00040000  /* MC comp frame int mask enable */
+#define   VDE_I_VSYNCEN   0x00080000  /* VSYNC enable */
+#define   VDE_I_DMA0DDEN  0x00100000  /* DMA 0 descr done enable */
+#define   VDE_I_DMA0TDEN  0x00200000  /* DMA 0 trans done enable */
+#define   VDE_I_DMA1DDEN  0x00400000  /* DMA 1 descr done enable */
+#define   VDE_I_DMA1TDEN  0x00800000  /* DMA 1 trans done enable */
+#define   VDE_I_C1AVEN    0x01000000  /* cap 1 act vid end enable */
+#define   VDE_I_HQV0EN	  0x02000000  /* First hqv engine enable */
+#define   VDE_I_C1VBIEN	  0x04000000  /* Cap 1 VBI end enable */
+#define   VDE_I_LVDSSI    0x08000000  /* LVDS sense interrupt */
+#define   VDE_I_C0AVEN    0x10000000  /* Cap 0 act vid end enable */
+#define   VDE_I_C0VBIEN   0x20000000  /* Cap 0 VBI end enable */
+#define   VDE_I_LVDSSIEN  0x40000000  /* LVDS Sense enable */
+#define   VDE_I_ENABLE	  0x80000000  /* Global interrupt enable */
+
 #endif /* __VIA_CORE_H__ */
-- 
1.7.0.1

--
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[RFC] Second OLPC Viafb series, v2, Jonathan Corbet, (Wed Apr 28, 3:17 pm)
[PATCH 02/30] viafb: use proper pci config API, Jonathan Corbet, (Wed Apr 28, 3:17 pm)
[PATCH 04/30] viafb: Retain GEMODE reserved bits, Jonathan Corbet, (Wed Apr 28, 3:17 pm)
[PATCH 05/30] viafb: Unify duplicated set_bpp() code, Jonathan Corbet, (Wed Apr 28, 3:17 pm)
[PATCH 12/30] viafb: Move core stuff into via-core.c, Jonathan Corbet, (Wed Apr 28, 3:17 pm)
[PATCH 13/30] viafb: Separate global and fb-specific data, Jonathan Corbet, (Wed Apr 28, 3:17 pm)
[PATCH 14/30] viafb: add a driver for GPIO lines, Jonathan Corbet, (Wed Apr 28, 3:17 pm)
[PATCH 15/30] viafb: package often used basic io functions, Jonathan Corbet, (Wed Apr 28, 3:17 pm)
[PATCH 19/30] viafb: Introduce viafb_find_i2c_adapter(), Jonathan Corbet, (Wed Apr 28, 3:17 pm)
[PATCH 20/30] via: Rationalize vt1636 detection, Jonathan Corbet, (Wed Apr 28, 3:17 pm)
[PATCH 21/30] viafb: Add a simple interrupt management inf ..., Jonathan Corbet, (Wed Apr 28, 3:17 pm)
[PATCH 22/30] viafb: Add a simple VX855 DMA engine driver, Jonathan Corbet, (Wed Apr 28, 3:17 pm)
[PATCH 25/30] viafb: unify modesetting functions, Jonathan Corbet, (Wed Apr 28, 3:17 pm)
[PATCH 27/30] viafb: replace inb/outb, Jonathan Corbet, (Wed Apr 28, 3:17 pm)
[PATCH 28/30] viafb: improve misc register handling, Jonathan Corbet, (Wed Apr 28, 3:17 pm)
[PATCH 29/30] viafb: fix proc entry removal, Jonathan Corbet, (Wed Apr 28, 3:17 pm)
[PATCH 30/30] viafb: make procfs entries optional, Jonathan Corbet, (Wed Apr 28, 3:17 pm)
Re: [RFC] Second OLPC Viafb series, v2, Bruno Prémont, (Thu Apr 29, 10:26 am)
Re: [RFC] Second OLPC Viafb series, v2, Jonathan Corbet, (Fri Apr 30, 8:39 am)
Re: [PATCH 13/30] viafb: Separate global and fb-specific data, Florian Tobias Schan ..., (Fri Apr 30, 11:07 am)
Re: [PATCH 13/30] viafb: Separate global and fb-specific data, Jonathan Corbet, (Fri Apr 30, 11:22 am)
Re: [PATCH 13/30] viafb: Separate global and fb-specific data, Florian Tobias Schan ..., (Fri Apr 30, 11:43 am)
Re: [PATCH 02/30] viafb: use proper pci config API, Florian Tobias Schan ..., (Sat May 1, 7:01 am)
Re: [PATCH 12/30] viafb: Move core stuff into via-core.c, Florian Tobias Schan ..., (Sat May 1, 8:02 am)
Re: [PATCH 12/30] viafb: Move core stuff into via-core.c, Jonathan Corbet, (Sat May 1, 8:08 am)
Re: [PATCH 12/30] viafb: Move core stuff into via-core.c, Florian Tobias Schan ..., (Sat May 1, 8:29 am)
Re: [RFC] Second OLPC Viafb series, v2, Florian Tobias Schan ..., (Sat May 1, 2:28 pm)
Re: [RFC] Second OLPC Viafb series, v2, Jonathan Corbet, (Sat May 1, 3:57 pm)
Re: [PATCH 24/30] viafb: Add a driver for the video captur ..., Florian Tobias Schan ..., (Sat May 1, 6:18 pm)
Re: [PATCH 02/30] viafb: use proper pci config API, Jonathan Corbet, (Mon May 3, 7:37 pm)