Received: by 2002:a05:7208:9594:b0:7e:5202:c8b4 with SMTP id gs20csp1342743rbb; Mon, 26 Feb 2024 06:32:23 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUZZugXDw1rwSXiwt80kt/Bq3MkjvO6udtxT9YCS5RBorvyaKqfiNMJZk9+KVZRmhup88P9EJy0kZQ45zYt+yD034nlCmuDbVSeBjVx5Q== X-Google-Smtp-Source: AGHT+IHdhcX4q3Pmfcz9R2y1NOHVZdSC8tcNFIEiodso3sgxCWYJTdoAuzEd2AITYLPfbkj50Z7D X-Received: by 2002:a05:6512:3d1:b0:512:bdd3:1539 with SMTP id w17-20020a05651203d100b00512bdd31539mr3721776lfp.37.1708957943200; Mon, 26 Feb 2024 06:32:23 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708957943; cv=pass; d=google.com; s=arc-20160816; b=uRPyYJBBeJFy1kvVaSs9FCWPrzYT6tsef4kcqOddxuObdMjGfJv6T7ioCwbQnH6HIh Fxk3pUjHctuQSiZ8/2htRghoL2EPiy3DOI/KXmAIbyDJQ5FbQxuLPmGqOgYrrQ6WOOy2 0s03G7ZdkJl1kzz2WYVHZQhUAlZOsaYYXHEq37jBjpwqz4dH4ehnexsq6PtyB8ujzPg2 4L33U41yKYPB+o8Lg/jvmqe+aI2m2KmX17dEI4aPtOLiHVwTiMKB3lbGas8WorVNoBzg 8YB/0CrE7gx7ftCxWtJgNIeVIWDet0WAIyVoA+1hJxTwLOLg0phPRzIhAcladuqXSYmk HUgw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=KWnD/kSOjSEKIoMxJgjJO10MriJoXckBeclPwuCiMRg=; fh=odv3siBkyPeVb9G92gO5k4awbWsf0QmhRC4a25u6pQE=; b=QMZ1wueQSLig4hJ7eXGLZMMgRd9A5SBUomIlsHYn1yEK3YEKK8G144/Oay+CTnlPE9 HMILfIIe1Spna7TnvsdCehF6ZQ5IJLi6YrudByPrhJx58xPSKn0bKsxLazkvsdT5Q+8n //KMbYw+epU8lPrKRAShz31efP5CCmAjqANxM3ffMLSaKjYOEq/V8iuobNmcZ4NXttld aBWDmqN6yTYbqYjZOK2vhgxusiANUB7nHqWsu8qoM3WXoLvVmyVuadfz8qNqdR+3+urJ hD6hn8KhHH91xAqO+AvbGk25/1EMJFOJmz6JcwD/agNUUilPpnlbnqd0HYByKrfwe9Dc c+6Q==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=MwHNQKxy; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-81115-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-81115-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id w7-20020aa7dcc7000000b00561ba9c6137si2145630edu.679.2024.02.26.06.32.23 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Feb 2024 06:32:23 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-81115-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=MwHNQKxy; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-81115-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-81115-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com 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 CFFEA1F2B520 for ; Mon, 26 Feb 2024 10:17:21 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 6EDAE219FD; Mon, 26 Feb 2024 09:54:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="MwHNQKxy" Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.11]) (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 AD59F14280; Mon, 26 Feb 2024 09:54:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.11 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708941286; cv=none; b=flAfX2mSLXKatCyQPAXvooVZsYlW0gIHzSt0pXURny9YrRrNMN/vKXAFbJav/ymi4Res51fqPExkNKmlpvVQ7W3E4CYoBQcmqUD3/8lET0PFH9R1K6jqT2+Q+oYwaFpq25MvqSiogICBjWiRkyqMxTe5xJFbqkCsH0M8apEliaM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708941286; c=relaxed/simple; bh=enB6Xir2DeuVTnHYJjI3T8tlXiRYYBFbJ7oEag0B5HQ=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=hs81cbDautfHtX+lpXABoriy+rkPkpkuhRfIU0WMcnTNJMLzPD1O9KjpYDsdSk708Kyb0PmwzjahAWyUFWJf40JVwOpRhj1ePUbKCyszGzrOHSa8NdVw8NivrD2DXdeaUV65pkEAcix5IE1j5i/7BMaNvyxLGFiz3KhnLBsZVxA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=MwHNQKxy; arc=none smtp.client-ip=192.198.163.11 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1708941285; x=1740477285; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=enB6Xir2DeuVTnHYJjI3T8tlXiRYYBFbJ7oEag0B5HQ=; b=MwHNQKxyapHMpnWbJbPGAA4PsVaQsL+s7G2Fg2/MFrzecbTCK77RLLEQ XvrWJwX2SrndPLwan8IgkRXxHsX2+aeDyBkGFzFv2VZ5Qd+iWiDAV9uQ6 KLl4sge3gGLgG7m5ccmdsKNVHdvEvXskGPPRhCDIgLvqrYzeIXB64cvH3 PdvSqrBehmkL46bPEUwklt9a747rjyb5Yh9TaAuTN28kVzSgQPnjueKL7 EcSxFUWdQ9hxwav9cyZB9c4SJQCXDvsTMLp7gKZcxmJV50jjDf7ZeupO/ nWDM0ewyWqzVQiHrqLpAvh0L4nEHnMFlvQZ5KVx6fQMQLXkVXPD6RpCkH A==; X-IronPort-AV: E=McAfee;i="6600,9927,10995"; a="13859654" X-IronPort-AV: E=Sophos;i="6.06,185,1705392000"; d="scan'208";a="13859654" Received: from fmviesa003.fm.intel.com ([10.60.135.143]) by fmvoesa105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Feb 2024 01:54:44 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.06,185,1705392000"; d="scan'208";a="11205325" Received: from yilunxu-optiplex-7050.sh.intel.com (HELO localhost) ([10.239.159.165]) by fmviesa003.fm.intel.com with ESMTP; 26 Feb 2024 01:54:40 -0800 Date: Mon, 26 Feb 2024 17:50:38 +0800 From: Xu Yilun To: Charles Perry Cc: mdf@kernel.org, avandiver@markem-imaje.com, bcody@markem-imaje.com, Wu Hao , Xu Yilun , Tom Rix , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Michal Simek , linux-fpga@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: Re: [PATCH v4 3/3] fpga: xilinx-selectmap: add new driver Message-ID: References: <20240221195058.1281973-1-charles.perry@savoirfairelinux.com> <20240221195058.1281973-4-charles.perry@savoirfairelinux.com> 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=us-ascii Content-Disposition: inline In-Reply-To: <20240221195058.1281973-4-charles.perry@savoirfairelinux.com> On Wed, Feb 21, 2024 at 02:50:49PM -0500, 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 > --- > drivers/fpga/Kconfig | 8 +++ > drivers/fpga/Makefile | 1 + > drivers/fpga/xilinx-selectmap.c | 97 +++++++++++++++++++++++++++++++++ > 3 files changed, 106 insertions(+) > 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-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 > + > +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; > + > + 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); > + 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); Does the driver have to be used with OF or not? If yes, please specify the reason and enforce in Kconfig. If no, please ensure it decently compiles without CONFIG_OF. Thanks, Yilun > + > +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 > >