# SPDX-FileCopyrightText: <text>Copyright (c) 2026 Infineon Technologies AG,
# or an affiliate of Infineon Technologies AG. All rights reserved.</text>
#
# SPDX-License-Identifier: Apache-2.0

if(CONFIG_SOC_FAMILY_INFINEON_EDGE)

  if(CONFIG_BOARD_KIT_PSE84_EVAL)
    set(zephyr_ifx_cycfg_dir ${ZEPHYR_HAL_INFINEON_MODULE_DIR}/zephyr-ifx-cycfg/pse84/kit_pse84_eval)
  elseif(CONFIG_BOARD_KIT_PSE84_AI)
    set(zephyr_ifx_cycfg_dir ${ZEPHYR_HAL_INFINEON_MODULE_DIR}/zephyr-ifx-cycfg/pse84/kit_pse84_ai)
  else()
    message(FATAL_ERROR "No supported board selected.")
  endif()

  zephyr_include_directories(${zephyr_ifx_cycfg_dir})
  zephyr_include_directories(${zephyr_ifx_cycfg_dir}/device_headers)
  zephyr_library_sources(${zephyr_ifx_cycfg_dir}/cycfg_qspi_memslot.c)

  if(CONFIG_BUILD_WITH_TFM)
    zephyr_include_directories(${ZEPHYR_TRUSTED_FIRMWARE_M_MODULE_DIR}/platform/ext/target/infineon/pse84/shared/device/include)
  else()
    set(zephyr_ifx_pse84_dir ${ZEPHYR_HAL_INFINEON_MODULE_DIR}/zephyr-ifx-cycfg/pse84)
    zephyr_include_directories(${zephyr_ifx_pse84_dir})
    zephyr_library_sources(${zephyr_ifx_pse84_dir}/ifx_cycfg_init.c)

    if(CONFIG_USE_INFINEON_AUTANALOG_SAR_ADC AND NOT CONFIG_MFD_INFINEON_AUTANALOG)
      zephyr_library_sources(${zephyr_ifx_pse84_dir}/ifx_autanalog.c)
    endif()

  endif()
endif()

if(CONFIG_SOC_SERIES_PSC3)
  set(zephyr_ifx_cycfg_dir ${ZEPHYR_HAL_INFINEON_MODULE_DIR}/zephyr-ifx-cycfg/soc_psc3)

  zephyr_include_directories(${zephyr_ifx_cycfg_dir})
  zephyr_library_sources_ifdef(CONFIG_USE_INFINEON_HPPASS_SAR_ADC ${zephyr_ifx_cycfg_dir}/ifx_hppass_analog.c)
  zephyr_library_sources(${zephyr_ifx_cycfg_dir}/ifx_cycfg_init.c)
endif()
