bcm53xx: add kernel support for TP-LINK Archer C9 V1
[librecmc/librecmc.git] / target / linux / bcm53xx / patches-4.4 / 901-mtd-bcm47xxpart-add-device-specific-workarounds.patch
1 From: =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= <rafal@milecki.pl>
2 Subject: [PATCH] mtd: bcm47xxpart: add device specific workarounds
3 MIME-Version: 1.0
4 Content-Type: text/plain; charset=UTF-8
5 Content-Transfer-Encoding: 8bit
6
7 Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
8 ---
9
10 --- a/drivers/mtd/bcm47xxpart.c
11 +++ b/drivers/mtd/bcm47xxpart.c
12 @@ -14,6 +14,7 @@
13  #include <linux/slab.h>
14  #include <linux/mtd/mtd.h>
15  #include <linux/mtd/partitions.h>
16 +#include <linux/of.h>
17  
18  #include <uapi/linux/magic.h>
19  
20 @@ -159,6 +160,28 @@ static int bcm47xxpart_parse(struct mtd_info *master,
21                         break;
22                 }
23  
24 +               /*
25 +                * Device specific workarounds (hacks). We should use DT to
26 +                * define partitions but we need a working TRX firmware splitter
27 +                * first.
28 +                */
29 +               if (of_machine_is_compatible("asus,rt-ac87u") && offset == 0x7ec0000) {
30 +                       /*
31 +                        * "asus" partition uses JFFS2 which we don't detect and
32 +                        * we don't want to as this could affect other devices.
33 +                        */
34 +                       bcm47xxpart_add_part(&parts[curr_part++], "asus", offset, MTD_WRITEABLE);
35 +                       continue;
36 +               } else  if (of_machine_is_compatible("tplink,archer-c9-v1") && offset == 0xe40000) {
37 +                       /*
38 +                        * There is a whole set of partitions (not even listed
39 +                        * by original firmware): "default-mac", "pin",
40 +                        * "partition-table", etc.
41 +                        */
42 +                       bcm47xxpart_add_part(&parts[curr_part++], "tplink", offset, MTD_WRITEABLE);
43 +                       continue;
44 +               }
45 +
46                 /* Read beginning of the block */
47                 err = mtd_read(master, offset, BCM47XXPART_BYTES_TO_READ,
48                                &bytes_read, (uint8_t *)buf);