blob: 11f3307385dea9640f45bd0cc0d1579982394c5c [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
Bartlomiej Zolnierkiewicz9a5ae1f2008-07-16 20:33:42 +020014static struct const ide_port_info rapide_port_info = {
15 .host_flags = IDE_HFLAG_MMIO | IDE_HFLAG_NO_DMA,
16};
17
Bartlomiej Zolnierkiewicz57c802e2008-01-26 20:13:05 +010018static void rapide_setup_ports(hw_regs_t *hw, void __iomem *base,
19 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
32static int __devinit
33rapide_probe(struct expansion_card *ec, const struct ecard_id *id)
34{
Linus Torvalds1da177e2005-04-16 15:20:36 -070035 void __iomem *base;
Bartlomiej Zolnierkiewicz48c3c102008-07-23 19:55:57 +020036 struct ide_host *host;
Linus Torvalds1da177e2005-04-16 15:20:36 -070037 int ret;
Bartlomiej Zolnierkiewiczc97c6ac2008-07-23 19:55:50 +020038 hw_regs_t hw, *hws[] = { &hw, NULL, NULL, NULL };
Linus Torvalds1da177e2005-04-16 15:20:36 -070039
40 ret = ecard_request_resources(ec);
41 if (ret)
42 goto out;
43
Russell King10bdaaa2007-05-10 18:40:51 +010044 base = ecardm_iomap(ec, ECARD_RES_MEMC, 0, 0);
Linus Torvalds1da177e2005-04-16 15:20:36 -070045 if (!base) {
46 ret = -ENOMEM;
47 goto release;
48 }
49
Bartlomiej Zolnierkiewicz47bc7e72008-07-16 20:33:44 +020050 memset(&hw, 0, sizeof(hw));
51 rapide_setup_ports(&hw, base, base + 0x818, 1 << 6, ec->irq);
52 hw.chipset = ide_generic;
53 hw.dev = &ec->dev;
54
Bartlomiej Zolnierkiewicz48c3c102008-07-23 19:55:57 +020055 host = ide_host_alloc(&rapide_port_info, hws);
56 if (host == NULL) {
Bartlomiej Zolnierkiewicz47bc7e72008-07-16 20:33:44 +020057 ret = -ENOENT;
58 goto release;
Linus Torvalds1da177e2005-04-16 15:20:36 -070059 }
60
Bartlomiej Zolnierkiewicz48c3c102008-07-23 19:55:57 +020061 ide_host_register(host, &rapide_port_info, hws);
Bartlomiej Zolnierkiewicz47bc7e72008-07-16 20:33:44 +020062
Bartlomiej Zolnierkiewicz48c3c102008-07-23 19:55:57 +020063 ecard_set_drvdata(ec, host);
Bartlomiej Zolnierkiewicz47bc7e72008-07-16 20:33:44 +020064 goto out;
65
Linus Torvalds1da177e2005-04-16 15:20:36 -070066 release:
67 ecard_release_resources(ec);
68 out:
69 return ret;
70}
71
72static void __devexit rapide_remove(struct expansion_card *ec)
73{
Bartlomiej Zolnierkiewicz48c3c102008-07-23 19:55:57 +020074 struct ide_host *host = ecard_get_drvdata(ec);
Linus Torvalds1da177e2005-04-16 15:20:36 -070075
76 ecard_set_drvdata(ec, NULL);
77
Bartlomiej Zolnierkiewicz48c3c102008-07-23 19:55:57 +020078 ide_host_remove(host);
Bartlomiej Zolnierkiewiczfadd11c2008-02-01 23:09:33 +010079
Linus Torvalds1da177e2005-04-16 15:20:36 -070080 ecard_release_resources(ec);
81}
82
83static struct ecard_id rapide_ids[] = {
84 { MANU_YELLOWSTONE, PROD_YELLOWSTONE_RAPIDE32 },
85 { 0xffff, 0xffff }
86};
87
88static struct ecard_driver rapide_driver = {
89 .probe = rapide_probe,
90 .remove = __devexit_p(rapide_remove),
91 .id_table = rapide_ids,
92 .drv = {
93 .name = "rapide",
94 },
95};
96
97static int __init rapide_init(void)
98{
99 return ecard_register_driver(&rapide_driver);
100}
101
102MODULE_LICENSE("GPL");
103MODULE_DESCRIPTION("Yellowstone RAPIDE driver");
104
105module_init(rapide_init);