]> rtime.felk.cvut.cz Git - lincan.git/blobdiff - lincan/include/main.h
Added support for KVASER PCICAN-S/D/Q cards.
[lincan.git] / lincan / include / main.h
index 3bdc912e4ac0d96886ae5e88e000fd1b87320107..f73e96709b0def219fbc2d59c2e8a11a9749ea01 100644 (file)
@@ -7,41 +7,22 @@
  * Version lincan-0.2  9 Jul 2003
  */
 
-#include <asm/io.h>
-#include <linux/fs.h>
-#include <linux/version.h>
-#include <linux/wait.h>
-#include <linux/interrupt.h>
 #include "./can.h"
 #include "./constants.h"
+#include "./can_sysdep.h"
 #include "./can_queue.h"
 
 #ifdef CAN_DEBUG
-       #define DEBUGMSG(fmt,args...) printk(KERN_ERR "can.o (debug): " fmt,\
+       #define DEBUGMSG(fmt,args...) can_printk(KERN_ERR "can.o (debug): " fmt,\
        ##args)
 #else
        #define DEBUGMSG(fmt,args...)
 #endif
 
-#define CANMSG(fmt,args...) printk(KERN_ERR "can.o: " fmt,##args)
+#define CANMSG(fmt,args...) can_printk(KERN_ERR "can.o: " fmt,##args)
 
-#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,7))
 
-#define MINOR_NR \
-       (MINOR(file->f_dentry->d_inode->i_rdev))
-
-#else /* Linux kernel > 2.5.7 */
-
-#define MINOR_NR \
-       (minor(file->f_dentry->d_inode->i_rdev))
-#endif /* Linux kernel > 2.5.7 */
-
-#if ((LINUX_VERSION_CODE < KERNEL_VERSION(2,5,68)) && !defined(IRQ_RETVAL))
-   typedef void irqreturn_t;
-   #define IRQ_NONE
-   #define IRQ_HANDLED
-   #define IRQ_RETVAL(x)
-#endif /* <=2.5.67 */
+extern can_spinlock_t canuser_manipulation_lock;
 
 /**
  * struct canhardware_t - structure representing pointers to all CAN boards
@@ -53,7 +34,7 @@
 struct canhardware_t {
        int nr_boards;
        struct rtr_id *rtr_queue;
-       spinlock_t rtr_lock;
+       can_spinlock_t rtr_lock;
        struct candevice_t *candevice[MAX_HW_CARDS];
 };
 
@@ -102,6 +83,13 @@ struct candevice_t {
        struct hwspecops_t *hwspecops;
 
        struct canhardware_t *hosthardware_p;
+       
+       union {
+           #ifdef CAN_ENABLE_PCI_SUPPORT
+               struct pci_dev *pcidev;
+           #endif /*CAN_ENABLE_PCI_SUPPORT*/
+       } sysdevptr;
+
 };
 
 /**
@@ -113,6 +101,7 @@ struct candevice_t {
  * @flags: chip flags: %CHIP_CONFIGURED .. chip is configured,
  *     %CHIP_SEGMENTED .. access to the chip is segmented (mainly for i82527 chips)
  * @clock: chip base clock frequency in Hz
+ * @baudrate: selected chip baudrate in Hz
  * @write_register: write chip register function copy -
  * @read_register: read chip register function copy
  * @sja_cdr_reg: SJA specific register -
@@ -153,7 +142,8 @@ struct chip_t {
        int chip_irq;
        unsigned long chip_base_addr;
        unsigned int flags;
-       int clock; /* Chip clock in Hz */
+       long clock; /* Chip clock in Hz */
+       long baudrate;
 
        void (*write_register)(unsigned char data,unsigned long address);
        unsigned (*read_register)(unsigned long address);
@@ -170,7 +160,14 @@ struct chip_t {
 
        struct candevice_t *hostdevice;
        
-       int max_objects;        /* 1 for sja1000, 15 for */
+       int max_objects;        /* 1 for sja1000, 15 for i82527 */
+
+       can_spinlock_t chip_lock;
+
+    #ifdef CAN_WITH_RTL
+       pthread_t worker_thread;
+       unsigned long pend_flags;
+    #endif /*CAN_WITH_RTL*/
 };
 
 /**
@@ -186,6 +183,7 @@ struct chip_t {
  *     canque_test_outslot() call and is freed by canque_free_outslot()
  *     or rescheduled canque_again_outslot()
  * @tx_retry_cnt: transmission attempt counter
+ * @tx_timeout: can be used by chip driver to check for the transmission timeout
  * @rx_msg: temporary storage to hold received messages before
  *     calling to canque_filter_msg2edges()
  * @hostchip: pointer to the &chip_t structure this object belongs to
@@ -197,7 +195,7 @@ struct msgobj_t {
        unsigned long obj_base_addr;
        unsigned int minor;     /* associated device minor number  */
        unsigned int object;    /* object number in chip_t +1 for debug printk */
-       unsigned long flags; 
+       unsigned long obj_flags; 
        int ret;
 
        struct canque_ends_t *qends;
@@ -205,6 +203,7 @@ struct msgobj_t {
        struct canque_edge_t *tx_qedge;
        struct canque_slot_t *tx_slot;
        int tx_retry_cnt;
+       struct timer_list tx_timeout;
        
        struct canmsg_t rx_msg;
 
@@ -218,20 +217,33 @@ struct msgobj_t {
 
 /**
  * struct canuser_t - structure holding CAN user/client state
+ * @flags: used to distinguish Linux/RT-Linux type
  * @peers: for connection into list of object users
  * @qends: pointer to the ends structure corresponding for this user
- * @file: pointer to open device file state structure
  * @msgobj: communication object the user is connected to
  * @rx_edge0: default receive queue for filter IOCTL
+ * @userinfo: stores user context specific information.
+ *     The field @fileinfo.file holds pointer to open device file state structure
+ *     for the Linux user-space client applications
  * @magic: magic number to check consistency when pointer is retrieved
  *     from file private field
  */
 struct canuser_t {
+       unsigned long flags;
        struct list_head peers;
        struct canque_ends_t *qends;
-        struct file *file;      /* back ptr to file */
        struct msgobj_t *msgobj;
        struct canque_edge_t *rx_edge0; /* simplifies IOCTL */
+        union {
+               struct {
+                       struct file *file;  /* back ptr to file */
+               } fileinfo;
+           #ifdef CAN_WITH_RTL
+               struct {
+                       struct rtl_file *file;
+               } rtlinfo;
+           #endif /*CAN_WITH_RTL*/
+       } userinfo;
        int magic;
 };
 
@@ -314,12 +326,13 @@ struct chipspecops_t {
                                                        unsigned short btr1);
        int (*start_chip)(struct chip_t *chip);
        int (*stop_chip)(struct chip_t *chip);
-       irqreturn_t (*irq_handler)(int irq, void *dev_id, struct pt_regs *regs);
+       can_irqreturn_t (*irq_handler)(int irq, void *dev_id, struct pt_regs *regs);
 };
 
 struct mem_addr {
        void *address;
        struct mem_addr *next;
+       size_t size;
 };
 
 /* Structure for the RTR queue */
@@ -333,7 +346,7 @@ struct rtr_id {
 extern int major;
 extern int minor[MAX_TOT_CHIPS];
 extern int extended;
-extern int baudrate;
+extern int baudrate[MAX_TOT_CHIPS];
 extern char *hw[MAX_HW_CARDS];
 extern int irq[MAX_IRQ];
 extern unsigned long io[MAX_HW_CARDS];