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>
20 #include <asm/errno.h>
22 #include <asm/paccess.h>
24 #include <asm/dec/machtype.h>
25 #include <asm/dec/prom.h>
26 #include <asm/dec/tcinfo.h>
27 #include <asm/dec/tcmodule.h>
28 #include <asm/dec/interrupts.h>
30 MODULE_LICENSE("GPL");
31 slot_info tc_bus[MAX_SLOT];
32 static int num_tcslots;
36 * Interface to the world. Read comment in include/asm-mips/tc.h.
39 int search_tc_card(const char *name)
44 for (slot = 0; slot < num_tcslots; slot++) {
46 if ((sip->flags & FREE) &&
47 (strncmp(sip->name, name, strlen(name)) == 0)) {
55 void claim_tc_card(int slot)
57 if (tc_bus[slot].flags & IN_USE) {
58 printk("claim_tc_card: attempting to claim a card already in use\n");
61 tc_bus[slot].flags &= ~FREE;
62 tc_bus[slot].flags |= IN_USE;
65 void release_tc_card(int slot)
67 if (tc_bus[slot].flags & FREE) {
68 printk("release_tc_card: "
69 "attempting to release a card already free\n");
72 tc_bus[slot].flags &= ~IN_USE;
73 tc_bus[slot].flags |= FREE;
76 unsigned long get_tc_base_addr(int slot)
78 return tc_bus[slot].base_addr;
81 unsigned long get_tc_irq_nr(int slot)
83 return tc_bus[slot].interrupt;
86 unsigned long get_tc_speed(void)
88 return 100000 * (10000 / (unsigned long)info->clk_period);
92 * Probing for TURBOchannel modules
94 static void __init tc_probe(unsigned long startaddr, unsigned long size,
97 unsigned long slotaddr;
103 for (slot = 0; slot < slots; slot++) {
104 slotaddr = startaddr + slot * size;
105 module = ioremap_nocache(slotaddr, 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);
120 if (pattern[0] != 0x55 || pattern[1] != 0x00 ||
121 pattern[2] != 0xaa || pattern[3] != 0xff) {
125 err |= get_dbe(pattern[0], module + TC_PATTERN0);
126 err |= get_dbe(pattern[1], module + TC_PATTERN1);
127 err |= get_dbe(pattern[2], module + TC_PATTERN2);
128 err |= get_dbe(pattern[3], module + TC_PATTERN3);
135 if (pattern[0] != 0x55 || pattern[1] != 0x00 ||
136 pattern[2] != 0xaa || pattern[3] != 0xff) {
141 tc_bus[slot].base_addr = slotaddr;
142 for (i = 0; i < 8; i++) {
143 tc_bus[slot].firmware[i] =
144 module[TC_FIRM_VER + offset + 4 * i];
145 tc_bus[slot].vendor[i] =
146 module[TC_VENDOR + offset + 4 * i];
147 tc_bus[slot].name[i] =
148 module[TC_MODULE + offset + 4 * i];
150 tc_bus[slot].firmware[8] = 0;
151 tc_bus[slot].vendor[8] = 0;
152 tc_bus[slot].name[8] = 0;
154 * Looks unneccesary, but we may change
159 tc_bus[slot].interrupt = dec_interrupt[DEC_IRQ_TC0];
162 tc_bus[slot].interrupt = dec_interrupt[DEC_IRQ_TC1];
165 tc_bus[slot].interrupt = dec_interrupt[DEC_IRQ_TC2];
168 * Yuck! DS5000/200 onboard devices
171 tc_bus[slot].interrupt = dec_interrupt[DEC_IRQ_TC5];
174 tc_bus[slot].interrupt = dec_interrupt[DEC_IRQ_TC6];
177 tc_bus[slot].interrupt = -1;
188 static int __init tc_init(void)
192 unsigned long slot0addr;
193 unsigned long slot_size;
198 for (i = 0; i < MAX_SLOT; i++) {
199 tc_bus[i].base_addr = 0;
200 tc_bus[i].name[0] = 0;
201 tc_bus[i].vendor[0] = 0;
202 tc_bus[i].firmware[0] = 0;
203 tc_bus[i].interrupt = -1;
204 tc_bus[i].flags = FREE;
207 info = rex_gettcinfo();
208 slot0addr = CPHYSADDR((long)rex_slot_address(0));
210 switch (mips_machtype) {
211 case MACH_DS5000_200:
214 case MACH_DS5000_1XX:
215 case MACH_DS5000_2X0:
225 tc_clock = 10000 / info->clk_period;
227 if (info->slot_size && slot0addr) {
228 pr_info("TURBOchannel rev. %d at %d.%d MHz (with%s parity)\n",
229 info->revision, tc_clock / 10, tc_clock % 10,
230 info->parity ? "" : "out");
232 slot_size = info->slot_size << 20;
234 tc_probe(slot0addr, slot_size, num_tcslots);
236 for (i = 0; i < num_tcslots; i++) {
237 if (!tc_bus[i].base_addr)
239 pr_info(" slot %d: %s %s %s\n", i, tc_bus[i].vendor,
240 tc_bus[i].name, tc_bus[i].firmware);
247 subsys_initcall(tc_init);
249 EXPORT_SYMBOL(search_tc_card);
250 EXPORT_SYMBOL(claim_tc_card);
251 EXPORT_SYMBOL(release_tc_card);
252 EXPORT_SYMBOL(get_tc_base_addr);
253 EXPORT_SYMBOL(get_tc_irq_nr);
254 EXPORT_SYMBOL(get_tc_speed);