From: Sean Anderson <seanga2@gmail.com>
To: Marek Vasut <marex@denx.de>, u-boot@lists.denx.de
Cc: Sean Anderson <sean.anderson@seco.com>,
Angus Ainslie <angus@akkea.ca>, Bin Meng <bmeng.cn@gmail.com>,
Fabio Estevam <festevam@gmail.com>,
Kunihiko Hayashi <hayashi.kunihiko@socionext.com>,
Michal Simek <michal.simek@xilinx.com>,
Peng Fan <peng.fan@nxp.com>, Stefano Babic <sbabic@denx.de>
Subject: Re: [PATCH 3/4] usb: dwc3: Calculate REFCLKPER based on reference clock
Date: Sun, 30 Oct 2022 17:26:50 -0400 [thread overview]
Message-ID: <c6caa068-dbe8-be2e-3395-73e559797bbc@gmail.com> (raw)
In-Reply-To: <20221030210948.344661-3-marex@denx.de>
On 10/30/22 17:09, Marek Vasut wrote:
> From: Sean Anderson <sean.anderson@seco.com>
>
> Instead of using a special property to determine the reference clock
> period, use the rate of the reference clock. When we have a legacy
> snps,ref-clock-period-ns property and no reference clock, use it
> instead. Fractional clocks are not currently supported, and will be
> dealt with in the next commit.
>
> [ marek: Ported from Linux kernel commit
> 5114c3ee24875 ("usb: dwc3: Calculate REFCLKPER based on reference clock") ]
>
> Signed-off-by: Sean Anderson <sean.anderson@seco.com>
> Signed-off-by: Marek Vasut <marex@denx.de> # Port from Linux
> ---
> Cc: Angus Ainslie <angus@akkea.ca>
> Cc: Bin Meng <bmeng.cn@gmail.com>
> Cc: Fabio Estevam <festevam@gmail.com>
> Cc: Kunihiko Hayashi <hayashi.kunihiko@socionext.com>
> Cc: Michal Simek <michal.simek@xilinx.com>
> Cc: Peng Fan <peng.fan@nxp.com>
> Cc: Sean Anderson <sean.anderson@seco.com>
> Cc: Stefano Babic <sbabic@denx.de>
> ---
> drivers/usb/dwc3/core.c | 14 ++++++++++++--
> 1 file changed, 12 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c
> index 300450100c9..cf66976a088 100644
> --- a/drivers/usb/dwc3/core.c
> +++ b/drivers/usb/dwc3/core.c
> @@ -126,14 +126,24 @@ static void dwc3_frame_length_adjustment(struct dwc3 *dwc, u32 fladj)
> */
> static void dwc3_ref_clk_period(struct dwc3 *dwc)
> {
> + unsigned long period;
> + unsigned long rate;
> u32 reg;
>
> - if (dwc->ref_clk_per == 0)
> + if (dwc->ref_clk) {
> + rate = clk_get_rate(dwc->ref_clk);
> + if (!rate)
> + return;
> + period = NSEC_PER_SEC / rate;
> + } else if (dwc->ref_clk_per) {
> + period = dwc->ref_clk_per;
> + } else {
> return;
> + }
>
> reg = dwc3_readl(dwc->regs, DWC3_GUCTL);
> reg &= ~DWC3_GUCTL_REFCLKPER_MASK;
> - reg |= FIELD_PREP(DWC3_GUCTL_REFCLKPER_MASK, dwc->ref_clk_per);
> + reg |= FIELD_PREP(DWC3_GUCTL_REFCLKPER_MASK, period);
> dwc3_writel(dwc->regs, DWC3_GUCTL, reg);
> }
>
Reviewed-by: Sean Anderson <seanga2@gmail.com>
next prev parent reply other threads:[~2022-10-30 21:26 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-10-30 21:09 [PATCH 1/4] usb: dwc3: Cache ref_clk pointer in struct dwc3 Marek Vasut
2022-10-30 21:09 ` [PATCH 2/4] usb: dwc3: reference clock period configuration Marek Vasut
2022-10-30 21:26 ` Sean Anderson
2022-10-30 21:40 ` Marek Vasut
2022-10-30 21:09 ` [PATCH 3/4] usb: dwc3: Calculate REFCLKPER based on reference clock Marek Vasut
2022-10-30 21:26 ` Sean Anderson [this message]
2022-10-30 21:09 ` [PATCH 4/4] usb: dwc3: Program GFLADJ Marek Vasut
2022-10-30 21:27 ` Sean Anderson
2022-10-30 21:25 ` [PATCH 1/4] usb: dwc3: Cache ref_clk pointer in struct dwc3 Sean Anderson
2022-10-30 21:43 ` Marek Vasut
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=c6caa068-dbe8-be2e-3395-73e559797bbc@gmail.com \
--to=seanga2@gmail.com \
--cc=angus@akkea.ca \
--cc=bmeng.cn@gmail.com \
--cc=festevam@gmail.com \
--cc=hayashi.kunihiko@socionext.com \
--cc=marex@denx.de \
--cc=michal.simek@xilinx.com \
--cc=peng.fan@nxp.com \
--cc=sbabic@denx.de \
--cc=sean.anderson@seco.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