nor flash驱动与nand flash驱动的差别不大,只是设置不同的结构体而已,,

nor flash驱动代码:

#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 unsigned char nr_parts = ;
static struct mtd_partition nor_mtd_partition[] = {
[] = {
.name = "bootloader_nor",
.size = 0x00040000,
.offset = ,
},
[] = {
.name = "root_nor",
.offset = MTDPART_OFS_APPEND,
.size = MTDPART_SIZ_FULL,
}
}; static int __init my_nor_flash_init(void)
{
/*分配一个mtd_info结构体*/
int err;
nor_map = kzalloc(sizeof(struct map_info), GFP_KERNEL);
if(nor_map == NULL) {
printk(KERN_ALERT"map_info kzalloc error\n");
return -ENOMEM;
} /*设置: 物理基地址(phys), 大小(size), 位宽(bankwidth), 虚拟基地址(virt)*/
nor_map->name = "nor flash";
nor_map->phys = ;
nor_map->size = 0x100000; //大于真实nor flash的大小
nor_map->bankwidth = ; //16位 nor_map->virt = ioremap(nor_map->phys,nor_map->size);
if (nor_map->virt == NULL) {
printk(KERN_ALERT"Failed to ioremap flash region\n");
err = -EIO;
goto err_out;
} simple_map_init(nor_map); printk(KERN_ALERT"do_map_probe cfi_probe\n");
nor_mtd = do_map_probe("cfi_probe", nor_map);
if(nor_mtd = NULL) {
printk(KERN_ALERT" do_map_probe jedec_probe\n");
nor_mtd = do_map_probe("jedec_probe", nor_map);
} if(!nor_mtd) {
iounmap(nor_map->virt);
kfree(nor_map);
return -EIO;
}
nor_mtd->owner = THIS_MODULE; /*添加分区*/
if(mtd_device_register(nor_mtd, nor_mtd_partition, nr_parts) != ) {
printk(KERN_ALERT" mtd_device_register error\n");
return -EINVAL;
} return ; err_out:
kfree(nor_map);
return err;
} static void __exit my_nor_flash_exit(void)
{
iounmap(nor_map->virt);
kfree(nor_map);
} module_init(my_nor_flash_init);
module_exit(my_nor_flash_exit);
MODULE_LICENSE("GPL");

Smart210学习记录------nor flash驱动的更多相关文章

  1. Smart210学习记录----nand flash驱动

    [详解]如何编写Linux下Nand Flash驱动  :http://www.cnblogs.com/linux-rookie/articles/3016990.html 当读写文件请求到来的时候, ...

  2. Smart210学习记录-----Linux i2c驱动

    一:Linux i2c子系统简介: 1.Linux 的 I2C 体系结构分为 3 个组成部分: (1) I2C 核心. I2C 核心提供了 I2C 总线驱动和设备驱动的注册.注销方法,I2C 通信方法 ...

  3. Smart210学习记录------linux串口驱动

    转自:http://blog.chinaunix.net/xmlrpc.php?r=blog/article&uid=27025492&id=327609 一.核心数据结构 串口驱动有 ...

  4. Smart210学习记录-------Linux设备驱动结构

    cdev结构体 1 struct cdev { 2 struct kobject kobj; /* 内嵌的 kobject 对象 */ 3 struct module *owner; /*所属模块*/ ...

  5. Smart210学习记录-----SD/MMC/SDIO驱动

    转自:http://jingpin.jikexueyuan.com/article/23369.html http://blog.csdn.net/evilcode/article/details/7 ...

  6. Smart210学习记录-------linux驱动中断

    Linux中断 Linux 的中断处理分为两个半部,顶半部处理紧急的硬件操作,底半部处理不紧急的耗时操作.tasklet 和工作队列都是调度中断底半部的良好机制,tasklet 基于软中断实现.内核定 ...

  7. Smart210学习记录----beep linux字符设备驱动

    今天搞定了beep linux字符设备驱动,心里还是很开心的,哈哈...但在完成的过程中却遇到了一个非常棘手的问题,花费了我大量的时间,,,, 还是把问题描述一下吧,好像这个问题很普遍的,网上许多解决 ...

  8. Smart210学习记录------块设备

    转自:http://bbs.chinaunix.net/thread-2017377-1-1.html 本章的目的用尽可能最简单的方法写出一个能用的块设备驱动.所谓的能用,是指我们可以对这个驱动生成的 ...

  9. Smart210学习记录-------内存初始化

    买了Smart210的板子,开始学习中,,,,, 今天看了重定位DRAM ,然而内存需要初始化,早上信心满满的我到现在崩溃的我....也不知遭受了什么样的蹂躏 ,,还是记下一点学到的知识吧.. 数据手 ...

随机推荐

  1. CSS 高级语法 ---- 继承和选择器的分组

    1. 选择器的分组 —————————————————————————   可以对选择器进行分组,被分组的选择器享用共同的声明.   h1,h2,h3,h4,h5,h6 { color: green; ...

  2. Writing Text Files On The Client in Oracle Forms 10g

    Below is the example to write file on client in Oracle Forms 10g with webutil library package.Note:  ...

  3. mysql 增删改查基本语句

    增: insert insert into 表名(字段1,字段2,字段3......字段N) values(值1,值2,值3): 如果不申明插入那些字段,则默认所有字段. 在插入时注意,往哪个表增加, ...

  4. pycharm上运行django服务器端、ip地址访问

    安装Django  下载Django包,解压缩. CMD 进入解压路径下. 执行:python setup.py install 增加环境变量: C:\Python27\Scripts 测试djang ...

  5. redis windows下使用及redis命令

    出自:http://www.cnblogs.com/chenping-987123/archive/2012/01/29/2331079.html Redis 是一个开源,高级的键值对的存储.它经常作 ...

  6. 【数位dp】

    hdu5787 问:L ~ R有多少个数是K-wolf Number?其中,K-wolf Number的定义是这个数在十进制下,任意相邻的K个字符没有相同的. dp[i][j][k]表示有i个空位可填 ...

  7. Java通过jedis操作redis缓存

    package com.wodexiangce.util; import java.util.Set; import redis.clients.jedis.Jedis; /** * redis工具类 ...

  8. AlwaysOn数据同步问题探究

    随着AlwaysOn技术的流行,关于AlwayOn的问题也越来越多,某企业搭建有三副本的AlwaysOn一套,现想修改主节点上某张表的某个数据,看看会出现什么后果,如果结果正常,就同步到其他节点上:如 ...

  9. 【转】 TCP协议中的三次握手和四次挥手(图解)

    建立TCP需要三次握手才能建立,而断开连接则需要四次握手.整个过程如下图所示: 先来看看如何建立连接的. 首先Client端发送连接请求报文,Server段接受连接后回复ACK报文,并为这次连接分配资 ...

  10. c c++怎么判断一个字符串中是否含有汉字

    c c++怎么判断一个字符串中是否含有汉字 (2013-02-05 10:44:23) 转载▼     #include  #include  int main() { char sztext[] = ...