diff options
author | Sascha Hauer <sha@octopus.labnet.pengutronix.de> | 2007-10-15 17:16:25 +0200 |
---|---|---|
committer | Sascha Hauer <sha@octopus.labnet.pengutronix.de> | 2007-10-15 17:16:25 +0200 |
commit | 15a16e5f76f1785c55e42ab23cdd5f87d646b13c (patch) | |
tree | c25059a5b579d0dcaab18101d92cf3cd59c25908 /drivers | |
parent | cedcb274ae714aa0f1f38266ee27a575087ca715 (diff) | |
download | barebox-15a16e5f76f1785c55e42ab23cdd5f87d646b13c.tar.gz barebox-15a16e5f76f1785c55e42ab23cdd5f87d646b13c.tar.xz |
make NAND support compile
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/nand/Makefile | 2 | ||||
-rw-r--r-- | drivers/nand/nand.c | 67 | ||||
-rw-r--r-- | drivers/nand/nand_base.c | 13 | ||||
-rw-r--r-- | drivers/nand/nand_bbt.c | 2 | ||||
-rw-r--r-- | drivers/nand/nand_util.c | 2 |
5 files changed, 49 insertions, 37 deletions
diff --git a/drivers/nand/Makefile b/drivers/nand/Makefile index 487b36f0fc..f5cfacf069 100644 --- a/drivers/nand/Makefile +++ b/drivers/nand/Makefile @@ -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 diff --git a/drivers/nand/nand.c b/drivers/nand/nand.c index 73f68b2f43..18f90a035f 100644 --- a/drivers/nand/nand.c +++ b/drivers/nand/nand.c @@ -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) +struct nand_host { + struct mtd_info info; + struct nand_chip chip; + struct device_d *dev; +}; + +static int nand_probe (struct device_d *dev) { - 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 *host; -#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 + 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); + diff --git a/drivers/nand/nand_base.c b/drivers/nand/nand_base.c index faf3bf0140..4969a447d0 100644 --- a/drivers/nand/nand_base.c +++ b/drivers/nand/nand_base.c @@ -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; } diff --git a/drivers/nand/nand_bbt.c b/drivers/nand/nand_bbt.c index faffbae8fe..8ba6d59bb5 100644 --- a/drivers/nand/nand_bbt.c +++ b/drivers/nand/nand_bbt.c @@ -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 diff --git a/drivers/nand/nand_util.c b/drivers/nand/nand_util.c index 610497b228..d57294e624 100644 --- a/drivers/nand/nand_util.c +++ b/drivers/nand/nand_util.c @@ -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; |