From patchwork Wed Jan 27 09:17:21 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Magnus Damm X-Patchwork-Id: 75422 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter.kernel.org (8.14.3/8.14.2) with ESMTP id o0R9Nse9030961 for ; Wed, 27 Jan 2010 09:23:54 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751866Ab0A0JXv (ORCPT ); Wed, 27 Jan 2010 04:23:51 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1752695Ab0A0JXu (ORCPT ); Wed, 27 Jan 2010 04:23:50 -0500 Received: from mail-yx0-f188.google.com ([209.85.210.188]:47210 "EHLO mail-yx0-f188.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751866Ab0A0JXt (ORCPT ); Wed, 27 Jan 2010 04:23:49 -0500 Received: by yxe26 with SMTP id 26so4659552yxe.4 for ; Wed, 27 Jan 2010 01:23:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:from:to:cc:date:message-id :subject; bh=M6Yh1NQt8BV9FJPCe3wJwwETSWCdA8NrJhJ5QWIN3T4=; b=QPG5wjqhQaQfjW/8iIdQL7691TMEMyn7mujI/XmueyLqxKa+LkGJkWZVAa7ovCHfvN PP1BphdDZpIvHB81NkREn2OIvfukGCQ+/WdsipEtp704ekt525NnGHQZ7Ud7Vat5JBM1 4vRyndTMsQsBZzdae6uDhJA/dZ5WLP947wCIs= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=from:to:cc:date:message-id:subject; b=lyQAOl5dZErc3psM/a5FHm6jemSLfhOlZ9vk6fUymQyfPwtHGliC7bi1R2zZY3c50j NYnVEhI412wnjyWfPX05YizvxKeIjRAmstvZWLqpwHaAJdTCAP2eQcYGnrEgLq72x7/9 ekRK4Naf04b5MQC+hEVwdUYMss0h+JMOJp6lw= Received: by 10.150.118.24 with SMTP id q24mr7361137ybc.119.1264584228828; Wed, 27 Jan 2010 01:23:48 -0800 (PST) Received: from rxone.opensource.se (49.14.32.202.bf.2iij.net [202.32.14.49]) by mx.google.com with ESMTPS id 23sm2347921yxe.18.2010.01.27.01.23.45 (version=TLSv1/SSLv3 cipher=RC4-MD5); Wed, 27 Jan 2010 01:23:47 -0800 (PST) From: Magnus Damm To: linux-mtd@lists.infradead.org Cc: shimoda.yoshihiro@renesas.com, Magnus Damm , lethal@linux-sh.org, dwmw2@infradead.org, linux-sh@vger.kernel.org Date: Wed, 27 Jan 2010 18:17:21 +0900 Message-Id: <20100127091721.21320.90312.sendpatchset@rxone.opensource.se> Subject: [PATCH] mtd: sh_flctl SHBUSSEL and SEL_16BIT support Sender: linux-sh-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-sh@vger.kernel.org --- 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 (0=512 1=2048)*/ #define QTSEL_E (0x1 << 17) #define ENDIAN (0x1 << 16) /* 1 = little endian */