Patchwork [U-Boot,v4,1/3] spi: atmel_spi: using ip version to check whether has wdrbt

login
register
mail settings
Submitter Wu, Josh
Date April 17, 2013, 9:42 a.m.
Message ID <1366191764-17549-2-git-send-email-josh.wu@atmel.com>
Download mbox | patch
Permalink /patch/237182/
State Accepted
Delegated to: Andreas Bießmann
Headers show

Comments

Wu, Josh - April 17, 2013, 9:42 a.m.
From: Bo Shen <voice.shen@atmel.com>

Using IP version to check whether it has wdrbt bit in mode register

Tested in at91sam9x5ek and at91sam9n12ek.

Signed-off-by: Bo Shen <voice.shen@atmel.com>
[fix warning about incompatible parameter]
Signed-off-by: Josh Wu <josh.wu@atmel.com>
---
changes since v3:
  - rebase on top of atmel master tree.

 drivers/spi/atmel_spi.c |   15 ++++++++++++---
 drivers/spi/atmel_spi.h |    2 +-
 2 files changed, 13 insertions(+), 4 deletions(-)
Andreas Bießmann - May 12, 2013, 2:57 p.m.
Dear Josh Wu,

Josh Wu <josh.wu@atmel.com> writes:
>From: Bo Shen <voice.shen@atmel.com>
>
>Using IP version to check whether it has wdrbt bit in mode register
>
>Tested in at91sam9x5ek and at91sam9n12ek.
>
>Signed-off-by: Bo Shen <voice.shen@atmel.com>
>[fix warning about incompatible parameter]
>Signed-off-by: Josh Wu <josh.wu@atmel.com>
>
>---
>changes since v3:
>  - rebase on top of atmel master tree.
>
> drivers/spi/atmel_spi.c |   15 ++++++++++++---
> drivers/spi/atmel_spi.h |    2 +-
> 2 files changed, 13 insertions(+), 4 deletions(-)

applied to u-boot-atmel/master, thanks!

Best regards,
Andreas Bießmann
Andreas Bießmann - May 12, 2013, 2:57 p.m.
Dear Josh Wu,

Josh Wu <josh.wu@atmel.com> writes:
>Since at91sam9n12 is a subset of at91sam9x5, so put all at91sam9n12
>definitions in at91sam9x5 head file.
>
>Signed-off-by: Josh Wu <josh.wu@atmel.com>
>
>---
>arch/arm/include/asm/arch-at91/at91sam9_matrix.h   |    2 +-
> arch/arm/include/asm/arch-at91/at91sam9x5.h        |   19 ++++++++++++++++---
> arch/arm/include/asm/arch-at91/at91sam9x5_matrix.h |   17 ++++++++++++++---
> arch/arm/include/asm/arch-at91/hardware.h          |    2 +-
> 4 files changed, 32 insertions(+), 8 deletions(-)

applied to u-boot-atmel/master, thanks!

Best regards,
Andreas Bießmann
Andreas Bießmann - May 12, 2013, 2:57 p.m.
Dear Josh Wu,

Josh Wu <josh.wu@atmel.com> writes:
>Add support for following features:
>  - nand boot, with PMECC 2bit ECC for 512 bytes sector
>  - SPI flash boot
>  - SD card boot
>  - LCD support
>
>Signed-off-by: Josh Wu <josh.wu@atmel.com>
>[fix -Wimplicit-function-declaration for at91_lcd_hw_init()]
>Signed-off-by: Andreas Bießmann <andreas.devel@googlemail.com>
>---
> MAINTAINERS                                       |    3 +
> arch/arm/cpu/arm926ejs/at91/Makefile              |    1 +
> arch/arm/cpu/arm926ejs/at91/at91sam9n12_devices.c |  177 ++++++++++++++++
> arch/arm/cpu/arm926ejs/at91/clock.c               |    4 +-
> arch/arm/include/asm/arch-at91/at91_common.h      |    1 +
> board/atmel/at91sam9n12ek/Makefile                |   52 +++++
> board/atmel/at91sam9n12ek/at91sam9n12ek.c         |  228 ++++++++++++++++++++
> boards.cfg                                        |    3 +
> include/configs/at91sam9n12ek.h                   |  232 +++++++++++++++++++++
> 9 files changed, 699 insertions(+), 2 deletions(-)
> create mode 100644 arch/arm/cpu/arm926ejs/at91/at91sam9n12_devices.c
> create mode 100644 board/atmel/at91sam9n12ek/Makefile
> create mode 100644 board/atmel/at91sam9n12ek/at91sam9n12ek.c
> create mode 100644 include/configs/at91sam9n12ek.h

applied to u-boot-atmel/master, thanks!

Best regards,
Andreas Bießmann
Andreas Bießmann - May 12, 2013, 2:57 p.m.
Dear Josh Wu,

Josh Wu <josh.wu@atmel.com> writes:
>From: Bo Shen <voice.shen@atmel.com>
>
>Using IP version to check whether it has wdrbt bit in mode register
>
>Tested in at91sam9x5ek and at91sam9n12ek.
>
>Signed-off-by: Bo Shen <voice.shen@atmel.com>
>[fix warning about incompatible parameter]
>Signed-off-by: Josh Wu <josh.wu@atmel.com>
>
>---
>changes since v3:
>  - rebase on top of atmel master tree.
>
> drivers/spi/atmel_spi.c |   15 ++++++++++++---
> drivers/spi/atmel_spi.h |    2 +-
> 2 files changed, 13 insertions(+), 4 deletions(-)

applied to u-boot-atmel/master, thanks!

Best regards,
Andreas Bießmann
Andreas Bießmann - May 12, 2013, 2:57 p.m.
Dear Josh Wu,

Josh Wu <josh.wu@atmel.com> writes:
>Since at91sam9n12 is a subset of at91sam9x5, so put all at91sam9n12
>definitions in at91sam9x5 head file.
>
>Signed-off-by: Josh Wu <josh.wu@atmel.com>
>
>---
>arch/arm/include/asm/arch-at91/at91sam9_matrix.h   |    2 +-
> arch/arm/include/asm/arch-at91/at91sam9x5.h        |   19 ++++++++++++++++---
> arch/arm/include/asm/arch-at91/at91sam9x5_matrix.h |   17 ++++++++++++++---
> arch/arm/include/asm/arch-at91/hardware.h          |    2 +-
> 4 files changed, 32 insertions(+), 8 deletions(-)

applied to u-boot-atmel/master, thanks!

Best regards,
Andreas Bießmann
Andreas Bießmann - May 12, 2013, 2:57 p.m.
Dear Josh Wu,

Josh Wu <josh.wu@atmel.com> writes:
>Add support for following features:
>  - nand boot, with PMECC 2bit ECC for 512 bytes sector
>  - SPI flash boot
>  - SD card boot
>  - LCD support
>
>Signed-off-by: Josh Wu <josh.wu@atmel.com>
>[fix -Wimplicit-function-declaration for at91_lcd_hw_init()]
>Signed-off-by: Andreas Bießmann <andreas.devel@googlemail.com>
>---
> MAINTAINERS                                       |    3 +
> arch/arm/cpu/arm926ejs/at91/Makefile              |    1 +
> arch/arm/cpu/arm926ejs/at91/at91sam9n12_devices.c |  177 ++++++++++++++++
> arch/arm/cpu/arm926ejs/at91/clock.c               |    4 +-
> arch/arm/include/asm/arch-at91/at91_common.h      |    1 +
> board/atmel/at91sam9n12ek/Makefile                |   52 +++++
> board/atmel/at91sam9n12ek/at91sam9n12ek.c         |  228 ++++++++++++++++++++
> boards.cfg                                        |    3 +
> include/configs/at91sam9n12ek.h                   |  232 +++++++++++++++++++++
> 9 files changed, 699 insertions(+), 2 deletions(-)
> create mode 100644 arch/arm/cpu/arm926ejs/at91/at91sam9n12_devices.c
> create mode 100644 board/atmel/at91sam9n12ek/Makefile
> create mode 100644 board/atmel/at91sam9n12ek/at91sam9n12ek.c
> create mode 100644 include/configs/at91sam9n12ek.h

applied to u-boot-atmel/master, thanks!

Best regards,
Andreas Bießmann
Andreas Bießmann - May 12, 2013, 2:57 p.m.
Dear Josh Wu,

Josh Wu <josh.wu@atmel.com> writes:
>Signed-off-by: Josh Wu <josh.wu@atmel.com>
>
>---
>arch/arm/cpu/arm926ejs/at91/at91sam9260_devices.c |    4 ++++
> board/atmel/at91sam9260ek/at91sam9260ek.c         |   10 ++++++++++
> include/configs/at91sam9260ek.h                   |   16 ++++++++++++++--
> 3 files changed, 28 insertions(+), 2 deletions(-)

applied to u-boot-atmel/master, thanks!

Best regards,
Andreas Bießmann
Andreas Bießmann - May 12, 2013, 2:57 p.m.
Dear Josh Wu,

Josh Wu <josh.wu@atmel.com> writes:
>Signed-off-by: Josh Wu <josh.wu@atmel.com>
>
>---
>boards.cfg                      |    1 +
> include/configs/at91sam9260ek.h |   18 +++++++++++++++++-
> 2 files changed, 18 insertions(+), 1 deletion(-)

applied to u-boot-atmel/master, thanks!

Best regards,
Andreas Bießmann
Andreas Bießmann - May 12, 2013, 2:57 p.m.
Dear Bo Shen,

Bo Shen <voice.shen@atmel.com> writes:
>Using IP version for different setting
>  - Higher version supports 8bit mode
>  - Higher version bus width setting is different
>
>Signed-off-by: Bo Shen <voice.shen@atmel.com>
>
>---
>drivers/mmc/gen_atmel_mci.c |   42 ++++++++++++++++++++++++++++++++++++++----
> include/atmel_mci.h         |    2 ++
> 2 files changed, 40 insertions(+), 4 deletions(-)

applied to u-boot-atmel/master, thanks!

Best regards,
Andreas Bießmann
Andreas Bießmann - May 12, 2013, 2:57 p.m.
Dear Bo Shen,

Bo Shen <voice.shen@atmel.com> writes:
>add mmc card support with atmel mci driver
>
>Signed-off-by: Bo Shen <voice.shen@atmel.com>
>
>---
>drivers/mmc/gen_atmel_mci.c |    5 ++++-
> 1 file changed, 4 insertions(+), 1 deletion(-)

applied to u-boot-atmel/master, thanks!

Best regards,
Andreas Bießmann
Andreas Bießmann - May 12, 2013, 2:57 p.m.
Dear Andreas Bießmann,

Andreas Bießmann <andreas.devel@googlemail.com> writes:
>Signed-off-by: Andreas Bießmann <andreas.devel@googlemail.com>
>Acked-by: Bo Shen <voice.shen@atmel.com>
>
>---
>Changes in v2:
> * use only one ifdef for sam9G variants
>
> board/atmel/at91sam9260ek/at91sam9260ek.c |   12 ------------
> include/configs/at91sam9260ek.h           |   18 ++++++++++++++++++
> 2 files changed, 18 insertions(+), 12 deletions(-)

applied to u-boot-atmel/master, thanks!

Best regards,
Andreas Bießmann

Patch

diff --git a/drivers/spi/atmel_spi.c b/drivers/spi/atmel_spi.c
index f4b1bad..52594e3 100644
--- a/drivers/spi/atmel_spi.c
+++ b/drivers/spi/atmel_spi.c
@@ -30,6 +30,15 @@ 
 
 #include "atmel_spi.h"
 
+static int spi_has_wdrbt(struct atmel_spi_slave *slave)
+{
+	unsigned int ver;
+
+	ver = spi_readl(slave, VERSION);
+
+	return (ATMEL_SPI_VERSION_REV(ver) >= 0x210);
+}
+
 void spi_init()
 {
 
@@ -90,10 +99,10 @@  struct spi_slave *spi_setup_slave(unsigned int bus, unsigned int cs,
 
 	as->regs = regs;
 	as->mr = ATMEL_SPI_MR_MSTR | ATMEL_SPI_MR_MODFDIS
-#if defined(CONFIG_AT91SAM9X5) || defined(CONFIG_AT91SAM9M10G45)
-			| ATMEL_SPI_MR_WDRBT
-#endif
 			| ATMEL_SPI_MR_PCS(~(1 << cs) & 0xf);
+	if (spi_has_wdrbt(as))
+		as->mr |= ATMEL_SPI_MR_WDRBT;
+
 	spi_writel(as, CSR(cs), csrx);
 
 	return &as->slave;
diff --git a/drivers/spi/atmel_spi.h b/drivers/spi/atmel_spi.h
index 057de9a..d240945 100644
--- a/drivers/spi/atmel_spi.h
+++ b/drivers/spi/atmel_spi.h
@@ -64,7 +64,7 @@ 
 #define ATMEL_SPI_CSRx_DLYBCT(x)	((x) << 24)
 
 /* Bits in VERSION */
-#define ATMEL_SPI_VERSION_REV(x)	((x) << 0)
+#define ATMEL_SPI_VERSION_REV(x)	((x) & 0xfff)
 #define ATMEL_SPI_VERSION_MFN(x)	((x) << 16)
 
 /* Constants for CSRx:BITS */