From patchwork Fri Dec 17 15:55:10 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dario Binacchi X-Patchwork-Id: 1570166 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=Qzqn4Kh0; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=amarulasolutions.com header.i=@amarulasolutions.com header.a=rsa-sha256 header.s=google header.b=GT7+ilek; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.infradead.org (client-ip=2607:7c80:54:e::133; helo=bombadil.infradead.org; envelope-from=linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4JFvS55VMhz9sRN for ; Sat, 18 Dec 2021 03:23:45 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=0ORql5rwQpGl5Zgf0vvH9QsydlCIGjC19HiiB1KGzR8=; b=Qzqn4Kh0TfOCvl /X6djUpCPhBvBiCzYjs95hXrRvHfAjRFSRtkQdE9WBi2oaI3ltA9/mxjHBjUss92vGizB4tzTicM/ AawnOJjjcbSAxu6C+FuEg49XUTALrt+m4tUbkbnHjANWtEkTrRZw1z+K51Ld01y7H/sdAY3YKntNc peNWDDfPkMNPHjTHqOBrvkw6Lv8PvUCMJB7ioLoXKB+oP0GrnV2gz8SOx/wmj5lGfYrc3XHVCmHNx cm5PTSvut2uLxVLWYO5bEQcy4isjoBGcdOJu6jfCCpMQIxRezNPKTzvI6gPULj21b9mixB+2Djc9S 9zbn4F9xYYNs3L5/TaFw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1myG0T-00B9IZ-Ko; Fri, 17 Dec 2021 16:22:54 +0000 Received: from mail-ed1-x534.google.com ([2a00:1450:4864:20::534]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1myFaH-00B1T4-Ku for linux-mtd@lists.infradead.org; Fri, 17 Dec 2021 15:55:52 +0000 Received: by mail-ed1-x534.google.com with SMTP id g14so9453901edb.8 for ; Fri, 17 Dec 2021 07:55:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amarulasolutions.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=pCjPRfOE0ubdFKl1wroT8qZZ50obE6oG33Hg0XGM304=; b=GT7+ilekxSTS5dFNut7H6CiyF+s4HbxoxVMua+CSJLqW+fj8bgZ36r7laPoZzjTKVO /0ZsMq4hFsukMP44g8xdxWMyJ84oewN+Pqh49hxeu7h8jm/FApB0Emn134cSqYtoUf+Z PIca9tyY8AbC86kn8KUvHaTa5CHPRYorzTGPQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=pCjPRfOE0ubdFKl1wroT8qZZ50obE6oG33Hg0XGM304=; b=kGU78fKfSGybAEDzgk+NAPBAPHzqeYJ4gRBwTa+weVfa5jUih4xTtRFzrSWOcYR2j5 601wPlZ/El2+U7q9XoEWI5QdvnbPTLvusYExqIAf2/0fNew6cljRetBm7k+hXpSaDkpZ IgZfclJ/i3ER62/nM0iVeL23KjqQEhIcLl0h5wsfqpBFQDM2FflyHip9zBhHpZ1Rnkp3 z1gOGEVlalZUxKRgegb9bi02J1KL+ltbVAUVjpYrZwZSy5PBckLjITG4gy+V/n93J3qp Vli9dzkKP1ZWzHkfLSuLD5JqnZyQTBDWz8lASgIFGpDgI9HuKHzg8i7khzfrV5ojE2PE VDnw== X-Gm-Message-State: AOAM532qf3ewY+Gs8H7yssFpXSVCvSk3ORIbSh7wirBZVAFKAxLiChyl OR8u09+0TYzU7AXD6+IdNltqkw== X-Google-Smtp-Source: ABdhPJwq9J1DWJQ8i4E0EiIDgAaMs/AhSQZcnTaJ1HC6l3gTEc24oM/ESRtaqP0UYIOPboiOppaXCg== X-Received: by 2002:a17:907:1c81:: with SMTP id nb1mr3125382ejc.9.1639756548087; Fri, 17 Dec 2021 07:55:48 -0800 (PST) Received: from dario-ThinkPad-T14s-Gen-2i.amarulasolutions.com (host-79-56-50-241.retail.telecomitalia.it. [79.56.50.241]) by smtp.gmail.com with ESMTPSA id i6sm772158edx.46.2021.12.17.07.55.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 Dec 2021 07:55:47 -0800 (PST) From: Dario Binacchi To: linux-kernel@vger.kernel.org Cc: Dario Binacchi , Michael Trimarchi , Han Xu , Miquel Raynal , Richard Weinberger , Vignesh Raghavendra , linux-mtd@lists.infradead.org Subject: [RFC PATCH 2/4] mtd: rawnand: gpmi: support fast edo timings for mx28 Date: Fri, 17 Dec 2021 16:55:10 +0100 Message-Id: <20211217155512.1877408-3-dario.binacchi@amarulasolutions.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20211217155512.1877408-1-dario.binacchi@amarulasolutions.com> References: <20211217155512.1877408-1-dario.binacchi@amarulasolutions.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211217_075549_734426_F596FF05 X-CRM114-Status: GOOD ( 13.01 ) X-Spam-Score: -0.2 (/) X-Spam-Report: Spam detection software, running on the system "bombadil.infradead.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: In the mx28 reference manual there are examples of how to set up the GPMI controller to support fast NAND EDO timing. This patch has been tested on a 2048/64 byte NAND (Micron MT29F2G08ABAEAH4). Kernel mtd tests: - mtd_nandbiterrs - mtd_nandecctest - mtd_oobtest - mtd_pagetest - mtd_readtest - mtd_speedtest - mtd_str [...] Content analysis details: (-0.2 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2a00:1450:4864:20:0:0:0:534 listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-mtd" Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org In the mx28 reference manual there are examples of how to set up the GPMI controller to support fast NAND EDO timing. This patch has been tested on a 2048/64 byte NAND (Micron MT29F2G08ABAEAH4). Kernel mtd tests: - mtd_nandbiterrs - mtd_nandecctest - mtd_oobtest - mtd_pagetest - mtd_readtest - mtd_speedtest - mtd_stresstest - mtd_subpagetest - mtd_torturetest [cycles_count = 10000000] run without errors. Before this patch (mode 0): --------------------------- eraseblock write speed is 2098 KiB/s eraseblock read speed is 2680 KiB/s page write speed is 1689 KiB/s page read speed is 2522 KiB/s 2 page write speed is 1899 KiB/s 2 page read speed is 2579 KiB/s erase speed is 128000 KiB/s 2x multi-block erase speed is 73142 KiB/s 4x multi-block erase speed is 204800 KiB/s 8x multi-block erase speed is 256000 KiB/s 16x multi-block erase speed is 256000 KiB/s 32x multi-block erase speed is 256000 KiB/s 64x multi-block erase speed is 256000 KiB/s After this patch (mode 5): ------------------------- eraseblock write speed is 3390 KiB/s eraseblock read speed is 5688 KiB/s page write speed is 2680 KiB/s page read speed is 4876 KiB/s 2 page write speed is 2909 KiB/s 2 page read speed is 5224 KiB/s erase speed is 170666 KiB/s 2x multi-block erase speed is 204800 KiB/s 4x multi-block erase speed is 256000 KiB/s 8x multi-block erase speed is 256000 KiB/s 16x multi-block erase speed is 256000 KiB/s 32x multi-block erase speed is 256000 KiB/s 64x multi-block erase speed is 256000 KiB/s Signed-off-by: Dario Binacchi Co-developed-by: Michael Trimarchi --- drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.c b/drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.c index 65bcd1c548d2..fd935e893daf 100644 --- a/drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.c +++ b/drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.c @@ -772,8 +772,8 @@ static int gpmi_setup_interface(struct nand_chip *chip, int chipnr, if (IS_ERR(sdr)) return PTR_ERR(sdr); - /* Only MX6 GPMI controller can reach EDO timings */ - if (sdr->tRC_min <= 25000 && !GPMI_IS_MX6(this)) + /* Only MX28/MX6 GPMI controller can reach EDO timings */ + if (sdr->tRC_min <= 25000 && !GPMI_IS_MX28(this) && !GPMI_IS_MX6(this)) return -ENOTSUPP; /* Stop here if this call was just a check */ From patchwork Fri Dec 17 15:55:11 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dario Binacchi X-Patchwork-Id: 1570167 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=dOlZmuYm; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=amarulasolutions.com header.i=@amarulasolutions.com header.a=rsa-sha256 header.s=google header.b=gFDRtlH3; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.infradead.org (client-ip=2607:7c80:54:e::133; helo=bombadil.infradead.org; envelope-from=linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4JFvXB40YDz9t55 for ; Sat, 18 Dec 2021 03:27:22 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=OMYmVuo8TIvOEnFYBkNHAeNnos/01Cg9IbNc3EWD+ak=; b=dOlZmuYmtwF79r oeZu1G5xHSXFKEfXO9etFMrodKnFWaePXYu1AzvnUrn8vkVWeUvjnStslWyZlEX/TGKSCvDCcqgoG bQww5MH5HfLkv6WUm8spKlv19LHAE9RLjUbS5Z9mpViBlCM12xH85oEjNx3V3Gck4N8HTAf6fchoV uVeuxqcq/tPeUXZo4OJmFZknpkCV06SKZ4rXx/W91Swxke5Qos0IA03O2q+vrDQvS+fpG1tAVElJQ W5oLDM/19nC4RX7xrRF6UHBnwHqG2vWechF/DqSJ8ZGpwJT+q+BwuPj2VVt02kN9bVw75/QGg/O3w +wEzkP3CGqKa4NNypNtg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1myG41-00BA17-SO; Fri, 17 Dec 2021 16:26:34 +0000 Received: from mail-ed1-x534.google.com ([2a00:1450:4864:20::534]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1myFaI-00B1Tt-Gr for linux-mtd@lists.infradead.org; Fri, 17 Dec 2021 15:55:52 +0000 Received: by mail-ed1-x534.google.com with SMTP id y13so9359887edd.13 for ; Fri, 17 Dec 2021 07:55:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amarulasolutions.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=GPyuWnLPH8PFNFJh17BU4dw6g8DK6MUXDTmu7+hfLlY=; b=gFDRtlH3e1/Jlp1cAjp2QqkKroRvrg65fXs2p8TfqllBfCqoiogpYwTR2o5QbEEuD/ OogD9ePzwhTd3y+dc4zEXuNYNse3FghP9+qtQXfNman3VDrKlL33nC10tLbMMRpOpJ+Q pj0s34n97SOV7qZy0zdvh0DyIOmt/GleRGk3E= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=GPyuWnLPH8PFNFJh17BU4dw6g8DK6MUXDTmu7+hfLlY=; b=4kKL2bYnG47S1lcJH0PLSkBlqXK91RodkK1nqDyuYNNoZSgQCnoYOnkvMPrcsJS1bC LhySIYyVMJZGyf9Gw9zer/rDLMu2aMTNXd1jKydNbux3qGx3W6wgaaYKcpWLhzxgu6mG qEdvbFvvNYbaAYjETEro+lc6WNu4V4wBDAtIxTde5+a6xzO9I/Ml6szhDIfDxb2o1QO+ SQEQS9xC3vqPw8DQt0qqnzAA8ass/l1GefD1EnOSOog5zyTrFmY6LtBcWnGtbGpb2DNV 81hw0KRr0vWB1FNxXDSGOl2PFWX5OlhHfvJg2ba1JCcTmxi3kfZJES8WyVqwEmyre1Up sjng== X-Gm-Message-State: AOAM532G+HYjzD0moB6mMisFTHCT/I7QWaLMKxwcuV01SKs3uwrHrmzP 0w5iGJMxL3NrEHvKFq0Tal2B6w== X-Google-Smtp-Source: ABdhPJypWJce5q+VYVZqPNebWyJZp9GWchWxQ7EUMp01LDmMnu4A8AyP1ZlWihYdRXcrf843n+1caw== X-Received: by 2002:aa7:c6c8:: with SMTP id b8mr3513024eds.164.1639756549196; Fri, 17 Dec 2021 07:55:49 -0800 (PST) Received: from dario-ThinkPad-T14s-Gen-2i.amarulasolutions.com (host-79-56-50-241.retail.telecomitalia.it. [79.56.50.241]) by smtp.gmail.com with ESMTPSA id i6sm772158edx.46.2021.12.17.07.55.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 Dec 2021 07:55:48 -0800 (PST) From: Dario Binacchi To: linux-kernel@vger.kernel.org Cc: Dario Binacchi , Michael Trimarchi , Boris Brezillon , Han Xu , Miquel Raynal , Richard Weinberger , Vignesh Raghavendra , linux-mtd@lists.infradead.org Subject: [RFC PATCH 3/4] mtd: rawnand: gpmi: fix controller timings setting Date: Fri, 17 Dec 2021 16:55:11 +0100 Message-Id: <20211217155512.1877408-4-dario.binacchi@amarulasolutions.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20211217155512.1877408-1-dario.binacchi@amarulasolutions.com> References: <20211217155512.1877408-1-dario.binacchi@amarulasolutions.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211217_075550_623646_D38106F1 X-CRM114-Status: GOOD ( 10.70 ) X-Spam-Score: -0.2 (/) X-Spam-Report: Spam detection software, running on the system "bombadil.infradead.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: The controller registers are now set accordling to the real clock rate. Fixes: b1206122069a ("mtd: rawnand: gpmi: use core timings instead of an empirical derivation") Signed-off-by: Dario Binacchi Co-developed-by: Michael Trimarchi < [...] Content analysis details: (-0.2 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2a00:1450:4864:20:0:0:0:534 listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-mtd" Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org The controller registers are now set accordling to the real clock rate. Fixes: b1206122069a ("mtd: rawnand: gpmi: use core timings instead of an empirical derivation") Signed-off-by: Dario Binacchi Co-developed-by: Michael Trimarchi --- drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.c b/drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.c index fd935e893daf..0517b81bb24c 100644 --- a/drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.c +++ b/drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.c @@ -648,6 +648,7 @@ static void gpmi_nfc_compute_timings(struct gpmi_nand_data *this, const struct nand_sdr_timings *sdr) { struct gpmi_nfc_hardware_timing *hw = &this->hw; + struct resources *r = &this->resources; unsigned int dll_threshold_ps = this->devdata->max_chain_delay; unsigned int period_ps, reference_period_ps; unsigned int data_setup_cycles, data_hold_cycles, addr_setup_cycles; @@ -671,6 +672,8 @@ static void gpmi_nfc_compute_timings(struct gpmi_nand_data *this, wrn_dly_sel = BV_GPMI_CTRL1_WRN_DLY_SEL_NO_DELAY; } + hw->clk_rate = clk_round_rate(r->clock[0], hw->clk_rate); + /* SDR core timings are given in picoseconds */ period_ps = div_u64((u64)NSEC_PER_SEC * 1000, hw->clk_rate); From patchwork Fri Dec 17 15:55:12 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dario Binacchi X-Patchwork-Id: 1570168 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=YOW4ZQTK; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=amarulasolutions.com header.i=@amarulasolutions.com header.a=rsa-sha256 header.s=google header.b=XpLaJNf7; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.infradead.org (client-ip=2607:7c80:54:e::133; helo=bombadil.infradead.org; envelope-from=linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4JFvcM5PqKz9t55 for ; Sat, 18 Dec 2021 03:30:59 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=mi2yP9WIit4NgH+mNtgVB3jzSqXA8Aq3bYvBpLTKLeg=; b=YOW4ZQTKGNltv6 qLKkVkzs1DhMGuxrYwsnxqLlUR2gn3dDb00FT80Cz/7mqxnjiKXZvRlC/LigRa/vEx/mJvEWA/nYk qipAICz4cdO5Z06t3j3hiv3TPB01JAwQjHZhBpwOrX8hURsjDpyrqJ9td1DI+nU42U4XBqm2fKTtJ oQyQD2NtUgst4OjXDgfHIiyC0xse+6Irxi64EGqw/0cH6jQRkOM4m1MVITQ2mrzDWHabaSzSFafK1 bGIybQ6h4YDEkWgLyxaKlEw8Vyhbslh+0Y8TvWmDBI33bIJgIhHw6t5BuRpSxcebWl3Oesek89ZGw ttZ+k55HoMF1FFiyOC2w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1myG7S-00BAes-Pd; Fri, 17 Dec 2021 16:30:06 +0000 Received: from mail-ed1-x531.google.com ([2a00:1450:4864:20::531]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1myFaJ-00B1Uf-Q6 for linux-mtd@lists.infradead.org; Fri, 17 Dec 2021 15:55:54 +0000 Received: by mail-ed1-x531.google.com with SMTP id b7so9507300edd.6 for ; Fri, 17 Dec 2021 07:55:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amarulasolutions.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=M2WbEnBbDQgsL2Z6AiQ6BSUsHGfqd+FRDLIjDGY984c=; b=XpLaJNf7l0burOcMud+Y/VNOXEkyFXWUEHIk8Y7s5tKNFIHAjMfOcaCWrx41B+Kc0m mvcNEknsWkwTV7KeKr7rfN5L/Le/BnZMTuNzUrRGAC00oA6BK3Zv3JW1YsEyyUvU3ILk Q/3JEnlteQoPxIYMBDHuhvjjDbOM29L3iJOOk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=M2WbEnBbDQgsL2Z6AiQ6BSUsHGfqd+FRDLIjDGY984c=; b=JBKJL+JrHon8GffeyLGRULxbVig7i+nXabliJ8Ryq62wCFgvoDy0TSeMb+SQyKcyOG YQLg597N1UiUjRbhbLGWGGzGIDjfTpe5eOZlFHeSPkGiJthsYPHUOv5RCHCETBEVhJig zFP1jlnSq7iAnfjZipUtk6dz8xSp7OXjZoFwj/9h71t2WO3JCR/NiGuKaYicfY1VaweQ Yj8zbO7RDQ5GdM/oWHg8T/3LYJB4oqLgS1pdMBoZJqie6H/o+fHkwGCb/fRyffKKmPvZ xCalqQjOlhw4rcTZOuX/ZYsv5CghkeOZEPsRElwZ+/ILQweK0T5sFDiODvbqPA21jNRf uiUg== X-Gm-Message-State: AOAM531Qzub3O0KhXgnzJCQmfz8UJajIKmTTkSV8RXFRmwE/gz0EsSf+ 5K0Lhqqsj2JJSsqOBjcW0fMPkA== X-Google-Smtp-Source: ABdhPJzcYU0Q7QsepmRT6KYkMrmqU1jUmvusl/ehkTaW1AoUEGp3p/Eox5oq238UDGwWXE0qaV/eiQ== X-Received: by 2002:a17:906:3586:: with SMTP id o6mr3065886ejb.186.1639756550286; Fri, 17 Dec 2021 07:55:50 -0800 (PST) Received: from dario-ThinkPad-T14s-Gen-2i.amarulasolutions.com (host-79-56-50-241.retail.telecomitalia.it. [79.56.50.241]) by smtp.gmail.com with ESMTPSA id i6sm772158edx.46.2021.12.17.07.55.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 Dec 2021 07:55:49 -0800 (PST) From: Dario Binacchi To: linux-kernel@vger.kernel.org Cc: Dario Binacchi , Michael Trimarchi , Han Xu , Miquel Raynal , Richard Weinberger , Vignesh Raghavendra , linux-mtd@lists.infradead.org Subject: [RFC PATCH 4/4] mtd: rawnand: gpmi: validate controller clock rate Date: Fri, 17 Dec 2021 16:55:12 +0100 Message-Id: <20211217155512.1877408-5-dario.binacchi@amarulasolutions.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20211217155512.1877408-1-dario.binacchi@amarulasolutions.com> References: <20211217155512.1877408-1-dario.binacchi@amarulasolutions.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211217_075551_891350_80A695BB X-CRM114-Status: GOOD ( 21.57 ) X-Spam-Score: -0.2 (/) X-Spam-Report: Spam detection software, running on the system "bombadil.infradead.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: What to do when the real rate of the gpmi clock is not equal to the required one? The solutions proposed in [1] did not lead to a conclusion on how to validate the clock rate, so, inspired by the docu [...] Content analysis details: (-0.2 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2a00:1450:4864:20:0:0:0:531 listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-mtd" Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org What to do when the real rate of the gpmi clock is not equal to the required one? The solutions proposed in [1] did not lead to a conclusion on how to validate the clock rate, so, inspired by the document [2], I consider the rate correct only if not greater than the rate of the previous edo. In fact, in chapter 4.16.2 (NV-DDR) of the document [2], it is written that "If the host selects timing mode n, then its clock period shall be faster than the clock period of timing mode n-1 and slower than or equal to the clock period of timing mode n.". I thought that it could therefore also be used in this case, without therefore having to define the valid rate ranges empirically. [1] https://lore.kernel.org/r/20210702065350.209646-5-ebiggers@kernel.org [2] http://www.onfi.org/-/media/client/onfi/specs/onfi_3_0_gold.pdf?la=en Signed-off-by: Dario Binacchi Co-developed-by: Michael Trimarchi --- drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.c | 70 +++++++++++++++++----- 1 file changed, 54 insertions(+), 16 deletions(-) diff --git a/drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.c b/drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.c index 0517b81bb24c..3d37cd49abd5 100644 --- a/drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.c +++ b/drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.c @@ -570,6 +570,27 @@ static int bch_set_geometry(struct gpmi_nand_data *this) return ret; } +struct edo_mode { + u32 tRC_min; + long clk_rate; + u8 wrn_dly_sel; +}; + +static const struct edo_mode edo_modes[] = { + {.tRC_min = 30000, .clk_rate = 22000000, + .wrn_dly_sel = BV_GPMI_CTRL1_WRN_DLY_SEL_4_TO_8NS}, + {.tRC_min = 30000, .clk_rate = 22000000, + .wrn_dly_sel = BV_GPMI_CTRL1_WRN_DLY_SEL_4_TO_8NS}, + {.tRC_min = 30000, .clk_rate = 22000000, + .wrn_dly_sel = BV_GPMI_CTRL1_WRN_DLY_SEL_4_TO_8NS}, + {.tRC_min = 30000, .clk_rate = 22000000, + .wrn_dly_sel = BV_GPMI_CTRL1_WRN_DLY_SEL_4_TO_8NS}, + {.tRC_min = 25000, .clk_rate = 80000000, + .wrn_dly_sel = BV_GPMI_CTRL1_WRN_DLY_SEL_NO_DELAY}, + {.tRC_min = 20000, .clk_rate = 100000000, + .wrn_dly_sel = BV_GPMI_CTRL1_WRN_DLY_SEL_NO_DELAY}, +}; + /* * <1> Firstly, we should know what's the GPMI-clock means. * The GPMI-clock is the internal clock in the gpmi nand controller. @@ -644,8 +665,8 @@ static int bch_set_geometry(struct gpmi_nand_data *this) * RDN_DELAY = ----------------------- {3} * RP */ -static void gpmi_nfc_compute_timings(struct gpmi_nand_data *this, - const struct nand_sdr_timings *sdr) +static int gpmi_nfc_compute_timings(struct gpmi_nand_data *this, + const struct nand_sdr_timings *sdr) { struct gpmi_nfc_hardware_timing *hw = &this->hw; struct resources *r = &this->resources; @@ -657,22 +678,35 @@ static void gpmi_nfc_compute_timings(struct gpmi_nand_data *this, int sample_delay_ps, sample_delay_factor; u16 busy_timeout_cycles; u8 wrn_dly_sel; + long clk_rate; + int i, emode = -1; - if (sdr->tRC_min >= 30000) { - /* ONFI non-EDO modes [0-3] */ - hw->clk_rate = 22000000; - wrn_dly_sel = BV_GPMI_CTRL1_WRN_DLY_SEL_4_TO_8NS; - } else if (sdr->tRC_min >= 25000) { - /* ONFI EDO mode 4 */ - hw->clk_rate = 80000000; - wrn_dly_sel = BV_GPMI_CTRL1_WRN_DLY_SEL_NO_DELAY; - } else { - /* ONFI EDO mode 5 */ - hw->clk_rate = 100000000; - wrn_dly_sel = BV_GPMI_CTRL1_WRN_DLY_SEL_NO_DELAY; + /* Search the required EDO mode */ + for (i = 0; i < ARRAY_SIZE(edo_modes); i++) { + if (sdr->tRC_min >= edo_modes[i].tRC_min) { + emode = i; + break; + } + } + + if (emode < 0) { + dev_err(this->dev, "tRC_min %d not supported\n", sdr->tRC_min); + return -ENOTSUPP; + } + + clk_rate = clk_round_rate(r->clock[0], edo_modes[emode].clk_rate); + if (emode > 0 && !(clk_rate <= edo_modes[emode].clk_rate && + clk_rate > edo_modes[emode - 1].clk_rate)) { + dev_err(this->dev, + "edo mode %d clock setting: expected %ld, got %ld\n", + emode, edo_modes[emode].clk_rate, clk_rate); + return -ENOTSUPP; } - hw->clk_rate = clk_round_rate(r->clock[0], hw->clk_rate); + dev_dbg(this->dev, "edo mode %d @ %ld Hz\n", emode, clk_rate); + + hw->clk_rate = clk_rate; + wrn_dly_sel = edo_modes[emode].wrn_dly_sel; /* SDR core timings are given in picoseconds */ period_ps = div_u64((u64)NSEC_PER_SEC * 1000, hw->clk_rate); @@ -714,6 +748,7 @@ static void gpmi_nfc_compute_timings(struct gpmi_nand_data *this, hw->ctrl1n |= BF_GPMI_CTRL1_RDN_DELAY(sample_delay_factor) | BM_GPMI_CTRL1_DLL_ENABLE | (use_half_period ? BM_GPMI_CTRL1_HALF_PERIOD : 0); + return 0; } static int gpmi_nfc_apply_timings(struct gpmi_nand_data *this) @@ -769,6 +804,7 @@ static int gpmi_setup_interface(struct nand_chip *chip, int chipnr, { struct gpmi_nand_data *this = nand_get_controller_data(chip); const struct nand_sdr_timings *sdr; + int ret; /* Retrieve required NAND timings */ sdr = nand_get_sdr_timings(conf); @@ -784,7 +820,9 @@ static int gpmi_setup_interface(struct nand_chip *chip, int chipnr, return 0; /* Do the actual derivation of the controller timings */ - gpmi_nfc_compute_timings(this, sdr); + ret = gpmi_nfc_compute_timings(this, sdr); + if (ret) + return ret; this->hw.must_apply_timings = true;