Commit c1b20532 authored by Daniel Kim's avatar Daniel Kim Committed by John W. Linville

brcmfmac: Make firmware path a module parameter

This patch makes firmware path a module parameter so that firmware and
nvram files can be loaded from the specified path.
Signed-off-by: default avatarDaniel Kim <dekim@broadcom.com>
Signed-off-by: default avatarArend van Spriel <arend@broadcom.com>
Signed-off-by: default avatarJohn W. Linville <linville@tuxdriver.com>
parent 82d957e0
...@@ -666,28 +666,34 @@ static const struct brcmf_firmware_names brcmf_fwname_data[] = { ...@@ -666,28 +666,34 @@ static const struct brcmf_firmware_names brcmf_fwname_data[] = {
{ BRCM_CC_4354_CHIP_ID, 0xFFFFFFFF, BRCMF_FIRMWARE_NVRAM(BCM4354) } { BRCM_CC_4354_CHIP_ID, 0xFFFFFFFF, BRCMF_FIRMWARE_NVRAM(BCM4354) }
}; };
static const char *brcmf_sdio_get_fwname(struct brcmf_chip *ci, static int brcmf_sdio_get_fwnames(struct brcmf_chip *ci,
enum brcmf_firmware_type type) struct brcmf_sdio_dev *sdiodev)
{ {
int i; int i;
for (i = 0; i < ARRAY_SIZE(brcmf_fwname_data); i++) { for (i = 0; i < ARRAY_SIZE(brcmf_fwname_data); i++) {
if (brcmf_fwname_data[i].chipid == ci->chip && if (brcmf_fwname_data[i].chipid == ci->chip &&
brcmf_fwname_data[i].revmsk & BIT(ci->chiprev)) { brcmf_fwname_data[i].revmsk & BIT(ci->chiprev))
switch (type) { break;
case BRCMF_FIRMWARE_BIN:
return brcmf_fwname_data[i].bin;
case BRCMF_FIRMWARE_NVRAM:
return brcmf_fwname_data[i].nv;
default:
brcmf_err("invalid firmware type (%d)\n", type);
return NULL;
} }
if (i == ARRAY_SIZE(brcmf_fwname_data)) {
brcmf_err("Unknown chipid %d [%d]\n", ci->chip, ci->chiprev);
return -ENODEV;
} }
/* check if firmware path is provided by module parameter */
if (brcmf_firmware_path[0] != '\0') {
if (brcmf_firmware_path[strlen(brcmf_firmware_path) - 1] != '/')
strcat(brcmf_firmware_path, "/");
strcpy(sdiodev->fw_name, brcmf_firmware_path);
strcpy(sdiodev->nvram_name, brcmf_firmware_path);
} }
brcmf_err("Unknown chipid %d [%d]\n", strcat(sdiodev->fw_name, brcmf_fwname_data[i].bin);
ci->chip, ci->chiprev); strcat(sdiodev->nvram_name, brcmf_fwname_data[i].nv);
return NULL;
return 0;
} }
static void pkt_align(struct sk_buff *p, int len, int align) static void pkt_align(struct sk_buff *p, int len, int align)
...@@ -4160,11 +4166,12 @@ struct brcmf_sdio *brcmf_sdio_probe(struct brcmf_sdio_dev *sdiodev) ...@@ -4160,11 +4166,12 @@ struct brcmf_sdio *brcmf_sdio_probe(struct brcmf_sdio_dev *sdiodev)
brcmf_sdio_debugfs_create(bus); brcmf_sdio_debugfs_create(bus);
brcmf_dbg(INFO, "completed!!\n"); brcmf_dbg(INFO, "completed!!\n");
ret = brcmf_sdio_get_fwnames(bus->ci, sdiodev);
if (ret)
goto fail;
ret = brcmf_fw_get_firmwares(sdiodev->dev, BRCMF_FW_REQUEST_NVRAM, ret = brcmf_fw_get_firmwares(sdiodev->dev, BRCMF_FW_REQUEST_NVRAM,
brcmf_sdio_get_fwname(bus->ci, sdiodev->fw_name, sdiodev->nvram_name,
BRCMF_FIRMWARE_BIN),
brcmf_sdio_get_fwname(bus->ci,
BRCMF_FIRMWARE_NVRAM),
brcmf_sdio_firmware_callback); brcmf_sdio_firmware_callback);
if (ret != 0) { if (ret != 0) {
brcmf_err("async firmware request failed: %d\n", ret); brcmf_err("async firmware request failed: %d\n", ret);
......
...@@ -18,10 +18,15 @@ ...@@ -18,10 +18,15 @@
#include <linux/slab.h> #include <linux/slab.h>
#include <linux/device.h> #include <linux/device.h>
#include <linux/firmware.h> #include <linux/firmware.h>
#include <linux/module.h>
#include "dhd_dbg.h" #include "dhd_dbg.h"
#include "firmware.h" #include "firmware.h"
char brcmf_firmware_path[BRCMF_FW_PATH_LEN];
module_param_string(firmware_path, brcmf_firmware_path,
BRCMF_FW_PATH_LEN, 0440);
enum nvram_parser_state { enum nvram_parser_state {
IDLE, IDLE,
KEY, KEY,
......
...@@ -21,6 +21,11 @@ ...@@ -21,6 +21,11 @@
#define BRCMF_FW_REQ_FLAGS 0x00F0 #define BRCMF_FW_REQ_FLAGS 0x00F0
#define BRCMF_FW_REQ_NV_OPTIONAL 0x0010 #define BRCMF_FW_REQ_NV_OPTIONAL 0x0010
#define BRCMF_FW_PATH_LEN 256
#define BRCMF_FW_NAME_LEN 32
extern char brcmf_firmware_path[];
void brcmf_fw_nvram_free(void *nvram); void brcmf_fw_nvram_free(void *nvram);
/* /*
* Request firmware(s) asynchronously. When the asynchronous request * Request firmware(s) asynchronously. When the asynchronous request
......
...@@ -18,6 +18,8 @@ ...@@ -18,6 +18,8 @@
#define _BRCM_SDH_H_ #define _BRCM_SDH_H_
#include <linux/skbuff.h> #include <linux/skbuff.h>
#include <linux/firmware.h>
#include "firmware.h"
#define SDIO_FUNC_0 0 #define SDIO_FUNC_0 0
#define SDIO_FUNC_1 1 #define SDIO_FUNC_1 1
...@@ -182,6 +184,8 @@ struct brcmf_sdio_dev { ...@@ -182,6 +184,8 @@ struct brcmf_sdio_dev {
uint max_segment_size; uint max_segment_size;
uint txglomsz; uint txglomsz;
struct sg_table sgtable; struct sg_table sgtable;
char fw_name[BRCMF_FW_PATH_LEN + BRCMF_FW_NAME_LEN];
char nvram_name[BRCMF_FW_PATH_LEN + BRCMF_FW_NAME_LEN];
}; };
/* sdio core registers */ /* sdio core registers */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment