diff options
author | Marcus Glocker <mglocker@cvs.openbsd.org> | 2007-09-13 08:28:38 +0000 |
---|---|---|
committer | Marcus Glocker <mglocker@cvs.openbsd.org> | 2007-09-13 08:28:38 +0000 |
commit | 4136770efc99997cf49376074bcf603c8d76dbd5 (patch) | |
tree | 86ef8dfd69804acc60906becdf26f3429dddc488 /sys/dev/pci | |
parent | e305f169078afaa7f8e15739afc497ed0aa1e4f8 (diff) |
Enable access to PCI and Cardbus config space from the driver. Lets us
power on the device.
Diffstat (limited to 'sys/dev/pci')
-rw-r--r-- | sys/dev/pci/if_bwi_pci.c | 55 |
1 files changed, 39 insertions, 16 deletions
diff --git a/sys/dev/pci/if_bwi_pci.c b/sys/dev/pci/if_bwi_pci.c index 2e2abda4a11..3a84aee7bcc 100644 --- a/sys/dev/pci/if_bwi_pci.c +++ b/sys/dev/pci/if_bwi_pci.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_bwi_pci.c,v 1.1 2007/09/12 12:59:55 mglocker Exp $ */ +/* $OpenBSD: if_bwi_pci.c,v 1.2 2007/09/13 08:28:37 mglocker Exp $ */ /* * Copyright (c) 2007 Marcus Glocker <mglocker@openbsd.org> @@ -54,17 +54,20 @@ /* Base Address Register */ #define BWI_PCI_BAR0 0x10 -int bwi_pci_match(struct device *, void *, void *); -void bwi_pci_attach(struct device *, struct device *, void *); -int bwi_pci_detach(struct device *, int); +int bwi_pci_match(struct device *, void *, void *); +void bwi_pci_attach(struct device *, struct device *, void *); +int bwi_pci_detach(struct device *, int); +void bwi_pci_conf_write(void *, uint32_t, uint32_t); +uint32_t bwi_pci_conf_read(void *, uint32_t); struct bwi_pci_softc { - struct bwi_softc sc_bwi; + struct bwi_softc psc_bwi; - pci_chipset_tag_t sc_pc; - void *sc_ih; + pci_chipset_tag_t psc_pc; + pcitag_t psc_pcitag; + void *psc_ih; - bus_size_t sc_mapsize; + bus_size_t psc_mapsize; }; struct cfattach bwi_pci_ca = { @@ -98,18 +101,18 @@ bwi_pci_attach(struct device *parent, struct device *self, void *aux) { struct bwi_pci_softc *psc = (struct bwi_pci_softc *)self; struct pci_attach_args *pa = aux; - struct bwi_softc *sc = &psc->sc_bwi; + struct bwi_softc *sc = &psc->psc_bwi; const char *intrstr = NULL; pci_intr_handle_t ih; int error; sc->sc_dmat = pa->pa_dmat; - psc->sc_pc = pa->pa_pc; + psc->psc_pc = pa->pa_pc; /* map control / status registers */ error = pci_mapreg_map(pa, BWI_PCI_BAR0, PCI_MAPREG_TYPE_MEM | PCI_MAPREG_MEM_TYPE_32BIT, 0, - &sc->sc_mem_bt, &sc->sc_mem_bh, NULL, &psc->sc_mapsize, 0); + &sc->sc_mem_bt, &sc->sc_mem_bh, NULL, &psc->psc_mapsize, 0); if (error != 0) { printf(": could not map memory space\n"); return; @@ -122,10 +125,10 @@ bwi_pci_attach(struct device *parent, struct device *self, void *aux) } /* establish interrupt */ - intrstr = pci_intr_string(psc->sc_pc, ih); - psc->sc_ih = pci_intr_establish(psc->sc_pc, ih, IPL_NET, bwi_intr, sc, + intrstr = pci_intr_string(psc->psc_pc, ih); + psc->psc_ih = pci_intr_establish(psc->psc_pc, ih, IPL_NET, bwi_intr, sc, sc->sc_dev.dv_xname); - if (psc->sc_ih == NULL) { + if (psc->psc_ih == NULL) { printf(": could not establish interrupt"); if (intrstr != NULL) printf(" at %s", intrstr); @@ -134,6 +137,10 @@ bwi_pci_attach(struct device *parent, struct device *self, void *aux) } printf(": %s", intrstr); + /* we need to access PCI config space from the driver */ + sc->sc_conf_write = bwi_pci_conf_write; + sc->sc_conf_read = bwi_pci_conf_read; + bwi_attach(sc); } @@ -141,10 +148,26 @@ int bwi_pci_detach(struct device *self, int flags) { struct bwi_pci_softc *psc = (struct bwi_pci_softc *)self; - struct bwi_softc *sc = &psc->sc_bwi; + struct bwi_softc *sc = &psc->psc_bwi; bwi_detach(sc); - pci_intr_disestablish(psc->sc_pc, psc->sc_ih); + pci_intr_disestablish(psc->psc_pc, psc->psc_ih); return (0); } + +void +bwi_pci_conf_write(void *self, uint32_t reg, uint32_t val) +{ + struct bwi_pci_softc *psc = (struct bwi_pci_softc *)self; + + pci_conf_write(psc->psc_pc, psc->psc_pcitag, reg, val); +} + +uint32_t +bwi_pci_conf_read(void *self, uint32_t reg) +{ + struct bwi_pci_softc *psc = (struct bwi_pci_softc *)self; + + return (pci_conf_read(psc->psc_pc, psc->psc_pcitag, reg)); +} |