2005-04-16 22:20:36 +00:00
|
|
|
/*
|
|
|
|
* drivers/pcmcia/m32r_cfc.c
|
|
|
|
*
|
|
|
|
* Device driver for the CFC functionality of M32R.
|
|
|
|
*
|
|
|
|
* Copyright (c) 2001, 2002, 2003, 2004
|
|
|
|
* Hiroyuki Kondo, Naoto Sugai, Hayato Fujiwara
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <linux/module.h>
|
|
|
|
#include <linux/moduleparam.h>
|
|
|
|
#include <linux/init.h>
|
|
|
|
#include <linux/types.h>
|
|
|
|
#include <linux/fcntl.h>
|
|
|
|
#include <linux/string.h>
|
|
|
|
#include <linux/kernel.h>
|
|
|
|
#include <linux/errno.h>
|
|
|
|
#include <linux/timer.h>
|
|
|
|
#include <linux/ioport.h>
|
|
|
|
#include <linux/delay.h>
|
|
|
|
#include <linux/workqueue.h>
|
|
|
|
#include <linux/interrupt.h>
|
2005-10-29 18:07:23 +00:00
|
|
|
#include <linux/platform_device.h>
|
2005-06-22 00:16:14 +00:00
|
|
|
#include <linux/bitops.h>
|
2005-04-16 22:20:36 +00:00
|
|
|
#include <asm/irq.h>
|
|
|
|
#include <asm/io.h>
|
|
|
|
|
|
|
|
#include <pcmcia/ss.h>
|
|
|
|
|
|
|
|
#undef MAX_IO_WIN /* FIXME */
|
|
|
|
#define MAX_IO_WIN 1
|
|
|
|
#undef MAX_WIN /* FIXME */
|
|
|
|
#define MAX_WIN 1
|
|
|
|
|
|
|
|
#include "m32r_cfc.h"
|
|
|
|
|
|
|
|
/* Poll status interval -- 0 means default to interrupt */
|
|
|
|
static int poll_interval = 0;
|
|
|
|
|
|
|
|
typedef enum pcc_space { as_none = 0, as_comm, as_attr, as_io } pcc_as_t;
|
|
|
|
|
|
|
|
typedef struct pcc_socket {
|
|
|
|
u_short type, flags;
|
|
|
|
struct pcmcia_socket socket;
|
|
|
|
unsigned int number;
|
2008-02-05 06:27:35 +00:00
|
|
|
unsigned int ioaddr;
|
2005-04-16 22:20:36 +00:00
|
|
|
u_long mapaddr;
|
|
|
|
u_long base; /* PCC register base */
|
|
|
|
u_char cs_irq1, cs_irq2, intr;
|
|
|
|
pccard_io_map io_map[MAX_IO_WIN];
|
|
|
|
pccard_mem_map mem_map[MAX_WIN];
|
|
|
|
u_char io_win;
|
|
|
|
u_char mem_win;
|
|
|
|
pcc_as_t current_space;
|
|
|
|
u_char last_iodbex;
|
|
|
|
#ifdef CONFIG_PROC_FS
|
|
|
|
struct proc_dir_entry *proc;
|
|
|
|
#endif
|
|
|
|
} pcc_socket_t;
|
|
|
|
|
|
|
|
static int pcc_sockets = 0;
|
|
|
|
static pcc_socket_t socket[M32R_MAX_PCC] = {
|
|
|
|
{ 0, }, /* ... */
|
|
|
|
};
|
|
|
|
|
|
|
|
/*====================================================================*/
|
|
|
|
|
|
|
|
static unsigned int pcc_get(u_short, unsigned int);
|
|
|
|
static void pcc_set(u_short, unsigned int , unsigned int );
|
|
|
|
|
|
|
|
static DEFINE_SPINLOCK(pcc_lock);
|
|
|
|
|
|
|
|
#if !defined(CONFIG_PLAT_USRV)
|
|
|
|
static inline u_long pcc_port2addr(unsigned long port, int size) {
|
|
|
|
u_long addr = 0;
|
|
|
|
u_long odd;
|
|
|
|
|
|
|
|
if (size == 1) { /* byte access */
|
|
|
|
odd = (port&1) << 11;
|
|
|
|
port -= port & 1;
|
|
|
|
addr = CFC_IO_MAPBASE_BYTE - CFC_IOPORT_BASE + odd + port;
|
|
|
|
} else if (size == 2)
|
|
|
|
addr = CFC_IO_MAPBASE_WORD - CFC_IOPORT_BASE + port;
|
|
|
|
|
|
|
|
return addr;
|
|
|
|
}
|
|
|
|
#else /* CONFIG_PLAT_USRV */
|
|
|
|
static inline u_long pcc_port2addr(unsigned long port, int size) {
|
|
|
|
u_long odd;
|
|
|
|
u_long addr = ((port - CFC_IOPORT_BASE) & 0xf000) << 8;
|
|
|
|
|
|
|
|
if (size == 1) { /* byte access */
|
|
|
|
odd = port & 1;
|
|
|
|
port -= odd;
|
|
|
|
odd <<= 11;
|
|
|
|
addr = (addr | CFC_IO_MAPBASE_BYTE) + odd + (port & 0xfff);
|
|
|
|
} else if (size == 2) /* word access */
|
|
|
|
addr = (addr | CFC_IO_MAPBASE_WORD) + (port & 0xfff);
|
|
|
|
|
|
|
|
return addr;
|
|
|
|
}
|
|
|
|
#endif /* CONFIG_PLAT_USRV */
|
|
|
|
|
|
|
|
void pcc_ioread_byte(int sock, unsigned long port, void *buf, size_t size,
|
|
|
|
size_t nmemb, int flag)
|
|
|
|
{
|
|
|
|
u_long addr;
|
|
|
|
unsigned char *bp = (unsigned char *)buf;
|
|
|
|
unsigned long flags;
|
|
|
|
|
2009-10-23 10:56:46 +00:00
|
|
|
pr_debug("m32r_cfc: pcc_ioread_byte: sock=%d, port=%#lx, buf=%p, "
|
2005-04-16 22:20:36 +00:00
|
|
|
"size=%u, nmemb=%d, flag=%d\n",
|
|
|
|
sock, port, buf, size, nmemb, flag);
|
|
|
|
|
|
|
|
addr = pcc_port2addr(port, 1);
|
|
|
|
if (!addr) {
|
|
|
|
printk("m32r_cfc:ioread_byte null port :%#lx\n",port);
|
|
|
|
return;
|
|
|
|
}
|
2009-10-23 10:56:46 +00:00
|
|
|
pr_debug("m32r_cfc: pcc_ioread_byte: addr=%#lx\n", addr);
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
spin_lock_irqsave(&pcc_lock, flags);
|
|
|
|
/* read Byte */
|
|
|
|
while (nmemb--)
|
|
|
|
*bp++ = readb(addr);
|
|
|
|
spin_unlock_irqrestore(&pcc_lock, flags);
|
|
|
|
}
|
|
|
|
|
|
|
|
void pcc_ioread_word(int sock, unsigned long port, void *buf, size_t size,
|
|
|
|
size_t nmemb, int flag)
|
|
|
|
{
|
|
|
|
u_long addr;
|
|
|
|
unsigned short *bp = (unsigned short *)buf;
|
|
|
|
unsigned long flags;
|
|
|
|
|
2009-10-23 10:56:46 +00:00
|
|
|
pr_debug("m32r_cfc: pcc_ioread_word: sock=%d, port=%#lx, "
|
2005-04-16 22:20:36 +00:00
|
|
|
"buf=%p, size=%u, nmemb=%d, flag=%d\n",
|
|
|
|
sock, port, buf, size, nmemb, flag);
|
|
|
|
|
|
|
|
if (size != 2)
|
|
|
|
printk("m32r_cfc: ioread_word :illigal size %u : %#lx\n", size,
|
|
|
|
port);
|
|
|
|
if (size == 9)
|
|
|
|
printk("m32r_cfc: ioread_word :insw \n");
|
|
|
|
|
|
|
|
addr = pcc_port2addr(port, 2);
|
|
|
|
if (!addr) {
|
|
|
|
printk("m32r_cfc:ioread_word null port :%#lx\n",port);
|
|
|
|
return;
|
|
|
|
}
|
2009-10-23 10:56:46 +00:00
|
|
|
pr_debug("m32r_cfc: pcc_ioread_word: addr=%#lx\n", addr);
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
spin_lock_irqsave(&pcc_lock, flags);
|
|
|
|
/* read Word */
|
|
|
|
while (nmemb--)
|
|
|
|
*bp++ = readw(addr);
|
|
|
|
spin_unlock_irqrestore(&pcc_lock, flags);
|
|
|
|
}
|
|
|
|
|
|
|
|
void pcc_iowrite_byte(int sock, unsigned long port, void *buf, size_t size,
|
|
|
|
size_t nmemb, int flag)
|
|
|
|
{
|
|
|
|
u_long addr;
|
|
|
|
unsigned char *bp = (unsigned char *)buf;
|
|
|
|
unsigned long flags;
|
|
|
|
|
2009-10-23 10:56:46 +00:00
|
|
|
pr_debug("m32r_cfc: pcc_iowrite_byte: sock=%d, port=%#lx, "
|
2005-04-16 22:20:36 +00:00
|
|
|
"buf=%p, size=%u, nmemb=%d, flag=%d\n",
|
|
|
|
sock, port, buf, size, nmemb, flag);
|
|
|
|
|
|
|
|
/* write Byte */
|
|
|
|
addr = pcc_port2addr(port, 1);
|
|
|
|
if (!addr) {
|
|
|
|
printk("m32r_cfc:iowrite_byte null port:%#lx\n",port);
|
|
|
|
return;
|
|
|
|
}
|
2009-10-23 10:56:46 +00:00
|
|
|
pr_debug("m32r_cfc: pcc_iowrite_byte: addr=%#lx\n", addr);
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
spin_lock_irqsave(&pcc_lock, flags);
|
|
|
|
while (nmemb--)
|
|
|
|
writeb(*bp++, addr);
|
|
|
|
spin_unlock_irqrestore(&pcc_lock, flags);
|
|
|
|
}
|
|
|
|
|
|
|
|
void pcc_iowrite_word(int sock, unsigned long port, void *buf, size_t size,
|
|
|
|
size_t nmemb, int flag)
|
|
|
|
{
|
|
|
|
u_long addr;
|
|
|
|
unsigned short *bp = (unsigned short *)buf;
|
|
|
|
unsigned long flags;
|
|
|
|
|
2009-10-23 10:56:46 +00:00
|
|
|
pr_debug("m32r_cfc: pcc_iowrite_word: sock=%d, port=%#lx, "
|
2005-04-16 22:20:36 +00:00
|
|
|
"buf=%p, size=%u, nmemb=%d, flag=%d\n",
|
|
|
|
sock, port, buf, size, nmemb, flag);
|
|
|
|
|
|
|
|
if(size != 2)
|
|
|
|
printk("m32r_cfc: iowrite_word :illigal size %u : %#lx\n",
|
|
|
|
size, port);
|
|
|
|
if(size == 9)
|
|
|
|
printk("m32r_cfc: iowrite_word :outsw \n");
|
|
|
|
|
|
|
|
addr = pcc_port2addr(port, 2);
|
|
|
|
if (!addr) {
|
|
|
|
printk("m32r_cfc:iowrite_word null addr :%#lx\n",port);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
#if 1
|
|
|
|
if (addr & 1) {
|
|
|
|
printk("m32r_cfc:iowrite_word port addr (%#lx):%#lx\n", port,
|
|
|
|
addr);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
#endif
|
2009-10-23 10:56:46 +00:00
|
|
|
pr_debug("m32r_cfc: pcc_iowrite_word: addr=%#lx\n", addr);
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
spin_lock_irqsave(&pcc_lock, flags);
|
|
|
|
while (nmemb--)
|
|
|
|
writew(*bp++, addr);
|
|
|
|
spin_unlock_irqrestore(&pcc_lock, flags);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*====================================================================*/
|
|
|
|
|
|
|
|
#define IS_REGISTERED 0x2000
|
|
|
|
#define IS_ALIVE 0x8000
|
|
|
|
|
|
|
|
typedef struct pcc_t {
|
|
|
|
char *name;
|
|
|
|
u_short flags;
|
|
|
|
} pcc_t;
|
|
|
|
|
|
|
|
static pcc_t pcc[] = {
|
|
|
|
#if !defined(CONFIG_PLAT_USRV)
|
|
|
|
{ "m32r_cfc", 0 }, { "", 0 },
|
|
|
|
#else /* CONFIG_PLAT_USRV */
|
|
|
|
{ "m32r_cfc", 0 }, { "m32r_cfc", 0 }, { "m32r_cfc", 0 },
|
|
|
|
{ "m32r_cfc", 0 }, { "m32r_cfc", 0 }, { "", 0 },
|
|
|
|
#endif /* CONFIG_PLAT_USRV */
|
|
|
|
};
|
|
|
|
|
IRQ: Maintain regs pointer globally rather than passing to IRQ handlers
Maintain a per-CPU global "struct pt_regs *" variable which can be used instead
of passing regs around manually through all ~1800 interrupt handlers in the
Linux kernel.
The regs pointer is used in few places, but it potentially costs both stack
space and code to pass it around. On the FRV arch, removing the regs parameter
from all the genirq function results in a 20% speed up of the IRQ exit path
(ie: from leaving timer_interrupt() to leaving do_IRQ()).
Where appropriate, an arch may override the generic storage facility and do
something different with the variable. On FRV, for instance, the address is
maintained in GR28 at all times inside the kernel as part of general exception
handling.
Having looked over the code, it appears that the parameter may be handed down
through up to twenty or so layers of functions. Consider a USB character
device attached to a USB hub, attached to a USB controller that posts its
interrupts through a cascaded auxiliary interrupt controller. A character
device driver may want to pass regs to the sysrq handler through the input
layer which adds another few layers of parameter passing.
I've build this code with allyesconfig for x86_64 and i386. I've runtested the
main part of the code on FRV and i386, though I can't test most of the drivers.
I've also done partial conversion for powerpc and MIPS - these at least compile
with minimal configurations.
This will affect all archs. Mostly the changes should be relatively easy.
Take do_IRQ(), store the regs pointer at the beginning, saving the old one:
struct pt_regs *old_regs = set_irq_regs(regs);
And put the old one back at the end:
set_irq_regs(old_regs);
Don't pass regs through to generic_handle_irq() or __do_IRQ().
In timer_interrupt(), this sort of change will be necessary:
- update_process_times(user_mode(regs));
- profile_tick(CPU_PROFILING, regs);
+ update_process_times(user_mode(get_irq_regs()));
+ profile_tick(CPU_PROFILING);
I'd like to move update_process_times()'s use of get_irq_regs() into itself,
except that i386, alone of the archs, uses something other than user_mode().
Some notes on the interrupt handling in the drivers:
(*) input_dev() is now gone entirely. The regs pointer is no longer stored in
the input_dev struct.
(*) finish_unlinks() in drivers/usb/host/ohci-q.c needs checking. It does
something different depending on whether it's been supplied with a regs
pointer or not.
(*) Various IRQ handler function pointers have been moved to type
irq_handler_t.
Signed-Off-By: David Howells <dhowells@redhat.com>
(cherry picked from 1b16e7ac850969f38b375e511e3fa2f474a33867 commit)
2006-10-05 13:55:46 +00:00
|
|
|
static irqreturn_t pcc_interrupt(int, void *);
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
/*====================================================================*/
|
|
|
|
|
|
|
|
static struct timer_list poll_timer;
|
|
|
|
|
|
|
|
static unsigned int pcc_get(u_short sock, unsigned int reg)
|
|
|
|
{
|
|
|
|
unsigned int val = inw(reg);
|
2009-10-23 10:56:46 +00:00
|
|
|
pr_debug("m32r_cfc: pcc_get: reg(0x%08x)=0x%04x\n", reg, val);
|
2005-04-16 22:20:36 +00:00
|
|
|
return val;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void pcc_set(u_short sock, unsigned int reg, unsigned int data)
|
|
|
|
{
|
|
|
|
outw(data, reg);
|
2009-10-23 10:56:46 +00:00
|
|
|
pr_debug("m32r_cfc: pcc_set: reg(0x%08x)=0x%04x\n", reg, data);
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*======================================================================
|
|
|
|
|
|
|
|
See if a card is present, powered up, in IO mode, and already
|
|
|
|
bound to a (non PC Card) Linux driver. We leave these alone.
|
|
|
|
|
|
|
|
We make an exception for cards that seem to be serial devices.
|
|
|
|
|
|
|
|
======================================================================*/
|
|
|
|
|
|
|
|
static int __init is_alive(u_short sock)
|
|
|
|
{
|
|
|
|
unsigned int stat;
|
|
|
|
|
2009-10-23 10:56:46 +00:00
|
|
|
pr_debug("m32r_cfc: is_alive:\n");
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
printk("CF: ");
|
|
|
|
stat = pcc_get(sock, (unsigned int)PLD_CFSTS);
|
|
|
|
if (!stat)
|
|
|
|
printk("No ");
|
|
|
|
printk("Card is detected at socket %d : stat = 0x%08x\n", sock, stat);
|
2009-10-23 10:56:46 +00:00
|
|
|
pr_debug("m32r_cfc: is_alive: sock stat is 0x%04x\n", stat);
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2008-02-05 06:27:35 +00:00
|
|
|
static void add_pcc_socket(ulong base, int irq, ulong mapaddr,
|
|
|
|
unsigned int ioaddr)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
|
|
|
pcc_socket_t *t = &socket[pcc_sockets];
|
|
|
|
|
2009-10-23 10:56:46 +00:00
|
|
|
pr_debug("m32r_cfc: add_pcc_socket: base=%#lx, irq=%d, "
|
2005-04-16 22:20:36 +00:00
|
|
|
"mapaddr=%#lx, ioaddr=%08x\n",
|
|
|
|
base, irq, mapaddr, ioaddr);
|
|
|
|
|
|
|
|
/* add sockets */
|
|
|
|
t->ioaddr = ioaddr;
|
|
|
|
t->mapaddr = mapaddr;
|
|
|
|
#if !defined(CONFIG_PLAT_USRV)
|
|
|
|
t->base = 0;
|
|
|
|
t->flags = 0;
|
|
|
|
t->cs_irq1 = irq; // insert irq
|
|
|
|
t->cs_irq2 = irq + 1; // eject irq
|
|
|
|
#else /* CONFIG_PLAT_USRV */
|
|
|
|
t->base = base;
|
|
|
|
t->flags = 0;
|
|
|
|
t->cs_irq1 = 0; // insert irq
|
|
|
|
t->cs_irq2 = 0; // eject irq
|
|
|
|
#endif /* CONFIG_PLAT_USRV */
|
|
|
|
|
|
|
|
if (is_alive(pcc_sockets))
|
|
|
|
t->flags |= IS_ALIVE;
|
|
|
|
|
|
|
|
/* add pcc */
|
|
|
|
#if !defined(CONFIG_PLAT_USRV)
|
|
|
|
request_region((unsigned int)PLD_CFRSTCR, 0x20, "m32r_cfc");
|
|
|
|
#else /* CONFIG_PLAT_USRV */
|
|
|
|
{
|
|
|
|
unsigned int reg_base;
|
|
|
|
|
|
|
|
reg_base = (unsigned int)PLD_CFRSTCR;
|
|
|
|
reg_base |= pcc_sockets << 8;
|
|
|
|
request_region(reg_base, 0x20, "m32r_cfc");
|
|
|
|
}
|
|
|
|
#endif /* CONFIG_PLAT_USRV */
|
|
|
|
printk(KERN_INFO " %s ", pcc[pcc_sockets].name);
|
|
|
|
printk("pcc at 0x%08lx\n", t->base);
|
|
|
|
|
|
|
|
/* Update socket interrupt information, capabilities */
|
|
|
|
t->socket.features |= (SS_CAP_PCCARD | SS_CAP_STATIC_MAP);
|
|
|
|
t->socket.map_size = M32R_PCC_MAPSIZE;
|
|
|
|
t->socket.io_offset = ioaddr; /* use for io access offset */
|
|
|
|
t->socket.irq_mask = 0;
|
|
|
|
#if !defined(CONFIG_PLAT_USRV)
|
|
|
|
t->socket.pci_irq = PLD_IRQ_CFIREQ ; /* card interrupt */
|
|
|
|
#else /* CONFIG_PLAT_USRV */
|
|
|
|
t->socket.pci_irq = PLD_IRQ_CF0 + pcc_sockets;
|
|
|
|
#endif /* CONFIG_PLAT_USRV */
|
|
|
|
|
|
|
|
#ifndef CONFIG_PLAT_USRV
|
|
|
|
/* insert interrupt */
|
|
|
|
request_irq(irq, pcc_interrupt, 0, "m32r_cfc", pcc_interrupt);
|
2005-11-28 21:44:00 +00:00
|
|
|
#ifndef CONFIG_PLAT_MAPPI3
|
2005-04-16 22:20:36 +00:00
|
|
|
/* eject interrupt */
|
|
|
|
request_irq(irq+1, pcc_interrupt, 0, "m32r_cfc", pcc_interrupt);
|
2005-11-28 21:44:00 +00:00
|
|
|
#endif
|
2009-10-23 10:56:46 +00:00
|
|
|
pr_debug("m32r_cfc: enable CFMSK, RDYSEL\n");
|
2005-04-16 22:20:36 +00:00
|
|
|
pcc_set(pcc_sockets, (unsigned int)PLD_CFIMASK, 0x01);
|
|
|
|
#endif /* CONFIG_PLAT_USRV */
|
|
|
|
#if defined(CONFIG_PLAT_M32700UT) || defined(CONFIG_PLAT_USRV) || defined(CONFIG_PLAT_OPSPUT)
|
|
|
|
pcc_set(pcc_sockets, (unsigned int)PLD_CFCR1, 0x0200);
|
|
|
|
#endif
|
|
|
|
pcc_sockets++;
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*====================================================================*/
|
|
|
|
|
IRQ: Maintain regs pointer globally rather than passing to IRQ handlers
Maintain a per-CPU global "struct pt_regs *" variable which can be used instead
of passing regs around manually through all ~1800 interrupt handlers in the
Linux kernel.
The regs pointer is used in few places, but it potentially costs both stack
space and code to pass it around. On the FRV arch, removing the regs parameter
from all the genirq function results in a 20% speed up of the IRQ exit path
(ie: from leaving timer_interrupt() to leaving do_IRQ()).
Where appropriate, an arch may override the generic storage facility and do
something different with the variable. On FRV, for instance, the address is
maintained in GR28 at all times inside the kernel as part of general exception
handling.
Having looked over the code, it appears that the parameter may be handed down
through up to twenty or so layers of functions. Consider a USB character
device attached to a USB hub, attached to a USB controller that posts its
interrupts through a cascaded auxiliary interrupt controller. A character
device driver may want to pass regs to the sysrq handler through the input
layer which adds another few layers of parameter passing.
I've build this code with allyesconfig for x86_64 and i386. I've runtested the
main part of the code on FRV and i386, though I can't test most of the drivers.
I've also done partial conversion for powerpc and MIPS - these at least compile
with minimal configurations.
This will affect all archs. Mostly the changes should be relatively easy.
Take do_IRQ(), store the regs pointer at the beginning, saving the old one:
struct pt_regs *old_regs = set_irq_regs(regs);
And put the old one back at the end:
set_irq_regs(old_regs);
Don't pass regs through to generic_handle_irq() or __do_IRQ().
In timer_interrupt(), this sort of change will be necessary:
- update_process_times(user_mode(regs));
- profile_tick(CPU_PROFILING, regs);
+ update_process_times(user_mode(get_irq_regs()));
+ profile_tick(CPU_PROFILING);
I'd like to move update_process_times()'s use of get_irq_regs() into itself,
except that i386, alone of the archs, uses something other than user_mode().
Some notes on the interrupt handling in the drivers:
(*) input_dev() is now gone entirely. The regs pointer is no longer stored in
the input_dev struct.
(*) finish_unlinks() in drivers/usb/host/ohci-q.c needs checking. It does
something different depending on whether it's been supplied with a regs
pointer or not.
(*) Various IRQ handler function pointers have been moved to type
irq_handler_t.
Signed-Off-By: David Howells <dhowells@redhat.com>
(cherry picked from 1b16e7ac850969f38b375e511e3fa2f474a33867 commit)
2006-10-05 13:55:46 +00:00
|
|
|
static irqreturn_t pcc_interrupt(int irq, void *dev)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
u_int events = 0;
|
|
|
|
int handled = 0;
|
|
|
|
|
2009-10-23 10:56:46 +00:00
|
|
|
pr_debug("m32r_cfc: pcc_interrupt: irq=%d, dev=%p\n", irq, dev);
|
2005-04-16 22:20:36 +00:00
|
|
|
for (i = 0; i < pcc_sockets; i++) {
|
|
|
|
if (socket[i].cs_irq1 != irq && socket[i].cs_irq2 != irq)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
handled = 1;
|
2009-10-23 10:56:46 +00:00
|
|
|
pr_debug("m32r_cfc: pcc_interrupt: socket %d irq 0x%02x ",
|
2005-04-16 22:20:36 +00:00
|
|
|
i, irq);
|
|
|
|
events |= SS_DETECT; /* insert or eject */
|
|
|
|
if (events)
|
|
|
|
pcmcia_parse_events(&socket[i].socket, events);
|
|
|
|
}
|
2009-10-23 10:56:46 +00:00
|
|
|
pr_debug("m32r_cfc: pcc_interrupt: done\n");
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
return IRQ_RETVAL(handled);
|
|
|
|
} /* pcc_interrupt */
|
|
|
|
|
|
|
|
static void pcc_interrupt_wrapper(u_long data)
|
|
|
|
{
|
2009-10-23 10:56:46 +00:00
|
|
|
pr_debug("m32r_cfc: pcc_interrupt_wrapper:\n");
|
2006-12-02 17:55:06 +00:00
|
|
|
pcc_interrupt(0, NULL);
|
2005-04-16 22:20:36 +00:00
|
|
|
init_timer(&poll_timer);
|
|
|
|
poll_timer.expires = jiffies + poll_interval;
|
|
|
|
add_timer(&poll_timer);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*====================================================================*/
|
|
|
|
|
|
|
|
static int _pcc_get_status(u_short sock, u_int *value)
|
|
|
|
{
|
|
|
|
u_int status;
|
|
|
|
|
2009-10-23 10:56:46 +00:00
|
|
|
pr_debug("m32r_cfc: _pcc_get_status:\n");
|
2005-04-16 22:20:36 +00:00
|
|
|
status = pcc_get(sock, (unsigned int)PLD_CFSTS);
|
|
|
|
*value = (status) ? SS_DETECT : 0;
|
2009-10-23 10:56:46 +00:00
|
|
|
pr_debug("m32r_cfc: _pcc_get_status: status=0x%08x\n", status);
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
#if defined(CONFIG_PLAT_M32700UT) || defined(CONFIG_PLAT_USRV) || defined(CONFIG_PLAT_OPSPUT)
|
|
|
|
if ( status ) {
|
|
|
|
/* enable CF power */
|
|
|
|
status = inw((unsigned int)PLD_CPCR);
|
|
|
|
if (!(status & PLD_CPCR_CF)) {
|
2009-10-23 10:56:46 +00:00
|
|
|
pr_debug("m32r_cfc: _pcc_get_status: "
|
2005-04-16 22:20:36 +00:00
|
|
|
"power on (CPCR=0x%08x)\n", status);
|
|
|
|
status |= PLD_CPCR_CF;
|
|
|
|
outw(status, (unsigned int)PLD_CPCR);
|
|
|
|
udelay(100);
|
|
|
|
}
|
|
|
|
*value |= SS_POWERON;
|
|
|
|
|
|
|
|
pcc_set(sock, (unsigned int)PLD_CFBUFCR,0);/* enable buffer */
|
|
|
|
udelay(100);
|
|
|
|
|
|
|
|
*value |= SS_READY; /* always ready */
|
|
|
|
*value |= SS_3VCARD;
|
|
|
|
} else {
|
|
|
|
/* disable CF power */
|
|
|
|
status = inw((unsigned int)PLD_CPCR);
|
|
|
|
status &= ~PLD_CPCR_CF;
|
|
|
|
outw(status, (unsigned int)PLD_CPCR);
|
|
|
|
udelay(100);
|
2009-10-23 10:56:46 +00:00
|
|
|
pr_debug("m32r_cfc: _pcc_get_status: "
|
2005-04-16 22:20:36 +00:00
|
|
|
"power off (CPCR=0x%08x)\n", status);
|
|
|
|
}
|
2005-06-22 00:16:14 +00:00
|
|
|
#elif defined(CONFIG_PLAT_MAPPI2) || defined(CONFIG_PLAT_MAPPI3)
|
2005-04-16 22:20:36 +00:00
|
|
|
if ( status ) {
|
|
|
|
status = pcc_get(sock, (unsigned int)PLD_CPCR);
|
|
|
|
if (status == 0) { /* power off */
|
|
|
|
pcc_set(sock, (unsigned int)PLD_CPCR, 1);
|
|
|
|
pcc_set(sock, (unsigned int)PLD_CFBUFCR,0); /* force buffer off for ZA-36 */
|
|
|
|
udelay(50);
|
|
|
|
}
|
2005-06-22 00:16:14 +00:00
|
|
|
*value |= SS_POWERON;
|
|
|
|
|
|
|
|
pcc_set(sock, (unsigned int)PLD_CFBUFCR,0);
|
|
|
|
udelay(50);
|
|
|
|
pcc_set(sock, (unsigned int)PLD_CFRSTCR, 0x0101);
|
|
|
|
udelay(25); /* for IDE reset */
|
|
|
|
pcc_set(sock, (unsigned int)PLD_CFRSTCR, 0x0100);
|
|
|
|
mdelay(2); /* for IDE reset */
|
|
|
|
|
|
|
|
*value |= SS_READY;
|
|
|
|
*value |= SS_3VCARD;
|
|
|
|
} else {
|
|
|
|
/* disable CF power */
|
|
|
|
pcc_set(sock, (unsigned int)PLD_CPCR, 0);
|
|
|
|
udelay(100);
|
2009-10-23 10:56:46 +00:00
|
|
|
pr_debug("m32r_cfc: _pcc_get_status: "
|
2005-06-22 00:16:14 +00:00
|
|
|
"power off (CPCR=0x%08x)\n", status);
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
#else
|
|
|
|
#error no platform configuration
|
|
|
|
#endif
|
2009-10-23 10:56:46 +00:00
|
|
|
pr_debug("m32r_cfc: _pcc_get_status: GetStatus(%d) = %#4.4x\n",
|
2005-04-16 22:20:36 +00:00
|
|
|
sock, *value);
|
|
|
|
return 0;
|
|
|
|
} /* _get_status */
|
|
|
|
|
|
|
|
/*====================================================================*/
|
|
|
|
|
|
|
|
static int _pcc_set_socket(u_short sock, socket_state_t *state)
|
|
|
|
{
|
2009-10-23 10:56:46 +00:00
|
|
|
pr_debug("m32r_cfc: SetSocket(%d, flags %#3.3x, Vcc %d, Vpp %d, "
|
2005-04-16 22:20:36 +00:00
|
|
|
"io_irq %d, csc_mask %#2.2x)\n", sock, state->flags,
|
|
|
|
state->Vcc, state->Vpp, state->io_irq, state->csc_mask);
|
|
|
|
|
2005-06-22 00:16:14 +00:00
|
|
|
#if defined(CONFIG_PLAT_M32700UT) || defined(CONFIG_PLAT_USRV) || defined(CONFIG_PLAT_OPSPUT) || defined(CONFIG_PLAT_MAPPI2) || defined(CONFIG_PLAT_MAPPI3)
|
2005-04-16 22:20:36 +00:00
|
|
|
if (state->Vcc) {
|
|
|
|
if ((state->Vcc != 50) && (state->Vcc != 33))
|
|
|
|
return -EINVAL;
|
|
|
|
/* accept 5V and 3.3V */
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
if (state->flags & SS_RESET) {
|
2009-10-23 10:56:46 +00:00
|
|
|
pr_debug(":RESET\n");
|
2005-04-16 22:20:36 +00:00
|
|
|
pcc_set(sock,(unsigned int)PLD_CFRSTCR,0x101);
|
|
|
|
}else{
|
|
|
|
pcc_set(sock,(unsigned int)PLD_CFRSTCR,0x100);
|
|
|
|
}
|
|
|
|
if (state->flags & SS_OUTPUT_ENA){
|
2009-10-23 10:56:46 +00:00
|
|
|
pr_debug(":OUTPUT_ENA\n");
|
2005-04-16 22:20:36 +00:00
|
|
|
/* bit clear */
|
|
|
|
pcc_set(sock,(unsigned int)PLD_CFBUFCR,0);
|
|
|
|
} else {
|
|
|
|
pcc_set(sock,(unsigned int)PLD_CFBUFCR,1);
|
|
|
|
}
|
|
|
|
|
|
|
|
if(state->flags & SS_IOCARD){
|
2009-10-23 10:56:46 +00:00
|
|
|
pr_debug(":IOCARD");
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
if (state->flags & SS_PWR_AUTO) {
|
2009-10-23 10:56:46 +00:00
|
|
|
pr_debug(":PWR_AUTO");
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
if (state->csc_mask & SS_DETECT)
|
2009-10-23 10:56:46 +00:00
|
|
|
pr_debug(":csc-SS_DETECT");
|
2005-04-16 22:20:36 +00:00
|
|
|
if (state->flags & SS_IOCARD) {
|
|
|
|
if (state->csc_mask & SS_STSCHG)
|
2009-10-23 10:56:46 +00:00
|
|
|
pr_debug(":STSCHG");
|
2005-04-16 22:20:36 +00:00
|
|
|
} else {
|
|
|
|
if (state->csc_mask & SS_BATDEAD)
|
2009-10-23 10:56:46 +00:00
|
|
|
pr_debug(":BATDEAD");
|
2005-04-16 22:20:36 +00:00
|
|
|
if (state->csc_mask & SS_BATWARN)
|
2009-10-23 10:56:46 +00:00
|
|
|
pr_debug(":BATWARN");
|
2005-04-16 22:20:36 +00:00
|
|
|
if (state->csc_mask & SS_READY)
|
2009-10-23 10:56:46 +00:00
|
|
|
pr_debug(":READY");
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
2009-10-23 10:56:46 +00:00
|
|
|
pr_debug("\n");
|
2005-04-16 22:20:36 +00:00
|
|
|
return 0;
|
|
|
|
} /* _set_socket */
|
|
|
|
|
|
|
|
/*====================================================================*/
|
|
|
|
|
|
|
|
static int _pcc_set_io_map(u_short sock, struct pccard_io_map *io)
|
|
|
|
{
|
|
|
|
u_char map;
|
|
|
|
|
2009-10-23 10:56:46 +00:00
|
|
|
pr_debug("m32r_cfc: SetIOMap(%d, %d, %#2.2x, %d ns, "
|
2009-10-19 09:42:13 +00:00
|
|
|
"%#llx-%#llx)\n", sock, io->map, io->flags,
|
|
|
|
io->speed, (unsigned long long)io->start,
|
|
|
|
(unsigned long long)io->stop);
|
2005-04-16 22:20:36 +00:00
|
|
|
map = io->map;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
} /* _set_io_map */
|
|
|
|
|
|
|
|
/*====================================================================*/
|
|
|
|
|
|
|
|
static int _pcc_set_mem_map(u_short sock, struct pccard_mem_map *mem)
|
|
|
|
{
|
|
|
|
|
|
|
|
u_char map = mem->map;
|
|
|
|
u_long addr;
|
|
|
|
pcc_socket_t *t = &socket[sock];
|
|
|
|
|
2009-10-23 10:56:46 +00:00
|
|
|
pr_debug("m32r_cfc: SetMemMap(%d, %d, %#2.2x, %d ns, "
|
2009-10-19 09:42:13 +00:00
|
|
|
"%#llx, %#x)\n", sock, map, mem->flags,
|
|
|
|
mem->speed, (unsigned long long)mem->static_start,
|
|
|
|
mem->card_start);
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* sanity check
|
|
|
|
*/
|
|
|
|
if ((map > MAX_WIN) || (mem->card_start > 0x3ffffff)){
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* de-activate
|
|
|
|
*/
|
|
|
|
if ((mem->flags & MAP_ACTIVE) == 0) {
|
|
|
|
t->current_space = as_none;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Set mode
|
|
|
|
*/
|
|
|
|
if (mem->flags & MAP_ATTRIB) {
|
|
|
|
t->current_space = as_attr;
|
|
|
|
} else {
|
|
|
|
t->current_space = as_comm;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Set address
|
|
|
|
*/
|
|
|
|
addr = t->mapaddr + (mem->card_start & M32R_PCC_MAPMASK);
|
|
|
|
mem->static_start = addr + mem->card_start;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
} /* _set_mem_map */
|
|
|
|
|
|
|
|
#if 0 /* driver model ordering issue */
|
|
|
|
/*======================================================================
|
|
|
|
|
|
|
|
Routines for accessing socket information and register dumps via
|
|
|
|
/proc/bus/pccard/...
|
|
|
|
|
|
|
|
======================================================================*/
|
|
|
|
|
|
|
|
static ssize_t show_info(struct class_device *class_dev, char *buf)
|
|
|
|
{
|
|
|
|
pcc_socket_t *s = container_of(class_dev, struct pcc_socket,
|
|
|
|
socket.dev);
|
|
|
|
|
|
|
|
return sprintf(buf, "type: %s\nbase addr: 0x%08lx\n",
|
|
|
|
pcc[s->type].name, s->base);
|
|
|
|
}
|
|
|
|
|
|
|
|
static ssize_t show_exca(struct class_device *class_dev, char *buf)
|
|
|
|
{
|
|
|
|
/* FIXME */
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static CLASS_DEVICE_ATTR(info, S_IRUGO, show_info, NULL);
|
|
|
|
static CLASS_DEVICE_ATTR(exca, S_IRUGO, show_exca, NULL);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/*====================================================================*/
|
|
|
|
|
|
|
|
/* this is horribly ugly... proper locking needs to be done here at
|
|
|
|
* some time... */
|
|
|
|
#define LOCKED(x) do { \
|
|
|
|
int retval; \
|
|
|
|
unsigned long flags; \
|
|
|
|
spin_lock_irqsave(&pcc_lock, flags); \
|
|
|
|
retval = x; \
|
|
|
|
spin_unlock_irqrestore(&pcc_lock, flags); \
|
|
|
|
return retval; \
|
|
|
|
} while (0)
|
|
|
|
|
|
|
|
|
|
|
|
static int pcc_get_status(struct pcmcia_socket *s, u_int *value)
|
|
|
|
{
|
|
|
|
unsigned int sock = container_of(s, struct pcc_socket, socket)->number;
|
|
|
|
|
|
|
|
if (socket[sock].flags & IS_ALIVE) {
|
2009-10-23 10:56:46 +00:00
|
|
|
dev_dbg(&s->dev, "pcc_get_status: sock(%d) -EINVAL\n", sock);
|
2005-04-16 22:20:36 +00:00
|
|
|
*value = 0;
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
2009-10-23 10:56:46 +00:00
|
|
|
dev_dbg(&s->dev, "pcc_get_status: sock(%d)\n", sock);
|
2005-04-16 22:20:36 +00:00
|
|
|
LOCKED(_pcc_get_status(sock, value));
|
|
|
|
}
|
|
|
|
|
|
|
|
static int pcc_set_socket(struct pcmcia_socket *s, socket_state_t *state)
|
|
|
|
{
|
|
|
|
unsigned int sock = container_of(s, struct pcc_socket, socket)->number;
|
|
|
|
|
|
|
|
if (socket[sock].flags & IS_ALIVE) {
|
2009-10-23 10:56:46 +00:00
|
|
|
dev_dbg(&s->dev, "pcc_set_socket: sock(%d) -EINVAL\n", sock);
|
2005-04-16 22:20:36 +00:00
|
|
|
return -EINVAL;
|
|
|
|
}
|
2009-10-23 10:56:46 +00:00
|
|
|
dev_dbg(&s->dev, "pcc_set_socket: sock(%d)\n", sock);
|
2005-04-16 22:20:36 +00:00
|
|
|
LOCKED(_pcc_set_socket(sock, state));
|
|
|
|
}
|
|
|
|
|
|
|
|
static int pcc_set_io_map(struct pcmcia_socket *s, struct pccard_io_map *io)
|
|
|
|
{
|
|
|
|
unsigned int sock = container_of(s, struct pcc_socket, socket)->number;
|
|
|
|
|
|
|
|
if (socket[sock].flags & IS_ALIVE) {
|
2009-10-23 10:56:46 +00:00
|
|
|
dev_dbg(&s->dev, "pcc_set_io_map: sock(%d) -EINVAL\n", sock);
|
2005-04-16 22:20:36 +00:00
|
|
|
return -EINVAL;
|
|
|
|
}
|
2009-10-23 10:56:46 +00:00
|
|
|
dev_dbg(&s->dev, "pcc_set_io_map: sock(%d)\n", sock);
|
2005-04-16 22:20:36 +00:00
|
|
|
LOCKED(_pcc_set_io_map(sock, io));
|
|
|
|
}
|
|
|
|
|
|
|
|
static int pcc_set_mem_map(struct pcmcia_socket *s, struct pccard_mem_map *mem)
|
|
|
|
{
|
|
|
|
unsigned int sock = container_of(s, struct pcc_socket, socket)->number;
|
|
|
|
|
|
|
|
if (socket[sock].flags & IS_ALIVE) {
|
2009-10-23 10:56:46 +00:00
|
|
|
dev_dbg(&s->dev, "pcc_set_mem_map: sock(%d) -EINVAL\n", sock);
|
2005-04-16 22:20:36 +00:00
|
|
|
return -EINVAL;
|
|
|
|
}
|
2009-10-23 10:56:46 +00:00
|
|
|
dev_dbg(&s->dev, "pcc_set_mem_map: sock(%d)\n", sock);
|
2005-04-16 22:20:36 +00:00
|
|
|
LOCKED(_pcc_set_mem_map(sock, mem));
|
|
|
|
}
|
|
|
|
|
|
|
|
static int pcc_init(struct pcmcia_socket *s)
|
|
|
|
{
|
2009-10-23 10:56:46 +00:00
|
|
|
dev_dbg(&s->dev, "pcc_init()\n");
|
2005-04-16 22:20:36 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static struct pccard_operations pcc_operations = {
|
|
|
|
.init = pcc_init,
|
|
|
|
.get_status = pcc_get_status,
|
|
|
|
.set_socket = pcc_set_socket,
|
|
|
|
.set_io_map = pcc_set_io_map,
|
|
|
|
.set_mem_map = pcc_set_mem_map,
|
|
|
|
};
|
|
|
|
|
2009-02-06 15:40:12 +00:00
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
/*====================================================================*/
|
|
|
|
|
2009-02-06 15:40:12 +00:00
|
|
|
static struct platform_driver pcc_driver = {
|
|
|
|
.driver = {
|
|
|
|
.name = "cfc",
|
|
|
|
},
|
2005-04-16 22:20:36 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
static struct platform_device pcc_device = {
|
|
|
|
.name = "cfc",
|
|
|
|
.id = 0,
|
|
|
|
};
|
|
|
|
|
|
|
|
/*====================================================================*/
|
|
|
|
|
|
|
|
static int __init init_m32r_pcc(void)
|
|
|
|
{
|
|
|
|
int i, ret;
|
|
|
|
|
2009-02-06 15:40:12 +00:00
|
|
|
ret = platform_driver_register(&pcc_driver);
|
2005-04-16 22:20:36 +00:00
|
|
|
if (ret)
|
|
|
|
return ret;
|
|
|
|
|
|
|
|
ret = platform_device_register(&pcc_device);
|
|
|
|
if (ret){
|
2009-02-06 15:40:12 +00:00
|
|
|
platform_driver_unregister(&pcc_driver);
|
2005-04-16 22:20:36 +00:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2005-06-22 00:16:14 +00:00
|
|
|
#if defined(CONFIG_PLAT_MAPPI2) || defined(CONFIG_PLAT_MAPPI3)
|
2005-04-16 22:20:36 +00:00
|
|
|
pcc_set(0, (unsigned int)PLD_CFCR0, 0x0f0f);
|
|
|
|
pcc_set(0, (unsigned int)PLD_CFCR1, 0x0200);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
pcc_sockets = 0;
|
|
|
|
|
|
|
|
#if !defined(CONFIG_PLAT_USRV)
|
|
|
|
add_pcc_socket(M32R_PCC0_BASE, PLD_IRQ_CFC_INSERT, CFC_ATTR_MAPBASE,
|
|
|
|
CFC_IOPORT_BASE);
|
|
|
|
#else /* CONFIG_PLAT_USRV */
|
|
|
|
{
|
|
|
|
ulong base, mapaddr;
|
2008-02-05 06:27:35 +00:00
|
|
|
unsigned int ioaddr;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
for (i = 0 ; i < M32R_MAX_PCC ; i++) {
|
|
|
|
base = (ulong)PLD_CFRSTCR;
|
|
|
|
base = base | (i << 8);
|
|
|
|
ioaddr = (i + 1) << 12;
|
|
|
|
mapaddr = CFC_ATTR_MAPBASE | (i << 20);
|
|
|
|
add_pcc_socket(base, 0, mapaddr, ioaddr);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif /* CONFIG_PLAT_USRV */
|
|
|
|
|
|
|
|
if (pcc_sockets == 0) {
|
|
|
|
printk("socket is not found.\n");
|
|
|
|
platform_device_unregister(&pcc_device);
|
2009-02-06 15:40:12 +00:00
|
|
|
platform_driver_unregister(&pcc_driver);
|
2005-04-16 22:20:36 +00:00
|
|
|
return -ENODEV;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Set up interrupt handler(s) */
|
|
|
|
|
|
|
|
for (i = 0 ; i < pcc_sockets ; i++) {
|
2007-02-21 13:47:20 +00:00
|
|
|
socket[i].socket.dev.parent = &pcc_device.dev;
|
2005-04-16 22:20:36 +00:00
|
|
|
socket[i].socket.ops = &pcc_operations;
|
2010-01-06 11:18:13 +00:00
|
|
|
socket[i].socket.resource_ops = &pccard_static_ops;
|
2005-04-16 22:20:36 +00:00
|
|
|
socket[i].socket.owner = THIS_MODULE;
|
|
|
|
socket[i].number = i;
|
|
|
|
ret = pcmcia_register_socket(&socket[i].socket);
|
|
|
|
if (!ret)
|
|
|
|
socket[i].flags |= IS_REGISTERED;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Finally, schedule a polling interrupt */
|
|
|
|
if (poll_interval != 0) {
|
|
|
|
poll_timer.function = pcc_interrupt_wrapper;
|
|
|
|
poll_timer.data = 0;
|
|
|
|
init_timer(&poll_timer);
|
|
|
|
poll_timer.expires = jiffies + poll_interval;
|
|
|
|
add_timer(&poll_timer);
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
} /* init_m32r_pcc */
|
|
|
|
|
|
|
|
static void __exit exit_m32r_pcc(void)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i = 0; i < pcc_sockets; i++)
|
|
|
|
if (socket[i].flags & IS_REGISTERED)
|
|
|
|
pcmcia_unregister_socket(&socket[i].socket);
|
|
|
|
|
|
|
|
platform_device_unregister(&pcc_device);
|
|
|
|
if (poll_interval != 0)
|
|
|
|
del_timer_sync(&poll_timer);
|
|
|
|
|
2009-02-06 15:40:12 +00:00
|
|
|
platform_driver_unregister(&pcc_driver);
|
2005-04-16 22:20:36 +00:00
|
|
|
} /* exit_m32r_pcc */
|
|
|
|
|
|
|
|
module_init(init_m32r_pcc);
|
|
|
|
module_exit(exit_m32r_pcc);
|
|
|
|
MODULE_LICENSE("Dual MPL/GPL");
|
|
|
|
/*====================================================================*/
|