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