[18] | 1 | /* $Id: pci.c,v 1.1.1.1 2003/07/02 13:57:02 eleph Exp $ */
|
---|
| 2 | /*
|
---|
| 3 | * OS/2 implementation of Linux PCI functions (using direct port I/O)
|
---|
| 4 | *
|
---|
| 5 | * (C) 2000-2002 InnoTek Systemberatung GmbH
|
---|
| 6 | * (C) 2000-2001 Sander van Leeuwen (sandervl@xs4all.nl)
|
---|
| 7 | *
|
---|
| 8 | * Parts based on Linux kernel sources
|
---|
| 9 | *
|
---|
| 10 | * This program is free software; you can redistribute it and/or
|
---|
| 11 | * modify it under the terms of the GNU General Public License as
|
---|
| 12 | * published by the Free Software Foundation; either version 2 of
|
---|
| 13 | * the License, or (at your option) any later version.
|
---|
| 14 | *
|
---|
| 15 | * This program is distributed in the hope that it will be useful,
|
---|
| 16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
| 17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
| 18 | * GNU General Public License for more details.
|
---|
| 19 | *
|
---|
| 20 | * You should have received a copy of the GNU General Public
|
---|
| 21 | * License along with this program; if not, write to the Free
|
---|
| 22 | * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139,
|
---|
| 23 | * USA.
|
---|
| 24 | *
|
---|
| 25 | */
|
---|
| 26 |
|
---|
| 27 | #include "linux.h"
|
---|
| 28 | #include <linux/init.h>
|
---|
| 29 | #include <linux/poll.h>
|
---|
| 30 | #include <asm/uaccess.h>
|
---|
| 31 | #include <asm/hardirq.h>
|
---|
| 32 | #include <asm/io.h>
|
---|
| 33 | #include <sound/config.h>
|
---|
| 34 | #include <sound/asound.h>
|
---|
| 35 |
|
---|
| 36 | #define LINUX
|
---|
| 37 | #include <ossidc.h>
|
---|
| 38 | #include <stacktoflat.h>
|
---|
| 39 | #include <dbgos2.h>
|
---|
| 40 | #include <osspci.h>
|
---|
| 41 |
|
---|
| 42 | struct pci_dev pci_devices[MAX_PCI_DEVICES] = {0};
|
---|
| 43 | struct pci_bus pci_busses[MAX_PCI_BUSSES] = {0};
|
---|
| 44 |
|
---|
| 45 | HRESMGR hResMgr = 0;
|
---|
| 46 |
|
---|
| 47 | BOOL fSuspended = FALSE;
|
---|
| 48 | extern int nrCardsDetected;
|
---|
| 49 | //******************************************************************************
|
---|
| 50 | //******************************************************************************
|
---|
| 51 | OSSRET OSS32_APMResume()
|
---|
| 52 | {
|
---|
| 53 | int i;
|
---|
| 54 | struct pci_driver *driver;
|
---|
| 55 |
|
---|
| 56 | dprintf(("OSS32_APMResume"));
|
---|
| 57 | for(i=0;i<MAX_PCI_DEVICES;i++)
|
---|
| 58 | {
|
---|
| 59 | if(pci_devices[i].devfn)
|
---|
| 60 | {
|
---|
| 61 | driver = pci_devices[i].pcidriver;
|
---|
| 62 | if(driver && driver->resume) {
|
---|
| 63 | driver->resume(&pci_devices[i]);
|
---|
| 64 | fSuspended = FALSE;
|
---|
| 65 | }
|
---|
| 66 | }
|
---|
| 67 | }
|
---|
| 68 | fSuspended = FALSE;
|
---|
| 69 | return OSSERR_SUCCESS;
|
---|
| 70 | }
|
---|
| 71 | //******************************************************************************
|
---|
| 72 | //******************************************************************************
|
---|
| 73 | OSSRET OSS32_APMSuspend()
|
---|
| 74 | {
|
---|
| 75 | int i;
|
---|
| 76 | struct pci_driver *driver;
|
---|
| 77 |
|
---|
| 78 | dprintf(("OSS32_APMSuspend"));
|
---|
| 79 | fSuspended = TRUE;
|
---|
| 80 | for(i=0;i<MAX_PCI_DEVICES;i++)
|
---|
| 81 | {
|
---|
| 82 | if(pci_devices[i].devfn)
|
---|
| 83 | {
|
---|
| 84 | driver = pci_devices[i].pcidriver;
|
---|
| 85 | if(driver && driver->suspend) {
|
---|
| 86 | driver->suspend(&pci_devices[i], SNDRV_CTL_POWER_D3cold);
|
---|
| 87 | }
|
---|
| 88 | }
|
---|
| 89 | }
|
---|
| 90 | return OSSERR_SUCCESS;
|
---|
| 91 | }
|
---|
| 92 | //******************************************************************************
|
---|
| 93 | //******************************************************************************
|
---|
| 94 | int pcidev_prepare(struct pci_dev *dev)
|
---|
| 95 | {
|
---|
| 96 | dprintf(("pcidev_prepare %x not implemented", dev));
|
---|
| 97 | return 1; //todo: correct return value??
|
---|
| 98 | }
|
---|
| 99 | //******************************************************************************
|
---|
| 100 | //******************************************************************************
|
---|
| 101 | int pcidev_activate(struct pci_dev *dev)
|
---|
| 102 | {
|
---|
| 103 | dprintf(("pcidev_activate %x not implemented", dev));
|
---|
| 104 | return 1; //todo: correct return value??
|
---|
| 105 | }
|
---|
| 106 | //******************************************************************************
|
---|
| 107 | //******************************************************************************
|
---|
| 108 | int pcidev_deactivate(struct pci_dev *dev)
|
---|
| 109 | {
|
---|
| 110 | dprintf(("pcidev_deactivate %x not implemented", dev));
|
---|
| 111 | return 1; //todo: correct return value??
|
---|
| 112 | }
|
---|
| 113 |
|
---|
| 114 | #define PCI_CONFIG_ENABLE 0x80000000
|
---|
| 115 | #define PCI_CONFIG_ADDRESS 0xCF8
|
---|
| 116 | #define PCI_CONFIG_DATA 0xCFC
|
---|
| 117 | /*
|
---|
| 118 | * get number of devices of given PCIID
|
---|
| 119 | */
|
---|
| 120 | int pci_get_dev_num(ULONG pciId)
|
---|
| 121 | {
|
---|
| 122 | ULONG devNr, busNr, funcNr, temp, cfgaddrreg, detectedId;
|
---|
| 123 | int found = 0;
|
---|
| 124 |
|
---|
| 125 | cfgaddrreg = inl(PCI_CONFIG_ADDRESS);
|
---|
| 126 | for(busNr=0;busNr<MAX_PCI_BUSSES;busNr++) //BusNumber<255
|
---|
| 127 | {
|
---|
| 128 | for(devNr=0;devNr<32;devNr++)
|
---|
| 129 | {
|
---|
| 130 | for(funcNr=0;funcNr<8;funcNr++)
|
---|
| 131 | {
|
---|
| 132 | temp = ((ULONG)((ULONG)devNr<<11UL) + ((ULONG)busNr<<16UL) + ((ULONG)funcNr << 8UL));
|
---|
| 133 |
|
---|
| 134 | outl(PCI_CONFIG_ENABLE|temp, PCI_CONFIG_ADDRESS);
|
---|
| 135 | detectedId = inl(PCI_CONFIG_DATA);
|
---|
| 136 | // printk("det: %x, need: %x\n", detectedId, pciId);
|
---|
| 137 | if(detectedId == pciId)
|
---|
| 138 | found++;
|
---|
| 139 | }
|
---|
| 140 | }
|
---|
| 141 | }
|
---|
| 142 |
|
---|
| 143 | if(!found) {
|
---|
| 144 | outl(cfgaddrreg, PCI_CONFIG_ADDRESS);
|
---|
| 145 | return 0;
|
---|
| 146 | }
|
---|
| 147 | return found;
|
---|
| 148 | }
|
---|
| 149 | //******************************************************************************
|
---|
| 150 | //TODO: Doesn't completely fill in the pci_dev structure
|
---|
| 151 | //******************************************************************************
|
---|
| 152 | int FindPCIDevice(unsigned int vendor, unsigned int device, struct pci_dev near *pcidev, int idx)
|
---|
| 153 | {
|
---|
| 154 | IDC_RESOURCE idcres;
|
---|
| 155 | int i, residx = 0;
|
---|
| 156 |
|
---|
| 157 | pcidev->prepare = pcidev_prepare;
|
---|
| 158 | pcidev->activate = pcidev_activate;
|
---|
| 159 | pcidev->deactivate = pcidev_deactivate;
|
---|
| 160 | pcidev->active = 1;
|
---|
| 161 | pcidev->ro = 0;
|
---|
| 162 | pcidev->sibling = NULL;
|
---|
| 163 | pcidev->next = NULL;
|
---|
| 164 | pcidev->vendor = vendor;
|
---|
| 165 | pcidev->device = device;
|
---|
| 166 | pcidev->dma_mask = 0xFFFFFFFF;
|
---|
| 167 |
|
---|
| 168 |
|
---|
| 169 | // printk("FindPCIDevice vend: %x, id: %x\n",vendor, device);
|
---|
| 170 | hResMgr = 0;
|
---|
| 171 | hResMgr = RMFindPCIDevice(vendor, device, &idcres, idx);
|
---|
| 172 | if(hResMgr == 0) {
|
---|
| 173 | return FALSE;
|
---|
| 174 | }
|
---|
| 175 | pcidev->devfn = idcres.devfn;
|
---|
| 176 | //pcidev->devfn = idcres.devfn + 1;
|
---|
| 177 |
|
---|
| 178 | for(i=0;i<MAX_RES_IO;i++) {
|
---|
| 179 | if(idcres.io[i] != 0xffff) {
|
---|
| 180 | pcidev->resource[residx].name = 0;
|
---|
| 181 | pcidev->resource[residx].child = 0;
|
---|
| 182 | pcidev->resource[residx].sibling = 0;
|
---|
| 183 | pcidev->resource[residx].parent = 0;
|
---|
| 184 | pcidev->resource[residx].start = idcres.io[i];
|
---|
| 185 | pcidev->resource[residx].end = idcres.io[i] + idcres.iolength[i]; //inclusive??
|
---|
| 186 | pcidev->resource[residx].flags = IORESOURCE_IO | PCI_BASE_ADDRESS_SPACE_IO;
|
---|
| 187 |
|
---|
| 188 | residx++;
|
---|
| 189 | }
|
---|
| 190 | }
|
---|
| 191 | for(i=0;i<MAX_RES_MEM;i++) {
|
---|
| 192 | if(idcres.mem[i] != 0xffffffff) {
|
---|
| 193 | pcidev->resource[residx].name = 0;
|
---|
| 194 | pcidev->resource[residx].child = 0;
|
---|
| 195 | pcidev->resource[residx].sibling = 0;
|
---|
| 196 | pcidev->resource[residx].parent = 0;
|
---|
| 197 | pcidev->resource[residx].start = idcres.mem[i];
|
---|
| 198 | pcidev->resource[residx].end = idcres.mem[i] + idcres.memlength[i]; //inclusive??
|
---|
| 199 | pcidev->resource[residx].flags = IORESOURCE_MEM | IORESOURCE_MEM_WRITEABLE;
|
---|
| 200 | printk("residx: %i start: %x\n", residx, pcidev->resource[residx].start);
|
---|
| 201 | residx++;
|
---|
| 202 | }
|
---|
| 203 | }
|
---|
| 204 | for(i=0;i<MAX_RES_DMA;i++) {
|
---|
| 205 | if(idcres.dma[i] != 0xffff) {
|
---|
| 206 | pcidev->dma_resource[i].name = 0;
|
---|
| 207 | pcidev->dma_resource[i].child = 0;
|
---|
| 208 | pcidev->dma_resource[i].sibling = 0;
|
---|
| 209 | pcidev->dma_resource[i].parent = 0;
|
---|
| 210 | pcidev->dma_resource[i].start = idcres.dma[i];
|
---|
| 211 | pcidev->dma_resource[i].end = idcres.dma[i];
|
---|
| 212 | //todo: 8/16 bits
|
---|
| 213 | pcidev->dma_resource[i].flags = IORESOURCE_DMA;
|
---|
| 214 | }
|
---|
| 215 | }
|
---|
| 216 | for(i=0;i<MAX_RES_IRQ;i++) {
|
---|
| 217 | if(idcres.irq[i] != 0xffff) {
|
---|
| 218 | pcidev->irq_resource[i].name = 0;
|
---|
| 219 | pcidev->irq_resource[i].child = 0;
|
---|
| 220 | pcidev->irq_resource[i].sibling = 0;
|
---|
| 221 | pcidev->irq_resource[i].parent = 0;
|
---|
| 222 | pcidev->irq_resource[i].start = idcres.irq[i];
|
---|
| 223 | pcidev->irq_resource[i].end = idcres.irq[i];
|
---|
| 224 | //todo: irq flags
|
---|
| 225 | pcidev->irq_resource[9].flags = IORESOURCE_IRQ;
|
---|
| 226 | }
|
---|
| 227 | }
|
---|
| 228 | if(pcidev->irq_resource[0].start != 0xffff) {
|
---|
| 229 | pcidev->irq = pcidev->irq_resource[0].start;
|
---|
| 230 | }
|
---|
| 231 | else pcidev->irq = 0;
|
---|
| 232 |
|
---|
| 233 | if(idcres.busnr > MAX_PCI_BUSSES) {
|
---|
| 234 | DebugInt3();
|
---|
| 235 | return FALSE;
|
---|
| 236 | }
|
---|
| 237 | pcidev->bus = &pci_busses[idcres.busnr];
|
---|
| 238 | pcidev->bus->number = idcres.busnr;
|
---|
| 239 |
|
---|
| 240 | pci_read_config_word(pcidev, PCI_SUBSYSTEM_VENDOR_ID, &pcidev->subsystem_vendor);
|
---|
| 241 | pci_read_config_word(pcidev, PCI_SUBSYSTEM_ID, &pcidev->subsystem_device);
|
---|
| 242 |
|
---|
| 243 | return TRUE;
|
---|
| 244 | }
|
---|
| 245 | //******************************************************************************
|
---|
| 246 | //******************************************************************************
|
---|
| 247 | struct pci_dev *pci_find_device (unsigned int vendor, unsigned int device, struct pci_dev *from)
|
---|
| 248 | {
|
---|
| 249 | int i, idx;
|
---|
| 250 | HRESMGR hResMgrTmp = 0;
|
---|
| 251 |
|
---|
| 252 | if((int)from < 8) {
|
---|
| 253 | idx = (int)from; // dirty hack
|
---|
| 254 | // return 0;
|
---|
| 255 | } else
|
---|
| 256 | idx = 0;
|
---|
| 257 | // printk("searching device. vendor %x, pci id %x, idx %i\n",vendor,device, idx);
|
---|
| 258 | //not very pretty
|
---|
| 259 | if(hResMgr) {
|
---|
| 260 | hResMgrTmp = hResMgr;
|
---|
| 261 | hResMgr = 0;
|
---|
| 262 | }
|
---|
| 263 | for(i=0;i<MAX_PCI_DEVICES;i++)
|
---|
| 264 | {
|
---|
| 265 | if(pci_devices[i].devfn == 0)
|
---|
| 266 | {
|
---|
| 267 | if(FindPCIDevice(vendor, device, (struct pci_dev near *)&pci_devices[i], idx) == TRUE) {
|
---|
| 268 | if(hResMgrTmp) {
|
---|
| 269 | RMDestroy(hResMgr);
|
---|
| 270 | hResMgr = hResMgrTmp;
|
---|
| 271 | }
|
---|
| 272 | // pci_read_config_dword(&pci_devices[i], PCI_CLASS_REVISION, &pci_devices[i]._class);
|
---|
| 273 | // if (((pci_devices[i]._class >> 8) & 0xffff) == PCI_CLASS_MULTIMEDIA_AUDIO)
|
---|
| 274 | return &pci_devices[i];
|
---|
| 275 | }
|
---|
| 276 | #ifdef DEBUG
|
---|
| 277 | printk("wrong device. vendor %x, pci id %x\n",vendor,device);
|
---|
| 278 | #endif
|
---|
| 279 | break;
|
---|
| 280 | }
|
---|
| 281 | }
|
---|
| 282 | if(hResMgrTmp) {
|
---|
| 283 | RMDestroy(hResMgr);
|
---|
| 284 | hResMgr = hResMgrTmp;
|
---|
| 285 | }
|
---|
| 286 | return 0;
|
---|
| 287 | }
|
---|
| 288 | //******************************************************************************
|
---|
| 289 | //******************************************************************************
|
---|
| 290 | struct resource * __request_region(struct resource *a, unsigned long start, unsigned long n, const char *name)
|
---|
| 291 | {
|
---|
| 292 | struct resource *resource;
|
---|
| 293 |
|
---|
| 294 | if(a->flags & IORESOURCE_MEM) {
|
---|
| 295 | if(RMRequestMem(hResMgr, start, n) == FALSE) {
|
---|
| 296 | printk("RMRequestIO failed for io %x, length %x\n", start, n);
|
---|
| 297 | return NULL;
|
---|
| 298 | }
|
---|
| 299 | }
|
---|
| 300 | else
|
---|
| 301 | if(a->flags & IORESOURCE_IO) {
|
---|
| 302 | if(RMRequestIO(hResMgr, start, n) == FALSE) {
|
---|
| 303 | printk("RMRequestIO failed for io %x, length %x\n", start, n);
|
---|
| 304 | return NULL;
|
---|
| 305 | }
|
---|
| 306 | }
|
---|
| 307 |
|
---|
| 308 | resource = kmalloc(sizeof(struct resource), GFP_KERNEL);
|
---|
| 309 | if (resource == NULL)
|
---|
| 310 | return NULL;
|
---|
| 311 | resource->name = name;
|
---|
| 312 | resource->start = start;
|
---|
| 313 | resource->end = start + n - 1;
|
---|
| 314 | resource->flags = a->flags;
|
---|
| 315 | return resource;
|
---|
| 316 | }
|
---|
| 317 | //******************************************************************************
|
---|
| 318 | //******************************************************************************
|
---|
| 319 | void __release_region(struct resource *resource, unsigned long b, unsigned long c)
|
---|
| 320 | {
|
---|
| 321 | if(resource) {
|
---|
| 322 | kfree(resource);
|
---|
| 323 | }
|
---|
| 324 | }
|
---|
| 325 | //******************************************************************************
|
---|
| 326 | //******************************************************************************
|
---|
| 327 | int pci_get_flags (struct pci_dev *dev, int n_base)
|
---|
| 328 | {
|
---|
| 329 | if(n_base >= DEVICE_COUNT_RESOURCE || !dev->resource[n_base].flags) {
|
---|
| 330 | DebugInt3();
|
---|
| 331 | return 0;
|
---|
| 332 | }
|
---|
| 333 | return dev->resource[n_base].flags;
|
---|
| 334 | }
|
---|
| 335 | //******************************************************************************
|
---|
| 336 | #define CONFIG_CMD(dev, where) (0x80000000 | (dev->bus->number << 16) | (dev->devfn << 8) | (where & ~3))
|
---|
| 337 | //******************************************************************************
|
---|
| 338 | int pci_read_config_byte(struct pci_dev *dev, int where, u8 *value)
|
---|
| 339 | {
|
---|
| 340 | outl(CONFIG_CMD(dev,where), 0xCF8);
|
---|
| 341 | *value = inb(0xCFC + (where&3));
|
---|
| 342 | return PCIBIOS_SUCCESSFUL;
|
---|
| 343 | }
|
---|
| 344 | //******************************************************************************
|
---|
| 345 | //******************************************************************************
|
---|
| 346 | int pci_read_config_word(struct pci_dev *dev, int where, u16 *value)
|
---|
| 347 | {
|
---|
| 348 | outl(CONFIG_CMD(dev,where), 0xCF8);
|
---|
| 349 | *value = inw(0xCFC + (where&2));
|
---|
| 350 | return PCIBIOS_SUCCESSFUL;
|
---|
| 351 | }
|
---|
| 352 | //******************************************************************************
|
---|
| 353 | //******************************************************************************
|
---|
| 354 | int pci_read_config_dword(struct pci_dev *dev, int where, u32 *value)
|
---|
| 355 | {
|
---|
| 356 | outl(CONFIG_CMD(dev,where), 0xCF8);
|
---|
| 357 | *value = inl(0xCFC);
|
---|
| 358 | return PCIBIOS_SUCCESSFUL;
|
---|
| 359 | }
|
---|
| 360 | //******************************************************************************
|
---|
| 361 | //******************************************************************************
|
---|
| 362 | int pci_write_config_byte(struct pci_dev *dev, int where, u8 value)
|
---|
| 363 | {
|
---|
| 364 | outl(CONFIG_CMD(dev,where), 0xCF8);
|
---|
| 365 | outb(value, 0xCFC + (where&3));
|
---|
| 366 | return PCIBIOS_SUCCESSFUL;
|
---|
| 367 | }
|
---|
| 368 | //******************************************************************************
|
---|
| 369 | //******************************************************************************
|
---|
| 370 | int pci_write_config_word(struct pci_dev *dev, int where, u16 value)
|
---|
| 371 | {
|
---|
| 372 | outl(CONFIG_CMD(dev,where), 0xCF8);
|
---|
| 373 | outw(value, 0xCFC + (where&2));
|
---|
| 374 | return PCIBIOS_SUCCESSFUL;
|
---|
| 375 | }
|
---|
| 376 | //******************************************************************************
|
---|
| 377 | //******************************************************************************
|
---|
| 378 | int pci_write_config_dword(struct pci_dev *dev, int where, u32 value)
|
---|
| 379 | {
|
---|
| 380 | outl(CONFIG_CMD(dev,where), 0xCF8);
|
---|
| 381 | outl(value, 0xCFC);
|
---|
| 382 | return PCIBIOS_SUCCESSFUL;
|
---|
| 383 | }
|
---|
| 384 | //******************************************************************************
|
---|
| 385 | //******************************************************************************
|
---|
| 386 | int pcibios_present(void)
|
---|
| 387 | {
|
---|
| 388 | printk("pcibios_present -> pretend BIOS present\n");
|
---|
| 389 | return 1;
|
---|
| 390 | }
|
---|
| 391 | //******************************************************************************
|
---|
| 392 | //******************************************************************************
|
---|
| 393 | struct pci_dev *pci_find_slot (unsigned int bus, unsigned int devfn)
|
---|
| 394 | {
|
---|
| 395 | printk("pci_find_slot %d %x not implemented!!\n", bus, devfn);
|
---|
| 396 | DebugInt3();
|
---|
| 397 | return NULL;
|
---|
| 398 | }
|
---|
| 399 | //******************************************************************************
|
---|
| 400 | //******************************************************************************
|
---|
| 401 | int pci_dma_supported(struct pci_dev *dev, unsigned long mask)
|
---|
| 402 | {
|
---|
| 403 | printk("pci_dma_supported: return TRUE\n");
|
---|
| 404 | return 1;
|
---|
| 405 | }
|
---|
| 406 | //******************************************************************************
|
---|
| 407 | //******************************************************************************
|
---|
| 408 | int pci_find_capability(struct pci_dev *dev, int cap)
|
---|
| 409 | {
|
---|
| 410 | u16 status;
|
---|
| 411 | u8 pos, id;
|
---|
| 412 | int ttl = 48;
|
---|
| 413 |
|
---|
| 414 | pci_read_config_word(dev, PCI_STATUS, &status);
|
---|
| 415 | if (!(status & PCI_STATUS_CAP_LIST))
|
---|
| 416 | return 0;
|
---|
| 417 | pci_read_config_byte(dev, PCI_CAPABILITY_LIST, &pos);
|
---|
| 418 | while (ttl-- && pos >= 0x40) {
|
---|
| 419 | pos &= ~3;
|
---|
| 420 | pci_read_config_byte(dev, pos + PCI_CAP_LIST_ID, &id);
|
---|
| 421 | if (id == 0xff)
|
---|
| 422 | break;
|
---|
| 423 | if (id == cap)
|
---|
| 424 | return pos;
|
---|
| 425 | pci_read_config_byte(dev, pos + PCI_CAP_LIST_NEXT, &pos);
|
---|
| 426 | }
|
---|
| 427 | return 0;
|
---|
| 428 | }
|
---|
| 429 | //******************************************************************************
|
---|
| 430 | /*
|
---|
| 431 | * Set power management state of a device. For transitions from state D3
|
---|
| 432 | * it isn't as straightforward as one could assume since many devices forget
|
---|
| 433 | * their configuration space during wakeup. Returns old power state.
|
---|
| 434 | */
|
---|
| 435 | //******************************************************************************
|
---|
| 436 | int pci_set_power_state(struct pci_dev *dev, int new_state)
|
---|
| 437 | {
|
---|
| 438 | u32 base[5], romaddr;
|
---|
| 439 | u16 pci_command, pwr_command;
|
---|
| 440 | u8 pci_latency, pci_cacheline;
|
---|
| 441 | int i, old_state;
|
---|
| 442 | int pm = pci_find_capability(dev, PCI_CAP_ID_PM);
|
---|
| 443 |
|
---|
| 444 | if (!pm)
|
---|
| 445 | return 0;
|
---|
| 446 | pci_read_config_word(dev, pm + PCI_PM_CTRL, &pwr_command);
|
---|
| 447 | old_state = pwr_command & PCI_PM_CTRL_STATE_MASK;
|
---|
| 448 | if (old_state == new_state)
|
---|
| 449 | return old_state;
|
---|
| 450 | if (old_state == 3) {
|
---|
| 451 | pci_read_config_word(dev, PCI_COMMAND, &pci_command);
|
---|
| 452 | pci_write_config_word(dev, PCI_COMMAND, pci_command & ~(PCI_COMMAND_IO | PCI_COMMAND_MEMORY));
|
---|
| 453 | for (i = 0; i < 5; i++)
|
---|
| 454 | pci_read_config_dword(dev, PCI_BASE_ADDRESS_0 + i*4, &base[i]);
|
---|
| 455 | pci_read_config_dword(dev, PCI_ROM_ADDRESS, &romaddr);
|
---|
| 456 | pci_read_config_byte(dev, PCI_LATENCY_TIMER, &pci_latency);
|
---|
| 457 | pci_read_config_byte(dev, PCI_CACHE_LINE_SIZE, &pci_cacheline);
|
---|
| 458 | pci_write_config_word(dev, pm + PCI_PM_CTRL, new_state);
|
---|
| 459 | for (i = 0; i < 5; i++)
|
---|
| 460 | pci_write_config_dword(dev, PCI_BASE_ADDRESS_0 + i*4, base[i]);
|
---|
| 461 | pci_write_config_dword(dev, PCI_ROM_ADDRESS, romaddr);
|
---|
| 462 | pci_write_config_byte(dev, PCI_INTERRUPT_LINE, dev->irq);
|
---|
| 463 | pci_write_config_byte(dev, PCI_CACHE_LINE_SIZE, pci_cacheline);
|
---|
| 464 | pci_write_config_byte(dev, PCI_LATENCY_TIMER, pci_latency);
|
---|
| 465 | pci_write_config_word(dev, PCI_COMMAND, pci_command);
|
---|
| 466 | } else
|
---|
| 467 | pci_write_config_word(dev, pm + PCI_PM_CTRL, (pwr_command & ~PCI_PM_CTRL_STATE_MASK) | new_state);
|
---|
| 468 | return old_state;
|
---|
| 469 | }
|
---|
| 470 | //******************************************************************************
|
---|
| 471 | /*
|
---|
| 472 | * Initialize device before it's used by a driver. Ask low-level code
|
---|
| 473 | * to enable I/O and memory. Wake up the device if it was suspended.
|
---|
| 474 | * Beware, this function can fail.
|
---|
| 475 | */
|
---|
| 476 | //******************************************************************************
|
---|
| 477 | int pci_enable_device(struct pci_dev *dev)
|
---|
| 478 | {
|
---|
| 479 | u16 pci_command;
|
---|
| 480 |
|
---|
| 481 | printk("pci_enable_device %x\n", dev);
|
---|
| 482 |
|
---|
| 483 | pci_read_config_word(dev, PCI_COMMAND, &pci_command);
|
---|
| 484 | pci_write_config_word(dev, PCI_COMMAND, pci_command | (PCI_COMMAND_IO | PCI_COMMAND_MEMORY));
|
---|
| 485 | pci_set_power_state(dev, 0);
|
---|
| 486 | return 0;
|
---|
| 487 | }
|
---|
| 488 | //******************************************************************************
|
---|
| 489 | //******************************************************************************
|
---|
| 490 | int pci_register_driver(struct pci_driver *driver)
|
---|
| 491 | {
|
---|
| 492 | struct pci_dev *pcidev = NULL;
|
---|
| 493 | int i = 0, j;
|
---|
| 494 | int dev_num;
|
---|
| 495 | ULONG pcidevid;
|
---|
| 496 |
|
---|
| 497 | while(driver->id_table[i].vendor)
|
---|
| 498 | {
|
---|
| 499 | pcidevid = ((ULONG)driver->id_table[i].device << 16) |
|
---|
| 500 | (ULONG)driver->id_table[i].vendor;
|
---|
| 501 | dev_num = pci_get_dev_num(pcidevid);
|
---|
| 502 |
|
---|
| 503 | if (dev_num) {
|
---|
| 504 | printk("found: %i number of %x, id: %x\n",dev_num,driver->id_table[i].vendor, driver->id_table[i].device);
|
---|
| 505 |
|
---|
| 506 | for (j=0; j < dev_num; j++) // dirty hack for multiply cards with same PCIID
|
---|
| 507 | {
|
---|
| 508 | pcidev = pci_find_device(driver->id_table[i].vendor, driver->id_table[i].device, (struct pci_dev *)j);
|
---|
| 509 | // printk("checking pci vend: %x, id: %x %i\n",driver->id_table[i].vendor, driver->id_table[i].device, i);
|
---|
| 510 | #ifdef DEBUG
|
---|
| 511 | // dprintf(("checked device: vendor %x, pci id %x, pcidev %x, probe %x",
|
---|
| 512 | // driver->id_table[i].vendor,driver->id_table[i].device, pcidev, driver->probe));
|
---|
| 513 | #endif
|
---|
| 514 | if(pcidev && driver->probe) {
|
---|
| 515 | printk("found: %x, id: %x idx %i\n",driver->id_table[i].vendor, driver->id_table[i].device, j);
|
---|
| 516 |
|
---|
| 517 | if(driver->probe(pcidev, &driver->id_table[i]) == 0) {
|
---|
| 518 | //remove resource manager object for this device and
|
---|
| 519 | //register resources with RM
|
---|
| 520 | RMFinialize(hResMgr);
|
---|
| 521 | hResMgr = 0;
|
---|
| 522 |
|
---|
| 523 | //save driver pointer for suspend/resume calls
|
---|
| 524 | pcidev->pcidriver = (void *)driver;
|
---|
| 525 | pcidev->current_state = 4;
|
---|
| 526 | //return 1;
|
---|
| 527 | }
|
---|
| 528 | else pcidev->devfn = NULL;
|
---|
| 529 |
|
---|
| 530 | RMDestroy(hResMgr);
|
---|
| 531 | hResMgr = 0;
|
---|
| 532 | }
|
---|
| 533 | } // for j
|
---|
| 534 | return dev_num;
|
---|
| 535 | }
|
---|
| 536 | i++;
|
---|
| 537 | }
|
---|
| 538 | return 0;
|
---|
| 539 | }
|
---|
| 540 | //******************************************************************************
|
---|
| 541 | //******************************************************************************
|
---|
| 542 | int pci_module_init(struct pci_driver *drv)
|
---|
| 543 | {
|
---|
| 544 | int res = pci_register_driver(drv);
|
---|
| 545 | if (res < 0)
|
---|
| 546 | return res;
|
---|
| 547 | if (res == 0)
|
---|
| 548 | return -ENODEV;
|
---|
| 549 | nrCardsDetected+=res;
|
---|
| 550 | return 0;
|
---|
| 551 | }
|
---|
| 552 | //******************************************************************************
|
---|
| 553 | //******************************************************************************
|
---|
| 554 | int pci_unregister_driver(struct pci_driver *driver)
|
---|
| 555 | {
|
---|
| 556 | struct pci_dev *pcidev;
|
---|
| 557 | int i = 0, j;
|
---|
| 558 |
|
---|
| 559 | while(driver->id_table[i].vendor)
|
---|
| 560 | {
|
---|
| 561 | for(j=0;j<MAX_PCI_DEVICES;j++)
|
---|
| 562 | {
|
---|
| 563 | if(pci_devices[j].vendor == driver->id_table[i].vendor &&
|
---|
| 564 | pci_devices[j].device == driver->id_table[i].device)
|
---|
| 565 | {
|
---|
| 566 | if(driver->remove) {
|
---|
| 567 | driver->remove(&pci_devices[j]);
|
---|
| 568 | }
|
---|
| 569 | }
|
---|
| 570 | }
|
---|
| 571 | i++;
|
---|
| 572 | }
|
---|
| 573 | return 0;
|
---|
| 574 | }
|
---|
| 575 | //******************************************************************************
|
---|
| 576 | //******************************************************************************
|
---|
| 577 | void pci_set_master(struct pci_dev *dev)
|
---|
| 578 | {
|
---|
| 579 | u16 cmd;
|
---|
| 580 |
|
---|
| 581 | pci_read_config_word(dev, PCI_COMMAND, &cmd);
|
---|
| 582 | if (! (cmd & PCI_COMMAND_MASTER)) {
|
---|
| 583 | dprintf(("pci_set_master %x", dev));
|
---|
| 584 | cmd |= PCI_COMMAND_MASTER;
|
---|
| 585 | pci_write_config_word(dev, PCI_COMMAND, cmd);
|
---|
| 586 | }
|
---|
| 587 | return;
|
---|
| 588 | }
|
---|
| 589 | //******************************************************************************
|
---|
| 590 | // * Register a device with power management
|
---|
| 591 | //******************************************************************************
|
---|
| 592 | struct pm_dev *pm_register(pm_dev_t type, unsigned long id, pm_callback callback)
|
---|
| 593 | {
|
---|
| 594 | dprintf(("pm_register STUB"));
|
---|
| 595 | DebugInt3();
|
---|
| 596 | return NULL;
|
---|
| 597 | }
|
---|
| 598 | //******************************************************************************
|
---|
| 599 | // * Unregister a device with power management
|
---|
| 600 | //******************************************************************************
|
---|
| 601 | void pm_unregister(struct pm_dev *dev)
|
---|
| 602 | {
|
---|
| 603 | dprintf(("pm_unregister STUB"));
|
---|
| 604 | }
|
---|
| 605 | //******************************************************************************
|
---|
| 606 | //******************************************************************************
|
---|
| 607 | int __compat_get_order(unsigned long size)
|
---|
| 608 | {
|
---|
| 609 | int order;
|
---|
| 610 |
|
---|
| 611 | size = (size-1) >> (PAGE_SHIFT-1);
|
---|
| 612 | order = -1;
|
---|
| 613 | do {
|
---|
| 614 | size >>= 1;
|
---|
| 615 | order++;
|
---|
| 616 | } while (size);
|
---|
| 617 | return order;
|
---|
| 618 | }
|
---|
| 619 | //******************************************************************************
|
---|
| 620 | //******************************************************************************
|
---|
| 621 | void *pci_alloc_consistent(struct pci_dev *hwdev,
|
---|
| 622 | long size, dma_addr_t *dma_handle)
|
---|
| 623 | {
|
---|
| 624 | void *ret = NULL;
|
---|
| 625 | int gfp = GFP_ATOMIC;
|
---|
| 626 | int order;
|
---|
| 627 | #ifdef DEBUG
|
---|
| 628 | dprintf(("pci_alloc_consistent %d mask %x", size, (hwdev) ? hwdev->dma_mask : 0));
|
---|
| 629 | #endif
|
---|
| 630 | if (hwdev == NULL || hwdev->dma_mask != 0xffffffff) {
|
---|
| 631 | //try not to exhaust low memory (< 16mb) so allocate from the high region first
|
---|
| 632 | //if that doesn't satisfy the dma mask requirement, then get it from the low
|
---|
| 633 | //regino anyway
|
---|
| 634 | if(hwdev->dma_mask > 0x00ffffff) {
|
---|
| 635 | order = __compat_get_order(size);
|
---|
| 636 | ret = (void *)__get_free_pages(gfp|GFP_DMAHIGHMEM, order);
|
---|
| 637 | *dma_handle = virt_to_bus(ret);
|
---|
| 638 | if(*dma_handle > hwdev->dma_mask) {
|
---|
| 639 | free_pages((unsigned long)ret, __compat_get_order(size));
|
---|
| 640 | //be sure and allocate below 16 mb
|
---|
| 641 | gfp |= GFP_DMA;
|
---|
| 642 | ret = NULL;
|
---|
| 643 | }
|
---|
| 644 | }
|
---|
| 645 | else { //must always allocate below 16 mb
|
---|
| 646 | gfp |= GFP_DMA;
|
---|
| 647 | }
|
---|
| 648 | }
|
---|
| 649 | if(ret == NULL) {
|
---|
| 650 | ret = (void *)__get_free_pages(gfp, __compat_get_order(size));
|
---|
| 651 | }
|
---|
| 652 |
|
---|
| 653 | if (ret != NULL) {
|
---|
| 654 | memset(ret, 0, size);
|
---|
| 655 | *dma_handle = virt_to_bus(ret);
|
---|
| 656 | }
|
---|
| 657 | return ret;
|
---|
| 658 | }
|
---|
| 659 | //******************************************************************************
|
---|
| 660 | //******************************************************************************
|
---|
| 661 | void pci_free_consistent(struct pci_dev *hwdev, long size,
|
---|
| 662 | void *vaddr, dma_addr_t dma_handle)
|
---|
| 663 | {
|
---|
| 664 | free_pages((unsigned long)vaddr, __compat_get_order(size));
|
---|
| 665 | }
|
---|
| 666 | //******************************************************************************
|
---|
| 667 | //******************************************************************************
|
---|
| 668 | void pci_set_driver_data (struct pci_dev *dev, void *driver_data)
|
---|
| 669 | {
|
---|
| 670 | if (dev)
|
---|
| 671 | dev->driver_data = driver_data;
|
---|
| 672 | }
|
---|
| 673 | //******************************************************************************
|
---|
| 674 | //******************************************************************************
|
---|
| 675 | void *pci_get_driver_data (struct pci_dev *dev)
|
---|
| 676 | {
|
---|
| 677 | if (dev)
|
---|
| 678 | return dev->driver_data;
|
---|
| 679 | return 0;
|
---|
| 680 | }
|
---|
| 681 | //******************************************************************************
|
---|
| 682 | //******************************************************************************
|
---|
| 683 | unsigned long pci_get_dma_mask (struct pci_dev *dev)
|
---|
| 684 | {
|
---|
| 685 | if (dev)
|
---|
| 686 | return dev->dma_mask;
|
---|
| 687 | return 0;
|
---|
| 688 | }
|
---|
| 689 | //******************************************************************************
|
---|
| 690 | //******************************************************************************
|
---|
| 691 | void pci_set_dma_mask (struct pci_dev *dev, unsigned long mask)
|
---|
| 692 | {
|
---|
| 693 | if (dev)
|
---|
| 694 | dev->dma_mask = mask;
|
---|
| 695 | }
|
---|
| 696 | //******************************************************************************
|
---|
| 697 | //******************************************************************************
|
---|
| 698 | int release_resource(struct resource *newres)
|
---|
| 699 | {
|
---|
| 700 | return 0;
|
---|
| 701 | }
|
---|
| 702 |
|
---|
| 703 | //******************************************************************************
|
---|
| 704 | //******************************************************************************
|
---|
| 705 | int pci_set_latency_time(struct pci_dev *dev, int latency)
|
---|
| 706 | {
|
---|
| 707 | pci_write_config_byte(dev, PCI_LATENCY_TIMER, latency);
|
---|
| 708 | return 0;
|
---|
| 709 | }
|
---|
| 710 |
|
---|
| 711 | //******************************************************************************
|
---|
| 712 | //******************************************************************************
|
---|
| 713 | /**
|
---|
| 714 | * pci_save_state - save the PCI configuration space of a device before suspending
|
---|
| 715 | * @dev: - PCI device that we're dealing with
|
---|
| 716 | * @buffer: - buffer to hold config space context
|
---|
| 717 | *
|
---|
| 718 | * @buffer must be large enough to hold the entire PCI 2.2 config space
|
---|
| 719 | * (>= 64 bytes).
|
---|
| 720 | */
|
---|
| 721 | int pci_orig_save_state(struct pci_dev *dev, u32 *buffer)
|
---|
| 722 | {
|
---|
| 723 | int i;
|
---|
| 724 | if (buffer) {
|
---|
| 725 | /* XXX: 100% dword access ok here? */
|
---|
| 726 | for (i = 0; i < 16; i++)
|
---|
| 727 | pci_read_config_dword(dev, i * 4,&buffer[i]);
|
---|
| 728 | }
|
---|
| 729 | return 0;
|
---|
| 730 | }
|
---|
| 731 |
|
---|
| 732 | /**
|
---|
| 733 | * pci_restore_state - Restore the saved state of a PCI device
|
---|
| 734 | * @dev: - PCI device that we're dealing with
|
---|
| 735 | * @buffer: - saved PCI config space
|
---|
| 736 | *
|
---|
| 737 | */
|
---|
| 738 | int
|
---|
| 739 | pci_orig_restore_state(struct pci_dev *dev, u32 *buffer)
|
---|
| 740 | {
|
---|
| 741 | int i;
|
---|
| 742 |
|
---|
| 743 | if (buffer) {
|
---|
| 744 | for (i = 0; i < 16; i++)
|
---|
| 745 | pci_write_config_dword(dev,i * 4, buffer[i]);
|
---|
| 746 | }
|
---|
| 747 | /*
|
---|
| 748 | * otherwise, write the context information we know from bootup.
|
---|
| 749 | * This works around a problem where warm-booting from Windows
|
---|
| 750 | * combined with a D3(hot)->D0 transition causes PCI config
|
---|
| 751 | * header data to be forgotten.
|
---|
| 752 | */
|
---|
| 753 | else {
|
---|
| 754 | for (i = 0; i < 6; i ++)
|
---|
| 755 | pci_write_config_dword(dev,
|
---|
| 756 | PCI_BASE_ADDRESS_0 + (i * 4),
|
---|
| 757 | dev->resource[i].start);
|
---|
| 758 | pci_write_config_byte(dev, PCI_INTERRUPT_LINE, dev->irq);
|
---|
| 759 | }
|
---|
| 760 | return 0;
|
---|
| 761 | }
|
---|
| 762 |
|
---|
| 763 | struct saved_config_tbl {
|
---|
| 764 | struct pci_dev *pci;
|
---|
| 765 | u32 config[16];
|
---|
| 766 | };
|
---|
| 767 | statuc struct saved_config_tbl saved_tbl[16];
|
---|
| 768 |
|
---|
| 769 | void pci_save_state(struct pci_dev *pci)
|
---|
| 770 | {
|
---|
| 771 | int i;
|
---|
| 772 | /* FIXME: mutex needed for race? */
|
---|
| 773 | for (i = 0; i < ARRAY_SIZE(saved_tbl); i++) {
|
---|
| 774 | if (! saved_tbl[i].pci) {
|
---|
| 775 | saved_tbl[i].pci = pci;
|
---|
| 776 | pci_orig_save_state(pci, saved_tbl[i].config);
|
---|
| 777 | return;
|
---|
| 778 | }
|
---|
| 779 | }
|
---|
| 780 | printk(KERN_DEBUG "snd: no pci config space found!\n");
|
---|
| 781 | }
|
---|
| 782 |
|
---|
| 783 | void pci_restore_state(struct pci_dev *pci)
|
---|
| 784 | {
|
---|
| 785 | int i;
|
---|
| 786 | /* FIXME: mutex needed for race? */
|
---|
| 787 | for (i = 0; i < ARRAY_SIZE(saved_tbl); i++) {
|
---|
| 788 | if (saved_tbl[i].pci == pci) {
|
---|
| 789 | saved_tbl[i].pci = NULL;
|
---|
| 790 | pci_orig_restore_state(pci, saved_tbl[i].config);
|
---|
| 791 | return;
|
---|
| 792 | }
|
---|
| 793 | }
|
---|
| 794 | printk(KERN_DEBUG "snd: no saved pci config!\n");
|
---|
| 795 | }
|
---|
| 796 |
|
---|
| 797 | void pci_disable_device(struct pci_dev *dev)
|
---|
| 798 | {
|
---|
| 799 | u16 pci_command;
|
---|
| 800 |
|
---|
| 801 | pci_read_config_word(dev, PCI_COMMAND, &pci_command);
|
---|
| 802 | if (pci_command & PCI_COMMAND_MASTER) {
|
---|
| 803 | pci_command &= ~PCI_COMMAND_MASTER;
|
---|
| 804 | pci_write_config_word(dev, PCI_COMMAND, pci_command);
|
---|
| 805 | }
|
---|
| 806 | }
|
---|
| 807 |
|
---|
| 808 | int pci_request_region(struct pci_dev *pdev, int bar, char *res_name)
|
---|
| 809 | {
|
---|
| 810 | int flags;
|
---|
| 811 |
|
---|
| 812 | if (pci_resource_len(pdev, bar) == 0)
|
---|
| 813 | return 0;
|
---|
| 814 | flags = pci_get_flags(pdev, bar);
|
---|
| 815 | if (flags & IORESOURCE_IO) {
|
---|
| 816 | if (check_region(pci_resource_start(pdev, bar), pci_resource_len(pdev, bar)))
|
---|
| 817 | goto err_out;
|
---|
| 818 | request_region(pci_resource_start(pdev, bar),
|
---|
| 819 | pci_resource_len(pdev, bar), res_name);
|
---|
| 820 | }
|
---|
| 821 | return 0;
|
---|
| 822 |
|
---|
| 823 | err_out:
|
---|
| 824 | printk(KERN_WARNING "PCI: Unable to reserve %s region #%d:%lx@%lx for device %s\n",
|
---|
| 825 | flags & IORESOURCE_IO ? "I/O" : "mem",
|
---|
| 826 | bar + 1, /* PCI BAR # */
|
---|
| 827 | pci_resource_len(pdev, bar), pci_resource_start(pdev, bar),
|
---|
| 828 | res_name);
|
---|
| 829 | return -EBUSY;
|
---|
| 830 | }
|
---|
| 831 |
|
---|
| 832 | void pci_release_region(struct pci_dev *pdev, int bar)
|
---|
| 833 | {
|
---|
| 834 | int flags;
|
---|
| 835 |
|
---|
| 836 | if (pci_resource_len(pdev, bar) == 0)
|
---|
| 837 | return;
|
---|
| 838 | flags = pci_get_flags(pdev, bar);
|
---|
| 839 | if (flags & IORESOURCE_IO) {
|
---|
| 840 | release_region(pci_resource_start(pdev, bar),
|
---|
| 841 | pci_resource_len(pdev, bar));
|
---|
| 842 | }
|
---|
| 843 | }
|
---|
| 844 |
|
---|
| 845 | int pci_request_regions(struct pci_dev *pdev, char *res_name)
|
---|
| 846 | {
|
---|
| 847 | int i;
|
---|
| 848 |
|
---|
| 849 | for (i = 0; i < 6; i++)
|
---|
| 850 | if (pci_request_region(pdev, i, res_name))
|
---|
| 851 | goto err;
|
---|
| 852 | return 0;
|
---|
| 853 | err:
|
---|
| 854 | while (--i >= 0)
|
---|
| 855 | pci_release_region(pdev, i);
|
---|
| 856 | return -EBUSY;
|
---|
| 857 | }
|
---|
| 858 |
|
---|
| 859 | void pci_release_regions(struct pci_dev *pdev)
|
---|
| 860 | {
|
---|
| 861 | int i;
|
---|
| 862 | for (i = 0; i < 6; i++)
|
---|
| 863 | pci_release_region(pdev, i);
|
---|
| 864 | }
|
---|
| 865 |
|
---|
| 866 | const struct pci_device_id * pci_match_device(const struct pci_device_id *ids, struct pci_dev *dev)
|
---|
| 867 | {
|
---|
| 868 | u16 subsystem_vendor, subsystem_device;
|
---|
| 869 |
|
---|
| 870 | pci_read_config_word(dev, PCI_SUBSYSTEM_VENDOR_ID, &subsystem_vendor);
|
---|
| 871 | pci_read_config_word(dev, PCI_SUBSYSTEM_ID, &subsystem_device);
|
---|
| 872 |
|
---|
| 873 | while (ids->vendor || ids->subvendor || ids->class_mask) {
|
---|
| 874 | if ((ids->vendor == PCI_ANY_ID || ids->vendor == dev->vendor) &&
|
---|
| 875 | (ids->device == PCI_ANY_ID || ids->device == dev->device) &&
|
---|
| 876 | (ids->subvendor == PCI_ANY_ID || ids->subvendor == subsystem_vendor) &&
|
---|
| 877 | (ids->subdevice == PCI_ANY_ID || ids->subdevice == subsystem_device) &&
|
---|
| 878 | !((ids->class ^ dev->_class) & ids->class_mask))
|
---|
| 879 | return ids;
|
---|
| 880 | ids++;
|
---|
| 881 | }
|
---|
| 882 | return NULL;
|
---|
| 883 | }
|
---|
| 884 |
|
---|
| 885 | int snd_pci_dev_present(const struct pci_device_id *ids)
|
---|
| 886 | {
|
---|
| 887 | while (ids->vendor || ids->subvendor) {
|
---|
| 888 | if (pci_find_device(ids->vendor, ids->subvendor, NULL))
|
---|
| 889 | return 1;
|
---|
| 890 | ids++;
|
---|
| 891 | }
|
---|
| 892 | return 0;
|
---|
| 893 | }
|
---|
| 894 |
|
---|