From patchwork Tue Mar 30 21:16:56 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Igor Opaniuk X-Patchwork-Id: 1460253 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org 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=) Authentication-Results: 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=OpdzAR8E; dkim-atps=neutral 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 ozlabs.org (Postfix) with ESMTPS id 4F92Mq4C2Kz9sW0 for ; Wed, 31 Mar 2021 08:17:27 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id C87E982976; Tue, 30 Mar 2021 23:17:15 +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="OpdzAR8E"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id A2B078296A; Tue, 30 Mar 2021 23:17:09 +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.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,SPF_HELO_NONE,UPPERCASE_50_75 autolearn=no autolearn_force=no version=3.4.2 Received: from mail-lj1-x22d.google.com (mail-lj1-x22d.google.com [IPv6:2a00:1450:4864:20::22d]) (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 BD7218296A for ; Tue, 30 Mar 2021 23:17:06 +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=igor.opaniuk@foundries.io Received: by mail-lj1-x22d.google.com with SMTP id u10so21471505lju.7 for ; Tue, 30 Mar 2021 14:17:06 -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=OuoCtwieSC3v+m6vmNl6fK9XJMAH3XjLpmKF5w8Mt5w=; b=OpdzAR8EQdj4NkpJd5gEJpTKEQkw2SuV874Zk9Z+66zN97VjOT9D0JPsBiG/zhZB0V MCedCKywugePFf8GPAxyHtpaA+Sw57uLohhK5GHxt8B2wfsRl4VxGLr4rDCCuD9i1twe H5J4IY8niUp/zwSZH9YlsJsSxtJzTYQX6VkhV7dGo99C53cLpnmxe98rhp2esBkZuDyj C7ql2ton94mOtyoybY0SP7h/doygUidR7Xzifnd9Z44L0bvkaBM46OlZ1AfmxOpXpXqA gk4yzst4F9UBSdXcH2Jv7TdpyjBEYLGCBJXrGNrwjPf0zkyR+obUY6OYxtreE4v+rByq s9Fw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=OuoCtwieSC3v+m6vmNl6fK9XJMAH3XjLpmKF5w8Mt5w=; b=je4mE/4sAeazG32MafJPpgjHGszHJ3nhxH27Ib+NCfivlDtetfJ6qKnU4bSWzkua1Z rBisPO5V8Etyf4QIRBthGGJQDfBvLBHf+YaHBgB6V/oHHCBApA0DpQwWVzxttC9wp80W jIGGVfqnUG1P4dLe5t+R7wVFqKbRbqhgIKkf6YHZT8ALyG01xWaPsFJUXPBk2t12tDzh +ufZWFr8BVkRVEjuSoxQmYA4Qq1J6jRTpGJQGMNBf866lpMkUVc901WJKczLtRxFC7qG XIhjso35DxVoa6xhgfcwEEy4xrJAhZa3/AmH1iHxw4TVJTVrdVrUOvxfsEaHk2WVp3oP gs4Q== X-Gm-Message-State: AOAM533UJ1Ik0LtnrekF4DXZExsuYlFa3kqp1rR1ebuOHMtDomrMv87v k8JnMTH2emcJoDfekbVU1SqBXXKs+E8d5doS X-Google-Smtp-Source: ABdhPJwNdjhCPEUT7tf81t6/3IWcO9+ZiEA3f0SwrqNcz73H3m3+f/w8yUxwHo14xA0zVJqenXnIBg== X-Received: by 2002:a2e:9dc2:: with SMTP id x2mr96101ljj.306.1617139025926; Tue, 30 Mar 2021 14:17:05 -0700 (PDT) Received: from localhost ([109.108.76.111]) by smtp.gmail.com with ESMTPSA id z28sm2918473ljm.44.2021.03.30.14.17.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Mar 2021 14:17:05 -0700 (PDT) From: Igor Opaniuk X-Google-Original-From: Igor Opaniuk To: u-boot@lists.denx.de Cc: jorge@foundries.io, mike@foundries.io, ricardo@foundries.io, vanessa.maegima@foundries.io, tim.anderson@foundries.io, daiane.angolini@foundries.io, Igor Opaniuk , Masahiro Yamada Subject: [RFC PATCH v2 1/4] psci: add v1.0/v1.1 definitions from Linux Date: Wed, 31 Mar 2021 00:16:56 +0300 Message-Id: <20210330211659.1260518-2-igor.opaniuk@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210330211659.1260518-1-igor.opaniuk@gmail.com> References: <20210330211659.1260518-1-igor.opaniuk@gmail.com> 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.102.4 at phobos.denx.de X-Virus-Status: Clean From: Igor Opaniuk Sync and add PSCI API versions 1.0/1.1 definitions from Linux. Signed-off-by: Igor Opaniuk --- (no changes since v1) include/linux/psci.h | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/include/linux/psci.h b/include/linux/psci.h index 841dbc8da7..38edde3137 100644 --- a/include/linux/psci.h +++ b/include/linux/psci.h @@ -46,6 +46,14 @@ #define PSCI_0_2_FN64_MIGRATE PSCI_0_2_FN64(5) #define PSCI_0_2_FN64_MIGRATE_INFO_UP_CPU PSCI_0_2_FN64(7) +#define PSCI_1_0_FN_PSCI_FEATURES PSCI_0_2_FN(10) +#define PSCI_1_0_FN_SYSTEM_SUSPEND PSCI_0_2_FN(14) +#define PSCI_1_0_FN_SET_SUSPEND_MODE PSCI_0_2_FN(15) +#define PSCI_1_1_FN_SYSTEM_RESET2 PSCI_0_2_FN(18) + +#define PSCI_1_0_FN64_SYSTEM_SUSPEND PSCI_0_2_FN64(14) +#define PSCI_1_1_FN64_SYSTEM_RESET2 PSCI_0_2_FN64(18) + /* PSCI v0.2 power state encoding for CPU_SUSPEND function */ #define PSCI_0_2_POWER_STATE_ID_MASK 0xffff #define PSCI_0_2_POWER_STATE_ID_SHIFT 0 @@ -56,6 +64,13 @@ #define PSCI_0_2_POWER_STATE_AFFL_MASK \ (0x3 << PSCI_0_2_POWER_STATE_AFFL_SHIFT) +/* PSCI extended power state encoding for CPU_SUSPEND function */ +#define PSCI_1_0_EXT_POWER_STATE_ID_MASK 0xfffffff +#define PSCI_1_0_EXT_POWER_STATE_ID_SHIFT 0 +#define PSCI_1_0_EXT_POWER_STATE_TYPE_SHIFT 30 +#define PSCI_1_0_EXT_POWER_STATE_TYPE_MASK \ + (0x1 << PSCI_1_0_EXT_POWER_STATE_TYPE_SHIFT) + /* PSCI v0.2 affinity level state returned by AFFINITY_INFO */ #define PSCI_0_2_AFFINITY_LEVEL_ON 0 #define PSCI_0_2_AFFINITY_LEVEL_OFF 1 @@ -75,6 +90,18 @@ (((ver) & PSCI_VERSION_MAJOR_MASK) >> PSCI_VERSION_MAJOR_SHIFT) #define PSCI_VERSION_MINOR(ver) \ ((ver) & PSCI_VERSION_MINOR_MASK) +#define PSCI_VERSION(maj, min) \ + ((((maj) << PSCI_VERSION_MAJOR_SHIFT) & PSCI_VERSION_MAJOR_MASK) | \ + ((min) & PSCI_VERSION_MINOR_MASK)) + +/* PSCI features decoding (>=1.0) */ +#define PSCI_1_0_FEATURES_CPU_SUSPEND_PF_SHIFT 1 +#define PSCI_1_0_FEATURES_CPU_SUSPEND_PF_MASK \ + (0x1 << PSCI_1_0_FEATURES_CPU_SUSPEND_PF_SHIFT) + +#define PSCI_1_0_OS_INITIATED BIT(0) +#define PSCI_1_0_SUSPEND_MODE_PC 0 +#define PSCI_1_0_SUSPEND_MODE_OSI 1 /* PSCI return values (inclusive of all PSCI versions) */ #define PSCI_RET_SUCCESS 0 @@ -86,6 +113,7 @@ #define PSCI_RET_INTERNAL_FAILURE -6 #define PSCI_RET_NOT_PRESENT -7 #define PSCI_RET_DISABLED -8 +#define PSCI_RET_INVALID_ADDRESS -9 #ifdef CONFIG_ARM_PSCI_FW unsigned long invoke_psci_fn(unsigned long a0, unsigned long a1, From patchwork Tue Mar 30 21:16:57 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Igor Opaniuk X-Patchwork-Id: 1460255 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org 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=) Authentication-Results: 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=iKUK5CW/; dkim-atps=neutral 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 ozlabs.org (Postfix) with ESMTPS id 4F92NF5rLpz9sW0 for ; Wed, 31 Mar 2021 08:17:49 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 20EEB82982; Tue, 30 Mar 2021 23:17:26 +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="iKUK5CW/"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 1B0908297E; Tue, 30 Mar 2021 23:17:15 +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.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,SPF_HELO_NONE autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-lj1-x22d.google.com (mail-lj1-x22d.google.com [IPv6:2a00:1450:4864:20::22d]) (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 78E1982957 for ; Tue, 30 Mar 2021 23:17:08 +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=igor.opaniuk@foundries.io Received: by mail-lj1-x22d.google.com with SMTP id r20so21474043ljk.4 for ; Tue, 30 Mar 2021 14:17:08 -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=H4es0HaDYNC4lLJG0TDmlSNSDyYdFdzgeha6w60YQP4=; b=iKUK5CW//x8tD2965Qx+Qw4OhudhCVK8vU8DSFb/Kgfy3AuFoDM+0P/s4rkfnU2R4t iEX/npQYzSu4+p98ket+Uq4D7217MAGyudo3nodNBBMtfav3AwNj/HEpi54AygHhx3AN toRJdmGecc+IXUcNU2pRg7Gm9KE1OrGiQViE/BoYFa0kApSRlpJhUI+nKReRbw0kiZ0a pc/Ou85auRlv3RiLiezTlDdMLOvMUuEUI9Fob8eFyxUexQCasIyZPMJJGKFj/wtN39Rh JhajhEXTL1sw6aYVXZc22r5DMML/fCvCeW9GsbvlGOc+3vgQ0m6WxLAIfuyOpCG2ZDxD OJSw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=H4es0HaDYNC4lLJG0TDmlSNSDyYdFdzgeha6w60YQP4=; b=TE1KAREQY7cBSjMATQMdwb2qoXhCNakIvsccgqdDKPq9NW10CpRr/mD8d5hFasb+bA K6PuuEmQ4PATdVAqV6d17KDKW/qE2qgPGwNgl2IThyE+jRfvU8qGR3kCAziBngxI8OBe bgQaOQaGOkl/mHlvF4QVb0APkXMaUflORcXO4m2UafXeihFLM2YtJ/iNn0MUq3m2mpnS EknJ1n3GGnHheyJmvyJlebDe4Nf0Uh/uqIhzEfRgFGk9lejrzinJ+6R9VnT/cCrrxxH4 R3dSi8e3uof7tk3FTdwJYnRXNo+cDCql6gzo3fCvZgbZB8KsHJLCCiA6ZVs7irT2cBJi e/ag== X-Gm-Message-State: AOAM533kIwNptcNLffreDLc1E1a1dq1GUEK7d0BJxlwDY5WBGYtWMEPt R84V3QlZ7iSSBkuhb0RhpJRiHh9pUH4cmsL4 X-Google-Smtp-Source: ABdhPJxmMDarPD4q99olPxkjNqczCRX6Px57aCkiheKx/GU2keMhsKejDU9Z43wFQfsOEnC4+gV1hA== X-Received: by 2002:a05:651c:149:: with SMTP id c9mr80040ljd.101.1617139027464; Tue, 30 Mar 2021 14:17:07 -0700 (PDT) Received: from localhost ([109.108.76.111]) by smtp.gmail.com with ESMTPSA id u9sm2900196ljd.130.2021.03.30.14.17.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Mar 2021 14:17:06 -0700 (PDT) From: Igor Opaniuk X-Google-Original-From: Igor Opaniuk To: u-boot@lists.denx.de Cc: jorge@foundries.io, mike@foundries.io, ricardo@foundries.io, vanessa.maegima@foundries.io, tim.anderson@foundries.io, daiane.angolini@foundries.io, Igor Opaniuk , Jon Hunter , Masahiro Yamada , Michal Simek , Patrick Delaunay , Simon Glass , Yann Gautier Subject: [RFC PATCH v2 2/4] psci: add features/reset2 support Date: Wed, 31 Mar 2021 00:16:57 +0300 Message-Id: <20210330211659.1260518-3-igor.opaniuk@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210330211659.1260518-1-igor.opaniuk@gmail.com> References: <20210330211659.1260518-1-igor.opaniuk@gmail.com> 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.102.4 at phobos.denx.de X-Virus-Status: Clean From: Igor Opaniuk Adds support for: * PSCI_FEATURES, which was introduced in PSCI 1.0. This provides API that allows discovering whether a specific PSCI function is implemented and its features. * SYSTEM_RESET2, which was introduced in PSCI 1.1, which extends existing SYSTEM_RESET. It provides support for vendor-specific resets, providing reset_type as an additional param. For additional details visit [1]. Implementations of some functions were borrowed from Linux PSCI driver code [2]. [1] https://developer.arm.com/documentation/den0022/latest/ [2] drivers/firmware/psci/psci.c Signed-off-by: Igor Opaniuk --- (no changes since v1) drivers/firmware/psci.c | 70 +++++++++++++++++++++++++++++++++++++++++ include/linux/psci.h | 3 ++ 2 files changed, 73 insertions(+) diff --git a/drivers/firmware/psci.c b/drivers/firmware/psci.c index 68953cc4f4..8416cd445f 100644 --- a/drivers/firmware/psci.c +++ b/drivers/firmware/psci.c @@ -13,6 +13,7 @@ #include #include #include +#include #include #include #include @@ -26,12 +27,26 @@ #define PSCI_METHOD_HVC 1 #define PSCI_METHOD_SMC 2 +/* + * While a 64-bit OS can make calls with SMC32 calling conventions, for some + * calls it is necessary to use SMC64 to pass or return 64-bit values. + * For such calls PSCI_FN_NATIVE(version, name) will choose the appropriate + * (native-width) function ID. + */ +#if defined(CONFIG_ARM64) +#define PSCI_FN_NATIVE(version, name) PSCI_##version##_FN64_##name +#else +#define PSCI_FN_NATIVE(version, name) PSCI_##version##_FN_##name +#endif + #if CONFIG_IS_ENABLED(EFI_LOADER) int __efi_runtime_data psci_method; #else int psci_method __attribute__ ((section(".data"))); #endif +static bool reset2_supported; + unsigned long __efi_runtime invoke_psci_fn (unsigned long function_id, unsigned long arg0, unsigned long arg1, unsigned long arg2) @@ -53,6 +68,27 @@ unsigned long __efi_runtime invoke_psci_fn return res.a0; } +static int psci_features(u32 psci_func_id) +{ + return invoke_psci_fn(PSCI_1_0_FN_PSCI_FEATURES, + psci_func_id, 0, 0); +} + +static u32 psci_0_2_get_version(void) +{ + return invoke_psci_fn(PSCI_0_2_FN_PSCI_VERSION, 0, 0, 0); +} + +static void psci_init_system_reset2(void) +{ + int ret; + + ret = psci_features(PSCI_FN_NATIVE(1_1, SYSTEM_RESET2)); + + if (ret != PSCI_RET_NOT_SUPPORTED) + reset2_supported = true; +} + static int psci_bind(struct udevice *dev) { /* No SYSTEM_RESET support for PSCI 0.1 */ @@ -73,6 +109,7 @@ static int psci_bind(struct udevice *dev) static int psci_probe(struct udevice *dev) { const char *method; + u32 ver; #if defined(CONFIG_ARM64) if (current_el() == 3) @@ -94,6 +131,16 @@ static int psci_probe(struct udevice *dev) return -EINVAL; } + ver = psci_0_2_get_version(); + + pr_debug("PSCIv%d.%d detected in firmware.\n", + PSCI_VERSION_MAJOR(ver), + PSCI_VERSION_MINOR(ver)); + + if (PSCI_VERSION_MAJOR(ver) >= 1) { + psci_init_system_reset2(); + } + return 0; } @@ -141,6 +188,29 @@ void reset_misc(void) } #endif /* CONFIG_PSCI_RESET */ +void psci_sys_reset(u32 type) +{ + do_psci_probe(); + + if (type == SYSRESET_WARM && reset2_supported) { + /* + * reset_type[31] = 0 (architectural) + * reset_type[30:0] = 0 (SYSTEM_WARM_RESET) + * cookie = 0 (ignored by the implementation) + */ + invoke_psci_fn(PSCI_FN_NATIVE(1_1, SYSTEM_RESET2), 0, 0, 0); + } else { + invoke_psci_fn(PSCI_0_2_FN_SYSTEM_RESET, 0, 0, 0); + } +} + +void psci_sys_poweroff(void) +{ + do_psci_probe(); + + invoke_psci_fn(PSCI_0_2_FN_SYSTEM_OFF, 0, 0, 0); +} + #ifdef CONFIG_CMD_POWEROFF int do_poweroff(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) { diff --git a/include/linux/psci.h b/include/linux/psci.h index 38edde3137..c78c1079a8 100644 --- a/include/linux/psci.h +++ b/include/linux/psci.h @@ -118,6 +118,9 @@ #ifdef CONFIG_ARM_PSCI_FW unsigned long invoke_psci_fn(unsigned long a0, unsigned long a1, unsigned long a2, unsigned long a3); +void psci_sys_reset(u32 type); +void psci_sys_poweroff(void); + #else static inline unsigned long invoke_psci_fn(unsigned long a0, unsigned long a1, unsigned long a2, unsigned long a3) From patchwork Tue Mar 30 21:16:58 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Igor Opaniuk X-Patchwork-Id: 1460254 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org 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=) Authentication-Results: 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=IBssHnsz; dkim-atps=neutral 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) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4F92N52567z9sW0 for ; Wed, 31 Mar 2021 08:17:41 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 9EEA982998; Tue, 30 Mar 2021 23:17:18 +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="IBssHnsz"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id CC7058297F; Tue, 30 Mar 2021 23:17:12 +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.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,SPF_HELO_NONE autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-lf1-x132.google.com (mail-lf1-x132.google.com [IPv6:2a00:1450:4864:20::132]) (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 D968E82976 for ; Tue, 30 Mar 2021 23:17:09 +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=igor.opaniuk@foundries.io Received: by mail-lf1-x132.google.com with SMTP id o126so25956782lfa.0 for ; Tue, 30 Mar 2021 14:17:09 -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=S3Ld297ola2me+ioqgwsoEvktZpoYXMQrnLZtLQFS6o=; b=IBssHnszFQ+ZqXmKIVvxqRIV1l5lfbUdfO9lGEtEmamm/jqH1qSUiF2gQwW33Oz1OA h4V4/aqoIPHYIKT55JaHr+W/uqOso2Rxh/bUtBmMHC+1ABXCHtnsW7FLMa/v+ohJdokb ks+HQ2DCkL6qhPoS9O324vGaQlOQ1L0g3iZhBCayQjI9focxz3565GV8XfBBWUOWFQzJ +mvtzs1gp9f+GTUgyCNwEoyNPXbqhlkqF9V0Su64crf8fzJEnmzpnwKfxynZWKQkHjBn JUWZDONOqusuigYOKEAEYYrOg9tnEGAPkNZ9u2IS8bbujLhzEYj/aQCfMPSLZouHpRQv vATg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=S3Ld297ola2me+ioqgwsoEvktZpoYXMQrnLZtLQFS6o=; b=REx6HtVOABDNWh4uILuQ0xpPoBLIOqusXwaDRiFTWzBjznTJdbQUmQ9Gal+JiCQiIW Yej/ZM+U0KsGFYorvmBQ2aeLRlIW5yK7znl3uq4nFI0CG8ckNoX71T/TKs1i8qlYWoS7 i/idOdpAEhjodFtgA4IJRykLwpPytOd4MF2yr1pUCOJ0OEmRRU3Qi3PSVgE+0VzDTtr3 X48bOv1+xdsBJTjPPrnTxBbECmab3wp1PEb1KD4AZh94GpkL8CJyvb7Ry8hphIBjyZP/ acrDtWJIq6EBQ2gbZBKQd6PbiAGdVXC6BP5FXQmbCYMwrB5XFcYXQ3juhkDG4xeNkBUq dTyQ== X-Gm-Message-State: AOAM5334xe8p3RICFLeS1dQ0CFqd6uhUvvylbe5u24HQTmhDOevwthaq xj2B5UF9U5kKeTn7F5og8GNYqY4But09pHpU X-Google-Smtp-Source: ABdhPJw3jFpnZZSdoSExU+gNsnRuWsuK/+B/WkfsKv/xALftruejHsKVAWGIKGQ7UmliQTAx7x0/3Q== X-Received: by 2002:a19:2402:: with SMTP id k2mr77493lfk.138.1617139029030; Tue, 30 Mar 2021 14:17:09 -0700 (PDT) Received: from localhost ([109.108.76.111]) by smtp.gmail.com with ESMTPSA id t26sm2908864ljg.12.2021.03.30.14.17.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Mar 2021 14:17:08 -0700 (PDT) From: Igor Opaniuk X-Google-Original-From: Igor Opaniuk To: u-boot@lists.denx.de Cc: jorge@foundries.io, mike@foundries.io, ricardo@foundries.io, vanessa.maegima@foundries.io, tim.anderson@foundries.io, daiane.angolini@foundries.io, Igor Opaniuk Subject: [RFC PATCH v2 3/4] sysreset: psci: use psci driver exported functions Date: Wed, 31 Mar 2021 00:16:58 +0300 Message-Id: <20210330211659.1260518-4-igor.opaniuk@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210330211659.1260518-1-igor.opaniuk@gmail.com> References: <20210330211659.1260518-1-igor.opaniuk@gmail.com> 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.102.4 at phobos.denx.de X-Virus-Status: Clean From: Igor Opaniuk Use psci driver exported functions for reset/poweroff, instead of invoking directly invoke_psci_fn. Signed-off-by: Igor Opaniuk --- (no changes since v1) drivers/sysreset/sysreset_psci.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/drivers/sysreset/sysreset_psci.c b/drivers/sysreset/sysreset_psci.c index c7907b3226..83ecbcb9d2 100644 --- a/drivers/sysreset/sysreset_psci.c +++ b/drivers/sysreset/sysreset_psci.c @@ -11,22 +11,18 @@ static int psci_sysreset_request(struct udevice *dev, enum sysreset_t type) { - unsigned long function_id; - switch (type) { case SYSRESET_WARM: case SYSRESET_COLD: - function_id = PSCI_0_2_FN_SYSTEM_RESET; + psci_sys_reset(type); break; case SYSRESET_POWER_OFF: - function_id = PSCI_0_2_FN_SYSTEM_OFF; + psci_sys_poweroff(); break; default: return -ENOSYS; } - invoke_psci_fn(function_id, 0, 0, 0); - return -EINPROGRESS; } From patchwork Tue Mar 30 21:16:59 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Igor Opaniuk X-Patchwork-Id: 1460256 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org 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=) Authentication-Results: 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=BGqk05GR; dkim-atps=neutral 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 ozlabs.org (Postfix) with ESMTPS id 4F92NS5HYgz9sW0 for ; Wed, 31 Mar 2021 08:18:00 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id CFC33829B6; Tue, 30 Mar 2021 23:17:27 +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="BGqk05GR"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id CE17382982; Tue, 30 Mar 2021 23:17:15 +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.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,SPF_HELO_NONE autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-lf1-x130.google.com (mail-lf1-x130.google.com [IPv6:2a00:1450:4864:20::130]) (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 715568297B for ; Tue, 30 Mar 2021 23:17:11 +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=igor.opaniuk@foundries.io Received: by mail-lf1-x130.google.com with SMTP id v15so25900973lfq.5 for ; Tue, 30 Mar 2021 14:17:11 -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=JZKsnhyxglyqD9HExqjQu83iOFNgjO+rOKWE2i10oM0=; b=BGqk05GRqCinKG9rlK2s2bN4Snn/EFSJhy9IYDItCT4h74JJAhpybih5LhlgWKte0Z eThcbTdaojT3EfRNjZFhdrK5qT0IXsXLuPpr/rlAcdjeqjX8236hvMA2sHM2cFPdtgt0 WY1V+a/sNBiBoYrts3/EtTrKXssQ3mPjiffQXpklCgcw1u+zXsaCQEqPHv+9h+qS5lKu l9kHMoHZPO8qOAECe+ZvaDSOjcMg4yLQXy3RhAJgxZta5X/9syuKD4HXGfQZbT5f++W1 29Eyec/9HjJDheFTi4skOlhPlHpGkX446i2cvjbwWHiMTRXuFC4AzsAE3v62n9NddI+x /KrQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=JZKsnhyxglyqD9HExqjQu83iOFNgjO+rOKWE2i10oM0=; b=eWZrBueMVcwQP7aAJu7fftT4bZ0D677f8Vuw58xOpwrTbNSx8C9jmAwCSJ/dvwQ2LW zkb4ZrQdFXd4XbPOXGZ3x/DDYBMl+OayUxgb9p2rxQwjDDP5vL7fsY62/zqRuJI7of8T sJkmPimRrSVewkf7MK9EC8d3rlnXEtBNYBnHF07bGWcJiZRWnYHZ7kcYrrmIIGO+OSAN mW70lTbb+F66XfBOkfHtT5+myi1pcDT1AkuoG8XY17iLW/AWzPnuwNC85FKvkLUOdkgH CALXs4tE0eBIgFJsgZroeOw6alDOqWc7fCCFL2cewx2KxD6fHV2JH5I9CaVQW3XPdrKT HaFQ== X-Gm-Message-State: AOAM532pu/setElEoBsuUxVFS9OSSmpLKteAd3CxwZRf+5O51M0XWsPs snHLNYviPEIfk32E+nJJrzL5aVN+oZ7gKL8G X-Google-Smtp-Source: ABdhPJyKnaXL3NAi3fPFoHgv9hp2UqAF9MZmGMOxOlRKivjtQQtzn0MMCMtacyF/lfFLw+WFHf7rYg== X-Received: by 2002:a05:6512:6cd:: with SMTP id u13mr65335lff.326.1617139030613; Tue, 30 Mar 2021 14:17:10 -0700 (PDT) Received: from localhost ([109.108.76.111]) by smtp.gmail.com with ESMTPSA id y13sm231677ljn.94.2021.03.30.14.17.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Mar 2021 14:17:10 -0700 (PDT) From: Igor Opaniuk X-Google-Original-From: Igor Opaniuk To: u-boot@lists.denx.de Cc: jorge@foundries.io, mike@foundries.io, ricardo@foundries.io, vanessa.maegima@foundries.io, tim.anderson@foundries.io, daiane.angolini@foundries.io, Igor Opaniuk , Bin Meng , Heinrich Schuchardt , Priyanka Jain , Simon Glass Subject: [RFC PATCH v2 4/4] sysreset: provide type of reset in do_reset cmd Date: Wed, 31 Mar 2021 00:16:59 +0300 Message-Id: <20210330211659.1260518-5-igor.opaniuk@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210330211659.1260518-1-igor.opaniuk@gmail.com> References: <20210330211659.1260518-1-igor.opaniuk@gmail.com> 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.102.4 at phobos.denx.de X-Virus-Status: Clean From: Igor Opaniuk Add additional param for reset cmd, which provides type of reset. Signed-off-by: Igor Opaniuk --- cmd/boot.c | 6 +++++- drivers/sysreset/sysreset-uclass.c | 23 ++++++++++++++++++++++- 2 files changed, 27 insertions(+), 2 deletions(-) diff --git a/cmd/boot.c b/cmd/boot.c index 36aba22b30..f27277dacf 100644 --- a/cmd/boot.c +++ b/cmd/boot.c @@ -56,8 +56,12 @@ U_BOOT_CMD( #endif U_BOOT_CMD( - reset, 1, 0, do_reset, + reset, 2, 0, do_reset, "Perform RESET of the CPU", + "[0|1]\n" + " no param - cold reset [default]\n" + " 0 - cold reset\n" + " 1 - warm reset\n" "" ); diff --git a/drivers/sysreset/sysreset-uclass.c b/drivers/sysreset/sysreset-uclass.c index 6c9dc7a384..65342d8832 100644 --- a/drivers/sysreset/sysreset-uclass.c +++ b/drivers/sysreset/sysreset-uclass.c @@ -122,10 +122,31 @@ void reset_cpu(ulong addr) #if IS_ENABLED(CONFIG_SYSRESET_CMD_RESET) int do_reset(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) { + u32 param; + enum sysreset_t reset_type = SYSRESET_COLD; + + if (argc > 2) + return CMD_RET_USAGE; + + if (argc == 2) { + param = simple_strtoul(argv[1], NULL, 16); + + switch (param) { + case 0: + reset_type = SYSRESET_COLD; + break; + case 1: + reset_type = SYSRESET_WARM; + break; + default: + return CMD_RET_USAGE; + } + } + printf("resetting ...\n"); mdelay(100); - sysreset_walk_halt(SYSRESET_COLD); + sysreset_walk_halt(reset_type); return 0; }