From patchwork Wed Feb 23 14:36:02 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Simek X-Patchwork-Id: 1596744 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=FElDU2i7; 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 4K3drd5NFKz9sGf for ; Thu, 24 Feb 2022 01:36:17 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id A0A1183BA2; Wed, 23 Feb 2022 15:36:14 +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="FElDU2i7"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id DF34683B94; Wed, 23 Feb 2022 15:36:12 +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-x530.google.com (mail-ed1-x530.google.com [IPv6:2a00:1450:4864:20::530]) (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 0B5D683B94 for ; Wed, 23 Feb 2022 15:36:10 +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-x530.google.com with SMTP id w3so44544815edu.8 for ; Wed, 23 Feb 2022 06:36:09 -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=vYc/TRjYsMhsJ2+nlmGMHARO8ZJ/V3xK/n1VMo6EqdI=; b=FElDU2i7CU7hbf6t/BtBexyDGcHPlKWxx5bofD04xUMlDx275c4yxU/1Czg6KQK/Hk nfkYmdbtRGbqP/An0hAAGD498RfK0xVW9ueLfdiTMLjaCQMfgIbGScrIHTixFGc9TjOd 6ALTvKYzn7UvJuIrz4LE1cnjVoVAQJnK2gctRtDI4jn7ZxSM57WzGWJPvzjs66sbaCjA 5HYb2kxelGCILSO8lmmxUuuz8oavIsj1NqxwiRrdJd7OJ3d3NjaDEC274CPalPNXvTKv kRyDA042jNP6h/M+pg3uo8FSMhvy2DiIXBL/eQKAF3aWUR9bTn+3reMfy3gAIAbPJOhH dNzw== 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=vYc/TRjYsMhsJ2+nlmGMHARO8ZJ/V3xK/n1VMo6EqdI=; b=ySRbmloNOZRwoBR927mSNqvmxpLeJZIU1mbZUTyksOMi4iRVyRkUjOZLCBF7aow0Uo xu9z61mNBwgP1D/BWYoqgYUjeLy90ip1DYWrfeKBelm9fP1/0VVZNGpw+GRlFlUanl3x mSjYacYWEF8M8jHmsMrOtV9hmS39K3D4FfoINYKC1UkQgbH0agKLNLjg7NvBGEgwXl70 7R0pf0s/Lor1Yn+U/mMNf6QTKYzcf5MSrKTV5NHLASHX8joGxAB2akLE1sJUIgTOATWm eyFy0aZzJG3UlOlxxO1IsQNjBymvFC2+uuW5fLaLhJxmxScvepTz7KqNLVeoZHC0hAu7 G2kg== X-Gm-Message-State: AOAM532wC03pJVZ0pamaWQvg7Kwbv7ASDvvDwQIe1LXnANI/zFTO1Kap 5p1m5uffXEw/R4kytDyAQVHtqZCZCkHHbA== X-Google-Smtp-Source: ABdhPJwLUS8nXDph9rq2Oh9X9PhuP6KaqU+OWuQPi5bpBHdNSIvK2rkLnguZ8rqEQhWrOp7mWpWr6g== X-Received: by 2002:a05:6402:51d1:b0:412:e72f:c6d3 with SMTP id r17-20020a05640251d100b00412e72fc6d3mr20212835edd.61.1645626968818; Wed, 23 Feb 2022 06:36:08 -0800 (PST) Received: from localhost ([2a02:768:2307:40d6::f9e]) by smtp.gmail.com with ESMTPSA id b20sm4753035ede.58.2022.02.23.06.36.08 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 23 Feb 2022 06:36:08 -0800 (PST) From: Michal Simek To: u-boot@lists.denx.de, git@xilinx.com Cc: Ashok Reddy Soma Subject: [PATCH 1/4] firmware: zynqmp: Add and update firmware enums Date: Wed, 23 Feb 2022 15:36:02 +0100 Message-Id: <9aba090ec11d2591dbe6978e73e64384873c99fc.1645626962.git.michal.simek@xilinx.com> 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 Update enum pm_ioctl_id with more IOCTLs. Add enum pm_sd_config_type to support dynamic sd configuration. Signed-off-by: Ashok Reddy Soma Signed-off-by: Michal Simek --- include/zynqmp_firmware.h | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/include/zynqmp_firmware.h b/include/zynqmp_firmware.h index 41abc2eee951..6d7614f4af00 100644 --- a/include/zynqmp_firmware.h +++ b/include/zynqmp_firmware.h @@ -383,6 +383,29 @@ enum pm_ioctl_id { IOCTL_GET_LAST_RESET_REASON = 23, /* AIE ISR Clear */ IOCTL_AIE_ISR_CLEAR = 24, + /* Register SGI to ATF */ + IOCTL_REGISTER_SGI = 25, + /* Runtime feature configuration */ + IOCTL_SET_FEATURE_CONFIG = 26, + IOCTL_GET_FEATURE_CONFIG = 27, + /* IOCTL for Secure Read/Write Interface */ + IOCTL_READ_REG = 28, + IOCTL_MASK_WRITE_REG = 29, + /* Dynamic SD/GEM/USB configuration */ + IOCTL_SET_SD_CONFIG = 30, + IOCTL_SET_GEM_CONFIG = 31, + IOCTL_SET_USB_CONFIG = 32, + /* AIE/AIEML Operations */ + IOCTL_AIE_OPS = 33, + /* IOCTL to get default/current QoS */ + IOCTL_GET_QOS = 34, +}; + +enum pm_sd_config_type { + SD_CONFIG_EMMC_SEL = 1, /* To set SD_EMMC_SEL in CTRL_REG_SD */ + SD_CONFIG_BASECLK = 2, /* To set SD_BASECLK in SD_CONFIG_REG1 */ + SD_CONFIG_8BIT = 3, /* To set SD_8BIT in SD_CONFIG_REG2 */ + SD_CONFIG_FIXED = 4, /* To set fixed config registers */ }; #define PM_SIP_SVC 0xc2000000 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_ */ From patchwork Wed Feb 23 14:36:04 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Simek X-Patchwork-Id: 1596746 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=yw5nDcq4; 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 4K3ds02YQWz9sGf for ; Thu, 24 Feb 2022 01:36:36 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id DD35E83A8A; Wed, 23 Feb 2022 15:36:23 +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="yw5nDcq4"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id CB4E483BF4; 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-ej1-x62f.google.com (mail-ej1-x62f.google.com [IPv6:2a00:1450:4864:20::62f]) (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 5E5D0838C9 for ; Wed, 23 Feb 2022 15:36:13 +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-ej1-x62f.google.com with SMTP id p9so52849094ejd.6 for ; Wed, 23 Feb 2022 06:36:13 -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=HprSj4RrDqHvJv4A88acSuYZ28PlHuFxA/fmizozlWs=; b=yw5nDcq4LNo6MeOxZkFBqCScq4Xlgfv1PvxccRUsBAfPfYzc9T1+jYGz54nU/bLbVK cr+10p7Icq/2pIfqwXlhulBR8yuVRT/jcGQI2+ijdmUWRlhzZ62iOt8Xdo0aFk1vwjgW Olf8QdWxfpPLW4vLasTIKGK3lPBmDymgQEGwqKL1DZI+yElmwcLRPyZTFqQmEqsp3Xwk 6KTkHJEAv7fmwiN4tFzm396vhdx1lywhJ1dYBGvIM9svcZVIRfiyf1aPVUkaDQ+V9o0M fuGvyJp6bYqUx0syNzOllCLCO/y6BsEU2LctTkkpasFL+VFfz6kBmdO5Y5L/1QcmacLa drsA== 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=HprSj4RrDqHvJv4A88acSuYZ28PlHuFxA/fmizozlWs=; b=8C2shuLbxtvjwey71G9eHuK9F63lqmZcLh02A7Wy6kSyELukDqD1E/paskcP8tjY+6 t1BHcY4znR2/2eMZcdjsVl9RRgQiZ5dMFmxGijXx6jEsiEEjmCdxU4rFSKkKqMav/RoN saEaNc6gdaZEHfUsIbOTrvRsxUFvVokXLiyGKNpprKsgJEaqUcgJxdev7FwzfOoRMbuZ +x6iPaMWV4U40WLAOJrbzyFN5fFnhmteyq0S9m3n2muU95leUAmd3s9JfAhZuSOT2L00 YvAedwjlzn3OUw4XKTL6PSgkZBWOw2gpUN0o6KpoC26u5AuTKMqbXBsn10/jcVImMP/G 6Pxg== X-Gm-Message-State: AOAM530cPUJ1yh3jD6rXLYjW/x/V6+Xg29lCvWWF87R+309p5BW/eQiw iNbmXVlFX448g/iB+dhBVfi4tTvIVW7ODQ== X-Google-Smtp-Source: ABdhPJwO8sJwJMGsU+m4k0oD5m3VNrw7f1mTcNjXSadVvClP+0gBd6rnFtn2CfjD7rQKzCfiPA2Fxw== X-Received: by 2002:a17:906:7fc9:b0:6cf:d288:c9ef with SMTP id r9-20020a1709067fc900b006cfd288c9efmr586ejs.751.1645626972087; Wed, 23 Feb 2022 06:36:12 -0800 (PST) Received: from localhost ([2a02:768:2307:40d6::f9e]) by smtp.gmail.com with ESMTPSA id h27sm7778660ejb.13.2022.02.23.06.36.11 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 23 Feb 2022 06:36:11 -0800 (PST) From: Michal Simek To: u-boot@lists.denx.de, git@xilinx.com Cc: Ashok Reddy Soma Subject: [PATCH 3/4] lib: div64: Add support for round up of div64_u64 Date: Wed, 23 Feb 2022 15:36:04 +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 Most of the frequencies are not rounded up to a proper number. When we need to devide these frequencies to get a number for example frequency in Mhz, we see it as one less than the actual intended value. Ex: If we want to get Mhz from frequency 199999994hz, we will calculate it using div64_u64(199999994, 1000000) and we will get 199Mhz in place of 200Mhz. Add a macro DIV64_U64_ROUND_UP for rounding up div64_u64. This is taken from linux 'commit 68600f623d69("mm: don't miss the last page because of round-off error")'. Signed-off-by: Ashok Reddy Soma Signed-off-by: Michal Simek --- include/linux/math64.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/include/linux/math64.h b/include/linux/math64.h index 08584c8f237f..eaa9fd5b9685 100644 --- a/include/linux/math64.h +++ b/include/linux/math64.h @@ -48,6 +48,9 @@ static inline u64 div64_u64(u64 dividend, u64 divisor) return dividend / divisor; } +#define DIV64_U64_ROUND_UP(ll, d) \ + ({ u64 _tmp = (d); div64_u64((ll) + _tmp - 1, _tmp); }) + /** * div64_s64 - signed 64bit divide with 64bit divisor */ From patchwork Wed Feb 23 14:36:05 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Simek X-Patchwork-Id: 1596748 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=1yAyioYz; 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 4K3dsN4rNGz9sGf for ; Thu, 24 Feb 2022 01:36:56 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 1C98B83CCC; Wed, 23 Feb 2022 15:36:30 +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="1yAyioYz"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id B45B183CAE; Wed, 23 Feb 2022 15:36:20 +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-ej1-x62a.google.com (mail-ej1-x62a.google.com [IPv6:2a00:1450:4864:20::62a]) (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 3FCDE83CA5 for ; Wed, 23 Feb 2022 15:36:16 +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-ej1-x62a.google.com with SMTP id a23so52646754eju.3 for ; Wed, 23 Feb 2022 06:36:16 -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=pal7n9HJqDjSuJ/DV3yCCqPQY0GVE7lynY2ZV0dkNK0=; b=1yAyioYzG6G7b5vLik8LRUTGw/zPH1YGc7aMq+GOGbDyBAfjzFzwLW2c3mn6ZoEnlC 6bdPDjr9JUA3XBaaRFQPkD2yynD7elB49pCQRr3b2U5d2bKLFSe8I/UJalbJfZLPd1ko EER959KRR8VpqrkSqkjjijjvYmKLjLy/0modwHZ86THMKcGOHfTsci7tAdnc658U86gV s9bbj6HJpul9JEcGbkxwb+W3cUp+fh26lgS5ce7l5MUj4cgncsss6L15Iv5qOz84ZNkB gEi7EGE1uiVo4RGDyilryW6kw5k/k1LUBC2Yko+yXR0tw5kzV9/rZRI6/B9mmO5L6p2v zsvQ== 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=pal7n9HJqDjSuJ/DV3yCCqPQY0GVE7lynY2ZV0dkNK0=; b=GOGvAF3W+oju+Hk3hUNWlXNwhVA8P4Gbh3fB+jyoF19F2mU2mVWMp+nQFo2aDGMdih D0R3WsJutgPU4KmmEhO+IFdUr4NpCxIL2EU1RasYUAks1GWrq9oCPJULruJFxCrByTfC mBlfHgU1rVTLJaRadGcZ6JGF6zxWCht6DSFFNUaYU1B2hUO6KhWf5ox5Dqn/9ighKL9A D6eJBoOogURV8qCM0hd+zXwjJB+/FiZ8ecynWLEVgY5I0COl52buoH7RbBIuCJAoxV3k poVlt72oT3BVj+tQrehU4C0RmfRAq4GmViKU0fY1himOsS3DGTEMv/EkCdIRuaymSDHZ isyA== X-Gm-Message-State: AOAM530XT0Fx8iB1zZnz/J71r7bIUChxUj0vT3cUacQr/Lef1N7K0IAc uv9OwYKWjNA0482kNFXZ6MO2CeXhqkUW3g== X-Google-Smtp-Source: ABdhPJx5AIhzTXgm54VVvJ1xFpZMrZ7UweWqTOiAyh08S+A+aYysQMd0kq57ju+LXkpQvr3bAzSwig== X-Received: by 2002:a17:907:334c:b0:6cd:76b7:3948 with SMTP id yr12-20020a170907334c00b006cd76b73948mr27863ejb.55.1645626973649; Wed, 23 Feb 2022 06:36:13 -0800 (PST) Received: from localhost ([2a02:768:2307:40d6::f9e]) by smtp.gmail.com with ESMTPSA id s1sm9446934edd.100.2022.02.23.06.36.13 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 23 Feb 2022 06:36:13 -0800 (PST) From: Michal Simek To: u-boot@lists.denx.de, git@xilinx.com Cc: Ashok Reddy Soma , Jaehoon Chung , Peng Fan Subject: [PATCH 4/4] mmc: zynq_sdhci: Add support for dynamic configuration Date: Wed, 23 Feb 2022 15:36:05 +0100 Message-Id: <030a3ec041ff3efebd574b4d2b477ad85f12cbce.1645626962.git.michal.simek@xilinx.com> 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 support for dynamic configuration which will takes care of configuring the SD secure space configuration registers using firmware APIs, performing SD reset assert and deassert. High level sequence: - Check for the PM dynamic configuration support, if no error proceed with SD dynamic configurations(next steps) otherwise skip the dynamic configuration. - Put the SD Controller in reset. - Configure SD Fixed configurations. - Configure the SD Slot Type. - Configure the BASE_CLOCK. - Configure the 8-bit support. - Bring the SD Controller out of reset. In the above steps, apart from the Fixed configurations, remaining all configurations are dynamic and they will be read from devicetree. And also remove hardcoded secure register writes, as dynamic sd config support is added. Signed-off-by: Ashok Reddy Soma Signed-off-by: Michal Simek --- drivers/mmc/zynq_sdhci.c | 101 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 99 insertions(+), 2 deletions(-) diff --git a/drivers/mmc/zynq_sdhci.c b/drivers/mmc/zynq_sdhci.c index 33d00b06c777..d96f5d543f54 100644 --- a/drivers/mmc/zynq_sdhci.c +++ b/drivers/mmc/zynq_sdhci.c @@ -12,9 +12,12 @@ #include #include "mmc_private.h" #include +#include #include #include #include +#include +#include #include #include #include @@ -61,6 +64,7 @@ struct arasan_sdhci_priv { u8 deviceid; u8 bank; u8 no_1p8; + struct reset_ctl_bulk resets; }; /* For Versal platforms zynqmp_mmio_write() won't be available */ @@ -243,7 +247,7 @@ static int arasan_sdhci_execute_tuning(struct mmc *mmc, u8 opcode) char tuning_loop_counter = SDHCI_TUNING_LOOP_COUNT; u8 node_id = priv->deviceid ? NODE_SD_1 : NODE_SD_0; - debug("%s\n", __func__); + dev_dbg(mmc->dev, "%s\n", __func__); host = priv->host; @@ -703,6 +707,87 @@ static const struct sdhci_ops arasan_ops = { }; #endif +#if defined(CONFIG_ARCH_ZYNQMP) +static int sdhci_zynqmp_set_dynamic_config(struct arasan_sdhci_priv *priv, + struct udevice *dev) +{ + int ret; + u32 node_id = priv->deviceid ? NODE_SD_1 : NODE_SD_0; + struct clk clk; + unsigned long clock, mhz; + + ret = xilinx_pm_request(PM_REQUEST_NODE, node_id, ZYNQMP_PM_CAPABILITY_ACCESS, + ZYNQMP_PM_MAX_QOS, ZYNQMP_PM_REQUEST_ACK_NO, NULL); + if (ret) { + dev_err(dev, "Request node failed for %d\n", node_id); + return ret; + } + + ret = reset_get_bulk(dev, &priv->resets); + if (ret == -ENOTSUPP || ret == -ENOENT) { + dev_err(dev, "Reset not found\n"); + return 0; + } else if (ret) { + dev_err(dev, "Reset failed\n"); + return ret; + } + + ret = reset_assert_bulk(&priv->resets); + if (ret) { + dev_err(dev, "Reset assert failed\n"); + return ret; + } + + ret = zynqmp_pm_set_sd_config(node_id, SD_CONFIG_FIXED, 0); + if (ret) { + dev_err(dev, "SD_CONFIG_FIXED failed\n"); + return ret; + } + + ret = zynqmp_pm_set_sd_config(node_id, SD_CONFIG_EMMC_SEL, + dev_read_bool(dev, "non-removable")); + if (ret) { + dev_err(dev, "SD_CONFIG_EMMC_SEL failed\n"); + return ret; + } + + ret = clk_get_by_index(dev, 0, &clk); + if (ret < 0) { + dev_err(dev, "failed to get clock\n"); + return ret; + } + + clock = clk_get_rate(&clk); + if (IS_ERR_VALUE(clock)) { + dev_err(dev, "failed to get rate\n"); + return clock; + } + + mhz = DIV64_U64_ROUND_UP(clock, 1000000); + + ret = zynqmp_pm_set_sd_config(node_id, SD_CONFIG_BASECLK, mhz); + if (ret) { + dev_err(dev, "SD_CONFIG_BASECLK failed\n"); + return ret; + } + + ret = zynqmp_pm_set_sd_config(node_id, SD_CONFIG_8BIT, + (dev_read_u32_default(dev, "bus-width", 1) == 8)); + if (ret) { + dev_err(dev, "SD_CONFIG_8BIT failed\n"); + return ret; + } + + ret = reset_deassert_bulk(&priv->resets); + if (ret) { + dev_err(dev, "Reset release failed\n"); + return ret; + } + + return 0; +} +#endif + static int arasan_sdhci_probe(struct udevice *dev) { struct arasan_sdhci_plat *plat = dev_get_plat(dev); @@ -715,6 +800,18 @@ static int arasan_sdhci_probe(struct udevice *dev) host = priv->host; +#if defined(CONFIG_ARCH_ZYNQMP) + if (device_is_compatible(dev, "xlnx,zynqmp-8.9a")) { + ret = zynqmp_pm_is_function_supported(PM_IOCTL, + IOCTL_SET_SD_CONFIG); + if (!ret) { + ret = sdhci_zynqmp_set_dynamic_config(priv, dev); + if (ret) + return ret; + } + } +#endif + ret = clk_get_by_index(dev, 0, &clk); if (ret < 0) { dev_err(dev, "failed to get clock\n"); @@ -727,7 +824,7 @@ static int arasan_sdhci_probe(struct udevice *dev) return clock; } - debug("%s: CLK %ld\n", __func__, clock); + dev_dbg(dev, "%s: CLK %ld\n", __func__, clock); ret = clk_enable(&clk); if (ret) {