Skip to contentSkip to conversation

replace at91rm9200_usart by atmel_usart

PATCH New Andreas Bießmann 3 participants 10 messages Jun 12, 2011 – Jun 30, 2011

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

cover replace at91rm9200_usart by atmel_usart

This series is an RFC for atmel/next!

It should replace the current at91rm9200_usart driver by the common atmel_usart driver. This is tested on at91rm9200ek, there are patches included for the two other arm920t/at91 boards currently supported by u-boot.
Jens, Eric feel free to test this stuff.

Some of the patches where submitted before in another structure (move arm926ejs/at91/clock.c to arm/lib/at91 and use the API)
-> see http://patchwork.ozlabs.org/patch/99344/

    and http://patchwork.ozlabs.org/patch/99550/

They both are superseded by this series.

There may be some issues with one of the patches in this series if you reorder the patches. Therefore I would like to squash some of them together, if the review process shows that there are no other issues with it. There also might be some unnecessary reorering in some of the defines. This is subject to next version, but feel free to point them out.

Andreas Bie?mann (7):
arm920t/at91: add clock.c
arm920t/at91: use new clock.c features
arm920t/at91: add at91rm9200_devices.c
at91rm9200ek: use atmel_usart
eb_cpux9k2: use atmel_usart
cpuat91: use atmel_usart
driver/serial: delete at91rm9200_usart

 arch/arm/cpu/arm920t/at91/Makefile             |    3 +
 arch/arm/cpu/arm920t/at91/at91rm9200_devices.c |   85 +++++++++++++
 arch/arm/cpu/arm920t/at91/clock.c              |  160 ++++++++++++++++++++++++
 arch/arm/cpu/arm920t/at91/cpu.c                |   43 +++++++
 arch/arm/cpu/arm926ejs/at91/clock.c            |   35 +-----
 arch/arm/include/asm/arch-at91/at91rm9200.h    |   10 ++-
 arch/arm/include/asm/arch-at91/clk.h           |   42 ++++++-
 board/BuS/eb_cpux9k2/cpux9k2.c                 |    7 +
 board/atmel/at91rm9200ek/at91rm9200ek.c        |    7 +
 board/eukrea/cpuat91/cpuat91.c                 |    8 ++
 drivers/serial/Makefile                        |    1 -
 drivers/serial/at91rm9200_usart.c              |  126 -------------------
 include/configs/at91rm9200ek.h                 |   10 ++-
 include/configs/cpuat91.h                      |   12 +-
 include/configs/eb_cpux9k2.h                   |   10 +-
 15 files changed, 379 insertions(+), 180 deletions(-)
 create mode 100644 arch/arm/cpu/arm920t/at91/at91rm9200_devices.c
 create mode 100644 arch/arm/cpu/arm920t/at91/clock.c
 create mode 100644 arch/arm/cpu/arm920t/at91/cpu.c
 delete mode 100644 drivers/serial/at91rm9200_usart.c

regards

Andreas Bie?mann

Signature · 1 line
1.7.5.4
#1 lore raw

PATCH 1/7 arm920t/at91: add clock.c

This patch adds an copy of arm926ejs/at91/clock.c to arm920t/at91. The arm926ejs specialities are removed from arm920t version and vice versa.

---
 arch/arm/cpu/arm920t/at91/Makefile   |    1 +
 arch/arm/cpu/arm920t/at91/clock.c    |  160 ++++++++++++++++++++++++++++++++++
 arch/arm/cpu/arm926ejs/at91/clock.c  |   35 +-------
 arch/arm/include/asm/arch-at91/clk.h |   42 ++++++++--
 4 files changed, 198 insertions(+), 40 deletions(-)
 create mode 100644 arch/arm/cpu/arm920t/at91/clock.c
arch/arm/cpu/arm920t/at91/Makefile +1 -0
index 5c71b77..8258ecd 100644
@@ -28,6 +28,7 @@ LIB	= $(obj)lib$(SOC).o
 SOBJS	+= lowlevel_init.o
 COBJS	+= reset.o
 COBJS	+= timer.o
+COBJS	+= clock.o
 
 SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
 OBJS	:= $(addprefix $(obj),$(SOBJS) $(COBJS))
arch/arm/cpu/arm920t/at91/clock.c new file +160 -0

160 lines not on this page · raw message

arch/arm/cpu/arm926ejs/at91/clock.c +1 -34
index 608af2c..a7085de 100644
@@ -23,36 +23,6 @@
 
 DECLARE_GLOBAL_DATA_PTR;
 
-unsigned long get_cpu_clk_rate(void)
-{
-	return gd->cpu_clk_rate_hz;
-}
-
-unsigned long get_main_clk_rate(void)
-{
-	return gd->main_clk_rate_hz;
-}
-
-unsigned long get_mck_clk_rate(void)
-{
-	return gd->mck_rate_hz;
-}
-
-unsigned long get_plla_clk_rate(void)
-{
-	return gd->plla_rate_hz;
-}
-
-unsigned long get_pllb_clk_rate(void)
-{
-	return gd->pllb_rate_hz;
-}
-
-u32 get_pllb_init(void)
-{
-	return gd->at91_pllb_usb_init;
-}
-
 static unsigned long at91_css_to_rate(unsigned long css)
 {
 	switch (css) {
@@ -192,10 +162,7 @@ int at91_clock_init(unsigned long main_clock)
 	freq = gd->mck_rate_hz;
 
 	freq /= (1 << ((mckr & AT91_PMC_MCKR_PRES_MASK) >> 2));	/* prescale */
-#if defined(CONFIG_AT91RM9200)
-	/* mdiv */
-	gd->mck_rate_hz = freq / (1 + ((mckr & AT91_PMC_MCKR_MDIV_MASK) >> 8));
-#elif defined(CONFIG_AT91SAM9G20)
+#if defined(CONFIG_AT91SAM9G20)
 	/* mdiv ; (x >> 7) = ((x >> 8) * 2) */
 	gd->mck_rate_hz = (mckr & AT91_PMC_MCKR_MDIV_MASK) ?
 		freq / ((mckr & AT91_PMC_MCKR_MDIV_MASK) >> 7) : freq;
arch/arm/include/asm/arch-at91/clk.h +36 -6

49 lines not on this page · raw message

Signature · 1 line
1.7.5.4
#2 lore raw

PATCH 2/7 arm920t/at91: use new clock.c features

In reply to Andreas Bießmann

This patch enables the new clock features from arm920t/at91/clock.c. This is an required step to get at91rm9200_usart replaced by atmel_usart driver.

Cc Jens Scharsig <[email protected]>
Cc Eric B?nard <[email protected]>
---
 arch/arm/cpu/arm920t/at91/Makefile          |    1 +
 arch/arm/cpu/arm920t/at91/cpu.c             |   43 +++++++++++++++++++++++++++
 arch/arm/include/asm/arch-at91/at91rm9200.h |    1 +
 include/configs/at91rm9200ek.h              |    3 ++
 include/configs/cpuat91.h                   |    5 ++-
 include/configs/eb_cpux9k2.h                |    4 +-
 6 files changed, 53 insertions(+), 4 deletions(-)
 create mode 100644 arch/arm/cpu/arm920t/at91/cpu.c
arch/arm/cpu/arm920t/at91/Makefile +1 -0
index 8258ecd..4417dfe 100644
@@ -29,6 +29,7 @@ SOBJS	+= lowlevel_init.o
 COBJS	+= reset.o
 COBJS	+= timer.o
 COBJS	+= clock.o
+COBJS	+= cpu.o
 
 SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
 OBJS	:= $(addprefix $(obj),$(SOBJS) $(COBJS))
arch/arm/cpu/arm920t/at91/cpu.c new file +43 -0

43 lines not on this page · raw message

arch/arm/include/asm/arch-at91/at91rm9200.h +1 -0
index f1912e2..fd774b4 100644
@@ -22,6 +22,7 @@
 #define __AT91RM9200_H__
 
 #define CONFIG_AT91FAMILY	/* it's a member of AT91 */
+#define CONFIG_ARCH_CPU_INIT	/* we need arch_cpu_init() for hw timers */
 #define CONFIG_ARM920T		/* This is an ARM920T Core	*/
 
 /* Periperial Identifiers */
include/configs/at91rm9200ek.h +3 -0
index 16cd214..ee199ab 100644
@@ -55,6 +55,7 @@
  * CONFIG_SYS_HZ is the tick rate for timer tc0
  */
 #define AT91C_XTAL_CLOCK		18432000
+#define CONFIG_SYS_AT91_SLOW_CLOCK	32768
 #define AT91C_MAIN_CLOCK		((AT91C_XTAL_CLOCK / 4) * 39)
 #define AT91C_MASTER_CLOCK		(AT91C_MAIN_CLOCK / 3 )
 #define CONFIG_SYS_HZ_CLOCK		(AT91C_MASTER_CLOCK / 2)
@@ -66,6 +67,8 @@
 #define CONFIG_CPUAT91
 #define USE_920T_MMU
 
+#include <asm/hardware.h>	/* needed for port definitions */
+
 #define CONFIG_CMDLINE_TAG
 #define CONFIG_SETUP_MEMORY_TAGS
 #define CONFIG_INITRD_TAG
include/configs/cpuat91.h +3 -2
index cfaef15..2bda72b 100644
@@ -37,6 +37,7 @@
 #endif
 
 #define AT91C_XTAL_CLOCK		18432000
+#define CONFIG_SYS_AT91_SLOW_CLOCK	32768
 #define AT91C_MAIN_CLOCK		((AT91C_XTAL_CLOCK / 4) * 39)
 #define AT91C_MASTER_CLOCK		(AT91C_MAIN_CLOCK / 3)
 #define CONFIG_SYS_HZ_CLOCK		(AT91C_MASTER_CLOCK / 2)
@@ -45,11 +46,11 @@
 #define CONFIG_ARM920T
 #define CONFIG_AT91RM9200
 #define CONFIG_CPUAT91
-#define CONFIG_AT91FAMILY
-
 #undef CONFIG_USE_IRQ
 #define USE_920T_MMU
 
+#include <asm/hardware.h>	/* needed for port definitions */
+
 #define CONFIG_CMDLINE_TAG
 #define CONFIG_SETUP_MEMORY_TAGS
 #define CONFIG_INITRD_TAG
include/configs/eb_cpux9k2.h +2 -2
index e12770a..25b28f5 100644
@@ -36,7 +36,7 @@
 #define CONFIG_VERSION_VARIABLE
 #define CONFIG_IDENT_STRING	" on EB+CPUx9K2"
 
-#include <asm/arch/hardware.h>	/* needed for port definitions */
+#include <asm/hardware.h>	/* needed for port definitions */
 
 #define CONFIG_MISC_INIT_R
 
@@ -69,7 +69,7 @@
 #define CONFIG_SYS_HZ		1000
 #define CONFIG_SYS_HZ_CLOCK 	(AT91C_MASTER_CLOCK / 2)
 
-#define AT91_SLOW_CLOCK			32768		/* slow clock */
+#define CONFIG_SYS_AT91_SLOW_CLOCK	32768		/* slow clock */
 
 #define CONFIG_CMDLINE_TAG		1
 #define CONFIG_SETUP_MEMORY_TAGS	1
Signature · 1 line
1.7.5.4
#3 lore raw

PATCH 3/7 arm920t/at91: add at91rm9200_devices.c

In reply to Andreas Bießmann

This is a copy of arm926ejs/at91 api for perpherial initialisation. At the moment we just need the usart part of the api.

---
 arch/arm/cpu/arm920t/at91/Makefile             |    1 +
 arch/arm/cpu/arm920t/at91/at91rm9200_devices.c |   85 ++++++++++++++++++++++++
 arch/arm/include/asm/arch-at91/at91rm9200.h    |    9 ++-
 3 files changed, 93 insertions(+), 2 deletions(-)
 create mode 100644 arch/arm/cpu/arm920t/at91/at91rm9200_devices.c
arch/arm/cpu/arm920t/at91/Makefile +1 -0
index 4417dfe..309bcd6 100644
@@ -30,6 +30,7 @@ COBJS	+= reset.o
 COBJS	+= timer.o
 COBJS	+= clock.o
 COBJS	+= cpu.o
+COBJS	+= at91rm9200_devices.o
 
 SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
 OBJS	:= $(addprefix $(obj),$(SOBJS) $(COBJS))
arch/arm/cpu/arm920t/at91/at91rm9200_devices.c new file +85 -0

85 lines not on this page · raw message

arch/arm/include/asm/arch-at91/at91rm9200.h +7 -2
index fd774b4..42a32d3 100644
@@ -21,9 +21,10 @@
 #ifndef __AT91RM9200_H__
 #define __AT91RM9200_H__
 
-#define CONFIG_AT91FAMILY	/* it's a member of AT91 */
+#define CONFIG_AT91FAMILY	/* it's a member of AT91 family */
+#define CONFIG_ARM920T		/* it's an ARM920T Core */
 #define CONFIG_ARCH_CPU_INIT	/* we need arch_cpu_init() for hw timers */
-#define CONFIG_ARM920T		/* This is an ARM920T Core	*/
+#define CONFIG_AT91_GPIO	/* and require always gpio features */
 
 /* Periperial Identifiers */
 
@@ -78,6 +79,10 @@
 #define ATMEL_BASE_AIC		0xFFFFF000
 #define ATMEL_BASE_DBGU		0xFFFFF200
 #define ATMEL_BASE_PIO		0xFFFFF400	/* 4x 0x200 Offset */
+#define ATMEL_BASE_PIOA		0xFFFFF400
+#define ATMEL_BASE_PIOB		0xFFFFF600
+#define ATMEL_BASE_PIOC		0xFFFFF800
+#define ATMEL_BASE_PIOD		0xFFFFFA00
 #define ATMEL_BASE_PMC		0xFFFFFC00
 #define ATMEL_BASE_ST		0xFFFFFD00
 #define ATMEL_BASE_RTC		0xFFFFFE00
Signature · 1 line
1.7.5.4
#4 lore raw

PATCH 4/7 at91rm9200ek: use atmel_usart

In reply to Andreas Bießmann
---
 board/atmel/at91rm9200ek/at91rm9200ek.c |    7 +++++++
 include/configs/at91rm9200ek.h          |    7 +++++--
 2 files changed, 12 insertions(+), 2 deletions(-)
board/atmel/at91rm9200ek/at91rm9200ek.c +7 -0
index 5ebc24d..ec0daba 100644
@@ -31,6 +31,7 @@
 #include <asm/arch/hardware.h>
 #include <asm/arch/at91_pio.h>
 #include <asm/arch/at91_pmc.h>
+#include <asm/arch/at91_common.h>
 #include <asm/io.h>
 
 DECLARE_GLOBAL_DATA_PTR;
@@ -54,6 +55,12 @@ int board_init(void)
 	return 0;
 }
 
+int board_early_init_f(void)
+{
+	at91_seriald_hw_init();
+	return 0;
+}
+
 int dram_init (void)
 {
 	/* dram_init must store complete ramsize in gd->ram_size */
include/configs/at91rm9200ek.h +5 -2
index ee199ab..b847798 100644
@@ -73,6 +73,8 @@
 #define CONFIG_SETUP_MEMORY_TAGS
 #define CONFIG_INITRD_TAG
 
+#define CONFIG_BOARD_EARLY_INIT_F
+
 /*
  * Memory Configuration
  */
@@ -123,8 +125,9 @@
  * CONFIG_DBGU is DBGU unit on J10
  * CONFIG_USART1 is USART1 on J14
  */
-#define CONFIG_AT91RM9200_USART
-#define CONFIG_DBGU
+#define CONFIG_ATMEL_USART
+#define CONFIG_USART_BASE	ATMEL_BASE_DBGU
+#define CONFIG_USART_ID		0/* ignored in arm */
 
 #define CONFIG_SYS_BAUDRATE_TABLE	{115200 , 19200, 38400, 57600, 9600 }
 #define CONFIG_BAUDRATE			115200
Signature · 1 line
1.7.5.4
#5 lore raw

PATCH 5/7 eb_cpux9k2: use atmel_usart

In reply to Andreas Bießmann
---
 board/BuS/eb_cpux9k2/cpux9k2.c |    7 +++++++
 include/configs/eb_cpux9k2.h   |    6 ++++--
 2 files changed, 11 insertions(+), 2 deletions(-)
board/BuS/eb_cpux9k2/cpux9k2.c +7 -0
index e9a1cb2..a918b04 100644
@@ -33,6 +33,7 @@
 #include <asm/arch/at91_pio.h>
 #include <asm/arch/at91_pmc.h>
 #include <asm/arch/at91_mc.h>
+#include <asm/arch/at91_common.h>
 
 #ifdef CONFIG_STATUS_LED
 #include <status_led.h>
@@ -77,6 +78,12 @@ int board_init(void)
 	return 0;
 }
 
+int board_early_init_f(void)
+{
+	at91_seriald_hw_init();
+	return 0;
+}
+
 #ifdef CONFIG_MISC_INIT_R
 
 int misc_init_r(void)
include/configs/eb_cpux9k2.h +4 -2
index 25b28f5..c4b1e65 100644
@@ -39,6 +39,7 @@
 #include <asm/hardware.h>	/* needed for port definitions */
 
 #define CONFIG_MISC_INIT_R
+#define CONFIG_BOARD_EARLY_INIT_F
 
 /*--------------------------------------------------------------------------*/
 #define CONFIG_SYS_TEXT_BASE 		0x00000000
@@ -174,8 +175,9 @@
 #define CONFIG_SYS_BAUDRATE_TABLE	{ 115200, 19200, 38400, 57600, 9600 }
 
 #define CONFIG_BAUDRATE 115200
-#define CONFIG_AT91RM9200_USART
-#define CONFIG_DBGU			/* define DBGU as console */
+#define CONFIG_ATMEL_USART
+#define CONFIG_USART_BASE	ATMEL_BASE_DBGU
+#define CONFIG_USART_ID		0/* ignored in arm */
 
 /*
  * network
Signature · 1 line
1.7.5.4
#7 lore raw

PATCH 6/7 cpuat91: use atmel_usart

In reply to Andreas Bießmann
---
 board/eukrea/cpuat91/cpuat91.c |    8 ++++++++
 include/configs/cpuat91.h      |    7 ++++---
 2 files changed, 12 insertions(+), 3 deletions(-)
board/eukrea/cpuat91/cpuat91.c +8 -0
index fa4b25b..5d05414 100644
@@ -32,6 +32,7 @@
 #include <asm/arch/hardware.h>
 #include <asm/arch/at91_pio.h>
 #include <asm/arch/at91_pmc.h>
+#include <asm/arch/at91_common.h>
 
 DECLARE_GLOBAL_DATA_PTR;
 
@@ -52,6 +53,13 @@ int board_init(void)
 	return 0;
 }
 
+int board_early_init_f(void)
+{
+	at91_seriald_hw_init();
+	return 0;
+}
+
+
 int dram_init(void)
 {
 	/* dram_init must store complete ramsize in gd->ram_size */
include/configs/cpuat91.h +4 -3
index 2bda72b..75b881c 100644
@@ -54,6 +54,7 @@
 #define CONFIG_CMDLINE_TAG
 #define CONFIG_SETUP_MEMORY_TAGS
 #define CONFIG_INITRD_TAG
+#define CONFIG_BOARD_EARLY_INIT_F
 
 #ifndef CONFIG_SKIP_LOWLEVEL_INIT
 #define CONFIG_SYS_USE_MAIN_OSCILLATOR
@@ -87,9 +88,9 @@
 #define CONFIG_SYS_SDRC_TR_VAL	0x000002E0 /* Write refresh rate */
 #endif	/* CONFIG_SKIP_LOWLEVEL_INIT */
 
-/* define one of these to choose the DBGU, USART0 or USART1 as console */
-#define CONFIG_AT91RM9200_USART
-#define CONFIG_DBGU
+#define CONFIG_ATMEL_USART
+#define CONFIG_USART_BASE	ATMEL_BASE_DBGU
+#define CONFIG_USART_ID		0/* ignored in arm */
 
 #undef CONFIG_HARD_I2C
 #undef CONFIG_SOFT_I2C
Signature · 1 line
1.7.5.4
#8 lore raw

PATCH 7/7 driver/serial: delete at91rm9200_usart

In reply to Andreas Bießmann

The at91rm9200_usart driver could be fully replaced by atmel_usart driver.

---
 drivers/serial/Makefile           |    1 -
 drivers/serial/at91rm9200_usart.c |  126 -------------------------------------
 2 files changed, 0 insertions(+), 127 deletions(-)
 delete mode 100644 drivers/serial/at91rm9200_usart.c
drivers/serial/Makefile +0 -1
index 5a6011e..0e171b6 100644
@@ -28,7 +28,6 @@ LIB	:= $(obj)libserial.o
 COBJS-$(CONFIG_ALTERA_UART) += altera_uart.o
 COBJS-$(CONFIG_ALTERA_JTAG_UART) += altera_jtag_uart.o
 COBJS-$(CONFIG_ARM_DCC) += arm_dcc.o
-COBJS-$(CONFIG_AT91RM9200_USART) += at91rm9200_usart.o
 COBJS-$(CONFIG_ATMEL_USART) += atmel_usart.o
 COBJS-$(CONFIG_MCFUART) += mcfuart.o
 COBJS-$(CONFIG_NS9750_UART) += ns9750_serial.o
drivers/serial/at91rm9200_usart.c deleted +0 -126

126 lines not on this page · raw message

Signature · 1 line
1.7.5.4
#9 lore raw

cover replace at91rm9200_usart by atmel_usart

In reply to Andreas Bießmann

Dear Andreas Bie?mann,

Quoted 40 lines

This series is an RFC for atmel/next!

It should replace the current at91rm9200_usart driver by the common atmel_usart driver. This is tested on at91rm9200ek, there are patches included for the two other arm920t/at91 boards currently supported by u-boot.
Jens, Eric feel free to test this stuff.

Some of the patches where submitted before in another structure (move arm926ejs/at91/clock.c to arm/lib/at91 and use the API)
-> see http://patchwork.ozlabs.org/patch/99344/

    and http://patchwork.ozlabs.org/patch/99550/

They both are superseded by this series.

There may be some issues with one of the patches in this series if you reorder the patches. Therefore I would like to squash some of them together, if the review process shows that there are no other issues with it. There also might be some unnecessary reorering in some of the defines. This is subject to next version, but feel free to point them out.

Andreas Bie?mann (7):
arm920t/at91: add clock.c
arm920t/at91: use new clock.c features
arm920t/at91: add at91rm9200_devices.c
at91rm9200ek: use atmel_usart
eb_cpux9k2: use atmel_usart
cpuat91: use atmel_usart
driver/serial: delete at91rm9200_usart

 arch/arm/cpu/arm920t/at91/Makefile             |    3 +
 arch/arm/cpu/arm920t/at91/at91rm9200_devices.c |   85 +++++++++++++
 arch/arm/cpu/arm920t/at91/clock.c              |  160 ++++++++++++++++++++++++
 arch/arm/cpu/arm920t/at91/cpu.c                |   43 +++++++
 arch/arm/cpu/arm926ejs/at91/clock.c            |   35 +-----
 arch/arm/include/asm/arch-at91/at91rm9200.h    |   10 ++-
 arch/arm/include/asm/arch-at91/clk.h           |   42 ++++++-
 board/BuS/eb_cpux9k2/cpux9k2.c                 |    7 +
 board/atmel/at91rm9200ek/at91rm9200ek.c        |    7 +
 board/eukrea/cpuat91/cpuat91.c                 |    8 ++
 drivers/serial/Makefile                        |    1 -
 drivers/serial/at91rm9200_usart.c              |  126 -------------------
Quoted 8 lines
 include/configs/at91rm9200ek.h                 |   10 ++-
 include/configs/cpuat91.h                      |   12 +-
 include/configs/eb_cpux9k2.h                   |   10 +-
 15 files changed, 379 insertions(+), 180 deletions(-)
 create mode 100644 arch/arm/cpu/arm920t/at91/at91rm9200_devices.c
 create mode 100644 arch/arm/cpu/arm920t/at91/clock.c
 create mode 100644 arch/arm/cpu/arm920t/at91/cpu.c
 delete mode 100644 drivers/serial/at91rm9200_usart.c

Applied to u-boot-atmel/master.
Thanks,
Reinhard