brcm47xx: Add support for Huawei E970
[openwrt/svn-archive/archive.git] / target / linux / brcm47xx / patches-3.10 / 029-mtd-bcm47xxpart_detect_block_aligned_Squashfs_partition.patch
1 mtd: bcm47xxpart: detect block aligned Squashfs partition
2
3 Most of the bcm47xx devices use TRX format for storing kernel and some
4 partition like Squashfs or JFFS2. This is pretty flexible solution, CFE
5 (the bootloader) just writes (and later boots) TRX at some hardcoded
6 place and paritions can vary in the size.
7
8 However some devices don't use TRX format. Very recently we have
9 discovered ZTE H218N that has kernel and rootfs partitions at some
10 "random" places.
11
12 This patch allows Linux find a rootfs partition after installing custom
13 image with a CFE bootloader.
14
15 Signed-off-by: Rafał Miłecki <zajec5@gmail.com>
16
17 --- a/drivers/mtd/bcm47xxpart.c
18 +++ b/drivers/mtd/bcm47xxpart.c
19 @@ -33,6 +33,7 @@
20 #define ML_MAGIC1 0x39685a42
21 #define ML_MAGIC2 0x26594131
22 #define TRX_MAGIC 0x30524448
23 +#define SQSH_MAGIC 0x71736873 /* shsq */
24
25 struct trx_header {
26 uint32_t magic;
27 @@ -170,6 +171,13 @@ static int bcm47xxpart_parse(struct mtd_
28 offset = rounddown(offset + trx->length, blocksize);
29 continue;
30 }
31 +
32 + /* Squashfs on devices not using TRX */
33 + if (buf[0x000 / 4] == SQSH_MAGIC) {
34 + bcm47xxpart_add_part(&parts[curr_part++], "rootfs",
35 + offset, 0);
36 + continue;
37 + }
38 }
39
40 /* Look for NVRAM at the end of the last block. */