diff --git a/drivers/i2c/CMakeLists.txt b/drivers/i2c/CMakeLists.txt index baa6c9e658c94..260b631be521f 100644 --- a/drivers/i2c/CMakeLists.txt +++ b/drivers/i2c/CMakeLists.txt @@ -34,7 +34,8 @@ zephyr_library_sources_ifdef(CONFIG_I2C_ESP32 i2c_esp32.c) zephyr_library_sources_ifdef(CONFIG_I2C_GD32 i2c_gd32.c) zephyr_library_sources_ifdef(CONFIG_I2C_GECKO i2c_gecko.c) zephyr_library_sources_ifdef(CONFIG_I2C_IMX i2c_imx.c) -zephyr_library_sources_ifdef(CONFIG_I2C_INFINEON_CAT1 i2c_ifx_cat1.c) +zephyr_library_sources_ifdef(CONFIG_I2C_INFINEON_CAT1_HAL i2c_ifx_cat1.c) +zephyr_library_sources_ifdef(CONFIG_I2C_INFINEON_CAT1_PDL i2c_ifx_cat1_pdl.c) zephyr_library_sources_ifdef(CONFIG_I2C_INFINEON_XMC4 i2c_ifx_xmc4.c) zephyr_library_sources_ifdef(CONFIG_I2C_IPROC i2c_bcm_iproc.c) zephyr_library_sources_ifdef(CONFIG_I2C_ITE_ENHANCE i2c_ite_enhance.c) diff --git a/drivers/i2c/Kconfig.ifx_cat1 b/drivers/i2c/Kconfig.ifx_cat1 index 217178ad80eee..6775b33bd2576 100644 --- a/drivers/i2c/Kconfig.ifx_cat1 +++ b/drivers/i2c/Kconfig.ifx_cat1 @@ -5,23 +5,25 @@ # # SPDX-License-Identifier: Apache-2.0 -config I2C_INFINEON_CAT1 - bool "Infineon CAT1 I2C driver" +config I2C_INFINEON_CAT1_HAL + bool "Infineon CAT1 I2C HAL based driver" default y depends on DT_HAS_INFINEON_CAT1_I2C_ENABLED + depends on USE_INFINEON_LEGACY_HAL select USE_INFINEON_I2C select PINCTRL help - This option enables the I2C driver for Infineon CAT1 family. + This option enables the HAL based I2C driver for Infineon CAT1 family. -config I2C_PDL_INFINEON_CAT1 - bool "Infineon CAT1 I2C driver (PDL)" +config I2C_INFINEON_CAT1_PDL + bool "Infineon CAT1 I2C PDL based driver" default y - depends on DT_HAS_INFINEON_CAT1_I2C_PDL_ENABLED + depends on DT_HAS_INFINEON_CAT1_I2C_ENABLED + depends on !USE_INFINEON_LEGACY_HAL select USE_INFINEON_I2C select PINCTRL help - This option enables the I2C driver for the Infineon CAT1 family. + This option enables the PDL based I2C driver for the Infineon CAT1 family. config I2C_INFINEON_CAT1_TARGET_BUF int "I2C Target data buffer length" diff --git a/drivers/i2c/i2c_ifx_cat1_pdl.c b/drivers/i2c/i2c_ifx_cat1_pdl.c index e3b966475acaf..68a115e7982ea 100644 --- a/drivers/i2c/i2c_ifx_cat1_pdl.c +++ b/drivers/i2c/i2c_ifx_cat1_pdl.c @@ -1,6 +1,6 @@ /* - * (c) 2025 Infineon Technologies AG, or an affiliate of Infineon Technologies AG. - * All rights reserved. + * Copyright (c) 2025 Infineon Technologies AG, + * or an affiliate of Infineon Technologies AG. * * SPDX-License-Identifier: Apache-2.0 */ @@ -9,7 +9,9 @@ * @brief I2C driver for Infineon CAT1 MCU family. */ -#define DT_DRV_COMPAT infineon_cat1_i2c_pdl +#define DT_DRV_COMPAT infineon_cat1_i2c + +#include #include #include @@ -60,7 +62,7 @@ struct ifx_cat1_i2c_data { bool error; uint32_t async_pending; struct ifx_cat1_clock clock; -#if defined(COMPONENT_CAT1B) || defined(COMPONENT_CAT1C) || defined(COMPONENT_CAT1D) +#if defined(COMPONENT_CAT1B) || defined(COMPONENT_CAT1C) || defined(CONFIG_SOC_FAMILY_INFINEON_EDGE) uint8_t clock_peri_group; #endif struct i2c_target_config *p_target_config; @@ -230,7 +232,7 @@ void ifx_cat1_i2c_register_callback(const struct device *dev, uint32_t _i2c_set_peri_divider(const struct device *dev, uint32_t freq, bool is_slave) { /* Peripheral clock values for different I2C speeds according PDL API Reference Guide */ -#if defined(COMPONENT_CAT1D) +#if defined(CONFIG_SOC_FAMILY_INFINEON_EDGE) /* Must be between 1.55 MHz and 12.8 MHz for running i2c master at 100KHz */ #define _SCB_PERI_CLOCK_SLAVE_STD 6000000 /* Must be between 7.82 MHz and 15.38 MHz for running i2c master at 400KHz */ @@ -240,7 +242,7 @@ uint32_t _i2c_set_peri_divider(const struct device *dev, uint32_t freq, bool is_ #define _SCB_PERI_CLOCK_SLAVE_STD 8000000 /* Must be between 7.82 MHz and 15.38 MHz for running i2c master at 400KHz */ #define _SCB_PERI_CLOCK_SLAVE_FST 12500000 -#endif /* defined(COMPONENT_CAT1D) */ +#endif /* defined(CONFIG_SOC_FAMILY_INFINEON_EDGE) */ /* Must be between 1.55 MHz and 3.2 MHz for running i2c slave at 100KHz */ #define _SCB_PERI_CLOCK_MASTER_STD 2000000 @@ -251,7 +253,7 @@ uint32_t _i2c_set_peri_divider(const struct device *dev, uint32_t freq, bool is_ /* Must be between 15.84 MHz and 89.0 MHz for running i2c master at 1MHz */ #if defined(COMPONENT_CAT1A) || defined(COMPONENT_CAT1B) || defined(COMPONENT_CAT1C) || \ - defined(COMPONENT_CAT1D) + defined(CONFIG_SOC_FAMILY_INFINEON_EDGE) #define _SCB_PERI_CLOCK_SLAVE_FSTP 50000000 #elif defined(COMPONENT_CAT2) #define _SCB_PERI_CLOCK_SLAVE_FSTP 24000000 @@ -678,13 +680,13 @@ static const struct i2c_driver_api i2c_cat1_driver_api = { .target_register = ifx_cat1_i2c_target_register, .target_unregister = ifx_cat1_i2c_target_unregister}; -#if defined(COMPONENT_CAT1B) || defined(COMPONENT_CAT1C) || defined(COMPONENT_CAT1D) +#if defined(COMPONENT_CAT1B) || defined(COMPONENT_CAT1C) || defined(CONFIG_SOC_FAMILY_INFINEON_EDGE) #define PERI_INFO(n) .clock_peri_group = DT_PROP_BY_IDX(DT_INST_PHANDLE(n, clocks), peri_group, 1), #else #define PERI_INFO(n) #endif -#if defined(COMPONENT_CAT1D) +#if defined(CONFIG_SOC_FAMILY_INFINEON_EDGE) #define I2C_PERI_CLOCK_INIT(n) \ .clock = { \ .block = IFX_CAT1_PERIPHERAL_GROUP_ADJUST( \ diff --git a/dts/bindings/i2c/infineon,cat1-i2c-pdl.yaml b/dts/bindings/i2c/infineon,cat1-i2c-pdl.yaml deleted file mode 100644 index ce442e8b1ff4b..0000000000000 --- a/dts/bindings/i2c/infineon,cat1-i2c-pdl.yaml +++ /dev/null @@ -1,74 +0,0 @@ -# Copyright (c) 2025 Infineon Technologies AG, -# or an affiliate of Infineon Technologies AG. -# -# SPDX-License-Identifier: Apache-2.0 - -description: | - Infineon CAT1 PDL-based I2C driver - - This driver configures the SCB as an I2C device. - - Example devicetree configuration with vl53l0x Time-of-Flight (ToF) - ranging sensor connected on the bus: - - i2c3: &scb3 { - compatible = "infineon,cat1-i2c-pdl"; - status = "okay"; - - #address-cells = <1>; - #size-cells = <0>; - - pinctrl-0 = <&p6_0_scb3_i2c_scl &p6_1_scb3_i2c_sda>; - pinctrl-names = "default"; - - vl53l0x@29 { - compatible = "st,vl53l0x"; - reg = <0x29>; - }; - }; - - The pinctrl nodes need to be configured as open-drain and - input-enable: - - &p6_0_scb3_i2c_scl { - drive-open-drain; - input-enable; - }; - - &p6_1_scb3_i2c_sda { - drive-open-drain; - input-enable; - }; - -compatible: "infineon,cat1-i2c-pdl" - -include: [i2c-controller.yaml, pinctrl-device.yaml, "infineon,cat1-scb.yaml"] - -properties: - reg: - type: array - required: true - - interrupts: - type: array - required: true - - pinctrl-0: - description: | - PORT pin configuration for SCL, SDA signals. - We expect that the phandles will reference pinctrl nodes. These - nodes will have a nodelabel that matches the Infineon SoC Pinctrl - defines and have following - format: p___. - - Examples: - pinctrl-0 = <&p6_0_scb3_i2c_scl &p6_1_scb3_i2c_sda>; - required: true - - pinctrl-names: - required: true - - clock-frequency: - type: int - description: | - Frequency that the I2C bus runs diff --git a/soc/infineon/edge/common/pinctrl_soc.h b/soc/infineon/edge/common/pinctrl_soc.h index 339bae9c7e11b..89c7d1caf6f1e 100644 --- a/soc/infineon/edge/common/pinctrl_soc.h +++ b/soc/infineon/edge/common/pinctrl_soc.h @@ -14,6 +14,8 @@ #include #include +#include +#include #ifdef __cplusplus extern "C" {