Skip to contentSkip to conversation

mflash: Initial support

PATCH In review unsik Kim 2 participants 7 messages Feb 25, 2009 – Mar 6, 2009

Subsystems (2)
lore
Share & tools
lore

unsik Kim

author
#0 lore raw

PATCH 1/1 mflash: Initial support

This driver supports mflash IO mode for linux.

Mflash is embedded flash drive and mainly targeted mobile and consumer electronic devices.

Internally, mflash has nand flash and other hardware logics and supports 2 different operation (ATA, IO) modes. ATA mode doesn't need any new driver and currently works well under standard IDE subsystem. Actually it's one chip SSD. IO mode is ATA-like custom mode for the host that doesn't have IDE interface.

Followings are brief descriptions about IO mode.
A. IO mode based on ATA protocol and uses some custom command. (read confirm, write confirm)
B. IO mode uses SRAM bus interface.
C. IO mode supports 4kB boot area, so host can boot from mflash.

---
Hello?

I already posted mflash patch before and many people comments for it. Unfotunately I broke my local git, so I can't generate git diff for old one. From now I'll post patches for this one as reference.

Here are some brief change status.
All the style issue from checkpatch fixed.
Documentation added.
reserved area feature added.
suspend, resume feature added.
remove currently not supported code.

I restrict this driver for ARM cause only tested for that arch. Is it right thing ?

I really appreciate for previous comments and any further comments are very very welcome.

---
 Documentation/blockdev/00-INDEX   |    2 +
 Documentation/blockdev/mflash.txt |   73 +++
 drivers/block/Kconfig             |   17 +
 drivers/block/Makefile            |    1 +
 drivers/block/mg_disk.c           |  981 +++++++++++++++++++++++++++++++++++++
 include/linux/mg_disk.h           |  173 +++++++
 6 files changed, 1247 insertions(+), 0 deletions(-)
 create mode 100644 Documentation/blockdev/mflash.txt
 create mode 100644 drivers/block/mg_disk.c
 create mode 100644 include/linux/mg_disk.h
Documentation/blockdev/00-INDEX +2 -0
index 86f054c..c08df56 100644
@@ -8,6 +8,8 @@ cpqarray.txt
 	- info on using Compaq's SMART2 Intelligent Disk Array Controllers.
 floppy.txt
 	- notes and driver options for the floppy disk driver.
+mflash.txt
+	- info on mGine m(g)flash driver for linux.
 nbd.txt
 	- info on a TCP implementation of a network block device.
 paride.txt
Documentation/blockdev/mflash.txt new file +73 -0

73 lines not on this page · raw message

drivers/block/Kconfig +17 -0
index 0344a8a..88ad8e7 100644
@@ -403,6 +403,23 @@ config ATA_OVER_ETH
 	This driver provides Support for ATA over Ethernet block
 	devices like the Coraid EtherDrive (R) Storage Blade.
 
+config MG_DISK
+	tristate "mGine mflash, gflash support"
+	depends on ARM
+	help
+	  mGine mFlash(gFlash) block device driver
+
+config MG_DISK_RES
+	int "Size of reserved area before MBR"
+	depends on MG_DISK
+	default 0
+	help
+	  Define size of reserved area that usually used for boot. Unit is KB.
+	  All of the block device operation will be taken this value as start
+	  offset
+	  Examples:
+			1024 => 1 MB
+
 config SUNVDC
 	tristate "Sun Virtual Disk Client support"
 	depends on SUN_LDOMS
drivers/block/Makefile +1 -0
index 204332b..79dd7c7 100644
@@ -19,6 +19,7 @@ obj-$(CONFIG_BLK_CPQ_CISS_DA)  += cciss.o
 obj-$(CONFIG_BLK_DEV_DAC960)	+= DAC960.o
 obj-$(CONFIG_XILINX_SYSACE)	+= xsysace.o
 obj-$(CONFIG_CDROM_PKTCDVD)	+= pktcdvd.o
+obj-$(CONFIG_MG_DISK)		+= mg_disk.o
 obj-$(CONFIG_SUNVDC)		+= sunvdc.o
 
 obj-$(CONFIG_BLK_DEV_UMEM)	+= umem.o
drivers/block/mg_disk.c new file +981 -0

981 lines not on this page · raw message

include/linux/mg_disk.h new file +173 -0

173 lines not on this page · raw message

Signature · 4 lines
1.5.6.6

Regards,
unsik Kim
#1 lore raw
Quoted 11 lines · On Wed, 25 Feb 2009 18:31:14 +0900 unsik Kim <[email protected]> wrote:

This driver supports mflash IO mode for linux.

Mflash is embedded flash drive and mainly targeted mobile and consumer electronic devices.

Internally, mflash has nand flash and other hardware logics and supports 2 different operation (ATA, IO) modes. ATA mode doesn't need any new driver and currently works well under standard IDE subsystem. Actually it's one chip SSD. IO mode is ATA-like custom mode for the host that doesn't have IDE interface.

Quoted 6 lines

Followings are brief descriptions about IO mode.
A. IO mode based on ATA protocol and uses some custom command. (read confirm, write confirm)
B. IO mode uses SRAM bus interface.
C. IO mode supports 4kB boot area, so host can boot from mflash.

Have we fully explored the option of controlling this device with the current ATA or IDE code, rather than creating a whole new parallel block device implementation?

Quoted 29 lines

...

drivers/block/mg_disk.c new file +23 -0
@@ -0,0 +1,981 @@
+/*
+ *  drivers/block/mg_disk.c
+ *
+ *  Support for the mGine m[g]flash IO mode.
+ *  Based on legacy hd.c
+ *
+ * (c) 2008 mGine Co.,LTD
+ * (c) 2008 unsik Kim <[email protected]>
+ *
+ *  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/kernel.h>
+#include <linux/module.h>
+#include <linux/fs.h>
+#include <linux/blkdev.h>
+#include <linux/hdreg.h>
+#include <linux/interrupt.h>
+#include <linux/delay.h>
+#include <linux/platform_device.h>
+#include <linux/gpio.h>

drivers/block/mg_disk.c line 33

Quoted 10 lines
drivers/block/mg_disk.c new file +10 -0
+#include <linux/mg_disk.h>
+
+#define MG_RES_SEC (CONFIG_MG_DISK_RES << 1)
+
+static void mg_request(struct request_queue *);
+
+static void mg_dump_status(const char *msg, unsigned int stat,
+		struct mg_host *host)
+{
+	char *name = MG_DISK_NAME"?";

The "?" seems strange. Why do we want to print "mgd?" here?

Quoted 49 lines
drivers/block/mg_disk.c new file +49 -0
+	struct request *req;
+
+	if (host->breq) {
+		req = elv_next_request(host->breq);
+		if (req)
+			name = req->rq_disk->disk_name;
+	}
+
+	printk(KERN_DEBUG "%s: %s: status=0x%02x { ", name, msg, stat & 0xff);
+	if (stat & MG_REG_STATUS_BIT_BUSY)
+		printk("Busy ");
+	if (stat & MG_REG_STATUS_BIT_READY)
+		printk("DriveReady ");
+	if (stat & MG_REG_STATUS_BIT_WRITE_FAULT)
+		printk("WriteFault ");
+	if (stat & MG_REG_STATUS_BIT_SEEK_DONE)
+		printk("SeekComplete ");
+	if (stat & MG_REG_STATUS_BIT_DATA_REQ)
+		printk("DataRequest ");
+	if (stat & MG_REG_STATUS_BIT_CORRECTED_ERROR)
+		printk("CorrectedError ");
+	if (stat & MG_REG_STATUS_BIT_ERROR)
+		printk("Error ");
+	printk("}\n");
+	if ((stat & MG_REG_STATUS_BIT_ERROR) == 0) {
+		host->error = 0;
+	} else {
+		host->error = inb(host->dev_base + MG_REG_ERROR);
+		printk(KERN_DEBUG "%s: %s: error=0x%02x { ", name, msg,
+				host->error & 0xff);
+		if (host->error & MG_REG_ERR_BBK)
+			printk("BadSector ");
+		if (host->error & MG_REG_ERR_UNC)
+			printk("UncorrectableError ");
+		if (host->error & MG_REG_ERR_IDNF)
+			printk("SectorIdNotFound ");
+		if (host->error & MG_REG_ERR_ABRT)
+			printk("DriveStatusError ");
+		if (host->error & MG_REG_ERR_AMNF)
+			printk("AddrMarkNotFound ");
+		printk("}");
+		if (host->error &
+				(MG_REG_ERR_BBK | MG_REG_ERR_UNC |
+				 MG_REG_ERR_IDNF | MG_REG_ERR_AMNF)) {
+			if (host->breq) {
+				req = elv_next_request(host->breq);
+				if (req)
+					printk(", sector=%ld", req->sector);
+			}

drivers/block/mg_disk.c line 92

Quoted 10 lines
drivers/block/mg_disk.c new file +10 -0
+
+		}
+		printk("\n");
+	}
+}
+
+static unsigned int mg_wait(struct mg_host *host, u32 expect, u32 msec)
+{
+	u8 status;
+	u64 expire, cur_jiffies;

cur_jiffies64 would be a clearer name.

drivers/block/mg_disk.c line 95

Quoted 2 lines
drivers/block/mg_disk.c new file +2 -0
+	host->error = MG_ERR_NONE;
+	expire = get_jiffies_64() + msecs_to_jiffies(msec);

But why is this code using jiffies_64 at all? Why not use plain old jiffies and unsigned longs?

Quoted 13 lines
drivers/block/mg_disk.c new file +13 -0
+	status = inb(host->dev_base + MG_REG_STATUS);
+	do {
+		cur_jiffies = get_jiffies_64();
+		if (status & MG_REG_STATUS_BIT_BUSY) {
+			if (expect == MG_REG_STATUS_BIT_BUSY)
+				break;
+		} else {
+			/* Check the error condition! */
+			if (status & MG_REG_STATUS_BIT_ERROR) {
+				mg_dump_status("mg_wait", status, host);
+				break;
+			}
+

drivers/block/mg_disk.c line 119

Quoted 10 lines
drivers/block/mg_disk.c new file +10 -0
+			if (expect == MG_STAT_READY)
+				if (MG_READY_OK(status))
+					break;
+
+			if (expect == MG_REG_STATUS_BIT_DATA_REQ)
+				if (status & MG_REG_STATUS_BIT_DATA_REQ)
+					break;
+		}
+		status = inb(host->dev_base + MG_REG_STATUS);
+	} while (cur_jiffies < expire);

This loop will not handle jiffy wrap properly. Use time_after/time_before/etc.

drivers/block/mg_disk.c line 121

Quoted 1 line
drivers/block/mg_disk.c new file +1 -0
+	if (cur_jiffies >= expire)

ditto.

drivers/block/mg_disk.c line 125

Quoted 4 lines
drivers/block/mg_disk.c new file +4 -0
+		host->error = MG_ERR_TIMEOUT;
+
+	return host->error;
+}

This function appears to be doing up-to-multi-second busy wait looping. Bad.

Can we fix this by waiting for some interrupt? Presumably not. Can we at least do something to prevent it from locking up the whole machine for long periods while it chews up vast amounts of power? Evan a silly msleep(1) in there would help tremendously.

Quoted 16 lines
drivers/block/mg_disk.c new file +16 -0
+static void mg_unexpected_intr(struct mg_host *host)
+{
+	u32 status = inb(host->dev_base + MG_REG_STATUS);
+
+	mg_dump_status("mg_unexpected_intr", status, host);
+}
+
+static irqreturn_t mg_irq(int irq, void *dev_id)
+{
+	struct mg_host *host = dev_id;
+	void (*handler)(struct mg_host *) = host->mg_do_intr;
+
+	host->mg_do_intr = 0;
+	del_timer(&host->timer);
+	if (!handler)
+		handler = mg_unexpected_intr;

drivers/block/mg_disk.c line 152

Quoted 10 lines
drivers/block/mg_disk.c new file +10 -0
+	handler(host);
+	return IRQ_HANDLED;
+}
+
+static void mg_ide_fixstring(u8 *s, const int bytecount)
+{
+	u8 *p, *end = &s[bytecount & ~1]; /* bytecount must be even */
+
+	/* convert from big-endian to host byte order */
+	for (p = s ; p != end ; p += 2)

It's more conventional to omit the space before the semicolon in `for' statements.

Quoted 5 lines
drivers/block/mg_disk.c new file +5 -0
+		be16_to_cpus((u16 *) p);
+
+	/* strip leading blanks */
+	p = s;
+	while (s != end && *s == ' ')

drivers/block/mg_disk.c line 167

Quoted 10 lines
drivers/block/mg_disk.c new file +10 -0
+		++s;
+	/* compress internal blanks and strip trailing blanks */
+	while (s != end && *s) {
+		if (*s++ != ' ' || (s != end && *s && *s != ' '))
+			*p++ = *(s-1);
+	}
+	/* wipe out trailing garbage */
+	while (p != end)
+		*p++ = '\0';
+}

erk, what's this doing? Regularizing some ID text which it read from the device, it seems.

It should have a nice comment explaining this, and perhaps explaining the transformations which it attempts to make.

Because I'm sure that there's library code in the kernel which does at least some of whatever-this-function-does. Steve Rostedt presently has some infrastructure code of this nature under review.

Quoted 26 lines
drivers/block/mg_disk.c new file +26 -0
+static int mg_get_disk_id(struct mg_host *host)
+{
+	u32 i, res;
+	s32 err;
+	u16 *id = (u16 *)&host->id_data;
+	struct mg_drv_data *prv_data = host->dev->platform_data;
+
+	if (!prv_data->use_polling)
+		outb(MG_REG_CTRL_INTR_DISABLE,
+				host->dev_base + MG_REG_DRV_CTRL);
+
+	outb(MG_CMD_ID, host->dev_base + MG_REG_COMMAND);
+	err = mg_wait(host, MG_REG_STATUS_BIT_DATA_REQ, 3000);
+	if (err)
+		return err;
+
+	for (i = 0; i < (MG_SECTOR_SIZE >> 1); i++)
+		id[i] = le16_to_cpu(inw(host->dev_base + MG_BUFF_OFFSET +
+					i * 2));
+
+	outb(MG_CMD_RD_CONF, host->dev_base + MG_REG_COMMAND);
+	err = mg_wait(host, MG_STAT_READY, 3000);
+	if (err)
+		return err;
+
+	if ((host->id_data.field_valid & 1) == 0)

drivers/block/mg_disk.c line 204

Quoted 10 lines
drivers/block/mg_disk.c new file +10 -0
+		return MG_ERR_TRANSLATION;
+
+#ifdef __BIG_ENDIAN
+	host->id_data.lba_capacity = (host->id_data.lba_capacity << 16)
+		| (host->id_data.lba_capacity >> 16);
+#endif /* __BIG_ENDIAN */
+	if (MG_RES_SEC) {
+		/* modify cyls, lba_capacity */
+		host->id_data.cyls = (host->id_data.lba_capacity - MG_RES_SEC) /
+			host->id_data.heads / host->id_data.sectors;

Could a bad device trick the kernel into doing a divide-by-zero here?

Quoted 26 lines
drivers/block/mg_disk.c new file +23 -0
+		res = host->id_data.lba_capacity - host->id_data.cyls *
+			host->id_data.heads * host->id_data.sectors;
+		host->id_data.lba_capacity -= res;
+	}
+	host->tot_sectors = host->id_data.lba_capacity;
+	mg_ide_fixstring(host->id_data.model,
+			sizeof(host->id_data.model));
+	mg_ide_fixstring(host->id_data.serial_no,
+			sizeof(host->id_data.serial_no));
+	mg_ide_fixstring(host->id_data.fw_rev,
+			sizeof(host->id_data.fw_rev));
+	printk(KERN_INFO "mg_disk: model: %s\n", host->id_data.model);
+	printk(KERN_INFO "mg_disk: firm: %.8s\n", host->id_data.fw_rev);
+	printk(KERN_INFO "mg_disk: serial: %s\n",
+			host->id_data.serial_no);
+	printk(KERN_INFO "mg_disk: %d + reserved %d sectors\n",
+			host->tot_sectors, res);
+
+	if (!prv_data->use_polling)
+		outb(MG_REG_CTRL_INTR_ENABLE, host->dev_base + MG_REG_DRV_CTRL);
+
+	return err;
+}
 
...
 

drivers/block/mg_disk.c

Quoted 10 lines
drivers/block/mg_disk.c new file +10 -0
+static int mg_resume(struct platform_device *plat_dev)
+{
+	struct mg_drv_data *prv_data = plat_dev->dev.platform_data;
+	struct mg_host *host = prv_data->host;
+
+	if (mg_wait(host, MG_STAT_READY, 3000))
+		return -EIO;
+
+	outb(MG_CMD_WAKEUP, host->dev_base + MG_REG_COMMAND);
+	mdelay(1);

There's no way in which the reader of this code can determine why this delay is here, and why it has this duration. Comments shold be added to fix this!

Can we avoid using a busy-waiting delay?

Quoted 22 lines
drivers/block/mg_disk.c new file +22 -0
+	if (mg_wait(host, MG_STAT_READY, 3000))
+		return -EIO;
+
+	if (!prv_data->use_polling)
+		outb(MG_REG_CTRL_INTR_ENABLE, host->dev_base + MG_REG_DRV_CTRL);
+
+	return 0;
+}
+
+static int mg_probe(struct platform_device *plat_dev)
+{
+	struct mg_host *host;
+	struct resource *rsc;
+	struct mg_drv_data *prv_data = plat_dev->dev.platform_data;
+	int err = 0;
+
+	if (!prv_data) {
+		printk(KERN_ERR	"%s:%d fail (no driver_data)\n",
+				__func__, __LINE__);
+		err = -EINVAL;
+		goto probe_err;
+	}

drivers/block/mg_disk.c line 755

Quoted 10 lines
drivers/block/mg_disk.c new file +10 -0
+
+	/* alloc mg_host */
+	host = kmalloc(sizeof(struct mg_host), GFP_KERNEL);
+	if (!host) {
+		printk(KERN_ERR "%s:%d fail (no memory for mg_host)\n",
+				__func__, __LINE__);
+		err = -ENOMEM;
+		goto probe_err;
+	}
+	memset(host, 0, sizeof(struct mg_host));

use kzalloc()

Quoted 5 lines
drivers/block/mg_disk.c new file +5 -0
+	host->major = MG_DISK_MAJ;
+
+	/* link each other */
+	prv_data->host = host;
+	host->dev = &plat_dev->dev;

drivers/block/mg_disk.c line 770

Quoted 10 lines
drivers/block/mg_disk.c new file +10 -0
+
+	/* io remap */
+	rsc = platform_get_resource(plat_dev, IORESOURCE_MEM, 0);
+	if (!rsc) {
+		printk(KERN_ERR "%s:%d platform_get_resource fail\n",
+				__func__, __LINE__);
+		err = -EINVAL;
+		goto probe_err_2;
+	}
+	host->dev_base = (unsigned long)ioremap(rsc->start , rsc->end + 1);

ioremap() returns `void __iomem *'. Casting it into an unsigned long loses the sparse-checkable annotation and loses the (correct) information that this is an address.

IOW, host->dev_base has the wrong type, doesn't it?

Quoted 13 lines
drivers/block/mg_disk.c new file +13 -0
+	if (!host->dev_base) {
+		printk(KERN_ERR "%s:%d ioremap fail\n",
+				__func__, __LINE__);
+		err = -EIO;
+		goto probe_err_2;
+	}
+	MG_DBG("dev_base = 0x%x\n", (u32)host->dev_base);
+
+	/* get reset pin */
+	rsc = platform_get_resource(plat_dev, IORESOURCE_IO, 0);
+	if (!rsc) {
+		printk(KERN_ERR "%s:%d get reset pin fail\n",
+				__func__, __LINE__);

drivers/block/mg_disk.c line 793

Quoted 10 lines
drivers/block/mg_disk.c new file +10 -0
+		err = -EIO;
+		goto probe_err_3;
+	}
+	host->rst = rsc->start;
+
+	/* init rst pin */
+	err = gpio_request(host->rst, "mg_rst");
+	if (err)
+		goto probe_err_3;
+	gpio_direction_output(host->rst, 1);

Did this driver express a dependency on GPIO in its Kconfig?

Quoted 12 lines
drivers/block/mg_disk.c new file +9 -0
+	/* disk init */
+	err = mg_disk_init(host);
+	if (err) {
+		printk(KERN_ERR "%s:%d fail (err code : %d)\n",
+				__func__, __LINE__, err);
+		err = -EIO;
+		goto probe_err_3a;
+	}
+
 
...
author
#2 lore raw

Hello?

First of all, thanks for your kind review and sorry for very late reply.

Quoted 5 lines

Have we fully explored the option of controlling this device with the current ATA or IDE code, rather than creating a whole new parallel block device implementation?

As you see, this driver quite similar with ATA code. (especially PATA platform device driver) I think integrating with ATA is possible. But, I think integration is not adequate at this time.

Because,

1. ATA layer deals standard ATA protocol. ATA layer have many low- level device specific interface, but data transfer keeps ATA rule. But, mflash IO mode doesn't.

2. Even though currently not used in mflash driver code, mflash has some custom command and modes. (nand fusing, firmware patch, etc) If this feature supported in linux kernel, ATA layer more altered.

3. Currently PATA platform device driver doesn't support interrupt. (I'm not sure) But, mflash uses interrupt (polling mode is just for debug).

4. mflash is somewhat under-develop product. Even though some company already using mflash their own product, I think more time is needed for standardization of custom command and mode. That time (maybe October) I will talk to with ATA people. If they accept integration, I will integrate.

All the other requests will be reflected with upcoming patch.

Signature · 1 line
unsik Kim <[email protected]>
#3 lore raw
Quoted 8 lines · On Thu, 5 Mar 2009 18:24:47 +0900 unsik Kim <[email protected]> wrote:

1. ATA layer deals standard ATA protocol. ATA layer have many low- level device specific interface, but data transfer keeps ATA rule. But, mflash IO mode doesn't.

2. Even though currently not used in mflash driver code, mflash has some custom command and modes. (nand fusing, firmware patch, etc) If this feature supported in linux kernel, ATA layer more altered.

Quoted 8 lines

3. Currently PATA platform device driver doesn't support interrupt. (I'm not sure) But, mflash uses interrupt (polling mode is just for debug).

4. mflash is somewhat under-develop product. Even though some company already using mflash their own product, I think more time is needed for standardization of custom command and mode. That time (maybe October) I will talk to with ATA people. If they accept integration, I will integrate.

Thsi is fairly important information. Please include it in the changelog for the patch, and maintain it.

author
#4 lore raw

PATCH 1/1 mflash: Initial support

This driver supports mflash IO mode for linux.

Mflash is embedded flash drive and mainly targeted mobile and consumer electronic devices.

Internally, mflash has nand flash and other hardware logics and supports 2 different operation (ATA, IO) modes. ATA mode doesn't need any new driver and currently works well under standard IDE subsystem. Actually it's one chip SSD. IO mode is ATA-like custom mode for the host that doesn't have IDE interface.

Followings are brief descriptions about IO mode.
A. IO mode based on ATA protocol and uses some custom command. (read confirm, write confirm)
B. IO mode uses SRAM bus interface.
C. IO mode supports 4kB boot area, so host can boot from mflash.

This driver is quitely simillar with standard ATA driver, but cause of following reasons currently seperated with ATA layer.

1. ATA layer deals standard ATA protocol. ATA layer have many low- level device specific interface, but data transfer keeps ATA rule. But, mflash IO mode doesn't.

2. Even though currently not used in mflash driver code, mflash has some custom command and modes. (nand fusing, firmware patch, etc) If this feature supported in linux kernel, ATA layer more altered.

3. Currently PATA platform device driver doesn't support interrupt. (I'm not sure) But, mflash uses interrupt (polling mode is just for debug).

4. mflash is somewhat under-develop product. Even though some company already using mflash their own product, I think more time is needed for standardization of custom command and mode. That time (maybe October) I will talk to with ATA people. If they accept integration, I will integrate.

---
Hello?

I don't know how to patch change log. (I wonder it is possible or not) So I resend my first patch again. Only Change log changes.

Regards,
unsik Kim

---
 Documentation/blockdev/00-INDEX   |    2 +
 Documentation/blockdev/mflash.txt |   73 +++
 drivers/block/Kconfig             |   17 +
 drivers/block/Makefile            |    1 +
 drivers/block/mg_disk.c           |  981 +++++++++++++++++++++++++++++++++++++
 include/linux/mg_disk.h           |  173 +++++++
 6 files changed, 1247 insertions(+), 0 deletions(-)
 create mode 100644 Documentation/blockdev/mflash.txt
 create mode 100644 drivers/block/mg_disk.c
 create mode 100644 include/linux/mg_disk.h
Documentation/blockdev/00-INDEX +2 -0
index 86f054c..c08df56 100644
@@ -8,6 +8,8 @@ cpqarray.txt
 	- info on using Compaq's SMART2 Intelligent Disk Array Controllers.
 floppy.txt
 	- notes and driver options for the floppy disk driver.
+mflash.txt
+	- info on mGine m(g)flash driver for linux.
 nbd.txt
 	- info on a TCP implementation of a network block device.
 paride.txt
Documentation/blockdev/mflash.txt new file +73 -0

73 lines not on this page · raw message

drivers/block/Kconfig +17 -0
index 0344a8a..88ad8e7 100644
@@ -403,6 +403,23 @@ config ATA_OVER_ETH
 	This driver provides Support for ATA over Ethernet block
 	devices like the Coraid EtherDrive (R) Storage Blade.
 
+config MG_DISK
+	tristate "mGine mflash, gflash support"
+	depends on ARM
+	help
+	  mGine mFlash(gFlash) block device driver
+
+config MG_DISK_RES
+	int "Size of reserved area before MBR"
+	depends on MG_DISK
+	default 0
+	help
+	  Define size of reserved area that usually used for boot. Unit is KB.
+	  All of the block device operation will be taken this value as start
+	  offset
+	  Examples:
+			1024 => 1 MB
+
 config SUNVDC
 	tristate "Sun Virtual Disk Client support"
 	depends on SUN_LDOMS
drivers/block/Makefile +1 -0
index 204332b..79dd7c7 100644
@@ -19,6 +19,7 @@ obj-$(CONFIG_BLK_CPQ_CISS_DA)  += cciss.o
 obj-$(CONFIG_BLK_DEV_DAC960)	+= DAC960.o
 obj-$(CONFIG_XILINX_SYSACE)	+= xsysace.o
 obj-$(CONFIG_CDROM_PKTCDVD)	+= pktcdvd.o
+obj-$(CONFIG_MG_DISK)		+= mg_disk.o
 obj-$(CONFIG_SUNVDC)		+= sunvdc.o
 
 obj-$(CONFIG_BLK_DEV_UMEM)	+= umem.o
drivers/block/mg_disk.c new file +981 -0

981 lines not on this page · raw message

include/linux/mg_disk.h new file +173 -0

173 lines not on this page · raw message

Signature · 1 line
1.5.6.6
author
#5 lore raw

PATCH v2 1/1 mflash: Initial support v2

In reply to Andrew Morton

[2009.03.05]
* refine and reduce mg_wait's timeout value
* remove pointless "?"
* use correct jiffy wrap
* replace local mg_ide_fixstring to libata_core's
* avoid divide-by-zero
* change host->dev_base type to 'void __iomem *'
* add missing GPIOLIB and ATA dependency
(All the changes above this line comments by Andrew Morton)
* reduce probing time:
mflash spends a lot of time in reset.
(the first time hard reset after power on > hard reset > soft reset) add dev_attr field to mg_drv_data and reset-out GPIO resource for avoid duplicate reset sequence

---
This is same as <[email protected]> titled "[PATCH] mflash: reflect akpm's review". Only change change log and title. (because old title was not suitable and need more explanation in change log)

Regards,
unsik Kim

---
 Documentation/blockdev/mflash.txt |   13 ++-
 drivers/block/Kconfig             |    2 +-
 drivers/block/mg_disk.c           |  352 ++++++++++++++++++++-----------------
 include/linux/mg_disk.h           |   57 +++++--
 4 files changed, 246 insertions(+), 178 deletions(-)
Documentation/blockdev/mflash.txt +12 -1
index d7522eb..1f610ec 100644
@@ -36,6 +36,8 @@ configuration file is all. Here is some pseudo example.
 static struct mg_drv_data mflash_drv_data = {
 	/* If you want to polling driver set to 1 */
 	.use_polling = 0,
+	/* device attribution */
+	.dev_attr = MG_BOOT_DEV
 };
 
 static struct resource mg_mflash_rsc[] = {
@@ -55,9 +57,18 @@ static struct resource mg_mflash_rsc[] = {
 	[2] = {
 		.start = 43,
 		.end = 43,
-		.name = "mg_rst",
+		.name = MG_RST_PIN,
 		.flags = IORESOURCE_IO
 	},
+	/* mflash reset-out pin
+	 * If you use mflash as storage device (i.e. other than MG_BOOT_DEV),
+	 * should assign this */
+	[3] = {
+		.start = 51,
+		.end = 51,
+		.name = MG_RSTOUT_PIN,
+		.flags = IORESOURCE_IO
+	}
 };
 
 static struct platform_device mflash_dev = {
drivers/block/Kconfig +1 -1
index 88ad8e7..8d32823 100644
@@ -405,7 +405,7 @@ config ATA_OVER_ETH
 
 config MG_DISK
 	tristate "mGine mflash, gflash support"
-	depends on ARM
+	depends on ARM && ATA && GPIOLIB
 	help
 	  mGine mFlash(gFlash) block device driver
 
drivers/block/mg_disk.c +188 -164

687 lines not on this page · raw message

include/linux/mg_disk.h +45 -12

93 lines not on this page · raw message

Signature · 1 line
1.5.6.6
#6 lore raw

Re: [PATCH v2] mflash: Initial support v2

Quoted 3 lines · On Fri, 6 Mar 2009 11:29:10 +0900 unsik Kim <[email protected]> wrote:

This is same as <[email protected]> titled "[PATCH] mflash: reflect akpm's review". Only change change log and title. (because old title was not suitable and need more explanation in change log)

OK, that worked, thanks.

I merged both patches into my tree, with the intention of sending them on to Jens for review and possible integration via the block tree. (IOW: ping!!!!).

Please cc jens on future emails regarding this driver, thanks.