From patchwork Tue Dec 27 10:04:50 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ivan Bornyakov X-Patchwork-Id: 36807 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp1319432wrt; Tue, 27 Dec 2022 02:16:46 -0800 (PST) X-Google-Smtp-Source: AMrXdXv+ekvmECVhrbo4Vn6gGGiNh14w0IeuD22G40qREBYZXD19k/1Pu2TO9yiSykc5IyHru/TC X-Received: by 2002:a17:906:fb97:b0:7c1:64dc:ac3c with SMTP id lr23-20020a170906fb9700b007c164dcac3cmr17965265ejb.59.1672136206090; Tue, 27 Dec 2022 02:16:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672136206; cv=none; d=google.com; s=arc-20160816; b=QJEalpbAUiIPPH8LuM6Mgd4exF4hnOQpRVNyJAUstcAz3FhHFVk1r73/hw9dJ2Rr7O uqotRFhI3eTHQnJckPmL9Le3DQWimESCR+rj8V74M1HSketboDCc6Q/i5nDJufivUuYE f51BozGUkrlJICpel73hsOXI4byYX7zHNuoVeDPSq4g4eg8lJitS1Y+vgLlBVbi2OS0i huEdL97dWje/k+E4beXjHBods6368mCbRZGW92IouvDrbv/3CKZWFnohOV8bBTCFYCPb XUhCI6dy0gMwCdSD7JOzCWp6ZwerW9TrSBa++dhtFoAI+SKFRS6r8UvS95/PjRm1epoh mtuQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=XM79o3xc3aqIzLs/kC03gR/ABs+LGuj/R3x8/QEqYuE=; b=TI7SZV4PsaX+x+Jv2A1xSBmP5cS9NsKBO0cVjCKfYwYX34HNwqb6Tn+5XXMZvYTRVL 6kKIQt7yjHMTUJTXa+oG1GbJvAXTkzFTKuqYFuJCQH2idFXcK5Gw72THgcNA57+NcRNl ktreheJSE4VXVqEV4IouRPmPAzbCtOJ5cJ3eM3wzg0h7DuYe9S3ewRrj7L7L0Zx/zUJM BhMQHg5aPCBoWMQkumunklZDSl5iURE+ZcuWzeBYX+O3ZV1p0G5f2co2U80bwUV8qBDW O93RkHBdPwb3N8ZTAUWR+2JU46usWYzph57IdAqDU+2UnBDNgtffvZqLSHjkrQi0UZTJ UBBg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@metrotek.ru header.s=mail header.b=NRKaVERj; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id oz8-20020a1709077d8800b007c0c9bd6206si11394921ejc.553.2022.12.27.02.16.20; Tue, 27 Dec 2022 02:16:46 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=fail header.i=@metrotek.ru header.s=mail header.b=NRKaVERj; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231373AbiL0KHk (ORCPT + 99 others); Tue, 27 Dec 2022 05:07:40 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37086 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230201AbiL0KHa (ORCPT ); Tue, 27 Dec 2022 05:07:30 -0500 Received: from mail.pr-group.ru (mail.pr-group.ru [178.18.215.3]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 755D964C3; Tue, 27 Dec 2022 02:07:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=metrotek.ru; s=mail; h=from:subject:date:message-id:to:cc:mime-version:content-transfer-encoding: in-reply-to:references; bh=PYDm95PWaADa9YxjFLIe4Cqpn1ITTd0IS1l03smDoZI=; b=NRKaVERjP8DPCHUa1B+i6P3ve/o20Ki43luqRob99yEHHPV3BdvQx8tteWZBssTlc19fpTU5j+6YM +HdiekDTphI0msuVJKGfQvw88BKqaoOXVWfN5jBn87HMA/T0BtmWEd9LZhylJhyY+fSbdmchmvc9kS VhelAq6A6RAWzFzd4hFUlgZVrX9Esw+s8kLBIPBb+4B+1hnQGY5OOtnDEcde+UO0IgLQ3IYgFuB7yv z9xowIiEbnf+5K2WCAsSjxJ8EKC+SQyLLcTnFwYk8YTeeQlUXTM73efdd38kxASJ4+wt+TyjtkBZKK b9/jxjbE3RK26+4+8pFhVqHDGWPccHw== X-Kerio-Anti-Spam: Build: [Engines: 2.16.5.1460, Stamp: 3], Multi: [Enabled, t: (0.000009,0.012572)], BW: [Enabled, t: (0.000022,0.000001)], RTDA: [Enabled, t: (0.089347), Hit: No, Details: v2.42.0; Id: 15.52ka2i.1gl9gprcr.3ma; mclb], total: 0(700) X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Level: X-Footer: bWV0cm90ZWsucnU= Received: from localhost.localdomain ([78.37.162.181]) (authenticated user i.bornyakov@metrotek.ru) by mail.pr-group.ru with ESMTPSA (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256 bits)); Tue, 27 Dec 2022 13:07:11 +0300 From: Ivan Bornyakov To: Conor Dooley , Moritz Fischer , Wu Hao , Xu Yilun , Tom Rix , =?utf-8?q?Ilpo_J?= =?utf-8?q?=C3=A4rvinen?= Cc: Ivan Bornyakov , linux-fpga@vger.kernel.org, linux-kernel@vger.kernel.org, system@metrotek.ru Subject: [PATCH v3 3/3] fpga: microchip-spi: separate data frame write routine Date: Tue, 27 Dec 2022 13:04:50 +0300 Message-Id: <20221227100450.2257-4-i.bornyakov@metrotek.ru> X-Mailer: git-send-email 2.38.2 In-Reply-To: <20221227100450.2257-1-i.bornyakov@metrotek.ru> References: <20221227100450.2257-1-i.bornyakov@metrotek.ru> MIME-Version: 1.0 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1753361894454097827?= X-GMAIL-MSGID: =?utf-8?q?1753361894454097827?= mpf_ops_write() function writes bitstream data to the FPGA by a smaller frames. Introduce mpf_spi_frame_write() function which is for writing a single data frame and use it in mpf_ops_write(). No functional changes intended. Signed-off-by: Ivan Bornyakov Acked-by: Conor Dooley --- drivers/fpga/microchip-spi.c | 36 +++++++++++++++++++++++------------- 1 file changed, 23 insertions(+), 13 deletions(-) diff --git a/drivers/fpga/microchip-spi.c b/drivers/fpga/microchip-spi.c index 8d1d9476d0cc..ea92e5d106fa 100644 --- a/drivers/fpga/microchip-spi.c +++ b/drivers/fpga/microchip-spi.c @@ -274,9 +274,30 @@ static int mpf_ops_write_init(struct fpga_manager *mgr, return 0; } +static int mpf_spi_frame_write(struct mpf_priv *priv, const char *buf) +{ + struct spi_transfer xfers[2] = { + { + .tx_buf = &priv->tx, + .len = 1, + }, { + .tx_buf = buf, + .len = MPF_SPI_FRAME_SIZE, + }, + }; + int ret; + + ret = mpf_poll_status(priv, 0); + if (ret < 0) + return ret; + + priv->tx = MPF_SPI_FRAME; + + return spi_sync_transfer(priv->spi, xfers, ARRAY_SIZE(xfers)); +} + static int mpf_ops_write(struct fpga_manager *mgr, const char *buf, size_t count) { - struct spi_transfer xfers[2] = { 0 }; struct mpf_priv *priv = mgr->priv; struct device *dev = &mgr->dev; int ret, i; @@ -287,19 +308,8 @@ static int mpf_ops_write(struct fpga_manager *mgr, const char *buf, size_t count return -EINVAL; } - xfers[0].tx_buf = &priv->tx; - xfers[0].len = 1; - for (i = 0; i < count / MPF_SPI_FRAME_SIZE; i++) { - xfers[1].tx_buf = buf + i * MPF_SPI_FRAME_SIZE; - xfers[1].len = MPF_SPI_FRAME_SIZE; - - ret = mpf_poll_status(priv, 0); - if (ret >= 0) { - priv->tx = MPF_SPI_FRAME; - ret = spi_sync_transfer(priv->spi, xfers, ARRAY_SIZE(xfers)); - } - + ret = mpf_spi_frame_write(priv, buf + i * MPF_SPI_FRAME_SIZE); if (ret) { dev_err(dev, "Failed to write bitstream frame %d/%zu\n", i, count / MPF_SPI_FRAME_SIZE);