From patchwork Thu May 1 09:56:14 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lee Jones X-Patchwork-Id: 29450 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ie0-f197.google.com (mail-ie0-f197.google.com [209.85.223.197]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 847C3203F3 for ; Thu, 1 May 2014 09:57:22 +0000 (UTC) Received: by mail-ie0-f197.google.com with SMTP id rd18sf15353121iec.0 for ; Thu, 01 May 2014 02:57:22 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:in-reply-to:references:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :list-post:list-help:list-archive:list-unsubscribe; bh=brDM9BFLGwF2o7JDx6kpJbM+6nEfGZYlQTL9nFYlmZ0=; b=QBuoXKx0Yi0Ugr1fx9E+LWrrK76sdps2/fVPfrUeeUKt86PSkZu5XzIQ7HtRo9IxCT WcsNQNXPEwAgHbHUHXjQDkrRoo8WUiFx1SevV5IDxuDi7VEBzwsYxqxEu4sigcZH0zDP xuYOFm0Amu5ROEfEieRIAhvArhMcUcjkHAQwIQ9SqYtubAgsu1SjV1K+h5+8GqCpM3km msuNgvUXNNQF6gjTDjpYoTMJp5cN5krZ9WrkVryNVLcCwJTNVtcvy/9gS1gu3BiJux5g xL1weUkv0oKEKEeN/6caiEJojB8IhSMdiFOtWD9rxZmDrTJ80ivH6I5hnnZFl+nTWXEE 2vlg== X-Gm-Message-State: ALoCoQnjtcP2/aEuTNEmb/gUEH2eaV/q2plJyAQKX68kW1VLkNlVqIPHdgnfRq8VhJh4X8ULoK1p X-Received: by 10.182.241.9 with SMTP id we9mr5301500obc.22.1398938241985; Thu, 01 May 2014 02:57:21 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.40.74 with SMTP id w68ls989812qgw.53.gmail; Thu, 01 May 2014 02:57:21 -0700 (PDT) X-Received: by 10.220.59.65 with SMTP id k1mr8106849vch.22.1398938241875; Thu, 01 May 2014 02:57:21 -0700 (PDT) Received: from mail-ve0-f173.google.com (mail-ve0-f173.google.com [209.85.128.173]) by mx.google.com with ESMTPS id tc5si5965637vcb.215.2014.05.01.02.57.21 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 01 May 2014 02:57:21 -0700 (PDT) Received-SPF: none (google.com: patch+caf_=patchwork-forward=linaro.org@linaro.org does not designate permitted sender hosts) client-ip=209.85.128.173; Received: by mail-ve0-f173.google.com with SMTP id pa12so2681961veb.32 for ; Thu, 01 May 2014 02:57:21 -0700 (PDT) X-Received: by 10.58.74.38 with SMTP id q6mr8018233vev.7.1398938241728; Thu, 01 May 2014 02:57:21 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patches@linaro.org Received: by 10.220.221.72 with SMTP id ib8csp12891vcb; Thu, 1 May 2014 02:57:21 -0700 (PDT) X-Received: by 10.194.24.74 with SMTP id s10mr8140355wjf.43.1398938240904; Thu, 01 May 2014 02:57:20 -0700 (PDT) Received: from mail-wi0-f177.google.com (mail-wi0-f177.google.com [209.85.212.177]) by mx.google.com with ESMTPS id ry7si10548721wjb.46.2014.05.01.02.57.20 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 01 May 2014 02:57:20 -0700 (PDT) Received-SPF: none (google.com: lee.jones@linaro.org does not designate permitted sender hosts) client-ip=209.85.212.177; Received: by mail-wi0-f177.google.com with SMTP id cc10so402513wib.16 for ; Thu, 01 May 2014 02:57:20 -0700 (PDT) X-Received: by 10.194.63.196 with SMTP id i4mr1406545wjs.50.1398938240409; Thu, 01 May 2014 02:57:20 -0700 (PDT) Received: from lee--X1.home (host109-148-238-223.range109-148.btcentralplus.com. [109.148.238.223]) by mx.google.com with ESMTPSA id bj5sm2696494wib.3.2014.05.01.02.57.18 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 01 May 2014 02:57:19 -0700 (PDT) From: Lee Jones To: linux-kernel@vger.kernel.org Cc: computersforpeace@gmail.com, linux-mtd@lists.infradead.org, kernel@stlinux.com, Lee Jones Subject: [PATCH 07/47] mtd: nand: stm_nand_bch: change between BCH and Hamming modes Date: Thu, 1 May 2014 10:56:14 +0100 Message-Id: <1398938214-17847-8-git-send-email-lee.jones@linaro.org> X-Mailer: git-send-email 1.8.3.2 In-Reply-To: <1398938214-17847-1-git-send-email-lee.jones@linaro.org> References: <1398938214-17847-1-git-send-email-lee.jones@linaro.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: patch+caf_=patchwork-forward=linaro.org@linaro.org does not designate permitted sender hosts) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Precedence: list Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org List-ID: X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , 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 */