From patchwork Fri Oct 12 08:48:25 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Boris Brezillon X-Patchwork-Id: 10638089 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 950D91508 for ; Fri, 12 Oct 2018 08:49:05 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 86E802B742 for ; Fri, 12 Oct 2018 08:49:05 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7B9872B758; Fri, 12 Oct 2018 08:49:05 +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 291FA2B742 for ; Fri, 12 Oct 2018 08:49:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726788AbeJLQUZ (ORCPT ); Fri, 12 Oct 2018 12:20:25 -0400 Received: from mail.bootlin.com ([62.4.15.54]:43228 "EHLO mail.bootlin.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728019AbeJLQUZ (ORCPT ); Fri, 12 Oct 2018 12:20:25 -0400 Received: by mail.bootlin.com (Postfix, from userid 110) id 80B9F20DDC; 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 5912F20DE1; Fri, 12 Oct 2018 10:48:33 +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 18/18] mtd: spi-nor: Make sure the 8D-8D-8D can be selected on mx25uw51245g Date: Fri, 12 Oct 2018 10:48:25 +0200 Message-Id: <20181012084825.23697-19-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 mx25uw51245g support 8D-8D-8D mode. Patch the macronix_opi_change_mode() and macronix_opi_tweak_params() functions to support this mode. Signed-off-by: Boris Brezillon --- drivers/mtd/spi-nor/spi-nor.c | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/drivers/mtd/spi-nor/spi-nor.c b/drivers/mtd/spi-nor/spi-nor.c index d961e3a7b500..e8bd807b7520 100644 --- a/drivers/mtd/spi-nor/spi-nor.c +++ b/drivers/mtd/spi-nor/spi-nor.c @@ -1709,6 +1709,10 @@ static int macronix_opi_change_mode(struct spi_nor *nor, val |= CR2_REG0_MODE_OPI_STR; break; + case SPI_NOR_MODE_OPI_FULL_DTR: + val |= CR2_REG0_MODE_OPI_DTR; + break; + default: /* * If we reach that point, there's a serious problem in the @@ -1732,7 +1736,11 @@ static void macronix_opi_adjust_op(struct spi_nor *nor, struct spi_mem_op *op) case SPINOR_OP_READ_4B: case SPINOR_OP_READ_FAST_4B: op->dummy.nbytes = 20; - op->cmd.opcode = 0xec; + if (nor->mode == SPI_NOR_MODE_OPI_FULL_DTR) + op->cmd.opcode = 0xee; + else + op->cmd.opcode = 0xec; + break; case SPINOR_OP_PP: @@ -1781,8 +1789,11 @@ static void macronix_opi_adjust_op(struct spi_nor *nor, struct spi_mem_op *op) if (op->addr.nbytes) op->addr.buswidth = 8; - if (op->dummy.nbytes) + if (op->dummy.nbytes) { op->dummy.buswidth = 8; + if (op->dummy.dtr) + op->dummy.nbytes *= 2; + } if (op->data.buswidth) op->data.buswidth = 8; @@ -1805,6 +1816,14 @@ static void macronix_opi_tweak_params(struct spi_nor *nor, spi_nor_set_pp_settings(¶ms->page_programs[SNOR_CMD_PP_8_8_8], 0x12ed, SNOR_PROTO_8_8_8 | SNOR_PROTO_INST_2BYTE); + + params->hwcaps.mask |= SNOR_HWCAPS_OPI_FULL_DTR; + spi_nor_set_read_settings(¶ms->reads[SNOR_CMD_READ_8D_8D_8D], + 0, 20, 0xee11, + SNOR_PROTO_8D_8D_8D | SNOR_PROTO_INST_2BYTE); + spi_nor_set_pp_settings(¶ms->page_programs[SNOR_CMD_PP_8D_8D_8D], + 0x12ed, + SNOR_PROTO_8D_8D_8D | SNOR_PROTO_INST_2BYTE); } /* Used when the "_ext_id" is two bytes at most */