brcm47xx: add support for Netgear WGR614 V10
[openwrt/svn-archive/archive.git] / target / linux / brcm47xx / patches-3.14 / 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 diff --git a/drivers/bcma/driver_chipcommon_sflash.c b/drivers/bcma/driver_chipcommon_sflash.c
15 index 7e11ef4..25d9e17 100644
16 --- a/drivers/bcma/driver_chipcommon_sflash.c
17 +++ b/drivers/bcma/driver_chipcommon_sflash.c
18 @@ -9,6 +9,7 @@
19
20 #include <linux/platform_device.h>
21 #include <linux/bcma/bcma.h>
22 +#include <bcm47xx_board.h>
23
24 static struct resource bcma_sflash_resource = {
25 .name = "bcma_sflash",
26 @@ -41,6 +42,13 @@ static const struct bcma_sflash_tbl_e bcma_sflash_st_tbl[] = {
27 { NULL },
28 };
29
30 +/* Some devices use smaller blocks (and have more of them) */
31 +static const struct bcma_sflash_tbl_e bcma_sflash_st_shrink_tbl[] = {
32 + { "M25P16", 0x14, 0x1000, 512, },
33 + { "M25P32", 0x15, 0x1000, 1024, },
34 + { NULL },
35 +};
36 +
37 static const struct bcma_sflash_tbl_e bcma_sflash_sst_tbl[] = {
38 { "SST25WF512", 1, 0x1000, 16, },
39 { "SST25VF512", 0x48, 0x1000, 16, },
40 @@ -84,6 +92,23 @@ static void bcma_sflash_cmd(struct bcma_drv_cc *cc, u32 opcode)
41 bcma_err(cc->core->bus, "SFLASH control command failed (timeout)!\n");
42 }
43
44 +const struct bcma_sflash_tbl_e *bcma_sflash_shrink_flash(u32 id)
45 +{
46 + enum bcm47xx_board board = bcm47xx_board_get();
47 + const struct bcma_sflash_tbl_e *e;
48 +
49 + switch (board) {
50 + case BCM47XX_BOARD_NETGEAR_WGR614_V10:
51 + for (e = bcma_sflash_st_shrink_tbl; e->name; e++) {
52 + if (e->id == id)
53 + return e;
54 + }
55 + return NULL;
56 + default:
57 + return NULL;
58 + }
59 +}
60 +
61 /* Initialize serial flash access */
62 int bcma_sflash_init(struct bcma_drv_cc *cc)
63 {
64 @@ -114,6 +139,10 @@ int bcma_sflash_init(struct bcma_drv_cc *cc)
65 case 0x13:
66 return -ENOTSUPP;
67 default:
68 + e = bcma_sflash_shrink_flash(id);
69 + if (e)
70 + break;
71 +
72 for (e = bcma_sflash_st_tbl; e->name; e++) {
73 if (e->id == id)
74 break;
75 --
76 1.8.4.5
77