soc: apple: rtkit: Add apple_rtkit_idle() function
authorHector Martin <marcan@marcan.st>
Mon, 23 Jan 2023 06:53:54 +0000 (15:53 +0900)
committerHector Martin <marcan@marcan.st>
Tue, 31 Jan 2023 11:35:47 +0000 (20:35 +0900)
This is yet another low power mode, used by DCP.

Reviewed-by: Eric Curtin <ecurtin@redhat.com>
Reviewed-by: Sven Peter <sven@svenpeter.dev>
Signed-off-by: Hector Martin <marcan@marcan.st>
drivers/soc/apple/rtkit.c
include/linux/soc/apple/rtkit.h

index 8ec74d7539eb4fd57ce9f84642d8fc5dbf474cf0..efb1fa77dff2fa728a0cf13a7f2e147614dab1dc 100644 (file)
@@ -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 */
 };
@@ -881,6 +882,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;
index c9cabb679cd1119c376d80be11f5ca9e3a63d054..a2446b45ed7f85d7363e1d9df606284935856dcc 100644 (file)
@@ -104,6 +104,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.
  */