| .. | .. |
|---|
| 1 | | -/****************************************************************************** |
|---|
| 2 | | - * |
|---|
| 3 | | - * Copyright(c) 2009-2012 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 | | - *****************************************************************************/ |
|---|
| 1 | +// SPDX-License-Identifier: GPL-2.0 |
|---|
| 2 | +/* Copyright(c) 2009-2012 Realtek Corporation.*/ |
|---|
| 25 | 3 | |
|---|
| 26 | 4 | #include "../wifi.h" |
|---|
| 27 | 5 | #include "../pci.h" |
|---|
| .. | .. |
|---|
| 61 | 39 | do { |
|---|
| 62 | 40 | cpustatus = rtl_read_byte(rtlpriv, TCR); |
|---|
| 63 | 41 | if (cpustatus & IMEM_RDY) { |
|---|
| 64 | | - RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, |
|---|
| 65 | | - "IMEM Ready after CPU has refilled\n"); |
|---|
| 42 | + rtl_dbg(rtlpriv, COMP_INIT, DBG_LOUD, |
|---|
| 43 | + "IMEM Ready after CPU has refilled\n"); |
|---|
| 66 | 44 | break; |
|---|
| 67 | 45 | } |
|---|
| 68 | 46 | |
|---|
| .. | .. |
|---|
| 158 | 136 | struct rtl_priv *rtlpriv = rtl_priv(hw); |
|---|
| 159 | 137 | struct sk_buff *skb; |
|---|
| 160 | 138 | struct rtl_tcb_desc *tcb_desc; |
|---|
| 161 | | - unsigned char *seg_ptr; |
|---|
| 162 | 139 | u16 frag_threshold = MAX_FIRMWARE_CODE_SIZE; |
|---|
| 163 | 140 | u16 frag_length, frag_offset = 0; |
|---|
| 164 | 141 | u16 extra_descoffset = 0; |
|---|
| .. | .. |
|---|
| 188 | 165 | if (!skb) |
|---|
| 189 | 166 | return false; |
|---|
| 190 | 167 | skb_reserve(skb, extra_descoffset); |
|---|
| 191 | | - seg_ptr = skb_put_data(skb, |
|---|
| 192 | | - code_virtual_address + frag_offset, |
|---|
| 193 | | - (u32)(frag_length - extra_descoffset)); |
|---|
| 168 | + skb_put_data(skb, code_virtual_address + frag_offset, |
|---|
| 169 | + (u32)(frag_length - extra_descoffset)); |
|---|
| 194 | 170 | |
|---|
| 195 | 171 | tcb_desc = (struct rtl_tcb_desc *)(skb->cb); |
|---|
| 196 | 172 | tcb_desc->queue_index = TXCMD_QUEUE; |
|---|
| .. | .. |
|---|
| 219 | 195 | short pollingcnt = 1000; |
|---|
| 220 | 196 | bool rtstatus = true; |
|---|
| 221 | 197 | |
|---|
| 222 | | - RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, |
|---|
| 223 | | - "LoadStaus(%d)\n", loadfw_status); |
|---|
| 198 | + rtl_dbg(rtlpriv, COMP_INIT, DBG_LOUD, |
|---|
| 199 | + "LoadStaus(%d)\n", loadfw_status); |
|---|
| 224 | 200 | |
|---|
| 225 | 201 | firmware->fwstatus = (enum fw_status)loadfw_status; |
|---|
| 226 | 202 | |
|---|
| .. | .. |
|---|
| 280 | 256 | goto status_check_fail; |
|---|
| 281 | 257 | } |
|---|
| 282 | 258 | |
|---|
| 283 | | - RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, |
|---|
| 284 | | - "DMEM code download success, cpustatus(%#x)\n", |
|---|
| 285 | | - cpustatus); |
|---|
| 259 | + rtl_dbg(rtlpriv, COMP_INIT, DBG_LOUD, |
|---|
| 260 | + "DMEM code download success, cpustatus(%#x)\n", |
|---|
| 261 | + cpustatus); |
|---|
| 286 | 262 | |
|---|
| 287 | 263 | /* Prevent Delay too much and being scheduled out */ |
|---|
| 288 | 264 | /* Polling Load Firmware ready */ |
|---|
| .. | .. |
|---|
| 294 | 270 | udelay(40); |
|---|
| 295 | 271 | } while (pollingcnt--); |
|---|
| 296 | 272 | |
|---|
| 297 | | - RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, |
|---|
| 298 | | - "Polling Load Firmware ready, cpustatus(%x)\n", |
|---|
| 299 | | - cpustatus); |
|---|
| 273 | + rtl_dbg(rtlpriv, COMP_INIT, DBG_LOUD, |
|---|
| 274 | + "Polling Load Firmware ready, cpustatus(%x)\n", |
|---|
| 275 | + cpustatus); |
|---|
| 300 | 276 | |
|---|
| 301 | 277 | if (((cpustatus & LOAD_FW_READY) != LOAD_FW_READY) || |
|---|
| 302 | 278 | (pollingcnt <= 0)) { |
|---|
| .. | .. |
|---|
| 314 | 290 | rtl_write_dword(rtlpriv, RCR, (tmpu4b | RCR_APPFCS | |
|---|
| 315 | 291 | RCR_APP_ICV | RCR_APP_MIC)); |
|---|
| 316 | 292 | |
|---|
| 317 | | - RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, |
|---|
| 318 | | - "Current RCR settings(%#x)\n", tmpu4b); |
|---|
| 293 | + rtl_dbg(rtlpriv, COMP_INIT, DBG_LOUD, |
|---|
| 294 | + "Current RCR settings(%#x)\n", tmpu4b); |
|---|
| 319 | 295 | |
|---|
| 320 | 296 | /* Set to normal mode. */ |
|---|
| 321 | 297 | rtl_write_byte(rtlpriv, LBKMD_SEL, LBK_NORMAL); |
|---|
| .. | .. |
|---|
| 328 | 304 | } |
|---|
| 329 | 305 | |
|---|
| 330 | 306 | status_check_fail: |
|---|
| 331 | | - RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, |
|---|
| 332 | | - "loadfw_status(%d), rtstatus(%x)\n", |
|---|
| 333 | | - loadfw_status, rtstatus); |
|---|
| 307 | + rtl_dbg(rtlpriv, COMP_INIT, DBG_LOUD, |
|---|
| 308 | + "loadfw_status(%d), rtstatus(%x)\n", |
|---|
| 309 | + loadfw_status, rtstatus); |
|---|
| 334 | 310 | return rtstatus; |
|---|
| 335 | 311 | } |
|---|
| 336 | 312 | |
|---|
| .. | .. |
|---|
| 361 | 337 | firmware->firmwareversion = byte(pfwheader->version, 0); |
|---|
| 362 | 338 | firmware->pfwheader->fwpriv.hci_sel = 1;/* pcie */ |
|---|
| 363 | 339 | |
|---|
| 364 | | - RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, |
|---|
| 365 | | - "signature:%x, version:%x, size:%x, imemsize:%x, sram size:%x\n", |
|---|
| 366 | | - pfwheader->signature, |
|---|
| 367 | | - pfwheader->version, pfwheader->dmem_size, |
|---|
| 368 | | - pfwheader->img_imem_size, pfwheader->img_sram_size); |
|---|
| 340 | + rtl_dbg(rtlpriv, COMP_INIT, DBG_LOUD, |
|---|
| 341 | + "signature:%x, version:%x, size:%x, imemsize:%x, sram size:%x\n", |
|---|
| 342 | + pfwheader->signature, |
|---|
| 343 | + pfwheader->version, pfwheader->dmem_size, |
|---|
| 344 | + pfwheader->img_imem_size, pfwheader->img_sram_size); |
|---|
| 369 | 345 | |
|---|
| 370 | 346 | /* 2. Retrieve IMEM image. */ |
|---|
| 371 | 347 | if ((pfwheader->img_imem_size == 0) || (pfwheader->img_imem_size > |
|---|
| .. | .. |
|---|
| 466 | 442 | memset((ph2c_buffer + totallen + tx_desclen), 0, len); |
|---|
| 467 | 443 | |
|---|
| 468 | 444 | /* CMD len */ |
|---|
| 469 | | - SET_BITS_TO_LE_4BYTE((ph2c_buffer + totallen + tx_desclen), |
|---|
| 470 | | - 0, 16, pcmd_len[i]); |
|---|
| 445 | + le32p_replace_bits((__le32 *)(ph2c_buffer + totallen + |
|---|
| 446 | + tx_desclen), pcmd_len[i], |
|---|
| 447 | + GENMASK(15, 0)); |
|---|
| 471 | 448 | |
|---|
| 472 | 449 | /* CMD ID */ |
|---|
| 473 | | - SET_BITS_TO_LE_4BYTE((ph2c_buffer + totallen + tx_desclen), |
|---|
| 474 | | - 16, 8, pelement_id[i]); |
|---|
| 450 | + le32p_replace_bits((__le32 *)(ph2c_buffer + totallen + |
|---|
| 451 | + tx_desclen), pelement_id[i], |
|---|
| 452 | + GENMASK(23, 16)); |
|---|
| 475 | 453 | |
|---|
| 476 | 454 | /* CMD Sequence */ |
|---|
| 477 | 455 | *cmd_start_seq = *cmd_start_seq % 0x80; |
|---|
| 478 | | - SET_BITS_TO_LE_4BYTE((ph2c_buffer + totallen + tx_desclen), |
|---|
| 479 | | - 24, 7, *cmd_start_seq); |
|---|
| 456 | + le32p_replace_bits((__le32 *)(ph2c_buffer + totallen + |
|---|
| 457 | + tx_desclen), *cmd_start_seq, |
|---|
| 458 | + GENMASK(30, 24)); |
|---|
| 480 | 459 | ++*cmd_start_seq; |
|---|
| 481 | 460 | |
|---|
| 482 | 461 | /* Copy memory */ |
|---|
| .. | .. |
|---|
| 486 | 465 | /* CMD continue */ |
|---|
| 487 | 466 | /* set the continue in prevoius cmd. */ |
|---|
| 488 | 467 | if (i < cmd_num - 1) |
|---|
| 489 | | - SET_BITS_TO_LE_4BYTE((ph2c_buffer + pre_continueoffset), |
|---|
| 490 | | - 31, 1, 1); |
|---|
| 468 | + le32p_replace_bits((__le32 *)(ph2c_buffer + |
|---|
| 469 | + pre_continueoffset), |
|---|
| 470 | + 1, BIT(31)); |
|---|
| 491 | 471 | |
|---|
| 492 | 472 | pre_continueoffset = totallen; |
|---|
| 493 | 473 | |
|---|
| .. | .. |
|---|
| 569 | 549 | return true; |
|---|
| 570 | 550 | } |
|---|
| 571 | 551 | |
|---|
| 572 | | -void rtl92s_set_fw_pwrmode_cmd(struct ieee80211_hw *hw, u8 Mode) |
|---|
| 552 | +void rtl92s_set_fw_pwrmode_cmd(struct ieee80211_hw *hw, u8 mode) |
|---|
| 573 | 553 | { |
|---|
| 574 | 554 | struct rtl_mac *mac = rtl_mac(rtl_priv(hw)); |
|---|
| 575 | 555 | struct rtl_ps_ctl *ppsc = rtl_psc(rtl_priv(hw)); |
|---|
| 576 | 556 | struct h2c_set_pwrmode_parm pwrmode; |
|---|
| 577 | 557 | u16 max_wakeup_period = 0; |
|---|
| 578 | 558 | |
|---|
| 579 | | - pwrmode.mode = Mode; |
|---|
| 559 | + pwrmode.mode = mode; |
|---|
| 580 | 560 | pwrmode.flag_low_traffic_en = 0; |
|---|
| 581 | 561 | pwrmode.flag_lpnav_en = 0; |
|---|
| 582 | 562 | pwrmode.flag_rf_low_snr_en = 0; |
|---|
| 583 | 563 | pwrmode.flag_dps_en = 0; |
|---|
| 584 | 564 | pwrmode.bcn_rx_en = 0; |
|---|
| 585 | 565 | pwrmode.bcn_to = 0; |
|---|
| 586 | | - SET_BITS_TO_LE_2BYTE((u8 *)(&pwrmode) + 8, 0, 16, |
|---|
| 587 | | - mac->vif->bss_conf.beacon_int); |
|---|
| 566 | + le16p_replace_bits((__le16 *)(((u8 *)(&pwrmode) + 8)), |
|---|
| 567 | + mac->vif->bss_conf.beacon_int, GENMASK(15, 0)); |
|---|
| 588 | 568 | pwrmode.app_itv = 0; |
|---|
| 589 | 569 | pwrmode.awake_bcn_itvl = ppsc->reg_max_lps_awakeintvl; |
|---|
| 590 | 570 | pwrmode.smart_ps = 1; |
|---|
| .. | .. |
|---|
| 626 | 606 | joinbss_rpt.bssid[3] = mac->bssid[3]; |
|---|
| 627 | 607 | joinbss_rpt.bssid[4] = mac->bssid[4]; |
|---|
| 628 | 608 | joinbss_rpt.bssid[5] = mac->bssid[5]; |
|---|
| 629 | | - SET_BITS_TO_LE_2BYTE((u8 *)(&joinbss_rpt) + 8, 0, 16, |
|---|
| 630 | | - mac->vif->bss_conf.beacon_int); |
|---|
| 631 | | - SET_BITS_TO_LE_2BYTE((u8 *)(&joinbss_rpt) + 10, 0, 16, mac->assoc_id); |
|---|
| 609 | + le16p_replace_bits((__le16 *)(((u8 *)(&joinbss_rpt) + 8)), |
|---|
| 610 | + mac->vif->bss_conf.beacon_int, GENMASK(15, 0)); |
|---|
| 611 | + le16p_replace_bits((__le16 *)(((u8 *)(&joinbss_rpt) + 10)), |
|---|
| 612 | + mac->assoc_id, GENMASK(15, 0)); |
|---|
| 632 | 613 | |
|---|
| 633 | 614 | _rtl92s_firmware_set_h2c_cmd(hw, FW_H2C_JOINBSSRPT, (u8 *)&joinbss_rpt); |
|---|
| 634 | 615 | } |
|---|