From: "yong.mao-NuS5LvNUpcJWk0Htik3J/w@public.gmane.org" <yong.mao-NuS5LvNUpcJWk0Htik3J/w@public.gmane.org>
To: Chun-Hung Wu <chun-hung.wu-NuS5LvNUpcJWk0Htik3J/w@public.gmane.org>
Cc: mirq-linux-CoA6ZxLDdyEEUmgCuDUIdw@public.gmane.org,
Jonathan Hunter
<jonathanh-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>,
Al Cooper <alcooperx-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>,
Adrian Hunter
<adrian.hunter-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>,
Florian Fainelli
<f.fainelli-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>,
bcm-kernel-feedback-list-dY08KVG/lbpWk0Htik3J/w@public.gmane.org,
Andy Gross <agross-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>,
Bjorn Andersson
<bjorn.andersson-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>,
Michal Simek
<michal.simek-gjFFaj9aHVfQT0dZR+AlfA@public.gmane.org>,
Thierry Reding
<thierry.reding-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>,
Chaotian Jing
<chaotian.jing-NuS5LvNUpcJWk0Htik3J/w@public.gmane.org>,
Ulf Hansson <ulf.hansson-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>,
Rob Herring <robh+dt-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>,
Mark Rutland <mark.rutland-5wv7dgnIgG8@public.gmane.org>,
Matthias Brugger
<matthias.bgg-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>,
Linus Walleij
<linus.walleij-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>,
Pavel Machek <pavel-+ZI9xUNit7I@public.gmane.org>,
Kate Stewart
<kstewart-hQyY1W1yCW8ekmWlsbkhG0B+6BGkLq7r@public.gmane.org>,
Greg Kroah-Hartman
<gregkh-hQyY1W1yCW8ekmWlsbkhG0B+6BGkLq7r@public.gmane.org>M
Subject: Re: [PATCH v5 3/5] mmc: mediatek: refine msdc timeout api
Date: Tue, 28 Apr 2020 20:28:47 +0800 [thread overview]
Message-ID: <1588076927.730.2.camel@mhfsdcap03> (raw)
In-Reply-To: <1588031768-23677-4-git-send-email-chun-hung.wu-NuS5LvNUpcJWk0Htik3J/w@public.gmane.org>
On Tue, 2020-04-28 at 07:56 +0800, Chun-Hung Wu wrote:
> Extract msdc timeout api common part to have
> better code architecture and avoid redundent
please correct the word "redundant" in next version
> code.
>
> Signed-off-by: Chun-Hung Wu <chun-hung.wu@mediatek.com>
Acked-by: Yong Mao <yong.mao@mediatek.com>
> ---
> drivers/mmc/host/mtk-sd.c | 32 ++++++++++++++++++++++----------
> 1 file changed, 22 insertions(+), 10 deletions(-)
>
> diff --git a/drivers/mmc/host/mtk-sd.c b/drivers/mmc/host/mtk-sd.c
> index 7726dcf..a2328fb 100644
> --- a/drivers/mmc/host/mtk-sd.c
> +++ b/drivers/mmc/host/mtk-sd.c
> @@ -699,21 +699,21 @@ static void msdc_unprepare_data(struct msdc_host *host, struct mmc_request *mrq)
> }
> }
>
> -/* clock control primitives */
> -static void msdc_set_timeout(struct msdc_host *host, u32 ns, u32 clks)
> +static u64 msdc_timeout_cal(struct msdc_host *host, u64 ns, u64 clks)
> {
> - u32 timeout, clk_ns;
> + u64 timeout, clk_ns;
> u32 mode = 0;
>
> - host->timeout_ns = ns;
> - host->timeout_clks = clks;
> if (host->mmc->actual_clock == 0) {
> timeout = 0;
> } else {
> - clk_ns = 1000000000UL / host->mmc->actual_clock;
> - timeout = (ns + clk_ns - 1) / clk_ns + clks;
> + clk_ns = 1000000000ULL;
> + do_div(clk_ns, host->mmc->actual_clock);
> + timeout = ns + clk_ns - 1;
> + do_div(timeout, clk_ns);
> + timeout += clks;
> /* in 1048576 sclk cycle unit */
> - timeout = (timeout + (0x1 << 20) - 1) >> 20;
> + timeout = DIV_ROUND_UP(timeout, (0x1 << 20));
> if (host->dev_comp->clk_div_bits == 8)
> sdr_get_field(host->base + MSDC_CFG,
> MSDC_CFG_CKMOD, &mode);
> @@ -723,9 +723,21 @@ static void msdc_set_timeout(struct msdc_host *host, u32 ns, u32 clks)
> /*DDR mode will double the clk cycles for data timeout */
> timeout = mode >= 2 ? timeout * 2 : timeout;
> timeout = timeout > 1 ? timeout - 1 : 0;
> - timeout = timeout > 255 ? 255 : timeout;
> }
> - sdr_set_field(host->base + SDC_CFG, SDC_CFG_DTOC, timeout);
> + return timeout;
> +}
> +
> +/* clock control primitives */
> +static void msdc_set_timeout(struct msdc_host *host, u64 ns, u64 clks)
> +{
> + u64 timeout;
> +
> + host->timeout_ns = ns;
> + host->timeout_clks = clks;
> +
> + timeout = msdc_timeout_cal(host, ns, clks);
> + sdr_set_field(host->base + SDC_CFG, SDC_CFG_DTOC,
> + (u32)(timeout > 255 ? 255 : timeout));
> }
>
> static void msdc_gate_clock(struct msdc_host *host)
next prev parent reply other threads:[~2020-04-28 12:28 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-04-27 23:56 [PATCH v5 0/5] mmc: mediatek: add mmc cqhci support Chun-Hung Wu
2020-04-27 23:56 ` [PATCH v5 2/5] mmc: host: Remove redundant CQE bindings Chun-Hung Wu
2020-04-27 23:56 ` [PATCH v5 3/5] mmc: mediatek: refine msdc timeout api Chun-Hung Wu
[not found] ` <1588031768-23677-4-git-send-email-chun-hung.wu-NuS5LvNUpcJWk0Htik3J/w@public.gmane.org>
2020-04-28 12:28 ` yong.mao-NuS5LvNUpcJWk0Htik3J/w [this message]
[not found] ` <1588031768-23677-1-git-send-email-chun-hung.wu-NuS5LvNUpcJWk0Htik3J/w@public.gmane.org>
2020-04-27 23:56 ` [PATCH v5 1/5] mmc: core: Extend mmc_of_parse() to parse CQE bindings Chun-Hung Wu
2020-05-06 13:00 ` Veerabhadrarao Badiganti
[not found] ` <9bc2454f-0b42-e256-7927-2564b56f369f-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org>
2020-05-06 16:36 ` Ulf Hansson
2020-05-07 16:33 ` Veerabhadrarao Badiganti
[not found] ` <f9fa0232-3945-4e47-9238-0b51f6531199-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org>
2020-05-08 5:05 ` Ulf Hansson
2020-05-12 1:16 ` Chun-Hung Wu
2020-04-27 23:56 ` [PATCH v5 4/5] mmc: mediatek: command queue support Chun-Hung Wu
[not found] ` <1588031768-23677-5-git-send-email-chun-hung.wu-NuS5LvNUpcJWk0Htik3J/w@public.gmane.org>
2020-04-28 13:02 ` yong.mao-NuS5LvNUpcJWk0Htik3J/w
2020-04-27 23:56 ` [PATCH v5 5/5] dt-bindings: mmc: mediatek: Add document for mt6779 Chun-Hung Wu
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=1588076927.730.2.camel@mhfsdcap03 \
--to=yong.mao-nus5lvnupcjwk0htik3j/w@public.gmane.org \
--cc=adrian.hunter-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org \
--cc=agross-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org \
--cc=alcooperx-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
--cc=bcm-kernel-feedback-list-dY08KVG/lbpWk0Htik3J/w@public.gmane.org \
--cc=bjorn.andersson-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org \
--cc=chaotian.jing-NuS5LvNUpcJWk0Htik3J/w@public.gmane.org \
--cc=chun-hung.wu-NuS5LvNUpcJWk0Htik3J/w@public.gmane.org \
--cc=f.fainelli-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
--cc=gregkh-hQyY1W1yCW8ekmWlsbkhG0B+6BGkLq7r@public.gmane.org \
--cc=jonathanh-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org \
--cc=kstewart-hQyY1W1yCW8ekmWlsbkhG0B+6BGkLq7r@public.gmane.org \
--cc=linus.walleij-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org \
--cc=mark.rutland-5wv7dgnIgG8@public.gmane.org \
--cc=matthias.bgg-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
--cc=michal.simek-gjFFaj9aHVfQT0dZR+AlfA@public.gmane.org \
--cc=mirq-linux-CoA6ZxLDdyEEUmgCuDUIdw@public.gmane.org \
--cc=pavel-+ZI9xUNit7I@public.gmane.org \
--cc=robh+dt-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org \
--cc=thierry.reding-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
--cc=ulf.hansson-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org \
/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