Skip to contentSkip to conversation

davinci: Platform support for OMAP-L137/AM17x NOR flash driver

PATCH Superseded Savinay Dharmappa 2 participants 3 messages Nov 12, 2010 – Nov 19, 2010

Subsystems (4)

v2 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 2/2 davinci: Platform support for OMAP-L137/AM17x NOR flash driver

From: Aleksey Makarov <[email protected]>

Adds platform support for OMAP-L137/AM17x NOR flash driver.

Also, configures chip select 3 to control NOR flash's upper address lines.

---
Since v1:
Addressed Sergei's comments at [1].

[1] http://linux.davincidsp.com/pipermail/davinci-linux-open-source/2010-November/020923.html

 arch/arm/mach-davinci/Kconfig           |    8 +
 arch/arm/mach-davinci/board-da830-evm.c |  219 +++++++++++++++++++++++++++++++
 2 files changed, 227 insertions(+), 0 deletions(-)
arch/arm/mach-davinci/Kconfig +8 -0
index 9aca60c..baa39ee 100644
@@ -142,6 +142,14 @@ config DA830_UI_NAND
 	help
 	  Say Y here to use the NAND flash. Do not forget to setup
 	  the switch correctly.
+
+config DA830_UI_NOR
+        bool "NOR flash"
+        help
+          Configure this option to specify the that AEMIF CE2/CE3 will be used to
+          communicate to the NOR flash. Do not forget to setup the switch SW1
+          on UI card correctly.
+
 endchoice
 
 config MACH_DAVINCI_DA850_EVM
arch/arm/mach-davinci/board-da830-evm.c +219 -0

237 lines not on this page · raw message

Signature · 1 line
1.5.6
#1 lore raw

Hello.

Quoted 6 lines · Savinay Dharmappa

From: Aleksey Makarov<[email protected]>

Adds platform support for OMAP-L137/AM17x NOR flash driver.

Also, configures chip select 3 to control NOR flash's upper address lines.

Please add back my signoff, omitted in this version. Some of the code,
including bug fixes, was authored by me.

Quoted 1 line
Quoted 6 lines
arch/arm/mach-davinci/board-da830-evm.c +0 -0
index 1bb89d3..cd35198 100644

[...]

arch/arm/mach-davinci/board-da830-evm.c static inline void da830_evm_init_nand(int mux_mode) · line 436

Quoted 7 lines
arch/arm/mach-davinci/board-da830-evm.c +3 -0
@@ -429,6 +431,221 @@ static inline void da830_evm_init_nand(int mux_mode)
  static inline void da830_evm_init_nand(int mux_mode) { }
  #endif
 
+#ifdef CONFIG_DA830_UI_NOR
+/*
+ * Number of Address line

Only "lines".

arch/arm/mach-davinci/board-da830-evm.c static inline void da830_evm_init_nand(int mux_mode) · line 445

Quoted 9 lines

going to the NOR flash that are latched using
+ * AEMIF address lines B_EMIF_BA0-B_EMIF_A12 on CS2.

arch/arm/mach-davinci/board-da830-evm.c +7 -0
+#define NOR_WINDOW_SIZE_LOG2     15
+#define NOR_WINDOW_SIZE         (1 << NOR_WINDOW_SIZE_LOG2)
+
+static struct {
+	struct clk *clk;
+	struct {
+		struct resource *res;

You're not using this field outside da830_evm_nor_init() now, so there's
not much point in keeping it...

arch/arm/mach-davinci/board-da830-evm.c static inline void da830_evm_init_nand(int mux_mode)

Quoted 10 lines
arch/arm/mach-davinci/board-da830-evm.c +9 -0
+		void __iomem *addr;
+	} latch, aemif;
+} da830_evm_nor;
 
+static void da830_evm_nor_set_window(unsigned long offset, void *data)
+{
+	/*
+	 * CS2 and CS3 address lines are used to address NOR flash. Address
+	 * line A0-A14 going to the NOR flash are latched using AEMIF address
+	 * lines B_EMIF_BA0-B_EMIF_A12 on CS2.

Are they really latched, and not just used live when the NOR chip is
accessed? What's the point of latching them?

arch/arm/mach-davinci/board-da830-evm.c static inline void da830_evm_init_nand(int mux_mode) · line 500

Quoted 13 lines
arch/arm/mach-davinci/board-da830-evm.c +13 -0
+static int da830_evm_nor_init(void *data, int cs)
+{
+	/* Turn on AEMIF clocks */
+	da830_evm_nor.clk = clk_get(NULL, "aemif");
+	if (IS_ERR(da830_evm_nor.clk)) {
+		pr_err("%s: could not get AEMIF clock\n", __func__);
+		da830_evm_nor.clk = NULL;
+		return -ENODEV;
+	}
+	clk_enable(da830_evm_nor.clk);
+
+	da830_evm_nor.aemif.res = request_mem_region(DA8XX_AEMIF_CTL_BASE,
+						     SZ_32K, "AEMIF control");

No need to store it -- you don't use it afterwards.

Quoted 5 lines
arch/arm/mach-davinci/board-da830-evm.c +5 -0
+	if (da830_evm_nor.aemif.res == NULL) {
+		pr_err("%s: could not request AEMIF control region\n",
+			__func__);
+		goto err_clk;
+	}

[...]

arch/arm/mach-davinci/board-da830-evm.c static inline void da830_evm_init_nand(int mux_mode) · line 526

Quoted 4 lines
arch/arm/mach-davinci/board-da830-evm.c +4 -0
+	/* Setup the window to access the latch */
+	da830_evm_nor.latch.res =
+		request_mem_region(DA8XX_AEMIF_CS3_BASE, PAGE_SIZE,
+				   "DA830 UI NOR address latch");

Same comment here...

Quoted 5 lines
arch/arm/mach-davinci/board-da830-evm.c +5 -0
+	if (da830_evm_nor.latch.res == NULL) {
+		pr_err("%s: could not request address latch region\n",
+			__func__);
+		goto err_aemif_ioremap;
+	}

[...]

arch/arm/mach-davinci/board-da830-evm.c static inline void da830_evm_init_nand(int mux_mode) · line 630

Quoted 8 lines
arch/arm/mach-davinci/board-da830-evm.c +8 -0
+static inline void da830_evm_init_nor(int mux_mode)
+{
+	int ret;
+
+	if (HAS_MMC) {
+		pr_warning("WARNING: both MMC/SD and NOR are "
+				"enabled, but they share AEMIF pins.\n"
+					"\tDisable MMC/SD for NOR support.\n");

This line is over-indented.

WBR, Sergei

#2 lore raw

Hi Sergei,

Quoted 6 lines · Sergei Shtylyov

Hello.

Quoted 1 line · Savinay Dharmappa

From: Aleksey Makarov<[email protected]>

Quoted 9 lines
Quoted 4 lines

Adds platform support for OMAP-L137/AM17x NOR flash driver.

Also, configures chip select 3 to control NOR flash's upper address lines.

Please add back my signoff, omitted in this version. Some of the code,

including bug fixes, was authored by me.

I'll add your sign-off.

Quoted 7 lines
Quoted 1 line

Review

Quoted 3 lines
(quoted diff) +0 -0

b/arch/arm/mach-davinci/board-da830-evm.c

Quoted 5 lines
Quoted 3 lines

index 1bb89d3..cd35198 100644

arch/arm/mach-davinci/board-da830-evm.c +0 -0

[...]

arch/arm/mach-davinci/board-da830-evm.c static inline void da830_evm_init_nand(int

Quoted 1 line
arch/arm/mach-davinci/board-da830-evm.c +0 -0
@@ -429,6 +431,221 @@ static inline void da830_evm_init_nand(int

mux_mode)

Quoted 9 lines

arch/arm/mach-davinci/board-da830-evm.c static inline void da830_evm_init_nand(int mux_mode)

Quoted 6 lines
arch/arm/mach-davinci/board-da830-evm.c +3 -0
  static inline void da830_evm_init_nand(int mux_mode) { }
  #endif
 
+#ifdef CONFIG_DA830_UI_NOR
+/*
+ * Number of Address line

Only "lines".

Ok.

Quoted 11 lines

arch/arm/mach-davinci/board-da830-evm.c static inline void da830_evm_init_nand(int mux_mode) · line 445

Quoted 9 lines

going to the NOR flash that are latched using
+ * AEMIF address lines B_EMIF_BA0-B_EMIF_A12 on CS2.

arch/arm/mach-davinci/board-da830-evm.c +7 -0
+#define NOR_WINDOW_SIZE_LOG2     15
+#define NOR_WINDOW_SIZE         (1 << NOR_WINDOW_SIZE_LOG2)
+
+static struct {
+	struct clk *clk;
+	struct {
+		struct resource *res;

You're not using this field outside da830_evm_nor_init() now, so

there's

Quoted 2 lines

not much point in keeping it...

Ok. I'll use it as a local variable in da830_evm_nor_init().

Quoted 9 lines

arch/arm/mach-davinci/board-da830-evm.c static inline void da830_evm_init_nand(int mux_mode)

Quoted 9 lines
arch/arm/mach-davinci/board-da830-evm.c +8 -0
+		void __iomem *addr;
+	} latch, aemif;
+} da830_evm_nor;
 
+static void da830_evm_nor_set_window(unsigned long offset, void *data)
+{
+	/*
+	 * CS2 and CS3 address lines are used to address NOR flash. Address
+	 * line A0-A14 going to the NOR flash are latched using AEMIF

address

Quoted 5 lines

arch/arm/mach-davinci/board-da830-evm.c

Quoted 1 line
arch/arm/mach-davinci/board-da830-evm.c +1 -0
+	 * lines B_EMIF_BA0-B_EMIF_A12 on CS2.

Are they really latched, and not just used live when the NOR chip is
accessed? What's the point of latching them?

You are right. I'll correct the comment.

Quoted 5 lines
Quoted 5 lines
arch/arm/mach-davinci/board-da830-evm.c +5 -0
+static int da830_evm_nor_init(void *data, int cs)
+{
+	/* Turn on AEMIF clocks */
+	da830_evm_nor.clk = clk_get(NULL, "aemif");
+	if (IS_ERR(da830_evm_nor.clk)) {
Quoted 8 lines

arch/arm/mach-davinci/board-da830-evm.c static inline void da830_evm_init_nand(int mux_mode)

Quoted 8 lines
arch/arm/mach-davinci/board-da830-evm.c +8 -0
+		pr_err("%s: could not get AEMIF clock\n", __func__);
+		da830_evm_nor.clk = NULL;
+		return -ENODEV;
+	}
+	clk_enable(da830_evm_nor.clk);
+
+	da830_evm_nor.aemif.res = request_mem_region(DA8XX_AEMIF_CTL_BASE,
+						     SZ_32K, "AEMIF

control");

Quoted 3 lines

No need to store it -- you don't use it afterwards.

Ok.

Quoted 23 lines
Quoted 5 lines
arch/arm/mach-davinci/board-da830-evm.c +5 -0
+	if (da830_evm_nor.aemif.res == NULL) {
+		pr_err("%s: could not request AEMIF control region\n",
+			__func__);
+		goto err_clk;
+	}

[...]

arch/arm/mach-davinci/board-da830-evm.c static inline void da830_evm_init_nand(int mux_mode) · line 526

Quoted 4 lines
arch/arm/mach-davinci/board-da830-evm.c +4 -0
+	/* Setup the window to access the latch */
+	da830_evm_nor.latch.res =
+		request_mem_region(DA8XX_AEMIF_CS3_BASE, PAGE_SIZE,
+				   "DA830 UI NOR address latch");

Same comment here...

Quoted 5 lines
arch/arm/mach-davinci/board-da830-evm.c +5 -0
+	if (da830_evm_nor.latch.res == NULL) {
+		pr_err("%s: could not request address latch region\n",
+			__func__);
+		goto err_aemif_ioremap;
+	}

[...]

Quoted 8 lines

arch/arm/mach-davinci/board-da830-evm.c static inline void da830_evm_init_nand(int mux_mode)

Quoted 8 lines
arch/arm/mach-davinci/board-da830-evm.c +8 -0
+static inline void da830_evm_init_nor(int mux_mode)
+{
+	int ret;
+
+	if (HAS_MMC) {
+		pr_warning("WARNING: both MMC/SD and NOR are "
+				"enabled, but they share AEMIF pins.\n"
+					"\tDisable MMC/SD for NOR

support.\n");

Quoted 2 lines

This line is over-indented.

Ok. Will address your comments and send an updated an version

Thanks,
Savinay