2 * tc-init: We assume the TURBOchannel to be up and running so
3 * just probe for Modules and fill in the global data structure
6 * This file is subject to the terms and conditions of the GNU General Public
7 * License. See the file "COPYING" in the main directory of this archive
10 * Copyright (c) Harald Koerfgen, 1998
11 * Copyright (c) 2001, 2003, 2005 Maciej W. Rozycki
13 #include <linux/init.h>
14 #include <linux/kernel.h>
15 #include <linux/module.h>
16 #include <linux/string.h>
17 #include <linux/types.h>
19 #include <asm/addrspace.h>
21 #include <asm/errno.h>
23 #include <asm/paccess.h>
25 #include <asm/dec/machtype.h>
26 #include <asm/dec/prom.h>
27 #include <asm/dec/tcinfo.h>
28 #include <asm/dec/tcmodule.h>
29 #include <asm/dec/interrupts.h>
31 MODULE_LICENSE("GPL");
32 slot_info tc_bus
[MAX_SLOT
];
33 static int num_tcslots
;
37 * Interface to the world. Read comment in include/asm-mips/tc.h.
40 int search_tc_card(const char *name
)
45 for (slot
= 0; slot
< num_tcslots
; slot
++) {
47 if ((sip
->flags
& FREE
) &&
48 (strncmp(sip
->name
, name
, strlen(name
)) == 0)) {
56 void claim_tc_card(int slot
)
58 if (tc_bus
[slot
].flags
& IN_USE
) {
59 printk("claim_tc_card: attempting to claim a card already in use\n");
62 tc_bus
[slot
].flags
&= ~FREE
;
63 tc_bus
[slot
].flags
|= IN_USE
;
66 void release_tc_card(int slot
)
68 if (tc_bus
[slot
].flags
& FREE
) {
69 printk("release_tc_card: "
70 "attempting to release a card already free\n");
73 tc_bus
[slot
].flags
&= ~IN_USE
;
74 tc_bus
[slot
].flags
|= FREE
;
77 unsigned long get_tc_base_addr(int slot
)
79 return tc_bus
[slot
].base_addr
;
82 unsigned long get_tc_irq_nr(int slot
)
84 return tc_bus
[slot
].interrupt
;
87 unsigned long get_tc_speed(void)
89 return 100000 * (10000 / (unsigned long)info
->clk_period
);
93 * Probing for TURBOchannel modules
95 static void __init
tc_probe(unsigned long startaddr
, unsigned long size
,
98 unsigned long slotaddr
;
104 for (slot
= 0; slot
< slots
; slot
++) {
105 slotaddr
= startaddr
+ slot
* size
;
106 module
= ioremap_nocache(slotaddr
, size
);
112 err
|= get_dbe(pattern
[0], module
+ OLDCARD
+ TC_PATTERN0
);
113 err
|= get_dbe(pattern
[1], module
+ OLDCARD
+ TC_PATTERN1
);
114 err
|= get_dbe(pattern
[2], module
+ OLDCARD
+ TC_PATTERN2
);
115 err
|= get_dbe(pattern
[3], module
+ OLDCARD
+ TC_PATTERN3
);
121 if (pattern
[0] != 0x55 || pattern
[1] != 0x00 ||
122 pattern
[2] != 0xaa || pattern
[3] != 0xff) {
126 err
|= get_dbe(pattern
[0], module
+ TC_PATTERN0
);
127 err
|= get_dbe(pattern
[1], module
+ TC_PATTERN1
);
128 err
|= get_dbe(pattern
[2], module
+ TC_PATTERN2
);
129 err
|= get_dbe(pattern
[3], module
+ TC_PATTERN3
);
136 if (pattern
[0] != 0x55 || pattern
[1] != 0x00 ||
137 pattern
[2] != 0xaa || pattern
[3] != 0xff) {
142 tc_bus
[slot
].base_addr
= slotaddr
;
143 for (i
= 0; i
< 8; i
++) {
144 tc_bus
[slot
].firmware
[i
] =
145 module
[TC_FIRM_VER
+ offset
+ 4 * i
];
146 tc_bus
[slot
].vendor
[i
] =
147 module
[TC_VENDOR
+ offset
+ 4 * i
];
148 tc_bus
[slot
].name
[i
] =
149 module
[TC_MODULE
+ offset
+ 4 * i
];
151 tc_bus
[slot
].firmware
[8] = 0;
152 tc_bus
[slot
].vendor
[8] = 0;
153 tc_bus
[slot
].name
[8] = 0;
155 * Looks unneccesary, but we may change
160 tc_bus
[slot
].interrupt
= dec_interrupt
[DEC_IRQ_TC0
];
163 tc_bus
[slot
].interrupt
= dec_interrupt
[DEC_IRQ_TC1
];
166 tc_bus
[slot
].interrupt
= dec_interrupt
[DEC_IRQ_TC2
];
169 * Yuck! DS5000/200 onboard devices
172 tc_bus
[slot
].interrupt
= dec_interrupt
[DEC_IRQ_TC5
];
175 tc_bus
[slot
].interrupt
= dec_interrupt
[DEC_IRQ_TC6
];
178 tc_bus
[slot
].interrupt
= -1;
189 static int __init
tc_init(void)
193 unsigned long slot0addr
;
194 unsigned long slot_size
;
199 for (i
= 0; i
< MAX_SLOT
; i
++) {
200 tc_bus
[i
].base_addr
= 0;
201 tc_bus
[i
].name
[0] = 0;
202 tc_bus
[i
].vendor
[0] = 0;
203 tc_bus
[i
].firmware
[0] = 0;
204 tc_bus
[i
].interrupt
= -1;
205 tc_bus
[i
].flags
= FREE
;
208 info
= rex_gettcinfo();
209 slot0addr
= CPHYSADDR((long)rex_slot_address(0));
211 switch (mips_machtype
) {
212 case MACH_DS5000_200
:
215 case MACH_DS5000_1XX
:
216 case MACH_DS5000_2X0
:
226 tc_clock
= 10000 / info
->clk_period
;
228 if (info
->slot_size
&& slot0addr
) {
229 pr_info("TURBOchannel rev. %d at %d.%d MHz (with%s parity)\n",
230 info
->revision
, tc_clock
/ 10, tc_clock
% 10,
231 info
->parity
? "" : "out");
233 slot_size
= info
->slot_size
<< 20;
235 tc_probe(slot0addr
, slot_size
, num_tcslots
);
237 for (i
= 0; i
< num_tcslots
; i
++) {
238 if (!tc_bus
[i
].base_addr
)
240 pr_info(" slot %d: %s %s %s\n", i
, tc_bus
[i
].vendor
,
241 tc_bus
[i
].name
, tc_bus
[i
].firmware
);
248 subsys_initcall(tc_init
);
250 EXPORT_SYMBOL(search_tc_card
);
251 EXPORT_SYMBOL(claim_tc_card
);
252 EXPORT_SYMBOL(release_tc_card
);
253 EXPORT_SYMBOL(get_tc_base_addr
);
254 EXPORT_SYMBOL(get_tc_irq_nr
);
255 EXPORT_SYMBOL(get_tc_speed
);