2
* pci.c - Low-Level PCI Access in IA-64
4
* Derived from bios32.c of i386 tree.
6
* (c) Copyright 2002, 2005 Hewlett-Packard Development Company, L.P.
7
* David Mosberger-Tang <davidm@hpl.hp.com>
8
* Bjorn Helgaas <bjorn.helgaas@hp.com>
9
* Copyright (C) 2004 Silicon Graphics, Inc.
11
* Note: Above list of copyright holders is incomplete...
15
#include <xen/pci_regs.h>
16
#include <xen/spinlock.h>
20
#include <asm/hw_irq.h>
23
* Low-level SAL-based PCI configuration access functions. Note that SAL
24
* calls are already serialized (via sal_lock), so we don't need another
25
* synchronization mechanism here.
28
#define PCI_SAL_ADDRESS(seg, bus, devfn, reg) \
29
(((u64) seg << 24) | (bus << 16) | (devfn << 8) | (reg))
31
/* SAL 3.2 adds support for extended config space. */
33
#define PCI_SAL_EXT_ADDRESS(seg, bus, devfn, reg) \
34
(((u64) seg << 28) | (bus << 20) | (devfn << 12) | (reg))
37
pci_sal_read (unsigned int seg, unsigned int bus, unsigned int devfn,
38
int reg, int len, u32 *value)
43
if (!value || (seg > 65535) || (bus > 255) || (devfn > 255) || (reg > 4095))
46
if ((seg | reg) <= 255) {
47
addr = PCI_SAL_ADDRESS(seg, bus, devfn, reg);
50
addr = PCI_SAL_EXT_ADDRESS(seg, bus, devfn, reg);
53
result = ia64_sal_pci_config_read(addr, mode, len, &data);
62
pci_sal_write (unsigned int seg, unsigned int bus, unsigned int devfn,
63
int reg, int len, u32 value)
68
if ((seg > 65535) || (bus > 255) || (devfn > 255) || (reg > 4095))
71
if ((seg | reg) <= 255) {
72
addr = PCI_SAL_ADDRESS(seg, bus, devfn, reg);
75
addr = PCI_SAL_EXT_ADDRESS(seg, bus, devfn, reg);
78
result = ia64_sal_pci_config_write(addr, mode, len, value);
85
uint8_t pci_conf_read8(
86
unsigned int bus, unsigned int dev, unsigned int func, unsigned int reg)
89
BUG_ON((bus > 255) || (dev > 31) || (func > 7) || (reg > 255));
90
pci_sal_read(0, bus, (dev<<3)|func, reg, 1, &value);
91
return (uint8_t)value;
94
uint16_t pci_conf_read16(
95
unsigned int bus, unsigned int dev, unsigned int func, unsigned int reg)
98
BUG_ON((bus > 255) || (dev > 31) || (func > 7) || (reg > 255));
99
pci_sal_read(0, bus, (dev<<3)|func, reg, 2, &value);
100
return (uint16_t)value;
103
uint32_t pci_conf_read32(
104
unsigned int bus, unsigned int dev, unsigned int func, unsigned int reg)
107
BUG_ON((bus > 255) || (dev > 31) || (func > 7) || (reg > 255));
108
pci_sal_read(0, bus, (dev<<3)|func, reg, 4, &value);
109
return (uint32_t)value;
112
void pci_conf_write8(
113
unsigned int bus, unsigned int dev, unsigned int func, unsigned int reg,
116
BUG_ON((bus > 255) || (dev > 31) || (func > 7) || (reg > 255));
117
pci_sal_write(0, bus, (dev<<3)|func, reg, 1, data);
120
void pci_conf_write16(
121
unsigned int bus, unsigned int dev, unsigned int func, unsigned int reg,
124
BUG_ON((bus > 255) || (dev > 31) || (func > 7) || (reg > 255));
125
pci_sal_write(0, bus, (dev<<3)|func, reg, 2, data);
128
void pci_conf_write32(
129
unsigned int bus, unsigned int dev, unsigned int func, unsigned int reg,
132
BUG_ON((bus > 255) || (dev > 31) || (func > 7) || (reg > 255));
133
pci_sal_write(0, bus, (dev<<3)|func, reg, 4, data);
136
int pci_find_ext_capability(int seg, int bus, int devfn, int cap)