From mboxrd@z Thu Jan 1 00:00:00 1970 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) 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> In-Reply-To: <1395735604-26706-1-git-send-email-lee.jones@linaro.org> References: <1395735604-26706-1-git-send-email-lee.jones@linaro.org> 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 List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , 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 */ -- 1.8.3.2