From: Valentin Longchamp <valentin.longchamp@keymile.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH] kw_spi: fix clock prescaler computation
Date: Tue, 14 Aug 2012 11:32:11 +0200 [thread overview]
Message-ID: <502A1B1B.5020802@keymile.com> (raw)
In-Reply-To: <1340972242-24360-1-git-send-email-valentin.longchamp@keymile.com>
Hi Prafulla,
I haven't received feedback about this patch from you. Can I please kindly
remind you about it since I am about to send patches that deal with SPI clk setting.
Thank you.
On 06/29/2012 02:17 PM, Valentin Longchamp wrote:
> The computation was not correct with low clock values: setting a 1MHz
> clock would result in an overlap that would then configure a 25Mhz
> clock.
>
> This patch implements a correct computation method according to the
> kirkwood functionnal spec. table 629 (Serial Memory Interface
> Configuration Register).
>
> Signed-off-by: Valentin Longchamp <valentin.longchamp@keymile.com>
> cc: Holger Brunck <holger.brunck@keymile.com>
> cc: Prafulla Wadaskar <prafulla@marvell.com>
> ---
> arch/arm/include/asm/arch-kirkwood/spi.h | 1 +
> drivers/spi/kirkwood_spi.c | 5 +++--
> 2 files changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/arch/arm/include/asm/arch-kirkwood/spi.h b/arch/arm/include/asm/arch-kirkwood/spi.h
> index 1d5043f..5a38dc5 100644
> --- a/arch/arm/include/asm/arch-kirkwood/spi.h
> +++ b/arch/arm/include/asm/arch-kirkwood/spi.h
> @@ -38,6 +38,7 @@ struct kwspi_registers {
> };
>
> #define KWSPI_CLKPRESCL_MASK 0x1f
> +#define KWSPI_CLKPRESCL_MIN 0x12
> #define KWSPI_CSN_ACT 1 /* Activates serial memory interface */
> #define KWSPI_SMEMRDY (1 << 1) /* SerMem Data xfer ready */
> #define KWSPI_IRQUNMASK 1 /* unmask SPI interrupt */
> diff --git a/drivers/spi/kirkwood_spi.c b/drivers/spi/kirkwood_spi.c
> index ee14669..9b3f6a4 100644
> --- a/drivers/spi/kirkwood_spi.c
> +++ b/drivers/spi/kirkwood_spi.c
> @@ -57,8 +57,9 @@ struct spi_slave *spi_setup_slave(unsigned int bus, unsigned int cs,
> writel(~KWSPI_CSN_ACT | KWSPI_SMEMRDY, &spireg->ctrl);
>
> /* calculate spi clock prescaller using max_hz */
> - data = ((CONFIG_SYS_TCLK / 2) / max_hz) & KWSPI_CLKPRESCL_MASK;
> - data |= 0x10;
> + data = ((CONFIG_SYS_TCLK / 2) / max_hz) + 0x10;
> + data = data < KWSPI_CLKPRESCL_MIN ? KWSPI_CLKPRESCL_MIN : data;
> + data = data > KWSPI_CLKPRESCL_MASK ? KWSPI_CLKPRESCL_MASK : data;
>
> /* program spi clock prescaller using max_hz */
> writel(KWSPI_ADRLEN_3BYTE | data, &spireg->cfg);
>
next prev parent reply other threads:[~2012-08-14 9:32 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-06-29 12:17 [U-Boot] [PATCH] kw_spi: fix clock prescaler computation Valentin Longchamp
2012-08-14 9:32 ` Valentin Longchamp [this message]
2012-08-14 13:15 ` Prafulla Wadaskar
2012-08-15 15:26 ` Valentin Longchamp
2012-08-15 15:31 ` [U-Boot] [PATCH v2] " Valentin Longchamp
2012-08-16 4:13 ` Prafulla Wadaskar
2012-09-03 8:43 ` Prafulla Wadaskar
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=502A1B1B.5020802@keymile.com \
--to=valentin.longchamp@keymile.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.