aboutsummaryrefslogtreecommitdiffstats
path: root/target/linux/bcm53xx
diff options
context:
space:
mode:
authorRafał Miłecki <zajec5@gmail.com>2016-04-27 21:20:45 +0000
committerLuka Perkov <luka@openwrt.org>2016-06-19 19:07:47 +0200
commitbdbe2c8a7ad24dc080740b5a89fc6e2bcfe0f197 (patch)
tree67ef25c6939633f0a6415429f76b13ea6295a2b2 /target/linux/bcm53xx
parent1e22c9b9eb691878156dfe32fb1e117737f1d248 (diff)
downloadmaster-187ad058-bdbe2c8a7ad24dc080740b5a89fc6e2bcfe0f197.tar.gz
master-187ad058-bdbe2c8a7ad24dc080740b5a89fc6e2bcfe0f197.tar.bz2
master-187ad058-bdbe2c8a7ad24dc080740b5a89fc6e2bcfe0f197.zip
bcm53xx: add m25p80 workaround for SPI flash writing problems
Signed-off-by: Rafał Miłecki <zajec5@gmail.com> git-svn-id: svn://svn.openwrt.org/openwrt/trunk@49264 3c298f89-4303-0410-b956-a3cf2f4a3e73
Diffstat (limited to 'target/linux/bcm53xx')
-rw-r--r--target/linux/bcm53xx/patches-4.4/406-mtd-m25p80-use-single-SPI-message-for-writing-data.patch62
1 files changed, 62 insertions, 0 deletions
diff --git a/target/linux/bcm53xx/patches-4.4/406-mtd-m25p80-use-single-SPI-message-for-writing-data.patch b/target/linux/bcm53xx/patches-4.4/406-mtd-m25p80-use-single-SPI-message-for-writing-data.patch
new file mode 100644
index 0000000000..0e0cce219c
--- /dev/null
+++ b/target/linux/bcm53xx/patches-4.4/406-mtd-m25p80-use-single-SPI-message-for-writing-data.patch
@@ -0,0 +1,62 @@
+From: =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= <zajec5@gmail.com>
+Subject: [PATCH] mtd: m25p80: use single SPI message for writing data
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+On all 3 tested Northstar devices with following flash memories:
+mx25l6405d (8192 Kbytes)
+mx25l12805d (16384 Kbytes)
+mx25l25635e (32768 Kbytes)
+I noticed writing to be broken. Not a single bit was changed leaving all
+bytes set to 0xff.
+
+This is most likely some problem related to the SPI controller or its
+driver. Using a single SPI message seems to workaround this. Of course
+it's not perfect solution as copying whole data into a new buffer makes
+writing slower.
+
+Signed-off-by: Rafał Miłecki <zajec5@gmail.com>
+---
+
+--- a/drivers/mtd/devices/m25p80.c
++++ b/drivers/mtd/devices/m25p80.c
+@@ -78,29 +78,30 @@ static void m25p80_write(struct spi_nor *nor, loff_t to, size_t len,
+ {
+ struct m25p *flash = nor->priv;
+ struct spi_device *spi = flash->spi;
++ u8 *command = kzalloc(MAX_CMD_SIZE + len, GFP_KERNEL);
+ struct spi_transfer t[2] = {};
+ struct spi_message m;
+ int cmd_sz = m25p_cmdsz(nor);
++ int i;
+
+ spi_message_init(&m);
+
+ if (nor->program_opcode == SPINOR_OP_AAI_WP && nor->sst_write_second)
+ cmd_sz = 1;
+
+- flash->command[0] = nor->program_opcode;
+- m25p_addr2cmd(nor, to, flash->command);
++ command[0] = nor->program_opcode;
++ m25p_addr2cmd(nor, to, command);
++ memcpy(&command[cmd_sz], buf, len);
+
+- t[0].tx_buf = flash->command;
+- t[0].len = cmd_sz;
++ t[0].tx_buf = command;
++ t[0].len = cmd_sz + len;
+ spi_message_add_tail(&t[0], &m);
+
+- t[1].tx_buf = buf;
+- t[1].len = len;
+- spi_message_add_tail(&t[1], &m);
+-
+ spi_sync(spi, &m);
+
+ *retlen += m.actual_length - cmd_sz;
++
++ kfree(command);
+ }
+
+ static inline unsigned int m25p80_rx_nbits(struct spi_nor *nor)