Received: by 2002:a25:31c3:0:0:0:0:0 with SMTP id x186csp631646ybx; Wed, 6 Nov 2019 06:10:07 -0800 (PST) X-Google-Smtp-Source: APXvYqzYJ1DJORz7341GEByzohNag0KMcteK7b4MlH3xj73CTK2Ornz7TL1kf5FZ8l7klv8J2vHM X-Received: by 2002:a17:906:e291:: with SMTP id gg17mr18663894ejb.209.1573049407275; Wed, 06 Nov 2019 06:10:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1573049407; cv=none; d=google.com; s=arc-20160816; b=Gc1n2/sP3phsVngrgMfovW7C7CfDrWnHO39BCqQdqILs3eOefJdgtnUr1FiAONPZgf VtsDnURVcDuB1kfWeVxWObnokyhuvXlitpCG2A0w7pHRE+4puBRfG56AiD1dqkjEzilv MsSBVYFBH6I3BmwtrlxHdc4AJ/LbjMoLMpJnUeoec0M/hjzAtiT52SA+JyCLxa4MGzTE uEiRSdqptcmTrYTw7lM//GpVhbqGCLZrb65Fm1Cg+Oc0qY/roDbcRSRRYy/IcCAaLXV9 m8lWsDD4ERpU8kSi9Rrkb883tAfdU6kPmWy4oi1R83hF9NPyy7qsEiL3n6tTb7geDIzb Ct/g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=IGrpDRKjGtiRT6QlcUQ2diK8Wp4T7B3HNEKu57gaI70=; b=UH6Y0qh2ygskn/2/DPGxG1fG63xjyWAqdT+BX0J0XmHbj4PIpkYiz9dnrAv5c5ZuXi nfLeBAEo3hUex8lCNulRQHaRgWs3ePYx1ysPcUE+oHKdBWEc1GPYFn1gVMmtqjD6xMR+ RvXp6YwIbOsxe3DWCfF3tUmZudqRpWc2nOIE1UzevNzgIHTA5evdzGxj/J0P3KZ6aHxo 3S2fmtldv9AcaL5svr//fNYmt69AJmRnxmEWZtmoFN1czgX53V34y/64+vpNe+kp/iJ6 XjqO5VS96LgdoKagmx91yXM4o7OoUFC/e32tJrsHLTGOYpyHf68fqcY7EJeLdi14RUE4 LAPw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=M4LY1AVp; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i1si785095eja.102.2019.11.06.06.09.42; Wed, 06 Nov 2019 06:10:07 -0800 (PST) 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; dkim=pass header.i=@gmail.com header.s=20161025 header.b=M4LY1AVp; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731781AbfKFOIr (ORCPT + 99 others); Wed, 6 Nov 2019 09:08:47 -0500 Received: from mail-pg1-f194.google.com ([209.85.215.194]:36006 "EHLO mail-pg1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726917AbfKFOIq (ORCPT ); Wed, 6 Nov 2019 09:08:46 -0500 Received: by mail-pg1-f194.google.com with SMTP id k13so5904098pgh.3; Wed, 06 Nov 2019 06:08:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=IGrpDRKjGtiRT6QlcUQ2diK8Wp4T7B3HNEKu57gaI70=; b=M4LY1AVpLRKaQ2PYpl4ihvdNmjYEbPsEsgJGBp5awZvOHExCB4h9/vK/P1ajy7wo4R eCznYQKQmR0sxuEQhx2oXaGnZRS0+eVNZY2kX4ZjBV+ps4U7af3uQx7sDze9vlQLznir 0+HGyIcrR0PoJ69qYWqFpl7aLdHYCXI3x25DrYnY6IKnvJ8a3f1uICEEInJ1jqriXyOi AAPSaDfApqTsa50NTGrK4sl1f6wa1GLuun1S1qnjDGiOinOxUozoZUHhc192xjATsI1Z nG4xZajoba2Bx/4KevwV9PXpoOylk3TpskZAbiV/uma4ZsBPl4rEF50ZQ44nc2Od9vxI bmOw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=IGrpDRKjGtiRT6QlcUQ2diK8Wp4T7B3HNEKu57gaI70=; b=RQWpBBCjDw4ovNi0WCHAr6zD3iSp1fLPNv9Rj1y+8yZHSUymPiw8jOXnDM/8MLKan9 085P2dRq6ck8Vb5mJDPiw41Nr6BKCC0heZB3AQhSP0BT4sSpFcKUwdmDCx1fAMNmCXZT bE+Bg1Y3ZInY7PVhF50FZ6FcdwzOsDqCYz9R6MvgbPtAHvHCp79IGAR4EH+IdSbO5qrB oksxUHyVIggYPQHcntFvlbeyRowI0H1MR4IF6sAlS1snQsBeSytAoX/LipyFMKu+C3Ot Qir9AUII3/ENMayj5bNfsM/912AfVAG/W1RNHv2Ra3+ek9bKPYdG2VpxAssgGGVPrYmY XmBA== X-Gm-Message-State: APjAAAVrbrPUkA3OY8w6YJ6O4+Sjc/BnZxDvtmGQ5/5Dy7ctcdlDMW7k 5UieQLSp5U0elN1NSHz42Pk= X-Received: by 2002:a65:5885:: with SMTP id d5mr3017512pgu.278.1573049326032; Wed, 06 Nov 2019 06:08:46 -0800 (PST) Received: from localhost.localdomain ([2001:19f0:7001:2668:5400:1ff:fe62:2bbd]) by smtp.gmail.com with ESMTPSA id a16sm4707345pfc.56.2019.11.06.06.08.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Nov 2019 06:08:43 -0800 (PST) From: Chuanhong Guo To: linux-mtd@lists.infradead.org Cc: David Woodhouse , Brian Norris , Miquel Raynal , Richard Weinberger , Vignesh Raghavendra , Rob Herring , Mark Rutland , Matthias Brugger , Tudor Ambarus , devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, linux-kernel@vger.kernel.org, Chuanhong Guo Subject: [PATCH 1/2] mtd: mtk-quadspi: add support for memory-mapped flash reading Date: Wed, 6 Nov 2019 22:07:47 +0800 Message-Id: <20191106140748.13100-2-gch981213@gmail.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20191106140748.13100-1-gch981213@gmail.com> References: <20191106140748.13100-1-gch981213@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org PIO reading mode on this controller is ridiculously inefficient (one cmd+addr+dummy sequence reads only one byte) This patch adds support for reading from memory-mapped flash area which increases reading speed from 1MB/s to 5.6MB/s Signed-off-by: Chuanhong Guo --- drivers/mtd/spi-nor/mtk-quadspi.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/drivers/mtd/spi-nor/mtk-quadspi.c b/drivers/mtd/spi-nor/mtk-quadspi.c index 34db01ab6cab..ba8b3be39896 100644 --- a/drivers/mtd/spi-nor/mtk-quadspi.c +++ b/drivers/mtd/spi-nor/mtk-quadspi.c @@ -106,6 +106,7 @@ struct mtk_nor { struct spi_nor nor; struct device *dev; void __iomem *base; /* nor flash base address */ + void __iomem *flash_base; struct clk *spi_clk; struct clk *nor_clk; }; @@ -272,6 +273,11 @@ static ssize_t mtk_nor_read(struct spi_nor *nor, loff_t from, size_t length, mtk_nor_set_read_mode(mtk_nor); mtk_nor_set_addr(mtk_nor, addr); + if (mtk_nor->flash_base) { + memcpy_fromio(buffer, mtk_nor->flash_base + from, length); + return length; + } + for (i = 0; i < length; i++) { ret = mtk_nor_execute_cmd(mtk_nor, MTK_NOR_PIO_READ_CMD); if (ret < 0) @@ -475,6 +481,11 @@ static int mtk_nor_drv_probe(struct platform_device *pdev) if (IS_ERR(mtk_nor->base)) return PTR_ERR(mtk_nor->base); + res = platform_get_resource(pdev, IORESOURCE_MEM, 1); + mtk_nor->flash_base = devm_ioremap_resource(&pdev->dev, res); + if (IS_ERR(mtk_nor->flash_base)) + mtk_nor->flash_base = NULL; + mtk_nor->spi_clk = devm_clk_get(&pdev->dev, "spi"); if (IS_ERR(mtk_nor->spi_clk)) return PTR_ERR(mtk_nor->spi_clk); -- 2.21.0