-/* can_devrtl.c - CAN message queues functions for the RT-Linux
- * Linux CAN-bus device driver.
- * 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.3 17 Jun 2004
- */
+/**************************************************************************/
+/* File: can_devrtl.c - CAN message queues functions for the RT-Linux */
+/* */
+/* LinCAN - (Not only) Linux CAN bus driver */
+/* Copyright (C) 2002-2009 DCE FEE CTU Prague <http://dce.felk.cvut.cz> */
+/* Copyright (C) 2002-2009 Pavel Pisa <pisa@cmp.felk.cvut.cz> */
+/* Funded by OCERA and FRESCOR IST projects */
+/* */
+/* LinCAN is free software; you can redistribute it and/or modify it */
+/* under terms of the GNU General Public License as published by the */
+/* Free Software Foundation; either version 2, or (at your option) any */
+/* later version. LinCAN is distributed in the hope that it will be */
+/* useful, but WITHOUT ANY WARRANTY; without even the implied warranty */
+/* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU */
+/* General Public License for more details. You should have received a */
+/* copy of the GNU General Public License along with LinCAN; see file */
+/* COPYING. If not, write to the Free Software Foundation, 675 Mass Ave, */
+/* Cambridge, MA 02139, USA. */
+/* */
+/* To allow use of LinCAN in the compact embedded systems firmware */
+/* and RT-executives (RTEMS for example), main authors agree with next */
+/* special exception: */
+/* */
+/* Including LinCAN header files in a file, instantiating LinCAN generics */
+/* or templates, or linking other files with LinCAN objects to produce */
+/* an application image/executable, does not by itself cause the */
+/* resulting application image/executable to be covered by */
+/* the GNU General Public License. */
+/* This exception does not however invalidate any other reasons */
+/* why the executable file might be covered by the GNU Public License. */
+/* Publication of enhanced or derived LinCAN files is required although. */
+/**************************************************************************/
#ifdef CAN_WITH_RTL
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;
int irq2linux=0;
+ int ret;
pthread_t thread=NULL;
DEBUGMSG("can_rtl_isr invoked for irq %d\n",irq_num);
continue;
if(chip->chip_irq!=irq_num) continue;
+ if(chip->chipspecops->irq_accept)
+ ret=chip->chipspecops->irq_accept(chip->chip_irq,chip);
+
set_bit(MSGOBJ_IRQ_REQUEST_b,&chip->pend_flags);
set_bit(MSGOBJ_WORKER_WAKE_b,&chip->pend_flags);
if(chip->flags & CHIP_IRQ_PCI)
irq2linux=1;
+#ifdef CAN_ENABLE_VME_SUPPORT
+ if (chip->flags & CHIP_IRQ_VME)
+ tundra_rtl_ack_irq_vector(irq_num);
+#endif
if(!chip->worker_thread) continue;
thread=chip->worker_thread;
pthread_kill(thread,RTL_SIGNAL_WAKEUP);
}
}
- if(irq2linux)
- rtl_global_pend_irq(irq_num);
+ /* The following lines are commented out because of it is not
+ * possible to share level activated (PCI) IRQs between Linux
+ * and RT-Linux. */
+/* if(irq2linux) */
+/* rtl_global_pend_irq(irq_num); */
/*if(thread) rtl_reschedule_thread(thread);*/
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;
+ rtl_irqstate_t flags;
if(!chip) return 0;
but it seems to not work without that */
if(chip->chip_irq>=0) {
if ((chip->flags & CHIP_IRQ_VME) == 0) can_enable_irq(chip->chip_irq);
- else tundra_rtl_enable_pci_irq();
+ #ifdef CAN_ENABLE_VME_SUPPORT
+ #if 0
+ else tundra_rtl_enable_pci_irq();
+ #endif
/* FIXME: Bad practice. Doesn't work with more
- * than one card. */
+ * than one card.
+ *
+ * irq_accept added to the LinCAN driver now,
+ * and above workaround should not be required.
+ * Enable rtl_hard_enable_irq() at line
+ * ca91c042.c:1045
+ */
+ #endif /*CAN_ENABLE_VME_SUPPORT*/
+
}
+ rtl_no_interrupts (flags);
RTL_MARK_SUSPENDED(pthread_self());
if(test_and_clear_bit(MSGOBJ_WORKER_WAKE_b,&chip->pend_flags)){
RTL_MARK_READY(pthread_self());
+ rtl_restore_interrupts (flags);
continue;
}
+ rtl_restore_interrupts (flags);
rtl_schedule();
}
}
-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;
attrib_p=&attrib;
}
- if(chip->chipspecops->irq_handler){
+ 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)
}
-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)) {
+ 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)