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 ,然而内存需要初始化,早上信心满满的我到现在崩溃的我....也不知遭受了什么样的蹂躏 ,,还是记下一点学到的知识吧.. 数据手 ...
随机推荐
- selenium高亮显示操作步骤方法
package com.allin.pc;import java.util.List;import org.openqa.selenium.WebElement;import org.openqa.s ...
- 【OOAD】设计模式概述
模式的诞生与定义 模式起源于建筑业而非软件业模式(Pattern)之父——美国加利佛尼亚大学环境结构中心研究所所长Christopher Alexander博士<A Pattern Langua ...
- fifter常见的运用场景
没配置过滤器 package servlet; import java.io.IOException; import javax.servlet.ServletException; import ja ...
- runtime运行机制方法学习
runtime这玩意第一次听说时都不知道是什么,经过了解后才知道它就是oc动态语言的机制,没有它那oc就不能称为动态语言.在之前可能大家对runtime了解都不深,随着编程技能的日益加深和需要,大家开 ...
- hello word
开通微博,用于记录在工作中遇到的点滴问题. 2015/08/31
- 将java源文件制成jar包
很多人都在苦恼,如何将写好的程序代码能在日后随时调用和配置在项目中运行 今天,就让梦逸来给大家分享这个过程 首先,创建好一个文件夹,文件夹名称随意 这个文件夹中是用来存放java源文件( 未编译的 x ...
- 用c语言编写二分查找法
二分法的适用范围为有序数列,这方面很有局限性. #include<stdio.h> //二分查找法 void binary_search(int a[],int start,int mid ...
- Java数据库操作
一.JDBC 1.JDBC Java数据库连接,用于Java程序中实现数据库操作功能,java.sql包中提供了执行SQL语句,访问各种数据库的方法,并为各种不同的数据库提供统一的操作接口及类. 2. ...
- Props属性
大多数组件在创建时就可以使用各种参数来进行定制.用于定制的这些参数就称为props(属性). import React, { Component } from 'react'; import { Ap ...
- 学习di'z地址
Swift学习地址https://numbbbbb.gitbooks.io/-the-swift-programming-language-/content/ http://www.oschina.n ...