make NAND support compile
This commit is contained in:
parent
cedcb274ae
commit
15a16e5f76
|
@ -4,4 +4,4 @@ obj-$(CONFIG_NAND) += nand_bbt.o
|
|||
obj-$(CONFIG_NAND) += nand.o
|
||||
obj-$(CONFIG_NAND) += nand_ecc.o
|
||||
obj-$(CONFIG_NAND) += nand_ids.o
|
||||
obj-$(CONFIG_NAND) += nand_util.o
|
||||
#obj-$(CONFIG_NAND) += nand_util.o
|
||||
|
|
|
@ -23,20 +23,16 @@
|
|||
|
||||
#include <common.h>
|
||||
#include <nand.h>
|
||||
#include <init.h>
|
||||
#include <xfuncs.h>
|
||||
#include <driver.h>
|
||||
|
||||
#ifndef CFG_NAND_BASE_LIST
|
||||
#define CFG_NAND_BASE_LIST { CFG_NAND_BASE }
|
||||
#endif
|
||||
char *default_nand_name = "huhu";
|
||||
|
||||
int nand_curr_device = -1;
|
||||
nand_info_t nand_info[CFG_MAX_NAND_DEVICE];
|
||||
|
||||
static struct nand_chip nand_chip[CFG_MAX_NAND_DEVICE];
|
||||
static ulong base_address[CFG_MAX_NAND_DEVICE] = CFG_NAND_BASE_LIST;
|
||||
|
||||
static const char default_nand_name[] = "nand";
|
||||
|
||||
extern int board_nand_init(struct nand_chip *nand);
|
||||
static inline int board_nand_init(struct nand_chip *nand)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void nand_init_chip(struct mtd_info *mtd, struct nand_chip *nand,
|
||||
ulong base_addr)
|
||||
|
@ -57,23 +53,38 @@ static void nand_init_chip(struct mtd_info *mtd, struct nand_chip *nand,
|
|||
|
||||
}
|
||||
|
||||
void nand_init(void)
|
||||
{
|
||||
int i;
|
||||
unsigned int size = 0;
|
||||
for (i = 0; i < CFG_MAX_NAND_DEVICE; i++) {
|
||||
nand_init_chip(&nand_info[i], &nand_chip[i], base_address[i]);
|
||||
size += nand_info[i].size;
|
||||
if (nand_curr_device == -1)
|
||||
nand_curr_device = i;
|
||||
}
|
||||
printf("%lu MiB\n", size / (1024 * 1024));
|
||||
struct nand_host {
|
||||
struct mtd_info info;
|
||||
struct nand_chip chip;
|
||||
struct device_d *dev;
|
||||
};
|
||||
|
||||
#ifdef CFG_NAND_SELECT_DEVICE
|
||||
/*
|
||||
* Select the chip in the board/cpu specific driver
|
||||
*/
|
||||
board_nand_select_device(nand_info[nand_curr_device].priv, nand_curr_device);
|
||||
#endif
|
||||
static int nand_probe (struct device_d *dev)
|
||||
{
|
||||
struct nand_host *host;
|
||||
|
||||
host = xzalloc(sizeof(*host));
|
||||
|
||||
nand_init_chip(&host->info, &host->chip, dev->map_base);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static struct driver_d nand_driver = {
|
||||
.name = "nand_flash",
|
||||
.probe = nand_probe,
|
||||
// .read = nand_read,
|
||||
// .write = nand_write,
|
||||
// .erase = nand_erase,
|
||||
// .protect= nand_protect,
|
||||
// .memmap = generic_memmap_ro,
|
||||
// .info = nand_info,
|
||||
};
|
||||
|
||||
static int nand_init(void)
|
||||
{
|
||||
return register_driver(&nand_driver);
|
||||
}
|
||||
|
||||
device_initcall(nand_init);
|
||||
|
||||
|
|
|
@ -78,9 +78,10 @@
|
|||
#include <linux/mtd/mtd.h>
|
||||
#include <linux/mtd/nand.h>
|
||||
#include <linux/mtd/nand_ecc.h>
|
||||
#include <clock.h>
|
||||
|
||||
#include <asm/io.h>
|
||||
#include <asm/errno.h>
|
||||
#include <errno.h>
|
||||
|
||||
#ifdef CONFIG_JFFS2_NAND
|
||||
#include <jffs2/jffs2.h>
|
||||
|
@ -833,22 +834,22 @@ static int nand_wait(struct mtd_info *mtd, struct nand_chip *this, int state)
|
|||
#else
|
||||
static int nand_wait(struct mtd_info *mtd, struct nand_chip *this, int state)
|
||||
{
|
||||
unsigned long timeo;
|
||||
uint64_t timeo, start;
|
||||
|
||||
if (state == FL_ERASING)
|
||||
timeo = (CFG_HZ * 400) / 1000;
|
||||
timeo = 400 * MSECOND;
|
||||
else
|
||||
timeo = (CFG_HZ * 20) / 1000;
|
||||
timeo = 20 * MSECOND;
|
||||
|
||||
if ((state == FL_ERASING) && (this->options & NAND_IS_AND))
|
||||
this->cmdfunc(mtd, NAND_CMD_STATUS_MULTI, -1, -1);
|
||||
else
|
||||
this->cmdfunc(mtd, NAND_CMD_STATUS, -1, -1);
|
||||
|
||||
reset_timer();
|
||||
start = get_time_ns();
|
||||
|
||||
while (1) {
|
||||
if (get_timer(0) > timeo) {
|
||||
if (is_timeout(start, timeo)) {
|
||||
printf("Timeout!");
|
||||
return 0x01;
|
||||
}
|
||||
|
|
|
@ -58,7 +58,7 @@
|
|||
#include <linux/mtd/mtd.h>
|
||||
#include <linux/mtd/nand.h>
|
||||
|
||||
#include <asm/errno.h>
|
||||
#include <errno.h>
|
||||
|
||||
/**
|
||||
* check_pattern - [GENERIC] check if a pattern is in the buffer
|
||||
|
|
|
@ -36,7 +36,7 @@
|
|||
#include <malloc.h>
|
||||
|
||||
#include <nand.h>
|
||||
#include <jffs2/jffs2.h>
|
||||
//#include <jffs2/jffs2.h>
|
||||
|
||||
typedef struct erase_info erase_info_t;
|
||||
typedef struct mtd_info mtd_info_t;
|
||||
|
|
Loading…
Reference in New Issue