icside.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721
  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 int icside_dma_init(ide_hwif_t *hwif, const struct ide_port_info *d)
  319. {
  320. hwif->dmatable_cpu = NULL;
  321. hwif->dmatable_dma = 0;
  322. return 0;
  323. }
  324. static const struct ide_dma_ops icside_v6_dma_ops = {
  325. .dma_host_set = icside_dma_host_set,
  326. .dma_setup = icside_dma_setup,
  327. .dma_exec_cmd = icside_dma_exec_cmd,
  328. .dma_start = icside_dma_start,
  329. .dma_end = icside_dma_end,
  330. .dma_test_irq = icside_dma_test_irq,
  331. .dma_timeout = icside_dma_timeout,
  332. .dma_lost_irq = icside_dma_lost_irq,
  333. };
  334. #else
  335. #define icside_v6_dma_ops NULL
  336. #endif
  337. static int icside_dma_off_init(ide_hwif_t *hwif, const struct ide_port_info *d)
  338. {
  339. return -EOPNOTSUPP;
  340. }
  341. static ide_hwif_t *
  342. icside_setup(void __iomem *base, struct cardinfo *info, struct expansion_card *ec)
  343. {
  344. unsigned long port = (unsigned long)base + info->dataoffset;
  345. ide_hwif_t *hwif;
  346. hwif = ide_find_port();
  347. if (hwif) {
  348. /*
  349. * Ensure we're using MMIO
  350. */
  351. default_hwif_mmiops(hwif);
  352. hwif->io_ports.data_addr = port;
  353. hwif->io_ports.error_addr = port + (1 << info->stepping);
  354. hwif->io_ports.nsect_addr = port + (2 << info->stepping);
  355. hwif->io_ports.lbal_addr = port + (3 << info->stepping);
  356. hwif->io_ports.lbam_addr = port + (4 << info->stepping);
  357. hwif->io_ports.lbah_addr = port + (5 << info->stepping);
  358. hwif->io_ports.device_addr = port + (6 << info->stepping);
  359. hwif->io_ports.status_addr = port + (7 << info->stepping);
  360. hwif->io_ports.ctl_addr =
  361. (unsigned long)base + info->ctrloffset;
  362. hwif->irq = ec->irq;
  363. hwif->chipset = ide_acorn;
  364. hwif->gendev.parent = &ec->dev;
  365. hwif->dev = &ec->dev;
  366. }
  367. return hwif;
  368. }
  369. static int __init
  370. icside_register_v5(struct icside_state *state, struct expansion_card *ec)
  371. {
  372. ide_hwif_t *hwif;
  373. void __iomem *base;
  374. u8 idx[4] = { 0xff, 0xff, 0xff, 0xff };
  375. base = ecardm_iomap(ec, ECARD_RES_MEMC, 0, 0);
  376. if (!base)
  377. return -ENOMEM;
  378. state->irq_port = base;
  379. ec->irqaddr = base + ICS_ARCIN_V5_INTRSTAT;
  380. ec->irqmask = 1;
  381. ecard_setirq(ec, &icside_ops_arcin_v5, state);
  382. /*
  383. * Be on the safe side - disable interrupts
  384. */
  385. icside_irqdisable_arcin_v5(ec, 0);
  386. hwif = icside_setup(base, &icside_cardinfo_v5, ec);
  387. if (!hwif)
  388. return -ENODEV;
  389. state->hwif[0] = hwif;
  390. idx[0] = hwif->index;
  391. ide_device_add(idx, NULL);
  392. return 0;
  393. }
  394. static const struct ide_port_info icside_v6_port_info __initdata = {
  395. .init_dma = icside_dma_off_init,
  396. .port_ops = &icside_v6_no_dma_port_ops,
  397. .dma_ops = &icside_v6_dma_ops,
  398. .host_flags = IDE_HFLAG_SERIALIZE | IDE_HFLAG_MMIO,
  399. .mwdma_mask = ATA_MWDMA2,
  400. .swdma_mask = ATA_SWDMA2,
  401. };
  402. static int __init
  403. icside_register_v6(struct icside_state *state, struct expansion_card *ec)
  404. {
  405. ide_hwif_t *hwif, *mate;
  406. void __iomem *ioc_base, *easi_base;
  407. unsigned int sel = 0;
  408. int ret;
  409. u8 idx[4] = { 0xff, 0xff, 0xff, 0xff };
  410. struct ide_port_info d = icside_v6_port_info;
  411. ioc_base = ecardm_iomap(ec, ECARD_RES_IOCFAST, 0, 0);
  412. if (!ioc_base) {
  413. ret = -ENOMEM;
  414. goto out;
  415. }
  416. easi_base = ioc_base;
  417. if (ecard_resource_flags(ec, ECARD_RES_EASI)) {
  418. easi_base = ecardm_iomap(ec, ECARD_RES_EASI, 0, 0);
  419. if (!easi_base) {
  420. ret = -ENOMEM;
  421. goto out;
  422. }
  423. /*
  424. * Enable access to the EASI region.
  425. */
  426. sel = 1 << 5;
  427. }
  428. writeb(sel, ioc_base);
  429. ecard_setirq(ec, &icside_ops_arcin_v6, state);
  430. state->irq_port = easi_base;
  431. state->ioc_base = ioc_base;
  432. /*
  433. * Be on the safe side - disable interrupts
  434. */
  435. icside_irqdisable_arcin_v6(ec, 0);
  436. /*
  437. * Find and register the interfaces.
  438. */
  439. hwif = icside_setup(easi_base, &icside_cardinfo_v6_1, ec);
  440. mate = icside_setup(easi_base, &icside_cardinfo_v6_2, ec);
  441. if (!hwif || !mate) {
  442. ret = -ENODEV;
  443. goto out;
  444. }
  445. state->hwif[0] = hwif;
  446. state->hwif[1] = mate;
  447. hwif->hwif_data = state;
  448. hwif->config_data = (unsigned long)ioc_base;
  449. hwif->select_data = sel;
  450. mate->hwif_data = state;
  451. mate->config_data = (unsigned long)ioc_base;
  452. mate->select_data = sel | 1;
  453. if (ec->dma != NO_DMA && !request_dma(ec->dma, hwif->name)) {
  454. d.init_dma = icside_dma_init;
  455. d.port_ops = &icside_v6_port_ops;
  456. d.dma_ops = NULL;
  457. }
  458. idx[0] = hwif->index;
  459. idx[1] = mate->index;
  460. ide_device_add(idx, &d);
  461. return 0;
  462. out:
  463. return ret;
  464. }
  465. static int __devinit
  466. icside_probe(struct expansion_card *ec, const struct ecard_id *id)
  467. {
  468. struct icside_state *state;
  469. void __iomem *idmem;
  470. int ret;
  471. ret = ecard_request_resources(ec);
  472. if (ret)
  473. goto out;
  474. state = kzalloc(sizeof(struct icside_state), GFP_KERNEL);
  475. if (!state) {
  476. ret = -ENOMEM;
  477. goto release;
  478. }
  479. state->type = ICS_TYPE_NOTYPE;
  480. idmem = ecardm_iomap(ec, ECARD_RES_IOCFAST, 0, 0);
  481. if (idmem) {
  482. unsigned int type;
  483. type = readb(idmem + ICS_IDENT_OFFSET) & 1;
  484. type |= (readb(idmem + ICS_IDENT_OFFSET + 4) & 1) << 1;
  485. type |= (readb(idmem + ICS_IDENT_OFFSET + 8) & 1) << 2;
  486. type |= (readb(idmem + ICS_IDENT_OFFSET + 12) & 1) << 3;
  487. ecardm_iounmap(ec, idmem);
  488. state->type = type;
  489. }
  490. switch (state->type) {
  491. case ICS_TYPE_A3IN:
  492. dev_warn(&ec->dev, "A3IN unsupported\n");
  493. ret = -ENODEV;
  494. break;
  495. case ICS_TYPE_A3USER:
  496. dev_warn(&ec->dev, "A3USER unsupported\n");
  497. ret = -ENODEV;
  498. break;
  499. case ICS_TYPE_V5:
  500. ret = icside_register_v5(state, ec);
  501. break;
  502. case ICS_TYPE_V6:
  503. ret = icside_register_v6(state, ec);
  504. break;
  505. default:
  506. dev_warn(&ec->dev, "unknown interface type\n");
  507. ret = -ENODEV;
  508. break;
  509. }
  510. if (ret == 0) {
  511. ecard_set_drvdata(ec, state);
  512. goto out;
  513. }
  514. kfree(state);
  515. release:
  516. ecard_release_resources(ec);
  517. out:
  518. return ret;
  519. }
  520. static void __devexit icside_remove(struct expansion_card *ec)
  521. {
  522. struct icside_state *state = ecard_get_drvdata(ec);
  523. switch (state->type) {
  524. case ICS_TYPE_V5:
  525. /* FIXME: tell IDE to stop using the interface */
  526. /* Disable interrupts */
  527. icside_irqdisable_arcin_v5(ec, 0);
  528. break;
  529. case ICS_TYPE_V6:
  530. /* FIXME: tell IDE to stop using the interface */
  531. if (ec->dma != NO_DMA)
  532. free_dma(ec->dma);
  533. /* Disable interrupts */
  534. icside_irqdisable_arcin_v6(ec, 0);
  535. /* Reset the ROM pointer/EASI selection */
  536. writeb(0, state->ioc_base);
  537. break;
  538. }
  539. ecard_set_drvdata(ec, NULL);
  540. kfree(state);
  541. ecard_release_resources(ec);
  542. }
  543. static void icside_shutdown(struct expansion_card *ec)
  544. {
  545. struct icside_state *state = ecard_get_drvdata(ec);
  546. unsigned long flags;
  547. /*
  548. * Disable interrupts from this card. We need to do
  549. * this before disabling EASI since we may be accessing
  550. * this register via that region.
  551. */
  552. local_irq_save(flags);
  553. ec->ops->irqdisable(ec, 0);
  554. local_irq_restore(flags);
  555. /*
  556. * Reset the ROM pointer so that we can read the ROM
  557. * after a soft reboot. This also disables access to
  558. * the IDE taskfile via the EASI region.
  559. */
  560. if (state->ioc_base)
  561. writeb(0, state->ioc_base);
  562. }
  563. static const struct ecard_id icside_ids[] = {
  564. { MANU_ICS, PROD_ICS_IDE },
  565. { MANU_ICS2, PROD_ICS2_IDE },
  566. { 0xffff, 0xffff }
  567. };
  568. static struct ecard_driver icside_driver = {
  569. .probe = icside_probe,
  570. .remove = __devexit_p(icside_remove),
  571. .shutdown = icside_shutdown,
  572. .id_table = icside_ids,
  573. .drv = {
  574. .name = "icside",
  575. },
  576. };
  577. static int __init icside_init(void)
  578. {
  579. return ecard_register_driver(&icside_driver);
  580. }
  581. MODULE_AUTHOR("Russell King <rmk@arm.linux.org.uk>");
  582. MODULE_LICENSE("GPL");
  583. MODULE_DESCRIPTION("ICS IDE driver");
  584. module_init(icside_init);