Smart210学习记录------nor flash驱动
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驱动的更多相关文章
- Smart210学习记录----nand flash驱动
[详解]如何编写Linux下Nand Flash驱动 :http://www.cnblogs.com/linux-rookie/articles/3016990.html 当读写文件请求到来的时候, ...
- Smart210学习记录-----Linux i2c驱动
一:Linux i2c子系统简介: 1.Linux 的 I2C 体系结构分为 3 个组成部分: (1) I2C 核心. I2C 核心提供了 I2C 总线驱动和设备驱动的注册.注销方法,I2C 通信方法 ...
- Smart210学习记录------linux串口驱动
转自:http://blog.chinaunix.net/xmlrpc.php?r=blog/article&uid=27025492&id=327609 一.核心数据结构 串口驱动有 ...
- Smart210学习记录-------Linux设备驱动结构
cdev结构体 1 struct cdev { 2 struct kobject kobj; /* 内嵌的 kobject 对象 */ 3 struct module *owner; /*所属模块*/ ...
- Smart210学习记录-----SD/MMC/SDIO驱动
转自:http://jingpin.jikexueyuan.com/article/23369.html http://blog.csdn.net/evilcode/article/details/7 ...
- Smart210学习记录-------linux驱动中断
Linux中断 Linux 的中断处理分为两个半部,顶半部处理紧急的硬件操作,底半部处理不紧急的耗时操作.tasklet 和工作队列都是调度中断底半部的良好机制,tasklet 基于软中断实现.内核定 ...
- Smart210学习记录----beep linux字符设备驱动
今天搞定了beep linux字符设备驱动,心里还是很开心的,哈哈...但在完成的过程中却遇到了一个非常棘手的问题,花费了我大量的时间,,,, 还是把问题描述一下吧,好像这个问题很普遍的,网上许多解决 ...
- Smart210学习记录------块设备
转自:http://bbs.chinaunix.net/thread-2017377-1-1.html 本章的目的用尽可能最简单的方法写出一个能用的块设备驱动.所谓的能用,是指我们可以对这个驱动生成的 ...
- Smart210学习记录-------内存初始化
买了Smart210的板子,开始学习中,,,,, 今天看了重定位DRAM ,然而内存需要初始化,早上信心满满的我到现在崩溃的我....也不知遭受了什么样的蹂躏 ,,还是记下一点学到的知识吧.. 数据手 ...
随机推荐
- [问题2015S04] 复旦高等代数 II(14级)每周一题(第五教学周)
[问题2015S04] 设 \(A\) 为 \(n\) 阶方阵, \(C\) 为 \(k\times n\) 矩阵, 且对任意的 \(\lambda\in\mathbb{C}\), \(\begin{ ...
- [问题2014S05] 解答
[问题2014S05] 解答 (本解答由谷嵘同学提供) 首先, 由 \(\mathrm{tr}(AB)=\mathrm{tr}(BA)\) 可得 \(a=0\), 或者由 Cauchy-Binet ...
- 简单方法判断JavaScript对象为null或者属性为空
对已声明但未初始化的和未声明的变量执行typeof,都返回undefined,null表示一个空对象指针,typeof操作会返回object 首先说下null与undefined区别: 对已声明但未初 ...
- python_way ,day25 CMDB_models (数据库设计)
from django.db import models from django.contrib.auth.models import User # Create your models here. ...
- 软件测试--测试Demo
视频地址(第二课时):https://pan.baidu.com/s/1gfLVC2n 软件安装好了! 软件默认的浏览器是火狐. 如果需要IE,chrome,都在前一篇的安装包里有. 测试结果 视频里 ...
- shader函数
Intrinsic Functions (DirectX HLSL) The following table lists the intrinsic functions available in HL ...
- php 对多维数组排序array_multisort
php 对多维数组排序array_multisort 排序顺序标志: SORT_ASC - 按照上升顺序排序 SORT_DESC - 按照下降顺序排序 排序类型标志: SORT_REGULAR - 将 ...
- sentinel搭建redis集群经验总结
一.protected-mode默认情况下,redis node和sentinel的protected-mode都是yes,在搭建集群时,若想从远程连接redis集群,需要将redis node和se ...
- Linux 下安装pip
安装pip 使用脚本安装和升级pip 要安装或升级pip,需要下载 get-pip.py. 地址:https://bootstrap.pypa.io/get-pip.py 然后运行以下命令 (需要管理 ...
- 转<%%>、<%=%>、<%$%>、<%@%>的区别
1. 未定义的命名空间前缀“xsd” 上周在项目开发中遇到这样的一个问题,在一个页面用到了自定义的Picker控件,在IE6.7.8.9以及IE10兼容模式下都没有任何问题,但是一换到IE10时已选择 ...