From patchwork Tue Nov 2 13:49:44 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oleksandr Suvorov X-Patchwork-Id: 1549697 X-Patchwork-Delegate: monstr@monstr.eu Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=foundries.io header.i=@foundries.io header.a=rsa-sha256 header.s=google header.b=Yx50hFdT; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4HkBBG2cjRz9sVc for ; Wed, 3 Nov 2021 00:50:46 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 7ED80835FD; Tue, 2 Nov 2021 14:50:20 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=foundries.io Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=foundries.io header.i=@foundries.io header.b="Yx50hFdT"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 235C183201; Tue, 2 Nov 2021 14:50:14 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: 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.2 Received: from mail-lf1-x12b.google.com (mail-lf1-x12b.google.com [IPv6:2a00:1450:4864:20::12b]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 662E68314A for ; Tue, 2 Nov 2021 14:50:01 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=foundries.io Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=oleksandr.suvorov@foundries.io Received: by mail-lf1-x12b.google.com with SMTP id u11so43154453lfs.1 for ; Tue, 02 Nov 2021 06:50:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=foundries.io; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Reyq9e/xpLRxyYrGrdYT6b/SWTXc5YxwSbytDQOBA6w=; b=Yx50hFdTvYU5KUkihJh55xI5dXVbwKE166x7tBcYFXN2QKR4r/7ohaWA59w7MWOU5r YwNjgHbVCcGwq4/m0Vcdc++42YL2q/30bCBXOVq8r+lNwxYLyti/jDdvIvdPQFKqFSgB YcDpZQqWck265j5OB0q3ws6juc+LqIinBtKZ7NWfU2RUf0WB4jW9PUtkLin1YJhAuSvV 6TO6jfyKltpPBqRDMB3MbS/TVDC6YtsNv9l7RbeHSNzSiLBkUGnMt6IzCuEmpmir7Qp+ bajp0AHKyqllHr5/tKa3CBLqJZmh7wTuVNI/fL4vI6OC8RGCquZMA0frXUo47Tw+scVE WCvQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Reyq9e/xpLRxyYrGrdYT6b/SWTXc5YxwSbytDQOBA6w=; b=Z+cqTSNb/VKWECTZwOiZiNvxZVLU8hK5am3mi73KRxeQLFj5y0Mf5HkNJ23ig54zV3 HniTEC0bhkRk8PxxNdMe0JjhvBEC1n/gay5nqT8hRMHhgWawyIvlyXxnzjoerwcf9XW5 wSlB8+fIcU1g8LqdIEs9VUO7hsUXii9vNgVGOv+dFoTClp+SNxxE/ea5bZhVW0LNPG30 m28trHE93Q3RGjrHl2pDPwb4+NgY3BPBvowBFITlYdLaBzqavyB3LxAMbJ72WGQWAEfr Ig70hgX1yvRMRjkBhGzrC5Dl0uTOtITESEyXQwDTEXOdCxIlE/VupuQmiESQU8tegnjv ju6A== X-Gm-Message-State: AOAM530fHDjUJQhqHeGaeGLGZAGBZigy7jhdWl9UpEM8mpAU4vK7Bl00 4wOUZWCp0Mc5+9rHtSqlgp+oVAF594ptzg== X-Google-Smtp-Source: ABdhPJy5uzqrIbo+vgp/c4hvqa+HT12/Lttl1k+2VtWr4e+D7PsSxyS8aXTmWOLuAHmJrIRlN47MJw== X-Received: by 2002:a05:6512:32c8:: with SMTP id f8mr5204135lfg.223.1635861000391; Tue, 02 Nov 2021 06:50:00 -0700 (PDT) Received: from localhost.localdomain ([83.218.251.13]) by smtp.gmail.com with ESMTPSA id w6sm216292ljw.89.2021.11.02.06.49.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Nov 2021 06:49:59 -0700 (PDT) From: Oleksandr Suvorov To: u-boot@lists.denx.de Cc: Ricardo Salveti , Igor Opaniuk , Jorge Ramirez-Ortiz , Oleksandr Suvorov , Alexandru Gagniuc , Heiko Schocher , Michal Simek , Philippe Reynes , Simon Glass Subject: [PATCH v3 2/3] fpga: add fit_fpga_load function Date: Tue, 2 Nov 2021 15:49:44 +0200 Message-Id: <20211102134945.135159-3-oleksandr.suvorov@foundries.io> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211102134945.135159-2-oleksandr.suvorov@foundries.io> References: <20211102134945.135159-1-oleksandr.suvorov@foundries.io> <20211102134945.135159-2-oleksandr.suvorov@foundries.io> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 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.2 at phobos.denx.de X-Virus-Status: Clean Introduce a function which passes an fpga compatible string from FIT images to FPGA drivers. This lets the different implementations decide how to handle it. Some code of Jorge Ramirez-Ortiz is reused. Signed-off-by: Oleksandr Suvorov --- (no changes since v1) common/spl/spl_fit.c | 6 ++---- drivers/fpga/fpga.c | 35 ++++++++++++++++++++++++++++------- include/fpga.h | 4 ++++ 3 files changed, 34 insertions(+), 11 deletions(-) diff --git a/common/spl/spl_fit.c b/common/spl/spl_fit.c index 5fe0273d66..bd29e8c59d 100644 --- a/common/spl/spl_fit.c +++ b/common/spl/spl_fit.c @@ -580,11 +580,9 @@ static int spl_fit_upload_fpga(struct spl_fit_info *ctx, int node, compatible = fdt_getprop(ctx->fit, node, "compatible", NULL); if (!compatible) warn_deprecated("'fpga' image without 'compatible' property"); - else if (strcmp(compatible, "u-boot,fpga-legacy")) - printf("Ignoring compatible = %s property\n", compatible); - ret = fpga_load(0, (void *)fpga_image->load_addr, fpga_image->size, - BIT_FULL); + ret = fit_fpga_load(0, (void *)fpga_image->load_addr, fpga_image->size, + BIT_FULL, compatible); if (ret) { printf("%s: Cannot load the image to the FPGA\n", __func__); return ret; diff --git a/drivers/fpga/fpga.c b/drivers/fpga/fpga.c index 3b0a44b242..2266c7d83a 100644 --- a/drivers/fpga/fpga.c +++ b/drivers/fpga/fpga.c @@ -197,9 +197,9 @@ int fpga_fsload(int devnum, const void *buf, size_t size, fpga_fs_info *fpga_fsinfo) { int ret_val = FPGA_FAIL; /* assume failure */ - const fpga_desc *desc = fpga_validate(devnum, buf, size, - (char *)__func__); + const fpga_desc *desc; + desc = fpga_validate(devnum, buf, size, (char *)__func__); if (desc) { switch (desc->devtype) { case fpga_xilinx: @@ -225,10 +225,9 @@ int fpga_loads(int devnum, const void *buf, size_t size, struct fpga_secure_info *fpga_sec_info) { int ret_val = FPGA_FAIL; + const fpga_desc *desc; - const fpga_desc *desc = fpga_validate(devnum, buf, size, - (char *)__func__); - + desc = fpga_validate(devnum, buf, size, (char *)__func__); if (desc) { switch (desc->devtype) { case fpga_xilinx: @@ -249,15 +248,31 @@ int fpga_loads(int devnum, const void *buf, size_t size, } #endif +int fit_fpga_load(int devnum, const void *buf, size_t bsize, + bitstream_type bstype, const char *compatible) +{ + fpga_desc *desc = (fpga_desc *)fpga_validate(devnum, buf, bsize, + (char *)__func__); + + if (!desc) + return FPGA_FAIL; + /* + * Store the compatible string to proceed it in underlying + * functions + */ + desc->compatible = (char *)compatible; + + return fpga_load(devnum, buf, bsize, bstype); +} /* - * Generic multiplexing code + * Generic multiplexing code: + * Each architecture must handle the mandatory FPGA DT compatible property. */ int fpga_load(int devnum, const void *buf, size_t bsize, bitstream_type bstype) { int ret_val = FPGA_FAIL; /* assume failure */ const fpga_desc *desc = fpga_validate(devnum, buf, bsize, (char *)__func__); - if (desc) { switch (desc->devtype) { case fpga_xilinx: @@ -270,6 +285,9 @@ int fpga_load(int devnum, const void *buf, size_t bsize, bitstream_type bstype) break; case fpga_altera: #if defined(CONFIG_FPGA_ALTERA) + if (strncmp(desc->compatible, "u-boot,fpga-legacy", 18)) + printf("Ignoring compatible = %s property\n", + desc->compatible); ret_val = altera_load(desc->devdesc, buf, bsize); #else fpga_no_sup((char *)__func__, "Altera devices"); @@ -277,6 +295,9 @@ int fpga_load(int devnum, const void *buf, size_t bsize, bitstream_type bstype) break; case fpga_lattice: #if defined(CONFIG_FPGA_LATTICE) + if (strncmp(desc->compatible, "u-boot,fpga-legacy", 18)) + printf("Ignoring compatible = %s property\n", + desc->compatible); ret_val = lattice_load(desc->devdesc, buf, bsize); #else fpga_no_sup((char *)__func__, "Lattice devices"); diff --git a/include/fpga.h b/include/fpga.h index ec5144334d..2891f32106 100644 --- a/include/fpga.h +++ b/include/fpga.h @@ -35,6 +35,7 @@ typedef enum { /* typedef fpga_type */ typedef struct { /* typedef fpga_desc */ fpga_type devtype; /* switch value to select sub-functions */ void *devdesc; /* real device descriptor */ + char *compatible; /* device compatible string */ } fpga_desc; /* end, typedef fpga_desc */ typedef struct { /* typedef fpga_desc */ @@ -63,6 +64,9 @@ int fpga_add(fpga_type devtype, void *desc); int fpga_count(void); const fpga_desc *const fpga_get_desc(int devnum); int fpga_is_partial_data(int devnum, size_t img_len); +/* the DT compatible property must be handled by the different FPGA archs */ +int fit_fpga_load(int devnum, const void *buf, size_t bsize, + bitstream_type bstype, const char *compatible); int fpga_load(int devnum, const void *buf, size_t bsize, bitstream_type bstype); int fpga_fsload(int devnum, const void *buf, size_t size,