summaryrefslogtreecommitdiff
path: root/package/boot/uboot-lantiq/patches/0011-sf-spansion-add-support-for-4-byte-address-mode.patch
blob: 9471d47c769daa46fee137db1a2614e431ab82c7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
From 0add8e5c60961d2b99174610df8d3d9d6d192b74 Mon Sep 17 00:00:00 2001
From: Daniel Schwierzeck <daniel.schwierzeck@gmail.com>
Date: Wed, 7 Nov 2012 14:16:11 +0100
Subject: sf: spansion: add support for 4-byte address mode

Signed-off-by: Daniel Schwierzeck <daniel.schwierzeck@gmail.com>

--- a/drivers/mtd/spi/spansion.c
+++ b/drivers/mtd/spi/spansion.c
@@ -31,6 +31,10 @@
 
 #include "spi_flash_internal.h"
 
+#define S25FLXX_BRRD		0x16		/* Read Bank Register */
+#define S25FLXX_BRWR		0x17		/* Write Bank Register */
+#define S25FLXX_BAR_EXTADD	(1 << 7)	/* Extended address enable */
+
 struct spansion_spi_flash_params {
 	u16 idcode1;
 	u16 idcode2;
@@ -112,6 +116,23 @@ static const struct spansion_spi_flash_p
 	},
 };
 
+static __maybe_unused int spansion_set_4byte_mode(struct spi_flash *flash)
+{
+	struct spi_slave *spi = flash->spi;
+	u8 bar, cmd;
+	int err;
+
+	cmd = S25FLXX_BRRD;
+	err = spi_flash_cmd(spi, cmd, &bar, 1);
+	if (err)
+		return err;
+
+	bar |= S25FLXX_BAR_EXTADD;
+	cmd = S25FLXX_BRWR;
+
+	return spi_flash_cmd_write(spi, &cmd, 1, &bar, 1);
+}
+
 int spi_flash_probe_spansion(struct spi_flash *flash, u8 *idcode)
 {
 	const struct spansion_spi_flash_params *params;
@@ -144,5 +165,10 @@ int spi_flash_probe_spansion(struct spi_
 	flash->sector_size = 256 * params->pages_per_sector;
 	flash->size = flash->sector_size * params->nr_sectors;
 
+#ifdef CONFIG_SPI_FLASH_4BYTE_MODE
+	if (flash->size > (1 << 24))
+		flash->set_4byte_mode = spansion_set_4byte_mode;
+#endif
+
 	return 1;
 }