Received: by 2002:a25:ef43:0:0:0:0:0 with SMTP id w3csp229504ybm; Thu, 28 May 2020 01:02:08 -0700 (PDT) X-Google-Smtp-Source: ABdhPJztHYihSeRAS869pKEfEjMENOnnmiiNib0j7DWKSIS6dkSgaZiV23MkBxWx7lBdbwHcH78K X-Received: by 2002:a17:906:8383:: with SMTP id p3mr1770710ejx.529.1590652928650; Thu, 28 May 2020 01:02:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1590652928; cv=none; d=google.com; s=arc-20160816; b=ykOgbeHNiHJjJ1XhZulqAXJpLJkWYAOkGKoy+8xTK1dP+tWsYt4BdmlhBzITuOYG9t V0iIDr8+cW8gklfK3DwxdJJKe50VTLJsaIBHooHMc9UTYwtVMLUS6dscZnhF7Ugj00oa in4P8P28aqxeMmBSPSOEGYWDkn3C504C+Cyz4J5lb7BnQlX2+x9i2z7+D+qp+t6yGwNH QL7WBAhEH+1USGdVDPHRoPdlSUZRdN67+DPbMbzs0Wf/XMhLLaKo6u+K1gRZy7dQi3FH xaY575RfDV7UzwwXinNx2PkqtsfukNtVznM/M5pwupsD/WwiOfwNTSYrEHQ0d6Cy0UDp nvow== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=i957V/2FNe74+sZekMhYbIdPCZWod5BtOHrUE2WxjkY=; b=AOQ+DtZiybsKFP7FMCGTpKVY5C9yOXH2P3+WHa6yHW7YbSGgZIN7Le8O+BbCao0yN0 2NiHZTKc1G+x+33bpuFZcCajw2zXpn8WzPIZ5qvckCFogdiT5mg5QamfKipg5aaRx5K5 YgSsMx7WJtHgJQebapkUIge81Ya20psY8XN+rL3syf6isskQDASnnFXCBJtsM6u5CfNi v1fY90OJZrfVZMjkrPobjv/SDaj5BO/IROfO+IHs5QxcH7AfXCCAeIz0tJ5SmsYIhQwS PXtYgxgvYRxB7LR/Cok8+J3p8IueLVd1ee9gSe7JhSpuTP4c53UT3lvzXKtJeuqI8BLs T6vQ== 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 c2si3651053edq.134.2020.05.28.01.01.45; Thu, 28 May 2020 01:02: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 S1726953AbgE1H7X (ORCPT + 99 others); Thu, 28 May 2020 03:59:23 -0400 Received: from twhmllg4.macronix.com ([122.147.135.202]:31269 "EHLO TWHMLLG4.macronix.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726857AbgE1H7U (ORCPT ); Thu, 28 May 2020 03:59:20 -0400 Received: from localhost.localdomain ([172.17.195.96]) by TWHMLLG4.macronix.com with ESMTP id 04S7wMHj030973; Thu, 28 May 2020 15:58:31 +0800 (GMT-8) (envelope-from masonccyang@mxic.com.tw) From: Mason Yang To: broonie@kernel.org, tudor.ambarus@microchip.com, miquel.raynal@bootlin.com, richard@nod.at, vigneshr@ti.com, boris.brezillon@collabora.com, matthias.bgg@gmail.com Cc: p.yadav@ti.com, juliensu@mxic.com.tw, linux-kernel@vger.kernel.org, linux-mtd@lists.infradead.org, linux-spi@vger.kernel.org Subject: [PATCH v3 10/14] mtd: spi-nor: core: use dummy cycle and address width info from SFDP Date: Thu, 28 May 2020 15:58:12 +0800 Message-Id: <1590652696-8844-11-git-send-email-masonccyang@mxic.com.tw> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1590652696-8844-1-git-send-email-masonccyang@mxic.com.tw> References: <1590652696-8844-1-git-send-email-masonccyang@mxic.com.tw> X-MAIL: TWHMLLG4.macronix.com 04S7wMHj030973 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Pratyush Yadav 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 | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/drivers/mtd/spi-nor/core.c b/drivers/mtd/spi-nor/core.c index 117d117..cbfdf544 100644 --- a/drivers/mtd/spi-nor/core.c +++ b/drivers/mtd/spi-nor/core.c @@ -435,6 +435,8 @@ int spi_nor_write_cr2(struct spi_nor *nor, u32 addr, u8 *cr2) 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 = @@ -443,10 +445,19 @@ 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; + } + 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) @@ -466,6 +477,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 = @@ -474,6 +487,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); -- 1.9.1