mirror of
https://github.com/FEX-Emu/linux.git
synced 2024-12-16 14:02:10 +00:00
mtd: Add new SmartMedia/xD FTL
This implements new readwrite SmartMedia/xd FTL. mtd driver must have support proper ECC and badblock verification based on oob parts for 512 bytes nand. Also mtd driver must define read_oob and write_oob, which are used to read and write both data and oob together. Signed-off-by: Maxim Levitsky <maximlevitsky@gmail.com> Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
This commit is contained in:
parent
a7790532f5
commit
7d17c02a01
@ -304,6 +304,27 @@ config SSFDC
|
||||
This enables read only access to SmartMedia formatted NAND
|
||||
flash. You can mount it with FAT file system.
|
||||
|
||||
|
||||
config SM_FTL
|
||||
tristate "SmartMedia/xD new translation layer"
|
||||
depends on EXPERIMENTAL && BLOCK
|
||||
select MTD_BLKDEVS
|
||||
help
|
||||
This enables new and very EXPERMENTAL support for SmartMedia/xD
|
||||
FTL (Flash tanslation layer)
|
||||
Write support isn't yet well tested, therefore this code IS likely to
|
||||
eat your card, so please don't use it together with valuable data.
|
||||
Use readonly driver (CONFIG_SSFDC) instead.
|
||||
|
||||
config SM_FTL_MUSEUM
|
||||
boolean "Additional Support for 1MiB and 2MiB SmartMedia cards"
|
||||
depends on SM_FTL && MTD_NAND
|
||||
select MTD_NAND_ECC_SMC
|
||||
help
|
||||
Very old SmartMedia cards need ECC to be calculated in the FTL
|
||||
Such cards are very rare, thus enabling this option is mostly useless
|
||||
Also this support is completely UNTESTED.
|
||||
|
||||
config MTD_OOPS
|
||||
tristate "Log panic/oops to an MTD buffer"
|
||||
depends on MTD
|
||||
|
@ -24,6 +24,7 @@ obj-$(CONFIG_NFTL) += nftl.o
|
||||
obj-$(CONFIG_INFTL) += inftl.o
|
||||
obj-$(CONFIG_RFD_FTL) += rfd_ftl.o
|
||||
obj-$(CONFIG_SSFDC) += ssfdc.o
|
||||
obj-$(CONFIG_SM_FTL) += sm_ftl.o
|
||||
obj-$(CONFIG_MTD_OOPS) += mtdoops.o
|
||||
|
||||
nftl-objs := nftlcore.o nftlmount.o
|
||||
|
1284
drivers/mtd/sm_ftl.c
Normal file
1284
drivers/mtd/sm_ftl.c
Normal file
File diff suppressed because it is too large
Load Diff
94
drivers/mtd/sm_ftl.h
Normal file
94
drivers/mtd/sm_ftl.h
Normal file
@ -0,0 +1,94 @@
|
||||
/*
|
||||
* Copyright © 2009 - Maxim Levitsky
|
||||
* SmartMedia/xD translation layer
|
||||
*
|
||||
* Based loosly on ssfdc.c which is
|
||||
* © 2005 Eptar srl
|
||||
* Author: Claudio Lanconelli <lanconelli.claudio@eptar.com>
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#include <linux/mtd/blktrans.h>
|
||||
#include <linux/kfifo.h>
|
||||
#include <linux/sched.h>
|
||||
#include <linux/completion.h>
|
||||
#include <linux/mtd/mtd.h>
|
||||
|
||||
|
||||
|
||||
struct ftl_zone {
|
||||
int initialized;
|
||||
int16_t *lba_to_phys_table; /* LBA to physical table */
|
||||
struct kfifo free_sectors; /* queue of free sectors */
|
||||
};
|
||||
|
||||
struct sm_ftl {
|
||||
struct mtd_blktrans_dev *trans;
|
||||
|
||||
struct mutex mutex; /* protects the structure */
|
||||
struct ftl_zone *zones; /* FTL tables for each zone */
|
||||
|
||||
/* Media information */
|
||||
int block_size; /* block size in bytes */
|
||||
int zone_size; /* zone size in blocks */
|
||||
int zone_count; /* number of zones */
|
||||
int max_lba; /* maximum lba in a zone */
|
||||
int smallpagenand; /* 256 bytes/page nand */
|
||||
int readonly; /* is FS readonly */
|
||||
int unstable;
|
||||
int cis_block; /* CIS block location */
|
||||
int cis_boffset; /* CIS offset in the block */
|
||||
int cis_page_offset; /* CIS offset in the page */
|
||||
void *cis_buffer; /* tmp buffer for cis reads */
|
||||
|
||||
/* Cache */
|
||||
int cache_block; /* block number of cached block */
|
||||
int cache_zone; /* zone of cached block */
|
||||
unsigned char *cache_data; /* cached block data */
|
||||
long unsigned int cache_data_invalid_bitmap;
|
||||
int cache_clean;
|
||||
struct work_struct flush_work;
|
||||
struct timer_list timer;
|
||||
|
||||
/* Async erase stuff */
|
||||
struct completion erase_completion;
|
||||
|
||||
/* Geometry stuff */
|
||||
int heads;
|
||||
int sectors;
|
||||
int cylinders;
|
||||
|
||||
struct attribute_group *disk_attributes;
|
||||
};
|
||||
|
||||
struct chs_entry {
|
||||
unsigned long size;
|
||||
unsigned short cyl;
|
||||
unsigned char head;
|
||||
unsigned char sec;
|
||||
};
|
||||
|
||||
|
||||
#define SM_FTL_PARTN_BITS 3
|
||||
|
||||
#define sm_printk(format, ...) \
|
||||
printk(KERN_WARNING "sm_ftl" ": " format "\n", ## __VA_ARGS__)
|
||||
|
||||
#define dbg(format, ...) \
|
||||
if (debug) \
|
||||
printk(KERN_DEBUG "sm_ftl" ": " format "\n", ## __VA_ARGS__)
|
||||
|
||||
#define dbg_verbose(format, ...) \
|
||||
if (debug > 1) \
|
||||
printk(KERN_DEBUG "sm_ftl" ": " format "\n", ## __VA_ARGS__)
|
||||
|
||||
|
||||
static void sm_erase_callback(struct erase_info *self);
|
||||
static int sm_erase_block(struct sm_ftl *ftl, int zone_num, uint16_t block,
|
||||
int put_free);
|
||||
static void sm_mark_block_bad(struct sm_ftl *ftl, int zone_num, int block);
|
||||
|
||||
static int sm_recheck_media(struct sm_ftl *ftl);
|
Loading…
Reference in New Issue
Block a user