From patchwork Fri Oct 12 08:48:22 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Boris Brezillon X-Patchwork-Id: 10638087 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id CF6D717E1 for ; Fri, 12 Oct 2018 08:49:04 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BEAAE2B742 for ; Fri, 12 Oct 2018 08:49:04 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B2C2E2B758; Fri, 12 Oct 2018 08:49:04 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4DD042B742 for ; Fri, 12 Oct 2018 08:49:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727953AbeJLQU0 (ORCPT ); Fri, 12 Oct 2018 12:20:26 -0400 Received: from mail.bootlin.com ([62.4.15.54]:43227 "EHLO mail.bootlin.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728014AbeJLQU0 (ORCPT ); Fri, 12 Oct 2018 12:20:26 -0400 Received: by mail.bootlin.com (Postfix, from userid 110) id 63E1420703; Fri, 12 Oct 2018 10:48:58 +0200 (CEST) Received: from localhost.localdomain (AAubervilliers-681-1-7-245.w90-88.abo.wanadoo.fr [90.88.129.245]) by mail.bootlin.com (Postfix) with ESMTPSA id 60A3120DDD; Fri, 12 Oct 2018 10:48:32 +0200 (CEST) From: Boris Brezillon To: David Woodhouse , Brian Norris , Boris Brezillon , Marek Vasut , Richard Weinberger , linux-mtd@lists.infradead.org, Yogesh Gaur , Vignesh R , Cyrille Pitchen Cc: Julien Su , Mason Yang , , Mark Brown , linux-spi@vger.kernel.org Subject: [PATCH RFC 15/18] mtd: spi-nor: Add DTR support to the spi-mem logic Date: Fri, 12 Oct 2018 10:48:22 +0200 Message-Id: <20181012084825.23697-16-boris.brezillon@bootlin.com> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20181012084825.23697-1-boris.brezillon@bootlin.com> References: <20181012084825.23697-1-boris.brezillon@bootlin.com> Sender: linux-spi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-spi@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Make sure op->xxx.dtr fields are properly filled and unmask DTR modes in spi_nor_spimem_adjust_hwcaps() so that DTR support detection is done through spi_mem_supports_op(). Signed-off-by: Boris Brezillon --- drivers/mtd/spi-nor/spi-nor.c | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/drivers/mtd/spi-nor/spi-nor.c b/drivers/mtd/spi-nor/spi-nor.c index 98dab7f6938e..9ff957dc351c 100644 --- a/drivers/mtd/spi-nor/spi-nor.c +++ b/drivers/mtd/spi-nor/spi-nor.c @@ -280,12 +280,18 @@ static ssize_t spi_nor_spimem_read_data(struct spi_nor *nor, loff_t ofs, /* get transfer protocols. */ op.cmd.buswidth = spi_nor_get_protocol_inst_nbits(nor->read_proto); + op.cmd.dtr = spi_nor_protocol_inst_is_dtr(nor->read_proto); op.addr.buswidth = spi_nor_get_protocol_addr_nbits(nor->read_proto); + op.addr.dtr = spi_nor_protocol_addr_is_dtr(nor->read_proto); op.dummy.buswidth = op.addr.buswidth; + op.dummy.dtr = op.addr.dtr; op.data.buswidth = spi_nor_get_protocol_data_nbits(nor->read_proto); + op.data.dtr = spi_nor_protocol_data_is_dtr(nor->read_proto); /* convert the dummy cycles to the number of bytes */ op.dummy.nbytes = (nor->read_dummy * op.dummy.buswidth) / 8; + if (op.dummy.dtr) + op.dummy.nbytes *= 2; if (nor->read_proto & SNOR_PROTO_INST_2BYTE) op.cmd.nbytes = 2; @@ -345,8 +351,11 @@ static ssize_t spi_nor_spimem_write_data(struct spi_nor *nor, loff_t ofs, /* get transfer protocols. */ op.cmd.buswidth = spi_nor_get_protocol_inst_nbits(nor->write_proto); + op.cmd.dtr = spi_nor_protocol_inst_is_dtr(nor->write_proto); op.addr.buswidth = spi_nor_get_protocol_addr_nbits(nor->write_proto); + op.addr.dtr = spi_nor_protocol_addr_is_dtr(nor->write_proto); op.data.buswidth = spi_nor_get_protocol_data_nbits(nor->write_proto); + op.data.dtr = spi_nor_protocol_data_is_dtr(nor->write_proto); if (nor->write_proto & SNOR_PROTO_INST_2BYTE) op.cmd.nbytes = 2; @@ -3043,11 +3052,17 @@ static int spi_nor_spimem_check_readop(struct spi_nor *nor, SPI_MEM_OP_DATA_IN(0, NULL, 1)); op.cmd.buswidth = spi_nor_get_protocol_inst_nbits(read->proto); + op.cmd.dtr = spi_nor_protocol_inst_is_dtr(read->proto); op.addr.buswidth = spi_nor_get_protocol_addr_nbits(read->proto); + op.addr.dtr = spi_nor_protocol_addr_is_dtr(read->proto); op.data.buswidth = spi_nor_get_protocol_data_nbits(read->proto); + op.data.dtr = spi_nor_protocol_addr_is_dtr(read->proto); op.dummy.buswidth = op.addr.buswidth; + op.dummy.dtr = op.addr.dtr; op.dummy.nbytes = (read->num_mode_clocks + read->num_wait_states) * op.dummy.buswidth / 8; + if (op.dummy.dtr) + op.dummy.nbytes *= 2; if (read->proto & SNOR_PROTO_INST_2BYTE) op.cmd.nbytes = 2; @@ -3077,8 +3092,11 @@ static int spi_nor_spimem_check_progop(struct spi_nor *nor, SPI_MEM_OP_DATA_OUT(0, NULL, 1)); op.cmd.buswidth = spi_nor_get_protocol_inst_nbits(pp->proto); + op.cmd.dtr = spi_nor_protocol_inst_is_dtr(pp->proto); op.addr.buswidth = spi_nor_get_protocol_addr_nbits(pp->proto); + op.addr.dtr = spi_nor_protocol_addr_is_dtr(pp->proto); op.data.buswidth = spi_nor_get_protocol_data_nbits(pp->proto); + op.data.dtr = spi_nor_protocol_addr_is_dtr(pp->proto); if (pp->proto & SNOR_PROTO_INST_2BYTE) op.cmd.nbytes = 2; @@ -3106,9 +3124,6 @@ spi_nor_spimem_adjust_hwcaps(struct spi_nor *nor, { unsigned int cap; - /* DTR modes are not supported yet, mask them all. */ - *hwcaps &= ~SNOR_HWCAPS_DTR; - /* Start with read commands. */ for (cap = 0; cap < 32; cap++) { int idx;