ide: cleanup setting hwif->mmio flag
[cascardo/linux.git] / drivers / ide / arm / bast-ide.c
1 /*
2  * Copyright (c) 2003-2004 Simtec Electronics
3  *  Ben Dooks <ben@simtec.co.uk>
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License version 2 as
7  * published by the Free Software Foundation.
8  *
9 */
10
11 #include <linux/module.h>
12 #include <linux/errno.h>
13 #include <linux/ide.h>
14 #include <linux/init.h>
15
16 #include <asm/mach-types.h>
17
18 #include <asm/io.h>
19 #include <asm/irq.h>
20 #include <asm/arch/map.h>
21 #include <asm/arch/bast-map.h>
22 #include <asm/arch/bast-irq.h>
23
24 #define DRV_NAME "bast-ide"
25
26 static int __init bastide_register(unsigned int base, unsigned int aux, int irq)
27 {
28         ide_hwif_t *hwif;
29         hw_regs_t hw;
30         int i;
31         u8 idx[4] = { 0xff, 0xff, 0xff, 0xff };
32
33         memset(&hw, 0, sizeof(hw));
34
35         base += BAST_IDE_CS;
36         aux  += BAST_IDE_CS;
37
38         for (i = IDE_DATA_OFFSET; i <= IDE_STATUS_OFFSET; i++) {
39                 hw.io_ports[i] = (unsigned long)base;
40                 base += 0x20;
41         }
42
43         hw.io_ports[IDE_CONTROL_OFFSET] = aux + (6 * 0x20);
44         hw.irq = irq;
45
46         hwif = ide_find_port();
47         if (hwif == NULL)
48                 goto out;
49
50         i = hwif->index;
51
52         if (hwif->present)
53                 ide_unregister(i);
54         else
55                 ide_init_port_data(hwif, i);
56
57         ide_init_port_hw(hwif, &hw);
58         hwif->port_ops = NULL;
59
60         idx[0] = i;
61
62         ide_device_add(idx, NULL);
63 out:
64         return 0;
65 }
66
67 static int __init bastide_init(void)
68 {
69         unsigned long base = BAST_VA_IDEPRI + BAST_IDE_CS;
70
71         /* we can treat the VR1000 and the BAST the same */
72
73         if (!(machine_is_bast() || machine_is_vr1000()))
74                 return 0;
75
76         printk("BAST: IDE driver, (c) 2003-2004 Simtec Electronics\n");
77
78         if (!request_mem_region(base, 0x400000, DRV_NAME)) {
79                 printk(KERN_ERR "%s: resources busy\n", DRV_NAME);
80                 return -EBUSY;
81         }
82
83         bastide_register(BAST_VA_IDEPRI, BAST_VA_IDEPRIAUX, IRQ_IDE0);
84         bastide_register(BAST_VA_IDESEC, BAST_VA_IDESECAUX, IRQ_IDE1);
85
86         return 0;
87 }
88
89 module_init(bastide_init);
90
91 MODULE_AUTHOR("Ben Dooks <ben@simtec.co.uk>");
92 MODULE_LICENSE("GPL");
93 MODULE_DESCRIPTION("Simtec BAST / Thorcom VR1000 IDE driver");