icside.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704
  1. /*
  2. * Copyright (c) 1996-2004 Russell King.
  3. *
  4. * Please note that this platform does not support 32-bit IDE IO.
  5. */
  6. #include <linux/string.h>
  7. #include <linux/module.h>
  8. #include <linux/ioport.h>
  9. #include <linux/slab.h>
  10. #include <linux/blkdev.h>
  11. #include <linux/errno.h>
  12. #include <linux/hdreg.h>
  13. #include <linux/ide.h>
  14. #include <linux/dma-mapping.h>
  15. #include <linux/device.h>
  16. #include <linux/init.h>
  17. #include <linux/scatterlist.h>
  18. #include <linux/io.h>
  19. #include <asm/dma.h>
  20. #include <asm/ecard.h>
  21. #define ICS_IDENT_OFFSET 0x2280
  22. #define ICS_ARCIN_V5_INTRSTAT 0x0000
  23. #define ICS_ARCIN_V5_INTROFFSET 0x0004
  24. #define ICS_ARCIN_V5_IDEOFFSET 0x2800
  25. #define ICS_ARCIN_V5_IDEALTOFFSET 0x2b80
  26. #define ICS_ARCIN_V5_IDESTEPPING 6
  27. #define ICS_ARCIN_V6_IDEOFFSET_1 0x2000
  28. #define ICS_ARCIN_V6_INTROFFSET_1 0x2200
  29. #define ICS_ARCIN_V6_INTRSTAT_1 0x2290
  30. #define ICS_ARCIN_V6_IDEALTOFFSET_1 0x2380
  31. #define ICS_ARCIN_V6_IDEOFFSET_2 0x3000
  32. #define ICS_ARCIN_V6_INTROFFSET_2 0x3200
  33. #define ICS_ARCIN_V6_INTRSTAT_2 0x3290
  34. #define ICS_ARCIN_V6_IDEALTOFFSET_2 0x3380
  35. #define ICS_ARCIN_V6_IDESTEPPING 6
  36. struct cardinfo {
  37. unsigned int dataoffset;
  38. unsigned int ctrloffset;
  39. unsigned int stepping;
  40. };
  41. static struct cardinfo icside_cardinfo_v5 = {
  42. .dataoffset = ICS_ARCIN_V5_IDEOFFSET,
  43. .ctrloffset = ICS_ARCIN_V5_IDEALTOFFSET,
  44. .stepping = ICS_ARCIN_V5_IDESTEPPING,
  45. };
  46. static struct cardinfo icside_cardinfo_v6_1 = {
  47. .dataoffset = ICS_ARCIN_V6_IDEOFFSET_1,
  48. .ctrloffset = ICS_ARCIN_V6_IDEALTOFFSET_1,
  49. .stepping = ICS_ARCIN_V6_IDESTEPPING,
  50. };
  51. static struct cardinfo icside_cardinfo_v6_2 = {
  52. .dataoffset = ICS_ARCIN_V6_IDEOFFSET_2,
  53. .ctrloffset = ICS_ARCIN_V6_IDEALTOFFSET_2,
  54. .stepping = ICS_ARCIN_V6_IDESTEPPING,
  55. };
  56. struct icside_state {
  57. unsigned int channel;
  58. unsigned int enabled;
  59. void __iomem *irq_port;
  60. void __iomem *ioc_base;
  61. unsigned int type;
  62. ide_hwif_t *hwif[2];
  63. };
  64. #define ICS_TYPE_A3IN 0
  65. #define ICS_TYPE_A3USER 1
  66. #define ICS_TYPE_V6 3
  67. #define ICS_TYPE_V5 15
  68. #define ICS_TYPE_NOTYPE ((unsigned int)-1)
  69. /* ---------------- Version 5 PCB Support Functions --------------------- */
  70. /* Prototype: icside_irqenable_arcin_v5 (struct expansion_card *ec, int irqnr)
  71. * Purpose : enable interrupts from card
  72. */
  73. static void icside_irqenable_arcin_v5 (struct expansion_card *ec, int irqnr)
  74. {
  75. struct icside_state *state = ec->irq_data;
  76. writeb(0, state->irq_port + ICS_ARCIN_V5_INTROFFSET);
  77. }
  78. /* Prototype: icside_irqdisable_arcin_v5 (struct expansion_card *ec, int irqnr)
  79. * Purpose : disable interrupts from card
  80. */
  81. static void icside_irqdisable_arcin_v5 (struct expansion_card *ec, int irqnr)
  82. {
  83. struct icside_state *state = ec->irq_data;
  84. readb(state->irq_port + ICS_ARCIN_V5_INTROFFSET);
  85. }
  86. static const expansioncard_ops_t icside_ops_arcin_v5 = {
  87. .irqenable = icside_irqenable_arcin_v5,
  88. .irqdisable = icside_irqdisable_arcin_v5,
  89. };
  90. /* ---------------- Version 6 PCB Support Functions --------------------- */
  91. /* Prototype: icside_irqenable_arcin_v6 (struct expansion_card *ec, int irqnr)
  92. * Purpose : enable interrupts from card
  93. */
  94. static void icside_irqenable_arcin_v6 (struct expansion_card *ec, int irqnr)
  95. {
  96. struct icside_state *state = ec->irq_data;
  97. void __iomem *base = state->irq_port;
  98. state->enabled = 1;
  99. switch (state->channel) {
  100. case 0:
  101. writeb(0, base + ICS_ARCIN_V6_INTROFFSET_1);
  102. readb(base + ICS_ARCIN_V6_INTROFFSET_2);
  103. break;
  104. case 1:
  105. writeb(0, base + ICS_ARCIN_V6_INTROFFSET_2);
  106. readb(base + ICS_ARCIN_V6_INTROFFSET_1);
  107. break;
  108. }
  109. }
  110. /* Prototype: icside_irqdisable_arcin_v6 (struct expansion_card *ec, int irqnr)
  111. * Purpose : disable interrupts from card
  112. */
  113. static void icside_irqdisable_arcin_v6 (struct expansion_card *ec, int irqnr)
  114. {
  115. struct icside_state *state = ec->irq_data;
  116. state->enabled = 0;
  117. readb(state->irq_port + ICS_ARCIN_V6_INTROFFSET_1);
  118. readb(state->irq_port + ICS_ARCIN_V6_INTROFFSET_2);
  119. }
  120. /* Prototype: icside_irqprobe(struct expansion_card *ec)
  121. * Purpose : detect an active interrupt from card
  122. */
  123. static int icside_irqpending_arcin_v6(struct expansion_card *ec)
  124. {
  125. struct icside_state *state = ec->irq_data;
  126. return readb(state->irq_port + ICS_ARCIN_V6_INTRSTAT_1) & 1 ||
  127. readb(state->irq_port + ICS_ARCIN_V6_INTRSTAT_2) & 1;
  128. }
  129. static const expansioncard_ops_t icside_ops_arcin_v6 = {
  130. .irqenable = icside_irqenable_arcin_v6,
  131. .irqdisable = icside_irqdisable_arcin_v6,
  132. .irqpending = icside_irqpending_arcin_v6,
  133. };
  134. /*
  135. * Handle routing of interrupts. This is called before
  136. * we write the command to the drive.
  137. */
  138. static void icside_maskproc(ide_drive_t *drive, int mask)
  139. {
  140. ide_hwif_t *hwif = HWIF(drive);
  141. struct icside_state *state = hwif->hwif_data;
  142. unsigned long flags;
  143. local_irq_save(flags);
  144. state->channel = hwif->channel;
  145. if (state->enabled && !mask) {
  146. switch (hwif->channel) {
  147. case 0:
  148. writeb(0, state->irq_port + ICS_ARCIN_V6_INTROFFSET_1);
  149. readb(state->irq_port + ICS_ARCIN_V6_INTROFFSET_2);
  150. break;
  151. case 1:
  152. writeb(0, state->irq_port + ICS_ARCIN_V6_INTROFFSET_2);
  153. readb(state->irq_port + ICS_ARCIN_V6_INTROFFSET_1);
  154. break;
  155. }
  156. } else {
  157. readb(state->irq_port + ICS_ARCIN_V6_INTROFFSET_2);
  158. readb(state->irq_port + ICS_ARCIN_V6_INTROFFSET_1);
  159. }
  160. local_irq_restore(flags);
  161. }
  162. #ifdef CONFIG_BLK_DEV_IDEDMA_ICS
  163. /*
  164. * SG-DMA support.
  165. *
  166. * Similar to the BM-DMA, but we use the RiscPCs IOMD DMA controllers.
  167. * There is only one DMA controller per card, which means that only
  168. * one drive can be accessed at one time. NOTE! We do not enforce that
  169. * here, but we rely on the main IDE driver spotting that both
  170. * interfaces use the same IRQ, which should guarantee this.
  171. */
  172. /*
  173. * Configure the IOMD to give the appropriate timings for the transfer
  174. * mode being requested. We take the advice of the ATA standards, and
  175. * calculate the cycle time based on the transfer mode, and the EIDE
  176. * MW DMA specs that the drive provides in the IDENTIFY command.
  177. *
  178. * We have the following IOMD DMA modes to choose from:
  179. *
  180. * Type Active Recovery Cycle
  181. * A 250 (250) 312 (550) 562 (800)
  182. * B 187 250 437
  183. * C 125 (125) 125 (375) 250 (500)
  184. * D 62 125 187
  185. *
  186. * (figures in brackets are actual measured timings)
  187. *
  188. * However, we also need to take care of the read/write active and
  189. * recovery timings:
  190. *
  191. * Read Write
  192. * Mode Active -- Recovery -- Cycle IOMD type
  193. * MW0 215 50 215 480 A
  194. * MW1 80 50 50 150 C
  195. * MW2 70 25 25 120 C
  196. */
  197. static void icside_set_dma_mode(ide_drive_t *drive, const u8 xfer_mode)
  198. {
  199. int cycle_time, use_dma_info = 0;
  200. switch (xfer_mode) {
  201. case XFER_MW_DMA_2:
  202. cycle_time = 250;
  203. use_dma_info = 1;
  204. break;
  205. case XFER_MW_DMA_1:
  206. cycle_time = 250;
  207. use_dma_info = 1;
  208. break;
  209. case XFER_MW_DMA_0:
  210. cycle_time = 480;
  211. break;
  212. case XFER_SW_DMA_2:
  213. case XFER_SW_DMA_1:
  214. case XFER_SW_DMA_0:
  215. cycle_time = 480;
  216. break;
  217. }
  218. /*
  219. * If we're going to be doing MW_DMA_1 or MW_DMA_2, we should
  220. * take care to note the values in the ID...
  221. */
  222. if (use_dma_info && drive->id->eide_dma_time > cycle_time)
  223. cycle_time = drive->id->eide_dma_time;
  224. drive->drive_data = cycle_time;
  225. printk("%s: %s selected (peak %dMB/s)\n", drive->name,
  226. ide_xfer_verbose(xfer_mode), 2000 / drive->drive_data);
  227. }
  228. static void icside_dma_host_set(ide_drive_t *drive, int on)
  229. {
  230. }
  231. static int icside_dma_end(ide_drive_t *drive)
  232. {
  233. ide_hwif_t *hwif = HWIF(drive);
  234. struct expansion_card *ec = ECARD_DEV(hwif->dev);
  235. drive->waiting_for_dma = 0;
  236. disable_dma(ec->dma);
  237. /* Teardown mappings after DMA has completed. */
  238. ide_destroy_dmatable(drive);
  239. return get_dma_residue(ec->dma) != 0;
  240. }
  241. static void icside_dma_start(ide_drive_t *drive)
  242. {
  243. ide_hwif_t *hwif = HWIF(drive);
  244. struct expansion_card *ec = ECARD_DEV(hwif->dev);
  245. /* We can not enable DMA on both channels simultaneously. */
  246. BUG_ON(dma_channel_active(ec->dma));
  247. enable_dma(ec->dma);
  248. }
  249. static int icside_dma_setup(ide_drive_t *drive)
  250. {
  251. ide_hwif_t *hwif = HWIF(drive);
  252. struct expansion_card *ec = ECARD_DEV(hwif->dev);
  253. struct request *rq = hwif->hwgroup->rq;
  254. unsigned int dma_mode;
  255. if (rq_data_dir(rq))
  256. dma_mode = DMA_MODE_WRITE;
  257. else
  258. dma_mode = DMA_MODE_READ;
  259. /*
  260. * We can not enable DMA on both channels.
  261. */
  262. BUG_ON(dma_channel_active(ec->dma));
  263. hwif->sg_nents = ide_build_sglist(drive, rq);
  264. /*
  265. * Ensure that we have the right interrupt routed.
  266. */
  267. icside_maskproc(drive, 0);
  268. /*
  269. * Route the DMA signals to the correct interface.
  270. */
  271. writeb(hwif->select_data, hwif->config_data);
  272. /*
  273. * Select the correct timing for this drive.
  274. */
  275. set_dma_speed(ec->dma, drive->drive_data);
  276. /*
  277. * Tell the DMA engine about the SG table and
  278. * data direction.
  279. */
  280. set_dma_sg(ec->dma, hwif->sg_table, hwif->sg_nents);
  281. set_dma_mode(ec->dma, dma_mode);
  282. drive->waiting_for_dma = 1;
  283. return 0;
  284. }
  285. static void icside_dma_exec_cmd(ide_drive_t *drive, u8 cmd)
  286. {
  287. /* issue cmd to drive */
  288. ide_execute_command(drive, cmd, ide_dma_intr, 2 * WAIT_CMD, NULL);
  289. }
  290. static int icside_dma_test_irq(ide_drive_t *drive)
  291. {
  292. ide_hwif_t *hwif = HWIF(drive);
  293. struct icside_state *state = hwif->hwif_data;
  294. return readb(state->irq_port +
  295. (hwif->channel ?
  296. ICS_ARCIN_V6_INTRSTAT_2 :
  297. ICS_ARCIN_V6_INTRSTAT_1)) & 1;
  298. }
  299. static void icside_dma_timeout(ide_drive_t *drive)
  300. {
  301. printk(KERN_ERR "%s: DMA timeout occurred: ", drive->name);
  302. if (icside_dma_test_irq(drive))
  303. return;
  304. ide_dump_status(drive, "DMA timeout", ide_read_status(drive));
  305. icside_dma_end(drive);
  306. }
  307. static void icside_dma_lost_irq(ide_drive_t *drive)
  308. {
  309. printk(KERN_ERR "%s: IRQ lost\n", drive->name);
  310. }
  311. static void icside_dma_init(ide_hwif_t *hwif)
  312. {
  313. hwif->dmatable_cpu = NULL;
  314. hwif->dmatable_dma = 0;
  315. hwif->set_dma_mode = icside_set_dma_mode;
  316. hwif->dma_host_set = icside_dma_host_set;
  317. hwif->dma_setup = icside_dma_setup;
  318. hwif->dma_exec_cmd = icside_dma_exec_cmd;
  319. hwif->dma_start = icside_dma_start;
  320. hwif->ide_dma_end = icside_dma_end;
  321. hwif->ide_dma_test_irq = icside_dma_test_irq;
  322. hwif->dma_timeout = icside_dma_timeout;
  323. hwif->dma_lost_irq = icside_dma_lost_irq;
  324. }
  325. #else
  326. #define icside_dma_init(hwif) (0)
  327. #endif
  328. static ide_hwif_t *
  329. icside_setup(void __iomem *base, struct cardinfo *info, struct expansion_card *ec)
  330. {
  331. unsigned long port = (unsigned long)base + info->dataoffset;
  332. ide_hwif_t *hwif;
  333. hwif = ide_find_port();
  334. if (hwif) {
  335. int i;
  336. /*
  337. * Ensure we're using MMIO
  338. */
  339. default_hwif_mmiops(hwif);
  340. hwif->mmio = 1;
  341. for (i = IDE_DATA_OFFSET; i <= IDE_STATUS_OFFSET; i++) {
  342. hwif->io_ports[i] = port;
  343. port += 1 << info->stepping;
  344. }
  345. hwif->io_ports[IDE_CONTROL_OFFSET] = (unsigned long)base + info->ctrloffset;
  346. hwif->irq = ec->irq;
  347. hwif->noprobe = 0;
  348. hwif->chipset = ide_acorn;
  349. hwif->gendev.parent = &ec->dev;
  350. hwif->dev = &ec->dev;
  351. }
  352. return hwif;
  353. }
  354. static int __init
  355. icside_register_v5(struct icside_state *state, struct expansion_card *ec)
  356. {
  357. ide_hwif_t *hwif;
  358. void __iomem *base;
  359. u8 idx[4] = { 0xff, 0xff, 0xff, 0xff };
  360. base = ecardm_iomap(ec, ECARD_RES_MEMC, 0, 0);
  361. if (!base)
  362. return -ENOMEM;
  363. state->irq_port = base;
  364. ec->irqaddr = base + ICS_ARCIN_V5_INTRSTAT;
  365. ec->irqmask = 1;
  366. ecard_setirq(ec, &icside_ops_arcin_v5, state);
  367. /*
  368. * Be on the safe side - disable interrupts
  369. */
  370. icside_irqdisable_arcin_v5(ec, 0);
  371. hwif = icside_setup(base, &icside_cardinfo_v5, ec);
  372. if (!hwif)
  373. return -ENODEV;
  374. state->hwif[0] = hwif;
  375. idx[0] = hwif->index;
  376. ide_device_add(idx, NULL);
  377. return 0;
  378. }
  379. static const struct ide_port_info icside_v6_port_info __initdata = {
  380. .host_flags = IDE_HFLAG_SERIALIZE |
  381. IDE_HFLAG_NO_DMA | /* no SFF-style DMA */
  382. IDE_HFLAG_NO_AUTOTUNE,
  383. .mwdma_mask = ATA_MWDMA2,
  384. .swdma_mask = ATA_SWDMA2,
  385. };
  386. static int __init
  387. icside_register_v6(struct icside_state *state, struct expansion_card *ec)
  388. {
  389. ide_hwif_t *hwif, *mate;
  390. void __iomem *ioc_base, *easi_base;
  391. unsigned int sel = 0;
  392. int ret;
  393. u8 idx[4] = { 0xff, 0xff, 0xff, 0xff };
  394. struct ide_port_info d = icside_v6_port_info;
  395. ioc_base = ecardm_iomap(ec, ECARD_RES_IOCFAST, 0, 0);
  396. if (!ioc_base) {
  397. ret = -ENOMEM;
  398. goto out;
  399. }
  400. easi_base = ioc_base;
  401. if (ecard_resource_flags(ec, ECARD_RES_EASI)) {
  402. easi_base = ecardm_iomap(ec, ECARD_RES_EASI, 0, 0);
  403. if (!easi_base) {
  404. ret = -ENOMEM;
  405. goto out;
  406. }
  407. /*
  408. * Enable access to the EASI region.
  409. */
  410. sel = 1 << 5;
  411. }
  412. writeb(sel, ioc_base);
  413. ecard_setirq(ec, &icside_ops_arcin_v6, state);
  414. state->irq_port = easi_base;
  415. state->ioc_base = ioc_base;
  416. /*
  417. * Be on the safe side - disable interrupts
  418. */
  419. icside_irqdisable_arcin_v6(ec, 0);
  420. /*
  421. * Find and register the interfaces.
  422. */
  423. hwif = icside_setup(easi_base, &icside_cardinfo_v6_1, ec);
  424. mate = icside_setup(easi_base, &icside_cardinfo_v6_2, ec);
  425. if (!hwif || !mate) {
  426. ret = -ENODEV;
  427. goto out;
  428. }
  429. state->hwif[0] = hwif;
  430. state->hwif[1] = mate;
  431. hwif->maskproc = icside_maskproc;
  432. hwif->hwif_data = state;
  433. hwif->config_data = (unsigned long)ioc_base;
  434. hwif->select_data = sel;
  435. mate->maskproc = icside_maskproc;
  436. mate->hwif_data = state;
  437. mate->config_data = (unsigned long)ioc_base;
  438. mate->select_data = sel | 1;
  439. if (ec->dma != NO_DMA && !request_dma(ec->dma, hwif->name)) {
  440. icside_dma_init(hwif);
  441. icside_dma_init(mate);
  442. } else
  443. d.mwdma_mask = d.swdma_mask = 0;
  444. idx[0] = hwif->index;
  445. idx[1] = mate->index;
  446. ide_device_add(idx, &d);
  447. return 0;
  448. out:
  449. return ret;
  450. }
  451. static int __devinit
  452. icside_probe(struct expansion_card *ec, const struct ecard_id *id)
  453. {
  454. struct icside_state *state;
  455. void __iomem *idmem;
  456. int ret;
  457. ret = ecard_request_resources(ec);
  458. if (ret)
  459. goto out;
  460. state = kzalloc(sizeof(struct icside_state), GFP_KERNEL);
  461. if (!state) {
  462. ret = -ENOMEM;
  463. goto release;
  464. }
  465. state->type = ICS_TYPE_NOTYPE;
  466. idmem = ecardm_iomap(ec, ECARD_RES_IOCFAST, 0, 0);
  467. if (idmem) {
  468. unsigned int type;
  469. type = readb(idmem + ICS_IDENT_OFFSET) & 1;
  470. type |= (readb(idmem + ICS_IDENT_OFFSET + 4) & 1) << 1;
  471. type |= (readb(idmem + ICS_IDENT_OFFSET + 8) & 1) << 2;
  472. type |= (readb(idmem + ICS_IDENT_OFFSET + 12) & 1) << 3;
  473. ecardm_iounmap(ec, idmem);
  474. state->type = type;
  475. }
  476. switch (state->type) {
  477. case ICS_TYPE_A3IN:
  478. dev_warn(&ec->dev, "A3IN unsupported\n");
  479. ret = -ENODEV;
  480. break;
  481. case ICS_TYPE_A3USER:
  482. dev_warn(&ec->dev, "A3USER unsupported\n");
  483. ret = -ENODEV;
  484. break;
  485. case ICS_TYPE_V5:
  486. ret = icside_register_v5(state, ec);
  487. break;
  488. case ICS_TYPE_V6:
  489. ret = icside_register_v6(state, ec);
  490. break;
  491. default:
  492. dev_warn(&ec->dev, "unknown interface type\n");
  493. ret = -ENODEV;
  494. break;
  495. }
  496. if (ret == 0) {
  497. ecard_set_drvdata(ec, state);
  498. goto out;
  499. }
  500. kfree(state);
  501. release:
  502. ecard_release_resources(ec);
  503. out:
  504. return ret;
  505. }
  506. static void __devexit icside_remove(struct expansion_card *ec)
  507. {
  508. struct icside_state *state = ecard_get_drvdata(ec);
  509. switch (state->type) {
  510. case ICS_TYPE_V5:
  511. /* FIXME: tell IDE to stop using the interface */
  512. /* Disable interrupts */
  513. icside_irqdisable_arcin_v5(ec, 0);
  514. break;
  515. case ICS_TYPE_V6:
  516. /* FIXME: tell IDE to stop using the interface */
  517. if (ec->dma != NO_DMA)
  518. free_dma(ec->dma);
  519. /* Disable interrupts */
  520. icside_irqdisable_arcin_v6(ec, 0);
  521. /* Reset the ROM pointer/EASI selection */
  522. writeb(0, state->ioc_base);
  523. break;
  524. }
  525. ecard_set_drvdata(ec, NULL);
  526. kfree(state);
  527. ecard_release_resources(ec);
  528. }
  529. static void icside_shutdown(struct expansion_card *ec)
  530. {
  531. struct icside_state *state = ecard_get_drvdata(ec);
  532. unsigned long flags;
  533. /*
  534. * Disable interrupts from this card. We need to do
  535. * this before disabling EASI since we may be accessing
  536. * this register via that region.
  537. */
  538. local_irq_save(flags);
  539. ec->ops->irqdisable(ec, 0);
  540. local_irq_restore(flags);
  541. /*
  542. * Reset the ROM pointer so that we can read the ROM
  543. * after a soft reboot. This also disables access to
  544. * the IDE taskfile via the EASI region.
  545. */
  546. if (state->ioc_base)
  547. writeb(0, state->ioc_base);
  548. }
  549. static const struct ecard_id icside_ids[] = {
  550. { MANU_ICS, PROD_ICS_IDE },
  551. { MANU_ICS2, PROD_ICS2_IDE },
  552. { 0xffff, 0xffff }
  553. };
  554. static struct ecard_driver icside_driver = {
  555. .probe = icside_probe,
  556. .remove = __devexit_p(icside_remove),
  557. .shutdown = icside_shutdown,
  558. .id_table = icside_ids,
  559. .drv = {
  560. .name = "icside",
  561. },
  562. };
  563. static int __init icside_init(void)
  564. {
  565. return ecard_register_driver(&icside_driver);
  566. }
  567. MODULE_AUTHOR("Russell King <rmk@arm.linux.org.uk>");
  568. MODULE_LICENSE("GPL");
  569. MODULE_DESCRIPTION("ICS IDE driver");
  570. module_init(icside_init);