2 * drivers/pcmcia/m32r_cfc.c
4 * Device driver for the CFC functionality of M32R.
6 * Copyright (c) 2001, 2002, 2003, 2004
7 * Hiroyuki Kondo, Naoto Sugai, Hayato Fujiwara
10 #include <linux/module.h>
11 #include <linux/moduleparam.h>
12 #include <linux/init.h>
13 #include <linux/types.h>
14 #include <linux/fcntl.h>
15 #include <linux/string.h>
16 #include <linux/kernel.h>
17 #include <linux/errno.h>
18 #include <linux/timer.h>
19 #include <linux/slab.h>
20 #include <linux/ioport.h>
21 #include <linux/delay.h>
22 #include <linux/workqueue.h>
23 #include <linux/interrupt.h>
24 #include <linux/platform_device.h>
25 #include <linux/bitops.h>
28 #include <asm/system.h>
30 #include <pcmcia/cs_types.h>
31 #include <pcmcia/ss.h>
32 #include <pcmcia/cs.h>
34 #undef MAX_IO_WIN /* FIXME */
36 #undef MAX_WIN /* FIXME */
41 #ifdef CONFIG_PCMCIA_DEBUG
42 static int m32r_cfc_debug
;
43 module_param(m32r_cfc_debug
, int, 0644);
44 #define debug(lvl, fmt, arg...) do { \
45 if (m32r_cfc_debug > (lvl)) \
46 printk(KERN_DEBUG "m32r_cfc: " fmt , ## arg); \
49 #define debug(n, args...) do { } while (0)
52 /* Poll status interval -- 0 means default to interrupt */
53 static int poll_interval
= 0;
55 typedef enum pcc_space
{ as_none
= 0, as_comm
, as_attr
, as_io
} pcc_as_t
;
57 typedef struct pcc_socket
{
59 struct pcmcia_socket socket
;
63 u_long base
; /* PCC register base */
64 u_char cs_irq1
, cs_irq2
, intr
;
65 pccard_io_map io_map
[MAX_IO_WIN
];
66 pccard_mem_map mem_map
[MAX_WIN
];
69 pcc_as_t current_space
;
72 struct proc_dir_entry
*proc
;
76 static int pcc_sockets
= 0;
77 static pcc_socket_t socket
[M32R_MAX_PCC
] = {
81 /*====================================================================*/
83 static unsigned int pcc_get(u_short
, unsigned int);
84 static void pcc_set(u_short
, unsigned int , unsigned int );
86 static DEFINE_SPINLOCK(pcc_lock
);
88 #if !defined(CONFIG_PLAT_USRV)
89 static inline u_long
pcc_port2addr(unsigned long port
, int size
) {
93 if (size
== 1) { /* byte access */
96 addr
= CFC_IO_MAPBASE_BYTE
- CFC_IOPORT_BASE
+ odd
+ port
;
98 addr
= CFC_IO_MAPBASE_WORD
- CFC_IOPORT_BASE
+ port
;
102 #else /* CONFIG_PLAT_USRV */
103 static inline u_long
pcc_port2addr(unsigned long port
, int size
) {
105 u_long addr
= ((port
- CFC_IOPORT_BASE
) & 0xf000) << 8;
107 if (size
== 1) { /* byte access */
111 addr
= (addr
| CFC_IO_MAPBASE_BYTE
) + odd
+ (port
& 0xfff);
112 } else if (size
== 2) /* word access */
113 addr
= (addr
| CFC_IO_MAPBASE_WORD
) + (port
& 0xfff);
117 #endif /* CONFIG_PLAT_USRV */
119 void pcc_ioread_byte(int sock
, unsigned long port
, void *buf
, size_t size
,
120 size_t nmemb
, int flag
)
123 unsigned char *bp
= (unsigned char *)buf
;
126 debug(3, "m32r_cfc: pcc_ioread_byte: sock=%d, port=%#lx, buf=%p, "
127 "size=%u, nmemb=%d, flag=%d\n",
128 sock
, port
, buf
, size
, nmemb
, flag
);
130 addr
= pcc_port2addr(port
, 1);
132 printk("m32r_cfc:ioread_byte null port :%#lx\n",port
);
135 debug(3, "m32r_cfc: pcc_ioread_byte: addr=%#lx\n", addr
);
137 spin_lock_irqsave(&pcc_lock
, flags
);
141 spin_unlock_irqrestore(&pcc_lock
, flags
);
144 void pcc_ioread_word(int sock
, unsigned long port
, void *buf
, size_t size
,
145 size_t nmemb
, int flag
)
148 unsigned short *bp
= (unsigned short *)buf
;
151 debug(3, "m32r_cfc: pcc_ioread_word: sock=%d, port=%#lx, "
152 "buf=%p, size=%u, nmemb=%d, flag=%d\n",
153 sock
, port
, buf
, size
, nmemb
, flag
);
156 printk("m32r_cfc: ioread_word :illigal size %u : %#lx\n", size
,
159 printk("m32r_cfc: ioread_word :insw \n");
161 addr
= pcc_port2addr(port
, 2);
163 printk("m32r_cfc:ioread_word null port :%#lx\n",port
);
166 debug(3, "m32r_cfc: pcc_ioread_word: addr=%#lx\n", addr
);
168 spin_lock_irqsave(&pcc_lock
, flags
);
172 spin_unlock_irqrestore(&pcc_lock
, flags
);
175 void pcc_iowrite_byte(int sock
, unsigned long port
, void *buf
, size_t size
,
176 size_t nmemb
, int flag
)
179 unsigned char *bp
= (unsigned char *)buf
;
182 debug(3, "m32r_cfc: pcc_iowrite_byte: sock=%d, port=%#lx, "
183 "buf=%p, size=%u, nmemb=%d, flag=%d\n",
184 sock
, port
, buf
, size
, nmemb
, flag
);
187 addr
= pcc_port2addr(port
, 1);
189 printk("m32r_cfc:iowrite_byte null port:%#lx\n",port
);
192 debug(3, "m32r_cfc: pcc_iowrite_byte: addr=%#lx\n", addr
);
194 spin_lock_irqsave(&pcc_lock
, flags
);
197 spin_unlock_irqrestore(&pcc_lock
, flags
);
200 void pcc_iowrite_word(int sock
, unsigned long port
, void *buf
, size_t size
,
201 size_t nmemb
, int flag
)
204 unsigned short *bp
= (unsigned short *)buf
;
207 debug(3, "m32r_cfc: pcc_iowrite_word: sock=%d, port=%#lx, "
208 "buf=%p, size=%u, nmemb=%d, flag=%d\n",
209 sock
, port
, buf
, size
, nmemb
, flag
);
212 printk("m32r_cfc: iowrite_word :illigal size %u : %#lx\n",
215 printk("m32r_cfc: iowrite_word :outsw \n");
217 addr
= pcc_port2addr(port
, 2);
219 printk("m32r_cfc:iowrite_word null addr :%#lx\n",port
);
224 printk("m32r_cfc:iowrite_word port addr (%#lx):%#lx\n", port
,
229 debug(3, "m32r_cfc: pcc_iowrite_word: addr=%#lx\n", addr
);
231 spin_lock_irqsave(&pcc_lock
, flags
);
234 spin_unlock_irqrestore(&pcc_lock
, flags
);
237 /*====================================================================*/
239 #define IS_REGISTERED 0x2000
240 #define IS_ALIVE 0x8000
242 typedef struct pcc_t
{
247 static pcc_t pcc
[] = {
248 #if !defined(CONFIG_PLAT_USRV)
249 { "m32r_cfc", 0 }, { "", 0 },
250 #else /* CONFIG_PLAT_USRV */
251 { "m32r_cfc", 0 }, { "m32r_cfc", 0 }, { "m32r_cfc", 0 },
252 { "m32r_cfc", 0 }, { "m32r_cfc", 0 }, { "", 0 },
253 #endif /* CONFIG_PLAT_USRV */
256 static irqreturn_t
pcc_interrupt(int, void *);
258 /*====================================================================*/
260 static struct timer_list poll_timer
;
262 static unsigned int pcc_get(u_short sock
, unsigned int reg
)
264 unsigned int val
= inw(reg
);
265 debug(3, "m32r_cfc: pcc_get: reg(0x%08x)=0x%04x\n", reg
, val
);
270 static void pcc_set(u_short sock
, unsigned int reg
, unsigned int data
)
273 debug(3, "m32r_cfc: pcc_set: reg(0x%08x)=0x%04x\n", reg
, data
);
276 /*======================================================================
278 See if a card is present, powered up, in IO mode, and already
279 bound to a (non PC Card) Linux driver. We leave these alone.
281 We make an exception for cards that seem to be serial devices.
283 ======================================================================*/
285 static int __init
is_alive(u_short sock
)
289 debug(3, "m32r_cfc: is_alive:\n");
292 stat
= pcc_get(sock
, (unsigned int)PLD_CFSTS
);
295 printk("Card is detected at socket %d : stat = 0x%08x\n", sock
, stat
);
296 debug(3, "m32r_cfc: is_alive: sock stat is 0x%04x\n", stat
);
301 static void add_pcc_socket(ulong base
, int irq
, ulong mapaddr
,
304 pcc_socket_t
*t
= &socket
[pcc_sockets
];
306 debug(3, "m32r_cfc: add_pcc_socket: base=%#lx, irq=%d, "
307 "mapaddr=%#lx, ioaddr=%08x\n",
308 base
, irq
, mapaddr
, ioaddr
);
312 t
->mapaddr
= mapaddr
;
313 #if !defined(CONFIG_PLAT_USRV)
316 t
->cs_irq1
= irq
; // insert irq
317 t
->cs_irq2
= irq
+ 1; // eject irq
318 #else /* CONFIG_PLAT_USRV */
321 t
->cs_irq1
= 0; // insert irq
322 t
->cs_irq2
= 0; // eject irq
323 #endif /* CONFIG_PLAT_USRV */
325 if (is_alive(pcc_sockets
))
326 t
->flags
|= IS_ALIVE
;
329 #if !defined(CONFIG_PLAT_USRV)
330 request_region((unsigned int)PLD_CFRSTCR
, 0x20, "m32r_cfc");
331 #else /* CONFIG_PLAT_USRV */
333 unsigned int reg_base
;
335 reg_base
= (unsigned int)PLD_CFRSTCR
;
336 reg_base
|= pcc_sockets
<< 8;
337 request_region(reg_base
, 0x20, "m32r_cfc");
339 #endif /* CONFIG_PLAT_USRV */
340 printk(KERN_INFO
" %s ", pcc
[pcc_sockets
].name
);
341 printk("pcc at 0x%08lx\n", t
->base
);
343 /* Update socket interrupt information, capabilities */
344 t
->socket
.features
|= (SS_CAP_PCCARD
| SS_CAP_STATIC_MAP
);
345 t
->socket
.map_size
= M32R_PCC_MAPSIZE
;
346 t
->socket
.io_offset
= ioaddr
; /* use for io access offset */
347 t
->socket
.irq_mask
= 0;
348 #if !defined(CONFIG_PLAT_USRV)
349 t
->socket
.pci_irq
= PLD_IRQ_CFIREQ
; /* card interrupt */
350 #else /* CONFIG_PLAT_USRV */
351 t
->socket
.pci_irq
= PLD_IRQ_CF0
+ pcc_sockets
;
352 #endif /* CONFIG_PLAT_USRV */
354 #ifndef CONFIG_PLAT_USRV
355 /* insert interrupt */
356 request_irq(irq
, pcc_interrupt
, 0, "m32r_cfc", pcc_interrupt
);
357 #ifndef CONFIG_PLAT_MAPPI3
358 /* eject interrupt */
359 request_irq(irq
+1, pcc_interrupt
, 0, "m32r_cfc", pcc_interrupt
);
361 debug(3, "m32r_cfc: enable CFMSK, RDYSEL\n");
362 pcc_set(pcc_sockets
, (unsigned int)PLD_CFIMASK
, 0x01);
363 #endif /* CONFIG_PLAT_USRV */
364 #if defined(CONFIG_PLAT_M32700UT) || defined(CONFIG_PLAT_USRV) || defined(CONFIG_PLAT_OPSPUT)
365 pcc_set(pcc_sockets
, (unsigned int)PLD_CFCR1
, 0x0200);
373 /*====================================================================*/
375 static irqreturn_t
pcc_interrupt(int irq
, void *dev
)
381 debug(3, "m32r_cfc: pcc_interrupt: irq=%d, dev=%p\n", irq
, dev
);
382 for (i
= 0; i
< pcc_sockets
; i
++) {
383 if (socket
[i
].cs_irq1
!= irq
&& socket
[i
].cs_irq2
!= irq
)
387 debug(3, "m32r_cfc: pcc_interrupt: socket %d irq 0x%02x ",
389 events
|= SS_DETECT
; /* insert or eject */
391 pcmcia_parse_events(&socket
[i
].socket
, events
);
393 debug(3, "m32r_cfc: pcc_interrupt: done\n");
395 return IRQ_RETVAL(handled
);
396 } /* pcc_interrupt */
398 static void pcc_interrupt_wrapper(u_long data
)
400 debug(3, "m32r_cfc: pcc_interrupt_wrapper:\n");
401 pcc_interrupt(0, NULL
);
402 init_timer(&poll_timer
);
403 poll_timer
.expires
= jiffies
+ poll_interval
;
404 add_timer(&poll_timer
);
407 /*====================================================================*/
409 static int _pcc_get_status(u_short sock
, u_int
*value
)
413 debug(3, "m32r_cfc: _pcc_get_status:\n");
414 status
= pcc_get(sock
, (unsigned int)PLD_CFSTS
);
415 *value
= (status
) ? SS_DETECT
: 0;
416 debug(3, "m32r_cfc: _pcc_get_status: status=0x%08x\n", status
);
418 #if defined(CONFIG_PLAT_M32700UT) || defined(CONFIG_PLAT_USRV) || defined(CONFIG_PLAT_OPSPUT)
420 /* enable CF power */
421 status
= inw((unsigned int)PLD_CPCR
);
422 if (!(status
& PLD_CPCR_CF
)) {
423 debug(3, "m32r_cfc: _pcc_get_status: "
424 "power on (CPCR=0x%08x)\n", status
);
425 status
|= PLD_CPCR_CF
;
426 outw(status
, (unsigned int)PLD_CPCR
);
429 *value
|= SS_POWERON
;
431 pcc_set(sock
, (unsigned int)PLD_CFBUFCR
,0);/* enable buffer */
434 *value
|= SS_READY
; /* always ready */
437 /* disable CF power */
438 status
= inw((unsigned int)PLD_CPCR
);
439 status
&= ~PLD_CPCR_CF
;
440 outw(status
, (unsigned int)PLD_CPCR
);
442 debug(3, "m32r_cfc: _pcc_get_status: "
443 "power off (CPCR=0x%08x)\n", status
);
445 #elif defined(CONFIG_PLAT_MAPPI2) || defined(CONFIG_PLAT_MAPPI3)
447 status
= pcc_get(sock
, (unsigned int)PLD_CPCR
);
448 if (status
== 0) { /* power off */
449 pcc_set(sock
, (unsigned int)PLD_CPCR
, 1);
450 pcc_set(sock
, (unsigned int)PLD_CFBUFCR
,0); /* force buffer off for ZA-36 */
453 *value
|= SS_POWERON
;
455 pcc_set(sock
, (unsigned int)PLD_CFBUFCR
,0);
457 pcc_set(sock
, (unsigned int)PLD_CFRSTCR
, 0x0101);
458 udelay(25); /* for IDE reset */
459 pcc_set(sock
, (unsigned int)PLD_CFRSTCR
, 0x0100);
460 mdelay(2); /* for IDE reset */
465 /* disable CF power */
466 pcc_set(sock
, (unsigned int)PLD_CPCR
, 0);
468 debug(3, "m32r_cfc: _pcc_get_status: "
469 "power off (CPCR=0x%08x)\n", status
);
472 #error no platform configuration
474 debug(3, "m32r_cfc: _pcc_get_status: GetStatus(%d) = %#4.4x\n",
479 /*====================================================================*/
481 static int _pcc_set_socket(u_short sock
, socket_state_t
*state
)
483 debug(3, "m32r_cfc: SetSocket(%d, flags %#3.3x, Vcc %d, Vpp %d, "
484 "io_irq %d, csc_mask %#2.2x)\n", sock
, state
->flags
,
485 state
->Vcc
, state
->Vpp
, state
->io_irq
, state
->csc_mask
);
487 #if defined(CONFIG_PLAT_M32700UT) || defined(CONFIG_PLAT_USRV) || defined(CONFIG_PLAT_OPSPUT) || defined(CONFIG_PLAT_MAPPI2) || defined(CONFIG_PLAT_MAPPI3)
489 if ((state
->Vcc
!= 50) && (state
->Vcc
!= 33))
491 /* accept 5V and 3.3V */
494 if (state
->flags
& SS_RESET
) {
495 debug(3, ":RESET\n");
496 pcc_set(sock
,(unsigned int)PLD_CFRSTCR
,0x101);
498 pcc_set(sock
,(unsigned int)PLD_CFRSTCR
,0x100);
500 if (state
->flags
& SS_OUTPUT_ENA
){
501 debug(3, ":OUTPUT_ENA\n");
503 pcc_set(sock
,(unsigned int)PLD_CFBUFCR
,0);
505 pcc_set(sock
,(unsigned int)PLD_CFBUFCR
,1);
508 #ifdef CONFIG_PCMCIA_DEBUG
509 if(state
->flags
& SS_IOCARD
){
512 if (state
->flags
& SS_PWR_AUTO
) {
513 debug(3, ":PWR_AUTO");
515 if (state
->csc_mask
& SS_DETECT
)
516 debug(3, ":csc-SS_DETECT");
517 if (state
->flags
& SS_IOCARD
) {
518 if (state
->csc_mask
& SS_STSCHG
)
521 if (state
->csc_mask
& SS_BATDEAD
)
522 debug(3, ":BATDEAD");
523 if (state
->csc_mask
& SS_BATWARN
)
524 debug(3, ":BATWARN");
525 if (state
->csc_mask
& SS_READY
)
533 /*====================================================================*/
535 static int _pcc_set_io_map(u_short sock
, struct pccard_io_map
*io
)
539 debug(3, "m32r_cfc: SetIOMap(%d, %d, %#2.2x, %d ns, "
540 "%#llx-%#llx)\n", sock
, io
->map
, io
->flags
,
541 io
->speed
, (unsigned long long)io
->start
,
542 (unsigned long long)io
->stop
);
548 /*====================================================================*/
550 static int _pcc_set_mem_map(u_short sock
, struct pccard_mem_map
*mem
)
553 u_char map
= mem
->map
;
555 pcc_socket_t
*t
= &socket
[sock
];
557 debug(3, "m32r_cfc: SetMemMap(%d, %d, %#2.2x, %d ns, "
558 "%#llx, %#x)\n", sock
, map
, mem
->flags
,
559 mem
->speed
, (unsigned long long)mem
->static_start
,
565 if ((map
> MAX_WIN
) || (mem
->card_start
> 0x3ffffff)){
572 if ((mem
->flags
& MAP_ACTIVE
) == 0) {
573 t
->current_space
= as_none
;
580 if (mem
->flags
& MAP_ATTRIB
) {
581 t
->current_space
= as_attr
;
583 t
->current_space
= as_comm
;
589 addr
= t
->mapaddr
+ (mem
->card_start
& M32R_PCC_MAPMASK
);
590 mem
->static_start
= addr
+ mem
->card_start
;
596 #if 0 /* driver model ordering issue */
597 /*======================================================================
599 Routines for accessing socket information and register dumps via
602 ======================================================================*/
604 static ssize_t
show_info(struct class_device
*class_dev
, char *buf
)
606 pcc_socket_t
*s
= container_of(class_dev
, struct pcc_socket
,
609 return sprintf(buf
, "type: %s\nbase addr: 0x%08lx\n",
610 pcc
[s
->type
].name
, s
->base
);
613 static ssize_t
show_exca(struct class_device
*class_dev
, char *buf
)
620 static CLASS_DEVICE_ATTR(info
, S_IRUGO
, show_info
, NULL
);
621 static CLASS_DEVICE_ATTR(exca
, S_IRUGO
, show_exca
, NULL
);
624 /*====================================================================*/
626 /* this is horribly ugly... proper locking needs to be done here at
628 #define LOCKED(x) do { \
630 unsigned long flags; \
631 spin_lock_irqsave(&pcc_lock, flags); \
633 spin_unlock_irqrestore(&pcc_lock, flags); \
638 static int pcc_get_status(struct pcmcia_socket
*s
, u_int
*value
)
640 unsigned int sock
= container_of(s
, struct pcc_socket
, socket
)->number
;
642 if (socket
[sock
].flags
& IS_ALIVE
) {
643 debug(3, "m32r_cfc: pcc_get_status: sock(%d) -EINVAL\n", sock
);
647 debug(3, "m32r_cfc: pcc_get_status: sock(%d)\n", sock
);
648 LOCKED(_pcc_get_status(sock
, value
));
651 static int pcc_set_socket(struct pcmcia_socket
*s
, socket_state_t
*state
)
653 unsigned int sock
= container_of(s
, struct pcc_socket
, socket
)->number
;
655 if (socket
[sock
].flags
& IS_ALIVE
) {
656 debug(3, "m32r_cfc: pcc_set_socket: sock(%d) -EINVAL\n", sock
);
659 debug(3, "m32r_cfc: pcc_set_socket: sock(%d)\n", sock
);
660 LOCKED(_pcc_set_socket(sock
, state
));
663 static int pcc_set_io_map(struct pcmcia_socket
*s
, struct pccard_io_map
*io
)
665 unsigned int sock
= container_of(s
, struct pcc_socket
, socket
)->number
;
667 if (socket
[sock
].flags
& IS_ALIVE
) {
668 debug(3, "m32r_cfc: pcc_set_io_map: sock(%d) -EINVAL\n", sock
);
671 debug(3, "m32r_cfc: pcc_set_io_map: sock(%d)\n", sock
);
672 LOCKED(_pcc_set_io_map(sock
, io
));
675 static int pcc_set_mem_map(struct pcmcia_socket
*s
, struct pccard_mem_map
*mem
)
677 unsigned int sock
= container_of(s
, struct pcc_socket
, socket
)->number
;
679 if (socket
[sock
].flags
& IS_ALIVE
) {
680 debug(3, "m32r_cfc: pcc_set_mem_map: sock(%d) -EINVAL\n", sock
);
683 debug(3, "m32r_cfc: pcc_set_mem_map: sock(%d)\n", sock
);
684 LOCKED(_pcc_set_mem_map(sock
, mem
));
687 static int pcc_init(struct pcmcia_socket
*s
)
689 debug(3, "m32r_cfc: pcc_init()\n");
693 static struct pccard_operations pcc_operations
= {
695 .get_status
= pcc_get_status
,
696 .set_socket
= pcc_set_socket
,
697 .set_io_map
= pcc_set_io_map
,
698 .set_mem_map
= pcc_set_mem_map
,
701 static int cfc_drv_pcmcia_suspend(struct platform_device
*dev
,
704 return pcmcia_socket_dev_suspend(&dev
->dev
);
707 static int cfc_drv_pcmcia_resume(struct platform_device
*dev
)
709 return pcmcia_socket_dev_resume(&dev
->dev
);
711 /*====================================================================*/
713 static struct platform_driver pcc_driver
= {
716 .owner
= THIS_MODULE
,
718 .suspend
= cfc_drv_pcmcia_suspend
,
719 .resume
= cfc_drv_pcmcia_resume
,
722 static struct platform_device pcc_device
= {
727 /*====================================================================*/
729 static int __init
init_m32r_pcc(void)
733 ret
= platform_driver_register(&pcc_driver
);
737 ret
= platform_device_register(&pcc_device
);
739 platform_driver_unregister(&pcc_driver
);
743 #if defined(CONFIG_PLAT_MAPPI2) || defined(CONFIG_PLAT_MAPPI3)
744 pcc_set(0, (unsigned int)PLD_CFCR0
, 0x0f0f);
745 pcc_set(0, (unsigned int)PLD_CFCR1
, 0x0200);
750 #if !defined(CONFIG_PLAT_USRV)
751 add_pcc_socket(M32R_PCC0_BASE
, PLD_IRQ_CFC_INSERT
, CFC_ATTR_MAPBASE
,
753 #else /* CONFIG_PLAT_USRV */
758 for (i
= 0 ; i
< M32R_MAX_PCC
; i
++) {
759 base
= (ulong
)PLD_CFRSTCR
;
760 base
= base
| (i
<< 8);
761 ioaddr
= (i
+ 1) << 12;
762 mapaddr
= CFC_ATTR_MAPBASE
| (i
<< 20);
763 add_pcc_socket(base
, 0, mapaddr
, ioaddr
);
766 #endif /* CONFIG_PLAT_USRV */
768 if (pcc_sockets
== 0) {
769 printk("socket is not found.\n");
770 platform_device_unregister(&pcc_device
);
771 platform_driver_unregister(&pcc_driver
);
775 /* Set up interrupt handler(s) */
777 for (i
= 0 ; i
< pcc_sockets
; i
++) {
778 socket
[i
].socket
.dev
.parent
= &pcc_device
.dev
;
779 socket
[i
].socket
.ops
= &pcc_operations
;
780 socket
[i
].socket
.resource_ops
= &pccard_nonstatic_ops
;
781 socket
[i
].socket
.owner
= THIS_MODULE
;
782 socket
[i
].number
= i
;
783 ret
= pcmcia_register_socket(&socket
[i
].socket
);
785 socket
[i
].flags
|= IS_REGISTERED
;
787 #if 0 /* driver model ordering issue */
788 class_device_create_file(&socket
[i
].socket
.dev
,
789 &class_device_attr_info
);
790 class_device_create_file(&socket
[i
].socket
.dev
,
791 &class_device_attr_exca
);
795 /* Finally, schedule a polling interrupt */
796 if (poll_interval
!= 0) {
797 poll_timer
.function
= pcc_interrupt_wrapper
;
799 init_timer(&poll_timer
);
800 poll_timer
.expires
= jiffies
+ poll_interval
;
801 add_timer(&poll_timer
);
805 } /* init_m32r_pcc */
807 static void __exit
exit_m32r_pcc(void)
811 for (i
= 0; i
< pcc_sockets
; i
++)
812 if (socket
[i
].flags
& IS_REGISTERED
)
813 pcmcia_unregister_socket(&socket
[i
].socket
);
815 platform_device_unregister(&pcc_device
);
816 if (poll_interval
!= 0)
817 del_timer_sync(&poll_timer
);
819 platform_driver_unregister(&pcc_driver
);
820 } /* exit_m32r_pcc */
822 module_init(init_m32r_pcc
);
823 module_exit(exit_m32r_pcc
);
824 MODULE_LICENSE("Dual MPL/GPL");
825 /*====================================================================*/