From: "Andreas Bießmann" <andreas.devel@googlemail.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH 1/3] arm: atmel: at91sam9x5: cleanup cs configure for spi
Date: Tue, 17 Dec 2013 10:06:12 +0100 [thread overview]
Message-ID: <52B01404.9010402@gmail.com> (raw)
In-Reply-To: <1386663242-12143-2-git-send-email-voice.shen@atmel.com>
Hi Bo,
On 12/10/2013 09:14 AM, Bo Shen wrote:
> As the cs for spi is worked in gpio mode, so no need to configure
> it as peripheral and then configure to gpio.
That statement may be correct.
>
> Signed-off-by: Bo Shen <voice.shen@atmel.com>
> ---
>
> arch/arm/cpu/arm926ejs/at91/at91sam9x5_devices.c | 28 +++++-----------------
> board/atmel/at91sam9x5ek/at91sam9x5ek.c | 1 -
> 2 files changed, 6 insertions(+), 23 deletions(-)
>
> diff --git a/arch/arm/cpu/arm926ejs/at91/at91sam9x5_devices.c b/arch/arm/cpu/arm926ejs/at91/at91sam9x5_devices.c
> index 6d94572..745dce6 100644
> --- a/arch/arm/cpu/arm926ejs/at91/at91sam9x5_devices.c
> +++ b/arch/arm/cpu/arm926ejs/at91/at91sam9x5_devices.c
> @@ -130,20 +130,12 @@ void at91_spi0_hw_init(unsigned long cs_mask)
> writel(1 << ATMEL_ID_SPI0, &pmc->pcer);
>
> if (cs_mask & (1 << 0))
> - at91_set_a_periph(AT91_PIO_PORTA, 14, 0);
> - if (cs_mask & (1 << 1))
> - at91_set_b_periph(AT91_PIO_PORTA, 7, 0);
> - if (cs_mask & (1 << 2))
> - at91_set_b_periph(AT91_PIO_PORTA, 1, 0);
> - if (cs_mask & (1 << 3))
> - at91_set_b_periph(AT91_PIO_PORTB, 3, 0);
> - if (cs_mask & (1 << 4))
> at91_set_pio_output(AT91_PIO_PORTA, 14, 0);
> - if (cs_mask & (1 << 5))
> + if (cs_mask & (1 << 1))
> at91_set_pio_output(AT91_PIO_PORTA, 7, 0);
> - if (cs_mask & (1 << 6))
> + if (cs_mask & (1 << 2))
> at91_set_pio_output(AT91_PIO_PORTA, 1, 0);
> - if (cs_mask & (1 << 7))
> + if (cs_mask & (1 << 3))
> at91_set_pio_output(AT91_PIO_PORTB, 3, 0);
> }
>
> @@ -159,20 +151,12 @@ void at91_spi1_hw_init(unsigned long cs_mask)
> writel(1 << ATMEL_ID_SPI1, &pmc->pcer);
>
> if (cs_mask & (1 << 0))
> - at91_set_b_periph(AT91_PIO_PORTA, 8, 0);
> - if (cs_mask & (1 << 1))
> - at91_set_b_periph(AT91_PIO_PORTA, 0, 0);
> - if (cs_mask & (1 << 2))
> - at91_set_b_periph(AT91_PIO_PORTA, 31, 0);
> - if (cs_mask & (1 << 3))
> - at91_set_b_periph(AT91_PIO_PORTA, 30, 0);
> - if (cs_mask & (1 << 4))
> at91_set_pio_output(AT91_PIO_PORTA, 8, 0);
> - if (cs_mask & (1 << 5))
> + if (cs_mask & (1 << 1))
> at91_set_pio_output(AT91_PIO_PORTA, 0, 0);
> - if (cs_mask & (1 << 6))
> + if (cs_mask & (1 << 2))
> at91_set_pio_output(AT91_PIO_PORTA, 31, 0);
> - if (cs_mask & (1 << 7))
> + if (cs_mask & (1 << 3))
> at91_set_pio_output(AT91_PIO_PORTA, 30, 0);
> }
But these changes to at91_spiX_hw_init() are wrong!
The point is that we want to set the spi CS line to GPIO or peripheral
mode by the function. Maybe the interface is bad but all of these
functions behave like this. The assumption is that we always have 4 SPI
CS per port, to setup the first one as peripheral we need to give 0x01
as mask, to setup the same CS as GPIO we need to apply offset of 4 bits
-> 0x10 mask.
> #endif
> diff --git a/board/atmel/at91sam9x5ek/at91sam9x5ek.c b/board/atmel/at91sam9x5ek/at91sam9x5ek.c
> index 6f67c34..fb74a30 100644
> --- a/board/atmel/at91sam9x5ek/at91sam9x5ek.c
> +++ b/board/atmel/at91sam9x5ek/at91sam9x5ek.c
> @@ -272,7 +272,6 @@ int board_init(void)
>
> #ifdef CONFIG_ATMEL_SPI
> at91_spi0_hw_init(1 << 0);
> - at91_spi0_hw_init(1 << 4);
So the correct change would be to remove the first line and leave the
at91_spiX_hw_init() untouched.
> #endif
>
> #ifdef CONFIG_MACB
>
@jagannadh.teki: I grabbed that patch delegated to you @ patchwork.
Best regards
Andreas Bie?mann
next prev parent reply other threads:[~2013-12-17 9:06 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-12-10 8:13 [U-Boot] [PATCH 0/3] arm: atmel: clean up for at91sam9x5ek board Bo Shen
2013-12-10 8:14 ` [U-Boot] [PATCH 1/3] arm: atmel: at91sam9x5: cleanup cs configure for spi Bo Shen
2013-12-17 9:06 ` Andreas Bießmann [this message]
2013-12-17 9:34 ` [U-Boot] [PATCH v2 " Bo Shen
2013-12-17 16:24 ` [U-Boot] [U-Boot,v2,1/3] " Andreas Bießmann
2013-12-10 8:14 ` [U-Boot] [PATCH 2/3] arm: atmel: at91sam9x5: cleanup unneeded undef Bo Shen
2013-12-17 16:24 ` [U-Boot] [U-Boot,2/3] " Andreas Bießmann
2013-12-10 8:14 ` [U-Boot] [PATCH 3/3] arm: atmel: at91sam9x5: move CONFIG_SYS_NO_FLASH to proper position Bo Shen
2013-12-17 16:25 ` [U-Boot] [U-Boot, " Andreas Bießmann
2013-12-17 9:07 ` [U-Boot] [PATCH 0/3] arm: atmel: clean up for at91sam9x5ek board Andreas Bießmann
2013-12-17 9:42 ` Bo Shen
2013-12-17 9:45 ` Bo Shen
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=52B01404.9010402@gmail.com \
--to=andreas.devel@googlemail.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