ixp4xx: add support for linux 3.3.1
[openwrt/svn-archive/archive.git] / target / linux / brcm47xx / patches-3.0 / 0017-mtd-bcm47xx-add-bcm47xx-part-parser.patch
1 From 1934b89b42976a083c2ad8d8fdc526ab5b05c5e4 Mon Sep 17 00:00:00 2001
2 From: Hauke Mehrtens <hauke@hauke-m.de>
3 Date: Sun, 17 Jul 2011 14:54:11 +0200
4 Subject: [PATCH 17/26] mtd: bcm47xx: add bcm47xx part parser
5
6
7 Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
8 ---
9 drivers/mtd/Kconfig | 7 +
10 drivers/mtd/Makefile | 1 +
11 drivers/mtd/bcm47xxpart.c | 536 +++++++++++++++++++++++++++++++++++++++++++++
12 3 files changed, 544 insertions(+), 0 deletions(-)
13 create mode 100644 drivers/mtd/bcm47xxpart.c
14
15 --- a/drivers/mtd/Kconfig
16 +++ b/drivers/mtd/Kconfig
17 @@ -173,6 +173,13 @@ config MTD_MYLOADER_PARTS
18 You will still need the parsing functions to be called by the driver
19 for your particular device. It won't happen automatically.
20
21 +config MTD_BCM47XX_PARTS
22 + tristate "BCM47XX partitioning support"
23 + default y
24 + depends on BCM47XX
25 + ---help---
26 + bcm47XX partitioning support
27 +
28 comment "User Modules And Translation Layers"
29
30 config MTD_CHAR
31 --- a/drivers/mtd/Makefile
32 +++ b/drivers/mtd/Makefile
33 @@ -12,6 +12,7 @@ obj-$(CONFIG_MTD_CMDLINE_PARTS) += cmdli
34 obj-$(CONFIG_MTD_AFS_PARTS) += afs.o
35 obj-$(CONFIG_MTD_AR7_PARTS) += ar7part.o
36 obj-$(CONFIG_MTD_MYLOADER_PARTS) += myloader.o
37 +obj-$(CONFIG_MTD_BCM47XX_PARTS) += bcm47xxpart.o
38
39 # 'Users' - code which presents functionality to userspace.
40 obj-$(CONFIG_MTD_CHAR) += mtdchar.o
41 --- /dev/null
42 +++ b/drivers/mtd/bcm47xxpart.c
43 @@ -0,0 +1,536 @@
44 +/*
45 + * Copyright (C) 2006 Felix Fietkau <nbd@openwrt.org>
46 + * Copyright (C) 2005 Waldemar Brodkorb <wbx@openwrt.org>
47 + * Copyright (C) 2004 Florian Schirmer (jolt@tuxbox.org)
48 + *
49 + * original functions for finding root filesystem from Mike Baker
50 + *
51 + * This program is free software; you can redistribute it and/or modify it
52 + * under the terms of the GNU General Public License as published by the
53 + * Free Software Foundation; either version 2 of the License, or (at your
54 + * option) any later version.
55 + *
56 + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
57 + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
58 + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
59 + * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
60 + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
61 + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
62 + * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
63 + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
64 + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
65 + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
66 + *
67 + * You should have received a copy of the GNU General Public License along
68 + * with this program; if not, write to the Free Software Foundation, Inc.,
69 + * 675 Mass Ave, Cambridge, MA 02139, USA.
70 + *
71 + * Copyright 2001-2003, Broadcom Corporation
72 + * All Rights Reserved.
73 + *
74 + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
75 + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
76 + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
77 + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
78 + *
79 + * Flash mapping for BCM947XX boards
80 + */
81 +
82 +#define pr_fmt(fmt) "bcm47xx_part: " fmt
83 +#include <linux/init.h>
84 +#include <linux/module.h>
85 +#include <linux/types.h>
86 +#include <linux/kernel.h>
87 +#include <linux/sched.h>
88 +#include <linux/wait.h>
89 +#include <linux/mtd/mtd.h>
90 +#include <linux/mtd/partitions.h>
91 +#include <linux/crc32.h>
92 +#include <linux/io.h>
93 +#include <asm/mach-bcm47xx/nvram.h>
94 +#include <asm/mach-bcm47xx/bcm47xx.h>
95 +#include <asm/fw/cfe/cfe_api.h>
96 +
97 +
98 +#define TRX_MAGIC 0x30524448 /* "HDR0" */
99 +#define TRX_VERSION 1
100 +#define TRX_MAX_LEN 0x3A0000
101 +#define TRX_NO_HEADER 1 /* Do not write TRX header */
102 +#define TRX_GZ_FILES 0x2 /* Contains up to TRX_MAX_OFFSET individual gzip files */
103 +#define TRX_MAX_OFFSET 3
104 +
105 +struct trx_header {
106 + u32 magic; /* "HDR0" */
107 + u32 len; /* Length of file including header */
108 + u32 crc32; /* 32-bit CRC from flag_version to end of file */
109 + u32 flag_version; /* 0:15 flags, 16:31 version */
110 + u32 offsets[TRX_MAX_OFFSET]; /* Offsets of partitions from start of header */
111 +};
112 +
113 +/* for Edimax Print servers which use an additional header
114 + * then the firmware on flash looks like :
115 + * EDIMAX HEADER | TRX HEADER
116 + * As this header is 12 bytes long we have to handle it
117 + * and skip it to find the TRX header
118 + */
119 +#define EDIMAX_PS_HEADER_MAGIC 0x36315350 /* "PS16" */
120 +#define EDIMAX_PS_HEADER_LEN 0xc /* 12 bytes long for edimax header */
121 +
122 +#define NVRAM_SPACE 0x8000
123 +
124 +#define ROUTER_NETGEAR_WGR614L 1
125 +#define ROUTER_NETGEAR_WNR834B 2
126 +#define ROUTER_NETGEAR_WNDR3300 3
127 +#define ROUTER_NETGEAR_WNR3500L 4
128 +#define ROUTER_SIMPLETECH_SIMPLESHARE 5
129 +
130 +static struct mtd_partition bcm47xx_parts[] = {
131 + { name: "cfe", offset:0, size:0, mask_flags:MTD_WRITEABLE, },
132 + { name: "linux", offset:0, size:0, },
133 + { name: "rootfs", offset:0, size:0, },
134 + { name: "nvram", offset:0, size:0, },
135 + { name: NULL, }, /* Used to create custom partitons with the function get_router() */
136 + { name: NULL, },
137 +};
138 +
139 +static int
140 +find_cfe_size(struct mtd_info *mtd)
141 +{
142 + struct trx_header *trx;
143 + unsigned char buf[512];
144 + int off;
145 + size_t len;
146 + int blocksize;
147 +
148 + trx = (struct trx_header *) buf;
149 +
150 + blocksize = mtd->erasesize;
151 + if (blocksize < 0x10000)
152 + blocksize = 0x10000;
153 +
154 + for (off = (128*1024); off < mtd->size; off += blocksize) {
155 + memset(buf, 0xe5, sizeof(buf));
156 +
157 + /*
158 + * Read into buffer
159 + */
160 + if (mtd->read(mtd, off, sizeof(buf), &len, buf) ||
161 + len != sizeof(buf))
162 + continue;
163 +
164 + if (le32_to_cpu(trx->magic) == EDIMAX_PS_HEADER_MAGIC) {
165 + if (mtd->read(mtd, off + EDIMAX_PS_HEADER_LEN,
166 + sizeof(buf), &len, buf) || len != sizeof(buf)) {
167 + continue;
168 + } else {
169 + pr_notice("Found edimax header\n");
170 + }
171 + }
172 +
173 + /* found a TRX header */
174 + if (le32_to_cpu(trx->magic) == TRX_MAGIC)
175 + goto found;
176 + }
177 +
178 + pr_notice("%s: Couldn't find bootloader size\n", mtd->name);
179 + return -1;
180 +
181 + found:
182 + pr_notice("bootloader size: %d\n", off);
183 + return off;
184 +
185 +}
186 +
187 +/*
188 + * Copied from mtdblock.c
189 + *
190 + * Cache stuff...
191 + *
192 + * Since typical flash erasable sectors are much larger than what Linux's
193 + * buffer cache can handle, we must implement read-modify-write on flash
194 + * sectors for each block write requests. To avoid over-erasing flash sectors
195 + * and to speed things up, we locally cache a whole flash sector while it is
196 + * being written to until a different sector is required.
197 + */
198 +
199 +static void erase_callback(struct erase_info *done)
200 +{
201 + wait_queue_head_t *wait_q = (wait_queue_head_t *)done->priv;
202 + wake_up(wait_q);
203 +}
204 +
205 +static int erase_write(struct mtd_info *mtd, unsigned long pos,
206 + int len, const char *buf)
207 +{
208 + struct erase_info erase;
209 + DECLARE_WAITQUEUE(wait, current);
210 + wait_queue_head_t wait_q;
211 + size_t retlen;
212 + int ret;
213 +
214 + /*
215 + * First, let's erase the flash block.
216 + */
217 +
218 + init_waitqueue_head(&wait_q);
219 + erase.mtd = mtd;
220 + erase.callback = erase_callback;
221 + erase.addr = pos;
222 + erase.len = len;
223 + erase.priv = (u_long)&wait_q;
224 +
225 + set_current_state(TASK_INTERRUPTIBLE);
226 + add_wait_queue(&wait_q, &wait);
227 +
228 + ret = mtd->erase(mtd, &erase);
229 + if (ret) {
230 + set_current_state(TASK_RUNNING);
231 + remove_wait_queue(&wait_q, &wait);
232 + pr_warn("erase of region [0x%lx, 0x%x] on \"%s\" failed\n",
233 + pos, len, mtd->name);
234 + return ret;
235 + }
236 +
237 + schedule(); /* Wait for erase to finish. */
238 + remove_wait_queue(&wait_q, &wait);
239 +
240 + /*
241 + * Next, write data to flash.
242 + */
243 +
244 + ret = mtd->write(mtd, pos, len, &retlen, buf);
245 + if (ret)
246 + return ret;
247 + if (retlen != len)
248 + return -EIO;
249 + return 0;
250 +}
251 +
252 +
253 +static int
254 +find_dual_image_off(struct mtd_info *mtd)
255 +{
256 + struct trx_header trx;
257 + int off, blocksize;
258 + size_t len;
259 +
260 + blocksize = mtd->erasesize;
261 + if (blocksize < 0x10000)
262 + blocksize = 0x10000;
263 +
264 + for (off = (128*1024); off < mtd->size; off += blocksize) {
265 + memset(&trx, 0xe5, sizeof(trx));
266 + /*
267 + * Read into buffer
268 + */
269 + if (mtd->read(mtd, off, sizeof(trx), &len, (char *) &trx) ||
270 + len != sizeof(trx))
271 + continue;
272 + /* found last TRX header */
273 + if (le32_to_cpu(trx.magic) == TRX_MAGIC) {
274 + if (le32_to_cpu(trx.flag_version >> 16) == 2) {
275 + pr_notice("dual image TRX header found\n");
276 + return mtd->size / 2;
277 + } else {
278 + return 0;
279 + }
280 + }
281 + }
282 + return 0;
283 +}
284 +
285 +
286 +static int
287 +find_root(struct mtd_info *mtd, struct mtd_partition *part)
288 +{
289 + struct trx_header trx, *trx2;
290 + unsigned char buf[512], *block;
291 + int off, blocksize, trxoff = 0;
292 + u32 i, crc = ~0;
293 + size_t len;
294 + bool edimax = false;
295 +
296 + blocksize = mtd->erasesize;
297 + if (blocksize < 0x10000)
298 + blocksize = 0x10000;
299 +
300 + for (off = (128*1024); off < mtd->size; off += blocksize) {
301 + memset(&trx, 0xe5, sizeof(trx));
302 +
303 + /*
304 + * Read into buffer
305 + */
306 + if (mtd->read(mtd, off, sizeof(trx), &len, (char *) &trx) ||
307 + len != sizeof(trx))
308 + continue;
309 +
310 + /* found an edimax header */
311 + if (le32_to_cpu(trx.magic) == EDIMAX_PS_HEADER_MAGIC) {
312 + /* read the correct trx header */
313 + if (mtd->read(mtd, off + EDIMAX_PS_HEADER_LEN,
314 + sizeof(trx), &len, (char *) &trx) ||
315 + len != sizeof(trx)) {
316 + continue;
317 + } else {
318 + pr_notice("Found an edimax ps header\n");
319 + edimax = true;
320 + }
321 + }
322 +
323 + /* found a TRX header */
324 + if (le32_to_cpu(trx.magic) == TRX_MAGIC) {
325 + part->offset = le32_to_cpu(trx.offsets[2]) ? :
326 + le32_to_cpu(trx.offsets[1]);
327 + part->size = le32_to_cpu(trx.len);
328 +
329 + part->size -= part->offset;
330 + part->offset += off;
331 + if (edimax) {
332 + off += EDIMAX_PS_HEADER_LEN;
333 + trxoff = EDIMAX_PS_HEADER_LEN;
334 + }
335 +
336 + goto found;
337 + }
338 + }
339 +
340 + pr_warn("%s: Couldn't find root filesystem\n",
341 + mtd->name);
342 + return -1;
343 +
344 + found:
345 + pr_notice("TRX offset : %x\n", trxoff);
346 + if (part->size == 0)
347 + return 0;
348 +
349 + if (mtd->read(mtd, part->offset, sizeof(buf), &len, buf) || len != sizeof(buf))
350 + return 0;
351 +
352 + /* Move the fs outside of the trx */
353 + part->size = 0;
354 +
355 + if (trx.len != part->offset + part->size - off) {
356 + /* Update the trx offsets and length */
357 + trx.len = part->offset + part->size - off;
358 +
359 + /* Update the trx crc32 */
360 + for (i = (u32) &(((struct trx_header *)NULL)->flag_version); i <= trx.len; i += sizeof(buf)) {
361 + if (mtd->read(mtd, off + i, sizeof(buf), &len, buf) || len != sizeof(buf))
362 + return 0;
363 + crc = crc32_le(crc, buf, min(sizeof(buf), trx.len - i));
364 + }
365 + trx.crc32 = crc;
366 +
367 + /* read first eraseblock from the trx */
368 + block = kmalloc(mtd->erasesize, GFP_KERNEL);
369 + trx2 = (struct trx_header *) block;
370 + if (mtd->read(mtd, off - trxoff, mtd->erasesize, &len, block) || len != mtd->erasesize) {
371 + pr_err("Error accessing the first trx eraseblock\n");
372 + return 0;
373 + }
374 +
375 + pr_notice("Updating TRX offsets and length:\n");
376 + pr_notice("old trx = [0x%08x, 0x%08x, 0x%08x], len=0x%08x crc32=0x%08x\n", trx2->offsets[0], trx2->offsets[1], trx2->offsets[2], trx2->len, trx2->crc32);
377 + pr_notice("new trx = [0x%08x, 0x%08x, 0x%08x], len=0x%08x crc32=0x%08x\n", trx.offsets[0], trx.offsets[1], trx.offsets[2], trx.len, trx.crc32);
378 +
379 + /* Write updated trx header to the flash */
380 + memcpy(block + trxoff, &trx, sizeof(trx));
381 + if (mtd->unlock)
382 + mtd->unlock(mtd, off - trxoff, mtd->erasesize);
383 + erase_write(mtd, off - trxoff, mtd->erasesize, block);
384 + if (mtd->sync)
385 + mtd->sync(mtd);
386 + kfree(block);
387 + pr_notice("Done\n");
388 + }
389 +
390 + return part->size;
391 +}
392 +
393 +static int get_router(void)
394 +{
395 + char buf[20];
396 + u32 boardnum = 0;
397 + u16 boardtype = 0;
398 + u16 boardrev = 0;
399 + u32 boardflags = 0;
400 + u16 sdram_init = 0;
401 + u16 cardbus = 0;
402 + u16 strev = 0;
403 +
404 + if (nvram_getenv("boardnum", buf, sizeof(buf)) >= 0)
405 + boardnum = simple_strtoul(buf, NULL, 0);
406 + if (nvram_getenv("boardtype", buf, sizeof(buf)) >= 0)
407 + boardtype = simple_strtoul(buf, NULL, 0);
408 + if (nvram_getenv("boardrev", buf, sizeof(buf)) >= 0)
409 + boardrev = simple_strtoul(buf, NULL, 0);
410 + if (nvram_getenv("boardflags", buf, sizeof(buf)) >= 0)
411 + boardflags = simple_strtoul(buf, NULL, 0);
412 + if (nvram_getenv("sdram_init", buf, sizeof(buf)) >= 0)
413 + sdram_init = simple_strtoul(buf, NULL, 0);
414 + if (nvram_getenv("cardbus", buf, sizeof(buf)) >= 0)
415 + cardbus = simple_strtoul(buf, NULL, 0);
416 + if (nvram_getenv("st_rev", buf, sizeof(buf)) >= 0)
417 + strev = simple_strtoul(buf, NULL, 0);
418 +
419 + if ((boardnum == 8 || boardnum == 01)
420 + && boardtype == 0x0472 && cardbus == 1) {
421 + /* Netgear WNR834B, Netgear WNR834Bv2 */
422 + return ROUTER_NETGEAR_WNR834B;
423 + }
424 +
425 + if (boardnum == 01 && boardtype == 0x0472 && boardrev == 0x23) {
426 + /* Netgear WNDR-3300 */
427 + return ROUTER_NETGEAR_WNDR3300;
428 + }
429 +
430 + if ((boardnum == 83258 || boardnum == 01)
431 + && boardtype == 0x048e
432 + && (boardrev == 0x11 || boardrev == 0x10)
433 + && boardflags == 0x750
434 + && sdram_init == 0x000A) {
435 + /* Netgear WGR614v8/L/WW 16MB ram, cfe v1.3 or v1.5 */
436 + return ROUTER_NETGEAR_WGR614L;
437 + }
438 +
439 + if ((boardnum == 1 || boardnum == 3500)
440 + && boardtype == 0x04CF
441 + && (boardrev == 0x1213 || boardrev == 02)) {
442 + /* Netgear WNR3500v2/U/L */
443 + return ROUTER_NETGEAR_WNR3500L;
444 + }
445 +
446 + if (boardtype == 0x042f
447 + && boardrev == 0x10
448 + && boardflags == 0
449 + && strev == 0x11) {
450 + /* Simpletech Simpleshare */
451 + return ROUTER_SIMPLETECH_SIMPLESHARE;
452 + }
453 +
454 + return 0;
455 +}
456 +
457 +static int parse_bcm47xx_partitions(struct mtd_info *mtd,
458 + struct mtd_partition **pparts,
459 +// struct mtd_part_parser_data *data)
460 + unsigned long data)
461 +{
462 + int cfe_size;
463 + int dual_image_offset = 0;
464 + /* e.g Netgear 0x003e0000-0x003f0000 : "board_data", we exclude this
465 + * part from our mapping to prevent overwriting len/checksum on e.g.
466 + * Netgear WGR614v8/L/WW
467 + */
468 + int custom_data_size = 0;
469 +
470 + cfe_size = find_cfe_size(mtd);
471 + if (cfe_size < 0)
472 + return 0;
473 +
474 + /* boot loader */
475 + bcm47xx_parts[0].offset = 0;
476 + bcm47xx_parts[0].size = cfe_size;
477 +
478 + /* nvram */
479 + if (cfe_size != 384 * 1024) {
480 +
481 + switch (get_router()) {
482 + case ROUTER_NETGEAR_WGR614L:
483 + case ROUTER_NETGEAR_WNR834B:
484 + case ROUTER_NETGEAR_WNDR3300:
485 + case ROUTER_NETGEAR_WNR3500L:
486 + /* Netgear: checksum is @ 0x003AFFF8 for 4M flash or checksum
487 + * is @ 0x007AFFF8 for 8M flash
488 + */
489 + custom_data_size = mtd->erasesize;
490 +
491 + bcm47xx_parts[3].offset = mtd->size - roundup(NVRAM_SPACE, mtd->erasesize);
492 + bcm47xx_parts[3].size = roundup(NVRAM_SPACE, mtd->erasesize);
493 +
494 + /* Place CFE board_data into a partition */
495 + bcm47xx_parts[4].name = "board_data";
496 + bcm47xx_parts[4].offset = bcm47xx_parts[3].offset - custom_data_size;
497 + bcm47xx_parts[4].size = custom_data_size;
498 + break;
499 +
500 + case ROUTER_SIMPLETECH_SIMPLESHARE:
501 + /* Fixup Simpletech Simple share nvram */
502 +
503 + pr_notice("Setting up simpletech nvram\n");
504 + custom_data_size = mtd->erasesize;
505 +
506 + bcm47xx_parts[3].offset = mtd->size - roundup(NVRAM_SPACE, mtd->erasesize) * 2;
507 + bcm47xx_parts[3].size = roundup(NVRAM_SPACE, mtd->erasesize);
508 +
509 + /* Place backup nvram into a partition */
510 + bcm47xx_parts[4].name = "nvram_copy";
511 + bcm47xx_parts[4].offset = mtd->size - roundup(NVRAM_SPACE, mtd->erasesize);
512 + bcm47xx_parts[4].size = roundup(NVRAM_SPACE, mtd->erasesize);
513 + break;
514 +
515 + default:
516 + bcm47xx_parts[3].offset = mtd->size - roundup(NVRAM_SPACE, mtd->erasesize);
517 + bcm47xx_parts[3].size = roundup(NVRAM_SPACE, mtd->erasesize);
518 + }
519 +
520 + } else {
521 + /* nvram (old 128kb config partition on netgear wgt634u) */
522 + bcm47xx_parts[3].offset = bcm47xx_parts[0].size;
523 + bcm47xx_parts[3].size = roundup(NVRAM_SPACE, mtd->erasesize);
524 + }
525 +
526 + /* dual image offset*/
527 + pr_notice("Looking for dual image\n");
528 + dual_image_offset = find_dual_image_off(mtd);
529 + /* linux (kernel and rootfs) */
530 + if (cfe_size != 384 * 1024) {
531 + if (get_router() == ROUTER_SIMPLETECH_SIMPLESHARE) {
532 + bcm47xx_parts[1].offset = bcm47xx_parts[0].size;
533 + bcm47xx_parts[1].size = bcm47xx_parts[4].offset - dual_image_offset -
534 + bcm47xx_parts[1].offset - custom_data_size;
535 + } else {
536 + bcm47xx_parts[1].offset = bcm47xx_parts[0].size;
537 + bcm47xx_parts[1].size = bcm47xx_parts[3].offset - dual_image_offset -
538 + bcm47xx_parts[1].offset - custom_data_size;
539 + }
540 + } else {
541 + /* do not count the elf loader, which is on one block */
542 + bcm47xx_parts[1].offset = bcm47xx_parts[0].size +
543 + bcm47xx_parts[3].size + mtd->erasesize;
544 + bcm47xx_parts[1].size = mtd->size -
545 + bcm47xx_parts[0].size -
546 + (2*bcm47xx_parts[3].size) -
547 + mtd->erasesize - custom_data_size;
548 + }
549 +
550 + /* find and size rootfs */
551 + find_root(mtd, &bcm47xx_parts[2]);
552 + bcm47xx_parts[2].size = mtd->size - dual_image_offset -
553 + bcm47xx_parts[2].offset -
554 + bcm47xx_parts[3].size - custom_data_size;
555 + *pparts = bcm47xx_parts;
556 + return bcm47xx_parts[4].name == NULL ? 4 : 5;
557 +}
558 +
559 +static struct mtd_part_parser bcm47xx_parser = {
560 + .owner = THIS_MODULE,
561 + .parse_fn = parse_bcm47xx_partitions,
562 + .name = "bcm47xx",
563 +};
564 +
565 +static int __init bcm47xx_parser_init(void)
566 +{
567 + return register_mtd_parser(&bcm47xx_parser);
568 +}
569 +
570 +static void __exit bcm47xx_parser_exit(void)
571 +{
572 + deregister_mtd_parser(&bcm47xx_parser);
573 +}
574 +
575 +module_init(bcm47xx_parser_init);
576 +module_exit(bcm47xx_parser_exit);
577 +
578 +MODULE_LICENSE("GPL");
579 +MODULE_DESCRIPTION("Parsing code for flash partitions on bcm47xx SoCs");