From mboxrd@z Thu Jan 1 00:00:00 1970 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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A8441C433F5 for ; Thu, 11 Nov 2021 10:00:01 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 10C8D61107 for ; Thu, 11 Nov 2021 10:00:01 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 10C8D61107 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=foundries.io Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=lists.denx.de Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 10FF383A3B; Thu, 11 Nov 2021 10:59:40 +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="WSGMs/ws"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 87D6383A1B; Thu, 11 Nov 2021 10:59:17 +0100 (CET) Received: from mail-lj1-x22f.google.com (mail-lj1-x22f.google.com [IPv6:2a00:1450:4864:20::22f]) (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 992E483A1A for ; Thu, 11 Nov 2021 10:59:03 +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-lj1-x22f.google.com with SMTP id d11so10842209ljg.8 for ; Thu, 11 Nov 2021 01:59:03 -0800 (PST) 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=E30nCZbSe5Yj9CHVtOJ9zcAeGNR6I6PwQTayDFsug7g=; b=WSGMs/wskxoeyvY6hzGaGR2bfTJiRE6KJs0Tb0jtzX7PT4N/r69PxzTj3ARCBJ7g/P 1IO4kiX5wR39gYT0djB2GfUHXTR1ulr6J2EJwHml6N3AGHMTroyTxWdksiQbL84qlbGh RxEc76ZC0ti1DboROD/WrjmnzicFH1UHD6qT8QKGqKzO82rKfYnYOlmuPhNy2IXKWy1c yrb9Yvcbf+c0x4rTZgBrW+CEligBAvu4erL0qc0RIGH6uLQMd2teN+ScCpa7QZ/8Jd+L oSshLdE+cBop7y3sPkADAtCrnR7vSEK7jhfxHfcSLX/GmP2NsjE//iy2EUlLEBfz5FO+ amfg== 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=E30nCZbSe5Yj9CHVtOJ9zcAeGNR6I6PwQTayDFsug7g=; b=Z0tfW8zuXEXN6z9fNIDg+VDRSqgE6asNR19P7MDKfZ2CZuPhjw9qKBCqT09AIEz+1f VILfrX/4lfA/CZa5cOGDFekd1rnPzeKWlthgah4nLp6+2CZS//1kMnjYoYySPJdpSHqD Ut59Ag1kh784dFgA+WyxBSYrDKXn3eA3xSo4TllsfMbRQvBAa/90rnQLybdYbcs/4SUd IC79+Mpe5LbN7qRFUPBnJ0tdDIOTzQU1DkS8gIIopjm+6DDgRd04rGM7BVJZfK48Ghkm mKBUqTs3RAeVOzXD7Cb3pZvmly5SwVvuPIrwiXb1iibjexy3hWFsk/6cg+JK6LLu/ljO 0upQ== X-Gm-Message-State: AOAM5301u8kB7QQ6o0Opx44Y9i2b5BSCE02cmS6mxYR52Z4BQLBSZyzl WN0YlyPpPnvK91Cq3uXX1DOR2k/CV7+Rjg== X-Google-Smtp-Source: ABdhPJw3jDp3oux49QNN1Ha8vaesglJaDYwIecGGE3k3ASEJn80B6shD4e+lbG7mxeEwswtcKcEkcQ== X-Received: by 2002:a2e:9e88:: with SMTP id f8mr5924638ljk.460.1636624742674; Thu, 11 Nov 2021 01:59:02 -0800 (PST) Received: from localhost.localdomain ([83.218.251.13]) by smtp.gmail.com with ESMTPSA id i1sm240582lfu.307.2021.11.11.01.59.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Nov 2021 01:59:02 -0800 (PST) From: Oleksandr Suvorov To: u-boot@lists.denx.de Cc: Michal Simek , Igor Opaniuk , Ricardo Salveti , Jorge Ramirez-Ortiz , Oleksandr Suvorov , Alexandru Gagniuc , Heiko Schocher , Philippe Reynes , Simon Glass Subject: [RFC PATCH v4 2/6] fpga: add fit_fpga_load function Date: Thu, 11 Nov 2021 11:58:38 +0200 Message-Id: <20211111095842.47443-3-oleksandr.suvorov@foundries.io> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211111095842.47443-2-oleksandr.suvorov@foundries.io> References: <20211111095842.47443-1-oleksandr.suvorov@foundries.io> <20211111095842.47443-2-oleksandr.suvorov@foundries.io> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 Tested-by: Ricardo Salveti --- (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 5fe0273d66d..bd29e8c59d4 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 3b0a44b2420..2266c7d83a4 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 ec5144334df..2891f321061 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, -- 2.31.1