blob: fe22e0dceb16cc8ae7549733f8b75e5c66d67c98 [file] [log] [blame]
William Juulcfa460a2007-10-31 13:53:06 +01001/*
William Juulcfa460a2007-10-31 13:53:06 +01002 * (C) 1999-2003 David Woodhouse <dwmw2@infradead.org>
3 */
wdenka1e329b2002-01-26 00:07:42 +00004
5#ifndef __MTD_NFTL_H__
6#define __MTD_NFTL_H__
7
William Juulcfa460a2007-10-31 13:53:06 +01008#include <linux/mtd/mtd.h>
9#include <linux/mtd/blktrans.h>
wdenka1e329b2002-01-26 00:07:42 +000010
William Juulcfa460a2007-10-31 13:53:06 +010011#include <linux/mtd/nftl-user.h>
wdenka1e329b2002-01-26 00:07:42 +000012
13/* these info are used in ReplUnitTable */
Wolfgang Denk4b070802008-08-14 14:41:06 +020014#define BLOCK_NIL 0xffff /* last block of a chain */
15#define BLOCK_FREE 0xfffe /* free block */
wdenka1e329b2002-01-26 00:07:42 +000016#define BLOCK_NOTEXPLORED 0xfffd /* non explored block, only used during mounting */
Wolfgang Denk4b070802008-08-14 14:41:06 +020017#define BLOCK_RESERVED 0xfffc /* bios block or bad block */
wdenka1e329b2002-01-26 00:07:42 +000018
19struct NFTLrecord {
William Juulcfa460a2007-10-31 13:53:06 +010020 struct mtd_blktrans_dev mbd;
wdenka1e329b2002-01-26 00:07:42 +000021 __u16 MediaUnit, SpareMediaUnit;
22 __u32 EraseSize;
23 struct NFTLMediaHeader MediaHdr;
24 int usecount;
25 unsigned char heads;
26 unsigned char sectors;
27 unsigned short cylinders;
28 __u16 numvunits;
Wolfgang Denk4b070802008-08-14 14:41:06 +020029 __u16 lastEUN; /* should be suppressed */
wdenka1e329b2002-01-26 00:07:42 +000030 __u16 numfreeEUNs;
Wolfgang Denk53677ef2008-05-20 16:00:29 +020031 __u16 LastFreeEUN; /* To speed up finding a free EUN */
wdenka1e329b2002-01-26 00:07:42 +000032 int head,sect,cyl;
Wolfgang Denk53677ef2008-05-20 16:00:29 +020033 __u16 *EUNtable; /* [numvunits]: First EUN for each virtual unit */
34 __u16 *ReplUnitTable; /* [numEUNs]: ReplUnitNumber for each */
Wolfgang Denk4b070802008-08-14 14:41:06 +020035 unsigned int nb_blocks; /* number of physical blocks */
36 unsigned int nb_boot_blocks; /* number of blocks used by the bios */
37 struct erase_info instr;
William Juulcfa460a2007-10-31 13:53:06 +010038 struct nand_ecclayout oobinfo;
wdenka1e329b2002-01-26 00:07:42 +000039};
40
William Juulcfa460a2007-10-31 13:53:06 +010041int NFTL_mount(struct NFTLrecord *s);
42int NFTL_formatblock(struct NFTLrecord *s, int block);
43
Scott Woodc45912d2008-10-24 16:20:43 -050044int nftl_read_oob(struct mtd_info *mtd, loff_t offs, size_t len,
45 size_t *retlen, uint8_t *buf);
46int nftl_write_oob(struct mtd_info *mtd, loff_t offs, size_t len,
47 size_t *retlen, uint8_t *buf);
48
William Juulcfa460a2007-10-31 13:53:06 +010049#ifndef NFTL_MAJOR
50#define NFTL_MAJOR 93
51#endif
52
wdenka1e329b2002-01-26 00:07:42 +000053#define MAX_NFTLS 16
William Juulcfa460a2007-10-31 13:53:06 +010054#define MAX_SECTORS_PER_UNIT 64
wdenka1e329b2002-01-26 00:07:42 +000055#define NFTL_PARTN_BITS 4
56
57#endif /* __MTD_NFTL_H__ */