m32r_pcc.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751
  1. /*
  2. * drivers/pcmcia/m32r_pcc.c
  3. *
  4. * Device driver for the PCMCIA functionality of M32R.
  5. *
  6. * Copyright (c) 2001, 2002, 2003, 2004
  7. * Hiroyuki Kondo, Naoto Sugai, Hayato Fujiwara
  8. */
  9. #include <linux/module.h>
  10. #include <linux/moduleparam.h>
  11. #include <linux/init.h>
  12. #include <linux/types.h>
  13. #include <linux/fcntl.h>
  14. #include <linux/string.h>
  15. #include <linux/kernel.h>
  16. #include <linux/errno.h>
  17. #include <linux/timer.h>
  18. #include <linux/ioport.h>
  19. #include <linux/delay.h>
  20. #include <linux/workqueue.h>
  21. #include <linux/interrupt.h>
  22. #include <linux/platform_device.h>
  23. #include <linux/bitops.h>
  24. #include <asm/irq.h>
  25. #include <asm/io.h>
  26. #include <asm/addrspace.h>
  27. #include <pcmcia/ss.h>
  28. /* XXX: should be moved into asm/irq.h */
  29. #define PCC0_IRQ 24
  30. #define PCC1_IRQ 25
  31. #include "m32r_pcc.h"
  32. #define CHAOS_PCC_DEBUG
  33. #ifdef CHAOS_PCC_DEBUG
  34. static volatile u_short dummy_readbuf;
  35. #endif
  36. #define PCC_DEBUG_DBEX
  37. /* Poll status interval -- 0 means default to interrupt */
  38. static int poll_interval = 0;
  39. typedef enum pcc_space { as_none = 0, as_comm, as_attr, as_io } pcc_as_t;
  40. typedef struct pcc_socket {
  41. u_short type, flags;
  42. struct pcmcia_socket socket;
  43. unsigned int number;
  44. unsigned int ioaddr;
  45. u_long mapaddr;
  46. u_long base; /* PCC register base */
  47. u_char cs_irq, intr;
  48. pccard_io_map io_map[MAX_IO_WIN];
  49. pccard_mem_map mem_map[MAX_WIN];
  50. u_char io_win;
  51. u_char mem_win;
  52. pcc_as_t current_space;
  53. u_char last_iodbex;
  54. #ifdef CHAOS_PCC_DEBUG
  55. u_char last_iosize;
  56. #endif
  57. #ifdef CONFIG_PROC_FS
  58. struct proc_dir_entry *proc;
  59. #endif
  60. } pcc_socket_t;
  61. static int pcc_sockets = 0;
  62. static pcc_socket_t socket[M32R_MAX_PCC] = {
  63. { 0, }, /* ... */
  64. };
  65. /*====================================================================*/
  66. static unsigned int pcc_get(u_short, unsigned int);
  67. static void pcc_set(u_short, unsigned int , unsigned int );
  68. static DEFINE_SPINLOCK(pcc_lock);
  69. void pcc_iorw(int sock, unsigned long port, void *buf, size_t size, size_t nmemb, int wr, int flag)
  70. {
  71. u_long addr;
  72. u_long flags;
  73. int need_ex;
  74. #ifdef PCC_DEBUG_DBEX
  75. int _dbex;
  76. #endif
  77. pcc_socket_t *t = &socket[sock];
  78. #ifdef CHAOS_PCC_DEBUG
  79. int map_changed = 0;
  80. #endif
  81. /* Need lock ? */
  82. spin_lock_irqsave(&pcc_lock, flags);
  83. /*
  84. * Check if need dbex
  85. */
  86. need_ex = (size > 1 && flag == 0) ? PCMOD_DBEX : 0;
  87. #ifdef PCC_DEBUG_DBEX
  88. _dbex = need_ex;
  89. need_ex = 0;
  90. #endif
  91. /*
  92. * calculate access address
  93. */
  94. addr = t->mapaddr + port - t->ioaddr + KSEG1; /* XXX */
  95. /*
  96. * Check current mapping
  97. */
  98. if (t->current_space != as_io || t->last_iodbex != need_ex) {
  99. u_long cbsz;
  100. /*
  101. * Disable first
  102. */
  103. pcc_set(sock, PCCR, 0);
  104. /*
  105. * Set mode and io address
  106. */
  107. cbsz = (t->flags & MAP_16BIT) ? 0 : PCMOD_CBSZ;
  108. pcc_set(sock, PCMOD, PCMOD_AS_IO | cbsz | need_ex);
  109. pcc_set(sock, PCADR, addr & 0x1ff00000);
  110. /*
  111. * Enable and read it
  112. */
  113. pcc_set(sock, PCCR, 1);
  114. #ifdef CHAOS_PCC_DEBUG
  115. #if 0
  116. map_changed = (t->current_space == as_attr && size == 2); /* XXX */
  117. #else
  118. map_changed = 1;
  119. #endif
  120. #endif
  121. t->current_space = as_io;
  122. }
  123. /*
  124. * access to IO space
  125. */
  126. if (size == 1) {
  127. /* Byte */
  128. unsigned char *bp = (unsigned char *)buf;
  129. #ifdef CHAOS_DEBUG
  130. if (map_changed) {
  131. dummy_readbuf = readb(addr);
  132. }
  133. #endif
  134. if (wr) {
  135. /* write Byte */
  136. while (nmemb--) {
  137. writeb(*bp++, addr);
  138. }
  139. } else {
  140. /* read Byte */
  141. while (nmemb--) {
  142. *bp++ = readb(addr);
  143. }
  144. }
  145. } else {
  146. /* Word */
  147. unsigned short *bp = (unsigned short *)buf;
  148. #ifdef CHAOS_PCC_DEBUG
  149. if (map_changed) {
  150. dummy_readbuf = readw(addr);
  151. }
  152. #endif
  153. if (wr) {
  154. /* write Word */
  155. while (nmemb--) {
  156. #ifdef PCC_DEBUG_DBEX
  157. if (_dbex) {
  158. unsigned char *cp = (unsigned char *)bp;
  159. unsigned short tmp;
  160. tmp = cp[1] << 8 | cp[0];
  161. writew(tmp, addr);
  162. bp++;
  163. } else
  164. #endif
  165. writew(*bp++, addr);
  166. }
  167. } else {
  168. /* read Word */
  169. while (nmemb--) {
  170. #ifdef PCC_DEBUG_DBEX
  171. if (_dbex) {
  172. unsigned char *cp = (unsigned char *)bp;
  173. unsigned short tmp;
  174. tmp = readw(addr);
  175. cp[0] = tmp & 0xff;
  176. cp[1] = (tmp >> 8) & 0xff;
  177. bp++;
  178. } else
  179. #endif
  180. *bp++ = readw(addr);
  181. }
  182. }
  183. }
  184. #if 1
  185. /* addr is no longer used */
  186. if ((addr = pcc_get(sock, PCIRC)) & PCIRC_BWERR) {
  187. printk("m32r_pcc: BWERR detected : port 0x%04lx : iosize %dbit\n",
  188. port, size * 8);
  189. pcc_set(sock, PCIRC, addr);
  190. }
  191. #endif
  192. /*
  193. * save state
  194. */
  195. t->last_iosize = size;
  196. t->last_iodbex = need_ex;
  197. /* Need lock ? */
  198. spin_unlock_irqrestore(&pcc_lock,flags);
  199. return;
  200. }
  201. void pcc_ioread(int sock, unsigned long port, void *buf, size_t size, size_t nmemb, int flag) {
  202. pcc_iorw(sock, port, buf, size, nmemb, 0, flag);
  203. }
  204. void pcc_iowrite(int sock, unsigned long port, void *buf, size_t size, size_t nmemb, int flag) {
  205. pcc_iorw(sock, port, buf, size, nmemb, 1, flag);
  206. }
  207. /*====================================================================*/
  208. #define IS_REGISTERED 0x2000
  209. #define IS_ALIVE 0x8000
  210. typedef struct pcc_t {
  211. char *name;
  212. u_short flags;
  213. } pcc_t;
  214. static pcc_t pcc[] = {
  215. { "xnux2", 0 }, { "xnux2", 0 },
  216. };
  217. static irqreturn_t pcc_interrupt(int, void *);
  218. /*====================================================================*/
  219. static struct timer_list poll_timer;
  220. static unsigned int pcc_get(u_short sock, unsigned int reg)
  221. {
  222. return inl(socket[sock].base + reg);
  223. }
  224. static void pcc_set(u_short sock, unsigned int reg, unsigned int data)
  225. {
  226. outl(data, socket[sock].base + reg);
  227. }
  228. /*======================================================================
  229. See if a card is present, powered up, in IO mode, and already
  230. bound to a (non PC Card) Linux driver. We leave these alone.
  231. We make an exception for cards that seem to be serial devices.
  232. ======================================================================*/
  233. static int __init is_alive(u_short sock)
  234. {
  235. unsigned int stat;
  236. unsigned int f;
  237. stat = pcc_get(sock, PCIRC);
  238. f = (stat & (PCIRC_CDIN1 | PCIRC_CDIN2)) >> 16;
  239. if(!f){
  240. printk("m32r_pcc: No Card is detected at socket %d : stat = 0x%08x\n",stat,sock);
  241. return 0;
  242. }
  243. if(f!=3)
  244. printk("m32r_pcc: Insertion fail (%.8x) at socket %d\n",stat,sock);
  245. else
  246. printk("m32r_pcc: Card is Inserted at socket %d(%.8x)\n",sock,stat);
  247. return 0;
  248. }
  249. static void add_pcc_socket(ulong base, int irq, ulong mapaddr,
  250. unsigned int ioaddr)
  251. {
  252. pcc_socket_t *t = &socket[pcc_sockets];
  253. /* add sockets */
  254. t->ioaddr = ioaddr;
  255. t->mapaddr = mapaddr;
  256. t->base = base;
  257. #ifdef CHAOS_PCC_DEBUG
  258. t->flags = MAP_16BIT;
  259. #else
  260. t->flags = 0;
  261. #endif
  262. if (is_alive(pcc_sockets))
  263. t->flags |= IS_ALIVE;
  264. /* add pcc */
  265. if (t->base > 0) {
  266. request_region(t->base, 0x20, "m32r-pcc");
  267. }
  268. printk(KERN_INFO " %s ", pcc[pcc_sockets].name);
  269. printk("pcc at 0x%08lx\n", t->base);
  270. /* Update socket interrupt information, capabilities */
  271. t->socket.features |= (SS_CAP_PCCARD | SS_CAP_STATIC_MAP);
  272. t->socket.map_size = M32R_PCC_MAPSIZE;
  273. t->socket.io_offset = ioaddr; /* use for io access offset */
  274. t->socket.irq_mask = 0;
  275. t->socket.pci_irq = 2 + pcc_sockets; /* XXX */
  276. request_irq(irq, pcc_interrupt, 0, "m32r-pcc", pcc_interrupt);
  277. pcc_sockets++;
  278. return;
  279. }
  280. /*====================================================================*/
  281. static irqreturn_t pcc_interrupt(int irq, void *dev)
  282. {
  283. int i, j, irc;
  284. u_int events, active;
  285. int handled = 0;
  286. pr_debug("m32r_pcc: pcc_interrupt(%d)\n", irq);
  287. for (j = 0; j < 20; j++) {
  288. active = 0;
  289. for (i = 0; i < pcc_sockets; i++) {
  290. if ((socket[i].cs_irq != irq) &&
  291. (socket[i].socket.pci_irq != irq))
  292. continue;
  293. handled = 1;
  294. irc = pcc_get(i, PCIRC);
  295. irc >>=16;
  296. pr_debug("m32r_pcc: interrupt: socket %d pcirc 0x%02x ",
  297. i, irc);
  298. if (!irc)
  299. continue;
  300. events = (irc) ? SS_DETECT : 0;
  301. events |= (pcc_get(i,PCCR) & PCCR_PCEN) ? SS_READY : 0;
  302. pr_debug("m32r_pcc: event 0x%02x\n", events);
  303. if (events)
  304. pcmcia_parse_events(&socket[i].socket, events);
  305. active |= events;
  306. active = 0;
  307. }
  308. if (!active) break;
  309. }
  310. if (j == 20)
  311. printk(KERN_NOTICE "m32r-pcc: infinite loop in interrupt handler\n");
  312. pr_debug("m32r_pcc: interrupt done\n");
  313. return IRQ_RETVAL(handled);
  314. } /* pcc_interrupt */
  315. static void pcc_interrupt_wrapper(u_long data)
  316. {
  317. pcc_interrupt(0, NULL);
  318. init_timer(&poll_timer);
  319. poll_timer.expires = jiffies + poll_interval;
  320. add_timer(&poll_timer);
  321. }
  322. /*====================================================================*/
  323. static int _pcc_get_status(u_short sock, u_int *value)
  324. {
  325. u_int status;
  326. status = pcc_get(sock,PCIRC);
  327. *value = ((status & PCIRC_CDIN1) && (status & PCIRC_CDIN2))
  328. ? SS_DETECT : 0;
  329. status = pcc_get(sock,PCCR);
  330. #if 0
  331. *value |= (status & PCCR_PCEN) ? SS_READY : 0;
  332. #else
  333. *value |= SS_READY; /* XXX: always */
  334. #endif
  335. status = pcc_get(sock,PCCSIGCR);
  336. *value |= (status & PCCSIGCR_VEN) ? SS_POWERON : 0;
  337. pr_debug("m32r_pcc: GetStatus(%d) = %#4.4x\n", sock, *value);
  338. return 0;
  339. } /* _get_status */
  340. /*====================================================================*/
  341. static int _pcc_set_socket(u_short sock, socket_state_t *state)
  342. {
  343. u_long reg = 0;
  344. pr_debug("m32r_pcc: SetSocket(%d, flags %#3.3x, Vcc %d, Vpp %d, "
  345. "io_irq %d, csc_mask %#2.2x)", sock, state->flags,
  346. state->Vcc, state->Vpp, state->io_irq, state->csc_mask);
  347. if (state->Vcc) {
  348. /*
  349. * 5V only
  350. */
  351. if (state->Vcc == 50) {
  352. reg |= PCCSIGCR_VEN;
  353. } else {
  354. return -EINVAL;
  355. }
  356. }
  357. if (state->flags & SS_RESET) {
  358. pr_debug("m32r_pcc: :RESET\n");
  359. reg |= PCCSIGCR_CRST;
  360. }
  361. if (state->flags & SS_OUTPUT_ENA){
  362. pr_debug("m32r_pcc: :OUTPUT_ENA\n");
  363. /* bit clear */
  364. } else {
  365. reg |= PCCSIGCR_SEN;
  366. }
  367. pcc_set(sock,PCCSIGCR,reg);
  368. if(state->flags & SS_IOCARD){
  369. pr_debug("m32r_pcc: :IOCARD");
  370. }
  371. if (state->flags & SS_PWR_AUTO) {
  372. pr_debug("m32r_pcc: :PWR_AUTO");
  373. }
  374. if (state->csc_mask & SS_DETECT)
  375. pr_debug("m32r_pcc: :csc-SS_DETECT");
  376. if (state->flags & SS_IOCARD) {
  377. if (state->csc_mask & SS_STSCHG)
  378. pr_debug("m32r_pcc: :STSCHG");
  379. } else {
  380. if (state->csc_mask & SS_BATDEAD)
  381. pr_debug("m32r_pcc: :BATDEAD");
  382. if (state->csc_mask & SS_BATWARN)
  383. pr_debug("m32r_pcc: :BATWARN");
  384. if (state->csc_mask & SS_READY)
  385. pr_debug("m32r_pcc: :READY");
  386. }
  387. pr_debug("m32r_pcc: \n");
  388. return 0;
  389. } /* _set_socket */
  390. /*====================================================================*/
  391. static int _pcc_set_io_map(u_short sock, struct pccard_io_map *io)
  392. {
  393. u_char map;
  394. pr_debug("m32r_pcc: SetIOMap(%d, %d, %#2.2x, %d ns, "
  395. "%#llx-%#llx)\n", sock, io->map, io->flags,
  396. io->speed, (unsigned long long)io->start,
  397. (unsigned long long)io->stop);
  398. map = io->map;
  399. return 0;
  400. } /* _set_io_map */
  401. /*====================================================================*/
  402. static int _pcc_set_mem_map(u_short sock, struct pccard_mem_map *mem)
  403. {
  404. u_char map = mem->map;
  405. u_long mode;
  406. u_long addr;
  407. pcc_socket_t *t = &socket[sock];
  408. #ifdef CHAOS_PCC_DEBUG
  409. #if 0
  410. pcc_as_t last = t->current_space;
  411. #endif
  412. #endif
  413. pr_debug("m32r_pcc: SetMemMap(%d, %d, %#2.2x, %d ns, "
  414. "%#llx, %#x)\n", sock, map, mem->flags,
  415. mem->speed, (unsigned long long)mem->static_start,
  416. mem->card_start);
  417. /*
  418. * sanity check
  419. */
  420. if ((map > MAX_WIN) || (mem->card_start > 0x3ffffff)){
  421. return -EINVAL;
  422. }
  423. /*
  424. * de-activate
  425. */
  426. if ((mem->flags & MAP_ACTIVE) == 0) {
  427. t->current_space = as_none;
  428. return 0;
  429. }
  430. /*
  431. * Disable first
  432. */
  433. pcc_set(sock, PCCR, 0);
  434. /*
  435. * Set mode
  436. */
  437. if (mem->flags & MAP_ATTRIB) {
  438. mode = PCMOD_AS_ATTRIB | PCMOD_CBSZ;
  439. t->current_space = as_attr;
  440. } else {
  441. mode = 0; /* common memory */
  442. t->current_space = as_comm;
  443. }
  444. pcc_set(sock, PCMOD, mode);
  445. /*
  446. * Set address
  447. */
  448. addr = t->mapaddr + (mem->card_start & M32R_PCC_MAPMASK);
  449. pcc_set(sock, PCADR, addr);
  450. mem->static_start = addr + mem->card_start;
  451. /*
  452. * Enable again
  453. */
  454. pcc_set(sock, PCCR, 1);
  455. #ifdef CHAOS_PCC_DEBUG
  456. #if 0
  457. if (last != as_attr) {
  458. #else
  459. if (1) {
  460. #endif
  461. dummy_readbuf = *(u_char *)(addr + KSEG1);
  462. }
  463. #endif
  464. return 0;
  465. } /* _set_mem_map */
  466. #if 0 /* driver model ordering issue */
  467. /*======================================================================
  468. Routines for accessing socket information and register dumps via
  469. /proc/bus/pccard/...
  470. ======================================================================*/
  471. static ssize_t show_info(struct class_device *class_dev, char *buf)
  472. {
  473. pcc_socket_t *s = container_of(class_dev, struct pcc_socket,
  474. socket.dev);
  475. return sprintf(buf, "type: %s\nbase addr: 0x%08lx\n",
  476. pcc[s->type].name, s->base);
  477. }
  478. static ssize_t show_exca(struct class_device *class_dev, char *buf)
  479. {
  480. /* FIXME */
  481. return 0;
  482. }
  483. static CLASS_DEVICE_ATTR(info, S_IRUGO, show_info, NULL);
  484. static CLASS_DEVICE_ATTR(exca, S_IRUGO, show_exca, NULL);
  485. #endif
  486. /*====================================================================*/
  487. /* this is horribly ugly... proper locking needs to be done here at
  488. * some time... */
  489. #define LOCKED(x) do { \
  490. int retval; \
  491. unsigned long flags; \
  492. spin_lock_irqsave(&pcc_lock, flags); \
  493. retval = x; \
  494. spin_unlock_irqrestore(&pcc_lock, flags); \
  495. return retval; \
  496. } while (0)
  497. static int pcc_get_status(struct pcmcia_socket *s, u_int *value)
  498. {
  499. unsigned int sock = container_of(s, struct pcc_socket, socket)->number;
  500. if (socket[sock].flags & IS_ALIVE) {
  501. *value = 0;
  502. return -EINVAL;
  503. }
  504. LOCKED(_pcc_get_status(sock, value));
  505. }
  506. static int pcc_set_socket(struct pcmcia_socket *s, socket_state_t *state)
  507. {
  508. unsigned int sock = container_of(s, struct pcc_socket, socket)->number;
  509. if (socket[sock].flags & IS_ALIVE)
  510. return -EINVAL;
  511. LOCKED(_pcc_set_socket(sock, state));
  512. }
  513. static int pcc_set_io_map(struct pcmcia_socket *s, struct pccard_io_map *io)
  514. {
  515. unsigned int sock = container_of(s, struct pcc_socket, socket)->number;
  516. if (socket[sock].flags & IS_ALIVE)
  517. return -EINVAL;
  518. LOCKED(_pcc_set_io_map(sock, io));
  519. }
  520. static int pcc_set_mem_map(struct pcmcia_socket *s, struct pccard_mem_map *mem)
  521. {
  522. unsigned int sock = container_of(s, struct pcc_socket, socket)->number;
  523. if (socket[sock].flags & IS_ALIVE)
  524. return -EINVAL;
  525. LOCKED(_pcc_set_mem_map(sock, mem));
  526. }
  527. static int pcc_init(struct pcmcia_socket *s)
  528. {
  529. pr_debug("m32r_pcc: init call\n");
  530. return 0;
  531. }
  532. static struct pccard_operations pcc_operations = {
  533. .init = pcc_init,
  534. .get_status = pcc_get_status,
  535. .set_socket = pcc_set_socket,
  536. .set_io_map = pcc_set_io_map,
  537. .set_mem_map = pcc_set_mem_map,
  538. };
  539. /*====================================================================*/
  540. static struct platform_driver pcc_driver = {
  541. .driver = {
  542. .name = "pcc",
  543. },
  544. };
  545. static struct platform_device pcc_device = {
  546. .name = "pcc",
  547. .id = 0,
  548. };
  549. /*====================================================================*/
  550. static int __init init_m32r_pcc(void)
  551. {
  552. int i, ret;
  553. ret = platform_driver_register(&pcc_driver);
  554. if (ret)
  555. return ret;
  556. ret = platform_device_register(&pcc_device);
  557. if (ret){
  558. platform_driver_unregister(&pcc_driver);
  559. return ret;
  560. }
  561. printk(KERN_INFO "m32r PCC probe:\n");
  562. pcc_sockets = 0;
  563. add_pcc_socket(M32R_PCC0_BASE, PCC0_IRQ, M32R_PCC0_MAPBASE, 0x1000);
  564. #ifdef CONFIG_M32RPCC_SLOT2
  565. add_pcc_socket(M32R_PCC1_BASE, PCC1_IRQ, M32R_PCC1_MAPBASE, 0x2000);
  566. #endif
  567. if (pcc_sockets == 0) {
  568. printk("socket is not found.\n");
  569. platform_device_unregister(&pcc_device);
  570. platform_driver_unregister(&pcc_driver);
  571. return -ENODEV;
  572. }
  573. /* Set up interrupt handler(s) */
  574. for (i = 0 ; i < pcc_sockets ; i++) {
  575. socket[i].socket.dev.parent = &pcc_device.dev;
  576. socket[i].socket.ops = &pcc_operations;
  577. socket[i].socket.resource_ops = &pccard_static_ops;
  578. socket[i].socket.owner = THIS_MODULE;
  579. socket[i].number = i;
  580. ret = pcmcia_register_socket(&socket[i].socket);
  581. if (!ret)
  582. socket[i].flags |= IS_REGISTERED;
  583. }
  584. /* Finally, schedule a polling interrupt */
  585. if (poll_interval != 0) {
  586. poll_timer.function = pcc_interrupt_wrapper;
  587. poll_timer.data = 0;
  588. init_timer(&poll_timer);
  589. poll_timer.expires = jiffies + poll_interval;
  590. add_timer(&poll_timer);
  591. }
  592. return 0;
  593. } /* init_m32r_pcc */
  594. static void __exit exit_m32r_pcc(void)
  595. {
  596. int i;
  597. for (i = 0; i < pcc_sockets; i++)
  598. if (socket[i].flags & IS_REGISTERED)
  599. pcmcia_unregister_socket(&socket[i].socket);
  600. platform_device_unregister(&pcc_device);
  601. if (poll_interval != 0)
  602. del_timer_sync(&poll_timer);
  603. platform_driver_unregister(&pcc_driver);
  604. } /* exit_m32r_pcc */
  605. module_init(init_m32r_pcc);
  606. module_exit(exit_m32r_pcc);
  607. MODULE_LICENSE("Dual MPL/GPL");
  608. /*====================================================================*/