Commit 8d2effea authored by Stefan Roese's avatar Stefan Roese Committed by Wolfgang Denk

mtd: Update MTD infrastructure to support 64bit device size

This patch brings the U-Boot MTD infrastructure in sync with the current
Linux MTD version (2.6.30-rc3). Biggest change is the 64bit device size
support and a resync of the mtdpart.c file which has seen multiple fixes
meanwhile.
Signed-off-by: default avatarStefan Roese <sr@denx.de>
Cc: Scott Wood <scottwood@freescale.com>
Cc: Kyungmin Park <kmpark@infradead.org>
parent 0a572655
......@@ -19,6 +19,10 @@
#include <asm/io.h>
#if !defined(CONFIG_SYS_64BIT_VSPRINTF)
#warning Please define CONFIG_SYS_64BIT_VSPRINTF for correct output!
#endif
static struct mtd_info *mtd;
static loff_t next_ofs;
......@@ -53,7 +57,7 @@ static int arg_off_size(int argc, char *argv[], ulong *off, size_t *size)
}
if ((*off + *size) > mtd->size) {
printf("total chip size (0x%x) exceeded!\n", mtd->size);
printf("total chip size (0x%llx) exceeded!\n", mtd->size);
return -1;
}
......
......@@ -109,7 +109,7 @@ int saveenv(void)
if (onenand_write(&onenand_mtd, env_addr, onenand_mtd.writesize, &retlen,
(u_char *) env_ptr)) {
printf("OneNAND: write failed at 0x%08x\n", instr.addr);
printf("OneNAND: write failed at 0x%llx\n", instr.addr);
return 2;
}
......
......@@ -123,7 +123,7 @@ static void cfi_mtd_sync(struct mtd_info *mtd)
*/
}
static int cfi_mtd_lock(struct mtd_info *mtd, loff_t ofs, size_t len)
static int cfi_mtd_lock(struct mtd_info *mtd, loff_t ofs, uint64_t len)
{
flash_info_t *fi = mtd->priv;
......@@ -135,7 +135,7 @@ static int cfi_mtd_lock(struct mtd_info *mtd, loff_t ofs, size_t len)
return 0;
}
static int cfi_mtd_unlock(struct mtd_info *mtd, loff_t ofs, size_t len)
static int cfi_mtd_unlock(struct mtd_info *mtd, loff_t ofs, uint64_t len)
{
flash_info_t *fi = mtd->priv;
......
This diff is collapsed.
......@@ -36,12 +36,15 @@
#include <malloc.h>
#include <div64.h>
#include <asm/errno.h>
#include <linux/mtd/mtd.h>
#include <nand.h>
#include <jffs2/jffs2.h>
#if !defined(CONFIG_SYS_64BIT_VSPRINTF)
#warning Please define CONFIG_SYS_64BIT_VSPRINTF for correct output!
#endif
typedef struct erase_info erase_info_t;
typedef struct mtd_info mtd_info_t;
......@@ -127,7 +130,7 @@ int nand_erase_opts(nand_info_t *meminfo, const nand_erase_options_t *opts)
if (ret > 0) {
if (!opts->quiet)
printf("\rSkipping bad block at "
"0x%08x "
"0x%08llx "
" \n",
erase.addr);
continue;
......@@ -181,11 +184,11 @@ int nand_erase_opts(nand_info_t *meminfo, const nand_erase_options_t *opts)
if (percent != percent_complete) {
percent_complete = percent;
printf("\rErasing at 0x%x -- %3d%% complete.",
printf("\rErasing at 0x%llx -- %3d%% complete.",
erase.addr, percent);
if (opts->jffs2 && result == 0)
printf(" Cleanmarker written at 0x%x.",
printf(" Cleanmarker written at 0x%llx.",
erase.addr);
}
}
......
......@@ -8,6 +8,7 @@
#define __MTD_MTD_H__
#include <linux/types.h>
#include <div64.h>
#include <linux/mtd/mtd-abi.h>
#define MTD_CHAR_MAJOR 90
......@@ -20,6 +21,8 @@
#define MTD_ERASE_DONE 0x08
#define MTD_ERASE_FAILED 0x10
#define MTD_FAIL_ADDR_UNKNOWN -1LL
/*
* Enumeration for NAND/OneNAND flash chip state
*/
......@@ -37,13 +40,13 @@ enum {
};
/* If the erase fails, fail_addr might indicate exactly which block failed. If
fail_addr = 0xffffffff, the failure was not at the device level or was not
fail_addr = MTD_FAIL_ADDR_UNKNOWN, the failure was not at the device level or was not
specific to any particular block. */
struct erase_info {
struct mtd_info *mtd;
u_int32_t addr;
u_int32_t len;
u_int32_t fail_addr;
uint64_t addr;
uint64_t len;
uint64_t fail_addr;
u_long time;
u_long retries;
u_int dev;
......@@ -55,7 +58,7 @@ struct erase_info {
};
struct mtd_erase_region_info {
u_int32_t offset; /* At which this region starts, from the beginning of the MTD */
uint64_t offset; /* At which this region starts, from the beginning of the MTD */
u_int32_t erasesize; /* For this region */
u_int32_t numblocks; /* Number of blocks of erasesize in this region */
unsigned long *lockmap; /* If keeping bitmap of locks */
......@@ -110,7 +113,7 @@ struct mtd_oob_ops {
struct mtd_info {
u_char type;
u_int32_t flags;
u_int32_t size; /* Total size of the MTD */
uint64_t size; // Total size of the MTD
/* "Major" erase size for the device. Naïve users may take this
* to be the only erase size available, or may use the more detailed
......@@ -202,8 +205,8 @@ struct mtd_info {
void (*sync) (struct mtd_info *mtd);
/* Chip-supported device locking */
int (*lock) (struct mtd_info *mtd, loff_t ofs, size_t len);
int (*unlock) (struct mtd_info *mtd, loff_t ofs, size_t len);
int (*lock) (struct mtd_info *mtd, loff_t ofs, uint64_t len);
int (*unlock) (struct mtd_info *mtd, loff_t ofs, uint64_t len);
/* Power Management functions */
int (*suspend) (struct mtd_info *mtd);
......@@ -236,6 +239,16 @@ struct mtd_info {
void (*put_device) (struct mtd_info *mtd);
};
static inline uint32_t mtd_div_by_eb(uint64_t sz, struct mtd_info *mtd)
{
do_div(sz, mtd->erasesize);
return sz;
}
static inline uint32_t mtd_mod_by_eb(uint64_t sz, struct mtd_info *mtd)
{
return do_div(sz, mtd->erasesize);
}
/* Kernel-side ioctl definitions */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment