diff options
author | Hauke Mehrtens <hauke@hauke-m.de> | 2009-05-27 18:28:07 +0000 |
---|---|---|
committer | Hauke Mehrtens <hauke@hauke-m.de> | 2009-05-27 18:28:07 +0000 |
commit | 4d9d62eadac086d1e1482473bf292c06a3f4ff6e (patch) | |
tree | 4b5e85e4aaebce96869a14714ed47648c80c6979 /target/linux/amazon/files | |
parent | f2fa4d7035a3aeedf7526438cbc4a5a9c0ba4d98 (diff) | |
download | upstream-4d9d62eadac086d1e1482473bf292c06a3f4ff6e.tar.gz upstream-4d9d62eadac086d1e1482473bf292c06a3f4ff6e.tar.bz2 upstream-4d9d62eadac086d1e1482473bf292c06a3f4ff6e.zip |
Detect 16MB flash chips
SVN-Revision: 16120
Diffstat (limited to 'target/linux/amazon/files')
-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; } |