From patchwork Fri Jul 22 14:16:08 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oleksandr Suvorov X-Patchwork-Id: 1659601 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=kGHsOv0P; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4LqBNm68ysz9sGq for ; Sat, 23 Jul 2022 00:18:00 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 8B54684118; Fri, 22 Jul 2022 16:16:54 +0200 (CEST) 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="kGHsOv0P"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 1FE5F83FB3; Fri, 22 Jul 2022 16:16:33 +0200 (CEST) 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-wr1-x431.google.com (mail-wr1-x431.google.com [IPv6:2a00:1450:4864:20::431]) (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 B377B83FA1 for ; Fri, 22 Jul 2022 16:16:29 +0200 (CEST) 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-wr1-x431.google.com with SMTP id b26so6713252wrc.2 for ; Fri, 22 Jul 2022 07:16:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=foundries.io; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc; bh=bsHESJOEjr7Rh7blPzvcLAbmsxSRmNbGvDSf7ST8V1E=; b=kGHsOv0PQ2eTZICmePSbhfrpVBbbrWqhmgiCsT4M8k8qT/hLdelIU3c/implrrUsR+ 7oGsT/7npOgPn0DnLgycbmGw3h0/SrN0W8mwYaNAqeIS9k7feaP3ypS8wf1Ejkwdpc6j RMJHf983iJwuzBe+iZHom8rIAM0jEWaf0qEjrboPxmrUUsEguEqDPqR29fYYSF9arQVt wbxGdL1SiUF82zxDZA4Lp+Pafbb/D8ug7oVZIOEjLdOPUQIc/8lfo1jrh9PVQ4A4txD3 beTzdQNsEzbLiiDHtBfUzErMy5BjJXHRrn/sqsLoryv5NmhrISqvhLFM/JVQJg/IhlVG 79Pg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc; bh=bsHESJOEjr7Rh7blPzvcLAbmsxSRmNbGvDSf7ST8V1E=; b=znKYaaP8vX4sIhrXUva0czQi8JiaKrjRF9yjv7JedJmISWwHO8dBYZtaRz3eQEMLHA rjffI/W6piDgPkUhgkaH3X6cFQ3Kd7OZu/qrlEC9lcBYamwR8CPt2rI/B1/+Soxi2hbW TiLvN/30VRIBJY55wHOejxL4epaTDUHgd5wjLE3l6aR/Or1d0wuRaGzyE0tIxuN/OU1s ypYDyZoVXpyTrjpBiHkQJP1gQFgm4yfBUNIA1u0jmK0NH8temI2b/E4fQ41VDRPg6Tn5 KtwyW+yb2cL6GTAfamD90mIDwkMSMfFtlqxaQllptqWBMqRz+NdKNAjlTseC4/+0f/3e MYig== X-Gm-Message-State: AJIora8e8c1wySoB8J/ve2AEvdL23CNp6V358yLbCR/SVBG9TKDmDnh9 mM6BQqj1vPonet6Gp3wpMaIdV2DEeVFUdA== X-Google-Smtp-Source: AGRyM1vjQ3ErX6wTOLw4JOBX1uNg5X1XPTsbNPy2R+vPmcH3rEQEDQgCBiALJfJu7YjJICHiXQO5Tw== X-Received: by 2002:adf:e187:0:b0:21d:64c6:74f0 with SMTP id az7-20020adfe187000000b0021d64c674f0mr85071wrb.221.1658499388953; Fri, 22 Jul 2022 07:16:28 -0700 (PDT) Received: from cryobook.. ([89.105.248.137]) by smtp.gmail.com with ESMTPSA id d13-20020adf9c8d000000b0021e4c3b2967sm4855364wre.65.2022.07.22.07.16.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Jul 2022 07:16:28 -0700 (PDT) From: Oleksandr Suvorov To: u-boot@lists.denx.de Cc: Michal Simek , Adrian Fiergolski , Ricardo Salveti , Jorge Ramirez-Ortiz , Igor Opaniuk , Oleksandr Suvorov , Michal Simek Subject: [PATCH v12 07/13] fpga: add fpga_compatible2flag Date: Fri, 22 Jul 2022 17:16:08 +0300 Message-Id: <20220722141614.297383-8-oleksandr.suvorov@foundries.io> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220722141614.297383-7-oleksandr.suvorov@foundries.io> References: <20220722141614.297383-1-oleksandr.suvorov@foundries.io> <20220722141614.297383-2-oleksandr.suvorov@foundries.io> <20220722141614.297383-3-oleksandr.suvorov@foundries.io> <20220722141614.297383-4-oleksandr.suvorov@foundries.io> <20220722141614.297383-5-oleksandr.suvorov@foundries.io> <20220722141614.297383-6-oleksandr.suvorov@foundries.io> <20220722141614.297383-7-oleksandr.suvorov@foundries.io> MIME-Version: 1.0 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 Add a "compatible" string to binary flag converter, which uses a callback str2flag() of given FPGA driver if available. Signed-off-by: Oleksandr Suvorov Tested-by: Ricardo Salveti Tested-by: Adrian Fiergolski --- Changes in v12: - define the function only if FPGA_LOAD_SECURE enabled; Changes in v10: - fix mixed types of return value; drivers/fpga/fpga.c | 26 ++++++++++++++++++++++++++ include/fpga.h | 1 + 2 files changed, 27 insertions(+) diff --git a/drivers/fpga/fpga.c b/drivers/fpga/fpga.c index 185bd547cb5..4db5c0a91e9 100644 --- a/drivers/fpga/fpga.c +++ b/drivers/fpga/fpga.c @@ -357,3 +357,29 @@ int fpga_info(int devnum) return fpga_dev_info(devnum); } + +#if CONFIG_IS_ENABLED(FPGA_LOAD_SECURE) +int fpga_compatible2flag(int devnum, const char *compatible) +{ + const fpga_desc * const desc = fpga_get_desc(devnum); + + if (!desc) + return 0; + + switch (desc->devtype) { +#if defined(CONFIG_FPGA_XILINX) + case fpga_xilinx: + { + xilinx_desc *xdesc = (xilinx_desc *)desc->devdesc; + + if (xdesc->operations && xdesc->operations->str2flag) + return xdesc->operations->str2flag(xdesc, compatible); + } +#endif + default: + break; + } + + return 0; +} +#endif diff --git a/include/fpga.h b/include/fpga.h index 6365e1569e3..13b1bbee3ca 100644 --- a/include/fpga.h +++ b/include/fpga.h @@ -75,5 +75,6 @@ int fpga_dump(int devnum, const void *buf, size_t bsize); int fpga_info(int devnum); const fpga_desc *const fpga_validate(int devnum, const void *buf, size_t bsize, char *fn); +int fpga_compatible2flag(int devnum, const char *compatible); #endif /* _FPGA_H_ */