diff options
Diffstat (limited to 'sys')
-rw-r--r-- | sys/arch/sparc64/dev/pci_machdep.c | 27 | ||||
-rw-r--r-- | sys/arch/sparc64/dev/psycho.c | 23 | ||||
-rw-r--r-- | sys/arch/sparc64/dev/pyro.c | 22 | ||||
-rw-r--r-- | sys/arch/sparc64/dev/schizo.c | 21 | ||||
-rw-r--r-- | sys/arch/sparc64/include/pci_machdep.h | 5 |
5 files changed, 69 insertions, 29 deletions
diff --git a/sys/arch/sparc64/dev/pci_machdep.c b/sys/arch/sparc64/dev/pci_machdep.c index 7b9e3ae3fb7..ae0a25c1768 100644 --- a/sys/arch/sparc64/dev/pci_machdep.c +++ b/sys/arch/sparc64/dev/pci_machdep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pci_machdep.c,v 1.33 2008/01/03 21:30:07 kettenis Exp $ */ +/* $OpenBSD: pci_machdep.c,v 1.34 2008/01/19 11:13:43 kettenis Exp $ */ /* $NetBSD: pci_machdep.c,v 1.22 2001/07/20 00:07:13 eeh Exp $ */ /* @@ -316,21 +316,13 @@ sparc64_pci_enumerate_bus(struct pci_softc *sc, return (0); } -/* assume we are mapped little-endian/side-effect */ pcireg_t pci_conf_read(pci_chipset_tag_t pc, pcitag_t tag, int reg) { pcireg_t val = (pcireg_t)~0; - DPRINTF(SPDB_CONF, ("pci_conf_read: tag %lx reg %x ", - (long)PCITAG_OFFSET(tag), reg)); - if (PCITAG_NODE(tag) != -1) { - val = bus_space_read_4(pc->bustag, pc->bushandle, - (PCITAG_OFFSET(tag) << pc->tagshift) + reg); - } else - DPRINTF(SPDB_CONF, ("pci_conf_read: bogus pcitag %x\n", - (int)PCITAG_OFFSET(tag))); - DPRINTF(SPDB_CONF, (" returning %08x\n", (u_int)val)); + if (PCITAG_NODE(tag) != -1) + val = pc->conf_read(pc, tag, reg); return (val); } @@ -338,17 +330,8 @@ pci_conf_read(pci_chipset_tag_t pc, pcitag_t tag, int reg) void pci_conf_write(pci_chipset_tag_t pc, pcitag_t tag, int reg, pcireg_t data) { - DPRINTF(SPDB_CONF, ("pci_conf_write: tag %lx; reg %x; data %x; ", - (long)PCITAG_OFFSET(tag), reg, (int)data)); - - /* If we don't know it, just punt. */ - if (PCITAG_NODE(tag) == -1) { - DPRINTF(SPDB_CONF, ("pci_config_write: bad addr")); - return; - } - - bus_space_write_4(pc->bustag, pc->bushandle, - (PCITAG_OFFSET(tag) << pc->tagshift) + reg, data); + if (PCITAG_NODE(tag) != -1) + pc->conf_write(pc, tag, reg, data); } /* diff --git a/sys/arch/sparc64/dev/psycho.c b/sys/arch/sparc64/dev/psycho.c index 2fae1859431..f36cf6bc097 100644 --- a/sys/arch/sparc64/dev/psycho.c +++ b/sys/arch/sparc64/dev/psycho.c @@ -1,4 +1,4 @@ -/* $OpenBSD: psycho.c,v 1.54 2007/10/08 18:30:13 krw Exp $ */ +/* $OpenBSD: psycho.c,v 1.55 2008/01/19 11:13:43 kettenis Exp $ */ /* $NetBSD: psycho.c,v 1.39 2001/10/07 20:30:41 eeh Exp $ */ /* @@ -115,6 +115,9 @@ int psycho_intr_map(struct pci_attach_args *, pci_intr_handle_t *); void psycho_identify_pbm(struct psycho_softc *sc, struct psycho_pbm *pp, struct pcibus_attach_args *pa); +pcireg_t psycho_conf_read(pci_chipset_tag_t, pcitag_t, int); +void psycho_conf_write(pci_chipset_tag_t, pcitag_t, int, pcireg_t); + /* base pci_chipset */ extern struct sparc_pci_chipset _sparc_pci_chipset; @@ -540,6 +543,8 @@ psycho_attach(struct device *parent, struct device *self, void *aux) pba.pba_memt = sc->sc_psycho_this->pp_memt; pba.pba_pc->bustag = sc->sc_configtag; pba.pba_pc->bushandle = sc->sc_configaddr; + pba.pba_pc->conf_read = psycho_conf_read; + pba.pba_pc->conf_write = psycho_conf_write; pba.pba_pc->intr_map = psycho_intr_map; if (sc->sc_mode == PSYCHO_MODE_PSYCHO) @@ -1047,6 +1052,21 @@ psycho_bus_addr(bus_space_tag_t t, bus_space_tag_t t0, bus_space_handle_t h) return (-1); } + +pcireg_t +psycho_conf_read(pci_chipset_tag_t pc, pcitag_t tag, int reg) +{ + return (bus_space_read_4(pc->bustag, pc->bushandle, + PCITAG_OFFSET(tag) + reg)); +} + +void +psycho_conf_write(pci_chipset_tag_t pc, pcitag_t tag, int reg, pcireg_t data) +{ + bus_space_write_4(pc->bustag, pc->bushandle, + PCITAG_OFFSET(tag) + reg, data); +} + /* * Bus-specific interrupt mapping */ @@ -1239,4 +1259,3 @@ psycho_sabre_dvmamap_sync(bus_dma_tag_t t, bus_dma_tag_t t0, bus_dmamap_t map, if (ops & (BUS_DMASYNC_POSTREAD | BUS_DMASYNC_PREWRITE)) membar(MemIssue); } - diff --git a/sys/arch/sparc64/dev/pyro.c b/sys/arch/sparc64/dev/pyro.c index ab2ba3e577d..5f1ff439196 100644 --- a/sys/arch/sparc64/dev/pyro.c +++ b/sys/arch/sparc64/dev/pyro.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pyro.c,v 1.10 2007/10/10 11:31:49 krw Exp $ */ +/* $OpenBSD: pyro.c,v 1.11 2008/01/19 11:13:43 kettenis Exp $ */ /* * Copyright (c) 2002 Jason L. Wright (jason@thought.net) @@ -73,6 +73,9 @@ bus_space_tag_t _pyro_alloc_bus_tag(struct pyro_pbm *, const char *, int, int, int); bus_dma_tag_t pyro_alloc_dma_tag(struct pyro_pbm *); +pcireg_t pyro_conf_read(pci_chipset_tag_t, pcitag_t, int); +void pyro_conf_write(pci_chipset_tag_t, pcitag_t, int, pcireg_t); + int pyro_intr_map(struct pci_attach_args *, pci_intr_handle_t *); int _pyro_bus_map(bus_space_tag_t, bus_space_tag_t, bus_addr_t, bus_size_t, int, bus_space_handle_t *); @@ -188,6 +191,8 @@ pyro_init(struct pyro_softc *sc, int busa) pba.pba_dmat = pbm->pp_dmat; pba.pba_memt = pbm->pp_memt; pba.pba_iot = pbm->pp_iot; + pba.pba_pc->conf_read = pyro_conf_read; + pba.pba_pc->conf_write = pyro_conf_write; pba.pba_pc->intr_map = pyro_intr_map; free(busranges, M_DEVBUF); @@ -229,6 +234,20 @@ pyro_print(void *aux, const char *p) return (QUIET); } +pcireg_t +pyro_conf_read(pci_chipset_tag_t pc, pcitag_t tag, int reg) +{ + return (bus_space_read_4(pc->bustag, pc->bushandle, + (PCITAG_OFFSET(tag) << 4) + reg)); +} + +void +pyro_conf_write(pci_chipset_tag_t pc, pcitag_t tag, int reg, pcireg_t data) +{ + bus_space_write_4(pc->bustag, pc->bushandle, + (PCITAG_OFFSET(tag) << 4) + reg, data); +} + /* * Bus-specific interrupt mapping */ @@ -352,7 +371,6 @@ pyro_alloc_chipset(struct pyro_pbm *pbm, int node, pci_chipset_tag_t pc) memcpy(npc, pc, sizeof *pc); npc->cookie = pbm; npc->rootnode = node; - npc->tagshift = 4; /* PCIe has a larger config space */ return (npc); } diff --git a/sys/arch/sparc64/dev/schizo.c b/sys/arch/sparc64/dev/schizo.c index b8ae049f7cd..10b2e3287e5 100644 --- a/sys/arch/sparc64/dev/schizo.c +++ b/sys/arch/sparc64/dev/schizo.c @@ -1,4 +1,4 @@ -/* $OpenBSD: schizo.c,v 1.52 2007/11/13 15:51:59 kettenis Exp $ */ +/* $OpenBSD: schizo.c,v 1.53 2008/01/19 11:13:43 kettenis Exp $ */ /* * Copyright (c) 2002 Jason L. Wright (jason@thought.net) @@ -85,6 +85,9 @@ bus_space_tag_t schizo_alloc_bus_tag(struct schizo_pbm *, const char *, int, int, int); bus_dma_tag_t schizo_alloc_dma_tag(struct schizo_pbm *); +pcireg_t schizo_conf_read(pci_chipset_tag_t, pcitag_t, int); +void schizo_conf_write(pci_chipset_tag_t, pcitag_t, int, pcireg_t); + int schizo_intr_map(struct pci_attach_args *, pci_intr_handle_t *); int schizo_bus_map(bus_space_tag_t, bus_space_tag_t, bus_addr_t, bus_size_t, int, bus_space_handle_t *); @@ -223,6 +226,8 @@ schizo_init(struct schizo_softc *sc, int busa) pba.pba_dmat = pbm->sp_dmat; pba.pba_memt = pbm->sp_memt; pba.pba_iot = pbm->sp_iot; + pba.pba_pc->conf_read = schizo_conf_read; + pba.pba_pc->conf_write = schizo_conf_write; pba.pba_pc->intr_map = schizo_intr_map; free(busranges, M_DEVBUF); @@ -433,6 +438,20 @@ schizo_print(void *aux, const char *p) return (QUIET); } +pcireg_t +schizo_conf_read(pci_chipset_tag_t pc, pcitag_t tag, int reg) +{ + return (bus_space_read_4(pc->bustag, pc->bushandle, + PCITAG_OFFSET(tag) + reg)); +} + +void +schizo_conf_write(pci_chipset_tag_t pc, pcitag_t tag, int reg, pcireg_t data) +{ + bus_space_write_4(pc->bustag, pc->bushandle, + PCITAG_OFFSET(tag) + reg, data); +} + /* * Bus-specific interrupt mapping */ diff --git a/sys/arch/sparc64/include/pci_machdep.h b/sys/arch/sparc64/include/pci_machdep.h index c18ca9c5923..f97af5807c9 100644 --- a/sys/arch/sparc64/include/pci_machdep.h +++ b/sys/arch/sparc64/include/pci_machdep.h @@ -1,4 +1,4 @@ -/* $OpenBSD: pci_machdep.h,v 1.18 2007/11/25 00:38:49 kettenis Exp $ */ +/* $OpenBSD: pci_machdep.h,v 1.19 2008/01/19 11:13:43 kettenis Exp $ */ /* $NetBSD: pci_machdep.h,v 1.7 2001/07/20 00:07:14 eeh Exp $ */ /* @@ -68,7 +68,8 @@ struct sparc_pci_chipset { bus_space_handle_t bushandle; int rootnode; /* PCI controller */ int busnode[256]; - int tagshift; + pcireg_t (*conf_read)(pci_chipset_tag_t, pcitag_t, int); + void (*conf_write)(pci_chipset_tag_t, pcitag_t, int, pcireg_t); int (*intr_map)(struct pci_attach_args *, pci_intr_handle_t *); }; |