Skip to contentSkip to conversation

Add ssfdc read-only translation layer

PATCH In review Claudio Lanconelli 2 participants 4 messages Jun 22, 2006 – Aug 25, 2006

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Add ssfdc read-only translation layer

Hi,
here is another try.
Now it builds fine against git mtd-2.6, however I can't test if it works anymore after the changes, my target system at the moment doesn't support kernel 2.6, sigh!

One question, I use major number 44 (since it's the number used by old ssfdc.c) but I don't know if it's the correct number.

drivers/mtd/nand/Kconfig +16 -0
index 3db77ee..462c4ce 100644
@@ -31,6 +31,22 @@ config MTD_NAND_ECC_SMC
 	  Software ECC according to the Smart Media Specification.
 	  The original Linux implementation had byte 0 and 1 swapped.
 
+config MTD_NAND_SSFDC_READONLY
+	bool "NAND SSFDC (SmartMedia) read only translation layer"
+	depends on MTD_NAND
+	default n
+	help
+	  This enable read only access to SmartMedia formatted Nand
+	  flash. You can mount it with FAT file system.
+
+config MTD_NAND_SSFDC_GETGEO
+	bool "Enable SmartMedia standard geometry CHS"
+	depends on MTD_NAND_SSFDC_READONLY
+	default n
+	help
+	  This forces the get geometry system call to return standard
+	  CHS values for SmartMedia.
+
 config MTD_NAND_AUTCPU12
 	tristate "SmartMediaCard on autronix autcpu12 board"
 	depends on MTD_NAND && ARCH_AUTCPU12
drivers/mtd/nand/Makefile +1 -0
index f747593..adee70e 100644
@@ -22,5 +22,6 @@ obj-$(CONFIG_MTD_NAND_TS7250)		+= ts7250
 obj-$(CONFIG_MTD_NAND_NANDSIM)		+= nandsim.o
 obj-$(CONFIG_MTD_NAND_CS553X)		+= cs553x_nand.o
 obj-$(CONFIG_MTD_NAND_NDFC)		+= ndfc.o
+obj-$(CONFIG_MTD_NAND_SSFDC_READONLY)	+= ssfdc_ro.o
 
 nand-objs = nand_base.o nand_bbt.o
drivers/mtd/nand/ssfdc_ro.c new file +484 -0

484 lines not on this page · raw message

#1 lore raw
Quoted 5 lines · Claudio Lanconelli

Hi,
here is another try.
Now it builds fine against git mtd-2.6, however I can't test if it works anymore after the changes,
my target system at the moment doesn't support kernel 2.6, sigh!

Thanks.

Quoted 2 lines

One question, I use major number 44 (since it's the number used by old ssfdc.c) but I don't know if it's the correct number.

It isn't. Please send mail to [email protected] requesting a new major number.

Also, why is the GETGEO stuff conditional? Why not just build it in always? And do we need the table? Can't we just calculate it? There's code to do similar calculations in NFTL already.

Signature · 1 line
dwmw2
#2 lore raw
Quoted 6 lines · David Woodhouse
Quoted 2 lines

One question, I use major number 44 (since it's the number used by old ssfdc.c) but I don't know if it's the correct number.

It isn't. Please send mail to [email protected] requesting a new major number.

Done, I'm waiting for a reply.

Quoted 2 lines

Also, why is the GETGEO stuff conditional? Why not just build it in always?

You're right, no need for conditional. I removed it and tested the code with getgeo code. I'll prepare the patch again without it.

Quoted 4 lines

And do we need the table? Can't we just calculate it? There's code to do similar calculations in NFTL already.

SSFDC specifications recommends the exact CHS combinations of the table in the code to maintain data compatibility. It may works even with NTFL calculations but with different CHS values. Why not the table?

#3 lore raw
In reply to David Woodhouse

Hi,

Quoted 7 lines
Quoted 3 lines

One question, I use major number 44 (since it's the number used by old ssfdc.c) but I don't know if it's the correct number.

It isn't. Please send mail to [email protected] requesting a new major number.

It takes some time but finally I got a new major number:

257 block SSFDC Flash Translation Layer filesystem
0 = /dev/ssfdca First SSFDC layer
8 = /dev/ssfdcb Second SSFDC layer
16 = /dev/ssfdcc Third SSFDC layer
24 = /dev/ssfdcd 4th SSFDC layer
32 = /dev/ssfdce 5th SSFDC layer
40 = /dev/ssfdcf 6th SSFDC layer
48 = /dev/ssfdcg 7th SSFDC layer
56 = /dev/ssfdch 8th SSFDC layer

Quoted 5 lines

Also, why is the GETGEO stuff conditional? Why not just build it in always? And do we need the table? Can't we just calculate it? There's code to do similar calculations in NFTL already.

and also I removed GETGETO conditional stuffs.
New version in the attachment

Cheers,
Claudio Lanconelli

drivers/mtd/nand/Kconfig +8 -0
index 3db77ee..e66226f 100644
@@ -31,6 +31,14 @@ config MTD_NAND_ECC_SMC
 	  Software ECC according to the Smart Media Specification.
 	  The original Linux implementation had byte 0 and 1 swapped.
 
+config MTD_NAND_SSFDC_READONLY
+	bool "NAND SSFDC (SmartMedia) read only translation layer"
+	depends on MTD_NAND
+	default n
+	help
+	  This enable read only access to SmartMedia formatted Nand
+	  flash. You can mount it with FAT file system.
+
 config MTD_NAND_AUTCPU12
 	tristate "SmartMediaCard on autronix autcpu12 board"
 	depends on MTD_NAND && ARCH_AUTCPU12
drivers/mtd/nand/Makefile +1 -0
index f747593..adee70e 100644
@@ -22,5 +22,6 @@ obj-$(CONFIG_MTD_NAND_TS7250)		+= ts7250
 obj-$(CONFIG_MTD_NAND_NANDSIM)		+= nandsim.o
 obj-$(CONFIG_MTD_NAND_CS553X)		+= cs553x_nand.o
 obj-$(CONFIG_MTD_NAND_NDFC)		+= ndfc.o
+obj-$(CONFIG_MTD_NAND_SSFDC_READONLY)	+= ssfdc_ro.o
 
 nand-objs = nand_base.o nand_bbt.o
drivers/mtd/nand/ssfdc_ro.c +4 -20
old mode 100755
new mode 100644
index 30a16ea..d2e7643
@@ -20,16 +20,12 @@ #include <linux/mtd/mtd.h>
 #include <linux/mtd/nand.h>
 #include <linux/mtd/blktrans.h>
 
-/* #undef CONFIG_MTD_NAND_SSFDC_GETGEO */
-
 struct ssfdcr_record {
 	struct mtd_blktrans_dev mbd;
 	int usecount;
-#ifdef CONFIG_MTD_NAND_SSFDC_GETGEO
 	unsigned char heads;
 	unsigned char sectors;
 	unsigned short cylinders;
-#endif
 	int cis_block;			/* block n. containing CIS/IDI */
 	int erase_size;			/* phys_block_size */
 	unsigned short *logic_block_map; /* all zones (max 8192 phys blocks on
@@ -37,8 +33,7 @@ #endif
 	int map_len;			/* n. phys_blocks on the card */
 };
 
-
-#define SSFDCR_MAJOR		44
+#define SSFDCR_MAJOR		257
 #define SSFDCR_PARTN_BITS	3
 
 #define SECTOR_SIZE		512
@@ -60,8 +55,6 @@ SumSector	2,000	4,000	8,000	16,000	32,00
 SectorSize	512	512	512	512	512	512	512	512
 **/
 
-#ifdef CONFIG_MTD_NAND_SSFDC_GETGEO
-
 typedef struct {
 	unsigned long size;
 	unsigned short cyl;
@@ -104,14 +97,12 @@ static int get_chs(unsigned long size, u
 
 	return found;
 }
-#endif
 
 /* These bytes are the signature for the CIS/IDI sector */
 static const uint8_t cis_numbers[] = {
 	0x01, 0x03, 0xD9, 0x01, 0xFF, 0x18, 0x02, 0xDF, 0x01, 0x20
 };
 
-
 /* Read and check for a valid CIS sector */
 static int get_valid_cis_sector(struct mtd_info *mtd)
 {
@@ -140,7 +131,7 @@ static int get_valid_cis_sector(struct m
 				/* Found */
 				cis_sector = (int)(offset >> SECTOR_SHIFT);
 			} else {
-				DEBUG(MTD_DEBUG_LEVEL0,
+				DEBUG(MTD_DEBUG_LEVEL1,
 					"SSFDC_RO: CIS/IDI sector not found"
 					" on %s (mtd%d)\n", mtd->name,
 					mtd->index);
@@ -245,7 +236,6 @@ static int get_logical_address(uint8_t *
 	return block_address;
 }
 
-
 /* Build the logic block map */
 static int build_logical_block_map(struct ssfdcr_record *ssfdc)
 {
@@ -330,8 +320,9 @@ static void ssfdcr_add_mtd(struct mtd_bl
 		(ssfdc->map_len + MAX_PHYS_BLK_PER_ZONE - 1) /
 		MAX_PHYS_BLK_PER_ZONE);
 
-#ifdef CONFIG_MTD_NAND_SSFDC_GETGEO
 	/* Set geometry */
+	ssfdc->heads = 16;
+	ssfdc->sectors = 32;
 	get_chs( mtd->size, NULL, &ssfdc->heads, &ssfdc->sectors);
 	ssfdc->cylinders = (unsigned short)((mtd->size >> SECTOR_SHIFT) /
 			((long)ssfdc->sectors * (long)ssfdc->heads));
@@ -343,9 +334,6 @@ #ifdef CONFIG_MTD_NAND_SSFDC_GETGEO
 
 	ssfdc->mbd.size = (long)ssfdc->heads * (long)ssfdc->cylinders *
 				(long)ssfdc->sectors;
-#else
-	ssfdc->mbd.size  = ssfdc->map_len * (ssfdc->erase_size >> SECTOR_SHIFT);
-#endif
 
 	/* Allocate logical block map */
 	ssfdc->logic_block_map = kmalloc( sizeof(ssfdc->logic_block_map[0]) *
@@ -429,7 +417,6 @@ static int ssfdcr_readsect(struct mtd_bl
 	return 0;
 }
 
-#ifdef CONFIG_MTD_NAND_SSFDC_GETGEO
 static int ssfdcr_getgeo(struct mtd_blktrans_dev *dev,  struct hd_geometry *geo)
 {
 	struct ssfdcr_record *ssfdc = (struct ssfdcr_record *)dev;
@@ -443,7 +430,6 @@ static int ssfdcr_getgeo(struct mtd_blkt
 
 	return 0;
 }
-#endif
 
 /****************************************************************************
  *
@@ -455,9 +441,7 @@ static struct mtd_blktrans_ops ssfdcr_tr
 	.name		= "ssfdc",
 	.major		= SSFDCR_MAJOR,
 	.part_bits	= SSFDCR_PARTN_BITS,
-#ifdef CONFIG_MTD_NAND_SSFDC_GETGEO
 	.getgeo		= ssfdcr_getgeo,
-#endif
 	.readsect	= ssfdcr_readsect,
 	.add_mtd	= ssfdcr_add_mtd,
 	.remove_dev	= ssfdcr_remove_dev,