Module Name:    src
Committed By:   khorben
Date:           Sun Mar 11 00:17:29 UTC 2018

Modified Files:
        src/sys/dev/sdmmc: if_bwfm_sdio.c

Log Message:
Outsource setting the backplane window into a specific function so it
can be called and reused in different places.

>From OpenBSD.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sys/dev/sdmmc/if_bwfm_sdio.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/dev/sdmmc/if_bwfm_sdio.c
diff -u src/sys/dev/sdmmc/if_bwfm_sdio.c:1.1 src/sys/dev/sdmmc/if_bwfm_sdio.c:1.2
--- src/sys/dev/sdmmc/if_bwfm_sdio.c:1.1	Tue Nov  7 16:30:32 2017
+++ src/sys/dev/sdmmc/if_bwfm_sdio.c	Sun Mar 11 00:17:28 2018
@@ -1,4 +1,4 @@
-/* $NetBSD: if_bwfm_sdio.c,v 1.1 2017/11/07 16:30:32 khorben Exp $ */
+/* $NetBSD: if_bwfm_sdio.c,v 1.2 2018/03/11 00:17:28 khorben Exp $ */
 /* $OpenBSD: if_bwfm_sdio.c,v 1.1 2017/10/11 17:19:50 patrick Exp $ */
 /*
  * Copyright (c) 2010-2016 Broadcom Corporation
@@ -73,6 +73,7 @@ int		 bwfm_sdio_match(device_t, cfdata_t
 void		 bwfm_sdio_attach(device_t, struct device *, void *);
 int		 bwfm_sdio_detach(device_t, 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,
@@ -218,6 +219,21 @@ bwfm_sdio_detach(struct device *self, in
 	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)
 {
@@ -246,15 +262,7 @@ bwfm_sdio_read_4(struct bwfm_sdio_softc 
 	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;
@@ -299,15 +307,7 @@ bwfm_sdio_write_4(struct bwfm_sdio_softc
 	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;

Reply via email to