Linux 2.6.11 下 MTD驱动情景实例分析(2)

                      .size = (0x300000 - 0x40000), /* last 256KB is yamon env */ //这块给自解压                                                         //的压缩内核,最后留了点给booterloader的环境变量,它没有被设备驱动使用,而是由booterloader以自己的方式访问。

                      .offset = MTDPART_OFS_APPEND,

        }

};

如果你增加或者是减少了你的flash空间(通过增加或减少flash芯片)或则你想调整几个分区的大小,你只需要修改这个表就可以了。

 

如果你还有一块NAND区,那么你可能有如下的分区表(au1550nd.c):

const static struct mtd_partition partition_info[] = {

       {

              .name = "NAND FS 0",

             .offset = 0,

             .size = 8*1024*1024

       },

       {

              .name = "NAND FS 1",

              .offset =  MTDPART_OFS_APPEND,

             .size =    MTDPART_SIZ_FULL

       }

};

 

整个alchemy_flash.c就两个函数: alchemy_mtd_init(void)和 alchemy_mtd_cleanup()。

int __init alchemy_mtd_init(void)

{

       struct mtd_partition *parts;

       int nb_parts = 0;

       unsigned long window_addr;

       unsigned long window_size;

      

       /* Default flash buswidth */

       alchemy_map.bankwidth = BOARD_FLASH_WIDTH;

 

       window_addr = 0x20000000 - BOARD_FLASH_SIZE;

       window_size = BOARD_FLASH_SIZE;

#ifdef CONFIG_MIPS_MIRAGE_WHY

       /* Boot ROM flash bank only; no user bank */

       window_addr = 0x1C000000;

       window_size = 0x04000000;

       /* USERFS from 0x1C00 0000 to 0x1FC00000 */

       alchemy_partitions[0].size = 0x03C00000;

#endif

 

       /*

        * Static partition definition selection

        */

       parts = alchemy_partitions;

       nb_parts = NB_OF(alchemy_partitions);

       alchemy_map.size = window_size;

 

       /*

        * Now let's probe for the actual flash.  Do it here since

        * specific machine settings might have been set above.

        */

       printk(KERN_NOTICE BOARD_MAP_NAME ": probing %d-bit flash bus\n",

                     alchemy_map.bankwidth*8);

       alchemy_map.virt = ioremap(window_addr, window_size);

       mymtd = do_map_probe("cfi_probe", &alchemy_map);

       if (!mymtd) {

              iounmap(alchemy_map.virt);

              return -ENXIO;

       }

       mymtd->owner = THIS_MODULE;

 

       add_mtd_partitions(mymtd, parts, nb_parts);

       return 0;

}

 

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/wzwyjx.html