rapide: set hwif->chipset
[deliverable/linux.git] / drivers / ide / arm / rapide.c
CommitLineData
1da177e4
LT
1/*
2 * linux/drivers/ide/arm/rapide.c
3 *
4 * Copyright (c) 1996-2002 Russell King.
5 */
6
7#include <linux/module.h>
8#include <linux/slab.h>
9#include <linux/blkdev.h>
10#include <linux/errno.h>
11#include <linux/ide.h>
12#include <linux/init.h>
13
14#include <asm/ecard.h>
15
1da177e4
LT
16static ide_hwif_t *
17rapide_locate_hwif(void __iomem *base, void __iomem *ctrl, unsigned int sz, int irq)
18{
19 unsigned long port = (unsigned long)base;
baa8f3e9
BZ
20 ide_hwif_t *hwif = ide_find_port(port);
21 int i;
1da177e4 22
baa8f3e9
BZ
23 if (hwif == NULL)
24 goto out;
1da177e4 25
1da177e4 26 for (i = IDE_DATA_OFFSET; i <= IDE_STATUS_OFFSET; i++) {
1da177e4
LT
27 hwif->io_ports[i] = port;
28 port += sz;
29 }
1da177e4 30 hwif->io_ports[IDE_CONTROL_OFFSET] = (unsigned long)ctrl;
9239b333 31 hwif->irq = irq;
2ad1e558 32 hwif->mmio = 1;
1da177e4 33 default_hwif_mmiops(hwif);
baa8f3e9 34out:
1da177e4
LT
35 return hwif;
36}
37
38static int __devinit
39rapide_probe(struct expansion_card *ec, const struct ecard_id *id)
40{
41 ide_hwif_t *hwif;
42 void __iomem *base;
43 int ret;
8447d9d5 44 u8 idx[4] = { 0xff, 0xff, 0xff, 0xff };
1da177e4
LT
45
46 ret = ecard_request_resources(ec);
47 if (ret)
48 goto out;
49
10bdaaa0 50 base = ecardm_iomap(ec, ECARD_RES_MEMC, 0, 0);
1da177e4
LT
51 if (!base) {
52 ret = -ENOMEM;
53 goto release;
54 }
55
56 hwif = rapide_locate_hwif(base, base + 0x818, 1 << 6, ec->irq);
57 if (hwif) {
23d8e72c 58 hwif->chipset = ide_generic;
1da177e4
LT
59 hwif->hwif_data = base;
60 hwif->gendev.parent = &ec->dev;
61 hwif->noprobe = 0;
8447d9d5
BZ
62
63 idx[0] = hwif->index;
64
65 ide_device_add(idx);
66
1da177e4
LT
67 ecard_set_drvdata(ec, hwif);
68 goto out;
69 }
70
1da177e4
LT
71 release:
72 ecard_release_resources(ec);
73 out:
74 return ret;
75}
76
77static void __devexit rapide_remove(struct expansion_card *ec)
78{
79 ide_hwif_t *hwif = ecard_get_drvdata(ec);
80
81 ecard_set_drvdata(ec, NULL);
82
83 /* there must be a better way */
84 ide_unregister(hwif - ide_hwifs);
1da177e4
LT
85 ecard_release_resources(ec);
86}
87
88static struct ecard_id rapide_ids[] = {
89 { MANU_YELLOWSTONE, PROD_YELLOWSTONE_RAPIDE32 },
90 { 0xffff, 0xffff }
91};
92
93static struct ecard_driver rapide_driver = {
94 .probe = rapide_probe,
95 .remove = __devexit_p(rapide_remove),
96 .id_table = rapide_ids,
97 .drv = {
98 .name = "rapide",
99 },
100};
101
102static int __init rapide_init(void)
103{
104 return ecard_register_driver(&rapide_driver);
105}
106
107MODULE_LICENSE("GPL");
108MODULE_DESCRIPTION("Yellowstone RAPIDE driver");
109
110module_init(rapide_init);
This page took 0.282366 seconds and 5 git commands to generate.