From 405ab182a9749501f22df4455f9f2fbc1189adc1 Mon Sep 17 00:00:00 2001 From: Vit Stanicek Date: Mon, 24 Jun 2024 13:19:08 +0200 Subject: [PATCH] drivers: intc_nxp_pint: Decouple from fsl_power.h Add drivers/interrupt_controller/intc_nxp_pint/power.h abstracting EnableDeepSleepIRQ and DisableDeepSleepIRQ invocations from intc_nxp_pint.c. Modify intc_nxp_pint.c to use that file. fsl_power.c and fsl_power.h can't be built on the mimxrt685_evk/mimxrt685s/hifi4 target, so it's excluded from it in hal_nxp. Signed-off-by: Vit Stanicek --- drivers/interrupt_controller/intc_nxp_pint.c | 13 ++----- .../intc_nxp_pint/power.h | 39 +++++++++++++++++++ 2 files changed, 43 insertions(+), 9 deletions(-) create mode 100644 drivers/interrupt_controller/intc_nxp_pint/power.h diff --git a/drivers/interrupt_controller/intc_nxp_pint.c b/drivers/interrupt_controller/intc_nxp_pint.c index 2a11fd7ad45..f794a0a2979 100644 --- a/drivers/interrupt_controller/intc_nxp_pint.c +++ b/drivers/interrupt_controller/intc_nxp_pint.c @@ -12,7 +12,8 @@ #include #include -#include + +#include "intc_nxp_pint/power.h" #define DT_DRV_COMPAT nxp_pint @@ -94,14 +95,8 @@ int nxp_pint_pin_enable(uint8_t pin, enum nxp_pint_trigger trigger, bool wake) * driver handles the IRQ */ PINT_PinInterruptConfig(pint_base, slot, trigger, NULL); -#if !(defined(FSL_FEATURE_POWERLIB_EXTEND) && (FSL_FEATURE_POWERLIB_EXTEND != 0)) - if (wake) { - EnableDeepSleepIRQ(pint_irq_cfg[slot].irq); - } else { - DisableDeepSleepIRQ(pint_irq_cfg[slot].irq); - irq_enable(pint_irq_cfg[slot].irq); - } -#endif + nxp_pint_pin_deep_sleep_irq(pint_irq_cfg[slot].irq, wake); + return 0; } diff --git a/drivers/interrupt_controller/intc_nxp_pint/power.h b/drivers/interrupt_controller/intc_nxp_pint/power.h new file mode 100644 index 00000000000..0be24a5c6d0 --- /dev/null +++ b/drivers/interrupt_controller/intc_nxp_pint/power.h @@ -0,0 +1,39 @@ +/* + * Copyright 2024 NXP + * + * SPDX-License-Identifier: Apache-2.0 + */ + +/* + * This file abstracts operations exposed by fsl_power.h from NXP HAL, + * for cases when that driver can't be compiled (DSP targets). + */ + +#ifndef __ZEPHYR_DRIVERS_INTERRUPT_CONTROLLER_INTC_NXP_PINT_POWER_H__ +#define __ZEPHYR_DRIVERS_INTERRUPT_CONTROLLER_INTC_NXP_PINT_POWER_H__ + +#include +#include +#include + +#if defined(FSL_FEATURE_SOC_PMC_COUNT) && FSL_FEATURE_SOC_PMC_COUNT > 0 +#include +#endif + +static inline void nxp_pint_pin_deep_sleep_irq(uint8_t irq, bool wake) +{ +#if (defined(FSL_FEATURE_SOC_PMC_COUNT) && FSL_FEATURE_SOC_PMC_COUNT > 0) && \ + !(defined(FSL_FEATURE_POWERLIB_EXTEND) && (FSL_FEATURE_POWERLIB_EXTEND != 0)) + if (wake) { + EnableDeepSleepIRQ(irq); + } else { + DisableDeepSleepIRQ(irq); + irq_enable(irq); + } +#else + ARG_UNUSED(irq); + ARG_UNUSED(wake); +#endif +} + +#endif