Search Linux Wireless

Re: [PATCH v3 05/12] wifi: rtlwifi: Add rtl8192du/hw.{c,h}

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, 2024-03-20 at 21:37 +0200, Bitterblue Smith wrote:

> These contain mostly hardware init/deinit routines for RTL8192DU.
> 
> Signed-off-by: Bitterblue Smith <rtl8821cerfe2@xxxxxxxxx>
> ---
> v3:
>  - No change.
> 
> v2:
>  - Patch is new in v2, split from patch 3/3 in v1.
> ---
>  .../wireless/realtek/rtlwifi/rtl8192du/hw.c   | 1244 +++++++++++++++++
>  .../wireless/realtek/rtlwifi/rtl8192du/hw.h   |   24 +
>  2 files changed, 1268 insertions(+)
>  create mode 100644 drivers/net/wireless/realtek/rtlwifi/rtl8192du/hw.c
>  create mode 100644 drivers/net/wireless/realtek/rtlwifi/rtl8192du/hw.h
> 
> diff --git a/drivers/net/wireless/realtek/rtlwifi/rtl8192du/hw.c
> b/drivers/net/wireless/realtek/rtlwifi/rtl8192du/hw.c
> new file mode 100644
> index 000000000000..e72d30e4ce3a
> --- /dev/null
> +++ b/drivers/net/wireless/realtek/rtlwifi/rtl8192du/hw.c
> @@ -0,0 +1,1244 @@
> 

[...]

> +       case HW_VAR_H2C_FW_JOINBSSRPT: {
> +               u8 tmp_regcr, tmp_reg422;
> +               bool recover = false;
> +               u8 mstatus = *val;
> +
> +               if (mstatus == RT_MEDIA_CONNECT) {
> +                       rtlpriv->cfg->ops->set_hw_reg(hw,
> +                                                     HW_VAR_AID, NULL);
> +                       tmp_regcr = rtl_read_byte(rtlpriv, REG_CR + 1);
> +                       rtl_write_byte(rtlpriv, REG_CR + 1,
> +                                      (tmp_regcr | BIT(0)));
> +                       _rtl92de_set_bcn_ctrl_reg(hw, 0, BIT(3));
> +                       _rtl92de_set_bcn_ctrl_reg(hw, BIT(4), 0);

For REG_BCN_CTRL,

BIT_EN_BCN_FUNCTION BIT(3)
BIT_DIS_TSF_UDT BIT(4)

> +                       tmp_reg422 = rtl_read_byte(rtlpriv,
> +                                                  REG_FWHW_TXQ_CTRL + 2);
> +                       if (tmp_reg422 & BIT(6))

For 0x420,

BIT_EN_BCNQ_DL BIT(22)  // i.e. 0x422[6]

> +                               recover = true;
> +                       rtl_write_byte(rtlpriv, REG_FWHW_TXQ_CTRL + 2,
> +                                      tmp_reg422 & (~BIT(6)));
> +
> +                       /* We don't implement FW LPS so this is not needed. */
> +                       /* rtl92d_set_fw_rsvdpagepkt(hw, 0); */
> +
> +                       _rtl92de_set_bcn_ctrl_reg(hw, BIT(3), 0);
> +                       _rtl92de_set_bcn_ctrl_reg(hw, 0, BIT(4));
> +                       if (recover)
> +                               rtl_write_byte(rtlpriv,
> +                                              REG_FWHW_TXQ_CTRL + 2,
> +                                              tmp_reg422);
> +                       rtl_write_byte(rtlpriv, REG_CR + 1,
> +                                      (tmp_regcr & ~(BIT(0))));
> +               }
> +               rtl92d_set_fw_joinbss_report_cmd(hw, (*val));
> +               break;
> +       }
> 

[...]

> +static bool _rtl92de_llt_table_init(struct ieee80211_hw *hw, u8 txpktbuf_bndy)
> +{
> +       struct rtl_priv *rtlpriv = rtl_priv(hw);
> +       unsigned short i;
> +       bool status;
> +       u8 maxpage;
> +
> +       if (rtlpriv->rtlhal.macphymode == SINGLEMAC_SINGLEPHY)
> +               maxpage = 255;
> +       else
> +               maxpage = 127;
> +
> +       for (i = 0; i < (txpktbuf_bndy - 1); i++) {
> +               status = rtl92de_llt_write(hw, i, i + 1);
> +               if (!status)
> +                       return status;
> +       }
> +
> +       /* end of list */
> +       status = rtl92de_llt_write(hw, txpktbuf_bndy - 1, 0xFF);
> +       if (!status)
> +               return status;
> +
> +       /* Make the other pages as ring buffer */
> +       /* This ring buffer is used as beacon buffer if we */
> +       /* config this MAC as two MAC transfer. */
> +       /* Otherwise used as local loopback buffer.  */
> +       for (i = txpktbuf_bndy; i < maxpage; i++) {
> +               status = rtl92de_llt_write(hw, i, (i + 1));

parenthesis of (i + 1) is unnecessary. 

> +               if (!status)
> +                       return status;
> +       }
> +
> +       /* Let last entry point to the start entry of ring buffer */
> +       status = rtl92de_llt_write(hw, maxpage, txpktbuf_bndy);
> +       if (!status)
> +               return status;
> +
> +       return true;
> +}
> +
> 

[...]


> +
> +static bool _rtl92du_init_power_on(struct ieee80211_hw *hw)
> +{
> +       struct rtl_priv *rtlpriv = rtl_priv(hw);
> +       unsigned short wordtmp;
> +       unsigned char bytetmp;
> +       u16 retry;
> +
> +       retry = 0;

nit: just 'u16 retry = 0' ?


> +       do {
> +               if (rtl_read_byte(rtlpriv, REG_APS_FSMCO) & PFM_ALDN)
> +                       break;
> +
> +               if (retry++ > 1000)
> +                       return false;
> +       } while (true);
> +

[...]

> +int rtl92du_hw_init(struct ieee80211_hw *hw)
> +{
> +

[...]

> +
> +       rtlphy->rfreg_chnlval[0] = rtl_get_rfreg(hw, RF90_PATH_A,
> +                                                RF_CHNLBW,
> +                                                RFREG_OFFSET_MASK);
> +       rtlphy->rfreg_chnlval[1] = rtl_get_rfreg(hw, RF90_PATH_B,
> +                                                RF_CHNLBW,
> +                                                RFREG_OFFSET_MASK);

Long register names cause multiple lines of code. How about..

	rtlphy->rfreg_chnlval[0] =
		rtl_get_rfreg(hw, RF90_PATH_A, RF_CHNLBW, RFREG_OFFSET_MASK);
	rtlphy->rfreg_chnlval[1] =
		rtl_get_rfreg(hw, RF90_PATH_B, RF_CHNLBW, RFREG_OFFSET_MASK);


> +
> +static void _rtl92du_poweroff_adapter(struct ieee80211_hw *hw)
> +{
> +       struct rtl_priv *rtlpriv = rtl_priv(hw);
> +       u8 delay = 100;

'retry' would be clearer. 


> diff --git a/drivers/net/wireless/realtek/rtlwifi/rtl8192du/hw.h
> b/drivers/net/wireless/realtek/rtlwifi/rtl8192du/hw.h
> new file mode 100644
> index 000000000000..731aa3b78d07
> --- /dev/null
> +++ b/drivers/net/wireless/realtek/rtlwifi/rtl8192du/hw.h
> @@ -0,0 +1,24 @@
> +/* SPDX-License-Identifier: GPL-2.0 */
> +/* Copyright(c) 2009-2012  Realtek Corporation.*/
> +
> +#ifndef __RTL92DE_HW_H__
> +#define __RTL92DE_HW_H__

RTL92DU_HW_H







[Index of Archives]     [Linux Host AP]     [ATH6KL]     [Linux Wireless Personal Area Network]     [Linux Bluetooth]     [Wireless Regulations]     [Linux Netdev]     [Kernel Newbies]     [Linux Kernel]     [IDE]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite Hiking]     [MIPS Linux]     [ARM Linux]     [Linux RAID]

  Powered by Linux