⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mba44b0.c

📁 microwindows移植到S3C44B0的源码
💻 C
字号:
/* *  drivers/mtd/nand/s3c44b0.c * *  nand flash on anji mba-44b0 borad. *   * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * */#include <linux/slab.h>#include <linux/module.h>#include <linux/mtd/mtd.h>#include <linux/mtd/nand.h>#include <linux/mtd/partitions.h>#include <asm/io.h>#include <asm/hardware.h>static struct mtd_info *mba44b0_mtd = NULL;/* * Module stuff *//* * Define partitions for flash device */const static struct mtd_partition partition_info[] = {	{ name: "Kernel Image",	  offset: 0,	  size: 768*1024 },			{ name: "File System",	  offset: 768*1024,	  size: 4*1024*1024 },			{ name: "test",	  offset: 5*1024*1024,	  size: 8*1024*1024 }};#define NUM_PARTITIONS 3/* * Main initialization routine */int __init mba44b0_init (void){	struct nand_chip *this;	/* Allocate memory for MTD device structure and private data */	mba44b0_mtd = kmalloc (sizeof(struct mtd_info) + sizeof (struct nand_chip),				GFP_KERNEL);	if (!mba44b0_mtd) {		printk ("Unable to allocate NAND MTD device structure.\n");		return -ENOMEM;	}	/* Get pointer to private data */	this = (struct nand_chip *) (&mba44b0_mtd[1]);	/* Initialize structures */	memset((char *) mba44b0_mtd, 0, sizeof(struct mtd_info));	memset((char *) this, 0, sizeof(struct nand_chip));	/* Link the private data with the MTD structure */	mba44b0_mtd->priv = this;	/* Set address of NAND IO lines */	this->IO_ADDR = 0x04000000;	this->CTRL_ADDR = &PDATF;	this->CLE = 0x20;	this->ALE = 0x40;	this->NCE = 0x00;	/* Scan to find existence of the device */	if (nand_scan (mba44b0_mtd)) {		kfree (mba44b0_mtd);		return -ENXIO;	}	init_waitqueue_head(&this->wq);	/* Allocate memory for internal data buffer */	this->data_buf = kmalloc (sizeof(u_char) * (mba44b0_mtd->oobblock + mba44b0_mtd->oobsize), GFP_KERNEL);	if (!this->data_buf) {		printk ("Unable to allocate NAND data buffer for SPIA.\n");		kfree (mba44b0_mtd);		return -ENOMEM;	}	/* Register the partitions */	add_mtd_partitions(mba44b0_mtd, partition_info, NUM_PARTITIONS);	/* Return happy */	return 0;}module_init(mba44b0_init);/* * Clean up routine */#ifdef MODULEstatic void __exit mba44b0_cleanup (void){	struct nand_chip *this = (struct nand_chip *) &mba44b0_mtd[1];	/* Unregister the device */	del_mtd_device (mba44b0_mtd);	/* Free internal data buffer */	kfree (this->data_buf);	/* Free the MTD device structure */	kfree (mba44b0_mtd);}module_exit(mba44b0_cleanup);#endifMODULE_LICENSE("GPL");MODULE_AUTHOR("tpu");MODULE_DESCRIPTION("Board-specific glue layer for NAND flash on SPIA board");

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -