From patchwork Mon Mar 6 17:21:09 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Mahapatra, Amit Kumar" X-Patchwork-Id: 659277 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 alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 43B63C6FD19 for ; Mon, 6 Mar 2023 17:53:57 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 29CD41173; Mon, 6 Mar 2023 18:53:05 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 29CD41173 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1678125235; bh=KxpEDeTf9E17Ydj8/5wdVALLUfACV4v70g86LYsEQ38=; h=From:To:Subject:Date:In-Reply-To:References:CC:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=nFy98GCtq1vbJk0MmZrK0hx29gcFlhIHudDr2Dhl9S7NGnU6Oy2R2QEb1hcfA5ylM ycQcujh4FAT2Ha4SH1woXekqHExLbldgxrVzogIjwdMQ3I1dPTD56RYmMAKsp9LDGH HtE6KGzdDzAtT+JnsHEnCjNkqt+T4KXgFeqha0ok= Received: from mailman-core.alsa-project.org (mailman-core.alsa-project.org [10.254.200.10]) by alsa1.perex.cz (Postfix) with ESMTP id B83B6F80687; Mon, 6 Mar 2023 18:43:26 +0100 (CET) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 7FEE1F8042F; Mon, 6 Mar 2023 18:29:50 +0100 (CET) Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on20628.outbound.protection.outlook.com [IPv6:2a01:111:f400:fe5a::628]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 386C4F800C9 for ; Mon, 6 Mar 2023 18:29:45 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 386C4F800C9 Authentication-Results: alsa1.perex.cz; dkim=pass (1024-bit key, unprotected) header.d=amd.com header.i=@amd.com header.a=rsa-sha256 header.s=selector1 header.b=m40pqWBe ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=MQbl4zoj1kcPriEAKRrLdlNcHjMXgyhIil+/bNAOclk+SIA2yPqHZmZBGIGDgajLFVKf3Vs6GxIGg6MyYP6WwhlQge146ucEzvN8qiDmcim1Q2WOe2vSuKhldMR0wNnmoom9BDzEOlLMr8ifx2EgDuwV/vcrn3DbH4szTDkaWD5Z2rea2v6Cc0fhW+3cuA0hv3n/V76GYClgO3lRK0eiDlE9We0vjGXuHBqzE2AJm+BXcxTr6PYWlDJCdXUxITNuY6Tu+QS04beARN0lBkZip5ojWffMyXBWBaT93AAMB4oaqVViVkLM0uh31ElrRDg1a7Wiwjko34tsIKYAt/fSrA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=2pEjyARU/iDHF4qEL808MswcLI+5ZEPTvCc976Kw1g4=; b=YUtwnU1CjkFz45a0ldiWrzaVKLyTcT1rZSzuBlhhEQbFr/zNVL3N8TcGgQqFyhJMKbJfMCTfK6qCwdxH4/3goEV137WOHhOIHb5uqHOM24ddBSHnKP7shaLMQqV2MHnYQB3NX0XWD9UOkx10Ln/h4rCwiswtU9opF4QRudgWDPhIv5dJi+XMuyMYCiCEw8d2iG4B9r5qmgxr2K1F4J2bovaGsKqdFVUT5dqYR/AABqMRsdxn+JzGK0BDYH/1xRhjDd7azs3ooOne0gdEjOfdlhWOcEqrkEhpzxdafpSqW3jBVu1fImjK4bj6q+OeURajZz3NWp0TPhgTGHQf+1xlWg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=kernel.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=2pEjyARU/iDHF4qEL808MswcLI+5ZEPTvCc976Kw1g4=; b=m40pqWBebs4l0rN1O3v5vWW+xl8drhkuYDRot59GYbmX5C81OPbhBSwVJdBonrB4WsG5T1m4j6hy9aqWL+KSDWiMP6Dl2jTkEX0RyKekUmE5hxkolBuQqlCnhb0dYvHA4WsJo1DpnYnn8wM3OIl+aLDzlYCshsc61Uu9cAiods8= Received: from BN7PR06CA0048.namprd06.prod.outlook.com (2603:10b6:408:34::25) by CY8PR12MB8299.namprd12.prod.outlook.com (2603:10b6:930:6c::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6156.28; Mon, 6 Mar 2023 17:29:40 +0000 Received: from BN8NAM11FT063.eop-nam11.prod.protection.outlook.com (2603:10b6:408:34:cafe::b6) by BN7PR06CA0048.outlook.office365.com (2603:10b6:408:34::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6156.28 via Frontend Transport; Mon, 6 Mar 2023 17:29:40 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB03.amd.com; pr=C Received: from SATLEXMB03.amd.com (165.204.84.17) by BN8NAM11FT063.mail.protection.outlook.com (10.13.177.110) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6178.15 via Frontend Transport; Mon, 6 Mar 2023 17:29:40 +0000 Received: from SATLEXMB06.amd.com (10.181.40.147) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.34; Mon, 6 Mar 2023 11:29:39 -0600 Received: from SATLEXMB04.amd.com (10.181.40.145) by SATLEXMB06.amd.com (10.181.40.147) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.34; Mon, 6 Mar 2023 11:29:39 -0600 Received: from xhdsneeli40.xilinx.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server id 15.1.2375.34 via Frontend Transport; Mon, 6 Mar 2023 11:29:12 -0600 From: Amit Kumar Mahapatra To: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH V5 15/15] spi: spi-zynqmp-gqspi: Add parallel memories support in GQSPI driver Date: Mon, 6 Mar 2023 22:51:09 +0530 Message-ID: <20230306172109.595464-16-amit.kumar-mahapatra@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230306172109.595464-1-amit.kumar-mahapatra@amd.com> References: <20230306172109.595464-1-amit.kumar-mahapatra@amd.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN8NAM11FT063:EE_|CY8PR12MB8299:EE_ X-MS-Office365-Filtering-Correlation-Id: 3affa16c-80ce-4c67-a23b-08db1e685e05 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: LgLhUNXgl6Yy+nBga6v7THj/EQbJve9kHETbxJj2RP9lIl6OMXq2gnVea0m7qaksalEfXA2Q+2UrsV4Rwzr+YdrUF/iwyn5CfMdIY6SXcLI55rJ5er08hLMpDSLDPa3ggzgxQY/ftohClc7P69ed0ntwnG6aUiP30G2m0e/Y17mZV+f20HWwvvtcfsEvPTOiPIiwWhbnh9OgDE0OEYDbCj1HKbeUVupP7WANl+Dt66kNmgodsJ41H16vBPvswsVFdIoO0gXCwYa0Ucpd2RPc0j5tC7Cskv8+zsaS8+IWdGQuSRATr3F08PGjFHW3h3Yrwa07Pconvr85fXTE3Ogkk5SbnOEXxO7fywAV3TONYQhem610wQtXNTNxwdO2Ils01oiYvZ/jrKJ3PyWiQvIktUmJQjsT5A1MP6d1KegS2tBpuelflMyGzHLqr1Nwj7EQBhodcGwGKowvYkIGeCoHYnGO/HzyKi3ogvbri2gvcQRlj3QmPfUY/uz+jUsug/MHSVVpTJXJzJVqj/jAVli+0S3RSiPnCprqmT3QpQ8fz15HEoPoH9JXPXXjlA/QjIw2i/PDDrQ6crfckUN7BwsFFvxw9oSrGW4Px9U0/ZeSD1NyxwjxLHnCI2d+UKDXqmyV0ZBY8UStmq1+SSC66lbW08ceAfLYnCSh7LMbutHLi9J3+JmA9B1pGNK8mcQAXoY9CVa7sgYHw1xtPTKtImM4xmxfHomSQKGGMkwPO7JZYf7wpXvsKSv8jyKexWspO5yHuM3UyVpZOHylhXAj+f0voFS+s1gefXjqpYtIOPJnGCRUdkIZozoBW1Gs2VrVvmyGAC3ZGQ0Eze5PoXcOZ/ZwNh34eZYejbFDR7SmyAAuF3U= X-Forefront-Antispam-Report: CIP:165.204.84.17; CTRY:US; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:SATLEXMB03.amd.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230025)(4636009)(136003)(376002)(346002)(39860400002)(396003)(451199018)(40470700004)(46966006)(36840700001)(40460700003)(186003)(6666004)(81166007)(356005)(921005)(8936002)(36860700001)(41300700001)(8676002)(2906002)(82740400003)(5660300002)(70206006)(70586007)(4326008)(7366002)(7276002)(7416002)(7406005)(7336002)(426003)(478600001)(2616005)(1076003)(47076005)(26005)(36756003)(316002)(110136005)(54906003)(40480700001)(82310400005)(86362001)(1191002)(83380400001)(336012)(41080700001)(2101003)(36900700001)(84006005)(83996005); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Mar 2023 17:29:40.4510 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 3affa16c-80ce-4c67-a23b-08db1e685e05 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d; Ip=[165.204.84.17]; Helo=[SATLEXMB03.amd.com] X-MS-Exchange-CrossTenant-AuthSource: BN8NAM11FT063.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY8PR12MB8299 X-MailFrom: amit.kumar-mahapatra@amd.com X-Mailman-Rule-Hits: nonmember-moderation X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-alsa-devel.alsa-project.org-0; header-match-alsa-devel.alsa-project.org-1 Message-ID-Hash: 34G7BAAIMJFEQSKKJZU3WEYOCHZLT3XV X-Message-ID-Hash: 34G7BAAIMJFEQSKKJZU3WEYOCHZLT3XV X-Mailman-Approved-At: Mon, 06 Mar 2023 17:43:04 +0000 CC: git@amd.com, linux-spi@vger.kernel.org, linux-kernel@vger.kernel.org, joel@jms.id.au, andrew@aj.id.au, radu_nicolae.pirea@upb.ro, nicolas.ferre@microchip.com, alexandre.belloni@bootlin.com, claudiu.beznea@microchip.com, bcm-kernel-feedback-list@broadcom.com, fancer.lancer@gmail.com, kernel@pengutronix.de, festevam@gmail.com, linux-imx@nxp.com, jbrunet@baylibre.com, martin.blumenstingl@googlemail.com, avifishman70@gmail.com, tmaimon77@gmail.com, tali.perry1@gmail.com, venture@google.com, yuenn@google.com, benjaminfair@google.com, yogeshgaur.83@gmail.com, konrad.dybcio@somainline.org, alim.akhtar@samsung.com, ldewangan@nvidia.com, thierry.reding@gmail.com, jonathanh@nvidia.com, michal.simek@amd.com, linux-aspeed@lists.ozlabs.org, openbmc@lists.ozlabs.org, linux-arm-kernel@lists.infradead.org, linux-rpi-kernel@lists.infradead.org, linux-amlogic@lists.infradead.org, linux-mediatek@lists.infradead.org, linux-arm-msm@vger.kernel.org, linux-rockchip@lists.infradead.org, linux-samsung-soc@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, linux-sunxi@lists.linux.dev, linux-tegra@vger.kernel.org, netdev@vger.kernel.org, linux-wpan@vger.kernel.org, libertas-dev@lists.infradead.org, linux-wireless@vger.kernel.org, linux-mtd@lists.infradead.org, lars@metafoo.de, Michael.Hennerich@analog.com, linux-iio@vger.kernel.org, michael@walle.cc, palmer@dabbelt.com, linux-riscv@lists.infradead.org, alsa-devel@alsa-project.org, patches@opensource.cirrus.com, linuxppc-dev@lists.ozlabs.org, amitrkcian2002@gmail.com, amit.kumar-mahapatra@amd.com X-Mailman-Version: 3.3.8 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: During GQSPI driver probe set ctlr->multi-cs-cap for enabling multi CS capability of the controller. In parallel mode the controller can either split the data between both the flash or can send the same data to both the flashes, this is determined by the STRIPE bit. While sending commands to the flashes the GQSPI driver send the same command to both the flashes by resetting the STRIPE bit, but while writing/reading data to & from the flash the GQSPI driver splits the data evenly between both the flashes by setting the STRIPE bit. Signed-off-by: Amit Kumar Mahapatra --- drivers/spi/spi-zynqmp-gqspi.c | 39 +++++++++++++++++++++++++++++++++- 1 file changed, 38 insertions(+), 1 deletion(-) diff --git a/drivers/spi/spi-zynqmp-gqspi.c b/drivers/spi/spi-zynqmp-gqspi.c index 4759f704bf5c..9e44371bfda2 100644 --- a/drivers/spi/spi-zynqmp-gqspi.c +++ b/drivers/spi/spi-zynqmp-gqspi.c @@ -23,6 +23,7 @@ #include #include #include +#include /* Generic QSPI register offsets */ #define GQSPI_CONFIG_OFST 0x00000100 @@ -192,6 +193,7 @@ struct qspi_platform_data { * @op_lock: Operational lock * @speed_hz: Current SPI bus clock speed in hz * @has_tapdelay: Used for tapdelay register available in qspi + * @is_parallel: Used for multi CS support */ struct zynqmp_qspi { struct spi_controller *ctlr; @@ -214,8 +216,33 @@ struct zynqmp_qspi { struct mutex op_lock; u32 speed_hz; bool has_tapdelay; + bool is_parallel; }; +/** + * zynqmp_gqspi_update_stripe - For GQSPI controller data stripe capabilities + * @op: Pointer to mem ops + * Return: Status of the data stripe + * + * Returns true if data stripe need to be enabled, else returns false + */ +bool zynqmp_gqspi_update_stripe(const struct spi_mem_op *op) +{ + if (op->cmd.opcode == SPINOR_OP_BE_4K || + op->cmd.opcode == SPINOR_OP_BE_32K || + op->cmd.opcode == SPINOR_OP_CHIP_ERASE || + op->cmd.opcode == SPINOR_OP_SE || + op->cmd.opcode == SPINOR_OP_BE_32K_4B || + op->cmd.opcode == SPINOR_OP_SE_4B || + op->cmd.opcode == SPINOR_OP_BE_4K_4B || + op->cmd.opcode == SPINOR_OP_WRSR || + op->cmd.opcode == SPINOR_OP_BRWR || + (op->cmd.opcode == SPINOR_OP_WRSR2 && !op->addr.nbytes)) + return false; + + return true; +} + /** * zynqmp_gqspi_read - For GQSPI controller read operation * @xqspi: Pointer to the zynqmp_qspi structure @@ -470,7 +497,14 @@ static void zynqmp_qspi_chipselect(struct spi_device *qspi, bool is_high) genfifoentry |= GQSPI_GENFIFO_MODE_SPI; - if (qspi->cs_index_mask & GQSPI_SELECT_UPPER_CS) { + if ((qspi->cs_index_mask & GQSPI_SELECT_LOWER_CS) && + (qspi->cs_index_mask & GQSPI_SELECT_UPPER_CS)) { + zynqmp_gqspi_selectslave(xqspi, + GQSPI_SELECT_FLASH_CS_BOTH, + GQSPI_SELECT_FLASH_BUS_BOTH); + if (!xqspi->is_parallel) + xqspi->is_parallel = true; + } else if (qspi->cs_index_mask & GQSPI_SELECT_UPPER_CS) { zynqmp_gqspi_selectslave(xqspi, GQSPI_SELECT_FLASH_CS_UPPER, GQSPI_SELECT_FLASH_BUS_LOWER); @@ -1139,6 +1173,8 @@ static int zynqmp_qspi_exec_op(struct spi_mem *mem, } if (op->data.nbytes) { + if (xqspi->is_parallel && zynqmp_gqspi_update_stripe(op)) + genfifoentry |= GQSPI_GENFIFO_STRIPE; reinit_completion(&xqspi->data_completion); if (op->data.dir == SPI_MEM_DATA_OUT) { xqspi->txbuf = (u8 *)op->data.buf.out; @@ -1334,6 +1370,7 @@ static int zynqmp_qspi_probe(struct platform_device *pdev) ctlr->bits_per_word_mask = SPI_BPW_MASK(8); ctlr->dev.of_node = np; ctlr->auto_runtime_pm = true; + ctlr->multi_cs_cap = true; ret = devm_spi_register_controller(&pdev->dev, ctlr); if (ret) {