📄 dvm2440.c
字号:
/* * $Id: dvm2440.c,v 1.14 2009/04/10 11:14:27 gleixner Exp $ * * Handle mapping of the NOR flash on Cogent EDB7312 boards * * Copyright 2002 SYSGO Real-Time Solutions GmbH * * 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 <linux/module.h>#include <linux/types.h>#include <linux/kernel.h>#include <linux/init.h>#include <asm/io.h>#include <linux/mtd/mtd.h>#include <linux/mtd/map.h>#ifdef CONFIG_MTD_PARTITIONS#include <linux/mtd/partitions.h>#endif#define WINDOW_ADDR 0x00000000 /* physical properties of flash */#define WINDOW_SIZE 0x02000000#define BUSWIDTH 4//#define FLASH_BLOCKSIZE_MAIN 0x20000//#define FLASH_NUMBLOCKS_MAIN 128/* can be "cfi_probe", "jedec_probe", "map_rom", NULL }; */#define PROBETYPES { "cfi_probe", NULL }#define MSG_PREFIX "DVM2440-NOR:" /* prefix for our printk()'s *///#define MTDID "DVM2440-nor" /* for mtdparts= partitioning */static struct mtd_info *mymtd;struct map_info dvm2440nor_map = { .name = "NOR flash on DVM2440", .size = WINDOW_SIZE, .bankwidth = BUSWIDTH, .phys = WINDOW_ADDR,};#ifdef CONFIG_MTD_PARTITIONS/* * MTD partitioning stuff */static struct mtd_partition dvm2440_partitions[] ={ { .name = "bootloader", .size = SZ_512K, .offset = 0 }, { .name = "Kernel", .size = SZ_2M, .offset = SZ_512K }, { .name = "Root FS", .size = 0xA00000, //10M .offset = 0x280000 }, { .name = "App part", .size = 0x1200000, //18M .offset = 0xc80000 }, { .name = "/etc config", .size = 0x180000, //1.5M .offset = 0x1e80000 },};static const char *probes[] = { NULL };//static const char *probes[] = { "RedBoot", "cmdlinepart", NULL };#endifstatic int mtd_parts_nb = 0;static struct mtd_partition *mtd_parts = 0;int __init init_dvm2440nor(void){ static const char *rom_probe_types[] = PROBETYPES; const char **type; const char *part_type = 0; printk(KERN_NOTICE MSG_PREFIX "0x%08x at 0x%08x\n", WINDOW_SIZE, WINDOW_ADDR); dvm2440nor_map.virt = ioremap(WINDOW_ADDR, WINDOW_SIZE); if (!dvm2440nor_map.virt) { printk(MSG_PREFIX "failed to ioremap\n"); return -EIO; } simple_map_init(&dvm2440nor_map); mymtd = 0; type = rom_probe_types; for(; !mymtd && *type; type++) { mymtd = do_map_probe(*type, &dvm2440nor_map); } if (mymtd) { mymtd->owner = THIS_MODULE;#ifdef CONFIG_MTD_PARTITIONS mtd_parts_nb = parse_mtd_partitions(mymtd, probes, &mtd_parts, 0); if (mtd_parts_nb > 0) part_type = "detected"; if (mtd_parts_nb == 0) { mtd_parts = dvm2440_partitions; mtd_parts_nb = ARRAY_SIZE(dvm2440_partitions); part_type = "static"; }#endif add_mtd_device(mymtd); if (mtd_parts_nb == 0) printk(KERN_NOTICE MSG_PREFIX "no partition info available\n"); else { printk(KERN_NOTICE MSG_PREFIX "using %s partition definition\n", part_type); add_mtd_partitions(mymtd, mtd_parts, mtd_parts_nb); } return 0; } iounmap((void *)dvm2440nor_map.virt); return -ENXIO;}static void __exit cleanup_dvm2440nor(void){ if (mymtd) { del_mtd_device(mymtd); map_destroy(mymtd); } if (dvm2440nor_map.virt) { iounmap((void *)dvm2440nor_map.virt); dvm2440nor_map.virt = 0; }}module_init(init_dvm2440nor);module_exit(cleanup_dvm2440nor);MODULE_LICENSE("GPL");MODULE_AUTHOR("tanght <tanght@dvmicro.com.cn>");MODULE_DESCRIPTION("Generic configurable MTD map driver");
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -