From: Jonas Gorski <jogo@openwrt.org>
Date: Sun, 23 Aug 2015 09:35:56 +0000 (+0000)
Subject: brcm63xx: ensure dummy byte is set for mapped spi flash with fast read
X-Git-Tag: reboot~2204
X-Git-Url: http://git.cdn.openwrt.org/?a=commitdiff_plain;h=ecdce239a54b7a4c4aa760a659c13642e1817326;p=openwrt%2Fstaging%2Fjogo.git

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.

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

SVN-Revision: 46707
---

diff --git a/target/linux/brcm63xx/patches-3.18/345-MIPS-BCM63XX-fixup-mapped-SPI-flash-access-on-boot.patch b/target/linux/brcm63xx/patches-3.18/345-MIPS-BCM63XX-fixup-mapped-SPI-flash-access-on-boot.patch
index 2b19600776..c8bef13625 100644
--- a/target/linux/brcm63xx/patches-3.18/345-MIPS-BCM63XX-fixup-mapped-SPI-flash-access-on-boot.patch
+++ b/target/linux/brcm63xx/patches-3.18/345-MIPS-BCM63XX-fixup-mapped-SPI-flash-access-on-boot.patch
@@ -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;
++
++			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;
 +
-+		val &= ~FLASH_CTRL_MB_EN;
-+		val &= ~FLASH_CTRL_READ_OPCODE_MASK;
++			if (cmd != SPINOR_OP_READ_FAST && cmd != SPINOR_OP_READ4_FAST)
++				return;
 +
-+		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;
++			val &= ~FLASH_CTRL_DUMMY_BYTES_MASK;
++			val |= 1 << FLASH_CTRL_DUMMY_BYTES_SHIFT;
 +		}
 +
 +		bcm_rset_writel(RSET_HSSPI, val, HSSPI_FLASH_CTRL_REG);
diff --git a/target/linux/brcm63xx/patches-3.18/355-MIPS-BCM63XX-allow-board-implementations-to-force-fl.patch b/target/linux/brcm63xx/patches-3.18/355-MIPS-BCM63XX-allow-board-implementations-to-force-fl.patch
index 7e408f69fb..bdbba036b5 100644
--- a/target/linux/brcm63xx/patches-3.18/355-MIPS-BCM63XX-allow-board-implementations-to-force-fl.patch
+++ b/target/linux/brcm63xx/patches-3.18/355-MIPS-BCM63XX-allow-board-implementations-to-force-fl.patch
@@ -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:
diff --git a/target/linux/brcm63xx/patches-3.18/372_dont_register_pflash_when_available_in_dtb.patch b/target/linux/brcm63xx/patches-3.18/372_dont_register_pflash_when_available_in_dtb.patch
index 88efc2360b..25384ebb68 100644
--- a/target/linux/brcm63xx/patches-3.18/372_dont_register_pflash_when_available_in_dtb.patch
+++ b/target/linux/brcm63xx/patches-3.18/372_dont_register_pflash_when_available_in_dtb.patch
@@ -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:
diff --git a/target/linux/brcm63xx/patches-3.18/400-bcm963xx_flashmap.patch b/target/linux/brcm63xx/patches-3.18/400-bcm963xx_flashmap.patch
index 03534c0aab..c693ace363 100644
--- a/target/linux/brcm63xx/patches-3.18/400-bcm963xx_flashmap.patch
+++ b/target/linux/brcm63xx/patches-3.18/400-bcm963xx_flashmap.patch
@@ -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
  	}
  };
  
diff --git a/target/linux/brcm63xx/patches-3.18/411-MIPS-BCM63XX-Register-SPI-flash-if-present.patch b/target/linux/brcm63xx/patches-3.18/411-MIPS-BCM63XX-Register-SPI-flash-if-present.patch
index 24a5888ef5..23b3b83486 100644
--- a/target/linux/brcm63xx/patches-3.18/411-MIPS-BCM63XX-Register-SPI-flash-if-present.patch
+++ b/target/linux/brcm63xx/patches-3.18/411-MIPS-BCM63XX-Register-SPI-flash-if-present.patch
@@ -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:
diff --git a/target/linux/brcm63xx/patches-3.18/415-MIPS-BCM63XX-export-the-attached-flash-type.patch b/target/linux/brcm63xx/patches-3.18/415-MIPS-BCM63XX-export-the-attached-flash-type.patch
index 55639cafab..44763bb256 100644
--- a/target/linux/brcm63xx/patches-3.18/415-MIPS-BCM63XX-export-the-attached-flash-type.patch
+++ b/target/linux/brcm63xx/patches-3.18/415-MIPS-BCM63XX-export-the-attached-flash-type.patch
@@ -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;
  	}
  }
diff --git a/target/linux/brcm63xx/patches-3.18/418-MIPS-BCM63XX-pass-caldata-info-to-flash.patch b/target/linux/brcm63xx/patches-3.18/418-MIPS-BCM63XX-pass-caldata-info-to-flash.patch
index b329c312f5..484e1fd5a2 100644
--- a/target/linux/brcm63xx/patches-3.18/418-MIPS-BCM63XX-pass-caldata-info-to-flash.patch
+++ b/target/linux/brcm63xx/patches-3.18/418-MIPS-BCM63XX-pass-caldata-info-to-flash.patch
@@ -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)
  	}
  }
  
diff --git a/target/linux/brcm63xx/patches-3.18/422-BCM63XX-add-a-fixup-for-rt2x00-devices.patch b/target/linux/brcm63xx/patches-3.18/422-BCM63XX-add-a-fixup-for-rt2x00-devices.patch
index bff489b960..4a0a7b0a71 100644
--- a/target/linux/brcm63xx/patches-3.18/422-BCM63XX-add-a-fixup-for-rt2x00-devices.patch
+++ b/target/linux/brcm63xx/patches-3.18/422-BCM63XX-add-a-fixup-for-rt2x00-devices.patch
@@ -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)
  	}
  }
  
diff --git a/target/linux/brcm63xx/patches-3.18/511-board_V2500V.patch b/target/linux/brcm63xx/patches-3.18/511-board_V2500V.patch
index 2d8951fc08..5b7c789dac 100644
--- a/target/linux/brcm63xx/patches-3.18/511-board_V2500V.patch
+++ b/target/linux/brcm63xx/patches-3.18/511-board_V2500V.patch
@@ -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;
  
diff --git a/target/linux/brcm63xx/patches-4.1/345-MIPS-BCM63XX-fixup-mapped-SPI-flash-access-on-boot.patch b/target/linux/brcm63xx/patches-4.1/345-MIPS-BCM63XX-fixup-mapped-SPI-flash-access-on-boot.patch
index 2b19600776..c8bef13625 100644
--- a/target/linux/brcm63xx/patches-4.1/345-MIPS-BCM63XX-fixup-mapped-SPI-flash-access-on-boot.patch
+++ b/target/linux/brcm63xx/patches-4.1/345-MIPS-BCM63XX-fixup-mapped-SPI-flash-access-on-boot.patch
@@ -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;
++
++			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;
 +
-+		val &= ~FLASH_CTRL_MB_EN;
-+		val &= ~FLASH_CTRL_READ_OPCODE_MASK;
++			if (cmd != SPINOR_OP_READ_FAST && cmd != SPINOR_OP_READ4_FAST)
++				return;
 +
-+		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;
++			val &= ~FLASH_CTRL_DUMMY_BYTES_MASK;
++			val |= 1 << FLASH_CTRL_DUMMY_BYTES_SHIFT;
 +		}
 +
 +		bcm_rset_writel(RSET_HSSPI, val, HSSPI_FLASH_CTRL_REG);
diff --git a/target/linux/brcm63xx/patches-4.1/355-MIPS-BCM63XX-allow-board-implementations-to-force-fl.patch b/target/linux/brcm63xx/patches-4.1/355-MIPS-BCM63XX-allow-board-implementations-to-force-fl.patch
index 7e408f69fb..bdbba036b5 100644
--- a/target/linux/brcm63xx/patches-4.1/355-MIPS-BCM63XX-allow-board-implementations-to-force-fl.patch
+++ b/target/linux/brcm63xx/patches-4.1/355-MIPS-BCM63XX-allow-board-implementations-to-force-fl.patch
@@ -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:
diff --git a/target/linux/brcm63xx/patches-4.1/372_dont_register_pflash_when_available_in_dtb.patch b/target/linux/brcm63xx/patches-4.1/372_dont_register_pflash_when_available_in_dtb.patch
index 88efc2360b..25384ebb68 100644
--- a/target/linux/brcm63xx/patches-4.1/372_dont_register_pflash_when_available_in_dtb.patch
+++ b/target/linux/brcm63xx/patches-4.1/372_dont_register_pflash_when_available_in_dtb.patch
@@ -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:
diff --git a/target/linux/brcm63xx/patches-4.1/400-bcm963xx_flashmap.patch b/target/linux/brcm63xx/patches-4.1/400-bcm963xx_flashmap.patch
index 03534c0aab..c693ace363 100644
--- a/target/linux/brcm63xx/patches-4.1/400-bcm963xx_flashmap.patch
+++ b/target/linux/brcm63xx/patches-4.1/400-bcm963xx_flashmap.patch
@@ -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
  	}
  };
  
diff --git a/target/linux/brcm63xx/patches-4.1/411-MIPS-BCM63XX-Register-SPI-flash-if-present.patch b/target/linux/brcm63xx/patches-4.1/411-MIPS-BCM63XX-Register-SPI-flash-if-present.patch
index 20453709c2..3a09563427 100644
--- a/target/linux/brcm63xx/patches-4.1/411-MIPS-BCM63XX-Register-SPI-flash-if-present.patch
+++ b/target/linux/brcm63xx/patches-4.1/411-MIPS-BCM63XX-Register-SPI-flash-if-present.patch
@@ -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:
diff --git a/target/linux/brcm63xx/patches-4.1/415-MIPS-BCM63XX-export-the-attached-flash-type.patch b/target/linux/brcm63xx/patches-4.1/415-MIPS-BCM63XX-export-the-attached-flash-type.patch
index 55639cafab..44763bb256 100644
--- a/target/linux/brcm63xx/patches-4.1/415-MIPS-BCM63XX-export-the-attached-flash-type.patch
+++ b/target/linux/brcm63xx/patches-4.1/415-MIPS-BCM63XX-export-the-attached-flash-type.patch
@@ -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;
  	}
  }
diff --git a/target/linux/brcm63xx/patches-4.1/418-MIPS-BCM63XX-pass-caldata-info-to-flash.patch b/target/linux/brcm63xx/patches-4.1/418-MIPS-BCM63XX-pass-caldata-info-to-flash.patch
index b329c312f5..484e1fd5a2 100644
--- a/target/linux/brcm63xx/patches-4.1/418-MIPS-BCM63XX-pass-caldata-info-to-flash.patch
+++ b/target/linux/brcm63xx/patches-4.1/418-MIPS-BCM63XX-pass-caldata-info-to-flash.patch
@@ -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)
  	}
  }
  
diff --git a/target/linux/brcm63xx/patches-4.1/422-BCM63XX-add-a-fixup-for-rt2x00-devices.patch b/target/linux/brcm63xx/patches-4.1/422-BCM63XX-add-a-fixup-for-rt2x00-devices.patch
index bff489b960..4a0a7b0a71 100644
--- a/target/linux/brcm63xx/patches-4.1/422-BCM63XX-add-a-fixup-for-rt2x00-devices.patch
+++ b/target/linux/brcm63xx/patches-4.1/422-BCM63XX-add-a-fixup-for-rt2x00-devices.patch
@@ -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)
  	}
  }
  
diff --git a/target/linux/brcm63xx/patches-4.1/511-board_V2500V.patch b/target/linux/brcm63xx/patches-4.1/511-board_V2500V.patch
index 2d8951fc08..5b7c789dac 100644
--- a/target/linux/brcm63xx/patches-4.1/511-board_V2500V.patch
+++ b/target/linux/brcm63xx/patches-4.1/511-board_V2500V.patch
@@ -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;