public inbox for netdev@vger.kernel.org
 help / color / mirror / Atom feed
From: Hayes Wang <hayeswang@realtek.com>
To: Chih Kai Hsu <hsu.chih.kai@realtek.com>,
	"kuba@kernel.org" <kuba@kernel.org>,
	"davem@davemloft.net" <davem@davemloft.net>
Cc: "netdev@vger.kernel.org" <netdev@vger.kernel.org>,
	nic_swsd <nic_swsd@realtek.com>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"linux-usb@vger.kernel.org" <linux-usb@vger.kernel.org>,
	"edumazet@google.com" <edumazet@google.com>,
	"bjorn@mork.no" <bjorn@mork.no>,
	"pabeni@redhat.com" <pabeni@redhat.com>,
	Chih Kai Hsu <hsu.chih.kai@realtek.com>
Subject: RE: [PATCH net-next v3 1/2] r8152: add helper functions for PLA/USB OCP registers
Date: Tue, 24 Mar 2026 06:04:03 +0000	[thread overview]
Message-ID: <be38bdf5c2b64629920bfe6688907992@realtek.com> (raw)
In-Reply-To: <20260323082226.2601-451-nic_swsd@realtek.com>

Chih Kai Hsu <hsu.chih.kai@realtek.com>
> Sent: Monday, March 23, 2026 4:22 PM

> @@ -7166,21 +6942,17 @@ static void r8153_init(struct r8152 *tp)
>  	r8153_u1u2en(tp, true);
>  	usb_enable_lpm(tp->udev);
> 
> -	ocp_data = ocp_read_byte(tp, MCU_TYPE_PLA, PLA_CONFIG6);
> -	ocp_data |= LANWAKE_CLR_EN;
> -	ocp_write_byte(tp, MCU_TYPE_PLA, PLA_CONFIG6, ocp_data);
> +	ocp_byte_set_bits(tp, MCU_TYPE_PLA, PLA_CONFIG6,
> LANWAKE_CLR_EN);
> 
> -	ocp_data = ocp_read_byte(tp, MCU_TYPE_PLA, PLA_LWAKE_CTRL_REG);
> -	ocp_data &= ~LANWAKE_PIN;
> -	ocp_write_byte(tp, MCU_TYPE_PLA, PLA_LWAKE_CTRL_REG, ocp_data);
> +	ocp_byte_clr_bits(tp, MCU_TYPE_PLA, PLA_LWAKE_CTRL_REG,
> LANWAKE_PIN);
> 
>  	/* rx aggregation */
> -	ocp_data = ocp_read_word(tp, MCU_TYPE_USB, USB_USB_CTRL);
> -	ocp_data &= ~(RX_AGG_DISABLE | RX_ZERO_EN);
> -	if (tp->dell_tb_rx_agg_bug)
> -		ocp_data |= RX_AGG_DISABLE;
> +	ocp_word_clr_bits(tp, MCU_TYPE_USB, USB_USB_CTRL,
> +			  RX_AGG_DISABLE | RX_ZERO_EN);
> 
> -	ocp_write_word(tp, MCU_TYPE_USB, USB_USB_CTRL, ocp_data);
> +	if (tp->dell_tb_rx_agg_bug)
> +		ocp_word_set_bits(tp, MCU_TYPE_USB, USB_USB_CTRL,
> +				  RX_AGG_DISABLE);

I think you could combine above, such as

	if (tp->dell_tb_rx_agg_bug)
		ocp_word_w0w1(tp, MCU_TYPE_USB, USB_USB_CTRL, RX_ZERO_EN,
			      RX_AGG_DISABLE);
	else
		ocp_word_clr_bits(tp, MCU_TYPE_USB, USB_USB_CTRL,
				  RX_AGG_DISABLE | RX_ZERO_EN);

>  	rtl_tally_reset(tp);
> 
> @@ -7200,7 +6972,6 @@ static void r8153_init(struct r8152 *tp)
> 
>  static void r8153b_init(struct r8152 *tp)
>  {
> -	u32 ocp_data;
>  	u16 data;
>  	int i;
> 
[...]
> @@ -8306,48 +8028,39 @@ static void r8156b_init(struct r8152 *tp)
> 
>  	usb_enable_lpm(tp->udev);
> 
> -	ocp_data = ocp_read_word(tp, MCU_TYPE_PLA, PLA_RCR);
> -	ocp_data &= ~SLOT_EN;
> -	ocp_write_word(tp, MCU_TYPE_PLA, PLA_RCR, ocp_data);
> +	ocp_word_clr_bits(tp, MCU_TYPE_PLA, PLA_RCR, SLOT_EN);
> 
> -	ocp_data = ocp_read_word(tp, MCU_TYPE_PLA, PLA_CPCR);
> -	ocp_data |= FLOW_CTRL_EN;
> -	ocp_write_word(tp, MCU_TYPE_PLA, PLA_CPCR, ocp_data);
> +	ocp_word_set_bits(tp, MCU_TYPE_PLA, PLA_CPCR, FLOW_CTRL_EN);
> 
>  	/* enable fc timer and set timer to 600 ms. */
>  	ocp_write_word(tp, MCU_TYPE_USB, USB_FC_TIMER,
>  		       CTRL_TIMER_EN | (600 / 8));
> 
> -	ocp_data = ocp_read_word(tp, MCU_TYPE_USB, USB_FW_CTRL);
>  	if (!(ocp_read_word(tp, MCU_TYPE_PLA, PLA_POL_GPIO_CTRL) &
> DACK_DET_EN))
> -		ocp_data |= FLOW_CTRL_PATCH_2;
> -	ocp_data &= ~AUTO_SPEEDUP;
> -	ocp_write_word(tp, MCU_TYPE_USB, USB_FW_CTRL, ocp_data);
> +		ocp_word_set_bits(tp, MCU_TYPE_USB, USB_FW_CTRL,
> +				  FLOW_CTRL_PATCH_2);
> +
> +	ocp_word_clr_bits(tp, MCU_TYPE_USB, USB_FW_CTRL, AUTO_SPEEDUP);

I think you could combine above, such as

	if (!(ocp_read_word(tp, MCU_TYPE_PLA, PLA_POL_GPIO_CTRL) & DACK_DET_EN))
		ocp_word_w0w1(tp, MCU_TYPE_USB, USB_FW_CTRL, AUTO_SPEEDUP,
			      FLOW_CTRL_PATCH_2);
	else
		ocp_word_clr_bits(tp, MCU_TYPE_USB, USB_FW_CTRL, AUTO_SPEEDUP);

Best Regards,
Hayes


  reply	other threads:[~2026-03-24  6:05 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-23  8:22 [PATCH net-next v3 0/2] r8152: add helper functions for PLA/USB/PHY OCP registers Chih Kai Hsu
2026-03-23  8:22 ` [PATCH net-next v3 1/2] r8152: add helper functions for PLA/USB " Chih Kai Hsu
2026-03-24  6:04   ` Hayes Wang [this message]
2026-03-25  3:00     ` Chih Kai Hsu
2026-03-24 18:05   ` Simon Horman
2026-03-25  3:35     ` Chih Kai Hsu
2026-03-25 16:44       ` Simon Horman
2026-03-23  8:22 ` [PATCH net-next v3 2/2] r8152: add helper functions for PHY " Chih Kai Hsu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=be38bdf5c2b64629920bfe6688907992@realtek.com \
    --to=hayeswang@realtek.com \
    --cc=bjorn@mork.no \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=hsu.chih.kai@realtek.com \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=nic_swsd@realtek.com \
    --cc=pabeni@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox