aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorManikanta Pubbisetty <c_mpubbi@qti.qualcomm.com>2015-10-09 04:55:59 -0400
committerKalle Valo <kvalo@qca.qualcomm.com>2015-10-14 01:58:35 -0400
commitdb0984e51a187f5bbe41231af7e671cc12586346 (patch)
tree3320db5ed6d0c2995844194eac1711b3dc40d934
parent0a51b343abfe2c0dbcbd9ec3c4b18bb8779fefa8 (diff)
ath10k: select board data based on BMI chip id and board id
QCA99X0 uses radio specific board names based on chip id and board id combinations. We get these IDs from the target using BMI after otp.bin has been started. This patch reorders the call to the function ath10k_core_fetch_board_file so that we have OTP binary before requesting for boardid-chipid. We get this OTP data after parsing firmware-N.bin. [kvalo@qca.qualcomm.com: try BMI_PARAM_GET_EEPROM_BOARD_ID with all boards and detect if command is not supported] Signed-off-by: Manikanta Pubbisetty <c_mpubbi@qti.qualcomm.com> Signed-off-by: Kalle Valo <kvalo@qca.qualcomm.com>
-rw-r--r--drivers/net/wireless/ath/ath10k/bmi.h10
-rw-r--r--drivers/net/wireless/ath/ath10k/core.c79
-rw-r--r--drivers/net/wireless/ath/ath10k/core.h4
-rw-r--r--drivers/net/wireless/ath/ath10k/debug.c8
4 files changed, 93 insertions, 8 deletions
diff --git a/drivers/net/wireless/ath/ath10k/bmi.h b/drivers/net/wireless/ath/ath10k/bmi.h
index df7c7616533b..7d3231acfb24 100644
--- a/drivers/net/wireless/ath/ath10k/bmi.h
+++ b/drivers/net/wireless/ath/ath10k/bmi.h
@@ -82,6 +82,16 @@ enum bmi_cmd_id {
82 82
83#define BMI_NVRAM_SEG_NAME_SZ 16 83#define BMI_NVRAM_SEG_NAME_SZ 16
84 84
85#define BMI_PARAM_GET_EEPROM_BOARD_ID 0x10
86
87#define ATH10K_BMI_BOARD_ID_FROM_OTP_MASK 0x7c00
88#define ATH10K_BMI_BOARD_ID_FROM_OTP_LSB 10
89
90#define ATH10K_BMI_CHIP_ID_FROM_OTP_MASK 0x18000
91#define ATH10K_BMI_CHIP_ID_FROM_OTP_LSB 15
92
93#define ATH10K_BMI_BOARD_ID_STATUS_MASK 0xff
94
85struct bmi_cmd { 95struct bmi_cmd {
86 __le32 id; /* enum bmi_cmd_id */ 96 __le32 id; /* enum bmi_cmd_id */
87 union { 97 union {
diff --git a/drivers/net/wireless/ath/ath10k/core.c b/drivers/net/wireless/ath/ath10k/core.c
index 99a4e145c9b6..13de3617d5ab 100644
--- a/drivers/net/wireless/ath/ath10k/core.c
+++ b/drivers/net/wireless/ath/ath10k/core.c
@@ -448,6 +448,56 @@ out:
448 return ret; 448 return ret;
449} 449}
450 450
451static int ath10k_core_get_board_id_from_otp(struct ath10k *ar)
452{
453 u32 result, address;
454 u8 board_id, chip_id;
455 int ret;
456
457 address = ar->hw_params.patch_load_addr;
458
459 if (!ar->otp_data || !ar->otp_len) {
460 ath10k_warn(ar,
461 "failed to retrieve board id because of invalid otp\n");
462 return -ENODATA;
463 }
464
465 ath10k_dbg(ar, ATH10K_DBG_BOOT,
466 "boot upload otp to 0x%x len %zd for board id\n",
467 address, ar->otp_len);
468
469 ret = ath10k_bmi_fast_download(ar, address, ar->otp_data, ar->otp_len);
470 if (ret) {
471 ath10k_err(ar, "could not write otp for board id check: %d\n",
472 ret);
473 return ret;
474 }
475
476 ret = ath10k_bmi_execute(ar, address, BMI_PARAM_GET_EEPROM_BOARD_ID,
477 &result);
478 if (ret) {
479 ath10k_err(ar, "could not execute otp for board id check: %d\n",
480 ret);
481 return ret;
482 }
483
484 board_id = MS(result, ATH10K_BMI_BOARD_ID_FROM_OTP);
485 chip_id = MS(result, ATH10K_BMI_CHIP_ID_FROM_OTP);
486
487 ath10k_dbg(ar, ATH10K_DBG_BOOT,
488 "boot get otp board id result 0x%08x board_id %d chip_id %d\n",
489 result, board_id, chip_id);
490
491 if ((result & ATH10K_BMI_BOARD_ID_STATUS_MASK) != 0)
492 return -EOPNOTSUPP;
493
494 ar->id.bmi_ids_valid = true;
495 ar->id.bmi_board_id = board_id;
496 ar->id.bmi_chip_id = chip_id;
497
498 return 0;
499}
500
451static int ath10k_download_and_run_otp(struct ath10k *ar) 501static int ath10k_download_and_run_otp(struct ath10k *ar)
452{ 502{
453 u32 result, address = ar->hw_params.patch_load_addr; 503 u32 result, address = ar->hw_params.patch_load_addr;
@@ -792,12 +842,22 @@ err:
792static int ath10k_core_create_board_name(struct ath10k *ar, char *name, 842static int ath10k_core_create_board_name(struct ath10k *ar, char *name,
793 size_t name_len) 843 size_t name_len)
794{ 844{
845 if (ar->id.bmi_ids_valid) {
846 scnprintf(name, name_len,
847 "bus=%s,bmi-chip-id=%d,bmi-board-id=%d",
848 ath10k_bus_str(ar->hif.bus),
849 ar->id.bmi_chip_id,
850 ar->id.bmi_board_id);
851 goto out;
852 }
853
795 scnprintf(name, name_len, 854 scnprintf(name, name_len,
796 "bus=%s,vendor=%04x,device=%04x,subsystem-vendor=%04x,subsystem-device=%04x", 855 "bus=%s,vendor=%04x,device=%04x,subsystem-vendor=%04x,subsystem-device=%04x",
797 ath10k_bus_str(ar->hif.bus), 856 ath10k_bus_str(ar->hif.bus),
798 ar->id.vendor, ar->id.device, 857 ar->id.vendor, ar->id.device,
799 ar->id.subsystem_vendor, ar->id.subsystem_device); 858 ar->id.subsystem_vendor, ar->id.subsystem_device);
800 859
860out:
801 ath10k_dbg(ar, ATH10K_DBG_BOOT, "boot using board name '%s'\n", name); 861 ath10k_dbg(ar, ATH10K_DBG_BOOT, "boot using board name '%s'\n", name);
802 862
803 return 0; 863 return 0;
@@ -1060,12 +1120,6 @@ static int ath10k_core_fetch_firmware_files(struct ath10k *ar)
1060 /* calibration file is optional, don't check for any errors */ 1120 /* calibration file is optional, don't check for any errors */
1061 ath10k_fetch_cal_file(ar); 1121 ath10k_fetch_cal_file(ar);
1062 1122
1063 ret = ath10k_core_fetch_board_file(ar);
1064 if (ret) {
1065 ath10k_err(ar, "failed to fetch board file: %d\n", ret);
1066 return ret;
1067 }
1068
1069 ar->fw_api = 5; 1123 ar->fw_api = 5;
1070 ath10k_dbg(ar, ATH10K_DBG_BOOT, "trying fw api %d\n", ar->fw_api); 1124 ath10k_dbg(ar, ATH10K_DBG_BOOT, "trying fw api %d\n", ar->fw_api);
1071 1125
@@ -1675,6 +1729,19 @@ static int ath10k_core_probe_fw(struct ath10k *ar)
1675 goto err_power_down; 1729 goto err_power_down;
1676 } 1730 }
1677 1731
1732 ret = ath10k_core_get_board_id_from_otp(ar);
1733 if (ret && ret != -EOPNOTSUPP) {
1734 ath10k_err(ar, "failed to get board id from otp for qca99x0: %d\n",
1735 ret);
1736 return ret;
1737 }
1738
1739 ret = ath10k_core_fetch_board_file(ar);
1740 if (ret) {
1741 ath10k_err(ar, "failed to fetch board file: %d\n", ret);
1742 goto err_free_firmware_files;
1743 }
1744
1678 ret = ath10k_core_init_firmware_features(ar); 1745 ret = ath10k_core_init_firmware_features(ar);
1679 if (ret) { 1746 if (ret) {
1680 ath10k_err(ar, "fatal problem with firmware features: %d\n", 1747 ath10k_err(ar, "fatal problem with firmware features: %d\n",
diff --git a/drivers/net/wireless/ath/ath10k/core.h b/drivers/net/wireless/ath/ath10k/core.h
index af5c0d741659..7cc7cdd56c95 100644
--- a/drivers/net/wireless/ath/ath10k/core.h
+++ b/drivers/net/wireless/ath/ath10k/core.h
@@ -681,6 +681,10 @@ struct ath10k {
681 u32 device; 681 u32 device;
682 u32 subsystem_vendor; 682 u32 subsystem_vendor;
683 u32 subsystem_device; 683 u32 subsystem_device;
684
685 bool bmi_ids_valid;
686 u8 bmi_board_id;
687 u8 bmi_chip_id;
684 } id; 688 } id;
685 689
686 int fw_api; 690 int fw_api;
diff --git a/drivers/net/wireless/ath/ath10k/debug.c b/drivers/net/wireless/ath/ath10k/debug.c
index 7e8f6511b232..eab71e2eb4d7 100644
--- a/drivers/net/wireless/ath/ath10k/debug.c
+++ b/drivers/net/wireless/ath/ath10k/debug.c
@@ -129,8 +129,12 @@ void ath10k_print_driver_info(struct ath10k *ar)
129 129
130 ath10k_core_get_fw_features_str(ar, fw_features, sizeof(fw_features)); 130 ath10k_core_get_fw_features_str(ar, fw_features, sizeof(fw_features));
131 131
132 scnprintf(boardinfo, sizeof(boardinfo), "sub %04x:%04x", 132 if (ar->id.bmi_ids_valid)
133 ar->id.subsystem_vendor, ar->id.subsystem_device); 133 scnprintf(boardinfo, sizeof(boardinfo), "bmi %d:%d",
134 ar->id.bmi_chip_id, ar->id.bmi_board_id);
135 else
136 scnprintf(boardinfo, sizeof(boardinfo), "sub %04x:%04x",
137 ar->id.subsystem_vendor, ar->id.subsystem_device);
134 138
135 ath10k_info(ar, "%s (0x%08x, 0x%08x %s) fw %s fwapi %d bdapi %d htt-ver %d.%d wmi-op %d htt-op %d cal %s max-sta %d raw %d hwcrypto %d features %s\n", 139 ath10k_info(ar, "%s (0x%08x, 0x%08x %s) fw %s fwapi %d bdapi %d htt-ver %d.%d wmi-op %d htt-op %d cal %s max-sta %d raw %d hwcrypto %d features %s\n",
136 ar->hw_params.name, 140 ar->hw_params.name,