icside.c 17 KB

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