]> rtime.felk.cvut.cz Git - lincan.git/commitdiff
USBCAN converter code updated to match full version of LinCAN sources.
authorPavel Pisa <pisa@cmp.felk.cvut.cz>
Sat, 1 Oct 2011 20:37:50 +0000 (22:37 +0200)
committerPavel Pisa <pisa@cmp.felk.cvut.cz>
Sat, 1 Oct 2011 20:37:50 +0000 (22:37 +0200)
Signed-off-by: Pavel Pisa <pisa@cmp.felk.cvut.cz>
19 files changed:
embedded/app/usbcan/can/can_queue.h
embedded/app/usbcan/can/can_sysdep.h
embedded/app/usbcan/can/can_sysless.h
embedded/app/usbcan/can/canmsg.h
embedded/app/usbcan/can/constants.h
embedded/app/usbcan/can/devcommon.h
embedded/app/usbcan/can/finish.h
embedded/app/usbcan/can/i82527.h
embedded/app/usbcan/can/main.h
embedded/app/usbcan/can/modparms.h
embedded/app/usbcan/can/setup.h
embedded/app/usbcan/can/sja1000p.h
embedded/app/usbcan/can_quesysless.c
embedded/app/usbcan/can_queue.c
embedded/app/usbcan/devcommon.c
embedded/app/usbcan/finish.c
embedded/app/usbcan/setup.c
embedded/app/usbcan/sja1000p.c
embedded/app/usbcan/usb_vend.c

index 42eeef4bae5c7f5d7862fed3d938a6d17caefaa4..a600b80b313fb794859811a0749da3a5e211ba14 100644 (file)
@@ -1,10 +1,35 @@
-/* can_queue.h - CAN queues and message passing infrastructure 
- * Linux CAN-bus device driver.
- * Written 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_queue.h - CAN queues and message passing infrastructure      */
+/*                                                                        */
+/* 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.  */
+/**************************************************************************/
 
 #ifndef _CAN_QUEUE_H
 #define _CAN_QUEUE_H
@@ -14,7 +39,7 @@
 #include "./can_sysdep.h"
 
 /**
- * struct canque_slot_t - one CAN message slot in the CAN FIFO queue 
+ * struct canque_slot_t - one CAN message slot in the CAN FIFO queue
  * @next: pointer to the next/younger slot
  * @slot_flags: space for flags and optional command describing action
  *     associated with slot data
@@ -35,9 +60,9 @@
  * @fifo_flags: this field holds global flags describing state of the FIFO.
  *     %CAN_FIFOF_ERROR is set when some error condition occurs.
  *     %CAN_FIFOF_ERR2BLOCK defines, that error should lead to the FIFO block state.
- *     %CAN_FIFOF_BLOCK state blocks insertion of the next messages. 
- *     %CAN_FIFOF_OVERRUN attempt to acquire new slot, when FIFO is full. 
- *     %CAN_FIFOF_FULL indicates FIFO full state. 
+ *     %CAN_FIFOF_BLOCK state blocks insertion of the next messages.
+ *     %CAN_FIFOF_OVERRUN attempt to acquire new slot, when FIFO is full.
+ *     %CAN_FIFOF_FULL indicates FIFO full state.
  *     %CAN_FIFOF_EMPTY indicates no allocated slot in the FIFO.
  *     %CAN_FIFOF_DEAD condition indication. Used when FIFO is beeing destroyed.
  * @error_code: futher description of error condition
@@ -49,7 +74,7 @@
  * @fifo_lock: the lock to ensure atomicity of slot manipulation operations.
  * @slotsnr:  number of allocated slots
  *
- * This structure represents CAN FIFO queue. It is implemented as 
+ * This structure represents CAN FIFO queue. It is implemented as
  * a single linked list of slots prepared for processing. The empty slots
  * are stored in single linked list (@flist).
  */
@@ -105,7 +130,7 @@ struct canque_fifo_t {
 
 
 /**
- * canque_fifo_get_inslot - allocate slot for the input of one CAN message 
+ * canque_fifo_get_inslot - allocate slot for the input of one CAN message
  * @fifo: pointer to the FIFO structure
  * @slotp: pointer to location to store pointer to the allocated slot.
  * @cmd: optional command associated with allocated slot.
@@ -297,7 +322,7 @@ struct canchip_t;
  * @pending_inops: bitmask of pending operations
  * @pending_outops: bitmask of pending operations
  *
- * This structure represents one direction connection from messages source 
+ * This structure represents one direction connection from messages source
  * (@inends) to message consumer (@outends) fifo ends hub. The edge contains
  * &struct canque_fifo_t for message fifo implementation.
  */
@@ -324,7 +349,7 @@ struct canque_edge_t {
  * struct canque_ends_t - CAN message delivery subsystem graph vertex (FIFO ends)
  * @ends_flags: this field holds flags describing state of the ENDS structure.
  * @active: the array of the lists of active edges directed to the ends structure
- *     with ready messages. The array is indexed by the edges priorities. 
+ *     with ready messages. The array is indexed by the edges priorities.
  * @idle: the list of the edges directed to the ends structure with empty FIFOs.
  * @inlist: the list of outgoing edges input sides.
  * @outlist: the list of all incoming edges output sides. Each of there edges
@@ -332,7 +357,7 @@ struct canque_edge_t {
  * @ends_lock: the lock synchronizing operations between threads accessing
  *     same ends structure.
  * @notify: pointer to notify procedure. The next state changes are notified.
- *     %CANQUEUE_NOTIFY_EMPTY (out->in call) - all slots are processed by FIFO out side. 
+ *     %CANQUEUE_NOTIFY_EMPTY (out->in call) - all slots are processed by FIFO out side.
  *     %CANQUEUE_NOTIFY_SPACE (out->in call) - full state negated => there is space for new message.
  *     %CANQUEUE_NOTIFY_PROC  (in->out call) - empty state negated => out side is requested to process slots.
  *     %CANQUEUE_NOTIFY_NOUSR (both) - notify, that the last user has released the edge usage
@@ -492,11 +517,11 @@ unsigned int canque_filtid2internal(unsigned long id, int filtflags)
 
 int canque_get_inslot(struct canque_ends_t *qends,
        struct canque_edge_t **qedgep, struct canque_slot_t **slotp, int cmd);
-       
+
 int canque_get_inslot4id(struct canque_ends_t *qends,
        struct canque_edge_t **qedgep, struct canque_slot_t **slotp,
        int cmd, unsigned long id, int prio);
-       
+
 int canque_put_inslot(struct canque_ends_t *qends,
        struct canque_edge_t *qedge, struct canque_slot_t *slot);
 
@@ -516,7 +541,7 @@ int canque_again_outslot(struct canque_ends_t *qends,
 
 int canque_set_filt(struct canque_edge_t *qedge,
        unsigned long filtid, unsigned long filtmask, int flags);
-       
+
 int canque_flush(struct canque_edge_t *qedge);
 
 int canqueue_disconnect_edge(struct canque_edge_t *qedge);
@@ -564,7 +589,7 @@ can_spin_irqflags_t canque_edge_lock_both_ends(struct canque_ends_t *inends, str
                can_spin_lock_irqsave(&outends->ends_lock, flags);
                if(outends!=inends) can_spin_lock(&inends->ends_lock);
        }
-       return flags;   
+       return flags;
 }
 
 static inline
@@ -584,11 +609,11 @@ void __canque_edge_decref_body(struct canque_edge_t *edge)
        int dead_fl=0;
        struct canque_ends_t *inends=edge->inends;
        struct canque_ends_t *outends=edge->outends;
-       
+
        flags=canque_edge_lock_both_ends(inends, outends);
        if(atomic_dec_and_test(&edge->edge_used)) {
                dead_fl=!canque_fifo_test_and_set_fl(&edge->fifo,DEAD);
-               /* Because of former evolution of edge references 
+               /* Because of former evolution of edge references
                   management notify of CANQUEUE_NOTIFY_NOUSR could
                   be moved to canque_edge_do_dead :-) */
        }
@@ -615,17 +640,19 @@ static inline
 void canque_edge_decref(struct canque_edge_t *edge)
 {
        int x, y;
-       
+
         x = atomic_read(&edge->edge_used);
         do{
                if(x<=1)
                        return __canque_edge_decref(edge);
                y=x;
+           #ifdef CAN_HAVE_ATOMIC_CMPXCHG
+               atomic_cmpxchg(&edge->edge_used, x, x-1);
+           #else /* workaround for case that atomic_cmpxchg is not defined */
                /* This code strongly depends on the definition of atomic_t !!!! */
-               /* x=cmpxchg(&edge->edge_used, x, x-1); */
-               /* Next alternative could be more portable */
                x=__cmpxchg(&edge->edge_used, x, x-1, sizeof(atomic_t));
                /* If even this does not help, comment out CAN_HAVE_ARCH_CMPXCHG in can_sysdep.h */
+           #endif
        } while(x!=y);
 }
 #endif
@@ -636,7 +663,7 @@ struct canque_edge_t *canque_first_inedge(struct canque_ends_t *qends)
        can_spin_irqflags_t flags;
        struct list_head *entry;
        struct canque_edge_t *edge;
-       
+
        can_spin_lock_irqsave(&qends->ends_lock, flags);
        entry=qends->inlist.next;
     skip_dead:
@@ -661,7 +688,7 @@ struct canque_edge_t *canque_next_inedge(struct canque_ends_t *qends, struct can
        can_spin_irqflags_t flags;
        struct list_head *entry;
        struct canque_edge_t *next;
-       
+
        can_spin_lock_irqsave(&qends->ends_lock, flags);
        entry=edge->inpeers.next;
     skip_dead:
@@ -689,7 +716,7 @@ struct canque_edge_t *canque_first_outedge(struct canque_ends_t *qends)
        can_spin_irqflags_t flags;
        struct list_head *entry;
        struct canque_edge_t *edge;
-       
+
        can_spin_lock_irqsave(&qends->ends_lock, flags);
        entry=qends->outlist.next;
     skip_dead:
@@ -714,7 +741,7 @@ struct canque_edge_t *canque_next_outedge(struct canque_ends_t *qends, struct ca
        can_spin_irqflags_t flags;
        struct list_head *entry;
        struct canque_edge_t *next;
-       
+
        can_spin_lock_irqsave(&qends->ends_lock, flags);
        entry=edge->outpeers.next;
     skip_dead:
index 5a3b86cdd922a53a4d52f274416c9eb4800ef3fd..2e234202821d4ef1f5297d42db4e5b42a464b6c4 100644 (file)
@@ -1,226 +1 @@
-/* can_sysdep.h - hides differences between individual Linux kernel 
- *                versions and RT extensions 
- * Linux CAN-bus device driver.
- * Written 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
- */
-
-#ifndef _CAN_SYSDEP_H
-#define _CAN_SYSDEP_H
-
-#ifdef CAN_WITH_RTL
-#include <rtl.h>
-#include <rtl_sync.h>
-#include <rtl_core.h>
-#include <rtl_mutex.h>
-#include <rtl_sched.h>
-#include <time.h>
-#endif /*CAN_WITH_RTL*/
-
-/*#define __NO_VERSION__*/
-/*#include <linux/module.h>*/
-
-#include <linux/version.h>
-#include <linux/wait.h>
-#include <linux/list.h>
-#include <linux/fs.h>
-#include <linux/ioport.h>
-#include <linux/delay.h>
-#include <linux/sched.h>
-#include <linux/interrupt.h>
-#include <asm/errno.h>
-
-#include <asm/io.h>
-#include <asm/atomic.h>
-#include <asm/irq.h>
-#include <asm/uaccess.h>
-
-#include "lincan_config.h"
-
-/*optional features*/
-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0))
-#define CAN_ENABLE_KERN_FASYNC
-#ifdef CONFIG_PCI
-#define CAN_ENABLE_PCI_SUPPORT
-#endif
-#ifdef CONFIG_OC_LINCANVME
-#define CAN_ENABLE_VME_SUPPORT
-#endif
-#endif
-
-#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,4,0))
-#include <linux/malloc.h>
-#else
-#include <linux/slab.h>
-#endif
-
-#ifdef CAN_ENABLE_PCI_SUPPORT
-#include "linux/pci.h"
-#endif /*CAN_ENABLE_PCI_SUPPORT*/
-
-/* Next is not sctrictly correct, because of 2.3.0, 2.3.1, 2.3.2
-   kernels need next definitions  too */
-#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,2,19)) /* may need correction */
-  #define wait_queue_head_t struct wait_queue *
-  #define wait_queue_t      struct wait_queue
-  #define init_waitqueue_head(queue_head) (*queue_head=NULL)
-  #define init_waitqueue_entry(qentry,qtask) \
-                        (qentry->next=NULL,qentry->task=qtask)
-  #define DECLARE_WAIT_QUEUE_HEAD(name) \
-        struct wait_queue * name=NULL
-  #define DECLARE_WAITQUEUE(wait, current) \
-        struct wait_queue wait = { current, NULL }
-  #define init_MUTEX(sem) (*sem=MUTEX)
-  #define DECLARE_MUTEX(name) struct semaphore name=MUTEX
-#endif /* 2.2.19 */
-
-#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,4,0)) && !defined(DECLARE_TASKLET)
-  #define tasklet_struct tq_struct
-  #define DECLARE_TASKLET(_name, _func, _data) \
-                struct tq_struct _name = { sync: 0, routine: _func, data: (void*)_data }
-
-  /* void tasklet_init(struct tasklet_struct *t, void (*func)(unsigned long), unsigned long data); */
-  #define tasklet_init(_tasklet, _func, _data) \
-    do{ \
-       /* (_tasklet)->next=NULL; */ \
-       /* Above not needed for 2.2.x and buggy for 2.4.x */ \
-       (_tasklet)->sync=0; \
-       (_tasklet)->routine=_func; \
-       (_tasklet)->data=(void*)_data; \
-    }while(0)
-
-  /* void tasklet_schedule(struct tasklet_struct *t) */
-  #define tasklet_schedule(_tasklet) \
-    do{ \
-       queue_task(_tasklet,&tq_immediate); \
-       mark_bh(IMMEDIATE_BH); \
-    }while(0)
-
-  /* void tasklet_kill(struct tasklet_struct *t); */
-  #define tasklet_kill(_tasklet) \
-                synchronize_irq()
-
-#endif /* 2.4.0 */
-
-
-#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,7)) || (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0))
-
-#define MINOR_NR \
-       (MINOR(file->f_dentry->d_inode->i_rdev))
-
-#else /* Linux kernel < 2.5.7 or >= 2.6.0 */
-
-#define MINOR_NR \
-       (minor(file->f_dentry->d_inode->i_rdev))
-
-#endif /* Linux kernel < 2.5.7 or >= 2.6.0 */
-
-#ifndef CAN_WITH_RTL
-#if ((LINUX_VERSION_CODE < KERNEL_VERSION(2,5,68)) && !defined(IRQ_RETVAL))
-  typedef void can_irqreturn_t;
-  #define CAN_IRQ_NONE
-  #define CAN_IRQ_HANDLED
-  #define CAN_IRQ_RETVAL(x)
-#else /* <=2.5.67 */
-  typedef irqreturn_t can_irqreturn_t;
-  #define CAN_IRQ_NONE    IRQ_NONE
-  #define CAN_IRQ_HANDLED IRQ_HANDLED
-  #define CAN_IRQ_RETVAL  IRQ_RETVAL
-#endif /* <=2.5.67 */
-#else /*CAN_WITH_RTL*/
-  typedef int can_irqreturn_t;
-  #define CAN_IRQ_NONE        0
-  #define CAN_IRQ_HANDLED     1
-  #define CAN_IRQ_RETVAL(x)   ((x) != 0)
-#endif /*CAN_WITH_RTL*/
-
-#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,33))
-   #define can_synchronize_irq(irqnum) synchronize_irq()
-#else /* >=2.5.33 */
-   #define can_synchronize_irq synchronize_irq
-#endif
-
-#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,4,0))
-  #define del_timer_sync del_timer
-#endif /* <2.4.0 */
-
-#ifdef __HAVE_ARCH_CMPXCHG
-  #define CAN_HAVE_ARCH_CMPXCHG
-#endif
-
-#ifndef CAN_WITH_RTL
-/* Standard LINUX kernel */
-
-#define can_spinlock_t             spinlock_t
-#define can_spin_irqflags_t        unsigned long
-#define can_spin_lock              spin_lock
-#define can_spin_unlock            spin_unlock
-#define can_spin_lock_irqsave      spin_lock_irqsave
-#define can_spin_unlock_irqrestore spin_unlock_irqrestore
-#define can_spin_lock_init         spin_lock_init
-
-#ifndef DEFINE_SPINLOCK
-#define CAN_DEFINE_SPINLOCK(x)     can_spinlock_t x = SPIN_LOCK_UNLOCKED
-#else /*DEFINE_SPINLOCK*/
-#define CAN_DEFINE_SPINLOCK        DEFINE_SPINLOCK
-#endif /*DEFINE_SPINLOCK*/
-
-#if defined(CONFIG_PREEMPT) || (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0))
-#define can_preempt_disable        preempt_disable
-#define can_preempt_enable         preempt_enable
-#else /*CONFIG_PREEMPT*/
-#define can_preempt_disable()      do { } while (0)
-#define can_preempt_enable()       do { } while (0)
-#endif /*CONFIG_PREEMPT*/
-
-#define can_enable_irq             enable_irq
-#define can_disable_irq            disable_irq
-
-#define can_printk                 printk
-
-/* CAN message timestamp source, it is called from interrupt context */
-#define can_gettimeofday do_gettimeofday
-
-#else /*CAN_WITH_RTL*/
-
-#define can_spinlock_t             rtl_spinlock_t
-#define can_spin_irqflags_t        rtl_irqstate_t
-#define can_spin_lock              rtl_spin_lock
-#define can_spin_unlock            rtl_spin_unlock
-#define can_spin_lock_irqsave      rtl_spin_lock_irqsave
-#define can_spin_unlock_irqrestore rtl_spin_unlock_irqrestore
-#define can_spin_lock_init         rtl_spin_lock_init
-
-#define CAN_DEFINE_SPINLOCK(x)     can_spinlock_t x = SPIN_LOCK_UNLOCKED
-
-#define can_preempt_disable()      do { } while (0)
-#define can_preempt_enable()       do { } while (0)
-
-#define can_enable_irq             rtl_hard_enable_irq
-#define can_disable_irq            rtl_hard_disable_irq
-
-#define can_printk                 rtl_printf
-
-/*
- * terrible hack to test rtl_file private_data concept, ugh !!!
- * this would result in crash on architectures,  where 
- * sizeof(int) < sizeof(void *)
- */
-#define can_set_rtl_file_private_data(fptr, p) do{ fptr->f_minor=(long)(p); } while(0)
-#define can_get_rtl_file_private_data(fptr) ((void*)((fptr)->f_minor))
-
-extern can_spinlock_t can_irq_manipulation_lock;
-
-/* CAN message timestamp source, it is called from interrupt context */
-#define can_gettimeofday(ptr) do {\
-         struct timespec temp_timespec;\
-         clock_gettime(CLOCK_REALTIME,&temp_timespec);\
-         ptr->tv_usec=temp_timespec.tv_nsec/1000;\
-         ptr->tv_sec=temp_timespec.tv_sec;\
-       } while(0)
-
-#endif /*CAN_WITH_RTL*/
-
-#endif /*_CAN_SYSDEP_H*/
+#include "can_sysless.h"
index af3d7031fd34ec6659a6567ecb080faf2b22061e..1648b7cd0068b4351b0105353ef2f7e866c1a149 100644 (file)
@@ -1,23 +1,40 @@
-/* can_sysdep.h - hides differences between individual Linux kernel
- *                versions and RT extensions
- * Linux CAN-bus device driver.
- * Written 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_sysless.h - provides can_sysdep.h definitions to hide        */
+/*                      between Linux kernel and embedded target build    */
+/*                                                                        */
+/* 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.  */
+/**************************************************************************/
 
 #ifndef _CAN_SYSDEP_H
 #define _CAN_SYSDEP_H
 
-#ifdef CAN_WITH_RTL
-#include <rtl.h>
-#include <rtl_sync.h>
-#include <rtl_core.h>
-#include <rtl_mutex.h>
-#include <rtl_sched.h>
-#include <time.h>
-#endif /*CAN_WITH_RTL*/
 
 #include <cpu_def.h>
 #include <malloc.h>
@@ -39,161 +56,35 @@ typedef struct { volatile int counter; } atomic_t;
        (type *)( (char *)__mptr - offsetof(type,member) );})
 
 
-/*#define __NO_VERSION__*/
-/*#include <linux/module.h>*/
-
-// #include <linux/version.h>
-// #include <linux/wait.h>
-// #include <linux/list.h>
-// #include <linux/fs.h>
-// #include <linux/ioport.h>
-// #include <linux/delay.h>
-// #include <linux/sched.h>
-// #include <linux/interrupt.h>
-// #include <asm/errno.h>
-//
-// #include <asm/io.h>
-// #include <asm/atomic.h>
-// #include <asm/irq.h>
-// #include <asm/uaccess.h>
-
-// #include "lincan_config.h"
-
-/*optional features*/
-// #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0))
-// #define CAN_ENABLE_KERN_FASYNC
-// #ifdef CONFIG_PCI
-// #define CAN_ENABLE_PCI_SUPPORT
-// #endif
-// #ifdef CONFIG_OC_LINCANVME
-// #define CAN_ENABLE_VME_SUPPORT
-// #endif
-// #endif
-
-// #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,4,0))
-// #include <linux/malloc.h>
-// #else
-// #include <linux/slab.h>
-// #endif
-
-// #ifdef CAN_ENABLE_PCI_SUPPORT
-// #include "linux/pci.h"
-// #endif /*CAN_ENABLE_PCI_SUPPORT*/
-
-/* Next is not sctrictly correct, because of 2.3.0, 2.3.1, 2.3.2
-   kernels need next definitions  too */
-// #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,2,19)) /* may need correction */
-   #define wait_queue_head_t struct wait_queue *
-   #define wait_queue_t      struct wait_queue
-   #define init_waitqueue_head(queue_head) (*queue_head=NULL)
-  #define init_waitqueue_entry(qentry,qtask) \
-                        (qentry->next=NULL,qentry->task=qtask)
-  #define DECLARE_WAIT_QUEUE_HEAD(name) \
-        struct wait_queue * name=NULL
-  #define DECLARE_WAITQUEUE(wait, current) \
+
+#define wait_queue_head_t struct wait_queue *
+#define wait_queue_t      struct wait_queue
+#define init_waitqueue_head(queue_head) (*queue_head=NULL)
+#define init_waitqueue_entry(qentry,qtask) \
+               (qentry->next=NULL,qentry->task=qtask)
+#define DECLARE_WAIT_QUEUE_HEAD(name) \
+       struct wait_queue * name=NULL
+#define DECLARE_WAITQUEUE(wait, current) \
         struct wait_queue wait = { current, NULL }
-//   #define init_MUTEX(sem) (*sem=MUTEX)
-//   #define DECLARE_MUTEX(name) struct semaphore name=MUTEX
-// #endif /* 2.2.19 */
-
-// #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,4,0)) && !defined(DECLARE_TASKLET)
-//   #define tasklet_struct tq_struct
-/*  #define DECLARE_TASKLET(_name, _func, _data) \
-                struct tq_struct _name = { sync: 0, routine: _func, data: (void*)_data }*/
-//
-//   /* void tasklet_init(struct tasklet_struct *t, void (*func)(unsigned long), unsigned long data); */
-/*   #define tasklet_init(_tasklet, _func, _data) \
-    do{ \
-       (_tasklet)->sync=0; \
-       (_tasklet)->routine=_func; \
-       (_tasklet)->data=(void*)_data; \
-    }while(0)*/
-//
-//   /* void tasklet_schedule(struct tasklet_struct *t) */
-/*  #define tasklet_schedule(_tasklet) \
-    do{ \
-       queue_task(_tasklet,&tq_immediate); \
-       mark_bh(IMMEDIATE_BH); \
-    }while(0)*/
-//
-//   /* void tasklet_kill(struct tasklet_struct *t); */
-/*  #define tasklet_kill(_tasklet) \
-                synchronize_irq()*/
-//
-// #endif /* 2.4.0 */
-
-
-// #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,7)) || (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0))
-
-#define MINOR_NR \
-       (MINOR(file->f_dentry->d_inode->i_rdev))
-
-// #else /* Linux kernel < 2.5.7 or >= 2.6.0 */
-//
-/*#define MINOR_NR \
-       (minor(file->f_dentry->d_inode->i_rdev))*/
-//
-// #endif /* Linux kernel < 2.5.7 or >= 2.6.0 */
-
-// #ifndef CAN_WITH_RTL
-// #if ((LINUX_VERSION_CODE < KERNEL_VERSION(2,5,68)) && !defined(IRQ_RETVAL))
-  typedef void can_irqreturn_t;
-  #define CAN_IRQ_NONE
-  #define CAN_IRQ_HANDLED
-  #define CAN_IRQ_RETVAL(x)
-// #else /* <=2.5.67 */
-//   typedef irqreturn_t can_irqreturn_t;
-//   #define CAN_IRQ_NONE    IRQ_NONE
-//   #define CAN_IRQ_HANDLED IRQ_HANDLED
-//   #define CAN_IRQ_RETVAL  IRQ_RETVAL
-// #endif /* <=2.5.67 */
-// #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19))
-/*  #define CAN_IRQ_HANDLER_ARGS(irq_number, dev_id) \
-               int irq_number, void *dev_id, struct pt_regs *regs*/
-// #else /* < 2.6.19 */
-  #define CAN_IRQ_HANDLER_ARGS(irq_number, dev_id) \
+
+typedef irqreturn_t     can_irqreturn_t;
+#define CAN_IRQ_NONE    IRQ_NONE
+#define CAN_IRQ_HANDLED IRQ_HANDLED
+#define CAN_IRQ_RETVAL  IRQ_RETVAL
+
+#define CAN_IRQ_HANDLER_ARGS(irq_number, dev_id) \
                int irq_number, void *dev_id
-// #endif /* < 2.6.19 */
-// #else /*CAN_WITH_RTL*/
-//   typedef int can_irqreturn_t;
-//   #define CAN_IRQ_NONE        0
-//   #define CAN_IRQ_HANDLED     1
-//   #define CAN_IRQ_RETVAL(x)   ((x) != 0)
-/*  #define CAN_IRQ_HANDLER_ARGS(irq_number, dev_id) \
-               int irq_number, void *dev_id, struct pt_regs *regs*/
-// #endif /*CAN_WITH_RTL*/
-
-// #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,33))
-//    #define can_synchronize_irq(irqnum) synchronize_irq()
-// #else /* >=2.5.33 */
-   #define can_synchronize_irq synchronize_irq
-// #endif
-
-// #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,4,0))
-//   #define del_timer_sync del_timer
-// #endif /* <2.4.0 */
-
-// #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,9))
-   typedef unsigned long can_ioptr_t;
-   #define can_ioptr2ulong(ioaddr) ((unsigned long)(ioaddr))
-   #define can_ulong2ioptr(addr)   ((unsigned long)(addr))
-   #define can_inb(ioaddr) inb(ioaddr)
-   #define can_outb(data,ioaddr) outb(data,ioaddr)
-   #define can_inw(ioaddr) inb(ioaddr)
-   #define can_outw(data,ioaddr) outb(data,ioaddr)
-   #define can_inl(ioaddr) inb(ioaddr)
-   #define can_outl(data,ioaddr) outb(data,ioaddr)
-// #else /* >=2.6.9 */
-//    typedef void __iomem * can_ioptr_t;
-//    #define can_ioptr2ulong(ioaddr) ((unsigned long __force)(ioaddr))
-//    #define can_ulong2ioptr(addr)   ((can_ioptr_t)(addr))
-//    #define can_inb(ioaddr) inb(can_ioptr2ulong(ioaddr))
-//    #define can_outb(data,ioaddr) outb(data,can_ioptr2ulong(ioaddr))
-//    #define can_inw(ioaddr) inb(can_ioptr2ulong(ioaddr))
-//    #define can_outw(data,ioaddr) outb(data,can_ioptr2ulong(ioaddr))
-//    #define can_inl(ioaddr) inb(can_ioptr2ulong(ioaddr))
-//    #define can_outl(data,ioaddr) outb(data,can_ioptr2ulong(ioaddr))
-// #endif
+#define can_synchronize_irq(irqnum) do {} while(0)
+
+typedef unsigned long can_ioptr_t;
+#define can_ioptr2ulong(ioaddr) ((unsigned long)(ioaddr))
+#define can_ulong2ioptr(addr)   ((unsigned long)(addr))
+#define can_inb(ioaddr) inb(ioaddr)
+#define can_outb(data,ioaddr) outb(data,ioaddr)
+#define can_inw(ioaddr) inb(ioaddr)
+#define can_outw(data,ioaddr) outb(data,ioaddr)
+#define can_inl(ioaddr) inb(ioaddr)
+#define can_outl(data,ioaddr) outb(data,ioaddr)
 
 #define can_readb  readb
 #define can_writeb writeb
@@ -208,13 +99,12 @@ typedef struct { volatile int counter; } atomic_t;
   #define CAN_HAVE_ARCH_CMPXCHG
 #endif
 
-// #ifndef CAN_WITH_RTL
-/* Standard LINUX kernel */
-
 #define can_spinlock_t             long
 #define can_spin_irqflags_t        unsigned long
-#define can_spin_lock(lock)        cli()
-#define can_spin_unlock(lock)      sti()
+/* Only one CPU is supposed on sys-less embedded target => no need for spinloks */
+#define can_spin_lock(lock)        do { } while (0)
+#define can_spin_unlock(lock)      do { } while (0)
+/* Only one CPU is supposed on sys-less embedded target => no need for spinloks */
 #define can_spin_lock_irqsave(lock,flags)      save_and_cli(flags)
 #define can_spin_unlock_irqrestore(lock,flags) restore_flags(flags)
 #define can_spin_lock_init         can_splck_init
@@ -227,18 +117,16 @@ void can_splck_init(can_spinlock_t *x)
        *x=0;
 }
 
-// #if !defined(CONFIG_PREEMPT_RT) && ( defined(CONFIG_PREEMPT) || (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)) )
-// #define can_preempt_disable        preempt_disable
-// #define can_preempt_enable         preempt_enable
-// #else /*CONFIG_PREEMPT*/
 #define can_preempt_disable()      do { } while (0)
 #define can_preempt_enable()       do { } while (0)
-// #endif /*CONFIG_PREEMPT*/
 
-// #define can_enable_irq             sti()
-// #define can_disable_irq            cli()
-#define can_enable_irq(var)           (var=1)
-#define can_disable_irq(var)          (var=0)
+#if 1
+#define can_enable_irq(var)        do { } while (0)
+#define can_disable_irq(var)       do { } while (0)
+#else
+#define can_enable_irq             enable_irq
+#define can_disable_irq            disable_irq
+#endif
 
 #define can_printk                 printf
 #define KERN_CRIT
@@ -254,6 +142,7 @@ void can_splck_init(can_spinlock_t *x)
 #define test_and_change_bit ____atomic_test_and_change_bit
 #define raw_local_irq_save(flags) save_and_cli(flags);
 #define raw_local_irq_restore(flags) restore_flags(flags);
+
 /*
  * These functions are the basis of our bit ops.
  *
@@ -494,44 +383,4 @@ static inline void udelay(long time)
        while(ticks>0);
 }
 
-// #else /*CAN_WITH_RTL*/
-//
-// #define can_spinlock_t             long
-// #define can_spin_irqflags_t        unsigned long
-// #define can_spin_lock              save_and_cli
-// #define can_spin_unlock            restore_flags
-// #define can_spin_lock_irqsave      save_and_cli
-// #define can_spin_unlock_irqrestore restore_flags
-// #define can_spin_lock_init         can_splck_init
-//
-// #define CAN_DEFINE_SPINLOCK(x)     can_spinlock_t x = 0
-//
-// #define can_preempt_disable()      do { } while (0)
-// #define can_preempt_enable()       do { } while (0)
-//
-// #define can_enable_irq             sti
-// #define can_disable_irq            cli
-//
-// #define can_printk                 rtl_printf
-//
-// /*
-//  * terrible hack to test rtl_file private_data concept, ugh !!!
-//  * this would result in crash on architectures,  where
-//  * sizeof(int) < sizeof(void *)
-//  */
-// #define can_set_rtl_file_private_data(fptr, p) do{ fptr->f_minor=(long)(p); } while(0)
-// #define can_get_rtl_file_private_data(fptr) ((void*)((fptr)->f_minor))
-//
-// extern can_spinlock_t can_irq_manipulation_lock;
-//
-// /* CAN message timestamp source, it is called from interrupt context */
-/*#define can_gettimeofday(ptr) do {\
-         struct timespec temp_timespec;\
-         clock_gettime(CLOCK_REALTIME,&temp_timespec);\
-         ptr->tv_usec=temp_timespec.tv_nsec/1000;\
-         ptr->tv_sec=temp_timespec.tv_sec;\
-       } while(0)*/
-//
-// #endif /*CAN_WITH_RTL*/
-
 #endif /*_CAN_SYSDEP_H*/
index 779f68c52c3fc23026cba058d1919084f3d3c63e..7cc22aee9ff29b12c0b84ab289aa11de7baf5d22 100644 (file)
@@ -1,10 +1,35 @@
-/* canmsg.h - common kernel-space and user-space CAN message structure
- * Linux CAN-bus device driver.
- * Written 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: canmsg.h - common kernel-space and user-space CAN message struct */
+/*                                                                        */
+/* 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.  */
+/**************************************************************************/
 
 #ifndef _CANMSG_T_H
 #define _CANMSG_T_H
 extern "C" {
 #endif
 
-/* 
+/*
  * CAN_MSG_VERSION_2 enables new canmsg_t layout compatible with
  * can4linux project from http://www.port.de/
- * 
+ *
  */
 #define CAN_MSG_VERSION_2
 
@@ -45,7 +70,7 @@ typedef unsigned long canmsg_id_t;
  * struct canmsg_t - structure representing CAN message
  * @flags:  message flags
  *      %MSG_RTR .. message is Remote Transmission Request,
- *     %MSG_EXT .. message with extended ID, 
+ *     %MSG_EXT .. message with extended ID,
  *      %MSG_OVR .. indication of queue overflow condition,
  *     %MSG_LOCAL .. message originates from this node.
  * @cob:    communication object number (not used)
@@ -86,7 +111,7 @@ typedef struct canmsg_t canmsg_t;
  * struct canfilt_t - structure for acceptance filter setup
  * @flags:  message flags
  *      %MSG_RTR .. message is Remote Transmission Request,
- *     %MSG_EXT .. message with extended ID, 
+ *     %MSG_EXT .. message with extended ID,
  *      %MSG_OVR .. indication of queue overflow condition,
  *     %MSG_LOCAL .. message originates from this node.
  *     there are corresponding mask bits
index 8ba9ba465179e836ea45cd7dc1b4a5435bd33d39..1f0a45cc77d8382b1e7592a4cf4e4fd9f584faf8 100644 (file)
@@ -1,11 +1,36 @@
-/* constants.h
- * Header file for the Linux CAN-bus driver.
- * Written by Arnaud Westenberg email:arnaud@wanadoo.nl
- * Rewritten for 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: constants.h - driver build time constant parameters              */
+/*                                                                        */
+/* 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                               */
+/* Based on CAN driver code by Arnaud Westenberg <arnaud@wanadoo.nl>      */
+/*                                                                        */
+/* 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.  */
+/**************************************************************************/
 
 #ifndef __CONSTANTS_H__
 #define __CONSTANTS_H__
@@ -19,7 +44,7 @@
 /* Version of the driver */
 #define CAN_DRV_VER_MAJOR 0
 #define CAN_DRV_VER_MINOR 3
-#define CAN_DRV_VER_PATCH 3
+#define CAN_DRV_VER_PATCH 4
 #define CAN_DRV_VER ((CAN_DRV_VER_MAJOR<<16) | (CAN_DRV_VER_MINOR<<8) | CAN_DRV_VER_PATCH)
 
 /* Default driver major number, see /usr/src/linux/Documentation/devices.txt */
 #define CHIP_IRQ_VME     (1<<5)  /* interrupt is VME bus and requires VME bridge */
 #define CHIP_IRQ_CUSTOM  (1<<6)  /* custom interrupt provided by board or chip code */
 #define CHIP_IRQ_FAST    (1<<7)  /* interrupt handler only schedules postponed processing */
+#define CHIP_KEEP_DATA   (1<<8)  /* let the hotplug device free its chip_data structure itself */
 
 #define CHIP_MAX_IRQLOOP 1000
 
index 837ffb6b11724964f5014191b430d827e58f93d8..a70771baf69019e1d1856ae7dd90a21bcda387cf 100644 (file)
@@ -1,10 +1,36 @@
-/* devcommon.h - common device code
- * 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: devcommon.h - common device code                                 */
+/*                                                                        */
+/* 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                               */
+/* Based on CAN driver code by Arnaud Westenberg <arnaud@wanadoo.nl>      */
+/*                                                                        */
+/* 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.  */
+/**************************************************************************/
 
 #include "./canmsg.h"
 #include "./can_sysdep.h"
index 87df0465c16f465698cf08238ab5dd909d9b6262..290b5115b04646dd8ba8d348d39dbac80d6ad277 100644 (file)
@@ -1,11 +1,36 @@
-/* finish.h
- * Header file for the Linux CAN-bus driver.
- * Written by Arnaud Westenberg email:arnaud@wanadoo.nl
- * Rewritten for 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: finish.h - finalization of the driver operations                 */
+/*                                                                        */
+/* 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                               */
+/* Based on CAN driver code by Arnaud Westenberg <arnaud@wanadoo.nl>      */
+/*                                                                        */
+/* 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.  */
+/**************************************************************************/
 
 void msgobj_done(struct msgobj_t *obj);
 void canchip_done(struct canchip_t *chip);
index 17473968f0771acdd603bd5fb9637c241f9fb8a0..6ebf94dc15e0e90d4a153378ece4e471f8d4f0d5 100644 (file)
@@ -1,22 +1,47 @@
-/* i82527.h
- * Header file for the Linux CAN-bus driver.
- * Written by Arnaud Westenberg email:arnaud@wanadoo.nl
- * Rewritten for 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: i82527.h - Intel i82527 CAN controller support                   */
+/*                                                                        */
+/* 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                               */
+/* Based on CAN driver code by Arnaud Westenberg <arnaud@wanadoo.nl>      */
+/*                                                                        */
+/* 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.  */
+/**************************************************************************/
 
 int i82527_enable_configuration(struct canchip_t *chip);
 int i82527_disable_configuration(struct canchip_t *chip);
 int i82527_chip_config(struct canchip_t *chip);
-int i82527_baud_rate(struct canchip_t *chip, int rate, int clock, int sjw, 
+int i82527_baud_rate(struct canchip_t *chip, int rate, int clock, int sjw,
                                                int sampl_pt, int flags);
-int i82527_standard_mask(struct canchip_t *chip, unsigned short code, 
+int i82527_standard_mask(struct canchip_t *chip, unsigned short code,
                                                        unsigned short mask);
-int i82527_extended_mask(struct canchip_t *chip, unsigned long code, 
+int i82527_extended_mask(struct canchip_t *chip, unsigned long code,
                                                        unsigned long mask);
-int i82527_message15_mask(struct canchip_t *chip, unsigned long code, 
+int i82527_message15_mask(struct canchip_t *chip, unsigned long code,
                                                        unsigned long mask);
 int i82527_clear_objects(struct canchip_t *chip);
 int i82527_config_irqs(struct canchip_t *chip, short irqs);
@@ -26,7 +51,7 @@ int i82527_pre_write_config(struct canchip_t *chip, struct msgobj_t *obj,
 int i82527_send_msg(struct canchip_t *chip, struct msgobj_t *obj,
                                                        struct canmsg_t *msg);
 int i82527_remote_request(struct canchip_t *chip, struct msgobj_t *obj);
-int i82527_set_btregs(struct canchip_t *chip, unsigned short btr0, 
+int i82527_set_btregs(struct canchip_t *chip, unsigned short btr0,
                                                        unsigned short btr1);
 int i82527_start_chip(struct canchip_t *chip);
 int i82527_stop_chip(struct canchip_t *chip);
index 23c8ab3135c7835c2f757dde40b8f570e5c926e4..b7d2c59ba29444c7cb414d56039e9c3fcc2924a5 100644 (file)
@@ -1,21 +1,44 @@
-/* main.h
- * Header file for the Linux CAN-bus driver.
- * Written by Arnaud Westenberg email:arnaud@wanadoo.nl
- * Rewritten for 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
- */
-
-#ifndef MAIN_H
-#define MAIN_H
-
-#include <malloc.h>
+/**************************************************************************/
+/* File: main.h - the CAN driver basic data structures and functions      */
+/*                                                                        */
+/* 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                               */
+/* Based on CAN driver code by Arnaud Westenberg <arnaud@wanadoo.nl>      */
+/*                                                                        */
+/* 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.  */
+/**************************************************************************/
+
+#ifndef _CAN_MAIN_H
+#define _CAN_MAIN_H
 
 #include "./can.h"
 #include "./constants.h"
 #include "./ul_listbase.h"
-#include "./can_sysless.h"
+#include "./can_sysdep.h"
 #include "./can_queue.h"
 #include "./errno.h"
 
@@ -82,7 +105,8 @@ struct candevice_t {
        int candev_idx;                 /* board index in canhardware_t.candevice[] */
        unsigned long io_addr;          /* IO/physical MEM address */
        unsigned long res_addr;         /* optional reset register port */
-       unsigned long dev_base_addr;    /* CPU translated IO/virtual MEM address */
+       can_ioptr_t dev_base_addr;      /* CPU translated IO/virtual MEM address */
+       can_ioptr_t aux_base_addr;      /* CPU translated IO/virtual MEM address */
        unsigned int flags;
        int nr_all_chips;
        int nr_82527_chips;
@@ -161,13 +185,13 @@ struct canchip_t {
        char *chip_type;
        int chip_idx;   /* chip index in candevice_t.chip[] */
        int chip_irq;
-       unsigned long chip_base_addr;
+       can_ioptr_t chip_base_addr;
        unsigned int flags;
        long clock; /* Chip clock in Hz */
        long baudrate;
 
-       void (*write_register)(unsigned data,unsigned long address);
-       unsigned (*read_register)(unsigned long address);
+       void (*write_register)(unsigned data, can_ioptr_t address);
+       unsigned (*read_register)(can_ioptr_t address);
 
        void *chip_data;
 
@@ -221,7 +245,7 @@ struct canchip_t {
  *              that reuse same object for TX
  */
 struct msgobj_t {
-       unsigned long obj_base_addr;
+       can_ioptr_t obj_base_addr;
        unsigned int minor;     /* associated device minor number  */
        unsigned int object;    /* object number in canchip_t +1 for debug printk */
        unsigned long obj_flags;
@@ -302,11 +326,12 @@ struct hwspecops_t {
        int (*release_io)(struct candevice_t *candev);
        int (*reset)(struct candevice_t *candev);
        int (*init_hw_data)(struct candevice_t *candev);
+       void (*done_hw_data)(struct candevice_t *candev);
        int (*init_chip_data)(struct candevice_t *candev, int chipnr);
        int (*init_obj_data)(struct canchip_t *chip, int objnr);
        int (*program_irq)(struct candevice_t *candev);
-       void (*write_register)(unsigned data,unsigned long address);
-       unsigned (*read_register)(unsigned long address);
+       void (*write_register)(unsigned data, can_ioptr_t address);
+       unsigned (*read_register)(can_ioptr_t address);
 };
 
 /**
@@ -386,57 +411,57 @@ extern int major;
 extern int minor[MAX_TOT_CHIPS];
 extern int extended;
 extern int baudrate[MAX_TOT_CHIPS];
-extern char *hw[MAX_HW_CARDS];
 extern int irq[MAX_IRQ];
+extern char *hw[MAX_HW_CARDS];
 extern unsigned long io[MAX_HW_CARDS];
+extern long clockfreq[MAX_HW_CARDS];
 extern int processlocal;
 
 extern struct canhardware_t *hardware_p;
-//extern struct canchip_t *chips_p[MAX_TOT_CHIPS];
-struct canchip_t *chips_p[MAX_TOT_CHIPS];
+extern struct canchip_t *chips_p[MAX_TOT_CHIPS];
 extern struct msgobj_t *objects_p[MAX_TOT_MSGOBJS];
 
 extern struct mem_addr *mem_head;
 
 
 #if defined(CONFIG_OC_LINCAN_PORTIO_ONLY)
-extern inline void can_write_reg(const struct canchip_t *chip, unsigned char data, unsigned address)
+extern inline void can_write_reg(const struct canchip_t *chip, unsigned char data, unsigned reg_offs)
 {
-       outb(data, chip->chip_base_addr+address);
+       can_outb(data, chip->chip_base_addr+reg_offs);
 }
-extern inline unsigned can_read_reg(const struct canchip_t *chip, unsigned address)
+extern inline unsigned can_read_reg(const struct canchip_t *chip, unsigned reg_offs)
 {
-       return inb(chip->chip_base_addr+address);
+       return can_inb(chip->chip_base_addr+reg_offs);
 }
 extern inline void canobj_write_reg(const struct canchip_t *chip, const struct msgobj_t *obj,
-                               unsigned char data, unsigned address)
+                               unsigned char data, unsigned reg_offs)
 {
-       outb(data, obj->obj_base_addr+address);
+       can_outb(data, obj->obj_base_addr+reg_offs);
 }
 extern inline unsigned canobj_read_reg(const struct canchip_t *chip, const struct msgobj_t *obj,
-                               unsigned address)
+                               unsigned reg_offs)
 {
-       return inb(obj->obj_base_addr+address);
+       return can_inb(obj->obj_base_addr+reg_offs);
 }
 
 #elif defined(CONFIG_OC_LINCAN_MEMIO_ONLY)
-extern inline void can_write_reg(const struct canchip_t *chip, unsigned char data, unsigned address)
+extern inline void can_write_reg(const struct canchip_t *chip, unsigned char data, unsigned reg_offs)
 {
-       writeb(data, chip->chip_base_addr+address);
+       can_writeb(data, chip->chip_base_addr+reg_offs);
 }
-extern inline unsigned can_read_reg(const struct canchip_t *chip, unsigned address)
+extern inline unsigned can_read_reg(const struct canchip_t *chip, unsigned reg_offs)
 {
-       return readb(chip->chip_base_addr+address);
+       return can_readb(chip->chip_base_addr+reg_offs);
 }
 extern inline void canobj_write_reg(const struct canchip_t *chip, const struct msgobj_t *obj,
-                               unsigned char data, unsigned address)
+                               unsigned char data, unsigned reg_offs)
 {
-       writeb(data, obj->obj_base_addr+address);
+       can_writeb(data, obj->obj_base_addr+reg_offs);
 }
 extern inline unsigned canobj_read_reg(const struct canchip_t *chip, const struct msgobj_t *obj,
-                               unsigned address)
+                               unsigned reg_offs)
 {
-       return readb(obj->obj_base_addr+address);
+       return can_readb(obj->obj_base_addr+reg_offs);
 }
 
 #else /*CONFIG_OC_LINCAN_DYNAMICIO*/
@@ -444,47 +469,53 @@ extern inline unsigned canobj_read_reg(const struct canchip_t *chip, const struc
 #define CONFIG_OC_LINCAN_DYNAMICIO
 #endif
 
-/* Inline function to write to the hardware registers. The argument address is
- * relative to the memory map of the chip and not the absolute memory address.
+/* Inline function to write to the hardware registers. The argument reg_offs is
+ * relative to the memory map of the chip and not the absolute memory reg_offs.
  */
-extern inline void can_write_reg(const struct canchip_t *chip, unsigned char data, unsigned address)
+extern inline void can_write_reg(const struct canchip_t *chip, unsigned char data, unsigned reg_offs)
 {
-       unsigned long address_to_write;
-       address_to_write = chip->chip_base_addr+address;
+       can_ioptr_t address_to_write;
+       address_to_write = chip->chip_base_addr+reg_offs;
        chip->write_register(data, address_to_write);
 }
 
-extern inline unsigned can_read_reg(const struct canchip_t *chip, unsigned address)
+extern inline unsigned can_read_reg(const struct canchip_t *chip, unsigned reg_offs)
 {
-       unsigned long address_to_read;
-       address_to_read = chip->chip_base_addr+address;
+       can_ioptr_t address_to_read;
+       address_to_read = chip->chip_base_addr+reg_offs;
        return chip->read_register(address_to_read);
 }
 
 extern inline void canobj_write_reg(const struct canchip_t *chip, const struct msgobj_t *obj,
-                               unsigned char data, unsigned address)
+                               unsigned char data, unsigned reg_offs)
 {
-       unsigned long address_to_write;
-       address_to_write = obj->obj_base_addr+address;
+       can_ioptr_t address_to_write;
+       address_to_write = obj->obj_base_addr+reg_offs;
        chip->write_register(data, address_to_write);
 }
 
 extern inline unsigned canobj_read_reg(const struct canchip_t *chip, const struct msgobj_t *obj,
-                               unsigned address)
+                               unsigned reg_offs)
 {
-       unsigned long address_to_read;
-       address_to_read = obj->obj_base_addr+address;
+       can_ioptr_t address_to_read;
+       address_to_read = obj->obj_base_addr+reg_offs;
        return chip->read_register(address_to_read);
 }
 
 #endif /*CONFIG_OC_LINCAN_DYNAMICIO*/
 
-int can_base_addr_fixup(struct candevice_t *candev, unsigned long new_base);
+int can_base_addr_fixup(struct candevice_t *candev, can_ioptr_t new_base);
 int can_request_io_region(unsigned long start, unsigned long n, const char *name);
 void can_release_io_region(unsigned long start, unsigned long n);
 int can_request_mem_region(unsigned long start, unsigned long n, const char *name);
 void can_release_mem_region(unsigned long start, unsigned long n);
 
+#ifdef CAN_ENABLE_PCI_SUPPORT
+struct pci_dev *can_pci_get_next_untaken_device(unsigned int vendor, unsigned int device);
+struct pci_dev *can_pci_get_next_untaken_subsyst(unsigned int vendor, unsigned int device,
+                       unsigned int ss_vendor, unsigned int ss_device);
+#endif /*CAN_ENABLE_PCI_SUPPORT*/
+
 struct boardtype_t {
        const char *boardtype;
        int (*board_register)(struct hwspecops_t *hwspecops);
@@ -519,5 +550,9 @@ void can_filltimestamp(canmsg_tstamp_t *ptimestamp)
 extern int can_rtl_priority;
 #endif /*CAN_WITH_RTL*/
 
-#endif /* MAIN_H */
+extern struct candevice_t* register_hotplug_dev(const char *hwname,int (*chipdataregfnc)(struct canchip_t *chip,void *data),void *devdata);
+extern void deregister_hotplug_dev(struct candevice_t *dev);
+extern void cleanup_hotplug_dev(struct candevice_t *dev);
+
+#endif /* _CAN_MAIN_H */
 
index 66919313dd11d5c508882e15c82928e496b10255..c33e1266eb4ffe637d2c2e3871ae944553d772d0 100644 (file)
@@ -1,10 +1,35 @@
-/* mod_parms.h
- * Header file for the Linux CAN-bus driver.
- * Written by Arnaud Westenberg email:arnaud@wanadoo.nl
- * Rewritten for 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: modparms.h - driver module parameters parsing                    */
+/*                                                                        */
+/* 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                               */
+/* Based on CAN driver code by Arnaud Westenberg <arnaud@wanadoo.nl>      */
+/*                                                                        */
+/* 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.  */
+/**************************************************************************/
 
 int parse_mod_parms(void);
index d35a8b1e51192a7d0fd270749478a7479a79cfb8..300c486fdef732c1f2ca2a461a7c0bd5fc274d21 100644 (file)
@@ -1,13 +1,39 @@
-/* setup.h
- * Header file for the Linux CAN-bus driver.
- * Written by Arnaud Westenberg email:arnaud@wanadoo.nl
- * Rewritten for 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: setup.h - CAN driver and chips setup code                        */
+/*                                                                        */
+/* 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                               */
+/* Based on CAN driver code by Arnaud Westenberg <arnaud@wanadoo.nl>      */
+/*                                                                        */
+/* 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.  */
+/**************************************************************************/
 
 int init_hw_struct(void);
+int init_new_hw_struct(int devnr);
 int list_hw(void);
 void *can_checked_malloc(size_t size);
 int can_checked_free(void *address_p);
index fe81a9c4522a2c7565417cb390be5513d10420ba..67667f680047815d274a3fbd9396ae5b5fa59f5c 100644 (file)
@@ -1,16 +1,40 @@
-/* sja1000p.h
- * Header file for the Linux CAN-bus driver.
- * Written by Arnaud Westenberg email:arnaud@wanadoo.nl
- * Added by T.Motylewski@bfad.de
- * See app. note an97076.pdf from Philips Semiconductors
- * and SJA1000 data sheet
- * PELICAN mode
- * This software is released under the GPL-License.
- * Version lincan-0.3  17 Jun 2004
- */
-
-#ifndef SJA1000P_H
-#define SJA1000P_H
+/**************************************************************************/
+/* File: sja1000p.h - Philips/NXP SJA1000 chip PeliCanCAN mode support    */
+/*                                                                        */
+/* 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>             */
+/* Copyright (C) 2004-2005 Tomasz Motylewski (BFAD GmbH)                  */
+/* Funded by OCERA and FRESCOR IST projects                               */
+/* Based on CAN driver code by Arnaud Westenberg <arnaud@wanadoo.nl>      */
+/*                                                                        */
+/* 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.  */
+/**************************************************************************/
+
+#ifndef _CAN_SJA1000P_H
+#define _CAN_SJA1000P_H
 
 int sja1000p_chip_config(struct canchip_t *chip);
 int sja1000p_extended_mask(struct canchip_t *chip, unsigned long code, unsigned long mask);
@@ -202,4 +226,4 @@ enum sja1000_CDR {
 /** flags for sja1000_baud_rate */
 #define BTR1_SAM (1<<1)
 
-#endif /* SJA1000P_H */
+#endif /* _CAN_SJA1000P_H */
index f11f90db7b8e239dc293d19aa922aa49761014a4..c7c7f33c84bcd1c06c9de6ce4cbfbfbaff1c6b0b 100644 (file)
@@ -1,10 +1,35 @@
-/* can_quesysless.c - CAN message queues functions for the Linux kernel
- * 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_quesysless.c - CAN queue functions for embedded target       */
+/*                                                                        */
+/* 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.  */
+/**************************************************************************/
 
 #include "./can/can.h"
 #include "./can/can_sysdep.h"
index 9815fd01d248cda0342b37a5e13dbc3d53ddfc3d..6505e1db9ece13f949a1914ad6cd80308ed6c577 100644 (file)
@@ -1,10 +1,35 @@
-/* can_queue.c - CAN message queues
- * 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_queue.c - CAN message queues                                 */
+/*                                                                        */
+/* 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.  */
+/**************************************************************************/
 
 #include "./can/can.h"
 #include "./can/can_sysdep.h"
@@ -20,7 +45,7 @@ extern int processlocal;
 
 atomic_t edge_num_cnt;
 
-// #define CAN_DEBUG
+//#define CAN_DEBUG
 #undef CAN_DEBUG
 
 #ifdef CAN_DEBUG
@@ -561,8 +586,8 @@ int canqueue_disconnect_edge(struct canque_edge_t *qedge)
        } else {
                DEBUGQUE("canqueue_disconnect_edge called with not fully connected edge");
                if(inends) can_spin_lock_irqsave(&inends->ends_lock,flags);
-               if(outends) can_spin_lock(&outends->ends_lock);
-               flags=0;
+               else if(outends) can_spin_lock_irqsave(&outends->ends_lock,flags);
+               else flags=0;
        }
 
        can_spin_lock(&qedge->fifo.fifo_lock);
@@ -584,8 +609,8 @@ int canqueue_disconnect_edge(struct canque_edge_t *qedge)
        if(inends && outends) {
                canque_edge_unlock_both_ends(inends, outends, flags);
        } else {
-               if(outends) can_spin_unlock(&outends->ends_lock);
                if(inends) can_spin_unlock_irqrestore(&inends->ends_lock,flags);
+               else if(outends) can_spin_unlock_irqrestore(&outends->ends_lock,flags);
        }
 
        DEBUGQUE("canqueue_disconnect_edge %d returned %d\n",qedge->edge_num,ret);
index eada97bcb13005f6b0d4b281b594e5fe8d854ca0..0b0c576e5a9a51f6c1633e0e1d4085570cf4d0a4 100644 (file)
@@ -1,10 +1,35 @@
-/* devcommon.c - common device code
- * 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: devcommon.c - common device code                                 */
+/*                                                                        */
+/* 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.  */
+/**************************************************************************/
 
 #include "./can/can.h"
 #include "./can/can_sysdep.h"
@@ -59,7 +84,10 @@ void canqueue_notify_chip(struct canque_ends_t *qends, struct canque_edge_t *qed
                case CANQUEUE_NOTIFY_PROC:
                    #ifndef CAN_WITH_RTL
                        /*wake_up(&qends->endinfo.chipinfo.daemonq);*/
-                       chip->chipspecops->wakeup_tx(chip, obj);
+                       if(canque_fifo_test_fl(&qedge->fifo, READY)){
+                               if ((chip) && (chip->flags & CHIP_ATTACHED))
+                                       chip->chipspecops->wakeup_tx(chip, obj);
+                       }
                    #else /*CAN_WITH_RTL*/
                        can_msgobj_set_fl(obj,TX_REQUEST);
                        canqueue_wake_chip_worker(qends, chip, obj);
index fad2c0594bc0ce75b6161d7c468175378e5928ec..efecef64f15ee7bf69839a3583437812e6852094 100644 (file)
@@ -1,14 +1,39 @@
-/* finish.c - finalization of the driver operation
- * Linux CAN-bus device driver.
- * Written by Arnaud Westenberg email:arnaud@wanadoo.nl
- * Rewritten for 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: finish.c - finalization of the driver operations                 */
+/*                                                                        */
+/* 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                               */
+/* Based on CAN driver code by Arnaud Westenberg <arnaud@wanadoo.nl>      */
+/*                                                                        */
+/* 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.  */
+/**************************************************************************/
 
 #include "./can/can.h"
-#include "./can/can_sysless.h"
+#include "./can/can_sysdep.h"
 #include "./can/main.h"
 #include "./can/devcommon.h"
 #include "./can/finish.h"
@@ -79,7 +104,7 @@ void canchip_done(struct canchip_t *chip)
 // Not using interrupts
 //     can_chip_free_irq(chip);
 
-//     can_synchronize_irq(chip->chip_irq);
+//     can_synchronize_irq(chip->chip_irq);
 
        for(i=0; i<chip->max_objects; i++){
                if((obj=chip->msgobj[i])==NULL)
index e046c9be24265da5847c9a4f7f7beb6371f3df97..22b21bb9aea29aeddd425544a4945bd975c6bce2 100644 (file)
@@ -1,14 +1,39 @@
-/* setup.c
- * Linux CAN-bus device driver.
- * Written by Arnaud Westenberg email:arnaud@wanadoo.nl
- * Rewritten for 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: setup.c - CAN driver and chips setup code                        */
+/*                                                                        */
+/* 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                               */
+/* Based on CAN driver code by Arnaud Westenberg <arnaud@wanadoo.nl>      */
+/*                                                                        */
+/* 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.  */
+/**************************************************************************/
 
 #include "./can/can.h"
-#include "./can/can_sysless.h"
+#include "./can/can_sysdep.h"
 #include "./can/main.h"
 #include "./can/devcommon.h"
 #include "./can/setup.h"
@@ -16,7 +41,7 @@
 
 int init_hwspecops(struct candevice_t *candev, int *irqnum_p);
 int init_device_struct(int card, int *chan_param_idx_p, int *irq_param_idx_p);
-int init_chip_struct(struct candevice_t *candev, int chipnr, int irq, long baudrate);
+int init_chip_struct(struct candevice_t *candev, int chipnr, int irq, long baudrate, long clock);
 int init_obj_struct(struct candevice_t *candev, struct canchip_t *hostchip, int objnr);
 
 /**
@@ -30,9 +55,9 @@ int init_obj_struct(struct candevice_t *candev, struct canchip_t *hostchip, int
  * This function is prepared to simplify board specific xxx_request_io() function
  * for memory mapped devices.
  */
-int can_base_addr_fixup(struct candevice_t *candev, unsigned long new_base)
+int can_base_addr_fixup(struct candevice_t *candev, can_ioptr_t new_base)
 {
-       unsigned long offs;
+       long offs;
        int i, j;
 
        offs=new_base-candev->dev_base_addr;
@@ -270,6 +295,7 @@ int register_chip_struct(struct canchip_t *chip, int minorbase)
  * @chipnr: index of the chip in the corresponding device/board structure
  * @irq: chip IRQ number or (-1) if not appropriate
  * @baudrate: baudrate in the units of 1Bd
+ * @clock: optional chip base clock frequency in 1Hz step
  *
  * Chip structure is allocated and chip specific operations are filled by
  * call to board specific init_chip_data() which calls chip specific
@@ -278,7 +304,7 @@ int register_chip_struct(struct canchip_t *chip, int minorbase)
  *
  * Return Value: returns negative number in the case of fail
  */
-int init_chip_struct(struct candevice_t *candev, int chipnr, int irq, long baudrate)
+int init_chip_struct(struct candevice_t *candev, int chipnr, int irq, long baudrate, long clock)
 {
        struct canchip_t *chip;
        int objnr;
@@ -302,6 +328,7 @@ int init_chip_struct(struct candevice_t *candev, int chipnr, int irq, long baudr
        chip->hostdevice=candev;
        chip->chip_irq=irq;
        chip->baudrate=baudrate;
+       chip->clock=clock;
        chip->flags=0x0;
 
        if(candev->hwspecops->init_chip_data(candev,chipnr)<0)
index 8a527ffe23973e6a30b072211582e07cec0ade5a..bbee1cd19b3f40b17aca43250a6f570824480206 100644 (file)
@@ -1,13 +1,37 @@
-/* sja1000.c
- * Linux CAN-bus device driver.
- * Written by Arnaud Westenberg email:arnaud@wanadoo.nl
- * Changed for PeliCan mode SJA1000 by Tomasz Motylewski (BFAD GmbH)
- * T.Motylewski@bfad.de
- * Rewritten for 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: sja1000p.c - Philips/NXP SJA1000 chip PeliCanCAN mode support    */
+/*                                                                        */
+/* 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>             */
+/* Copyright (C) 2004-2005 Tomasz Motylewski (BFAD GmbH)                  */
+/* Funded by OCERA and FRESCOR IST projects                               */
+/* Based on CAN driver code by Arnaud Westenberg <arnaud@wanadoo.nl>      */
+/*                                                                        */
+/* 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.  */
+/**************************************************************************/
 
 #include "./can/can.h"
 #include "./can/can_sysdep.h"
index 29cd74b957d2746c026e47d71bc4fd0592b6c407..7ab1b95198da7a19bf20d0f96cd965540c2553a9 100644 (file)
@@ -4,7 +4,7 @@
 #include <system_def.h>
 #include <hal_intr.h>
 #include "./can/can.h"
-#include "./can/can_sysless.h"
+#include "./can/can_sysdep.h"
 #include "./can/main.h"
 #include "./can/devcommon.h"
 #include "./usb/usb_vend.h"