关于Intel TE28F320C flash MTD驱动的问题!

sdzbbz 2008-08-25 09:58:15
各位前辈,我用的是MPC850嵌入式Linux,flash用的是Intel TE28F320C,想做MTD驱动,已经从网上下载了相关的代码,可是系统启动的时候就是检测不到flash,不知道还有哪里设置的不合适呢?我已经从内核中都设置好了有关CFI和MTD的选项,我的intel_flash.c如下:
/*
* Normal mappings of flash chips on at91rm9200 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 0x40000000L //基地址,flash位于片选0
#define WINDOW_SIZE 0x400000L //flash大小 4M
#define BUSWIDTH 1 //擦写块的大小,64k

static struct mtd_info *pmp_mtd;

__u8 intel_read8(struct map_info *map, unsigned long ofs)
{
return readb(map->map_priv_1 + ofs);
}

__u16 intel_read16(struct map_info *map, unsigned long ofs)
{
return readw(map->map_priv_1 + ofs);
}

__u32 intel_read32(struct map_info *map, unsigned long ofs)
{
return readl(map->map_priv_1 + ofs);
}

void intel_copy_from(struct map_info *map, void *to, unsigned long from, ssize_t len)
{
memcpy(to, (void *)(map->map_priv_1 + from), len);
}

void intel_write8(struct map_info *map, __u8 d, unsigned long adr)
{
writeb(d, map->map_priv_1 + adr);
}

void intel_write16(struct map_info *map, __u16 d, unsigned long adr)
{
writew(d, map->map_priv_1 + adr);
}

void intel_write32(struct map_info *map, __u32 d, unsigned long adr)
{
writel(d, map->map_priv_1 + adr);
}

void intel_copy_to(struct map_info *map, unsigned long to, const void *from, ssize_t len)
{
memcpy((void *)(map->map_priv_1 + to), from, len);
}

struct map_info intel_map = {
name: "Intel flash device",
size: WINDOW_SIZE,
buswidth: BUSWIDTH,
read8: intel_read8,
read16: intel_read16,
read32: intel_read32,
copy_from: intel_copy_from,
write8: intel_write8,
write16: intel_write16,
write32: intel_write32,
copy_to: intel_copy_to,

map_priv_1: WINDOW_ADDR,
map_priv_2: -1,
};

//以下是分区的内容,当然要根据你自己的需要确定了
static struct mtd_partition intel_partitions[] = {
{
name: "reserved for bootloader",
size: 0x020000, //u-boot空间,128k
offset: 0x0, //偏移为0
mask_flags: MTD_WRITEABLE,
},
{
name: "reserved for kernel",
size: 0x0090000, //kernel,576k
offset: 0x0b0000, //偏移为128k
mask_flags: MTD_WRITEABLE,
},
{
name: "reserved for ramdisk",
size: 0x200000, //ramdisk,2M
offset: 0x2b0000, //偏移为2.6M
mask_flags: MTD_WRITEABLE,

},
{
name: "jffs2",
size: 0x100000, //jffs分区,1M
offset: 0x3b0000, //偏移为3.6M
}
};

int __init init_flash(void)
{
printk(KERN_NOTICE "Intel te28f320 flash device: %x at %x\n", WINDOW_SIZE, WINDOW_ADDR);
intel_map.map_priv_1 = (unsigned long)ioremap(WINDOW_ADDR, WINDOW_SIZE);

if (!intel_map.map_priv_1) {
printk("Failed to ioremap/n");
return -EIO;
}

pmp_mtd = do_map_probe("jedec_probe", &intel_map);
if (!pmp_mtd) {
pmp_mtd = do_map_probe("cfi_probe", &intel_map);
}

if (pmp_mtd) {
pmp_mtd->module = THIS_MODULE;
pmp_mtd->erasesize = 0x10000;
return add_mtd_partitions(pmp_mtd, intel_partitions, sizeof(intel_partitions) / sizeof(struct mtd_partition));
}

iounmap((void *)intel_map.map_priv_1);

return -ENXIO;
}

static void __exit cleanup_flash(void)
{
if (pmp_mtd) {
del_mtd_partitions(pmp_mtd);
map_destroy(pmp_mtd);
}

if (intel_map.map_priv_1) {
iounmap((void *)intel_map.map_priv_1);
intel_map.map_priv_1 = 0;
}
}

module_init(init_flash);
module_exit(cleanup_flash);


系统启动信息里总是如下:
…………
FFS2 version 2.1. (C) 2001 Red Hat, Inc., designed by Axis Communications AB.
loop: loaded (max 8 devices)
Serial driver version 5.05a (2001-03-20) with no serial options enabled
PPP generic driver version 2.4.1
physmap flash device: 400000 at 40000000
mtd: Giving out device 0 to Physically mapped flash
Intel tef320c3 flash device: 400000 at 40000000
JEDEC: Found no Intel flash device device at location zero
CFI: Found no Intel flash device device at location zero
NET4: Linux TCP/IP 1.0 for NET4.0
IP Protocols: ICMP, UDP, TCP, IGMP
IP: routing cache hash table of 512 buckets, 4Kbytes
TCP: Hash tables configured (established 2048 bind 2048)
…………
请问我还需要修改mtd/chips/cfi_probe.c吗?
...全文
247 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
cuiwei598 2008-10-14
  • 打赏
  • 举报
回复
#define BUSWIDTH 2 //16bit 总线宽度

21,597

社区成员

发帖
与我相关
我的任务
社区描述
硬件/嵌入开发 驱动开发/核心开发
社区管理员
  • 驱动开发/核心开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧