-/* 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
#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
* @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
* @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).
*/
/**
- * 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.
* @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.
*/
* 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
* @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
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);
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);
can_spin_lock_irqsave(&outends->ends_lock, flags);
if(outends!=inends) can_spin_lock(&inends->ends_lock);
}
- return flags;
+ return flags;
}
static inline
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 :-) */
}
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
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:
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:
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:
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:
-/* 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"
-/* 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>
(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
#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
*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
#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.
*
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*/
-/* 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
* 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)
* 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
-/* 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__
/* 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
-/* 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"
-/* 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);
-/* 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);
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);
-/* 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"
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;
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;
* 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;
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);
};
/**
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*/
#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);
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 */
-/* 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);
-/* 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);
-/* 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);
/** flags for sja1000_baud_rate */
#define BTR1_SAM (1<<1)
-#endif /* SJA1000P_H */
+#endif /* _CAN_SJA1000P_H */
-/* 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"
-/* 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"
atomic_t edge_num_cnt;
-// #define CAN_DEBUG
+//#define CAN_DEBUG
#undef CAN_DEBUG
#ifdef CAN_DEBUG
} 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);
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);
-/* 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"
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);
-/* 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"
// 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)
-/* 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"
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);
/**
* 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;
* @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
*
* 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;
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)
-/* 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"
#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"