Skip to contentSkip to conversation

arm: atmel: add at91sam9n12ek board support

PATCH Superseded Josh Wu 1 participant 5 messages Mar 25, 2013

Subsystems (3)

v3 of 4 Superseded Latest is v4 →

lore
Share & tools
lore

Josh Wu

author
#0 lore raw

v3 cover arm: atmel: add at91sam9n12ek board support

This patch series will add at91sam9n12ek board support. In the board, spi/nand flash, mmc, lcd are supported.

TODO:
- ethernet support
- usb support.

Changes since v1:
- split into more patches to make it clearer.
- include an extra patch that use run-time detect for spi ip.
- include an extra patch to remove the chip select for clock part.
- merge at91sam9n12 register definition with at91sam9x5.
- fix copyright issue and add maintainer.
- disable pull-up as possible as we can.
- add mtdparts command.
- fix warnings and typos.

Changes since v2:
- re-arrange the patch series order. move patch
'at91: clock: remove chip macro for plla div2' ahead to 9n12 patches.
- remove redudent blank line in the end of at91sam9n12_devices.c

Bo Shen (1):
spi: atmel_spi: using ip version to check whether has wdrbt

Josh Wu (3):
at91: clock: remove chip macro for plla div2.
arm: at91: add at91sam9n12 register definition
arm: at91: add at91sam9n12ek board support

 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                |   13 +-
 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 +-
 board/atmel/at91sam9n12ek/Makefile                 |   52 +++++
 board/atmel/at91sam9n12ek/at91sam9n12ek.c          |  228 +++++++++++++++++++
 boards.cfg                                         |    3 +
 drivers/spi/atmel_spi.c                            |   15 +-
 drivers/spi/atmel_spi.h                            |    2 +-
 include/configs/at91sam9n12ek.h                    |  232 ++++++++++++++++++++
 14 files changed, 748 insertions(+), 18 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
Signature · 1 line
1.7.9.5
author
#1 lore raw

PATCH v3 1/4 spi: atmel_spi: using ip version to check whether has wdrbt

From: Bo Shen <[email protected]>

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

Tested in at91sam9x5ek and at91sam9n12ek.

[fix warning about incompatible parameter]
---
 drivers/spi/atmel_spi.c |   15 ++++++++++++---
 drivers/spi/atmel_spi.h |    2 +-
 2 files changed, 13 insertions(+), 4 deletions(-)
drivers/spi/atmel_spi.c +12 -3
index ce7d460..9cd7834 100644
@@ -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()
 {
 
@@ -92,10 +101,10 @@ struct spi_slave *spi_setup_slave(unsigned int bus, unsigned int cs,
 	as->slave.cs = 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;
drivers/spi/atmel_spi.h +1 -1
index 057de9a..d240945 100644
@@ -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 */
Signature · 1 line
1.7.9.5
author
#2 lore raw

PATCH v3 2/4 at91: clock: remove chip macro for plla div2.

In reply to Josh Wu

at91sam9x5, at91sam9n12, at91sam9g45/m10g45 has plla div2 bits. For other at91 arm926ejs chips, this plla div2 bits (bit-12 in mckr) is reserved and default value after reset is 0. So we can handle all the chip in a same way.

now we can simply remove the chip select macro.

This patch also changes the div2 code to a more readable format.

---
 arch/arm/cpu/arm926ejs/at91/clock.c |   11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)
arch/arm/cpu/arm926ejs/at91/clock.c +6 -5
index f825388..b6fd2ef 100644
@@ -155,11 +155,12 @@ int at91_clock_init(unsigned long main_clock)
 	 * For now, assume this parentage won't change.
 	 */
 	mckr = readl(&pmc->mckr);
-#if defined(CONFIG_AT91SAM9G45) || defined(CONFIG_AT91SAM9M10G45) \
-		|| defined(CONFIG_AT91SAM9X5)
-	/* plla divisor by 2 */
-	gd->arch.plla_rate_hz /= (1 << ((mckr & 1 << 12) >> 12));
-#endif
+
+	/* plla divisor by 2, Only for AT91SAM9G45, 9M10G45, 9X5, 9N12 */
+	/* For other AT91 chip, the bit 12 of MCKR is reserved, default is 0 */
+	if (mckr & (1 << 12))
+		gd->arch.plla_rate_hz >>= 1;
+
 	gd->arch.mck_rate_hz = at91_css_to_rate(mckr & AT91_PMC_MCKR_CSS_MASK);
 	freq = gd->arch.mck_rate_hz;
 
Signature · 1 line
1.7.9.5
author
#3 lore raw

PATCH v3 3/4 arm: at91: add at91sam9n12 register definition

In reply to Josh Wu

Since at91sam9n12 is a subset of at91sam9x5, so put all at91sam9n12 definitions in at91sam9x5 head file.

---
 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(-)
arch/arm/include/asm/arch-at91/at91sam9_matrix.h +1 -1
index b9a93b0..6e0bebd 100644
@@ -23,7 +23,7 @@
 #include <asm/arch/at91cap9_matrix.h>
 #elif defined(CONFIG_AT91SAM9G45) || defined(CONFIG_AT91SAM9M10G45)
 #include <asm/arch/at91sam9g45_matrix.h>
-#elif defined(CONFIG_AT91SAM9X5)
+#elif defined(CONFIG_AT91SAM9N12) || defined(CONFIG_AT91SAM9X5)
 #include <asm/arch/at91sam9x5_matrix.h>
 #else
 #error "Unsupported AT91SAM9/CAP9 processor"
arch/arm/include/asm/arch-at91/at91sam9x5.h +16 -3
index b7d1932..85e42f5 100644
@@ -1,10 +1,10 @@
 /*
  * Chip-specific header file for the AT91SAM9x5 family
  *
- *  Copyright (C) 2012 Atmel Corporation.
+ *  Copyright (C) 2012-2013 Atmel Corporation.
  *
  * Definitions for the SoC:
- * AT91SAM9x5
+ * AT91SAM9x5 & AT91SAM9N12
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -22,10 +22,12 @@
 #define ATMEL_ID_SYS	1	/* System Controller Interrupt */
 #define ATMEL_ID_PIOAB	2	/* Parallel I/O Controller A and B */
 #define ATMEL_ID_PIOCD	3	/* Parallel I/O Controller C and D */
-#define ATMEL_ID_SMD	4	/* SMD Soft Modem (SMD) */
+#define ATMEL_ID_SMD	4	/* SMD Soft Modem (SMD), only for AT91SAM9X5 */
+#define ATMEL_ID_FUSE	4	/* FUSE Controller, only for AT91SAM9N12 */
 #define ATMEL_ID_USART0	5	/* USART 0 */
 #define ATMEL_ID_USART1	6	/* USART 1 */
 #define ATMEL_ID_USART2	7	/* USART 2 */
+#define ATMEL_ID_USART3	8	/* USART 3 */
 #define ATMEL_ID_TWI0	9	/* Two-Wire Interface 0 */
 #define ATMEL_ID_TWI1	10	/* Two-Wire Interface 1 */
 #define ATMEL_ID_TWI2	11	/* Two-Wire Interface 2 */
@@ -46,6 +48,7 @@
 #define ATMEL_ID_HSMCI1	26	/* High Speed Multimedia Card Interface 1 */
 #define ATMEL_ID_EMAC1	27	/* Ethernet MAC1 */
 #define ATMEL_ID_SSC	28	/* Synchronous Serial Controller */
+#define ATMEL_ID_TRNG	30	/* True Random Number Generator */
 #define ATMEL_ID_IRQ	31	/* Advanced Interrupt Controller */
 
 /*
@@ -85,6 +88,7 @@
 /*
  * System Peripherals
  */
+#define ATMEL_BASE_FUSE		0xffffdc00
 #define ATMEL_BASE_MATRIX	0xffffde00
 #define ATMEL_BASE_PMECC	0xffffe000
 #define ATMEL_BASE_PMERRLOC	0xffffe600
@@ -111,10 +115,15 @@
  */
 #define ATMEL_BASE_ROM		0x00100000 /* Internal ROM base address */
 #define ATMEL_BASE_SRAM		0x00300000 /* Internal SRAM base address */
+
+#ifdef CONFIG_AT91SAM9N12
+#define ATMEL_BASE_OHCI		0x00500000 /* USB Host controller */
+#else	/* AT91SAM9X5 */
 #define ATMEL_BASE_SMD		0x00400000 /* SMD Controller */
 #define ATMEL_BASE_UDPHS_FIFO	0x00500000 /* USB Device HS controller */
 #define ATMEL_BASE_OHCI		0x00600000 /* USB Host controller (OHCI) */
 #define ATMEL_BASE_EHCI		0x00700000 /* USB Host controller (EHCI) */
+#endif
 
 /* 9x5 series chip id definitions */
 #define ARCH_ID_AT91SAM9X5	0x819a05a0
@@ -140,7 +149,11 @@
 /*
  * Cpu Name
  */
+#ifdef CONFIG_AT91SAM9N12
+#define ATMEL_CPU_NAME	"AT91SAM9N12"
+#else	/* AT91SAM9X5 */
 #define ATMEL_CPU_NAME	get_cpu_name()
+#endif
 
 /*
  * Other misc defines
arch/arm/include/asm/arch-at91/at91sam9x5_matrix.h +14 -3
index d6ce6fa..0d33069 100644
@@ -1,10 +1,10 @@
 /*
  * Matrix-centric header file for the AT91SAM9X5 family
  *
- *  Copyright (C) 2012 Atmel Corporation.
+ *  Copyright (C) 2012-2013 Atmel Corporation.
  *
  * Memory Controllers (MATRIX, EBI) - System peripherals registers.
- * Based on AT91SAM9X5 preliminary datasheet.
+ * Based on AT91SAM9X5 & AT91SAM9N12 preliminary datasheet.
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -17,14 +17,25 @@
 
 #ifndef __ASSEMBLY__
 
+/* AT91SAM9N12 Matrix definition is a subset of AT91SAM9X5. */
 struct at91_matrix {
 	u32	mcfg[16];
 	u32	scfg[16];
 	u32	pras[16][2];
 	u32	mrcr;           /* 0x100 Master Remap Control */
-	u32	filler[7];
+	u32	filler[5];
+#ifdef CONFIG_AT91SAM9X5
+	u32	filler1[2];
+#endif
+	/* EBI Chip Select Assignment Register
+	 * 0x118: AT91SAM9N12
+	 * 0x120: AT91SAM9X5
+	 */
 	u32	ebicsa;
 	u32	filler4[47];
+#ifdef CONFIG_AT91SAM9N12
+	u32	filler5[2];
+#endif
 	u32	wpmr;
 	u32	wpsr;
 };
arch/arm/include/asm/arch-at91/hardware.h +1 -1
index 4c4ee70..8812b11 100644
@@ -37,7 +37,7 @@
 # include <asm/arch/at91sam9rl.h>
 #elif defined(CONFIG_AT91SAM9G45) || defined(CONFIG_AT91SAM9M10G45)
 # include <asm/arch/at91sam9g45.h>
-#elif defined(CONFIG_AT91SAM9X5)
+#elif defined(CONFIG_AT91SAM9N12) || defined(CONFIG_AT91SAM9X5)
 # include <asm/arch/at91sam9x5.h>
 #elif defined(CONFIG_AT91CAP9)
 # include <asm/arch/at91cap9.h>
Signature · 1 line
1.7.9.5
author
#4 lore raw

PATCH v3 4/4 arm: at91: add at91sam9n12ek board support

In reply to Josh Wu

Add support for following features:
- nand boot, with PMECC 2bit ECC for 512 bytes sector
- SPI flash boot
- SD card boot
- LCD support

---
changes since v2:
- remove redudent blank line in the end of at91sam9n12_devices.c.

 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               |    2 +-
 board/atmel/at91sam9n12ek/Makefile                |   52 +++++
 board/atmel/at91sam9n12ek/at91sam9n12ek.c         |  228 ++++++++++++++++++++
 boards.cfg                                        |    3 +
 include/configs/at91sam9n12ek.h                   |  232 +++++++++++++++++++++
 8 files changed, 697 insertions(+), 1 deletion(-)
 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
MAINTAINERS +3 -0
index 0951108..51f5b5f 100644
@@ -1009,6 +1009,9 @@ Richard Woodruff <[email protected]>
 
 	omap2420h4	ARM1136EJS
 
+Josh Wu <[email protected]>
+	at91sam9n12ek	ARM926EJS (AT91SAM9N12 SoC)
+
 Ilya Yanok <[email protected]>
 
 	mcx		ARM ARMV7 (AM35x SoC)
arch/arm/cpu/arm926ejs/at91/Makefile +1 -0
index 346e58f..c4408f6 100644
@@ -35,6 +35,7 @@ COBJS-$(CONFIG_AT91SAM9263)	+= at91sam9263_devices.o
 COBJS-$(CONFIG_AT91SAM9RL)	+= at91sam9rl_devices.o
 COBJS-$(CONFIG_AT91SAM9M10G45)	+= at91sam9m10g45_devices.o
 COBJS-$(CONFIG_AT91SAM9G45)	+= at91sam9m10g45_devices.o
+COBJS-$(CONFIG_AT91SAM9N12)	+= at91sam9n12_devices.o
 COBJS-$(CONFIG_AT91SAM9X5)	+= at91sam9x5_devices.o
 COBJS-$(CONFIG_AT91_EFLASH)	+= eflash.o
 COBJS-$(CONFIG_AT91_LED)	+= led.o
arch/arm/cpu/arm926ejs/at91/at91sam9n12_devices.c new file +177 -0

177 lines not on this page · raw message

arch/arm/cpu/arm926ejs/at91/clock.c +1 -1
index b6fd2ef..cc28896 100644
@@ -172,7 +172,7 @@ int at91_clock_init(unsigned long main_clock)
 	if (mckr & AT91_PMC_MCKR_MDIV_MASK)
 		freq /= 2;			/* processor clock division */
 #elif defined(CONFIG_AT91SAM9G45) || defined(CONFIG_AT91SAM9M10G45) \
-		|| defined(CONFIG_AT91SAM9X5)
+		|| defined(CONFIG_AT91SAM9N12) || defined(CONFIG_AT91SAM9X5)
 	/* mdiv <==> divisor
 	 *  0   <==>   1
 	 *  1   <==>   2
board/atmel/at91sam9n12ek/Makefile new file +52 -0

52 lines not on this page · raw message

board/atmel/at91sam9n12ek/at91sam9n12ek.c new file +228 -0

228 lines not on this page · raw message

boards.cfg +3 -0
index 272a5fc..c45cde3 100644
@@ -106,6 +106,9 @@ at91sam9x5ek_mmc             arm         arm926ejs   at91sam9x5ek        atmel
 at91sam9xeek_dataflash_cs0   arm         arm926ejs   at91sam9260ek       atmel          at91        at91sam9260ek:AT91SAM9XE,SYS_USE_DATAFLASH_CS0
 at91sam9xeek_dataflash_cs1   arm         arm926ejs   at91sam9260ek       atmel          at91        at91sam9260ek:AT91SAM9XE,SYS_USE_DATAFLASH_CS1
 at91sam9xeek_nandflash       arm         arm926ejs   at91sam9260ek       atmel          at91        at91sam9260ek:AT91SAM9XE,SYS_USE_NANDFLASH
+at91sam9n12ek_nandflash      arm         arm926ejs   at91sam9n12ek       atmel          at91        at91sam9n12ek:AT91SAM9N12,SYS_USE_NANDFLASH
+at91sam9n12ek_spiflash       arm         arm926ejs   at91sam9n12ek       atmel          at91        at91sam9n12ek:AT91SAM9N12,SYS_USE_SPIFLASH
+at91sam9n12ek_mmc            arm         arm926ejs   at91sam9n12ek       atmel          at91        at91sam9n12ek:AT91SAM9N12,SYS_USE_MMC
 snapper9260                  arm         arm926ejs   -                   bluewater      at91        snapper9260:AT91SAM9260
 snapper9g20                  arm         arm926ejs   snapper9260         bluewater      at91        snapper9260:AT91SAM9G20
 vl_ma2sc                     arm         arm926ejs   vl_ma2sc            BuS            at91
include/configs/at91sam9n12ek.h new file +232 -0

232 lines not on this page · raw message

Signature · 1 line
1.7.9.5