Larry Finger | aa45a67 | 2014-02-28 15:16:43 -0600 | [diff] [blame] | 1 | /****************************************************************************** |
| 2 | * |
| 3 | * Copyright(c) 2009-2014 Realtek Corporation. |
| 4 | * |
| 5 | * This program is free software; you can redistribute it and/or modify it |
| 6 | * under the terms of version 2 of the GNU General Public License as |
| 7 | * published by the Free Software Foundation. |
| 8 | * |
| 9 | * This program is distributed in the hope that it will be useful, but WITHOUT |
| 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
| 11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for |
| 12 | * more details. |
| 13 | * |
| 14 | * The full GNU General Public License is included in this distribution in the |
| 15 | * file called LICENSE. |
| 16 | * |
| 17 | * Contact Information: |
| 18 | * wlanfae <wlanfae@realtek.com> |
| 19 | * Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park, |
| 20 | * Hsinchu 300, Taiwan. |
| 21 | * |
| 22 | * Larry Finger <Larry.Finger@lwfinger.net> |
| 23 | * |
| 24 | *****************************************************************************/ |
| 25 | |
| 26 | #include "../wifi.h" |
Larry Finger | cbd0c85 | 2014-02-28 15:16:48 -0600 | [diff] [blame] | 27 | #include "../pci.h" |
| 28 | #include "../base.h" |
Larry Finger | aa45a67 | 2014-02-28 15:16:43 -0600 | [diff] [blame] | 29 | #include "fw_common.h" |
| 30 | #include <linux/module.h> |
| 31 | |
Larry Finger | aa45a67 | 2014-02-28 15:16:43 -0600 | [diff] [blame] | 32 | void rtl8723_enable_fw_download(struct ieee80211_hw *hw, bool enable) |
| 33 | { |
| 34 | struct rtl_priv *rtlpriv = rtl_priv(hw); |
| 35 | u8 tmp; |
| 36 | |
| 37 | if (enable) { |
| 38 | tmp = rtl_read_byte(rtlpriv, REG_SYS_FUNC_EN + 1); |
Larry Finger | 0529c6b | 2014-09-26 16:40:24 -0500 | [diff] [blame] | 39 | rtl_write_byte(rtlpriv, REG_SYS_FUNC_EN + 1, |
| 40 | tmp | 0x04); |
Larry Finger | aa45a67 | 2014-02-28 15:16:43 -0600 | [diff] [blame] | 41 | |
| 42 | tmp = rtl_read_byte(rtlpriv, REG_MCUFWDL); |
| 43 | rtl_write_byte(rtlpriv, REG_MCUFWDL, tmp | 0x01); |
| 44 | |
| 45 | tmp = rtl_read_byte(rtlpriv, REG_MCUFWDL + 2); |
| 46 | rtl_write_byte(rtlpriv, REG_MCUFWDL + 2, tmp & 0xf7); |
| 47 | } else { |
| 48 | tmp = rtl_read_byte(rtlpriv, REG_MCUFWDL); |
| 49 | rtl_write_byte(rtlpriv, REG_MCUFWDL, tmp & 0xfe); |
| 50 | |
| 51 | rtl_write_byte(rtlpriv, REG_MCUFWDL + 1, 0x00); |
| 52 | } |
| 53 | } |
| 54 | EXPORT_SYMBOL_GPL(rtl8723_enable_fw_download); |
| 55 | |
| 56 | void rtl8723_fw_block_write(struct ieee80211_hw *hw, |
| 57 | const u8 *buffer, u32 size) |
| 58 | { |
| 59 | struct rtl_priv *rtlpriv = rtl_priv(hw); |
| 60 | u32 blocksize = sizeof(u32); |
| 61 | u8 *bufferptr = (u8 *)buffer; |
| 62 | u32 *pu4byteptr = (u32 *)buffer; |
| 63 | u32 i, offset, blockcount, remainsize; |
| 64 | |
| 65 | blockcount = size / blocksize; |
| 66 | remainsize = size % blocksize; |
| 67 | |
| 68 | for (i = 0; i < blockcount; i++) { |
| 69 | offset = i * blocksize; |
| 70 | rtl_write_dword(rtlpriv, (FW_8192C_START_ADDRESS + offset), |
| 71 | *(pu4byteptr + i)); |
| 72 | } |
| 73 | if (remainsize) { |
| 74 | offset = blockcount * blocksize; |
| 75 | bufferptr += offset; |
| 76 | for (i = 0; i < remainsize; i++) { |
| 77 | rtl_write_byte(rtlpriv, |
| 78 | (FW_8192C_START_ADDRESS + offset + i), |
| 79 | *(bufferptr + i)); |
| 80 | } |
| 81 | } |
| 82 | } |
| 83 | EXPORT_SYMBOL_GPL(rtl8723_fw_block_write); |
| 84 | |
| 85 | void rtl8723_fw_page_write(struct ieee80211_hw *hw, |
| 86 | u32 page, const u8 *buffer, u32 size) |
| 87 | { |
| 88 | struct rtl_priv *rtlpriv = rtl_priv(hw); |
| 89 | u8 value8; |
| 90 | u8 u8page = (u8) (page & 0x07); |
| 91 | |
| 92 | value8 = (rtl_read_byte(rtlpriv, REG_MCUFWDL + 2) & 0xF8) | u8page; |
| 93 | |
| 94 | rtl_write_byte(rtlpriv, (REG_MCUFWDL + 2), value8); |
| 95 | rtl8723_fw_block_write(hw, buffer, size); |
| 96 | } |
| 97 | EXPORT_SYMBOL_GPL(rtl8723_fw_page_write); |
| 98 | |
Larry Finger | 0529c6b | 2014-09-26 16:40:24 -0500 | [diff] [blame] | 99 | void rtl8723_fill_dummy(u8 *pfwbuf, u32 *pfwlen) |
Larry Finger | aa45a67 | 2014-02-28 15:16:43 -0600 | [diff] [blame] | 100 | { |
| 101 | u32 fwlen = *pfwlen; |
| 102 | u8 remain = (u8) (fwlen % 4); |
| 103 | |
| 104 | remain = (remain == 0) ? 0 : (4 - remain); |
| 105 | |
| 106 | while (remain > 0) { |
| 107 | pfwbuf[fwlen] = 0; |
| 108 | fwlen++; |
| 109 | remain--; |
| 110 | } |
| 111 | *pfwlen = fwlen; |
| 112 | } |
Larry Finger | 0529c6b | 2014-09-26 16:40:24 -0500 | [diff] [blame] | 113 | EXPORT_SYMBOL(rtl8723_fill_dummy); |
Larry Finger | aa45a67 | 2014-02-28 15:16:43 -0600 | [diff] [blame] | 114 | |
| 115 | void rtl8723_write_fw(struct ieee80211_hw *hw, |
Larry Finger | cbd0c85 | 2014-02-28 15:16:48 -0600 | [diff] [blame] | 116 | enum version_8723e version, |
Larry Finger | 0529c6b | 2014-09-26 16:40:24 -0500 | [diff] [blame] | 117 | u8 *buffer, u32 size, u8 max_page) |
Larry Finger | aa45a67 | 2014-02-28 15:16:43 -0600 | [diff] [blame] | 118 | { |
| 119 | struct rtl_priv *rtlpriv = rtl_priv(hw); |
Joe Perches | 1851cb4 | 2014-03-24 13:15:40 -0700 | [diff] [blame] | 120 | u8 *bufferptr = buffer; |
Larry Finger | 0529c6b | 2014-09-26 16:40:24 -0500 | [diff] [blame] | 121 | u32 page_nums, remain_size; |
Larry Finger | aa45a67 | 2014-02-28 15:16:43 -0600 | [diff] [blame] | 122 | u32 page, offset; |
| 123 | |
Larry Finger | 0529c6b | 2014-09-26 16:40:24 -0500 | [diff] [blame] | 124 | RT_TRACE(rtlpriv, COMP_FW, DBG_TRACE, "FW size is %d bytes,\n", size); |
Larry Finger | aa45a67 | 2014-02-28 15:16:43 -0600 | [diff] [blame] | 125 | |
Larry Finger | cbd0c85 | 2014-02-28 15:16:48 -0600 | [diff] [blame] | 126 | rtl8723_fill_dummy(bufferptr, &size); |
Larry Finger | aa45a67 | 2014-02-28 15:16:43 -0600 | [diff] [blame] | 127 | |
Larry Finger | 0529c6b | 2014-09-26 16:40:24 -0500 | [diff] [blame] | 128 | page_nums = size / FW_8192C_PAGE_SIZE; |
| 129 | remain_size = size % FW_8192C_PAGE_SIZE; |
Larry Finger | aa45a67 | 2014-02-28 15:16:43 -0600 | [diff] [blame] | 130 | |
Larry Finger | 0529c6b | 2014-09-26 16:40:24 -0500 | [diff] [blame] | 131 | if (page_nums > max_page) { |
Larry Finger | aa45a67 | 2014-02-28 15:16:43 -0600 | [diff] [blame] | 132 | RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, |
Larry Finger | 0529c6b | 2014-09-26 16:40:24 -0500 | [diff] [blame] | 133 | "Page numbers should not greater than %d\n", max_page); |
Larry Finger | aa45a67 | 2014-02-28 15:16:43 -0600 | [diff] [blame] | 134 | } |
Larry Finger | 0529c6b | 2014-09-26 16:40:24 -0500 | [diff] [blame] | 135 | for (page = 0; page < page_nums; page++) { |
Larry Finger | aa45a67 | 2014-02-28 15:16:43 -0600 | [diff] [blame] | 136 | offset = page * FW_8192C_PAGE_SIZE; |
| 137 | rtl8723_fw_page_write(hw, page, (bufferptr + offset), |
| 138 | FW_8192C_PAGE_SIZE); |
| 139 | } |
Larry Finger | 0529c6b | 2014-09-26 16:40:24 -0500 | [diff] [blame] | 140 | |
| 141 | if (remain_size) { |
| 142 | offset = page_nums * FW_8192C_PAGE_SIZE; |
| 143 | page = page_nums; |
Larry Finger | aa45a67 | 2014-02-28 15:16:43 -0600 | [diff] [blame] | 144 | rtl8723_fw_page_write(hw, page, (bufferptr + offset), |
Larry Finger | 0529c6b | 2014-09-26 16:40:24 -0500 | [diff] [blame] | 145 | remain_size); |
Larry Finger | aa45a67 | 2014-02-28 15:16:43 -0600 | [diff] [blame] | 146 | } |
Larry Finger | 0529c6b | 2014-09-26 16:40:24 -0500 | [diff] [blame] | 147 | RT_TRACE(rtlpriv, COMP_FW, DBG_TRACE, "FW write done.\n"); |
Larry Finger | aa45a67 | 2014-02-28 15:16:43 -0600 | [diff] [blame] | 148 | } |
| 149 | EXPORT_SYMBOL_GPL(rtl8723_write_fw); |
| 150 | |
| 151 | void rtl8723ae_firmware_selfreset(struct ieee80211_hw *hw) |
| 152 | { |
Larry Finger | 0529c6b | 2014-09-26 16:40:24 -0500 | [diff] [blame] | 153 | u8 u1b_tmp; |
Larry Finger | aa45a67 | 2014-02-28 15:16:43 -0600 | [diff] [blame] | 154 | u8 delay = 100; |
| 155 | struct rtl_priv *rtlpriv = rtl_priv(hw); |
| 156 | |
| 157 | rtl_write_byte(rtlpriv, REG_HMETFR + 3, 0x20); |
Larry Finger | 0529c6b | 2014-09-26 16:40:24 -0500 | [diff] [blame] | 158 | u1b_tmp = rtl_read_byte(rtlpriv, REG_SYS_FUNC_EN + 1); |
Larry Finger | aa45a67 | 2014-02-28 15:16:43 -0600 | [diff] [blame] | 159 | |
Larry Finger | 0529c6b | 2014-09-26 16:40:24 -0500 | [diff] [blame] | 160 | while (u1b_tmp & BIT(2)) { |
Larry Finger | aa45a67 | 2014-02-28 15:16:43 -0600 | [diff] [blame] | 161 | delay--; |
| 162 | if (delay == 0) |
| 163 | break; |
| 164 | udelay(50); |
Larry Finger | 0529c6b | 2014-09-26 16:40:24 -0500 | [diff] [blame] | 165 | u1b_tmp = rtl_read_byte(rtlpriv, REG_SYS_FUNC_EN + 1); |
Larry Finger | aa45a67 | 2014-02-28 15:16:43 -0600 | [diff] [blame] | 166 | } |
| 167 | if (delay == 0) { |
Larry Finger | 0529c6b | 2014-09-26 16:40:24 -0500 | [diff] [blame] | 168 | u1b_tmp = rtl_read_byte(rtlpriv, REG_SYS_FUNC_EN + 1); |
| 169 | rtl_write_byte(rtlpriv, REG_SYS_FUNC_EN + 1, |
| 170 | u1b_tmp&(~BIT(2))); |
Larry Finger | aa45a67 | 2014-02-28 15:16:43 -0600 | [diff] [blame] | 171 | } |
| 172 | } |
| 173 | EXPORT_SYMBOL_GPL(rtl8723ae_firmware_selfreset); |
| 174 | |
| 175 | void rtl8723be_firmware_selfreset(struct ieee80211_hw *hw) |
| 176 | { |
| 177 | u8 u1b_tmp; |
| 178 | struct rtl_priv *rtlpriv = rtl_priv(hw); |
| 179 | |
| 180 | u1b_tmp = rtl_read_byte(rtlpriv, REG_RSV_CTRL + 1); |
| 181 | rtl_write_byte(rtlpriv, REG_RSV_CTRL + 1, (u1b_tmp & (~BIT(0)))); |
| 182 | |
| 183 | u1b_tmp = rtl_read_byte(rtlpriv, REG_SYS_FUNC_EN + 1); |
| 184 | rtl_write_byte(rtlpriv, REG_SYS_FUNC_EN + 1, (u1b_tmp & (~BIT(2)))); |
| 185 | udelay(50); |
| 186 | |
| 187 | u1b_tmp = rtl_read_byte(rtlpriv, REG_RSV_CTRL + 1); |
| 188 | rtl_write_byte(rtlpriv, REG_RSV_CTRL + 1, (u1b_tmp | BIT(0))); |
| 189 | |
| 190 | u1b_tmp = rtl_read_byte(rtlpriv, REG_SYS_FUNC_EN + 1); |
| 191 | rtl_write_byte(rtlpriv, REG_SYS_FUNC_EN + 1, (u1b_tmp | BIT(2))); |
| 192 | |
| 193 | RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, |
| 194 | " _8051Reset8723be(): 8051 reset success .\n"); |
| 195 | } |
| 196 | EXPORT_SYMBOL_GPL(rtl8723be_firmware_selfreset); |
| 197 | |
Larry Finger | 0529c6b | 2014-09-26 16:40:24 -0500 | [diff] [blame] | 198 | int rtl8723_fw_free_to_go(struct ieee80211_hw *hw, bool is_8723be, |
| 199 | int max_count) |
Larry Finger | aa45a67 | 2014-02-28 15:16:43 -0600 | [diff] [blame] | 200 | { |
| 201 | struct rtl_priv *rtlpriv = rtl_priv(hw); |
| 202 | int err = -EIO; |
| 203 | u32 counter = 0; |
| 204 | u32 value32; |
| 205 | |
| 206 | do { |
| 207 | value32 = rtl_read_dword(rtlpriv, REG_MCUFWDL); |
Larry Finger | 0529c6b | 2014-09-26 16:40:24 -0500 | [diff] [blame] | 208 | } while ((counter++ < max_count) && |
Larry Finger | aa45a67 | 2014-02-28 15:16:43 -0600 | [diff] [blame] | 209 | (!(value32 & FWDL_CHKSUM_RPT))); |
| 210 | |
Larry Finger | 0529c6b | 2014-09-26 16:40:24 -0500 | [diff] [blame] | 211 | if (counter >= max_count) { |
Larry Finger | aa45a67 | 2014-02-28 15:16:43 -0600 | [diff] [blame] | 212 | RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, |
Larry Finger | cbd0c85 | 2014-02-28 15:16:48 -0600 | [diff] [blame] | 213 | "chksum report fail ! REG_MCUFWDL:0x%08x .\n", |
Larry Finger | aa45a67 | 2014-02-28 15:16:43 -0600 | [diff] [blame] | 214 | value32); |
| 215 | goto exit; |
| 216 | } |
| 217 | RT_TRACE(rtlpriv, COMP_FW, DBG_TRACE, |
| 218 | "Checksum report OK ! REG_MCUFWDL:0x%08x .\n", value32); |
| 219 | |
Larry Finger | cbd0c85 | 2014-02-28 15:16:48 -0600 | [diff] [blame] | 220 | value32 = rtl_read_dword(rtlpriv, REG_MCUFWDL) | MCUFWDL_RDY; |
Larry Finger | aa45a67 | 2014-02-28 15:16:43 -0600 | [diff] [blame] | 221 | value32 &= ~WINTINI_RDY; |
| 222 | rtl_write_dword(rtlpriv, REG_MCUFWDL, value32); |
| 223 | |
| 224 | if (is_8723be) |
| 225 | rtl8723be_firmware_selfreset(hw); |
| 226 | counter = 0; |
| 227 | |
| 228 | do { |
| 229 | value32 = rtl_read_dword(rtlpriv, REG_MCUFWDL); |
| 230 | if (value32 & WINTINI_RDY) { |
| 231 | RT_TRACE(rtlpriv, COMP_FW, DBG_TRACE, |
Larry Finger | 0529c6b | 2014-09-26 16:40:24 -0500 | [diff] [blame] | 232 | "Polling FW ready success!! REG_MCUFWDL:0x%08x .\n", |
Larry Finger | aa45a67 | 2014-02-28 15:16:43 -0600 | [diff] [blame] | 233 | value32); |
| 234 | err = 0; |
| 235 | goto exit; |
| 236 | } |
Larry Finger | aa45a67 | 2014-02-28 15:16:43 -0600 | [diff] [blame] | 237 | |
Larry Finger | 0529c6b | 2014-09-26 16:40:24 -0500 | [diff] [blame] | 238 | mdelay(FW_8192C_POLLING_DELAY); |
| 239 | |
| 240 | } while (counter++ < max_count); |
Larry Finger | aa45a67 | 2014-02-28 15:16:43 -0600 | [diff] [blame] | 241 | |
| 242 | RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, |
| 243 | "Polling FW ready fail!! REG_MCUFWDL:0x%08x .\n", |
| 244 | value32); |
| 245 | |
| 246 | exit: |
| 247 | return err; |
| 248 | } |
| 249 | EXPORT_SYMBOL_GPL(rtl8723_fw_free_to_go); |
| 250 | |
| 251 | int rtl8723_download_fw(struct ieee80211_hw *hw, |
Larry Finger | 0529c6b | 2014-09-26 16:40:24 -0500 | [diff] [blame] | 252 | bool is_8723be, int max_count) |
Larry Finger | aa45a67 | 2014-02-28 15:16:43 -0600 | [diff] [blame] | 253 | { |
| 254 | struct rtl_priv *rtlpriv = rtl_priv(hw); |
| 255 | struct rtl_hal *rtlhal = rtl_hal(rtl_priv(hw)); |
Larry Finger | 7c24d08 | 2015-08-03 15:56:12 -0500 | [diff] [blame] | 256 | struct rtlwifi_firmware_header *pfwheader; |
Larry Finger | aa45a67 | 2014-02-28 15:16:43 -0600 | [diff] [blame] | 257 | u8 *pfwdata; |
| 258 | u32 fwsize; |
| 259 | int err; |
| 260 | enum version_8723e version = rtlhal->version; |
Larry Finger | 0529c6b | 2014-09-26 16:40:24 -0500 | [diff] [blame] | 261 | int max_page; |
Larry Finger | aa45a67 | 2014-02-28 15:16:43 -0600 | [diff] [blame] | 262 | |
| 263 | if (!rtlhal->pfirmware) |
| 264 | return 1; |
| 265 | |
Larry Finger | 7c24d08 | 2015-08-03 15:56:12 -0500 | [diff] [blame] | 266 | pfwheader = (struct rtlwifi_firmware_header *)rtlhal->pfirmware; |
Joe Perches | 1851cb4 | 2014-03-24 13:15:40 -0700 | [diff] [blame] | 267 | pfwdata = rtlhal->pfirmware; |
Larry Finger | aa45a67 | 2014-02-28 15:16:43 -0600 | [diff] [blame] | 268 | fwsize = rtlhal->fwsize; |
Larry Finger | aa45a67 | 2014-02-28 15:16:43 -0600 | [diff] [blame] | 269 | |
Larry Finger | 5c99f04 | 2014-09-26 16:40:25 -0500 | [diff] [blame] | 270 | if (!is_8723be) |
Larry Finger | 0529c6b | 2014-09-26 16:40:24 -0500 | [diff] [blame] | 271 | max_page = 6; |
| 272 | else |
| 273 | max_page = 8; |
Larry Finger | cbd0c85 | 2014-02-28 15:16:48 -0600 | [diff] [blame] | 274 | if (rtlpriv->cfg->ops->is_fw_header(pfwheader)) { |
Larry Finger | 1bae2ae | 2014-03-04 16:53:49 -0600 | [diff] [blame] | 275 | RT_TRACE(rtlpriv, COMP_FW, DBG_LOUD, |
Larry Finger | aa45a67 | 2014-02-28 15:16:43 -0600 | [diff] [blame] | 276 | "Firmware Version(%d), Signature(%#x), Size(%d)\n", |
| 277 | pfwheader->version, pfwheader->signature, |
Larry Finger | 7c24d08 | 2015-08-03 15:56:12 -0500 | [diff] [blame] | 278 | (int)sizeof(struct rtlwifi_firmware_header)); |
Larry Finger | aa45a67 | 2014-02-28 15:16:43 -0600 | [diff] [blame] | 279 | |
Larry Finger | 7c24d08 | 2015-08-03 15:56:12 -0500 | [diff] [blame] | 280 | pfwdata = pfwdata + sizeof(struct rtlwifi_firmware_header); |
| 281 | fwsize = fwsize - sizeof(struct rtlwifi_firmware_header); |
Larry Finger | aa45a67 | 2014-02-28 15:16:43 -0600 | [diff] [blame] | 282 | } |
Larry Finger | 0529c6b | 2014-09-26 16:40:24 -0500 | [diff] [blame] | 283 | |
| 284 | if (rtl_read_byte(rtlpriv, REG_MCUFWDL)&BIT(7)) { |
Larry Finger | aa45a67 | 2014-02-28 15:16:43 -0600 | [diff] [blame] | 285 | if (is_8723be) |
| 286 | rtl8723be_firmware_selfreset(hw); |
| 287 | else |
| 288 | rtl8723ae_firmware_selfreset(hw); |
Larry Finger | 0529c6b | 2014-09-26 16:40:24 -0500 | [diff] [blame] | 289 | rtl_write_byte(rtlpriv, REG_MCUFWDL, 0x00); |
Larry Finger | aa45a67 | 2014-02-28 15:16:43 -0600 | [diff] [blame] | 290 | } |
Larry Finger | cbd0c85 | 2014-02-28 15:16:48 -0600 | [diff] [blame] | 291 | rtl8723_enable_fw_download(hw, true); |
Larry Finger | 0529c6b | 2014-09-26 16:40:24 -0500 | [diff] [blame] | 292 | rtl8723_write_fw(hw, version, pfwdata, fwsize, max_page); |
Larry Finger | cbd0c85 | 2014-02-28 15:16:48 -0600 | [diff] [blame] | 293 | rtl8723_enable_fw_download(hw, false); |
Larry Finger | aa45a67 | 2014-02-28 15:16:43 -0600 | [diff] [blame] | 294 | |
Larry Finger | 0529c6b | 2014-09-26 16:40:24 -0500 | [diff] [blame] | 295 | err = rtl8723_fw_free_to_go(hw, is_8723be, max_count); |
Larry Finger | aa45a67 | 2014-02-28 15:16:43 -0600 | [diff] [blame] | 296 | if (err) { |
| 297 | RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, |
| 298 | "Firmware is not ready to run!\n"); |
| 299 | } else { |
Larry Finger | 0529c6b | 2014-09-26 16:40:24 -0500 | [diff] [blame] | 300 | RT_TRACE(rtlpriv, COMP_FW, DBG_TRACE, |
Larry Finger | aa45a67 | 2014-02-28 15:16:43 -0600 | [diff] [blame] | 301 | "Firmware is ready to run!\n"); |
| 302 | } |
| 303 | return 0; |
| 304 | } |
| 305 | EXPORT_SYMBOL_GPL(rtl8723_download_fw); |
| 306 | |
Larry Finger | aa45a67 | 2014-02-28 15:16:43 -0600 | [diff] [blame] | 307 | bool rtl8723_cmd_send_packet(struct ieee80211_hw *hw, |
| 308 | struct sk_buff *skb) |
| 309 | { |
| 310 | struct rtl_priv *rtlpriv = rtl_priv(hw); |
| 311 | struct rtl_pci *rtlpci = rtl_pcidev(rtl_pcipriv(hw)); |
| 312 | struct rtl8192_tx_ring *ring; |
| 313 | struct rtl_tx_desc *pdesc; |
| 314 | struct sk_buff *pskb = NULL; |
| 315 | u8 own; |
| 316 | unsigned long flags; |
| 317 | |
| 318 | ring = &rtlpci->tx_ring[BEACON_QUEUE]; |
| 319 | |
| 320 | pskb = __skb_dequeue(&ring->queue); |
| 321 | if (pskb) |
| 322 | kfree_skb(pskb); |
| 323 | |
| 324 | spin_lock_irqsave(&rtlpriv->locks.irq_th_lock, flags); |
| 325 | |
| 326 | pdesc = &ring->desc[0]; |
| 327 | own = (u8) rtlpriv->cfg->ops->get_desc((u8 *)pdesc, true, HW_DESC_OWN); |
| 328 | |
| 329 | rtlpriv->cfg->ops->fill_tx_cmddesc(hw, (u8 *)pdesc, 1, 1, skb); |
| 330 | |
| 331 | __skb_queue_tail(&ring->queue, skb); |
| 332 | |
| 333 | spin_unlock_irqrestore(&rtlpriv->locks.irq_th_lock, flags); |
| 334 | |
| 335 | rtlpriv->cfg->ops->tx_polling(hw, BEACON_QUEUE); |
| 336 | |
| 337 | return true; |
| 338 | } |
| 339 | EXPORT_SYMBOL_GPL(rtl8723_cmd_send_packet); |