2 * Copyright © 2009 - Maxim Levitsky
3 * SmartMedia/xD translation layer
5 * Based loosly on ssfdc.c which is
7 * Author: Claudio Lanconelli <lanconelli.claudio@eptar.com>
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.
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>
24 int16_t *lba_to_phys_table
; /* LBA to physical table */
25 struct kfifo free_sectors
; /* queue of free sectors */
29 struct mtd_blktrans_dev
*trans
;
31 struct mutex mutex
; /* protects the structure */
32 struct ftl_zone
*zones
; /* FTL tables for each zone */
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 bool readonly
; /* is FS readonly */
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 */
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
;
53 struct work_struct flush_work
;
54 struct timer_list timer
;
61 struct attribute_group
*disk_attributes
;
72 #define SM_FTL_PARTN_BITS 3
74 #define sm_printk(format, ...) \
75 printk(KERN_WARNING "sm_ftl" ": " format "\n", ## __VA_ARGS__)
77 #define dbg(format, ...) \
79 printk(KERN_DEBUG "sm_ftl" ": " format "\n", ## __VA_ARGS__)
81 #define dbg_verbose(format, ...) \
83 printk(KERN_DEBUG "sm_ftl" ": " format "\n", ## __VA_ARGS__)
86 static int sm_erase_block(struct sm_ftl
*ftl
, int zone_num
, uint16_t block
,
88 static void sm_mark_block_bad(struct sm_ftl
*ftl
, int zone_num
, int block
);
90 static int sm_recheck_media(struct sm_ftl
*ftl
);