diff options
author | Kalle Valo <kvalo@qca.qualcomm.com> | 2011-09-07 03:55:16 -0400 |
---|---|---|
committer | Kalle Valo <kvalo@qca.qualcomm.com> | 2011-09-16 11:48:34 -0400 |
commit | 772c31ee438e4d2d7a5e049b8d73c2ee8902f656 (patch) | |
tree | 646a40cda4b7ffe83e691323f767a4af42f1ed07 | |
parent | 92ecbff48e3993ca58525533dc58ec1025c45609 (diff) |
ath6kl: separate firmware fetch from upload
In preparation for the new firmware image format.
Signed-off-by: Kalle Valo <kvalo@qca.qualcomm.com>
-rw-r--r-- | drivers/net/wireless/ath/ath6kl/init.c | 249 |
1 files changed, 153 insertions, 96 deletions
diff --git a/drivers/net/wireless/ath/ath6kl/init.c b/drivers/net/wireless/ath/ath6kl/init.c index 91716709cac8..4055947ffd67 100644 --- a/drivers/net/wireless/ath/ath6kl/init.c +++ b/drivers/net/wireless/ath/ath6kl/init.c | |||
@@ -744,6 +744,9 @@ static int ath6kl_fetch_board_file(struct ath6kl *ar) | |||
744 | const char *filename; | 744 | const char *filename; |
745 | int ret; | 745 | int ret; |
746 | 746 | ||
747 | if (ar->fw_board != NULL) | ||
748 | return 0; | ||
749 | |||
747 | switch (ar->version.target_ver) { | 750 | switch (ar->version.target_ver) { |
748 | case AR6003_REV2_VERSION: | 751 | case AR6003_REV2_VERSION: |
749 | filename = AR6003_REV2_BOARD_DATA_FILE; | 752 | filename = AR6003_REV2_BOARD_DATA_FILE; |
@@ -798,6 +801,144 @@ static int ath6kl_fetch_board_file(struct ath6kl *ar) | |||
798 | return 0; | 801 | return 0; |
799 | } | 802 | } |
800 | 803 | ||
804 | static int ath6kl_fetch_otp_file(struct ath6kl *ar) | ||
805 | { | ||
806 | const char *filename; | ||
807 | int ret; | ||
808 | |||
809 | if (ar->fw_otp != NULL) | ||
810 | return 0; | ||
811 | |||
812 | switch (ar->version.target_ver) { | ||
813 | case AR6003_REV2_VERSION: | ||
814 | filename = AR6003_REV2_OTP_FILE; | ||
815 | break; | ||
816 | case AR6004_REV1_VERSION: | ||
817 | ath6kl_dbg(ATH6KL_DBG_TRC, "AR6004 doesn't need OTP file\n"); | ||
818 | return 0; | ||
819 | break; | ||
820 | default: | ||
821 | filename = AR6003_REV3_OTP_FILE; | ||
822 | break; | ||
823 | } | ||
824 | |||
825 | ret = ath6kl_get_fw(ar, filename, &ar->fw_otp, | ||
826 | &ar->fw_otp_len); | ||
827 | if (ret) { | ||
828 | ath6kl_err("Failed to get OTP file %s: %d\n", | ||
829 | filename, ret); | ||
830 | return ret; | ||
831 | } | ||
832 | |||
833 | return 0; | ||
834 | } | ||
835 | |||
836 | static int ath6kl_fetch_fw_file(struct ath6kl *ar) | ||
837 | { | ||
838 | const char *filename; | ||
839 | int ret; | ||
840 | |||
841 | if (ar->fw != NULL) | ||
842 | return 0; | ||
843 | |||
844 | if (testmode) { | ||
845 | switch (ar->version.target_ver) { | ||
846 | case AR6003_REV2_VERSION: | ||
847 | filename = AR6003_REV2_TCMD_FIRMWARE_FILE; | ||
848 | break; | ||
849 | case AR6003_REV3_VERSION: | ||
850 | filename = AR6003_REV3_TCMD_FIRMWARE_FILE; | ||
851 | break; | ||
852 | case AR6004_REV1_VERSION: | ||
853 | ath6kl_warn("testmode not supported with ar6004\n"); | ||
854 | return -EOPNOTSUPP; | ||
855 | default: | ||
856 | ath6kl_warn("unknown target version: 0x%x\n", | ||
857 | ar->version.target_ver); | ||
858 | return -EINVAL; | ||
859 | } | ||
860 | |||
861 | set_bit(TESTMODE, &ar->flag); | ||
862 | |||
863 | goto get_fw; | ||
864 | } | ||
865 | |||
866 | switch (ar->version.target_ver) { | ||
867 | case AR6003_REV2_VERSION: | ||
868 | filename = AR6003_REV2_FIRMWARE_FILE; | ||
869 | break; | ||
870 | case AR6004_REV1_VERSION: | ||
871 | filename = AR6004_REV1_FIRMWARE_FILE; | ||
872 | break; | ||
873 | default: | ||
874 | filename = AR6003_REV3_FIRMWARE_FILE; | ||
875 | break; | ||
876 | } | ||
877 | |||
878 | get_fw: | ||
879 | ret = ath6kl_get_fw(ar, filename, &ar->fw, &ar->fw_len); | ||
880 | if (ret) { | ||
881 | ath6kl_err("Failed to get firmware file %s: %d\n", | ||
882 | filename, ret); | ||
883 | return ret; | ||
884 | } | ||
885 | |||
886 | return 0; | ||
887 | } | ||
888 | |||
889 | static int ath6kl_fetch_patch_file(struct ath6kl *ar) | ||
890 | { | ||
891 | const char *filename; | ||
892 | int ret; | ||
893 | |||
894 | switch (ar->version.target_ver) { | ||
895 | case AR6003_REV2_VERSION: | ||
896 | filename = AR6003_REV2_PATCH_FILE; | ||
897 | break; | ||
898 | case AR6004_REV1_VERSION: | ||
899 | /* FIXME: implement for AR6004 */ | ||
900 | return 0; | ||
901 | break; | ||
902 | default: | ||
903 | filename = AR6003_REV3_PATCH_FILE; | ||
904 | break; | ||
905 | } | ||
906 | |||
907 | if (ar->fw_patch == NULL) { | ||
908 | ret = ath6kl_get_fw(ar, filename, &ar->fw_patch, | ||
909 | &ar->fw_patch_len); | ||
910 | if (ret) { | ||
911 | ath6kl_err("Failed to get patch file %s: %d\n", | ||
912 | filename, ret); | ||
913 | return ret; | ||
914 | } | ||
915 | } | ||
916 | |||
917 | return 0; | ||
918 | } | ||
919 | |||
920 | static int ath6kl_fetch_firmwares(struct ath6kl *ar) | ||
921 | { | ||
922 | int ret; | ||
923 | |||
924 | ret = ath6kl_fetch_board_file(ar); | ||
925 | if (ret) | ||
926 | return ret; | ||
927 | |||
928 | ret = ath6kl_fetch_otp_file(ar); | ||
929 | if (ret) | ||
930 | return ret; | ||
931 | |||
932 | ret = ath6kl_fetch_fw_file(ar); | ||
933 | if (ret) | ||
934 | return ret; | ||
935 | |||
936 | ret = ath6kl_fetch_patch_file(ar); | ||
937 | if (ret) | ||
938 | return ret; | ||
939 | |||
940 | return 0; | ||
941 | } | ||
801 | 942 | ||
802 | static int ath6kl_upload_board_file(struct ath6kl *ar) | 943 | static int ath6kl_upload_board_file(struct ath6kl *ar) |
803 | { | 944 | { |
@@ -805,11 +946,8 @@ static int ath6kl_upload_board_file(struct ath6kl *ar) | |||
805 | u32 board_data_size, board_ext_data_size; | 946 | u32 board_data_size, board_ext_data_size; |
806 | int ret; | 947 | int ret; |
807 | 948 | ||
808 | if (ar->fw_board == NULL) { | 949 | if (WARN_ON(ar->fw_board == NULL)) |
809 | ret = ath6kl_fetch_board_file(ar); | 950 | return -ENOENT; |
810 | if (ret) | ||
811 | return ret; | ||
812 | } | ||
813 | 951 | ||
814 | /* | 952 | /* |
815 | * Determine where in Target RAM to write Board Data. | 953 | * Determine where in Target RAM to write Board Data. |
@@ -909,32 +1047,11 @@ static int ath6kl_upload_board_file(struct ath6kl *ar) | |||
909 | 1047 | ||
910 | static int ath6kl_upload_otp(struct ath6kl *ar) | 1048 | static int ath6kl_upload_otp(struct ath6kl *ar) |
911 | { | 1049 | { |
912 | const char *filename; | ||
913 | u32 address, param; | 1050 | u32 address, param; |
914 | int ret; | 1051 | int ret; |
915 | 1052 | ||
916 | switch (ar->version.target_ver) { | 1053 | if (WARN_ON(ar->fw_otp == NULL)) |
917 | case AR6003_REV2_VERSION: | 1054 | return -ENOENT; |
918 | filename = AR6003_REV2_OTP_FILE; | ||
919 | break; | ||
920 | case AR6004_REV1_VERSION: | ||
921 | ath6kl_dbg(ATH6KL_DBG_TRC, "AR6004 doesn't need OTP file\n"); | ||
922 | return 0; | ||
923 | break; | ||
924 | default: | ||
925 | filename = AR6003_REV3_OTP_FILE; | ||
926 | break; | ||
927 | } | ||
928 | |||
929 | if (ar->fw_otp == NULL) { | ||
930 | ret = ath6kl_get_fw(ar, filename, &ar->fw_otp, | ||
931 | &ar->fw_otp_len); | ||
932 | if (ret) { | ||
933 | ath6kl_err("Failed to get OTP file %s: %d\n", | ||
934 | filename, ret); | ||
935 | return ret; | ||
936 | } | ||
937 | } | ||
938 | 1055 | ||
939 | address = ath6kl_get_load_address(ar->version.target_ver, | 1056 | address = ath6kl_get_load_address(ar->version.target_ver, |
940 | APP_LOAD_ADDR); | 1057 | APP_LOAD_ADDR); |
@@ -957,54 +1074,11 @@ static int ath6kl_upload_otp(struct ath6kl *ar) | |||
957 | 1074 | ||
958 | static int ath6kl_upload_firmware(struct ath6kl *ar) | 1075 | static int ath6kl_upload_firmware(struct ath6kl *ar) |
959 | { | 1076 | { |
960 | const char *filename; | ||
961 | u32 address; | 1077 | u32 address; |
962 | int ret; | 1078 | int ret; |
963 | 1079 | ||
964 | if (testmode) { | 1080 | if (WARN_ON(ar->fw == NULL)) |
965 | switch (ar->version.target_ver) { | 1081 | return -ENOENT; |
966 | case AR6003_REV2_VERSION: | ||
967 | filename = AR6003_REV2_TCMD_FIRMWARE_FILE; | ||
968 | break; | ||
969 | case AR6003_REV3_VERSION: | ||
970 | filename = AR6003_REV3_TCMD_FIRMWARE_FILE; | ||
971 | break; | ||
972 | case AR6004_REV1_VERSION: | ||
973 | ath6kl_warn("testmode not supported with ar6004\n"); | ||
974 | return -EOPNOTSUPP; | ||
975 | default: | ||
976 | ath6kl_warn("unknown target version: 0x%x\n", | ||
977 | ar->version.target_ver); | ||
978 | return -EINVAL; | ||
979 | } | ||
980 | |||
981 | set_bit(TESTMODE, &ar->flag); | ||
982 | |||
983 | goto get_fw; | ||
984 | } | ||
985 | |||
986 | switch (ar->version.target_ver) { | ||
987 | case AR6003_REV2_VERSION: | ||
988 | filename = AR6003_REV2_FIRMWARE_FILE; | ||
989 | break; | ||
990 | case AR6004_REV1_VERSION: | ||
991 | filename = AR6004_REV1_FIRMWARE_FILE; | ||
992 | break; | ||
993 | default: | ||
994 | filename = AR6003_REV3_FIRMWARE_FILE; | ||
995 | break; | ||
996 | } | ||
997 | |||
998 | get_fw: | ||
999 | |||
1000 | if (ar->fw == NULL) { | ||
1001 | ret = ath6kl_get_fw(ar, filename, &ar->fw, &ar->fw_len); | ||
1002 | if (ret) { | ||
1003 | ath6kl_err("Failed to get firmware file %s: %d\n", | ||
1004 | filename, ret); | ||
1005 | return ret; | ||
1006 | } | ||
1007 | } | ||
1008 | 1082 | ||
1009 | address = ath6kl_get_load_address(ar->version.target_ver, | 1083 | address = ath6kl_get_load_address(ar->version.target_ver, |
1010 | APP_LOAD_ADDR); | 1084 | APP_LOAD_ADDR); |
@@ -1030,32 +1104,11 @@ get_fw: | |||
1030 | 1104 | ||
1031 | static int ath6kl_upload_patch(struct ath6kl *ar) | 1105 | static int ath6kl_upload_patch(struct ath6kl *ar) |
1032 | { | 1106 | { |
1033 | const char *filename; | ||
1034 | u32 address, param; | 1107 | u32 address, param; |
1035 | int ret; | 1108 | int ret; |
1036 | 1109 | ||
1037 | switch (ar->version.target_ver) { | 1110 | if (WARN_ON(ar->fw_patch == NULL)) |
1038 | case AR6003_REV2_VERSION: | 1111 | return -ENOENT; |
1039 | filename = AR6003_REV2_PATCH_FILE; | ||
1040 | break; | ||
1041 | case AR6004_REV1_VERSION: | ||
1042 | /* FIXME: implement for AR6004 */ | ||
1043 | return 0; | ||
1044 | break; | ||
1045 | default: | ||
1046 | filename = AR6003_REV3_PATCH_FILE; | ||
1047 | break; | ||
1048 | } | ||
1049 | |||
1050 | if (ar->fw_patch == NULL) { | ||
1051 | ret = ath6kl_get_fw(ar, filename, &ar->fw_patch, | ||
1052 | &ar->fw_patch_len); | ||
1053 | if (ret) { | ||
1054 | ath6kl_err("Failed to get patch file %s: %d\n", | ||
1055 | filename, ret); | ||
1056 | return ret; | ||
1057 | } | ||
1058 | } | ||
1059 | 1112 | ||
1060 | address = ath6kl_get_load_address(ar->version.target_ver, | 1113 | address = ath6kl_get_load_address(ar->version.target_ver, |
1061 | DATASET_PATCH_ADDR); | 1114 | DATASET_PATCH_ADDR); |
@@ -1362,6 +1415,10 @@ int ath6kl_core_init(struct ath6kl *ar) | |||
1362 | goto err_htc_cleanup; | 1415 | goto err_htc_cleanup; |
1363 | } | 1416 | } |
1364 | 1417 | ||
1418 | ret = ath6kl_fetch_firmwares(ar); | ||
1419 | if (ret) | ||
1420 | goto err_htc_cleanup; | ||
1421 | |||
1365 | ret = ath6kl_init_upload(ar); | 1422 | ret = ath6kl_init_upload(ar); |
1366 | if (ret) | 1423 | if (ret) |
1367 | goto err_htc_cleanup; | 1424 | goto err_htc_cleanup; |