diff options
author | Larry Finger <Larry.Finger@lwfinger.net> | 2017-01-19 23:28:06 +0300 |
---|---|---|
committer | Kalle Valo <kvalo@codeaurora.org> | 2017-01-20 13:06:09 +0300 |
commit | 89d32c9071aacdd7f631c36ff9c7d3403229d568 (patch) | |
tree | 740148bebbdd542127a607e5d79504de2fc1a2b2 /drivers/net/wireless/realtek/rtlwifi/rtl8723com | |
parent | 9336d376edf131e00ef986741afc134b114cfc37 (diff) | |
download | linux-89d32c9071aacdd7f631c36ff9c7d3403229d568.tar.xz |
rtlwifi: Download firmware as bytes rather than as dwords
The firmware is read from disk as a little-endian byte string. The code
that loads the firmware into the device transfers it as 4-byte quantities.
The routines that write multi-byte quantities on BE hardware assume that
the data are in CPU order, and automatically do the conversion to the LE
order required by the device. As a result, the firmware is transmitted
incorrectly. Rather than do multiple byte swaps on the data, the download
routine is revised to transmit bytes rather than dwords. Although the
number of I/O operations is increased, the firmware is not often loaded.
All drivers have the same bug, and use essentially the same code to
download firmware. These routines have been moved into rtlwifi.
Some CamelCase variables have been renamed.
Signed-off-by: Larry Finger <Larry.Finger@lwfinger.net>
Cc: Ping-Ke Shih <pkshih@realtek.com>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
Diffstat (limited to 'drivers/net/wireless/realtek/rtlwifi/rtl8723com')
-rw-r--r-- | drivers/net/wireless/realtek/rtlwifi/rtl8723com/fw_common.c | 69 | ||||
-rw-r--r-- | drivers/net/wireless/realtek/rtlwifi/rtl8723com/fw_common.h | 6 |
2 files changed, 5 insertions, 70 deletions
diff --git a/drivers/net/wireless/realtek/rtlwifi/rtl8723com/fw_common.c b/drivers/net/wireless/realtek/rtlwifi/rtl8723com/fw_common.c index 8e0d038df701..ac573d69f6d6 100644 --- a/drivers/net/wireless/realtek/rtlwifi/rtl8723com/fw_common.c +++ b/drivers/net/wireless/realtek/rtlwifi/rtl8723com/fw_common.c @@ -26,6 +26,7 @@ #include "../wifi.h" #include "../pci.h" #include "../base.h" +#include "../efuse.h" #include "fw_common.h" #include <linux/module.h> @@ -53,65 +54,6 @@ void rtl8723_enable_fw_download(struct ieee80211_hw *hw, bool enable) } EXPORT_SYMBOL_GPL(rtl8723_enable_fw_download); -void rtl8723_fw_block_write(struct ieee80211_hw *hw, - const u8 *buffer, u32 size) -{ - struct rtl_priv *rtlpriv = rtl_priv(hw); - u32 blocksize = sizeof(u32); - u8 *bufferptr = (u8 *)buffer; - u32 *pu4byteptr = (u32 *)buffer; - u32 i, offset, blockcount, remainsize; - - blockcount = size / blocksize; - remainsize = size % blocksize; - - for (i = 0; i < blockcount; i++) { - offset = i * blocksize; - rtl_write_dword(rtlpriv, (FW_8192C_START_ADDRESS + offset), - *(pu4byteptr + i)); - } - if (remainsize) { - offset = blockcount * blocksize; - bufferptr += offset; - for (i = 0; i < remainsize; i++) { - rtl_write_byte(rtlpriv, - (FW_8192C_START_ADDRESS + offset + i), - *(bufferptr + i)); - } - } -} -EXPORT_SYMBOL_GPL(rtl8723_fw_block_write); - -void rtl8723_fw_page_write(struct ieee80211_hw *hw, - u32 page, const u8 *buffer, u32 size) -{ - struct rtl_priv *rtlpriv = rtl_priv(hw); - u8 value8; - u8 u8page = (u8) (page & 0x07); - - value8 = (rtl_read_byte(rtlpriv, REG_MCUFWDL + 2) & 0xF8) | u8page; - - rtl_write_byte(rtlpriv, (REG_MCUFWDL + 2), value8); - rtl8723_fw_block_write(hw, buffer, size); -} -EXPORT_SYMBOL_GPL(rtl8723_fw_page_write); - -void rtl8723_fill_dummy(u8 *pfwbuf, u32 *pfwlen) -{ - u32 fwlen = *pfwlen; - u8 remain = (u8) (fwlen % 4); - - remain = (remain == 0) ? 0 : (4 - remain); - - while (remain > 0) { - pfwbuf[fwlen] = 0; - fwlen++; - remain--; - } - *pfwlen = fwlen; -} -EXPORT_SYMBOL(rtl8723_fill_dummy); - void rtl8723_write_fw(struct ieee80211_hw *hw, enum version_8723e version, u8 *buffer, u32 size, u8 max_page) @@ -123,7 +65,7 @@ void rtl8723_write_fw(struct ieee80211_hw *hw, RT_TRACE(rtlpriv, COMP_FW, DBG_TRACE, "FW size is %d bytes,\n", size); - rtl8723_fill_dummy(bufferptr, &size); + rtl_fill_dummy(bufferptr, &size); page_nums = size / FW_8192C_PAGE_SIZE; remain_size = size % FW_8192C_PAGE_SIZE; @@ -134,15 +76,14 @@ void rtl8723_write_fw(struct ieee80211_hw *hw, } for (page = 0; page < page_nums; page++) { offset = page * FW_8192C_PAGE_SIZE; - rtl8723_fw_page_write(hw, page, (bufferptr + offset), - FW_8192C_PAGE_SIZE); + rtl_fw_page_write(hw, page, (bufferptr + offset), + FW_8192C_PAGE_SIZE); } if (remain_size) { offset = page_nums * FW_8192C_PAGE_SIZE; page = page_nums; - rtl8723_fw_page_write(hw, page, (bufferptr + offset), - remain_size); + rtl_fw_page_write(hw, page, (bufferptr + offset), remain_size); } RT_TRACE(rtlpriv, COMP_FW, DBG_TRACE, "FW write done.\n"); } diff --git a/drivers/net/wireless/realtek/rtlwifi/rtl8723com/fw_common.h b/drivers/net/wireless/realtek/rtlwifi/rtl8723com/fw_common.h index 8ea372d1626e..77c25a976233 100644 --- a/drivers/net/wireless/realtek/rtlwifi/rtl8723com/fw_common.h +++ b/drivers/net/wireless/realtek/rtlwifi/rtl8723com/fw_common.h @@ -28,7 +28,6 @@ #define REG_SYS_FUNC_EN 0x0002 #define REG_MCUFWDL 0x0080 -#define FW_8192C_START_ADDRESS 0x1000 #define FW_8192C_PAGE_SIZE 4096 #define FW_8723A_POLLING_TIMEOUT_COUNT 1000 #define FW_8723B_POLLING_TIMEOUT_COUNT 6000 @@ -84,10 +83,6 @@ enum rtl8723be_cmd { void rtl8723ae_firmware_selfreset(struct ieee80211_hw *hw); void rtl8723be_firmware_selfreset(struct ieee80211_hw *hw); void rtl8723_enable_fw_download(struct ieee80211_hw *hw, bool enable); -void rtl8723_fw_block_write(struct ieee80211_hw *hw, - const u8 *buffer, u32 size); -void rtl8723_fw_page_write(struct ieee80211_hw *hw, - u32 page, const u8 *buffer, u32 size); void rtl8723_write_fw(struct ieee80211_hw *hw, enum version_8723e version, u8 *buffer, u32 size, u8 max_page); @@ -95,6 +90,5 @@ int rtl8723_fw_free_to_go(struct ieee80211_hw *hw, bool is_8723be, int count); int rtl8723_download_fw(struct ieee80211_hw *hw, bool is_8723be, int count); bool rtl8723_cmd_send_packet(struct ieee80211_hw *hw, struct sk_buff *skb); -void rtl8723_fill_dummy(u8 *pfwbuf, u32 *pfwlen); #endif |