pata_icside.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686
  1. #include <linux/kernel.h>
  2. #include <linux/module.h>
  3. #include <linux/init.h>
  4. #include <linux/blkdev.h>
  5. #include <scsi/scsi_host.h>
  6. #include <linux/ata.h>
  7. #include <linux/libata.h>
  8. #include <asm/dma.h>
  9. #include <asm/ecard.h>
  10. #define DRV_NAME "pata_icside"
  11. #define ICS_IDENT_OFFSET 0x2280
  12. #define ICS_ARCIN_V5_INTRSTAT 0x0000
  13. #define ICS_ARCIN_V5_INTROFFSET 0x0004
  14. #define ICS_ARCIN_V6_INTROFFSET_1 0x2200
  15. #define ICS_ARCIN_V6_INTRSTAT_1 0x2290
  16. #define ICS_ARCIN_V6_INTROFFSET_2 0x3200
  17. #define ICS_ARCIN_V6_INTRSTAT_2 0x3290
  18. struct portinfo {
  19. unsigned int dataoffset;
  20. unsigned int ctrloffset;
  21. unsigned int stepping;
  22. };
  23. static const struct portinfo pata_icside_portinfo_v5 = {
  24. .dataoffset = 0x2800,
  25. .ctrloffset = 0x2b80,
  26. .stepping = 6,
  27. };
  28. static const struct portinfo pata_icside_portinfo_v6_1 = {
  29. .dataoffset = 0x2000,
  30. .ctrloffset = 0x2380,
  31. .stepping = 6,
  32. };
  33. static const struct portinfo pata_icside_portinfo_v6_2 = {
  34. .dataoffset = 0x3000,
  35. .ctrloffset = 0x3380,
  36. .stepping = 6,
  37. };
  38. #define PATA_ICSIDE_MAX_SG 128
  39. struct pata_icside_state {
  40. void __iomem *irq_port;
  41. void __iomem *ioc_base;
  42. unsigned int type;
  43. unsigned int dma;
  44. struct {
  45. u8 port_sel;
  46. u8 disabled;
  47. unsigned int speed[ATA_MAX_DEVICES];
  48. } port[2];
  49. struct scatterlist sg[PATA_ICSIDE_MAX_SG];
  50. };
  51. #define ICS_TYPE_A3IN 0
  52. #define ICS_TYPE_A3USER 1
  53. #define ICS_TYPE_V6 3
  54. #define ICS_TYPE_V5 15
  55. #define ICS_TYPE_NOTYPE ((unsigned int)-1)
  56. /* ---------------- Version 5 PCB Support Functions --------------------- */
  57. /* Prototype: pata_icside_irqenable_arcin_v5 (struct expansion_card *ec, int irqnr)
  58. * Purpose : enable interrupts from card
  59. */
  60. static void pata_icside_irqenable_arcin_v5 (struct expansion_card *ec, int irqnr)
  61. {
  62. struct pata_icside_state *state = ec->irq_data;
  63. writeb(0, state->irq_port + ICS_ARCIN_V5_INTROFFSET);
  64. }
  65. /* Prototype: pata_icside_irqdisable_arcin_v5 (struct expansion_card *ec, int irqnr)
  66. * Purpose : disable interrupts from card
  67. */
  68. static void pata_icside_irqdisable_arcin_v5 (struct expansion_card *ec, int irqnr)
  69. {
  70. struct pata_icside_state *state = ec->irq_data;
  71. readb(state->irq_port + ICS_ARCIN_V5_INTROFFSET);
  72. }
  73. static const expansioncard_ops_t pata_icside_ops_arcin_v5 = {
  74. .irqenable = pata_icside_irqenable_arcin_v5,
  75. .irqdisable = pata_icside_irqdisable_arcin_v5,
  76. };
  77. /* ---------------- Version 6 PCB Support Functions --------------------- */
  78. /* Prototype: pata_icside_irqenable_arcin_v6 (struct expansion_card *ec, int irqnr)
  79. * Purpose : enable interrupts from card
  80. */
  81. static void pata_icside_irqenable_arcin_v6 (struct expansion_card *ec, int irqnr)
  82. {
  83. struct pata_icside_state *state = ec->irq_data;
  84. void __iomem *base = state->irq_port;
  85. if (!state->port[0].disabled)
  86. writeb(0, base + ICS_ARCIN_V6_INTROFFSET_1);
  87. if (!state->port[1].disabled)
  88. writeb(0, base + ICS_ARCIN_V6_INTROFFSET_2);
  89. }
  90. /* Prototype: pata_icside_irqdisable_arcin_v6 (struct expansion_card *ec, int irqnr)
  91. * Purpose : disable interrupts from card
  92. */
  93. static void pata_icside_irqdisable_arcin_v6 (struct expansion_card *ec, int irqnr)
  94. {
  95. struct pata_icside_state *state = ec->irq_data;
  96. readb(state->irq_port + ICS_ARCIN_V6_INTROFFSET_1);
  97. readb(state->irq_port + ICS_ARCIN_V6_INTROFFSET_2);
  98. }
  99. /* Prototype: pata_icside_irqprobe(struct expansion_card *ec)
  100. * Purpose : detect an active interrupt from card
  101. */
  102. static int pata_icside_irqpending_arcin_v6(struct expansion_card *ec)
  103. {
  104. struct pata_icside_state *state = ec->irq_data;
  105. return readb(state->irq_port + ICS_ARCIN_V6_INTRSTAT_1) & 1 ||
  106. readb(state->irq_port + ICS_ARCIN_V6_INTRSTAT_2) & 1;
  107. }
  108. static const expansioncard_ops_t pata_icside_ops_arcin_v6 = {
  109. .irqenable = pata_icside_irqenable_arcin_v6,
  110. .irqdisable = pata_icside_irqdisable_arcin_v6,
  111. .irqpending = pata_icside_irqpending_arcin_v6,
  112. };
  113. /*
  114. * SG-DMA support.
  115. *
  116. * Similar to the BM-DMA, but we use the RiscPCs IOMD DMA controllers.
  117. * There is only one DMA controller per card, which means that only
  118. * one drive can be accessed at one time. NOTE! We do not enforce that
  119. * here, but we rely on the main IDE driver spotting that both
  120. * interfaces use the same IRQ, which should guarantee this.
  121. */
  122. /*
  123. * Configure the IOMD to give the appropriate timings for the transfer
  124. * mode being requested. We take the advice of the ATA standards, and
  125. * calculate the cycle time based on the transfer mode, and the EIDE
  126. * MW DMA specs that the drive provides in the IDENTIFY command.
  127. *
  128. * We have the following IOMD DMA modes to choose from:
  129. *
  130. * Type Active Recovery Cycle
  131. * A 250 (250) 312 (550) 562 (800)
  132. * B 187 (200) 250 (550) 437 (750)
  133. * C 125 (125) 125 (375) 250 (500)
  134. * D 62 (50) 125 (375) 187 (425)
  135. *
  136. * (figures in brackets are actual measured timings on DIOR/DIOW)
  137. *
  138. * However, we also need to take care of the read/write active and
  139. * recovery timings:
  140. *
  141. * Read Write
  142. * Mode Active -- Recovery -- Cycle IOMD type
  143. * MW0 215 50 215 480 A
  144. * MW1 80 50 50 150 C
  145. * MW2 70 25 25 120 C
  146. */
  147. static void pata_icside_set_dmamode(struct ata_port *ap, struct ata_device *adev)
  148. {
  149. struct pata_icside_state *state = ap->host->private_data;
  150. struct ata_timing t;
  151. unsigned int cycle;
  152. char iomd_type;
  153. /*
  154. * DMA is based on a 16MHz clock
  155. */
  156. if (ata_timing_compute(adev, adev->dma_mode, &t, 1000, 1))
  157. return;
  158. /*
  159. * Choose the IOMD cycle timing which ensure that the interface
  160. * satisfies the measured active, recovery and cycle times.
  161. */
  162. if (t.active <= 50 && t.recover <= 375 && t.cycle <= 425)
  163. iomd_type = 'D', cycle = 187;
  164. else if (t.active <= 125 && t.recover <= 375 && t.cycle <= 500)
  165. iomd_type = 'C', cycle = 250;
  166. else if (t.active <= 200 && t.recover <= 550 && t.cycle <= 750)
  167. iomd_type = 'B', cycle = 437;
  168. else
  169. iomd_type = 'A', cycle = 562;
  170. ata_dev_printk(adev, KERN_INFO, "timings: act %dns rec %dns cyc %dns (%c)\n",
  171. t.active, t.recover, t.cycle, iomd_type);
  172. state->port[ap->port_no].speed[adev->devno] = cycle;
  173. }
  174. static void pata_icside_bmdma_setup(struct ata_queued_cmd *qc)
  175. {
  176. struct ata_port *ap = qc->ap;
  177. struct pata_icside_state *state = ap->host->private_data;
  178. struct scatterlist *sg, *rsg = state->sg;
  179. unsigned int write = qc->tf.flags & ATA_TFLAG_WRITE;
  180. /*
  181. * We are simplex; BUG if we try to fiddle with DMA
  182. * while it's active.
  183. */
  184. BUG_ON(dma_channel_active(state->dma));
  185. /*
  186. * Copy ATAs scattered sg list into a contiguous array of sg
  187. */
  188. ata_for_each_sg(sg, qc) {
  189. memcpy(rsg, sg, sizeof(*sg));
  190. rsg++;
  191. }
  192. /*
  193. * Route the DMA signals to the correct interface
  194. */
  195. writeb(state->port[ap->port_no].port_sel, state->ioc_base);
  196. set_dma_speed(state->dma, state->port[ap->port_no].speed[qc->dev->devno]);
  197. set_dma_sg(state->dma, state->sg, rsg - state->sg);
  198. set_dma_mode(state->dma, write ? DMA_MODE_WRITE : DMA_MODE_READ);
  199. /* issue r/w command */
  200. ap->ops->exec_command(ap, &qc->tf);
  201. }
  202. static void pata_icside_bmdma_start(struct ata_queued_cmd *qc)
  203. {
  204. struct ata_port *ap = qc->ap;
  205. struct pata_icside_state *state = ap->host->private_data;
  206. BUG_ON(dma_channel_active(state->dma));
  207. enable_dma(state->dma);
  208. }
  209. static void pata_icside_bmdma_stop(struct ata_queued_cmd *qc)
  210. {
  211. struct ata_port *ap = qc->ap;
  212. struct pata_icside_state *state = ap->host->private_data;
  213. disable_dma(state->dma);
  214. /* see ata_bmdma_stop */
  215. ata_altstatus(ap);
  216. }
  217. static u8 pata_icside_bmdma_status(struct ata_port *ap)
  218. {
  219. struct pata_icside_state *state = ap->host->private_data;
  220. void __iomem *irq_port;
  221. irq_port = state->irq_port + (ap->port_no ? ICS_ARCIN_V6_INTRSTAT_2 :
  222. ICS_ARCIN_V6_INTRSTAT_1);
  223. return readb(irq_port) & 1 ? ATA_DMA_INTR : 0;
  224. }
  225. static int icside_dma_init(struct ata_probe_ent *ae, struct expansion_card *ec)
  226. {
  227. struct pata_icside_state *state = ae->private_data;
  228. int i;
  229. for (i = 0; i < ATA_MAX_DEVICES; i++) {
  230. state->port[0].speed[i] = 480;
  231. state->port[1].speed[i] = 480;
  232. }
  233. if (ec->dma != NO_DMA && !request_dma(ec->dma, DRV_NAME)) {
  234. state->dma = ec->dma;
  235. ae->mwdma_mask = 0x07; /* MW0..2 */
  236. }
  237. return 0;
  238. }
  239. static int pata_icside_port_start(struct ata_port *ap)
  240. {
  241. /* No PRD to alloc */
  242. return ata_pad_alloc(ap, ap->dev);
  243. }
  244. static struct scsi_host_template pata_icside_sht = {
  245. .module = THIS_MODULE,
  246. .name = DRV_NAME,
  247. .ioctl = ata_scsi_ioctl,
  248. .queuecommand = ata_scsi_queuecmd,
  249. .can_queue = ATA_DEF_QUEUE,
  250. .this_id = ATA_SHT_THIS_ID,
  251. .sg_tablesize = PATA_ICSIDE_MAX_SG,
  252. .cmd_per_lun = ATA_SHT_CMD_PER_LUN,
  253. .emulated = ATA_SHT_EMULATED,
  254. .use_clustering = ATA_SHT_USE_CLUSTERING,
  255. .proc_name = DRV_NAME,
  256. .dma_boundary = ~0, /* no dma boundaries */
  257. .slave_configure = ata_scsi_slave_config,
  258. .slave_destroy = ata_scsi_slave_destroy,
  259. .bios_param = ata_std_bios_param,
  260. };
  261. /* wish this was exported from libata-core */
  262. static void ata_dummy_noret(struct ata_port *port)
  263. {
  264. }
  265. /*
  266. * We need to shut down unused ports to prevent spurious interrupts.
  267. * FIXME: the libata core doesn't call this function for PATA interfaces.
  268. */
  269. static void pata_icside_port_disable(struct ata_port *ap)
  270. {
  271. struct pata_icside_state *state = ap->host->private_data;
  272. ata_port_printk(ap, KERN_ERR, "disabling icside port\n");
  273. ata_port_disable(ap);
  274. state->port[ap->port_no].disabled = 1;
  275. if (state->type == ICS_TYPE_V6) {
  276. /*
  277. * Disable interrupts from this port, otherwise we
  278. * receive spurious interrupts from the floating
  279. * interrupt line.
  280. */
  281. void __iomem *irq_port = state->irq_port +
  282. (ap->port_no ? ICS_ARCIN_V6_INTROFFSET_2 : ICS_ARCIN_V6_INTROFFSET_1);
  283. readb(irq_port);
  284. }
  285. }
  286. static u8 pata_icside_irq_ack(struct ata_port *ap, unsigned int chk_drq)
  287. {
  288. unsigned int bits = chk_drq ? ATA_BUSY | ATA_DRQ : ATA_BUSY;
  289. u8 status;
  290. status = ata_busy_wait(ap, bits, 1000);
  291. if (status & bits)
  292. if (ata_msg_err(ap))
  293. printk(KERN_ERR "abnormal status 0x%X\n", status);
  294. if (ata_msg_intr(ap))
  295. printk(KERN_INFO "%s: irq ack: drv_stat 0x%X\n",
  296. __FUNCTION__, status);
  297. return status;
  298. }
  299. static struct ata_port_operations pata_icside_port_ops = {
  300. .port_disable = pata_icside_port_disable,
  301. .set_dmamode = pata_icside_set_dmamode,
  302. .tf_load = ata_tf_load,
  303. .tf_read = ata_tf_read,
  304. .exec_command = ata_exec_command,
  305. .check_status = ata_check_status,
  306. .dev_select = ata_std_dev_select,
  307. .bmdma_setup = pata_icside_bmdma_setup,
  308. .bmdma_start = pata_icside_bmdma_start,
  309. .data_xfer = ata_data_xfer_noirq,
  310. /* no need to build any PRD tables for DMA */
  311. .qc_prep = ata_noop_qc_prep,
  312. .qc_issue = ata_qc_issue_prot,
  313. .freeze = ata_bmdma_freeze,
  314. .thaw = ata_bmdma_thaw,
  315. .error_handler = ata_bmdma_error_handler,
  316. .post_internal_cmd = pata_icside_bmdma_stop,
  317. .irq_handler = ata_interrupt,
  318. .irq_clear = ata_dummy_noret,
  319. .irq_on = ata_irq_on,
  320. .irq_ack = pata_icside_irq_ack,
  321. .port_start = pata_icside_port_start,
  322. .bmdma_stop = pata_icside_bmdma_stop,
  323. .bmdma_status = pata_icside_bmdma_status,
  324. };
  325. static void
  326. pata_icside_add_port(struct ata_probe_ent *ae, void __iomem *base,
  327. const struct portinfo *info)
  328. {
  329. struct ata_ioports *ioaddr = &ae->port[ae->n_ports++];
  330. void __iomem *cmd = base + info->dataoffset;
  331. ioaddr->cmd_addr = cmd;
  332. ioaddr->data_addr = cmd + (ATA_REG_DATA << info->stepping);
  333. ioaddr->error_addr = cmd + (ATA_REG_ERR << info->stepping);
  334. ioaddr->feature_addr = cmd + (ATA_REG_FEATURE << info->stepping);
  335. ioaddr->nsect_addr = cmd + (ATA_REG_NSECT << info->stepping);
  336. ioaddr->lbal_addr = cmd + (ATA_REG_LBAL << info->stepping);
  337. ioaddr->lbam_addr = cmd + (ATA_REG_LBAM << info->stepping);
  338. ioaddr->lbah_addr = cmd + (ATA_REG_LBAH << info->stepping);
  339. ioaddr->device_addr = cmd + (ATA_REG_DEVICE << info->stepping);
  340. ioaddr->status_addr = cmd + (ATA_REG_STATUS << info->stepping);
  341. ioaddr->command_addr = cmd + (ATA_REG_CMD << info->stepping);
  342. ioaddr->ctl_addr = base + info->ctrloffset;
  343. ioaddr->altstatus_addr = ioaddr->ctl_addr;
  344. }
  345. static int __init
  346. pata_icside_register_v5(struct ata_probe_ent *ae, struct expansion_card *ec)
  347. {
  348. struct pata_icside_state *state = ae->private_data;
  349. void __iomem *base;
  350. base = ioremap(ecard_resource_start(ec, ECARD_RES_MEMC),
  351. ecard_resource_len(ec, ECARD_RES_MEMC));
  352. if (!base)
  353. return -ENOMEM;
  354. state->irq_port = base;
  355. ec->irqaddr = base + ICS_ARCIN_V5_INTRSTAT;
  356. ec->irqmask = 1;
  357. ec->irq_data = state;
  358. ec->ops = &pata_icside_ops_arcin_v5;
  359. /*
  360. * Be on the safe side - disable interrupts
  361. */
  362. ec->ops->irqdisable(ec, ec->irq);
  363. pata_icside_add_port(ae, base, &pata_icside_portinfo_v5);
  364. return 0;
  365. }
  366. static int __init
  367. pata_icside_register_v6(struct ata_probe_ent *ae, struct expansion_card *ec)
  368. {
  369. struct pata_icside_state *state = ae->private_data;
  370. void __iomem *ioc_base, *easi_base;
  371. unsigned int sel = 0;
  372. int ret;
  373. ioc_base = ioremap(ecard_resource_start(ec, ECARD_RES_IOCFAST),
  374. ecard_resource_len(ec, ECARD_RES_IOCFAST));
  375. if (!ioc_base) {
  376. ret = -ENOMEM;
  377. goto out;
  378. }
  379. easi_base = ioc_base;
  380. if (ecard_resource_flags(ec, ECARD_RES_EASI)) {
  381. easi_base = ioremap(ecard_resource_start(ec, ECARD_RES_EASI),
  382. ecard_resource_len(ec, ECARD_RES_EASI));
  383. if (!easi_base) {
  384. ret = -ENOMEM;
  385. goto unmap_slot;
  386. }
  387. /*
  388. * Enable access to the EASI region.
  389. */
  390. sel = 1 << 5;
  391. }
  392. writeb(sel, ioc_base);
  393. ec->irq_data = state;
  394. ec->ops = &pata_icside_ops_arcin_v6;
  395. state->irq_port = easi_base;
  396. state->ioc_base = ioc_base;
  397. state->port[0].port_sel = sel;
  398. state->port[1].port_sel = sel | 1;
  399. /*
  400. * Be on the safe side - disable interrupts
  401. */
  402. ec->ops->irqdisable(ec, ec->irq);
  403. /*
  404. * Find and register the interfaces.
  405. */
  406. pata_icside_add_port(ae, easi_base, &pata_icside_portinfo_v6_1);
  407. pata_icside_add_port(ae, easi_base, &pata_icside_portinfo_v6_2);
  408. /*
  409. * FIXME: work around libata's aversion to calling port_disable.
  410. * This permanently disables interrupts on port 0 - bad luck if
  411. * you have a drive on that port.
  412. */
  413. state->port[0].disabled = 1;
  414. return icside_dma_init(ae, ec);
  415. unmap_slot:
  416. iounmap(ioc_base);
  417. out:
  418. return ret;
  419. }
  420. static int __devinit
  421. pata_icside_probe(struct expansion_card *ec, const struct ecard_id *id)
  422. {
  423. struct pata_icside_state *state;
  424. struct ata_probe_ent ae;
  425. void __iomem *idmem;
  426. int ret;
  427. ret = ecard_request_resources(ec);
  428. if (ret)
  429. goto out;
  430. state = kzalloc(sizeof(struct pata_icside_state), GFP_KERNEL);
  431. if (!state) {
  432. ret = -ENOMEM;
  433. goto release;
  434. }
  435. state->type = ICS_TYPE_NOTYPE;
  436. state->dma = NO_DMA;
  437. idmem = ioremap(ecard_resource_start(ec, ECARD_RES_IOCFAST),
  438. ecard_resource_len(ec, ECARD_RES_IOCFAST));
  439. if (idmem) {
  440. unsigned int type;
  441. type = readb(idmem + ICS_IDENT_OFFSET) & 1;
  442. type |= (readb(idmem + ICS_IDENT_OFFSET + 4) & 1) << 1;
  443. type |= (readb(idmem + ICS_IDENT_OFFSET + 8) & 1) << 2;
  444. type |= (readb(idmem + ICS_IDENT_OFFSET + 12) & 1) << 3;
  445. iounmap(idmem);
  446. state->type = type;
  447. }
  448. memset(&ae, 0, sizeof(ae));
  449. INIT_LIST_HEAD(&ae.node);
  450. ae.dev = &ec->dev;
  451. ae.port_ops = &pata_icside_port_ops;
  452. ae.sht = &pata_icside_sht;
  453. ae.pio_mask = 0x1f;
  454. ae.irq = ec->irq;
  455. ae.port_flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST;
  456. ae._host_flags = ATA_HOST_SIMPLEX;
  457. ae.private_data = state;
  458. switch (state->type) {
  459. case ICS_TYPE_A3IN:
  460. dev_warn(&ec->dev, "A3IN unsupported\n");
  461. ret = -ENODEV;
  462. break;
  463. case ICS_TYPE_A3USER:
  464. dev_warn(&ec->dev, "A3USER unsupported\n");
  465. ret = -ENODEV;
  466. break;
  467. case ICS_TYPE_V5:
  468. ret = pata_icside_register_v5(&ae, ec);
  469. break;
  470. case ICS_TYPE_V6:
  471. ret = pata_icside_register_v6(&ae, ec);
  472. break;
  473. default:
  474. dev_warn(&ec->dev, "unknown interface type\n");
  475. ret = -ENODEV;
  476. break;
  477. }
  478. if (ret == 0)
  479. ret = ata_device_add(&ae) == 0 ? -ENODEV : 0;
  480. if (ret == 0)
  481. goto out;
  482. kfree(state);
  483. release:
  484. ecard_release_resources(ec);
  485. out:
  486. return ret;
  487. }
  488. static void pata_icside_shutdown(struct expansion_card *ec)
  489. {
  490. struct ata_host *host = ecard_get_drvdata(ec);
  491. unsigned long flags;
  492. /*
  493. * Disable interrupts from this card. We need to do
  494. * this before disabling EASI since we may be accessing
  495. * this register via that region.
  496. */
  497. local_irq_save(flags);
  498. if (ec->ops)
  499. ec->ops->irqdisable(ec, ec->irq);
  500. local_irq_restore(flags);
  501. /*
  502. * Reset the ROM pointer so that we can read the ROM
  503. * after a soft reboot. This also disables access to
  504. * the IDE taskfile via the EASI region.
  505. */
  506. if (host) {
  507. struct pata_icside_state *state = host->private_data;
  508. if (state->ioc_base)
  509. writeb(0, state->ioc_base);
  510. }
  511. }
  512. static void __devexit pata_icside_remove(struct expansion_card *ec)
  513. {
  514. struct ata_host *host = ecard_get_drvdata(ec);
  515. struct pata_icside_state *state = host->private_data;
  516. ata_host_detach(host);
  517. pata_icside_shutdown(ec);
  518. /*
  519. * don't NULL out the drvdata - devres/libata wants it
  520. * to free the ata_host structure.
  521. */
  522. ec->ops = NULL;
  523. ec->irq_data = NULL;
  524. if (state->dma != NO_DMA)
  525. free_dma(state->dma);
  526. if (state->ioc_base)
  527. iounmap(state->ioc_base);
  528. if (state->ioc_base != state->irq_port)
  529. iounmap(state->irq_port);
  530. kfree(state);
  531. ecard_release_resources(ec);
  532. }
  533. static const struct ecard_id pata_icside_ids[] = {
  534. { MANU_ICS, PROD_ICS_IDE },
  535. { MANU_ICS2, PROD_ICS2_IDE },
  536. { 0xffff, 0xffff }
  537. };
  538. static struct ecard_driver pata_icside_driver = {
  539. .probe = pata_icside_probe,
  540. .remove = __devexit_p(pata_icside_remove),
  541. .shutdown = pata_icside_shutdown,
  542. .id_table = pata_icside_ids,
  543. .drv = {
  544. .name = DRV_NAME,
  545. },
  546. };
  547. static int __init pata_icside_init(void)
  548. {
  549. return ecard_register_driver(&pata_icside_driver);
  550. }
  551. static void __exit pata_icside_exit(void)
  552. {
  553. ecard_remove_driver(&pata_icside_driver);
  554. }
  555. MODULE_AUTHOR("Russell King <rmk@arm.linux.org.uk>");
  556. MODULE_LICENSE("GPL");
  557. MODULE_DESCRIPTION("ICS PATA driver");
  558. module_init(pata_icside_init);
  559. module_exit(pata_icside_exit);