Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp60218ybz; Fri, 24 Apr 2020 11:48:07 -0700 (PDT) X-Google-Smtp-Source: APiQypLZxhYZOgrqMpkyyT4Lno2VbwwWk138npEkvyMuIcMFw8Km8FJ3crMei11LC9Pdv8dPhThI X-Received: by 2002:a05:6402:3046:: with SMTP id bu6mr8658701edb.106.1587754087171; Fri, 24 Apr 2020 11:48:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1587754087; cv=none; d=google.com; s=arc-20160816; b=rf9N5k+84uoH87bWKAR+82k3aRNRn0dMeeRgx5/U8vNDRbOHxxGv+cwLXPCzw4bRlS HC+MenHW/mPi71LW9jgXUYlQLmLVML+agkYGAIgWxA18Oc7hH6Ik1uWcnseR2HlkrPTv nUveJ3oj4D/7Zm+f0lUc9vZu/Ld2uPs2CLH+Ln1NOJdQd+IFg0Sb1JD7sllfHrZFP2Eh EDzdTADX8bC9zqOoSWtr9/s9DlOw5kKKWZr9Gkpj67abFSQYMSKh30MnupbuyBEXLHr/ PE93oam6aj3M+0vpmNWAZeSGOBhYC8vW/uLWVc1BWF2uOmh3E+VnH4zusS1yT+578Yto L3/A== 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=+jepDXSfYfhqn1Grk7ZhPEamfAFpPI5NMwOs7iuBpr4=; b=IoN27S36/7IP8ds+AFr1sTYlIPZq6JGgHMrGHxXm+UA6u6/fW0mZsYlvCBInFQ0Upd HstOuhZ1DaxXEDNVazjlbjGpZzDrHwelDKHIPVE5/jfOAgTKgjEgpk0VXWlcQnLNaIKY +Ciq811raWArcKE9EzrpvrZqFS0cReQojBE0QhKF6JGiTtYqAOSUb/+BL/lwxGO8tHnZ UPAt90ucGcdLuFysNb1mH9JO8MTOqsByop9A9D99SPJyqokYYFQGXHfbtxZ3KjUIlHou er2rD4AnNKd44vytBRAz88DZw9K26V54wyHP8yZaNz++lKdbO+R8Yv8fMvDK4whA1q3e qYpw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=rCsMxsNT; 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 bs4si3658885ejb.275.2020.04.24.11.47.43; Fri, 24 Apr 2020 11:48:07 -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=rCsMxsNT; 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 S1729321AbgDXSpH (ORCPT + 99 others); Fri, 24 Apr 2020 14:45:07 -0400 Received: from fllv0015.ext.ti.com ([198.47.19.141]:44024 "EHLO fllv0015.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729114AbgDXSpG (ORCPT ); Fri, 24 Apr 2020 14:45:06 -0400 Received: from lelv0266.itg.ti.com ([10.180.67.225]) by fllv0015.ext.ti.com (8.15.2/8.15.2) with ESMTP id 03OIipPx102796; Fri, 24 Apr 2020 13:44:51 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1587753891; bh=+jepDXSfYfhqn1Grk7ZhPEamfAFpPI5NMwOs7iuBpr4=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=rCsMxsNTogOLSAmuC3KzHXPYtHRWez+H9s6RMpUkhyNwVNXnnWbHhWFzswPe57wXj mqF0NXwRfcAl+9aMa8eRaJ4UpZkMnkBtTuMR5BBELU9ItsIeziOvmkHJ52H6t+6d+x edf9YDIPwj7ojvb3fz6iEBzs0qInp0R/TWaoy4t4= Received: from DLEE100.ent.ti.com (dlee100.ent.ti.com [157.170.170.30]) by lelv0266.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 03OIipLr065197 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Fri, 24 Apr 2020 13:44:51 -0500 Received: from DLEE107.ent.ti.com (157.170.170.37) by DLEE100.ent.ti.com (157.170.170.30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1979.3; Fri, 24 Apr 2020 13:44:51 -0500 Received: from lelv0327.itg.ti.com (10.180.67.183) by DLEE107.ent.ti.com (157.170.170.37) 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, 24 Apr 2020 13:44:51 -0500 Received: from pratyush-OptiPlex-790.dhcp.ti.com (ileax41-snat.itg.ti.com [10.172.224.153]) by lelv0327.itg.ti.com (8.15.2/8.15.2) with ESMTP id 03OIiAaF047967; Fri, 24 Apr 2020 13:44:47 -0500 From: Pratyush Yadav To: Tudor Ambarus , Miquel Raynal , Richard Weinberger , Vignesh Raghavendra , Mark Brown , Nicolas Ferre , Alexandre Belloni , Ludovic Desroches , , , , CC: Pratyush Yadav , Sekhar Nori Subject: [PATCH v4 09/16] mtd: spi-nor: use dummy cycle and address width info from SFDP Date: Sat, 25 Apr 2020 00:14:03 +0530 Message-ID: <20200424184410.8578-10-p.yadav@ti.com> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200424184410.8578-1-p.yadav@ti.com> References: <20200424184410.8578-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 The xSPI Profile 1.0 table specifies how many dummy cycles and address bytes are needed for the Read Status Register command in octal DTR mode. Use that information to send the correct Read SR command. Signed-off-by: Pratyush Yadav --- drivers/mtd/spi-nor/core.c | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/drivers/mtd/spi-nor/core.c b/drivers/mtd/spi-nor/core.c index 9c92fc897fb4..3d181c7deda7 100644 --- a/drivers/mtd/spi-nor/core.c +++ b/drivers/mtd/spi-nor/core.c @@ -357,6 +357,8 @@ int spi_nor_write_disable(struct spi_nor *nor) static int spi_nor_read_sr(struct spi_nor *nor, u8 *sr) { int ret; + u8 addr_bytes = nor->params->rdsr_addr_nbytes; + u8 dummy = nor->params->rdsr_dummy; if (nor->spimem) { struct spi_mem_op op = @@ -365,10 +367,21 @@ static int spi_nor_read_sr(struct spi_nor *nor, u8 *sr) SPI_MEM_OP_NO_DUMMY, SPI_MEM_OP_DATA_IN(1, sr, 1)); + if (spi_nor_protocol_is_dtr(nor->reg_proto)) { + op.addr.nbytes = addr_bytes; + op.addr.val = 0; + op.dummy.nbytes = dummy; + } + + spi_nor_spimem_setup_op(nor, &op, nor->reg_proto); + ret = spi_mem_exec_op(nor->spimem, &op); } else { - ret = nor->controller_ops->read_reg(nor, SPINOR_OP_RDSR, - sr, 1); + if (spi_nor_protocol_is_dtr(nor->reg_proto)) + ret = -ENOTSUPP; + else + ret = nor->controller_ops->read_reg(nor, SPINOR_OP_RDSR, + sr, 1); } if (ret) @@ -388,6 +401,8 @@ static int spi_nor_read_sr(struct spi_nor *nor, u8 *sr) static int spi_nor_read_fsr(struct spi_nor *nor, u8 *fsr) { int ret; + u8 addr_bytes = nor->params->rdsr_addr_nbytes; + u8 dummy = nor->params->rdsr_dummy; if (nor->spimem) { struct spi_mem_op op = @@ -396,6 +411,12 @@ static int spi_nor_read_fsr(struct spi_nor *nor, u8 *fsr) SPI_MEM_OP_NO_DUMMY, SPI_MEM_OP_DATA_IN(1, fsr, 1)); + if (spi_nor_protocol_is_dtr(nor->reg_proto)) { + op.addr.nbytes = addr_bytes; + op.addr.val = 0; + op.dummy.nbytes = dummy; + } + spi_nor_spimem_setup_op(nor, &op, nor->reg_proto); ret = spi_mem_exec_op(nor->spimem, &op); -- 2.25.0