kernel: backport MTD patch extracing TRX code to separated parser
[openwrt/openwrt.git] / target / linux / bcm53xx / patches-4.9 / 900-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 @@ -15,6 +15,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 @@ -134,6 +135,36 @@ static int bcm47xxpart_parse(struct mtd_
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-c5-v2") && 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 + } else if (of_machine_is_compatible("tplink,archer-c9-v1") && offset == 0xe40000) {
45 + /*
46 + * There is a whole set of partitions (not even listed
47 + * by original firmware): "default-mac", "pin",
48 + * "partition-table", etc.
49 + */
50 + bcm47xxpart_add_part(&parts[curr_part++], "tplink", offset, MTD_WRITEABLE);
51 + continue;
52 + }
53 +
54 /* Read beginning of the block */
55 err = mtd_read(master, offset, BCM47XXPART_BYTES_TO_READ,
56 &bytes_read, (uint8_t *)buf);