aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/ath/ath9k/hif_usb.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/net/wireless/ath/ath9k/hif_usb.c')
-rw-r--r--drivers/net/wireless/ath/ath9k/hif_usb.c58
1 files changed, 41 insertions, 17 deletions
diff --git a/drivers/net/wireless/ath/ath9k/hif_usb.c b/drivers/net/wireless/ath/ath9k/hif_usb.c
index 77b359162d6c..5f3ea7091ae0 100644
--- a/drivers/net/wireless/ath/ath9k/hif_usb.c
+++ b/drivers/net/wireless/ath/ath9k/hif_usb.c
@@ -16,12 +16,10 @@
16 16
17#include "htc.h" 17#include "htc.h"
18 18
19#define ATH9K_FW_USB_DEV(devid, fw) \
20 { USB_DEVICE(0x0cf3, devid), .driver_info = (unsigned long) fw }
21
22static struct usb_device_id ath9k_hif_usb_ids[] = { 19static struct usb_device_id ath9k_hif_usb_ids[] = {
23 ATH9K_FW_USB_DEV(0x9271, "ar9271.fw"), 20 { USB_DEVICE(0x0cf3, 0x9271) },
24 ATH9K_FW_USB_DEV(0x1006, "ar9271.fw"), 21 { USB_DEVICE(0x0cf3, 0x1006) },
22 { USB_DEVICE(0x0cf3, 0x7010) },
25 { }, 23 { },
26}; 24};
27 25
@@ -756,6 +754,7 @@ static int ath9k_hif_usb_download_fw(struct hif_device_usb *hif_dev)
756 size_t len = hif_dev->firmware->size; 754 size_t len = hif_dev->firmware->size;
757 u32 addr = AR9271_FIRMWARE; 755 u32 addr = AR9271_FIRMWARE;
758 u8 *buf = kzalloc(4096, GFP_KERNEL); 756 u8 *buf = kzalloc(4096, GFP_KERNEL);
757 u32 firm_offset;
759 758
760 if (!buf) 759 if (!buf)
761 return -ENOMEM; 760 return -ENOMEM;
@@ -779,32 +778,37 @@ static int ath9k_hif_usb_download_fw(struct hif_device_usb *hif_dev)
779 } 778 }
780 kfree(buf); 779 kfree(buf);
781 780
781 if (hif_dev->device_id == 0x7010)
782 firm_offset = AR7010_FIRMWARE_TEXT;
783 else
784 firm_offset = AR9271_FIRMWARE_TEXT;
785
782 /* 786 /*
783 * Issue FW download complete command to firmware. 787 * Issue FW download complete command to firmware.
784 */ 788 */
785 err = usb_control_msg(hif_dev->udev, usb_sndctrlpipe(hif_dev->udev, 0), 789 err = usb_control_msg(hif_dev->udev, usb_sndctrlpipe(hif_dev->udev, 0),
786 FIRMWARE_DOWNLOAD_COMP, 790 FIRMWARE_DOWNLOAD_COMP,
787 0x40 | USB_DIR_OUT, 791 0x40 | USB_DIR_OUT,
788 AR9271_FIRMWARE_TEXT >> 8, 0, NULL, 0, HZ); 792 firm_offset >> 8, 0, NULL, 0, HZ);
789 if (err) 793 if (err)
790 return -EIO; 794 return -EIO;
791 795
792 dev_info(&hif_dev->udev->dev, "ath9k_htc: Transferred FW: %s, size: %ld\n", 796 dev_info(&hif_dev->udev->dev, "ath9k_htc: Transferred FW: %s, size: %ld\n",
793 "ar9271.fw", (unsigned long) hif_dev->firmware->size); 797 hif_dev->fw_name, (unsigned long) hif_dev->firmware->size);
794 798
795 return 0; 799 return 0;
796} 800}
797 801
798static int ath9k_hif_usb_dev_init(struct hif_device_usb *hif_dev, 802static int ath9k_hif_usb_dev_init(struct hif_device_usb *hif_dev)
799 const char *fw_name)
800{ 803{
801 int ret; 804 int ret;
802 805
803 /* Request firmware */ 806 /* Request firmware */
804 ret = request_firmware(&hif_dev->firmware, fw_name, &hif_dev->udev->dev); 807 ret = request_firmware(&hif_dev->firmware, hif_dev->fw_name,
808 &hif_dev->udev->dev);
805 if (ret) { 809 if (ret) {
806 dev_err(&hif_dev->udev->dev, 810 dev_err(&hif_dev->udev->dev,
807 "ath9k_htc: Firmware - %s not found\n", fw_name); 811 "ath9k_htc: Firmware - %s not found\n", hif_dev->fw_name);
808 goto err_fw_req; 812 goto err_fw_req;
809 } 813 }
810 814
@@ -820,7 +824,8 @@ static int ath9k_hif_usb_dev_init(struct hif_device_usb *hif_dev,
820 ret = ath9k_hif_usb_download_fw(hif_dev); 824 ret = ath9k_hif_usb_download_fw(hif_dev);
821 if (ret) { 825 if (ret) {
822 dev_err(&hif_dev->udev->dev, 826 dev_err(&hif_dev->udev->dev,
823 "ath9k_htc: Firmware - %s download failed\n", fw_name); 827 "ath9k_htc: Firmware - %s download failed\n",
828 hif_dev->fw_name);
824 goto err_fw_download; 829 goto err_fw_download;
825 } 830 }
826 831
@@ -847,7 +852,6 @@ static int ath9k_hif_usb_probe(struct usb_interface *interface,
847{ 852{
848 struct usb_device *udev = interface_to_usbdev(interface); 853 struct usb_device *udev = interface_to_usbdev(interface);
849 struct hif_device_usb *hif_dev; 854 struct hif_device_usb *hif_dev;
850 const char *fw_name = (const char *) id->driver_info;
851 int ret = 0; 855 int ret = 0;
852 856
853 hif_dev = kzalloc(sizeof(struct hif_device_usb), GFP_KERNEL); 857 hif_dev = kzalloc(sizeof(struct hif_device_usb), GFP_KERNEL);
@@ -872,7 +876,29 @@ static int ath9k_hif_usb_probe(struct usb_interface *interface,
872 goto err_htc_hw_alloc; 876 goto err_htc_hw_alloc;
873 } 877 }
874 878
875 ret = ath9k_hif_usb_dev_init(hif_dev, fw_name); 879 /* Find out which firmware to load */
880
881 switch(hif_dev->device_id) {
882 case 0x9271:
883 case 0x1006:
884 hif_dev->fw_name = "ar9271.fw";
885 break;
886 case 0x7010:
887 if (le16_to_cpu(udev->descriptor.bcdDevice) == 0x0202)
888 hif_dev->fw_name = "ar7010_1_1.fw";
889 else
890 hif_dev->fw_name = "ar7010.fw";
891 break;
892 default:
893 break;
894 }
895
896 if (!hif_dev->fw_name) {
897 dev_err(&udev->dev, "Can't determine firmware !\n");
898 goto err_htc_hw_alloc;
899 }
900
901 ret = ath9k_hif_usb_dev_init(hif_dev);
876 if (ret) { 902 if (ret) {
877 ret = -EINVAL; 903 ret = -EINVAL;
878 goto err_hif_init_usb; 904 goto err_hif_init_usb;
@@ -907,12 +933,10 @@ static void ath9k_hif_usb_reboot(struct usb_device *udev)
907 void *buf; 933 void *buf;
908 int ret; 934 int ret;
909 935
910 buf = kmalloc(4, GFP_KERNEL); 936 buf = kmemdup(&reboot_cmd, 4, GFP_KERNEL);
911 if (!buf) 937 if (!buf)
912 return; 938 return;
913 939
914 memcpy(buf, &reboot_cmd, 4);
915
916 ret = usb_bulk_msg(udev, usb_sndbulkpipe(udev, USB_REG_OUT_PIPE), 940 ret = usb_bulk_msg(udev, usb_sndbulkpipe(udev, USB_REG_OUT_PIPE),
917 buf, 4, NULL, HZ); 941 buf, 4, NULL, HZ);
918 if (ret) 942 if (ret)