icside.c 16 KB

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