Linux下norflash驱动编写方法
来源:互联网 发布:淘宝团队 编辑:程序博客网 时间:2024/05/16 15:57
Linux下norflash驱动编写步骤
1. 分配map_info结构体
2. 设置: 物理基地址(phys), 大小(size), 位宽(bankwidth), 虚拟基地址(virt)
3. 使用: 调用NOR FLASH协议层提供的函数来识别
4. add_mtd_partitions
如:
#include <linux/module.h>
#include <linux/types.h>
#include <linux/kernel.h>
#include <linux/init.h>
#include <linux/slab.h>
#include <linux/device.h>
#include <linux/platform_device.h>
#include <linux/mtd/mtd.h>
#include <linux/mtd/map.h>
#include <linux/mtd/partitions.h>
#include <linux/mtd/physmap.h>
#include <linux/mtd/concat.h>
#include <linux/io.h>
static struct map_info *nor_map;
static struct mtd_info *nor_mtd;
static struct mtd_partition nor_parts[]={
[0] = {
.name = "bootloader_nor",
.size = 0x00040000,
.offset = 0,
},
[1] = {
.name = "root_nor",
.offset = MTDPART_OFS_APPEND,
.size = MTDPART_SIZ_FULL,
}
};
static int norflash_driver_init()
{
nor_map=kzalloc(sizeof(struct map_info), GFP_KERNEL);
nor_map->name="nor_drv";
nor_map->size=0x1000000;
nor_map->phys=0;
nor_map->bankwidth=2;
nor_map->virt=ioremap(nor_map->phys, nor_map->size);
simple_map_init(s3c_nor_map);
printk("use cfi_probe\n");
nor_mtd=do_map_probe("cfi_probe", s3c_nor_map);
if (!nor_mtd)
{
printk("use jedec_probe\n");
nor_mtd=do_map_probe("jedec_probe", s3c_nor_map);
}
if (!nor_mtd)
{
iounmap(s3c_nor_map->virt);
kfree(s3c_nor_map);
return -EIO;
}
nor_mtd->owner=THIS_MODULE;
add_mtd_partitions(nor_mtd, nor_parts, 2);
return 0;
}
static void norflash_driver_exit()
{
del_mtd_partitions(nor_mtd);
map_destroy(nor_mtd);
iounmap(nor_map->virt);
kzfree(nor_map);
}
module_init(norflash_driver_init);
module_exit(norflash_driver_exit);
MODULE_LICENSE("GPL");
- Linux下norflash驱动编写方法
- norflash驱动编写
- norflash驱动编写
- norflash驱动编写
- linux-2.6.32 norflash 驱动编写 "probe fail"错误解决之道
- linux NorFlash 驱动详解
- linux下usb驱动编写
- Linux下USB驱动编写
- linux下编写RTC驱动
- u-boot下spi norflash驱动大杂绘
- Norflash 驱动
- 如何编写linux下nand flash驱动
- 如何编写linux下nand flash驱动
- 如何编写linux下nand flash驱动
- 如何编写linux下nand flash驱动
- 编写Linux网卡设备驱动(下)
- 编写Linux网卡设备驱动(下) .
- 如何编写linux下nand flash驱动
- KMP muban
- kmp算法之next数组
- OCP-1Z0-052-V8.02-10题
- 摩登年代(魔力一点点)】【高清1280版HD-RMVB.国语中英双字】【2013最新徐峥喜剧大片
- 学习笔记之javaweb基础:JSP的HelloWorld及其运行原理
- Linux下norflash驱动编写方法
- Java序列化和克隆--对象深度拷贝
- 二分搜索的时间复杂度O(logN)如何得到
- [OGRE]基础教程来三发:来谈一谈摄像机吧
- Java从零单排Round2----Java概述
- VS2010一键配置cocos2d-x开发,帅呆了
- windows8.1 体验还不错
- Linux内核分析 - 网络[十三]:校验和 .
- AMSR-E数据下载和处理