From patchwork Wed Apr 5 08:37:42 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Guochun Mao X-Patchwork-Id: 747176 X-Patchwork-Delegate: cyrille.pitchen@atmel.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3vyggf659Qz9s7g for ; Wed, 5 Apr 2017 19:35:42 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="MKXxex3X"; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=infradead.org header.i=@infradead.org header.b="gcasDPW4"; dkim-atps=neutral DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=y9ZrEZlLvI8SI6kYnAfwSs3ejdYQztRUw0FFLmAoNag=; b=MKXxex3Xuijv7w vLvRqfTW38MWvZISxIshj7LuJR4zHp2W1aEHTFccmI/pY6R0l38j85iewXVCnFYlU0D5IUB6r99nJ RumQ8oDTYOnfCm7hJuLUaS80az9O7zeGl8slIh2UoKj1Ptlh8FOOTxyogmCPpWX67Gj3jvE4unRyC N/JLPH16xK2coNWdepwPK3DR8tWTNRl0ZU0VjrszQPW3jJLo2BuGvr2PW4TDRKzINCX1vqD1wwudH EVdtkZpJR+EZNAantBZ0n9itJ3UpzEvI5sYuEi9gvXblb/dHuBTT0GxITUPU5sH/huD7YLqxLjPPJ p9vlMo+sJsJEkLDMXFYg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1cvhLm-00019d-7J; Wed, 05 Apr 2017 09:35:38 +0000 Received: from casper.infradead.org ([2001:770:15f::2]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1cvgXb-0002jR-Vu; Wed, 05 Apr 2017 08:43:50 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Type:MIME-Version:References: In-Reply-To:Message-ID:Date:Subject:CC:To:From:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=OxQtlJiIijoJlL0jmfgvtlzgNA5e254MldUnCr942g0=; b=gcasDPW4ebkfC2xQb4rThUQCw 7Z3WQwHnzy80Z/De1ktgnXxb0LPgwM00Zye1JoHmwLnHSosCWfZVqAZtTBEIPWBcLj3sBcfNv2fsr zOjGGR3jgDL+VC2Kwbs/4MfWbRSiRhz3mvdBITzOgxnJEPYfblwXYPhahItEDzL20K9eCsUKGNTL1 CT//8R4dNIpWMOr7+l1vSd3Z1LgTxejnpMV0DtS/U/rDLMoYhJG1mA/aFlx63RZ2nq99Og48I/IDP kwzH/EkjMevCa8g0TvPX3u5DsdqB8db3yOuEvd0z8ia6JN2E7EfSMpFVFTMMTeGjTR864WK4uWCmv Wqn5QO71Q==; Received: from [210.61.82.184] (helo=mailgw02.mediatek.com) by casper.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1cvgXP-0003sT-KT; Wed, 05 Apr 2017 08:43:37 +0000 Received: from mtkhts09.mediatek.inc [(172.21.101.70)] by mailgw02.mediatek.com (envelope-from ) (mhqrelay.mediatek.com ESMTP with TLS) with ESMTP id 690629061; Wed, 05 Apr 2017 16:38:47 +0800 Received: from mhfsdcap03.mhfswrd (10.17.3.153) by mtkhts09.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 14.3.266.1; Wed, 5 Apr 2017 16:38:46 +0800 From: Guochun Mao To: Cyrille Pitchen Subject: [PATCH v1 1/1] mtd: mtk-nor: set controller's address width according to nor flash Date: Wed, 5 Apr 2017 16:37:42 +0800 Message-ID: <1491381462-21893-2-git-send-email-guochun.mao@mediatek.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1491381462-21893-1-git-send-email-guochun.mao@mediatek.com> References: <1491381462-21893-1-git-send-email-guochun.mao@mediatek.com> MIME-Version: 1.0 X-MTK: N X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170405_094335_978629_87F32258 X-CRM114-Status: GOOD ( 17.91 ) X-Spam-Score: -1.1 (-) X-Spam-Report: SpamAssassin version 3.4.1 on casper.infradead.org summary: Content analysis details: (-1.1 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 SPF_PASS SPF: sender matches SPF record -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] 0.8 RDNS_NONE Delivered to internal network by a host with no rDNS 0.0 UNPARSEABLE_RELAY Informational: message has unparseable relay lines X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mark Rutland , devicetree@vger.kernel.org, Guochun Mao , Richard Weinberger , Russell King , linux-kernel@vger.kernel.org, Rob Herring , linux-mtd@lists.infradead.org, Matthias Brugger , linux-mediatek@lists.infradead.org, David Woodhouse , linux-arm-kernel@lists.infradead.org Sender: "linux-mtd" Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org When nor's size larger than 16MByte, nor's address width maybe set to 3 or 4, and controller should change address width according to nor's setting. Signed-off-by: Guochun Mao Acked-by: Cyrille Pitchen --- drivers/mtd/spi-nor/mtk-quadspi.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/drivers/mtd/spi-nor/mtk-quadspi.c b/drivers/mtd/spi-nor/mtk-quadspi.c index e661877..b637770 100644 --- a/drivers/mtd/spi-nor/mtk-quadspi.c +++ b/drivers/mtd/spi-nor/mtk-quadspi.c @@ -104,6 +104,8 @@ #define MTK_NOR_MAX_RX_TX_SHIFT 6 /* can shift up to 56 bits (7 bytes) transfer by MTK_NOR_PRG_CMD */ #define MTK_NOR_MAX_SHIFT 7 +/* nor controller 4-byte address mode enable bit */ +#define MTK_NOR_4B_ADDR_EN BIT(4) /* Helpers for accessing the program data / shift data registers */ #define MTK_NOR_PRG_REG(n) (MTK_NOR_PRGDATA0_REG + 4 * (n)) @@ -230,10 +232,35 @@ static int mt8173_nor_write_buffer_disable(struct mt8173_nor *mt8173_nor) 10000); } +static void mt8173_nor_set_addr_width(struct mt8173_nor *mt8173_nor) +{ + u8 val; + struct spi_nor *nor = &mt8173_nor->nor; + + val = readb(mt8173_nor->base + MTK_NOR_DUAL_REG); + + switch (nor->addr_width) { + case 3: + val &= ~MTK_NOR_4B_ADDR_EN; + break; + case 4: + val |= MTK_NOR_4B_ADDR_EN; + break; + default: + dev_warn(mt8173_nor->dev, "Unexpected address width %u.\n", + nor->addr_width); + break; + } + + writeb(val, mt8173_nor->base + MTK_NOR_DUAL_REG); +} + static void mt8173_nor_set_addr(struct mt8173_nor *mt8173_nor, u32 addr) { int i; + mt8173_nor_set_addr_width(mt8173_nor); + for (i = 0; i < 3; i++) { writeb(addr & 0xff, mt8173_nor->base + MTK_NOR_RADR0_REG + i * 4); addr >>= 8;