blob: b5b6ed8b82b211fa0ccdd695e3cebc604e5588ad [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
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
Bartlomiej Zolnierkiewicz57c802e2008-01-26 20:13:05 +010016static void rapide_setup_ports(hw_regs_t *hw, void __iomem *base,
17 void __iomem *ctrl, unsigned int sz, int irq)
Linus Torvalds1da177e2005-04-16 15:20:36 -070018{
19 unsigned long port = (unsigned long)base;
Bartlomiej Zolnierkiewiczbaa8f3e2007-10-20 00:32:31 +020020 int i;
Linus Torvalds1da177e2005-04-16 15:20:36 -070021
Linus Torvalds1da177e2005-04-16 15:20:36 -070022 for (i = IDE_DATA_OFFSET; i <= IDE_STATUS_OFFSET; i++) {
Bartlomiej Zolnierkiewicz57c802e2008-01-26 20:13:05 +010023 hw->io_ports[i] = port;
Linus Torvalds1da177e2005-04-16 15:20:36 -070024 port += sz;
25 }
Bartlomiej Zolnierkiewicz57c802e2008-01-26 20:13:05 +010026 hw->io_ports[IDE_CONTROL_OFFSET] = (unsigned long)ctrl;
27 hw->irq = irq;
Linus Torvalds1da177e2005-04-16 15:20:36 -070028}
29
30static int __devinit
31rapide_probe(struct expansion_card *ec, const struct ecard_id *id)
32{
33 ide_hwif_t *hwif;
34 void __iomem *base;
35 int ret;
Bartlomiej Zolnierkiewicz8447d9d2007-10-20 00:32:31 +020036 u8 idx[4] = { 0xff, 0xff, 0xff, 0xff };
Bartlomiej Zolnierkiewicz57c802e2008-01-26 20:13:05 +010037 hw_regs_t hw;
Linus Torvalds1da177e2005-04-16 15:20:36 -070038
39 ret = ecard_request_resources(ec);
40 if (ret)
41 goto out;
42
Russell King10bdaaa2007-05-10 18:40:51 +010043 base = ecardm_iomap(ec, ECARD_RES_MEMC, 0, 0);
Linus Torvalds1da177e2005-04-16 15:20:36 -070044 if (!base) {
45 ret = -ENOMEM;
46 goto release;
47 }
48
Bartlomiej Zolnierkiewicz57c802e2008-01-26 20:13:05 +010049 hwif = ide_find_port((unsigned long)base);
Linus Torvalds1da177e2005-04-16 15:20:36 -070050 if (hwif) {
Bartlomiej Zolnierkiewicz57c802e2008-01-26 20:13:05 +010051 memset(&hw, 0, sizeof(hw));
52 rapide_setup_ports(&hw, base, base + 0x818, 1 << 6, ec->irq);
53 hw.chipset = ide_generic;
54 hw.dev = &ec->dev;
55
56 ide_init_port_hw(hwif, &hw);
57
58 hwif->mmio = 1;
59 default_hwif_mmiops(hwif);
60
Bartlomiej Zolnierkiewicz8447d9d2007-10-20 00:32:31 +020061 idx[0] = hwif->index;
62
63 ide_device_add(idx);
64
Linus Torvalds1da177e2005-04-16 15:20:36 -070065 ecard_set_drvdata(ec, hwif);
66 goto out;
67 }
68
Linus Torvalds1da177e2005-04-16 15:20:36 -070069 release:
70 ecard_release_resources(ec);
71 out:
72 return ret;
73}
74
75static void __devexit rapide_remove(struct expansion_card *ec)
76{
77 ide_hwif_t *hwif = ecard_get_drvdata(ec);
78
79 ecard_set_drvdata(ec, NULL);
80
Bartlomiej Zolnierkiewiczfadd11c2008-02-01 23:09:33 +010081 ide_unregister(hwif->index);
82
Linus Torvalds1da177e2005-04-16 15:20:36 -070083 ecard_release_resources(ec);
84}
85
86static struct ecard_id rapide_ids[] = {
87 { MANU_YELLOWSTONE, PROD_YELLOWSTONE_RAPIDE32 },
88 { 0xffff, 0xffff }
89};
90
91static struct ecard_driver rapide_driver = {
92 .probe = rapide_probe,
93 .remove = __devexit_p(rapide_remove),
94 .id_table = rapide_ids,
95 .drv = {
96 .name = "rapide",
97 },
98};
99
100static int __init rapide_init(void)
101{
102 return ecard_register_driver(&rapide_driver);
103}
104
105MODULE_LICENSE("GPL");
106MODULE_DESCRIPTION("Yellowstone RAPIDE driver");
107
108module_init(rapide_init);