Received: by 2002:ab2:620c:0:b0:1ef:ffd0:ce49 with SMTP id o12csp852862lqt; Tue, 19 Mar 2024 06:06:02 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWAA4pogn8BL44kfzD5RM7v5EfkGmWt5NqmnMW1wOwxUvIV5pmuNbaE0htMW97GjXumTp8Z1J3/HMXKyreAhQ21IrVdFPYCwsrgEhcm3Q== X-Google-Smtp-Source: AGHT+IFnqxe35YYK1cVw/hk/wEHkQPeHOhjpi2cplyPpNPFzaioENckY4pQM2907VlxPpl3UHhOv X-Received: by 2002:a17:906:dfc4:b0:a46:dedc:163c with SMTP id jt4-20020a170906dfc400b00a46dedc163cmr1365262ejc.2.1710853562144; Tue, 19 Mar 2024 06:06:02 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1710853562; cv=pass; d=google.com; s=arc-20160816; b=UosawcYDF7rCfIxe+QNKb9uMYWUkqHPpfZ2PwimHHDfiAVrQbK1wB0w7xKIs+BiUbe WfwDs1JlVLjP5zT3cFlfqRCRZ4K9vRt42WcQ9ZZvFKYGscydrEeWt1JSJx8ppRcXzQQ3 Tde7ilYDu+LXQwSHRHwhnxGmsWPqdioXf853BnFaM2vEmZXZl+0uISnijJcz5+D0Jce9 M1W0hL/6bOZ42his6Av9IEtHuOk6mtAk7fN2IvNSbpTnq4n6seOeaJfh45Iy0Doa5l5E 9wwBVVsfVh7didNmJHmdF6Pu3SkRneNn2o7zTwaIcj5plD7HgYZzMNEUunRwHE6LYhqP 9VEg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=thread-index:thread-topic:content-transfer-encoding:mime-version :list-unsubscribe:list-subscribe:list-id:precedence:subject :references:in-reply-to:message-id:cc:to:from:date:dkim-signature :dkim-filter; bh=CK99kLcw9PEfo9MbsDde8HxpTFYuUaCC9hKhjNwcG5Q=; fh=ajjsI6Ry/Hb9vRhu7s1SiVpq9wr7cFn3DcIM4rRNlUI=; b=yIrR1VzqPSkMvk3Z9zFGtTP/cUd5BL97Uv30jGbmjdzAjdyulmWdFoNnZhvyL4qDPP Fve9+cACtYaBt9q/eF6YXOGIrJSgW5w1nrVRrAUTJqNEEtTuCUmxgREhH2tsk2EC2VkN vURRJaeXC6ktBXRwXBZDI+Y8AqYzAPD1wX08tXX2gL9ttAaDrBhrmNHI42loae0XF75D vOnMF9vb0ucbNJcIFSK85f8YXNYt0kMR2BcnfEnE5yUHqJoPQUGoL5QauVNbzFqXL5cr mFJu53NVszyKuLIISxboHBwaTH4Eq0awoKY3VYR18aSZbU8MZRpMGTzJ5odEZWn0kGPt 1anA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@savoirfairelinux.com header.s=DFC430D2-D198-11EC-948E-34200CB392D2 header.b=AHyUN+tF; arc=pass (i=1 spf=pass spfdomain=savoirfairelinux.com dkim=pass dkdomain=savoirfairelinux.com); spf=pass (google.com: domain of linux-kernel+bounces-107554-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-107554-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id qb41-20020a1709077ea900b00a46a1fbc0f8si3569185ejc.401.2024.03.19.06.06.02 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Mar 2024 06:06:02 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-107554-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@savoirfairelinux.com header.s=DFC430D2-D198-11EC-948E-34200CB392D2 header.b=AHyUN+tF; arc=pass (i=1 spf=pass spfdomain=savoirfairelinux.com dkim=pass dkdomain=savoirfairelinux.com); spf=pass (google.com: domain of linux-kernel+bounces-107554-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-107554-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id ACC571F22983 for ; Tue, 19 Mar 2024 13:06:01 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 4F9BE4085D; Tue, 19 Mar 2024 13:05:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=savoirfairelinux.com header.i=@savoirfairelinux.com header.b="AHyUN+tF" Received: from mail.savoirfairelinux.com (mail.savoirfairelinux.com [208.88.110.44]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7F4397E767; Tue, 19 Mar 2024 13:05:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=208.88.110.44 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710853543; cv=none; b=TJz+LVrTnWio17FWbRLIzNNOp0TfCpQndXrBclsdPkpLJ7MG3dJCyxzeBTBe2eeE+kYeAz0KzgHoOn4cuIG/1zA0v+B9MqlMF2bYuYhdY/JyGiMTRHhE5SXtjFV9Yrpj9zDJOH6gfZr8OaDGyyqtO/3M5fS6eDcYApM38Ujq0S8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710853543; c=relaxed/simple; bh=/97r7iXSsDNTYmULHXVK1ctFTQ73QJVdp8X5PO/FNT8=; h=Date:From:To:Cc:Message-ID:In-Reply-To:References:Subject: MIME-Version:Content-Type; b=cCV+ktnNSqrqe5agH/BQY8QcS5sTKZS3Qt3LNTE+8XVjk4Ctr46G9S8RnEsReZtZheR9B1qLQLF71DLv8KJDddcJ1HsNEt9rigq23gCkTW9hpHYkzq0wbVWytGZLggwI9MTvTakpBK8QFtrC2/P7UEde41atiEZn1AN9HHfgJi4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=savoirfairelinux.com; spf=pass smtp.mailfrom=savoirfairelinux.com; dkim=pass (2048-bit key) header.d=savoirfairelinux.com header.i=@savoirfairelinux.com header.b=AHyUN+tF; arc=none smtp.client-ip=208.88.110.44 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=savoirfairelinux.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=savoirfairelinux.com Received: from localhost (localhost [127.0.0.1]) by mail.savoirfairelinux.com (Postfix) with ESMTP id 1C1689C4ACB; Tue, 19 Mar 2024 09:05:32 -0400 (EDT) Received: from mail.savoirfairelinux.com ([127.0.0.1]) by localhost (mail.savoirfairelinux.com [127.0.0.1]) (amavis, port 10032) with ESMTP id GurWxxw7TEHa; Tue, 19 Mar 2024 09:05:30 -0400 (EDT) Received: from localhost (localhost [127.0.0.1]) by mail.savoirfairelinux.com (Postfix) with ESMTP id 2CBAF9C5396; Tue, 19 Mar 2024 09:05:30 -0400 (EDT) DKIM-Filter: OpenDKIM Filter v2.10.3 mail.savoirfairelinux.com 2CBAF9C5396 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=savoirfairelinux.com; s=DFC430D2-D198-11EC-948E-34200CB392D2; t=1710853530; bh=CK99kLcw9PEfo9MbsDde8HxpTFYuUaCC9hKhjNwcG5Q=; h=Date:From:To:Message-ID:MIME-Version; b=AHyUN+tFORXxM96kQQtuHIT4SdsL5VJ3hgTNhNAGF+wOQkEsjUzKX3YLNwPRFnIaz pB3cwMh1tThhGRJS9A/cu7pO6haCd5zIwSDus1DL7N8j9OWFhSW/L9fMBvtygkBjgV cCRptOrbrc1tU+purpQ64BgAvXF3nM8UnahqXl2icsYpgzFX44TcQ+ZofjxkG8J1hj 3zkyiHNEIo04N1gwcPSOiMJCbOkhpdTCTfacyJDLrqWyKPuuvU07V79VGsuRi/tr2p L7/cDD+KOUA+9YzZnrqI0m5CeN8ANbtpCU3Ad2MzXeYgtJyJWiNMTgH8S7KizDpGB9 wiRKJzETIgFgg== X-Virus-Scanned: amavis at mail.savoirfairelinux.com Received: from mail.savoirfairelinux.com ([127.0.0.1]) by localhost (mail.savoirfairelinux.com [127.0.0.1]) (amavis, port 10026) with ESMTP id YVFnzGiEUBxk; Tue, 19 Mar 2024 09:05:30 -0400 (EDT) Received: from mail.savoirfairelinux.com (mail.savoirfairelinux.com [192.168.48.237]) by mail.savoirfairelinux.com (Postfix) with ESMTP id DD3BA9C4ACB; Tue, 19 Mar 2024 09:05:29 -0400 (EDT) Date: Tue, 19 Mar 2024 09:05:29 -0400 (EDT) From: Charles Perry To: Xu Yilun Cc: mdf , Allen VANDIVER , Brian CODY , hao wu , yilun xu , Tom Rix , Rob Herring , krzysztof kozlowski+dt , Conor Dooley , Michal Simek , linux-fpga , devicetree , linux-kernel , linux-arm-kernel Message-ID: <1292581697.1872237.1710853529674.JavaMail.zimbra@savoirfairelinux.com> In-Reply-To: References: <20240313225746.489253-1-charles.perry@savoirfairelinux.com> <20240313225746.489253-4-charles.perry@savoirfairelinux.com> Subject: Re: [PATCH v5 3/3] fpga: xilinx-selectmap: add new driver Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Mailer: Zimbra 8.8.15_GA_4581 (ZimbraWebClient - FF120 (Linux)/8.8.15_GA_4581) Thread-Topic: fpga: xilinx-selectmap: add new driver Thread-Index: 0HF96KxB+j7D1rBnTxEW357y9Tr3RQ== On Mar 19, 2024, at 2:35 AM, Xu Yilun yilun.xu@linux.intel.com wrote: > On Wed, Mar 13, 2024 at 06:57:37PM -0400, Charles Perry wrote: >> Xilinx 7 series FPGA can be programmed using a parallel port named >> the SelectMAP interface in the datasheet. This interface is compatible >> with the i.MX6 EIM bus controller but other types of external memory >> mapped parallel bus might work. >> >> xilinx-selectmap currently only supports the x8 mode where data is loaded >> at one byte per rising edge of the clock, with the MSb of each byte >> presented to the D0 pin. >> >> Signed-off-by: Charles Perry >> --- >> Changes since v4: (from Yilun review) >> * xilinx-core: select between prog/init and prog_b/init-b >> >> drivers/fpga/Kconfig | 8 +++ >> drivers/fpga/Makefile | 1 + >> drivers/fpga/xilinx-core.c | 29 +++++++++- >> drivers/fpga/xilinx-selectmap.c | 97 +++++++++++++++++++++++++++++++++ >> 4 files changed, 133 insertions(+), 2 deletions(-) >> create mode 100644 drivers/fpga/xilinx-selectmap.c >> >> diff --git a/drivers/fpga/Kconfig b/drivers/fpga/Kconfig >> index d27a1ebf40838..37b35f58f0dfb 100644 >> --- a/drivers/fpga/Kconfig >> +++ b/drivers/fpga/Kconfig >> @@ -67,6 +67,14 @@ config FPGA_MGR_STRATIX10_SOC >> config FPGA_MGR_XILINX_CORE >> tristate >> >> +config FPGA_MGR_XILINX_SELECTMAP >> + tristate "Xilinx Configuration over SelectMAP" >> + depends on HAS_IOMEM >> + select FPGA_MGR_XILINX_CORE >> + help >> + FPGA manager driver support for Xilinx FPGA configuration >> + over SelectMAP interface. >> + >> config FPGA_MGR_XILINX_SPI >> tristate "Xilinx Configuration over Slave Serial (SPI)" >> depends on SPI >> diff --git a/drivers/fpga/Makefile b/drivers/fpga/Makefile >> index 7ec795b6a5a70..aeb89bb13517e 100644 >> --- a/drivers/fpga/Makefile >> +++ b/drivers/fpga/Makefile >> @@ -16,6 +16,7 @@ obj-$(CONFIG_FPGA_MGR_SOCFPGA_A10) += socfpga-a10.o >> obj-$(CONFIG_FPGA_MGR_STRATIX10_SOC) += stratix10-soc.o >> obj-$(CONFIG_FPGA_MGR_TS73XX) += ts73xx-fpga.o >> obj-$(CONFIG_FPGA_MGR_XILINX_CORE) += xilinx-core.o >> +obj-$(CONFIG_FPGA_MGR_XILINX_SELECTMAP) += xilinx-selectmap.o >> obj-$(CONFIG_FPGA_MGR_XILINX_SPI) += xilinx-spi.o >> obj-$(CONFIG_FPGA_MGR_ZYNQ_FPGA) += zynq-fpga.o >> obj-$(CONFIG_FPGA_MGR_ZYNQMP_FPGA) += zynqmp-fpga.o >> diff --git a/drivers/fpga/xilinx-core.c b/drivers/fpga/xilinx-core.c >> index a35c43382dd5f..ccdeb45eba4ee 100644 >> --- a/drivers/fpga/xilinx-core.c >> +++ b/drivers/fpga/xilinx-core.c >> @@ -171,6 +171,29 @@ static int xilinx_core_write_complete(struct fpga_manager >> *mgr, >> return -ETIMEDOUT; >> } >> >> +/** >> + * xilinx_core_devm_gpiod_get - Obtain a resource-managed GPIO using a >> + * legacy consumer name fallback. >> + * >> + * @dev: Device managing the GPIO >> + * @con_id: Consumer id >> + * @legacy_con_id: Legacy consumer id >> + * @flags: optional GPIO initialization flags >> + */ > > No need to have kernel doc comments for internal functions. > Ok, will remove. >> +static inline struct gpio_desc * >> +xilinx_core_devm_gpiod_get(struct device *dev, const char *con_id, >> + const char *legacy_con_id, enum gpiod_flags flags) >> +{ >> + struct gpio_desc *desc; >> + >> + desc = devm_gpiod_get(dev, con_id, flags); >> + if (IS_ERR(desc) && PTR_ERR(desc) == -ENOENT && >> + of_device_is_compatible(dev->of_node, "xlnx,fpga-slave-serial")) >> + desc = devm_gpiod_get(dev, legacy_con_id, flags); >> + >> + return desc; >> +} >> + >> static const struct fpga_manager_ops xilinx_core_ops = { >> .state = xilinx_core_state, >> .write_init = xilinx_core_write_init, >> @@ -186,12 +209,14 @@ int xilinx_core_probe(struct xilinx_fpga_core *core) >> return -EINVAL; >> >> /* PROGRAM_B is active low */ >> - core->prog_b = devm_gpiod_get(core->dev, "prog_b", GPIOD_OUT_LOW); >> + core->prog_b = xilinx_core_devm_gpiod_get(core->dev, "prog", "prog_b", >> + GPIOD_OUT_LOW); >> if (IS_ERR(core->prog_b)) >> return dev_err_probe(core->dev, PTR_ERR(core->prog_b), >> "Failed to get PROGRAM_B gpio\n"); >> >> - core->init_b = devm_gpiod_get_optional(core->dev, "init-b", GPIOD_IN); >> + core->init_b = xilinx_core_devm_gpiod_get(core->dev, "init", "init-b", >> + GPIOD_IN); >> if (IS_ERR(core->init_b)) >> return dev_err_probe(core->dev, PTR_ERR(core->init_b), >> "Failed to get INIT_B gpio\n"); > > Please make a separate patch for the naming change. This give a chance > to explain why the change and how to correctly use the GPIO names. > Ok >> diff --git a/drivers/fpga/xilinx-selectmap.c b/drivers/fpga/xilinx-selectmap.c >> new file mode 100644 >> index 0000000000000..b63f4623f8b2c >> --- /dev/null >> +++ b/drivers/fpga/xilinx-selectmap.c >> @@ -0,0 +1,97 @@ >> +// SPDX-License-Identifier: GPL-2.0-only >> +/* >> + * Xilinx Spartan6 and 7 Series SelectMAP interface driver >> + * >> + * (C) 2024 Charles Perry >> + * >> + * Manage Xilinx FPGA firmware loaded over the SelectMAP configuration >> + * interface. >> + */ >> + >> +#include "xilinx-core.h" >> + >> +#include >> +#include >> +#include >> +#include >> +#include >> +#include > > alphabetical order please. > Ok >> + >> +struct xilinx_selectmap_conf { >> + struct xilinx_fpga_core core; >> + void __iomem *base; >> +}; >> + >> +#define to_xilinx_selectmap_conf(obj) \ >> + container_of(obj, struct xilinx_selectmap_conf, core) >> + >> +static int xilinx_selectmap_write(struct xilinx_fpga_core *core, >> + const char *buf, size_t count) >> +{ >> + struct xilinx_selectmap_conf *conf = to_xilinx_selectmap_conf(core); >> + u32 i; >> + >> + for (i = 0; i < count; ++i) >> + writeb(buf[i], conf->base); >> + >> + return 0; >> +} >> + >> +static int xilinx_selectmap_probe(struct platform_device *pdev) >> +{ >> + struct xilinx_selectmap_conf *conf; >> + struct resource *r; >> + void __iomem *base; >> + struct gpio_desc *csi_b; >> + struct gpio_desc *rdwr_b; > > One gpio_desc is enough, is it? We don't use these gpio_desc anywhere > else. > Ok > BTW, reverse Xmas tree is not strictly required, but please do it when it is > easy to follow. > Ok >> + >> + conf = devm_kzalloc(&pdev->dev, sizeof(*conf), GFP_KERNEL); >> + if (!conf) >> + return -ENOMEM; >> + >> + conf->core.dev = &pdev->dev; >> + conf->core.write = xilinx_selectmap_write; >> + >> + base = devm_platform_get_and_ioremap_resource(pdev, 0, &r); > > I can't find where 'r' is used. > > Thanks, > Yilun > I'm guilty of keeping things around in case I need them in the future here! Ok, will use NULL. Regards, Charles >> + if (IS_ERR(base)) >> + return dev_err_probe(&pdev->dev, PTR_ERR(base), >> + "ioremap error\n"); >> + conf->base = base; >> + >> + /* CSI_B is active low */ >> + csi_b = devm_gpiod_get_optional(&pdev->dev, "csi", GPIOD_OUT_HIGH); >> + if (IS_ERR(csi_b)) >> + return dev_err_probe(&pdev->dev, PTR_ERR(csi_b), >> + "Failed to get CSI_B gpio\n"); >> + >> + /* RDWR_B is active low */ >> + rdwr_b = devm_gpiod_get_optional(&pdev->dev, "rdwr", GPIOD_OUT_HIGH); >> + if (IS_ERR(rdwr_b)) >> + return dev_err_probe(&pdev->dev, PTR_ERR(rdwr_b), >> + "Failed to get RDWR_B gpio\n"); >> + >> + return xilinx_core_probe(&conf->core); >> +} >> + >> +static const struct of_device_id xlnx_selectmap_of_match[] = { >> + { .compatible = "xlnx,fpga-xc7s-selectmap", }, // Spartan-7 >> + { .compatible = "xlnx,fpga-xc7a-selectmap", }, // Artix-7 >> + { .compatible = "xlnx,fpga-xc7k-selectmap", }, // Kintex-7 >> + { .compatible = "xlnx,fpga-xc7v-selectmap", }, // Virtex-7 >> + {}, >> +}; >> +MODULE_DEVICE_TABLE(of, xlnx_selectmap_of_match); >> + >> +static struct platform_driver xilinx_selectmap_driver = { >> + .driver = { >> + .name = "xilinx-selectmap", >> + .of_match_table = xlnx_selectmap_of_match, >> + }, >> + .probe = xilinx_selectmap_probe, >> +}; >> + >> +module_platform_driver(xilinx_selectmap_driver); >> + >> +MODULE_LICENSE("GPL"); >> +MODULE_AUTHOR("Charles Perry "); >> +MODULE_DESCRIPTION("Load Xilinx FPGA firmware over SelectMap"); >> -- >> 2.43.0