m32r_pcc.c 16 KB

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