Blame view
drivers/ide/gayle.c
4.66 KB
1da177e4c Linux-2.6.12-rc2 |
1 |
/* |
58f189fcc ide: delete filen... |
2 |
* Amiga Gayle IDE Driver |
1da177e4c Linux-2.6.12-rc2 |
3 4 5 6 7 8 9 |
* * Created 9 Jul 1997 by Geert Uytterhoeven * * This file is subject to the terms and conditions of the GNU General Public * License. See the file COPYING in the main directory of this archive for * more details. */ |
1da177e4c Linux-2.6.12-rc2 |
10 11 12 13 |
#include <linux/types.h> #include <linux/mm.h> #include <linux/interrupt.h> #include <linux/blkdev.h> |
1da177e4c Linux-2.6.12-rc2 |
14 15 16 |
#include <linux/ide.h> #include <linux/init.h> #include <linux/zorro.h> |
513f3c10d ide: export ide_d... |
17 |
#include <linux/module.h> |
9aed23026 m68k: amiga - Ami... |
18 |
#include <linux/platform_device.h> |
1da177e4c Linux-2.6.12-rc2 |
19 20 21 22 23 24 25 26 |
#include <asm/setup.h> #include <asm/amigahw.h> #include <asm/amigaints.h> #include <asm/amigayle.h> /* |
1da177e4c Linux-2.6.12-rc2 |
27 28 |
* Offsets from one of the above bases */ |
1da177e4c Linux-2.6.12-rc2 |
29 |
#define GAYLE_CONTROL 0x101a |
1da177e4c Linux-2.6.12-rc2 |
30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
/* * These are at different offsets from the base */ #define GAYLE_IRQ_4000 0xdd3020 /* MSB = 1, Harddisk is source of */ #define GAYLE_IRQ_1200 0xda9000 /* interrupt */ /* * Offset of the secondary port for IDE doublers * Note that GAYLE_CONTROL is NOT available then! */ #define GAYLE_NEXT_PORT 0x1000 |
1da177e4c Linux-2.6.12-rc2 |
44 45 46 47 |
#define GAYLE_NUM_HWIFS 2 #define GAYLE_NUM_PROBE_HWIFS (ide_doubler ? GAYLE_NUM_HWIFS : \ GAYLE_NUM_HWIFS-1) #define GAYLE_HAS_CONTROL_REG (!ide_doubler) |
513f3c10d ide: export ide_d... |
48 |
|
90ab5ee94 module_param: mak... |
49 |
static bool ide_doubler; |
9dcba7f2b gayle: add "doubl... |
50 51 |
module_param_named(doubler, ide_doubler, bool, 0); MODULE_PARM_DESC(doubler, "enable support for IDE doublers"); |
1da177e4c Linux-2.6.12-rc2 |
52 53 54 55 |
/* * Check and acknowledge the interrupt status */ |
f4d3ffa52 ide: move ack_int... |
56 |
static int gayle_test_irq(ide_hwif_t *hwif) |
1da177e4c Linux-2.6.12-rc2 |
57 |
{ |
9aed23026 m68k: amiga - Ami... |
58 |
unsigned char ch; |
1da177e4c Linux-2.6.12-rc2 |
59 |
|
9aed23026 m68k: amiga - Ami... |
60 61 62 63 |
ch = z_readb(hwif->io_ports.irq_addr); if (!(ch & GAYLE_IRQ_IDE)) return 0; return 1; |
1da177e4c Linux-2.6.12-rc2 |
64 |
} |
eba8999ce ide: move IRQ cle... |
65 |
static void gayle_a1200_clear_irq(ide_drive_t *drive) |
1da177e4c Linux-2.6.12-rc2 |
66 |
{ |
9aed23026 m68k: amiga - Ami... |
67 |
ide_hwif_t *hwif = drive->hwif; |
1da177e4c Linux-2.6.12-rc2 |
68 |
|
9aed23026 m68k: amiga - Ami... |
69 70 |
(void)z_readb(hwif->io_ports.status_addr); z_writeb(0x7c, hwif->io_ports.irq_addr); |
1da177e4c Linux-2.6.12-rc2 |
71 |
} |
9f36d3143 ide: remove hw_re... |
72 |
static void __init gayle_setup_ports(struct ide_hw *hw, unsigned long base, |
f4d3ffa52 ide: move ack_int... |
73 |
unsigned long ctl, unsigned long irq_port) |
29dd59755 ide: remove ide_s... |
74 75 76 77 |
{ int i; memset(hw, 0, sizeof(*hw)); |
4c3032d8a ide: add struct i... |
78 |
hw->io_ports.data_addr = base; |
29dd59755 ide: remove ide_s... |
79 80 |
for (i = 1; i < 8; i++) |
4c3032d8a ide: add struct i... |
81 |
hw->io_ports_array[i] = base + 2 + i * 4; |
29dd59755 ide: remove ide_s... |
82 |
|
4c3032d8a ide: add struct i... |
83 84 |
hw->io_ports.ctl_addr = ctl; hw->io_ports.irq_addr = irq_port; |
29dd59755 ide: remove ide_s... |
85 86 |
hw->irq = IRQ_AMIGA_PORTS; |
29dd59755 ide: remove ide_s... |
87 |
} |
f4d3ffa52 ide: move ack_int... |
88 89 90 |
static const struct ide_port_ops gayle_a4000_port_ops = { .test_irq = gayle_test_irq, }; |
eba8999ce ide: move IRQ cle... |
91 92 |
static const struct ide_port_ops gayle_a1200_port_ops = { .clear_irq = gayle_a1200_clear_irq, |
f4d3ffa52 ide: move ack_int... |
93 |
.test_irq = gayle_test_irq, |
eba8999ce ide: move IRQ cle... |
94 |
}; |
a4cd1a344 gayle: set IDE_HF... |
95 |
static const struct ide_port_info gayle_port_info = { |
09a3e7918 ide: make m68k ho... |
96 97 |
.host_flags = IDE_HFLAG_MMIO | IDE_HFLAG_SERIALIZE | IDE_HFLAG_NO_DMA, |
255115fb3 ide: allow host d... |
98 |
.irq_flags = IRQF_SHARED, |
29e52cf79 ide: remove chips... |
99 |
.chipset = ide_generic, |
a4cd1a344 gayle: set IDE_HF... |
100 |
}; |
1da177e4c Linux-2.6.12-rc2 |
101 102 103 |
/* * Probe for a Gayle IDE interface (and optionally for an IDE doubler) */ |
9aed23026 m68k: amiga - Ami... |
104 |
static int __init amiga_gayle_ide_probe(struct platform_device *pdev) |
1da177e4c Linux-2.6.12-rc2 |
105 |
{ |
9aed23026 m68k: amiga - Ami... |
106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 |
struct resource *res; struct gayle_ide_platform_data *pdata; unsigned long base, ctrlport, irqport; unsigned int i; int error; struct ide_hw hw[GAYLE_NUM_HWIFS], *hws[GAYLE_NUM_HWIFS]; struct ide_port_info d = gayle_port_info; struct ide_host *host; res = platform_get_resource(pdev, IORESOURCE_MEM, 0); if (!res) return -ENODEV; if (!request_mem_region(res->start, resource_size(res), "IDE")) return -EBUSY; pdata = pdev->dev.platform_data; pr_info("ide: Gayle IDE controller (A%u style%s) ", pdata->explicit_ack ? 1200 : 4000, ide_doubler ? ", IDE doubler" : ""); base = (unsigned long)ZTWO_VADDR(pdata->base); ctrlport = 0; irqport = (unsigned long)ZTWO_VADDR(pdata->irqport); if (pdata->explicit_ack) d.port_ops = &gayle_a1200_port_ops; else d.port_ops = &gayle_a4000_port_ops; for (i = 0; i < GAYLE_NUM_PROBE_HWIFS; i++, base += GAYLE_NEXT_PORT) { if (GAYLE_HAS_CONTROL_REG) ctrlport = base + GAYLE_CONTROL; gayle_setup_ports(&hw[i], base, ctrlport, irqport); hws[i] = &hw[i]; |
1da177e4c Linux-2.6.12-rc2 |
142 |
} |
1da177e4c Linux-2.6.12-rc2 |
143 |
|
9aed23026 m68k: amiga - Ami... |
144 145 146 |
error = ide_host_add(&d, hws, i, &host); if (error) goto out; |
1da177e4c Linux-2.6.12-rc2 |
147 |
|
9aed23026 m68k: amiga - Ami... |
148 149 |
platform_set_drvdata(pdev, host); return 0; |
1da177e4c Linux-2.6.12-rc2 |
150 |
|
9aed23026 m68k: amiga - Ami... |
151 152 153 154 155 156 157 158 159 160 161 162 163 164 |
out: release_mem_region(res->start, resource_size(res)); return error; } static int __exit amiga_gayle_ide_remove(struct platform_device *pdev) { struct ide_host *host = platform_get_drvdata(pdev); struct resource *res = platform_get_resource(pdev, IORESOURCE_MEM, 0); ide_host_remove(host); release_mem_region(res->start, resource_size(res)); return 0; } |
1da177e4c Linux-2.6.12-rc2 |
165 |
|
9aed23026 m68k: amiga - Ami... |
166 167 168 169 170 171 172 |
static struct platform_driver amiga_gayle_ide_driver = { .remove = __exit_p(amiga_gayle_ide_remove), .driver = { .name = "amiga-gayle-ide", .owner = THIS_MODULE, }, }; |
1da177e4c Linux-2.6.12-rc2 |
173 |
|
9aed23026 m68k: amiga - Ami... |
174 175 176 177 178 |
static int __init amiga_gayle_ide_init(void) { return platform_driver_probe(&amiga_gayle_ide_driver, amiga_gayle_ide_probe); } |
8ac4ce742 ide: fix host dri... |
179 |
|
9aed23026 m68k: amiga - Ami... |
180 |
module_init(amiga_gayle_ide_init); |
96cc112c0 gayle: release re... |
181 |
|
9aed23026 m68k: amiga - Ami... |
182 183 184 |
static void __exit amiga_gayle_ide_exit(void) { platform_driver_unregister(&amiga_gayle_ide_driver); |
1da177e4c Linux-2.6.12-rc2 |
185 |
} |
ade2daf9c ide: make remaini... |
186 |
|
9aed23026 m68k: amiga - Ami... |
187 |
module_exit(amiga_gayle_ide_exit); |
6e1d17da7 ide/legacy/gayle.... |
188 189 |
MODULE_LICENSE("GPL"); |
9aed23026 m68k: amiga - Ami... |
190 |
MODULE_ALIAS("platform:amiga-gayle-ide"); |