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