aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKalle Valo <kvalo@qca.qualcomm.com>2011-09-07 03:55:17 -0400
committerKalle Valo <kvalo@qca.qualcomm.com>2011-09-16 11:48:34 -0400
commita01ac4144e7af80f8c1fd861dc5d280c5687c2a9 (patch)
tree1ce639d49515d3da5cf0ffefbd34a36a3317c1ef
parent50d412346e49aee71b66d90dffb68f8d90ed35b2 (diff)
ath6kl: refactor firmware load address code
Currently the load address was calculated everytime when it was needed, and with a mess if clauses. Simplify this by adding a field to struct ath6kl for each address and choose the address with simple switch statements. Also move the code just after target version is retrieved. That way it's easier to override the values later in the boot process. Signed-off-by: Kalle Valo <kvalo@qca.qualcomm.com>
-rw-r--r--drivers/net/wireless/ath/ath6kl/core.h6
-rw-r--r--drivers/net/wireless/ath/ath6kl/init.c76
2 files changed, 42 insertions, 40 deletions
diff --git a/drivers/net/wireless/ath/ath6kl/core.h b/drivers/net/wireless/ath/ath6kl/core.h
index 761e550f0f81..77783f8175e6 100644
--- a/drivers/net/wireless/ath/ath6kl/core.h
+++ b/drivers/net/wireless/ath/ath6kl/core.h
@@ -462,6 +462,12 @@ struct ath6kl {
462 size_t rx_report_len; 462 size_t rx_report_len;
463 } tm; 463 } tm;
464 464
465 struct {
466 u32 dataset_patch_addr;
467 u32 app_load_addr;
468 u32 app_start_override_addr;
469 } hw;
470
465 u16 conf_flags; 471 u16 conf_flags;
466 wait_queue_head_t event_wq; 472 wait_queue_head_t event_wq;
467 struct ath6kl_mbox_info mbox_info; 473 struct ath6kl_mbox_info mbox_info;
diff --git a/drivers/net/wireless/ath/ath6kl/init.c b/drivers/net/wireless/ath/ath6kl/init.c
index 41f4e0d5858a..f94c049fe214 100644
--- a/drivers/net/wireless/ath/ath6kl/init.c
+++ b/drivers/net/wireless/ath/ath6kl/init.c
@@ -56,12 +56,6 @@ module_param(testmode, uint, 0644);
56 56
57#define CONFIG_AR600x_DEBUG_UART_TX_PIN 8 57#define CONFIG_AR600x_DEBUG_UART_TX_PIN 8
58 58
59enum addr_type {
60 DATASET_PATCH_ADDR,
61 APP_LOAD_ADDR,
62 APP_START_OVERRIDE_ADDR,
63};
64
65#define ATH6KL_DATA_OFFSET 64 59#define ATH6KL_DATA_OFFSET 64
66struct sk_buff *ath6kl_buf_alloc(int size) 60struct sk_buff *ath6kl_buf_alloc(int size)
67{ 61{
@@ -636,30 +630,6 @@ int ath6kl_unavail_ev(struct ath6kl *ar)
636} 630}
637 631
638/* firmware upload */ 632/* firmware upload */
639static u32 ath6kl_get_load_address(u32 target_ver, enum addr_type type)
640{
641 WARN_ON(target_ver != AR6003_REV2_VERSION &&
642 target_ver != AR6003_REV3_VERSION &&
643 target_ver != AR6004_REV1_VERSION);
644
645 switch (type) {
646 case DATASET_PATCH_ADDR:
647 return (target_ver == AR6003_REV2_VERSION) ?
648 AR6003_REV2_DATASET_PATCH_ADDRESS :
649 AR6003_REV3_DATASET_PATCH_ADDRESS;
650 case APP_LOAD_ADDR:
651 return (target_ver == AR6003_REV2_VERSION) ?
652 AR6003_REV2_APP_LOAD_ADDRESS :
653 0x1234;
654 case APP_START_OVERRIDE_ADDR:
655 return (target_ver == AR6003_REV2_VERSION) ?
656 AR6003_REV2_APP_START_OVERRIDE :
657 AR6003_REV3_APP_START_OVERRIDE;
658 default:
659 return 0;
660 }
661}
662
663static int ath6kl_get_fw(struct ath6kl *ar, const char *filename, 633static int ath6kl_get_fw(struct ath6kl *ar, const char *filename,
664 u8 **fw, size_t *fw_len) 634 u8 **fw, size_t *fw_len)
665{ 635{
@@ -1179,8 +1149,7 @@ static int ath6kl_upload_otp(struct ath6kl *ar)
1179 if (WARN_ON(ar->fw_otp == NULL)) 1149 if (WARN_ON(ar->fw_otp == NULL))
1180 return -ENOENT; 1150 return -ENOENT;
1181 1151
1182 address = ath6kl_get_load_address(ar->version.target_ver, 1152 address = ar->hw.app_load_addr;
1183 APP_LOAD_ADDR);
1184 1153
1185 ret = ath6kl_bmi_fast_download(ar, address, ar->fw_otp, 1154 ret = ath6kl_bmi_fast_download(ar, address, ar->fw_otp,
1186 ar->fw_otp_len); 1155 ar->fw_otp_len);
@@ -1191,8 +1160,7 @@ static int ath6kl_upload_otp(struct ath6kl *ar)
1191 1160
1192 /* execute the OTP code */ 1161 /* execute the OTP code */
1193 param = 0; 1162 param = 0;
1194 address = ath6kl_get_load_address(ar->version.target_ver, 1163 address = ar->hw.app_start_override_addr;
1195 APP_START_OVERRIDE_ADDR);
1196 ath6kl_bmi_execute(ar, address, &param); 1164 ath6kl_bmi_execute(ar, address, &param);
1197 1165
1198 return ret; 1166 return ret;
@@ -1206,8 +1174,7 @@ static int ath6kl_upload_firmware(struct ath6kl *ar)
1206 if (WARN_ON(ar->fw == NULL)) 1174 if (WARN_ON(ar->fw == NULL))
1207 return -ENOENT; 1175 return -ENOENT;
1208 1176
1209 address = ath6kl_get_load_address(ar->version.target_ver, 1177 address = ar->hw.app_load_addr;
1210 APP_LOAD_ADDR);
1211 1178
1212 ret = ath6kl_bmi_fast_download(ar, address, ar->fw, ar->fw_len); 1179 ret = ath6kl_bmi_fast_download(ar, address, ar->fw, ar->fw_len);
1213 1180
@@ -1221,8 +1188,7 @@ static int ath6kl_upload_firmware(struct ath6kl *ar)
1221 * Don't need to setup app_start override addr on AR6004 1188 * Don't need to setup app_start override addr on AR6004
1222 */ 1189 */
1223 if (ar->target_type != TARGET_TYPE_AR6004) { 1190 if (ar->target_type != TARGET_TYPE_AR6004) {
1224 address = ath6kl_get_load_address(ar->version.target_ver, 1191 address = ar->hw.app_start_override_addr;
1225 APP_START_OVERRIDE_ADDR);
1226 ath6kl_bmi_set_app_start(ar, address); 1192 ath6kl_bmi_set_app_start(ar, address);
1227 } 1193 }
1228 return ret; 1194 return ret;
@@ -1236,8 +1202,7 @@ static int ath6kl_upload_patch(struct ath6kl *ar)
1236 if (WARN_ON(ar->fw_patch == NULL)) 1202 if (WARN_ON(ar->fw_patch == NULL))
1237 return -ENOENT; 1203 return -ENOENT;
1238 1204
1239 address = ath6kl_get_load_address(ar->version.target_ver, 1205 address = ar->hw.dataset_patch_addr;
1240 DATASET_PATCH_ADDR);
1241 1206
1242 ret = ath6kl_bmi_write(ar, address, ar->fw_patch, ar->fw_patch_len); 1207 ret = ath6kl_bmi_write(ar, address, ar->fw_patch, ar->fw_patch_len);
1243 if (ret) { 1208 if (ret) {
@@ -1384,6 +1349,33 @@ static int ath6kl_init_upload(struct ath6kl *ar)
1384 return status; 1349 return status;
1385} 1350}
1386 1351
1352static int ath6kl_init_hw_params(struct ath6kl *ar)
1353{
1354 switch (ar->version.target_ver) {
1355 case AR6003_REV2_VERSION:
1356 ar->hw.dataset_patch_addr = AR6003_REV2_DATASET_PATCH_ADDRESS;
1357 ar->hw.app_load_addr = AR6003_REV2_APP_LOAD_ADDRESS;
1358 ar->hw.app_start_override_addr = AR6003_REV2_APP_START_OVERRIDE;
1359 break;
1360 case AR6003_REV3_VERSION:
1361 ar->hw.dataset_patch_addr = AR6003_REV3_DATASET_PATCH_ADDRESS;
1362 ar->hw.app_load_addr = 0x1234;
1363 ar->hw.app_start_override_addr = AR6003_REV3_APP_START_OVERRIDE;
1364 break;
1365 case AR6004_REV1_VERSION:
1366 ar->hw.dataset_patch_addr = AR6003_REV2_DATASET_PATCH_ADDRESS;
1367 ar->hw.app_load_addr = AR6003_REV3_APP_LOAD_ADDRESS;
1368 ar->hw.app_start_override_addr = AR6003_REV3_APP_START_OVERRIDE;
1369 break;
1370 default:
1371 ath6kl_err("Unsupported hardware version: 0x%x\n",
1372 ar->version.target_ver);
1373 return -EINVAL;
1374 }
1375
1376 return 0;
1377}
1378
1387static int ath6kl_init(struct net_device *dev) 1379static int ath6kl_init(struct net_device *dev)
1388{ 1380{
1389 struct ath6kl *ar = ath6kl_priv(dev); 1381 struct ath6kl *ar = ath6kl_priv(dev);
@@ -1523,6 +1515,10 @@ int ath6kl_core_init(struct ath6kl *ar)
1523 ar->target_type = le32_to_cpu(targ_info.type); 1515 ar->target_type = le32_to_cpu(targ_info.type);
1524 ar->wdev->wiphy->hw_version = le32_to_cpu(targ_info.version); 1516 ar->wdev->wiphy->hw_version = le32_to_cpu(targ_info.version);
1525 1517
1518 ret = ath6kl_init_hw_params(ar);
1519 if (ret)
1520 goto err_bmi_cleanup;
1521
1526 ret = ath6kl_configure_target(ar); 1522 ret = ath6kl_configure_target(ar);
1527 if (ret) 1523 if (ret)
1528 goto err_bmi_cleanup; 1524 goto err_bmi_cleanup;