blob: d73c3d10087c72133d5db9bd5902ea1e94758008 [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>
Linus Torvalds1da177e2005-04-16 15:20:36 -07006#include <linux/blkdev.h>
7#include <linux/errno.h>
8#include <linux/ide.h>
9#include <linux/init.h>
10
11#include <asm/ecard.h>
12
Al Viro1137fb62008-10-26 05:40:26 +000013static const struct ide_port_info rapide_port_info = {
Bartlomiej Zolnierkiewicz9a5ae1f2008-07-16 20:33:42 +020014 .host_flags = IDE_HFLAG_MMIO | IDE_HFLAG_NO_DMA,
Bartlomiej Zolnierkiewicz29e52cf2009-05-17 19:12:22 +020015 .chipset = ide_generic,
Bartlomiej Zolnierkiewicz9a5ae1f2008-07-16 20:33:42 +020016};
17
Bartlomiej Zolnierkiewicz9f36d312009-05-17 19:12:25 +020018static void rapide_setup_ports(struct ide_hw *hw, void __iomem *base,
Bartlomiej Zolnierkiewicz57c802e2008-01-26 20:13:05 +010019 void __iomem *ctrl, unsigned int sz, int irq)
Linus Torvalds1da177e2005-04-16 15:20:36 -070020{
21 unsigned long port = (unsigned long)base;
Bartlomiej Zolnierkiewiczbaa8f3e2007-10-20 00:32:31 +020022 int i;
Linus Torvalds1da177e2005-04-16 15:20:36 -070023
Bartlomiej Zolnierkiewicz4c3032d2008-04-27 15:38:32 +020024 for (i = 0; i <= 7; i++) {
25 hw->io_ports_array[i] = port;
Linus Torvalds1da177e2005-04-16 15:20:36 -070026 port += sz;
27 }
Bartlomiej Zolnierkiewicz4c3032d2008-04-27 15:38:32 +020028 hw->io_ports.ctl_addr = (unsigned long)ctrl;
Bartlomiej Zolnierkiewicz57c802e2008-01-26 20:13:05 +010029 hw->irq = irq;
Linus Torvalds1da177e2005-04-16 15:20:36 -070030}
31
Greg Kroah-Hartmanfe31edc2012-12-21 13:21:03 -080032static int rapide_probe(struct expansion_card *ec, const struct ecard_id *id)
Linus Torvalds1da177e2005-04-16 15:20:36 -070033{
Linus Torvalds1da177e2005-04-16 15:20:36 -070034 void __iomem *base;
Bartlomiej Zolnierkiewicz48c3c102008-07-23 19:55:57 +020035 struct ide_host *host;
Linus Torvalds1da177e2005-04-16 15:20:36 -070036 int ret;
Bartlomiej Zolnierkiewicz9f36d312009-05-17 19:12:25 +020037 struct ide_hw hw, *hws[] = { &hw };
Linus Torvalds1da177e2005-04-16 15:20:36 -070038
39 ret = ecard_request_resources(ec);
40 if (ret)
41 goto out;
42
Russell King10bdaaa2007-05-10 18:40:51 +010043 base = ecardm_iomap(ec, ECARD_RES_MEMC, 0, 0);
Linus Torvalds1da177e2005-04-16 15:20:36 -070044 if (!base) {
45 ret = -ENOMEM;
46 goto release;
47 }
48
Bartlomiej Zolnierkiewicz47bc7e72008-07-16 20:33:44 +020049 memset(&hw, 0, sizeof(hw));
50 rapide_setup_ports(&hw, base, base + 0x818, 1 << 6, ec->irq);
Bartlomiej Zolnierkiewicz47bc7e72008-07-16 20:33:44 +020051 hw.dev = &ec->dev;
52
Bartlomiej Zolnierkiewiczdca39832009-05-17 19:12:24 +020053 ret = ide_host_add(&rapide_port_info, hws, 1, &host);
Bartlomiej Zolnierkiewicz6f904d02008-07-23 19:55:57 +020054 if (ret)
Bartlomiej Zolnierkiewicz47bc7e72008-07-16 20:33:44 +020055 goto release;
Bartlomiej Zolnierkiewicz47bc7e72008-07-16 20:33:44 +020056
Bartlomiej Zolnierkiewicz48c3c102008-07-23 19:55:57 +020057 ecard_set_drvdata(ec, host);
Bartlomiej Zolnierkiewicz47bc7e72008-07-16 20:33:44 +020058 goto out;
59
Linus Torvalds1da177e2005-04-16 15:20:36 -070060 release:
61 ecard_release_resources(ec);
62 out:
63 return ret;
64}
65
Greg Kroah-Hartmanfe31edc2012-12-21 13:21:03 -080066static void rapide_remove(struct expansion_card *ec)
Linus Torvalds1da177e2005-04-16 15:20:36 -070067{
Bartlomiej Zolnierkiewicz48c3c102008-07-23 19:55:57 +020068 struct ide_host *host = ecard_get_drvdata(ec);
Linus Torvalds1da177e2005-04-16 15:20:36 -070069
70 ecard_set_drvdata(ec, NULL);
71
Bartlomiej Zolnierkiewicz48c3c102008-07-23 19:55:57 +020072 ide_host_remove(host);
Bartlomiej Zolnierkiewiczfadd11c2008-02-01 23:09:33 +010073
Linus Torvalds1da177e2005-04-16 15:20:36 -070074 ecard_release_resources(ec);
75}
76
77static struct ecard_id rapide_ids[] = {
78 { MANU_YELLOWSTONE, PROD_YELLOWSTONE_RAPIDE32 },
79 { 0xffff, 0xffff }
80};
81
82static struct ecard_driver rapide_driver = {
83 .probe = rapide_probe,
Greg Kroah-Hartmanfe31edc2012-12-21 13:21:03 -080084 .remove = rapide_remove,
Linus Torvalds1da177e2005-04-16 15:20:36 -070085 .id_table = rapide_ids,
86 .drv = {
87 .name = "rapide",
88 },
89};
90
91static int __init rapide_init(void)
92{
93 return ecard_register_driver(&rapide_driver);
94}
95
Bartlomiej Zolnierkiewicz37c5ef52008-07-24 22:53:27 +020096static void __exit rapide_exit(void)
97{
Al Viro1137fb62008-10-26 05:40:26 +000098 ecard_remove_driver(&rapide_driver);
Bartlomiej Zolnierkiewicz37c5ef52008-07-24 22:53:27 +020099}
100
Linus Torvalds1da177e2005-04-16 15:20:36 -0700101MODULE_LICENSE("GPL");
102MODULE_DESCRIPTION("Yellowstone RAPIDE driver");
103
104module_init(rapide_init);
Bartlomiej Zolnierkiewicz37c5ef52008-07-24 22:53:27 +0200105module_exit(rapide_exit);