Root/target/linux/rdc/files-2.6.30/arch/x86/mach-rdc321x/boards/bifferboard.c

1/*
2 * Bifferboard RDC321x platform devices
3 *
4 * Copyright (C) 2010 bifferos@yahoo.co.uk
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version 2
9 * of the License, or (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the
18 * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19 * Boston, MA 02110-1301, USA.
20 *
21 */
22
23#include <linux/init.h>
24#include <linux/mtd/physmap.h>
25#include <linux/input.h>
26
27#include <asm/rdc_boards.h>
28
29static int __init parse_bifferboard_partitions(struct mtd_info *master, struct mtd_partition **pparts, unsigned long plat_data)
30{
31    int res;
32    size_t len;
33    struct mtd_partition *rdc_flash_parts;
34    u32 kernel_len;
35    u16 tmp;
36
37    if (master->size == 0x100000)
38        kernel_len = master->size - 0x10000;
39    else {
40        res = master->read(master, 0x4000 + 1036, 2, &len, (char *) &tmp);
41        if (res)
42            return res;
43        kernel_len = tmp * master->erasesize;
44    }
45    
46    rdc_flash_parts = kzalloc(sizeof(struct mtd_partition) * 4, GFP_KERNEL);
47    
48    *pparts = rdc_flash_parts;
49
50    rdc_flash_parts[0].name = "biffboot";
51    rdc_flash_parts[0].offset = master->size - 0x10000;
52    rdc_flash_parts[0].size = 0x10000;
53    rdc_flash_parts[0].mask_flags = MTD_WRITEABLE;
54    rdc_flash_parts[1].name = "firmware";
55    rdc_flash_parts[1].offset = 0;
56    rdc_flash_parts[1].size = rdc_flash_parts[0].offset;
57    rdc_flash_parts[2].name = "kernel";
58    rdc_flash_parts[2].offset = 0x00000000;
59    rdc_flash_parts[2].size = kernel_len;
60    
61    if (master->size == 0x100000)
62        return 2;
63
64    rdc_flash_parts[3].name = "rootfs";
65    rdc_flash_parts[3].offset = MTDPART_OFS_APPEND;
66    rdc_flash_parts[3].size = rdc_flash_parts[1].size - rdc_flash_parts[2].size;
67
68    return 4;
69}
70
71struct mtd_part_parser __initdata bifferboard_parser = {
72    .owner = THIS_MODULE,
73    .parse_fn = parse_bifferboard_partitions,
74    .name = "Bifferboard",
75};
76
77static int __init bifferboard_setup(void)
78{
79    return register_mtd_parser(&bifferboard_parser);
80}
81
82arch_initcall(bifferboard_setup);
83

Archive Download this file



interactive