Commit 83bc9c31 authored by Hante Meuleman's avatar Hante Meuleman Committed by John W. Linville

brcmfmac: cleanup of usb firmware download routines

Clean code related to firmware download routines. Remove obsolete
delay and increase delay after reset command.
Reviewed-by: default avatarArend Van Spriel <arend@broadcom.com>
Signed-off-by: default avatarHante Meuleman <meuleman@broadcom.com>
Signed-off-by: default avatarFranky Lin <frankyl@broadcom.com>
Signed-off-by: default avatarJohn W. Linville <linville@tuxdriver.com>
parent 5c36b99a
...@@ -42,13 +42,11 @@ ...@@ -42,13 +42,11 @@
#define IOCTL_RESP_TIMEOUT 2000 #define IOCTL_RESP_TIMEOUT 2000
#define BRCMF_USB_DLIMAGE_SPINWAIT 100 /* in unit of ms */ #define BRCMF_USB_RESET_GETVER_SPINWAIT 100 /* in unit of ms */
#define BRCMF_USB_DLIMAGE_LIMIT 500 /* spinwait limit (ms) */ #define BRCMF_USB_RESET_GETVER_LOOP_CNT 10
#define BRCMF_POSTBOOT_ID 0xA123 /* ID to detect if dongle #define BRCMF_POSTBOOT_ID 0xA123 /* ID to detect if dongle
has boot up */ has boot up */
#define BRCMF_USB_RESETCFG_SPINWAIT 1 /* wait after resetcfg (ms) */
#define BRCMF_USB_NRXQ 50 #define BRCMF_USB_NRXQ 50
#define BRCMF_USB_NTXQ 50 #define BRCMF_USB_NTXQ 50
...@@ -829,8 +827,7 @@ brcmf_usb_dlneeded(struct brcmf_usbdev_info *devinfo) ...@@ -829,8 +827,7 @@ brcmf_usb_dlneeded(struct brcmf_usbdev_info *devinfo)
/* Check if firmware downloaded already by querying runtime ID */ /* Check if firmware downloaded already by querying runtime ID */
id.chip = cpu_to_le32(0xDEAD); id.chip = cpu_to_le32(0xDEAD);
brcmf_usb_dl_cmd(devinfo, DL_GETVER, &id, brcmf_usb_dl_cmd(devinfo, DL_GETVER, &id, sizeof(id));
sizeof(struct bootrom_id_le));
chipid = le32_to_cpu(id.chip); chipid = le32_to_cpu(id.chip);
chiprev = le32_to_cpu(id.chiprev); chiprev = le32_to_cpu(id.chiprev);
...@@ -841,8 +838,7 @@ brcmf_usb_dlneeded(struct brcmf_usbdev_info *devinfo) ...@@ -841,8 +838,7 @@ brcmf_usb_dlneeded(struct brcmf_usbdev_info *devinfo)
brcmf_dbg(USB, "chip %d rev 0x%x\n", chipid, chiprev); brcmf_dbg(USB, "chip %d rev 0x%x\n", chipid, chiprev);
if (chipid == BRCMF_POSTBOOT_ID) { if (chipid == BRCMF_POSTBOOT_ID) {
brcmf_dbg(USB, "firmware already downloaded\n"); brcmf_dbg(USB, "firmware already downloaded\n");
brcmf_usb_dl_cmd(devinfo, DL_RESETCFG, &id, brcmf_usb_dl_cmd(devinfo, DL_RESETCFG, &id, sizeof(id));
sizeof(struct bootrom_id_le));
return false; return false;
} else { } else {
devinfo->bus_pub.devid = chipid; devinfo->bus_pub.devid = chipid;
...@@ -855,38 +851,29 @@ static int ...@@ -855,38 +851,29 @@ static int
brcmf_usb_resetcfg(struct brcmf_usbdev_info *devinfo) brcmf_usb_resetcfg(struct brcmf_usbdev_info *devinfo)
{ {
struct bootrom_id_le id; struct bootrom_id_le id;
u16 wait = 0, wait_time; u32 loop_cnt;
brcmf_dbg(USB, "Enter\n"); brcmf_dbg(USB, "Enter\n");
if (devinfo == NULL) loop_cnt = 0;
return -EINVAL; do {
mdelay(BRCMF_USB_RESET_GETVER_SPINWAIT);
/* Give dongle chance to boot */ loop_cnt++;
wait_time = BRCMF_USB_DLIMAGE_SPINWAIT;
while (wait < BRCMF_USB_DLIMAGE_LIMIT) {
mdelay(wait_time);
wait += wait_time;
id.chip = cpu_to_le32(0xDEAD); /* Get the ID */ id.chip = cpu_to_le32(0xDEAD); /* Get the ID */
brcmf_usb_dl_cmd(devinfo, DL_GETVER, &id, brcmf_usb_dl_cmd(devinfo, DL_GETVER, &id, sizeof(id));
sizeof(struct bootrom_id_le));
if (id.chip == cpu_to_le32(BRCMF_POSTBOOT_ID)) if (id.chip == cpu_to_le32(BRCMF_POSTBOOT_ID))
break; break;
} } while (loop_cnt < BRCMF_USB_RESET_GETVER_LOOP_CNT);
if (id.chip == cpu_to_le32(BRCMF_POSTBOOT_ID)) { if (id.chip == cpu_to_le32(BRCMF_POSTBOOT_ID)) {
brcmf_dbg(USB, "download done %d ms postboot chip 0x%x/rev 0x%x\n", brcmf_dbg(USB, "postboot chip 0x%x/rev 0x%x\n",
wait, le32_to_cpu(id.chip), le32_to_cpu(id.chiprev)); le32_to_cpu(id.chip), le32_to_cpu(id.chiprev));
brcmf_usb_dl_cmd(devinfo, DL_RESETCFG, &id,
sizeof(struct bootrom_id_le));
/* XXX this wait may not be necessary */ brcmf_usb_dl_cmd(devinfo, DL_RESETCFG, &id, sizeof(id));
mdelay(BRCMF_USB_RESETCFG_SPINWAIT);
return 0; return 0;
} else { } else {
brcmf_dbg(ERROR, "Cannot talk to Dongle. Firmware is not UP, %d ms\n", brcmf_dbg(ERROR, "Cannot talk to Dongle. Firmware is not UP, %d ms\n",
wait); BRCMF_USB_RESET_GETVER_SPINWAIT * loop_cnt);
return -EINVAL; return -EINVAL;
} }
} }
......
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