|
@@ -820,3 +820,145 @@ int pwrdm_read_mem_retst(struct powerdomain *pwrdm, u8 bank)
|
|
return ret;
|
|
return ret;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+/**
|
|
|
|
+ * pwrdm_clear_all_prev_pwrst - clear previous powerstate register for a pwrdm
|
|
|
|
+ * @pwrdm: struct powerdomain * to clear
|
|
|
|
+ *
|
|
|
|
+ * Clear the powerdomain's previous power state register @pwrdm.
|
|
|
|
+ * Clears the entire register, including logic and memory bank
|
|
|
|
+ * previous power states. Returns -EINVAL if the powerdomain pointer
|
|
|
|
+ * is null, or returns 0 upon success.
|
|
|
|
+ */
|
|
|
|
+int pwrdm_clear_all_prev_pwrst(struct powerdomain *pwrdm)
|
|
|
|
+{
|
|
|
|
+ int ret = -EINVAL;
|
|
|
|
+
|
|
|
|
+ if (!pwrdm)
|
|
|
|
+ return ret;
|
|
|
|
+
|
|
|
|
+ /*
|
|
|
|
+ * XXX should get the powerdomain's current state here;
|
|
|
|
+ * warn & fail if it is not ON.
|
|
|
|
+ */
|
|
|
|
+
|
|
|
|
+ pr_debug("powerdomain: %s: clearing previous power state reg\n",
|
|
|
|
+ pwrdm->name);
|
|
|
|
+
|
|
|
|
+ if (arch_pwrdm && arch_pwrdm->pwrdm_clear_all_prev_pwrst)
|
|
|
|
+ ret = arch_pwrdm->pwrdm_clear_all_prev_pwrst(pwrdm);
|
|
|
|
+
|
|
|
|
+ return ret;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+/**
|
|
|
|
+ * pwrdm_enable_hdwr_sar - enable automatic hardware SAR for a pwrdm
|
|
|
|
+ * @pwrdm: struct powerdomain *
|
|
|
|
+ *
|
|
|
|
+ * Enable automatic context save-and-restore upon power state change
|
|
|
|
+ * for some devices in the powerdomain @pwrdm. Warning: this only
|
|
|
|
+ * affects a subset of devices in a powerdomain; check the TRM
|
|
|
|
+ * closely. Returns -EINVAL if the powerdomain pointer is null or if
|
|
|
|
+ * the powerdomain does not support automatic save-and-restore, or
|
|
|
|
+ * returns 0 upon success.
|
|
|
|
+ */
|
|
|
|
+int pwrdm_enable_hdwr_sar(struct powerdomain *pwrdm)
|
|
|
|
+{
|
|
|
|
+ int ret = -EINVAL;
|
|
|
|
+
|
|
|
|
+ if (!pwrdm)
|
|
|
|
+ return ret;
|
|
|
|
+
|
|
|
|
+ if (!(pwrdm->flags & PWRDM_HAS_HDWR_SAR))
|
|
|
|
+ return ret;
|
|
|
|
+
|
|
|
|
+ pr_debug("powerdomain: %s: setting SAVEANDRESTORE bit\n", pwrdm->name);
|
|
|
|
+
|
|
|
|
+ if (arch_pwrdm && arch_pwrdm->pwrdm_enable_hdwr_sar)
|
|
|
|
+ ret = arch_pwrdm->pwrdm_enable_hdwr_sar(pwrdm);
|
|
|
|
+
|
|
|
|
+ return ret;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+/**
|
|
|
|
+ * pwrdm_disable_hdwr_sar - disable automatic hardware SAR for a pwrdm
|
|
|
|
+ * @pwrdm: struct powerdomain *
|
|
|
|
+ *
|
|
|
|
+ * Disable automatic context save-and-restore upon power state change
|
|
|
|
+ * for some devices in the powerdomain @pwrdm. Warning: this only
|
|
|
|
+ * affects a subset of devices in a powerdomain; check the TRM
|
|
|
|
+ * closely. Returns -EINVAL if the powerdomain pointer is null or if
|
|
|
|
+ * the powerdomain does not support automatic save-and-restore, or
|
|
|
|
+ * returns 0 upon success.
|
|
|
|
+ */
|
|
|
|
+int pwrdm_disable_hdwr_sar(struct powerdomain *pwrdm)
|
|
|
|
+{
|
|
|
|
+ int ret = -EINVAL;
|
|
|
|
+
|
|
|
|
+ if (!pwrdm)
|
|
|
|
+ return ret;
|
|
|
|
+
|
|
|
|
+ if (!(pwrdm->flags & PWRDM_HAS_HDWR_SAR))
|
|
|
|
+ return ret;
|
|
|
|
+
|
|
|
|
+ pr_debug("powerdomain: %s: clearing SAVEANDRESTORE bit\n", pwrdm->name);
|
|
|
|
+
|
|
|
|
+ if (arch_pwrdm && arch_pwrdm->pwrdm_disable_hdwr_sar)
|
|
|
|
+ ret = arch_pwrdm->pwrdm_disable_hdwr_sar(pwrdm);
|
|
|
|
+
|
|
|
|
+ return ret;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+/**
|
|
|
|
+ * pwrdm_has_hdwr_sar - test whether powerdomain supports hardware SAR
|
|
|
|
+ * @pwrdm: struct powerdomain *
|
|
|
|
+ *
|
|
|
|
+ * Returns 1 if powerdomain @pwrdm supports hardware save-and-restore
|
|
|
|
+ * for some devices, or 0 if it does not.
|
|
|
|
+ */
|
|
|
|
+bool pwrdm_has_hdwr_sar(struct powerdomain *pwrdm)
|
|
|
|
+{
|
|
|
|
+ return (pwrdm && pwrdm->flags & PWRDM_HAS_HDWR_SAR) ? 1 : 0;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+/**
|
|
|
|
+ * pwrdm_set_lowpwrstchange - Request a low power state change
|
|
|
|
+ * @pwrdm: struct powerdomain *
|
|
|
|
+ *
|
|
|
|
+ * Allows a powerdomain to transtion to a lower power sleep state
|
|
|
|
+ * from an existing sleep state without waking up the powerdomain.
|
|
|
|
+ * Returns -EINVAL if the powerdomain pointer is null or if the
|
|
|
|
+ * powerdomain does not support LOWPOWERSTATECHANGE, or returns 0
|
|
|
|
+ * upon success.
|
|
|
|
+ */
|
|
|
|
+int pwrdm_set_lowpwrstchange(struct powerdomain *pwrdm)
|
|
|
|
+{
|
|
|
|
+ int ret = -EINVAL;
|
|
|
|
+
|
|
|
|
+ if (!pwrdm)
|
|
|
|
+ return -EINVAL;
|
|
|
|
+
|
|
|
|
+ if (!(pwrdm->flags & PWRDM_HAS_LOWPOWERSTATECHANGE))
|
|
|
|
+ return -EINVAL;
|
|
|
|
+
|
|
|
|
+ pr_debug("powerdomain: %s: setting LOWPOWERSTATECHANGE bit\n",
|
|
|
|
+ pwrdm->name);
|
|
|
|
+
|
|
|
|
+ if (arch_pwrdm && arch_pwrdm->pwrdm_set_lowpwrstchange)
|
|
|
|
+ ret = arch_pwrdm->pwrdm_set_lowpwrstchange(pwrdm);
|
|
|
|
+
|
|
|
|
+ return ret;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+/**
|
|
|
|
+ * pwrdm_wait_transition - wait for powerdomain power transition to finish
|
|
|
|
+ * @pwrdm: struct powerdomain * to wait for
|
|
|
|
+ *
|
|
|
|
+ * If the powerdomain @pwrdm is in the process of a state transition,
|
|
|
|
+ * spin until it completes the power transition, or until an iteration
|
|
|
|
+ * bailout value is reached. Returns -EINVAL if the powerdomain
|
|
|
|
+ * pointer is null, -EAGAIN if the bailout value was reached, or
|
|
|
|
+ * returns 0 upon success.
|
|
|
|
+ */
|
|
|
|
+int pwrdm_wait_transition(struct powerdomain *pwrdm)
|
|
|
|
+{
|
|
|
|
+ int ret = -EINVAL;
|