Use pci_arch_t also on Sparc64 (but disable PCI probing for now, hangs)

git-svn-id: svn://coreboot.org/openbios/openbios-devel@270 f158a5a8-5612-0410-a976-696ce0be7e32
This commit is contained in:
Blue Swirl
2008-11-29 13:18:32 +00:00
parent f34790fc87
commit f446864114
7 changed files with 83 additions and 40 deletions

View File

@@ -1,22 +1,26 @@
#ifndef _H_PCI
#define _H_PCI
typedef uint32_t pci_addr;
typedef struct pci_arch_t pci_arch_t;
struct pci_arch_t {
char * name;
uint16_t vendor_id;
uint16_t device_id;
uint32_t cfg_addr;
uint32_t cfg_data;
uint32_t cfg_base;
uint32_t cfg_len;
uint32_t mem_base;
uint32_t mem_len;
uint32_t io_base;
uint32_t io_len;
uint32_t rbase;
uint32_t rlen;
const char * name;
uint16_t vendor_id;
uint16_t device_id;
unsigned long cfg_addr;
unsigned long cfg_data;
unsigned long cfg_base;
unsigned long cfg_len;
unsigned long mem_base;
unsigned long mem_len;
unsigned long io_base;
unsigned long io_len;
unsigned long rbase;
unsigned long rlen;
};
extern pci_arch_t *arch;
#endif /* _H_PCI */

View File

@@ -3,7 +3,7 @@
#include "asm/io.h"
#if !(PCI_CONFIG_1 || PCI_CONFIG_2)
#if !(defined(PCI_CONFIG_1) || defined(PCI_CONFIG_2))
#define PCI_CONFIG_1 1 /* default */
#endif
@@ -11,8 +11,6 @@
/* PCI Configuration Mechanism #1 */
extern pci_arch_t *arch;
#define PCI_ADDR(bus, dev, fn) \
((pci_addr) (arch->cfg_base \
| (uint32_t) (bus) << 16 \

View File

@@ -11,10 +11,8 @@
/* PCI Configuration Mechanism #1 */
/* Have pci_addr in the same format as the values written to 0xcf8
* so register accesses can be made easy. */
#define PCI_ADDR(bus, dev, fn) \
((pci_addr) (0x80000000u \
((pci_addr) (arch->cfg_base \
| (uint32_t) (bus) << 16 \
| (uint32_t) (dev) << 11 \
| (uint32_t) (fn) << 8))
@@ -23,46 +21,47 @@
#define PCI_DEV(pcidev) ((uint8_t) ((pcidev) >> 11) & 0x1f)
#define PCI_FN(pcidev) ((uint8_t) ((pcidev) >> 8) & 7)
#define APB_SPECIAL_BASE 0x1fe00000000ULL
#define PCI_CONFIG (APB_SPECIAL_BASE + 0x1000000ULL)
#define APB_MEM_BASE 0x1ff00000000ULL
static inline uint8_t pci_config_read8(pci_addr dev, uint8_t reg)
{
out_le32((void *)PCI_CONFIG, dev | (reg & ~3));
return in_8((void *)(APB_MEM_BASE | (reg & 3)));
uint8_t res;
out_le32((unsigned *)arch->cfg_addr, dev | (reg & ~3));
res = in_8((unsigned char*)(arch->cfg_data + (reg & 3)));
return res;
}
static inline uint16_t pci_config_read16(pci_addr dev, uint8_t reg)
{
out_le32((void *)PCI_CONFIG, dev | (reg & ~3));
return in_le16((void *)(APB_MEM_BASE | (reg & 2)));
uint16_t res;
out_le32((unsigned *)arch->cfg_addr, dev | (reg & ~3));
res = in_le16((unsigned short*)(arch->cfg_data + (reg & 2)));
return res;
}
static inline uint32_t pci_config_read32(pci_addr dev, uint8_t reg)
{
out_le32((void *)PCI_CONFIG, dev | reg);
return in_le32((void *)(APB_MEM_BASE | reg));
uint32_t res;
out_le32((unsigned *)arch->cfg_addr, dev | reg);
res = in_le32((unsigned *)(arch->cfg_data + reg));
return res;
}
static inline void pci_config_write8(pci_addr dev, uint8_t reg, uint8_t val)
{
out_le32((void *)PCI_CONFIG, dev | (reg & ~3));
out_8((void *)(APB_MEM_BASE | (reg & 3)), val);
out_le32((unsigned *)arch->cfg_addr, dev | (reg & ~3));
out_8((unsigned char*)(arch->cfg_data + (reg & 3)), val);
}
static inline void pci_config_write16(pci_addr dev, uint8_t reg, uint16_t val)
{
out_le32((void *)PCI_CONFIG, dev | (reg & ~3));
out_le16((void *)(APB_MEM_BASE | (reg & 2)), val);
out_le32((unsigned *)arch->cfg_addr, dev | (reg & ~3));
out_le16((unsigned short *)(arch->cfg_data + (reg & 2)), val);
}
static inline void pci_config_write32(pci_addr dev, uint8_t reg, uint32_t val)
{
out_le32((void *)PCI_CONFIG, dev | reg);
out_le32((void *)(APB_MEM_BASE | reg), val);
out_le32((unsigned *)arch->cfg_addr, dev | reg);
out_le32((unsigned *)(arch->cfg_data + reg), val);
}
#else /* !PCI_CONFIG_1 */
#error PCI Configuration Mechanism is not specified or implemented
#endif