From: Kalle Valo <kvalo@qca.qualcomm.com>
To: linux-wireless@vger.kernel.org
Subject: [PATCH 1/9] ath6kl: query device tree for firmware board-id
Date: Mon, 12 Sep 2011 14:12:06 +0300 [thread overview]
Message-ID: <20110912111206.16921.90687.stgit@localhost6.localdomain6> (raw)
From: Sam Leffler <sleffler@chromium.org>
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>
---
drivers/net/wireless/ath/ath6kl/init.c | 64 ++++++++++++++++++++++++++++++++
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 eca34aa..9171670 100644
--- a/drivers/net/wireless/ath/ath6kl/init.c
+++ b/drivers/net/wireless/ath/ath6kl/init.c
@@ -15,6 +15,7 @@
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
+#include <linux/of.h>
#include <linux/mmc/sdio_func.h>
#include "core.h"
#include "cfg80211.h"
@@ -680,6 +681,64 @@ static int ath6kl_get_fw(struct ath6kl *ar, const char *filename,
return ret;
}
+#ifdef CONFIG_OF
+static const char *get_target_ver_dir(const struct ath6kl *ar)
+{
+ switch (ar->version.target_ver) {
+ case AR6003_REV1_VERSION:
+ return "ath6k/AR6003/hw1.0";
+ case AR6003_REV2_VERSION:
+ return "ath6k/AR6003/hw2.0";
+ case AR6003_REV3_VERSION:
+ return "ath6k/AR6003/hw2.1.1";
+ }
+ ath6kl_warn("%s: unsupported target version 0x%x.\n", __func__,
+ ar->version.target_ver);
+ return NULL;
+}
+
+/*
+ * Check the device tree for a board-id and use it to construct
+ * the pathname to the firmware file. Used (for now) to find a
+ * fallback to the "bdata.bin" file--typically a symlink to the
+ * appropriate board-specific file.
+ */
+static bool check_device_tree(struct ath6kl *ar)
+{
+ static const char *board_id_prop = "atheros,board-id";
+ struct device_node *node;
+ char board_filename[64];
+ const char *board_id;
+ int ret;
+
+ for_each_compatible_node(node, NULL, "atheros,ath6kl") {
+ board_id = of_get_property(node, board_id_prop, NULL);
+ if (board_id == NULL) {
+ ath6kl_warn("No \"%s\" property on %s node.\n",
+ board_id_prop, node->name);
+ continue;
+ }
+ snprintf(board_filename, sizeof(board_filename),
+ "%s/bdata.%s.bin", get_target_ver_dir(ar), board_id);
+
+ ret = ath6kl_get_fw(ar, board_filename, &ar->fw_board,
+ &ar->fw_board_len);
+ if (ret) {
+ ath6kl_err("Failed to get DT board file %s: %d\n",
+ board_filename, ret);
+ continue;
+ }
+ return true;
+ }
+ return false;
+}
+#else
+static bool check_device_tree(struct ath6kl *ar)
+{
+ return false;
+}
+#endif /* CONFIG_OF */
+
static int ath6kl_fetch_board_file(struct ath6kl *ar)
{
const char *filename;
@@ -704,6 +763,11 @@ static int ath6kl_fetch_board_file(struct ath6kl *ar)
return 0;
}
+ if (check_device_tree(ar)) {
+ /* got board file from device tree */
+ return 0;
+ }
+
/* there was no proper board file, try to use default instead */
ath6kl_warn("Failed to get board file %s (%d), trying to find default board file.\n",
filename, ret);
next reply other threads:[~2011-09-12 11:12 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-09-12 11:12 Kalle Valo [this message]
2011-09-12 11:12 ` [PATCH 2/9] ath6kl: separate firmware fetch from upload Kalle Valo
2011-09-12 11:12 ` [PATCH 3/9] ath6kl: fix busy loop in ath6kl_bmi_get_rx_lkahd() Kalle Valo
2011-09-12 11:12 ` [PATCH 4/9] ath6kl: add support for firmware API 2 format Kalle Valo
2011-09-12 11:12 ` [PATCH 5/9] ath6kl: refactor firmware load address code Kalle Valo
2011-09-12 11:12 ` [PATCH 6/9] ath6kl: refactor firmware ext data addr and reserved ram handling size Kalle Valo
2011-09-12 11:12 ` [PATCH 7/9] ath6kl: read firmware start address from hardware Kalle Valo
2011-09-12 11:13 ` [PATCH 8/9] ath6kl: read reserved ram size from firmware file Kalle Valo
2011-09-12 11:13 ` [PATCH 9/9] ath6kl: add firmware capabilities support Kalle Valo
2011-09-15 13:37 ` [PATCH 1/9] ath6kl: query device tree for firmware board-id Kalle Valo
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20110912111206.16921.90687.stgit@localhost6.localdomain6 \
--to=kvalo@qca.qualcomm.com \
--cc=linux-wireless@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox