···87878888int RIOPCIinit(struct rio_info *p, int Mode);89899090-#if 09191-static void RIOAllocateInterrupts(struct rio_info *);9292-static int RIOReport(struct rio_info *);9393-static void RIOStopInterrupts(struct rio_info *, int, int);9494-#endif9595-9690static int RIOScrub(int, BYTE *, int);97919898-#if 09999-extern int rio_intr();100100-101101-/*102102-** Init time code.103103-*/104104-void105105-rioinit( p, info )106106-struct rio_info * p;107107-struct RioHostInfo * info;108108-{109109- /*110110- ** Multi-Host card support - taking the easy way out - sorry !111111- ** We allocate and set up the Host and Port structs when the112112- ** driver is called to 'install' the first host.113113- ** We check for this first 'call' by testing the RIOPortp pointer.114114- */115115- if ( !p->RIOPortp )116116- {117117- rio_dprintk (RIO_DEBUG_INIT, "Allocating and setting up driver data structures\n");118118-119119- RIOAllocDataStructs(p); /* allocate host/port structs */120120- RIOSetupDataStructs(p); /* setup topology structs */121121- }122122-123123- RIOInitHosts( p, info ); /* hunt down the hardware */124124-125125- RIOAllocateInterrupts(p); /* allocate interrupts */126126- RIOReport(p); /* show what we found */127127-}128128-129129-/*130130-** Initialise the Cards 131131-*/ 132132-void133133-RIOInitHosts(p, info)134134-struct rio_info * p;135135-struct RioHostInfo * info;136136-{137137-/*138138-** 15.10.1998 ARG - ESIL 0762 part fix139139-** If there is no ISA card definition - we always look for PCI cards.140140-** As we currently only support one host card this lets an ISA card141141-** definition take precedence over PLUG and PLAY.142142-** No ISA card - we are PLUG and PLAY with PCI.143143-*/144144-145145- /*146146- ** Note - for PCI both these will be zero, that's okay because147147- ** RIOPCIInit() fills them in if a card is found.148148- */149149- p->RIOHosts[p->RIONumHosts].Ivec = info->vector;150150- p->RIOHosts[p->RIONumHosts].PaddrP = info->location;151151-152152- /*153153- ** Check that we are able to accommodate another host154154- */155155- if ( p->RIONumHosts >= RIO_HOSTS )156156- {157157- p->RIOFailed++;158158- return;159159- }160160-161161- if ( info->bus & ISA_BUS )162162- {163163- rio_dprintk (RIO_DEBUG_INIT, "initialising card %d (ISA)\n", p->RIONumHosts);164164- RIOISAinit(p, p->mode);165165- }166166- else167167- {168168- rio_dprintk (RIO_DEBUG_INIT, "initialising card %d (PCI)\n", p->RIONumHosts);169169- RIOPCIinit(p, RIO_PCI_DEFAULT_MODE);170170- }171171-172172- rio_dprintk (RIO_DEBUG_INIT, "Total hosts initialised so far : %d\n", p->RIONumHosts);173173-174174-175175-#ifdef FUTURE_RELEASE176176- if (p->bus & EISA_BUS)177177- /* EISA card */178178- RIOEISAinit(p, RIO_EISA_DEFAULT_MODE);179179-180180- if (p->bus & MCA_BUS)181181- /* MCA card */182182- RIOMCAinit(p, RIO_MCA_DEFAULT_MODE);183183-#endif184184-}185185-186186-/*187187-** go through memory for an AT host that we pass in the device info188188-** structure and initialise189189-*/190190-void191191-RIOISAinit(p, mode)192192-struct rio_info * p;193193-int mode;194194-{195195-196196- /* XXX Need to implement this. */197197-#if 0198198- p->intr_tid = iointset(p->RIOHosts[p->RIONumHosts].Ivec,199199- (int (*)())rio_intr, (char*)p->RIONumHosts);200200-201201- rio_dprintk (RIO_DEBUG_INIT, "Set interrupt handler, intr_tid = 0x%x\n", p->intr_tid );202202-203203- if (RIODoAT(p, p->RIOHosts[p->RIONumHosts].PaddrP, mode)) {204204- return;205205- }206206- else {207207- rio_dprintk (RIO_DEBUG_INIT, "RIODoAT failed\n");208208- p->RIOFailed++;209209- }210210-#endif211211-212212-}213213-214214-/*215215-** RIODoAT :216216-**217217-** Map in a boards physical address, check that the board is there,218218-** test the board and if everything is okay assign the board an entry219219-** in the Rio Hosts structure.220220-*/221221-int222222-RIODoAT(p, Base, mode)223223-struct rio_info * p;224224-int Base;225225-int mode;226226-{227227-#define FOUND 1228228-#define NOT_FOUND 0229229-230230- caddr_t cardAddr;231231-232232- /*233233- ** Check to see if we actually have a board at this physical address.234234- */235235- if ((cardAddr = RIOCheckForATCard(Base)) != 0) {236236- /*237237- ** Now test the board to see if it is working.238238- */239239- if (RIOBoardTest(Base, cardAddr, RIO_AT, 0) == RIO_SUCCESS) {240240- /*241241- ** Fill out a slot in the Rio host structure.242242- */243243- if (RIOAssignAT(p, Base, cardAddr, mode)) {244244- return(FOUND);245245- }246246- }247247- RIOMapout(Base, RIO_AT_MEM_SIZE, cardAddr);248248- }249249- return(NOT_FOUND);250250-}251251-252252-caddr_t253253-RIOCheckForATCard(Base)254254-int Base;255255-{256256- int off;257257- struct DpRam *cardp; /* (Points at the host) */258258- caddr_t virtAddr;259259- unsigned char RIOSigTab[24];260260-/*261261-** Table of values to search for as prom signature of a host card262262-*/263263- strcpy(RIOSigTab, "JBJGPGGHINSMJPJR");264264-265265- /*266266- ** Hey! Yes, You reading this code! Yo, grab a load a this:267267- **268268- ** IF the card is using WORD MODE rather than BYTE MODE269269- ** then it will occupy 128K of PHYSICAL memory area. So,270270- ** you might think that the following Mapin is wrong. Well,271271- ** it isn't, because the SECOND 64K of occupied space is an272272- ** EXACT COPY of the FIRST 64K. (good?), so, we need only273273- ** map it in in one 64K block.274274- */275275- if (RIOMapin(Base, RIO_AT_MEM_SIZE, &virtAddr) == -1) {276276- rio_dprintk (RIO_DEBUG_INIT, "RIO-init: Couldn't map the board in!\n");277277- return((caddr_t)0);278278- }279279-280280- /*281281- ** virtAddr points to the DP ram of the system.282282- ** We now cast this to a pointer to a RIO Host,283283- ** and have a rummage about in the PROM.284284- */285285- cardp = (struct DpRam *)virtAddr;286286-287287- for (off=0; RIOSigTab[off]; off++) {288288- if ((RBYTE(cardp->DpSignature[off]) & 0xFF) != RIOSigTab[off]) {289289- /*290290- ** Signature mismatch - card not at this address291291- */292292- RIOMapout(Base, RIO_AT_MEM_SIZE, virtAddr);293293- rio_dprintk (RIO_DEBUG_INIT, "RIO-init: Couldn't match the signature 0x%x 0x%x!\n",294294- (int)cardp, off);295295- return((caddr_t)0);296296- }297297- }298298-299299- /*300300- ** If we get here then we must have found a valid board so return301301- ** its virtual address.302302- */303303- return(virtAddr);304304-}305305-#endif3069230793/**30894** RIOAssignAT :···153367 rio_dprintk (RIO_DEBUG_INIT, "RIO-init: Tests Passed at 0x%x\n", Base);154368 return(1);155369}156156-#if 0157157-#ifdef FUTURE_RELEASE158158-int RIOMCAinit(int Mode)159159-{160160- uchar SlotNumber;161161- caddr_t Caddr;162162- uint Paddr;163163- uint Ivec;164164- int Handle;165165- int ret = 0;166166-167167- /*168168- ** Valid mode information for MCA cards169169- ** is only FAST LINKS170170- */171171- Mode = (Mode & FAST_LINKS) ? McaTpFastLinks : McaTpSlowLinks;172172- rio_dprintk (RIO_DEBUG_INIT, "RIOMCAinit(%d)\n",Mode);173173-174174-175175- /*176176- ** Check out each of the slots177177- */178178- for (SlotNumber = 0; SlotNumber < McaMaxSlots; SlotNumber++) {179179- /*180180- ** Enable the slot we want to talk to181181- */182182- outb( McaSlotSelect, SlotNumber | McaSlotEnable );183183-184184- /*185185- ** Read the ID word from the slot186186- */187187- if (((inb(McaIdHigh)<< 8)|inb(McaIdLow)) == McaRIOId)188188- {189189- rio_dprintk (RIO_DEBUG_INIT, "Potential MCA card in slot %d\n", SlotNumber);190190-191191- /*192192- ** Card appears to be a RIO MCA card!193193- */194194- RIOMachineType |= (1<<RIO_MCA);195195-196196- /*197197- ** Just check we haven't found too many wonderful objects198198- */199199- if ( RIONumHosts >= RIO_HOSTS )200200- {201201- Rprintf(RIOMesgTooManyCards);202202- return(ret);203203- }204204-205205- /*206206- ** McaIrqEnable contains the interrupt vector, and a card207207- ** enable bit.208208- */209209- Ivec = inb(McaIrqEnable);210210-211211- rio_dprintk (RIO_DEBUG_INIT, "Ivec is %x\n", Ivec);212212-213213- switch ( Ivec & McaIrqMask )214214- {215215- case McaIrq9:216216- rio_dprintk (RIO_DEBUG_INIT, "IRQ9\n");217217- break;218218- case McaIrq3:219219- rio_dprintk (RIO_DEBUG_INIT, "IRQ3\n");220220- break;221221- case McaIrq4:222222- rio_dprintk (RIO_DEBUG_INIT, "IRQ4\n");223223- break;224224- case McaIrq7:225225- rio_dprintk (RIO_DEBUG_INIT, "IRQ7\n");226226- break;227227- case McaIrq10:228228- rio_dprintk (RIO_DEBUG_INIT, "IRQ10\n");229229- break;230230- case McaIrq11:231231- rio_dprintk (RIO_DEBUG_INIT, "IRQ11\n");232232- break;233233- case McaIrq12:234234- rio_dprintk (RIO_DEBUG_INIT, "IRQ12\n");235235- break;236236- case McaIrq15:237237- rio_dprintk (RIO_DEBUG_INIT, "IRQ15\n");238238- break;239239- }240240-241241- /*242242- ** If the card enable bit isn't set, then set it!243243- */244244- if ((Ivec & McaCardEnable) != McaCardEnable) {245245- rio_dprintk (RIO_DEBUG_INIT, "McaCardEnable not set - setting!\n");246246- outb(McaIrqEnable,Ivec|McaCardEnable);247247- } else248248- rio_dprintk (RIO_DEBUG_INIT, "McaCardEnable already set\n");249249-250250- /*251251- ** Convert the IRQ enable mask into something useful252252- */253253- Ivec = RIOMcaToIvec[Ivec & McaIrqMask];254254-255255- /*256256- ** Find the physical address257257- */258258- rio_dprintk (RIO_DEBUG_INIT, "inb(McaMemory) is %x\n", inb(McaMemory));259259- Paddr = McaAddress(inb(McaMemory));260260-261261- rio_dprintk (RIO_DEBUG_INIT, "MCA card has Ivec %d Addr %x\n", Ivec, Paddr);262262-263263- if ( Paddr != 0 )264264- {265265-266266- /*267267- ** Tell the memory mapper that we want to talk to it268268- */269269- Handle = RIOMapin( Paddr, RIO_MCA_MEM_SIZE, &Caddr );270270-271271- if ( Handle == -1 ) {272272- rio_dprintk (RIO_DEBUG_INIT, "Couldn't map %d bytes at %x\n", RIO_MCA_MEM_SIZE, Paddr;273273- continue;274274- }275275-276276- rio_dprintk (RIO_DEBUG_INIT, "Board mapped to vaddr 0x%x\n", Caddr);277277-278278- /*279279- ** And check that it is actually there!280280- */281281- if ( RIOBoardTest( Paddr,Caddr,RIO_MCA,SlotNumber ) == RIO_SUCCESS )282282- {283283- rio_dprintk (RIO_DEBUG_INIT, "Board has passed test\n");284284- rio_dprintk (RIO_DEBUG_INIT, "Slot %d. Type %d. Paddr 0x%x. Caddr 0x%x. Mode 0x%x.\n",285285- SlotNumber, RIO_MCA, Paddr, Caddr, Mode);286286-287287- /*288288- ** Board has passed its scrub test. Fill in all the289289- ** transient stuff.290290- */291291- p->RIOHosts[RIONumHosts].Slot = SlotNumber;292292- p->RIOHosts[RIONumHosts].Ivec = Ivec;293293- p->RIOHosts[RIONumHosts].Type = RIO_MCA;294294- p->RIOHosts[RIONumHosts].Copy = bcopy;295295- p->RIOHosts[RIONumHosts].PaddrP = Paddr;296296- p->RIOHosts[RIONumHosts].Caddr = Caddr;297297- p->RIOHosts[RIONumHosts].CardP = (struct DpRam *)Caddr;298298- p->RIOHosts[RIONumHosts].Mode = Mode;299299- WBYTE(p->RIOHosts[p->RIONumHosts].ResetInt , 0xff);300300- p->RIOHosts[RIONumHosts].UniqueNum =301301- ((RBYTE(p->RIOHosts[RIONumHosts].Unique[0])&0xFF)<<0)|302302- ((RBYTE(p->RIOHosts[RIONumHosts].Unique[1])&0xFF)<<8)|303303- ((RBYTE(p->RIOHosts[RIONumHosts].Unique[2])&0xFF)<<16)|304304- ((RBYTE(p->RIOHosts[RIONumHosts].Unique[3])&0xFF)<<24);305305- RIONumHosts++;306306- ret++;307307- }308308- else309309- {310310- /*311311- ** It failed the test, so ignore it.312312- */313313- rio_dprintk (RIO_DEBUG_INIT, "TEST FAILED\n");314314- RIOMapout(Paddr, RIO_MCA_MEM_SIZE, Caddr );315315- }316316- }317317- else318318- {319319- rio_dprintk (RIO_DEBUG_INIT, "Slot %d - Paddr zero!\n", SlotNumber);320320- }321321- }322322- else323323- {324324- rio_dprintk (RIO_DEBUG_INIT, "Slot %d NOT RIO\n", SlotNumber);325325- }326326- }327327- /*328328- ** Now we have checked all the slots, turn off the MCA slot selector329329- */330330- outb(McaSlotSelect,0);331331- rio_dprintk (RIO_DEBUG_INIT, "Slot %d NOT RIO\n", SlotNumber);332332- return ret;333333-}334334-335335-int RIOEISAinit( int Mode )336336-{337337- static int EISADone = 0;338338- uint Paddr;339339- int PollIntMixMsgDone = 0;340340- caddr_t Caddr;341341- ushort Ident;342342- uchar EisaSlot;343343- uchar Ivec;344344- int ret = 0;345345-346346- /*347347- ** The only valid mode information for EISA hosts is fast or slow348348- ** links.349349- */350350- Mode = (Mode & FAST_LINKS) ? EISA_TP_FAST_LINKS : EISA_TP_SLOW_LINKS;351351-352352- if ( EISADone )353353- {354354- rio_dprintk (RIO_DEBUG_INIT, "RIOEISAinit() - already done, return.\n");355355- return(0);356356- }357357-358358- EISADone++;359359-360360- rio_dprintk (RIO_DEBUG_INIT, "RIOEISAinit()\n");361361-362362-363363- /*364364- ** First check all cards to see if ANY are set for polled mode operation.365365- ** If so, set ALL to polled.366366- */367367-368368- for ( EisaSlot=1; EisaSlot<=RIO_MAX_EISA_SLOTS; EisaSlot++ )369369- {370370- Ident = (INBZ(EisaSlot,EISA_PRODUCT_IDENT_HI)<<8) |371371- INBZ(EisaSlot,EISA_PRODUCT_IDENT_LO);372372-373373- if ( Ident == RIO_EISA_IDENT )374374- {375375- rio_dprintk (RIO_DEBUG_INIT, "Found Specialix product\n");376376-377377- if ( INBZ(EisaSlot,EISA_PRODUCT_NUMBER) != RIO_EISA_PRODUCT_CODE )378378- {379379- rio_dprintk (RIO_DEBUG_INIT, "Not Specialix RIO - Product number %x\n",380380- INBZ(EisaSlot, EISA_PRODUCT_NUMBER));381381- continue; /* next slot */382382- }383383- /*384384- ** Its a Specialix RIO!385385- */386386- rio_dprintk (RIO_DEBUG_INIT, "RIO Revision %d\n",387387- INBZ(EisaSlot, EISA_REVISION_NUMBER));388388-389389- RIOMachineType |= (1<<RIO_EISA);390390-391391- /*392392- ** Just check we haven't found too many wonderful objects393393- */394394- if ( RIONumHosts >= RIO_HOSTS )395395- {396396- Rprintf(RIOMesgTooManyCards);397397- return 0;398398- }399399-400400- /*401401- ** Ensure that the enable bit is set!402402- */403403- OUTBZ( EisaSlot, EISA_ENABLE, RIO_EISA_ENABLE_BIT );404404-405405- /*406406- ** EISA_INTERRUPT_VEC contains the interrupt vector.407407- */408408- Ivec = INBZ(EisaSlot,EISA_INTERRUPT_VEC);409409-410410-#ifdef RIODEBUG411411- switch ( Ivec & EISA_INTERRUPT_MASK )412412- {413413- case EISA_IRQ_3:414414- rio_dprintk (RIO_DEBUG_INIT, "EISA IRQ 3\n");415415- break;416416- case EISA_IRQ_4:417417- rio_dprintk (RIO_DEBUG_INIT, "EISA IRQ 4\n");418418- break;419419- case EISA_IRQ_5:420420- rio_dprintk (RIO_DEBUG_INIT, "EISA IRQ 5\n");421421- break;422422- case EISA_IRQ_6:423423- rio_dprintk (RIO_DEBUG_INIT, "EISA IRQ 6\n");424424- break;425425- case EISA_IRQ_7:426426- rio_dprintk (RIO_DEBUG_INIT, "EISA IRQ 7\n");427427- break;428428- case EISA_IRQ_9:429429- rio_dprintk (RIO_DEBUG_INIT, "EISA IRQ 9\n");430430- break;431431- case EISA_IRQ_10:432432- rio_dprintk (RIO_DEBUG_INIT, "EISA IRQ 10\n");433433- break;434434- case EISA_IRQ_11:435435- rio_dprintk (RIO_DEBUG_INIT, "EISA IRQ 11\n");436436- break;437437- case EISA_IRQ_12:438438- rio_dprintk (RIO_DEBUG_INIT, "EISA IRQ 12\n");439439- break;440440- case EISA_IRQ_14:441441- rio_dprintk (RIO_DEBUG_INIT, "EISA IRQ 14\n");442442- break;443443- case EISA_IRQ_15:444444- rio_dprintk (RIO_DEBUG_INIT, "EISA IRQ 15\n");445445- break;446446- case EISA_POLLED:447447- rio_dprintk (RIO_DEBUG_INIT, "EISA POLLED\n");448448- break;449449- default:450450- rio_dprintk (RIO_DEBUG_INIT, NULL,DBG_INIT|DBG_FAIL,"Shagged interrupt number!\n");451451- Ivec &= EISA_CONTROL_MASK;452452- }453453-#endif454454-455455- if ( (Ivec & EISA_INTERRUPT_MASK) ==456456- EISA_POLLED )457457- {458458- RIOWillPoll = 1;459459- break; /* From EisaSlot loop */460460- }461461- }462462- }463463-464464- /*465465- ** Do it all again now we know whether to change all cards to polled466466- ** mode or not467467- */468468-469469- for ( EisaSlot=1; EisaSlot<=RIO_MAX_EISA_SLOTS; EisaSlot++ )470470- {471471- Ident = (INBZ(EisaSlot,EISA_PRODUCT_IDENT_HI)<<8) |472472- INBZ(EisaSlot,EISA_PRODUCT_IDENT_LO);473473-474474- if ( Ident == RIO_EISA_IDENT )475475- {476476- if ( INBZ(EisaSlot,EISA_PRODUCT_NUMBER) != RIO_EISA_PRODUCT_CODE )477477- continue; /* next slot */478478-479479- /*480480- ** Its a Specialix RIO!481481- */482482-483483- /*484484- ** Ensure that the enable bit is set!485485- */486486- OUTBZ( EisaSlot, EISA_ENABLE, RIO_EISA_ENABLE_BIT );487487-488488- /*489489- ** EISA_INTERRUPT_VEC contains the interrupt vector.490490- */491491- Ivec = INBZ(EisaSlot,EISA_INTERRUPT_VEC);492492-493493- if ( RIOWillPoll )494494- {495495- /*496496- ** If we are going to operate in polled mode, but this497497- ** board is configured to be interrupt driven, display498498- ** the message explaining the situation to the punter,499499- ** assuming we haven't already done so.500500- */501501-502502- if ( !PollIntMixMsgDone &&503503- (Ivec & EISA_INTERRUPT_MASK) != EISA_POLLED )504504- {505505- Rprintf(RIOMesgAllPolled);506506- PollIntMixMsgDone = 1;507507- }508508-509509- /*510510- ** Ungraciously ignore whatever the board reports as its511511- ** interrupt vector...512512- */513513-514514- Ivec &= ~EISA_INTERRUPT_MASK;515515-516516- /*517517- ** ...and force it to dance to the poll tune.518518- */519519-520520- Ivec |= EISA_POLLED;521521- }522522-523523- /*524524- ** Convert the IRQ enable mask into something useful (0-15)525525- */526526- Ivec = RIOEisaToIvec(Ivec);527527-528528- rio_dprintk (RIO_DEBUG_INIT, "EISA host in slot %d has Ivec 0x%x\n",529529- EisaSlot, Ivec);530530-531531- /*532532- ** Find the physical address533533- */534534- Paddr = (INBZ(EisaSlot,EISA_MEMORY_BASE_HI)<<24) |535535- (INBZ(EisaSlot,EISA_MEMORY_BASE_LO)<<16);536536-537537- rio_dprintk (RIO_DEBUG_INIT, "EISA card has Ivec %d Addr %x\n", Ivec, Paddr);538538-539539- if ( Paddr == 0 )540540- {541541- rio_dprintk (RIO_DEBUG_INIT,542542- "Board in slot %d configured for address zero!\n", EisaSlot);543543- continue;544544- }545545-546546- /*547547- ** Tell the memory mapper that we want to talk to it548548- */549549- rio_dprintk (RIO_DEBUG_INIT, "About to map EISA card \n");550550-551551- if (RIOMapin( Paddr, RIO_EISA_MEM_SIZE, &Caddr) == -1) {552552- rio_dprintk (RIO_DEBUG_INIT, "Couldn't map %d bytes at %x\n",553553- RIO_EISA_MEM_SIZE,Paddr);554554- continue;555555- }556556-557557- rio_dprintk (RIO_DEBUG_INIT, "Board mapped to vaddr 0x%x\n", Caddr);558558-559559- /*560560- ** And check that it is actually there!561561- */562562- if ( RIOBoardTest( Paddr,Caddr,RIO_EISA,EisaSlot) == RIO_SUCCESS )563563- {564564- rio_dprintk (RIO_DEBUG_INIT, "Board has passed test\n");565565- rio_dprintk (RIO_DEBUG_INIT, 566566- "Slot %d. Ivec %d. Type %d. Paddr 0x%x. Caddr 0x%x. Mode 0x%x.\n",567567- EisaSlot,Ivec,RIO_EISA,Paddr,Caddr,Mode);568568-569569- /*570570- ** Board has passed its scrub test. Fill in all the571571- ** transient stuff.572572- */573573- p->RIOHosts[RIONumHosts].Slot = EisaSlot;574574- p->RIOHosts[RIONumHosts].Ivec = Ivec;575575- p->RIOHosts[RIONumHosts].Type = RIO_EISA;576576- p->RIOHosts[RIONumHosts].Copy = bcopy;577577- p->RIOHosts[RIONumHosts].PaddrP = Paddr;578578- p->RIOHosts[RIONumHosts].Caddr = Caddr;579579- p->RIOHosts[RIONumHosts].CardP = (struct DpRam *)Caddr;580580- p->RIOHosts[RIONumHosts].Mode = Mode;581581- /*582582- ** because the EISA prom is mapped into IO space, we583583- ** need to copy the unqiue number into the memory area584584- ** that it would have occupied, so that the download585585- ** code can determine its ID and card type.586586- */587587- WBYTE(p->RIOHosts[RIONumHosts].Unique[0],INBZ(EisaSlot,EISA_UNIQUE_NUM_0));588588- WBYTE(p->RIOHosts[RIONumHosts].Unique[1],INBZ(EisaSlot,EISA_UNIQUE_NUM_1));589589- WBYTE(p->RIOHosts[RIONumHosts].Unique[2],INBZ(EisaSlot,EISA_UNIQUE_NUM_2));590590- WBYTE(p->RIOHosts[RIONumHosts].Unique[3],INBZ(EisaSlot,EISA_UNIQUE_NUM_3));591591- p->RIOHosts[RIONumHosts].UniqueNum =592592- ((RBYTE(p->RIOHosts[RIONumHosts].Unique[0])&0xFF)<<0)|593593- ((RBYTE(p->RIOHosts[RIONumHosts].Unique[1])&0xFF)<<8)|594594- ((RBYTE(p->RIOHosts[RIONumHosts].Unique[2])&0xFF)<<16)|595595- ((RBYTE(p->RIOHosts[RIONumHosts].Unique[3])&0xFF)<<24);596596- INBZ(EisaSlot,EISA_INTERRUPT_RESET);597597- RIONumHosts++;598598- ret++;599599- }600600- else601601- {602602- /*603603- ** It failed the test, so ignore it.604604- */605605- rio_dprintk (RIO_DEBUG_INIT, "TEST FAILED\n");606606-607607- RIOMapout(Paddr, RIO_EISA_MEM_SIZE, Caddr );608608- }609609- }610610- }611611- if (RIOMachineType & RIO_EISA)612612- return ret+1;613613- return ret;614614-}615615-#endif616616-617617-618618-#ifndef linux619619-620620-#define CONFIG_ADDRESS 0xcf8621621-#define CONFIG_DATA 0xcfc622622-#define FORWARD_REG 0xcfa623623-624624-625625-static int626626-read_config(int bus_number, int device_num, int r_number) 627627-{628628- unsigned int cav;629629- unsigned int val;630630-631631-/*632632- Build config_address_value:633633-634634- 31 24 23 16 15 11 10 8 7 0 635635- ------------------------------------------------------636636- |1| 0000000 | bus_number | device # | 000 | register |637637- ------------------------------------------------------638638-*/639639-640640- cav = r_number & 0xff;641641- cav |= ((device_num & 0x1f) << 11);642642- cav |= ((bus_number & 0xff) << 16);643643- cav |= 0x80000000; /* Enable bit */644644- outpd(CONFIG_ADDRESS,cav);645645- val = inpd(CONFIG_DATA);646646- outpd(CONFIG_ADDRESS,0);647647- return val;648648-}649649-650650-static651651-write_config(bus_number,device_num,r_number,val) 652652-{653653- unsigned int cav;654654-655655-/*656656- Build config_address_value:657657-658658- 31 24 23 16 15 11 10 8 7 0 659659- ------------------------------------------------------660660- |1| 0000000 | bus_number | device # | 000 | register |661661- ------------------------------------------------------662662-*/663663-664664- cav = r_number & 0xff;665665- cav |= ((device_num & 0x1f) << 11);666666- cav |= ((bus_number & 0xff) << 16);667667- cav |= 0x80000000; /* Enable bit */668668- outpd(CONFIG_ADDRESS, cav);669669- outpd(CONFIG_DATA, val);670670- outpd(CONFIG_ADDRESS, 0);671671- return val;672672-}673673-#else674674-/* XXX Implement these... */675675-static int676676-read_config(int bus_number, int device_num, int r_number) 677677-{678678- return 0;679679-}680680-681681-static int682682-write_config(int bus_number, int device_num, int r_number) 683683-{684684- return 0;685685-}686686-687687-#endif688688-689689-int690690-RIOPCIinit(p, Mode)691691-struct rio_info *p;692692-int Mode;693693-{694694- #define MAX_PCI_SLOT 32695695- #define RIO_PCI_JET_CARD 0x200011CB696696-697697- static int slot; /* count of machine's PCI slots searched so far */698698- caddr_t Caddr; /* Virtual address of the current PCI host card. */699699- unsigned char Ivec; /* interrupt vector for the current PCI host */700700- unsigned long Paddr; /* Physical address for the current PCI host */701701- int Handle; /* Handle to Virtual memory allocated for current PCI host */702702-703703-704704- rio_dprintk (RIO_DEBUG_INIT, "Search for a RIO PCI card - start at slot %d\n", slot);705705-706706- /*707707- ** Initialise the search status708708- */709709- p->RIOLastPCISearch = RIO_FAIL;710710-711711- while ( (slot < MAX_PCI_SLOT) & (p->RIOLastPCISearch != RIO_SUCCESS) )712712- {713713- rio_dprintk (RIO_DEBUG_INIT, "Currently testing slot %d\n", slot);714714-715715- if (read_config(0,slot,0) == RIO_PCI_JET_CARD) {716716- p->RIOHosts[p->RIONumHosts].Ivec = 0;717717- Paddr = read_config(0,slot,0x18);718718- Paddr = Paddr - (Paddr & 0x1); /* Mask off the io bit */719719-720720- if ( (Paddr == 0) || ((Paddr & 0xffff0000) == 0xffff0000) ) {721721- rio_dprintk (RIO_DEBUG_INIT, "Goofed up slot\n"); /* what! */722722- slot++;723723- continue;724724- }725725-726726- p->RIOHosts[p->RIONumHosts].PaddrP = Paddr;727727- Ivec = (read_config(0,slot,0x3c) & 0xff);728728-729729- rio_dprintk (RIO_DEBUG_INIT, "PCI Host at 0x%x, Intr %d\n", (int)Paddr, Ivec);730730-731731- Handle = RIOMapin( Paddr, RIO_PCI_MEM_SIZE, &Caddr );732732- if (Handle == -1) {733733- rio_dprintk (RIO_DEBUG_INIT, "Couldn't map %d bytes at 0x%x\n", RIO_PCI_MEM_SIZE, (int)Paddr);734734- slot++;735735- continue;736736- }737737- p->RIOHosts[p->RIONumHosts].Ivec = Ivec + 32;738738- p->intr_tid = iointset(p->RIOHosts[p->RIONumHosts].Ivec,739739- (int (*)())rio_intr, (char *)p->RIONumHosts);740740- if (RIOBoardTest( Paddr, Caddr, RIO_PCI, 0 ) == RIO_SUCCESS) {741741- rio_dprintk (RIO_DEBUG_INIT, ("Board has passed test\n");742742- rio_dprintk (RIO_DEBUG_INIT, ("Paddr 0x%x. Caddr 0x%x. Mode 0x%x.\n", Paddr, Caddr, Mode);743743-744744- /*745745- ** Board has passed its scrub test. Fill in all the746746- ** transient stuff.747747- */748748- p->RIOHosts[p->RIONumHosts].Slot = 0;749749- p->RIOHosts[p->RIONumHosts].Ivec = Ivec + 32;750750- p->RIOHosts[p->RIONumHosts].Type = RIO_PCI;751751- p->RIOHosts[p->RIONumHosts].Copy = rio_pcicopy; 752752- p->RIOHosts[p->RIONumHosts].PaddrP = Paddr;753753- p->RIOHosts[p->RIONumHosts].Caddr = Caddr;754754- p->RIOHosts[p->RIONumHosts].CardP = (struct DpRam *)Caddr;755755- p->RIOHosts[p->RIONumHosts].Mode = Mode;756756-757757-#if 0758758- WBYTE(p->RIOHosts[p->RIONumHosts].Control, 759759- BOOT_FROM_RAM | EXTERNAL_BUS_OFF | 760760- p->RIOHosts[p->RIONumHosts].Mode | 761761- INTERRUPT_DISABLE );762762- WBYTE(p->RIOHosts[p->RIONumHosts].ResetInt,0xff);763763- WBYTE(p->RIOHosts[p->RIONumHosts].Control,764764- BOOT_FROM_RAM | EXTERNAL_BUS_OFF | 765765- p->RIOHosts[p->RIONumHosts].Mode |766766- INTERRUPT_DISABLE );767767- WBYTE(p->RIOHosts[p->RIONumHosts].ResetInt,0xff);768768-#else769769- WBYTE(p->RIOHosts[p->RIONumHosts].ResetInt, 0xff);770770-#endif771771- p->RIOHosts[p->RIONumHosts].UniqueNum =772772- ((RBYTE(p->RIOHosts[p->RIONumHosts].Unique[0])&0xFF)<<0)|773773- ((RBYTE(p->RIOHosts[p->RIONumHosts].Unique[1])&0xFF)<<8)|774774- ((RBYTE(p->RIOHosts[p->RIONumHosts].Unique[2])&0xFF)<<16)|775775- ((RBYTE(p->RIOHosts[p->RIONumHosts].Unique[3])&0xFF)<<24);776776-777777- rio_dprintk (RIO_DEBUG_INIT, "Unique no 0x%x.\n", 778778- p->RIOHosts[p->RIONumHosts].UniqueNum);779779-780780- p->RIOLastPCISearch = RIO_SUCCESS;781781- p->RIONumHosts++;782782- }783783- }784784- slot++;785785- }786786-787787- if ( slot >= MAX_PCI_SLOT ) {788788- rio_dprintk (RIO_DEBUG_INIT, "All %d PCI slots have tested for RIO cards !!!\n",789789- MAX_PCI_SLOT);790790- }791791-792792-793793- /*794794- ** I don't think we want to do this anymore795795- **796796-797797- if (!p->RIOLastPCISearch == RIO_FAIL ) {798798- p->RIOFailed++;799799- }800800-801801- **802802- */803803-}804804-805805-#ifdef FUTURE_RELEASE806806-void riohalt( void )807807-{808808- int host;809809- for ( host=0; host<p->RIONumHosts; host++ )810810- {811811- rio_dprintk (RIO_DEBUG_INIT, "Stop host %d\n", host);812812- (void)RIOBoardTest( p->RIOHosts[host].PaddrP, p->RIOHosts[host].Caddr, p->RIOHosts[host].Type,p->RIOHosts[host].Slot );813813- }814814-}815815-#endif816816-#endif817370818371static uchar val[] = {819372#ifdef VERY_LONG_TEST···3871262 return RIO_SUCCESS;3881263}3891264390390-/*391391-** try to ensure that every host is either in polled mode392392-** or is in interrupt mode. Only allow interrupt mode if393393-** all hosts can interrupt (why?)394394-** and force into polled mode if told to. Patch up the395395-** interrupt vector & salute The Queen when you've done.396396-*/397397-#if 0398398-static void399399-RIOAllocateInterrupts(p)400400-struct rio_info * p;401401-{402402- int Host;403403-404404- /*405405- ** Easy case - if we have been told to poll, then we poll.406406- */407407- if (p->mode & POLLED_MODE) {408408- RIOStopInterrupts(p, 0, 0);409409- return;410410- }411411-412412- /*413413- ** check - if any host has been set to polled mode, then all must be.414414- */415415- for (Host=0; Host<p->RIONumHosts; Host++) {416416- if ( (p->RIOHosts[Host].Type != RIO_AT) &&417417- (p->RIOHosts[Host].Ivec == POLLED) ) {418418- RIOStopInterrupts(p, 1, Host );419419- return;420420- }421421- }422422- for (Host=0; Host<p->RIONumHosts; Host++) {423423- if (p->RIOHosts[Host].Type == RIO_AT) {424424- if ( (p->RIOHosts[Host].Ivec - 32) == 0) {425425- RIOStopInterrupts(p, 2, Host );426426- return;427427- }428428- }429429- }430430-}431431-432432-/*433433-** something has decided that we can't be doing with these434434-** new-fangled interrupt thingies. Set everything up to just435435-** poll.436436-*/437437-static void438438-RIOStopInterrupts(p, Reason, Host)439439-struct rio_info * p;440440-int Reason;441441-int Host; 442442-{443443-#ifdef FUTURE_RELEASE444444- switch (Reason) {445445- case 0: /* forced into polling by rio_polled */446446- break;447447- case 1: /* SCU has set 'Host' into polled mode */448448- break;449449- case 2: /* there aren't enough interrupt vectors for 'Host' */450450- break;451451- }452452-#endif453453-454454- for (Host=0; Host<p->RIONumHosts; Host++ ) {455455- struct Host *HostP = &p->RIOHosts[Host];456456-457457- switch (HostP->Type) {458458- case RIO_AT:459459- /*460460- ** The AT host has it's interrupts disabled by clearing the461461- ** int_enable bit.462462- */463463- HostP->Mode &= ~INTERRUPT_ENABLE;464464- HostP->Ivec = POLLED;465465- break;466466-#ifdef FUTURE_RELEASE467467- case RIO_EISA:468468- /*469469- ** The EISA host has it's interrupts disabled by setting the470470- ** Ivec to zero471471- */472472- HostP->Ivec = POLLED;473473- break;474474-#endif475475- case RIO_PCI:476476- /*477477- ** The PCI host has it's interrupts disabled by clearing the478478- ** int_enable bit, like a regular host card.479479- */480480- HostP->Mode &= ~RIO_PCI_INT_ENABLE;481481- HostP->Ivec = POLLED;482482- break;483483-#ifdef FUTURE_RELEASE484484- case RIO_MCA:485485- /*486486- ** There's always one, isn't there?487487- ** The MCA host card cannot have it's interrupts disabled.488488- */489489- RIOPatchVec(HostP);490490- break;491491-#endif492492- }493493- }494494-}495495-496496-/*497497-** This function is called at init time to setup the data structures.498498-*/499499-void500500-RIOAllocDataStructs(p)501501-struct rio_info * p;502502-{503503- int port,504504- host,505505- tm;506506-507507- p->RIOPortp = (struct Port *)sysbrk(RIO_PORTS * sizeof(struct Port));508508- if (!p->RIOPortp) {509509- rio_dprintk (RIO_DEBUG_INIT, "RIO-init: No memory for port structures\n");510510- p->RIOFailed++;511511- return;512512- } 513513- bzero( p->RIOPortp, sizeof(struct Port) * RIO_PORTS );514514- rio_dprintk (RIO_DEBUG_INIT, "RIO-init: allocated and cleared memory for port structs\n");515515- rio_dprintk (RIO_DEBUG_INIT, "First RIO port struct @0x%x, size=0x%x bytes\n",516516- (int)p->RIOPortp, sizeof(struct Port));517517-518518- for( port=0; port<RIO_PORTS; port++ ) {519519- p->RIOPortp[port].PortNum = port;520520- p->RIOPortp[port].TtyP = &p->channel[port];521521- sreset (p->RIOPortp[port].InUse); /* Let the first guy uses it */522522- p->RIOPortp[port].portSem = -1; /* Let the first guy takes it */523523- p->RIOPortp[port].ParamSem = -1; /* Let the first guy takes it */524524- p->RIOPortp[port].timeout_id = 0; /* Let the first guy takes it */525525- }526526-527527- p->RIOHosts = (struct Host *)sysbrk(RIO_HOSTS * sizeof(struct Host));528528- if (!p->RIOHosts) {529529- rio_dprintk (RIO_DEBUG_INIT, "RIO-init: No memory for host structures\n");530530- p->RIOFailed++;531531- return;532532- }533533- bzero(p->RIOHosts, sizeof(struct Host)*RIO_HOSTS);534534- rio_dprintk (RIO_DEBUG_INIT, "RIO-init: allocated and cleared memory for host structs\n");535535- rio_dprintk (RIO_DEBUG_INIT, "First RIO host struct @0x%x, size=0x%x bytes\n",536536- (int)p->RIOHosts, sizeof(struct Host));537537-538538- for( host=0; host<RIO_HOSTS; host++ ) {539539- spin_lock_init (&p->RIOHosts[host].HostLock);540540- p->RIOHosts[host].timeout_id = 0; /* Let the first guy takes it */541541- }542542- /*543543- ** check that the buffer size is valid, round down to the next power of544544- ** two if necessary; if the result is zero, then, hey, no double buffers.545545- */546546- for ( tm = 1; tm && tm <= p->RIOConf.BufferSize; tm <<= 1 )547547- ;548548- tm >>= 1;549549- p->RIOBufferSize = tm;550550- p->RIOBufferMask = tm ? tm - 1 : 0;551551-}552552-553553-/*554554-** this function gets called whenever the data structures need to be555555-** re-setup, for example, after a riohalt (why did I ever invent it?)556556-*/557557-void558558-RIOSetupDataStructs(p)559559-struct rio_info * p;560560-{561561- int host, entry, rup;562562-563563- for ( host=0; host<RIO_HOSTS; host++ ) {564564- struct Host *HostP = &p->RIOHosts[host];565565- for ( entry=0; entry<LINKS_PER_UNIT; entry++ ) {566566- HostP->Topology[entry].Unit = ROUTE_DISCONNECT;567567- HostP->Topology[entry].Link = NO_LINK;568568- }569569- bcopy("HOST X", HostP->Name, 7);570570- HostP->Name[5] = '1'+host;571571- for (rup=0; rup<(MAX_RUP + LINKS_PER_UNIT); rup++) {572572- if (rup < MAX_RUP) {573573- for (entry=0; entry<LINKS_PER_UNIT; entry++ ) {574574- HostP->Mapping[rup].Topology[entry].Unit = ROUTE_DISCONNECT;575575- HostP->Mapping[rup].Topology[entry].Link = NO_LINK;576576- }577577- RIODefaultName(p, HostP, rup);578578- }579579- spin_lock_init(&HostP->UnixRups[rup].RupLock);580580- }581581- }582582-}583583-#endif58412655851266int5861267RIODefaultName(p, HostP, UnitId)···3941463struct Host * HostP;3951464uint UnitId;3961465{397397-#ifdef CHECK398398- CheckHost( Host );399399- CheckUnitId( UnitId );400400-#endif4011466 bcopy("UNKNOWN RTA X-XX",HostP->Mapping[UnitId].Name,17);4021467 HostP->Mapping[UnitId].Name[12]='1'+(HostP-p->RIOHosts);4031468 if ((UnitId+1) > 9) {···4101483#define RIO_RELEASE "Linux"4111484#define RELEASE_ID "1.0"4121485413413-#if 0414414-static int415415-RIOReport(p)416416-struct rio_info * p;417417-{418418- char * RIORelease = RIO_RELEASE;419419- char * RIORelID = RELEASE_ID;420420- int host;421421-422422- rio_dprintk (RIO_DEBUG_INIT, "RIO : Release: %s ID: %s\n", RIORelease, RIORelID);423423-424424- if ( p->RIONumHosts==0 ) {425425- rio_dprintk (RIO_DEBUG_INIT, "\nNo Hosts configured\n");426426- return(0);427427- }428428-429429- for ( host=0; host < p->RIONumHosts; host++ ) {430430- struct Host *HostP = &p->RIOHosts[host];431431- switch ( HostP->Type ) {432432- case RIO_AT:433433- rio_dprintk (RIO_DEBUG_INIT, "AT BUS : found the card at 0x%x\n", HostP->PaddrP);434434- }435435- }436436- return 0;437437-}438438-#endif439439-4401486static struct rioVersion stVersion;44114874421488struct rioVersion *···42215224231523 return &stVersion;4241524}425425-426426-#if 0427427-int428428-RIOMapin(paddr, size, vaddr)429429-paddr_t paddr;430430-int size;431431-caddr_t * vaddr;432432-{433433- *vaddr = (caddr_t)permap( (long)paddr, size);434434- return ((int)*vaddr);435435-}436436-437437-void438438-RIOMapout(paddr, size, vaddr)439439-paddr_t paddr;440440-long size;441441-caddr_t vaddr;442442-{443443-}444444-#endif445445-44615254471526void4481527RIOHostReset(Type, DpRamP, Slot)···4491570 WBYTE(DpRamP->DpResetTpu, 0xFF);4501571 udelay(3);4511572 break;452452-#ifdef FUTURE_RELEASE453453- case RIO_EISA:454454- /*455455- ** Bet this doesn't work!456456- */457457- OUTBZ( Slot, EISA_CONTROL_PORT,458458- EISA_TP_RUN | EISA_TP_BUS_DISABLE |459459- EISA_TP_SLOW_LINKS | EISA_TP_BOOT_FROM_RAM );460460- OUTBZ( Slot, EISA_CONTROL_PORT,461461- EISA_TP_RESET | EISA_TP_BUS_DISABLE | 462462- EISA_TP_SLOW_LINKS | EISA_TP_BOOT_FROM_RAM );463463- suspend( 3 );464464- OUTBZ( Slot, EISA_CONTROL_PORT,465465- EISA_TP_RUN | EISA_TP_BUS_DISABLE | 466466- EISA_TP_SLOW_LINKS | EISA_TP_BOOT_FROM_RAM );467467- break;468468- case RIO_MCA:469469- WBYTE(DpRamP->DpControl , McaTpBootFromRam | McaTpBusDisable );470470- WBYTE(DpRamP->DpResetTpu , 0xFF );471471- suspend( 3 );472472- WBYTE(DpRamP->DpControl , McaTpBootFromRam | McaTpBusDisable );473473- WBYTE(DpRamP->DpResetTpu , 0xFF );474474- suspend( 3 );475475- break;476476-#endif4771573 case RIO_PCI:4781574 rio_dprintk (RIO_DEBUG_INIT, " (RIO_PCI)\n");4791575 DpRamP->DpControl = RIO_PCI_BOOT_FROM_RAM;···4581604 /* for (i=0; i<6000; i++); */4591605 /* suspend( 3 ); */4601606 break;461461-#ifdef FUTURE_RELEASE462462- default:463463- Rprintf(RIOMesgNoSupport,Type,DpRamP,Slot);464464- return;465465-#endif466466-4671607 default:4681608 rio_dprintk (RIO_DEBUG_INIT, " (UNKNOWN)\n");4691609 break;