⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 m5272c3.c.4m

📁 linux 下的coldfire cpu的 nor flash 驱动程序
💻 4M
字号:
/* * * Normal mappings of chips in physical memory */#include <linux/module.h>#include <linux/types.h>#include <linux/kernel.h>#include <asm/io.h>#include <linux/mtd/mtd.h>#include <linux/mtd/map.h>#include <linux/mtd/partitions.h>#include <linux/config.h>#define WINDOW_ADDR 0xff800000#define WINDOW_SIZE 0x400000       //4M flash sean #define BUSWIDTH 2static struct mtd_info *mymtd;struct map_info m5272c3_map = {	name: "MCF5272C3 flash device",	phys: WINDOW_ADDR,	size: WINDOW_SIZE,	bankwidth: BUSWIDTH};/* * MTD 'PARTITIONING' STUFF  */#define BOOT_SIZE 0x40000   //256K  bootload reserved#define IMAGE_SIZE 0x340000 //kenerl and romfs#define DATA_SIZE 0x80000   //user space#define NUM_PARTITIONS 3static struct mtd_partition partition_info[] = {		{				name: "boot",				size: BOOT_SIZE,				offset: 0		},        {                name: "image",                size: IMAGE_SIZE,                offset: BOOT_SIZE        },		{                name: "data",                size: DATA_SIZE,                offset: (BOOT_SIZE + IMAGE_SIZE)        }};int __init init_m5272c3(void){	printk(KERN_NOTICE "Motorola M5272C3 flash device: 0x%x at 0x%x\n", WINDOW_SIZE, WINDOW_ADDR);	m5272c3_map.virt = ioremap(WINDOW_ADDR, WINDOW_SIZE);	if (!m5272c3_map.virt) {		printk("Failed to ioremap\n");		return -EIO;	}	simple_map_init(&m5272c3_map);	mymtd = do_map_probe("cfi_probe", &m5272c3_map);	if (mymtd) {		mymtd->owner = THIS_MODULE;		add_mtd_device(mymtd);                add_mtd_partitions(mymtd, partition_info, NUM_PARTITIONS);		return 0;	}	iounmap((void *)m5272c3_map.virt);	return -ENXIO;}static void __exit cleanup_m5272c3(void){	if (mymtd) {		del_mtd_device(mymtd);		map_destroy(mymtd);	}	if (m5272c3_map.virt) {		iounmap((void *)m5272c3_map.virt);		m5272c3_map.virt = 0;	}}module_init(init_m5272c3);module_exit(cleanup_m5272c3);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -