Linux wireless drivers development
 help / color / mirror / Atom feed
From: Kalle Valo <kvalo@qca.qualcomm.com>
To: kvalo@qca.qualcomm.com
Cc: linux-wireless@vger.kernel.org
Subject: [PATCH 08/10] ath6kl: add firmware filename info to struct ath6kl_hw
Date: Mon, 14 Nov 2011 19:31:23 +0200	[thread overview]
Message-ID: <20111114173123.29925.51892.stgit@localhost6.localdomain6> (raw)
In-Reply-To: <20111114172836.29925.4134.stgit@localhost6.localdomain6>

Signed-off-by: Kalle Valo <kvalo@qca.qualcomm.com>
---
 drivers/net/wireless/ath/ath6kl/core.h |    8 ++
 drivers/net/wireless/ath/ath6kl/init.c |  149 +++++++++++++-------------------
 2 files changed, 67 insertions(+), 90 deletions(-)

diff --git a/drivers/net/wireless/ath/ath6kl/core.h b/drivers/net/wireless/ath/ath6kl/core.h
index b14ad11..1697c00 100644
--- a/drivers/net/wireless/ath/ath6kl/core.h
+++ b/drivers/net/wireless/ath/ath6kl/core.h
@@ -553,6 +553,14 @@ struct ath6kl {
 		u32 board_ext_data_addr;
 		u32 reserved_ram_size;
 		u32 board_addr;
+
+		const char *fw_otp;
+		const char *fw;
+		const char *fw_tcmd;
+		const char *fw_patch;
+		const char *fw_api2;
+		const char *fw_board;
+		const char *fw_default_board;
 	} hw;
 
 	u16 conf_flags;
diff --git a/drivers/net/wireless/ath/ath6kl/init.c b/drivers/net/wireless/ath/ath6kl/init.c
index 208e77e..9d6e50d 100644
--- a/drivers/net/wireless/ath/ath6kl/init.c
+++ b/drivers/net/wireless/ath/ath6kl/init.c
@@ -44,6 +44,14 @@ static const struct ath6kl_hw hw_list[] = {
 
 		/* hw2.0 needs override address hardcoded */
 		.app_start_override_addr	= 0x944C00,
+
+		.fw_otp			= AR6003_HW_2_0_OTP_FILE,
+		.fw			= AR6003_HW_2_0_FIRMWARE_FILE,
+		.fw_tcmd		= AR6003_HW_2_0_TCMD_FIRMWARE_FILE,
+		.fw_patch		= AR6003_HW_2_0_PATCH_FILE,
+		.fw_api2		= AR6003_HW_2_0_FIRMWARE_2_FILE,
+		.fw_board		= AR6003_HW_2_0_BOARD_DATA_FILE,
+		.fw_default_board	= AR6003_HW_2_0_DEFAULT_BOARD_DATA_FILE,
 	},
 	{
 		.id				= AR6003_HW_2_1_1_VERSION,
@@ -52,6 +60,14 @@ static const struct ath6kl_hw hw_list[] = {
 		.app_load_addr			= 0x1234,
 		.board_ext_data_addr		= 0x542330,
 		.reserved_ram_size		= 512,
+
+		.fw_otp			= AR6003_HW_2_1_1_OTP_FILE,
+		.fw			= AR6003_HW_2_1_1_FIRMWARE_FILE,
+		.fw_tcmd		= AR6003_HW_2_1_1_TCMD_FIRMWARE_FILE,
+		.fw_patch		= AR6003_HW_2_1_1_PATCH_FILE,
+		.fw_api2		= AR6003_HW_2_1_1_FIRMWARE_2_FILE,
+		.fw_board		= AR6003_HW_2_1_1_BOARD_DATA_FILE,
+		.fw_default_board	= AR6003_HW_2_1_1_DEFAULT_BOARD_DATA_FILE,
 	},
 	{
 		.id				= AR6004_HW_1_0_VERSION,
@@ -61,6 +77,11 @@ static const struct ath6kl_hw hw_list[] = {
 		.board_ext_data_addr		= 0x437000,
 		.reserved_ram_size		= 19456,
 		.board_addr			= 0x433900,
+
+		.fw			= AR6004_HW_1_0_FIRMWARE_FILE,
+		.fw_api2		= AR6004_HW_1_0_FIRMWARE_2_FILE,
+		.fw_board		= AR6004_HW_1_0_BOARD_DATA_FILE,
+		.fw_default_board	= AR6004_HW_1_0_DEFAULT_BOARD_DATA_FILE,
 	},
 	{
 		.id				= AR6004_HW_1_1_VERSION,
@@ -70,6 +91,11 @@ static const struct ath6kl_hw hw_list[] = {
 		.board_ext_data_addr		= 0x437000,
 		.reserved_ram_size		= 11264,
 		.board_addr			= 0x43d400,
+
+		.fw			= AR6004_HW_1_1_FIRMWARE_FILE,
+		.fw_api2		= AR6004_HW_1_1_FIRMWARE_2_FILE,
+		.fw_board		= AR6004_HW_1_1_BOARD_DATA_FILE,
+		.fw_default_board	= AR6004_HW_1_1_DEFAULT_BOARD_DATA_FILE,
 	},
 };
 
@@ -652,17 +678,10 @@ static int ath6kl_fetch_board_file(struct ath6kl *ar)
 	if (ar->fw_board != NULL)
 		return 0;
 
-	switch (ar->version.target_ver) {
-	case AR6003_HW_2_0_VERSION:
-		filename = AR6003_HW_2_0_BOARD_DATA_FILE;
-		break;
-	case AR6004_HW_1_0_VERSION:
-		filename = AR6004_HW_1_0_BOARD_DATA_FILE;
-		break;
-	default:
-		filename = AR6003_HW_2_1_1_BOARD_DATA_FILE;
-		break;
-	}
+	if (WARN_ON(ar->hw.fw_board == NULL))
+		return -EINVAL;
+
+	filename = ar->hw.fw_board;
 
 	ret = ath6kl_get_fw(ar, filename, &ar->fw_board,
 			    &ar->fw_board_len);
@@ -680,17 +699,7 @@ static int ath6kl_fetch_board_file(struct ath6kl *ar)
 	ath6kl_warn("Failed to get board file %s (%d), trying to find default board file.\n",
 		    filename, ret);
 
-	switch (ar->version.target_ver) {
-	case AR6003_HW_2_0_VERSION:
-		filename = AR6003_HW_2_0_DEFAULT_BOARD_DATA_FILE;
-		break;
-	case AR6004_HW_1_0_VERSION:
-		filename = AR6004_HW_1_0_DEFAULT_BOARD_DATA_FILE;
-		break;
-	default:
-		filename = AR6003_HW_2_1_1_DEFAULT_BOARD_DATA_FILE;
-		break;
-	}
+	filename = ar->hw.fw_default_board;
 
 	ret = ath6kl_get_fw(ar, filename, &ar->fw_board,
 			    &ar->fw_board_len);
@@ -714,19 +723,14 @@ static int ath6kl_fetch_otp_file(struct ath6kl *ar)
 	if (ar->fw_otp != NULL)
 		return 0;
 
-	switch (ar->version.target_ver) {
-	case AR6003_HW_2_0_VERSION:
-		filename = AR6003_HW_2_0_OTP_FILE;
-		break;
-	case AR6004_HW_1_0_VERSION:
-		ath6kl_dbg(ATH6KL_DBG_TRC, "AR6004 doesn't need OTP file\n");
+	if (ar->hw.fw_otp == NULL) {
+		ath6kl_dbg(ATH6KL_DBG_BOOT,
+			   "no OTP file configured for this hw\n");
 		return 0;
-		break;
-	default:
-		filename = AR6003_HW_2_1_1_OTP_FILE;
-		break;
 	}
 
+	filename = ar->hw.fw_otp;
+
 	ret = ath6kl_get_fw(ar, filename, &ar->fw_otp,
 			    &ar->fw_otp_len);
 	if (ret) {
@@ -747,38 +751,22 @@ static int ath6kl_fetch_fw_file(struct ath6kl *ar)
 		return 0;
 
 	if (testmode) {
-		switch (ar->version.target_ver) {
-		case AR6003_HW_2_0_VERSION:
-			filename = AR6003_HW_2_0_TCMD_FIRMWARE_FILE;
-			break;
-		case AR6003_HW_2_1_1_VERSION:
-			filename = AR6003_HW_2_1_1_TCMD_FIRMWARE_FILE;
-			break;
-		case AR6004_HW_1_0_VERSION:
-			ath6kl_warn("testmode not supported with ar6004\n");
+		if (ar->hw.fw_tcmd == NULL) {
+			ath6kl_warn("testmode not supported\n");
 			return -EOPNOTSUPP;
-		default:
-			ath6kl_warn("unknown target version: 0x%x\n",
-				       ar->version.target_ver);
-			return -EINVAL;
 		}
 
+		filename = ar->hw.fw_tcmd;
+
 		set_bit(TESTMODE, &ar->flag);
 
 		goto get_fw;
 	}
 
-	switch (ar->version.target_ver) {
-	case AR6003_HW_2_0_VERSION:
-		filename = AR6003_HW_2_0_FIRMWARE_FILE;
-		break;
-	case AR6004_HW_1_0_VERSION:
-		filename = AR6004_HW_1_0_FIRMWARE_FILE;
-		break;
-	default:
-		filename = AR6003_HW_2_1_1_FIRMWARE_FILE;
-		break;
-	}
+	if (WARN_ON(ar->hw.fw == NULL))
+		return -EINVAL;
+
+	filename = ar->hw.fw;
 
 get_fw:
 	ret = ath6kl_get_fw(ar, filename, &ar->fw, &ar->fw_len);
@@ -796,27 +784,20 @@ static int ath6kl_fetch_patch_file(struct ath6kl *ar)
 	const char *filename;
 	int ret;
 
-	switch (ar->version.target_ver) {
-	case AR6003_HW_2_0_VERSION:
-		filename = AR6003_HW_2_0_PATCH_FILE;
-		break;
-	case AR6004_HW_1_0_VERSION:
-		/* FIXME: implement for AR6004 */
+	if (ar->fw_patch != NULL)
 		return 0;
-		break;
-	default:
-		filename = AR6003_HW_2_1_1_PATCH_FILE;
-		break;
-	}
 
-	if (ar->fw_patch == NULL) {
-		ret = ath6kl_get_fw(ar, filename, &ar->fw_patch,
-				    &ar->fw_patch_len);
-		if (ret) {
-			ath6kl_err("Failed to get patch file %s: %d\n",
-				   filename, ret);
-			return ret;
-		}
+	if (ar->hw.fw_patch == NULL)
+		return 0;
+
+	filename = ar->hw.fw_patch;
+
+	ret = ath6kl_get_fw(ar, filename, &ar->fw_patch,
+			    &ar->fw_patch_len);
+	if (ret) {
+		ath6kl_err("Failed to get patch file %s: %d\n",
+			   filename, ret);
+		return ret;
 	}
 
 	return 0;
@@ -851,22 +832,10 @@ static int ath6kl_fetch_fw_api2(struct ath6kl *ar)
 	int ret, ie_id, i, index, bit;
 	__le32 *val;
 
-	switch (ar->version.target_ver) {
-	case AR6003_HW_2_0_VERSION:
-		filename = AR6003_HW_2_0_FIRMWARE_2_FILE;
-		break;
-	case AR6003_HW_2_1_1_VERSION:
-		filename = AR6003_HW_2_1_1_FIRMWARE_2_FILE;
-		break;
-	case AR6004_HW_1_0_VERSION:
-		filename = AR6004_HW_1_0_FIRMWARE_2_FILE;
-		break;
-	case AR6004_HW_1_1_VERSION:
-		filename = AR6004_HW_1_1_FIRMWARE_2_FILE;
-		break;
-	default:
+	if (ar->hw.fw_api2 == NULL)
 		return -EOPNOTSUPP;
-	}
+
+	filename = ar->hw.fw_api2;
 
 	ret = request_firmware(&fw, filename, ar->dev);
 	if (ret)


  parent reply	other threads:[~2011-11-14 17:31 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-11-14 17:29 [PATCH 00/10] ath6kl: configurable board address and multivif Kalle Valo
2011-11-14 17:30 ` [PATCH 01/10] ath6kl: remove hw version related parameter defines Kalle Valo
2011-11-14 17:30 ` [PATCH 02/10] ath6kl: move hw version related to parameters to struct Kalle Valo
2011-11-14 17:30 ` [PATCH 03/10] ath6kl: add board address to struct ath6kl_hw Kalle Valo
2011-11-14 17:30 ` [PATCH 04/10] ath6kl: add firmware IE for board data address Kalle Valo
2011-11-14 17:30 ` [PATCH 05/10] ath6kl: add name field to struct ath6kl_hw Kalle Valo
2011-11-14 17:31 ` [PATCH 06/10] ath6kl: use hardware version names consistently Kalle Valo
2011-11-14 17:31 ` [PATCH 07/10] ath6kl: add ar6004 firmwares to sdio module Kalle Valo
2011-11-14 17:31 ` Kalle Valo [this message]
2011-11-14 17:31 ` [PATCH 09/10] ath6kl: make maximum number of vifs runtime configurable Kalle Valo
2011-11-14 17:31 ` [PATCH 10/10] ath6kl: add firmware IE for maximum number of vifs Kalle Valo
2011-11-16  8:37 ` [PATCH 00/10] ath6kl: configurable board address and multivif 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=20111114173123.29925.51892.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