diff options
author | hauke <hauke@3c298f89-4303-0410-b956-a3cf2f4a3e73> | 2009-05-27 18:28:07 +0000 |
---|---|---|
committer | hauke <hauke@3c298f89-4303-0410-b956-a3cf2f4a3e73> | 2009-05-27 18:28:07 +0000 |
commit | 5d27cef032925e73d67b9f65a783f69c7f43b317 (patch) | |
tree | ac0b784b6b1765c761029ac8f1f83a90038434ff /target/linux/amazon/files/drivers | |
parent | e7b7d5aed1adaf42204c7df45e8b14b0782d9d4e (diff) |
[amazon] Detect 16MB flash chips
git-svn-id: svn://svn.openwrt.org/openwrt/trunk@16120 3c298f89-4303-0410-b956-a3cf2f4a3e73
Diffstat (limited to 'target/linux/amazon/files/drivers')
-rw-r--r-- | target/linux/amazon/files/drivers/mtd/maps/amazon.c | 40 |
1 files changed, 32 insertions, 8 deletions
diff --git a/target/linux/amazon/files/drivers/mtd/maps/amazon.c b/target/linux/amazon/files/drivers/mtd/maps/amazon.c index 3e7dc4f583..8c31141898 100644 --- a/target/linux/amazon/files/drivers/mtd/maps/amazon.c +++ b/target/linux/amazon/files/drivers/mtd/maps/amazon.c @@ -41,7 +41,7 @@ static struct map_info amazon_map = { .name = "AMAZON_FLASH", .bankwidth = 2, - .size = 0x400000, + .size = 0x1000000, }; static map_word amazon_read16(struct map_info * map, unsigned long ofs) @@ -107,18 +107,24 @@ unsigned long flash_start = 0x13000000; unsigned long flash_size = 0x800000; unsigned long uImage_size = 0x10000d; -int find_uImage_size(unsigned long start_offset){ +int find_uImage_size(unsigned long start_offset) +{ + unsigned long magic; unsigned long temp; - - printk("trying to find uImage and its size\n"); + amazon_copy_from(&amazon_map, &magic, start_offset, 4); + if (!(ntohl(magic) == 0x27051956)) { + printk(KERN_INFO "amazon_mtd: invalid magic (0x%08X) of kernel at 0x%08lx \n", ntohl(magic), start_offset); + return 0; + } amazon_copy_from(&amazon_map, &temp, start_offset + 12, 4); - printk("kernel size is %d \n", temp + 0x40); + printk(KERN_INFO "amazon_mtd: kernel size is %ld \n", temp + 0x40); return temp + 0x40; } int __init init_amazon_mtd(void) { int ret = 0; + unsigned long uimage_size; struct mtd_info *mymtd = NULL; struct mtd_partition *parts = NULL; @@ -146,10 +152,28 @@ int __init init_amazon_mtd(void) mymtd->owner = THIS_MODULE; parts = &amazon_partitions[0]; - amazon_partitions[2].offset = UBOOT_SIZE + find_uImage_size(amazon_partitions[1].offset); - amazon_partitions[1].size = mymtd->size - amazon_partitions[1].offset - (2 * mymtd->erasesize); - amazon_partitions[2].size = mymtd->size - amazon_partitions[2].offset - (2 * mymtd->erasesize); + + /* Some Samsung devices are containing a 16 MB flash chip with a bigger U-Boot partition. */ + if(mymtd->size == 0x01000000 && mymtd->erasesize == 0x00020000) { + printk(KERN_INFO "amazon_mtd: Found big flash chip!\n"); + amazon_partitions[0].size = 0x60000; + amazon_partitions[1].offset = 0x60000; + uimage_size = find_uImage_size(amazon_partitions[1].offset); + amazon_partitions[1].size = uimage_size; + amazon_partitions[2].offset = 0x60000 + uimage_size; + amazon_partitions[2].size = mymtd->size - amazon_partitions[2].offset - mymtd->erasesize; + } else { + printk(KERN_INFO "amazon_mtd: Found small flash chip!\n"); + uimage_size = find_uImage_size(amazon_partitions[1].offset); + amazon_partitions[1].size = uimage_size; + amazon_partitions[2].offset = UBOOT_SIZE + uimage_size; + amazon_partitions[2].size = mymtd->size - amazon_partitions[2].offset - (2 * mymtd->erasesize); + } + add_mtd_partitions(mymtd, parts, 3); + + printk(KERN_INFO "amazon_mtd: added %s flash with %dMB\n", + amazon_map.name, mymtd->size >> 20); return 0; } |