From patchwork Wed Nov 8 17:11:46 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Biju Das X-Patchwork-Id: 13450325 X-Patchwork-Delegate: geert@linux-m68k.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 30104C4167B for ; Wed, 8 Nov 2023 17:12:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232467AbjKHRMF (ORCPT ); Wed, 8 Nov 2023 12:12:05 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53908 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232483AbjKHRMD (ORCPT ); Wed, 8 Nov 2023 12:12:03 -0500 Received: from relmlie6.idc.renesas.com (relmlor2.renesas.com [210.160.252.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 273691FF6; Wed, 8 Nov 2023 09:11:59 -0800 (PST) X-IronPort-AV: E=Sophos;i="6.03,286,1694703600"; d="scan'208";a="186043539" Received: from unknown (HELO relmlir6.idc.renesas.com) ([10.200.68.152]) by relmlie6.idc.renesas.com with ESMTP; 09 Nov 2023 02:11:59 +0900 Received: from localhost.localdomain (unknown [10.226.92.247]) by relmlir6.idc.renesas.com (Postfix) with ESMTP id 3A68F402E576; Thu, 9 Nov 2023 02:11:55 +0900 (JST) From: Biju Das To: Mark Brown Cc: Biju Das , linux-spi@vger.kernel.org, linux-mtd@lists.infradead.org, Geert Uytterhoeven , Prabhakar Mahadev Lad , Miquel Raynal , Michael Walle , Biju Das , linux-renesas-soc@vger.kernel.org Subject: [PATCH RFC 1/4] spi: spi-mem: Add set_iofv() callback Date: Wed, 8 Nov 2023 17:11:46 +0000 Message-Id: <20231108171149.258656-2-biju.das.jz@bp.renesas.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20231108171149.258656-1-biju.das.jz@bp.renesas.com> References: <20231108171149.258656-1-biju.das.jz@bp.renesas.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-renesas-soc@vger.kernel.org As per section 8.14 on the AT25QL128A hardware manual, IO0..IO3 must be set to Hi-Z state for this flash for fast read quad IO. Snippet from HW manual section 8.14: The upper nibble of the Mode(M7-4) controls the length of the next FAST Read Quad IO instruction through the inclusion or exclusion of the first byte instruction code. The lower nibble bits of the Mode(M3-0) are don't care. However, the IO pins must be high-impedance before the falling edge of the first data out clock. Add set_iofv() callback for configuring IO fixed values to control the pin state. Signed-off-by: Biju Das --- drivers/spi/spi-mem.c | 20 ++++++++++++++++++++ include/linux/spi/spi-mem.h | 4 ++++ 2 files changed, 24 insertions(+) diff --git a/drivers/spi/spi-mem.c b/drivers/spi/spi-mem.c index edd7430d4c05..0cfca8c438e3 100644 --- a/drivers/spi/spi-mem.c +++ b/drivers/spi/spi-mem.c @@ -297,6 +297,26 @@ static void spi_mem_access_end(struct spi_mem *mem) pm_runtime_put(ctlr->dev.parent); } +/** + * spi_mem_set_iofv() - Set IO fixed values to control the pin state + * @mem: the SPI memory + * @val: the IO fixed values + * + * Set IO fixed values to control the pin state. + * + * Return: 0 in case of success, a negative error code otherwise. + */ +int spi_mem_set_iofv(struct spi_mem *mem, u32 val) +{ + struct spi_controller *ctlr = mem->spi->controller; + + if (ctlr->mem_ops && ctlr->mem_ops->set_iofv) + return ctlr->mem_ops->set_iofv(mem, val); + + return 0; +} +EXPORT_SYMBOL_GPL(spi_mem_set_iofv); + /** * spi_mem_exec_op() - Execute a memory operation * @mem: the SPI memory diff --git a/include/linux/spi/spi-mem.h b/include/linux/spi/spi-mem.h index 6b0a7dc48a4b..e50f89bf5ba9 100644 --- a/include/linux/spi/spi-mem.h +++ b/include/linux/spi/spi-mem.h @@ -232,6 +232,7 @@ static inline void *spi_mem_get_drvdata(struct spi_mem *mem) * limitations (can be alignment or max RX/TX size * limitations) * @supports_op: check if an operation is supported by the controller + * @set_iofv: set IO fixed values to control the pin state * @exec_op: execute a SPI memory operation * @get_name: get a custom name for the SPI mem device from the controller. * This might be needed if the controller driver has been ported @@ -274,6 +275,7 @@ struct spi_controller_mem_ops { int (*adjust_op_size)(struct spi_mem *mem, struct spi_mem_op *op); bool (*supports_op)(struct spi_mem *mem, const struct spi_mem_op *op); + int (*set_iofv)(struct spi_mem *mem, u32 val); int (*exec_op)(struct spi_mem *mem, const struct spi_mem_op *op); const char *(*get_name)(struct spi_mem *mem); @@ -367,6 +369,8 @@ int spi_mem_adjust_op_size(struct spi_mem *mem, struct spi_mem_op *op); bool spi_mem_supports_op(struct spi_mem *mem, const struct spi_mem_op *op); +int spi_mem_set_iofv(struct spi_mem *mem, u32 val); + int spi_mem_exec_op(struct spi_mem *mem, const struct spi_mem_op *op); From patchwork Wed Nov 8 17:11:47 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Biju Das X-Patchwork-Id: 13450326 X-Patchwork-Delegate: geert@linux-m68k.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id BEA5DC4332F for ; Wed, 8 Nov 2023 17:12:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232470AbjKHRMH (ORCPT ); Wed, 8 Nov 2023 12:12:07 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53922 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232488AbjKHRMG (ORCPT ); Wed, 8 Nov 2023 12:12:06 -0500 Received: from relmlie5.idc.renesas.com (relmlor1.renesas.com [210.160.252.171]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 44D9A1FFC for ; Wed, 8 Nov 2023 09:12:04 -0800 (PST) X-IronPort-AV: E=Sophos;i="6.03,286,1694703600"; d="scan'208";a="182203715" Received: from unknown (HELO relmlir6.idc.renesas.com) ([10.200.68.152]) by relmlie5.idc.renesas.com with ESMTP; 09 Nov 2023 02:12:03 +0900 Received: from localhost.localdomain (unknown [10.226.92.247]) by relmlir6.idc.renesas.com (Postfix) with ESMTP id DA3F2402E576; Thu, 9 Nov 2023 02:11:59 +0900 (JST) From: Biju Das To: Tudor Ambarus , Pratyush Yadav , Miquel Raynal , Richard Weinberger , Vignesh Raghavendra Cc: Biju Das , Michael Walle , Mark Brown , linux-mtd@lists.infradead.org, Geert Uytterhoeven , Prabhakar Mahadev Lad , Biju Das , linux-renesas-soc@vger.kernel.org Subject: [PATCH RFC 2/4] mtd: spi-nor: Add post_sfdp() callback Date: Wed, 8 Nov 2023 17:11:47 +0000 Message-Id: <20231108171149.258656-3-biju.das.jz@bp.renesas.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20231108171149.258656-1-biju.das.jz@bp.renesas.com> References: <20231108171149.258656-1-biju.das.jz@bp.renesas.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-renesas-soc@vger.kernel.org Some generic flash devices such as Renesas AT25QL128A serial nor flash requires the IO pins must be in high-impedance before the falling edge of the first data out clock for the Fast Read Quad IO. Add post_sfdp() callback for generic flash devices and then call spi_mem_set_iofv() to configure IO fixed value to control the pin state. Signed-off-by: Biju Das --- drivers/mtd/spi-nor/core.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/drivers/mtd/spi-nor/core.c b/drivers/mtd/spi-nor/core.c index 1c443fe568cf..eef3c286b174 100644 --- a/drivers/mtd/spi-nor/core.c +++ b/drivers/mtd/spi-nor/core.c @@ -1997,6 +1997,21 @@ int spi_nor_sr2_bit7_quad_enable(struct spi_nor *nor) return 0; } +static int spi_nor_generic_post_sfdp_fixup(struct spi_nor *nor) +{ + struct spi_device *spi = nor->spimem->spi; + const u8 *id = nor->id; + + if (spi->mode & SPI_TX_QUAD && nor->spimem) { + const struct spi_nor_id *at25ql128a_id = SNOR_ID(0x1f, 0x42, 0x18); + + if (!memcmp(id, at25ql128a_id->bytes, at25ql128a_id->len)) + return spi_mem_set_iofv(nor->spimem, 0xff); + } + + return 0; +} + static const struct spi_nor_manufacturer *manufacturers[] = { &spi_nor_atmel, &spi_nor_eon, @@ -2015,8 +2030,13 @@ static const struct spi_nor_manufacturer *manufacturers[] = { &spi_nor_xmc, }; +static const struct spi_nor_fixups spi_nor_generic_fixups = { + .post_sfdp = spi_nor_generic_post_sfdp_fixup, +}; + static const struct flash_info spi_nor_generic_flash = { .name = "spi-nor-generic", + .fixups = &spi_nor_generic_fixups, }; static const struct flash_info *spi_nor_match_id(struct spi_nor *nor, From patchwork Wed Nov 8 17:11:48 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Biju Das X-Patchwork-Id: 13450330 X-Patchwork-Delegate: geert@linux-m68k.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 07935C4167B for ; Wed, 8 Nov 2023 17:12:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232099AbjKHRML (ORCPT ); Wed, 8 Nov 2023 12:12:11 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53924 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232483AbjKHRMJ (ORCPT ); Wed, 8 Nov 2023 12:12:09 -0500 Received: from relmlie5.idc.renesas.com (relmlor1.renesas.com [210.160.252.171]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 5E0B61BFF for ; Wed, 8 Nov 2023 09:12:07 -0800 (PST) X-IronPort-AV: E=Sophos;i="6.03,286,1694703600"; d="scan'208";a="182203724" Received: from unknown (HELO relmlir6.idc.renesas.com) ([10.200.68.152]) by relmlie5.idc.renesas.com with ESMTP; 09 Nov 2023 02:12:07 +0900 Received: from localhost.localdomain (unknown [10.226.92.247]) by relmlir6.idc.renesas.com (Postfix) with ESMTP id 5EACB402E68C; Thu, 9 Nov 2023 02:12:04 +0900 (JST) From: Biju Das To: Krzysztof Kozlowski Cc: Biju Das , Geert Uytterhoeven , Prabhakar Mahadev Lad , Mark Brown , Miquel Raynal , Michael Walle , Biju Das , linux-renesas-soc@vger.kernel.org Subject: [PATCH RFC 3/4] memory: renesas-rpc-if: Add support for overriding IO fixed values Date: Wed, 8 Nov 2023 17:11:48 +0000 Message-Id: <20231108171149.258656-4-biju.das.jz@bp.renesas.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20231108171149.258656-1-biju.das.jz@bp.renesas.com> References: <20231108171149.258656-1-biju.das.jz@bp.renesas.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-renesas-soc@vger.kernel.org Add support for overriding IO fixed values to control the pin state based on the flash type. Signed-off-by: Biju Das --- drivers/memory/renesas-rpc-if.c | 20 ++++++++++++++++++++ include/memory/renesas-rpc-if.h | 1 + 2 files changed, 21 insertions(+) diff --git a/drivers/memory/renesas-rpc-if.c b/drivers/memory/renesas-rpc-if.c index 9695b2d3ae59..17bc604cdfff 100644 --- a/drivers/memory/renesas-rpc-if.c +++ b/drivers/memory/renesas-rpc-if.c @@ -325,6 +325,26 @@ static void rpcif_rzg2l_timing_adjust_sdr(struct rpcif_priv *rpc) regmap_write(rpc->regmap, RPCIF_PHYADD, 0x80000032); } +int rpcif_set_iofv(struct device *dev, u32 val) +{ + struct rpcif_priv *rpc = dev_get_drvdata(dev); + int ret; + + ret = pm_runtime_resume_and_get(dev); + if (ret) + return ret; + + regmap_update_bits(rpc->regmap, RPCIF_CMNCR, RPCIF_CMNCR_IOFV(3), + RPCIF_CMNCR_IO0FV(val & 0x3) | + RPCIF_CMNCR_IO2FV((val >> 4) & 0x3) | + RPCIF_CMNCR_IO3FV((val >> 6) & 0x3)); + + pm_runtime_put(dev); + + return 0; +} +EXPORT_SYMBOL(rpcif_set_iofv); + int rpcif_hw_init(struct device *dev, bool hyperflash) { struct rpcif_priv *rpc = dev_get_drvdata(dev); diff --git a/include/memory/renesas-rpc-if.h b/include/memory/renesas-rpc-if.h index b8fa30fd6b50..124ca9c16a39 100644 --- a/include/memory/renesas-rpc-if.h +++ b/include/memory/renesas-rpc-if.h @@ -71,6 +71,7 @@ struct rpcif { int rpcif_sw_init(struct rpcif *rpc, struct device *dev); int rpcif_hw_init(struct device *dev, bool hyperflash); +int rpcif_set_iofv(struct device *dev, u32 val); void rpcif_prepare(struct device *dev, const struct rpcif_op *op, u64 *offs, size_t *len); int rpcif_manual_xfer(struct device *dev); From patchwork Wed Nov 8 17:11:49 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Biju Das X-Patchwork-Id: 13450331 X-Patchwork-Delegate: geert@linux-m68k.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4F9E2C4167D for ; Wed, 8 Nov 2023 17:12:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232559AbjKHRMS (ORCPT ); Wed, 8 Nov 2023 12:12:18 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53222 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232602AbjKHRMQ (ORCPT ); Wed, 8 Nov 2023 12:12:16 -0500 Received: from relmlie6.idc.renesas.com (relmlor2.renesas.com [210.160.252.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 09CD3E8; Wed, 8 Nov 2023 09:12:10 -0800 (PST) X-IronPort-AV: E=Sophos;i="6.03,286,1694703600"; d="scan'208";a="186043560" Received: from unknown (HELO relmlir6.idc.renesas.com) ([10.200.68.152]) by relmlie6.idc.renesas.com with ESMTP; 09 Nov 2023 02:12:10 +0900 Received: from localhost.localdomain (unknown [10.226.92.247]) by relmlir6.idc.renesas.com (Postfix) with ESMTP id BD82A402E669; Thu, 9 Nov 2023 02:12:07 +0900 (JST) From: Biju Das To: Mark Brown Cc: Biju Das , linux-spi@vger.kernel.org, Miquel Raynal , Michael Walle , Krzysztof Kozlowski , Geert Uytterhoeven , Prabhakar Mahadev Lad , Biju Das , linux-renesas-soc@vger.kernel.org Subject: [PATCH RFC 4/4] spi: rpc-if: Add set_iofv() callback Date: Wed, 8 Nov 2023 17:11:49 +0000 Message-Id: <20231108171149.258656-5-biju.das.jz@bp.renesas.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20231108171149.258656-1-biju.das.jz@bp.renesas.com> References: <20231108171149.258656-1-biju.das.jz@bp.renesas.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-renesas-soc@vger.kernel.org Add set_iofv() callback for configuring IO fixed values to control the pin state. Signed-off-by: Biju Das --- drivers/spi/spi-rpc-if.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/drivers/spi/spi-rpc-if.c b/drivers/spi/spi-rpc-if.c index e11146932828..8b5c41de99af 100644 --- a/drivers/spi/spi-rpc-if.c +++ b/drivers/spi/spi-rpc-if.c @@ -75,6 +75,14 @@ static bool rpcif_spi_mem_supports_op(struct spi_mem *mem, return true; } +static int rpcif_spi_mem_set_iofv(struct spi_mem *mem, const u32 val) +{ + struct rpcif *rpc = + spi_controller_get_devdata(mem->spi->controller); + + return rpcif_set_iofv(rpc->dev, val); +} + static ssize_t rpcif_spi_mem_dirmap_read(struct spi_mem_dirmap_desc *desc, u64 offs, size_t len, void *buf) { @@ -121,6 +129,7 @@ static int rpcif_spi_mem_exec_op(struct spi_mem *mem, } static const struct spi_controller_mem_ops rpcif_spi_mem_ops = { + .set_iofv = rpcif_spi_mem_set_iofv, .supports_op = rpcif_spi_mem_supports_op, .exec_op = rpcif_spi_mem_exec_op, .dirmap_create = rpcif_spi_mem_dirmap_create,