Received: by 2002:a25:1104:0:0:0:0:0 with SMTP id 4csp645076ybr; Fri, 22 May 2020 15:44:19 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxx8nP5/ojYEbFNuGQ3SZPGD45klGgJxwjRjnO61GZAWugwOw79/pTpJ6uM27Pzu80k+FFZ X-Received: by 2002:aa7:d993:: with SMTP id u19mr4861247eds.358.1590187459054; Fri, 22 May 2020 15:44:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1590187459; cv=none; d=google.com; s=arc-20160816; b=eimtAIW3rUY7Q2p4mmNbDw6odkoYejw12ySNnL5+BvAfh7Qd37inroy4eFoszcjIpd zsnkUkN0JVR3ZIJgZ3ZfXt1YGWOjk4eWpwu2Ovq+UHR9pfCO17/InrrN8aZ/HLpl1JZ7 1ftB6xFLb4AFzUREndOpCy9+KM2A/s5g+dnXXd4F1FvoTOAkALltsnrzAX3PTIUYyy8Z rGRuRI/0SSD0I9yvpjFCQTCDTcL4tUl2/Nip0qZyR+6OmEAO/IgIt/tMfCQSB2KzhShb ARJz2EGHjVMs9tAlSGxhhLpwaRTADv340CPZypfMOzY5sfymnTV/ZY/+ICddEnOL+kiV hZ3Q== 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=c7C3r3QF/TMH/epmeuxUZDNfTYW7xsLdZE5YulWo4ZQ=; b=ipIkH7pzYNZ4M36zQDg8hH7/xMVQB7mmL8o5EvkRca8vDJcoWaL9JEiuJZ3pXZxDxV JKlSdRxjLV+q4DRAwt8HIsebh/ZGVPCRHSCkbDDk1ZsiY8LsYUhY2GjTXFnFCXlBHHSz U/ZetHRq6+dTPqxgADs87owDlj+cPYZED0Tyc7D2frk1uwyIYCNGjDd2Q+/AZ3GPCAfZ 5/hz/iOw65F+TqDEgv4bUSYL6SvcAyuAXu6uVv50Y5O/qXw0v1+Uf7lEUnWvVILvTXn3 VW2HQftiya7YaIWDJrODw8Hbye+pQxTBehVcVPrFAoxDlkjYGhwZoIZOQMCz1X3C5hkI 4sHQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=sY6dMtIb; 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; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id p16si5300654ejd.80.2020.05.22.15.43.56; Fri, 22 May 2020 15:44:19 -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; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=sY6dMtIb; 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; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731358AbgEVWl7 (ORCPT + 99 others); Fri, 22 May 2020 18:41:59 -0400 Received: from lelv0142.ext.ti.com ([198.47.23.249]:35608 "EHLO lelv0142.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731138AbgEVWl7 (ORCPT ); Fri, 22 May 2020 18:41:59 -0400 Received: from lelv0265.itg.ti.com ([10.180.67.224]) by lelv0142.ext.ti.com (8.15.2/8.15.2) with ESMTP id 04MMfl95072950; Fri, 22 May 2020 17:41:47 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1590187307; bh=c7C3r3QF/TMH/epmeuxUZDNfTYW7xsLdZE5YulWo4ZQ=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=sY6dMtIbE4ucQ89M9rgHZOKwY229kVUfJ8o2cZwRCipUbOjYYF4DNsK9YiF+Xlnmk NMQnOeAs+inamfPGdbbr588Abww/k6LjH6fB6RmGpD5NzpFm0G2hLGJKEquv4A/KkZ Si71KruWAnp3RgsFuPKRDH1B/ukl2z3PpIz6k2YE= Received: from DLEE112.ent.ti.com (dlee112.ent.ti.com [157.170.170.23]) by lelv0265.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 04MMfkhS079807 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Fri, 22 May 2020 17:41:46 -0500 Received: from DLEE112.ent.ti.com (157.170.170.23) by DLEE112.ent.ti.com (157.170.170.23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1979.3; Fri, 22 May 2020 17:41:46 -0500 Received: from lelv0326.itg.ti.com (10.180.67.84) by DLEE112.ent.ti.com (157.170.170.23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1979.3 via Frontend Transport; Fri, 22 May 2020 17:41:46 -0500 Received: from pratyush-OptiPlex-790.dhcp.ti.com (ileax41-snat.itg.ti.com [10.172.224.153]) by lelv0326.itg.ti.com (8.15.2/8.15.2) with ESMTP id 04MMeh5i044559; Fri, 22 May 2020 17:41:41 -0500 From: Pratyush Yadav To: Tudor Ambarus , Miquel Raynal , Richard Weinberger , Vignesh Raghavendra , Mark Brown , Nicolas Ferre , Alexandre Belloni , Ludovic Desroches , Matthias Brugger , Michal Simek , , , , , CC: Pratyush Yadav , Sekhar Nori , Boris Brezillon , Mason Yang Subject: [PATCH v8 11/19] mtd: spi-nor: core: do 2 byte reads for SR and FSR in DTR mode Date: Sat, 23 May 2020 04:10:34 +0530 Message-ID: <20200522224042.29970-12-p.yadav@ti.com> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200522224042.29970-1-p.yadav@ti.com> References: <20200522224042.29970-1-p.yadav@ti.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 2ad248140b6c..5cb7e391cd29 100644 --- a/drivers/mtd/spi-nor/core.c +++ b/drivers/mtd/spi-nor/core.c @@ -350,7 +350,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. */ @@ -371,6 +371,11 @@ static int spi_nor_read_sr(struct spi_nor *nor, u8 *sr) op.addr.nbytes = addr_bytes; op.addr.val = 0; op.dummy.nbytes = 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); @@ -394,7 +399,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. */ @@ -415,6 +421,11 @@ static int spi_nor_read_fsr(struct spi_nor *nor, u8 *fsr) op.addr.nbytes = addr_bytes; op.addr.val = 0; op.dummy.nbytes = 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.26.2