blob: bb081ad53f311c7b1deae294e1e81e12d16967f9 [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{
35 ide_hwif_t *hwif;
36 void __iomem *base;
37 int ret;
Bartlomiej Zolnierkiewicz8447d9d2007-10-20 00:32:31 +020038 u8 idx[4] = { 0xff, 0xff, 0xff, 0xff };
Bartlomiej Zolnierkiewicz57c802e2008-01-26 20:13:05 +010039 hw_regs_t 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 Zolnierkiewicz59bff5b2008-04-26 17:36:32 +020051 hwif = ide_find_port();
Linus Torvalds1da177e2005-04-16 15:20:36 -070052 if (hwif) {
Bartlomiej Zolnierkiewicz57c802e2008-01-26 20:13:05 +010053 memset(&hw, 0, sizeof(hw));
54 rapide_setup_ports(&hw, base, base + 0x818, 1 << 6, ec->irq);
55 hw.chipset = ide_generic;
56 hw.dev = &ec->dev;
57
58 ide_init_port_hw(hwif, &hw);
59
Bartlomiej Zolnierkiewicz57c802e2008-01-26 20:13:05 +010060 default_hwif_mmiops(hwif);
61
Bartlomiej Zolnierkiewicz8447d9d2007-10-20 00:32:31 +020062 idx[0] = hwif->index;
63
Bartlomiej Zolnierkiewicz9a5ae1f2008-07-16 20:33:42 +020064 ide_device_add(idx, &rapide_port_info);
Bartlomiej Zolnierkiewicz8447d9d2007-10-20 00:32:31 +020065
Linus Torvalds1da177e2005-04-16 15:20:36 -070066 ecard_set_drvdata(ec, hwif);
67 goto out;
68 }
69
Linus Torvalds1da177e2005-04-16 15:20:36 -070070 release:
71 ecard_release_resources(ec);
72 out:
73 return ret;
74}
75
76static void __devexit rapide_remove(struct expansion_card *ec)
77{
78 ide_hwif_t *hwif = ecard_get_drvdata(ec);
79
80 ecard_set_drvdata(ec, NULL);
81
Bartlomiej Zolnierkiewicz387750c2008-04-27 15:38:31 +020082 ide_unregister(hwif);
Bartlomiej Zolnierkiewiczfadd11c2008-02-01 23:09:33 +010083
Linus Torvalds1da177e2005-04-16 15:20:36 -070084 ecard_release_resources(ec);
85}
86
87static struct ecard_id rapide_ids[] = {
88 { MANU_YELLOWSTONE, PROD_YELLOWSTONE_RAPIDE32 },
89 { 0xffff, 0xffff }
90};
91
92static struct ecard_driver rapide_driver = {
93 .probe = rapide_probe,
94 .remove = __devexit_p(rapide_remove),
95 .id_table = rapide_ids,
96 .drv = {
97 .name = "rapide",
98 },
99};
100
101static int __init rapide_init(void)
102{
103 return ecard_register_driver(&rapide_driver);
104}
105
106MODULE_LICENSE("GPL");
107MODULE_DESCRIPTION("Yellowstone RAPIDE driver");
108
109module_init(rapide_init);