]> rtime.felk.cvut.cz Git - lincan.git/blobdiff - lincan/include/main.h
Added support for Unicontrols PCAN cards series and baudrate setting.
[lincan.git] / lincan / include / main.h
index 2fa81ced2d4dc640e6e9eaa363ad73dfc111fd5a..78eace8ee71d4f02bfa2b22472025e72f5867d40 100644 (file)
@@ -11,6 +11,7 @@
 #include "./constants.h"
 #include "./can_sysdep.h"
 #include "./can_queue.h"
+#include "lincan_config.h"
 
 #ifdef CAN_DEBUG
        #define DEBUGMSG(fmt,args...) can_printk(KERN_ERR "can.o (debug): " fmt,\
@@ -104,8 +105,9 @@ struct candevice_t {
  *     %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 -
+ * @write_register: write chip register function copy
  * @read_register: read chip register function copy
+ * @chip_data: pointer for optional chip specific data extension
  * @sja_cdr_reg: SJA specific register -
  *     holds hardware specific options for the Clock Divider
  *     register. Options defined in the sja1000.h file:
@@ -158,7 +160,9 @@ struct chip_t {
 
        void (*write_register)(unsigned char data,unsigned long address);
        unsigned (*read_register)(unsigned long address);
-
+       
+       void *chip_data;
+       
        unsigned short sja_cdr_reg; /* sja1000 only! */
        unsigned short sja_ocr_reg; /* sja1000 only! */
        unsigned short int_cpu_reg; /* intel 82527 only! */
@@ -308,6 +312,7 @@ struct hwspecops_t {
  * @remote_request: configures message object and asks for RTR message
  * @check_tx_stat: checks state of transmission engine
  * @wakeup_tx: wakeup TX processing
+ * @filtch_rq: optional routine for propagation of outgoing edges filters to HW
  * @enable_configuration: enable chip configuration mode
  * @disable_configuration: disable chip configuration mode
  * @set_btregs: configures bitrate registers
@@ -335,6 +340,7 @@ struct chipspecops_t {
        int (*remote_request)(struct chip_t *chip, struct msgobj_t *obj);
        int (*check_tx_stat)(struct chip_t *chip);
        int (*wakeup_tx)(struct chip_t *chip, struct msgobj_t *obj);
+       int (*filtch_rq)(struct chip_t *chip, struct msgobj_t *obj);
        int (*enable_configuration)(struct chip_t *chip);
        int (*disable_configuration)(struct chip_t *chip);
        int (*set_btregs)(struct chip_t *chip, unsigned short btr0, 
@@ -373,6 +379,52 @@ 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 chip_t *chip, unsigned char data, unsigned address)
+{
+       outb(data, chip->chip_base_addr+address);
+}
+extern inline unsigned can_read_reg(const struct chip_t *chip, unsigned address)
+{
+       return inb(chip->chip_base_addr+address);
+}
+extern inline void canobj_write_reg(const struct chip_t *chip, const struct msgobj_t *obj,
+                               unsigned char data, unsigned address)
+{
+       outb(data, obj->obj_base_addr+address);
+}
+extern inline unsigned canobj_read_reg(const struct chip_t *chip, const struct msgobj_t *obj,
+                               unsigned address)
+{
+       return inb(obj->obj_base_addr+address);
+}
+
+#elif defined(CONFIG_OC_LINCAN_MEMIO_ONLY)
+extern inline void can_write_reg(const struct chip_t *chip, unsigned char data, unsigned address)
+{
+       writeb(data, chip->chip_base_addr+address);
+}
+extern inline unsigned can_read_reg(const struct chip_t *chip, unsigned address)
+{
+       return readb(chip->chip_base_addr+address);
+}
+extern inline void canobj_write_reg(const struct chip_t *chip, const struct msgobj_t *obj,
+                               unsigned char data, unsigned address)
+{
+       writeb(data, obj->obj_base_addr+address);
+}
+extern inline unsigned canobj_read_reg(const struct chip_t *chip, const struct msgobj_t *obj,
+                               unsigned address)
+{
+       return readb(obj->obj_base_addr+address);
+}
+
+#else /*CONFIG_OC_LINCAN_DYNAMICIO*/
+#ifndef 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.
  */
@@ -406,6 +458,8 @@ extern inline unsigned canobj_read_reg(const struct chip_t *chip, const struct m
        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_request_io_region(unsigned long start, unsigned long n, const char *name);
 void can_release_io_region(unsigned long start, unsigned long n);