kernel: refresh patches for kernel 3.18
[openwrt/svn-archive/archive.git] / target / linux / brcm47xx / patches-3.18 / 800-bcma-add-table-of-serial-flashes-with-smaller-blocks.patch
1 From 597715c61ae75a05ab3310a34ff3857a006f0f63 Mon Sep 17 00:00:00 2001
2 From: =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= <zajec5@gmail.com>
3 Date: Thu, 20 Nov 2014 21:32:42 +0100
4 Subject: [PATCH] bcma: add table of serial flashes with smaller blocks
5 MIME-Version: 1.0
6 Content-Type: text/plain; charset=UTF-8
7 Content-Transfer-Encoding: 8bit
8
9 Signed-off-by: Rafał Miłecki <zajec5@gmail.com>
10 ---
11 drivers/bcma/driver_chipcommon_sflash.c | 29 +++++++++++++++++++++++++++++
12 1 file changed, 29 insertions(+)
13
14 --- a/drivers/bcma/driver_chipcommon_sflash.c
15 +++ b/drivers/bcma/driver_chipcommon_sflash.c
16 @@ -9,6 +9,7 @@
17
18 #include <linux/platform_device.h>
19 #include <linux/bcma/bcma.h>
20 +#include <bcm47xx_board.h>
21
22 static struct resource bcma_sflash_resource = {
23 .name = "bcma_sflash",
24 @@ -41,6 +42,13 @@ static const struct bcma_sflash_tbl_e bc
25 { NULL },
26 };
27
28 +/* Some devices use smaller blocks (and have more of them) */
29 +static const struct bcma_sflash_tbl_e bcma_sflash_st_shrink_tbl[] = {
30 + { "M25P16", 0x14, 0x1000, 512, },
31 + { "M25P32", 0x15, 0x1000, 1024, },
32 + { NULL },
33 +};
34 +
35 static const struct bcma_sflash_tbl_e bcma_sflash_sst_tbl[] = {
36 { "SST25WF512", 1, 0x1000, 16, },
37 { "SST25VF512", 0x48, 0x1000, 16, },
38 @@ -84,6 +92,23 @@ static void bcma_sflash_cmd(struct bcma_
39 bcma_err(cc->core->bus, "SFLASH control command failed (timeout)!\n");
40 }
41
42 +const struct bcma_sflash_tbl_e *bcma_sflash_shrink_flash(u32 id)
43 +{
44 + enum bcm47xx_board board = bcm47xx_board_get();
45 + const struct bcma_sflash_tbl_e *e;
46 +
47 + switch (board) {
48 + case BCM47XX_BOARD_NETGEAR_WGR614_V10:
49 + for (e = bcma_sflash_st_shrink_tbl; e->name; e++) {
50 + if (e->id == id)
51 + return e;
52 + }
53 + return NULL;
54 + default:
55 + return NULL;
56 + }
57 +}
58 +
59 /* Initialize serial flash access */
60 int bcma_sflash_init(struct bcma_drv_cc *cc)
61 {
62 @@ -114,6 +139,10 @@ int bcma_sflash_init(struct bcma_drv_cc
63 case 0x13:
64 return -ENOTSUPP;
65 default:
66 + e = bcma_sflash_shrink_flash(id);
67 + if (e)
68 + break;
69 +
70 for (e = bcma_sflash_st_tbl; e->name; e++) {
71 if (e->id == id)
72 break;