brcm47xx: update mtd drivers
[openwrt/svn-archive/archive.git] / target / linux / brcm47xx / patches-3.10 / 021-mtd-bcm47xxpart-detect-block-aligned-Squashfs-partit.patch
1 From 020c6bcfbeabee72c18d862769d72cf9241b9004 Mon Sep 17 00:00:00 2001
2 From: =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= <zajec5@gmail.com>
3 Date: Mon, 21 Oct 2013 22:34:37 +0200
4 Subject: [PATCH] mtd: bcm47xxpart: detect block aligned Squashfs partition
5 MIME-Version: 1.0
6 Content-Type: text/plain; charset=UTF-8
7 Content-Transfer-Encoding: 8bit
8
9 Most of the bcm47xx devices use TRX format for storing kernel and some
10 partition like Squashfs or JFFS2. This is pretty flexible solution, CFE
11 (the bootloader) just writes (and later boots) TRX at some hardcoded
12 place and paritions can vary in the size.
13
14 However some devices don't use TRX format. Very recently we have
15 discovered ZTE H218N that has kernel and rootfs partitions at some
16 "random" places.
17
18 This patch allows Linux find a rootfs partition after installing custom
19 image with a CFE bootloader.
20
21 Signed-off-by: Rafał Miłecki <zajec5@gmail.com>
22 Signed-off-by: Brian Norris <computersforpeace@gmail.com>
23 ---
24 drivers/mtd/bcm47xxpart.c | 8 ++++++++
25 1 file changed, 8 insertions(+)
26
27 --- a/drivers/mtd/bcm47xxpart.c
28 +++ b/drivers/mtd/bcm47xxpart.c
29 @@ -32,6 +32,7 @@
30 #define ML_MAGIC1 0x39685a42
31 #define ML_MAGIC2 0x26594131
32 #define TRX_MAGIC 0x30524448
33 +#define SQSH_MAGIC 0x71736873 /* shsq */
34
35 struct trx_header {
36 uint32_t magic;
37 @@ -174,6 +175,13 @@ static int bcm47xxpart_parse(struct mtd_
38 offset = rounddown(offset + trx->length, blocksize);
39 continue;
40 }
41 +
42 + /* Squashfs on devices not using TRX */
43 + if (buf[0x000 / 4] == SQSH_MAGIC) {
44 + bcm47xxpart_add_part(&parts[curr_part++], "rootfs",
45 + offset, 0);
46 + continue;
47 + }
48 }
49
50 /* Look for NVRAM at the end of the last block. */