]> rtime.felk.cvut.cz Git - lincan.git/commitdiff
Merge: LinCAN driver updated to work on Real-Time Preemption enabled kernel.
authorppisa <pisa@cmp.felk.cvut.cz>
Sat, 5 Nov 2005 23:20:00 +0000 (00:20 +0100)
committerppisa <pisa@cmp.felk.cvut.cz>
Sat, 5 Nov 2005 23:20:00 +0000 (00:20 +0100)
Merge commit 'remotes/sf-ocera-lincan/master'

lincan/include/can_sysdep.h
lincan/src/bfadcan.c
lincan/src/c_can.c
lincan/src/msmcan.c
lincan/src/nsi.c
lincan/src/pcan_dongle.c
lincan/src/pcccan.c
lincan/src/pimx1.c
lincan/src/smartcan.c
lincan/src/ssv.c

index 3966e8fc4d6c595479d1b07b846c5e96342fdee3..5a3b86cdd922a53a4d52f274416c9eb4800ef3fd 100644 (file)
 #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
 #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)
 
index 78c76607a72ddfd9741c4237b64a00ebe5d23954..f6d831b70f2e08d53a042bff5a8917eb8e63e4c5 100644 (file)
@@ -28,7 +28,7 @@ MODULE_PARM(clock_freq,"i");
 
 /* cli and sti are not allowed in 2.5.5x SMP kernels */
 #ifdef WINDOWED_ACCESS
-static can_spinlock_t bfadcan_win_lock=SPIN_LOCK_UNLOCKED;
+static CAN_DEFINE_SPINLOCK(bfadcan_win_lock);
 #endif
 
 /*
index ed3991c7c90fc2ba69198c0aee6a637929300d54..9929467bb479dc7fcb959fc76dacc544726dbddf 100644 (file)
 extern int stdmask;
 extern int extmask;
 
-can_spinlock_t c_can_spwlock = SPIN_LOCK_UNLOCKED;     // Spin lock for write operations
-can_spinlock_t c_can_sprlock = SPIN_LOCK_UNLOCKED;     // Spin lock for read operations
-can_spinlock_t c_can_if1lock = SPIN_LOCK_UNLOCKED;     // spin lock for the if1 register
-can_spinlock_t c_can_if2lock = SPIN_LOCK_UNLOCKED;     // spin lcok for the if2 register
+CAN_DEFINE_SPINLOCK(c_can_spwlock);    // Spin lock for write operations
+CAN_DEFINE_SPINLOCK(c_can_sprlock);    // Spin lock for read operations
+CAN_DEFINE_SPINLOCK(c_can_if1lock);    // spin lock for the if1 register
+CAN_DEFINE_SPINLOCK(c_can_if2lock);    // spin lcok for the if2 register
 
 /**
  * c_can_enable_configuration - enable chip configuration mode
index 230e7862788327e6ee474fc92c4cff72f55ecbe7..9851b5ff5fb34a85443e89c076f06292f4861ac8 100644 (file)
@@ -13,7 +13,7 @@
 #include "../include/msmcan.h"
 #include "../include/i82527.h"
 
-static can_spinlock_t msmcan_port_lock=SPIN_LOCK_UNLOCKED;
+static CAN_DEFINE_SPINLOCK(msmcan_port_lock);
 
 /* IO_RANGE is the io-memory range that gets reserved, please adjust according
  * your hardware. Example: #define IO_RANGE 0x100 for i82527 chips or
index 777850bac2f1c39648e2a1fdbedf2dd8c62c9a21..ce9c591e1e2a6b9eafbba00a5c8cc8e27f0368b0 100644 (file)
@@ -16,7 +16,7 @@
 int nsican_irq=-1;
 unsigned long nsican_base=0x0;
 
-static can_spinlock_t nsican_port_lock=SPIN_LOCK_UNLOCKED;
+static CAN_DEFINE_SPINLOCK(nsican_port_lock);
 
 /* IO_RANGE is the io-memory range that gets reserved, please adjust according
  * your hardware. Example: #define IO_RANGE 0x100 for i82527 chips or
index 6bd34964a02a3eef102363cbbc4726294a31856f..ce94186c4a5fc753338f18f6480bef544ffa57ae 100644 (file)
@@ -109,7 +109,7 @@ typedef void (*PARPORT_IRQ_HANLDER)(int, void *, struct pt_regs *);
 
 /****************************************************************************/
 // GLOBALS
-spinlock_t pcan_lock = SPIN_LOCK_UNLOCKED;
+CAN_DEFINE_SPINLOCK(pcan_lock);
 
 /****************************************************************************/
 // LOCALS
@@ -158,14 +158,9 @@ static u8 pcan_dongle_sp_readreg(struct DONGLE_PORT *dng, u8 port) // read a reg
   u16 _PC_ = _PB_ + 1;
   u8  b0, b1 ;
   u8  irqEnable = inb(_PC_) & 0x10; // don't influence irqEnable
-  unsigned long flags;
+  can_spin_irqflags_t flags;
 
-  #if LINUX_VERSION_CODE < KERNEL_VERSION(2,4,18)
-  save_flags(flags);
-  cli();
-  #else
-  spin_lock_irqsave(&pcan_lock, flags);
-  #endif
+  can_spin_lock_irqsave(&pcan_lock, flags);
 
   outb((0x0B ^ 0x0D) | irqEnable, _PC_);
   outb((port & 0x1F) | 0x80,      _PA_);
@@ -175,11 +170,7 @@ static u8 pcan_dongle_sp_readreg(struct DONGLE_PORT *dng, u8 port) // read a reg
   b0=nibble_decode[inb(_PB_)>>3];
   outb((0x0B ^ 0x0D) | irqEnable, _PC_);
 
-  #if LINUX_VERSION_CODE < KERNEL_VERSION(2,4,18)
-  restore_flags(flags);
-  #else
-  spin_unlock_irqrestore(&pcan_lock, flags);
-  #endif
+  can_spin_unlock_irqrestore(&pcan_lock, flags);
 
   return  (b1 << 4) | b0 ;
 }
@@ -189,14 +180,9 @@ static void pcan_dongle_writereg(struct DONGLE_PORT *dng, u8 port, u8 data) // w
   u16 _PA_ = (u16)dng->dwPort;
   u16 _PC_ = _PA_ + 2;
   u8  irqEnable = inb(_PC_) & 0x10; // don't influence irqEnable
-  unsigned long flags;
+  can_spin_irqflags_t flags;
 
-  #if LINUX_VERSION_CODE < KERNEL_VERSION(2,4,18)
-  save_flags(flags);
-  cli();
-  #else
-  spin_lock_irqsave(&pcan_lock, flags);
-  #endif
+  can_spin_lock_irqsave(&pcan_lock, flags);
 
   outb((0x0B ^ 0x0D) | irqEnable, _PC_);
   outb(port & 0x1F,               _PA_);
@@ -204,11 +190,7 @@ static void pcan_dongle_writereg(struct DONGLE_PORT *dng, u8 port, u8 data) // w
   outb(data,                      _PA_);
   outb((0x0B ^ 0x0D) | irqEnable, _PC_);
 
-  #if LINUX_VERSION_CODE < KERNEL_VERSION(2,4,18)
-  restore_flags(flags);
-  #else
-  spin_unlock_irqrestore(&pcan_lock, flags);
-  #endif
+  can_spin_unlock_irqrestore(&pcan_lock, flags);
 }
 
 // functions for EPP port
@@ -218,14 +200,9 @@ static u8 pcan_dongle_epp_readreg(struct DONGLE_PORT *dng, u8 port) // read a re
   u16 _PC_ = _PA_ + 2;
   u8  wert;
   u8  irqEnable = inb(_PC_) & 0x10; // don't influence irqEnable
-  unsigned long flags;
+  can_spin_irqflags_t flags;
 
-  #if LINUX_VERSION_CODE < KERNEL_VERSION(2,4,18)
-  save_flags(flags);
-  cli();
-  #else
-  spin_lock_irqsave(&pcan_lock, flags);
-  #endif
+  can_spin_lock_irqsave(&pcan_lock, flags);
 
   outb((0x0B ^ 0x0F) | irqEnable, _PC_);
   outb((port & 0x1F) | 0x80,      _PA_);
@@ -233,11 +210,7 @@ static u8 pcan_dongle_epp_readreg(struct DONGLE_PORT *dng, u8 port) // read a re
   wert = inb(_PA_);
   outb((0x0B ^ 0x0F) | irqEnable, _PC_);
 
-  #if LINUX_VERSION_CODE < KERNEL_VERSION(2,4,18)
-  restore_flags(flags);
-  #else
-  spin_unlock_irqrestore(&pcan_lock, flags);
-  #endif
+  can_spin_unlock_irqrestore(&pcan_lock, flags);
 
   return wert;
 }
index a6b3ad080eb625e2215aa83fc20defb2376861e7..b568912b10ced1697484ad1554c8b097b29bb2d9 100644 (file)
@@ -20,7 +20,7 @@
 int pcccan_irq=-1;
 unsigned long pcccan_base=0x0;
 
-static can_spinlock_t pcccan_port_lock=SPIN_LOCK_UNLOCKED;
+static CAN_DEFINE_SPINLOCK(pcccan_port_lock);
 
 /*
  * IO_RANGE is the io-memory range that gets reserved, please adjust according
index 8486882d98ef51a324c9afbd9947e66e27699452..a24ddd81b58946d525623aaba3ec4683d4e3f8d4 100644 (file)
@@ -11,6 +11,9 @@
 #include "../include/can_sysdep.h"
 #include "../include/main.h"
 #include "../include/sja1000p.h"
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,14))
+#include <linux/irq.h>
+#endif /* <2.6.14 */
 #include <asm/arch/hardware.h>
 #include <asm/arch/imx-regs.h>
 
@@ -29,7 +32,7 @@
 #define NR_82527 0
 #define NR_SJA1000 1
 
-static can_spinlock_t pimx1_setup_hardware_lock=SPIN_LOCK_UNLOCKED;
+static CAN_DEFINE_SPINLOCK(pimx1_setup_hardware_lock);
 
 int pimx1_setup_hardware(struct candevice_t *candev)
 {
@@ -40,10 +43,17 @@ int pimx1_setup_hardware(struct candevice_t *candev)
        EIM_CS1U = 0x00000902;
        EIM_CS1L = 0x82820903;
        imx_gpio_mode(PA21_PF_A0);
+
+    #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,14))
        /* Setup IRQ port as input */
+       imx_gpio_mode(GPIO_PORTB | GPIO_GIUS | GPIO_IN  | GPIO_PUEN | 17);
+       /* Setup SJA1000 reset as output */
+       imx_gpio_mode(GPIO_PORTB | GPIO_GIUS | GPIO_OUT | GPIO_DR | 15);
+    #else /* <2.6.14 */
        imx_gpio_mode(GPIO_PORTB | GPIO_IN | GPIO_PUEN | GPIO_GPIO | 17);
-       /* Setup SJA1000 reset as ourput */
        imx_gpio_mode(GPIO_PORTB | GPIO_OUT | GPIO_GPIO | 15);
+    #endif /* <2.6.14 */
+
        DR(1) |= 1<<15;
        can_spin_unlock_irqrestore(&pimx1_setup_hardware_lock,flags);
 
@@ -86,7 +96,8 @@ int pimx1_request_io(struct candevice_t *candev)
                return -ENODEV;
        }
        can_base_addr_fixup(candev, remap_addr);
-       CANMSG("Registered IO-memory: 0x%lx - 0x%lx\n", candev->io_addr, candev->io_addr + PIMX1_CAN_IO_RANGE - 1);
+       CANMSG("Registered IO-memory: 0x%lx - 0x%lx (VMA 0x%lx)\n", 
+               candev->io_addr, candev->io_addr + PIMX1_CAN_IO_RANGE - 1, (long)remap_addr);
        return 0;
 }
 
@@ -124,7 +135,7 @@ int pimx1_release_io(struct candevice_t *candev)
  */
 void pimx1_write_register(unsigned data, unsigned long address)
 {
-       /*DEBUGMSG("pimx1_write_register: addr=0x%lx data=0x%x",
+       /*DEBUGMSG("pimx1_write_register: addr=0x%lx data=0x%x\n",
                address,data);*/
        writeb(data,address);
 }
index eddd13dd30f4f718f082d6bf4d8c31062003f5c5..a7a990d5a8bcbcae6776a239fe2fe39cadb57d56 100644 (file)
@@ -16,7 +16,7 @@
 int smartcan_irq=-1;
 unsigned long smartcan_base=0x0;
 
-static can_spinlock_t smartcan_port_lock=SPIN_LOCK_UNLOCKED;
+static CAN_DEFINE_SPINLOCK(smartcan_port_lock);
 
 int smartcan_request_io(struct candevice_t *candev)
 {
index 3cd003d1b45f64b0871baaeb4e109c124b769b48..45aef4b91ae26225b5ddb6d1f08701dd1d3c9d37 100644 (file)
@@ -14,7 +14,7 @@
 int ssvcan_irq[2]={-1,-1};
 unsigned long ssvcan_base=0x0;
 
-static can_spinlock_t ssv_port_lock=SPIN_LOCK_UNLOCKED;
+static CAN_DEFINE_SPINLOCK(ssv_port_lock);
 
 /* IO_RANGE is the io-memory range that gets reserved, please adjust according
  * your hardware. Example: #define IO_RANGE 0x100 for i82527 chips or