Skip to contentSkip to conversation

soc: apple: rtkit: Add apple_rtkit_idle() function

PATCH In review Hector Martin 3 participants 4 messages Jan 23, 2023 – Jan 31, 2023 Arm/Apple machine support

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 soc: apple: rtkit: Add apple_rtkit_idle() function

This is yet another low power mode, used by DCP.

---
 drivers/soc/apple/rtkit.c       | 21 +++++++++++++++++++++
 include/linux/soc/apple/rtkit.h |  5 +++++
 2 files changed, 26 insertions(+)
drivers/soc/apple/rtkit.c +21 -0
index ceb4516e442c..509b050cf040 100644
@@ -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;
include/linux/soc/apple/rtkit.h +5 -0
index 2a0edb5fa6fe..f8d9cc0691de 100644
@@ -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.
  */
Signature · 1 line
2.35.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 5 lines · Hector Martin

This is yet another low power mode, used by DCP.

---

New power state, nice

Is mise le meas/Regards,

Eric Curtin

Quoted 63 lines
 drivers/soc/apple/rtkit.c       | 21 +++++++++++++++++++++
 include/linux/soc/apple/rtkit.h |  5 +++++
 2 files changed, 26 insertions(+)
drivers/soc/apple/rtkit.c +21 -0
index ceb4516e442c..509b050cf040 100644
@@ -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;
include/linux/soc/apple/rtkit.h +5 -1
index 2a0edb5fa6fe..f8d9cc0691de 100644
@@ -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.
  */
--

2.35.1