* [U-Boot] [PATCH atmel/next 1/7] arm920t/at91: add clock.c
2011-06-12 11:49 [U-Boot] [PATCH atmel/next 0/7] replace at91rm9200_usart by atmel_usart Andreas Bießmann
@ 2011-06-12 11:49 ` Andreas Bießmann
2011-06-12 11:49 ` [U-Boot] [PATCH atmel/next 2/7] arm920t/at91: use new clock.c features Andreas Bießmann
` (6 subsequent siblings)
7 siblings, 0 replies; 10+ messages in thread
From: Andreas Bießmann @ 2011-06-12 11:49 UTC (permalink / raw)
To: u-boot
This patch adds an copy of arm926ejs/at91/clock.c to arm920t/at91. The
arm926ejs specialities are removed from arm920t version and vice versa.
Signed-off-by: Andreas Bie?mann <andreas.devel@googlemail.com>
---
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
diff --git a/arch/arm/cpu/arm920t/at91/Makefile b/arch/arm/cpu/arm920t/at91/Makefile
index 5c71b77..8258ecd 100644
--- a/arch/arm/cpu/arm920t/at91/Makefile
+++ b/arch/arm/cpu/arm920t/at91/Makefile
@@ -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))
diff --git a/arch/arm/cpu/arm920t/at91/clock.c b/arch/arm/cpu/arm920t/at91/clock.c
new file mode 100644
index 0000000..02318b3
--- /dev/null
+++ b/arch/arm/cpu/arm920t/at91/clock.c
@@ -0,0 +1,160 @@
+/*
+ * [origin: Linux kernel linux/arch/arm/mach-at91/clock.c]
+ *
+ * Copyright (C) 2011 Andreas Bie?mann
+ * Copyright (C) 2005 David Brownell
+ * Copyright (C) 2005 Ivan Kokshaysky
+ * Copyright (C) 2009 Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
+ *
+ * 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
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ */
+#include <common.h>
+#include <asm/io.h>
+#include <asm/arch/hardware.h>
+#include <asm/arch/at91_pmc.h>
+#include <asm/arch/clk.h>
+
+#if !defined(CONFIG_AT91FAMILY)
+# error You need to define CONFIG_AT91FAMILY in your board config!
+#endif
+
+DECLARE_GLOBAL_DATA_PTR;
+
+static unsigned long at91_css_to_rate(unsigned long css)
+{
+ switch (css) {
+ case AT91_PMC_MCKR_CSS_SLOW:
+ return CONFIG_SYS_AT91_SLOW_CLOCK;
+ case AT91_PMC_MCKR_CSS_MAIN:
+ return gd->main_clk_rate_hz;
+ case AT91_PMC_MCKR_CSS_PLLA:
+ return gd->plla_rate_hz;
+ case AT91_PMC_MCKR_CSS_PLLB:
+ return gd->pllb_rate_hz;
+ }
+
+ return 0;
+}
+
+#ifdef CONFIG_USB_ATMEL
+static unsigned at91_pll_calc(unsigned main_freq, unsigned out_freq)
+{
+ unsigned i, div = 0, mul = 0, diff = 1 << 30;
+ unsigned ret = (out_freq > 155000000) ? 0xbe00 : 0x3e00;
+
+ /* PLL output max 240 MHz (or 180 MHz per errata) */
+ if (out_freq > 240000000)
+ goto fail;
+
+ for (i = 1; i < 256; i++) {
+ int diff1;
+ unsigned input, mul1;
+
+ /*
+ * PLL input between 1MHz and 32MHz per spec, but lower
+ * frequences seem necessary in some cases so allow 100K.
+ * Warning: some newer products need 2MHz min.
+ */
+ input = main_freq / i;
+ if (input < 100000)
+ continue;
+ if (input > 32000000)
+ continue;
+
+ mul1 = out_freq / input;
+ if (mul1 > 2048)
+ continue;
+ if (mul1 < 2)
+ goto fail;
+
+ diff1 = out_freq - input * mul1;
+ if (diff1 < 0)
+ diff1 = -diff1;
+ if (diff > diff1) {
+ diff = diff1;
+ div = i;
+ mul = mul1;
+ if (diff == 0)
+ break;
+ }
+ }
+ if (i == 256 && diff > (out_freq >> 5))
+ goto fail;
+ return ret | ((mul - 1) << 16) | div;
+fail:
+ return 0;
+}
+#endif
+
+static u32 at91_pll_rate(u32 freq, u32 reg)
+{
+ unsigned mul, div;
+
+ div = reg & 0xff;
+ mul = (reg >> 16) & 0x7ff;
+ if (div && mul) {
+ freq /= div;
+ freq *= mul + 1;
+ } else
+ freq = 0;
+
+ return freq;
+}
+
+
+int at91_clock_init(unsigned long main_clock)
+{
+ unsigned freq, mckr;
+ at91_pmc_t *pmc = (at91_pmc_t *) ATMEL_BASE_PMC;
+#ifndef CONFIG_SYS_AT91_MAIN_CLOCK
+ unsigned tmp;
+ /*
+ * When the bootloader initialized the main oscillator correctly,
+ * there's no problem using the cycle counter. But if it didn't,
+ * or when using oscillator bypass mode, we must be told the speed
+ * of the main clock.
+ */
+ if (!main_clock) {
+ do {
+ tmp = readl(&pmc->mcfr);
+ } while (!(tmp & AT91_PMC_MCFR_MAINRDY));
+ tmp &= AT91_PMC_MCFR_MAINF_MASK;
+ main_clock = tmp * (CONFIG_SYS_AT91_SLOW_CLOCK / 16);
+ }
+#endif
+ gd->main_clk_rate_hz = main_clock;
+
+ /* report if PLLA is more than mildly overclocked */
+ gd->plla_rate_hz = at91_pll_rate(main_clock, readl(&pmc->pllar));
+
+#ifdef CONFIG_USB_ATMEL
+ /*
+ * USB clock init: choose 48 MHz PLLB value,
+ * disable 48MHz clock during usb peripheral suspend.
+ *
+ * REVISIT: assumes MCK doesn't derive from PLLB!
+ */
+ gd->at91_pllb_usb_init = at91_pll_calc(main_clock, 48000000 * 2) |
+ AT91_PMC_PLLBR_USBDIV_2;
+ gd->pllb_rate_hz = at91_pll_rate(main_clock, gd->at91_pllb_usb_init);
+#endif
+
+ /*
+ * MCK and CPU derive from one of those primary clocks.
+ * For now, assume this parentage won't change.
+ */
+ mckr = readl(&pmc->mckr);
+ gd->mck_rate_hz = at91_css_to_rate(mckr & AT91_PMC_MCKR_CSS_MASK);
+ freq = gd->mck_rate_hz;
+
+ freq /= (1 << ((mckr & AT91_PMC_MCKR_PRES_MASK) >> 2)); /* prescale */
+ /* mdiv */
+ gd->mck_rate_hz = freq / (1 + ((mckr & AT91_PMC_MCKR_MDIV_MASK) >> 8));
+ gd->cpu_clk_rate_hz = freq;
+
+ return 0;
+}
+
diff --git a/arch/arm/cpu/arm926ejs/at91/clock.c b/arch/arm/cpu/arm926ejs/at91/clock.c
index 608af2c..a7085de 100644
--- a/arch/arm/cpu/arm926ejs/at91/clock.c
+++ b/arch/arm/cpu/arm926ejs/at91/clock.c
@@ -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;
diff --git a/arch/arm/include/asm/arch-at91/clk.h b/arch/arm/include/asm/arch-at91/clk.h
index 457e6c9..f645327 100644
--- a/arch/arm/include/asm/arch-at91/clk.h
+++ b/arch/arm/include/asm/arch-at91/clk.h
@@ -26,13 +26,43 @@
#define __ASM_ARM_ARCH_CLK_H__
#include <asm/arch/hardware.h>
+#include <asm/global_data.h>
-unsigned long get_cpu_clk_rate(void);
-unsigned long get_main_clk_rate(void);
-unsigned long get_mck_clk_rate(void);
-unsigned long get_plla_clk_rate(void);
-unsigned long get_pllb_clk_rate(void);
-unsigned int get_pllb_init(void);
+static inline unsigned long get_cpu_clk_rate(void)
+{
+ DECLARE_GLOBAL_DATA_PTR;
+ return gd->cpu_clk_rate_hz;
+}
+
+static inline unsigned long get_main_clk_rate(void)
+{
+ DECLARE_GLOBAL_DATA_PTR;
+ return gd->main_clk_rate_hz;
+}
+
+static inline unsigned long get_mck_clk_rate(void)
+{
+ DECLARE_GLOBAL_DATA_PTR;
+ return gd->mck_rate_hz;
+}
+
+static inline unsigned long get_plla_clk_rate(void)
+{
+ DECLARE_GLOBAL_DATA_PTR;
+ return gd->plla_rate_hz;
+}
+
+static inline unsigned long get_pllb_clk_rate(void)
+{
+ DECLARE_GLOBAL_DATA_PTR;
+ return gd->pllb_rate_hz;
+}
+
+static inline u32 get_pllb_init(void)
+{
+ DECLARE_GLOBAL_DATA_PTR;
+ return gd->at91_pllb_usb_init;
+}
static inline unsigned long get_macb_pclk_rate(unsigned int dev_id)
{
--
1.7.5.4
^ permalink raw reply related [flat|nested] 10+ messages in thread* [U-Boot] [PATCH atmel/next 2/7] arm920t/at91: use new clock.c features
2011-06-12 11:49 [U-Boot] [PATCH atmel/next 0/7] replace at91rm9200_usart by atmel_usart Andreas Bießmann
2011-06-12 11:49 ` [U-Boot] [PATCH atmel/next 1/7] arm920t/at91: add clock.c Andreas Bießmann
@ 2011-06-12 11:49 ` Andreas Bießmann
2011-06-12 11:49 ` [U-Boot] [PATCH atmel/next 3/7] arm920t/at91: add at91rm9200_devices.c Andreas Bießmann
` (5 subsequent siblings)
7 siblings, 0 replies; 10+ messages in thread
From: Andreas Bießmann @ 2011-06-12 11:49 UTC (permalink / raw)
To: u-boot
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.
Signed-off-by: Andreas Bie?mann <andreas.devel@googlemail.com>
Cc: Jens Scharsig <js_at_ng@scharsoft.de>
Cc: Eric B?nard <eric@eukrea.com>
---
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
diff --git a/arch/arm/cpu/arm920t/at91/Makefile b/arch/arm/cpu/arm920t/at91/Makefile
index 8258ecd..4417dfe 100644
--- a/arch/arm/cpu/arm920t/at91/Makefile
+++ b/arch/arm/cpu/arm920t/at91/Makefile
@@ -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))
diff --git a/arch/arm/cpu/arm920t/at91/cpu.c b/arch/arm/cpu/arm920t/at91/cpu.c
new file mode 100644
index 0000000..74a1158
--- /dev/null
+++ b/arch/arm/cpu/arm920t/at91/cpu.c
@@ -0,0 +1,43 @@
+/*
+ * [origin: arch/arm/cpu/arm926ejs/at91/cpu.c]
+ *
+ * (C) Copyright 2011
+ * Andreas Bie?mann, andreas.devel at googlemail.com
+ * (C) Copyright 2010
+ * Reinhard Meyer, reinhard.meyer at emk-elektronik.de
+ * (C) Copyright 2009
+ * Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * 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 the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ */
+
+#include <common.h>
+#include <asm/io.h>
+#include <asm/arch/hardware.h>
+#include <asm/arch/clk.h>
+
+#ifndef CONFIG_SYS_AT91_MAIN_CLOCK
+#define CONFIG_SYS_AT91_MAIN_CLOCK 0
+#endif
+
+int arch_cpu_init(void)
+{
+ return at91_clock_init(CONFIG_SYS_AT91_MAIN_CLOCK);
+}
+
diff --git a/arch/arm/include/asm/arch-at91/at91rm9200.h b/arch/arm/include/asm/arch-at91/at91rm9200.h
index f1912e2..fd774b4 100644
--- a/arch/arm/include/asm/arch-at91/at91rm9200.h
+++ b/arch/arm/include/asm/arch-at91/at91rm9200.h
@@ -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 */
diff --git a/include/configs/at91rm9200ek.h b/include/configs/at91rm9200ek.h
index 16cd214..ee199ab 100644
--- a/include/configs/at91rm9200ek.h
+++ b/include/configs/at91rm9200ek.h
@@ -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
diff --git a/include/configs/cpuat91.h b/include/configs/cpuat91.h
index cfaef15..2bda72b 100644
--- a/include/configs/cpuat91.h
+++ b/include/configs/cpuat91.h
@@ -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
diff --git a/include/configs/eb_cpux9k2.h b/include/configs/eb_cpux9k2.h
index e12770a..25b28f5 100644
--- a/include/configs/eb_cpux9k2.h
+++ b/include/configs/eb_cpux9k2.h
@@ -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
--
1.7.5.4
^ permalink raw reply related [flat|nested] 10+ messages in thread* [U-Boot] [PATCH atmel/next 3/7] arm920t/at91: add at91rm9200_devices.c
2011-06-12 11:49 [U-Boot] [PATCH atmel/next 0/7] replace at91rm9200_usart by atmel_usart Andreas Bießmann
2011-06-12 11:49 ` [U-Boot] [PATCH atmel/next 1/7] arm920t/at91: add clock.c Andreas Bießmann
2011-06-12 11:49 ` [U-Boot] [PATCH atmel/next 2/7] arm920t/at91: use new clock.c features Andreas Bießmann
@ 2011-06-12 11:49 ` Andreas Bießmann
2011-06-12 11:49 ` [U-Boot] [PATCH atmel/next 4/7] at91rm9200ek: use atmel_usart Andreas Bießmann
` (4 subsequent siblings)
7 siblings, 0 replies; 10+ messages in thread
From: Andreas Bießmann @ 2011-06-12 11:49 UTC (permalink / raw)
To: u-boot
This is a copy of arm926ejs/at91 api for perpherial initialisation.
At the moment we just need the usart part of the api.
Signed-off-by: Andreas Bie?mann <andreas.devel@googlemail.com>
---
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
diff --git a/arch/arm/cpu/arm920t/at91/Makefile b/arch/arm/cpu/arm920t/at91/Makefile
index 4417dfe..309bcd6 100644
--- a/arch/arm/cpu/arm920t/at91/Makefile
+++ b/arch/arm/cpu/arm920t/at91/Makefile
@@ -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))
diff --git a/arch/arm/cpu/arm920t/at91/at91rm9200_devices.c b/arch/arm/cpu/arm920t/at91/at91rm9200_devices.c
new file mode 100644
index 0000000..f610a1e
--- /dev/null
+++ b/arch/arm/cpu/arm920t/at91/at91rm9200_devices.c
@@ -0,0 +1,85 @@
+/*
+ * [partely copied from arch/arm/cpu/arm926ejs/at91/arm9260_devices.c]
+ *
+ * (C) Copyright 2011
+ * Andreas Bie?mann <andreas.devel@googlemail.com>
+ *
+ * (C) Copyright 2007-2008
+ * Stelian Pop <stelian.pop@leadtechdesign.com>
+ * Lead Tech Design <www.leadtechdesign.com>
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * 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 the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ */
+
+#include <common.h>
+#include <asm/io.h>
+#include <asm/arch/at91_common.h>
+#include <asm/arch/at91_pmc.h>
+#include <asm/arch/gpio.h>
+
+/*
+ * if CONFIG_AT91_GPIO_PULLUP ist set, keep pullups on on all
+ * peripheral pins. Good to have if hardware is soldered optionally
+ * or in case of SPI no slave is selected. Avoid lines to float
+ * needlessly. Use a short local PUP define.
+ *
+ * Due to errata "TXD floats when CTS is inactive" pullups are always
+ * on for TXD pins.
+ */
+#ifdef CONFIG_AT91_GPIO_PULLUP
+# define PUP CONFIG_AT91_GPIO_PULLUP
+#else
+# define PUP 0
+#endif
+
+void at91_serial0_hw_init(void)
+{
+ at91_pmc_t *pmc = (at91_pmc_t *)ATMEL_BASE_PMC;
+
+ at91_set_a_periph(AT91_PIO_PORTA, 17, 1); /* TXD0 */
+ at91_set_a_periph(AT91_PIO_PORTA, 18, PUP); /* RXD0 */
+ writel(1 << ATMEL_ID_USART0, &pmc->pcer);
+}
+
+void at91_serial1_hw_init(void)
+{
+ at91_pmc_t *pmc = (at91_pmc_t *)ATMEL_BASE_PMC;
+
+ at91_set_a_periph(AT91_PIO_PORTB, 20, PUP); /* RXD1 */
+ at91_set_a_periph(AT91_PIO_PORTB, 21, 1); /* TXD1 */
+ writel(1 << ATMEL_ID_USART1, &pmc->pcer);
+}
+
+void at91_serial2_hw_init(void)
+{
+ at91_pmc_t *pmc = (at91_pmc_t *)ATMEL_BASE_PMC;
+
+ at91_set_a_periph(AT91_PIO_PORTA, 22, PUP); /* RXD2 */
+ at91_set_a_periph(AT91_PIO_PORTA, 23, 1); /* TXD2 */
+ writel(1 << ATMEL_ID_USART2, &pmc->pcer);
+}
+
+
+void at91_seriald_hw_init(void)
+{
+ at91_set_a_periph(AT91_PIO_PORTA, 30, PUP); /* DRXD */
+ at91_set_a_periph(AT91_PIO_PORTA, 31, 1); /* DTXD */
+ /* writing SYS to PCER has no effect on AT91RM9200 */
+}
+
diff --git a/arch/arm/include/asm/arch-at91/at91rm9200.h b/arch/arm/include/asm/arch-at91/at91rm9200.h
index fd774b4..42a32d3 100644
--- a/arch/arm/include/asm/arch-at91/at91rm9200.h
+++ b/arch/arm/include/asm/arch-at91/at91rm9200.h
@@ -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
--
1.7.5.4
^ permalink raw reply related [flat|nested] 10+ messages in thread* [U-Boot] [PATCH atmel/next 4/7] at91rm9200ek: use atmel_usart
2011-06-12 11:49 [U-Boot] [PATCH atmel/next 0/7] replace at91rm9200_usart by atmel_usart Andreas Bießmann
` (2 preceding siblings ...)
2011-06-12 11:49 ` [U-Boot] [PATCH atmel/next 3/7] arm920t/at91: add at91rm9200_devices.c Andreas Bießmann
@ 2011-06-12 11:49 ` Andreas Bießmann
2011-06-12 11:49 ` [U-Boot] [PATCH atmel/next 5/7] eb_cpux9k2: " Andreas Bießmann
` (3 subsequent siblings)
7 siblings, 0 replies; 10+ messages in thread
From: Andreas Bießmann @ 2011-06-12 11:49 UTC (permalink / raw)
To: u-boot
Signed-off-by: Andreas Bie?mann <andreas.devel@googlemail.com>
---
board/atmel/at91rm9200ek/at91rm9200ek.c | 7 +++++++
include/configs/at91rm9200ek.h | 7 +++++--
2 files changed, 12 insertions(+), 2 deletions(-)
diff --git a/board/atmel/at91rm9200ek/at91rm9200ek.c b/board/atmel/at91rm9200ek/at91rm9200ek.c
index 5ebc24d..ec0daba 100644
--- a/board/atmel/at91rm9200ek/at91rm9200ek.c
+++ b/board/atmel/at91rm9200ek/at91rm9200ek.c
@@ -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 */
diff --git a/include/configs/at91rm9200ek.h b/include/configs/at91rm9200ek.h
index ee199ab..b847798 100644
--- a/include/configs/at91rm9200ek.h
+++ b/include/configs/at91rm9200ek.h
@@ -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
--
1.7.5.4
^ permalink raw reply related [flat|nested] 10+ messages in thread* [U-Boot] [PATCH atmel/next 5/7] eb_cpux9k2: use atmel_usart
2011-06-12 11:49 [U-Boot] [PATCH atmel/next 0/7] replace at91rm9200_usart by atmel_usart Andreas Bießmann
` (3 preceding siblings ...)
2011-06-12 11:49 ` [U-Boot] [PATCH atmel/next 4/7] at91rm9200ek: use atmel_usart Andreas Bießmann
@ 2011-06-12 11:49 ` Andreas Bießmann
2011-06-26 18:10 ` Jens Scharsig
2011-06-12 11:49 ` [U-Boot] [PATCH atmel/next 6/7] cpuat91: " Andreas Bießmann
` (2 subsequent siblings)
7 siblings, 1 reply; 10+ messages in thread
From: Andreas Bießmann @ 2011-06-12 11:49 UTC (permalink / raw)
To: u-boot
Signed-off-by: Andreas Bie?mann <andreas.devel@googlemail.com>
CC: Jens Scharsig <js_at_ng@scharsoft.de>
---
board/BuS/eb_cpux9k2/cpux9k2.c | 7 +++++++
include/configs/eb_cpux9k2.h | 6 ++++--
2 files changed, 11 insertions(+), 2 deletions(-)
diff --git a/board/BuS/eb_cpux9k2/cpux9k2.c b/board/BuS/eb_cpux9k2/cpux9k2.c
index e9a1cb2..a918b04 100644
--- a/board/BuS/eb_cpux9k2/cpux9k2.c
+++ b/board/BuS/eb_cpux9k2/cpux9k2.c
@@ -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)
diff --git a/include/configs/eb_cpux9k2.h b/include/configs/eb_cpux9k2.h
index 25b28f5..c4b1e65 100644
--- a/include/configs/eb_cpux9k2.h
+++ b/include/configs/eb_cpux9k2.h
@@ -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
--
1.7.5.4
^ permalink raw reply related [flat|nested] 10+ messages in thread* [U-Boot] [PATCH atmel/next 5/7] eb_cpux9k2: use atmel_usart
2011-06-12 11:49 ` [U-Boot] [PATCH atmel/next 5/7] eb_cpux9k2: " Andreas Bießmann
@ 2011-06-26 18:10 ` Jens Scharsig
0 siblings, 0 replies; 10+ messages in thread
From: Jens Scharsig @ 2011-06-26 18:10 UTC (permalink / raw)
To: u-boot
Am 12.06.2011 13:49, schrieb Andreas Bie?mann:
> Signed-off-by: Andreas Bie?mann<andreas.devel@googlemail.com>
> CC: Jens Scharsig<js_at_ng@scharsoft.de>
> ---
> board/BuS/eb_cpux9k2/cpux9k2.c | 7 +++++++
> include/configs/eb_cpux9k2.h | 6 ++++--
> 2 files changed, 11 insertions(+), 2 deletions(-)
>
Acked-by: Jens Scharsig<js_at_ng@scharsoft.de>
Tested-by: Jens Scharsig<js_at_ng@scharsoft.de> (for eb_cpux9k2 board)
^ permalink raw reply [flat|nested] 10+ messages in thread
* [U-Boot] [PATCH atmel/next 6/7] cpuat91: use atmel_usart
2011-06-12 11:49 [U-Boot] [PATCH atmel/next 0/7] replace at91rm9200_usart by atmel_usart Andreas Bießmann
` (4 preceding siblings ...)
2011-06-12 11:49 ` [U-Boot] [PATCH atmel/next 5/7] eb_cpux9k2: " Andreas Bießmann
@ 2011-06-12 11:49 ` Andreas Bießmann
2011-06-12 11:49 ` [U-Boot] [PATCH atmel/next 7/7] driver/serial: delete at91rm9200_usart Andreas Bießmann
2011-06-30 8:42 ` [U-Boot] [PATCH atmel/next 0/7] replace at91rm9200_usart by atmel_usart Reinhard Meyer
7 siblings, 0 replies; 10+ messages in thread
From: Andreas Bießmann @ 2011-06-12 11:49 UTC (permalink / raw)
To: u-boot
Signed-off-by: Andreas Bie?mann <andreas.devel@googlemail.com>
Cc: Eric B?nard <eric@eukrea.com>
---
board/eukrea/cpuat91/cpuat91.c | 8 ++++++++
include/configs/cpuat91.h | 7 ++++---
2 files changed, 12 insertions(+), 3 deletions(-)
diff --git a/board/eukrea/cpuat91/cpuat91.c b/board/eukrea/cpuat91/cpuat91.c
index fa4b25b..5d05414 100644
--- a/board/eukrea/cpuat91/cpuat91.c
+++ b/board/eukrea/cpuat91/cpuat91.c
@@ -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 */
diff --git a/include/configs/cpuat91.h b/include/configs/cpuat91.h
index 2bda72b..75b881c 100644
--- a/include/configs/cpuat91.h
+++ b/include/configs/cpuat91.h
@@ -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
--
1.7.5.4
^ permalink raw reply related [flat|nested] 10+ messages in thread* [U-Boot] [PATCH atmel/next 7/7] driver/serial: delete at91rm9200_usart
2011-06-12 11:49 [U-Boot] [PATCH atmel/next 0/7] replace at91rm9200_usart by atmel_usart Andreas Bießmann
` (5 preceding siblings ...)
2011-06-12 11:49 ` [U-Boot] [PATCH atmel/next 6/7] cpuat91: " Andreas Bießmann
@ 2011-06-12 11:49 ` Andreas Bießmann
2011-06-30 8:42 ` [U-Boot] [PATCH atmel/next 0/7] replace at91rm9200_usart by atmel_usart Reinhard Meyer
7 siblings, 0 replies; 10+ messages in thread
From: Andreas Bießmann @ 2011-06-12 11:49 UTC (permalink / raw)
To: u-boot
The at91rm9200_usart driver could be fully replaced by atmel_usart driver.
Signed-off-by: Andreas Bie?mann <andreas.devel@googlemail.com>
---
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
diff --git a/drivers/serial/Makefile b/drivers/serial/Makefile
index 5a6011e..0e171b6 100644
--- a/drivers/serial/Makefile
+++ b/drivers/serial/Makefile
@@ -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
diff --git a/drivers/serial/at91rm9200_usart.c b/drivers/serial/at91rm9200_usart.c
deleted file mode 100644
index 05ebbc3..0000000
--- a/drivers/serial/at91rm9200_usart.c
+++ /dev/null
@@ -1,126 +0,0 @@
-/*
- * (C) Copyright 2002
- * Lineo, Inc <www.lineo.com>
- * Bernhard Kuhn <bkuhn@lineo.com>
- *
- * (C) Copyright 2002
- * Sysgo Real-Time Solutions, GmbH <www.elinos.com>
- * Marius Groeger <mgroeger@sysgo.de>
- *
- * (C) Copyright 2002
- * Sysgo Real-Time Solutions, GmbH <www.elinos.com>
- * Alex Zuepke <azu@sysgo.de>
- *
- * Copyright (C) 1999 2000 2001 Erik Mouw (J.A.K.Mouw at its.tudelft.nl)
- *
- * 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
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- *
- */
-
-#include <common.h>
-
-#ifndef CONFIG_AT91_LEGACY
-#include <asm/io.h>
-#include <asm/arch/hardware.h>
-#define CONFIG_AT91_LEGACY
-#include <asm/arch-at91rm9200/AT91RM9200.h>
-#warning Please update to use C structur SoC access !
-#else
-#include <asm/arch/AT91RM9200.h>
-#endif
-
-DECLARE_GLOBAL_DATA_PTR;
-
-#if !defined(CONFIG_DBGU) && !defined(CONFIG_USART0) && !defined(CONFIG_USART1)
-#error must define one of CONFIG_DBGU or CONFIG_USART0 or CONFIG_USART1
-#endif
-
-/* ggi thunder */
-#ifdef CONFIG_DBGU
-AT91PS_USART us = (AT91PS_USART) AT91C_BASE_DBGU;
-#endif
-#ifdef CONFIG_USART0
-AT91PS_USART us = (AT91PS_USART) AT91C_BASE_US0;
-#endif
-#ifdef CONFIG_USART1
-AT91PS_USART us = (AT91PS_USART) AT91C_BASE_US1;
-#endif
-
-void serial_setbrg (void)
-{
- int baudrate;
-
- if ((baudrate = gd->baudrate) <= 0)
- baudrate = CONFIG_BAUDRATE;
- /* MASTER_CLOCK/(16 * baudrate) */
- us->US_BRGR = (AT91C_MASTER_CLOCK >> 4) / (unsigned)baudrate;
-}
-
-int serial_init (void)
-{
- /* make any port initializations specific to this port */
-#ifdef CONFIG_DBGU
- *AT91C_PIOA_PDR = AT91C_PA31_DTXD | AT91C_PA30_DRXD; /* PA 31 & 30 */
- *AT91C_PMC_PCER = 1 << AT91C_ID_SYS; /* enable clock */
-#endif
-#ifdef CONFIG_USART0
- *AT91C_PIOA_PDR = AT91C_PA17_TXD0 | AT91C_PA18_RXD0;
- *AT91C_PMC_PCER |= 1 << AT91C_ID_USART0; /* enable clock */
-#endif
-#ifdef CONFIG_USART1
- *AT91C_PIOB_PDR = AT91C_PB21_TXD1 | AT91C_PB20_RXD1;
- *AT91C_PMC_PCER |= 1 << AT91C_ID_USART1; /* enable clock */
-#endif
- serial_setbrg ();
-
- us->US_CR = AT91C_US_RSTRX | AT91C_US_RSTTX;
- us->US_CR = AT91C_US_RXEN | AT91C_US_TXEN;
- us->US_MR =
- (AT91C_US_CLKS_CLOCK | AT91C_US_CHRL_8_BITS |
- AT91C_US_PAR_NONE | AT91C_US_NBSTOP_1_BIT);
- us->US_IMR = ~0ul;
- return (0);
-}
-
-void serial_exit (void)
-{
- us->US_CR = (AT91C_US_RSTRX | AT91C_US_RSTTX);
-}
-
-void serial_putc (const char c)
-{
- if (c == '\n')
- serial_putc ('\r');
- while ((us->US_CSR & AT91C_US_TXRDY) == 0);
- us->US_THR = c;
-}
-
-void serial_puts (const char *s)
-{
- while (*s) {
- serial_putc (*s++);
- }
-}
-
-int serial_getc (void)
-{
- while ((us->US_CSR & AT91C_US_RXRDY) == 0);
- return us->US_RHR;
-}
-
-int serial_tstc (void)
-{
- return ((us->US_CSR & AT91C_US_RXRDY) == AT91C_US_RXRDY);
-}
--
1.7.5.4
^ permalink raw reply related [flat|nested] 10+ messages in thread* [U-Boot] [PATCH atmel/next 0/7] replace at91rm9200_usart by atmel_usart
2011-06-12 11:49 [U-Boot] [PATCH atmel/next 0/7] replace at91rm9200_usart by atmel_usart Andreas Bießmann
` (6 preceding siblings ...)
2011-06-12 11:49 ` [U-Boot] [PATCH atmel/next 7/7] driver/serial: delete at91rm9200_usart Andreas Bießmann
@ 2011-06-30 8:42 ` Reinhard Meyer
7 siblings, 0 replies; 10+ messages in thread
From: Reinhard Meyer @ 2011-06-30 8:42 UTC (permalink / raw)
To: u-boot
Dear Andreas Bie?mann,
> 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
Applied to u-boot-atmel/master.
Thanks,
Reinhard
^ permalink raw reply [flat|nested] 10+ messages in thread