/* * * Handle mapping of the flash on Any ADI Boards * * Author: Leo @ Analog Devices * Copyright: (C) 2005 Analog Devices * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * */ #include #include #include #include #include #include #include #include #include extern int board_flash_start,board_flash_size; unsigned int WINDOW_ADDR, WINDOW_SIZE; /* partition_info gives details on the logical partitions that the split the * single flash device into. If the size if zero we use up to the end of the * device. The below settings works only for 8MB and 16MB flash */ #if CONFIG_SQUASHFS /* Define Flash Partition table for Squash FS */ /* Bootloader and Kernel partition sizes in KBytes */ #define BOOT_SIZE 2*64 /* 2 blocks of 64KBytes each */ #define JFFS2_RW_PART 12*64 /* 8 blocks of 64KBytes each */ #define KERNEL_SIZE 10*64 /* 10 blocks of 64KBytes each */ /* Define default partition information for 8MB and 16MB Flash */ static struct mtd_partition partition_info[]={ { .name = "Ikanos boot partition", .offset = 0, .size = BOOT_SIZE * 1024 }, { .name = "IKANOS JFFS2 RW Partition", .offset = BOOT_SIZE * 1024, .size = JFFS2_RW_PART * 1024 }, { .name = "Ikanos Kernel Partition", .offset = (BOOT_SIZE + JFFS2_RW_PART) * 1024, .size = KERNEL_SIZE * 1024 }, { .name = "Ikanos FileSystem Partition", .offset = (BOOT_SIZE + JFFS2_RW_PART + KERNEL_SIZE) * 1024 } }; #elif CONFIG_JFFS2_FS /* Define Flash Partition table for JFFS2 */ /* Bootloader and Kernel partition sizes in KBytes */ #define BOOT_SIZE 4*64 /* 4 blocks of 64KBytes each */ #define KERNEL_SIZE 16*64 /* 1MB: 16 blocks of 64KBytes each */ /* Define default Flash partition information for 8MB and 16MB Flash */ static struct mtd_partition partition_info[]={ { .name = "Ikanos boot partition", .offset = 0, .size = BOOT_SIZE * 1024 }, { .name = "Ikanos Kernel Partition", .offset = BOOT_SIZE * 1024, .size = KERNEL_SIZE * 1024 }, { .name = "Ikanos FileSystem Partition", .offset = (BOOT_SIZE + KERNEL_SIZE) * 1024 } }; #endif static unsigned int myfs_start = 0; static int __init setfs_start(char *str) { get_option(&str, &myfs_start); return 1; } static struct mtd_info *mymtd; struct map_info mb_map = { .name = "Ikanos flash", .phys = 0, .size = 0, .bankwidth = 2, }; int __init init_mb(void) { u8 num_partitions = 0; u32 tmp; WINDOW_ADDR = board_flash_start & 0x1FFFFFFF; WINDOW_SIZE = board_flash_size; tmp = myfs_start & 0x1FFFFFFF; if(((tmp)<(WINDOW_ADDR+0x40000)) || (tmp>(WINDOW_ADDR+WINDOW_SIZE))) panic("!!! File system start address(myfs_start) setting 0x%x is wrong. \n", myfs_start); mb_map.phys = WINDOW_ADDR; mb_map.size = WINDOW_SIZE; /* * Update Filesystem partition offset and kernel partition size based * on the bootargs (environment variables) set by the user */ #if CONFIG_SQUASHFS partition_info[3].offset = (myfs_start &0x1FFFFFFF) - WINDOW_ADDR; partition_info[2].size = partition_info[3].offset - partition_info[2].offset; num_partitions = 4; #elif CONFIG_JFFS2_FS partition_info[2].offset = (myfs_start &0x1FFFFFFF) - WINDOW_ADDR; partition_info[1].size = partition_info[2].offset - partition_info[1].offset; num_partitions = 3; #endif printk(KERN_NOTICE "On Board flash device: 0x%x at 0x%x\n", WINDOW_SIZE, WINDOW_ADDR); mb_map.virt = ioremap(WINDOW_ADDR, WINDOW_SIZE); if (!mb_map.virt) { printk("Failed to ioremap\n"); return -EIO; } simple_map_init(&mb_map); mymtd = do_map_probe("cfi_probe", &mb_map); if (mymtd) { mymtd->owner = THIS_MODULE; add_mtd_device(mymtd); add_mtd_partitions(mymtd, partition_info, num_partitions); return 0; } iounmap((void *)mb_map.virt); return -ENXIO; } static void __exit cleanup_mb(void) { if (mymtd) { del_mtd_device(mymtd); map_destroy(mymtd); } if (mb_map.virt) { iounmap((void *)mb_map.virt); mb_map.virt = 0; } } module_init(init_mb); module_exit(cleanup_mb); __setup("myfs_start=", setfs_start); MODULE_AUTHOR("Leo @ Analog Devices"); MODULE_DESCRIPTION("MTD map driver Ikanos Fusiv vx180 board"); MODULE_LICENSE("GPL");