Skip to contentSkip to conversation

RM9200 EBI write/read interface

PATCH New Joachim Eastwood 2 participants 5 messages Feb 9, 2013 – Feb 11, 2013

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

cover RM9200 EBI write/read interface

Hi,

This patch introduces a EBI (External Bus Interface) read/write interface for RM9200. This allow to use the real base address for the SDRAMC on RM9200 and share SDRAMC headers for RM9200 and SAM9.

In the process at91_ramc can now be made private to mach-at91 since the at91_cf driver will use at91_ebi instead.

The ultimate goal is to create a EBI driver for RM9200. This will make it possible to setup EBI and SMC for external chips.

My board has octal USART which needs SMC to be setup correctly and this is not currently possible when using DT. Boards with NOR and NAND flash where SMC is not setup by bootloader will also benefit from such a driver.

I'm working this EBI driver and its DT bindings right now but would like some comments on this before I proceed.

Joachim Eastwood (2):
ARM: at91: create ebi read/write interface for RM9200
ARM: at91: move at91_ramc.h and clean up includes

 arch/arm/boot/dts/at91rm9200.dtsi                  |  4 +-
 arch/arm/mach-at91/at91_ramc.h                     | 31 +++++++++++
 arch/arm/mach-at91/at91rm9200.c                    |  3 +-
 arch/arm/mach-at91/at91rm9200_devices.c            | 14 ++---
 arch/arm/mach-at91/at91sam9_alt_reset.S            |  2 +-
 arch/arm/mach-at91/at91sam9g45_reset.S             |  2 +-
 arch/arm/mach-at91/board-cpuat91.c                 |  2 -
 arch/arm/mach-at91/board-eco920.c                  |  6 +--
 arch/arm/mach-at91/board-kb9202.c                  |  2 -
 arch/arm/mach-at91/board-picotux200.c              |  3 --
 arch/arm/mach-at91/board-rm9200dk.c                |  2 -
 arch/arm/mach-at91/board-rm9200ek.c                |  2 -
 arch/arm/mach-at91/board-yl-9200.c                 |  4 +-
 arch/arm/mach-at91/generic.h                       |  3 ++
 arch/arm/mach-at91/include/mach/at91_ebi.h         | 20 +++++++
 arch/arm/mach-at91/include/mach/at91_ramc.h        | 32 -----------
 arch/arm/mach-at91/include/mach/at91rm9200.h       |  1 +
 .../arm/mach-at91/include/mach/at91rm9200_sdramc.h | 63 ----------------------
 arch/arm/mach-at91/include/mach/at91sam9_sdramc.h  |  2 +
 arch/arm/mach-at91/pm.c                            |  2 +-
 arch/arm/mach-at91/pm.h                            |  9 ++--
 arch/arm/mach-at91/pm_slowclock.S                  |  2 +-
 arch/arm/mach-at91/setup.c                         | 10 ++++
 drivers/pcmcia/at91_cf.c                           |  6 +--
 24 files changed, 94 insertions(+), 133 deletions(-)
 create mode 100644 arch/arm/mach-at91/at91_ramc.h
 create mode 100644 arch/arm/mach-at91/include/mach/at91_ebi.h
 delete mode 100644 arch/arm/mach-at91/include/mach/at91_ramc.h
 delete mode 100644 arch/arm/mach-at91/include/mach/at91rm9200_sdramc.h
Signature · 1 line
1.8.0
#1 lore raw

PATCH 1/2 ARM: at91: create ebi read/write interface for RM9200

Introduce ebi read/write functions on AT91RM9200 to make it possible to have a common SDRAMC header and driver.

SDRAMC register layout is more or less the same on RM9200 and SAM926x. The only difference is the header file for RM9200 uses a different offset on SDRAMC registers. The offset used is actually for RM9200 MC.

By using the real base for SDRAMC on RM9200 header files can be shared. With this change there are also no users of ramc outside mach-at91.

---
 arch/arm/boot/dts/at91rm9200.dtsi                  |  4 +-
 arch/arm/mach-at91/at91rm9200.c                    |  3 +-
 arch/arm/mach-at91/at91rm9200_devices.c            | 14 ++---
 arch/arm/mach-at91/board-eco920.c                  |  6 +--
 arch/arm/mach-at91/board-yl-9200.c                 |  4 +-
 arch/arm/mach-at91/generic.h                       |  3 ++
 arch/arm/mach-at91/include/mach/at91_ebi.h         | 20 +++++++
 arch/arm/mach-at91/include/mach/at91_ramc.h        |  1 -
 arch/arm/mach-at91/include/mach/at91rm9200.h       |  1 +
 .../arm/mach-at91/include/mach/at91rm9200_sdramc.h | 63 ----------------------
 arch/arm/mach-at91/include/mach/at91sam9_sdramc.h  |  2 +
 arch/arm/mach-at91/pm.c                            |  2 +-
 arch/arm/mach-at91/pm.h                            |  7 ++-
 arch/arm/mach-at91/setup.c                         | 10 ++++
 drivers/pcmcia/at91_cf.c                           |  6 +--
 15 files changed, 59 insertions(+), 87 deletions(-)
 create mode 100644 arch/arm/mach-at91/include/mach/at91_ebi.h
 delete mode 100644 arch/arm/mach-at91/include/mach/at91rm9200_sdramc.h
arch/arm/boot/dts/at91rm9200.dtsi +2 -2
index 5d3ed5a..48dd97f 100644
@@ -64,9 +64,9 @@
 				atmel,external-irqs = <25 26 27 28 29 30 31>;
 			};
 
-			ramc0: ramc at ffffff00 {
+			ramc0: ramc at ffffff90 {
 				compatible = "atmel,at91rm9200-sdramc";
-				reg = <0xffffff00 0x100>;
+				reg = <0xffffff90 0x30>;
 			};
 
 			pmc: pmc at fffffc00 {
arch/arm/mach-at91/at91rm9200.c +2 -1
index 36b05fc..c4c22d1 100644
@@ -325,7 +325,8 @@ static void __init at91rm9200_map_io(void)
 static void __init at91rm9200_ioremap_registers(void)
 {
 	at91rm9200_ioremap_st(AT91RM9200_BASE_ST);
-	at91_ioremap_ramc(0, AT91RM9200_BASE_MC, 256);
+	at91_ioremap_ebi(AT91RM9200_BASE_MC, 144);
+	at91_ioremap_ramc(0, AT91RM9200_BASE_SDRAMC, 48);
 }
 
 static void __init at91rm9200_initialize(void)
arch/arm/mach-at91/at91rm9200_devices.c +7 -7
index 3ebc979..a298707 100644
@@ -20,7 +20,7 @@
 
 #include <mach/at91rm9200.h>
 #include <mach/at91rm9200_mc.h>
-#include <mach/at91_ramc.h>
+#include <mach/at91_ebi.h>
 
 #include "board.h"
 #include "generic.h"
@@ -242,15 +242,15 @@ void __init at91_add_device_cf(struct at91_cf_data *data)
 	data->chipselect = 4;		/* can only use EBI ChipSelect 4 */
 
 	/* CF takes over CS4, CS5, CS6 */
-	csa = at91_ramc_read(0, AT91_EBI_CSA);
-	at91_ramc_write(0, AT91_EBI_CSA, csa | AT91_EBI_CS4A_SMC_COMPACTFLASH);
+	csa = at91_ebi_read(AT91_EBI_CSA);
+	at91_ebi_write(AT91_EBI_CSA, csa | AT91_EBI_CS4A_SMC_COMPACTFLASH);
 
 	/*
 	 * Static memory controller timing adjustments.
 	 * REVISIT:  these timings are in terms of MCK cycles, so
 	 * when MCK changes (cpufreq etc) so must these values...
 	 */
-	at91_ramc_write(0, AT91_SMC_CSR(4),
+	at91_ebi_write(AT91_SMC_CSR(4),
 				  AT91_SMC_ACSS_STD
 				| AT91_SMC_DBW_16
 				| AT91_SMC_BAT
@@ -424,11 +424,11 @@ void __init at91_add_device_nand(struct atmel_nand_data *data)
 		return;
 
 	/* enable the address range of CS3 */
-	csa = at91_ramc_read(0, AT91_EBI_CSA);
-	at91_ramc_write(0, AT91_EBI_CSA, csa | AT91_EBI_CS3A_SMC_SMARTMEDIA);
+	csa = at91_ebi_read(AT91_EBI_CSA);
+	at91_ebi_write(AT91_EBI_CSA, csa | AT91_EBI_CS3A_SMC_SMARTMEDIA);
 
 	/* set the bus interface characteristics */
-	at91_ramc_write(0, AT91_SMC_CSR(3), AT91_SMC_ACSS_STD | AT91_SMC_DBW_8 | AT91_SMC_WSEN
+	at91_ebi_write(AT91_SMC_CSR(3), AT91_SMC_ACSS_STD | AT91_SMC_DBW_8 | AT91_SMC_WSEN
 		| AT91_SMC_NWS_(5)
 		| AT91_SMC_TDF_(1)
 		| AT91_SMC_RWSETUP_(0)	/* tDS Data Set up Time 30 - ns */
arch/arm/mach-at91/board-eco920.c +3 -3
index 77de410..fbe9f7b 100644
@@ -25,7 +25,7 @@
 #include <asm/mach/map.h>
 
 #include <mach/at91rm9200_mc.h>
-#include <mach/at91_ramc.h>
+#include <mach/at91_ebi.h>
 #include <mach/cpu.h>
 
 #include "at91_aic.h"
@@ -123,7 +123,7 @@ static void __init eco920_board_init(void)
 	at91_add_device_mci(0, &eco920_mci0_data);
 	platform_device_register(&eco920_flash);
 
-	at91_ramc_write(0, AT91_SMC_CSR(7),	AT91_SMC_RWHOLD_(1)
+	at91_ebi_write(AT91_SMC_CSR(7),	AT91_SMC_RWHOLD_(1)
 				| AT91_SMC_RWSETUP_(1)
 				| AT91_SMC_DBW_8
 				| AT91_SMC_WSEN
@@ -135,7 +135,7 @@ static void __init eco920_board_init(void)
 	at91_set_deglitch(AT91_PIN_PA23, 1);
 
 /* Initialization of the Static Memory Controller for Chip Select 3 */
-	at91_ramc_write(0, AT91_SMC_CSR(3),
+	at91_ebi_write(AT91_SMC_CSR(3),
 		AT91_SMC_DBW_16  |	/* 16 bit */
 		AT91_SMC_WSEN    |
 		AT91_SMC_NWS_(5) |	/* wait states */
arch/arm/mach-at91/board-yl-9200.c +2 -2
index be08377..541ce1d 100644
@@ -44,7 +44,7 @@
 
 #include <mach/hardware.h>
 #include <mach/at91rm9200_mc.h>
-#include <mach/at91_ramc.h>
+#include <mach/at91_ebi.h>
 #include <mach/cpu.h>
 
 #include "at91_aic.h"
@@ -377,7 +377,7 @@ static void yl9200_init_video(void)
 	at91_set_A_periph(AT91_PIN_PC6, 0);
 
 	/* Initialization of the Static Memory Controller for Chip Select 2 */
-	at91_ramc_write(0, AT91_SMC_CSR(2), AT91_SMC_DBW_16		/* 16 bit */
+	at91_ebi_write(AT91_SMC_CSR(2), AT91_SMC_DBW_16		/* 16 bit */
 			| AT91_SMC_WSEN | AT91_SMC_NWS_(0x4)	/* wait states */
 			| AT91_SMC_TDF_(0x100)			/* float time */
 	);
arch/arm/mach-at91/generic.h +3 -0
index 78ab065..3cced6b 100644
@@ -69,6 +69,9 @@ extern void at91_ioremap_shdwc(u32 base_addr);
 /* Matrix */
 extern void at91_ioremap_matrix(u32 base_addr);
 
+/* EBI */
+extern void at91_ioremap_ebi(u32 addr, u32 size);
+
 /* Ram Controler */
 extern void at91_ioremap_ramc(int id, u32 addr, u32 size);
 
arch/arm/mach-at91/include/mach/at91_ebi.h new file +20 -0
new file mode 100644
index 0000000..4d400c0
@@ -0,0 +1,20 @@
+/*
+ * Header file for the Atmel EBI Controller
+ *
+ * Copyright (C) 2012 Joachim Eastwood <[email protected]>
+ *
+ * Under GPLv2 only
+ */
+
+#ifndef __AT91_EBI_H__
+#define __AT91_EBI_H__
+
+extern void __iomem *at91_ebi_base;
+
+#define at91_ebi_read(field) \
+	__raw_readl(at91_ebi_base + field)
+
+#define at91_ebi_write(field, value) \
+	__raw_writel(value, at91_ebi_base + field)
+
+#endif /* __AT91_EBI_H__ */
arch/arm/mach-at91/include/mach/at91_ramc.h +0 -1
index d8aeb27..038041d 100644
@@ -25,7 +25,6 @@ extern void __iomem *at91_ramc_base[];
 #define AT91_MEMCTRL_SDRAMC	1
 #define AT91_MEMCTRL_DDRSDR	2
 
-#include <mach/at91rm9200_sdramc.h>
 #include <mach/at91sam9_ddrsdr.h>
 #include <mach/at91sam9_sdramc.h>
 
arch/arm/mach-at91/include/mach/at91rm9200.h +1 -0
index e67317c..cca1b96 100644
@@ -87,6 +87,7 @@
 #define AT91RM9200_BASE_ST	0xfffffd00	/* System Timer */
 #define AT91RM9200_BASE_RTC	0xfffffe00	/* Real-Time Clock */
 #define AT91RM9200_BASE_MC	0xffffff00	/* Memory Controllers */
+#define AT91RM9200_BASE_SDRAMC	0xffffff90	/* SDRAM Controller */
 
 /*
  * Internal Memory.
arch/arm/mach-at91/include/mach/at91rm9200_sdramc.h deleted +0 -63

63 lines not on this page · raw message

arch/arm/mach-at91/include/mach/at91sam9_sdramc.h +2 -0
index 3d085a9..e45aff7 100644
@@ -57,6 +57,8 @@
 #define		AT91_SDRAMC_TRAS	(0xf << 24)		/* Active to Precharge Delay */
 #define		AT91_SDRAMC_TXSR	(0xf << 28)		/* Exit Self Refresh to Active Delay */
 
+#define AT91_SDRAMC_SRR		0x0c	/* SDRAM Controller Self Refresh Register AT91RM9200 only */
+
 #define AT91_SDRAMC_LPR		0x10	/* SDRAM Controller Low Power Register */
 #define		AT91_SDRAMC_LPCB		(3 << 0)	/* Low-power Configurations */
 #define			AT91_SDRAMC_LPCB_DISABLE		0
arch/arm/mach-at91/pm.c +1 -1
index adb6db8..5ba38e5 100644
@@ -316,7 +316,7 @@ static int __init at91_pm_init(void)
 
 	/* AT91RM9200 SDRAM low-power mode cannot be used with self-refresh. */
 	if (cpu_is_at91rm9200())
-		at91_ramc_write(0, AT91RM9200_SDRAMC_LPR, 0);
+		at91_ramc_write(0, AT91_SDRAMC_LPR, 0);
 
 	suspend_set_ops(&at91_pm_ops);
 
arch/arm/mach-at91/pm.h +3 -4
index 38f467c..c5dd8dc 100644
@@ -12,7 +12,6 @@
 #define __ARCH_ARM_MACH_AT91_PM
 
 #include <mach/at91_ramc.h>
-#include <mach/at91rm9200_sdramc.h>
 
 /*
  * The AT91RM9200 goes into self-refresh mode with this command, and will
@@ -26,7 +25,7 @@
 
 static inline void at91rm9200_standby(void)
 {
-	u32 lpr = at91_ramc_read(0, AT91RM9200_SDRAMC_LPR);
+	u32 lpr = at91_ramc_read(0, AT91_SDRAMC_LPR);
 
 	asm volatile(
 		"b    1f\n\t"
@@ -37,8 +36,8 @@ static inline void at91rm9200_standby(void)
 		"    mcr    p15, 0, %0, c7, c0, 4\n\t"
 		"    str    %5, [%1, %2]"
 		:
-		: "r" (0), "r" (AT91_BASE_SYS), "r" (AT91RM9200_SDRAMC_LPR),
-		  "r" (1), "r" (AT91RM9200_SDRAMC_SRR),
+		: "r" (0), "r" (at91_ramc_base[0]), "r" (AT91_SDRAMC_LPR),
+		  "r" (1), "r" (AT91_SDRAMC_SRR),
 		  "r" (lpr));
 }
 
arch/arm/mach-at91/setup.c +10 -0
index 4b67847..10d5b2f 100644
@@ -54,6 +54,16 @@ void __init at91_init_interrupts(unsigned int *priority)
 	at91_gpio_irq_setup();
 }
 
+void __iomem *at91_ebi_base;
+EXPORT_SYMBOL_GPL(at91_ebi_base);
+
+void __init at91_ioremap_ebi(u32 addr, u32 size)
+{
+	at91_ebi_base = ioremap(addr, size);
+	if (!at91_ebi_base)
+		panic("Impossible to ioremap ebi. 0x%x\n", addr);
+}
+
 void __iomem *at91_ramc_base[2];
 EXPORT_SYMBOL_GPL(at91_ramc_base);
 
drivers/pcmcia/at91_cf.c +3 -3
index 01463c7..d9d696f 100644
@@ -26,7 +26,7 @@
 #include <asm/sizes.h>
 
 #include <mach/at91rm9200_mc.h>
-#include <mach/at91_ramc.h>
+#include <mach/at91_ebi.h>
 
 
 /*
@@ -157,7 +157,7 @@ static int at91_cf_set_io_map(struct pcmcia_socket *s, struct pccard_io_map *io)
 	/*
 	 * Use 16 bit accesses unless/until we need 8-bit i/o space.
 	 */
-	csr = at91_ramc_read(0, AT91_SMC_CSR(cf->board->chipselect)) & ~AT91_SMC_DBW;
+	csr = at91_ebi_read(AT91_SMC_CSR(cf->board->chipselect)) & ~AT91_SMC_DBW;
 
 	/*
 	 * NOTE: this CF controller ignores IOIS16, so we can't really do
@@ -176,7 +176,7 @@ static int at91_cf_set_io_map(struct pcmcia_socket *s, struct pccard_io_map *io)
 		csr |= AT91_SMC_DBW_16;
 		pr_debug("%s: 16bit i/o bus\n", driver_name);
 	}
-	at91_ramc_write(0, AT91_SMC_CSR(cf->board->chipselect), csr);
+	at91_ebi_write(AT91_SMC_CSR(cf->board->chipselect), csr);
 
 	io->start = cf->socket.io_offset;
 	io->stop = io->start + SZ_2K - 1;
Signature · 1 line
1.8.0
#2 lore raw

PATCH 1/2 ARM: at91: create ebi read/write interface for RM9200

Quoted 11 lines · Joachim Eastwood

Introduce ebi read/write functions on AT91RM9200 to make it possible to have a common SDRAMC header and driver.

SDRAMC register layout is more or less the same on RM9200 and SAM926x. The only difference is the header file for RM9200 uses a different offset on SDRAMC registers. The offset used is actually for RM9200 MC.

By using the real base for SDRAMC on RM9200 header files can be shared. With this change there are also no users of ramc outside mach-at91.

nack the idea is wrong on rm9200 we have sdramc that do ram controler + EBI

and the EBI is completly soc dependant

and you have 2 ebi on 9263 and 9g45 so the no

Best Regards,
J.

Quoted 398 lines
---
 arch/arm/boot/dts/at91rm9200.dtsi                  |  4 +-
 arch/arm/mach-at91/at91rm9200.c                    |  3 +-
 arch/arm/mach-at91/at91rm9200_devices.c            | 14 ++---
 arch/arm/mach-at91/board-eco920.c                  |  6 +--
 arch/arm/mach-at91/board-yl-9200.c                 |  4 +-
 arch/arm/mach-at91/generic.h                       |  3 ++
 arch/arm/mach-at91/include/mach/at91_ebi.h         | 20 +++++++
 arch/arm/mach-at91/include/mach/at91_ramc.h        |  1 -
 arch/arm/mach-at91/include/mach/at91rm9200.h       |  1 +
 .../arm/mach-at91/include/mach/at91rm9200_sdramc.h | 63 ----------------------
 arch/arm/mach-at91/include/mach/at91sam9_sdramc.h  |  2 +
 arch/arm/mach-at91/pm.c                            |  2 +-
 arch/arm/mach-at91/pm.h                            |  7 ++-
 arch/arm/mach-at91/setup.c                         | 10 ++++
 drivers/pcmcia/at91_cf.c                           |  6 +--
 15 files changed, 59 insertions(+), 87 deletions(-)
 create mode 100644 arch/arm/mach-at91/include/mach/at91_ebi.h
 delete mode 100644 arch/arm/mach-at91/include/mach/at91rm9200_sdramc.h
arch/arm/boot/dts/at91rm9200.dtsi +2 -2
index 5d3ed5a..48dd97f 100644
@@ -64,9 +64,9 @@
 				atmel,external-irqs = <25 26 27 28 29 30 31>;
 			};
 
-			ramc0: ramc at ffffff00 {
+			ramc0: ramc at ffffff90 {
 				compatible = "atmel,at91rm9200-sdramc";
-				reg = <0xffffff00 0x100>;
+				reg = <0xffffff90 0x30>;
 			};
 
 			pmc: pmc at fffffc00 {
arch/arm/mach-at91/at91rm9200.c +2 -1
index 36b05fc..c4c22d1 100644
@@ -325,7 +325,8 @@ static void __init at91rm9200_map_io(void)
 static void __init at91rm9200_ioremap_registers(void)
 {
 	at91rm9200_ioremap_st(AT91RM9200_BASE_ST);
-	at91_ioremap_ramc(0, AT91RM9200_BASE_MC, 256);
+	at91_ioremap_ebi(AT91RM9200_BASE_MC, 144);
+	at91_ioremap_ramc(0, AT91RM9200_BASE_SDRAMC, 48);
 }
 
 static void __init at91rm9200_initialize(void)
arch/arm/mach-at91/at91rm9200_devices.c +7 -7
index 3ebc979..a298707 100644
@@ -20,7 +20,7 @@
 
 #include <mach/at91rm9200.h>
 #include <mach/at91rm9200_mc.h>
-#include <mach/at91_ramc.h>
+#include <mach/at91_ebi.h>
 
 #include "board.h"
 #include "generic.h"
@@ -242,15 +242,15 @@ void __init at91_add_device_cf(struct at91_cf_data *data)
 	data->chipselect = 4;		/* can only use EBI ChipSelect 4 */
 
 	/* CF takes over CS4, CS5, CS6 */
-	csa = at91_ramc_read(0, AT91_EBI_CSA);
-	at91_ramc_write(0, AT91_EBI_CSA, csa | AT91_EBI_CS4A_SMC_COMPACTFLASH);
+	csa = at91_ebi_read(AT91_EBI_CSA);
+	at91_ebi_write(AT91_EBI_CSA, csa | AT91_EBI_CS4A_SMC_COMPACTFLASH);
 
 	/*
 	 * Static memory controller timing adjustments.
 	 * REVISIT:  these timings are in terms of MCK cycles, so
 	 * when MCK changes (cpufreq etc) so must these values...
 	 */
-	at91_ramc_write(0, AT91_SMC_CSR(4),
+	at91_ebi_write(AT91_SMC_CSR(4),
 				  AT91_SMC_ACSS_STD
 				| AT91_SMC_DBW_16
 				| AT91_SMC_BAT
@@ -424,11 +424,11 @@ void __init at91_add_device_nand(struct atmel_nand_data *data)
 		return;
 
 	/* enable the address range of CS3 */
-	csa = at91_ramc_read(0, AT91_EBI_CSA);
-	at91_ramc_write(0, AT91_EBI_CSA, csa | AT91_EBI_CS3A_SMC_SMARTMEDIA);
+	csa = at91_ebi_read(AT91_EBI_CSA);
+	at91_ebi_write(AT91_EBI_CSA, csa | AT91_EBI_CS3A_SMC_SMARTMEDIA);
 
 	/* set the bus interface characteristics */
-	at91_ramc_write(0, AT91_SMC_CSR(3), AT91_SMC_ACSS_STD | AT91_SMC_DBW_8 | AT91_SMC_WSEN
+	at91_ebi_write(AT91_SMC_CSR(3), AT91_SMC_ACSS_STD | AT91_SMC_DBW_8 | AT91_SMC_WSEN
 		| AT91_SMC_NWS_(5)
 		| AT91_SMC_TDF_(1)
 		| AT91_SMC_RWSETUP_(0)	/* tDS Data Set up Time 30 - ns */
arch/arm/mach-at91/board-eco920.c +3 -3
index 77de410..fbe9f7b 100644
@@ -25,7 +25,7 @@
 #include <asm/mach/map.h>
 
 #include <mach/at91rm9200_mc.h>
-#include <mach/at91_ramc.h>
+#include <mach/at91_ebi.h>
 #include <mach/cpu.h>
 
 #include "at91_aic.h"
@@ -123,7 +123,7 @@ static void __init eco920_board_init(void)
 	at91_add_device_mci(0, &eco920_mci0_data);
 	platform_device_register(&eco920_flash);
 
-	at91_ramc_write(0, AT91_SMC_CSR(7),	AT91_SMC_RWHOLD_(1)
+	at91_ebi_write(AT91_SMC_CSR(7),	AT91_SMC_RWHOLD_(1)
 				| AT91_SMC_RWSETUP_(1)
 				| AT91_SMC_DBW_8
 				| AT91_SMC_WSEN
@@ -135,7 +135,7 @@ static void __init eco920_board_init(void)
 	at91_set_deglitch(AT91_PIN_PA23, 1);
 
 /* Initialization of the Static Memory Controller for Chip Select 3 */
-	at91_ramc_write(0, AT91_SMC_CSR(3),
+	at91_ebi_write(AT91_SMC_CSR(3),
 		AT91_SMC_DBW_16  |	/* 16 bit */
 		AT91_SMC_WSEN    |
 		AT91_SMC_NWS_(5) |	/* wait states */
arch/arm/mach-at91/board-yl-9200.c +2 -2
index be08377..541ce1d 100644
@@ -44,7 +44,7 @@
 
 #include <mach/hardware.h>
 #include <mach/at91rm9200_mc.h>
-#include <mach/at91_ramc.h>
+#include <mach/at91_ebi.h>
 #include <mach/cpu.h>
 
 #include "at91_aic.h"
@@ -377,7 +377,7 @@ static void yl9200_init_video(void)
 	at91_set_A_periph(AT91_PIN_PC6, 0);
 
 	/* Initialization of the Static Memory Controller for Chip Select 2 */
-	at91_ramc_write(0, AT91_SMC_CSR(2), AT91_SMC_DBW_16		/* 16 bit */
+	at91_ebi_write(AT91_SMC_CSR(2), AT91_SMC_DBW_16		/* 16 bit */
 			| AT91_SMC_WSEN | AT91_SMC_NWS_(0x4)	/* wait states */
 			| AT91_SMC_TDF_(0x100)			/* float time */
 	);
arch/arm/mach-at91/generic.h +3 -0
index 78ab065..3cced6b 100644
@@ -69,6 +69,9 @@ extern void at91_ioremap_shdwc(u32 base_addr);
 /* Matrix */
 extern void at91_ioremap_matrix(u32 base_addr);
 
+/* EBI */
+extern void at91_ioremap_ebi(u32 addr, u32 size);
+
 /* Ram Controler */
 extern void at91_ioremap_ramc(int id, u32 addr, u32 size);
 
arch/arm/mach-at91/include/mach/at91_ebi.h new file +20 -0
new file mode 100644
index 0000000..4d400c0
@@ -0,0 +1,20 @@
+/*
+ * Header file for the Atmel EBI Controller
+ *
+ * Copyright (C) 2012 Joachim Eastwood <[email protected]>
+ *
+ * Under GPLv2 only
+ */
+
+#ifndef __AT91_EBI_H__
+#define __AT91_EBI_H__
+
+extern void __iomem *at91_ebi_base;
+
+#define at91_ebi_read(field) \
+	__raw_readl(at91_ebi_base + field)
+
+#define at91_ebi_write(field, value) \
+	__raw_writel(value, at91_ebi_base + field)
+
+#endif /* __AT91_EBI_H__ */
arch/arm/mach-at91/include/mach/at91_ramc.h +0 -1
index d8aeb27..038041d 100644
@@ -25,7 +25,6 @@ extern void __iomem *at91_ramc_base[];
 #define AT91_MEMCTRL_SDRAMC	1
 #define AT91_MEMCTRL_DDRSDR	2
 
-#include <mach/at91rm9200_sdramc.h>
 #include <mach/at91sam9_ddrsdr.h>
 #include <mach/at91sam9_sdramc.h>
 
arch/arm/mach-at91/include/mach/at91rm9200.h +1 -0
index e67317c..cca1b96 100644
@@ -87,6 +87,7 @@
 #define AT91RM9200_BASE_ST	0xfffffd00	/* System Timer */
 #define AT91RM9200_BASE_RTC	0xfffffe00	/* Real-Time Clock */
 #define AT91RM9200_BASE_MC	0xffffff00	/* Memory Controllers */
+#define AT91RM9200_BASE_SDRAMC	0xffffff90	/* SDRAM Controller */
 
 /*
  * Internal Memory.
arch/arm/mach-at91/include/mach/at91rm9200_sdramc.h deleted +0 -63
deleted file mode 100644
index aa047f45..0000000
@@ -1,63 +0,0 @@
-/*
- * arch/arm/mach-at91/include/mach/at91rm9200_sdramc.h
- *
- * Copyright (C) 2005 Ivan Kokshaysky
- * Copyright (C) SAN People
- *
- * Memory Controllers (SDRAMC only) - System peripherals registers.
- * Based on AT91RM9200 datasheet revision E.
- *
- * 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.
- */
-
-#ifndef AT91RM9200_SDRAMC_H
-#define AT91RM9200_SDRAMC_H
-
-/* SDRAM Controller registers */
-#define AT91RM9200_SDRAMC_MR		0x90			/* Mode Register */
-#define		AT91RM9200_SDRAMC_MODE	(0xf << 0)		/* Command Mode */
-#define			AT91RM9200_SDRAMC_MODE_NORMAL		(0 << 0)
-#define			AT91RM9200_SDRAMC_MODE_NOP		(1 << 0)
-#define			AT91RM9200_SDRAMC_MODE_PRECHARGE	(2 << 0)
-#define			AT91RM9200_SDRAMC_MODE_LMR		(3 << 0)
-#define			AT91RM9200_SDRAMC_MODE_REFRESH	(4 << 0)
-#define		AT91RM9200_SDRAMC_DBW		(1   << 4)		/* Data Bus Width */
-#define			AT91RM9200_SDRAMC_DBW_32	(0 << 4)
-#define			AT91RM9200_SDRAMC_DBW_16	(1 << 4)
-
-#define AT91RM9200_SDRAMC_TR		0x94			/* Refresh Timer Register */
-#define		AT91RM9200_SDRAMC_COUNT	(0xfff << 0)		/* Refresh Timer Count */
-
-#define AT91RM9200_SDRAMC_CR		0x98			/* Configuration Register */
-#define		AT91RM9200_SDRAMC_NC		(3   <<  0)		/* Number of Column Bits */
-#define			AT91RM9200_SDRAMC_NC_8	(0 << 0)
-#define			AT91RM9200_SDRAMC_NC_9	(1 << 0)
-#define			AT91RM9200_SDRAMC_NC_10	(2 << 0)
-#define			AT91RM9200_SDRAMC_NC_11	(3 << 0)
-#define		AT91RM9200_SDRAMC_NR		(3   <<  2)		/* Number of Row Bits */
-#define			AT91RM9200_SDRAMC_NR_11	(0 << 2)
-#define			AT91RM9200_SDRAMC_NR_12	(1 << 2)
-#define			AT91RM9200_SDRAMC_NR_13	(2 << 2)
-#define		AT91RM9200_SDRAMC_NB		(1   <<  4)		/* Number of Banks */
-#define			AT91RM9200_SDRAMC_NB_2	(0 << 4)
-#define			AT91RM9200_SDRAMC_NB_4	(1 << 4)
-#define		AT91RM9200_SDRAMC_CAS		(3   <<  5)		/* CAS Latency */
-#define			AT91RM9200_SDRAMC_CAS_2	(2 << 5)
-#define		AT91RM9200_SDRAMC_TWR		(0xf <<  7)		/* Write Recovery Delay */
-#define		AT91RM9200_SDRAMC_TRC		(0xf << 11)		/* Row Cycle Delay */
-#define		AT91RM9200_SDRAMC_TRP		(0xf << 15)		/* Row Precharge Delay */
-#define		AT91RM9200_SDRAMC_TRCD	(0xf << 19)		/* Row to Column Delay */
-#define		AT91RM9200_SDRAMC_TRAS	(0xf << 23)		/* Active to Precharge Delay */
-#define		AT91RM9200_SDRAMC_TXSR	(0xf << 27)		/* Exit Self Refresh to Active Delay */
-
-#define AT91RM9200_SDRAMC_SRR		0x9c			/* Self Refresh Register */
-#define AT91RM9200_SDRAMC_LPR		0xa0			/* Low Power Register */
-#define AT91RM9200_SDRAMC_IER		0xa4			/* Interrupt Enable Register */
-#define AT91RM9200_SDRAMC_IDR		0xa8			/* Interrupt Disable Register */
-#define AT91RM9200_SDRAMC_IMR		0xac			/* Interrupt Mask Register */
-#define AT91RM9200_SDRAMC_ISR		0xb0			/* Interrupt Status Register */
-
-#endif
arch/arm/mach-at91/include/mach/at91sam9_sdramc.h +2 -0
index 3d085a9..e45aff7 100644
@@ -57,6 +57,8 @@
 #define		AT91_SDRAMC_TRAS	(0xf << 24)		/* Active to Precharge Delay */
 #define		AT91_SDRAMC_TXSR	(0xf << 28)		/* Exit Self Refresh to Active Delay */
 
+#define AT91_SDRAMC_SRR		0x0c	/* SDRAM Controller Self Refresh Register AT91RM9200 only */
+
 #define AT91_SDRAMC_LPR		0x10	/* SDRAM Controller Low Power Register */
 #define		AT91_SDRAMC_LPCB		(3 << 0)	/* Low-power Configurations */
 #define			AT91_SDRAMC_LPCB_DISABLE		0
arch/arm/mach-at91/pm.c +1 -1
index adb6db8..5ba38e5 100644
@@ -316,7 +316,7 @@ static int __init at91_pm_init(void)
 
 	/* AT91RM9200 SDRAM low-power mode cannot be used with self-refresh. */
 	if (cpu_is_at91rm9200())
-		at91_ramc_write(0, AT91RM9200_SDRAMC_LPR, 0);
+		at91_ramc_write(0, AT91_SDRAMC_LPR, 0);
 
 	suspend_set_ops(&at91_pm_ops);
 
arch/arm/mach-at91/pm.h +3 -4
index 38f467c..c5dd8dc 100644
@@ -12,7 +12,6 @@
 #define __ARCH_ARM_MACH_AT91_PM
 
 #include <mach/at91_ramc.h>
-#include <mach/at91rm9200_sdramc.h>
 
 /*
  * The AT91RM9200 goes into self-refresh mode with this command, and will
@@ -26,7 +25,7 @@
 
 static inline void at91rm9200_standby(void)
 {
-	u32 lpr = at91_ramc_read(0, AT91RM9200_SDRAMC_LPR);
+	u32 lpr = at91_ramc_read(0, AT91_SDRAMC_LPR);
 
 	asm volatile(
 		"b    1f\n\t"
@@ -37,8 +36,8 @@ static inline void at91rm9200_standby(void)
 		"    mcr    p15, 0, %0, c7, c0, 4\n\t"
 		"    str    %5, [%1, %2]"
 		:
-		: "r" (0), "r" (AT91_BASE_SYS), "r" (AT91RM9200_SDRAMC_LPR),
-		  "r" (1), "r" (AT91RM9200_SDRAMC_SRR),
+		: "r" (0), "r" (at91_ramc_base[0]), "r" (AT91_SDRAMC_LPR),
+		  "r" (1), "r" (AT91_SDRAMC_SRR),
 		  "r" (lpr));
 }
 
arch/arm/mach-at91/setup.c +10 -0
index 4b67847..10d5b2f 100644
@@ -54,6 +54,16 @@ void __init at91_init_interrupts(unsigned int *priority)
 	at91_gpio_irq_setup();
 }
 
+void __iomem *at91_ebi_base;
+EXPORT_SYMBOL_GPL(at91_ebi_base);
+
+void __init at91_ioremap_ebi(u32 addr, u32 size)
+{
+	at91_ebi_base = ioremap(addr, size);
+	if (!at91_ebi_base)
+		panic("Impossible to ioremap ebi. 0x%x\n", addr);
+}
+
 void __iomem *at91_ramc_base[2];
 EXPORT_SYMBOL_GPL(at91_ramc_base);
 
drivers/pcmcia/at91_cf.c +3 -3
index 01463c7..d9d696f 100644
@@ -26,7 +26,7 @@
 #include <asm/sizes.h>
 
 #include <mach/at91rm9200_mc.h>
-#include <mach/at91_ramc.h>
+#include <mach/at91_ebi.h>
 
 
 /*
@@ -157,7 +157,7 @@ static int at91_cf_set_io_map(struct pcmcia_socket *s, struct pccard_io_map *io)
 	/*
 	 * Use 16 bit accesses unless/until we need 8-bit i/o space.
 	 */
-	csr = at91_ramc_read(0, AT91_SMC_CSR(cf->board->chipselect)) & ~AT91_SMC_DBW;
+	csr = at91_ebi_read(AT91_SMC_CSR(cf->board->chipselect)) & ~AT91_SMC_DBW;
 
 	/*
 	 * NOTE: this CF controller ignores IOIS16, so we can't really do
@@ -176,7 +176,7 @@ static int at91_cf_set_io_map(struct pcmcia_socket *s, struct pccard_io_map *io)
 		csr |= AT91_SMC_DBW_16;
 		pr_debug("%s: 16bit i/o bus\n", driver_name);
 	}
-	at91_ramc_write(0, AT91_SMC_CSR(cf->board->chipselect), csr);
+	at91_ebi_write(AT91_SMC_CSR(cf->board->chipselect), csr);
 
 	io->start = cf->socket.io_offset;
 	io->stop = io->start + SZ_2K - 1;
Signature · 1 line
1.8.0
#3 lore raw

PATCH 1/2 ARM: at91: create ebi read/write interface for RM9200

Quoted 13 lines · Jean-Christophe PLAGNIOL-VILLARD
Quoted 11 lines · Joachim Eastwood

Introduce ebi read/write functions on AT91RM9200 to make it possible to have a common SDRAMC header and driver.

SDRAMC register layout is more or less the same on RM9200 and SAM926x. The only difference is the header file for RM9200 uses a different offset on SDRAMC registers. The offset used is actually for RM9200 MC.

By using the real base for SDRAMC on RM9200 header files can be shared. With this change there are also no users of ramc outside mach-at91.

Quoted 5 lines

nack the idea is wrong on rm9200 we have sdramc that do ram controler + EBI

and the EBI is completly soc dependant

and you have 2 ebi on 9263 and 9g45 so the no

Well, the at91_ebi_read/write functions in this patch was only meant for RM9200. Guess I should have called it at91rm9200_ebi_read/write or something.

Anyway; my goal is to create an EBI driver for AT91RM9200 which will use DT to setup EBI/SMC for devices hooked up to EBI. This driver will live in drivers/bus. The sdramc "driver" can continue to live in mach-at91 but the handling of EBI and SMC will move into a proper driver.

Do you a better approach?

The two patches I posted was only a clean up to prepare for a proper driver living in drivers/bus. I'll try to finish up the rest of the series so you see the whole picture.

regards
Joachim Eastwood

#4 lore raw

PATCH 2/2 ARM: at91: move at91_ramc.h and clean up includes

In reply to Joachim Eastwood

Now that the ebi interface isn't handled by ramc, make ramc private to mach-at91.

And while at it clean up some unnecessary ramc includes in the RM9200 board files.

---
 arch/arm/mach-at91/at91_ramc.h              | 31 +++++++++++++++++++++++++++++
 arch/arm/mach-at91/at91sam9_alt_reset.S     |  2 +-
 arch/arm/mach-at91/at91sam9g45_reset.S      |  2 +-
 arch/arm/mach-at91/board-cpuat91.c          |  2 --
 arch/arm/mach-at91/board-kb9202.c           |  2 --
 arch/arm/mach-at91/board-picotux200.c       |  3 ---
 arch/arm/mach-at91/board-rm9200dk.c         |  2 --
 arch/arm/mach-at91/board-rm9200ek.c         |  2 --
 arch/arm/mach-at91/include/mach/at91_ramc.h | 31 -----------------------------
 arch/arm/mach-at91/pm.h                     |  2 +-
 arch/arm/mach-at91/pm_slowclock.S           |  2 +-
 11 files changed, 35 insertions(+), 46 deletions(-)
 create mode 100644 arch/arm/mach-at91/at91_ramc.h
 delete mode 100644 arch/arm/mach-at91/include/mach/at91_ramc.h
arch/arm/mach-at91/at91_ramc.h new file +31 -0
new file mode 100644
index 0000000..038041d
@@ -0,0 +1,31 @@
+/*
+ * Header file for the Atmel RAM Controller
+ *
+ * Copyright (C) 2011 Jean-Christophe PLAGNIOL-VILLARD <[email protected]>
+ *
+ * Under GPLv2 only
+ */
+
+#ifndef __AT91_RAMC_H__
+#define __AT91_RAMC_H__
+
+#ifndef __ASSEMBLY__
+extern void __iomem *at91_ramc_base[];
+
+#define at91_ramc_read(id, field) \
+	__raw_readl(at91_ramc_base[id] + field)
+
+#define at91_ramc_write(id, field, value) \
+	__raw_writel(value, at91_ramc_base[id] + field)
+#else
+.extern at91_ramc_base
+#endif
+
+#define AT91_MEMCTRL_MC		0
+#define AT91_MEMCTRL_SDRAMC	1
+#define AT91_MEMCTRL_DDRSDR	2
+
+#include <mach/at91sam9_ddrsdr.h>
+#include <mach/at91sam9_sdramc.h>
+
+#endif /* __AT91_RAMC_H__ */
arch/arm/mach-at91/at91sam9_alt_reset.S +1 -1
index f039538..7430f3c 100644
@@ -15,7 +15,7 @@
 
 #include <linux/linkage.h>
 #include <mach/hardware.h>
-#include <mach/at91_ramc.h>
+#include "at91_ramc.h"
 #include "at91_rstc.h"
 
 			.arm
arch/arm/mach-at91/at91sam9g45_reset.S +1 -1
index 721a1a3..d021154 100644
@@ -12,7 +12,7 @@
 
 #include <linux/linkage.h>
 #include <mach/hardware.h>
-#include <mach/at91_ramc.h>
+#include "at91_ramc.h"
 #include "at91_rstc.h"
 			.arm
 
arch/arm/mach-at91/board-cpuat91.c +0 -2
index 42f1353..89a9ea0 100644
@@ -36,8 +36,6 @@
 #include <asm/mach/map.h>
 #include <asm/mach/irq.h>
 
-#include <mach/at91rm9200_mc.h>
-#include <mach/at91_ramc.h>
 #include <mach/cpu.h>
 
 #include "at91_aic.h"
arch/arm/mach-at91/board-kb9202.c +0 -2
index 0c519d9..4d4ef55 100644
@@ -36,8 +36,6 @@
 #include <asm/mach/irq.h>
 
 #include <mach/cpu.h>
-#include <mach/at91rm9200_mc.h>
-#include <mach/at91_ramc.h>
 
 #include "at91_aic.h"
 #include "board.h"
arch/arm/mach-at91/board-picotux200.c +0 -3
index ab2b2ec..69a8bce 100644
@@ -37,9 +37,6 @@
 #include <asm/mach/map.h>
 #include <asm/mach/irq.h>
 
-#include <mach/at91rm9200_mc.h>
-#include <mach/at91_ramc.h>
-
 #include "at91_aic.h"
 #include "board.h"
 #include "generic.h"
arch/arm/mach-at91/board-rm9200dk.c +0 -2
index 690541b..dce4c77 100644
@@ -39,8 +39,6 @@
 #include <asm/mach/irq.h>
 
 #include <mach/hardware.h>
-#include <mach/at91rm9200_mc.h>
-#include <mach/at91_ramc.h>
 
 #include "at91_aic.h"
 #include "board.h"
arch/arm/mach-at91/board-rm9200ek.c +0 -2
index 8b17dad..1369bf6 100644
@@ -39,8 +39,6 @@
 #include <asm/mach/irq.h>
 
 #include <mach/hardware.h>
-#include <mach/at91rm9200_mc.h>
-#include <mach/at91_ramc.h>
 
 #include "at91_aic.h"
 #include "board.h"
arch/arm/mach-at91/include/mach/at91_ramc.h deleted +0 -31
deleted file mode 100644
index 038041d..0000000
@@ -1,31 +0,0 @@
-/*
- * Header file for the Atmel RAM Controller
- *
- * Copyright (C) 2011 Jean-Christophe PLAGNIOL-VILLARD <[email protected]>
- *
- * Under GPLv2 only
- */
-
-#ifndef __AT91_RAMC_H__
-#define __AT91_RAMC_H__
-
-#ifndef __ASSEMBLY__
-extern void __iomem *at91_ramc_base[];
-
-#define at91_ramc_read(id, field) \
-	__raw_readl(at91_ramc_base[id] + field)
-
-#define at91_ramc_write(id, field, value) \
-	__raw_writel(value, at91_ramc_base[id] + field)
-#else
-.extern at91_ramc_base
-#endif
-
-#define AT91_MEMCTRL_MC		0
-#define AT91_MEMCTRL_SDRAMC	1
-#define AT91_MEMCTRL_DDRSDR	2
-
-#include <mach/at91sam9_ddrsdr.h>
-#include <mach/at91sam9_sdramc.h>
-
-#endif /* __AT91_RAMC_H__ */
arch/arm/mach-at91/pm.h +1 -1
index c5dd8dc..8f3a4f7 100644
@@ -11,7 +11,7 @@
 #ifndef __ARCH_ARM_MACH_AT91_PM
 #define __ARCH_ARM_MACH_AT91_PM
 
-#include <mach/at91_ramc.h>
+#include "at91_ramc.h"
 
 /*
  * The AT91RM9200 goes into self-refresh mode with this command, and will
arch/arm/mach-at91/pm_slowclock.S +1 -1
index 098c28d..ac49fd4 100644
@@ -15,7 +15,7 @@
 #include <linux/linkage.h>
 #include <mach/hardware.h>
 #include <mach/at91_pmc.h>
-#include <mach/at91_ramc.h>
+#include "at91_ramc.h"
 
 
 #ifdef CONFIG_SOC_AT91SAM9263
Signature · 1 line
1.8.0