From: Andy P. <at...@us...> - 2002-04-09 12:44:30
|
Update of /cvsroot/linux-vax/kernel-2.4/include/linux/mtd In directory usw-pr-cvs1:/tmp/cvs-serv17906/linux/mtd Modified Files: cfi.h compatmac.h doc2000.h flashchip.h ftl.h iflash.h jedec.h map.h mtd.h nand.h nand_ids.h nftl.h partitions.h pmc551.h Added Files: cfi_endian.h gen_probe.h nand_ecc.h Removed Files: mapped.h Log Message: sync 2.4.15 commit 3 --- NEW FILE --- /* * $Id: cfi_endian.h,v 1.1 2002/04/09 12:44:17 atp Exp $ * */ #include <asm/byteorder.h> #ifndef CONFIG_MTD_CFI_ADV_OPTIONS #define CFI_HOST_ENDIAN #else #ifdef CONFIG_MTD_CFI_NOSWAP #define CFI_HOST_ENDIAN #endif #ifdef CONFIG_MTD_CFI_LE_BYTE_SWAP #define CFI_LITTLE_ENDIAN #endif #ifdef CONFIG_MTD_CFI_BE_BYTE_SWAP #define CFI_BIG_ENDIAN #endif #endif #if defined(CFI_LITTLE_ENDIAN) #define cpu_to_cfi8(x) (x) #define cfi8_to_cpu(x) (x) #define cpu_to_cfi16(x) cpu_to_le16(x) #define cpu_to_cfi32(x) cpu_to_le32(x) #define cfi16_to_cpu(x) le16_to_cpu(x) #define cfi32_to_cpu(x) le32_to_cpu(x) #elif defined (CFI_BIG_ENDIAN) #define cpu_to_cfi8(x) (x) #define cfi8_to_cpu(x) (x) #define cpu_to_cfi16(x) cpu_to_be16(x) #define cpu_to_cfi32(x) cpu_to_be32(x) #define cfi16_to_cpu(x) be16_to_cpu(x) #define cfi32_to_cpu(x) be32_to_cpu(x) #elif defined (CFI_HOST_ENDIAN) #define cpu_to_cfi8(x) (x) #define cfi8_to_cpu(x) (x) #define cpu_to_cfi16(x) (x) #define cpu_to_cfi32(x) (x) #define cfi16_to_cpu(x) (x) #define cfi32_to_cpu(x) (x) #else #error No CFI endianness defined #endif --- NEW FILE --- /* * (C) 2001, 2001 Red Hat, Inc. * GPL'd * $Id: gen_probe.h,v 1.1 2002/04/09 12:44:17 atp Exp $ */ #ifndef __LINUX_MTD_GEN_PROBE_H__ #define __LINUX_MTD_GEN_PROBE_H__ #include <linux/mtd/flashchip.h> #include <linux/mtd/map.h> #include <linux/mtd/cfi.h> struct chip_probe { char *name; int (*probe_chip)(struct map_info *map, __u32 base, struct flchip *chips, struct cfi_private *cfi); }; struct mtd_info *mtd_do_chip_probe(struct map_info *map, struct chip_probe *cp); #endif /* __LINUX_MTD_GEN_PROBE_H__ */ --- NEW FILE --- /* * drivers/mtd/nand_ecc.h * * Copyright (C) 2000 Steven J. Hill (sj...@co...) * * $Id: nand_ecc.h,v 1.1 2002/04/09 12:44:17 atp Exp $ * * 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. * * This file is the header for the ECC algorithm. */ /* * Creates non-inverted ECC code from line parity */ void nand_trans_result(u_char reg2, u_char reg3, u_char *ecc_code); /* * Calculate 3 byte ECC code for 256 byte block */ void nand_calculate_ecc (const u_char *dat, u_char *ecc_code); /* * Detect and correct a 1 bit error for 256 byte block */ int nand_correct_data (u_char *dat, u_char *read_ecc, u_char *calc_ecc); Index: cfi.h =================================================================== RCS file: /cvsroot/linux-vax/kernel-2.4/include/linux/mtd/cfi.h,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -u -r1.1.1.1 -r1.2 --- cfi.h 14 Jan 2001 16:48:13 -0000 1.1.1.1 +++ cfi.h 9 Apr 2002 12:44:17 -0000 1.2 @@ -7,8 +7,155 @@ #ifndef __MTD_CFI_H__ #define __MTD_CFI_H__ +#include <linux/config.h> +#include <linux/delay.h> #include <linux/types.h> +#include <linux/interrupt.h> #include <linux/mtd/flashchip.h> +#include <linux/mtd/cfi_endian.h> + +/* + * You can optimize the code size and performance by defining only + * the geometry(ies) available on your hardware. + * CFIDEV_INTERLEAVE_n, where represents the interleave (number of chips to fill the bus width) + * CFIDEV_BUSWIDTH_n, where n is the bus width in bytes (1, 2 or 4 bytes) + * + * By default, all (known) geometries are supported. + */ + +#ifndef CONFIG_MTD_CFI_GEOMETRY + +#define CFIDEV_INTERLEAVE_1 (1) +#define CFIDEV_INTERLEAVE_2 (2) +#define CFIDEV_INTERLEAVE_4 (4) + +#define CFIDEV_BUSWIDTH_1 (1) +#define CFIDEV_BUSWIDTH_2 (2) +#define CFIDEV_BUSWIDTH_4 (4) + +#else + +#ifdef CONFIG_MTD_CFI_I1 +#define CFIDEV_INTERLEAVE_1 (1) +#endif +#ifdef CONFIG_MTD_CFI_I2 +#define CFIDEV_INTERLEAVE_2 (2) +#endif +#ifdef CONFIG_MTD_CFI_I4 +#define CFIDEV_INTERLEAVE_4 (4) +#endif + +#ifdef CONFIG_MTD_CFI_B1 +#define CFIDEV_BUSWIDTH_1 (1) +#endif +#ifdef CONFIG_MTD_CFI_B2 +#define CFIDEV_BUSWIDTH_2 (2) +#endif +#ifdef CONFIG_MTD_CFI_B4 +#define CFIDEV_BUSWIDTH_4 (4) +#endif + +#endif + +/* + * The following macros are used to select the code to execute: + * cfi_buswidth_is_*() + * cfi_interleave_is_*() + * [where * is either 1, 2 or 4] + * Those macros should be used with 'if' statements. If only one of few + * geometry arrangements are selected, they expand to constants thus allowing + * the compiler (most of them being 0) to optimize away all the unneeded code, + * while still validating the syntax (which is not possible with embedded + * #if ... #endif constructs). + */ + +#ifdef CFIDEV_INTERLEAVE_1 +# ifdef CFIDEV_INTERLEAVE +# undef CFIDEV_INTERLEAVE +# define CFIDEV_INTERLEAVE (cfi->interleave) +# else +# define CFIDEV_INTERLEAVE CFIDEV_INTERLEAVE_1 +# endif +# define cfi_interleave_is_1() (CFIDEV_INTERLEAVE == CFIDEV_INTERLEAVE_1) +#else +# define cfi_interleave_is_1() (0) +#endif + +#ifdef CFIDEV_INTERLEAVE_2 +# ifdef CFIDEV_INTERLEAVE +# undef CFIDEV_INTERLEAVE +# define CFIDEV_INTERLEAVE (cfi->interleave) +# else +# define CFIDEV_INTERLEAVE CFIDEV_INTERLEAVE_2 +# endif +# define cfi_interleave_is_2() (CFIDEV_INTERLEAVE == CFIDEV_INTERLEAVE_2) +#else +# define cfi_interleave_is_2() (0) +#endif + +#ifdef CFIDEV_INTERLEAVE_4 +# ifdef CFIDEV_INTERLEAVE +# undef CFIDEV_INTERLEAVE +# define CFIDEV_INTERLEAVE (cfi->interleave) +# else +# define CFIDEV_INTERLEAVE CFIDEV_INTERLEAVE_4 +# endif +# define cfi_interleave_is_4() (CFIDEV_INTERLEAVE == CFIDEV_INTERLEAVE_4) +#else +# define cfi_interleave_is_4() (0) +#endif + +#ifndef CFIDEV_INTERLEAVE +#error You must define at least one interleave to support! +#endif + +#ifdef CFIDEV_BUSWIDTH_1 +# ifdef CFIDEV_BUSWIDTH +# undef CFIDEV_BUSWIDTH +# define CFIDEV_BUSWIDTH (map->buswidth) +# else +# define CFIDEV_BUSWIDTH CFIDEV_BUSWIDTH_1 +# endif +# define cfi_buswidth_is_1() (CFIDEV_BUSWIDTH == CFIDEV_BUSWIDTH_1) +#else +# define cfi_buswidth_is_1() (0) +#endif + +#ifdef CFIDEV_BUSWIDTH_2 +# ifdef CFIDEV_BUSWIDTH +# undef CFIDEV_BUSWIDTH +# define CFIDEV_BUSWIDTH (map->buswidth) +# else +# define CFIDEV_BUSWIDTH CFIDEV_BUSWIDTH_2 +# endif +# define cfi_buswidth_is_2() (CFIDEV_BUSWIDTH == CFIDEV_BUSWIDTH_2) +#else +# define cfi_buswidth_is_2() (0) +#endif + +#ifdef CFIDEV_BUSWIDTH_4 +# ifdef CFIDEV_BUSWIDTH +# undef CFIDEV_BUSWIDTH +# define CFIDEV_BUSWIDTH (map->buswidth) +# else +# define CFIDEV_BUSWIDTH CFIDEV_BUSWIDTH_4 +# endif +# define cfi_buswidth_is_4() (CFIDEV_BUSWIDTH == CFIDEV_BUSWIDTH_4) +#else +# define cfi_buswidth_is_4() (0) +#endif + +#ifndef CFIDEV_BUSWIDTH +#error You must define at least one bus width to support! +#endif + +/* NB: these values must represents the number of bytes needed to meet the + * device type (x8, x16, x32). Eg. a 32 bit device is 4 x 8 bytes. + * These numbers are used in calculations. + */ +#define CFI_DEVICETYPE_X8 (8 / 8) +#define CFI_DEVICETYPE_X16 (16 / 8) +#define CFI_DEVICETYPE_X32 (32 / 8) /* NB: We keep these structures in memory in HOST byteorder, except * where individually noted. @@ -37,7 +184,7 @@ __u16 InterfaceDesc; __u16 MaxBufWriteSize; __u8 NumEraseRegions; - __u32 EraseRegionInfo[1]; /* Not host ordered */ + __u32 EraseRegionInfo[0]; /* Not host ordered */ } __attribute__((packed)); /* Extended Query Structure for both PRI and ALT */ @@ -82,20 +229,165 @@ #define P_ID_RESERVED 65535 +#define CFI_MODE_CFI 0 +#define CFI_MODE_JEDEC 1 + struct cfi_private { __u16 cmdset; void *cmdset_priv; int interleave; + int device_type; + int cfi_mode; /* Are we a JEDEC device pretending to be CFI? */ + int addr_unlock1; + int addr_unlock2; + int fast_prog; struct mtd_info *(*cmdset_setup)(struct map_info *); - struct cfi_ident cfiq; /* For now only one. We insist that all devs + struct cfi_ident *cfiq; /* For now only one. We insist that all devs must be of the same type. */ + int mfr, id; int numchips; unsigned long chipshift; /* Because they're of the same type */ const char *im_name; /* inter_module name for cmdset_setup */ struct flchip chips[0]; /* per-chip data structure for each chip */ - /* do not add extra fields after "chips" */ }; #define MAX_CFI_CHIPS 8 /* Entirely arbitrary to avoid realloc() */ + +/* + * Returns the command address according to the given geometry. + */ +static inline __u32 cfi_build_cmd_addr(__u32 cmd_ofs, int interleave, int type) +{ + return (cmd_ofs * type) * interleave; +} + +/* + * Transforms the CFI command for the given geometry (bus width & interleave. + */ +static inline __u32 cfi_build_cmd(u_char cmd, struct map_info *map, struct cfi_private *cfi) +{ + __u32 val = 0; + + if (cfi_buswidth_is_1()) { + /* 1 x8 device */ + val = cmd; + } else if (cfi_buswidth_is_2()) { + if (cfi_interleave_is_1()) { + /* 1 x16 device in x16 mode */ + val = cpu_to_cfi16(cmd); + } else if (cfi_interleave_is_2()) { + /* 2 (x8, x16 or x32) devices in x8 mode */ + val = cpu_to_cfi16((cmd << 8) | cmd); + } + } else if (cfi_buswidth_is_4()) { + if (cfi_interleave_is_1()) { + /* 1 x32 device in x32 mode */ + val = cpu_to_cfi32(cmd); + } else if (cfi_interleave_is_2()) { + /* 2 x16 device in x16 mode */ + val = cpu_to_cfi32((cmd << 16) | cmd); + } else if (cfi_interleave_is_4()) { + /* 4 (x8, x16 or x32) devices in x8 mode */ + val = (cmd << 16) | cmd; + val = cpu_to_cfi32((val << 8) | val); + } + } + return val; +} +#define CMD(x) cfi_build_cmd((x), map, cfi) + +/* + * Read a value according to the bus width. + */ + +static inline __u32 cfi_read(struct map_info *map, __u32 addr) +{ + if (cfi_buswidth_is_1()) { + return map->read8(map, addr); + } else if (cfi_buswidth_is_2()) { + return map->read16(map, addr); + } else if (cfi_buswidth_is_4()) { + return map->read32(map, addr); + } else { + return 0; + } +} + +/* + * Write a value according to the bus width. + */ + +static inline void cfi_write(struct map_info *map, __u32 val, __u32 addr) +{ + if (cfi_buswidth_is_1()) { + map->write8(map, val, addr); + } else if (cfi_buswidth_is_2()) { + map->write16(map, val, addr); + } else if (cfi_buswidth_is_4()) { + map->write32(map, val, addr); + } +} + +/* + * Sends a CFI command to a bank of flash for the given geometry. + * + * Returns the offset in flash where the command was written. + * If prev_val is non-null, it will be set to the value at the command address, + * before the command was written. + */ +static inline __u32 cfi_send_gen_cmd(u_char cmd, __u32 cmd_addr, __u32 base, + struct map_info *map, struct cfi_private *cfi, + int type, __u32 *prev_val) +{ + __u32 val; + __u32 addr = base + cfi_build_cmd_addr(cmd_addr, CFIDEV_INTERLEAVE, type); + + val = cfi_build_cmd(cmd, map, cfi); + + if (prev_val) + *prev_val = cfi_read(map, addr); + + cfi_write(map, val, addr); + + return addr - base; +} + +static inline __u8 cfi_read_query(struct map_info *map, __u32 addr) +{ + if (cfi_buswidth_is_1()) { + return map->read8(map, addr); + } else if (cfi_buswidth_is_2()) { + return cfi16_to_cpu(map->read16(map, addr)); + } else if (cfi_buswidth_is_4()) { + return cfi32_to_cpu(map->read32(map, addr)); + } else { + return 0; + } +} + +static inline void cfi_udelay(int us) +{ +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,2,0) + if (current->need_resched) { + unsigned long t = us * HZ / 1000000; + if (t < 1) + t = 1; + set_current_state(TASK_UNINTERRUPTIBLE); + schedule_timeout(t); + } + else +#endif + udelay(us); +} +static inline void cfi_spin_lock(spinlock_t *mutex) +{ + spin_lock_bh(mutex); +} + +static inline void cfi_spin_unlock(spinlock_t *mutex) +{ + spin_unlock_bh(mutex); +} + #endif /* __MTD_CFI_H__ */ Index: compatmac.h =================================================================== RCS file: /cvsroot/linux-vax/kernel-2.4/include/linux/mtd/compatmac.h,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -u -r1.1.1.1 -r1.2 Index: doc2000.h =================================================================== RCS file: /cvsroot/linux-vax/kernel-2.4/include/linux/mtd/doc2000.h,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -u -r1.1.1.1 -r1.2 --- doc2000.h 14 Jan 2001 16:48:15 -0000 1.1.1.1 +++ doc2000.h 9 Apr 2002 12:44:17 -0000 1.2 @@ -43,18 +43,22 @@ * On PPC, it's mmap'd and 16-bit wide. * Others use readb/writeb */ -#if defined(__arm__) -#define ReadDOC_(adr, reg) ((unsigned char)(*(__u32 *)(((unsigned long)adr)+(reg<<2)))) -#define WriteDOC_(d, adr, reg) do{ *(__u32 *)(((unsigned long)adr)+(reg<<2)) = (__u32)d} while(0) +#if defined(__arm__) +#define ReadDOC_(adr, reg) ((unsigned char)(*(__u32 *)(((unsigned long)adr)+((reg)<<2)))) +#define WriteDOC_(d, adr, reg) do{ *(__u32 *)(((unsigned long)adr)+((reg)<<2)) = (__u32)d; wmb();} while(0) +#define DOC_IOREMAP_LEN 0x8000 #elif defined(__ppc__) -#define ReadDOC_(adr, reg) ((unsigned char)(*(__u16 *)(((unsigned long)adr)+(reg<<1)))) -#define WriteDOC_(d, adr, reg) do{ *(__u16 *)(((unsigned long)adr)+(reg<<1)) = (__u16)d} while(0) +#define ReadDOC_(adr, reg) ((unsigned char)(*(__u16 *)(((unsigned long)adr)+((reg)<<1)))) +#define WriteDOC_(d, adr, reg) do{ *(__u16 *)(((unsigned long)adr)+((reg)<<1)) = (__u16)d; wmb();} while(0) +#define DOC_IOREMAP_LEN 0x4000 #else -#define ReadDOC_(adr, reg) readb(((unsigned long)adr) + reg) -#define WriteDOC_(d, adr, reg) writeb(d, ((unsigned long)adr) + reg) +#define ReadDOC_(adr, reg) readb(((unsigned long)adr) + (reg)) +#define WriteDOC_(d, adr, reg) writeb(d, ((unsigned long)adr) + (reg)) +#define DOC_IOREMAP_LEN 0x2000 + #endif -#if defined(__i386__) +#if defined(__i386__) || defined(__x86_64__) #define USE_MEMCPY #endif @@ -130,6 +134,7 @@ int numchips; struct Nand *chips; struct mtd_info *nextdoc; + struct semaphore lock; }; int doc_decode_ecc(unsigned char sector[512], unsigned char ecc1[6]); Index: flashchip.h =================================================================== RCS file: /cvsroot/linux-vax/kernel-2.4/include/linux/mtd/flashchip.h,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -u -r1.1.1.1 -r1.2 --- flashchip.h 14 Jan 2001 16:48:15 -0000 1.1.1.1 +++ flashchip.h 9 Apr 2002 12:44:17 -0000 1.2 @@ -25,12 +25,17 @@ FL_CFI_QUERY, FL_JEDEC_QUERY, FL_ERASING, + FL_ERASE_SUSPENDING, FL_ERASE_SUSPENDED, FL_WRITING, + FL_WRITING_TO_BUFFER, + FL_WRITE_SUSPENDING, FL_WRITE_SUSPENDED, FL_PM_SUSPENDED, FL_SYNCING, FL_UNLOADING, + FL_LOCKING, + FL_UNLOCKING, FL_UNKNOWN } flstate_t; Index: ftl.h =================================================================== RCS file: /cvsroot/linux-vax/kernel-2.4/include/linux/mtd/ftl.h,v retrieving revision 1.1.1.2 retrieving revision 1.2 diff -u -r1.1.1.2 -r1.2 --- ftl.h 25 Feb 2001 23:14:50 -0000 1.1.1.2 +++ ftl.h 9 Apr 2002 12:44:17 -0000 1.2 @@ -1,4 +1,7 @@ /* + * $Id$ + * + * Derived from (and probably identical to): * ftl.h 1.7 1999/10/25 20:23:17 * * The contents of this file are subject to the Mozilla Public License @@ -16,8 +19,8 @@ * are Copyright (C) 1999 David A. Hinds. All Rights Reserved. * * Alternatively, the contents of this file may be used under the - * terms of the GNU General Public License version 2 (the "GPL"), in which - * case the provisions of the GPL are applicable instead of the + * terms of the GNU General Public License version 2 (the "GPL"), in + * which case the provisions of the GPL are applicable instead of the * above. If you wish to allow the use of your version of this file * only under the terms of the GPL and not to allow others to use * your version of this file under the MPL, indicate your decision by Index: iflash.h =================================================================== RCS file: /cvsroot/linux-vax/kernel-2.4/include/linux/mtd/iflash.h,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -u -r1.1.1.1 -r1.2 --- iflash.h 14 Jan 2001 16:48:15 -0000 1.1.1.1 +++ iflash.h 9 Apr 2002 12:44:17 -0000 1.2 @@ -1,4 +1,4 @@ -/* iflash.h $revision$ $date$ (David Hinds) */ +/* $Id$ */ #ifndef __MTD_IFLASH_H__ #define __MTD_IFLASH_H__ Index: jedec.h =================================================================== RCS file: /cvsroot/linux-vax/kernel-2.4/include/linux/mtd/jedec.h,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -u -r1.1.1.1 -r1.2 --- jedec.h 14 Jan 2001 16:48:16 -0000 1.1.1.1 +++ jedec.h 9 Apr 2002 12:44:17 -0000 1.2 @@ -64,6 +64,4 @@ struct jedec_flash_chip chips[MAX_JEDEC_CHIPS]; }; -extern const struct JEDECTable *jedec_idtoinf(__u8 mfr,__u8 id); - #endif Index: map.h =================================================================== RCS file: /cvsroot/linux-vax/kernel-2.4/include/linux/mtd/map.h,v retrieving revision 1.1.1.2 retrieving revision 1.2 diff -u -r1.1.1.2 -r1.2 --- map.h 25 Feb 2001 23:14:50 -0000 1.1.1.2 +++ map.h 9 Apr 2002 12:44:17 -0000 1.2 @@ -53,47 +53,23 @@ unsigned long map_priv_1; unsigned long map_priv_2; void *fldrv_priv; - void (*fldrv_destroy)(struct mtd_info *); - const char *im_name; + struct mtd_chip_driver *fldrv; }; -#ifdef CONFIG_MODULES -/* - * Probe for the contents of a map device and make an MTD structure - * if anything is recognised. Doesn't register it because the calling - * map driver needs to set the 'module' field first. - */ -static inline struct mtd_info *do_map_probe(struct map_info *map, const char *funcname, const char *modname) -{ - struct mtd_info *(*probe_p)(struct map_info *); - struct mtd_info *mtd = NULL; - if ((probe_p = inter_module_get_request(modname, funcname))) - mtd = (*probe_p)(map); /* map->im_name is set by probe */ +struct mtd_chip_driver { + struct mtd_info *(*probe)(struct map_info *map); + void (*destroy)(struct mtd_info *); + struct module *module; + char *name; + struct list_head list; +}; - return mtd; -} +void register_mtd_chip_driver(struct mtd_chip_driver *); +void unregister_mtd_chip_driver(struct mtd_chip_driver *); +struct mtd_info *do_map_probe(char *name, struct map_info *map); -/* - * Commonly-used probe functions for different types of chip. - */ -#define do_cfi_probe(x) do_map_probe(x, "cfi_probe", "cfi_probe") -#define do_jedec_probe(x) do_map_probe(x, "jedec_probe", "jedec_probe") -#define do_ram_probe(x) do_map_probe(x, "map_ram_probe", "map_ram") -#define do_rom_probe(x) do_map_probe(x, "map_rom_probe", "map_rom") -#else - /* without module support, call probe function directly */ -extern struct mtd_info *cfi_probe(struct map_info *); -extern struct mtd_info *jedec_probe(struct map_info *); -extern struct mtd_info *map_ram_probe(struct map_info *); -extern struct mtd_info *map_rom_probe(struct map_info *); - -#define do_cfi_probe(x) cfi_probe(x) -#define do_jedec_probe(x) jedec_probe(x) -#define do_ram_probe(x) map_ram_probe(x) -#define do_rom_probe(x) map_rom_probe(x) -#endif /* * Destroy an MTD device which was created for a map device. @@ -103,8 +79,12 @@ { struct map_info *map = mtd->priv; - map->fldrv_destroy(mtd); - inter_module_put(map->im_name); + if (map->fldrv->destroy) + map->fldrv->destroy(mtd); +#ifdef CONFIG_MODULES + if (map->fldrv->module) + __MOD_DEC_USE_COUNT(map->fldrv->module); +#endif kfree(mtd); } Index: mtd.h =================================================================== RCS file: /cvsroot/linux-vax/kernel-2.4/include/linux/mtd/mtd.h,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -u -r1.1.1.1 -r1.2 --- mtd.h 14 Jan 2001 16:48:17 -0000 1.1.1.1 +++ mtd.h 9 Apr 2002 12:44:17 -0000 1.2 @@ -16,13 +16,13 @@ #endif /* __KERNEL__ */ struct erase_info_user { - unsigned long start; - unsigned long length; + u_int32_t start; + u_int32_t length; }; struct mtd_oob_buf { - loff_t start; - ssize_t length; + u_int32_t start; + u_int32_t length; unsigned char *ptr; }; @@ -68,13 +68,21 @@ struct mtd_info_user { u_char type; - u_long flags; - u_long size; // Total size of the MTD - u_long erasesize; - u_long oobblock; // Size of OOB blocks (e.g. 512) - u_long oobsize; // Amount of OOB data per block (e.g. 16) - u_long ecctype; - u_long eccsize; + u_int32_t flags; + u_int32_t size; // Total size of the MTD + u_int32_t erasesize; + u_int32_t oobblock; // Size of OOB blocks (e.g. 512) + u_int32_t oobsize; // Amount of OOB data per block (e.g. 16) + u_int32_t ecctype; + u_int32_t eccsize; +}; + +struct region_info_user { + u_int32_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 in this region */ + u_int32_t regionindex; }; #define MEMGETINFO _IOR('M', 1, struct mtd_info_user) @@ -83,11 +91,14 @@ #define MEMREADOOB _IOWR('M', 4, struct mtd_oob_buf) #define MEMLOCK _IOW('M', 5, struct erase_info_user) #define MEMUNLOCK _IOW('M', 6, struct erase_info_user) +#define MEMGETREGIONCOUNT _IOR('M', 7, int) +#define MEMGETREGIONINFO _IOWR('M', 8, struct region_info_user) #ifndef __KERNEL__ typedef struct mtd_info_user mtd_info_t; typedef struct erase_info_user erase_info_t; +typedef struct region_info_user region_info_t; /* User-space ioctl definitions */ @@ -103,8 +114,8 @@ struct erase_info { struct mtd_info *mtd; - u_long addr; - u_long len; + u_int32_t addr; + u_int32_t len; u_long time; u_long retries; u_int dev; @@ -115,22 +126,40 @@ struct erase_info *next; }; +struct mtd_erase_region_info { + u_int32_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 */ +}; struct mtd_info { u_char type; - u_long flags; - u_long size; // Total size of the MTD - u_long erasesize; - u_long oobblock; // Size of OOB blocks (e.g. 512) - u_long oobsize; // Amount of OOB data per block (e.g. 16) - u_long ecctype; - u_long eccsize; + u_int32_t flags; + u_int32_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 + * information below if they desire + */ + u_int32_t erasesize; + + u_int32_t oobblock; // Size of OOB blocks (e.g. 512) + u_int32_t oobsize; // Amount of OOB data per block (e.g. 16) + u_int32_t ecctype; + u_int32_t eccsize; // Kernel-only stuff starts here. char *name; int index; - u_long bank_size; + /* Data for variable erase regions. If numeraseregions is zero, + * it means that the whole device has erasesize as given above. + */ + int numeraseregions; + struct mtd_erase_region_info *eraseregions; + + /* This really shouldn't be here. It can go away in 2.5 */ + u_int32_t bank_size; struct module *module; int (*erase) (struct mtd_info *mtd, struct erase_info *instr); Index: nand.h =================================================================== RCS file: /cvsroot/linux-vax/kernel-2.4/include/linux/mtd/nand.h,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -u -r1.1.1.1 -r1.2 Index: nand_ids.h =================================================================== RCS file: /cvsroot/linux-vax/kernel-2.4/include/linux/mtd/nand_ids.h,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -u -r1.1.1.1 -r1.2 Index: nftl.h =================================================================== RCS file: /cvsroot/linux-vax/kernel-2.4/include/linux/mtd/nftl.h,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -u -r1.1.1.1 -r1.2 --- nftl.h 14 Jan 2001 16:48:18 -0000 1.1.1.1 +++ nftl.h 9 Apr 2002 12:44:17 -0000 1.2 @@ -115,6 +115,7 @@ #define MAX_NFTLS 16 #define MAX_SECTORS_PER_UNIT 32 +#define NFTL_PARTN_BITS 4 #endif /* __KERNEL__ */ Index: partitions.h =================================================================== RCS file: /cvsroot/linux-vax/kernel-2.4/include/linux/mtd/partitions.h,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -u -r1.1.1.1 -r1.2 --- partitions.h 14 Jan 2001 16:48:20 -0000 1.1.1.1 +++ partitions.h 9 Apr 2002 12:44:17 -0000 1.2 @@ -22,10 +22,11 @@ * * For each partition, these fields are available: * name: string that will be used to label the partition's MTD device. - * size: the partition size; if 0, the partition will extend to the end of the - * master MTD device. - * offset: absolute starting position within the master MTD device; if 0, - * partition will start where the previous one ended. + * size: the partition size; if defined as MTDPART_SIZ_FULL, the partition + * will extend to the end of the master MTD device. + * offset: absolute starting position within the master MTD device; if + * defined as MTDPART_OFS_APPEND, the partition will start where the + * previous one ended. * mask_flags: contains flags that have to be masked (removed) from the * master MTD flag set for the corresponding MTD partition. * For example, to force a read-only partition, simply adding @@ -37,10 +38,13 @@ struct mtd_partition { char *name; /* identifier string */ - u_long size; /* partition size */ - u_long offset; /* offset within the master MTD space */ - u_long mask_flags; /* master MTD flags to mask out for this partition */ + u_int32_t size; /* partition size */ + u_int32_t offset; /* offset within the master MTD space */ + u_int32_t mask_flags; /* master MTD flags to mask out for this partition */ }; + +#define MTDPART_OFS_APPEND (-1) +#define MTDPART_SIZ_FULL (0) int add_mtd_partitions(struct mtd_info *, struct mtd_partition *, int); Index: pmc551.h =================================================================== RCS file: /cvsroot/linux-vax/kernel-2.4/include/linux/mtd/pmc551.h,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -u -r1.1.1.1 -r1.2 --- pmc551.h 14 Jan 2001 16:48:19 -0000 1.1.1.1 +++ pmc551.h 9 Apr 2002 12:44:17 -0000 1.2 @@ -26,9 +26,9 @@ struct mypriv { struct pci_dev *dev; u_char *start; - u32 mem_map0_base_val; - u32 curr_mem_map0_val; - u32 aperture_size; + u32 base_map0; + u32 curr_map0; + u32 asize; struct mtd_info *nextpmc551; }; @@ -37,9 +37,10 @@ */ static int pmc551_erase(struct mtd_info *, struct erase_info *); static void pmc551_unpoint(struct mtd_info *, u_char *); +static int pmc551_point (struct mtd_info *mtd, loff_t from, size_t len, size_t *retlen, u_char **mtdbuf); static int pmc551_read(struct mtd_info *, loff_t, size_t, size_t *, u_char *); -static int pmc551_write(struct mtd_info *, loff_t, size_t, size_t *, const u_char -*); +static int pmc551_write(struct mtd_info *, loff_t, size_t, size_t *, const u_char *); + /* * Define the PCI ID's if the kernel doesn't define them for us @@ -73,9 +74,6 @@ #define PMC551_DRAM_BLK_SET_COL_MUX(x,v) (((x) & ~0x00007000) | (((v) & 0x7) << 12)) #define PMC551_DRAM_BLK_SET_ROW_MUX(x,v) (((x) & ~0x00000f00) | (((v) & 0xf) << 8)) - -#define PMC551_ADDR_HIGH_MASK 0x3ff00000 -#define PMC551_ADDR_LOW_MASK 0x000fffff #endif /* __MTD_PMC551_H__ */ --- mapped.h DELETED --- |