ide: add struct ide_host (take 3)
[deliverable/linux.git] / drivers / ide / arm / rapide.c
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
14 static struct const ide_port_info rapide_port_info = {
15 .host_flags = IDE_HFLAG_MMIO | IDE_HFLAG_NO_DMA,
16 };
17
18 static void rapide_setup_ports(hw_regs_t *hw, void __iomem *base,
19 void __iomem *ctrl, unsigned int sz, int irq)
20 {
21 unsigned long port = (unsigned long)base;
22 int i;
23
24 for (i = 0; i <= 7; i++) {
25 hw->io_ports_array[i] = port;
26 port += sz;
27 }
28 hw->io_ports.ctl_addr = (unsigned long)ctrl;
29 hw->irq = irq;
30 }
31
32 static int __devinit
33 rapide_probe(struct expansion_card *ec, const struct ecard_id *id)
34 {
35 void __iomem *base;
36 struct ide_host *host;
37 int ret;
38 hw_regs_t hw, *hws[] = { &hw, NULL, NULL, NULL };
39
40 ret = ecard_request_resources(ec);
41 if (ret)
42 goto out;
43
44 base = ecardm_iomap(ec, ECARD_RES_MEMC, 0, 0);
45 if (!base) {
46 ret = -ENOMEM;
47 goto release;
48 }
49
50 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
55 host = ide_host_alloc(&rapide_port_info, hws);
56 if (host == NULL) {
57 ret = -ENOENT;
58 goto release;
59 }
60
61 ide_host_register(host, &rapide_port_info, hws);
62
63 ecard_set_drvdata(ec, host);
64 goto out;
65
66 release:
67 ecard_release_resources(ec);
68 out:
69 return ret;
70 }
71
72 static void __devexit rapide_remove(struct expansion_card *ec)
73 {
74 struct ide_host *host = ecard_get_drvdata(ec);
75
76 ecard_set_drvdata(ec, NULL);
77
78 ide_host_remove(host);
79
80 ecard_release_resources(ec);
81 }
82
83 static struct ecard_id rapide_ids[] = {
84 { MANU_YELLOWSTONE, PROD_YELLOWSTONE_RAPIDE32 },
85 { 0xffff, 0xffff }
86 };
87
88 static 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
97 static int __init rapide_init(void)
98 {
99 return ecard_register_driver(&rapide_driver);
100 }
101
102 MODULE_LICENSE("GPL");
103 MODULE_DESCRIPTION("Yellowstone RAPIDE driver");
104
105 module_init(rapide_init);
This page took 0.034189 seconds and 5 git commands to generate.