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 phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 0D85EC636D3 for ; Sun, 12 Feb 2023 22:40:57 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 4FB2B84528; Sun, 12 Feb 2023 23:40:55 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=denx.de Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=denx.de; s=phobos-20191101; t=1676241655; bh=znqRivE/WkV/skUpe9g8cTAqCp+PtFJS/Hyo3VIFAq0=; h=Date:Subject:To:Cc:References:From:In-Reply-To:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=wkvpwgTHlQO6Iw/2TNvomgP7cwkmVFR9dYV7+xdc167Wp3kB5a7Rs9zu5/68Rk56I LgDxMAKA50AGjPLbpdI75XBZU1+lWts1ov7/DgFoQtPXMKYbT3PcYFzyp9wdHsotSh oFT3xiaPGBPg/Lgw8p45opkJXmN9Jk6BPH5EyZzcLuUhjcG+66F2T5hme5TsBBZnA3 5KlQEyGvwN7K6lL0owmt7yn2Lx0CwKsPX8xyZH369+fWXS7JT0E+75XE6Ey0lCUh/k o76rClwyElGC/D/ksfDb2aKBIfV4oIDRaqFfZjLpUN6eTSOJhXwaJb+tO8X7rmMsoy O/bC0S9Z/TNtg== Received: from [127.0.0.1] (p578adb1c.dip0.t-ipconnect.de [87.138.219.28]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: marex@denx.de) by phobos.denx.de (Postfix) with ESMTPSA id 6EB4C844BF; Sun, 12 Feb 2023 23:40:52 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=denx.de; s=phobos-20191101; t=1676241652; bh=znqRivE/WkV/skUpe9g8cTAqCp+PtFJS/Hyo3VIFAq0=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=VwbqUwDIue279uSFKbGEKB4Sj7/q3OzwXFOykXvz8lKWQHrYbETv5jRZd6MVPSBsd ahgkDKSY1eOCpoAKCX2DnkOOz+JgA1Tp2cbQthRuAwtKAdpnKfUU8xeSKZBSq4NlfD ohOD8hyryg0MdKeDpbdM09NVynwhlC5A5+nRNrIK7ACG9wYlLnRAmbKI5WAkkPjV2C IM44TQRHyG7Ii2ESn0J881fAk0FqWmhujSJI23k6caYmFb9KUJ1LJfzHyDBb88I6Wk E3h5jiHH9fcejCip7Eo2vJSo2A9VqXrgpA0QuTEnTt9dE+qwM3GQBBob0tlm/BLPVz LmPZiDbKfIBXA== Message-ID: Date: Sun, 12 Feb 2023 23:40:51 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.7.1 Subject: Re: [PATCH 3/4] mtd/fpga: add fpga directory to mtd (with Cyclone 10) Content-Language: en-US To: Ulf Samuelsson , u-boot@lists.denx.de Cc: monstr@monstr.eu, sjg@chromium.org, Ulf Samuelsson , Miquel Raynal References: <20230211100743.12087-1-u-boot@emagii.com> <20230211100743.12087-4-u-boot@emagii.com> <0a7c186e-8372-8ace-9491-1b952801bd6e@denx.de> <4407e740-9017-b21e-243a-0e1321ac1075@denx.de> <46d7ce9f-3759-57db-588e-ac61f4cb6a0c@emagii.com> From: Marek Vasut In-Reply-To: <46d7ce9f-3759-57db-588e-ac61f4cb6a0c@emagii.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.6 at phobos.denx.de X-Virus-Status: Clean On 2/12/23 23:07, Ulf Samuelsson wrote: > Den 2023-02-12 kl. 21:01, skrev Marek Vasut: > > On 2/12/23 20:52, Ulf Samuelsson wrote: > >> > >> > >> Den 2023-02-12 kl. 20:31, skrev Marek Vasut: > >>  > On 2/11/23 11:07, u-boot@emagii.com wrote: > >>  > > >>  > [...] > >>  > > >>  >> +static int cyc10_write(struct mtd_info *mtd, loff_t to, size_t > len, > >>  >> +                 size_t *retlen, const u_char *buf) > >>  >> +{ > >>  >> +    struct udevice *dev = mtd->dev; > >>  >> +    struct spi_slave *slave = dev_get_parent_priv(dev); > >>  >> +    struct cyc10_plat *fpga = dev_get_plat(dev); > >>  >> +    int ret; > >>  > > >>  > Do I read this right, that the 'write' callback is the only one > doing > >>  > meaningful work, all the other callbacks are just empty stubs ? > >>  > Yes, you cannot read back the configuration data. > > > > That makes it look like any framework which supports "write" callback > would be suitable, not just MTD framework. > > > >>  > Why not update drivers/fpga/cyclon2.c which is Passive Serial > >>  > implementation already present in U-Boot for Altera Cyclone II > FPGA , > >>  > with Cyclone 10 FPGA support ? I believe the PS protocol changed > very > >>  > little. > >> Since the MTD command set is enough to configure the FPGA, the FPGA > commands can be removed from the build. The FPGA command set requires > you to supply addresses, but the MTD command set uses devices. > >> > >> So: > >> * Smaller U-Boot image > > > > The MTD framework is rather large, compared to the trivial FPGA > framework. Can you back this claim with any numbers ? > > I am assuming that the MTD framework is needed anyway. FPGA and MTD support is orthogonal, you cannot make that assumption. Consider SoC-FPGA machine booting from eMMC, Altera Cyclone V SoC does support that mode of operation, and MTD support can be disabled. > We certainly need it. > > > >> * Simplified user interface. > > > > If I am to select between 'fpga load' and 'mtd write' for FPGA > bitstream loading , my obvious choice would be 'fpga load' . How is > using 'mtd write' any better or simpler ? > > > fpga load 0   ${loadaddr} ${filesize} > mtd write spy ${loadaddr} > > The questions I ask myself. > So is "0" the "spy" FPGA or the "spx" FPGA? You can use DT /aliases node to enumerate the FPGAs the same way i2c busses, SPI NORs, SD/MMC devices etc. are enumerated . Also have a look at e.g. 'net list' command, similar functionality can be added to the FPGA command to list all registered FPGAs. > Why should I have to remember the size of the FPGA bitstream? Because it is not always possible to extract that information from the bitstream blob, remember, some of those blobs may be just raw binaries of the SRAM/flash content . > >> * The FPGA is an SPI peripheral, so why not add it to the SPI part > of the device tree? > > > > You can add the device into DT and still operate it using the U-Boot > FPGA framework, just add the DT support. Why not do it that way ? > > I don't think you can add the device into DT in U-Boot as it is today. > You can create FPGA contents and add that to the device tree, but not > the configuration itself. At least, I have not seen it. > If I have missed it, where is an example? Have a look at the Linux FPGA DT bindings in Documentation/devicetree/bindings/fpga/ . You can implement parsing of those bindings into the U-Boot FPGA framework and then add your FPGA device configuration interface into the DT. > The FPGA framework is not really setup to use device-tree to describe > configuration. > > Only 5 defconfigs in U-Boot uses the FPGA framework. > * astro_mcf5373l_defconfig > * syzygy_hub_defconfig > * xilinx_zynqmp_virt_defconfig > * xilinx_zynq_virt_defconfig These two ^ cover very much every zynq 7000 and zynqmp device in existence, since the way those are used is in combination with provided custom board DT. > * bitmain_antminer_s9_defconfig There is also arch/arm/mach-socfpga/Kconfig: imply FPGA_SOCFPGA , which activates the CONFIG_FPGA on all of Altera Cyclone V/Arria V/Stratix 10/Agilex and whatever new SoCFPGA Intel has. > Their device trees have leafs for configuration: > * compatible = "fpga-region"; > * compatible = "xlnx,zynq-devcfg-1.0"; > Neither "fpga-region" or "xlnx,zynq-devcfg-1.0" have any compatible > drivers, so there is really no support for configuration based on > device-tree at the moment. That's correct > If I look at boards using the Altera, no board uses a driver > to configure the FPGA. Instead they implement a number of callbacks > in the board files which manually handles the SPI bus outside the SPI > driver. No trace of device tree. Which boards do you refer to ? > > Let me be blunt about this, I have this feeling that what is > happening here is just overloading of MTD framework with unrelated > functionality (FPGA bitstream loading). MTD framework simply is not the > right place, esp. if there is dedicated FPGA framework, with existing > Altera PS driver no less. > > When you are configuring an FPGA, you are writing a bitstream > to an SRAM inside the FPGA. SRAM are memories. > > The MTD framework does exactly what is needed for passive serial. > I do not see that there is another place to add a device-tree based > FPGA configuration, so you basically have to replicate the MTD > framework, in order to have FPGA configuration in the device tree. Update the existing FPGA framework to parse the necessary DT bindings. Please do not overload existing framework (MTD or whatever) with unrelated functionality only because it provides the .write callback. While this may look like a good idea to cover one very specific use case, it would fail once all the other use cases which are already covered by the FPGA framework come into picture.