generic/3.10: rename mtd patches
[openwrt.git] / target / linux / generic / patches-3.10 / 470-mtd-m25p80-add-pm25-flash-support.patch
1 From dbca80cf6b3c0d0f130cdfb4b1f19f2092f62174 Mon Sep 17 00:00:00 2001
2 From: Michel Stempin <michel.stempin@wanadoo.fr>
3 Date: Sun, 18 Aug 2013 00:50:26 +0200
4 Subject: [PATCH v2] mtd: m25p80: add support for PMC SPI flash
5
6 This patch adds support for PMC (now Chingis, part of ISSI) Pm25LV512 (512
7 kBbit), Pm25LV010 (1 Mbit) and Pm25LQ032 (32 Mbit) SPI flash.
8
9 Two generations of PMC SPI flash chips are addressed:
10
11 1) Pm25LV512 and Pm25LV010 - These have 4KB sectors and 32KB blocks. The 4KB
12 sector erase uses a non-standard opcode (0xd7). They do not support JEDEC RDID
13 (0x9f), and so they can only be detected by matching their name string with
14 pre-configured platform data. Because of the cascaded acquisitions, the
15 datasheet is no longer available on the current manufacturer's website,
16 although it is still commonly used in some recent wireless routers [1]. Only
17 public datasheet available seems to be on GeoCities [2].
18
19 2) Pm25LQ032 - A newer generation flash, with 4KB sectors and 32KB blocks. It
20 uses the standard erase and JEDEC read-ID opcodes. Manufacturer's datasheet is
21 available [3].
22
23 [1] https://forum.openwrt.org/viewtopic.php?pid=186360#p186360
24 [2] http://www.geocities.jp/scottle556/pdf/Pm25LV512-010.pdf
25 [3] http://www.chingistek.com/img/Product_Files/Pm25LQ032C%20datasheet%20v1.6.1.pdf
26
27 Signed-off-by: Gabor Juhos <juhosg@openwrt.org>
28 Signed-off-by: Michel Stempin <michel.stempin@wanadoo.fr>
29 CC: Brian Norris <computersforpeace@gmail.com>
30 CC: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
31 ---
32
33 Changes in v2:
34  - style and documentation improvements
35
36  drivers/mtd/devices/m25p80.c | 10 ++++++++++
37  1 file changed, 10 insertions(+)
38
39 --- a/drivers/mtd/devices/m25p80.c
40 +++ b/drivers/mtd/devices/m25p80.c
41 @@ -45,6 +45,7 @@
42  #define        OPCODE_BE_4K            0x20    /* Erase 4KiB block */
43  #define        OPCODE_BE_32K           0x52    /* Erase 32KiB block */
44  #define        OPCODE_CHIP_ERASE       0xc7    /* Erase whole flash chip */
45 +#define        OPCODE_BE_4K_PMC        0xd7    /* Erase 4KiB block on PMC chips*/
46  #define        OPCODE_SE               0xd8    /* Sector erase (usually 64KiB) */
47  #define        OPCODE_RDID             0x9f    /* Read JEDEC ID */
48  
49 @@ -682,6 +683,7 @@ struct flash_info {
50  #define        SECT_4K         0x01            /* OPCODE_BE_4K works uniformly */
51  #define        M25P_NO_ERASE   0x02            /* No erase command needed */
52  #define        SST_WRITE       0x04            /* use SST byte programming */
53 +#define        SECT_4K_PMC     0x08            /* OPCODE_BE_4K_PMC works uniformly */
54  };
55  
56  #define INFO(_jedec_id, _ext_id, _sector_size, _n_sectors, _flags)     \
57 @@ -765,6 +767,11 @@ static const struct spi_device_id m25p_i
58         { "n25q128a13",  INFO(0x20ba18, 0, 64 * 1024, 256, 0) },
59         { "n25q256a", INFO(0x20ba19, 0, 64 * 1024, 512, SECT_4K) },
60  
61 +       /* PMC -- pm25x "blocks" are 32K, sectors are 4K */
62 +       { "pm25lv512", INFO(0, 0, 32 * 1024, 2, SECT_4K_PMC) },
63 +       { "pm25lv010", INFO(0, 0, 32 * 1024, 4, SECT_4K_PMC) },
64 +       { "pm25lq032", INFO(0x7F9D46, 0, 64 * 1024,  64, SECT_4K) },
65 +
66         /* Spansion -- single (large) sector size only, at least
67          * for the chips listed here (without boot sectors).
68          */
69 @@ -1017,6 +1024,9 @@ static int m25p_probe(struct spi_device
70         if (info->flags & SECT_4K) {
71                 flash->erase_opcode = OPCODE_BE_4K;
72                 flash->mtd.erasesize = 4096;
73 +       } else if (info->flags & SECT_4K_PMC) {
74 +               flash->erase_opcode = OPCODE_BE_4K_PMC;
75 +               flash->mtd.erasesize = 4096;
76         } else {
77                 flash->erase_opcode = OPCODE_SE;
78                 flash->mtd.erasesize = info->sector_size;