Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp2807143imm; Mon, 13 Aug 2018 00:21:06 -0700 (PDT) X-Google-Smtp-Source: AA+uWPzXm5FXH5kSw/cCIObah79z9e5l7SQ96EFiRYdLzWVuNB2UzrQkkaI5U9fAI/DqG/gqqdWN X-Received: by 2002:a63:ae42:: with SMTP id e2-v6mr13296309pgp.351.1534144866777; Mon, 13 Aug 2018 00:21:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1534144866; cv=none; d=google.com; s=arc-20160816; b=WtXnhm+aMBCjUwyud039v9HAN65khpS1t73PyPjwt8MMfIT49F67w2Vte/381jnebG nRMujWERx18YeQo5fRU+t5rNcMmEB+UX/q5l67db1aGFKzr7wIEx9Dv8AT2FR9TmGj0d LyERlgJQ0HUhHw6EkK3apmlsB3PSxnt7qt6MD5BJqJi45tCvivP2lwMFQSnWD7+Lhyda rPcaVol2cGb4m6TbLlCnjs+C6RMe03Kd+vAopNUI5Dlh+jQKP2m7Jb2WWEubebG1kbXt sA7mzLKmj/QoaJcALkcQiq3QS+pjmRgz0xDionE5mTB3xlEtUMXdFknyFAkVGvEIguaY CX7A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=GmrTOZW9Wk48rUlzdPKW/jkOXW59Oz+EpE615CbafVc=; b=F6w6z+KZOB/a/Edcq0LV1XZLCPZhIQDm69CtQE8V9B+9eYVMsJS7uoFYvGC/XeZxXf LTsEYyi1HQ0IDiONj0/3fv7DW6ajfGLvKc1Yz1yWB4uFKYCa2BWkOjP355/H8c4M/jW4 VRUkhqPSexWwykoUpSpw8tqGIiZS4zkyJ/15XzVDiJtLz4y/3462/Ai208hjEt7tNXsy PcnstPF0+pSERO42LCmXcXYUWEDmj9S9AAlg+/2TZKFv2+TFQTMG+s8QRt6T/kjG/+jx XSU1PEkXfNlqQDrouAdN9rS58Gyt2k6oBh7G0S0k3r6/R0VJiXJHexW5Fseui+0aBcQ+ IKpQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id o81-v6si17634408pfj.350.2018.08.13.00.20.52; Mon, 13 Aug 2018 00:21:06 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728531AbeHMKAh (ORCPT + 99 others); Mon, 13 Aug 2018 06:00:37 -0400 Received: from Galois.linutronix.de ([146.0.238.70]:37223 "EHLO Galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726577AbeHMKAg (ORCPT ); Mon, 13 Aug 2018 06:00:36 -0400 Received: from hsi-kbw-5-158-153-52.hsi19.kabel-badenwuerttemberg.de ([5.158.153.52] helo=kurt.tec.linutronix.de) by Galois.linutronix.de with esmtpsa (TLS1.2:DHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.80) (envelope-from ) id 1fp78G-00012F-UV; Mon, 13 Aug 2018 09:19:17 +0200 From: Kurt Kanzenbach To: Boris Brezillon , Miquel Raynal Cc: Richard Weinberger , David Woodhouse , Brian Norris , Marek Vasut , Kurt Kanzenbach , Masahiro Yamada , Wenyou Yang , Jagdish Gediya , Jane Wan , linux-mtd@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 2/2] mtd: rawnand: fsl_ifc: fixup SRAM init for newer ctrl versions Date: Mon, 13 Aug 2018 09:18:46 +0200 Message-Id: <20180813071846.9433-3-kurt@linutronix.de> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180813071846.9433-1-kurt@linutronix.de> References: <20180813071846.9433-1-kurt@linutronix.de> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Newer versions of the IFC controller use a different method of initializing the internal SRAM: Instead of reading from flash, a bit in the NAND configuration register has to be set in order to trigger the self-initializing process. Signed-off-by: Kurt Kanzenbach --- Changes since v1: - Subject - Coding style - Using timeout constant - Move version check completely into fsl_ifc_sram_init() drivers/mtd/nand/raw/fsl_ifc_nand.c | 33 ++++++++++++++++++++++++++------- include/linux/fsl_ifc.h | 2 ++ 2 files changed, 28 insertions(+), 7 deletions(-) diff --git a/drivers/mtd/nand/raw/fsl_ifc_nand.c b/drivers/mtd/nand/raw/fsl_ifc_nand.c index e4f5792dc589..7e7729df7827 100644 --- a/drivers/mtd/nand/raw/fsl_ifc_nand.c +++ b/drivers/mtd/nand/raw/fsl_ifc_nand.c @@ -30,6 +30,7 @@ #include #include #include +#include #define ERR_BYTE 0xFF /* Value returned for read bytes when read failed */ @@ -769,6 +770,27 @@ static int fsl_ifc_sram_init(struct fsl_ifc_mtd *priv) uint32_t csor = 0, csor_8k = 0, csor_ext = 0; uint32_t cs = priv->bank; + if (ctrl->version < FSL_IFC_VERSION_1_1_0) + return 0; + + if (ctrl->version > FSL_IFC_VERSION_1_1_0) { + u32 ncfgr, status; + int ret; + + /* Trigger auto initialization */ + ncfgr = ifc_in32(&ifc_runtime->ifc_nand.ncfgr); + ifc_out32(ncfgr | IFC_NAND_NCFGR_SRAM_INIT_EN, &ifc_runtime->ifc_nand.ncfgr); + + /* Wait until done */ + ret = readx_poll_timeout(ifc_in32, &ifc_runtime->ifc_nand.ncfgr, + status, !(status & IFC_NAND_NCFGR_SRAM_INIT_EN), + 10, IFC_TIMEOUT_MSECS * 1000); + if (ret) + dev_err(priv->dev, "Failed to initialize SRAM!\n"); + + return ret; + } + /* Save CSOR and CSOR_ext */ csor = ifc_in32(&ifc_global->csor_cs[cs].csor); csor_ext = ifc_in32(&ifc_global->csor_cs[cs].csor_ext); @@ -825,6 +847,7 @@ static int fsl_ifc_chip_init(struct fsl_ifc_mtd *priv) struct nand_chip *chip = &priv->chip; struct mtd_info *mtd = nand_to_mtd(&priv->chip); u32 csor; + int ret; /* Fill in fsl_ifc_mtd structure */ mtd->dev.parent = priv->dev; @@ -918,13 +941,9 @@ static int fsl_ifc_chip_init(struct fsl_ifc_mtd *priv) chip->ecc.algo = NAND_ECC_HAMMING; } - if (ctrl->version >= FSL_IFC_VERSION_1_1_0) { - int ret; - - ret = fsl_ifc_sram_init(priv); - if (ret) - return ret; - } + ret = fsl_ifc_sram_init(priv); + if (ret) + return ret; /* * As IFC version 2.0.0 has 16KB of internal SRAM as compared to older diff --git a/include/linux/fsl_ifc.h b/include/linux/fsl_ifc.h index 3fdfede2f0f3..5f343b796ad9 100644 --- a/include/linux/fsl_ifc.h +++ b/include/linux/fsl_ifc.h @@ -274,6 +274,8 @@ */ /* Auto Boot Mode */ #define IFC_NAND_NCFGR_BOOT 0x80000000 +/* SRAM Initialization */ +#define IFC_NAND_NCFGR_SRAM_INIT_EN 0x20000000 /* Addressing Mode-ROW0+n/COL0 */ #define IFC_NAND_NCFGR_ADDR_MODE_RC0 0x00000000 /* Addressing Mode-ROW0+n/COL0+n */ -- 2.11.0