From patchwork Mon Jan 23 06:53:54 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hector Martin X-Patchwork-Id: 13111698 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id CF4F0C38142 for ; Mon, 23 Jan 2023 06:55:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject:Cc :To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=jor+1V58KDlUPK2roGELtlIP/8GPHA6bMmKQIcwLBHE=; b=gOJsGy+yzIsowE kaEKKnYzdV2yKw7JzNm5FAHsFJlfta4zD/d2tjZAeay+8dtgYAyzZEv9iCa5tlihTorS3UGamHL+y T9ffw8NR4VzGmvEVl5pc1gftnkG7gfIMJTwq70WtkVy2gApaA2GWIAnmOQoNJoGdewOZJ86bGHPiz yHTOahfYj65DVpP0qfWxaXNtrknkhW5boAP/lhE0KwolW49Lh4bTDcgXY1wyiFbb3zR3nNooHrYPR bqGMfnMEta986NdraCf5W6nE4mbmRc4nRTBdw9T75ZJ7F8aW2wyWEUgF58NhkzgCBF2Ty5GEvtio0 MtLWlllMXXHDHoj/0zbQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pJqio-00G7ZB-04; Mon, 23 Jan 2023 06:54:26 +0000 Received: from marcansoft.com ([212.63.210.85] helo=mail.marcansoft.com) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1pJqik-00G7YW-2P for linux-arm-kernel@lists.infradead.org; Mon, 23 Jan 2023 06:54:23 +0000 Received: from [127.0.0.1] (localhost [127.0.0.1]) (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) (Authenticated sender: sendonly@marcansoft.com) by mail.marcansoft.com (Postfix) with ESMTPSA id 3EFB1424EC; Mon, 23 Jan 2023 06:54:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=marcan.st; s=default; t=1674456860; bh=3ATZOYbwia5bXZiTe4S5ArLfc1jiIEHgvpFPv0DhVeI=; h=From:To:Cc:Subject:Date; b=npXBRqiUm+EM+RWevPNma/xz+UbtBNb9c48qZoNCGt0CFRsTTtg1Mpuqo9LNJOrKM vcp7qQK5bC9v/yJqcwB7wOgOQwvBzhdDELhGuYRhBFhrrMBwuVd0X+QaTeWj86rhpF Vd1Sq3LUAayez0qO59P+A3bwJVbfr5f1YBuV8XCYTIeUuaZTObU2EIusG06c99lnCY kQNeSZrp+CMY3hJjeSXKHVS4ft2rnJO9jwL9XIUNqvOr2zgxGsZAxlM/ReU6fSRwrE rBPJJMckQh2K/IdpXgUKdPSveh1bLBr1EitCbfS3omgH9dEZQNP4AdXM0OYcRpHicV mhInNYynK515g== From: Hector Martin To: Sven Peter Cc: Alyssa Rosenzweig , Janne Grunau , asahi@lists.linux.dev, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Hector Martin Subject: [PATCH] soc: apple: rtkit: Add apple_rtkit_idle() function Date: Mon, 23 Jan 2023 15:53:54 +0900 Message-Id: <20230123065354.28179-1-marcan@marcan.st> X-Mailer: git-send-email 2.35.1 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230122_225422_295301_8CD0FDF7 X-CRM114-Status: GOOD ( 10.94 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org This is yet another low power mode, used by DCP. Signed-off-by: Hector Martin Reviewed-by: Eric Curtin Reviewed-by: Sven Peter --- drivers/soc/apple/rtkit.c | 21 +++++++++++++++++++++ include/linux/soc/apple/rtkit.h | 5 +++++ 2 files changed, 26 insertions(+) diff --git a/drivers/soc/apple/rtkit.c b/drivers/soc/apple/rtkit.c index ceb4516e442c..509b050cf040 100644 --- a/drivers/soc/apple/rtkit.c +++ b/drivers/soc/apple/rtkit.c @@ -9,6 +9,7 @@ enum { APPLE_RTKIT_PWR_STATE_OFF = 0x00, /* power off, cannot be restarted */ APPLE_RTKIT_PWR_STATE_SLEEP = 0x01, /* sleeping, can be restarted */ + APPLE_RTKIT_PWR_STATE_IDLE = 0x201, /* sleeping, retain state */ APPLE_RTKIT_PWR_STATE_QUIESCED = 0x10, /* running but no communication */ APPLE_RTKIT_PWR_STATE_ON = 0x20, /* normal operating state */ }; @@ -882,6 +883,26 @@ int apple_rtkit_shutdown(struct apple_rtkit *rtk) } EXPORT_SYMBOL_GPL(apple_rtkit_shutdown); +int apple_rtkit_idle(struct apple_rtkit *rtk) +{ + int ret; + + /* if OFF is used here the co-processor will not wake up again */ + ret = apple_rtkit_set_ap_power_state(rtk, + APPLE_RTKIT_PWR_STATE_IDLE); + if (ret) + return ret; + + ret = apple_rtkit_set_iop_power_state(rtk, APPLE_RTKIT_PWR_STATE_IDLE); + if (ret) + return ret; + + rtk->iop_power_state = APPLE_RTKIT_PWR_STATE_IDLE; + rtk->ap_power_state = APPLE_RTKIT_PWR_STATE_IDLE; + return 0; +} +EXPORT_SYMBOL_GPL(apple_rtkit_idle); + int apple_rtkit_quiesce(struct apple_rtkit *rtk) { int ret; diff --git a/include/linux/soc/apple/rtkit.h b/include/linux/soc/apple/rtkit.h index 2a0edb5fa6fe..f8d9cc0691de 100644 --- a/include/linux/soc/apple/rtkit.h +++ b/include/linux/soc/apple/rtkit.h @@ -132,6 +132,11 @@ int apple_rtkit_wake(struct apple_rtkit *rtk); */ int apple_rtkit_shutdown(struct apple_rtkit *rtk); +/* + * Put the co-processor into idle mode + */ +int apple_rtkit_idle(struct apple_rtkit *rtk); + /* * Checks if RTKit is running and ready to handle messages. */