pci_ops_conf1.c

Go to the documentation of this file.
00001 #include <console/console.h>
00002 #include <arch/io.h>
00003 #include <arch/pciconf.h>
00004 #include <device/pci.h>
00005 #include <device/pci_ids.h>
00006 #include <device/pci_ops.h>
00007 /*
00008  * Functions for accessing PCI configuration space with type 1 accesses
00009  */
00010 
00011 #if PCI_IO_CFG_EXT == 0
00012 #define CONFIG_CMD(bus,devfn, where)   (0x80000000 | (bus << 16) | (devfn << 8) | (where & ~3))
00013 #else
00014 #define CONFIG_CMD(bus,devfn, where)   (0x80000000 | (bus << 16) | (devfn << 8) | ((where & 0xff) & ~3) | ((where & 0xf00)<<16) )
00015 #endif
00016 
00017 static uint8_t pci_conf1_read_config8(struct bus *pbus, int bus, int devfn, int where)
00018 {
00019                 outl(CONFIG_CMD(bus, devfn, where), 0xCF8);
00020                 return inb(0xCFC + (where & 3));
00021 }
00022 
00023 static uint16_t pci_conf1_read_config16(struct bus *pbus, int bus, int devfn, int where)
00024 {
00025                 outl(CONFIG_CMD(bus, devfn, where), 0xCF8);
00026                 return inw(0xCFC + (where & 2));
00027 }
00028 
00029 static uint32_t pci_conf1_read_config32(struct bus *pbus, int bus, int devfn, int where)
00030 {
00031                 outl(CONFIG_CMD(bus, devfn, where), 0xCF8);
00032                 return inl(0xCFC);
00033 }
00034 
00035 static void  pci_conf1_write_config8(struct bus *pbus, int bus, int devfn, int where, uint8_t value)
00036 {
00037                 outl(CONFIG_CMD(bus, devfn, where), 0xCF8);
00038                 outb(value, 0xCFC + (where & 3));
00039 }
00040 
00041 static void pci_conf1_write_config16(struct bus *pbus, int bus, int devfn, int where, uint16_t value)
00042 {
00043                 outl(CONFIG_CMD(bus, devfn, where), 0xCF8);
00044                 outw(value, 0xCFC + (where & 2));
00045 }
00046 
00047 static void pci_conf1_write_config32(struct bus *pbus, int bus, int devfn, int where, uint32_t value)
00048 {
00049                 outl(CONFIG_CMD(bus, devfn, where), 0xCF8);
00050                 outl(value, 0xCFC);
00051 }
00052 
00053 #undef CONFIG_CMD
00054 
00055 const struct pci_bus_operations pci_cf8_conf1 =
00056 {
00057         .read8  = pci_conf1_read_config8,
00058         .read16 = pci_conf1_read_config16,
00059         .read32 = pci_conf1_read_config32,
00060         .write8  = pci_conf1_write_config8,
00061         .write16 = pci_conf1_write_config16,
00062         .write32 = pci_conf1_write_config32,
00063 };

Generated on Wed Jan 7 14:14:21 2009 for coreboot by  doxygen 1.5.5