Commit | Line | Data |
---|---|---|
58f189fc | 1 | /* |
1da177e4 LT |
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 | /* list of registered interfaces */ | |
25 | static ide_hwif_t *ifs[2]; | |
26 | ||
27 | static int __init | |
28 | bastide_register(unsigned int base, unsigned int aux, int irq, | |
29 | ide_hwif_t **hwif) | |
30 | { | |
9e016a71 | 31 | ide_hwif_t *hwif; |
1da177e4 LT |
32 | hw_regs_t hw; |
33 | int i; | |
9e016a71 | 34 | u8 idx[4] = { 0xff, 0xff, 0xff, 0xff }; |
1da177e4 LT |
35 | |
36 | memset(&hw, 0, sizeof(hw)); | |
37 | ||
38 | base += BAST_IDE_CS; | |
39 | aux += BAST_IDE_CS; | |
40 | ||
41 | for (i = IDE_DATA_OFFSET; i <= IDE_STATUS_OFFSET; i++) { | |
42 | hw.io_ports[i] = (unsigned long)base; | |
43 | base += 0x20; | |
44 | } | |
45 | ||
46 | hw.io_ports[IDE_CONTROL_OFFSET] = aux + (6 * 0x20); | |
47 | hw.irq = irq; | |
48 | ||
9e016a71 BZ |
49 | hwif = ide_deprecated_find_port(hw.io_ports[IDE_DATA_OFFSET]); |
50 | if (hwif == NULL) | |
51 | goto out; | |
1da177e4 | 52 | |
9e016a71 BZ |
53 | i = hwif->index; |
54 | ||
55 | if (hwif->present) | |
909f4369 | 56 | ide_unregister(i, 0, 0); |
9e016a71 BZ |
57 | else if (!hwif->hold) |
58 | ide_init_port_data(hwif, i); | |
59 | ||
60 | ide_init_port_hw(hwif, &hw); | |
61 | hwif->quirkproc = NULL; | |
62 | ||
63 | idx[0] = i; | |
64 | ||
65 | ide_device_add(idx, NULL); | |
66 | out: | |
1da177e4 LT |
67 | return 0; |
68 | } | |
69 | ||
70 | static int __init bastide_init(void) | |
71 | { | |
72 | /* we can treat the VR1000 and the BAST the same */ | |
73 | ||
74 | if (!(machine_is_bast() || machine_is_vr1000())) | |
75 | return 0; | |
76 | ||
77 | printk("BAST: IDE driver, (c) 2003-2004 Simtec Electronics\n"); | |
78 | ||
79 | bastide_register(BAST_VA_IDEPRI, BAST_VA_IDEPRIAUX, IRQ_IDE0, &ifs[0]); | |
80 | bastide_register(BAST_VA_IDESEC, BAST_VA_IDESECAUX, IRQ_IDE1, &ifs[1]); | |
81 | return 0; | |
82 | } | |
83 | ||
84 | module_init(bastide_init); | |
85 | ||
86 | MODULE_AUTHOR("Ben Dooks <ben@simtec.co.uk>"); | |
87 | MODULE_LICENSE("GPL"); | |
88 | MODULE_DESCRIPTION("Simtec BAST / Thorcom VR1000 IDE driver"); |