aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mtd/sm_ftl.h
diff options
context:
space:
mode:
authorMaxim Levitsky <maximlevitsky@gmail.com>2010-02-22 13:39:41 -0500
committerDavid Woodhouse <David.Woodhouse@intel.com>2010-02-26 14:06:50 -0500
commit7d17c02a01a111f40986859f044c8c4cce8a4aa6 (patch)
treeb9fec0a8ad3073e3d7ca442fc1db17b054974e66 /drivers/mtd/sm_ftl.h
parenta7790532f5b7358c33a6b1834dc2b318de209f31 (diff)
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>
Diffstat (limited to 'drivers/mtd/sm_ftl.h')
-rw-r--r--drivers/mtd/sm_ftl.h94
1 files changed, 94 insertions, 0 deletions
diff --git a/drivers/mtd/sm_ftl.h b/drivers/mtd/sm_ftl.h
new file mode 100644
index 000000000000..e30e48e7f63d
--- /dev/null
+++ b/drivers/mtd/sm_ftl.h
@@ -0,0 +1,94 @@
1/*
2 * Copyright © 2009 - Maxim Levitsky
3 * SmartMedia/xD translation layer
4 *
5 * Based loosly on ssfdc.c which is
6 * © 2005 Eptar srl
7 * Author: Claudio Lanconelli <lanconelli.claudio@eptar.com>
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License version 2 as
11 * published by the Free Software Foundation.
12 */
13
14#include <linux/mtd/blktrans.h>
15#include <linux/kfifo.h>
16#include <linux/sched.h>
17#include <linux/completion.h>
18#include <linux/mtd/mtd.h>
19
20
21
22struct ftl_zone {
23 int initialized;
24 int16_t *lba_to_phys_table; /* LBA to physical table */
25 struct kfifo free_sectors; /* queue of free sectors */
26};
27
28struct sm_ftl {
29 struct mtd_blktrans_dev *trans;
30
31 struct mutex mutex; /* protects the structure */
32 struct ftl_zone *zones; /* FTL tables for each zone */
33
34 /* Media information */
35 int block_size; /* block size in bytes */
36 int zone_size; /* zone size in blocks */
37 int zone_count; /* number of zones */
38 int max_lba; /* maximum lba in a zone */
39 int smallpagenand; /* 256 bytes/page nand */
40 int readonly; /* is FS readonly */
41 int unstable;
42 int cis_block; /* CIS block location */
43 int cis_boffset; /* CIS offset in the block */
44 int cis_page_offset; /* CIS offset in the page */
45 void *cis_buffer; /* tmp buffer for cis reads */
46
47 /* Cache */
48 int cache_block; /* block number of cached block */
49 int cache_zone; /* zone of cached block */
50 unsigned char *cache_data; /* cached block data */
51 long unsigned int cache_data_invalid_bitmap;
52 int cache_clean;
53 struct work_struct flush_work;
54 struct timer_list timer;
55
56 /* Async erase stuff */
57 struct completion erase_completion;
58
59 /* Geometry stuff */
60 int heads;
61 int sectors;
62 int cylinders;
63
64 struct attribute_group *disk_attributes;
65};
66
67struct chs_entry {
68 unsigned long size;
69 unsigned short cyl;
70 unsigned char head;
71 unsigned char sec;
72};
73
74
75#define SM_FTL_PARTN_BITS 3
76
77#define sm_printk(format, ...) \
78 printk(KERN_WARNING "sm_ftl" ": " format "\n", ## __VA_ARGS__)
79
80#define dbg(format, ...) \
81 if (debug) \
82 printk(KERN_DEBUG "sm_ftl" ": " format "\n", ## __VA_ARGS__)
83
84#define dbg_verbose(format, ...) \
85 if (debug > 1) \
86 printk(KERN_DEBUG "sm_ftl" ": " format "\n", ## __VA_ARGS__)
87
88
89static void sm_erase_callback(struct erase_info *self);
90static int sm_erase_block(struct sm_ftl *ftl, int zone_num, uint16_t block,
91 int put_free);
92static void sm_mark_block_bad(struct sm_ftl *ftl, int zone_num, int block);
93
94static int sm_recheck_media(struct sm_ftl *ftl);