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 Maciej W. Rozycki
13 #include <linux/string.h>
14 #include <linux/init.h>
15 #include <linux/ioport.h>
16 #include <linux/kernel.h>
17 #include <linux/module.h>
19 #include <asm/addrspace.h>
20 #include <asm/errno.h>
21 #include <asm/dec/machtype.h>
22 #include <asm/dec/prom.h>
23 #include <asm/dec/tcinfo.h>
24 #include <asm/dec/tcmodule.h>
25 #include <asm/dec/interrupts.h>
26 #include <asm/paccess.h>
27 #include <asm/ptrace.h>
31 MODULE_LICENSE("GPL");
32 slot_info tc_bus
[MAX_SLOT
];
33 static int num_tcslots
;
36 unsigned long system_base
;
39 * Interface to the world. Read comment in include/asm-mips/tc.h.
42 int search_tc_card(const char *name
)
47 for (slot
= 0; slot
< num_tcslots
; slot
++) {
49 if ((sip
->flags
& FREE
) &&
50 (strncmp(sip
->name
, name
, strlen(name
)) == 0)) {
58 void claim_tc_card(int slot
)
60 if (tc_bus
[slot
].flags
& IN_USE
) {
61 printk("claim_tc_card: attempting to claim a card already in use\n");
64 tc_bus
[slot
].flags
&= ~FREE
;
65 tc_bus
[slot
].flags
|= IN_USE
;
68 void release_tc_card(int slot
)
70 if (tc_bus
[slot
].flags
& FREE
) {
71 printk("release_tc_card: "
72 "attempting to release a card already free\n");
75 tc_bus
[slot
].flags
&= ~IN_USE
;
76 tc_bus
[slot
].flags
|= FREE
;
79 unsigned long get_tc_base_addr(int slot
)
81 return tc_bus
[slot
].base_addr
;
84 unsigned long get_tc_irq_nr(int slot
)
86 return tc_bus
[slot
].interrupt
;
89 unsigned long get_tc_speed(void)
91 return 100000 * (10000 / (unsigned long)info
->clk_period
);
95 * Probing for TURBOchannel modules
97 static void __init
tc_probe(unsigned long startaddr
, unsigned long size
,
102 unsigned char pattern
[4];
103 unsigned char *module
;
105 for (slot
= 0; slot
< slots
; slot
++) {
106 module
= (char *)(startaddr
+ slot
* size
);
111 err
|= get_dbe(pattern
[0], module
+ OLDCARD
+ TC_PATTERN0
);
112 err
|= get_dbe(pattern
[1], module
+ OLDCARD
+ TC_PATTERN1
);
113 err
|= get_dbe(pattern
[2], module
+ OLDCARD
+ TC_PATTERN2
);
114 err
|= get_dbe(pattern
[3], module
+ OLDCARD
+ TC_PATTERN3
);
118 if (pattern
[0] != 0x55 || pattern
[1] != 0x00 ||
119 pattern
[2] != 0xaa || pattern
[3] != 0xff) {
123 err
|= get_dbe(pattern
[0], module
+ TC_PATTERN0
);
124 err
|= get_dbe(pattern
[1], module
+ TC_PATTERN1
);
125 err
|= get_dbe(pattern
[2], module
+ TC_PATTERN2
);
126 err
|= get_dbe(pattern
[3], module
+ TC_PATTERN3
);
131 if (pattern
[0] != 0x55 || pattern
[1] != 0x00 ||
132 pattern
[2] != 0xaa || pattern
[3] != 0xff)
135 tc_bus
[slot
].base_addr
= (unsigned long)module
;
136 for(i
= 0; i
< 8; i
++) {
137 tc_bus
[slot
].firmware
[i
] =
138 module
[TC_FIRM_VER
+ offset
+ 4 * i
];
139 tc_bus
[slot
].vendor
[i
] =
140 module
[TC_VENDOR
+ offset
+ 4 * i
];
141 tc_bus
[slot
].name
[i
] =
142 module
[TC_MODULE
+ offset
+ 4 * i
];
144 tc_bus
[slot
].firmware
[8] = 0;
145 tc_bus
[slot
].vendor
[8] = 0;
146 tc_bus
[slot
].name
[8] = 0;
148 * Looks unneccesary, but we may change
153 tc_bus
[slot
].interrupt
= dec_interrupt
[DEC_IRQ_TC0
];
156 tc_bus
[slot
].interrupt
= dec_interrupt
[DEC_IRQ_TC1
];
159 tc_bus
[slot
].interrupt
= dec_interrupt
[DEC_IRQ_TC2
];
162 * Yuck! DS5000/200 onboard devices
165 tc_bus
[slot
].interrupt
= dec_interrupt
[DEC_IRQ_TC5
];
168 tc_bus
[slot
].interrupt
= dec_interrupt
[DEC_IRQ_TC6
];
171 tc_bus
[slot
].interrupt
= -1;
180 void __init
tc_init(void)
184 unsigned long slot0addr
;
185 unsigned long slot_size
;
190 for (i
= 0; i
< MAX_SLOT
; i
++) {
191 tc_bus
[i
].base_addr
= 0;
192 tc_bus
[i
].name
[0] = 0;
193 tc_bus
[i
].vendor
[0] = 0;
194 tc_bus
[i
].firmware
[0] = 0;
195 tc_bus
[i
].interrupt
= -1;
196 tc_bus
[i
].flags
= FREE
;
199 info
= (tcinfo
*) rex_gettcinfo();
200 slot0addr
= (unsigned long)KSEG1ADDR(rex_slot_address(0));
202 switch (mips_machtype
) {
203 case MACH_DS5000_200
:
206 case MACH_DS5000_1XX
:
207 case MACH_DS5000_2X0
:
217 tc_clock
= 10000 / info
->clk_period
;
219 if (TURBOCHANNEL
&& info
->slot_size
&& slot0addr
) {
220 printk("TURBOchannel rev. %1d at %2d.%1d MHz ", info
->revision
,
221 tc_clock
/ 10, tc_clock
% 10);
222 printk("(with%s parity)\n", info
->parity
? "" : "out");
224 slot_size
= info
->slot_size
<< 20;
226 tc_probe(slot0addr
, slot_size
, num_tcslots
);
229 * All TURBOchannel DECstations have the onboard devices
230 * where the (num_tcslots + 0 or 1 on DS5k/xx) Option Module
233 if(mips_machtype
== MACH_DS5000_XX
)
238 system_base
= slot0addr
+ slot_size
* (num_tcslots
+ i
);
241 for (i
= 0; i
< num_tcslots
; i
++)
242 if (tc_bus
[i
].base_addr
) {
243 printk(" slot %d: ", i
);
244 printk("%s %s %s\n", tc_bus
[i
].vendor
,
245 tc_bus
[i
].name
, tc_bus
[i
].firmware
);
248 ioport_resource
.end
= KSEG2
- 1;
252 subsys_initcall(tc_init
);
254 EXPORT_SYMBOL(search_tc_card
);
255 EXPORT_SYMBOL(claim_tc_card
);
256 EXPORT_SYMBOL(release_tc_card
);
257 EXPORT_SYMBOL(get_tc_base_addr
);
258 EXPORT_SYMBOL(get_tc_irq_nr
);
259 EXPORT_SYMBOL(get_tc_speed
);
260 EXPORT_SYMBOL(system_base
);