#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)
/* 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
/*
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
#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
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
/****************************************************************************/
// GLOBALS
-spinlock_t pcan_lock = SPIN_LOCK_UNLOCKED;
+CAN_DEFINE_SPINLOCK(pcan_lock);
/****************************************************************************/
// LOCALS
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_);
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 ;
}
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_);
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
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_);
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;
}
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
#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>
#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)
{
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);
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;
}
*/
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);
}
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)
{
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