diff options
author | Patrick Wildt <patrick@cvs.openbsd.org> | 2018-02-07 22:08:25 +0000 |
---|---|---|
committer | Patrick Wildt <patrick@cvs.openbsd.org> | 2018-02-07 22:08:25 +0000 |
commit | 4503b1c55095709443a247c0bff1f495da66435e (patch) | |
tree | d8596614219e984fe697b94c6fca8aff59c1b9f5 /sys/dev/sdmmc | |
parent | 4d051eb7a84954ee6de556c3dc99924d9c0e8c0d (diff) |
Outsource setting the backplane window into a specific function so it
can be called and reused in different places.
Diffstat (limited to 'sys/dev/sdmmc')
-rw-r--r-- | sys/dev/sdmmc/if_bwfm_sdio.c | 38 |
1 files changed, 19 insertions, 19 deletions
diff --git a/sys/dev/sdmmc/if_bwfm_sdio.c b/sys/dev/sdmmc/if_bwfm_sdio.c index 733399aa543..65c64f1b144 100644 --- a/sys/dev/sdmmc/if_bwfm_sdio.c +++ b/sys/dev/sdmmc/if_bwfm_sdio.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_bwfm_sdio.c,v 1.2 2018/02/07 21:44:09 patrick Exp $ */ +/* $OpenBSD: if_bwfm_sdio.c,v 1.3 2018/02/07 22:08:24 patrick Exp $ */ /* * Copyright (c) 2010-2016 Broadcom Corporation * Copyright (c) 2016,2017 Patrick Wildt <patrick@blueri.se> @@ -75,6 +75,7 @@ int bwfm_sdio_match(struct device *, void *, void *); void bwfm_sdio_attach(struct device *, struct device *, void *); int bwfm_sdio_detach(struct device *, int); +void bwfm_sdio_backplane(struct bwfm_sdio_softc *, uint32_t); uint8_t bwfm_sdio_read_1(struct bwfm_sdio_softc *, uint32_t); uint32_t bwfm_sdio_read_4(struct bwfm_sdio_softc *, uint32_t); void bwfm_sdio_write_1(struct bwfm_sdio_softc *, uint32_t, @@ -226,6 +227,21 @@ bwfm_sdio_detach(struct device *self, int flags) return 0; } +void +bwfm_sdio_backplane(struct bwfm_sdio_softc *sc, uint32_t bar0) +{ + if (sc->sc_bar0 == bar0) + return; + + bwfm_sdio_write_1(sc, BWFM_SDIO_FUNC1_SBADDRLOW, + (bar0 >> 8) & 0x80); + bwfm_sdio_write_1(sc, BWFM_SDIO_FUNC1_SBADDRMID, + (bar0 >> 16) & 0xff); + bwfm_sdio_write_1(sc, BWFM_SDIO_FUNC1_SBADDRHIGH, + (bar0 >> 24) & 0xff); + sc->sc_bar0 = bar0; +} + uint8_t bwfm_sdio_read_1(struct bwfm_sdio_softc *sc, uint32_t addr) { @@ -254,15 +270,7 @@ bwfm_sdio_read_4(struct bwfm_sdio_softc *sc, uint32_t addr) uint32_t bar0 = addr & ~BWFM_SDIO_SB_OFT_ADDR_MASK; uint32_t rv; - if (sc->sc_bar0 != bar0) { - bwfm_sdio_write_1(sc, BWFM_SDIO_FUNC1_SBADDRLOW, - (bar0 >> 8) & 0x80); - bwfm_sdio_write_1(sc, BWFM_SDIO_FUNC1_SBADDRMID, - (bar0 >> 16) & 0xff); - bwfm_sdio_write_1(sc, BWFM_SDIO_FUNC1_SBADDRHIGH, - (bar0 >> 24) & 0xff); - sc->sc_bar0 = bar0; - } + bwfm_sdio_backplane(sc, bar0); addr &= BWFM_SDIO_SB_OFT_ADDR_MASK; addr |= BWFM_SDIO_SB_ACCESS_2_4B_FLAG; @@ -307,15 +315,7 @@ bwfm_sdio_write_4(struct bwfm_sdio_softc *sc, uint32_t addr, uint32_t data) struct sdmmc_function *sf; uint32_t bar0 = addr & ~BWFM_SDIO_SB_OFT_ADDR_MASK; - if (sc->sc_bar0 != bar0) { - bwfm_sdio_write_1(sc, BWFM_SDIO_FUNC1_SBADDRLOW, - (bar0 >> 8) & 0x80); - bwfm_sdio_write_1(sc, BWFM_SDIO_FUNC1_SBADDRMID, - (bar0 >> 16) & 0xff); - bwfm_sdio_write_1(sc, BWFM_SDIO_FUNC1_SBADDRHIGH, - (bar0 >> 24) & 0xff); - sc->sc_bar0 = bar0; - } + bwfm_sdio_backplane(sc, bar0); addr &= BWFM_SDIO_SB_OFT_ADDR_MASK; addr |= BWFM_SDIO_SB_ACCESS_2_4B_FLAG; |