From: kettenis Date: Sun, 6 Mar 2022 18:52:47 +0000 (+0000) Subject: Look for firmware for Apple Silicon devices in /etc/firmware/apple-bwfm. X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=ec9994a1ab17a93efb508a42556a8198443660dc;p=openbsd Look for firmware for Apple Silicon devices in /etc/firmware/apple-bwfm. ok deraadt@ --- diff --git a/sys/dev/ic/bwfm.c b/sys/dev/ic/bwfm.c index 85b6dd5b896..15e712c92ee 100644 --- a/sys/dev/ic/bwfm.c +++ b/sys/dev/ic/bwfm.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bwfm.c,v 1.100 2022/03/04 22:34:41 kettenis Exp $ */ +/* $OpenBSD: bwfm.c,v 1.101 2022/03/06 18:52:47 kettenis Exp $ */ /* * Copyright (c) 2010-2016 Broadcom Corporation * Copyright (c) 2016,2017 Patrick Wildt @@ -3161,17 +3161,18 @@ bwfm_loadfirmware(struct bwfm_softc *sc, const char *chip, const char *bus, board_type = sc->sc_board_type; if (board_type != NULL) { - r = snprintf(name, sizeof(name), "brcmfmac%s%s.%s.bin", chip, - bus, board_type); + r = snprintf(name, sizeof(name), "%sbrcmfmac%s%s.%s.bin", + sc->sc_fwdir, chip, bus, board_type); if ((r > 0 && r < sizeof(name)) && loadfirmware(name, ucode, size) != 0) *size = 0; } if (*size == 0) { - snprintf(name, sizeof(name), "brcmfmac%s%s.bin", chip, bus); + snprintf(name, sizeof(name), "%sbrcmfmac%s%s.bin", + sc->sc_fwdir, chip, bus); if (loadfirmware(name, ucode, size) != 0) { - snprintf(name, sizeof(name), "brcmfmac%s%s%s%s.bin", - chip, bus, board_type ? "." : "", + snprintf(name, sizeof(name), "%sbrcmfmac%s%s%s%s.bin", + sc->sc_fwdir, chip, bus, board_type ? "." : "", board_type ? board_type : ""); printf("%s: failed loadfirmware of file %s\n", DEVNAME(sc), name); @@ -3182,28 +3183,29 @@ bwfm_loadfirmware(struct bwfm_softc *sc, const char *chip, const char *bus, /* .txt needs to be processed first */ if (strlen(sc->sc_modrev) > 0) { r = snprintf(name, sizeof(name), - "brcmfmac%s%s.%s-%s-%s-%s.txt", chip, bus, board_type, - sc->sc_module, sc->sc_vendor, sc->sc_modrev); + "%sbrcmfmac%s%s.%s-%s-%s-%s.txt", sc->sc_fwdir, chip, bus, + board_type, sc->sc_module, sc->sc_vendor, sc->sc_modrev); if (r > 0 && r < sizeof(name)) loadfirmware(name, nvram, nvsize); } if (*nvsize == 0 && strlen(sc->sc_vendor) > 0) { r = snprintf(name, sizeof(name), - "brcmfmac%s%s.%s-%s-%s.txt", chip, bus, board_type, - sc->sc_module, sc->sc_vendor); + "%sbrcmfmac%s%s.%s-%s-%s.txt", sc->sc_fwdir, chip, bus, + board_type, sc->sc_module, sc->sc_vendor); if (r > 0 && r < sizeof(name)) loadfirmware(name, nvram, nvsize); } if (*nvsize == 0 && board_type != NULL) { - r = snprintf(name, sizeof(name), "brcmfmac%s%s.%s.txt", chip, - bus, board_type); + r = snprintf(name, sizeof(name), "%sbrcmfmac%s%s.%s.txt", + sc->sc_fwdir, chip, bus, board_type); if (r > 0 && r < sizeof(name)) loadfirmware(name, nvram, nvsize); } if (*nvsize == 0) { - snprintf(name, sizeof(name), "brcmfmac%s%s.txt", chip, bus); + snprintf(name, sizeof(name), "%sbrcmfmac%s%s.txt", + sc->sc_fwdir, chip, bus); loadfirmware(name, nvram, nvsize); } @@ -3219,14 +3221,16 @@ bwfm_loadfirmware(struct bwfm_softc *sc, const char *chip, const char *bus, /* .nvram is the pre-processed version */ if (*nvlen == 0) { - snprintf(name, sizeof(name), "brcmfmac%s%s.nvram", chip, bus); + snprintf(name, sizeof(name), "%sbrcmfmac%s%s.nvram", + sc->sc_fwdir, chip, bus); if (loadfirmware(name, nvram, nvsize) == 0) *nvlen = *nvsize; } if (*nvlen == 0 && strcmp(bus, "-sdio") == 0) { - snprintf(name, sizeof(name), "brcmfmac%s%s%s%s.txt", chip, bus, - board_type ? "." : "", board_type ? board_type : ""); + snprintf(name, sizeof(name), "%sbrcmfmac%s%s%s%s.txt", + sc->sc_fwdir, chip, bus, board_type ? "." : "", + board_type ? board_type : ""); printf("%s: failed loadfirmware of file %s\n", DEVNAME(sc), name); free(*ucode, M_DEVBUF, *size); @@ -3234,24 +3238,27 @@ bwfm_loadfirmware(struct bwfm_softc *sc, const char *chip, const char *bus, } if (board_type != NULL) { - r = snprintf(name, sizeof(name), "brcmfmac%s%s.%s.clm_blob", - chip, bus, board_type); + r = snprintf(name, sizeof(name), "%sbrcmfmac%s%s.%s.clm_blob", + sc->sc_fwdir, chip, bus, board_type); if (r > 0 && r < sizeof(name)) loadfirmware(name, &sc->sc_clm, &sc->sc_clmsize); } if (sc->sc_clmsize == 0) { - snprintf(name, sizeof(name), "brcmfmac%s%s.clm_blob", chip, bus); + snprintf(name, sizeof(name), "%sbrcmfmac%s%s.clm_blob", + sc->sc_fwdir, chip, bus); loadfirmware(name, &sc->sc_clm, &sc->sc_clmsize); } if (board_type != NULL) { - r = snprintf(name, sizeof(name), "brcmfmac%s%s.%s.txcap_blob", + r = snprintf(name, sizeof(name), + "%sbrcmfmac%s%s.%s.txcap_blob", sc->sc_fwdir, chip, bus, board_type); if (r > 0 && r < sizeof(name)) loadfirmware(name, &sc->sc_txcap, &sc->sc_txcapsize); } if (sc->sc_txcapsize == 0) { - snprintf(name, sizeof(name), "brcmfmac%s%s.txcap_blob", chip, bus); + snprintf(name, sizeof(name), "%sbrcmfmac%s%s.txcap_blob", + sc->sc_fwdir, chip, bus); loadfirmware(name, &sc->sc_txcap, &sc->sc_txcapsize); } diff --git a/sys/dev/ic/bwfmvar.h b/sys/dev/ic/bwfmvar.h index 065ab349323..cccc4ed1d0b 100644 --- a/sys/dev/ic/bwfmvar.h +++ b/sys/dev/ic/bwfmvar.h @@ -1,4 +1,4 @@ -/* $OpenBSD: bwfmvar.h,v 1.30 2022/03/04 22:34:41 kettenis Exp $ */ +/* $OpenBSD: bwfmvar.h,v 1.31 2022/03/06 18:52:47 kettenis Exp $ */ /* * Copyright (c) 2010-2016 Broadcom Corporation * Copyright (c) 2016,2017 Patrick Wildt @@ -186,6 +186,7 @@ struct bwfm_softc { int sc_bcdc_reqid; TAILQ_HEAD(, bwfm_proto_bcdc_ctl) sc_bcdc_rxctlq; + char sc_fwdir[16]; u_char *sc_clm; size_t sc_clmsize; u_char *sc_txcap; diff --git a/sys/dev/pci/if_bwfm_pci.c b/sys/dev/pci/if_bwfm_pci.c index fd473fb7d8d..30c55314baa 100644 --- a/sys/dev/pci/if_bwfm_pci.c +++ b/sys/dev/pci/if_bwfm_pci.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_bwfm_pci.c,v 1.68 2022/03/04 22:34:41 kettenis Exp $ */ +/* $OpenBSD: if_bwfm_pci.c,v 1.69 2022/03/06 18:52:47 kettenis Exp $ */ /* * Copyright (c) 2010-2016 Broadcom Corporation * Copyright (c) 2017 Patrick Wildt @@ -1121,6 +1121,10 @@ next: OF_getprop(sc->sc_sc.sc_node, "brcm,board-type", board_type, sizeof(board_type)); strlcpy(product, &board_type[6], sizeof(product)); + if (strncmp(board_type, "apple,", 6) == 0) { + strlcpy(sc->sc_sc.sc_fwdir, "apple-bwfm/", + sizeof(sc->sc_sc.sc_fwdir)); + } } printf("%s: firmware C-%s%s%s/P-%s_M-%s_V-%s__m-%s\n", DEVNAME(sc), chip,