Linux kernel mirror (for testing)
git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel
os
linux
1/*
2 * 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
14static void rapide_setup_ports(hw_regs_t *hw, void __iomem *base,
15 void __iomem *ctrl, unsigned int sz, int irq)
16{
17 unsigned long port = (unsigned long)base;
18 int i;
19
20 for (i = 0; i <= 7; i++) {
21 hw->io_ports_array[i] = port;
22 port += sz;
23 }
24 hw->io_ports.ctl_addr = (unsigned long)ctrl;
25 hw->irq = irq;
26}
27
28static int __devinit
29rapide_probe(struct expansion_card *ec, const struct ecard_id *id)
30{
31 ide_hwif_t *hwif;
32 void __iomem *base;
33 int ret;
34 u8 idx[4] = { 0xff, 0xff, 0xff, 0xff };
35 hw_regs_t hw;
36
37 ret = ecard_request_resources(ec);
38 if (ret)
39 goto out;
40
41 base = ecardm_iomap(ec, ECARD_RES_MEMC, 0, 0);
42 if (!base) {
43 ret = -ENOMEM;
44 goto release;
45 }
46
47 hwif = ide_find_port();
48 if (hwif) {
49 memset(&hw, 0, sizeof(hw));
50 rapide_setup_ports(&hw, base, base + 0x818, 1 << 6, ec->irq);
51 hw.chipset = ide_generic;
52 hw.dev = &ec->dev;
53
54 ide_init_port_hw(hwif, &hw);
55
56 hwif->host_flags = IDE_HFLAG_MMIO;
57 default_hwif_mmiops(hwif);
58
59 idx[0] = hwif->index;
60
61 ide_device_add(idx, NULL);
62
63 ecard_set_drvdata(ec, hwif);
64 goto out;
65 }
66
67 release:
68 ecard_release_resources(ec);
69 out:
70 return ret;
71}
72
73static void __devexit rapide_remove(struct expansion_card *ec)
74{
75 ide_hwif_t *hwif = ecard_get_drvdata(ec);
76
77 ecard_set_drvdata(ec, NULL);
78
79 ide_unregister(hwif);
80
81 ecard_release_resources(ec);
82}
83
84static struct ecard_id rapide_ids[] = {
85 { MANU_YELLOWSTONE, PROD_YELLOWSTONE_RAPIDE32 },
86 { 0xffff, 0xffff }
87};
88
89static struct ecard_driver rapide_driver = {
90 .probe = rapide_probe,
91 .remove = __devexit_p(rapide_remove),
92 .id_table = rapide_ids,
93 .drv = {
94 .name = "rapide",
95 },
96};
97
98static int __init rapide_init(void)
99{
100 return ecard_register_driver(&rapide_driver);
101}
102
103MODULE_LICENSE("GPL");
104MODULE_DESCRIPTION("Yellowstone RAPIDE driver");
105
106module_init(rapide_init);