public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Marek Vasut <marex@denx.de>
To: Junhui Liu <junhui.liu@pigmoral.tech>,
	Tom Rini <trini@konsulko.com>, Lukasz Majewski <lukma@denx.de>,
	Mattijs Korpershoek <mkorpershoek@baylibre.com>
Cc: u-boot@lists.denx.de, seashell11234455@gmail.com, pbrobinson@gmail.com
Subject: Re: [PATCH v3 7/8] usb: dwc2: Unify flush and reset logic with v4.20a support
Date: Mon, 6 Jan 2025 16:37:36 +0100	[thread overview]
Message-ID: <64b317fe-d5a2-4bc7-8c8a-fa608bccfa0b@denx.de> (raw)
In-Reply-To: <18180fa5d7b286a0.3a5aa491c048ad05.6820f85a01d7931@Jude-Air.local>

On 1/6/25 10:14 AM, Junhui Liu wrote:
> Hi Marek,
> 
> On 05/01/2025 20:19, Marek Vasut wrote:
>> On 1/4/25 4:37 AM, Junhui Liu wrote:
>>> From: Kongyang Liu <seashell11234455@gmail.com>
>>>
>>> This patch merges flush and reset logic for both host and gadget code
>>> into a common set of functions, reducing duplication. It also adds support
>>> for the updated reset logic to compatible with core version since v4.20a.
>>>
>>> This patch mainly refers to the patch in the kernel.
>>> link: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=65dc2e725286106f99c6f6b78e3d9c52c15f3a9c
>>
>> [...]
>>
>>> +++ b/drivers/usb/common/dwc2_core.c
>>> @@ -0,0 +1,115 @@
>>> +// SPDX-License-Identifier: GPL-2.0+
>>> +/*
>>> + * Copyright (c) 2024, Kongyang Liu <seashell11234455@gmail.com>
>>
>> 2025 now .
> 
> You're right. It should be 2024-2025.
> 
>>
>> [...]
>>
>>> +int dwc2_flush_rx_fifo(struct dwc2_core_regs *regs)
>>> +{
>>> +	int ret;
>>> +
>>> +	log_debug("Flush Rx FIFO\n");
>>> +
>>> +	/* Wait for AHB master IDLE state */
>>> +	ret = wait_for_bit_le32(&regs->global_regs.grstctl, GRSTCTL_AHBIDLE, true, 1000, false);
>>> +	if (ret) {
>>> +		log_warning("%s: Waiting for GRSTCTL_AHBIDLE timeout\n", __func__);
>>> +		return ret;
>>> +	}
>>> +
>>> +	writel(GRSTCTL_RXFFLSH, &regs->global_regs.grstctl);
>>> +
>>> +	ret = wait_for_bit_le32(&regs->global_regs.grstctl, GRSTCTL_RXFFLSH, false, 1000, false);
>>> +	if (ret) {
>>> +		log_warning("%s: Waiting for GRSTCTL_RXFFLSH timeout\n", __func__);
>>> +		return ret;
>>> +	}
>>> +
>>> +	/* Wait for at least 3 PHY Clocks */
>>> +	udelay(1);
>> Shouldn't this delay be derived from the PHY clock frequency somehow ?
>> Are we sure 1us is always sufficient ?
> 
> According to the datasheet, the PHY clock can be selected to 6/30/48/60
> MHz depending on the speed mode. And 1us is sufficient even for 6MHz
> (twice the 3 PHY clock at 6MHz), so I think 1us is acceptable here.

Please add a code comment like that ^ .

> If we want to derive the delay dynamically from the PHY clock frequency,
> we would need to read the PHY clock and speed mode cfg from the register
> and calculate the appropriate delay. This would add complexity to the
> code. In the current situation, a fixed delay of 1 us is sufficient for
> all supported clock frequencies and keeps the implementation simpler.
Thanks for the clarification, add a code comment and that is all fine.

  reply	other threads:[~2025-01-06 15:39 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-01-04  3:37 [PATCH v3 0/8] usb: dwc2: Refactor and update USB DWC2 driver Junhui Liu
2025-01-04  3:37 ` [PATCH v3 1/8] usb: dwc2: Extract register definitions to common header file Junhui Liu
2025-01-07  9:03   ` Mattijs Korpershoek
2025-01-04  3:37 ` [PATCH v3 2/8] usb: dwc2: Fix incorrect ULPI_UTMI_SEL bit setting Junhui Liu
2025-01-07  9:11   ` Mattijs Korpershoek
2025-01-04  3:37 ` [PATCH v3 3/8] USB: dwc2: Fix HBstLen setting for external DMA mode Junhui Liu
2025-01-07  9:16   ` Mattijs Korpershoek
2025-01-04  3:37 ` [PATCH v3 4/8] usb: dwc2: Clean up with bitfield macros Junhui Liu
2025-01-05 19:14   ` Marek Vasut
2025-01-07  9:22   ` Mattijs Korpershoek
2025-01-04  3:37 ` [PATCH v3 5/8] usb: dwc2: Align macros with Linux kernel definitions Junhui Liu
2025-01-07  9:26   ` Mattijs Korpershoek
2025-01-04  3:37 ` [PATCH v3 6/8] usb: dwc2: Extract macro definitions to common header Junhui Liu
2025-01-07  9:55   ` Mattijs Korpershoek
2025-01-07 12:52     ` Junhui Liu
2025-01-04  3:37 ` [PATCH v3 7/8] usb: dwc2: Unify flush and reset logic with v4.20a support Junhui Liu
2025-01-05 19:19   ` Marek Vasut
2025-01-06  9:14     ` Junhui Liu
2025-01-06 15:37       ` Marek Vasut [this message]
2025-01-07 12:39         ` Junhui Liu
2025-01-07 12:57           ` Marek Vasut
2025-01-04  3:37 ` [PATCH v3 8/8] usb: dwc2: Replace uint<x>_t types with u<x> Junhui Liu
2025-01-07  9:47 ` [PATCH v3 0/8] usb: dwc2: Refactor and update USB DWC2 driver Mattijs Korpershoek
2025-01-07 12:44   ` Junhui Liu

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=64b317fe-d5a2-4bc7-8c8a-fa608bccfa0b@denx.de \
    --to=marex@denx.de \
    --cc=junhui.liu@pigmoral.tech \
    --cc=lukma@denx.de \
    --cc=mkorpershoek@baylibre.com \
    --cc=pbrobinson@gmail.com \
    --cc=seashell11234455@gmail.com \
    --cc=trini@konsulko.com \
    --cc=u-boot@lists.denx.de \
    /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