X-Git-Url: http://rtime.felk.cvut.cz/gitweb/lincan.git/blobdiff_plain/a4c9ead4b64bd4de307f375c2ff313a7a07a06e0..a682f9de48bcce43fba6141fbdb4d451914e0bb4:/lincan/src/can_devrtl.c diff --git a/lincan/src/can_devrtl.c b/lincan/src/can_devrtl.c index d25072a..5bbc2c0 100644 --- a/lincan/src/can_devrtl.c +++ b/lincan/src/can_devrtl.c @@ -16,11 +16,17 @@ #include +#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; + struct canchip_t *chip; struct candevice_t *candev; int board_nr; int chip_nr; @@ -74,7 +80,7 @@ rtl_free_global_irq( irq ) void * can_chip_worker_thread(void *arg) { - struct chip_t *chip = (struct chip_t *) arg; + struct canchip_t *chip = (struct canchip_t *) arg; struct msgobj_t *obj; int ret, i; int loop_cnt; @@ -102,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; } @@ -126,8 +132,15 @@ void * can_chip_worker_thread(void *arg) /*re-enable chip IRQ, I am not sure, if this is required, but it seems to not work without that */ - if(chip->chip_irq>=0) - can_enable_irq(chip->chip_irq); + if(chip->chip_irq>=0) { + if ((chip->flags & CHIP_IRQ_VME) == 0) can_enable_irq(chip->chip_irq); + #ifdef CAN_ENABLE_VME_SUPPORT + else tundra_rtl_enable_pci_irq(); + /* FIXME: Bad practice. Doesn't work with more + * than one card. */ + #endif /*CAN_ENABLE_VME_SUPPORT*/ + + } RTL_MARK_SUSPENDED(pthread_self()); if(test_and_clear_bit(MSGOBJ_WORKER_WAKE_b,&chip->pend_flags)){ @@ -141,7 +154,7 @@ void * can_chip_worker_thread(void *arg) } -int can_chip_setup_irq(struct chip_t *chip) +int can_chip_setup_irq(struct canchip_t *chip) { int ret; struct sched_param sched_param; @@ -159,8 +172,16 @@ int can_chip_setup_irq(struct chip_t *chip) attrib_p=&attrib; } - if(chip->chipspecops->irq_handler){ - if (rtl_request_irq(chip->chip_irq,can_rtl_isr)) + if(chip->chipspecops->irq_handler && !(chip->flags & CHIP_IRQ_CUSTOM)){ + 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); @@ -174,12 +195,20 @@ int can_chip_setup_irq(struct chip_t *chip) } -void can_chip_free_irq(struct chip_t *chip) +void can_chip_free_irq(struct canchip_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); + if((chip->flags & CHIP_IRQ_SETUP) && (chip->chip_irq>=0) + && !(chip->flags & CHIP_IRQ_CUSTOM)) { + 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; } }