2 ** -----------------------------------------------------------------------------
4 ** Perle Specialix driver for Linux
5 ** Ported from existing RIO Driver for SCO sources.
7 * (C) 1990 - 2000 Specialix International Ltd., Byfleet, Surrey, UK.
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
25 ** Last Modified : 11/6/98 10:33:43
26 ** Retrieved : 11/6/98 10:33:49
28 ** ident @(#)rioinit.c 1.3
30 ** -----------------------------------------------------------------------------
33 static char *_rioinit_c_sccs_
= "@(#)rioinit.c 1.3";
36 #include <linux/config.h>
37 #include <linux/module.h>
38 #include <linux/slab.h>
39 #include <linux/errno.h>
41 #include <asm/system.h>
42 #include <asm/string.h>
43 #include <asm/semaphore.h>
44 #include <asm/uaccess.h>
46 #include <linux/termios.h>
47 #include <linux/serial.h>
49 #include <linux/generic_serial.h>
52 #include "linux_compat.h"
82 #include "rio_linux.h"
85 #define bcopy rio_pcicopy
87 int RIOPCIinit(struct rio_info
*p
, int Mode
);
90 static void RIOAllocateInterrupts(struct rio_info
*);
91 static int RIOReport(struct rio_info
*);
92 static void RIOStopInterrupts(struct rio_info
*, int, int);
95 static int RIOScrub(int, BYTE
*, int);
98 extern int rio_intr();
106 struct RioHostInfo
* info
;
109 ** Multi-Host card support - taking the easy way out - sorry !
110 ** We allocate and set up the Host and Port structs when the
111 ** driver is called to 'install' the first host.
112 ** We check for this first 'call' by testing the RIOPortp pointer.
116 rio_dprintk (RIO_DEBUG_INIT
, "Allocating and setting up driver data structures\n");
118 RIOAllocDataStructs(p
); /* allocate host/port structs */
119 RIOSetupDataStructs(p
); /* setup topology structs */
122 RIOInitHosts( p
, info
); /* hunt down the hardware */
124 RIOAllocateInterrupts(p
); /* allocate interrupts */
125 RIOReport(p
); /* show what we found */
129 ** Initialise the Cards
132 RIOInitHosts(p
, info
)
134 struct RioHostInfo
* info
;
137 ** 15.10.1998 ARG - ESIL 0762 part fix
138 ** If there is no ISA card definition - we always look for PCI cards.
139 ** As we currently only support one host card this lets an ISA card
140 ** definition take precedence over PLUG and PLAY.
141 ** No ISA card - we are PLUG and PLAY with PCI.
145 ** Note - for PCI both these will be zero, that's okay because
146 ** RIOPCIInit() fills them in if a card is found.
148 p
->RIOHosts
[p
->RIONumHosts
].Ivec
= info
->vector
;
149 p
->RIOHosts
[p
->RIONumHosts
].PaddrP
= info
->location
;
152 ** Check that we are able to accommodate another host
154 if ( p
->RIONumHosts
>= RIO_HOSTS
)
160 if ( info
->bus
& ISA_BUS
)
162 rio_dprintk (RIO_DEBUG_INIT
, "initialising card %d (ISA)\n", p
->RIONumHosts
);
163 RIOISAinit(p
, p
->mode
);
167 rio_dprintk (RIO_DEBUG_INIT
, "initialising card %d (PCI)\n", p
->RIONumHosts
);
168 RIOPCIinit(p
, RIO_PCI_DEFAULT_MODE
);
171 rio_dprintk (RIO_DEBUG_INIT
, "Total hosts initialised so far : %d\n", p
->RIONumHosts
);
174 #ifdef FUTURE_RELEASE
175 if (p
->bus
& EISA_BUS
)
177 RIOEISAinit(p
, RIO_EISA_DEFAULT_MODE
);
179 if (p
->bus
& MCA_BUS
)
181 RIOMCAinit(p
, RIO_MCA_DEFAULT_MODE
);
186 ** go through memory for an AT host that we pass in the device info
187 ** structure and initialise
195 /* XXX Need to implement this. */
197 p
->intr_tid
= iointset(p
->RIOHosts
[p
->RIONumHosts
].Ivec
,
198 (int (*)())rio_intr
, (char*)p
->RIONumHosts
);
200 rio_dprintk (RIO_DEBUG_INIT
, "Set interrupt handler, intr_tid = 0x%x\n", p
->intr_tid
);
202 if (RIODoAT(p
, p
->RIOHosts
[p
->RIONumHosts
].PaddrP
, mode
)) {
206 rio_dprintk (RIO_DEBUG_INIT
, "RIODoAT failed\n");
216 ** Map in a boards physical address, check that the board is there,
217 ** test the board and if everything is okay assign the board an entry
218 ** in the Rio Hosts structure.
221 RIODoAT(p
, Base
, mode
)
232 ** Check to see if we actually have a board at this physical address.
234 if ((cardAddr
= RIOCheckForATCard(Base
)) != 0) {
236 ** Now test the board to see if it is working.
238 if (RIOBoardTest(Base
, cardAddr
, RIO_AT
, 0) == RIO_SUCCESS
) {
240 ** Fill out a slot in the Rio host structure.
242 if (RIOAssignAT(p
, Base
, cardAddr
, mode
)) {
246 RIOMapout(Base
, RIO_AT_MEM_SIZE
, cardAddr
);
252 RIOCheckForATCard(Base
)
256 struct DpRam
*cardp
; /* (Points at the host) */
258 unsigned char RIOSigTab
[24];
260 ** Table of values to search for as prom signature of a host card
262 strcpy(RIOSigTab
, "JBJGPGGHINSMJPJR");
265 ** Hey! Yes, You reading this code! Yo, grab a load a this:
267 ** IF the card is using WORD MODE rather than BYTE MODE
268 ** then it will occupy 128K of PHYSICAL memory area. So,
269 ** you might think that the following Mapin is wrong. Well,
270 ** it isn't, because the SECOND 64K of occupied space is an
271 ** EXACT COPY of the FIRST 64K. (good?), so, we need only
272 ** map it in in one 64K block.
274 if (RIOMapin(Base
, RIO_AT_MEM_SIZE
, &virtAddr
) == -1) {
275 rio_dprintk (RIO_DEBUG_INIT
, "RIO-init: Couldn't map the board in!\n");
280 ** virtAddr points to the DP ram of the system.
281 ** We now cast this to a pointer to a RIO Host,
282 ** and have a rummage about in the PROM.
284 cardp
= (struct DpRam
*)virtAddr
;
286 for (off
=0; RIOSigTab
[off
]; off
++) {
287 if ((RBYTE(cardp
->DpSignature
[off
]) & 0xFF) != RIOSigTab
[off
]) {
289 ** Signature mismatch - card not at this address
291 RIOMapout(Base
, RIO_AT_MEM_SIZE
, virtAddr
);
292 rio_dprintk (RIO_DEBUG_INIT
, "RIO-init: Couldn't match the signature 0x%x 0x%x!\n",
299 ** If we get here then we must have found a valid board so return
300 ** its virtual address.
309 ** Fill out the fields in the p->RIOHosts structure now we know we know
310 ** we have a board present.
312 ** bits < 0 indicates 8 bit operation requested,
313 ** bits > 0 indicates 16 bit operation.
316 RIOAssignAT(p
, Base
, virtAddr
, mode
)
323 struct DpRam
*cardp
= (struct DpRam
*)virtAddr
;
325 if ((Base
< ONE_MEG
) || (mode
& BYTE_ACCESS_MODE
))
326 bits
= BYTE_OPERATION
;
328 bits
= WORD_OPERATION
;
331 ** Board has passed its scrub test. Fill in all the
334 p
->RIOHosts
[p
->RIONumHosts
].Caddr
= virtAddr
;
335 p
->RIOHosts
[p
->RIONumHosts
].CardP
= (struct DpRam
*)virtAddr
;
338 ** Revision 01 AT host cards don't support WORD operations,
340 if ( RBYTE(cardp
->DpRevision
) == 01 )
341 bits
= BYTE_OPERATION
;
343 p
->RIOHosts
[p
->RIONumHosts
].Type
= RIO_AT
;
344 p
->RIOHosts
[p
->RIONumHosts
].Copy
= bcopy
;
346 p
->RIOHosts
[p
->RIONumHosts
].Slot
= -1;
347 p
->RIOHosts
[p
->RIONumHosts
].Mode
= SLOW_LINKS
| SLOW_AT_BUS
| bits
;
348 WBYTE(p
->RIOHosts
[p
->RIONumHosts
].Control
,
349 BOOT_FROM_RAM
| EXTERNAL_BUS_OFF
|
350 p
->RIOHosts
[p
->RIONumHosts
].Mode
|
352 WBYTE(p
->RIOHosts
[p
->RIONumHosts
].ResetInt
,0xff);
353 WBYTE(p
->RIOHosts
[p
->RIONumHosts
].Control
,
354 BOOT_FROM_RAM
| EXTERNAL_BUS_OFF
|
355 p
->RIOHosts
[p
->RIONumHosts
].Mode
|
357 WBYTE(p
->RIOHosts
[p
->RIONumHosts
].ResetInt
,0xff);
358 p
->RIOHosts
[p
->RIONumHosts
].UniqueNum
=
359 ((RBYTE(p
->RIOHosts
[p
->RIONumHosts
].Unique
[0])&0xFF)<<0)|
360 ((RBYTE(p
->RIOHosts
[p
->RIONumHosts
].Unique
[1])&0xFF)<<8)|
361 ((RBYTE(p
->RIOHosts
[p
->RIONumHosts
].Unique
[2])&0xFF)<<16)|
362 ((RBYTE(p
->RIOHosts
[p
->RIONumHosts
].Unique
[3])&0xFF)<<24);
363 rio_dprintk (RIO_DEBUG_INIT
, "RIO-init: Uniquenum 0x%x\n",p
->RIOHosts
[p
->RIONumHosts
].UniqueNum
);
366 rio_dprintk (RIO_DEBUG_INIT
, "RIO-init: Tests Passed at 0x%x\n", Base
);
370 #ifdef FUTURE_RELEASE
371 int RIOMCAinit(int Mode
)
381 ** Valid mode information for MCA cards
382 ** is only FAST LINKS
384 Mode
= (Mode
& FAST_LINKS
) ? McaTpFastLinks
: McaTpSlowLinks
;
385 rio_dprintk (RIO_DEBUG_INIT
, "RIOMCAinit(%d)\n",Mode
);
389 ** Check out each of the slots
391 for (SlotNumber
= 0; SlotNumber
< McaMaxSlots
; SlotNumber
++) {
393 ** Enable the slot we want to talk to
395 outb( McaSlotSelect
, SlotNumber
| McaSlotEnable
);
398 ** Read the ID word from the slot
400 if (((inb(McaIdHigh
)<< 8)|inb(McaIdLow
)) == McaRIOId
)
402 rio_dprintk (RIO_DEBUG_INIT
, "Potential MCA card in slot %d\n", SlotNumber
);
405 ** Card appears to be a RIO MCA card!
407 RIOMachineType
|= (1<<RIO_MCA
);
410 ** Just check we haven't found too many wonderful objects
412 if ( RIONumHosts
>= RIO_HOSTS
)
414 Rprintf(RIOMesgTooManyCards
);
419 ** McaIrqEnable contains the interrupt vector, and a card
422 Ivec
= inb(McaIrqEnable
);
424 rio_dprintk (RIO_DEBUG_INIT
, "Ivec is %x\n", Ivec
);
426 switch ( Ivec
& McaIrqMask
)
429 rio_dprintk (RIO_DEBUG_INIT
, "IRQ9\n");
432 rio_dprintk (RIO_DEBUG_INIT
, "IRQ3\n");
435 rio_dprintk (RIO_DEBUG_INIT
, "IRQ4\n");
438 rio_dprintk (RIO_DEBUG_INIT
, "IRQ7\n");
441 rio_dprintk (RIO_DEBUG_INIT
, "IRQ10\n");
444 rio_dprintk (RIO_DEBUG_INIT
, "IRQ11\n");
447 rio_dprintk (RIO_DEBUG_INIT
, "IRQ12\n");
450 rio_dprintk (RIO_DEBUG_INIT
, "IRQ15\n");
455 ** If the card enable bit isn't set, then set it!
457 if ((Ivec
& McaCardEnable
) != McaCardEnable
) {
458 rio_dprintk (RIO_DEBUG_INIT
, "McaCardEnable not set - setting!\n");
459 outb(McaIrqEnable
,Ivec
|McaCardEnable
);
461 rio_dprintk (RIO_DEBUG_INIT
, "McaCardEnable already set\n");
464 ** Convert the IRQ enable mask into something useful
466 Ivec
= RIOMcaToIvec
[Ivec
& McaIrqMask
];
469 ** Find the physical address
471 rio_dprintk (RIO_DEBUG_INIT
, "inb(McaMemory) is %x\n", inb(McaMemory
));
472 Paddr
= McaAddress(inb(McaMemory
));
474 rio_dprintk (RIO_DEBUG_INIT
, "MCA card has Ivec %d Addr %x\n", Ivec
, Paddr
);
480 ** Tell the memory mapper that we want to talk to it
482 Handle
= RIOMapin( Paddr
, RIO_MCA_MEM_SIZE
, &Caddr
);
484 if ( Handle
== -1 ) {
485 rio_dprintk (RIO_DEBUG_INIT
, "Couldn't map %d bytes at %x\n", RIO_MCA_MEM_SIZE
, Paddr
;
489 rio_dprintk (RIO_DEBUG_INIT
, "Board mapped to vaddr 0x%x\n", Caddr
);
492 ** And check that it is actually there!
494 if ( RIOBoardTest( Paddr
,Caddr
,RIO_MCA
,SlotNumber
) == RIO_SUCCESS
)
496 rio_dprintk (RIO_DEBUG_INIT
, "Board has passed test\n");
497 rio_dprintk (RIO_DEBUG_INIT
, "Slot %d. Type %d. Paddr 0x%x. Caddr 0x%x. Mode 0x%x.\n",
498 SlotNumber
, RIO_MCA
, Paddr
, Caddr
, Mode
);
501 ** Board has passed its scrub test. Fill in all the
504 p
->RIOHosts
[RIONumHosts
].Slot
= SlotNumber
;
505 p
->RIOHosts
[RIONumHosts
].Ivec
= Ivec
;
506 p
->RIOHosts
[RIONumHosts
].Type
= RIO_MCA
;
507 p
->RIOHosts
[RIONumHosts
].Copy
= bcopy
;
508 p
->RIOHosts
[RIONumHosts
].PaddrP
= Paddr
;
509 p
->RIOHosts
[RIONumHosts
].Caddr
= Caddr
;
510 p
->RIOHosts
[RIONumHosts
].CardP
= (struct DpRam
*)Caddr
;
511 p
->RIOHosts
[RIONumHosts
].Mode
= Mode
;
512 WBYTE(p
->RIOHosts
[p
->RIONumHosts
].ResetInt
, 0xff);
513 p
->RIOHosts
[RIONumHosts
].UniqueNum
=
514 ((RBYTE(p
->RIOHosts
[RIONumHosts
].Unique
[0])&0xFF)<<0)|
515 ((RBYTE(p
->RIOHosts
[RIONumHosts
].Unique
[1])&0xFF)<<8)|
516 ((RBYTE(p
->RIOHosts
[RIONumHosts
].Unique
[2])&0xFF)<<16)|
517 ((RBYTE(p
->RIOHosts
[RIONumHosts
].Unique
[3])&0xFF)<<24);
524 ** It failed the test, so ignore it.
526 rio_dprintk (RIO_DEBUG_INIT
, "TEST FAILED\n");
527 RIOMapout(Paddr
, RIO_MCA_MEM_SIZE
, Caddr
);
532 rio_dprintk (RIO_DEBUG_INIT
, "Slot %d - Paddr zero!\n", SlotNumber
);
537 rio_dprintk (RIO_DEBUG_INIT
, "Slot %d NOT RIO\n", SlotNumber
);
541 ** Now we have checked all the slots, turn off the MCA slot selector
543 outb(McaSlotSelect
,0);
544 rio_dprintk (RIO_DEBUG_INIT
, "Slot %d NOT RIO\n", SlotNumber
);
548 int RIOEISAinit( int Mode
)
550 static int EISADone
= 0;
552 int PollIntMixMsgDone
= 0;
560 ** The only valid mode information for EISA hosts is fast or slow
563 Mode
= (Mode
& FAST_LINKS
) ? EISA_TP_FAST_LINKS
: EISA_TP_SLOW_LINKS
;
567 rio_dprintk (RIO_DEBUG_INIT
, "RIOEISAinit() - already done, return.\n");
573 rio_dprintk (RIO_DEBUG_INIT
, "RIOEISAinit()\n");
577 ** First check all cards to see if ANY are set for polled mode operation.
578 ** If so, set ALL to polled.
581 for ( EisaSlot
=1; EisaSlot
<=RIO_MAX_EISA_SLOTS
; EisaSlot
++ )
583 Ident
= (INBZ(EisaSlot
,EISA_PRODUCT_IDENT_HI
)<<8) |
584 INBZ(EisaSlot
,EISA_PRODUCT_IDENT_LO
);
586 if ( Ident
== RIO_EISA_IDENT
)
588 rio_dprintk (RIO_DEBUG_INIT
, "Found Specialix product\n");
590 if ( INBZ(EisaSlot
,EISA_PRODUCT_NUMBER
) != RIO_EISA_PRODUCT_CODE
)
592 rio_dprintk (RIO_DEBUG_INIT
, "Not Specialix RIO - Product number %x\n",
593 INBZ(EisaSlot
, EISA_PRODUCT_NUMBER
));
594 continue; /* next slot */
597 ** Its a Specialix RIO!
599 rio_dprintk (RIO_DEBUG_INIT
, "RIO Revision %d\n",
600 INBZ(EisaSlot
, EISA_REVISION_NUMBER
));
602 RIOMachineType
|= (1<<RIO_EISA
);
605 ** Just check we haven't found too many wonderful objects
607 if ( RIONumHosts
>= RIO_HOSTS
)
609 Rprintf(RIOMesgTooManyCards
);
614 ** Ensure that the enable bit is set!
616 OUTBZ( EisaSlot
, EISA_ENABLE
, RIO_EISA_ENABLE_BIT
);
619 ** EISA_INTERRUPT_VEC contains the interrupt vector.
621 Ivec
= INBZ(EisaSlot
,EISA_INTERRUPT_VEC
);
624 switch ( Ivec
& EISA_INTERRUPT_MASK
)
627 rio_dprintk (RIO_DEBUG_INIT
, "EISA IRQ 3\n");
630 rio_dprintk (RIO_DEBUG_INIT
, "EISA IRQ 4\n");
633 rio_dprintk (RIO_DEBUG_INIT
, "EISA IRQ 5\n");
636 rio_dprintk (RIO_DEBUG_INIT
, "EISA IRQ 6\n");
639 rio_dprintk (RIO_DEBUG_INIT
, "EISA IRQ 7\n");
642 rio_dprintk (RIO_DEBUG_INIT
, "EISA IRQ 9\n");
645 rio_dprintk (RIO_DEBUG_INIT
, "EISA IRQ 10\n");
648 rio_dprintk (RIO_DEBUG_INIT
, "EISA IRQ 11\n");
651 rio_dprintk (RIO_DEBUG_INIT
, "EISA IRQ 12\n");
654 rio_dprintk (RIO_DEBUG_INIT
, "EISA IRQ 14\n");
657 rio_dprintk (RIO_DEBUG_INIT
, "EISA IRQ 15\n");
660 rio_dprintk (RIO_DEBUG_INIT
, "EISA POLLED\n");
663 rio_dprintk (RIO_DEBUG_INIT
, NULL
,DBG_INIT
|DBG_FAIL
,"Shagged interrupt number!\n");
664 Ivec
&= EISA_CONTROL_MASK
;
668 if ( (Ivec
& EISA_INTERRUPT_MASK
) ==
672 break; /* From EisaSlot loop */
678 ** Do it all again now we know whether to change all cards to polled
682 for ( EisaSlot
=1; EisaSlot
<=RIO_MAX_EISA_SLOTS
; EisaSlot
++ )
684 Ident
= (INBZ(EisaSlot
,EISA_PRODUCT_IDENT_HI
)<<8) |
685 INBZ(EisaSlot
,EISA_PRODUCT_IDENT_LO
);
687 if ( Ident
== RIO_EISA_IDENT
)
689 if ( INBZ(EisaSlot
,EISA_PRODUCT_NUMBER
) != RIO_EISA_PRODUCT_CODE
)
690 continue; /* next slot */
693 ** Its a Specialix RIO!
697 ** Ensure that the enable bit is set!
699 OUTBZ( EisaSlot
, EISA_ENABLE
, RIO_EISA_ENABLE_BIT
);
702 ** EISA_INTERRUPT_VEC contains the interrupt vector.
704 Ivec
= INBZ(EisaSlot
,EISA_INTERRUPT_VEC
);
709 ** If we are going to operate in polled mode, but this
710 ** board is configured to be interrupt driven, display
711 ** the message explaining the situation to the punter,
712 ** assuming we haven't already done so.
715 if ( !PollIntMixMsgDone
&&
716 (Ivec
& EISA_INTERRUPT_MASK
) != EISA_POLLED
)
718 Rprintf(RIOMesgAllPolled
);
719 PollIntMixMsgDone
= 1;
723 ** Ungraciously ignore whatever the board reports as its
724 ** interrupt vector...
727 Ivec
&= ~EISA_INTERRUPT_MASK
;
730 ** ...and force it to dance to the poll tune.
737 ** Convert the IRQ enable mask into something useful (0-15)
739 Ivec
= RIOEisaToIvec(Ivec
);
741 rio_dprintk (RIO_DEBUG_INIT
, "EISA host in slot %d has Ivec 0x%x\n",
745 ** Find the physical address
747 Paddr
= (INBZ(EisaSlot
,EISA_MEMORY_BASE_HI
)<<24) |
748 (INBZ(EisaSlot
,EISA_MEMORY_BASE_LO
)<<16);
750 rio_dprintk (RIO_DEBUG_INIT
, "EISA card has Ivec %d Addr %x\n", Ivec
, Paddr
);
754 rio_dprintk (RIO_DEBUG_INIT
,
755 "Board in slot %d configured for address zero!\n", EisaSlot
);
760 ** Tell the memory mapper that we want to talk to it
762 rio_dprintk (RIO_DEBUG_INIT
, "About to map EISA card \n");
764 if (RIOMapin( Paddr
, RIO_EISA_MEM_SIZE
, &Caddr
) == -1) {
765 rio_dprintk (RIO_DEBUG_INIT
, "Couldn't map %d bytes at %x\n",
766 RIO_EISA_MEM_SIZE
,Paddr
);
770 rio_dprintk (RIO_DEBUG_INIT
, "Board mapped to vaddr 0x%x\n", Caddr
);
773 ** And check that it is actually there!
775 if ( RIOBoardTest( Paddr
,Caddr
,RIO_EISA
,EisaSlot
) == RIO_SUCCESS
)
777 rio_dprintk (RIO_DEBUG_INIT
, "Board has passed test\n");
778 rio_dprintk (RIO_DEBUG_INIT
,
779 "Slot %d. Ivec %d. Type %d. Paddr 0x%x. Caddr 0x%x. Mode 0x%x.\n",
780 EisaSlot
,Ivec
,RIO_EISA
,Paddr
,Caddr
,Mode
);
783 ** Board has passed its scrub test. Fill in all the
786 p
->RIOHosts
[RIONumHosts
].Slot
= EisaSlot
;
787 p
->RIOHosts
[RIONumHosts
].Ivec
= Ivec
;
788 p
->RIOHosts
[RIONumHosts
].Type
= RIO_EISA
;
789 p
->RIOHosts
[RIONumHosts
].Copy
= bcopy
;
790 p
->RIOHosts
[RIONumHosts
].PaddrP
= Paddr
;
791 p
->RIOHosts
[RIONumHosts
].Caddr
= Caddr
;
792 p
->RIOHosts
[RIONumHosts
].CardP
= (struct DpRam
*)Caddr
;
793 p
->RIOHosts
[RIONumHosts
].Mode
= Mode
;
795 ** because the EISA prom is mapped into IO space, we
796 ** need to copy the unqiue number into the memory area
797 ** that it would have occupied, so that the download
798 ** code can determine its ID and card type.
800 WBYTE(p
->RIOHosts
[RIONumHosts
].Unique
[0],INBZ(EisaSlot
,EISA_UNIQUE_NUM_0
));
801 WBYTE(p
->RIOHosts
[RIONumHosts
].Unique
[1],INBZ(EisaSlot
,EISA_UNIQUE_NUM_1
));
802 WBYTE(p
->RIOHosts
[RIONumHosts
].Unique
[2],INBZ(EisaSlot
,EISA_UNIQUE_NUM_2
));
803 WBYTE(p
->RIOHosts
[RIONumHosts
].Unique
[3],INBZ(EisaSlot
,EISA_UNIQUE_NUM_3
));
804 p
->RIOHosts
[RIONumHosts
].UniqueNum
=
805 ((RBYTE(p
->RIOHosts
[RIONumHosts
].Unique
[0])&0xFF)<<0)|
806 ((RBYTE(p
->RIOHosts
[RIONumHosts
].Unique
[1])&0xFF)<<8)|
807 ((RBYTE(p
->RIOHosts
[RIONumHosts
].Unique
[2])&0xFF)<<16)|
808 ((RBYTE(p
->RIOHosts
[RIONumHosts
].Unique
[3])&0xFF)<<24);
809 INBZ(EisaSlot
,EISA_INTERRUPT_RESET
);
816 ** It failed the test, so ignore it.
818 rio_dprintk (RIO_DEBUG_INIT
, "TEST FAILED\n");
820 RIOMapout(Paddr
, RIO_EISA_MEM_SIZE
, Caddr
);
824 if (RIOMachineType
& RIO_EISA
)
833 #define CONFIG_ADDRESS 0xcf8
834 #define CONFIG_DATA 0xcfc
835 #define FORWARD_REG 0xcfa
839 read_config(int bus_number
, int device_num
, int r_number
)
845 Build config_address_value:
847 31 24 23 16 15 11 10 8 7 0
848 ------------------------------------------------------
849 |1| 0000000 | bus_number | device # | 000 | register |
850 ------------------------------------------------------
853 cav
= r_number
& 0xff;
854 cav
|= ((device_num
& 0x1f) << 11);
855 cav
|= ((bus_number
& 0xff) << 16);
856 cav
|= 0x80000000; /* Enable bit */
857 outpd(CONFIG_ADDRESS
,cav
);
858 val
= inpd(CONFIG_DATA
);
859 outpd(CONFIG_ADDRESS
,0);
864 write_config(bus_number
,device_num
,r_number
,val
)
869 Build config_address_value:
871 31 24 23 16 15 11 10 8 7 0
872 ------------------------------------------------------
873 |1| 0000000 | bus_number | device # | 000 | register |
874 ------------------------------------------------------
877 cav
= r_number
& 0xff;
878 cav
|= ((device_num
& 0x1f) << 11);
879 cav
|= ((bus_number
& 0xff) << 16);
880 cav
|= 0x80000000; /* Enable bit */
881 outpd(CONFIG_ADDRESS
, cav
);
882 outpd(CONFIG_DATA
, val
);
883 outpd(CONFIG_ADDRESS
, 0);
887 /* XXX Implement these... */
889 read_config(int bus_number
, int device_num
, int r_number
)
895 write_config(int bus_number
, int device_num
, int r_number
)
907 #define MAX_PCI_SLOT 32
908 #define RIO_PCI_JET_CARD 0x200011CB
910 static int slot
; /* count of machine's PCI slots searched so far */
911 caddr_t Caddr
; /* Virtual address of the current PCI host card. */
912 unsigned char Ivec
; /* interrupt vector for the current PCI host */
913 unsigned long Paddr
; /* Physical address for the current PCI host */
914 int Handle
; /* Handle to Virtual memory allocated for current PCI host */
917 rio_dprintk (RIO_DEBUG_INIT
, "Search for a RIO PCI card - start at slot %d\n", slot
);
920 ** Initialise the search status
922 p
->RIOLastPCISearch
= RIO_FAIL
;
924 while ( (slot
< MAX_PCI_SLOT
) & (p
->RIOLastPCISearch
!= RIO_SUCCESS
) )
926 rio_dprintk (RIO_DEBUG_INIT
, "Currently testing slot %d\n", slot
);
928 if (read_config(0,slot
,0) == RIO_PCI_JET_CARD
) {
929 p
->RIOHosts
[p
->RIONumHosts
].Ivec
= 0;
930 Paddr
= read_config(0,slot
,0x18);
931 Paddr
= Paddr
- (Paddr
& 0x1); /* Mask off the io bit */
933 if ( (Paddr
== 0) || ((Paddr
& 0xffff0000) == 0xffff0000) ) {
934 rio_dprintk (RIO_DEBUG_INIT
, "Goofed up slot\n"); /* what! */
939 p
->RIOHosts
[p
->RIONumHosts
].PaddrP
= Paddr
;
940 Ivec
= (read_config(0,slot
,0x3c) & 0xff);
942 rio_dprintk (RIO_DEBUG_INIT
, "PCI Host at 0x%x, Intr %d\n", (int)Paddr
, Ivec
);
944 Handle
= RIOMapin( Paddr
, RIO_PCI_MEM_SIZE
, &Caddr
);
946 rio_dprintk (RIO_DEBUG_INIT
, "Couldn't map %d bytes at 0x%x\n", RIO_PCI_MEM_SIZE
, (int)Paddr
);
950 p
->RIOHosts
[p
->RIONumHosts
].Ivec
= Ivec
+ 32;
951 p
->intr_tid
= iointset(p
->RIOHosts
[p
->RIONumHosts
].Ivec
,
952 (int (*)())rio_intr
, (char *)p
->RIONumHosts
);
953 if (RIOBoardTest( Paddr
, Caddr
, RIO_PCI
, 0 ) == RIO_SUCCESS
) {
954 rio_dprintk (RIO_DEBUG_INIT
, ("Board has passed test\n");
955 rio_dprintk (RIO_DEBUG_INIT
, ("Paddr 0x%x. Caddr 0x%x. Mode 0x%x.\n", Paddr
, Caddr
, Mode
);
958 ** Board has passed its scrub test. Fill in all the
961 p
->RIOHosts
[p
->RIONumHosts
].Slot
= 0;
962 p
->RIOHosts
[p
->RIONumHosts
].Ivec
= Ivec
+ 32;
963 p
->RIOHosts
[p
->RIONumHosts
].Type
= RIO_PCI
;
964 p
->RIOHosts
[p
->RIONumHosts
].Copy
= rio_pcicopy
;
965 p
->RIOHosts
[p
->RIONumHosts
].PaddrP
= Paddr
;
966 p
->RIOHosts
[p
->RIONumHosts
].Caddr
= Caddr
;
967 p
->RIOHosts
[p
->RIONumHosts
].CardP
= (struct DpRam
*)Caddr
;
968 p
->RIOHosts
[p
->RIONumHosts
].Mode
= Mode
;
971 WBYTE(p
->RIOHosts
[p
->RIONumHosts
].Control
,
972 BOOT_FROM_RAM
| EXTERNAL_BUS_OFF
|
973 p
->RIOHosts
[p
->RIONumHosts
].Mode
|
975 WBYTE(p
->RIOHosts
[p
->RIONumHosts
].ResetInt
,0xff);
976 WBYTE(p
->RIOHosts
[p
->RIONumHosts
].Control
,
977 BOOT_FROM_RAM
| EXTERNAL_BUS_OFF
|
978 p
->RIOHosts
[p
->RIONumHosts
].Mode
|
980 WBYTE(p
->RIOHosts
[p
->RIONumHosts
].ResetInt
,0xff);
982 WBYTE(p
->RIOHosts
[p
->RIONumHosts
].ResetInt
, 0xff);
984 p
->RIOHosts
[p
->RIONumHosts
].UniqueNum
=
985 ((RBYTE(p
->RIOHosts
[p
->RIONumHosts
].Unique
[0])&0xFF)<<0)|
986 ((RBYTE(p
->RIOHosts
[p
->RIONumHosts
].Unique
[1])&0xFF)<<8)|
987 ((RBYTE(p
->RIOHosts
[p
->RIONumHosts
].Unique
[2])&0xFF)<<16)|
988 ((RBYTE(p
->RIOHosts
[p
->RIONumHosts
].Unique
[3])&0xFF)<<24);
990 rio_dprintk (RIO_DEBUG_INIT
, "Unique no 0x%x.\n",
991 p
->RIOHosts
[p
->RIONumHosts
].UniqueNum
);
993 p
->RIOLastPCISearch
= RIO_SUCCESS
;
1000 if ( slot
>= MAX_PCI_SLOT
) {
1001 rio_dprintk (RIO_DEBUG_INIT
, "All %d PCI slots have tested for RIO cards !!!\n",
1007 ** I don't think we want to do this anymore
1010 if (!p->RIOLastPCISearch == RIO_FAIL ) {
1018 #ifdef FUTURE_RELEASE
1019 void riohalt( void )
1022 for ( host
=0; host
<p
->RIONumHosts
; host
++ )
1024 rio_dprintk (RIO_DEBUG_INIT
, "Stop host %d\n", host
);
1025 (void)RIOBoardTest( p
->RIOHosts
[host
].PaddrP
, p
->RIOHosts
[host
].Caddr
, p
->RIOHosts
[host
].Type
,p
->RIOHosts
[host
].Slot
);
1031 static uchar val
[] = {
1032 #ifdef VERY_LONG_TEST
1033 0x00, 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80,
1034 0xa5, 0xff, 0x5a, 0x00, 0xff, 0xc9, 0x36,
1038 #define TEST_END sizeof(val)
1041 ** RAM test a board.
1042 ** Nothing too complicated, just enough to check it out.
1045 RIOBoardTest(paddr
, caddr
, type
, slot
)
1051 struct DpRam
*DpRam
= (struct DpRam
*)caddr
;
1057 rio_dprintk (RIO_DEBUG_INIT
, "RIO-init: Reset host type=%d, DpRam=0x%x, slot=%d\n",
1058 type
,(int)DpRam
, slot
);
1060 RIOHostReset(type
, DpRam
, slot
);
1063 ** Scrub the memory. This comes in several banks:
1064 ** DPsram1 - 7000h bytes
1065 ** DPsram2 - 200h bytes
1066 ** DPsram3 - 7000h bytes
1067 ** scratch - 1000h bytes
1070 rio_dprintk (RIO_DEBUG_INIT
, "RIO-init: Setup ram/size arrays\n");
1072 size
[0] = DP_SRAM1_SIZE
;
1073 size
[1] = DP_SRAM2_SIZE
;
1074 size
[2] = DP_SRAM3_SIZE
;
1075 size
[3] = DP_SCRATCH_SIZE
;
1077 ram
[0] = (char *)&DpRam
->DpSram1
[0];
1078 ram
[1] = (char *)&DpRam
->DpSram2
[0];
1079 ram
[2] = (char *)&DpRam
->DpSram3
[0];
1080 nbanks
= (type
== RIO_PCI
) ? 3 : 4;
1082 ram
[3] = (char *)&DpRam
->DpScratch
[0];
1086 rio_dprintk (RIO_DEBUG_INIT
, "RIO-init: Memory: 0x%x(0x%x), 0x%x(0x%x), 0x%x(0x%x)\n",
1087 (int)ram
[0], size
[0], (int)ram
[1], size
[1], (int)ram
[2], size
[2]);
1089 rio_dprintk (RIO_DEBUG_INIT
, "RIO-init: 0x%x(0x%x), 0x%x(0x%x), 0x%x(0x%x), 0x%x(0x%x)\n",
1090 (int)ram
[0], size
[0], (int)ram
[1], size
[1], (int)ram
[2], size
[2], (int)ram
[3],
1095 ** This scrub operation will test for crosstalk between
1096 ** banks. TEST_END is a magic number, and relates to the offset
1097 ** within the 'val' array used by Scrub.
1099 for (op
=0; op
<TEST_END
; op
++) {
1100 for (bank
=0; bank
<nbanks
; bank
++) {
1101 if (RIOScrub(op
, (BYTE
*)ram
[bank
], size
[bank
]) == RIO_FAIL
) {
1102 rio_dprintk (RIO_DEBUG_INIT
, "RIO-init: RIOScrub band %d, op %d failed\n",
1109 rio_dprintk (RIO_DEBUG_INIT
, "Test completed\n");
1115 ** Scrub an area of RAM.
1116 ** Define PRETEST and POSTTEST for a more thorough checking of the
1117 ** state of the memory.
1118 ** Call with op set to an index into the above 'val' array to determine
1119 ** which value will be written into memory.
1120 ** Call with op set to zero means that the RAM will not be read and checked
1121 ** before it is written.
1122 ** Call with op not zero, and the RAM will be read and compated with val[op-1]
1123 ** to check that the data from the previous phase was retained.
1126 RIOScrub(op
, ram
, size
)
1132 unsigned char oldbyte
;
1133 unsigned char newbyte
;
1134 unsigned char invbyte
;
1135 unsigned short oldword
;
1136 unsigned short newword
;
1137 unsigned short invword
;
1138 unsigned short swapword
;
1141 oldbyte
= val
[op
-1];
1142 oldword
= oldbyte
| (oldbyte
<<8);
1144 oldbyte
= oldword
= 0; /* Tell the compiler we've initilalized them. */
1146 newword
= newbyte
| (newbyte
<<8);
1148 invword
= invbyte
| (invbyte
<<8);
1151 ** Check that the RAM contains the value that should have been left there
1152 ** by the previous test (not applicable for pass zero)
1155 for (off
=0; off
<size
; off
++) {
1156 if (RBYTE(ram
[off
]) != oldbyte
) {
1157 rio_dprintk (RIO_DEBUG_INIT
, "RIO-init: Byte Pre Check 1: BYTE at offset 0x%x should have been=%x, was=%x\n", off
, oldbyte
, RBYTE(ram
[off
]));
1161 for (off
=0; off
<size
; off
+=2) {
1162 if (*(ushort
*)&ram
[off
] != oldword
) {
1163 rio_dprintk (RIO_DEBUG_INIT
, "RIO-init: Word Pre Check: WORD at offset 0x%x should have been=%x, was=%x\n",off
,oldword
,*(ushort
*)&ram
[off
]);
1164 rio_dprintk (RIO_DEBUG_INIT
, "RIO-init: Word Pre Check: BYTE at offset 0x%x is %x BYTE at offset 0x%x is %x\n", off
, RBYTE(ram
[off
]), off
+1, RBYTE(ram
[off
+1]));
1171 ** Now write the INVERSE of the test data into every location, using
1172 ** BYTE write operations, first checking before each byte is written
1173 ** that the location contains the old value still, and checking after
1174 ** the write that the location contains the data specified - this is
1175 ** the BYTE read/write test.
1177 for (off
=0; off
<size
; off
++) {
1178 if (op
&& (RBYTE(ram
[off
]) != oldbyte
)) {
1179 rio_dprintk (RIO_DEBUG_INIT
, "RIO-init: Byte Pre Check 2: BYTE at offset 0x%x should have been=%x, was=%x\n", off
, oldbyte
, RBYTE(ram
[off
]));
1182 WBYTE(ram
[off
],invbyte
);
1183 if (RBYTE(ram
[off
]) != invbyte
) {
1184 rio_dprintk (RIO_DEBUG_INIT
, "RIO-init: Byte Inv Check: BYTE at offset 0x%x should have been=%x, was=%x\n", off
, invbyte
, RBYTE(ram
[off
]));
1190 ** now, use WORD operations to write the test value into every location,
1191 ** check as before that the location contains the previous test value
1192 ** before overwriting, and that it contains the data value written
1194 ** This is the WORD operation test.
1196 for (off
=0; off
<size
; off
+=2) {
1197 if (*(ushort
*)&ram
[off
] != invword
) {
1198 rio_dprintk (RIO_DEBUG_INIT
, "RIO-init: Word Inv Check: WORD at offset 0x%x should have been=%x, was=%x\n", off
, invword
, *(ushort
*)&ram
[off
]);
1199 rio_dprintk (RIO_DEBUG_INIT
, "RIO-init: Word Inv Check: BYTE at offset 0x%x is %x BYTE at offset 0x%x is %x\n", off
, RBYTE(ram
[off
]), off
+1, RBYTE(ram
[off
+1]));
1203 *(ushort
*)&ram
[off
] = newword
;
1204 if ( *(ushort
*)&ram
[off
] != newword
) {
1205 rio_dprintk (RIO_DEBUG_INIT
, "RIO-init: Post Word Check 1: WORD at offset 0x%x should have been=%x, was=%x\n", off
, newword
, *(ushort
*)&ram
[off
]);
1206 rio_dprintk (RIO_DEBUG_INIT
, "RIO-init: Post Word Check 1: BYTE at offset 0x%x is %x BYTE at offset 0x%x is %x\n", off
, RBYTE(ram
[off
]), off
+1, RBYTE(ram
[off
+1]));
1212 ** now run through the block of memory again, first in byte mode
1213 ** then in word mode, and check that all the locations contain the
1214 ** required test data.
1216 for (off
=0; off
<size
; off
++) {
1217 if (RBYTE(ram
[off
]) != newbyte
) {
1218 rio_dprintk (RIO_DEBUG_INIT
, "RIO-init: Post Byte Check: BYTE at offset 0x%x should have been=%x, was=%x\n", off
, newbyte
, RBYTE(ram
[off
]));
1223 for (off
=0; off
<size
; off
+=2) {
1224 if ( *(ushort
*)&ram
[off
] != newword
) {
1225 rio_dprintk (RIO_DEBUG_INIT
, "RIO-init: Post Word Check 2: WORD at offset 0x%x should have been=%x, was=%x\n", off
, newword
, *(ushort
*)&ram
[off
]);
1226 rio_dprintk (RIO_DEBUG_INIT
, "RIO-init: Post Word Check 2: BYTE at offset 0x%x is %x BYTE at offset 0x%x is %x\n", off
, RBYTE(ram
[off
]), off
+1, RBYTE(ram
[off
+1]));
1232 ** time to check out byte swapping errors
1234 swapword
= invbyte
| (newbyte
<< 8);
1236 for (off
=0; off
<size
; off
+=2) {
1237 WBYTE(ram
[off
],invbyte
);
1238 WBYTE(ram
[off
+1],newbyte
);
1241 for ( off
=0; off
<size
; off
+=2 ) {
1242 if (*(ushort
*)&ram
[off
] != swapword
) {
1243 rio_dprintk (RIO_DEBUG_INIT
, "RIO-init: SwapWord Check 1: WORD at offset 0x%x should have been=%x, was=%x\n", off
, swapword
, *((ushort
*)&ram
[off
]));
1244 rio_dprintk (RIO_DEBUG_INIT
, "RIO-init: SwapWord Check 1: BYTE at offset 0x%x is %x BYTE at offset 0x%x is %x\n", off
, RBYTE(ram
[off
]), off
+1, RBYTE(ram
[off
+1]));
1247 *((ushort
*)&ram
[off
]) = ~swapword
;
1250 for (off
=0; off
<size
; off
+=2) {
1251 if (RBYTE(ram
[off
]) != newbyte
) {
1252 rio_dprintk (RIO_DEBUG_INIT
, "RIO-init: SwapWord Check 2: BYTE at offset 0x%x should have been=%x, was=%x\n", off
, newbyte
, RBYTE(ram
[off
]));
1255 if (RBYTE(ram
[off
+1]) != invbyte
) {
1256 rio_dprintk (RIO_DEBUG_INIT
, "RIO-init: SwapWord Check 2: BYTE at offset 0x%x should have been=%x, was=%x\n", off
+1, invbyte
, RBYTE(ram
[off
+1]));
1259 *((ushort
*)&ram
[off
]) = newword
;
1265 ** try to ensure that every host is either in polled mode
1266 ** or is in interrupt mode. Only allow interrupt mode if
1267 ** all hosts can interrupt (why?)
1268 ** and force into polled mode if told to. Patch up the
1269 ** interrupt vector & salute The Queen when you've done.
1273 RIOAllocateInterrupts(p
)
1274 struct rio_info
* p
;
1279 ** Easy case - if we have been told to poll, then we poll.
1281 if (p
->mode
& POLLED_MODE
) {
1282 RIOStopInterrupts(p
, 0, 0);
1287 ** check - if any host has been set to polled mode, then all must be.
1289 for (Host
=0; Host
<p
->RIONumHosts
; Host
++) {
1290 if ( (p
->RIOHosts
[Host
].Type
!= RIO_AT
) &&
1291 (p
->RIOHosts
[Host
].Ivec
== POLLED
) ) {
1292 RIOStopInterrupts(p
, 1, Host
);
1296 for (Host
=0; Host
<p
->RIONumHosts
; Host
++) {
1297 if (p
->RIOHosts
[Host
].Type
== RIO_AT
) {
1298 if ( (p
->RIOHosts
[Host
].Ivec
- 32) == 0) {
1299 RIOStopInterrupts(p
, 2, Host
);
1307 ** something has decided that we can't be doing with these
1308 ** new-fangled interrupt thingies. Set everything up to just
1312 RIOStopInterrupts(p
, Reason
, Host
)
1313 struct rio_info
* p
;
1317 #ifdef FUTURE_RELEASE
1319 case 0: /* forced into polling by rio_polled */
1321 case 1: /* SCU has set 'Host' into polled mode */
1323 case 2: /* there aren't enough interrupt vectors for 'Host' */
1328 for (Host
=0; Host
<p
->RIONumHosts
; Host
++ ) {
1329 struct Host
*HostP
= &p
->RIOHosts
[Host
];
1331 switch (HostP
->Type
) {
1334 ** The AT host has it's interrupts disabled by clearing the
1337 HostP
->Mode
&= ~INTERRUPT_ENABLE
;
1338 HostP
->Ivec
= POLLED
;
1340 #ifdef FUTURE_RELEASE
1343 ** The EISA host has it's interrupts disabled by setting the
1346 HostP
->Ivec
= POLLED
;
1351 ** The PCI host has it's interrupts disabled by clearing the
1352 ** int_enable bit, like a regular host card.
1354 HostP
->Mode
&= ~RIO_PCI_INT_ENABLE
;
1355 HostP
->Ivec
= POLLED
;
1357 #ifdef FUTURE_RELEASE
1360 ** There's always one, isn't there?
1361 ** The MCA host card cannot have it's interrupts disabled.
1371 ** This function is called at init time to setup the data structures.
1374 RIOAllocDataStructs(p
)
1375 struct rio_info
* p
;
1381 p
->RIOPortp
= (struct Port
*)sysbrk(RIO_PORTS
* sizeof(struct Port
));
1383 rio_dprintk (RIO_DEBUG_INIT
, "RIO-init: No memory for port structures\n");
1387 bzero( p
->RIOPortp
, sizeof(struct Port
) * RIO_PORTS
);
1388 rio_dprintk (RIO_DEBUG_INIT
, "RIO-init: allocated and cleared memory for port structs\n");
1389 rio_dprintk (RIO_DEBUG_INIT
, "First RIO port struct @0x%x, size=0x%x bytes\n",
1390 (int)p
->RIOPortp
, sizeof(struct Port
));
1392 for( port
=0; port
<RIO_PORTS
; port
++ ) {
1393 p
->RIOPortp
[port
].PortNum
= port
;
1394 p
->RIOPortp
[port
].TtyP
= &p
->channel
[port
];
1395 sreset (p
->RIOPortp
[port
].InUse
); /* Let the first guy uses it */
1396 p
->RIOPortp
[port
].portSem
= -1; /* Let the first guy takes it */
1397 p
->RIOPortp
[port
].ParamSem
= -1; /* Let the first guy takes it */
1398 p
->RIOPortp
[port
].timeout_id
= 0; /* Let the first guy takes it */
1401 p
->RIOHosts
= (struct Host
*)sysbrk(RIO_HOSTS
* sizeof(struct Host
));
1403 rio_dprintk (RIO_DEBUG_INIT
, "RIO-init: No memory for host structures\n");
1407 bzero(p
->RIOHosts
, sizeof(struct Host
)*RIO_HOSTS
);
1408 rio_dprintk (RIO_DEBUG_INIT
, "RIO-init: allocated and cleared memory for host structs\n");
1409 rio_dprintk (RIO_DEBUG_INIT
, "First RIO host struct @0x%x, size=0x%x bytes\n",
1410 (int)p
->RIOHosts
, sizeof(struct Host
));
1412 for( host
=0; host
<RIO_HOSTS
; host
++ ) {
1413 spin_lock_init (&p
->RIOHosts
[host
].HostLock
);
1414 p
->RIOHosts
[host
].timeout_id
= 0; /* Let the first guy takes it */
1417 ** check that the buffer size is valid, round down to the next power of
1418 ** two if necessary; if the result is zero, then, hey, no double buffers.
1420 for ( tm
= 1; tm
&& tm
<= p
->RIOConf
.BufferSize
; tm
<<= 1 )
1423 p
->RIOBufferSize
= tm
;
1424 p
->RIOBufferMask
= tm
? tm
- 1 : 0;
1428 ** this function gets called whenever the data structures need to be
1429 ** re-setup, for example, after a riohalt (why did I ever invent it?)
1432 RIOSetupDataStructs(p
)
1433 struct rio_info
* p
;
1435 int host
, entry
, rup
;
1437 for ( host
=0; host
<RIO_HOSTS
; host
++ ) {
1438 struct Host
*HostP
= &p
->RIOHosts
[host
];
1439 for ( entry
=0; entry
<LINKS_PER_UNIT
; entry
++ ) {
1440 HostP
->Topology
[entry
].Unit
= ROUTE_DISCONNECT
;
1441 HostP
->Topology
[entry
].Link
= NO_LINK
;
1443 bcopy("HOST X", HostP
->Name
, 7);
1444 HostP
->Name
[5] = '1'+host
;
1445 for (rup
=0; rup
<(MAX_RUP
+ LINKS_PER_UNIT
); rup
++) {
1446 if (rup
< MAX_RUP
) {
1447 for (entry
=0; entry
<LINKS_PER_UNIT
; entry
++ ) {
1448 HostP
->Mapping
[rup
].Topology
[entry
].Unit
= ROUTE_DISCONNECT
;
1449 HostP
->Mapping
[rup
].Topology
[entry
].Link
= NO_LINK
;
1451 RIODefaultName(p
, HostP
, rup
);
1453 spin_lock_init(&HostP
->UnixRups
[rup
].RupLock
);
1460 RIODefaultName(p
, HostP
, UnitId
)
1461 struct rio_info
* p
;
1462 struct Host
* HostP
;
1467 CheckUnitId( UnitId
);
1469 bcopy("UNKNOWN RTA X-XX",HostP
->Mapping
[UnitId
].Name
,17);
1470 HostP
->Mapping
[UnitId
].Name
[12]='1'+(HostP
-p
->RIOHosts
);
1471 if ((UnitId
+1) > 9) {
1472 HostP
->Mapping
[UnitId
].Name
[14]='0'+((UnitId
+1)/10);
1473 HostP
->Mapping
[UnitId
].Name
[15]='0'+((UnitId
+1)%10);
1476 HostP
->Mapping
[UnitId
].Name
[14]='1'+UnitId
;
1477 HostP
->Mapping
[UnitId
].Name
[15]=0;
1482 #define RIO_RELEASE "Linux"
1483 #define RELEASE_ID "1.0"
1488 struct rio_info
* p
;
1490 char * RIORelease
= RIO_RELEASE
;
1491 char * RIORelID
= RELEASE_ID
;
1494 rio_dprintk (RIO_DEBUG_INIT
, "RIO : Release: %s ID: %s\n", RIORelease
, RIORelID
);
1496 if ( p
->RIONumHosts
==0 ) {
1497 rio_dprintk (RIO_DEBUG_INIT
, "\nNo Hosts configured\n");
1501 for ( host
=0; host
< p
->RIONumHosts
; host
++ ) {
1502 struct Host
*HostP
= &p
->RIOHosts
[host
];
1503 switch ( HostP
->Type
) {
1505 rio_dprintk (RIO_DEBUG_INIT
, "AT BUS : found the card at 0x%x\n", HostP
->PaddrP
);
1512 static struct rioVersion stVersion
;
1517 strlcpy(stVersion
.version
, "RIO driver for linux V1.0",
1518 sizeof(stVersion
.version
));
1519 strlcpy(stVersion
.buildDate
, __DATE__
,
1520 sizeof(stVersion
.buildDate
));
1527 RIOMapin(paddr
, size
, vaddr
)
1532 *vaddr
= (caddr_t
)permap( (long)paddr
, size
);
1533 return ((int)*vaddr
);
1537 RIOMapout(paddr
, size
, vaddr
)
1547 RIOHostReset(Type
, DpRamP
, Slot
)
1549 volatile struct DpRam
*DpRamP
;
1555 rio_dprintk (RIO_DEBUG_INIT
, "RIOHostReset: type 0x%x", Type
);
1558 rio_dprintk (RIO_DEBUG_INIT
, " (RIO_AT)\n");
1559 WBYTE(DpRamP
->DpControl
, BOOT_FROM_RAM
| EXTERNAL_BUS_OFF
|
1560 INTERRUPT_DISABLE
| BYTE_OPERATION
|
1561 SLOW_LINKS
| SLOW_AT_BUS
);
1562 WBYTE(DpRamP
->DpResetTpu
, 0xFF);
1565 rio_dprintk (RIO_DEBUG_INIT
, "RIOHostReset: Don't know if it worked. Try reset again\n");
1566 WBYTE(DpRamP
->DpControl
, BOOT_FROM_RAM
| EXTERNAL_BUS_OFF
|
1567 INTERRUPT_DISABLE
| BYTE_OPERATION
|
1568 SLOW_LINKS
| SLOW_AT_BUS
);
1569 WBYTE(DpRamP
->DpResetTpu
, 0xFF);
1572 #ifdef FUTURE_RELEASE
1575 ** Bet this doesn't work!
1577 OUTBZ( Slot
, EISA_CONTROL_PORT
,
1578 EISA_TP_RUN
| EISA_TP_BUS_DISABLE
|
1579 EISA_TP_SLOW_LINKS
| EISA_TP_BOOT_FROM_RAM
);
1580 OUTBZ( Slot
, EISA_CONTROL_PORT
,
1581 EISA_TP_RESET
| EISA_TP_BUS_DISABLE
|
1582 EISA_TP_SLOW_LINKS
| EISA_TP_BOOT_FROM_RAM
);
1584 OUTBZ( Slot
, EISA_CONTROL_PORT
,
1585 EISA_TP_RUN
| EISA_TP_BUS_DISABLE
|
1586 EISA_TP_SLOW_LINKS
| EISA_TP_BOOT_FROM_RAM
);
1589 WBYTE(DpRamP
->DpControl
, McaTpBootFromRam
| McaTpBusDisable
);
1590 WBYTE(DpRamP
->DpResetTpu
, 0xFF );
1592 WBYTE(DpRamP
->DpControl
, McaTpBootFromRam
| McaTpBusDisable
);
1593 WBYTE(DpRamP
->DpResetTpu
, 0xFF );
1598 rio_dprintk (RIO_DEBUG_INIT
, " (RIO_PCI)\n");
1599 DpRamP
->DpControl
= RIO_PCI_BOOT_FROM_RAM
;
1600 DpRamP
->DpResetInt
= 0xFF;
1601 DpRamP
->DpResetTpu
= 0xFF;
1603 /* for (i=0; i<6000; i++); */
1606 #ifdef FUTURE_RELEASE
1608 Rprintf(RIOMesgNoSupport
,Type
,DpRamP
,Slot
);
1613 rio_dprintk (RIO_DEBUG_INIT
, " (UNKNOWN)\n");