export skb_attach symbol (#887)
[openwrt.git] / target / linux / brcm63xx-2.6 / patches / 040-bcm963xx_flashmap.patch
1 diff -urN linux-2.6.17/drivers/mtd/maps/bcm963xx-flash.c linux-2.6.17-brcm63xx/drivers/mtd/maps/bcm963xx-flash.c
2 --- linux-2.6.17/drivers/mtd/maps/bcm963xx-flash.c 1970-01-01 01:00:00.000000000 +0100
3 +++ linux-2.6.17-brcm63xx/drivers/mtd/maps/bcm963xx-flash.c 2006-08-30 13:03:16.000000000 +0200
4 @@ -0,0 +1,135 @@
5 +/*
6 + * $Id$
7 + * Copyright (C) 2006 Florian Fainelli
8 + * Copyright (C) $Date$ $Author$
9 + *
10 + * This program is free software; you can redistribute it and/or modify
11 + * it under the terms of the GNU General Public License as published by
12 + * the Free Software Foundation; either version 2 of the License, or
13 + * (at your option) any later version.
14 + *
15 + * This program is distributed in the hope that it will be useful,
16 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 + * GNU General Public License for more details.
19 + *
20 + * You should have received a copy of the GNU General Public License
21 + * along with this program; if not, write to the Free Software
22 + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
23 + */
24 +
25 +/* This is the BCM963xx flash map driver, in its actual state it only supports BCM96348 devices
26 + * this driver is able to manage both bootloader we found on these boards : CFE and RedBoot
27 + *
28 + * RedBoot :
29 + * - this bootloader allows us to parse partitions and therefore deduce the MTD partition table
30 + *
31 + * CFE :
32 + * - we have to use a "physically mapped flash" defined bellow
33 + *
34 + */
35 +
36 +#include <asm/io.h>
37 +#include <linux/init.h>
38 +#include <linux/mtd/map.h>
39 +#include <linux/mtd/mtd.h>
40 +#include <linux/mtd/partitions.h>
41 +#include <board.h>
42 +
43 +#define WINDOW_ADDR 0x1e400000 /* Real address of the flash */
44 +#define WINDOW_SIZE 0x800000 /* Size of flash */
45 +#define BUSWIDTH 2 /* Buswidth */
46 +#define EXTENDED_SIZE 0xBE400000 /* Extended flash addresse */
47 +
48 +extern int boot_loader_type; /* For RedBoot / CFE detection */
49 +extern int parse_redboot_partitions(struct mtd_info *master, struct mtd_partition **pparts, unsigned long fis_origin);
50 +static struct mtd_partition *parsed_parts;
51 +
52 +static void __exit bcm963xx_mtd_cleanup(void);
53 +
54 +static struct mtd_info *bcm963xx_mtd_info;
55 +
56 +static struct map_info bcm963xx_map = {
57 + .name = "bcm963xx",
58 + .size = WINDOW_SIZE,
59 + .bankwidth = BUSWIDTH,
60 + .phys = WINDOW_ADDR,
61 +};
62 +
63 +static struct mtd_partition bcm963xx_parts[] = {
64 + { name: "bootloader", size: 0, offset: 0, mask_flags: MTD_WRITEABLE },
65 + { name: "rootfs", size: 0, offset: 0},
66 + { name: "jffs2", size: 5 * 0x10000, offset: 57*0x10000}
67 +};
68 +
69 +static int bcm963xx_parts_size = sizeof(bcm963xx_parts) / sizeof(bcm963xx_parts[0]);
70 +
71 +static int __init bcm963xx_mtd_init(void)
72 +{
73 + printk("bcm963xx: 0x%08x at 0x%08x\n", WINDOW_SIZE, WINDOW_ADDR);
74 + bcm963xx_map.virt = ioremap(WINDOW_ADDR, WINDOW_SIZE);
75 +
76 + if (!bcm963xx_map.virt) {
77 + printk("bcm963xx: Failed to ioremap\n");
78 + return -EIO;
79 + }
80 +
81 + simple_map_init(&bcm963xx_map);
82 +
83 + bcm963xx_mtd_info = do_map_probe("cfi_probe", &bcm963xx_map);
84 +
85 + if (bcm963xx_mtd_info) {
86 + bcm963xx_mtd_info->owner = THIS_MODULE;
87 +
88 + if (boot_loader_type == BOOT_CFE)
89 + {
90 + add_mtd_device(bcm963xx_mtd_info);
91 + add_mtd_partitions(bcm963xx_mtd_info, bcm963xx_parts, bcm963xx_parts_size);
92 + return 0;
93 + }
94 + else
95 + {
96 + int parsed_nr_parts = 0;
97 + char * part_type;
98 +
99 + if (bcm963xx_mtd_info->size > 0x00400000) {
100 + printk("Support for extended flash memory size : 0x%08X ; ONLY 64MBIT SUPPORT\n", bcm963xx_mtd_info->size);
101 + bcm963xx_map.virt = (unsigned long)(EXTENDED_SIZE);
102 + }
103 +
104 +#ifdef CONFIG_MTD_REDBOOT_PARTS
105 + if (parsed_nr_parts == 0) {
106 + int ret = parse_redboot_partitions(bcm963xx_mtd_info, &parsed_parts, 0);
107 + if (ret > 0) {
108 + part_type = "RedBoot";
109 + parsed_nr_parts = ret;
110 + }
111 + }
112 +#endif
113 + add_mtd_partitions(bcm963xx_mtd_info, parsed_parts, parsed_nr_parts);
114 +
115 + return 0;
116 + }
117 + }
118 + iounmap(bcm963xx_map.virt);
119 + return -ENXIO;
120 +}
121 +
122 +static void __exit bcm963xx_mtd_cleanup(void)
123 +{
124 + if (bcm963xx_mtd_info) {
125 + del_mtd_partitions(bcm963xx_mtd_info);
126 + map_destroy(bcm963xx_mtd_info);
127 + }
128 +
129 + if (bcm963xx_map.virt) {
130 + iounmap(bcm963xx_map.virt);
131 + bcm963xx_map.virt = 0;
132 + }
133 +}
134 +
135 +module_init(bcm963xx_mtd_init);
136 +module_exit(bcm963xx_mtd_cleanup);
137 +
138 +MODULE_LICENSE("GPL");
139 +MODULE_AUTHOR("Florian Fainelli <florian@openwrt.org>");
140 diff -urN linux-2.6.17/drivers/mtd/maps/Kconfig linux-2.6.17-brcm63xx/drivers/mtd/maps/Kconfig
141 --- linux-2.6.17/drivers/mtd/maps/Kconfig 2006-06-18 03:49:35.000000000 +0200
142 +++ linux-2.6.17-brcm63xx/drivers/mtd/maps/Kconfig 2006-08-30 13:03:06.000000000 +0200
143 @@ -224,6 +224,13 @@
144 Flash memory access on 4G Systems MTX-1 Board. If you have one of
145 these boards and would like to use the flash chips on it, say 'Y'.
146
147 +config MTD_BCM963XX
148 + tristate "BCM963xx Flash device"
149 + depends on MIPS && MIPS_BRCM
150 + help
151 + Flash memory access on BCM963xx boards. Currently only works with
152 + RedBoot, CFE support coming soon.
153 +
154 config MTD_DILNETPC
155 tristate "CFI Flash device mapped on DIL/Net PC"
156 depends on X86 && MTD_CONCAT && MTD_PARTITIONS && MTD_CFI_INTELEXT
157 diff -urN linux-2.6.17/drivers/mtd/maps/Makefile linux-2.6.17-brcm63xx/drivers/mtd/maps/Makefile
158 --- linux-2.6.17/drivers/mtd/maps/Makefile 2006-06-18 03:49:35.000000000 +0200
159 +++ linux-2.6.17-brcm63xx/drivers/mtd/maps/Makefile 2006-08-30 13:03:06.000000000 +0200
160 @@ -71,3 +71,4 @@
161 obj-$(CONFIG_MTD_OMAP_NOR) += omap_nor.o
162 obj-$(CONFIG_MTD_MTX1) += mtx-1_flash.o
163 obj-$(CONFIG_MTD_TQM834x) += tqm834x.o
164 +obj-$(CONFIG_MTD_BCM963XX) += bcm963xx-flash.o
165 diff -urN linux-2.6.17/drivers/mtd/redboot.c linux-2.6.17-brcm63xx/drivers/mtd/redboot.c
166 --- linux-2.6.17/drivers/mtd/redboot.c 2006-06-18 03:49:35.000000000 +0200
167 +++ linux-2.6.17-brcm63xx/drivers/mtd/redboot.c 2006-08-30 13:03:06.000000000 +0200
168 @@ -39,7 +39,7 @@
169 return 1;
170 }
171
172 -static int parse_redboot_partitions(struct mtd_info *master,
173 +int parse_redboot_partitions(struct mtd_info *master,
174 struct mtd_partition **pparts,
175 unsigned long fis_origin)
176 {
177 @@ -120,11 +120,19 @@
178 goto out;
179 }
180
181 + if (!fis_origin) {
182 + for (i = 0; i < numslots; i++) {
183 + if (!strncmp(buf[i].name, "RedBoot", 8)) {
184 + fis_origin = (buf[i].flash_base & (master->size << 1) - 1);
185 + }
186 + }
187 + }
188 +
189 for (i = 0; i < numslots; i++) {
190 struct fis_list *new_fl, **prev;
191
192 if (buf[i].name[0] == 0xff)
193 - continue;
194 + break;
195 if (!redboot_checksum(&buf[i]))
196 break;
197
198 @@ -135,11 +143,10 @@
199 goto out;
200 }
201 new_fl->img = &buf[i];
202 - if (fis_origin) {
203 - buf[i].flash_base -= fis_origin;
204 - } else {
205 - buf[i].flash_base &= master->size-1;
206 - }
207 + if (fis_origin) {
208 + buf[i].flash_base -= fis_origin;
209 + }
210 + buf[i].flash_base &= (master->size << 1) - 1;
211
212 /* I'm sure the JFFS2 code has done me permanent damage.
213 * I now think the following is _normal_
This page took 0.072015 seconds and 5 git commands to generate.