Skip to contentSkip to conversation

ath10k: add bmi_read32/bmi_write32 functions

PATCH New Janusz Dziedzic 2 participants 3 messages Apr 18, 2013 – Apr 22, 2013 Qualcomm Atheros ATH10K wireless driver

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ath10k: add bmi_read32/bmi_write32 functions

Add ath10k_bmi_read32/ath10k_bmi_write32 functions and use them in core layer when read32/write32.

---
 drivers/net/wireless/ath/ath10k/bmi.h  |   27 +++++++++++
 drivers/net/wireless/ath/ath10k/core.c |   79 +++++++++-----------------------
 2 files changed, 49 insertions(+), 57 deletions(-)
drivers/net/wireless/ath/ath10k/bmi.h +27 -0
index e2bd70b..f431589 100644
@@ -191,6 +191,33 @@ int ath10k_bmi_read_memory(struct ath10k *ar, u32 address,
 			   void *buffer, u32 length);
 int ath10k_bmi_write_memory(struct ath10k *ar, u32 address,
 			    const void *buffer, u32 length);
+
+#define ath10k_bmi_read32(ar, item, val)				\
+	({								\
+		int ret;						\
+		u32 addr;						\
+		__le32 tmp;						\
+									\
+		addr = host_interest_item_address(ar->target_type,	\
+						  HI_ITEM(item));	\
+		ret = ath10k_bmi_read_memory(ar, addr, (u8 *) &tmp, 4); \
+		*val = __le32_to_cpu(tmp);				\
+		ret;							\
+	 })
+
+#define ath10k_bmi_write32(ar, item, val)				\
+	({ 								\
+		int ret;						\
+		u32 address;						\
+		__le32 v = __cpu_to_le32(val);				\
+									\
+		address = host_interest_item_address(ar->target_type,	\
+						     HI_ITEM(item));	\
+		ret = ath10k_bmi_write_memory(ar, address,		\
+					     (u8 *) &v, sizeof(v));	\
+		ret;							\
+	})
+
 int ath10k_bmi_execute(struct ath10k *ar, u32 address, u32 *param);
 int ath10k_bmi_lz_stream_start(struct ath10k *ar, u32 address);
 int ath10k_bmi_lz_data(struct ath10k *ar, const void *buffer, u32 length);
drivers/net/wireless/ath/ath10k/core.c +22 -57

173 lines not on this page · raw message

Signature · 1 line
1.7.9.5
Applied
#1 lore raw

PATCH 1/1 ath10k: add bmi_read32/bmi_write32 functions

Quoted 4 lines · Janusz Dziedzic

Add ath10k_bmi_read32/ath10k_bmi_write32 functions and use them in core layer when read32/write32.

Thanks, applied.

But can you do a followup patch, please:

Quoted 2 lines
drivers/net/wireless/ath/ath10k/core.c +2 -0
+	param_host = HTC_PROTOCOL_VERSION;
+	ret = ath10k_bmi_write32(ar, hi_app_host_interest, param_host);

[...]

Quoted 6 lines
drivers/net/wireless/ath/ath10k/core.c +2 -3
+	param_host = 0;
 	/* We do all byte-swapping on the host */
-	host_addr = host_interest_item_address(ar->target_type,
-					       HI_ITEM(hi_be));
-	ret = ath10k_bmi_write_memory(ar, host_addr, (u8 *)&param_target, 4);
+	ret = ath10k_bmi_write32(ar, hi_be, param_host);

[...]

Quoted 2 lines
(quoted diff) +2 -0
+	param_host = 0;
+	ret = ath10k_bmi_write32(ar, hi_fw_swap, param_host);

[...]

Quoted 2 lines
drivers/net/wireless/ath/ath10k/core.c +2 -0
+			param_host = (board_ext_data_size << 16) | 1;
+			ath10k_bmi_write32(ar, hi_board_ext_data_config, param_host);

[...]

Quoted 2 lines
drivers/net/wireless/ath/ath10k/core.c +2 -0
+	param_host = 1;
+	ath10k_bmi_write32(ar, hi_board_data_initialized, param_host);

[...]

Quoted 5 lines
drivers/net/wireless/ath/ath10k/core.c +5 -0
+		param_host = 7;
+		ath10k_bmi_write32(ar, hi_dbg_uart_txpin, param_host);
+
+		param_host = 1;
+		ath10k_bmi_write32(ar, hi_serial_enable, param_host);

[...]

drivers/net/wireless/ath/ath10k/core.c static int ath10k_init_download_firmware(struct ath10k *ar) · line 396

Quoted 2 lines
drivers/net/wireless/ath/ath10k/core.c +2 -0
+		param_host = 0;
+		ath10k_bmi_write32(ar, hi_serial_enable, param_host);

In the cases above the use of param_host variable is not really needed. For example, in the last case you can simplify the code like this:

ath10k_bmi_write32(ar, hi_serial_enable, 0);

It's a lot more comfortable to read code like that.

Signature · 1 line
Kalle Valo
#2 lore raw

PATCH 1/1 ath10k: add bmi_read32/bmi_write32 functions

Quoted 64 lines

-----Original Message-----
From: Kalle Valo [mailto:kvalo at qca.qualcomm.com]
Sent: 22 kwietnia 2013 12:12
To: Dziedzic Janusz
Cc: ath9k-devel at lists.ath9k.org
Subject: Re: [ath9k-devel] [PATCH] ath10k: add bmi_read32/bmi_write32 functions

Quoted 4 lines · Janusz Dziedzic

Add ath10k_bmi_read32/ath10k_bmi_write32 functions and use them in core layer when read32/write32.

Thanks, applied.

But can you do a followup patch, please:

Quoted 2 lines
drivers/net/wireless/ath/ath10k/core.c +2 -0
+	param_host = HTC_PROTOCOL_VERSION;
+	ret = ath10k_bmi_write32(ar, hi_app_host_interest, param_host);

[...]

drivers/net/wireless/ath/ath10k/core.c static int ath10k_init_configure_target(struct ath10k *ar)

Quoted 5 lines
drivers/net/wireless/ath/ath10k/core.c +1 -3
+	param_host = 0;
 	/* We do all byte-swapping on the host */
-	host_addr = host_interest_item_address(ar->target_type,
-					       HI_ITEM(hi_be));
-	ret = ath10k_bmi_write_memory(ar, host_addr, (u8

*)&param_target, 4);

Quoted 1 line
drivers/net/wireless/ath/ath10k/core.c +1 -0
+	ret = ath10k_bmi_write32(ar, hi_be, param_host);

[...]

Quoted 2 lines
(quoted diff) +2 -0
+	param_host = 0;
+	ret = ath10k_bmi_write32(ar, hi_fw_swap, param_host);

[...]

Review

Quoted 2 lines
(quoted diff) +2 -0
+			param_host = (board_ext_data_size << 16) | 1;
+			ath10k_bmi_write32(ar, hi_board_ext_data_config,

param_host);

[...]

Quoted 2 lines
drivers/net/wireless/ath/ath10k/core.c +2 -0
+	param_host = 1;
+	ath10k_bmi_write32(ar, hi_board_data_initialized, param_host);

[...]

Quoted 5 lines
drivers/net/wireless/ath/ath10k/core.c +5 -0
+		param_host = 7;
+		ath10k_bmi_write32(ar, hi_dbg_uart_txpin, param_host);
+
+		param_host = 1;
+		ath10k_bmi_write32(ar, hi_serial_enable, param_host);

[...]

drivers/net/wireless/ath/ath10k/core.c static int ath10k_init_download_firmware(struct ath10k *ar) · line 396

Quoted 2 lines
drivers/net/wireless/ath/ath10k/core.c +2 -0
+		param_host = 0;
+		ath10k_bmi_write32(ar, hi_serial_enable, param_host);

In the cases above the use of param_host variable is not really needed. For example, in the last case you can simplify the code like this:

Quoted 4 lines

ath10k_bmi_write32(ar, hi_serial_enable, 0);

It's a lot more comfortable to read code like that.

Sure, will do.

BR
Janusz