m32r_pcc.c 16 KB

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