···8788int RIOPCIinit(struct rio_info *p, int Mode);8990-#if 091-static void RIOAllocateInterrupts(struct rio_info *);92-static int RIOReport(struct rio_info *);93-static void RIOStopInterrupts(struct rio_info *, int, int);94-#endif95-96static int RIOScrub(int, BYTE *, int);9798-#if 099-extern int rio_intr();100-101-/*102-** Init time code.103-*/104-void105-rioinit( p, info )106-struct rio_info * p;107-struct RioHostInfo * info;108-{109- /*110- ** Multi-Host card support - taking the easy way out - sorry !111- ** We allocate and set up the Host and Port structs when the112- ** driver is called to 'install' the first host.113- ** We check for this first 'call' by testing the RIOPortp pointer.114- */115- if ( !p->RIOPortp )116- {117- rio_dprintk (RIO_DEBUG_INIT, "Allocating and setting up driver data structures\n");118-119- RIOAllocDataStructs(p); /* allocate host/port structs */120- RIOSetupDataStructs(p); /* setup topology structs */121- }122-123- RIOInitHosts( p, info ); /* hunt down the hardware */124-125- RIOAllocateInterrupts(p); /* allocate interrupts */126- RIOReport(p); /* show what we found */127-}128-129-/*130-** Initialise the Cards 131-*/ 132-void133-RIOInitHosts(p, info)134-struct rio_info * p;135-struct RioHostInfo * info;136-{137-/*138-** 15.10.1998 ARG - ESIL 0762 part fix139-** If there is no ISA card definition - we always look for PCI cards.140-** As we currently only support one host card this lets an ISA card141-** definition take precedence over PLUG and PLAY.142-** No ISA card - we are PLUG and PLAY with PCI.143-*/144-145- /*146- ** Note - for PCI both these will be zero, that's okay because147- ** RIOPCIInit() fills them in if a card is found.148- */149- p->RIOHosts[p->RIONumHosts].Ivec = info->vector;150- p->RIOHosts[p->RIONumHosts].PaddrP = info->location;151-152- /*153- ** Check that we are able to accommodate another host154- */155- if ( p->RIONumHosts >= RIO_HOSTS )156- {157- p->RIOFailed++;158- return;159- }160-161- if ( info->bus & ISA_BUS )162- {163- rio_dprintk (RIO_DEBUG_INIT, "initialising card %d (ISA)\n", p->RIONumHosts);164- RIOISAinit(p, p->mode);165- }166- else167- {168- rio_dprintk (RIO_DEBUG_INIT, "initialising card %d (PCI)\n", p->RIONumHosts);169- RIOPCIinit(p, RIO_PCI_DEFAULT_MODE);170- }171-172- rio_dprintk (RIO_DEBUG_INIT, "Total hosts initialised so far : %d\n", p->RIONumHosts);173-174-175-#ifdef FUTURE_RELEASE176- if (p->bus & EISA_BUS)177- /* EISA card */178- RIOEISAinit(p, RIO_EISA_DEFAULT_MODE);179-180- if (p->bus & MCA_BUS)181- /* MCA card */182- RIOMCAinit(p, RIO_MCA_DEFAULT_MODE);183-#endif184-}185-186-/*187-** go through memory for an AT host that we pass in the device info188-** structure and initialise189-*/190-void191-RIOISAinit(p, mode)192-struct rio_info * p;193-int mode;194-{195-196- /* XXX Need to implement this. */197-#if 0198- p->intr_tid = iointset(p->RIOHosts[p->RIONumHosts].Ivec,199- (int (*)())rio_intr, (char*)p->RIONumHosts);200-201- rio_dprintk (RIO_DEBUG_INIT, "Set interrupt handler, intr_tid = 0x%x\n", p->intr_tid );202-203- if (RIODoAT(p, p->RIOHosts[p->RIONumHosts].PaddrP, mode)) {204- return;205- }206- else {207- rio_dprintk (RIO_DEBUG_INIT, "RIODoAT failed\n");208- p->RIOFailed++;209- }210-#endif211-212-}213-214-/*215-** RIODoAT :216-**217-** Map in a boards physical address, check that the board is there,218-** test the board and if everything is okay assign the board an entry219-** in the Rio Hosts structure.220-*/221-int222-RIODoAT(p, Base, mode)223-struct rio_info * p;224-int Base;225-int mode;226-{227-#define FOUND 1228-#define NOT_FOUND 0229-230- caddr_t cardAddr;231-232- /*233- ** Check to see if we actually have a board at this physical address.234- */235- if ((cardAddr = RIOCheckForATCard(Base)) != 0) {236- /*237- ** Now test the board to see if it is working.238- */239- if (RIOBoardTest(Base, cardAddr, RIO_AT, 0) == RIO_SUCCESS) {240- /*241- ** Fill out a slot in the Rio host structure.242- */243- if (RIOAssignAT(p, Base, cardAddr, mode)) {244- return(FOUND);245- }246- }247- RIOMapout(Base, RIO_AT_MEM_SIZE, cardAddr);248- }249- return(NOT_FOUND);250-}251-252-caddr_t253-RIOCheckForATCard(Base)254-int Base;255-{256- int off;257- struct DpRam *cardp; /* (Points at the host) */258- caddr_t virtAddr;259- unsigned char RIOSigTab[24];260-/*261-** Table of values to search for as prom signature of a host card262-*/263- strcpy(RIOSigTab, "JBJGPGGHINSMJPJR");264-265- /*266- ** Hey! Yes, You reading this code! Yo, grab a load a this:267- **268- ** IF the card is using WORD MODE rather than BYTE MODE269- ** then it will occupy 128K of PHYSICAL memory area. So,270- ** you might think that the following Mapin is wrong. Well,271- ** it isn't, because the SECOND 64K of occupied space is an272- ** EXACT COPY of the FIRST 64K. (good?), so, we need only273- ** map it in in one 64K block.274- */275- if (RIOMapin(Base, RIO_AT_MEM_SIZE, &virtAddr) == -1) {276- rio_dprintk (RIO_DEBUG_INIT, "RIO-init: Couldn't map the board in!\n");277- return((caddr_t)0);278- }279-280- /*281- ** virtAddr points to the DP ram of the system.282- ** We now cast this to a pointer to a RIO Host,283- ** and have a rummage about in the PROM.284- */285- cardp = (struct DpRam *)virtAddr;286-287- for (off=0; RIOSigTab[off]; off++) {288- if ((RBYTE(cardp->DpSignature[off]) & 0xFF) != RIOSigTab[off]) {289- /*290- ** Signature mismatch - card not at this address291- */292- RIOMapout(Base, RIO_AT_MEM_SIZE, virtAddr);293- rio_dprintk (RIO_DEBUG_INIT, "RIO-init: Couldn't match the signature 0x%x 0x%x!\n",294- (int)cardp, off);295- return((caddr_t)0);296- }297- }298-299- /*300- ** If we get here then we must have found a valid board so return301- ** its virtual address.302- */303- return(virtAddr);304-}305-#endif306307/**308** RIOAssignAT :···153 rio_dprintk (RIO_DEBUG_INIT, "RIO-init: Tests Passed at 0x%x\n", Base);154 return(1);155}156-#if 0157-#ifdef FUTURE_RELEASE158-int RIOMCAinit(int Mode)159-{160- uchar SlotNumber;161- caddr_t Caddr;162- uint Paddr;163- uint Ivec;164- int Handle;165- int ret = 0;166-167- /*168- ** Valid mode information for MCA cards169- ** is only FAST LINKS170- */171- Mode = (Mode & FAST_LINKS) ? McaTpFastLinks : McaTpSlowLinks;172- rio_dprintk (RIO_DEBUG_INIT, "RIOMCAinit(%d)\n",Mode);173-174-175- /*176- ** Check out each of the slots177- */178- for (SlotNumber = 0; SlotNumber < McaMaxSlots; SlotNumber++) {179- /*180- ** Enable the slot we want to talk to181- */182- outb( McaSlotSelect, SlotNumber | McaSlotEnable );183-184- /*185- ** Read the ID word from the slot186- */187- if (((inb(McaIdHigh)<< 8)|inb(McaIdLow)) == McaRIOId)188- {189- rio_dprintk (RIO_DEBUG_INIT, "Potential MCA card in slot %d\n", SlotNumber);190-191- /*192- ** Card appears to be a RIO MCA card!193- */194- RIOMachineType |= (1<<RIO_MCA);195-196- /*197- ** Just check we haven't found too many wonderful objects198- */199- if ( RIONumHosts >= RIO_HOSTS )200- {201- Rprintf(RIOMesgTooManyCards);202- return(ret);203- }204-205- /*206- ** McaIrqEnable contains the interrupt vector, and a card207- ** enable bit.208- */209- Ivec = inb(McaIrqEnable);210-211- rio_dprintk (RIO_DEBUG_INIT, "Ivec is %x\n", Ivec);212-213- switch ( Ivec & McaIrqMask )214- {215- case McaIrq9:216- rio_dprintk (RIO_DEBUG_INIT, "IRQ9\n");217- break;218- case McaIrq3:219- rio_dprintk (RIO_DEBUG_INIT, "IRQ3\n");220- break;221- case McaIrq4:222- rio_dprintk (RIO_DEBUG_INIT, "IRQ4\n");223- break;224- case McaIrq7:225- rio_dprintk (RIO_DEBUG_INIT, "IRQ7\n");226- break;227- case McaIrq10:228- rio_dprintk (RIO_DEBUG_INIT, "IRQ10\n");229- break;230- case McaIrq11:231- rio_dprintk (RIO_DEBUG_INIT, "IRQ11\n");232- break;233- case McaIrq12:234- rio_dprintk (RIO_DEBUG_INIT, "IRQ12\n");235- break;236- case McaIrq15:237- rio_dprintk (RIO_DEBUG_INIT, "IRQ15\n");238- break;239- }240-241- /*242- ** If the card enable bit isn't set, then set it!243- */244- if ((Ivec & McaCardEnable) != McaCardEnable) {245- rio_dprintk (RIO_DEBUG_INIT, "McaCardEnable not set - setting!\n");246- outb(McaIrqEnable,Ivec|McaCardEnable);247- } else248- rio_dprintk (RIO_DEBUG_INIT, "McaCardEnable already set\n");249-250- /*251- ** Convert the IRQ enable mask into something useful252- */253- Ivec = RIOMcaToIvec[Ivec & McaIrqMask];254-255- /*256- ** Find the physical address257- */258- rio_dprintk (RIO_DEBUG_INIT, "inb(McaMemory) is %x\n", inb(McaMemory));259- Paddr = McaAddress(inb(McaMemory));260-261- rio_dprintk (RIO_DEBUG_INIT, "MCA card has Ivec %d Addr %x\n", Ivec, Paddr);262-263- if ( Paddr != 0 )264- {265-266- /*267- ** Tell the memory mapper that we want to talk to it268- */269- Handle = RIOMapin( Paddr, RIO_MCA_MEM_SIZE, &Caddr );270-271- if ( Handle == -1 ) {272- rio_dprintk (RIO_DEBUG_INIT, "Couldn't map %d bytes at %x\n", RIO_MCA_MEM_SIZE, Paddr;273- continue;274- }275-276- rio_dprintk (RIO_DEBUG_INIT, "Board mapped to vaddr 0x%x\n", Caddr);277-278- /*279- ** And check that it is actually there!280- */281- if ( RIOBoardTest( Paddr,Caddr,RIO_MCA,SlotNumber ) == RIO_SUCCESS )282- {283- rio_dprintk (RIO_DEBUG_INIT, "Board has passed test\n");284- rio_dprintk (RIO_DEBUG_INIT, "Slot %d. Type %d. Paddr 0x%x. Caddr 0x%x. Mode 0x%x.\n",285- SlotNumber, RIO_MCA, Paddr, Caddr, Mode);286-287- /*288- ** Board has passed its scrub test. Fill in all the289- ** transient stuff.290- */291- p->RIOHosts[RIONumHosts].Slot = SlotNumber;292- p->RIOHosts[RIONumHosts].Ivec = Ivec;293- p->RIOHosts[RIONumHosts].Type = RIO_MCA;294- p->RIOHosts[RIONumHosts].Copy = bcopy;295- p->RIOHosts[RIONumHosts].PaddrP = Paddr;296- p->RIOHosts[RIONumHosts].Caddr = Caddr;297- p->RIOHosts[RIONumHosts].CardP = (struct DpRam *)Caddr;298- p->RIOHosts[RIONumHosts].Mode = Mode;299- WBYTE(p->RIOHosts[p->RIONumHosts].ResetInt , 0xff);300- p->RIOHosts[RIONumHosts].UniqueNum =301- ((RBYTE(p->RIOHosts[RIONumHosts].Unique[0])&0xFF)<<0)|302- ((RBYTE(p->RIOHosts[RIONumHosts].Unique[1])&0xFF)<<8)|303- ((RBYTE(p->RIOHosts[RIONumHosts].Unique[2])&0xFF)<<16)|304- ((RBYTE(p->RIOHosts[RIONumHosts].Unique[3])&0xFF)<<24);305- RIONumHosts++;306- ret++;307- }308- else309- {310- /*311- ** It failed the test, so ignore it.312- */313- rio_dprintk (RIO_DEBUG_INIT, "TEST FAILED\n");314- RIOMapout(Paddr, RIO_MCA_MEM_SIZE, Caddr );315- }316- }317- else318- {319- rio_dprintk (RIO_DEBUG_INIT, "Slot %d - Paddr zero!\n", SlotNumber);320- }321- }322- else323- {324- rio_dprintk (RIO_DEBUG_INIT, "Slot %d NOT RIO\n", SlotNumber);325- }326- }327- /*328- ** Now we have checked all the slots, turn off the MCA slot selector329- */330- outb(McaSlotSelect,0);331- rio_dprintk (RIO_DEBUG_INIT, "Slot %d NOT RIO\n", SlotNumber);332- return ret;333-}334-335-int RIOEISAinit( int Mode )336-{337- static int EISADone = 0;338- uint Paddr;339- int PollIntMixMsgDone = 0;340- caddr_t Caddr;341- ushort Ident;342- uchar EisaSlot;343- uchar Ivec;344- int ret = 0;345-346- /*347- ** The only valid mode information for EISA hosts is fast or slow348- ** links.349- */350- Mode = (Mode & FAST_LINKS) ? EISA_TP_FAST_LINKS : EISA_TP_SLOW_LINKS;351-352- if ( EISADone )353- {354- rio_dprintk (RIO_DEBUG_INIT, "RIOEISAinit() - already done, return.\n");355- return(0);356- }357-358- EISADone++;359-360- rio_dprintk (RIO_DEBUG_INIT, "RIOEISAinit()\n");361-362-363- /*364- ** First check all cards to see if ANY are set for polled mode operation.365- ** If so, set ALL to polled.366- */367-368- for ( EisaSlot=1; EisaSlot<=RIO_MAX_EISA_SLOTS; EisaSlot++ )369- {370- Ident = (INBZ(EisaSlot,EISA_PRODUCT_IDENT_HI)<<8) |371- INBZ(EisaSlot,EISA_PRODUCT_IDENT_LO);372-373- if ( Ident == RIO_EISA_IDENT )374- {375- rio_dprintk (RIO_DEBUG_INIT, "Found Specialix product\n");376-377- if ( INBZ(EisaSlot,EISA_PRODUCT_NUMBER) != RIO_EISA_PRODUCT_CODE )378- {379- rio_dprintk (RIO_DEBUG_INIT, "Not Specialix RIO - Product number %x\n",380- INBZ(EisaSlot, EISA_PRODUCT_NUMBER));381- continue; /* next slot */382- }383- /*384- ** Its a Specialix RIO!385- */386- rio_dprintk (RIO_DEBUG_INIT, "RIO Revision %d\n",387- INBZ(EisaSlot, EISA_REVISION_NUMBER));388-389- RIOMachineType |= (1<<RIO_EISA);390-391- /*392- ** Just check we haven't found too many wonderful objects393- */394- if ( RIONumHosts >= RIO_HOSTS )395- {396- Rprintf(RIOMesgTooManyCards);397- return 0;398- }399-400- /*401- ** Ensure that the enable bit is set!402- */403- OUTBZ( EisaSlot, EISA_ENABLE, RIO_EISA_ENABLE_BIT );404-405- /*406- ** EISA_INTERRUPT_VEC contains the interrupt vector.407- */408- Ivec = INBZ(EisaSlot,EISA_INTERRUPT_VEC);409-410-#ifdef RIODEBUG411- switch ( Ivec & EISA_INTERRUPT_MASK )412- {413- case EISA_IRQ_3:414- rio_dprintk (RIO_DEBUG_INIT, "EISA IRQ 3\n");415- break;416- case EISA_IRQ_4:417- rio_dprintk (RIO_DEBUG_INIT, "EISA IRQ 4\n");418- break;419- case EISA_IRQ_5:420- rio_dprintk (RIO_DEBUG_INIT, "EISA IRQ 5\n");421- break;422- case EISA_IRQ_6:423- rio_dprintk (RIO_DEBUG_INIT, "EISA IRQ 6\n");424- break;425- case EISA_IRQ_7:426- rio_dprintk (RIO_DEBUG_INIT, "EISA IRQ 7\n");427- break;428- case EISA_IRQ_9:429- rio_dprintk (RIO_DEBUG_INIT, "EISA IRQ 9\n");430- break;431- case EISA_IRQ_10:432- rio_dprintk (RIO_DEBUG_INIT, "EISA IRQ 10\n");433- break;434- case EISA_IRQ_11:435- rio_dprintk (RIO_DEBUG_INIT, "EISA IRQ 11\n");436- break;437- case EISA_IRQ_12:438- rio_dprintk (RIO_DEBUG_INIT, "EISA IRQ 12\n");439- break;440- case EISA_IRQ_14:441- rio_dprintk (RIO_DEBUG_INIT, "EISA IRQ 14\n");442- break;443- case EISA_IRQ_15:444- rio_dprintk (RIO_DEBUG_INIT, "EISA IRQ 15\n");445- break;446- case EISA_POLLED:447- rio_dprintk (RIO_DEBUG_INIT, "EISA POLLED\n");448- break;449- default:450- rio_dprintk (RIO_DEBUG_INIT, NULL,DBG_INIT|DBG_FAIL,"Shagged interrupt number!\n");451- Ivec &= EISA_CONTROL_MASK;452- }453-#endif454-455- if ( (Ivec & EISA_INTERRUPT_MASK) ==456- EISA_POLLED )457- {458- RIOWillPoll = 1;459- break; /* From EisaSlot loop */460- }461- }462- }463-464- /*465- ** Do it all again now we know whether to change all cards to polled466- ** mode or not467- */468-469- for ( EisaSlot=1; EisaSlot<=RIO_MAX_EISA_SLOTS; EisaSlot++ )470- {471- Ident = (INBZ(EisaSlot,EISA_PRODUCT_IDENT_HI)<<8) |472- INBZ(EisaSlot,EISA_PRODUCT_IDENT_LO);473-474- if ( Ident == RIO_EISA_IDENT )475- {476- if ( INBZ(EisaSlot,EISA_PRODUCT_NUMBER) != RIO_EISA_PRODUCT_CODE )477- continue; /* next slot */478-479- /*480- ** Its a Specialix RIO!481- */482-483- /*484- ** Ensure that the enable bit is set!485- */486- OUTBZ( EisaSlot, EISA_ENABLE, RIO_EISA_ENABLE_BIT );487-488- /*489- ** EISA_INTERRUPT_VEC contains the interrupt vector.490- */491- Ivec = INBZ(EisaSlot,EISA_INTERRUPT_VEC);492-493- if ( RIOWillPoll )494- {495- /*496- ** If we are going to operate in polled mode, but this497- ** board is configured to be interrupt driven, display498- ** the message explaining the situation to the punter,499- ** assuming we haven't already done so.500- */501-502- if ( !PollIntMixMsgDone &&503- (Ivec & EISA_INTERRUPT_MASK) != EISA_POLLED )504- {505- Rprintf(RIOMesgAllPolled);506- PollIntMixMsgDone = 1;507- }508-509- /*510- ** Ungraciously ignore whatever the board reports as its511- ** interrupt vector...512- */513-514- Ivec &= ~EISA_INTERRUPT_MASK;515-516- /*517- ** ...and force it to dance to the poll tune.518- */519-520- Ivec |= EISA_POLLED;521- }522-523- /*524- ** Convert the IRQ enable mask into something useful (0-15)525- */526- Ivec = RIOEisaToIvec(Ivec);527-528- rio_dprintk (RIO_DEBUG_INIT, "EISA host in slot %d has Ivec 0x%x\n",529- EisaSlot, Ivec);530-531- /*532- ** Find the physical address533- */534- Paddr = (INBZ(EisaSlot,EISA_MEMORY_BASE_HI)<<24) |535- (INBZ(EisaSlot,EISA_MEMORY_BASE_LO)<<16);536-537- rio_dprintk (RIO_DEBUG_INIT, "EISA card has Ivec %d Addr %x\n", Ivec, Paddr);538-539- if ( Paddr == 0 )540- {541- rio_dprintk (RIO_DEBUG_INIT,542- "Board in slot %d configured for address zero!\n", EisaSlot);543- continue;544- }545-546- /*547- ** Tell the memory mapper that we want to talk to it548- */549- rio_dprintk (RIO_DEBUG_INIT, "About to map EISA card \n");550-551- if (RIOMapin( Paddr, RIO_EISA_MEM_SIZE, &Caddr) == -1) {552- rio_dprintk (RIO_DEBUG_INIT, "Couldn't map %d bytes at %x\n",553- RIO_EISA_MEM_SIZE,Paddr);554- continue;555- }556-557- rio_dprintk (RIO_DEBUG_INIT, "Board mapped to vaddr 0x%x\n", Caddr);558-559- /*560- ** And check that it is actually there!561- */562- if ( RIOBoardTest( Paddr,Caddr,RIO_EISA,EisaSlot) == RIO_SUCCESS )563- {564- rio_dprintk (RIO_DEBUG_INIT, "Board has passed test\n");565- rio_dprintk (RIO_DEBUG_INIT, 566- "Slot %d. Ivec %d. Type %d. Paddr 0x%x. Caddr 0x%x. Mode 0x%x.\n",567- EisaSlot,Ivec,RIO_EISA,Paddr,Caddr,Mode);568-569- /*570- ** Board has passed its scrub test. Fill in all the571- ** transient stuff.572- */573- p->RIOHosts[RIONumHosts].Slot = EisaSlot;574- p->RIOHosts[RIONumHosts].Ivec = Ivec;575- p->RIOHosts[RIONumHosts].Type = RIO_EISA;576- p->RIOHosts[RIONumHosts].Copy = bcopy;577- p->RIOHosts[RIONumHosts].PaddrP = Paddr;578- p->RIOHosts[RIONumHosts].Caddr = Caddr;579- p->RIOHosts[RIONumHosts].CardP = (struct DpRam *)Caddr;580- p->RIOHosts[RIONumHosts].Mode = Mode;581- /*582- ** because the EISA prom is mapped into IO space, we583- ** need to copy the unqiue number into the memory area584- ** that it would have occupied, so that the download585- ** code can determine its ID and card type.586- */587- WBYTE(p->RIOHosts[RIONumHosts].Unique[0],INBZ(EisaSlot,EISA_UNIQUE_NUM_0));588- WBYTE(p->RIOHosts[RIONumHosts].Unique[1],INBZ(EisaSlot,EISA_UNIQUE_NUM_1));589- WBYTE(p->RIOHosts[RIONumHosts].Unique[2],INBZ(EisaSlot,EISA_UNIQUE_NUM_2));590- WBYTE(p->RIOHosts[RIONumHosts].Unique[3],INBZ(EisaSlot,EISA_UNIQUE_NUM_3));591- p->RIOHosts[RIONumHosts].UniqueNum =592- ((RBYTE(p->RIOHosts[RIONumHosts].Unique[0])&0xFF)<<0)|593- ((RBYTE(p->RIOHosts[RIONumHosts].Unique[1])&0xFF)<<8)|594- ((RBYTE(p->RIOHosts[RIONumHosts].Unique[2])&0xFF)<<16)|595- ((RBYTE(p->RIOHosts[RIONumHosts].Unique[3])&0xFF)<<24);596- INBZ(EisaSlot,EISA_INTERRUPT_RESET);597- RIONumHosts++;598- ret++;599- }600- else601- {602- /*603- ** It failed the test, so ignore it.604- */605- rio_dprintk (RIO_DEBUG_INIT, "TEST FAILED\n");606-607- RIOMapout(Paddr, RIO_EISA_MEM_SIZE, Caddr );608- }609- }610- }611- if (RIOMachineType & RIO_EISA)612- return ret+1;613- return ret;614-}615-#endif616-617-618-#ifndef linux619-620-#define CONFIG_ADDRESS 0xcf8621-#define CONFIG_DATA 0xcfc622-#define FORWARD_REG 0xcfa623-624-625-static int626-read_config(int bus_number, int device_num, int r_number) 627-{628- unsigned int cav;629- unsigned int val;630-631-/*632- Build config_address_value:633-634- 31 24 23 16 15 11 10 8 7 0 635- ------------------------------------------------------636- |1| 0000000 | bus_number | device # | 000 | register |637- ------------------------------------------------------638-*/639-640- cav = r_number & 0xff;641- cav |= ((device_num & 0x1f) << 11);642- cav |= ((bus_number & 0xff) << 16);643- cav |= 0x80000000; /* Enable bit */644- outpd(CONFIG_ADDRESS,cav);645- val = inpd(CONFIG_DATA);646- outpd(CONFIG_ADDRESS,0);647- return val;648-}649-650-static651-write_config(bus_number,device_num,r_number,val) 652-{653- unsigned int cav;654-655-/*656- Build config_address_value:657-658- 31 24 23 16 15 11 10 8 7 0 659- ------------------------------------------------------660- |1| 0000000 | bus_number | device # | 000 | register |661- ------------------------------------------------------662-*/663-664- cav = r_number & 0xff;665- cav |= ((device_num & 0x1f) << 11);666- cav |= ((bus_number & 0xff) << 16);667- cav |= 0x80000000; /* Enable bit */668- outpd(CONFIG_ADDRESS, cav);669- outpd(CONFIG_DATA, val);670- outpd(CONFIG_ADDRESS, 0);671- return val;672-}673-#else674-/* XXX Implement these... */675-static int676-read_config(int bus_number, int device_num, int r_number) 677-{678- return 0;679-}680-681-static int682-write_config(int bus_number, int device_num, int r_number) 683-{684- return 0;685-}686-687-#endif688-689-int690-RIOPCIinit(p, Mode)691-struct rio_info *p;692-int Mode;693-{694- #define MAX_PCI_SLOT 32695- #define RIO_PCI_JET_CARD 0x200011CB696-697- static int slot; /* count of machine's PCI slots searched so far */698- caddr_t Caddr; /* Virtual address of the current PCI host card. */699- unsigned char Ivec; /* interrupt vector for the current PCI host */700- unsigned long Paddr; /* Physical address for the current PCI host */701- int Handle; /* Handle to Virtual memory allocated for current PCI host */702-703-704- rio_dprintk (RIO_DEBUG_INIT, "Search for a RIO PCI card - start at slot %d\n", slot);705-706- /*707- ** Initialise the search status708- */709- p->RIOLastPCISearch = RIO_FAIL;710-711- while ( (slot < MAX_PCI_SLOT) & (p->RIOLastPCISearch != RIO_SUCCESS) )712- {713- rio_dprintk (RIO_DEBUG_INIT, "Currently testing slot %d\n", slot);714-715- if (read_config(0,slot,0) == RIO_PCI_JET_CARD) {716- p->RIOHosts[p->RIONumHosts].Ivec = 0;717- Paddr = read_config(0,slot,0x18);718- Paddr = Paddr - (Paddr & 0x1); /* Mask off the io bit */719-720- if ( (Paddr == 0) || ((Paddr & 0xffff0000) == 0xffff0000) ) {721- rio_dprintk (RIO_DEBUG_INIT, "Goofed up slot\n"); /* what! */722- slot++;723- continue;724- }725-726- p->RIOHosts[p->RIONumHosts].PaddrP = Paddr;727- Ivec = (read_config(0,slot,0x3c) & 0xff);728-729- rio_dprintk (RIO_DEBUG_INIT, "PCI Host at 0x%x, Intr %d\n", (int)Paddr, Ivec);730-731- Handle = RIOMapin( Paddr, RIO_PCI_MEM_SIZE, &Caddr );732- if (Handle == -1) {733- rio_dprintk (RIO_DEBUG_INIT, "Couldn't map %d bytes at 0x%x\n", RIO_PCI_MEM_SIZE, (int)Paddr);734- slot++;735- continue;736- }737- p->RIOHosts[p->RIONumHosts].Ivec = Ivec + 32;738- p->intr_tid = iointset(p->RIOHosts[p->RIONumHosts].Ivec,739- (int (*)())rio_intr, (char *)p->RIONumHosts);740- if (RIOBoardTest( Paddr, Caddr, RIO_PCI, 0 ) == RIO_SUCCESS) {741- rio_dprintk (RIO_DEBUG_INIT, ("Board has passed test\n");742- rio_dprintk (RIO_DEBUG_INIT, ("Paddr 0x%x. Caddr 0x%x. Mode 0x%x.\n", Paddr, Caddr, Mode);743-744- /*745- ** Board has passed its scrub test. Fill in all the746- ** transient stuff.747- */748- p->RIOHosts[p->RIONumHosts].Slot = 0;749- p->RIOHosts[p->RIONumHosts].Ivec = Ivec + 32;750- p->RIOHosts[p->RIONumHosts].Type = RIO_PCI;751- p->RIOHosts[p->RIONumHosts].Copy = rio_pcicopy; 752- p->RIOHosts[p->RIONumHosts].PaddrP = Paddr;753- p->RIOHosts[p->RIONumHosts].Caddr = Caddr;754- p->RIOHosts[p->RIONumHosts].CardP = (struct DpRam *)Caddr;755- p->RIOHosts[p->RIONumHosts].Mode = Mode;756-757-#if 0758- WBYTE(p->RIOHosts[p->RIONumHosts].Control, 759- BOOT_FROM_RAM | EXTERNAL_BUS_OFF | 760- p->RIOHosts[p->RIONumHosts].Mode | 761- INTERRUPT_DISABLE );762- WBYTE(p->RIOHosts[p->RIONumHosts].ResetInt,0xff);763- WBYTE(p->RIOHosts[p->RIONumHosts].Control,764- BOOT_FROM_RAM | EXTERNAL_BUS_OFF | 765- p->RIOHosts[p->RIONumHosts].Mode |766- INTERRUPT_DISABLE );767- WBYTE(p->RIOHosts[p->RIONumHosts].ResetInt,0xff);768-#else769- WBYTE(p->RIOHosts[p->RIONumHosts].ResetInt, 0xff);770-#endif771- p->RIOHosts[p->RIONumHosts].UniqueNum =772- ((RBYTE(p->RIOHosts[p->RIONumHosts].Unique[0])&0xFF)<<0)|773- ((RBYTE(p->RIOHosts[p->RIONumHosts].Unique[1])&0xFF)<<8)|774- ((RBYTE(p->RIOHosts[p->RIONumHosts].Unique[2])&0xFF)<<16)|775- ((RBYTE(p->RIOHosts[p->RIONumHosts].Unique[3])&0xFF)<<24);776-777- rio_dprintk (RIO_DEBUG_INIT, "Unique no 0x%x.\n", 778- p->RIOHosts[p->RIONumHosts].UniqueNum);779-780- p->RIOLastPCISearch = RIO_SUCCESS;781- p->RIONumHosts++;782- }783- }784- slot++;785- }786-787- if ( slot >= MAX_PCI_SLOT ) {788- rio_dprintk (RIO_DEBUG_INIT, "All %d PCI slots have tested for RIO cards !!!\n",789- MAX_PCI_SLOT);790- }791-792-793- /*794- ** I don't think we want to do this anymore795- **796-797- if (!p->RIOLastPCISearch == RIO_FAIL ) {798- p->RIOFailed++;799- }800-801- **802- */803-}804-805-#ifdef FUTURE_RELEASE806-void riohalt( void )807-{808- int host;809- for ( host=0; host<p->RIONumHosts; host++ )810- {811- rio_dprintk (RIO_DEBUG_INIT, "Stop host %d\n", host);812- (void)RIOBoardTest( p->RIOHosts[host].PaddrP, p->RIOHosts[host].Caddr, p->RIOHosts[host].Type,p->RIOHosts[host].Slot );813- }814-}815-#endif816-#endif817818static uchar val[] = {819#ifdef VERY_LONG_TEST···387 return RIO_SUCCESS;388}389390-/*391-** try to ensure that every host is either in polled mode392-** or is in interrupt mode. Only allow interrupt mode if393-** all hosts can interrupt (why?)394-** and force into polled mode if told to. Patch up the395-** interrupt vector & salute The Queen when you've done.396-*/397-#if 0398-static void399-RIOAllocateInterrupts(p)400-struct rio_info * p;401-{402- int Host;403-404- /*405- ** Easy case - if we have been told to poll, then we poll.406- */407- if (p->mode & POLLED_MODE) {408- RIOStopInterrupts(p, 0, 0);409- return;410- }411-412- /*413- ** check - if any host has been set to polled mode, then all must be.414- */415- for (Host=0; Host<p->RIONumHosts; Host++) {416- if ( (p->RIOHosts[Host].Type != RIO_AT) &&417- (p->RIOHosts[Host].Ivec == POLLED) ) {418- RIOStopInterrupts(p, 1, Host );419- return;420- }421- }422- for (Host=0; Host<p->RIONumHosts; Host++) {423- if (p->RIOHosts[Host].Type == RIO_AT) {424- if ( (p->RIOHosts[Host].Ivec - 32) == 0) {425- RIOStopInterrupts(p, 2, Host );426- return;427- }428- }429- }430-}431-432-/*433-** something has decided that we can't be doing with these434-** new-fangled interrupt thingies. Set everything up to just435-** poll.436-*/437-static void438-RIOStopInterrupts(p, Reason, Host)439-struct rio_info * p;440-int Reason;441-int Host; 442-{443-#ifdef FUTURE_RELEASE444- switch (Reason) {445- case 0: /* forced into polling by rio_polled */446- break;447- case 1: /* SCU has set 'Host' into polled mode */448- break;449- case 2: /* there aren't enough interrupt vectors for 'Host' */450- break;451- }452-#endif453-454- for (Host=0; Host<p->RIONumHosts; Host++ ) {455- struct Host *HostP = &p->RIOHosts[Host];456-457- switch (HostP->Type) {458- case RIO_AT:459- /*460- ** The AT host has it's interrupts disabled by clearing the461- ** int_enable bit.462- */463- HostP->Mode &= ~INTERRUPT_ENABLE;464- HostP->Ivec = POLLED;465- break;466-#ifdef FUTURE_RELEASE467- case RIO_EISA:468- /*469- ** The EISA host has it's interrupts disabled by setting the470- ** Ivec to zero471- */472- HostP->Ivec = POLLED;473- break;474-#endif475- case RIO_PCI:476- /*477- ** The PCI host has it's interrupts disabled by clearing the478- ** int_enable bit, like a regular host card.479- */480- HostP->Mode &= ~RIO_PCI_INT_ENABLE;481- HostP->Ivec = POLLED;482- break;483-#ifdef FUTURE_RELEASE484- case RIO_MCA:485- /*486- ** There's always one, isn't there?487- ** The MCA host card cannot have it's interrupts disabled.488- */489- RIOPatchVec(HostP);490- break;491-#endif492- }493- }494-}495-496-/*497-** This function is called at init time to setup the data structures.498-*/499-void500-RIOAllocDataStructs(p)501-struct rio_info * p;502-{503- int port,504- host,505- tm;506-507- p->RIOPortp = (struct Port *)sysbrk(RIO_PORTS * sizeof(struct Port));508- if (!p->RIOPortp) {509- rio_dprintk (RIO_DEBUG_INIT, "RIO-init: No memory for port structures\n");510- p->RIOFailed++;511- return;512- } 513- bzero( p->RIOPortp, sizeof(struct Port) * RIO_PORTS );514- rio_dprintk (RIO_DEBUG_INIT, "RIO-init: allocated and cleared memory for port structs\n");515- rio_dprintk (RIO_DEBUG_INIT, "First RIO port struct @0x%x, size=0x%x bytes\n",516- (int)p->RIOPortp, sizeof(struct Port));517-518- for( port=0; port<RIO_PORTS; port++ ) {519- p->RIOPortp[port].PortNum = port;520- p->RIOPortp[port].TtyP = &p->channel[port];521- sreset (p->RIOPortp[port].InUse); /* Let the first guy uses it */522- p->RIOPortp[port].portSem = -1; /* Let the first guy takes it */523- p->RIOPortp[port].ParamSem = -1; /* Let the first guy takes it */524- p->RIOPortp[port].timeout_id = 0; /* Let the first guy takes it */525- }526-527- p->RIOHosts = (struct Host *)sysbrk(RIO_HOSTS * sizeof(struct Host));528- if (!p->RIOHosts) {529- rio_dprintk (RIO_DEBUG_INIT, "RIO-init: No memory for host structures\n");530- p->RIOFailed++;531- return;532- }533- bzero(p->RIOHosts, sizeof(struct Host)*RIO_HOSTS);534- rio_dprintk (RIO_DEBUG_INIT, "RIO-init: allocated and cleared memory for host structs\n");535- rio_dprintk (RIO_DEBUG_INIT, "First RIO host struct @0x%x, size=0x%x bytes\n",536- (int)p->RIOHosts, sizeof(struct Host));537-538- for( host=0; host<RIO_HOSTS; host++ ) {539- spin_lock_init (&p->RIOHosts[host].HostLock);540- p->RIOHosts[host].timeout_id = 0; /* Let the first guy takes it */541- }542- /*543- ** check that the buffer size is valid, round down to the next power of544- ** two if necessary; if the result is zero, then, hey, no double buffers.545- */546- for ( tm = 1; tm && tm <= p->RIOConf.BufferSize; tm <<= 1 )547- ;548- tm >>= 1;549- p->RIOBufferSize = tm;550- p->RIOBufferMask = tm ? tm - 1 : 0;551-}552-553-/*554-** this function gets called whenever the data structures need to be555-** re-setup, for example, after a riohalt (why did I ever invent it?)556-*/557-void558-RIOSetupDataStructs(p)559-struct rio_info * p;560-{561- int host, entry, rup;562-563- for ( host=0; host<RIO_HOSTS; host++ ) {564- struct Host *HostP = &p->RIOHosts[host];565- for ( entry=0; entry<LINKS_PER_UNIT; entry++ ) {566- HostP->Topology[entry].Unit = ROUTE_DISCONNECT;567- HostP->Topology[entry].Link = NO_LINK;568- }569- bcopy("HOST X", HostP->Name, 7);570- HostP->Name[5] = '1'+host;571- for (rup=0; rup<(MAX_RUP + LINKS_PER_UNIT); rup++) {572- if (rup < MAX_RUP) {573- for (entry=0; entry<LINKS_PER_UNIT; entry++ ) {574- HostP->Mapping[rup].Topology[entry].Unit = ROUTE_DISCONNECT;575- HostP->Mapping[rup].Topology[entry].Link = NO_LINK;576- }577- RIODefaultName(p, HostP, rup);578- }579- spin_lock_init(&HostP->UnixRups[rup].RupLock);580- }581- }582-}583-#endif584585int586RIODefaultName(p, HostP, UnitId)···394struct Host * HostP;395uint UnitId;396{397-#ifdef CHECK398- CheckHost( Host );399- CheckUnitId( UnitId );400-#endif401 bcopy("UNKNOWN RTA X-XX",HostP->Mapping[UnitId].Name,17);402 HostP->Mapping[UnitId].Name[12]='1'+(HostP-p->RIOHosts);403 if ((UnitId+1) > 9) {···410#define RIO_RELEASE "Linux"411#define RELEASE_ID "1.0"412413-#if 0414-static int415-RIOReport(p)416-struct rio_info * p;417-{418- char * RIORelease = RIO_RELEASE;419- char * RIORelID = RELEASE_ID;420- int host;421-422- rio_dprintk (RIO_DEBUG_INIT, "RIO : Release: %s ID: %s\n", RIORelease, RIORelID);423-424- if ( p->RIONumHosts==0 ) {425- rio_dprintk (RIO_DEBUG_INIT, "\nNo Hosts configured\n");426- return(0);427- }428-429- for ( host=0; host < p->RIONumHosts; host++ ) {430- struct Host *HostP = &p->RIOHosts[host];431- switch ( HostP->Type ) {432- case RIO_AT:433- rio_dprintk (RIO_DEBUG_INIT, "AT BUS : found the card at 0x%x\n", HostP->PaddrP);434- }435- }436- return 0;437-}438-#endif439-440static struct rioVersion stVersion;441442struct rioVersion *···422423 return &stVersion;424}425-426-#if 0427-int428-RIOMapin(paddr, size, vaddr)429-paddr_t paddr;430-int size;431-caddr_t * vaddr;432-{433- *vaddr = (caddr_t)permap( (long)paddr, size);434- return ((int)*vaddr);435-}436-437-void438-RIOMapout(paddr, size, vaddr)439-paddr_t paddr;440-long size;441-caddr_t vaddr;442-{443-}444-#endif445-446447void448RIOHostReset(Type, DpRamP, Slot)···449 WBYTE(DpRamP->DpResetTpu, 0xFF);450 udelay(3);451 break;452-#ifdef FUTURE_RELEASE453- case RIO_EISA:454- /*455- ** Bet this doesn't work!456- */457- OUTBZ( Slot, EISA_CONTROL_PORT,458- EISA_TP_RUN | EISA_TP_BUS_DISABLE |459- EISA_TP_SLOW_LINKS | EISA_TP_BOOT_FROM_RAM );460- OUTBZ( Slot, EISA_CONTROL_PORT,461- EISA_TP_RESET | EISA_TP_BUS_DISABLE | 462- EISA_TP_SLOW_LINKS | EISA_TP_BOOT_FROM_RAM );463- suspend( 3 );464- OUTBZ( Slot, EISA_CONTROL_PORT,465- EISA_TP_RUN | EISA_TP_BUS_DISABLE | 466- EISA_TP_SLOW_LINKS | EISA_TP_BOOT_FROM_RAM );467- break;468- case RIO_MCA:469- WBYTE(DpRamP->DpControl , McaTpBootFromRam | McaTpBusDisable );470- WBYTE(DpRamP->DpResetTpu , 0xFF );471- suspend( 3 );472- WBYTE(DpRamP->DpControl , McaTpBootFromRam | McaTpBusDisable );473- WBYTE(DpRamP->DpResetTpu , 0xFF );474- suspend( 3 );475- break;476-#endif477 case RIO_PCI:478 rio_dprintk (RIO_DEBUG_INIT, " (RIO_PCI)\n");479 DpRamP->DpControl = RIO_PCI_BOOT_FROM_RAM;···458 /* for (i=0; i<6000; i++); */459 /* suspend( 3 ); */460 break;461-#ifdef FUTURE_RELEASE462- default:463- Rprintf(RIOMesgNoSupport,Type,DpRamP,Slot);464- return;465-#endif466-467 default:468 rio_dprintk (RIO_DEBUG_INIT, " (UNKNOWN)\n");469 break;