[brcm63xx] add support for 2.6.37, patches from KanjiMonster
[openwrt.git] / target / linux / brcm63xx / patches-2.6.37 / 040-bcm963xx_flashmap.patch
1 From b1096781081b328fdac0e14a726ea04c2e9545c7 Mon Sep 17 00:00:00 2001
2 From: Axel Gembe <ago@bastart.eu.org>
3 Date: Mon, 12 May 2008 18:54:09 +0200
4 Subject: [PATCH] bcm963xx: flashmap support
5
6 Signed-off-by: Axel Gembe <ago@bastart.eu.org>
7 ---
8 arch/mips/bcm63xx/boards/board_bcm963xx.c | 19 +---------------
9 drivers/mtd/maps/bcm963xx-flash.c | 34 ++++++++++++++++++++++++----
10 drivers/mtd/redboot.c | 13 ++++++++--
11 3 files changed, 40 insertions(+), 26 deletions(-)
12
13 --- a/arch/mips/bcm63xx/boards/board_bcm963xx.c
14 +++ b/arch/mips/bcm63xx/boards/board_bcm963xx.c
15 @@ -816,20 +816,6 @@ void __init board_setup(void)
16 panic("unexpected CPU for bcm963xx board");
17 }
18
19 -static struct mtd_partition mtd_partitions[] = {
20 - {
21 - .name = "cfe",
22 - .offset = 0x0,
23 - .size = 0x40000,
24 - }
25 -};
26 -
27 -static struct physmap_flash_data flash_data = {
28 - .width = 2,
29 - .nr_parts = ARRAY_SIZE(mtd_partitions),
30 - .parts = mtd_partitions,
31 -};
32 -
33 static struct resource mtd_resources[] = {
34 {
35 .start = 0, /* filled at runtime */
36 @@ -839,12 +825,9 @@ static struct resource mtd_resources[] =
37 };
38
39 static struct platform_device mtd_dev = {
40 - .name = "physmap-flash",
41 + .name = "bcm963xx-flash",
42 .resource = mtd_resources,
43 .num_resources = ARRAY_SIZE(mtd_resources),
44 - .dev = {
45 - .platform_data = &flash_data,
46 - },
47 };
48
49 static struct gpio_led_platform_data bcm63xx_led_data;
50 --- a/drivers/mtd/maps/bcm963xx-flash.c
51 +++ b/drivers/mtd/maps/bcm963xx-flash.c
52 @@ -27,6 +27,8 @@
53 #include <linux/vmalloc.h>
54 #include <linux/platform_device.h>
55 #include <linux/io.h>
56 +#include <linux/magic.h>
57 +#include <linux/jffs2.h>
58
59 #include <asm/mach-bcm63xx/bcm963xx_tag.h>
60
61 @@ -35,6 +37,14 @@
62
63 #define PFX KBUILD_MODNAME ": "
64
65 +struct squashfs_super_block {
66 + __le32 s_magic;
67 + __le32 pad0[9];
68 + __le64 bytes_used;
69 +};
70 +
71 +extern int parse_redboot_partitions(struct mtd_info *master, struct mtd_partition **pparts, unsigned long fis_origin);
72 +
73 static struct mtd_partition *parsed_parts;
74
75 static struct mtd_info *bcm963xx_mtd_info;
76 @@ -56,7 +66,7 @@ static int parse_cfe_partitions(struct m
77 unsigned int rootfsaddr, kerneladdr, spareaddr;
78 unsigned int rootfslen, kernellen, sparelen, totallen;
79 int namelen = 0;
80 - int i;
81 + int i, offset;
82 char *boardid;
83 char *tagversion;
84
85 @@ -84,9 +94,11 @@ static int parse_cfe_partitions(struct m
86
87 kerneladdr = kerneladdr - BCM63XX_EXTENDED_SIZE;
88 rootfsaddr = kerneladdr + kernellen;
89 +
90 + rootfslen = ( ( rootfslen % master->erasesize ) > 0 ? (((rootfslen / master->erasesize) + 1 ) * master->erasesize) : rootfslen);
91 +
92 spareaddr = roundup(totallen, master->erasesize) + master->erasesize;
93 sparelen = master->size - spareaddr - master->erasesize;
94 - rootfslen = spareaddr - rootfsaddr;
95
96 /* Determine number of partitions */
97 namelen = 8;
98 @@ -214,9 +226,21 @@ static int bcm963xx_probe(struct platfor
99 }
100 }
101 } else {
102 - dev_info(&pdev->dev, "unsupported bootloader\n");
103 - err = -ENODEV;
104 - goto err_probe;
105 + printk(KERN_INFO PFX "assuming RedBoot bootloader\n");
106 + if (bcm963xx_mtd_info->size > 0x00400000) {
107 + printk(KERN_INFO PFX "Support for extended flash memory size : 0x%lx ; ONLY 64MBIT SUPPORT\n", bcm963xx_mtd_info->size);
108 + bcm963xx_map.virt = (u32)(BCM63XX_EXTENDED_SIZE);
109 + }
110 +
111 +#ifdef CONFIG_MTD_REDBOOT_PARTS
112 + if (parsed_nr_parts == 0) {
113 + int ret = parse_redboot_partitions(bcm963xx_mtd_info, &parsed_parts, 0);
114 + if (ret > 0) {
115 + part_type = "RedBoot";
116 + parsed_nr_parts = ret;
117 + }
118 + }
119 +#endif
120 }
121
122 return add_mtd_partitions(bcm963xx_mtd_info, parsed_parts,
123 --- a/drivers/mtd/redboot.c
124 +++ b/drivers/mtd/redboot.c
125 @@ -57,7 +57,7 @@ static inline int redboot_checksum(struc
126 return 1;
127 }
128
129 -static int parse_redboot_partitions(struct mtd_info *master,
130 +int parse_redboot_partitions(struct mtd_info *master,
131 struct mtd_partition **pparts,
132 unsigned long fis_origin)
133 {
134 @@ -180,6 +180,14 @@ static int parse_redboot_partitions(stru
135 goto out;
136 }
137
138 + if (!fis_origin) {
139 + for (i = 0; i < numslots; i++) {
140 + if (!strncmp(buf[i].name, "RedBoot", 8)) {
141 + fis_origin = (buf[i].flash_base & (master->size << 1) - 1);
142 + }
143 + }
144 + }
145 +
146 for (i = 0; i < numslots; i++) {
147 struct fis_list *new_fl, **prev;
148
149 @@ -202,9 +210,8 @@ static int parse_redboot_partitions(stru
150 new_fl->img = &buf[i];
151 if (fis_origin) {
152 buf[i].flash_base -= fis_origin;
153 - } else {
154 - buf[i].flash_base &= master->size-1;
155 }
156 + buf[i].flash_base &= (master->size << 1) - 1;
157
158 /* I'm sure the JFFS2 code has done me permanent damage.
159 * I now think the following is _normal_
This page took 0.04612 seconds and 5 git commands to generate.