Skip to contentSkip to conversation

Blackfin BF5xx Maps: Handle the case where flash memory and ethernet mac/phy are mapped onto the same async bank

PATCH In review Bryan Wu 3 participants 3 messages Jan 30, 2008 Memory technology devices (MTD)

lore
Share & tools
lore

Bryan Wu

author
#0 lore raw

PATCH 1/1 Blackfin BF5xx Maps: Handle the case where flash memory and ethernet mac/phy are mapped onto the same async bank

The BF533-STAMP does this for example.
All board-specific configuration goes in your board resources file.

---
 drivers/mtd/maps/Kconfig       |   45 ++++++++
 drivers/mtd/maps/Makefile      |    1 +
 drivers/mtd/maps/bf5xx-flash.c |  227 ++++++++++++++++++++++++++++++++++++++++
 3 files changed, 273 insertions(+), 0 deletions(-)
 create mode 100644 drivers/mtd/maps/bf5xx-flash.c
drivers/mtd/maps/Kconfig +45 -0
index a592fc0..5357f04 100644
@@ -528,6 +528,51 @@ config MTD_PCMCIA_ANONYMOUS
 
 	  If unsure, say N.
 
+config MTD_BF5xx
+	tristate "Blackfin BF533-STAMP Flash Chip Support"
+	depends on BFIN533_STAMP && MTD_CFI
+	select MTD_PARTITIONS
+	help
+	  Map driver which allows for simultaneous utilization of
+	  ethernet and CFI parallel flash.
+
+config BFIN_FLASH_BANK_0
+	hex "EBIU_AMBCTL For Flash (Bank 0)"
+	depends on MTD_BF5xx
+	default 0x7BB0
+	help
+	  For boards that share the async memory bank with both Flash and
+	  the Ethernet, these settings allow you to have EBIU settings just
+	  when the Flash is active.  The other EBIU settings in the main
+	  Blackfin menu will be utilized when the Flash is not active.
+config BFIN_FLASH_BANK_1
+	hex "EBIU_AMBCTL For Flash (Bank 1)"
+	depends on MTD_BF5xx
+	default 0x7BB0
+	help
+	  For boards that share the async memory bank with both Flash and
+	  the Ethernet, these settings allow you to have EBIU settings just
+	  when the Flash is active.  The other EBIU settings in the main
+	  Blackfin menu will be utilized when the Flash is not active.
+config BFIN_FLASH_BANK_2
+	hex "EBIU_AMBCTL For Flash (Bank 2)"
+	depends on MTD_BF5xx
+	default 0x7BB0
+	help
+	  For boards that share the async memory bank with both Flash and
+	  the Ethernet, these settings allow you to have EBIU settings just
+	  when the Flash is active.  The other EBIU settings in the main
+	  Blackfin menu will be utilized when the Flash is not active.
+config BFIN_FLASH_BANK_3
+	hex "EBIU_AMBCTL For Flash (Bank 3)"
+	depends on MTD_BF5xx
+	default 0x7BB0
+	help
+	  For boards that share the async memory bank with both Flash and
+	  the Ethernet, these settings allow you to have EBIU settings just
+	  when the Flash is active.  The other EBIU settings in the main
+	  Blackfin menu will be utilized when the Flash is not active.
+
 config MTD_UCLINUX
 	tristate "Generic uClinux RAM/ROM filesystem support"
 	depends on MTD_PARTITIONS && !MMU
drivers/mtd/maps/Makefile +1 -0
index 316382a..62eea4f 100644
@@ -69,3 +69,4 @@ obj-$(CONFIG_MTD_PLATRAM)	+= plat-ram.o
 obj-$(CONFIG_MTD_OMAP_NOR)	+= omap_nor.o
 obj-$(CONFIG_MTD_MTX1)		+= mtx-1_flash.o
 obj-$(CONFIG_MTD_INTEL_VR_NOR)	+= intel_vr_nor.o
+obj-$(CONFIG_MTD_BF5xx)		+= bf5xx-flash.o
drivers/mtd/maps/bf5xx-flash.c new file +227 -0

227 lines not on this page · raw message

Signature · 1 line
1.5.3.4
#1 lore raw

On Jan 30, 2008 10:02 AM, Bryan Wu <[email protected]> wrote:

switch_to_flash is calling SSYNC():

Quoted 23 lines
drivers/mtd/maps/bf5xx-flash.c new file +23 -0
+static void switch_to_flash(struct flash_save *save)
+{
+       local_irq_save(save->flags);
+
+       gpio_set_value(enet_flash_pin, 0);
+       SSYNC();
+
+       save->ambctl0 = bfin_read_EBIU_AMBCTL0();
+       save->ambctl1 = bfin_read_EBIU_AMBCTL1();
+       bfin_write_EBIU_AMBCTL0(BFIN_FLASH_AMBCTL0VAL);
+       bfin_write_EBIU_AMBCTL1(BFIN_FLASH_AMBCTL1VAL);
+       SSYNC();
+}
+
+static void switch_back(struct flash_save *save)
+{
+       bfin_write_EBIU_AMBCTL0(save->ambctl0);
+       bfin_write_EBIU_AMBCTL1(save->ambctl1);
+       SSYNC();
+
+       gpio_set_value(enet_flash_pin, 1);
+
+       local_irq_restore(save->flags);

drivers/mtd/maps/bf5xx-flash.c line 81

Quoted 10 lines
drivers/mtd/maps/bf5xx-flash.c new file +10 -0
+}
+
+static map_word bf5xx_read(struct map_info *map, unsigned long ofs)
+{
+       int nValue = 0x0;
+       map_word test;
+       struct flash_save save;
+
+       switch_to_flash(&save);
+       SSYNC();

Is it necessary to SSYNC() here as well?

Quoted 31 lines
drivers/mtd/maps/bf5xx-flash.c new file +31 -0
+       nValue = readw(map->virt + ofs);
+       SSYNC();
+       switch_back(&save);
+
+       test.x[0] = (u16)nValue;
+       return test;
+}
+
+static void bf5xx_copy_from(struct map_info *map, void *to, unsigned long from, ssize_t len)
+{
+       unsigned long i;
+       map_word test;
+
+       if ((unsigned long)to & 0x1) {
+               for (i = 0; i < len / 2 * 2; i += 2) {
+                       test = bf5xx_read(map, from + i);
+                       put_unaligned(test.x[0], (__le16 *)(to + i));
+               }
+       } else {
+               for (i = 0; i < len / 2 * 2; i += 2) {
+                       test = bf5xx_read(map, from + i);
+                       *((u16*)(to + i)) = test.x[0];
+               }
+       }
+
+       if (len & 0x1) {
+               test = bf5xx_read(map, from + i);
+               *((u8*)(to + i)) = (u8)test.x[0];
+       }
+}
+

drivers/mtd/maps/bf5xx-flash.c line 122

Quoted 10 lines
drivers/mtd/maps/bf5xx-flash.c new file +10 -0
+static void bf5xx_write(struct map_info *map, map_word d1, unsigned long ofs)
+{
+       u16 d;
+       struct flash_save save;
+
+       d = (u16)d1.x[0];
+
+       switch_to_flash(&save);
+
+       SSYNC();

Also here?

Quoted 5 lines
drivers/mtd/maps/bf5xx-flash.c new file +5 -0
+       writew(d, map->virt + ofs);
+       SSYNC();
+
+       switch_back(&save);
+}
#2 lore raw
Quoted 84 lines · Will Newton

On Jan 30, 2008 10:02 AM, Bryan Wu <[email protected]> wrote:

switch_to_flash is calling SSYNC():

Quoted 23 lines
drivers/mtd/maps/bf5xx-flash.c new file +23 -0
+static void switch_to_flash(struct flash_save *save)
+{
+       local_irq_save(save->flags);
+
+       gpio_set_value(enet_flash_pin, 0);
+       SSYNC();
+
+       save->ambctl0 = bfin_read_EBIU_AMBCTL0();
+       save->ambctl1 = bfin_read_EBIU_AMBCTL1();
+       bfin_write_EBIU_AMBCTL0(BFIN_FLASH_AMBCTL0VAL);
+       bfin_write_EBIU_AMBCTL1(BFIN_FLASH_AMBCTL1VAL);
+       SSYNC();
+}
+
+static void switch_back(struct flash_save *save)
+{
+       bfin_write_EBIU_AMBCTL0(save->ambctl0);
+       bfin_write_EBIU_AMBCTL1(save->ambctl1);
+       SSYNC();
+
+       gpio_set_value(enet_flash_pin, 1);
+
+       local_irq_restore(save->flags);

drivers/mtd/maps/bf5xx-flash.c line 81

Quoted 10 lines
drivers/mtd/maps/bf5xx-flash.c new file +10 -0
+}
+
+static map_word bf5xx_read(struct map_info *map, unsigned long ofs)
+{
+       int nValue = 0x0;
+       map_word test;
+       struct flash_save save;
+
+       switch_to_flash(&save);
+       SSYNC();

Is it necessary to SSYNC() here as well?

Quoted 31 lines
drivers/mtd/maps/bf5xx-flash.c new file +31 -0
+       nValue = readw(map->virt + ofs);
+       SSYNC();
+       switch_back(&save);
+
+       test.x[0] = (u16)nValue;
+       return test;
+}
+
+static void bf5xx_copy_from(struct map_info *map, void *to, unsigned long from, ssize_t len)
+{
+       unsigned long i;
+       map_word test;
+
+       if ((unsigned long)to & 0x1) {
+               for (i = 0; i < len / 2 * 2; i += 2) {
+                       test = bf5xx_read(map, from + i);
+                       put_unaligned(test.x[0], (__le16 *)(to + i));
+               }
+       } else {
+               for (i = 0; i < len / 2 * 2; i += 2) {
+                       test = bf5xx_read(map, from + i);
+                       *((u16*)(to + i)) = test.x[0];
+               }
+       }
+
+       if (len & 0x1) {
+               test = bf5xx_read(map, from + i);
+               *((u8*)(to + i)) = (u8)test.x[0];
+       }
+}
+

drivers/mtd/maps/bf5xx-flash.c line 122

Quoted 10 lines
drivers/mtd/maps/bf5xx-flash.c new file +10 -0
+static void bf5xx_write(struct map_info *map, map_word d1, unsigned long ofs)
+{
+       u16 d;
+       struct flash_save save;
+
+       d = (u16)d1.x[0];
+
+       switch_to_flash(&save);
+
+       SSYNC();

Also here?

Quoted 5 lines

drivers/mtd/maps/bf5xx-flash.c line 127

Quoted 5 lines
drivers/mtd/maps/bf5xx-flash.c new file +5 -0
+       writew(d, map->virt + ofs);
+       SSYNC();
+
+       switch_back(&save);
+}

thanks ... it should be fixed now
http://blackfin.uclinux.org/gf/project/linux-kernel/scmsvn/?action=browse&path=/&view=rev&root=linux-kernel&revision=4173
-mike