Skip to contentSkip to conversation

MIPS: lantiq: add NOR flash support

PATCH Superseded John Crispin 2 participants 5 messages Apr 5, 2011

Subsystems (2)

v7 of 9 Superseded Latest is v9 →

lore
Share & tools
lore
#0 lore raw

PATCH v7 1/1 MIPS: lantiq: add NOR flash support

This patch adds the driver/map for NOR devices attached to the SoC via the External Bus Unit (EBU).

---

Changes in V2
* handle the endianess bug inside the map code and not in the generic cfi code
* remove the addr swizzle patch

Changes in V3
* whitespace
* change __iomem void to void __iomem

Changes in V4
* fixes a checkpatch.pl bug, the second is a false positive
* whitespace cleanups
* remove unused typecasts
* cleanup ltq_copy_from and ltq_copy_to

Changes in V6
* cleanup/add comments
* fix line breaks
* properly handle return code of add_mtd_partitions()
* use pr_err instead of printk

Changes in V7
* remove bogus KERN_INFO from pr_err() call

This patch should be merged via the MIPS tree

 drivers/mtd/maps/Kconfig  |    9 ++
 drivers/mtd/maps/Makefile |    1 +
 drivers/mtd/maps/lantiq.c |  187 +++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 197 insertions(+), 0 deletions(-)
 create mode 100644 drivers/mtd/maps/lantiq.c
drivers/mtd/maps/Kconfig +9 -0
index 44b1f46..83376d3 100644
@@ -260,6 +260,15 @@ config MTD_BCM963XX
 	  Support for parsing CFE image tag and creating MTD partitions on
 	  Broadcom BCM63xx boards.
 
+config MTD_LANTIQ
+	bool "Lantiq SoC NOR support"
+	depends on LANTIQ
+	select MTD_PARTITIONS
+	help
+	  Lantiq SoCs have a EBU (External Bus Unit). This IP allows to attach
+	  a number of different peripherals to the SoC. This driver adds
+	  support for NOR chips to be added.
+
 config MTD_DILNETPC
 	tristate "CFI Flash device mapped on DIL/Net PC"
 	depends on X86 && MTD_PARTITIONS && MTD_CFI_INTELEXT && BROKEN
drivers/mtd/maps/Makefile +1 -0
index 08533bd..0db4ba3 100644
@@ -60,3 +60,4 @@ obj-$(CONFIG_MTD_VMU)		+= vmu-flash.o
 obj-$(CONFIG_MTD_GPIO_ADDR)	+= gpio-addr-flash.o
 obj-$(CONFIG_MTD_BCM963XX)	+= bcm963xx-flash.o
 obj-$(CONFIG_MTD_LATCH_ADDR)	+= latch-addr-flash.o
+obj-$(CONFIG_MTD_LANTIQ)	+= lantiq.o
drivers/mtd/maps/lantiq.c new file +187 -0

187 lines not on this page · raw message

Signature · 1 line
1.7.2.3
#1 lore raw
Quoted 4 lines · John Crispin
drivers/mtd/maps/lantiq.c new file +4 -0
+#include <lantiq_soc.h>
+#include <lantiq_platform.h>
+
+/* 

drivers/mtd/maps/lantiq.c line 35

Quoted 10 lines
drivers/mtd/maps/lantiq.c new file +10 -0
+ * The NOR flash is connected to the same external bus unit (EBU) as PCI.
+ * To make PCI work we need to enable the endianess swapping for the address
+ * written to the EBU. This endianess swapping works for PCI correctly but
+ * fails for attached NOR devices. To workaround this we need to use a complex
+ * map. The workaround involves swapping all addresses whilste probing the chip.
+ * Once probing is complete we stop swapping the addresses but swizzle the
+ * unlock addresses to ensure that access to the NOR device works correctly.
+ */
+
+static int ltq_mtd_probing;

Disclamer: I do not really understand the PCI/swapping issue, even though you wrote a comment about this, but still....

... I'm worried about this global variable. If you have multiple instances of such NOR flash, then you theoretically may have a situation when one of them is being probed, while another is being used for real. And this single global switch will break the one which is used for real.

IOW, the right solution would be to have per-chip flag, not a global flag.

Signature · 2 lines
Best Regards,
Artem Bityutskiy (Артём Битюцкий)
#2 lore raw
Quoted 9 lines

Review

Quoted 4 lines
(quoted diff) +2 -0
+
+static int ltq_mtd_probing;

... I'm worried about this global variable. If you have multiple instances of such NOR flash, then you theoretically may have a situation when one of them is being probed, while another is being used for real. And this single global switch will break the one which is used for real.

Quoted 4 lines

IOW, the right solution would be to have per-chip flag, not a global flag.

Hi,

we could dynamically allocate the instance of struct map_info and then use map_priv_1 to indicate whether the device is probing or not.

this would avoid using a global variable

John

#3 lore raw
Quoted 2 lines · John Crispin

we could dynamically allocate the instance of struct map_info and then use map_priv_1 to indicate whether the device is probing or not.

Yeah, may be you could indeed use map_priv_1 instead of the global variable already now?

Signature · 2 lines
Best Regards,
Artem Bityutskiy (Артём Битюцкий)
#4 lore raw
Quoted 9 lines · Artem Bityutskiy
Quoted 3 lines · John Crispin

we could dynamically allocate the instance of struct map_info and then use map_priv_1 to indicate whether the device is probing or not.

Yeah, may be you could indeed use map_priv_1 instead of the global variable already now?

Hi,

ok, let me add it to the patch ...

thanks, John