RFC: [PATCH 0/9 Integration of SmartMedia/xD into mtd subsystem
Subsystems (2)
Here is the result of my work of supporting an xD card reader that I have on my notebook.
I had to fix few problems in mtd translation layer, add few workarounds. This is by no way a final version of the patches, there is still lot of cleanup to do.
The patches weren't tested with checkpatch.pl for example.
I can now read and write an xD card, and I have no crashes. Still following issues remain:
1 - Write speed IS very SLOW, just about 200 Kbytes/s
In fact a reader in my printer gives me about 330 Kbytes/s, thus partially card is to blame.
Also, hardware doesn't support interrupts to test when card is ready, thus writes consume 100% of one cpu.
2 - I rely on mtd driver to have empty oob layout so I can read both oob and data using ->read_oob with MTD_OOB_PLACE.
I thinking to add new mode to allow to read whole oob + data and check ecc, or I will have to do pointless copying of data from 'censored' oob to normal structure. (This applies to FTL driver I also include in this patchset)
3 - Using the mtd device directly with anything but supplied FTL or SSFDC, on 'modern' xD cards just doesn't. These cards implement a fake nand command set, thus don't have a real oob.
It was disappointing for me too.
I suspect that all 'Type M' cards are of this fake type, but older cards are OK.
4 - Suspend/resume support works, but relies on all mtd users not to suspend in middle of card access, bacause in this case its very difficult/impossible to know card state.
Driver will refuse suspend in that case.
Access via all block devices is safe.
5 - And of course there are bugs, thus I warn you now that this driver has high probability to erase data from your card.
Thus DON'T USE THIS DRIVER IF ANYTHING IMPORTANT IS STORED ON THE CARD.
6 - driver only detects PCI ID of my notebook, so it might not load on compatable chips with different ID.
7 - patches developed against stable 2.6.32, and won't compile against latest git due to changes in kfifo api.
Feedback is welcome, flames too :-)
Best regards,
Maxim Levitsky
PATCH 1/9 MTD: call remove notifiers before removing the device
Quoted 1 line
From
d8cb6b03919de5ab1587cd4340c684f2c468aec7Mon Sep 17 00:00:00 2001
From: Maxim Levitsky <[email protected]>
Date: Tue, 5 Jan 2010 22:29:31 +0200
Subject: [PATCH 1/9] MTD: call remove notifiers before removing the device, so users
have chance to free the mtd device
--- drivers/mtd/mtdcore.c | 21 +++++++++++---------- 1 files changed, 11 insertions(+), 10 deletions(-)
drivers/mtd/mtdcore.c +11 -10
@@ -341,31 +341,32 @@ int add_mtd_device(struct mtd_info *mtd)int del_mtd_device (struct mtd_info *mtd) {int ret; +struct mtd_notifier *not;mutex_lock (&mtd_table_mutex);if (mtd_table[mtd->index] != mtd) { ret = -ENODEV ; - }else if (mtd->usecount) { + goto out_error; + } + +/* No need to get a refcount on the module containing +the notifier, since we hold the mtd_table_mutex */ +list_for_each_entry (not, &mtd_notifiers, list) + not->remove (mtd); + +if (mtd->usecount) {printk (KERN_NOTICE "Removing MTD device #%d (%s) with use count %d\n" , mtd->index, mtd->name, mtd->usecount); ret = -EBUSY ; }else { -struct mtd_notifier *not; -device_unregister (&mtd->dev); - -/* No need to get a refcount on the module containing -the notifier, since we hold the mtd_table_mutex */ -list_for_each_entry (not, &mtd_notifiers, list) - not->remove (mtd); - mtd_table[mtd->index] =NULL ; -module_put (THIS_MODULE ); ret =0 ; } +out_error:mutex_unlock (&mtd_table_mutex);return ret; }
Signature · 1 line
1.6.3.3
PATCH 2/9 MTD: create lockless versions of {get,put}_mtd_device
In reply to Maxim LevitskyQuoted 1 line
From
10333e0ed6dc7b176f2dfce04f08572f9e1b04ceMon Sep 17 00:00:00 2001
From: Maxim Levitsky <[email protected]>
Date: Tue, 5 Jan 2010 22:29:31 +0200
Subject: [PATCH 2/9] MTD: create lockless versions of {get,put}_mtd_device
This will be used to resolve deadlock in block translation layer
--- drivers/mtd/mtdcore.c | 55 +++++++++++++++++++++++++++------------------- include/linux/mtd/mtd.h | 3 +- 2 files changed, 34 insertions(+), 24 deletions(-)
drivers/mtd/mtdcore.c +32 -23
@@ -454,27 +454,30 @@ struct mtd_info *get_mtd_device(struct mtd_info *mtd, int num) ret =NULL ; } -if (!ret) - goto out_unlock; - -if (!try_module_get (ret->owner)) - goto out_unlock; - -if (ret->get_device) { - err = ret->get_device (ret); -if (err) - goto out_put; - } +if (!ret || (err =__get_mtd_device (ret))) + ret =ERR_PTR (err); - ret->usecount++;mutex_unlock (&mtd_table_mutex);return ret; +} -out_put: -module_put (ret->owner); -out_unlock: -mutex_unlock (&mtd_table_mutex); -return ERR_PTR (err); + +int __get_mtd_device (struct mtd_info *mtd) +{ +int err; + +if (!try_module_get (mtd->owner)) +return -ENODEV ; + +if (mtd->get_device) { + +if ((err = mtd->get_device (mtd))) { +module_put (mtd->owner); +return err; + } + } + mtd->usecount++; +return 0 ; }/**
@@ -525,18 +528,22 @@ out_unlock:void put_mtd_device (struct mtd_info *mtd) { -int c; -mutex_lock (&mtd_table_mutex); - c = --mtd->usecount; -if (mtd->put_device) - mtd->put_device (mtd); +__put_mtd_device (mtd);mutex_unlock (&mtd_table_mutex); -BUG_ON (c <0 );module_put (mtd->owner); } +void __put_mtd_device (struct mtd_info *mtd) +{ + --mtd->usecount; +BUG_ON (mtd->usecount <0 ); + +if (mtd->put_device) + mtd->put_device (mtd); +} +/* default_mtd_writev - default mtd writev method for MTD devices that * don't implement their own */
@@ -570,7 +577,9 @@ EXPORT_SYMBOL_GPL(add_mtd_device);EXPORT_SYMBOL_GPL (del_mtd_device);EXPORT_SYMBOL_GPL (get_mtd_device);EXPORT_SYMBOL_GPL (get_mtd_device_nm); +EXPORT_SYMBOL_GPL (__get_mtd_device);EXPORT_SYMBOL_GPL (put_mtd_device); +EXPORT_SYMBOL_GPL (__put_mtd_device);EXPORT_SYMBOL_GPL (register_mtd_user);EXPORT_SYMBOL_GPL (unregister_mtd_user);EXPORT_SYMBOL_GPL (default_mtd_writev);
include/linux/mtd/mtd.h +2 -1
@@ -290,8 +290,9 @@ extern int add_mtd_device(struct mtd_info *mtd);extern int del_mtd_device (struct mtd_info *mtd);extern struct mtd_info *get_mtd_device (struct mtd_info *mtd,int num); +extern int __get_mtd_device (struct mtd_info *mtd); +extern void __put_mtd_device (struct mtd_info *mtd);extern struct mtd_info *get_mtd_device_nm (const char *name); -extern void put_mtd_device (struct mtd_info *mtd);
Signature · 1 line
1.6.3.3
PATCH 3/9 MTD: blkdevs: major cleanups
In reply to Maxim LevitskyQuoted 1 line
From
ebc405ef4e2bcf14870e1b17fb3e356f1a20980cMon Sep 17 00:00:00 2001
From: Maxim Levitsky <[email protected]>
Date: Tue, 5 Jan 2010 23:25:12 +0200
Subject: [PATCH 3/9] MTD: blkdevs: major cleanups.
* Make disk queue and thread per mtd device
* Handle the case of mtd device diappearence correctly
--- drivers/mtd/ftl.c | 1 - drivers/mtd/inftlcore.c | 1 - drivers/mtd/mtd_blkdevs.c | 237 ++++++++++++++++++++++++++--------------- drivers/mtd/mtdblock.c | 1 - drivers/mtd/mtdblock_ro.c | 1 - drivers/mtd/mtdcore.c | 3 +- drivers/mtd/nftlcore.c | 1 - drivers/mtd/rfd_ftl.c | 1 - drivers/mtd/ssfdc.c | 1 - include/linux/mtd/blktrans.h | 13 ++- 10 files changed, 160 insertions(+), 100 deletions(-)
drivers/mtd/ftl.c +0 -1
@@ -1082,7 +1082,6 @@ static void ftl_remove_dev(struct mtd_blktrans_dev *dev) {del_mtd_blktrans_dev (dev);ftl_freepart ((partition_t *)dev); -kfree (dev); }static struct mtd_blktrans_ops ftl_tr = {
drivers/mtd/inftlcore.c +0 -1
@@ -139,7 +139,6 @@ static void inftl_remove_dev(struct mtd_blktrans_dev *dev)kfree (inftl->PUtable);kfree (inftl->VUtable); -kfree (inftl); }/*
drivers/mtd/mtd_blkdevs.c +150 -87
401 lines not on this page · raw message
drivers/mtd/mtdblock.c +0 -1
@@ -368,7 +368,6 @@ static void mtdblock_add_mtd(struct mtd_blktrans_ops *tr, struct mtd_info *mtd)static void mtdblock_remove_dev (struct mtd_blktrans_dev *dev) {del_mtd_blktrans_dev (dev); -kfree (dev); }static struct mtd_blktrans_ops mtdblock_tr = {
drivers/mtd/mtdblock_ro.c +0 -1
@@ -49,7 +49,6 @@ static void mtdblock_add_mtd(struct mtd_blktrans_ops *tr, struct mtd_info *mtd)static void mtdblock_remove_dev (struct mtd_blktrans_dev *dev) {del_mtd_blktrans_dev (dev); -kfree (dev); }static struct mtd_blktrans_ops mtdblock_tr = {
drivers/mtd/mtdcore.c +2 -1
@@ -532,7 +532,6 @@ void put_mtd_device(struct mtd_info *mtd)__put_mtd_device (mtd);mutex_unlock (&mtd_table_mutex); -module_put (mtd->owner); }void __put_mtd_device (struct mtd_info *mtd)
@@ -542,6 +541,8 @@ void __put_mtd_device(struct mtd_info *mtd)if (mtd->put_device) mtd->put_device (mtd); + +module_put (mtd->owner); }/* default_mtd_writev - default mtd writev method for MTD devices that
drivers/mtd/nftlcore.c +0 -1
@@ -126,7 +126,6 @@ static void nftl_remove_dev(struct mtd_blktrans_dev *dev)del_mtd_blktrans_dev (dev);kfree (nftl->ReplUnitTable);kfree (nftl->EUNtable); -kfree (nftl); }/*
drivers/mtd/rfd_ftl.c +0 -1
@@ -817,7 +817,6 @@ static void rfd_ftl_remove_dev(struct mtd_blktrans_dev *dev)vfree (part->sector_map);kfree (part->header_cache);kfree (part->blocks); -kfree (part); }static struct mtd_blktrans_ops rfd_ftl_tr = {
drivers/mtd/ssfdc.c +0 -1
@@ -375,7 +375,6 @@ static void ssfdcr_remove_dev(struct mtd_blktrans_dev *dev)del_mtd_blktrans_dev (dev);kfree (ssfdc->logic_block_map); -kfree (ssfdc); } static int ssfdcr_readsect(struct mtd_blktrans_dev *dev,
include/linux/mtd/blktrans.h +8 -5
@@ -24,10 +24,15 @@ struct mtd_blktrans_dev {int devnum;unsigned long size;int readonly; -void *blkcore_priv;/* gendisk in 2.5, devfs_handle in 2.4 */ -}; +int deleted; +int open; -struct blkcore_priv ;/* Differs for 2.4 and 2.5 kernels; private */ +struct gendisk *disk; +struct task_struct *thread; +struct request_queue *rq; +spinlock_t queue_lock; +void *priv; +};struct mtd_blktrans_ops {char *name;
@@ -60,8 +65,6 @@ struct mtd_blktrans_ops {struct list_head devs;struct list_head list;struct module *owner; - -struct mtd_blkcore_priv *blkcore_priv; };extern int register_mtd_blktrans (struct mtd_blktrans_ops *tr);
Signature · 1 line
1.6.3.3
PATCH 4/9 mtd-make mtdtrans thread suspend friendly
In reply to Maxim LevitskyQuoted 1 line
From
23892d5e002d63b7980742fa5445443547fcf8cfMon Sep 17 00:00:00 2001
From: Maxim Levitsky <[email protected]>
Date: Tue, 5 Jan 2010 23:25:19 +0200
Subject: [PATCH 4/9] mtd-make mtdtrans thread suspend friendly
--- drivers/mtd/mtd_blkdevs.c | 15 +++++++-------- 1 files changed, 7 insertions(+), 8 deletions(-)
drivers/mtd/mtd_blkdevs.c +7 -8
@@ -20,6 +20,7 @@#include <linux/init.h> #include <linux/mutex.h> #include <linux/kthread.h> +#include <linux/freezer.h> #include <asm/uaccess.h> #include "mtdcore.h"
@@ -79,37 +80,35 @@ static int mtd_blktrans_thread(void *arg)/* we might get involved when memory gets low, so use PF_MEMALLOC */ current->flags |=PF_MEMALLOC ; - -spin_lock_irq (rq->queue_lock); +set_freezable ();while (!kthread_should_stop ()) {int res; +try_to_freeze (); + +spin_lock_irq (rq->queue_lock);if (!req && !(req =blk_fetch_request (rq))) {set_current_state (TASK_INTERRUPTIBLE );spin_unlock_irq (rq->queue_lock);schedule (); -spin_lock_irq (rq->queue_lock);continue ; } -spin_unlock_irq (rq->queue_lock); +mutex_lock (&dev->lock); res =do_blktrans_request (dev->tr, dev, req);mutex_unlock (&dev->lock);spin_lock_irq (rq->queue_lock); -if (!__blk_end_request_cur (req, res)) req =NULL ; +spin_unlock_irq (rq->queue_lock); }if (req)__blk_end_request_all (req, -EIO ); - -spin_unlock_irq (rq->queue_lock); -return 0 ; }
Signature · 1 line
1.6.3.3
PATCH 5/9 NAND: export nand_do_read_oob and nand_do_write_oob
In reply to Maxim LevitskyQuoted 1 line
From
42a44a48f270f45e44595b6f3906df4a6cf28ba5Mon Sep 17 00:00:00 2001
From: Maxim Levitsky <[email protected]>
Date: Tue, 5 Jan 2010 23:25:20 +0200
Subject: [PATCH 5/9] NAND: export nand_do_read_oob and nand_do_write_oob
Drivers might need sane way to read/write oob area, but can't use mtd interface due to locking
--- drivers/mtd/nand/nand_base.c | 10 +++++----- include/linux/mtd/nand.h | 7 +++++++ 2 files changed, 12 insertions(+), 5 deletions(-)
drivers/mtd/nand/nand_base.c +5 -5
@@ -99,9 +99,6 @@ static struct nand_ecclayout nand_oob_128 = {static int nand_get_device (struct nand_chip *chip,struct mtd_info *mtd,int new_state); -static int nand_do_write_oob (struct mtd_info *mtd,loff_t to, -struct mtd_oob_ops *ops); -/* * For devices which display every fart in the system on a separate LED. Is * compiled away when LED support is disabled.
@@ -1458,7 +1455,7 @@ static int nand_write_oob_syndrome(struct mtd_info *mtd,* * NAND read out-of-band data from the spare area */ -static int nand_do_read_oob (struct mtd_info *mtd,loff_t from, +int nand_do_read_oob (struct mtd_info *mtd,loff_t from,struct mtd_oob_ops *ops) {int page, realpage, chipnr, sndcmd =1 ;
@@ -1993,7 +1990,7 @@ static int nand_write(struct mtd_info *mtd, loff_t to, size_t len,* * NAND write out-of-band */ -static int nand_do_write_oob (struct mtd_info *mtd,loff_t to, +int nand_do_write_oob (struct mtd_info *mtd,loff_t to,struct mtd_oob_ops *ops) {int chipnr, page, status, len;
@@ -2962,6 +2959,9 @@ EXPORT_SYMBOL_GPL(nand_scan);EXPORT_SYMBOL_GPL (nand_scan_ident);EXPORT_SYMBOL_GPL (nand_scan_tail);EXPORT_SYMBOL_GPL (nand_release); +EXPORT_SYMBOL_GPL (nand_do_read_oob); +EXPORT_SYMBOL_GPL (nand_do_write_oob); +static int __init nand_base_init (void ) {
include/linux/mtd/nand.h +7 -0
@@ -548,6 +548,13 @@ extern int nand_erase_nand(struct mtd_info *mtd, struct erase_info *instr,extern int nand_do_read (struct mtd_info *mtd,loff_t from,size_t len,size_t * retlen,uint8_t * buf); +extern int nand_do_read_oob (struct mtd_info *mtd,loff_t from, +struct mtd_oob_ops *ops); + +extern int nand_do_write_oob (struct mtd_info *mtd,loff_t to, +struct mtd_oob_ops *ops); + +/* * Constants for oob configuration */
Signature · 1 line
1.6.3.3
PATCH 6/9 mtd: common module for smartmedia/xD support
In reply to Maxim LevitskyQuoted 1 line
From
06cb6f7fa6d9c708ca0a208b33c6e3b5969aab44Mon Sep 17 00:00:00 2001
From: Maxim Levitsky <[email protected]>
Date: Wed, 6 Jan 2010 22:52:56 +0200
Subject: [PATCH 6/9] mtd: common module for smartmedia/xD support
--- drivers/mtd/Kconfig | 9 ++ drivers/mtd/Makefile | 1 + drivers/mtd/sm_common.c | 208 +++++++++++++++++++++++++++++++++++++++++++++++ drivers/mtd/sm_common.h | 31 +++++++ 4 files changed, 249 insertions(+), 0 deletions(-) create mode 100644 drivers/mtd/sm_common.c create mode 100644 drivers/mtd/sm_common.h
drivers/mtd/Kconfig +9 -0
@@ -25,6 +25,15 @@ config MTD_DEBUG_VERBOSE help Determines the verbosity level of the MTD debugging messages. +config MTD_NAND_SMARTMEDIA + boolean + +config MTD_SM_COMMON + depends on MTD_NAND + select MTD_NAND_SMARTMEDIA + tristate + default n + config MTD_TESTS tristate "MTD tests support" depends on m
drivers/mtd/Makefile +1 -0
@@ -7,6 +7,7 @@ obj-$(CONFIG_MTD) += mtd.o mtd-y := mtdcore.o mtdsuper.o mtdbdi.o mtd-$(CONFIG_MTD_PARTITIONS) += mtdpart.o +obj-$(CONFIG_MTD_SM_COMMON) += sm_common.o obj-$(CONFIG_MTD_CONCAT) += mtdconcat.o obj-$(CONFIG_MTD_REDBOOT_PARTS) += redboot.o obj-$(CONFIG_MTD_CMDLINE_PARTS) += cmdlinepart.o
drivers/mtd/sm_common.c new file +208 -0
209 lines not on this page · raw message
drivers/mtd/sm_common.h new file +31 -0
@@ -0,0 +1,31 @@ +/* +* Copyright (C) 2009 - Maxim Levitsky +* Common routines & support for SmartMedia/xD format +* +* 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/nand.h> + +struct sm_oob { +u32 reserved; +u8 data_status; +u8 block_status; +u8 lba_copy1[2 ]; +u8 ecc2[3 ]; +u8 lba_copy2[2 ]; +u8 ecc1[3 ]; +} __attribute__((packed)); + + +#define SM_SECTOR_SIZE 512 +#define SM_OOB_SIZE 16 +#define SM_SMALL_PAGE 256 + +extern int sm_register_device (struct mtd_info *mtd); +extern int sm_read_lba (struct sm_oob *oob); +extern void sm_write_lba (struct sm_oob *oob,u16 lba); +extern int sm_block_valid (struct sm_oob *oob); +extern int sm_sector_valid (struct sm_oob *oob);
Signature · 1 line
1.6.3.3
PATCH 7/9 NAND: add few workarounds for SmartMedia/xD chips.
In reply to Maxim LevitskyQuoted 1 line
From
3385017902902c80ce2110e7c5ae02abf296b8abMon Sep 17 00:00:00 2001
From: Maxim Levitsky <[email protected]>
Date: Wed, 6 Jan 2010 22:53:00 +0200
Subject: [PATCH 7/9] NAND: add few workarounds for SmartMedia/xD chips.
* Add seperate ID table
* Add support for mask rom devices
* Workaround for write protect status
--- drivers/mtd/nand/nand_base.c | 29 +++++++++++++++++++++-------- drivers/mtd/nand/nand_ids.c | 39 +++++++++++++++++++++++++++++++++++++++ drivers/mtd/sm_common.c | 2 +- include/linux/mtd/nand.h | 11 +++++++++++ 4 files changed, 72 insertions(+), 9 deletions(-)
drivers/mtd/nand/nand_base.c +21 -8
@@ -398,9 +398,17 @@ static int nand_default_block_markbad(struct mtd_info *mtd, loff_t ofs)static int nand_check_wp (struct mtd_info *mtd) {struct nand_chip *chip = mtd->priv; +int wp; +/* Check the WP bit */ chip->cmdfunc (mtd,NAND_CMD_STATUS ,-1 ,-1 ); -return (chip->read_byte (mtd) &NAND_STATUS_WP ) ?0 :1 ; + wp = (chip->read_byte (mtd) &NAND_STATUS_WP ) ?0 :1 ; + +/* broken xD cards report WP despite beeing writable */ +if (chip->options &NAND_BROKEN_XD ) +return 0 ; + +return wp; }/**
@@ -2505,14 +2513,18 @@ static struct nand_flash_dev *nand_get_flash_type(struct mtd_info *mtd, }/* Lookup the flash id */ -for (i =0 ; nand_flash_ids[i].name !=NULL ; i++) { -if (dev_id == nand_flash_ids[i].id) { - type = &nand_flash_ids[i]; +#ifdef CONFIG_MTD_NAND_SMARTMEDIA +if (chip->options &NAND_SMARTMEDIA ) + type = nand_smartmedia_flash_ids; + else +#endif + type = nand_flash_ids; + +for (i =0 ; type->name !=NULL ; type++) +if (dev_id == type->id)break ; - } - } -if (!type) +if (!type->name)return ERR_PTR (-ENODEV );if (!mtd->name)
@@ -2868,7 +2880,8 @@ int nand_scan_tail(struct mtd_info *mtd)/* Fill in remaining MTD driver data */ mtd->type =MTD_NANDFLASH ; - mtd->flags =MTD_CAP_NANDFLASH ; + mtd->flags = chip->options &NAND_ROM ?MTD_CAP_ROM : +MTD_CAP_NANDFLASH ; mtd->erase = nand_erase; mtd->point =NULL ; mtd->unpoint =NULL ;
drivers/mtd/nand/nand_ids.c +39 -0
@@ -127,6 +127,45 @@ struct nand_flash_dev nand_flash_ids[] = { {NULL,} }; +#ifdef CONFIG_MTD_NAND_SMARTMEDIA +struct nand_flash_dev nand_smartmedia_flash_ids[] = { + +/* SmartMedia */ + {"SmartMedia 1MiB 5V" ,0x6e ,256 ,1 ,0x1000 ,0 }, + {"SmartMedia 1MiB 3,3V" ,0xe8 ,256 ,1 ,0x1000 ,0 }, + {"SmartMedia 1MiB 3,3V" ,0xec ,256 ,1 ,0x1000 ,0 }, + {"SmartMedia 2MiB 3,3V" ,0xea ,256 ,2 ,0x1000 ,0 }, + {"SmartMedia 2MiB 5V" ,0x64 ,256 ,2 ,0x1000 ,0 }, + {"SmartMedia 2MiB 3,3V ROM" ,0x5d ,512 ,2 ,0x2000 ,NAND_ROM }, + {"SmartMedia 4MiB 3,3V" ,0xe3 ,512 ,4 ,0x2000 ,0 }, + {"SmartMedia 4MiB 3,3/5V" ,0xe5 ,512 ,4 ,0x2000 ,0 }, + {"SmartMedia 4MiB 5V" ,0x6b ,512 ,4 ,0x2000 ,0 }, + {"SmartMedia 4MiB 3,3V ROM" ,0xd5 ,512 ,4 ,0x2000 ,NAND_ROM }, + {"SmartMedia 8MiB 3,3V" ,0xe6 ,512 ,8 ,0x2000 ,0 }, + {"SmartMedia 8MiB 3,3V ROM" ,0xd6 ,512 ,8 ,0x2000 ,NAND_ROM }, + +/* xD / SmartMedia */ + {"SmartMedia/xD 16MiB 3,3V" ,0x73 ,512 ,16 ,0x4000 ,0 }, + {"SmartMedia 16MiB 3,3V ROM" ,0x57 ,512 ,16 ,0x4000 ,NAND_ROM }, + {"SmartMedia/xD 32MiB 3,3V" ,0x75 ,512 ,32 ,0x4000 ,0 }, + {"SmartMedia 32MiB 3,3V ROM" ,0x58 ,512 ,32 ,0x4000 ,NAND_ROM }, + {"SmartMedia/xD 64MiB 3,3V" ,0x76 ,512 ,64 ,0x4000 ,0 }, + {"SmartMedia 64MiB 3,3V ROM" ,0xd9 ,512 ,64 ,0x4000 ,NAND_ROM }, + {"SmartMedia/xD 128MiB 3,3V" ,0x79 ,512 ,128 ,0x4000 ,0 }, + {"SmartMedia 128MiB 3,3V ROM" ,0xda ,512 ,128 ,0x4000 ,NAND_ROM }, + {"SmartMedia/xD 256MiB 3,3V" ,0x71 ,512 ,256 ,0x4000 ,NAND_BROKEN_XD }, + {"SmartMedia 256MiB 3,3V ROM" ,0x5b ,512 ,256 ,0x4000 ,NAND_ROM }, + +/* xD only */ + {"xD 512MiB 3,3V" ,0xDC ,512 ,512 ,0x4000 ,NAND_BROKEN_XD }, + {"xD 1GiB 3,3V" ,0xD3 ,512 ,1024 ,0x4000 ,NAND_BROKEN_XD }, + {"xD 2GiB 3,3V" ,0xD5 ,512 ,2048 ,0x4000 ,NAND_BROKEN_XD }, + + {NULL ,} +}; +EXPORT_SYMBOL (nand_smartmedia_flash_ids); +#endif +/* * Manufacturer ID list */
drivers/mtd/sm_common.c +1 -1
@@ -181,7 +181,7 @@ int sm_register_device(struct mtd_info *mtd) {struct nand_chip *chip = (struct nand_chip *)mtd->priv; - chip->options |=NAND_SKIP_BBTSCAN |NAND_NO_AUTOINCR ; + chip->options |=NAND_SKIP_BBTSCAN |NAND_SMARTMEDIA |NAND_NO_AUTOINCR ; chip->block_bad = sm_block_bad; chip->block_markbad = sm_block_markbad;
include/linux/mtd/nand.h +11 -0
@@ -168,6 +168,11 @@ typedef enum {/* Chip does not allow subpage writes */ #define NAND_NO_SUBPAGE_WRITE 0x00000200 +/* Device is one of 'new' xD cards that expose fake nand command set */ +#define NAND_BROKEN_XD 0x00000400 + +/* Device behaves just like nand, but is readonly */ +#define NAND_ROM 0x00000800/* Options valid for Samsung large page devices */ #define NAND_SAMSUNG_LP_OPTIONS \
@@ -194,6 +199,11 @@ typedef enum {/* This option is defined if the board driver allocates its own buffers (e.g. because it needs them DMA-coherent */ #define NAND_OWN_BUFFERS 0x00040000 + +/* controller supports only xD/SmartMedia cards*/ +#define NAND_SMARTMEDIA 0x00080000 + +/* Options set by nand scan */ /* Nand scan has allocated controller struct */ #define NAND_CONTROLLER_ALLOC 0x80000000
@@ -468,6 +478,7 @@ struct nand_manufacturers { };extern struct nand_flash_dev nand_flash_ids[]; +extern struct nand_flash_dev nand_smartmedia_flash_ids[];extern struct nand_manufacturers nand_manuf_ids[];/**
Signature · 1 line
1.6.3.3
PATCH 8/9 mtd: SmartMedia/xD FTL
In reply to Maxim LevitskyQuoted 1 line
From
d9e0e1a8cb54011ed2775aa82e71e1a5ba3b5880Mon Sep 17 00:00:00 2001
From: Maxim Levitsky <[email protected]>
Date: Wed, 6 Jan 2010 23:06:24 +0200
Subject: [PATCH 8/9] mtd: SmartMedia/xD FTL
--- drivers/mtd/Kconfig | 12 + drivers/mtd/Makefile | 1 + drivers/mtd/sm_ftl.c | 1070 ++++++++++++++++++++++++++++++++++++++++++++++++++ drivers/mtd/sm_ftl.h | 79 ++++ 4 files changed, 1162 insertions(+), 0 deletions(-) create mode 100644 drivers/mtd/sm_ftl.c create mode 100644 drivers/mtd/sm_ftl.h
drivers/mtd/Kconfig +12 -0
@@ -313,6 +313,18 @@ 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 + select MTD_SM_COMMON + 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 MTD_OOPS tristate "Log panic/oops to an MTD buffer" depends on MTD
drivers/mtd/Makefile +1 -0
@@ -25,6 +25,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
drivers/mtd/sm_ftl.c new file +1070 -0
1,071 lines not on this page · raw message
drivers/mtd/sm_ftl.h new file +79 -0
79 lines not on this page · raw message
Signature · 1 line
1.6.3.3
PATCH 9/9 mtd: add nand driver for ricoh xD/SmartMedia reader
In reply to Maxim LevitskyQuoted 1 line
From
b1150984957b7a2b429d40173891098a035c8947Mon Sep 17 00:00:00 2001
From: Maxim Levitsky <[email protected]>
Date: Wed, 6 Jan 2010 23:06:28 +0200
Subject: [PATCH 9/9] mtd: add nand driver for ricoh xD/SmartMedia reader
--- MAINTAINERS | 6 + drivers/mtd/nand/Kconfig | 11 + drivers/mtd/nand/Makefile | 1 + drivers/mtd/nand/r822.c | 1014 +++++++++++++++++++++++++++++++++++++++++++++ drivers/mtd/nand/r822.h | 155 +++++++ 5 files changed, 1187 insertions(+), 0 deletions(-) create mode 100644 drivers/mtd/nand/r822.c create mode 100644 drivers/mtd/nand/r822.h
MAINTAINERS +6 -0
@@ -4466,6 +4466,12 @@ S: Maintained F: Documentation/rfkill.txt F: net/rfkill/ +RICOH SMARTMEDIA/XD DRIVER +M: Maxim Levitsky <[email protected]> +S: Maintained +F: drivers/mtd/nand/r822.c +F: drivers/mtd/nand/r822.h + RISCOM8 DRIVER S: Orphan F: Documentation/serial/riscom8.txt
drivers/mtd/nand/Kconfig +11 -0
@@ -106,6 +106,17 @@ config MTD_NAND_TS7250 config MTD_NAND_IDS tristate +config MTD_NAND_RICOH + tristate "Ricoh xD card reader" + default n + select MTD_SM_COMMON + help + Enable support for Ricoh xD card reader + You also need to enable ether + NAND SSFDC (SmartMedia) read only translation layer' or new + expermental, readwrite + 'SmartMedia/xD new translation layer' + config MTD_NAND_AU1550 tristate "Au1550/1200 NAND support" depends on SOC_AU1200 || SOC_AU1550
drivers/mtd/nand/Makefile +1 -0
@@ -42,5 +42,6 @@ obj-$(CONFIG_MTD_NAND_SOCRATES) += socrates_nand.o obj-$(CONFIG_MTD_NAND_TXX9NDFMC) += txx9ndfmc.o obj-$(CONFIG_MTD_NAND_W90P910) += w90p910_nand.o obj-$(CONFIG_MTD_NAND_NOMADIK) += nomadik_nand.o +obj-$(CONFIG_MTD_NAND_RICOH) += r822.o nand-objs := nand_base.o nand_bbt.o
drivers/mtd/nand/r822.c new file +1014 -0
1,014 lines not on this page · raw message
drivers/mtd/nand/r822.h new file +155 -0
155 lines not on this page · raw message
Signature · 1 line
1.6.3.3