diff options
author | Hante Meuleman <meuleman@broadcom.com> | 2012-11-14 21:46:06 -0500 |
---|---|---|
committer | John W. Linville <linville@tuxdriver.com> | 2012-11-16 14:28:46 -0500 |
commit | 83bc9c313d2d8af7900ec6f78a7a1f1b1f232af6 (patch) | |
tree | 070089a50a055c54cb2a8bbc9879431b41ef8667 | |
parent | 5c36b99add5c3212b6cdb97cc206e1e3e0fa1e3c (diff) |
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: Arend Van Spriel <arend@broadcom.com>
Signed-off-by: Hante Meuleman <meuleman@broadcom.com>
Signed-off-by: Franky Lin <frankyl@broadcom.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
-rw-r--r-- | drivers/net/wireless/brcm80211/brcmfmac/usb.c | 43 |
1 files changed, 15 insertions, 28 deletions
diff --git a/drivers/net/wireless/brcm80211/brcmfmac/usb.c b/drivers/net/wireless/brcm80211/brcmfmac/usb.c index 15070b61b161..395c49d6e80e 100644 --- a/drivers/net/wireless/brcm80211/brcmfmac/usb.c +++ b/drivers/net/wireless/brcm80211/brcmfmac/usb.c | |||
@@ -42,13 +42,11 @@ | |||
42 | 42 | ||
43 | #define IOCTL_RESP_TIMEOUT 2000 | 43 | #define IOCTL_RESP_TIMEOUT 2000 |
44 | 44 | ||
45 | #define BRCMF_USB_DLIMAGE_SPINWAIT 100 /* in unit of ms */ | 45 | #define BRCMF_USB_RESET_GETVER_SPINWAIT 100 /* in unit of ms */ |
46 | #define BRCMF_USB_DLIMAGE_LIMIT 500 /* spinwait limit (ms) */ | 46 | #define BRCMF_USB_RESET_GETVER_LOOP_CNT 10 |
47 | 47 | ||
48 | #define BRCMF_POSTBOOT_ID 0xA123 /* ID to detect if dongle | 48 | #define BRCMF_POSTBOOT_ID 0xA123 /* ID to detect if dongle |
49 | has boot up */ | 49 | has boot up */ |
50 | #define BRCMF_USB_RESETCFG_SPINWAIT 1 /* wait after resetcfg (ms) */ | ||
51 | |||
52 | #define BRCMF_USB_NRXQ 50 | 50 | #define BRCMF_USB_NRXQ 50 |
53 | #define BRCMF_USB_NTXQ 50 | 51 | #define BRCMF_USB_NTXQ 50 |
54 | 52 | ||
@@ -829,8 +827,7 @@ brcmf_usb_dlneeded(struct brcmf_usbdev_info *devinfo) | |||
829 | 827 | ||
830 | /* Check if firmware downloaded already by querying runtime ID */ | 828 | /* Check if firmware downloaded already by querying runtime ID */ |
831 | id.chip = cpu_to_le32(0xDEAD); | 829 | id.chip = cpu_to_le32(0xDEAD); |
832 | brcmf_usb_dl_cmd(devinfo, DL_GETVER, &id, | 830 | brcmf_usb_dl_cmd(devinfo, DL_GETVER, &id, sizeof(id)); |
833 | sizeof(struct bootrom_id_le)); | ||
834 | 831 | ||
835 | chipid = le32_to_cpu(id.chip); | 832 | chipid = le32_to_cpu(id.chip); |
836 | chiprev = le32_to_cpu(id.chiprev); | 833 | chiprev = le32_to_cpu(id.chiprev); |
@@ -841,8 +838,7 @@ brcmf_usb_dlneeded(struct brcmf_usbdev_info *devinfo) | |||
841 | brcmf_dbg(USB, "chip %d rev 0x%x\n", chipid, chiprev); | 838 | brcmf_dbg(USB, "chip %d rev 0x%x\n", chipid, chiprev); |
842 | if (chipid == BRCMF_POSTBOOT_ID) { | 839 | if (chipid == BRCMF_POSTBOOT_ID) { |
843 | brcmf_dbg(USB, "firmware already downloaded\n"); | 840 | brcmf_dbg(USB, "firmware already downloaded\n"); |
844 | brcmf_usb_dl_cmd(devinfo, DL_RESETCFG, &id, | 841 | brcmf_usb_dl_cmd(devinfo, DL_RESETCFG, &id, sizeof(id)); |
845 | sizeof(struct bootrom_id_le)); | ||
846 | return false; | 842 | return false; |
847 | } else { | 843 | } else { |
848 | devinfo->bus_pub.devid = chipid; | 844 | devinfo->bus_pub.devid = chipid; |
@@ -855,38 +851,29 @@ static int | |||
855 | brcmf_usb_resetcfg(struct brcmf_usbdev_info *devinfo) | 851 | brcmf_usb_resetcfg(struct brcmf_usbdev_info *devinfo) |
856 | { | 852 | { |
857 | struct bootrom_id_le id; | 853 | struct bootrom_id_le id; |
858 | u16 wait = 0, wait_time; | 854 | u32 loop_cnt; |
859 | 855 | ||
860 | brcmf_dbg(USB, "Enter\n"); | 856 | brcmf_dbg(USB, "Enter\n"); |
861 | 857 | ||
862 | if (devinfo == NULL) | 858 | loop_cnt = 0; |
863 | return -EINVAL; | 859 | do { |
864 | 860 | mdelay(BRCMF_USB_RESET_GETVER_SPINWAIT); | |
865 | /* Give dongle chance to boot */ | 861 | loop_cnt++; |
866 | wait_time = BRCMF_USB_DLIMAGE_SPINWAIT; | ||
867 | while (wait < BRCMF_USB_DLIMAGE_LIMIT) { | ||
868 | mdelay(wait_time); | ||
869 | wait += wait_time; | ||
870 | id.chip = cpu_to_le32(0xDEAD); /* Get the ID */ | 862 | id.chip = cpu_to_le32(0xDEAD); /* Get the ID */ |
871 | brcmf_usb_dl_cmd(devinfo, DL_GETVER, &id, | 863 | brcmf_usb_dl_cmd(devinfo, DL_GETVER, &id, sizeof(id)); |
872 | sizeof(struct bootrom_id_le)); | ||
873 | if (id.chip == cpu_to_le32(BRCMF_POSTBOOT_ID)) | 864 | if (id.chip == cpu_to_le32(BRCMF_POSTBOOT_ID)) |
874 | break; | 865 | break; |
875 | } | 866 | } while (loop_cnt < BRCMF_USB_RESET_GETVER_LOOP_CNT); |
876 | 867 | ||
877 | if (id.chip == cpu_to_le32(BRCMF_POSTBOOT_ID)) { | 868 | if (id.chip == cpu_to_le32(BRCMF_POSTBOOT_ID)) { |
878 | brcmf_dbg(USB, "download done %d ms postboot chip 0x%x/rev 0x%x\n", | 869 | brcmf_dbg(USB, "postboot chip 0x%x/rev 0x%x\n", |
879 | wait, le32_to_cpu(id.chip), le32_to_cpu(id.chiprev)); | 870 | le32_to_cpu(id.chip), le32_to_cpu(id.chiprev)); |
880 | |||
881 | brcmf_usb_dl_cmd(devinfo, DL_RESETCFG, &id, | ||
882 | sizeof(struct bootrom_id_le)); | ||
883 | 871 | ||
884 | /* XXX this wait may not be necessary */ | 872 | brcmf_usb_dl_cmd(devinfo, DL_RESETCFG, &id, sizeof(id)); |
885 | mdelay(BRCMF_USB_RESETCFG_SPINWAIT); | ||
886 | return 0; | 873 | return 0; |
887 | } else { | 874 | } else { |
888 | brcmf_dbg(ERROR, "Cannot talk to Dongle. Firmware is not UP, %d ms\n", | 875 | brcmf_dbg(ERROR, "Cannot talk to Dongle. Firmware is not UP, %d ms\n", |
889 | wait); | 876 | BRCMF_USB_RESET_GETVER_SPINWAIT * loop_cnt); |
890 | return -EINVAL; | 877 | return -EINVAL; |
891 | } | 878 | } |
892 | } | 879 | } |