linux-sh.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] mtd: sh_flctl SHBUSSEL and SEL_16BIT support
@ 2010-01-27  9:17 Magnus Damm
  2010-02-01 11:00 ` Yoshihiro Shimoda
  0 siblings, 1 reply; 7+ messages in thread
From: Magnus Damm @ 2010-01-27  9:17 UTC (permalink / raw)
  To: linux-mtd; +Cc: Magnus Damm, lethal, shimoda.yoshihiro, dwmw2, linux-sh

From: Magnus Damm <damm@opensource.se>

This patch extends the sh_flctl driver with support
for 16-bit bus configuration using SEL_16BIT and
support for multiplexed pins using SHBUSSEL.

Signed-off-by: Magnus Damm <damm@opensource.se>
---

 drivers/mtd/nand/sh_flctl.c  |   27 ++++++++++++++++++++++++++-
 include/linux/mtd/sh_flctl.h |    2 ++
 2 files changed, 28 insertions(+), 1 deletion(-)

--- 0015/drivers/mtd/nand/sh_flctl.c
+++ work/drivers/mtd/nand/sh_flctl.c	2010-01-26 23:25:33.000000000 +0900
@@ -105,6 +105,8 @@ static void set_addr(struct mtd_info *mt
 		addr = page_addr;	/* ERASE1 */
 	} else if (page_addr != -1) {
 		/* SEQIN, READ0, etc.. */
+		if (flctl->chip.options & NAND_BUSWIDTH_16)
+			column >>= 1;
 		if (flctl->page_size) {
 			addr = column & 0x0FFF;
 			addr |= (page_addr & 0xff) << 16;
@@ -280,7 +282,7 @@ static void write_fiforeg(struct sh_flct
 static void set_cmd_regs(struct mtd_info *mtd, uint32_t cmd, uint32_t flcmcdr_val)
 {
 	struct sh_flctl *flctl = mtd_to_flctl(mtd);
-	uint32_t flcmncr_val = readl(FLCMNCR(flctl));
+	uint32_t flcmncr_val = readl(FLCMNCR(flctl)) & ~SEL_16BIT;
 	uint32_t flcmdcr_val, addr_len_bytes = 0;
 
 	/* Set SNAND bit if page size is 2048byte */
@@ -302,6 +304,8 @@ static void set_cmd_regs(struct mtd_info
 	case NAND_CMD_READOOB:
 		addr_len_bytes = flctl->rw_ADRCNT;
 		flcmdcr_val |= CDSRC_E;
+		if (flctl->chip.options & NAND_BUSWIDTH_16)
+			flcmncr_val |= SEL_16BIT;
 		break;
 	case NAND_CMD_SEQIN:
 		/* This case is that cmd is READ0 or READ1 or READ00 */
@@ -310,6 +314,8 @@ static void set_cmd_regs(struct mtd_info
 	case NAND_CMD_PAGEPROG:
 		addr_len_bytes = flctl->rw_ADRCNT;
 		flcmdcr_val |= DOCMD2_E | CDSRC_E | SELRW;
+		if (flctl->chip.options & NAND_BUSWIDTH_16)
+			flcmncr_val |= SEL_16BIT;
 		break;
 	case NAND_CMD_READID:
 		flcmncr_val &= ~SNAND_E;
@@ -528,6 +534,8 @@ static void flctl_cmdfunc(struct mtd_inf
 		set_addr(mtd, 0, page_addr);
 
 		flctl->read_bytes = mtd->writesize + mtd->oobsize;
+		if (flctl->chip.options & NAND_BUSWIDTH_16)
+			column >>= 1;
 		flctl->index += column;
 		goto read_normal_exit;
 
@@ -691,6 +699,18 @@ static uint8_t flctl_read_byte(struct mt
 	return data;
 }
 
+static uint16_t flctl_read_word(struct mtd_info *mtd)
+{
+       struct sh_flctl *flctl = mtd_to_flctl(mtd);
+       int index = flctl->index;
+       uint16_t data;
+       uint16_t *buf = (uint16_t *)&flctl->done_buff[index];
+
+       data = *buf;
+       flctl->index += 2;
+       return data;
+}
+
 static void flctl_read_buf(struct mtd_info *mtd, uint8_t *buf, int len)
 {
 	int i;
@@ -829,6 +849,11 @@ static int __devinit flctl_probe(struct 
 	nand->select_chip = flctl_select_chip;
 	nand->cmdfunc = flctl_cmdfunc;
 
+	if (pdata->flcmncr_val & SEL_16BIT) {
+		nand->options |= NAND_BUSWIDTH_16;
+		nand->read_word = flctl_read_word;
+	}
+
 	ret = nand_scan_ident(flctl_mtd, 1);
 	if (ret)
 		goto err;
--- 0015/include/linux/mtd/sh_flctl.h
+++ work/include/linux/mtd/sh_flctl.h	2010-01-26 22:54:42.000000000 +0900
@@ -51,6 +51,8 @@
 #define _4ECCCNTEN	(0x1 << 24)
 #define _4ECCEN		(0x1 << 23)
 #define _4ECCCORRECT	(0x1 << 22)
+#define SHBUSSEL	(0x1 << 20)
+#define SEL_16BIT	(0x1 << 19)
 #define SNAND_E		(0x1 << 18)	/* SNAND (0Q2 1 48)*/
 #define QTSEL_E		(0x1 << 17)
 #define ENDIAN		(0x1 << 16)	/* 1 = little endian */

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2010-03-18  7:59 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-01-27  9:17 [PATCH] mtd: sh_flctl SHBUSSEL and SEL_16BIT support Magnus Damm
2010-02-01 11:00 ` Yoshihiro Shimoda
2010-01-27  9:11   ` [PATCH] mtd: trivial sh_flctl changes Magnus Damm
2010-02-01 10:59     ` Yoshihiro Shimoda
2010-02-02  4:04       ` Paul Mundt
2010-03-18  7:54     ` David Woodhouse
2010-03-18  7:59       ` Magnus Damm

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).