diff options
author | Greg Watson <jarrah@users.sourceforge.net> | 2003-10-12 19:07:39 +0000 |
---|---|---|
committer | Greg Watson <jarrah@users.sourceforge.net> | 2003-10-12 19:07:39 +0000 |
commit | 079d53232bfe7b6543c9efdeb19f9f96c5e5831d (patch) | |
tree | 3d5df196e3b7fde8a0341cfb688d9cd07f184b7f /src | |
parent | 47e64e8bed9aed42897f0290bcd711deff65971e (diff) |
get pci ops right
git-svn-id: svn://svn.coreboot.org/coreboot/trunk@1202 2b7e53f0-3cfb-0310-b3e9-8179ed1497e1
Diffstat (limited to 'src')
-rw-r--r-- | src/arch/ppc/lib/pci_ops.c | 78 |
1 files changed, 32 insertions, 46 deletions
diff --git a/src/arch/ppc/lib/pci_ops.c b/src/arch/ppc/lib/pci_ops.c index ecbbe8bb0b..69f34e8fc9 100644 --- a/src/arch/ppc/lib/pci_ops.c +++ b/src/arch/ppc/lib/pci_ops.c @@ -17,43 +17,8 @@ struct pci_ops { struct pci_ops pci_direct_ppc; -static unsigned __pci_config_read_32(unsigned address) -{ - out_le32((unsigned *)PCIC0_CFGADDR, address); - return in_le32((unsigned *)PCIC0_CFGDATA); -} - -static unsigned __pci_config_read_16(unsigned address) -{ - out_le32((unsigned *)PCIC0_CFGADDR, address); - return in_le16((unsigned short *)PCIC0_CFGDATA); -} - -static unsigned __pci_config_read_8(unsigned address) -{ - out_le32((unsigned *)PCIC0_CFGADDR, address); - return in_8((unsigned char *)PCIC0_CFGDATA); -} - -static void __pci_config_write_32(unsigned address, unsigned data) -{ - out_le32((unsigned *)PCIC0_CFGADDR, address); - out_le32((unsigned *)PCIC0_CFGDATA, data); -} - -static void __pci_config_write_16(unsigned address, unsigned short data) -{ - out_le32((unsigned *)PCIC0_CFGADDR, address); - out_le16((unsigned short *)PCIC0_CFGDATA, data); -} - -static void __pci_config_write_8(unsigned address, unsigned char data) -{ - out_le32((unsigned *)PCIC0_CFGADDR, address); - out_8((unsigned char *)PCIC0_CFGDATA, data); -} - -#define CONFIG_CMD(bus,devfn,where) (bus << 16 | devfn << 8 | where | 0x80000000) +#define CONFIG_CMD(bus,devfn,where) \ + ((bus << 16) | (devfn << 8) | (where & ~3) | 0x80000000) /* * Direct access to PCI hardware... @@ -138,35 +103,56 @@ void pci_set_method(void) static uint8_t pci_ppc_read_config8(unsigned char bus, int devfn, int where) { - return (uint8_t)__pci_config_read_8(CONFIG_CMD(bus, devfn, where)); + uint8_t res; + + out_le32((unsigned *)PCIC0_CFGADDR, CONFIG_CMD(bus, devfn, where)); + res = in_8((unsigned char *)PCIC0_CFGDATA + (where & 3)); + printk_spew("read8(0x%x,0x%x,0x%x)=0x%x\n", bus, devfn, where, res); + return res; } static uint16_t pci_ppc_read_config16(unsigned char bus, int devfn, int where) { - return (uint16_t)__pci_config_read_16(CONFIG_CMD(bus, devfn, where)); + uint16_t res; + + out_le32((unsigned *)PCIC0_CFGADDR, CONFIG_CMD(bus, devfn, where)); + res = in_le16((unsigned short *)PCIC0_CFGDATA + (where & 2)); + printk_spew("read16(0x%x,0x%x,0x%x)=0x%x\n", bus, devfn, where, res); + return res; } static uint32_t pci_ppc_read_config32(unsigned char bus, int devfn, int where) { - return (uint32_t)__pci_config_read_32(CONFIG_CMD(bus, devfn, where)); + uint32_t res; + + out_le32((unsigned *)PCIC0_CFGADDR, CONFIG_CMD(bus, devfn, where)); + res = in_le32((unsigned *)PCIC0_CFGDATA); + printk_spew("read32(0x%x,0x%x,0x%x)=0x%x\n", bus, devfn, where, res); + return res; } static int pci_ppc_write_config8(unsigned char bus, int devfn, int where, uint8_t data) { - __pci_config_write_8(CONFIG_CMD(bus, devfn, where), data); - return 0; + out_le32((unsigned *)PCIC0_CFGADDR, CONFIG_CMD(bus, devfn, where)); + out_8((unsigned char *)PCIC0_CFGDATA + (where & 3), data); + printk_spew("write8(0x%x,0x%x,0x%x)<-0x%x\n", bus, devfn, where, data); + return 0; } static int pci_ppc_write_config16(unsigned char bus, int devfn, int where, uint16_t data) { - __pci_config_write_16(CONFIG_CMD(bus, devfn, where), data); - return 0; + out_le32((unsigned *)PCIC0_CFGADDR, CONFIG_CMD(bus, devfn, where)); + out_le16((unsigned short *)PCIC0_CFGDATA + (where & 2), data); + printk_spew("write16(0x%x,0x%x,0x%x)<-0x%x\n", bus, devfn, where, data); + return 0; } static int pci_ppc_write_config32(unsigned char bus, int devfn, int where, uint32_t data) { - __pci_config_write_32(CONFIG_CMD(bus, devfn, where), data); - return 0; + out_le32((unsigned *)PCIC0_CFGADDR, CONFIG_CMD(bus, devfn, where)); + out_le32((unsigned *)PCIC0_CFGDATA, data); + printk_spew("write32(0x%x,0x%x,0x%x)<-0x%x\n", bus, devfn, where, data); + return 0; } struct pci_ops pci_direct_ppc = |