]> rtime.felk.cvut.cz Git - mf6xx.git/commitdiff
Corrected errors in interrupt enabling/disabling/handling; Tested on userspace applic...
authorRostislav Lisovy <lisovy@gmail.com>
Tue, 15 Feb 2011 21:43:48 +0000 (22:43 +0100)
committerRostislav Lisovy <lisovy@gmail.com>
Tue, 15 Feb 2011 21:43:48 +0000 (22:43 +0100)
src/uio/kernel/Makefile
src/uio/kernel/mf614.c

index 77d29dc98a6fd627e8c8adf22ba96c47162ea1b4..576834d62022eb0b20ffdeb60499fc2b6bb1445d 100755 (executable)
@@ -7,4 +7,10 @@ my_all:
 obj-m := mf614.o
 
 clean:
-       rm *.ko *.o 
+       rm *.ko *.o
+
+load:
+       sync
+       rmmod mf614
+       sync
+       insmod ./mf614.ko
index 674005dbfacd62a6ac3e8a037ea87cee45908633..117014a326fa87e52feb3f842656262f2d798617 100755 (executable)
@@ -3,17 +3,16 @@
 #include <linux/device.h>
 #include <linux/pci.h>
 #include <linux/slab.h>
-
-
-#include <linux/uio_driver.h>
 #include <linux/io.h>
+#include <linux/kernel.h>
+#include <linux/uio_driver.h>
 
 #define PCI_VENDOR_ID_HUMUSOFT         0x186c
 #define PCI_DEVICE_ID_MF614            0x0614
 #define PCI_SUBVENDOR_ID_HUMUSOFT      0x186c
 #define PCI_SUBDEVICE_DEVICE           0x0000
 
-#define STATUS_OFFSET                  0x10
+#define STATUS_REG                     0x10
 #define STATUS_T5INTE                  (u32) (1 << 19)
 #define STATUS_T5                      (u32) (1 << 3)
 #define STATUS_CCINTE                  (u32) (1 << 18)
 
 static irqreturn_t mf614_irq_handler(int irq, struct uio_info *info)
 {
-       void __iomem *status_reg = info->priv + STATUS_OFFSET;
+       void __iomem *status_reg = info->priv;
+       status_reg = ((u8*) status_reg) + STATUS_REG;
+
 
-       if ((ioread16(status_reg) & STATUS_T5INTE) 
-               && (ioread16(status_reg) & STATUS_T5))
+       if ((ioread32(status_reg) & STATUS_T5INTE) 
+               && (ioread32(status_reg) & STATUS_T5))
        {
-               iowrite16(ioread16(status_reg) & ~STATUS_T5INTE, status_reg);
+               //disable interrupt
+               iowrite32(ioread16(status_reg) & ~STATUS_T5INTE, status_reg);
                return IRQ_HANDLED;
        }
 
-       if ((ioread16(status_reg) & STATUS_CCINTE) 
-               && (ioread16(status_reg) & STATUS_CC))
+       if ((ioread32(status_reg) & STATUS_CCINTE) 
+               && (ioread32(status_reg) & STATUS_CC))
        {
-               iowrite16(ioread16(status_reg) & ~STATUS_CCINTE, status_reg);
+               //disable interrupt
+               iowrite32(ioread32(status_reg) & ~STATUS_CCINTE, status_reg);
                return IRQ_HANDLED;
        }
 
@@ -43,15 +46,17 @@ static irqreturn_t mf614_irq_handler(int irq, struct uio_info *info)
 
 static int mf614_irqcontrol(struct uio_info *info, s32 irq_on)
 {
-       void __iomem *status_reg = info->priv + STATUS_OFFSET;
+       void __iomem *status_reg = info->priv;
+       status_reg = ((u8*) status_reg) + STATUS_REG;
+
 
        if (irq_on == 0) { /* Disable interrupts */
-               iowrite16(ioread16(status_reg) & ~STATUS_T5INTE, status_reg);
-               iowrite16(ioread16(status_reg) & ~STATUS_CCINTE, status_reg);
+               iowrite32(ioread32(status_reg) & ~STATUS_T5INTE, status_reg);
+               iowrite32(ioread32(status_reg) & ~STATUS_CCINTE, status_reg);
        } 
        else if (irq_on == 1) {
-               iowrite16(ioread16(status_reg) | STATUS_T5INTE, status_reg);
-               iowrite16(ioread16(status_reg) | STATUS_CCINTE, status_reg);
+               iowrite32(ioread32(status_reg) | STATUS_T5INTE, status_reg);
+               iowrite32(ioread32(status_reg) | STATUS_CCINTE, status_reg);
        }
 
        return 0;
@@ -146,11 +151,12 @@ out_free:
 static void mf614_pci_remove(struct pci_dev *dev)
 {
        struct uio_info *info = pci_get_drvdata(dev);
-       void __iomem *status_reg = info->priv + STATUS_OFFSET;
+       void __iomem *status_reg = info->priv;
+       status_reg = ((u8*) status_reg) + STATUS_REG;
        
        /* Disable interrupts */
-       iowrite16(ioread16(status_reg) & ~STATUS_T5INTE, status_reg);   
-       iowrite16(ioread16(status_reg) & ~STATUS_CCINTE, status_reg);   
+       iowrite32(ioread32(status_reg) & ~STATUS_T5INTE, status_reg);   
+       iowrite32(ioread32(status_reg) & ~STATUS_CCINTE, status_reg);   
        
        uio_unregister_device(info);
        pci_release_regions(dev);