aboutsummaryrefslogtreecommitdiffstats
path: root/target/linux/ar7/patches-3.6/920-ar7part.patch
diff options
context:
space:
mode:
authorFlorian Fainelli <florian@openwrt.org>2012-11-11 18:41:09 +0000
committerFlorian Fainelli <florian@openwrt.org>2012-11-11 18:41:09 +0000
commitdbaa47e43b889f789c9a7d7801820ee88b55103c (patch)
tree7e70f06b761a1abdb0d07527569d68020208e225 /target/linux/ar7/patches-3.6/920-ar7part.patch
parent30b73257e7ace3621b497884c90fc0eb6ec4c6fe (diff)
downloadupstream-dbaa47e43b889f789c9a7d7801820ee88b55103c.tar.gz
upstream-dbaa47e43b889f789c9a7d7801820ee88b55103c.tar.bz2
upstream-dbaa47e43b889f789c9a7d7801820ee88b55103c.zip
[ar7] add support for Linux 3.6
git-svn-id: svn://svn.openwrt.org/openwrt/trunk@34154 3c298f89-4303-0410-b956-a3cf2f4a3e73
Diffstat (limited to 'target/linux/ar7/patches-3.6/920-ar7part.patch')
-rw-r--r--target/linux/ar7/patches-3.6/920-ar7part.patch118
1 files changed, 118 insertions, 0 deletions
diff --git a/target/linux/ar7/patches-3.6/920-ar7part.patch b/target/linux/ar7/patches-3.6/920-ar7part.patch
new file mode 100644
index 0000000000..cbd7f2639c
--- /dev/null
+++ b/target/linux/ar7/patches-3.6/920-ar7part.patch
@@ -0,0 +1,118 @@
+--- a/drivers/mtd/ar7part.c
++++ b/drivers/mtd/ar7part.c
+@@ -29,11 +29,14 @@
+ #include <linux/magic.h>
+ #include <linux/module.h>
+
++#include <asm/mach-ar7/prom.h>
++
+ #define AR7_PARTS 4
+ #define ROOT_OFFSET 0xe0000
+
+ #define LOADER_MAGIC1 le32_to_cpu(0xfeedfa42)
+ #define LOADER_MAGIC2 le32_to_cpu(0xfeed1281)
++#define LOADER_MAGIC3 le32_to_cpu(0x434d4d4c)
+
+ #ifndef SQUASHFS_MAGIC
+ #define SQUASHFS_MAGIC 0x73717368
+@@ -45,12 +48,16 @@ struct ar7_bin_rec {
+ unsigned int address;
+ };
+
++int create_titan_partitions(struct mtd_info *master,
++ struct mtd_partition **pparts,
++ struct mtd_part_parser_data *data);
++
+ static int create_mtd_partitions(struct mtd_info *master,
+ struct mtd_partition **pparts,
+ struct mtd_part_parser_data *data)
+ {
+ struct ar7_bin_rec header;
+- unsigned int offset;
++ unsigned int offset, mtd_start, mtd_end;
+ size_t len;
+ unsigned int pre_size = master->erasesize, post_size = 0;
+ unsigned int root_offset = ROOT_OFFSET;
+@@ -58,6 +65,16 @@ static int create_mtd_partitions(struct
+ int retries = 10;
+ struct mtd_partition *ar7_parts;
+
++ const char *prom_str = prom_getenv("ProductID");
++ char mtd_name[] = "mtd1";
++ if(prom_str &&
++ (strcmp(prom_str, "CYWL")==0 ||
++ strcmp(prom_str, "CYWM")==0 ||
++ strcmp(prom_str, "CYLM")==0 ||
++ strcmp(prom_str, "CYLL")==0)){
++ return create_titan_partitions(master, pparts, data);
++ }
++
+ ar7_parts = kzalloc(sizeof(*ar7_parts) * AR7_PARTS, GFP_KERNEL);
+ if (!ar7_parts)
+ return -ENOMEM;
+@@ -86,34 +103,39 @@ static int create_mtd_partitions(struct
+
+ pre_size = offset;
+
+- if (!ar7_parts[1].offset) {
+- ar7_parts[1].offset = master->size - master->erasesize;
+- post_size = master->erasesize;
+- }
+-
+ switch (header.checksum) {
+- case LOADER_MAGIC1:
+- while (header.length) {
+- offset += sizeof(header) + header.length;
+- mtd_read(master, offset, sizeof(header), &len,
+- (uint8_t *)&header);
+- }
+- root_offset = offset + sizeof(header) + 4;
+- break;
+ case LOADER_MAGIC2:
++ for (retries = 0; retries <= 9; retries++) {
++ mtd_name[3] = '0' + retries;
++ prom_str = prom_getenv(mtd_name);
++ if (prom_str == NULL)
++ continue;
++ sscanf(prom_str, "%i,%i", &mtd_start, &mtd_end);
++ if (pre_size == (mtd_start & 0x1ffffff)) {
++ ar7_parts[1].offset = mtd_end &= 0x1ffffff;
++ ar7_parts[1].size = post_size = master->size - mtd_end;
++ break;
++ }
++ }
++ case LOADER_MAGIC1:
++ root_offset = (header.checksum == LOADER_MAGIC1) ? 4 : 0;
+ while (header.length) {
+ offset += sizeof(header) + header.length;
+ mtd_read(master, offset, sizeof(header), &len,
+ (uint8_t *)&header);
+ }
+- root_offset = offset + sizeof(header) + 4 + 0xff;
+- root_offset &= ~(uint32_t)0xff;
++ root_offset += offset + sizeof(header);
+ break;
+ default:
+ printk(KERN_WARNING "Unknown magic: %08x\n", header.checksum);
+ break;
+ }
+
++ if (!ar7_parts[1].offset) {
++ post_size = master->erasesize;
++ ar7_parts[1].offset = master->size - post_size;
++ }
++
+ mtd_read(master, root_offset, sizeof(header), &len, (u8 *)&header);
+ if (header.checksum != SQUASHFS_MAGIC) {
+ root_offset += master->erasesize - 1;
+--- a/drivers/mtd/titanpart.c
++++ b/drivers/mtd/titanpart.c
+@@ -149,7 +149,7 @@ static void titan_add_partition(char * e
+ }
+ int create_titan_partitions(struct mtd_info *master,
+ struct mtd_partition **pparts,
+- unsigned long origin)
++ struct mtd_part_parser_data *data)
+ {
+ struct nsp_img_hdr_head hdr;
+ struct nsp_img_hdr_section_info sect_info;