Commit | Line | Data |
---|---|---|
1da177e4 | 1 | /* |
1da177e4 LT |
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 | ||
9a5ae1fa BZ |
14 | static struct const ide_port_info rapide_port_info = { |
15 | .host_flags = IDE_HFLAG_MMIO | IDE_HFLAG_NO_DMA, | |
16 | }; | |
17 | ||
57c802e8 BZ |
18 | static void rapide_setup_ports(hw_regs_t *hw, void __iomem *base, |
19 | void __iomem *ctrl, unsigned int sz, int irq) | |
1da177e4 LT |
20 | { |
21 | unsigned long port = (unsigned long)base; | |
baa8f3e9 | 22 | int i; |
1da177e4 | 23 | |
4c3032d8 BZ |
24 | for (i = 0; i <= 7; i++) { |
25 | hw->io_ports_array[i] = port; | |
1da177e4 LT |
26 | port += sz; |
27 | } | |
4c3032d8 | 28 | hw->io_ports.ctl_addr = (unsigned long)ctrl; |
57c802e8 | 29 | hw->irq = irq; |
1da177e4 LT |
30 | } |
31 | ||
32 | static int __devinit | |
33 | rapide_probe(struct expansion_card *ec, const struct ecard_id *id) | |
34 | { | |
35 | ide_hwif_t *hwif; | |
36 | void __iomem *base; | |
37 | int ret; | |
c97c6aca | 38 | hw_regs_t hw, *hws[] = { &hw, NULL, NULL, NULL }; |
8447d9d5 | 39 | u8 idx[4] = { 0xff, 0xff, 0xff, 0xff }; |
1da177e4 LT |
40 | |
41 | ret = ecard_request_resources(ec); | |
42 | if (ret) | |
43 | goto out; | |
44 | ||
10bdaaa0 | 45 | base = ecardm_iomap(ec, ECARD_RES_MEMC, 0, 0); |
1da177e4 LT |
46 | if (!base) { |
47 | ret = -ENOMEM; | |
48 | goto release; | |
49 | } | |
50 | ||
47bc7e74 BZ |
51 | 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; | |
57c802e8 | 55 | |
47bc7e74 BZ |
56 | hwif = ide_find_port(); |
57 | if (hwif == NULL) { | |
58 | ret = -ENOENT; | |
59 | goto release; | |
60 | } | |
57c802e8 | 61 | |
47bc7e74 | 62 | default_hwif_mmiops(hwif); |
57c802e8 | 63 | |
47bc7e74 | 64 | idx[0] = hwif->index; |
8447d9d5 | 65 | |
c97c6aca | 66 | ide_device_add(idx, &rapide_port_info, hws); |
8447d9d5 | 67 | |
47bc7e74 BZ |
68 | ecard_set_drvdata(ec, hwif); |
69 | goto out; | |
1da177e4 | 70 | |
1da177e4 LT |
71 | release: |
72 | ecard_release_resources(ec); | |
73 | out: | |
74 | return ret; | |
75 | } | |
76 | ||
77 | static 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 | ||
387750c3 | 83 | ide_unregister(hwif); |
fadd11c7 | 84 | |
1da177e4 LT |
85 | ecard_release_resources(ec); |
86 | } | |
87 | ||
88 | static struct ecard_id rapide_ids[] = { | |
89 | { MANU_YELLOWSTONE, PROD_YELLOWSTONE_RAPIDE32 }, | |
90 | { 0xffff, 0xffff } | |
91 | }; | |
92 | ||
93 | static 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 | ||
102 | static int __init rapide_init(void) | |
103 | { | |
104 | return ecard_register_driver(&rapide_driver); | |
105 | } | |
106 | ||
107 | MODULE_LICENSE("GPL"); | |
108 | MODULE_DESCRIPTION("Yellowstone RAPIDE driver"); | |
109 | ||
110 | module_init(rapide_init); |