- Move the declaration of struct upa_ranges and the UPA_RANGE_* macros

from sys/sparc64/include/ofw_upa.h to sys/sparc64/pci/ofw_pci.h and
  rename them to struct ofw_pci_ranges and OFW_PCI_RANGE_* respectively.
  This ranges struct only applies to host-PCI bridges but no to other
  bridges found on UPA. At the same time it applies to all host-PCI
  bridges regardless of whether the interconnection bus is Fireplane/
  Safari, JBus or UPA.
- While here rename the PCI_CS_* macros in sys/sparc64/pci/ofw_pci.h
  to OFW_PCI_CS_* in order to be consistent and change this header to
  use uintXX_t instead of u_intXX_t.
This commit is contained in:
Marius Strobl 2005-12-03 19:52:20 +00:00
parent 8215781ba2
commit 58299dd09e
5 changed files with 36 additions and 54 deletions

View File

@ -46,27 +46,9 @@ struct upa_regs {
u_int32_t size_lo;
};
struct upa_ranges {
u_int32_t cspace;
u_int32_t child_hi;
u_int32_t child_lo;
u_int32_t phys_hi;
u_int32_t phys_lo;
u_int32_t size_hi;
u_int32_t size_lo;
};
#define UPA_REG_PHYS(r) \
(((u_int64_t)(r)->phys_hi << 32) | (u_int64_t)(r)->phys_lo)
#define UPA_REG_SIZE(r) \
(((u_int64_t)(r)->size_hi << 32) | (u_int64_t)(r)->size_lo)
#define UPA_RANGE_CHILD(r) \
(((u_int64_t)(r)->child_hi << 32) | (u_int64_t)(r)->child_lo)
#define UPA_RANGE_PHYS(r) \
(((u_int64_t)(r)->phys_hi << 32) | (u_int64_t)(r)->phys_lo)
#define UPA_RANGE_SIZE(r) \
(((u_int64_t)(r)->size_hi << 32) | (u_int64_t)(r)->size_lo)
#define UPA_RANGE_CS(r) (((r)->cspace >> 24) & 0x03)
#endif /* !_MACHINE_OFW_UPA_H_ */

View File

@ -46,27 +46,9 @@ struct upa_regs {
u_int32_t size_lo;
};
struct upa_ranges {
u_int32_t cspace;
u_int32_t child_hi;
u_int32_t child_lo;
u_int32_t phys_hi;
u_int32_t phys_lo;
u_int32_t size_hi;
u_int32_t size_lo;
};
#define UPA_REG_PHYS(r) \
(((u_int64_t)(r)->phys_hi << 32) | (u_int64_t)(r)->phys_lo)
#define UPA_REG_SIZE(r) \
(((u_int64_t)(r)->size_hi << 32) | (u_int64_t)(r)->size_lo)
#define UPA_RANGE_CHILD(r) \
(((u_int64_t)(r)->child_hi << 32) | (u_int64_t)(r)->child_lo)
#define UPA_RANGE_PHYS(r) \
(((u_int64_t)(r)->phys_hi << 32) | (u_int64_t)(r)->phys_lo)
#define UPA_RANGE_SIZE(r) \
(((u_int64_t)(r)->size_hi << 32) | (u_int64_t)(r)->size_lo)
#define UPA_RANGE_CS(r) (((r)->cspace >> 24) & 0x03)
#endif /* !_MACHINE_OFW_UPA_H_ */

View File

@ -57,9 +57,9 @@ ofw_isa_range_restype(struct isa_ranges *range)
int ps = ISA_RANGE_PS(range);
switch (ps) {
case PCI_CS_IO:
case OFW_PCI_CS_IO:
return (SYS_RES_IOPORT);
case PCI_CS_MEM32:
case OFW_PCI_CS_MEM32:
return (SYS_RES_MEMORY);
default:
panic("ofw_isa_range_restype: illegal space %x", ps);

View File

@ -36,16 +36,34 @@
#include <machine/ofw_bus.h>
typedef u_int32_t ofw_pci_intr_t;
typedef uint32_t ofw_pci_intr_t;
#include "ofw_pci_if.h"
/* PCI range child spaces. XXX: are these MI? */
#define PCI_CS_CONFIG 0x00
#define PCI_CS_IO 0x01
#define PCI_CS_MEM32 0x02
#define PCI_CS_MEM64 0x03
#define OFW_PCI_CS_CONFIG 0x00
#define OFW_PCI_CS_IO 0x01
#define OFW_PCI_CS_MEM32 0x02
#define OFW_PCI_CS_MEM64 0x03
u_int8_t ofw_pci_alloc_busno(phandle_t);
struct ofw_pci_ranges {
uint32_t cspace;
uint32_t child_hi;
uint32_t child_lo;
uint32_t phys_hi;
uint32_t phys_lo;
uint32_t size_hi;
uint32_t size_lo;
};
#define OFW_PCI_RANGE_CHILD(r) \
(((uint64_t)(r)->child_hi << 32) | (uint64_t)(r)->child_lo)
#define OFW_PCI_RANGE_PHYS(r) \
(((uint64_t)(r)->phys_hi << 32) | (uint64_t)(r)->phys_lo)
#define OFW_PCI_RANGE_SIZE(r) \
(((uint64_t)(r)->size_hi << 32) | (uint64_t)(r)->size_lo)
#define OFW_PCI_RANGE_CS(r) (((r)->cspace >> 24) & 0x03)
uint8_t ofw_pci_alloc_busno(phandle_t);
#endif /* ! _SPARC64_PCI_OFW_PCI_H_ */

View File

@ -287,7 +287,7 @@ psycho_attach(device_t dev)
struct psycho_softc *sc;
struct psycho_softc *osc = NULL;
struct psycho_softc *asc;
struct upa_ranges *range;
struct ofw_pci_ranges *range;
struct upa_regs *reg;
const struct psycho_desc *desc;
phandle_t node;
@ -417,7 +417,7 @@ psycho_attach(device_t dev)
nrange = OF_getprop_alloc(node, "ranges", sizeof(*range),
(void **)&range);
/*
* Make sure that the expected ranges are present. The PCI_CS_MEM64
* Make sure that the expected ranges are present. The OFW_PCI_CS_MEM64
* one is not currently used though.
*/
if (nrange != PSYCHO_NRANGE)
@ -429,10 +429,10 @@ psycho_attach(device_t dev)
* memory and I/O handles.
*/
for (n = 0; n < PSYCHO_NRANGE; n++) {
i = UPA_RANGE_CS(&range[n]);
i = OFW_PCI_RANGE_CS(&range[n]);
if (sc->sc_pci_bh[i] != 0)
panic("%s: duplicate range for space %d", __func__, i);
sc->sc_pci_bh[i] = UPA_RANGE_PHYS(&range[n]);
sc->sc_pci_bh[i] = OFW_PCI_RANGE_PHYS(&range[n]);
}
free(range, M_OFWPROP);
@ -806,7 +806,7 @@ psycho_read_config(device_t dev, u_int bus, u_int slot, u_int func, u_int reg,
sc = device_get_softc(dev);
offset = PSYCHO_CONF_OFF(bus, slot, func, reg);
bh = sc->sc_pci_bh[PCI_CS_CONFIG];
bh = sc->sc_pci_bh[OFW_PCI_CS_CONFIG];
switch (width) {
case 1:
i = bus_space_peek_1(sc->sc_pci_cfgt, bh, offset, &byte);
@ -844,7 +844,7 @@ psycho_write_config(device_t dev, u_int bus, u_int slot, u_int func, u_int reg,
sc = device_get_softc(dev);
offset = PSYCHO_CONF_OFF(bus, slot, func, reg);
bh = sc->sc_pci_bh[PCI_CS_CONFIG];
bh = sc->sc_pci_bh[OFW_PCI_CS_CONFIG];
switch (width) {
case 1:
bus_space_write_1(sc->sc_pci_cfgt, bh, offset, val);
@ -1040,12 +1040,12 @@ psycho_alloc_resource(device_t bus, device_t child, int type, int *rid,
case SYS_RES_MEMORY:
rm = &sc->sc_pci_mem_rman;
bt = sc->sc_pci_memt;
bh = sc->sc_pci_bh[PCI_CS_MEM32];
bh = sc->sc_pci_bh[OFW_PCI_CS_MEM32];
break;
case SYS_RES_IOPORT:
rm = &sc->sc_pci_io_rman;
bt = sc->sc_pci_iot;
bh = sc->sc_pci_bh[PCI_CS_IO];
bh = sc->sc_pci_bh[OFW_PCI_CS_IO];
break;
default:
return (NULL);
@ -1150,10 +1150,10 @@ psycho_get_bus_handle(device_t dev, int type, bus_space_handle_t childhdl,
switch (type) {
case SYS_RES_IOPORT:
*tag = sc->sc_pci_iot;
return (sc->sc_pci_bh[PCI_CS_IO] + childhdl);
return (sc->sc_pci_bh[OFW_PCI_CS_IO] + childhdl);
case SYS_RES_MEMORY:
*tag = sc->sc_pci_memt;
return (sc->sc_pci_bh[PCI_CS_MEM32] + childhdl);
return (sc->sc_pci_bh[OFW_PCI_CS_MEM32] + childhdl);
default:
panic("%s: illegal space (%d)\n", __func__, type);
}