From patchwork Wed Feb 23 14:36:03 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Simek X-Patchwork-Id: 1596747 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=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=monstr-eu.20210112.gappssmtp.com header.i=@monstr-eu.20210112.gappssmtp.com header.a=rsa-sha256 header.s=20210112 header.b=2nOLfzaE; 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 (4096 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4K3dsB3HHDz9sGf for ; Thu, 24 Feb 2022 01:36:46 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 9FF1983CA9; Wed, 23 Feb 2022 15:36:26 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=fail (p=none dis=none) header.from=xilinx.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=monstr-eu.20210112.gappssmtp.com header.i=@monstr-eu.20210112.gappssmtp.com header.b="2nOLfzaE"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 8BFDB83CA4; Wed, 23 Feb 2022 15:36:16 +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=-1.7 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,SPF_HELO_NONE,SPF_NONE, T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.2 Received: from mail-ed1-x535.google.com (mail-ed1-x535.google.com [IPv6:2a00:1450:4864:20::535]) (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 33DBD83BF4 for ; Wed, 23 Feb 2022 15:36:11 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=fail (p=none dis=none) header.from=xilinx.com Authentication-Results: phobos.denx.de; spf=none smtp.mailfrom=monstr@monstr.eu Received: by mail-ed1-x535.google.com with SMTP id z22so44486143edd.1 for ; Wed, 23 Feb 2022 06:36:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=monstr-eu.20210112.gappssmtp.com; s=20210112; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=lHxq2/Ekz9b76DfN1dlIHr7ia2R203efwX/cv69Nsi0=; b=2nOLfzaE9qbsMoHrJ0m4ZIaIs3SV9G4oQDLlhprxD2fjX7M+KoaYUHum0eZ4Z78wIg /jXcdQj44HZiHTs6mEXWHw0HyKALvDwtldeY46GBQiMxlLQRoEFZh5l55w6kGcicEyLF JdiqHNlZ/Psr5xqETymqaeb7UgLasnKT+LJ4QicBE5+y6aXSpBnV8wfivmVvskJidnqw BuxuDwMpXZ6VlR+YlFB//rBjOxc4c+w5Y9SlWzuiu//s2o/CQKEXVmolmk4+zjaDeutn 9H0xxzTH7w5sw5zXRkM4W3/8xcrpHC7YvCL+tHYHBhcHEDBXiAVpjpWbZTOd/CGe85hn lngA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=lHxq2/Ekz9b76DfN1dlIHr7ia2R203efwX/cv69Nsi0=; b=3YJqnt6QzM7zcFXdI9TqLOyeWoFxsBWYnMDAgtJh9uaDDi8QxdnxBpfgZbtXxbAPO8 4rpGUNdgbY3eW279IF84ReuvtXfDtN7Ci9LkWVKepXNc/pMt8LAiUEKaOW/5Mb2zajGK G+/hhVgo2BD/+M/HKRxdeRGmQeDoJQzcK6Wg8a/HKfE7KsJfr8A4COF8sbb6QZmNhuP9 l4Nr2ZU46XCbGUINoxhpI4blymA4ir4UCx+ExKGHieAZnKzgspYD2aCBe2R1njGqhQ0M kO9W5UOqroin6+vDe4da8S7ouQlJ9N5J5cP+Z++a8obqs/1gvJtdn/m1Y3ZSDfY3PMum tDsg== X-Gm-Message-State: AOAM533dKRAlSkfSEm53K5pxPBrORGGBsp+hav+v0NNro2IcEM3b+Siy n5aeVS7mvNdmgtW9l48UfalTe4LRUHHzwg== X-Google-Smtp-Source: ABdhPJxYfE3/ieUAHuWqInTq9pfmhhxbl3SjeG0y1faOJfGy8Yy5k9MnPszCo8n5BrggykeLnDcq4Q== X-Received: by 2002:a50:9996:0:b0:413:2db7:6f87 with SMTP id m22-20020a509996000000b004132db76f87mr4722608edb.132.1645626970359; Wed, 23 Feb 2022 06:36:10 -0800 (PST) Received: from localhost ([2a02:768:2307:40d6::f9e]) by smtp.gmail.com with ESMTPSA id x7sm8503963edr.12.2022.02.23.06.36.09 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 23 Feb 2022 06:36:09 -0800 (PST) From: Michal Simek To: u-boot@lists.denx.de, git@xilinx.com Cc: Ashok Reddy Soma , Adrian Fiergolski , Jaehoon Chung Subject: [PATCH 2/4] firmware: zynqmp: Add support for set sd config and is function supported Date: Wed, 23 Feb 2022 15:36:03 +0100 Message-Id: X-Mailer: git-send-email 2.35.1 In-Reply-To: References: 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.5 at phobos.denx.de X-Virus-Status: Clean From: Ashok Reddy Soma Add firmware API's to set SD configuration and to check if a purticular function is supported. Signed-off-by: Ashok Reddy Soma Signed-off-by: Michal Simek --- drivers/firmware/firmware-zynqmp.c | 51 ++++++++++++++++++++++++++++++ include/zynqmp_firmware.h | 6 ++++ 2 files changed, 57 insertions(+) diff --git a/drivers/firmware/firmware-zynqmp.c b/drivers/firmware/firmware-zynqmp.c index 8d8492d99f7e..8916c5589635 100644 --- a/drivers/firmware/firmware-zynqmp.c +++ b/drivers/firmware/firmware-zynqmp.c @@ -140,6 +140,57 @@ unsigned int zynqmp_firmware_version(void) return pm_api_version; }; +int zynqmp_pm_set_sd_config(u32 node, enum pm_sd_config_type config, u32 value) +{ + int ret; + + ret = xilinx_pm_request(PM_IOCTL, node, IOCTL_SET_SD_CONFIG, + config, value, NULL); + if (ret) + printf("%s: node %d: set_sd_config %d failed\n", + __func__, node, config); + + return ret; +} + +int zynqmp_pm_is_function_supported(const u32 api_id, const u32 id) +{ + int ret; + u32 *bit_mask; + u32 ret_payload[PAYLOAD_ARG_CNT]; + + /* Input arguments validation */ + if (id >= 64 || (api_id != PM_IOCTL && api_id != PM_QUERY_DATA)) + return -EINVAL; + + /* Check feature check API version */ + ret = xilinx_pm_request(PM_FEATURE_CHECK, PM_FEATURE_CHECK, 0, 0, 0, + ret_payload); + if (ret) + return ret; + + /* Check if feature check version 2 is supported or not */ + if ((ret_payload[1] & FIRMWARE_VERSION_MASK) == PM_API_VERSION_2) { + /* + * Call feature check for IOCTL/QUERY API to get IOCTL ID or + * QUERY ID feature status. + */ + + ret = xilinx_pm_request(PM_FEATURE_CHECK, api_id, 0, 0, 0, + ret_payload); + if (ret) + return ret; + + bit_mask = &ret_payload[2]; + if ((bit_mask[(id / 32)] & BIT((id % 32))) == 0) + return -EOPNOTSUPP; + } else { + return -ENODATA; + } + + return 0; +} + /** * Send a configuration object to the PMU firmware. * diff --git a/include/zynqmp_firmware.h b/include/zynqmp_firmware.h index 6d7614f4af00..f577008736d9 100644 --- a/include/zynqmp_firmware.h +++ b/include/zynqmp_firmware.h @@ -438,6 +438,8 @@ int zynqmp_pmufw_config_close(void); void zynqmp_pmufw_load_config_object(const void *cfg_obj, size_t size); int xilinx_pm_request(u32 api_id, u32 arg0, u32 arg1, u32 arg2, u32 arg3, u32 *ret_payload); +int zynqmp_pm_set_sd_config(u32 node, enum pm_sd_config_type config, u32 value); +int zynqmp_pm_is_function_supported(const u32 api_id, const u32 id); /* Type of Config Object */ #define PM_CONFIG_OBJECT_TYPE_BASE 0x1U @@ -469,5 +471,9 @@ enum zynqmp_pm_request_ack { #define ZYNQMP_PM_CAPABILITY_UNUSABLE 0x8U #define ZYNQMP_PM_MAX_QOS 100U +/* Firmware feature check version mask */ +#define FIRMWARE_VERSION_MASK GENMASK(15, 0) +/* PM API versions */ +#define PM_API_VERSION_2 2 #endif /* _ZYNQMP_FIRMWARE_H_ */