All of lore.kernel.org
 help / color / mirror / Atom feed
From: See, Chin Liang <chin.liang.see@intel.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH v2 7/8] spi: cadence_qspi: Fix CS timings
Date: Mon, 28 Nov 2016 12:48:39 +0000	[thread overview]
Message-ID: <1480337316.1829.0.camel@intel.com> (raw)
In-Reply-To: <1480084688-24677-8-git-send-email-phil.edworthy@renesas.com>

Hi Phil,

On Jum, 2016-11-25 at 14:38 +0000, Phil Edworthy wrote:
> 
> The Cadence QSPI controller has specified overheads for the various
> CS
> times that are in addition to those programmed in to the Device Delay
> register. The overheads are different for the delays.
> 
> In addition, the existing code does not handle the case when the
> delay
> is less than a SCLK period.
> 
> This change accurately calculates the additional delays in Ref
> clocks.
> 
> Signed-off-by: Phil Edworthy <phil.edworthy@renesas.com>
> ---
> v2:
> ?Was "spi: cadence_qspi: Fix CQSPI_CAL_DELAY calculation"
> ?Note only did the existing code not cope with the delay less than
> ?an SCLK period, but the calculation didn't round properly, and
> ?didn't take into account the delays that the QSPI Controller adds
> ?to those programmed into the Device Delay reg.
> ---
> ?drivers/spi/cadence_qspi_apb.c | 23 ++++++++++++-----------
> ?1 file changed, 12 insertions(+), 11 deletions(-)
> 
> diff --git a/drivers/spi/cadence_qspi_apb.c
> b/drivers/spi/cadence_qspi_apb.c
> index 1cd636a..56ad952 100644
> --- a/drivers/spi/cadence_qspi_apb.c
> +++ b/drivers/spi/cadence_qspi_apb.c
> @@ -169,9 +169,6 @@
> ????????((readl(base + CQSPI_REG_CONFIG) >>?????????????\
> ????????????????CQSPI_REG_CONFIG_IDLE_LSB) & 0x1)
> 
> -#define CQSPI_CAL_DELAY(tdelay_ns, tref_ns, tsclk_ns)??????????\
> -???????((((tdelay_ns) - (tsclk_ns)) / (tref_ns)))
> -
> ?#define CQSPI_GET_RD_SRAM_LEVEL(reg_base)??????????????????????\
> ????????(((readl(reg_base + CQSPI_REG_SDRAMLEVEL)) >>???\
> ????????CQSPI_REG_SDRAMLEVEL_RD_LSB) & CQSPI_REG_SDRAMLEVEL_RD_MASK)
> @@ -357,16 +354,20 @@ void cadence_qspi_apb_delay(void *reg_base,
> ????????cadence_qspi_apb_controller_disable(reg_base);
> 
> ????????/* Convert to ns. */
> -???????ref_clk_ns = (1000000000) / ref_clk;
> +???????ref_clk_ns = DIV_ROUND_UP(1000000000, ref_clk);
> 
> ????????/* Convert to ns. */
> -???????sclk_ns = (1000000000) / sclk_hz;
> -
> -???????/* Plus 1 to round up 1 clock cycle. */
> -???????tshsl = CQSPI_CAL_DELAY(tshsl_ns, ref_clk_ns, sclk_ns) + 1;
> -???????tchsh = CQSPI_CAL_DELAY(tchsh_ns, ref_clk_ns, sclk_ns) + 1;
> -???????tslch = CQSPI_CAL_DELAY(tslch_ns, ref_clk_ns, sclk_ns) + 1;
> -???????tsd2d = CQSPI_CAL_DELAY(tsd2d_ns, ref_clk_ns, sclk_ns) + 1;
> +???????sclk_ns = DIV_ROUND_UP(1000000000, sclk_hz);
> +
> +???????/* The controller adds additional delay to that programmed in
> the reg */
> +???????if (tshsl_ns >= sclk_ns + ref_clk_ns)
> +???????????????tshsl_ns -= sclk_ns + ref_clk_ns;
> +???????if (tchsh_ns >= sclk_ns + 3 * ref_clk_ns)
> +???????????????tchsh_ns -= sclk_ns + 3 * ref_clk_ns;
Any reason we need this?
The DIV_ROUND_UP or previous + 1 in algo will ensure its more than a
SCLK period.

Thanks
Chin Liang

> 
> +???????tshsl = DIV_ROUND_UP(tshsl_ns, ref_clk_ns);
> +???????tchsh = DIV_ROUND_UP(tchsh_ns, ref_clk_ns);
> +???????tslch = DIV_ROUND_UP(tslch_ns, ref_clk_ns);
> +???????tsd2d = DIV_ROUND_UP(tsd2d_ns, ref_clk_ns);
> 
> ????????reg = ((tshsl & CQSPI_REG_DELAY_TSHSL_MASK)
> ????????????????????????<< CQSPI_REG_DELAY_TSHSL_LSB);
> --
> 2.7.4
> 
> 
> ________________________________
> 
> Confidentiality Notice.
> This message may contain information that is confidential or
> otherwise protected from disclosure. If you are not the intended
> recipient, you are hereby notified that any use, disclosure,
> dissemination, distribution, or copying of this message, or any
> attachments, is strictly prohibited. If you have received this
> message in error, please advise the sender by reply e-mail, and
> delete the message and any attachments. Thank you.

  parent reply	other threads:[~2016-11-28 12:48 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-11-25 14:38 [U-Boot] [PATCH v2 0/8] SF: Cadence QSPI driver fixes and clean up Phil Edworthy
2016-11-25 14:38 ` [U-Boot] [PATCH v2 1/8] spi: cadence_qspi: Fix clearing of pol/pha bits Phil Edworthy
2016-11-25 14:56   ` Marek Vasut
2016-11-25 15:29   ` Jagan Teki
2016-11-25 15:34     ` Phil Edworthy
2016-11-25 14:38 ` [U-Boot] [PATCH v2 2/8] spi: cadence_qspi: Fix baud rate calculation Phil Edworthy
2016-11-25 14:57   ` Marek Vasut
2016-11-25 15:19     ` Phil Edworthy
2016-11-25 15:53       ` Marek Vasut
2016-11-25 16:07         ` Jagan Teki
2016-11-25 15:41   ` Jagan Teki
2016-11-25 16:05     ` Phil Edworthy
2016-11-25 14:38 ` [U-Boot] [PATCH v2 3/8] spi: cadence_qspi: Better debug information on the SPI clock rate Phil Edworthy
2016-11-25 14:58   ` Marek Vasut
2016-11-25 14:38 ` [U-Boot] [PATCH v2 4/8] spi: cadence_qspi: Use #define for bits instead of bit shifts Phil Edworthy
2016-11-25 14:59   ` Marek Vasut
2016-11-25 15:22     ` Phil Edworthy
2016-11-25 16:06   ` Jagan Teki
2016-11-25 14:38 ` [U-Boot] [PATCH v2 5/8] spi: cadence_qspi: Clean up the #define names Phil Edworthy
2016-11-25 15:01   ` Marek Vasut
2016-11-25 14:38 ` [U-Boot] [PATCH v2 6/8] spi: cadence_qspi: Remove returns from end of void functions Phil Edworthy
2016-11-25 15:01   ` Marek Vasut
2016-11-25 14:38 ` [U-Boot] [PATCH v2 7/8] spi: cadence_qspi: Fix CS timings Phil Edworthy
2016-11-25 15:04   ` Marek Vasut
2016-11-28 12:48   ` See, Chin Liang [this message]
2016-11-29 10:13     ` Phil Edworthy
2016-11-25 14:38 ` [U-Boot] [PATCH v2 8/8] spi: cadence_qspi: Support specifying the sample edge used Phil Edworthy
2016-11-25 15:05   ` Marek Vasut
2016-11-25 15:24     ` Phil Edworthy
2016-11-28 13:37   ` See, Chin Liang
2016-11-28  8:07 ` [U-Boot] [PATCH v2 0/8] SF: Cadence QSPI driver fixes and clean up Jagan Teki
2016-11-28 12:50   ` Marek Vasut
2016-11-28 13:32     ` Jagan Teki

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=1480337316.1829.0.camel@intel.com \
    --to=chin.liang.see@intel.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.