From patchwork Tue Mar 25 08:19:23 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lee Jones X-Patchwork-Id: 26982 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-vc0-f197.google.com (mail-vc0-f197.google.com [209.85.220.197]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 1E35E20062 for ; Tue, 25 Mar 2014 08:23:03 +0000 (UTC) Received: by mail-vc0-f197.google.com with SMTP id if11sf298029vcb.0 for ; Tue, 25 Mar 2014 01:23:02 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:from:to:subject:date:message-id :in-reply-to:references:cc:precedence:list-id:list-unsubscribe :list-archive:list-post:list-help:list-subscribe:mime-version:sender :errors-to:x-original-sender:x-original-authentication-results :mailing-list:content-type:content-transfer-encoding; bh=vyOWx+5lj8uZx9gZQO8L+eMo+Bz0EynAj1HQzOssMdE=; b=BSFVCK/9gsanjcyRJJZzEBbA3KE2xw0OHtInsTWEg7+ibgBs4mxcSE1lzSTa97tc1V EiOntipQrm81aXpo9F9Nuvz4D3gI0St/AHPgiB5eJMfGuTOCK0AGj2uuAiu0FdyFaYGK o86aKJSYonjpgxSTchJxkcSqj8onQSg0BpiYa/WfH7cNXZKt8PlfEfmVsQiTkDzef2jo kNXywAJHcSc9GIL2uhgYv6WWgHLH6g8RWI1qEfnmaM+Q1IiByYqa/xeSPUXa+PgHEk1U t8icU5ixQ2br5wwsegqMOaV5OCEpGJSbfC3cshsYO+VL6CALuIO5pL/ATdoeRo1pdFpr 4oxg== X-Gm-Message-State: ALoCoQmCDf1B3/PBnKHFAIyZwaB7a4EHP7Mei52kY7XvMC6btjREUQSDKlcj8SdEeWLxHfZjbaJJ X-Received: by 10.236.173.42 with SMTP id u30mr11388955yhl.2.1395735782880; Tue, 25 Mar 2014 01:23:02 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.103.77 with SMTP id x71ls136823qge.31.gmail; Tue, 25 Mar 2014 01:23:02 -0700 (PDT) X-Received: by 10.220.114.135 with SMTP id e7mr5464620vcq.23.1395735782750; Tue, 25 Mar 2014 01:23:02 -0700 (PDT) Received: from mail-vc0-f178.google.com (mail-vc0-f178.google.com [209.85.220.178]) by mx.google.com with ESMTPS id xs6si3595031vec.56.2014.03.25.01.23.02 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 25 Mar 2014 01:23:02 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.220.178 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.220.178; Received: by mail-vc0-f178.google.com with SMTP id im17so129799vcb.37 for ; Tue, 25 Mar 2014 01:23:02 -0700 (PDT) X-Received: by 10.52.119.197 with SMTP id kw5mr46255027vdb.5.1395735782671; Tue, 25 Mar 2014 01:23:02 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.220.78.9 with SMTP id i9csp285391vck; Tue, 25 Mar 2014 01:23:01 -0700 (PDT) X-Received: by 10.180.25.46 with SMTP id z14mr20041482wif.49.1395735780905; Tue, 25 Mar 2014 01:23:00 -0700 (PDT) Received: from casper.infradead.org (casper.infradead.org. [2001:770:15f::2]) by mx.google.com with ESMTPS id s10si1347602wix.93.2014.03.25.01.23.00 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 25 Mar 2014 01:23:00 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-mtd-bounces+patch=linaro.org@lists.infradead.org designates 2001:770:15f::2 as permitted sender) client-ip=2001:770:15f::2; Received: from merlin.infradead.org ([2001:4978:20e::2]) by casper.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1WSMcj-00008j-4f; Tue, 25 Mar 2014 08:22:17 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1WSMcO-0002Ky-7K; Tue, 25 Mar 2014 08:21:56 +0000 Received: from mail-we0-f180.google.com ([74.125.82.180]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1WSMbL-00026E-3t for linux-mtd@lists.infradead.org; Tue, 25 Mar 2014 08:21:26 +0000 Received: by mail-we0-f180.google.com with SMTP id p61so81090wes.11 for ; Tue, 25 Mar 2014 01:20:29 -0700 (PDT) X-Received: by 10.180.87.9 with SMTP id t9mr20930931wiz.36.1395735629497; Tue, 25 Mar 2014 01:20:29 -0700 (PDT) Received: from lee--X1.home (host109-148-113-193.range109-148.btcentralplus.com. [109.148.113.193]) by mx.google.com with ESMTPSA id k4sm5567676wib.19.2014.03.25.01.20.27 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 25 Mar 2014 01:20:28 -0700 (PDT) From: Lee Jones To: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [RFC 06/47] mtd: nand: stm_nand_bch: change between BCH and Hamming modes Date: Tue, 25 Mar 2014 08:19:23 +0000 Message-Id: <1395735604-26706-7-git-send-email-lee.jones@linaro.org> X-Mailer: git-send-email 1.8.3.2 In-Reply-To: <1395735604-26706-1-git-send-email-lee.jones@linaro.org> References: <1395735604-26706-1-git-send-email-lee.jones@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20140325_042051_350659_5107ABE8 X-CRM114-Status: GOOD ( 11.74 ) X-Spam-Score: -2.6 (--) X-Spam-Report: SpamAssassin version 3.3.2 on merlin.infradead.org summary: Content analysis details: (-2.6 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [74.125.82.180 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] Cc: angus.clark@st.com, kernel@stlinux.com, lee.jones@linaro.org, linux-mtd@lists.infradead.org, pekon@ti.com, computersforpeace@gmail.com, dwmw2@infradead.org X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: , List-Help: , List-Subscribe: , MIME-Version: 1.0 Sender: "linux-mtd" Errors-To: linux-mtd-bounces+patch=linaro.org@lists.infradead.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: lee.jones@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.220.178 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 The EMISS is a device which, amongst other things, controls various flash memory modes. We make use of it here merely to flip the HAMMING_NOT_BCH bit dependant on whether we wish to operate in Hamming or BCH modes. The STM BCH driver makes good use of the helper introduced here. Signed-off-by: Lee Jones --- include/linux/mtd/stm_nand.h | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/include/linux/mtd/stm_nand.h b/include/linux/mtd/stm_nand.h index 9210d5c..da2006c 100644 --- a/include/linux/mtd/stm_nand.h +++ b/include/linux/mtd/stm_nand.h @@ -15,6 +15,8 @@ #ifndef __LINUX_STM_NAND_H #define __LINUX_STM_NAND_H +#include + struct stm_plat_nand_bch_data { struct stm_nand_bank_data *bank; enum stm_nand_bch_ecc_config bch_ecc_cfg; @@ -30,4 +32,44 @@ struct stm_plat_nand_bch_data { bool flashss; }; +#define EMISS_BASE 0xfef01000 +#define EMISS_CONFIG 0x0000 +#define EMISS_CONFIG_HAMMING_NOT_BCH (0x1 << 6) + +enum nandi_controllers { + STM_NANDI_UNCONFIGURED, + STM_NANDI_HAMMING, + STM_NANDI_BCH +}; + +static inline void emiss_nandi_select(enum nandi_controllers controller) +{ + unsigned v; + void __iomem *emiss_config_base; + + emiss_config_base = ioremap(EMISS_BASE, 4); + if (!emiss_config_base) { + pr_err("%s: failed to ioremap EMISS\n", __func__); + return; + } + + v = readl(emiss_config_base + EMISS_CONFIG); + + if (controller == STM_NANDI_HAMMING) { + if (v & EMISS_CONFIG_HAMMING_NOT_BCH) + goto out; + v |= EMISS_CONFIG_HAMMING_NOT_BCH; + } else { + if (!(v & EMISS_CONFIG_HAMMING_NOT_BCH)) + goto out; + v &= ~EMISS_CONFIG_HAMMING_NOT_BCH; + } + + writel(v, emiss_config_base + EMISS_CONFIG); + readl(emiss_config_base + EMISS_CONFIG); + +out: + iounmap(emiss_config_base); +} + #endif /* __LINUX_STM_NAND_H */