bcm47xx: add support for NETGEAR R6200 V1
[oweals/openwrt.git] / target / linux / bcm47xx / patches-4.19 / 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 @@ -42,6 +43,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 @@ -85,6 +93,24 @@ 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 +       case BCM47XX_BOARD_NETGEAR_WNR1000_V3:
50 +               for (e = bcma_sflash_st_shrink_tbl; e->name; e++) {
51 +                       if (e->id == id)
52 +                               return e;
53 +               }
54 +               return NULL;
55 +       default:
56 +               return NULL;
57 +       }
58 +}
59 +
60  /* Initialize serial flash access */
61  int bcma_sflash_init(struct bcma_drv_cc *cc)
62  {
63 @@ -115,6 +141,10 @@ int bcma_sflash_init(struct bcma_drv_cc
64                 case 0x13:
65                         return -ENOTSUPP;
66                 default:
67 +                       e = bcma_sflash_shrink_flash(id);
68 +                       if (e)
69 +                               break;
70 +
71                         for (e = bcma_sflash_st_tbl; e->name; e++) {
72                                 if (e->id == id)
73                                         break;