All of lore.kernel.org
 help / color / mirror / Atom feed
* [ath9k-devel] [PATCH] ath10k: add bmi_read32/bmi_write32 function
@ 2013-04-18  8:08 Janusz Dziedzic
  2013-04-18  8:16 ` Michal Kazior
  0 siblings, 1 reply; 4+ messages in thread
From: Janusz Dziedzic @ 2013-04-18  8:08 UTC (permalink / raw)
  To: ath9k-devel

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

Signed-off-by: Janusz Dziedzic <janusz.dziedzic@tieto.com>
---
 drivers/net/wireless/ath/ath10k/bmi.h  |   10 ++++++++++
 drivers/net/wireless/ath/ath10k/core.c |   24 ++++++++++++------------
 2 files changed, 22 insertions(+), 12 deletions(-)

diff --git a/drivers/net/wireless/ath/ath10k/bmi.h b/drivers/net/wireless/ath/ath10k/bmi.h
index e2bd70b..2035d5d 100644
--- a/drivers/net/wireless/ath/ath10k/bmi.h
+++ b/drivers/net/wireless/ath/ath10k/bmi.h
@@ -191,6 +191,16 @@ 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);
+static inline int ath10k_bmi_read32(struct ath10k *ar, u32 address,
+				    void *buffer)
+{
+	return ath10k_bmi_read_memory(ar, address, buffer, sizeof(u32));
+}
+static inline int ath10k_bmi_write32(struct ath10k *ar, u32 address,
+				     void *buffer)
+{
+	return ath10k_bmi_write_memory(ar, address, buffer, sizeof(u32));
+}
 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);
diff --git a/drivers/net/wireless/ath/ath10k/core.c b/drivers/net/wireless/ath/ath10k/core.c
index 213c851..0934a29 100644
--- a/drivers/net/wireless/ath/ath10k/core.c
+++ b/drivers/net/wireless/ath/ath10k/core.c
@@ -150,7 +150,7 @@ static int ath10k_init_configure_target(struct ath10k *ar)
 	param_target = __cpu_to_le32(HTC_PROTOCOL_VERSION);
 	host_addr = host_interest_item_address(ar->target_type,
 					       HI_ITEM(hi_app_host_interest));
-	ret = ath10k_bmi_write_memory(ar, host_addr, (u8 *)&param_target, 4);
+	ret = ath10k_bmi_write32(ar, host_addr, (u8 *)&param_target);
 	if (ret) {
 		ath10k_err("settings HTC version failed\n");
 		return ret;
@@ -159,7 +159,7 @@ static int ath10k_init_configure_target(struct ath10k *ar)
 	/* set the firmware mode to STA/IBSS/AP */
 	host_addr = host_interest_item_address(ar->target_type,
 					       HI_ITEM(hi_option_flag));
-	ret = ath10k_bmi_read_memory(ar, host_addr, (u8 *)&param_target, 4);
+	ret = ath10k_bmi_read32(ar, host_addr, (u8 *)&param_target);
 	param_host = __le32_to_cpu(param_target);
 	if (ret) {
 		ath10k_err("setting firmware mode (1/2) failed\n");
@@ -182,7 +182,7 @@ static int ath10k_init_configure_target(struct ath10k *ar)
 	param_target = __cpu_to_le32(param_host);
 	host_addr = host_interest_item_address(ar->target_type,
 					       HI_ITEM(hi_option_flag));
-	ret = ath10k_bmi_write_memory(ar, host_addr, (u8 *)&param_target, 4);
+	ret = ath10k_bmi_write32(ar, host_addr, (u8 *)&param_target);
 	if (ret) {
 		ath10k_err("setting firmware mode (2/2) failed\n");
 		return ret;
@@ -192,7 +192,7 @@ static int ath10k_init_configure_target(struct ath10k *ar)
 	/* 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, host_addr, (u8 *)&param_target);
 	if (ret) {
 		ath10k_err("setting host CPU BE mode failed\n");
 		return ret;
@@ -202,7 +202,7 @@ static int ath10k_init_configure_target(struct ath10k *ar)
 	param_target = __cpu_to_le32(0);
 	host_addr = host_interest_item_address(ar->target_type,
 					       HI_ITEM(hi_fw_swap));
-	ret = ath10k_bmi_write_memory(ar, host_addr, (u8 *)&param_target, 4);
+	ret = ath10k_bmi_write32(ar, host_addr, (u8 *)&param_target);
 
 	if (ret) {
 		ath10k_err("setting FW data/desc swap flags failed\n");
@@ -296,7 +296,7 @@ static int ath10k_init_transfer_bin_file(struct ath10k *ar,
 		/* Determine where in Target RAM to write Board Data */
 		host_addr = host_interest_item_address(ar->target_type,
 						       HI_ITEM(hi_board_ext_data));
-		ath10k_bmi_read_memory(ar, host_addr, (u8 *)&param_target, 4);
+		ath10k_bmi_read32(ar, host_addr, (u8 *)&param_target);
 		board_ext_address = __le32_to_cpu(param_target);
 
 		ath10k_dbg(ATH10K_DBG_BOOT,
@@ -327,7 +327,7 @@ static int ath10k_init_transfer_bin_file(struct ath10k *ar,
 			param_target = __cpu_to_le32((board_ext_data_size << 16) | 1);
 			host_addr = host_interest_item_address(ar->target_type,
 							       HI_ITEM(hi_board_ext_data_config));
-			ath10k_bmi_write_memory(ar, host_addr, (u8 *)&param_target, 4);
+			ath10k_bmi_write32(ar, host_addr, (u8 *)&param_target);
 
 			fw_entry_size = board_data_size;
 		}
@@ -368,7 +368,7 @@ static int ath10k_init_download_firmware(struct ath10k *ar)
 	/* Determine where in Target RAM to write Board Data */
 	host_addr = host_interest_item_address(ar->target_type,
 					       HI_ITEM(hi_board_data));
-	ath10k_bmi_read_memory(ar, host_addr, (u8 *)&param_target, 4);
+	ath10k_bmi_read32(ar, host_addr, (u8 *)&param_target);
 	address = __le32_to_cpu(param_target);
 
 	if (!address) {
@@ -388,7 +388,7 @@ static int ath10k_init_download_firmware(struct ath10k *ar)
 	param_target = __cpu_to_le32(1);
 	host_addr = host_interest_item_address(ar->target_type,
 					       HI_ITEM(hi_board_data_initialized));
-	ath10k_bmi_write_memory(ar, host_addr, (u8 *)&param_target, 4);
+	ath10k_bmi_write32(ar, host_addr, (u8 *)&param_target);
 
 	/* Transfer One Time Programmable data */
 	address = ar->hw_params.patch_load_addr;
@@ -419,12 +419,12 @@ static int ath10k_init_download_firmware(struct ath10k *ar)
 		param_target = __cpu_to_le32(7);
 		host_addr = host_interest_item_address(ar->target_type,
 						       HI_ITEM(hi_dbg_uart_txpin));
-		ath10k_bmi_write_memory(ar, host_addr, (u8 *)&param_target, 4);
+		ath10k_bmi_write32(ar, host_addr, (u8 *)&param_target);
 
 		param_target = __cpu_to_le32(1);
 		host_addr = host_interest_item_address(ar->target_type,
 						       HI_ITEM(hi_serial_enable));
-		ath10k_bmi_write_memory(ar, host_addr, (u8 *)&param_target, 4);
+		ath10k_bmi_write32(ar, host_addr, (u8 *)&param_target);
 	} else {
 		/*
 		 * Explicitly setting UART prints to zero as target turns it on
@@ -433,7 +433,7 @@ static int ath10k_init_download_firmware(struct ath10k *ar)
 		param_target = __cpu_to_le32(0);
 		host_addr = host_interest_item_address(ar->target_type,
 						       HI_ITEM(hi_serial_enable));
-		ath10k_bmi_write_memory(ar, host_addr, (u8 *)&param_target, 4);
+		ath10k_bmi_write32(ar, host_addr, (u8 *)&param_target);
 	}
 
 	ath10k_dbg(ATH10K_DBG_CORE, "Firmware downloaded\n");
-- 
1.7.9.5

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [ath9k-devel] [PATCH] ath10k: add bmi_read32/bmi_write32 function
  2013-04-18  8:08 [ath9k-devel] [PATCH] ath10k: add bmi_read32/bmi_write32 function Janusz Dziedzic
@ 2013-04-18  8:16 ` Michal Kazior
  2013-04-18  8:23   ` Janusz.Dziedzic at tieto.com
  2013-04-18 10:53   ` Kalle Valo
  0 siblings, 2 replies; 4+ messages in thread
From: Michal Kazior @ 2013-04-18  8:16 UTC (permalink / raw)
  To: ath9k-devel

On 18/04/13 10:08, Janusz Dziedzic wrote:
> Add ath10k_bmi_read32/ath10k_bmi_write32 functions
> and use them in core layer when read32/write32.
>
> Signed-off-by: Janusz Dziedzic <janusz.dziedzic@tieto.com>
> ---
>   drivers/net/wireless/ath/ath10k/bmi.h  |   10 ++++++++++
>   drivers/net/wireless/ath/ath10k/core.c |   24 ++++++++++++------------
>   2 files changed, 22 insertions(+), 12 deletions(-)
>
> diff --git a/drivers/net/wireless/ath/ath10k/bmi.h b/drivers/net/wireless/ath/ath10k/bmi.h
> index e2bd70b..2035d5d 100644
> --- a/drivers/net/wireless/ath/ath10k/bmi.h
> +++ b/drivers/net/wireless/ath/ath10k/bmi.h
> @@ -191,6 +191,16 @@ 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);
> +static inline int ath10k_bmi_read32(struct ath10k *ar, u32 address,
> +				    void *buffer)
> +{
> +	return ath10k_bmi_read_memory(ar, address, buffer, sizeof(u32));
> +}
> +static inline int ath10k_bmi_write32(struct ath10k *ar, u32 address,
> +				     void *buffer)
> +{
> +	return ath10k_bmi_write_memory(ar, address, buffer, sizeof(u32));
> +}

I think these functions should do endianess converions so it is not 
necessary at call sites anymore.

Also the buffer could be a u32* instead of a void* implicitly stating 
what the functions are meant to do.


-- Pozdrawiam / Best regards, Michal Kazior.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [ath9k-devel] [PATCH] ath10k: add bmi_read32/bmi_write32 function
  2013-04-18  8:16 ` Michal Kazior
@ 2013-04-18  8:23   ` Janusz.Dziedzic at tieto.com
  2013-04-18 10:53   ` Kalle Valo
  1 sibling, 0 replies; 4+ messages in thread
From: Janusz.Dziedzic at tieto.com @ 2013-04-18  8:23 UTC (permalink / raw)
  To: ath9k-devel

>-----Original Message-----
From: ath9k-devel-bounces@lists.ath9k.org [mailto:ath9k-devel-
>bounces at lists.ath9k.org] On Behalf Of Michal Kazior
>Sent: 18 kwietnia 2013 10:17
>To: ath9k-devel at lists.ath9k.org
>Subject: Re: [ath9k-devel] [PATCH] ath10k: add bmi_read32/bmi_write32
>function
>
>On 18/04/13 10:08, Janusz Dziedzic wrote:
>> Add ath10k_bmi_read32/ath10k_bmi_write32 functions and use them in
>> core layer when read32/write32.
>>
>> Signed-off-by: Janusz Dziedzic <janusz.dziedzic@tieto.com>
>> ---
>>   drivers/net/wireless/ath/ath10k/bmi.h  |   10 ++++++++++
>>   drivers/net/wireless/ath/ath10k/core.c |   24 ++++++++++++------------
>>   2 files changed, 22 insertions(+), 12 deletions(-)
>>
>> diff --git a/drivers/net/wireless/ath/ath10k/bmi.h
>> b/drivers/net/wireless/ath/ath10k/bmi.h
>> index e2bd70b..2035d5d 100644
>> --- a/drivers/net/wireless/ath/ath10k/bmi.h
>> +++ b/drivers/net/wireless/ath/ath10k/bmi.h
>> @@ -191,6 +191,16 @@ 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);
>> +static inline int ath10k_bmi_read32(struct ath10k *ar, u32 address,
>> +				    void *buffer)
>> +{
>> +	return ath10k_bmi_read_memory(ar, address, buffer, sizeof(u32)); }
>> +static inline int ath10k_bmi_write32(struct ath10k *ar, u32 address,
>> +				     void *buffer)
>> +{
>> +	return ath10k_bmi_write_memory(ar, address, buffer, sizeof(u32)); }
>
>I think these functions should do endianess converions so it is not necessary
>at call sites anymore.
>
>Also the buffer could be a u32* instead of a void* implicitly stating what the
>functions are meant to do.
>
OK, I will also change parameters list here and will move host_interest_item_address() to bmi layer.
So, seems more work required here.

BR
Janusz

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [ath9k-devel] [PATCH] ath10k: add bmi_read32/bmi_write32 function
  2013-04-18  8:16 ` Michal Kazior
  2013-04-18  8:23   ` Janusz.Dziedzic at tieto.com
@ 2013-04-18 10:53   ` Kalle Valo
  1 sibling, 0 replies; 4+ messages in thread
From: Kalle Valo @ 2013-04-18 10:53 UTC (permalink / raw)
  To: ath9k-devel

Michal Kazior <michal.kazior@tieto.com> writes:

> On 18/04/13 10:08, Janusz Dziedzic wrote:
>> Add ath10k_bmi_read32/ath10k_bmi_write32 functions
>> and use them in core layer when read32/write32.
>>
>> Signed-off-by: Janusz Dziedzic <janusz.dziedzic@tieto.com>
>> ---
>>   drivers/net/wireless/ath/ath10k/bmi.h  |   10 ++++++++++
>>   drivers/net/wireless/ath/ath10k/core.c |   24 ++++++++++++------------
>>   2 files changed, 22 insertions(+), 12 deletions(-)
>>
>> diff --git a/drivers/net/wireless/ath/ath10k/bmi.h b/drivers/net/wireless/ath/ath10k/bmi.h
>> index e2bd70b..2035d5d 100644
>> --- a/drivers/net/wireless/ath/ath10k/bmi.h
>> +++ b/drivers/net/wireless/ath/ath10k/bmi.h
>> @@ -191,6 +191,16 @@ 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);
>> +static inline int ath10k_bmi_read32(struct ath10k *ar, u32 address,
>> +				    void *buffer)
>> +{
>> +	return ath10k_bmi_read_memory(ar, address, buffer, sizeof(u32));
>> +}
>> +static inline int ath10k_bmi_write32(struct ath10k *ar, u32 address,
>> +				     void *buffer)
>> +{
>> +	return ath10k_bmi_write_memory(ar, address, buffer, sizeof(u32));
>> +}
>
> I think these functions should do endianess converions so it is not 
> necessary at call sites anymore.
>
> Also the buffer could be a u32* instead of a void* implicitly stating 
> what the functions are meant to do.

Yeah, the idea is that the wrappers simplify writing to registers
instead of duplicating the same code in every register access.

I think we can just follow what ath6kl does:

#define ath6kl_bmi_write_hi32(ar, item, val)				\
	({								\
		u32 addr;						\
		__le32 v;						\
									\
		addr = ath6kl_get_hi_item_addr(ar, HI_ITEM(item));	\
		v = cpu_to_le32(val);					\
		ath6kl_bmi_write(ar, addr, (u8 *) &v, sizeof(v));	\
	})

#define ath6kl_bmi_read_hi32(ar, item, val)				\
	({								\
		u32 addr, *check_type = val;				\
		__le32 tmp;						\
		int ret;						\
									\
		(void) (check_type == val);				\
		addr = ath6kl_get_hi_item_addr(ar, HI_ITEM(item));	\
		ret = ath6kl_bmi_read(ar, addr, (u8 *) &tmp, 4);	\
		*val = le32_to_cpu(tmp);				\
		ret;							\
	})

-- 
Kalle Valo

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2013-04-18 10:53 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-04-18  8:08 [ath9k-devel] [PATCH] ath10k: add bmi_read32/bmi_write32 function Janusz Dziedzic
2013-04-18  8:16 ` Michal Kazior
2013-04-18  8:23   ` Janusz.Dziedzic at tieto.com
2013-04-18 10:53   ` Kalle Valo

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.