icside.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713
  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. static const struct ide_port_ops icside_v6_no_dma_port_ops = {
  163. .maskproc = icside_maskproc,
  164. };
  165. #ifdef CONFIG_BLK_DEV_IDEDMA_ICS
  166. /*
  167. * SG-DMA support.
  168. *
  169. * Similar to the BM-DMA, but we use the RiscPCs IOMD DMA controllers.
  170. * There is only one DMA controller per card, which means that only
  171. * one drive can be accessed at one time. NOTE! We do not enforce that
  172. * here, but we rely on the main IDE driver spotting that both
  173. * interfaces use the same IRQ, which should guarantee this.
  174. */
  175. /*
  176. * Configure the IOMD to give the appropriate timings for the transfer
  177. * mode being requested. We take the advice of the ATA standards, and
  178. * calculate the cycle time based on the transfer mode, and the EIDE
  179. * MW DMA specs that the drive provides in the IDENTIFY command.
  180. *
  181. * We have the following IOMD DMA modes to choose from:
  182. *
  183. * Type Active Recovery Cycle
  184. * A 250 (250) 312 (550) 562 (800)
  185. * B 187 250 437
  186. * C 125 (125) 125 (375) 250 (500)
  187. * D 62 125 187
  188. *
  189. * (figures in brackets are actual measured timings)
  190. *
  191. * However, we also need to take care of the read/write active and
  192. * recovery timings:
  193. *
  194. * Read Write
  195. * Mode Active -- Recovery -- Cycle IOMD type
  196. * MW0 215 50 215 480 A
  197. * MW1 80 50 50 150 C
  198. * MW2 70 25 25 120 C
  199. */
  200. static void icside_set_dma_mode(ide_drive_t *drive, const u8 xfer_mode)
  201. {
  202. int cycle_time, use_dma_info = 0;
  203. switch (xfer_mode) {
  204. case XFER_MW_DMA_2:
  205. cycle_time = 250;
  206. use_dma_info = 1;
  207. break;
  208. case XFER_MW_DMA_1:
  209. cycle_time = 250;
  210. use_dma_info = 1;
  211. break;
  212. case XFER_MW_DMA_0:
  213. cycle_time = 480;
  214. break;
  215. case XFER_SW_DMA_2:
  216. case XFER_SW_DMA_1:
  217. case XFER_SW_DMA_0:
  218. cycle_time = 480;
  219. break;
  220. }
  221. /*
  222. * If we're going to be doing MW_DMA_1 or MW_DMA_2, we should
  223. * take care to note the values in the ID...
  224. */
  225. if (use_dma_info && drive->id->eide_dma_time > cycle_time)
  226. cycle_time = drive->id->eide_dma_time;
  227. drive->drive_data = cycle_time;
  228. printk("%s: %s selected (peak %dMB/s)\n", drive->name,
  229. ide_xfer_verbose(xfer_mode), 2000 / drive->drive_data);
  230. }
  231. static const struct ide_port_ops icside_v6_port_ops = {
  232. .set_dma_mode = icside_set_dma_mode,
  233. .maskproc = icside_maskproc,
  234. };
  235. static void icside_dma_host_set(ide_drive_t *drive, int on)
  236. {
  237. }
  238. static int icside_dma_end(ide_drive_t *drive)
  239. {
  240. ide_hwif_t *hwif = HWIF(drive);
  241. struct expansion_card *ec = ECARD_DEV(hwif->dev);
  242. drive->waiting_for_dma = 0;
  243. disable_dma(ec->dma);
  244. /* Teardown mappings after DMA has completed. */
  245. ide_destroy_dmatable(drive);
  246. return get_dma_residue(ec->dma) != 0;
  247. }
  248. static void icside_dma_start(ide_drive_t *drive)
  249. {
  250. ide_hwif_t *hwif = HWIF(drive);
  251. struct expansion_card *ec = ECARD_DEV(hwif->dev);
  252. /* We can not enable DMA on both channels simultaneously. */
  253. BUG_ON(dma_channel_active(ec->dma));
  254. enable_dma(ec->dma);
  255. }
  256. static int icside_dma_setup(ide_drive_t *drive)
  257. {
  258. ide_hwif_t *hwif = HWIF(drive);
  259. struct expansion_card *ec = ECARD_DEV(hwif->dev);
  260. struct request *rq = hwif->hwgroup->rq;
  261. unsigned int dma_mode;
  262. if (rq_data_dir(rq))
  263. dma_mode = DMA_MODE_WRITE;
  264. else
  265. dma_mode = DMA_MODE_READ;
  266. /*
  267. * We can not enable DMA on both channels.
  268. */
  269. BUG_ON(dma_channel_active(ec->dma));
  270. hwif->sg_nents = ide_build_sglist(drive, rq);
  271. /*
  272. * Ensure that we have the right interrupt routed.
  273. */
  274. icside_maskproc(drive, 0);
  275. /*
  276. * Route the DMA signals to the correct interface.
  277. */
  278. writeb(hwif->select_data, hwif->config_data);
  279. /*
  280. * Select the correct timing for this drive.
  281. */
  282. set_dma_speed(ec->dma, drive->drive_data);
  283. /*
  284. * Tell the DMA engine about the SG table and
  285. * data direction.
  286. */
  287. set_dma_sg(ec->dma, hwif->sg_table, hwif->sg_nents);
  288. set_dma_mode(ec->dma, dma_mode);
  289. drive->waiting_for_dma = 1;
  290. return 0;
  291. }
  292. static void icside_dma_exec_cmd(ide_drive_t *drive, u8 cmd)
  293. {
  294. /* issue cmd to drive */
  295. ide_execute_command(drive, cmd, ide_dma_intr, 2 * WAIT_CMD, NULL);
  296. }
  297. static int icside_dma_test_irq(ide_drive_t *drive)
  298. {
  299. ide_hwif_t *hwif = HWIF(drive);
  300. struct icside_state *state = hwif->hwif_data;
  301. return readb(state->irq_port +
  302. (hwif->channel ?
  303. ICS_ARCIN_V6_INTRSTAT_2 :
  304. ICS_ARCIN_V6_INTRSTAT_1)) & 1;
  305. }
  306. static void icside_dma_timeout(ide_drive_t *drive)
  307. {
  308. printk(KERN_ERR "%s: DMA timeout occurred: ", drive->name);
  309. if (icside_dma_test_irq(drive))
  310. return;
  311. ide_dump_status(drive, "DMA timeout", ide_read_status(drive));
  312. icside_dma_end(drive);
  313. }
  314. static void icside_dma_lost_irq(ide_drive_t *drive)
  315. {
  316. printk(KERN_ERR "%s: IRQ lost\n", drive->name);
  317. }
  318. static void icside_dma_init(ide_hwif_t *hwif)
  319. {
  320. hwif->dmatable_cpu = NULL;
  321. hwif->dmatable_dma = 0;
  322. hwif->dma_host_set = icside_dma_host_set;
  323. hwif->dma_setup = icside_dma_setup;
  324. hwif->dma_exec_cmd = icside_dma_exec_cmd;
  325. hwif->dma_start = icside_dma_start;
  326. hwif->ide_dma_end = icside_dma_end;
  327. hwif->ide_dma_test_irq = icside_dma_test_irq;
  328. hwif->dma_timeout = icside_dma_timeout;
  329. hwif->dma_lost_irq = icside_dma_lost_irq;
  330. }
  331. #else
  332. #define icside_dma_init(hwif) (0)
  333. #endif
  334. static ide_hwif_t *
  335. icside_setup(void __iomem *base, struct cardinfo *info, struct expansion_card *ec)
  336. {
  337. unsigned long port = (unsigned long)base + info->dataoffset;
  338. ide_hwif_t *hwif;
  339. hwif = ide_find_port();
  340. if (hwif) {
  341. int i;
  342. /*
  343. * Ensure we're using MMIO
  344. */
  345. default_hwif_mmiops(hwif);
  346. hwif->mmio = 1;
  347. for (i = IDE_DATA_OFFSET; i <= IDE_STATUS_OFFSET; i++) {
  348. hwif->io_ports[i] = port;
  349. port += 1 << info->stepping;
  350. }
  351. hwif->io_ports[IDE_CONTROL_OFFSET] = (unsigned long)base + info->ctrloffset;
  352. hwif->irq = ec->irq;
  353. hwif->noprobe = 0;
  354. hwif->chipset = ide_acorn;
  355. hwif->gendev.parent = &ec->dev;
  356. hwif->dev = &ec->dev;
  357. }
  358. return hwif;
  359. }
  360. static int __init
  361. icside_register_v5(struct icside_state *state, struct expansion_card *ec)
  362. {
  363. ide_hwif_t *hwif;
  364. void __iomem *base;
  365. u8 idx[4] = { 0xff, 0xff, 0xff, 0xff };
  366. base = ecardm_iomap(ec, ECARD_RES_MEMC, 0, 0);
  367. if (!base)
  368. return -ENOMEM;
  369. state->irq_port = base;
  370. ec->irqaddr = base + ICS_ARCIN_V5_INTRSTAT;
  371. ec->irqmask = 1;
  372. ecard_setirq(ec, &icside_ops_arcin_v5, state);
  373. /*
  374. * Be on the safe side - disable interrupts
  375. */
  376. icside_irqdisable_arcin_v5(ec, 0);
  377. hwif = icside_setup(base, &icside_cardinfo_v5, ec);
  378. if (!hwif)
  379. return -ENODEV;
  380. state->hwif[0] = hwif;
  381. idx[0] = hwif->index;
  382. ide_device_add(idx, NULL);
  383. return 0;
  384. }
  385. static const struct ide_port_info icside_v6_port_info __initdata = {
  386. .port_ops = &icside_v6_no_dma_port_ops,
  387. .host_flags = IDE_HFLAG_SERIALIZE |
  388. IDE_HFLAG_NO_DMA | /* no SFF-style DMA */
  389. IDE_HFLAG_NO_AUTOTUNE,
  390. .mwdma_mask = ATA_MWDMA2,
  391. .swdma_mask = ATA_SWDMA2,
  392. };
  393. static int __init
  394. icside_register_v6(struct icside_state *state, struct expansion_card *ec)
  395. {
  396. ide_hwif_t *hwif, *mate;
  397. void __iomem *ioc_base, *easi_base;
  398. unsigned int sel = 0;
  399. int ret;
  400. u8 idx[4] = { 0xff, 0xff, 0xff, 0xff };
  401. struct ide_port_info d = icside_v6_port_info;
  402. ioc_base = ecardm_iomap(ec, ECARD_RES_IOCFAST, 0, 0);
  403. if (!ioc_base) {
  404. ret = -ENOMEM;
  405. goto out;
  406. }
  407. easi_base = ioc_base;
  408. if (ecard_resource_flags(ec, ECARD_RES_EASI)) {
  409. easi_base = ecardm_iomap(ec, ECARD_RES_EASI, 0, 0);
  410. if (!easi_base) {
  411. ret = -ENOMEM;
  412. goto out;
  413. }
  414. /*
  415. * Enable access to the EASI region.
  416. */
  417. sel = 1 << 5;
  418. }
  419. writeb(sel, ioc_base);
  420. ecard_setirq(ec, &icside_ops_arcin_v6, state);
  421. state->irq_port = easi_base;
  422. state->ioc_base = ioc_base;
  423. /*
  424. * Be on the safe side - disable interrupts
  425. */
  426. icside_irqdisable_arcin_v6(ec, 0);
  427. /*
  428. * Find and register the interfaces.
  429. */
  430. hwif = icside_setup(easi_base, &icside_cardinfo_v6_1, ec);
  431. mate = icside_setup(easi_base, &icside_cardinfo_v6_2, ec);
  432. if (!hwif || !mate) {
  433. ret = -ENODEV;
  434. goto out;
  435. }
  436. state->hwif[0] = hwif;
  437. state->hwif[1] = mate;
  438. hwif->hwif_data = state;
  439. hwif->config_data = (unsigned long)ioc_base;
  440. hwif->select_data = sel;
  441. mate->maskproc = icside_maskproc;
  442. mate->hwif_data = state;
  443. mate->config_data = (unsigned long)ioc_base;
  444. mate->select_data = sel | 1;
  445. if (ec->dma != NO_DMA && !request_dma(ec->dma, hwif->name)) {
  446. icside_dma_init(hwif);
  447. icside_dma_init(mate);
  448. d.port_ops = &icside_v6_dma_port_ops;
  449. } else
  450. d.mwdma_mask = d.swdma_mask = 0;
  451. idx[0] = hwif->index;
  452. idx[1] = mate->index;
  453. ide_device_add(idx, &d);
  454. return 0;
  455. out:
  456. return ret;
  457. }
  458. static int __devinit
  459. icside_probe(struct expansion_card *ec, const struct ecard_id *id)
  460. {
  461. struct icside_state *state;
  462. void __iomem *idmem;
  463. int ret;
  464. ret = ecard_request_resources(ec);
  465. if (ret)
  466. goto out;
  467. state = kzalloc(sizeof(struct icside_state), GFP_KERNEL);
  468. if (!state) {
  469. ret = -ENOMEM;
  470. goto release;
  471. }
  472. state->type = ICS_TYPE_NOTYPE;
  473. idmem = ecardm_iomap(ec, ECARD_RES_IOCFAST, 0, 0);
  474. if (idmem) {
  475. unsigned int type;
  476. type = readb(idmem + ICS_IDENT_OFFSET) & 1;
  477. type |= (readb(idmem + ICS_IDENT_OFFSET + 4) & 1) << 1;
  478. type |= (readb(idmem + ICS_IDENT_OFFSET + 8) & 1) << 2;
  479. type |= (readb(idmem + ICS_IDENT_OFFSET + 12) & 1) << 3;
  480. ecardm_iounmap(ec, idmem);
  481. state->type = type;
  482. }
  483. switch (state->type) {
  484. case ICS_TYPE_A3IN:
  485. dev_warn(&ec->dev, "A3IN unsupported\n");
  486. ret = -ENODEV;
  487. break;
  488. case ICS_TYPE_A3USER:
  489. dev_warn(&ec->dev, "A3USER unsupported\n");
  490. ret = -ENODEV;
  491. break;
  492. case ICS_TYPE_V5:
  493. ret = icside_register_v5(state, ec);
  494. break;
  495. case ICS_TYPE_V6:
  496. ret = icside_register_v6(state, ec);
  497. break;
  498. default:
  499. dev_warn(&ec->dev, "unknown interface type\n");
  500. ret = -ENODEV;
  501. break;
  502. }
  503. if (ret == 0) {
  504. ecard_set_drvdata(ec, state);
  505. goto out;
  506. }
  507. kfree(state);
  508. release:
  509. ecard_release_resources(ec);
  510. out:
  511. return ret;
  512. }
  513. static void __devexit icside_remove(struct expansion_card *ec)
  514. {
  515. struct icside_state *state = ecard_get_drvdata(ec);
  516. switch (state->type) {
  517. case ICS_TYPE_V5:
  518. /* FIXME: tell IDE to stop using the interface */
  519. /* Disable interrupts */
  520. icside_irqdisable_arcin_v5(ec, 0);
  521. break;
  522. case ICS_TYPE_V6:
  523. /* FIXME: tell IDE to stop using the interface */
  524. if (ec->dma != NO_DMA)
  525. free_dma(ec->dma);
  526. /* Disable interrupts */
  527. icside_irqdisable_arcin_v6(ec, 0);
  528. /* Reset the ROM pointer/EASI selection */
  529. writeb(0, state->ioc_base);
  530. break;
  531. }
  532. ecard_set_drvdata(ec, NULL);
  533. kfree(state);
  534. ecard_release_resources(ec);
  535. }
  536. static void icside_shutdown(struct expansion_card *ec)
  537. {
  538. struct icside_state *state = ecard_get_drvdata(ec);
  539. unsigned long flags;
  540. /*
  541. * Disable interrupts from this card. We need to do
  542. * this before disabling EASI since we may be accessing
  543. * this register via that region.
  544. */
  545. local_irq_save(flags);
  546. ec->ops->irqdisable(ec, 0);
  547. local_irq_restore(flags);
  548. /*
  549. * Reset the ROM pointer so that we can read the ROM
  550. * after a soft reboot. This also disables access to
  551. * the IDE taskfile via the EASI region.
  552. */
  553. if (state->ioc_base)
  554. writeb(0, state->ioc_base);
  555. }
  556. static const struct ecard_id icside_ids[] = {
  557. { MANU_ICS, PROD_ICS_IDE },
  558. { MANU_ICS2, PROD_ICS2_IDE },
  559. { 0xffff, 0xffff }
  560. };
  561. static struct ecard_driver icside_driver = {
  562. .probe = icside_probe,
  563. .remove = __devexit_p(icside_remove),
  564. .shutdown = icside_shutdown,
  565. .id_table = icside_ids,
  566. .drv = {
  567. .name = "icside",
  568. },
  569. };
  570. static int __init icside_init(void)
  571. {
  572. return ecard_register_driver(&icside_driver);
  573. }
  574. MODULE_AUTHOR("Russell King <rmk@arm.linux.org.uk>");
  575. MODULE_LICENSE("GPL");
  576. MODULE_DESCRIPTION("ICS IDE driver");
  577. module_init(icside_init);