Received: by 2002:a25:e74b:0:0:0:0:0 with SMTP id e72csp1323498ybh; Thu, 23 Jul 2020 06:14:08 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy2Ur7UBLJj4/vquONFcIg6iDICBsDnJnvnjAOnInJy8N3cPXDnXJY2at+yuTqCd835yFdA X-Received: by 2002:a17:906:dbe9:: with SMTP id yd9mr4389577ejb.75.1595510048267; Thu, 23 Jul 2020 06:14:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1595510048; cv=none; d=google.com; s=arc-20160816; b=U2TMLxzdBvweKXVNu5fbZlNsx2nPzmySd+kHGVncWYX38EDNqHhgQJQyal5JtXCjj8 dZ40ZAArzhFe3YCUawTvc54AsDm2OQDOyajltPRtGqOreXcMJXoGFt56NtJn7oOAFc1s C1l+3XDr5tqTg9/hKY/2SsD1A/Nf2JV/0ftqLXBABY+OMmsn2pZJpYJDJnXkOUDsTDcF JqKgkXTM0iohRJCfNlUQZe6m4q295lmHlt/CdP9QLeLQxVK118erXuUbKzSG86MdmK6j nInwIneeSj1aKXibCzH8DT0/HKBC6miwVXE75H29otoEZUcFvLn9TkJcs67mI4rup8PU R/xA== 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; bh=7pJBQgA6ROrChHdssiK9fKUHlfVJgjwZHyVvapwnKhg=; b=qGZe1Q12HyDBS5dK9KumjrVod1hM7s1cJb7eJWIqEwIZAZNbSHW7kxE5MPUBdQZ7Zh vHOf+fhYnHzi7x876xYgsYjCI+WyHpfGwFbfp6IO9iRDaVlms/7PtDyYGp6vEEeCDCja p8WgKLARZ9y4WD75TQ1tyoTZ/sJ1/haIwdTlOc3FkG/D5MfzwBD0Vw5b6h576ew39h3u 545oOUQ7Sc1Aik3/Tzw/2PnBDt3+x43WwdSGKS8b75glSCAZv6mNGFuqt3LBK/NvZXuE N5t5XD3hJCBzhncgLdqy50xlMZm3yHDGVYHSiuZXDC/O7qKT/ZaKlO3LdNKZ6Gmh7kWg Hh7A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id lc15si1961731ejb.526.2020.07.23.06.13.45; Thu, 23 Jul 2020 06:14:08 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729168AbgGWNM4 (ORCPT + 99 others); Thu, 23 Jul 2020 09:12:56 -0400 Received: from relay5-d.mail.gandi.net ([217.70.183.197]:35667 "EHLO relay5-d.mail.gandi.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726521AbgGWNM4 (ORCPT ); Thu, 23 Jul 2020 09:12:56 -0400 X-Originating-IP: 42.109.196.68 Received: from localhost.localdomain (unknown [42.109.196.68]) (Authenticated sender: me@yadavpratyush.com) by relay5-d.mail.gandi.net (Postfix) with ESMTPSA id EABE71C0009; Thu, 23 Jul 2020 13:12:50 +0000 (UTC) From: Pratyush Yadav To: Tudor Ambarus , Miquel Raynal , Richard Weinberger , Vignesh Raghavendra , linux-mtd@lists.infradead.org, linux-kernel@vger.kernel.org Cc: Sekhar Nori , Boris Brezillon , Pratyush Yadav , Pratyush Yadav Subject: [PATCH v11 07/14] mtd: spi-nor: core: do 2 byte reads for SR and FSR in DTR mode Date: Thu, 23 Jul 2020 18:41:56 +0530 Message-Id: <20200723131203.40916-8-me@yadavpratyush.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200723131203.40916-1-me@yadavpratyush.com> References: <20200723131203.40916-1-me@yadavpratyush.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 From: Pratyush Yadav Some controllers, like the cadence qspi controller, have trouble reading only 1 byte in DTR mode. So, do 2 byte reads for SR and FSR commands in DTR mode, and then discard the second byte. Signed-off-by: Pratyush Yadav --- drivers/mtd/spi-nor/core.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/drivers/mtd/spi-nor/core.c b/drivers/mtd/spi-nor/core.c index 185ca1fa2b50..6efc86e2aba0 100644 --- a/drivers/mtd/spi-nor/core.c +++ b/drivers/mtd/spi-nor/core.c @@ -364,7 +364,7 @@ int spi_nor_write_disable(struct spi_nor *nor) * spi_nor_read_sr() - Read the Status Register. * @nor: pointer to 'struct spi_nor'. * @sr: pointer to a DMA-able buffer where the value of the - * Status Register will be written. + * Status Register will be written. Should be at least 2 bytes. * * Return: 0 on success, -errno otherwise. */ @@ -382,6 +382,11 @@ static int spi_nor_read_sr(struct spi_nor *nor, u8 *sr) if (spi_nor_protocol_is_dtr(nor->reg_proto)) { op.addr.nbytes = nor->params->rdsr_addr_nbytes; op.dummy.nbytes = nor->params->rdsr_dummy; + /* + * We don't want to read only one byte in DTR mode. So, + * read 2 and then discard the second byte. + */ + op.data.nbytes = 2; } spi_nor_spimem_setup_op(nor, &op, nor->reg_proto); @@ -400,7 +405,8 @@ static int spi_nor_read_sr(struct spi_nor *nor, u8 *sr) * spi_nor_read_fsr() - Read the Flag Status Register. * @nor: pointer to 'struct spi_nor' * @fsr: pointer to a DMA-able buffer where the value of the - * Flag Status Register will be written. + * Flag Status Register will be written. Should be at least 2 + * bytes. * * Return: 0 on success, -errno otherwise. */ @@ -418,6 +424,11 @@ static int spi_nor_read_fsr(struct spi_nor *nor, u8 *fsr) if (spi_nor_protocol_is_dtr(nor->reg_proto)) { op.addr.nbytes = nor->params->rdsr_addr_nbytes; op.dummy.nbytes = nor->params->rdsr_dummy; + /* + * We don't want to read only one byte in DTR mode. So, + * read 2 and then discard the second byte. + */ + op.data.nbytes = 2; } spi_nor_spimem_setup_op(nor, &op, nor->reg_proto); -- 2.27.0