|
1 | 1 | /*
|
2 |
| - * Copyright 2023 NXP |
| 2 | + * Copyright 2023, 2025 NXP |
3 | 3 | *
|
4 | 4 | * SPDX-License-Identifier: Apache-2.0
|
5 | 5 | */
|
6 | 6 |
|
7 | 7 | #define DT_DRV_COMPAT nxp_gau_dac
|
8 | 8 |
|
9 | 9 | #include <zephyr/drivers/dac.h>
|
10 |
| - |
11 | 10 | #include <fsl_dac.h>
|
12 | 11 | #include "fsl_clock.h"
|
13 | 12 | #define LOG_LEVEL CONFIG_DAC_LOG_LEVEL
|
@@ -51,10 +50,8 @@ static int nxp_gau_dac_channel_setup(const struct device *dev,
|
51 | 50 | dac_channel_config_t dac_channel_config = {0};
|
52 | 51 | bool use_internal = true;
|
53 | 52 |
|
54 |
| - pm_policy_state_lock_get(PM_STATE_STANDBY, PM_ALL_SUBSTATES); //Lock the PM MODE 3 |
55 |
| - pm_policy_state_lock_get(PM_STATE_SUSPEND_TO_IDLE, PM_ALL_SUBSTATES); //Lock the PM MODE 2 |
56 |
| - pm_policy_state_lock_get(PM_STATE_RUNTIME_IDLE, PM_ALL_SUBSTATES); //Lock the PM MODE 1 |
57 |
| - |
| 53 | + pm_policy_device_power_lock_get(dev);/*Lock the PM states*/ |
| 54 | + |
58 | 55 | if (channel_cfg->resolution != 10) {
|
59 | 56 | LOG_ERR("DAC only support 10 bit resolution");
|
60 | 57 | return -EINVAL;
|
@@ -143,29 +140,20 @@ static int nxp_gau_dac_init_common(const struct device *dev)
|
143 | 140 | int nxp_gau_deinit(const struct device *dev){
|
144 | 141 | const struct nxp_gau_dac_config *config = dev->config;
|
145 | 142 | DAC_Deinit(config->base);
|
146 |
| - |
147 |
| - pm_policy_state_lock_put(PM_STATE_STANDBY, PM_ALL_SUBSTATES); //Lock the PM MODE 3 |
148 |
| - pm_policy_state_lock_put(PM_STATE_SUSPEND_TO_IDLE, PM_ALL_SUBSTATES); //Lock the PM MODE 2 |
149 |
| - pm_policy_state_lock_put(PM_STATE_RUNTIME_IDLE, PM_ALL_SUBSTATES); //Lock the PM MODE 1 |
| 143 | + |
| 144 | + pm_policy_device_power_lock_put(dev); /*Free the PM states*/ |
150 | 145 | return 0;
|
151 | 146 | }
|
152 | 147 |
|
153 | 148 | static int dac_mcux_pm_action(const struct device *dev, enum pm_device_action action)
|
154 |
| -{ static const struct dac_channel_cfg dac_ch_cfg_pm = { |
155 |
| - .channel_id = DAC_CHANNEL_ID_RESTORE, |
156 |
| - .resolution = DAC_RESOLUTION_RESTORE, |
157 |
| - .buffered = true |
158 |
| - }; |
159 |
| - |
| 149 | +{ |
160 | 150 | switch (action) {
|
161 | 151 | case PM_DEVICE_ACTION_RESUME:
|
162 |
| - break; |
163 | 152 | case PM_DEVICE_ACTION_SUSPEND:
|
164 |
| - break; |
165 | 153 | case PM_DEVICE_ACTION_TURN_OFF:
|
166 | 154 | break;
|
167 | 155 | case PM_DEVICE_ACTION_TURN_ON:
|
168 |
| - nxp_gau_dac_init_common(dev); |
| 156 | + nxp_gau_dac_init_common(dev); |
169 | 157 | break;
|
170 | 158 | default:
|
171 | 159 | return -ENOTSUP;
|
|
0 commit comments