From owner-svn-src-all@FreeBSD.ORG Fri Apr 13 08:48:39 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 64E461065674; Fri, 13 Apr 2012 08:48:39 +0000 (UTC) (envelope-from adrian@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 364B08FC08; Fri, 13 Apr 2012 08:48:39 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q3D8mdl1068959; Fri, 13 Apr 2012 08:48:39 GMT (envelope-from adrian@svn.freebsd.org) Received: (from adrian@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q3D8mdRD068957; Fri, 13 Apr 2012 08:48:39 GMT (envelope-from adrian@svn.freebsd.org) Message-Id: <201204130848.q3D8mdRD068957@svn.freebsd.org> From: Adrian Chadd Date: Fri, 13 Apr 2012 08:48:38 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r234218 - head/sys/dev/ath X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 13 Apr 2012 08:48:39 -0000 Author: adrian Date: Fri Apr 13 08:48:38 2012 New Revision: 234218 URL: http://svn.freebsd.org/changeset/base/234218 Log: Introduce the ability to grab local EEPROM data from the firmware(9) interface. * Introduce a device hint, 'eeprom_firmware', which is the name of firmware to lookup. * If the lookup succeeds, take a copy of it and use it as the eeprom data. This isn't enabled by default - you have to define ATH_EEPROM_FIRMWARE. I'll add it to the configuration variables in a later commit. TODO: * just keep a firmware reference in ath_softc, and remove the need to waste the extra memory in having sc_eepromdata be a malloc()ed block. Modified: head/sys/dev/ath/if_ath_pci.c Modified: head/sys/dev/ath/if_ath_pci.c ============================================================================== --- head/sys/dev/ath/if_ath_pci.c Fri Apr 13 08:45:50 2012 (r234217) +++ head/sys/dev/ath/if_ath_pci.c Fri Apr 13 08:48:38 2012 (r234218) @@ -60,6 +60,14 @@ __FBSDID("$FreeBSD$"); #include #include +/* #define ATH_EEPROM_FIRMWARE */ + +/* For EEPROM firmware */ +#ifdef ATH_EEPROM_FIRMWARE +#include +#include +#endif /* ATH_EEPROM_FIRMWARE */ + /* * PCI glue. */ @@ -123,6 +131,10 @@ ath_pci_attach(device_t dev) struct ath_softc *sc = &psc->sc_sc; int error = ENXIO; int rid; +#ifdef ATH_EEPROM_FIRMWARE + const struct firmware *fw = NULL; + const char *buf; +#endif sc->sc_dev = dev; @@ -191,6 +203,37 @@ ath_pci_attach(device_t dev) goto bad3; } +#ifdef ATH_EEPROM_FIRMWARE + /* + * If there's an EEPROM firmware image, load that in. + */ + if (resource_string_value(device_get_name(dev), device_get_unit(dev), + "eeprom_firmware", &buf) == 0) { + if (bootverbose) + device_printf(dev, "%s: looking up firmware @ '%s'\n", + __func__, buf); + + fw = firmware_get(buf); + if (fw == NULL) { + device_printf(dev, "%s: couldn't find firmware\n", + __func__); + goto bad3; + } + + device_printf(dev, "%s: EEPROM firmware @ %p\n", + __func__, fw->data); + sc->sc_eepromdata = + malloc(fw->datasize, M_TEMP, M_WAITOK | M_ZERO); + if (! sc->sc_eepromdata) { + device_printf(dev, "%s: can't malloc eepromdata\n", + __func__); + goto bad3; + } + memcpy(sc->sc_eepromdata, fw->data, fw->datasize); + firmware_put(fw, 0); + } +#endif /* ATH_EEPROM_FIRMWARE */ + ATH_LOCK_INIT(sc); ATH_PCU_LOCK_INIT(sc); @@ -234,6 +277,9 @@ ath_pci_detach(device_t dev) bus_dma_tag_destroy(sc->sc_dmat); bus_release_resource(dev, SYS_RES_MEMORY, BS_BAR, psc->sc_sr); + if (sc->sc_eepromdata) + free(sc->sc_eepromdata, M_TEMP); + ATH_PCU_LOCK_DESTROY(sc); ATH_LOCK_DESTROY(sc);