pcicmd | PCI_CMD_MEMEN | PCI_CMD_IOEN, 2);
}
-/*
- * Subroutine: PCI_Config_VGA_Device
- *
- * Description: Configure a PCI VGA device by examining its I/O and memory
- * address space needs and allocating address space to it by
- * programming the address decoders in the Base Address Registers.
- *
- * Inputs: BusDevFunc Bus+Device+Function number
- * NumBaseAddr Number of base address registers to
- * configure
- *
- * Return: None
- *
- */
-void PCI_Config_VGA_Device(int BusDevFunc, int NumBaseAddr)
-{
- int AddrSlot, i;
- unsigned long AddrDesc, AddrProg, Min_Gnt_Val;
-
- unsigned long pcicmd;
- pcicmd = PCI_Read_CFG_Reg(BusDevFunc, PCI_CFG_COMMAND, 2);
- PCI_Write_CFG_Reg (BusDevFunc, PCI_CFG_COMMAND,
- pcicmd & ~(PCI_CMD_MEMEN|PCI_CMD_IOEN), 2);
-
- for (AddrSlot = 0; AddrSlot < NumBaseAddr; AddrSlot++) {
- /*
- * Write virtual address into register to check LSB.
- * LSB == 1 => IO space, else memory space.
- */
- PCI_Write_CFG_Reg (BusDevFunc,
- PCI_CFG_BASE_ADDRESS_0 + (4*AddrSlot),
- 0xFFFFFFFF, 4);
-
- AddrDesc = PCI_Read_CFG_Reg (BusDevFunc,
- PCI_CFG_BASE_ADDRESS_0 + (4*AddrSlot),
- 4);
-
- if (AddrDesc == 0) /* unimplemented, stop looking */
- continue; /* 01/04/99 MCG */
-
-#ifdef DEBUG
- printf("Read Base Addr Reg %d = 0x%08lx\n",AddrSlot,AddrDesc);
-#endif
-
- if ((AddrDesc & 1) == 1) { /* I/O space */
- AddrDesc &= 0xFFFFFFFC;
-
- for (i = 0; (AddrDesc & 1) != 1; i++)
- AddrDesc = AddrDesc >> 1;
-
- AddrDesc = 1 << i;
-#ifdef DEBUG
- printf(" PCI I/O space = 0x%lx bytes \n",AddrDesc);
-#endif
- for (AddrProg = CFG_PCI_PCI_IOADDR;
- AddrProg < LowestIOAddr;
- AddrProg += AddrDesc) {
- ; /* empty */
- }
-
- PCI_Write_CFG_Reg (BusDevFunc,
- PCI_CFG_BASE_ADDRESS_0 + (4*AddrSlot),
- AddrProg, 4);
- LowestIOAddr = AddrProg + AddrDesc;
- }
- else { /* memory space */
- AddrDesc &= 0xFFFFFFF0;
-
- for (i = 0; (AddrDesc & 1) != 1; i++)
- AddrDesc = AddrDesc >> 1;
-
- AddrDesc = 1 << i;
-
- if ((unsigned long)AddrDesc < 4096)
- AddrDesc = 4096;
-#ifdef DEBUG
- printf(" PCI Memory space = 0x%lx bytes \n",AddrDesc);
-#endif
- for (AddrProg = CFG_MIN_PCI_MEMADDR2;
- AddrProg < LowestMemAddr2;
- AddrProg += AddrDesc) {
- ; /* empty */
- }
-
- PCI_Write_CFG_Reg (BusDevFunc,
- PCI_CFG_BASE_ADDRESS_0 + (4*AddrSlot),
- AddrProg, 4);
- LowestMemAddr2 = AddrProg + AddrDesc;
- }
- }
-
- /*
- * Assign expansion ROM address
- */
- PCI_Write_CFG_Reg(BusDevFunc, PCI_CFG_EXPANSION_ROM, 0xFFFFFFFE, 4);
-
- AddrDesc = PCI_Read_CFG_Reg(BusDevFunc, PCI_CFG_EXPANSION_ROM, 4);
-
- if (AddrDesc != 0) {
-#ifdef DEBUG
- printf("Read Expansion ROM Addr Reg = 0x%08lx\n" , AddrDesc);
-#endif
- for (i = 0; (AddrDesc & 1) != 1; i++)
- AddrDesc = AddrDesc >> 1;
-
- AddrDesc = 1 << i;
-#ifdef DEBUG
- printf(" PCI Expansion ROM space = 0x%lx bytes\n", AddrDesc);
-#endif
- for (AddrProg = CFG_MIN_PCI_MEMADDR2;
- AddrProg < LowestMemAddr2;
- AddrProg += AddrDesc) {
- ; /* empty */
- }
- PCI_Write_CFG_Reg(BusDevFunc, PCI_CFG_EXPANSION_ROM, AddrProg, 4);
-#ifdef DEBUG
- printf(" PCI Expansion ROM addr = 0x%lx\n", AddrProg);
-#endif
- LowestMemAddr2 = AddrProg + AddrDesc;
- }
-
- Min_Gnt_Val = 0x80;
- PCI_Write_CFG_Reg(BusDevFunc, PCI_CFG_LATENCY_TIMER, Min_Gnt_Val, 1);
-
- /*
- * Disable interrupt line, if device says it wants to use interrupts
- */
- if (PCI_Read_CFG_Reg(BusDevFunc, PCI_CFG_DEV_INT_PIN, 1) != 0)
- PCI_Write_CFG_Reg(BusDevFunc, PCI_CFG_DEV_INT_LINE, 0xFF, 1);
-
- /*
- * Enable i/o space, memory space and master on this device
- */
- PCI_Write_CFG_Reg (BusDevFunc, PCI_CFG_COMMAND,
- pcicmd | PCI_CMD_MEMEN | PCI_CMD_IOEN, 2);
-}
-
/*
* Subroutine: PCI_Config_Bridge
*