blob: c4da3dd39f5cf502b9a942752b0d48ded74cee03 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
Linus Torvalds1da177e2005-04-16 15:20:36 -07002 * Copyright (c) 1996-2002 Russell King.
3 */
4
5#include <linux/module.h>
6#include <linux/slab.h>
7#include <linux/blkdev.h>
8#include <linux/errno.h>
9#include <linux/ide.h>
10#include <linux/init.h>
11
12#include <asm/ecard.h>
13
Al Viro1137fb62008-10-26 05:40:26 +000014static const struct ide_port_info rapide_port_info = {
Bartlomiej Zolnierkiewicz9a5ae1f2008-07-16 20:33:42 +020015 .host_flags = IDE_HFLAG_MMIO | IDE_HFLAG_NO_DMA,
Bartlomiej Zolnierkiewicz29e52cf2009-05-17 19:12:22 +020016 .chipset = ide_generic,
Bartlomiej Zolnierkiewicz9a5ae1f2008-07-16 20:33:42 +020017};
18
Bartlomiej Zolnierkiewicz57c802e2008-01-26 20:13:05 +010019static void rapide_setup_ports(hw_regs_t *hw, void __iomem *base,
20 void __iomem *ctrl, unsigned int sz, int irq)
Linus Torvalds1da177e2005-04-16 15:20:36 -070021{
22 unsigned long port = (unsigned long)base;
Bartlomiej Zolnierkiewiczbaa8f3e2007-10-20 00:32:31 +020023 int i;
Linus Torvalds1da177e2005-04-16 15:20:36 -070024
Bartlomiej Zolnierkiewicz4c3032d2008-04-27 15:38:32 +020025 for (i = 0; i <= 7; i++) {
26 hw->io_ports_array[i] = port;
Linus Torvalds1da177e2005-04-16 15:20:36 -070027 port += sz;
28 }
Bartlomiej Zolnierkiewicz4c3032d2008-04-27 15:38:32 +020029 hw->io_ports.ctl_addr = (unsigned long)ctrl;
Bartlomiej Zolnierkiewicz57c802e2008-01-26 20:13:05 +010030 hw->irq = irq;
Linus Torvalds1da177e2005-04-16 15:20:36 -070031}
32
33static int __devinit
34rapide_probe(struct expansion_card *ec, const struct ecard_id *id)
35{
Linus Torvalds1da177e2005-04-16 15:20:36 -070036 void __iomem *base;
Bartlomiej Zolnierkiewicz48c3c102008-07-23 19:55:57 +020037 struct ide_host *host;
Linus Torvalds1da177e2005-04-16 15:20:36 -070038 int ret;
Bartlomiej Zolnierkiewiczdca39832009-05-17 19:12:24 +020039 hw_regs_t hw, *hws[] = { &hw };
Linus Torvalds1da177e2005-04-16 15:20:36 -070040
41 ret = ecard_request_resources(ec);
42 if (ret)
43 goto out;
44
Russell King10bdaaa2007-05-10 18:40:51 +010045 base = ecardm_iomap(ec, ECARD_RES_MEMC, 0, 0);
Linus Torvalds1da177e2005-04-16 15:20:36 -070046 if (!base) {
47 ret = -ENOMEM;
48 goto release;
49 }
50
Bartlomiej Zolnierkiewicz47bc7e72008-07-16 20:33:44 +020051 memset(&hw, 0, sizeof(hw));
52 rapide_setup_ports(&hw, base, base + 0x818, 1 << 6, ec->irq);
Bartlomiej Zolnierkiewicz47bc7e72008-07-16 20:33:44 +020053 hw.dev = &ec->dev;
54
Bartlomiej Zolnierkiewiczdca39832009-05-17 19:12:24 +020055 ret = ide_host_add(&rapide_port_info, hws, 1, &host);
Bartlomiej Zolnierkiewicz6f904d02008-07-23 19:55:57 +020056 if (ret)
Bartlomiej Zolnierkiewicz47bc7e72008-07-16 20:33:44 +020057 goto release;
Bartlomiej Zolnierkiewicz47bc7e72008-07-16 20:33:44 +020058
Bartlomiej Zolnierkiewicz48c3c102008-07-23 19:55:57 +020059 ecard_set_drvdata(ec, host);
Bartlomiej Zolnierkiewicz47bc7e72008-07-16 20:33:44 +020060 goto out;
61
Linus Torvalds1da177e2005-04-16 15:20:36 -070062 release:
63 ecard_release_resources(ec);
64 out:
65 return ret;
66}
67
68static void __devexit rapide_remove(struct expansion_card *ec)
69{
Bartlomiej Zolnierkiewicz48c3c102008-07-23 19:55:57 +020070 struct ide_host *host = ecard_get_drvdata(ec);
Linus Torvalds1da177e2005-04-16 15:20:36 -070071
72 ecard_set_drvdata(ec, NULL);
73
Bartlomiej Zolnierkiewicz48c3c102008-07-23 19:55:57 +020074 ide_host_remove(host);
Bartlomiej Zolnierkiewiczfadd11c2008-02-01 23:09:33 +010075
Linus Torvalds1da177e2005-04-16 15:20:36 -070076 ecard_release_resources(ec);
77}
78
79static struct ecard_id rapide_ids[] = {
80 { MANU_YELLOWSTONE, PROD_YELLOWSTONE_RAPIDE32 },
81 { 0xffff, 0xffff }
82};
83
84static struct ecard_driver rapide_driver = {
85 .probe = rapide_probe,
86 .remove = __devexit_p(rapide_remove),
87 .id_table = rapide_ids,
88 .drv = {
89 .name = "rapide",
90 },
91};
92
93static int __init rapide_init(void)
94{
95 return ecard_register_driver(&rapide_driver);
96}
97
Bartlomiej Zolnierkiewicz37c5ef52008-07-24 22:53:27 +020098static void __exit rapide_exit(void)
99{
Al Viro1137fb62008-10-26 05:40:26 +0000100 ecard_remove_driver(&rapide_driver);
Bartlomiej Zolnierkiewicz37c5ef52008-07-24 22:53:27 +0200101}
102
Linus Torvalds1da177e2005-04-16 15:20:36 -0700103MODULE_LICENSE("GPL");
104MODULE_DESCRIPTION("Yellowstone RAPIDE driver");
105
106module_init(rapide_init);
Bartlomiej Zolnierkiewicz37c5ef52008-07-24 22:53:27 +0200107module_exit(rapide_exit);