Ignore:
Timestamp:
Mar 3, 2011, 8:59:04 PM (14 years ago)
Author:
David Azarewicz
Message:

interrupt fixes

File:
1 edited

Legend:

Unmodified
Added
Removed
  • GPL/branches/uniaud32-2.1.x/lib32/pci.c

    r536 r546  
    135135//******************************************************************************
    136136//******************************************************************************
    137 #ifdef ACPI
    138 struct SaveIRQForSlot
    139 {
    140         ULONG  ulSlotNo;
    141         BYTE   LowIRQ;
    142         BYTE   HighIRQ;
    143         BYTE   Pin;
    144 };
    145 extern struct SaveIRQForSlot sISRHigh[];
    146 extern int      SaveIRQCounter;
    147 #endif
    148 
    149137//Find the next matching PCI device starting with the device specified by pcidev
    150138static ULONG pci_query_device(const struct pci_device_id *id_table, struct pci_dev near *pcidev, ULONG ulLast)
    151139{
    152140        int             resNo, addr;
    153         u32 devNr, busNr, funcNr, detectedId, cfgaddrreg, temp, temp2;
     141        u32 devNr, busNr, funcNr, detectedId, cfgaddrreg, ulPciAdr, ulTmp1, ulTmp2;
    154142#ifdef ACPI
    155143        APIRET                   rc;
    156         ULONG                    temp1,temp3; //PS++
     144        ULONG                    PicIRQ, ApicIRQ;
    157145#endif
    158146        u8              headerType;
     
    168156                        for(;funcNr<8;funcNr++) {
    169157                                headerType = 0;
    170                                 temp = PCI_CONFIG_ENABLE | (busNr<<16) | (devNr<<11) | (funcNr<<8);
    171                                 outl(temp, PCI_CONFIG_ADDRESS);
     158                                ulPciAdr = PCI_CONFIG_ENABLE | (busNr<<16) | (devNr<<11) | (funcNr<<8);
     159                                outl(ulPciAdr, PCI_CONFIG_ADDRESS);
    172160                                detectedId = inl(PCI_CONFIG_DATA);
    173161
     
    177165                                }
    178166
    179                                 outl(temp + PCI_CLASS_REVISION, PCI_CONFIG_ADDRESS);
    180                                 temp2 = inl(PCI_CONFIG_DATA) >> 8; /* get class */
    181 
    182                                 //dprintf(("det=%x(%x) %x need=%x%x %x", detectedId, headerType, temp2, id_table->device&0xffff, id_table->vendor, id_table->class));
     167                                outl(ulPciAdr + PCI_CLASS_REVISION, PCI_CONFIG_ADDRESS);
     168                                ulTmp2 = inl(PCI_CONFIG_DATA) >> 8; /* get class */
     169
     170                                //dprintf(("det=%x(%x) %x need=%x%x %x", detectedId, headerType, ulTmp2, id_table->device&0xffff, id_table->vendor, id_table->class));
    183171
    184172                                if ( id_table->class ) {
    185                                         if ( (temp2 & id_table->class_mask) != id_table->class ) continue;
     173                                        if ( (ulTmp2 & id_table->class_mask) != id_table->class ) continue;
    186174                                } else {
    187                                         if ( (id_table->device == PCI_ANY_ID) && ((temp2 >> 8) != PCI_CLASS_MULTIMEDIA_AUDIO) ) continue;
     175                                        if ( (id_table->device == PCI_ANY_ID) && ((ulTmp2 >> 8) != PCI_CLASS_MULTIMEDIA_AUDIO) ) continue;
    188176                                }
    189177
     
    191179                                if ( (id_table->device != PCI_ANY_ID) && (id_table->device != (detectedId >> 16)) ) continue;
    192180
    193                                 outl(temp | (PCI_HEADER_TYPE & ~3), PCI_CONFIG_ADDRESS);
     181                                outl(ulPciAdr | (PCI_HEADER_TYPE & ~3), PCI_CONFIG_ADDRESS);
    194182                                headerType = inb(PCI_CONFIG_DATA + (PCI_HEADER_TYPE & 3));
    195183
     
    224212                                resNo = 0;
    225213                                for( addr = PCI_BASE_ADDRESS_0; addr <= PCI_BASE_ADDRESS_5; addr += 4 ) {
    226                                         pci_read_config_dword(pcidev, addr, &temp);
    227                                         if( temp != 0 && temp != 0xffffffff ) {
     214                                        pci_read_config_dword(pcidev, addr, &ulTmp1);
     215                                        if( ulTmp1 != 0 && ulTmp1 != 0xffffffff ) {
    228216                                                pci_write_config_dword(pcidev, addr, 0xffffffff);
    229                                                 pci_read_config_dword(pcidev, addr, &temp2);
    230                                                 pci_write_config_dword(pcidev, addr, temp);
    231 
    232                                                 if( temp & PCI_BASE_ADDRESS_SPACE_IO ) {
     217                                                pci_read_config_dword(pcidev, addr, &ulTmp2);
     218                                                pci_write_config_dword(pcidev, addr, ulTmp1);
     219
     220                                                if( ulTmp1 & PCI_BASE_ADDRESS_SPACE_IO ) {
    233221                                                        pcidev->resource[resNo].flags = IORESOURCE_IO | PCI_BASE_ADDRESS_SPACE_IO;
    234                                                         pcidev->resource[resNo].start = temp & PCI_BASE_ADDRESS_IO_MASK;
     222                                                        pcidev->resource[resNo].start = ulTmp1 & PCI_BASE_ADDRESS_IO_MASK;
    235223                                                        pcidev->resource[resNo].end   = pcidev->resource[resNo].start +
    236                                                                 ~(temp2 & PCI_BASE_ADDRESS_IO_MASK) + 1;
     224                                                                ~(ulTmp2 & PCI_BASE_ADDRESS_IO_MASK) + 1;
    237225                                                }
    238226                                                else
    239227                                                {
    240228                                                        pcidev->resource[resNo].flags = IORESOURCE_MEM | IORESOURCE_MEM_WRITEABLE;
    241                                                         pcidev->resource[resNo].start = temp & PCI_BASE_ADDRESS_MEM_MASK;
     229                                                        pcidev->resource[resNo].start = ulTmp1 & PCI_BASE_ADDRESS_MEM_MASK;
    242230                                                        pcidev->resource[resNo].end   = pcidev->resource[resNo].start +
    243                                                                 ~(temp2 & PCI_BASE_ADDRESS_MEM_MASK) + 1;
     231                                                                ~(ulTmp2 & PCI_BASE_ADDRESS_MEM_MASK) + 1;
    244232                                                }
    245233
    246234                                                resNo++;
    247 
    248235                                        }
    249236                                }
    250237
    251238                                // IRQ and PIN
    252                                 pci_read_config_dword(pcidev, PCI_INTERRUPT_LINE, &temp);
     239                                pci_read_config_dword(pcidev, PCI_INTERRUPT_LINE, &ulTmp1);
     240                                rprintf(("pci_query_device: PCI config IRQ=%d", ulTmp1&0xff));
    253241#ifdef ACPI
    254                                 sISRHigh[SaveIRQCounter].Pin  = (temp >> 8) & 0xf;
    255                                 temp2 = temp3 = 0;
    256242                                rc = ACPIFindPCIDevice( (ULONG)busNr,                                            // Bus
    257243                                                                                (ULONG)devNr,                                            // Dev
    258244                                                                                (ULONG)(pcidev->devfn >> 8) & 7,         // Function
    259                                                                                 &temp1,                                                          // PIC IRQ
    260                                                                                 &temp3,                                                          // APIC IRQ
     245                                                                                &PicIRQ,                                                         // PIC IRQ
     246                                                                                &ApicIRQ,                                                        // APIC IRQ
    261247                                                                                NULL,                                                            // ACPI handle to finding device
    262248                                                                                "Uniaud32");                                             // Name for acpi log
    263249                                if (!rc) {
    264250                                        // Check APIC IRQ, if we have /SMP /APIC, must be set
    265                                         if (temp1) temp = (temp & (~0xff)) | (temp1 & 0xff);
    266                                         // Check PIC IRQ
    267                                         else if (temp3) temp = (temp & (~0xff)) | (temp3 & 0xff);
    268                                         dprintf(("pci_query_device: IRQs ACPI PIC%d APIC%d", temp1, temp3));
    269                                         sISRHigh[SaveIRQCounter].LowIRQ  = temp1;
    270                                         sISRHigh[SaveIRQCounter].HighIRQ = temp3;
     251                                        if (ApicIRQ) ulTmp1 = (ulTmp1 & (~0xff)) | (ApicIRQ & 0xff);
     252                                        else if (PicIRQ) ulTmp1 = (ulTmp1 & (~0xff)) | (PicIRQ & 0xff);
     253                                        rprintf(("pci_query_device: IRQs ACPI PIC=%ld APIC=%ld chosen=%d", PicIRQ, ApicIRQ, ulTmp1&0xff));
    271254                                }
    272255#endif /* ACPI */
    273                                 if( (u8)temp && (u8)temp != 0xff ) {
     256                                if( (u8)ulTmp1 && (u8)ulTmp1 != 0xff ) {
    274257                                        pcidev->irq_resource[0].flags = IORESOURCE_IRQ;
    275                                         pcidev->irq_resource[0].start = pcidev->irq_resource[0].end   = temp & 0xffff;
    276                                         pcidev->irq = (u8)temp;
     258                                        pcidev->irq_resource[0].start = pcidev->irq_resource[0].end   = ulTmp1 & 0xffff;
     259                                        pcidev->irq = (u8)ulTmp1;
    277260                                }
    278261
     
    990973}
    991974
     975void PciAdjustInterrupts() {
     976        int i;
     977        struct pci_dev *pcidev;
     978        struct pci_driver *driver;
     979        ULONG PicIRQ, ApicIRQ, ulTmp1, rc;
     980
     981        for (i=0; i<MAX_PCI_DEVICES; i++) {
     982                if (!pci_devices[i].devfn) continue;
     983                pcidev = &pci_devices[i];
     984                rc = ACPIFindPCIDevice( pcidev->bus->number,                             // Bus
     985                                                                PCI_SLOT(pcidev->devfn),                         // Dev
     986                                                                PCI_FUNC(pcidev->devfn),                         // Function
     987                                                                &PicIRQ,                                                         // PIC IRQ
     988                                                                &ApicIRQ,                                                        // APIC IRQ
     989                                                                NULL,                                                            // ACPI handle to finding device
     990                                                                "Uniaud32");                                             // Name for acpi log
     991                if (!rc) {
     992                        ulTmp1 = 0;
     993                        // Check APIC IRQ, if we have /SMP /APIC, must be set
     994                        if (ApicIRQ) ulTmp1 = (ulTmp1 & (~0xff)) | (ApicIRQ & 0xff);
     995                        else if (PicIRQ) ulTmp1 = (ulTmp1 & (~0xff)) | (PicIRQ & 0xff);
     996                        rprintf(("PciAdjustInterrupts: IRQs ACPI PIC=%ld APIC=%ld was=%d chosen=%ld", PicIRQ, ApicIRQ, pcidev->irq, ulTmp1));
     997                        if( (u8)ulTmp1 && ((u8)ulTmp1 != 0xff) && ((u8)ulTmp1 != pcidev->irq) ) {
     998                                driver = pcidev->pcidriver;
     999                                if(driver && driver->suspend) driver->suspend(pcidev, SNDRV_CTL_POWER_D0);
     1000
     1001                                pcidev->irq_resource[0].flags = IORESOURCE_IRQ;
     1002                                pcidev->irq_resource[0].start = pcidev->irq_resource[0].end   = ulTmp1 & 0xffff;
     1003                                pcidev->irq = (u8)ulTmp1;
     1004
     1005                                if(driver && driver->resume) driver->resume(pcidev);
     1006                        }
     1007                }
     1008        } /* for loop */
     1009}
Note: See TracChangeset for help on using the changeset viewer.