CC: brcm63xx: ensure dummy byte is set for mapped spi flash with fast read

Some CFEs seem to misconfigure the mapped memory flash access with
fast read but without a dummy byte, causing all accesses to be prefixed
with 0xff.
This of course breaks reading out the nvram, so do not just move back to
single i/o accessors, but also ensure that the dummy byte is correctly
set.

Backport of r46707.

Signed-off-by: Jonas Gorski <jogo@openwrt.org>

git-svn-id: svn://svn.openwrt.org/openwrt/branches/chaos_calmer@46709 3c298f89-4303-0410-b956-a3cf2f4a3e73
zsun
jogo 2015-08-23 09:41:07 +00:00
parent dba0d7da24
commit 8640810776
9 changed files with 60 additions and 39 deletions

View File

@ -9,12 +9,20 @@ reads.
Signed-off-by: Jonas Gorski <jogo@openwrt.org>
---
arch/mips/bcm63xx/dev-flash.c | 36 ++++++++++++++++++++++++++++++++++++
1 file changed, 36 insertions(+)
arch/mips/bcm63xx/dev-flash.c | 51 ++++++++++++++++++++++++++++++++++++
1 file changed, 51 insertions(+)
--- a/arch/mips/bcm63xx/dev-flash.c
+++ b/arch/mips/bcm63xx/dev-flash.c
@@ -110,9 +110,46 @@ static int __init bcm63xx_detect_flash_t
@@ -16,6 +16,7 @@
#include <linux/mtd/mtd.h>
#include <linux/mtd/partitions.h>
#include <linux/mtd/physmap.h>
+#include <linux/mtd/spi-nor.h>
#include <bcm63xx_cpu.h>
#include <bcm63xx_dev_flash.h>
@@ -110,9 +111,59 @@ static int __init bcm63xx_detect_flash_t
}
}
@ -24,36 +32,49 @@ Signed-off-by: Jonas Gorski <jogo@openwrt.org>
+#define FLASH_CTRL_ADDR_BYTES_2 (0 << 8)
+#define FLASH_CTRL_ADDR_BYTES_3 (1 << 8)
+#define FLASH_CTRL_ADDR_BYTES_4 (2 << 8)
+#define FLASH_CTRL_DUMMY_BYTES_SHIFT 10
+#define FLASH_CTRL_DUMMY_BYTES_MASK (0x3 << FLASH_CTRL_DUMMY_BYTES_SHIFT)
+#define FLASH_CTRL_MB_EN (1 << 23)
+
void __init bcm63xx_flash_detect(void)
{
flash_type = bcm63xx_detect_flash_type();
+
+ /* reduce flash mapping to single i/o reads for safety */
+ /* ensure flash mapping has sane values */
+ if (flash_type == BCM63XX_FLASH_TYPE_SERIAL &&
+ (BCMCPU_IS_6318() || BCMCPU_IS_6328() || BCMCPU_IS_6362() ||
+ BCMCPU_IS_63268())) {
+ u32 val = bcm_rset_readl(RSET_HSSPI, HSSPI_FLASH_CTRL_REG);
+
+ if (!(val & FLASH_CTRL_MB_EN))
+ return;
+ if (val & FLASH_CTRL_MB_EN) {
+ /* cfe might configure non working dual-io mode */
+ val &= ~FLASH_CTRL_MB_EN;
+ val &= ~FLASH_CTRL_READ_OPCODE_MASK;
+ val &= ~FLASH_CTRL_DUMMY_BYTES_MASK;
+ val |= 1 << FLASH_CTRL_DUMMY_BYTES_SHIFT;
+
+ val &= ~FLASH_CTRL_MB_EN;
+ val &= ~FLASH_CTRL_READ_OPCODE_MASK;
+ switch (val & FLASH_CTRL_ADDR_BYTES_MASK) {
+ case FLASH_CTRL_ADDR_BYTES_3:
+ val |= SPINOR_OP_READ_FAST;
+ break;
+ case FLASH_CTRL_ADDR_BYTES_4:
+ val |= SPINOR_OP_READ4_FAST;
+ break;
+ case FLASH_CTRL_ADDR_BYTES_2:
+ default:
+ pr_warn("unsupported address byte mode (%x), not fixing up\n",
+ val & FLASH_CTRL_ADDR_BYTES_MASK);
+ return;
+ }
+ } else {
+ /* ensure dummy bytes is set to 1 for _FAST reads */
+ u8 cmd = val & FLASH_CTRL_READ_OPCODE_MASK;
+
+ switch (val & FLASH_CTRL_ADDR_BYTES_MASK) {
+ case FLASH_CTRL_ADDR_BYTES_3:
+ val |= 0x0b; /* OPCODE_FAST_READ */
+ break;
+ case FLASH_CTRL_ADDR_BYTES_4:
+ val |= 0x0c; /* OPCODE_FAST_READ_4B */
+ break;
+ case FLASH_CTRL_ADDR_BYTES_2:
+ default:
+ pr_warn("unsupported address byte mode (%x), not fixing up\n",
+ val & FLASH_CTRL_ADDR_BYTES_MASK);
+ return;
+ if (cmd != SPINOR_OP_READ_FAST && cmd != SPINOR_OP_READ4_FAST)
+ return;
+
+ val &= ~FLASH_CTRL_DUMMY_BYTES_MASK;
+ val |= 1 << FLASH_CTRL_DUMMY_BYTES_SHIFT;
+ }
+
+ bcm_rset_writel(RSET_HSSPI, val, HSSPI_FLASH_CTRL_REG);

View File

@ -14,7 +14,7 @@ Signed-off-by: Jonas Gorski <jogo@openwrt.org>
--- a/arch/mips/bcm63xx/dev-flash.c
+++ b/arch/mips/bcm63xx/dev-flash.c
@@ -57,6 +57,12 @@ static struct platform_device mtd_dev =
@@ -58,6 +58,12 @@ static struct platform_device mtd_dev =
},
};
@ -27,7 +27,7 @@ Signed-off-by: Jonas Gorski <jogo@openwrt.org>
static int __init bcm63xx_detect_flash_type(void)
{
u32 val;
@@ -158,12 +164,15 @@ int __init bcm63xx_flash_register(void)
@@ -172,12 +178,15 @@ int __init bcm63xx_flash_register(void)
switch (flash_type) {
case BCM63XX_FLASH_TYPE_PARALLEL:

View File

@ -1,6 +1,6 @@
--- a/arch/mips/bcm63xx/dev-flash.c
+++ b/arch/mips/bcm63xx/dev-flash.c
@@ -22,6 +22,8 @@
@@ -23,6 +23,8 @@
#include <bcm63xx_regs.h>
#include <bcm63xx_io.h>
@ -9,7 +9,7 @@
static int flash_type;
static struct mtd_partition mtd_partitions[] = {
@@ -164,6 +166,9 @@ int __init bcm63xx_flash_register(void)
@@ -178,6 +180,9 @@ int __init bcm63xx_flash_register(void)
switch (flash_type) {
case BCM63XX_FLASH_TYPE_PARALLEL:

View File

@ -12,7 +12,7 @@ Signed-off-by: Axel Gembe <ago@bastart.eu.org>
--- a/arch/mips/bcm63xx/dev-flash.c
+++ b/arch/mips/bcm63xx/dev-flash.c
@@ -34,7 +34,7 @@ static struct mtd_partition mtd_partitio
@@ -35,7 +35,7 @@ static struct mtd_partition mtd_partitio
}
};

View File

@ -11,10 +11,10 @@ Signed-off-by: Jonas Gorski <jonas.gorski@gmail.com>
--- a/arch/mips/bcm63xx/dev-flash.c
+++ b/arch/mips/bcm63xx/dev-flash.c
@@ -16,9 +16,12 @@
#include <linux/mtd/mtd.h>
@@ -17,9 +17,12 @@
#include <linux/mtd/partitions.h>
#include <linux/mtd/physmap.h>
#include <linux/mtd/spi-nor.h>
+#include <linux/spi/spi.h>
+#include <linux/spi/flash.h>
@ -24,7 +24,7 @@ Signed-off-by: Jonas Gorski <jonas.gorski@gmail.com>
#include <bcm63xx_regs.h>
#include <bcm63xx_io.h>
@@ -65,6 +68,21 @@ void __init bcm63xx_flash_force_phys_bas
@@ -66,6 +69,21 @@ void __init bcm63xx_flash_force_phys_bas
mtd_resources[0].end = end;
}
@ -46,7 +46,7 @@ Signed-off-by: Jonas Gorski <jonas.gorski@gmail.com>
static int __init bcm63xx_detect_flash_type(void)
{
u32 val;
@@ -72,9 +90,15 @@ static int __init bcm63xx_detect_flash_t
@@ -73,9 +91,15 @@ static int __init bcm63xx_detect_flash_t
switch (bcm63xx_get_cpu_id()) {
case BCM6318_CPU_ID:
/* only support serial flash */
@ -62,7 +62,7 @@ Signed-off-by: Jonas Gorski <jonas.gorski@gmail.com>
if (val & STRAPBUS_6328_BOOT_SEL_SERIAL)
return BCM63XX_FLASH_TYPE_SERIAL;
else
@@ -93,12 +117,20 @@ static int __init bcm63xx_detect_flash_t
@@ -94,12 +118,20 @@ static int __init bcm63xx_detect_flash_t
return BCM63XX_FLASH_TYPE_SERIAL;
case BCM6362_CPU_ID:
val = bcm_misc_readl(MISC_STRAPBUS_6362_REG);
@ -83,7 +83,7 @@ Signed-off-by: Jonas Gorski <jonas.gorski@gmail.com>
switch (val & STRAPBUS_6368_BOOT_SEL_MASK) {
case STRAPBUS_6368_BOOT_SEL_NAND:
return BCM63XX_FLASH_TYPE_NAND;
@@ -109,6 +141,11 @@ static int __init bcm63xx_detect_flash_t
@@ -110,6 +142,11 @@ static int __init bcm63xx_detect_flash_t
}
case BCM63268_CPU_ID:
val = bcm_misc_readl(MISC_STRAPBUS_63268_REG);
@ -95,7 +95,7 @@ Signed-off-by: Jonas Gorski <jonas.gorski@gmail.com>
if (val & STRAPBUS_63268_BOOT_SEL_SERIAL)
return BCM63XX_FLASH_TYPE_SERIAL;
else
@@ -181,8 +218,15 @@ int __init bcm63xx_flash_register(void)
@@ -195,8 +232,15 @@ int __init bcm63xx_flash_register(void)
return platform_device_register(&mtd_dev);
case BCM63XX_FLASH_TYPE_SERIAL:

View File

@ -11,7 +11,7 @@ Signed-off-by: Jonas Gorski <jogo@openwrt.org>
--- a/arch/mips/bcm63xx/dev-flash.c
+++ b/arch/mips/bcm63xx/dev-flash.c
@@ -236,3 +236,8 @@ int __init bcm63xx_flash_register(void)
@@ -250,3 +250,8 @@ int __init bcm63xx_flash_register(void)
return -ENODEV;
}
}

View File

@ -22,7 +22,7 @@ Subject: [PATCH 69/80] MIPS: BCM63XX: pass caldata info to flash
while (led_count < ARRAY_SIZE(board.leds) && board.leds[led_count].name)
--- a/arch/mips/bcm63xx/dev-flash.c
+++ b/arch/mips/bcm63xx/dev-flash.c
@@ -37,12 +37,15 @@ static struct mtd_partition mtd_partitio
@@ -38,12 +38,15 @@ static struct mtd_partition mtd_partitio
}
};
@ -38,7 +38,7 @@ Subject: [PATCH 69/80] MIPS: BCM63XX: pass caldata info to flash
};
static struct resource mtd_resources[] = {
@@ -70,6 +73,7 @@ void __init bcm63xx_flash_force_phys_bas
@@ -71,6 +74,7 @@ void __init bcm63xx_flash_force_phys_bas
static struct flash_platform_data bcm63xx_flash_data = {
.part_probe_types = bcm63xx_part_types,
@ -46,7 +46,7 @@ Subject: [PATCH 69/80] MIPS: BCM63XX: pass caldata info to flash
};
static struct spi_board_info bcm63xx_spi_flash_info[] = {
@@ -197,9 +201,13 @@ void __init bcm63xx_flash_detect(void)
@@ -211,9 +215,13 @@ void __init bcm63xx_flash_detect(void)
}
}

View File

@ -61,7 +61,7 @@ Subject: [PATCH 72/72] 446-BCM63XX-add-a-fixup-for-rt2x00-devices
}
--- a/arch/mips/bcm63xx/dev-flash.c
+++ b/arch/mips/bcm63xx/dev-flash.c
@@ -201,7 +201,7 @@ void __init bcm63xx_flash_detect(void)
@@ -215,7 +215,7 @@ void __init bcm63xx_flash_detect(void)
}
}

View File

@ -69,7 +69,7 @@
cfe = boot_addr + BCM963XX_CFE_VERSION_OFFSET;
--- a/arch/mips/bcm63xx/dev-flash.c
+++ b/arch/mips/bcm63xx/dev-flash.c
@@ -19,6 +19,7 @@
@@ -20,6 +20,7 @@
#include <linux/spi/spi.h>
#include <linux/spi/flash.h>
@ -77,7 +77,7 @@
#include <bcm63xx_cpu.h>
#include <bcm63xx_dev_flash.h>
#include <bcm63xx_dev_hsspi.h>
@@ -220,6 +221,13 @@ int __init bcm63xx_flash_register(int nu
@@ -234,6 +235,13 @@ int __init bcm63xx_flash_register(int nu
val = bcm_mpi_readl(MPI_CSBASE_REG(0));
val &= MPI_CSBASE_BASE_MASK;