]> rtime.felk.cvut.cz Git - lincan.git/blobdiff - lincan/src/can_devrtl.c
Added support for VME bus under RT Linux.
[lincan.git] / lincan / src / can_devrtl.c
index 812ea84a731be5de4952af924b4416ebb5f25f7e..5db8b82e8ed298a50b92839d21f9ff73b3982dd4 100644 (file)
@@ -3,7 +3,7 @@
  * New CAN queues by Pavel Pisa - OCERA team member
  * email:pisa@cmp.felk.cvut.cz
  * This software is released under the GPL-License.
- * Version lincan-0.2  9 Jul 2003
+ * Version lincan-0.3  17 Jun 2004
  */
 
 #ifdef CAN_WITH_RTL
 
 #include <rtl_malloc.h>
 
+#ifdef CAN_ENABLE_VME_SUPPORT
+#include "ca91c042.h"
+/* Modified version of ca91c042 driver can be found in
+ * components/comm/contrib directory. */
+#endif
+
+can_spinlock_t can_irq_manipulation_lock;
+
 unsigned int can_rtl_isr( unsigned int irq_num, struct pt_regs *r )
 {
        struct chip_t *chip;
@@ -100,7 +108,7 @@ void * can_chip_worker_thread(void *arg)
                        DEBUGMSG("IRQ_REQUEST processing ...\n");
                        loop_cnt = 100;
                        if(chip->chipspecops->irq_handler) do{
-                               ret=chip->chipspecops->irq_handler(chip->chip_irq,chip,NULL);
+                               ret=chip->chipspecops->irq_handler(chip->chip_irq,chip);
                        }while(ret && --loop_cnt);
                        continue;
                }
@@ -109,10 +117,15 @@ void * can_chip_worker_thread(void *arg)
                        for(i=0;i<chip->max_objects;i++){
                                if((obj=chip->msgobj[i])==NULL)
                                        continue;
-                               if(!can_msgobj_test_and_clear_fl(obj,TX_REQUEST))
-                                       continue;
-                               DEBUGMSG("Calling wakeup_tx\n");
-                               chip->chipspecops->wakeup_tx(chip, obj);
+                               if(can_msgobj_test_fl(obj,TX_REQUEST)) {
+                                       DEBUGMSG("Calling wakeup_tx\n");
+                                       chip->chipspecops->wakeup_tx(chip, obj);
+                               }
+                               if(can_msgobj_test_fl(obj,FILTCH_REQUEST)) {
+                                       DEBUGMSG("Calling filtch_rq\n");
+                                       if(chip->chipspecops->filtch_rq)
+                                               chip->chipspecops->filtch_rq(chip, obj);
+                               }
                        }
                        continue;
                }
@@ -153,7 +166,15 @@ int can_chip_setup_irq(struct chip_t *chip)
        }
        
        if(chip->chipspecops->irq_handler){
-               if (rtl_request_irq(chip->chip_irq,can_rtl_isr))
+               int (*my_request_irq)(unsigned int vector, unsigned int (*rtl_handler)(unsigned int irq, struct pt_regs *regs));
+#ifdef CAN_ENABLE_VME_SUPPORT
+               if ((chip->flags & CHIP_IRQ_VME) != 0)
+                       my_request_irq = rtl_request_vmeirq;
+               else
+#endif
+                       my_request_irq = rtl_request_irq;
+
+               if (my_request_irq(chip->chip_irq,can_rtl_isr))
                        return -1;
                else {
                        DEBUGMSG("Registered interrupt %d\n",chip->chip_irq);
@@ -172,7 +193,14 @@ void can_chip_free_irq(struct chip_t *chip)
        if(chip->worker_thread)
                pthread_delete_np(chip->worker_thread);
        if((chip->flags & CHIP_IRQ_SETUP) && (chip->chip_irq>=0)) {
-               rtl_free_irq(chip->chip_irq);
+               int (*my_free_irq)(unsigned int vector);
+#ifdef CAN_ENABLE_VME_SUPPORT
+               if ((chip->flags & CHIP_IRQ_VME) != 0)
+                       my_free_irq = rtl_free_vmeirq;
+               else
+#endif
+                       my_free_irq = rtl_free_irq;
+               my_free_irq(chip->chip_irq);
                chip->flags &= ~CHIP_IRQ_SETUP;
        }
 }