pci-direct.h 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. #ifndef ASM_PCI_DIRECT_H
  2. #define ASM_PCI_DIRECT_H 1
  3. #include <linux/types.h>
  4. #include <asm/io.h>
  5. /* Direct PCI access. This is used for PCI accesses in early boot before
  6. the PCI subsystem works. */
  7. #define PDprintk(x...)
  8. static inline u32 read_pci_config(u8 bus, u8 slot, u8 func, u8 offset)
  9. {
  10. u32 v;
  11. outl(0x80000000 | (bus<<16) | (slot<<11) | (func<<8) | offset, 0xcf8);
  12. v = inl(0xcfc);
  13. if (v != 0xffffffff)
  14. PDprintk("%x reading 4 from %x: %x\n", slot, offset, v);
  15. return v;
  16. }
  17. static inline u8 read_pci_config_byte(u8 bus, u8 slot, u8 func, u8 offset)
  18. {
  19. u8 v;
  20. outl(0x80000000 | (bus<<16) | (slot<<11) | (func<<8) | offset, 0xcf8);
  21. v = inb(0xcfc + (offset&3));
  22. PDprintk("%x reading 1 from %x: %x\n", slot, offset, v);
  23. return v;
  24. }
  25. static inline u16 read_pci_config_16(u8 bus, u8 slot, u8 func, u8 offset)
  26. {
  27. u16 v;
  28. outl(0x80000000 | (bus<<16) | (slot<<11) | (func<<8) | offset, 0xcf8);
  29. v = inw(0xcfc + (offset&2));
  30. PDprintk("%x reading 2 from %x: %x\n", slot, offset, v);
  31. return v;
  32. }
  33. static inline void write_pci_config(u8 bus, u8 slot, u8 func, u8 offset,
  34. u32 val)
  35. {
  36. PDprintk("%x writing to %x: %x\n", slot, offset, val);
  37. outl(0x80000000 | (bus<<16) | (slot<<11) | (func<<8) | offset, 0xcf8);
  38. outl(val, 0xcfc);
  39. }
  40. #endif