dai: intel: hda: Add power management

This patch addresses the following issues with the Intel HDA DAI driver:

1. Adds power management support for the HDA DAI driver by implementing
   the `hda_pm_action` function and integrating it with the Zephyr power
   management framework.
2. Ensures balanced calls to `pm_device_runtime_get` and
   `pm_device_runtime_put` by modifying the `probe` and `remove`
   functions to use these power management calls.
3. Ensures that the io0 power domain is active when the HD Audio is in
   use by assigning the correct power domain to the HDA DAI devices in
   the device tree files for various Intel ADSP platforms (ace15_mtpm,
   ace20_lnl, ace30, ace30_ptl).
4. Enables runtime power management for the HDA DAI devices by adding
   the `zephyr,pm-device-runtime-auto` property in the device tree.

These changes ensure that the HDA DAI driver properly manages power
states, reducing power consumption and improving system stability, while
ensuring the io0 power domain is active when required.

Signed-off-by: Tomasz Leman <tomasz.m.leman@intel.com>
This commit is contained in:
Tomasz Leman 2024-11-26 16:26:07 +01:00 committed by Benjamin Cabé
commit fd4a4bf702
5 changed files with 188 additions and 4 deletions

View file

@ -8,7 +8,10 @@
#include <stdbool.h>
#include <stdint.h>
#include <zephyr/spinlock.h>
#include <zephyr/device.h>
#include <zephyr/devicetree.h>
#include <zephyr/pm/device.h>
#include <zephyr/pm/device_runtime.h>
#include <zephyr/logging/log.h>
#define DT_DRV_COMPAT intel_hda_dai
@ -103,9 +106,35 @@ static int dai_hda_remove(const struct device *dev)
return 0;
}
static int hda_pm_action(const struct device *dev, enum pm_device_action action)
{
switch (action) {
case PM_DEVICE_ACTION_SUSPEND:
dai_hda_remove(dev);
break;
case PM_DEVICE_ACTION_RESUME:
dai_hda_probe(dev);
break;
case PM_DEVICE_ACTION_TURN_OFF:
case PM_DEVICE_ACTION_TURN_ON:
/* All device pm is handled during resume and suspend */
break;
default:
return -ENOTSUP;
}
return 0;
}
static int hda_init(const struct device *dev)
{
LOG_DBG("%s", __func__);
return pm_device_driver_init(dev, hda_pm_action);
}
static DEVICE_API(dai, dai_intel_hda_api_funcs) = {
.probe = dai_hda_probe,
.remove = dai_hda_remove,
.probe = pm_device_runtime_get,
.remove = pm_device_runtime_put,
.config_set = dai_hda_config_set,
.config_get = dai_hda_config_get,
.trigger = dai_hda_trigger,
@ -122,11 +151,14 @@ static DEVICE_API(dai, dai_intel_hda_api_funcs) = {
\
}; \
\
PM_DEVICE_DT_INST_DEFINE(n, hda_pm_action); \
\
DEVICE_DT_INST_DEFINE(n, \
NULL, NULL, \
hda_init, PM_DEVICE_DT_INST_GET(n), \
&dai_intel_hda_data_##n, \
&dai_intel_hda_config_##n, \
POST_KERNEL, 32, \
POST_KERNEL, \
CONFIG_DAI_INIT_PRIORITY, \
&dai_intel_hda_api_funcs);
DT_INST_FOREACH_STATUS_OKAY(DAI_INTEL_HDA_DEVICE_INIT)

View file

@ -612,96 +612,134 @@
hda0: hda@0 {
compatible = "intel,hda-dai";
power-domains = <&io0_domain>;
zephyr,pm-device-runtime-auto;
status = "okay";
reg = <0>;
};
hda1: hda@1 {
compatible = "intel,hda-dai";
power-domains = <&io0_domain>;
zephyr,pm-device-runtime-auto;
status = "okay";
reg = <1>;
};
hda2: hda@2 {
compatible = "intel,hda-dai";
power-domains = <&io0_domain>;
zephyr,pm-device-runtime-auto;
status = "okay";
reg = <2>;
};
hda3: hda@3 {
compatible = "intel,hda-dai";
power-domains = <&io0_domain>;
zephyr,pm-device-runtime-auto;
status = "okay";
reg = <3>;
};
hda4: hda@4 {
compatible = "intel,hda-dai";
power-domains = <&io0_domain>;
zephyr,pm-device-runtime-auto;
status = "okay";
reg = <4>;
};
hda5: hda@5 {
compatible = "intel,hda-dai";
power-domains = <&io0_domain>;
zephyr,pm-device-runtime-auto;
status = "okay";
reg = <5>;
};
hda6: hda@6 {
compatible = "intel,hda-dai";
power-domains = <&io0_domain>;
zephyr,pm-device-runtime-auto;
status = "okay";
reg = <6>;
};
hda7: hda@7 {
compatible = "intel,hda-dai";
power-domains = <&io0_domain>;
zephyr,pm-device-runtime-auto;
status = "okay";
reg = <7>;
};
hda8: hda@8 {
compatible = "intel,hda-dai";
power-domains = <&io0_domain>;
zephyr,pm-device-runtime-auto;
status = "okay";
reg = <8>;
};
hda9: hda@9 {
compatible = "intel,hda-dai";
power-domains = <&io0_domain>;
zephyr,pm-device-runtime-auto;
status = "okay";
reg = <9>;
};
hda10: hda@a {
compatible = "intel,hda-dai";
power-domains = <&io0_domain>;
zephyr,pm-device-runtime-auto;
status = "okay";
reg = <0x0a>;
};
hda11: hda@b {
compatible = "intel,hda-dai";
power-domains = <&io0_domain>;
zephyr,pm-device-runtime-auto;
status = "okay";
reg = <0x0b>;
};
hda12: hda@c {
compatible = "intel,hda-dai";
power-domains = <&io0_domain>;
zephyr,pm-device-runtime-auto;
status = "okay";
reg = <0x0c>;
};
hda13: hda@d {
compatible = "intel,hda-dai";
power-domains = <&io0_domain>;
zephyr,pm-device-runtime-auto;
status = "okay";
reg = <0x0d>;
};
hda14: hda@e {
compatible = "intel,hda-dai";
power-domains = <&io0_domain>;
zephyr,pm-device-runtime-auto;
status = "okay";
reg = <0x0e>;
};
hda15: hda@f {
compatible = "intel,hda-dai";
power-domains = <&io0_domain>;
zephyr,pm-device-runtime-auto;
status = "okay";
reg = <0x0f>;
};
hda16: hda@10 {
compatible = "intel,hda-dai";
power-domains = <&io0_domain>;
zephyr,pm-device-runtime-auto;
status = "okay";
reg = <0x10>;
};
hda17: hda@11 {
compatible = "intel,hda-dai";
power-domains = <&io0_domain>;
zephyr,pm-device-runtime-auto;
status = "okay";
reg = <0x11>;
};
hda18: hda@12 {
compatible = "intel,hda-dai";
power-domains = <&io0_domain>;
zephyr,pm-device-runtime-auto;
status = "okay";
reg = <0x12>;
};

View file

@ -466,96 +466,134 @@
hda0: hda@0 {
compatible = "intel,hda-dai";
power-domains = <&io0_domain>;
zephyr,pm-device-runtime-auto;
status = "okay";
reg = <0>;
};
hda1: hda@1 {
compatible = "intel,hda-dai";
power-domains = <&io0_domain>;
zephyr,pm-device-runtime-auto;
status = "okay";
reg = <1>;
};
hda2: hda@2 {
compatible = "intel,hda-dai";
power-domains = <&io0_domain>;
zephyr,pm-device-runtime-auto;
status = "okay";
reg = <2>;
};
hda3: hda@3 {
compatible = "intel,hda-dai";
power-domains = <&io0_domain>;
zephyr,pm-device-runtime-auto;
status = "okay";
reg = <3>;
};
hda4: hda@4 {
compatible = "intel,hda-dai";
power-domains = <&io0_domain>;
zephyr,pm-device-runtime-auto;
status = "okay";
reg = <4>;
};
hda5: hda@5 {
compatible = "intel,hda-dai";
power-domains = <&io0_domain>;
zephyr,pm-device-runtime-auto;
status = "okay";
reg = <5>;
};
hda6: hda@6 {
compatible = "intel,hda-dai";
power-domains = <&io0_domain>;
zephyr,pm-device-runtime-auto;
status = "okay";
reg = <6>;
};
hda7: hda@7 {
compatible = "intel,hda-dai";
power-domains = <&io0_domain>;
zephyr,pm-device-runtime-auto;
status = "okay";
reg = <7>;
};
hda8: hda@8 {
compatible = "intel,hda-dai";
power-domains = <&io0_domain>;
zephyr,pm-device-runtime-auto;
status = "okay";
reg = <8>;
};
hda9: hda@9 {
compatible = "intel,hda-dai";
power-domains = <&io0_domain>;
zephyr,pm-device-runtime-auto;
status = "okay";
reg = <9>;
};
hda10: hda@a {
compatible = "intel,hda-dai";
power-domains = <&io0_domain>;
zephyr,pm-device-runtime-auto;
status = "okay";
reg = <0x0a>;
};
hda11: hda@b {
compatible = "intel,hda-dai";
power-domains = <&io0_domain>;
zephyr,pm-device-runtime-auto;
status = "okay";
reg = <0x0b>;
};
hda12: hda@c {
compatible = "intel,hda-dai";
power-domains = <&io0_domain>;
zephyr,pm-device-runtime-auto;
status = "okay";
reg = <0x0c>;
};
hda13: hda@d {
compatible = "intel,hda-dai";
power-domains = <&io0_domain>;
zephyr,pm-device-runtime-auto;
status = "okay";
reg = <0x0d>;
};
hda14: hda@e {
compatible = "intel,hda-dai";
power-domains = <&io0_domain>;
zephyr,pm-device-runtime-auto;
status = "okay";
reg = <0x0e>;
};
hda15: hda@f {
compatible = "intel,hda-dai";
power-domains = <&io0_domain>;
zephyr,pm-device-runtime-auto;
status = "okay";
reg = <0x0f>;
};
hda16: hda@10 {
compatible = "intel,hda-dai";
power-domains = <&io0_domain>;
zephyr,pm-device-runtime-auto;
status = "okay";
reg = <0x10>;
};
hda17: hda@11 {
compatible = "intel,hda-dai";
power-domains = <&io0_domain>;
zephyr,pm-device-runtime-auto;
status = "okay";
reg = <0x11>;
};
hda18: hda@12 {
compatible = "intel,hda-dai";
power-domains = <&io0_domain>;
zephyr,pm-device-runtime-auto;
status = "okay";
reg = <0x12>;
};

View file

@ -591,96 +591,134 @@
hda0: hda@0 {
compatible = "intel,hda-dai";
power-domains = <&io0_domain>;
zephyr,pm-device-runtime-auto;
status = "okay";
reg = <0>;
};
hda1: hda@1 {
compatible = "intel,hda-dai";
power-domains = <&io0_domain>;
zephyr,pm-device-runtime-auto;
status = "okay";
reg = <1>;
};
hda2: hda@2 {
compatible = "intel,hda-dai";
power-domains = <&io0_domain>;
zephyr,pm-device-runtime-auto;
status = "okay";
reg = <2>;
};
hda3: hda@3 {
compatible = "intel,hda-dai";
power-domains = <&io0_domain>;
zephyr,pm-device-runtime-auto;
status = "okay";
reg = <3>;
};
hda4: hda@4 {
compatible = "intel,hda-dai";
power-domains = <&io0_domain>;
zephyr,pm-device-runtime-auto;
status = "okay";
reg = <4>;
};
hda5: hda@5 {
compatible = "intel,hda-dai";
power-domains = <&io0_domain>;
zephyr,pm-device-runtime-auto;
status = "okay";
reg = <5>;
};
hda6: hda@6 {
compatible = "intel,hda-dai";
power-domains = <&io0_domain>;
zephyr,pm-device-runtime-auto;
status = "okay";
reg = <6>;
};
hda7: hda@7 {
compatible = "intel,hda-dai";
power-domains = <&io0_domain>;
zephyr,pm-device-runtime-auto;
status = "okay";
reg = <7>;
};
hda8: hda@8 {
compatible = "intel,hda-dai";
power-domains = <&io0_domain>;
zephyr,pm-device-runtime-auto;
status = "okay";
reg = <8>;
};
hda9: hda@9 {
compatible = "intel,hda-dai";
power-domains = <&io0_domain>;
zephyr,pm-device-runtime-auto;
status = "okay";
reg = <9>;
};
hda10: hda@a {
compatible = "intel,hda-dai";
power-domains = <&io0_domain>;
zephyr,pm-device-runtime-auto;
status = "okay";
reg = <0x0a>;
};
hda11: hda@b {
compatible = "intel,hda-dai";
power-domains = <&io0_domain>;
zephyr,pm-device-runtime-auto;
status = "okay";
reg = <0x0b>;
};
hda12: hda@c {
compatible = "intel,hda-dai";
power-domains = <&io0_domain>;
zephyr,pm-device-runtime-auto;
status = "okay";
reg = <0x0c>;
};
hda13: hda@d {
compatible = "intel,hda-dai";
power-domains = <&io0_domain>;
zephyr,pm-device-runtime-auto;
status = "okay";
reg = <0x0d>;
};
hda14: hda@e {
compatible = "intel,hda-dai";
power-domains = <&io0_domain>;
zephyr,pm-device-runtime-auto;
status = "okay";
reg = <0x0e>;
};
hda15: hda@f {
compatible = "intel,hda-dai";
power-domains = <&io0_domain>;
zephyr,pm-device-runtime-auto;
status = "okay";
reg = <0x0f>;
};
hda16: hda@10 {
compatible = "intel,hda-dai";
power-domains = <&io0_domain>;
zephyr,pm-device-runtime-auto;
status = "okay";
reg = <0x10>;
};
hda17: hda@11 {
compatible = "intel,hda-dai";
power-domains = <&io0_domain>;
zephyr,pm-device-runtime-auto;
status = "okay";
reg = <0x11>;
};
hda18: hda@12 {
compatible = "intel,hda-dai";
power-domains = <&io0_domain>;
zephyr,pm-device-runtime-auto;
status = "okay";
reg = <0x12>;
};

View file

@ -596,96 +596,134 @@
hda0: hda@0 {
compatible = "intel,hda-dai";
power-domains = <&io0_domain>;
zephyr,pm-device-runtime-auto;
status = "okay";
reg = <0>;
};
hda1: hda@1 {
compatible = "intel,hda-dai";
power-domains = <&io0_domain>;
zephyr,pm-device-runtime-auto;
status = "okay";
reg = <1>;
};
hda2: hda@2 {
compatible = "intel,hda-dai";
power-domains = <&io0_domain>;
zephyr,pm-device-runtime-auto;
status = "okay";
reg = <2>;
};
hda3: hda@3 {
compatible = "intel,hda-dai";
power-domains = <&io0_domain>;
zephyr,pm-device-runtime-auto;
status = "okay";
reg = <3>;
};
hda4: hda@4 {
compatible = "intel,hda-dai";
power-domains = <&io0_domain>;
zephyr,pm-device-runtime-auto;
status = "okay";
reg = <4>;
};
hda5: hda@5 {
compatible = "intel,hda-dai";
power-domains = <&io0_domain>;
zephyr,pm-device-runtime-auto;
status = "okay";
reg = <5>;
};
hda6: hda@6 {
compatible = "intel,hda-dai";
power-domains = <&io0_domain>;
zephyr,pm-device-runtime-auto;
status = "okay";
reg = <6>;
};
hda7: hda@7 {
compatible = "intel,hda-dai";
power-domains = <&io0_domain>;
zephyr,pm-device-runtime-auto;
status = "okay";
reg = <7>;
};
hda8: hda@8 {
compatible = "intel,hda-dai";
power-domains = <&io0_domain>;
zephyr,pm-device-runtime-auto;
status = "okay";
reg = <8>;
};
hda9: hda@9 {
compatible = "intel,hda-dai";
power-domains = <&io0_domain>;
zephyr,pm-device-runtime-auto;
status = "okay";
reg = <9>;
};
hda10: hda@a {
compatible = "intel,hda-dai";
power-domains = <&io0_domain>;
zephyr,pm-device-runtime-auto;
status = "okay";
reg = <0x0a>;
};
hda11: hda@b {
compatible = "intel,hda-dai";
power-domains = <&io0_domain>;
zephyr,pm-device-runtime-auto;
status = "okay";
reg = <0x0b>;
};
hda12: hda@c {
compatible = "intel,hda-dai";
power-domains = <&io0_domain>;
zephyr,pm-device-runtime-auto;
status = "okay";
reg = <0x0c>;
};
hda13: hda@d {
compatible = "intel,hda-dai";
power-domains = <&io0_domain>;
zephyr,pm-device-runtime-auto;
status = "okay";
reg = <0x0d>;
};
hda14: hda@e {
compatible = "intel,hda-dai";
power-domains = <&io0_domain>;
zephyr,pm-device-runtime-auto;
status = "okay";
reg = <0x0e>;
};
hda15: hda@f {
compatible = "intel,hda-dai";
power-domains = <&io0_domain>;
zephyr,pm-device-runtime-auto;
status = "okay";
reg = <0x0f>;
};
hda16: hda@10 {
compatible = "intel,hda-dai";
power-domains = <&io0_domain>;
zephyr,pm-device-runtime-auto;
status = "okay";
reg = <0x10>;
};
hda17: hda@11 {
compatible = "intel,hda-dai";
power-domains = <&io0_domain>;
zephyr,pm-device-runtime-auto;
status = "okay";
reg = <0x11>;
};
hda18: hda@12 {
compatible = "intel,hda-dai";
power-domains = <&io0_domain>;
zephyr,pm-device-runtime-auto;
status = "okay";
reg = <0x12>;
};