aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSam Leffler <sleffler@chromium.org>2011-09-07 03:55:16 -0400
committerKalle Valo <kvalo@qca.qualcomm.com>2011-09-16 11:48:34 -0400
commit92ecbff48e3993ca58525533dc58ec1025c45609 (patch)
tree2c58a24632e7e50cdf935aa089cb3db7d74a8419
parent6bbc7c35ed0fb61c7739e91d5ee7016455770511 (diff)
ath6kl: query device tree for firmware board-id
When no default board data file is present query the device tree for a board-id setting to identify the board data to use. If the FDT lacks the necesary info fall back to the previous behaviour of using a compile-time board filename. Signed-off-by: Sam Leffler <sleffler@chromium.org> Signed-off-by: Kalle Valo <kvalo@qca.qualcomm.com>
-rw-r--r--drivers/net/wireless/ath/ath6kl/init.c64
1 files changed, 64 insertions, 0 deletions
diff --git a/drivers/net/wireless/ath/ath6kl/init.c b/drivers/net/wireless/ath/ath6kl/init.c
index eca34aa6e4ba..91716709cac8 100644
--- a/drivers/net/wireless/ath/ath6kl/init.c
+++ b/drivers/net/wireless/ath/ath6kl/init.c
@@ -15,6 +15,7 @@
15 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 15 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16 */ 16 */
17 17
18#include <linux/of.h>
18#include <linux/mmc/sdio_func.h> 19#include <linux/mmc/sdio_func.h>
19#include "core.h" 20#include "core.h"
20#include "cfg80211.h" 21#include "cfg80211.h"
@@ -680,6 +681,64 @@ static int ath6kl_get_fw(struct ath6kl *ar, const char *filename,
680 return ret; 681 return ret;
681} 682}
682 683
684#ifdef CONFIG_OF
685static const char *get_target_ver_dir(const struct ath6kl *ar)
686{
687 switch (ar->version.target_ver) {
688 case AR6003_REV1_VERSION:
689 return "ath6k/AR6003/hw1.0";
690 case AR6003_REV2_VERSION:
691 return "ath6k/AR6003/hw2.0";
692 case AR6003_REV3_VERSION:
693 return "ath6k/AR6003/hw2.1.1";
694 }
695 ath6kl_warn("%s: unsupported target version 0x%x.\n", __func__,
696 ar->version.target_ver);
697 return NULL;
698}
699
700/*
701 * Check the device tree for a board-id and use it to construct
702 * the pathname to the firmware file. Used (for now) to find a
703 * fallback to the "bdata.bin" file--typically a symlink to the
704 * appropriate board-specific file.
705 */
706static bool check_device_tree(struct ath6kl *ar)
707{
708 static const char *board_id_prop = "atheros,board-id";
709 struct device_node *node;
710 char board_filename[64];
711 const char *board_id;
712 int ret;
713
714 for_each_compatible_node(node, NULL, "atheros,ath6kl") {
715 board_id = of_get_property(node, board_id_prop, NULL);
716 if (board_id == NULL) {
717 ath6kl_warn("No \"%s\" property on %s node.\n",
718 board_id_prop, node->name);
719 continue;
720 }
721 snprintf(board_filename, sizeof(board_filename),
722 "%s/bdata.%s.bin", get_target_ver_dir(ar), board_id);
723
724 ret = ath6kl_get_fw(ar, board_filename, &ar->fw_board,
725 &ar->fw_board_len);
726 if (ret) {
727 ath6kl_err("Failed to get DT board file %s: %d\n",
728 board_filename, ret);
729 continue;
730 }
731 return true;
732 }
733 return false;
734}
735#else
736static bool check_device_tree(struct ath6kl *ar)
737{
738 return false;
739}
740#endif /* CONFIG_OF */
741
683static int ath6kl_fetch_board_file(struct ath6kl *ar) 742static int ath6kl_fetch_board_file(struct ath6kl *ar)
684{ 743{
685 const char *filename; 744 const char *filename;
@@ -704,6 +763,11 @@ static int ath6kl_fetch_board_file(struct ath6kl *ar)
704 return 0; 763 return 0;
705 } 764 }
706 765
766 if (check_device_tree(ar)) {
767 /* got board file from device tree */
768 return 0;
769 }
770
707 /* there was no proper board file, try to use default instead */ 771 /* there was no proper board file, try to use default instead */
708 ath6kl_warn("Failed to get board file %s (%d), trying to find default board file.\n", 772 ath6kl_warn("Failed to get board file %s (%d), trying to find default board file.\n",
709 filename, ret); 773 filename, ret);