Blame view
drivers/pcmcia/m32r_pcc.c
16.4 KB
1da177e4c Linux-2.6.12-rc2 |
1 2 3 4 5 6 7 8 9 10 11 12 |
/* * drivers/pcmcia/m32r_pcc.c * * Device driver for the PCMCIA 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> |
1da177e4c Linux-2.6.12-rc2 |
13 14 15 16 17 18 |
#include <linux/types.h> #include <linux/fcntl.h> #include <linux/string.h> #include <linux/kernel.h> #include <linux/errno.h> #include <linux/timer.h> |
1da177e4c Linux-2.6.12-rc2 |
19 20 21 22 |
#include <linux/ioport.h> #include <linux/delay.h> #include <linux/workqueue.h> #include <linux/interrupt.h> |
d052d1bef Create platform_d... |
23 |
#include <linux/platform_device.h> |
1977f0327 remove asm/bitops... |
24 |
#include <linux/bitops.h> |
1da177e4c Linux-2.6.12-rc2 |
25 26 |
#include <asm/irq.h> #include <asm/io.h> |
1da177e4c Linux-2.6.12-rc2 |
27 |
#include <asm/addrspace.h> |
1da177e4c Linux-2.6.12-rc2 |
28 |
#include <pcmcia/ss.h> |
1da177e4c Linux-2.6.12-rc2 |
29 30 31 32 33 34 35 36 37 38 39 40 41 |
/* XXX: should be moved into asm/irq.h */ #define PCC0_IRQ 24 #define PCC1_IRQ 25 #include "m32r_pcc.h" #define CHAOS_PCC_DEBUG #ifdef CHAOS_PCC_DEBUG static volatile u_short dummy_readbuf; #endif #define PCC_DEBUG_DBEX |
1da177e4c Linux-2.6.12-rc2 |
42 43 44 45 46 47 48 49 50 51 |
/* 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; |
906da809c pcmcia: replace k... |
52 |
unsigned int ioaddr; |
1da177e4c Linux-2.6.12-rc2 |
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 |
u_long mapaddr; u_long base; /* PCC register base */ u_char cs_irq, 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 CHAOS_PCC_DEBUG u_char last_iosize; #endif #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); void pcc_iorw(int sock, unsigned long port, void *buf, size_t size, size_t nmemb, int wr, int flag) { u_long addr; u_long flags; int need_ex; #ifdef PCC_DEBUG_DBEX int _dbex; #endif pcc_socket_t *t = &socket[sock]; #ifdef CHAOS_PCC_DEBUG int map_changed = 0; #endif /* Need lock ? */ spin_lock_irqsave(&pcc_lock, flags); /* * Check if need dbex */ need_ex = (size > 1 && flag == 0) ? PCMOD_DBEX : 0; #ifdef PCC_DEBUG_DBEX _dbex = need_ex; need_ex = 0; #endif /* * calculate access address */ addr = t->mapaddr + port - t->ioaddr + KSEG1; /* XXX */ /* * Check current mapping */ if (t->current_space != as_io || t->last_iodbex != need_ex) { u_long cbsz; /* * Disable first */ pcc_set(sock, PCCR, 0); /* * Set mode and io address */ cbsz = (t->flags & MAP_16BIT) ? 0 : PCMOD_CBSZ; pcc_set(sock, PCMOD, PCMOD_AS_IO | cbsz | need_ex); pcc_set(sock, PCADR, addr & 0x1ff00000); /* * Enable and read it */ pcc_set(sock, PCCR, 1); #ifdef CHAOS_PCC_DEBUG #if 0 map_changed = (t->current_space == as_attr && size == 2); /* XXX */ #else map_changed = 1; #endif #endif t->current_space = as_io; } /* * access to IO space */ if (size == 1) { /* Byte */ unsigned char *bp = (unsigned char *)buf; #ifdef CHAOS_DEBUG if (map_changed) { dummy_readbuf = readb(addr); } #endif if (wr) { /* write Byte */ while (nmemb--) { writeb(*bp++, addr); } } else { /* read Byte */ while (nmemb--) { *bp++ = readb(addr); } } } else { /* Word */ unsigned short *bp = (unsigned short *)buf; #ifdef CHAOS_PCC_DEBUG if (map_changed) { dummy_readbuf = readw(addr); } #endif if (wr) { /* write Word */ while (nmemb--) { #ifdef PCC_DEBUG_DBEX if (_dbex) { unsigned char *cp = (unsigned char *)bp; unsigned short tmp; tmp = cp[1] << 8 | cp[0]; writew(tmp, addr); bp++; } else #endif writew(*bp++, addr); } } else { /* read Word */ while (nmemb--) { #ifdef PCC_DEBUG_DBEX if (_dbex) { unsigned char *cp = (unsigned char *)bp; unsigned short tmp; tmp = readw(addr); cp[0] = tmp & 0xff; cp[1] = (tmp >> 8) & 0xff; bp++; } else #endif *bp++ = readw(addr); } } } #if 1 /* addr is no longer used */ if ((addr = pcc_get(sock, PCIRC)) & PCIRC_BWERR) { printk("m32r_pcc: BWERR detected : port 0x%04lx : iosize %dbit ", port, size * 8); pcc_set(sock, PCIRC, addr); } #endif /* * save state */ t->last_iosize = size; t->last_iodbex = need_ex; /* Need lock ? */ spin_unlock_irqrestore(&pcc_lock,flags); return; } void pcc_ioread(int sock, unsigned long port, void *buf, size_t size, size_t nmemb, int flag) { pcc_iorw(sock, port, buf, size, nmemb, 0, flag); } void pcc_iowrite(int sock, unsigned long port, void *buf, size_t size, size_t nmemb, int flag) { pcc_iorw(sock, port, buf, size, nmemb, 1, flag); } /*====================================================================*/ #define IS_REGISTERED 0x2000 #define IS_ALIVE 0x8000 typedef struct pcc_t { char *name; u_short flags; } pcc_t; static pcc_t pcc[] = { { "xnux2", 0 }, { "xnux2", 0 }, }; |
7d12e780e IRQ: Maintain reg... |
253 |
static irqreturn_t pcc_interrupt(int, void *); |
1da177e4c Linux-2.6.12-rc2 |
254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 |
/*====================================================================*/ static struct timer_list poll_timer; static unsigned int pcc_get(u_short sock, unsigned int reg) { return inl(socket[sock].base + reg); } static void pcc_set(u_short sock, unsigned int reg, unsigned int data) { outl(data, socket[sock].base + reg); } /*====================================================================== 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; unsigned int f; stat = pcc_get(sock, PCIRC); f = (stat & (PCIRC_CDIN1 | PCIRC_CDIN2)) >> 16; if(!f){ printk("m32r_pcc: No Card is detected at socket %d : stat = 0x%08x ",stat,sock); return 0; } if(f!=3) printk("m32r_pcc: Insertion fail (%.8x) at socket %d ",stat,sock); else printk("m32r_pcc: Card is Inserted at socket %d(%.8x) ",sock,stat); return 0; } |
4170a20f2 drivers/pcmcia/m3... |
299 300 |
static int add_pcc_socket(ulong base, int irq, ulong mapaddr, unsigned int ioaddr) |
1da177e4c Linux-2.6.12-rc2 |
301 302 |
{ pcc_socket_t *t = &socket[pcc_sockets]; |
4170a20f2 drivers/pcmcia/m3... |
303 |
int err; |
1da177e4c Linux-2.6.12-rc2 |
304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 |
/* add sockets */ t->ioaddr = ioaddr; t->mapaddr = mapaddr; t->base = base; #ifdef CHAOS_PCC_DEBUG t->flags = MAP_16BIT; #else t->flags = 0; #endif if (is_alive(pcc_sockets)) t->flags |= IS_ALIVE; /* add pcc */ if (t->base > 0) { request_region(t->base, 0x20, "m32r-pcc"); } printk(KERN_INFO " %s ", pcc[pcc_sockets].name); printk("pcc at 0x%08lx ", 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; t->socket.pci_irq = 2 + pcc_sockets; /* XXX */ |
4170a20f2 drivers/pcmcia/m3... |
332 333 334 335 336 337 |
err = request_irq(irq, pcc_interrupt, 0, "m32r-pcc", pcc_interrupt); if (err) { if (t->base > 0) release_region(t->base, 0x20); return err; } |
1da177e4c Linux-2.6.12-rc2 |
338 339 |
pcc_sockets++; |
4170a20f2 drivers/pcmcia/m3... |
340 |
return 0; |
1da177e4c Linux-2.6.12-rc2 |
341 342 343 344 |
} /*====================================================================*/ |
7d12e780e IRQ: Maintain reg... |
345 |
static irqreturn_t pcc_interrupt(int irq, void *dev) |
1da177e4c Linux-2.6.12-rc2 |
346 347 348 349 |
{ int i, j, irc; u_int events, active; int handled = 0; |
c9f50dddd pcmcia: use dynam... |
350 351 |
pr_debug("m32r_pcc: pcc_interrupt(%d) ", irq); |
1da177e4c Linux-2.6.12-rc2 |
352 353 354 355 356 357 358 359 360 361 |
for (j = 0; j < 20; j++) { active = 0; for (i = 0; i < pcc_sockets; i++) { if ((socket[i].cs_irq != irq) && (socket[i].socket.pci_irq != irq)) continue; handled = 1; irc = pcc_get(i, PCIRC); irc >>=16; |
c9f50dddd pcmcia: use dynam... |
362 363 |
pr_debug("m32r_pcc: interrupt: socket %d pcirc 0x%02x ", i, irc); |
1da177e4c Linux-2.6.12-rc2 |
364 365 366 367 368 |
if (!irc) continue; events = (irc) ? SS_DETECT : 0; events |= (pcc_get(i,PCCR) & PCCR_PCEN) ? SS_READY : 0; |
c9f50dddd pcmcia: use dynam... |
369 370 |
pr_debug("m32r_pcc: event 0x%02x ", events); |
1da177e4c Linux-2.6.12-rc2 |
371 372 373 374 375 376 377 378 379 380 381 382 |
if (events) pcmcia_parse_events(&socket[i].socket, events); active |= events; active = 0; } if (!active) break; } if (j == 20) printk(KERN_NOTICE "m32r-pcc: infinite loop in interrupt handler "); |
c9f50dddd pcmcia: use dynam... |
383 384 |
pr_debug("m32r_pcc: interrupt done "); |
1da177e4c Linux-2.6.12-rc2 |
385 386 387 388 389 390 |
return IRQ_RETVAL(handled); } /* pcc_interrupt */ static void pcc_interrupt_wrapper(u_long data) { |
9c8e7f5cc [PATCH] m32r pt_r... |
391 |
pcc_interrupt(0, NULL); |
1da177e4c Linux-2.6.12-rc2 |
392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 |
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; status = pcc_get(sock,PCIRC); *value = ((status & PCIRC_CDIN1) && (status & PCIRC_CDIN2)) ? SS_DETECT : 0; status = pcc_get(sock,PCCR); #if 0 *value |= (status & PCCR_PCEN) ? SS_READY : 0; #else *value |= SS_READY; /* XXX: always */ #endif status = pcc_get(sock,PCCSIGCR); *value |= (status & PCCSIGCR_VEN) ? SS_POWERON : 0; |
c9f50dddd pcmcia: use dynam... |
417 418 |
pr_debug("m32r_pcc: GetStatus(%d) = %#4.4x ", sock, *value); |
1da177e4c Linux-2.6.12-rc2 |
419 420 421 422 |
return 0; } /* _get_status */ /*====================================================================*/ |
1da177e4c Linux-2.6.12-rc2 |
423 424 425 |
static int _pcc_set_socket(u_short sock, socket_state_t *state) { u_long reg = 0; |
c9f50dddd pcmcia: use dynam... |
426 |
pr_debug("m32r_pcc: SetSocket(%d, flags %#3.3x, Vcc %d, Vpp %d, " |
1da177e4c Linux-2.6.12-rc2 |
427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 |
"io_irq %d, csc_mask %#2.2x)", sock, state->flags, state->Vcc, state->Vpp, state->io_irq, state->csc_mask); if (state->Vcc) { /* * 5V only */ if (state->Vcc == 50) { reg |= PCCSIGCR_VEN; } else { return -EINVAL; } } if (state->flags & SS_RESET) { |
c9f50dddd pcmcia: use dynam... |
442 443 |
pr_debug("m32r_pcc: :RESET "); |
1da177e4c Linux-2.6.12-rc2 |
444 445 446 |
reg |= PCCSIGCR_CRST; } if (state->flags & SS_OUTPUT_ENA){ |
c9f50dddd pcmcia: use dynam... |
447 448 |
pr_debug("m32r_pcc: :OUTPUT_ENA "); |
1da177e4c Linux-2.6.12-rc2 |
449 450 451 452 453 454 |
/* bit clear */ } else { reg |= PCCSIGCR_SEN; } pcc_set(sock,PCCSIGCR,reg); |
1da177e4c Linux-2.6.12-rc2 |
455 |
if(state->flags & SS_IOCARD){ |
c9f50dddd pcmcia: use dynam... |
456 |
pr_debug("m32r_pcc: :IOCARD"); |
1da177e4c Linux-2.6.12-rc2 |
457 458 |
} if (state->flags & SS_PWR_AUTO) { |
c9f50dddd pcmcia: use dynam... |
459 |
pr_debug("m32r_pcc: :PWR_AUTO"); |
1da177e4c Linux-2.6.12-rc2 |
460 461 |
} if (state->csc_mask & SS_DETECT) |
c9f50dddd pcmcia: use dynam... |
462 |
pr_debug("m32r_pcc: :csc-SS_DETECT"); |
1da177e4c Linux-2.6.12-rc2 |
463 464 |
if (state->flags & SS_IOCARD) { if (state->csc_mask & SS_STSCHG) |
c9f50dddd pcmcia: use dynam... |
465 |
pr_debug("m32r_pcc: :STSCHG"); |
1da177e4c Linux-2.6.12-rc2 |
466 467 |
} else { if (state->csc_mask & SS_BATDEAD) |
c9f50dddd pcmcia: use dynam... |
468 |
pr_debug("m32r_pcc: :BATDEAD"); |
1da177e4c Linux-2.6.12-rc2 |
469 |
if (state->csc_mask & SS_BATWARN) |
c9f50dddd pcmcia: use dynam... |
470 |
pr_debug("m32r_pcc: :BATWARN"); |
1da177e4c Linux-2.6.12-rc2 |
471 |
if (state->csc_mask & SS_READY) |
c9f50dddd pcmcia: use dynam... |
472 |
pr_debug("m32r_pcc: :READY"); |
1da177e4c Linux-2.6.12-rc2 |
473 |
} |
c9f50dddd pcmcia: use dynam... |
474 475 |
pr_debug("m32r_pcc: "); |
1da177e4c Linux-2.6.12-rc2 |
476 477 478 479 480 481 482 483 |
return 0; } /* _set_socket */ /*====================================================================*/ static int _pcc_set_io_map(u_short sock, struct pccard_io_map *io) { u_char map; |
c9f50dddd pcmcia: use dynam... |
484 |
pr_debug("m32r_pcc: SetIOMap(%d, %d, %#2.2x, %d ns, " |
5f784336d pcmcia: Fix possi... |
485 486 487 488 |
"%#llx-%#llx) ", sock, io->map, io->flags, io->speed, (unsigned long long)io->start, (unsigned long long)io->stop); |
1da177e4c Linux-2.6.12-rc2 |
489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 |
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 mode; u_long addr; pcc_socket_t *t = &socket[sock]; #ifdef CHAOS_PCC_DEBUG #if 0 pcc_as_t last = t->current_space; #endif #endif |
c9f50dddd pcmcia: use dynam... |
508 |
pr_debug("m32r_pcc: SetMemMap(%d, %d, %#2.2x, %d ns, " |
5f784336d pcmcia: Fix possi... |
509 510 511 512 |
"%#llx, %#x) ", sock, map, mem->flags, mem->speed, (unsigned long long)mem->static_start, mem->card_start); |
1da177e4c Linux-2.6.12-rc2 |
513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 |
/* * 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; } /* * Disable first */ pcc_set(sock, PCCR, 0); /* * Set mode */ if (mem->flags & MAP_ATTRIB) { mode = PCMOD_AS_ATTRIB | PCMOD_CBSZ; t->current_space = as_attr; } else { mode = 0; /* common memory */ t->current_space = as_comm; } pcc_set(sock, PCMOD, mode); /* * Set address */ addr = t->mapaddr + (mem->card_start & M32R_PCC_MAPMASK); pcc_set(sock, PCADR, addr); mem->static_start = addr + mem->card_start; /* * Enable again */ pcc_set(sock, PCCR, 1); #ifdef CHAOS_PCC_DEBUG #if 0 if (last != as_attr) { #else if (1) { #endif dummy_readbuf = *(u_char *)(addr + KSEG1); } #endif 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 base addr: 0x%08lx ", 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) { *value = 0; return -EINVAL; } LOCKED(_pcc_get_status(sock, value)); } |
1da177e4c Linux-2.6.12-rc2 |
627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 |
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) return -EINVAL; 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) return -EINVAL; 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) return -EINVAL; LOCKED(_pcc_set_mem_map(sock, mem)); } static int pcc_init(struct pcmcia_socket *s) { |
c9f50dddd pcmcia: use dynam... |
657 658 |
pr_debug("m32r_pcc: init call "); |
1da177e4c Linux-2.6.12-rc2 |
659 660 661 662 663 664 |
return 0; } static struct pccard_operations pcc_operations = { .init = pcc_init, .get_status = pcc_get_status, |
1da177e4c Linux-2.6.12-rc2 |
665 666 667 668 669 670 |
.set_socket = pcc_set_socket, .set_io_map = pcc_set_io_map, .set_mem_map = pcc_set_mem_map, }; /*====================================================================*/ |
7a192ec33 platform driver: ... |
671 672 673 |
static struct platform_driver pcc_driver = { .driver = { .name = "pcc", |
7a192ec33 platform driver: ... |
674 |
}, |
1da177e4c Linux-2.6.12-rc2 |
675 676 677 678 679 680 681 682 683 684 685 686 |
}; static struct platform_device pcc_device = { .name = "pcc", .id = 0, }; /*====================================================================*/ static int __init init_m32r_pcc(void) { int i, ret; |
7a192ec33 platform driver: ... |
687 |
ret = platform_driver_register(&pcc_driver); |
1da177e4c Linux-2.6.12-rc2 |
688 689 690 691 |
if (ret) return ret; ret = platform_device_register(&pcc_device); |
c795cf4f1 drivers/pcmcia/m3... |
692 693 |
if (ret) goto unreg_driv; |
1da177e4c Linux-2.6.12-rc2 |
694 695 696 697 698 |
printk(KERN_INFO "m32r PCC probe: "); pcc_sockets = 0; |
3da82065f drivers/pcmcia/m3... |
699 700 701 702 |
ret = add_pcc_socket(M32R_PCC0_BASE, PCC0_IRQ, M32R_PCC0_MAPBASE, 0x1000); if (ret) goto unreg_dev; |
1da177e4c Linux-2.6.12-rc2 |
703 704 |
#ifdef CONFIG_M32RPCC_SLOT2 |
3da82065f drivers/pcmcia/m3... |
705 706 707 708 |
ret = add_pcc_socket(M32R_PCC1_BASE, PCC1_IRQ, M32R_PCC1_MAPBASE, 0x2000); if (ret) goto unreg_dev; |
1da177e4c Linux-2.6.12-rc2 |
709 710 711 712 713 |
#endif if (pcc_sockets == 0) { printk("socket is not found. "); |
c795cf4f1 drivers/pcmcia/m3... |
714 715 |
ret = -ENODEV; goto unreg_dev; |
1da177e4c Linux-2.6.12-rc2 |
716 717 718 719 720 |
} /* Set up interrupt handler(s) */ for (i = 0 ; i < pcc_sockets ; i++) { |
ccbe48f76 [PATCH] m32r: cla... |
721 |
socket[i].socket.dev.parent = &pcc_device.dev; |
1da177e4c Linux-2.6.12-rc2 |
722 723 724 725 726 727 728 |
socket[i].socket.ops = &pcc_operations; socket[i].socket.resource_ops = &pccard_static_ops; socket[i].socket.owner = THIS_MODULE; socket[i].number = i; ret = pcmcia_register_socket(&socket[i].socket); if (!ret) socket[i].flags |= IS_REGISTERED; |
1da177e4c Linux-2.6.12-rc2 |
729 730 731 732 733 734 735 736 737 738 739 740 |
} /* 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; |
c795cf4f1 drivers/pcmcia/m3... |
741 742 743 744 745 746 |
unreg_dev: platform_device_unregister(&pcc_device); unreg_driv: platform_driver_unregister(&pcc_driver); return ret; |
1da177e4c Linux-2.6.12-rc2 |
747 748 749 750 751 752 753 754 755 756 757 758 759 |
} /* 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); |
7a192ec33 platform driver: ... |
760 |
platform_driver_unregister(&pcc_driver); |
1da177e4c Linux-2.6.12-rc2 |
761 762 763 764 765 766 |
} /* exit_m32r_pcc */ module_init(init_m32r_pcc); module_exit(exit_m32r_pcc); MODULE_LICENSE("Dual MPL/GPL"); /*====================================================================*/ |