c8febaf73f9cef7b0462cde32076f0c5f3c1e89e
[openwrt/openwrt.git] / target / linux / ramips / patches-4.14 / 304-spi-nor-enable-4B-opcodes-for-mx25l25635f.patch
1 This hack can be dropped after the next stable release from
2 v5.x-tree.
3
4 The problem was fixed upstream by
5
6 commit 2bffa65da43e ("mtd: spi-nor: Add a post BFPT fixup for MX25L25635E")
7
8 For reference see:
9 <https://github.com/openwrt/openwrt/pull/1743>
10
11 --- a/drivers/mtd/spi-nor/spi-nor.c
12 +++ b/drivers/mtd/spi-nor/spi-nor.c
13 @@ -1098,6 +1098,7 @@ static const struct flash_info spi_nor_i
14 { "mx25l12805d", INFO(0xc22018, 0, 64 * 1024, 256, 0) },
15 { "mx25l12855e", INFO(0xc22618, 0, 64 * 1024, 256, 0) },
16 { "mx25l25635e", INFO(0xc22019, 0, 64 * 1024, 512, SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ) },
17 + { "mx25l25635f", INFO(0xc22019, 0, 64 * 1024, 512, SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ | SPI_NOR_4B_OPCODES) },
18 { "mx25u25635f", INFO(0xc22539, 0, 64 * 1024, 512, SECT_4K | SPI_NOR_4B_OPCODES) },
19 { "mx25l25655e", INFO(0xc22619, 0, 64 * 1024, 512, 0) },
20 { "mx66l51235l", INFO(0xc2201a, 0, 64 * 1024, 1024, SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ | SPI_NOR_4B_OPCODES) },
21 @@ -1267,11 +1268,12 @@ static const struct flash_info spi_nor_i
22 { },
23 };
24
25 -static const struct flash_info *spi_nor_read_id(struct spi_nor *nor)
26 +static const struct flash_info *spi_nor_read_id(struct spi_nor *nor,
27 + const char *name)
28 {
29 int tmp;
30 u8 id[SPI_NOR_MAX_ID_LEN];
31 - const struct flash_info *info;
32 + const struct flash_info *info, *first_match = NULL;
33
34 tmp = nor->read_reg(nor, SPINOR_OP_RDID, id, SPI_NOR_MAX_ID_LEN);
35 if (tmp < 0) {
36 @@ -1282,10 +1284,16 @@ static const struct flash_info *spi_nor_
37 for (tmp = 0; tmp < ARRAY_SIZE(spi_nor_ids) - 1; tmp++) {
38 info = &spi_nor_ids[tmp];
39 if (info->id_len) {
40 - if (!memcmp(info->id, id, info->id_len))
41 - return &spi_nor_ids[tmp];
42 + if (!memcmp(info->id, id, info->id_len)) {
43 + if (!name || !strcmp(name, info->name))
44 + return info;
45 + if (!first_match)
46 + first_match = info;
47 + }
48 }
49 }
50 + if (first_match)
51 + return first_match;
52 dev_err(nor->dev, "unrecognized JEDEC id bytes: %02x, %02x, %02x\n",
53 id[0], id[1], id[2]);
54 return ERR_PTR(-ENODEV);
55 @@ -2765,7 +2773,7 @@ int spi_nor_scan(struct spi_nor *nor, co
56 info = spi_nor_match_id(name);
57 /* Try to auto-detect if chip name wasn't specified or not found */
58 if (!info)
59 - info = spi_nor_read_id(nor);
60 + info = spi_nor_read_id(nor, NULL);
61 if (IS_ERR_OR_NULL(info))
62 return -ENOENT;
63
64 @@ -2776,7 +2784,7 @@ int spi_nor_scan(struct spi_nor *nor, co
65 if (name && info->id_len) {
66 const struct flash_info *jinfo;
67
68 - jinfo = spi_nor_read_id(nor);
69 + jinfo = spi_nor_read_id(nor, name);
70 if (IS_ERR(jinfo)) {
71 return PTR_ERR(jinfo);
72 } else if (jinfo != info) {