Commit 8e1f2c70 authored by Bill Waters's avatar Bill Waters Committed by Benjamin Cabé
Browse files

drivers: pwm: Infineon: replace cat1 naming with tcpwm



* Changes driver naming to reflect hardware IP being used (TCPWM)
instead of referencing cat1.  Cat1 is an internal infineon
reference which has little meaning to users and is being phased
phased out.

Signed-off-by: default avatarBill Waters <bill.waters@infineon.com>
parent 66f50bef
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -55,7 +55,7 @@ zephyr_library_sources_ifdef(CONFIG_PWM_ENE_KB106X pwm_ene_kb106x.c)
zephyr_library_sources_ifdef(CONFIG_PWM_ENE_KB1200	pwm_ene_kb1200.c)
zephyr_library_sources_ifdef(CONFIG_PWM_RENESAS_RA	pwm_renesas_ra.c)
zephyr_library_sources_ifdef(CONFIG_PWM_RENESAS_RX_MTU	pwm_renesas_rx_mtu.c)
zephyr_library_sources_ifdef(CONFIG_PWM_INFINEON_CAT1	pwm_ifx_cat1.c)
zephyr_library_sources_ifdef(CONFIG_PWM_INFINEON_TCPWM	pwm_ifx_tcpwm.c)
zephyr_library_sources_ifdef(CONFIG_PWM_FAKE	pwm_fake.c)
zephyr_library_sources_ifdef(CONFIG_PWM_RENESAS_RZ_GPT	pwm_renesas_rz_gpt.c)
zephyr_library_sources_ifdef(CONFIG_PWM_RENESAS_RZ_MTU	pwm_renesas_rz_mtu.c)
+1 −1
Original line number Diff line number Diff line
@@ -126,7 +126,7 @@ source "drivers/pwm/Kconfig.renesas_ra"

source "drivers/pwm/Kconfig.renesas_rx_mtu"

source "drivers/pwm/Kconfig.ifx_cat1"
source "drivers/pwm/Kconfig.ifx_tcpwm"

source "drivers/pwm/Kconfig.fake"

+5 −5
Original line number Diff line number Diff line
# Infineon CAT1 PWM configuration options
# Infineon TCPWM PWM configuration options

# Copyright (c) 2024 Cypress Semiconductor Corporation (an Infineon company) or
# an affiliate of Cypress Semiconductor Corporation
#
# SPDX-License-Identifier: Apache-2.0

config PWM_INFINEON_CAT1
	bool "Infineon CAT1 PWM driver"
config PWM_INFINEON_TCPWM
	bool "Infineon TCPWM driver"
	default y
	depends on DT_HAS_INFINEON_CAT1_PWM_ENABLED
	depends on DT_HAS_INFINEON_TCPWM_PWM_ENABLED
	depends on SOC_FAMILY_INFINEON_CAT1B
	select USE_INFINEON_PWM
	select PINCTRL
	help
	  This option enables the PWM driver for Infineon CAT1 family.
	  This option enables the PWM driver for Infineon TCPWM peripheral.
+23 −23
Original line number Diff line number Diff line
@@ -6,10 +6,10 @@
 */

/**
 * @brief ADC driver for Infineon CAT1 MCU family.
 * PWM driver for Infineon MCUs using the TCPWM block.
 */

#define DT_DRV_COMPAT infineon_cat1_pwm
#define DT_DRV_COMPAT infineon_tcpwm_pwm

#include <zephyr/drivers/pwm.h>
#include <zephyr/drivers/pinctrl.h>
@@ -21,15 +21,15 @@
#include <cyhal_hw_types.h>

#include <zephyr/logging/log.h>
LOG_MODULE_REGISTER(pwm_ifx_cat1, CONFIG_PWM_LOG_LEVEL);
LOG_MODULE_REGISTER(pwm_ifx_tcpwm, CONFIG_PWM_LOG_LEVEL);

#define PWM_REG_BASE TCPWM0

struct ifx_cat1_pwm_data {
struct ifx_tcpwm_pwm_data {
	uint32_t pwm_num;
};

struct ifx_cat1_pwm_config {
struct ifx_tcpwm_pwm_config {
	TCPWM_GRP_CNT_Type *reg_addr;
	const struct pinctrl_dev_config *pcfg;
	bool resolution_32_bits;
@@ -38,10 +38,10 @@ struct ifx_cat1_pwm_config {
	uint32_t divider_val;
};

static int ifx_cat1_pwm_init(const struct device *dev)
static int ifx_tcpwm_pwm_init(const struct device *dev)
{
	struct ifx_cat1_pwm_data *data = dev->data;
	const struct ifx_cat1_pwm_config *config = dev->config;
	struct ifx_tcpwm_pwm_data *data = dev->data;
	const struct ifx_tcpwm_pwm_config *config = dev->config;
	cy_en_tcpwm_status_t status;
	int ret;
	uint32_t addr_offset = (uint32_t)config->reg_addr - TCPWM0_BASE;
@@ -91,11 +91,11 @@ static int ifx_cat1_pwm_init(const struct device *dev)
	return 0;
}

static int ifx_cat1_pwm_set_cycles(const struct device *dev, uint32_t channel,
static int ifx_tcpwm_pwm_set_cycles(const struct device *dev, uint32_t channel,
				   uint32_t period_cycles, uint32_t pulse_cycles, pwm_flags_t flags)
{
	struct ifx_cat1_pwm_data *data = dev->data;
	const struct ifx_cat1_pwm_config *config = dev->config;
	struct ifx_tcpwm_pwm_data *data = dev->data;
	const struct ifx_tcpwm_pwm_config *config = dev->config;

	if (!config->resolution_32_bits &&
	    ((period_cycles > UINT16_MAX) || (pulse_cycles > UINT16_MAX))) {
@@ -149,27 +149,27 @@ static int ifx_cat1_pwm_set_cycles(const struct device *dev, uint32_t channel,
	return 0;
}

static int ifx_cat1_pwm_get_cycles_per_sec(const struct device *dev, uint32_t channel,
static int ifx_tcpwm_pwm_get_cycles_per_sec(const struct device *dev, uint32_t channel,
					   uint64_t *cycles)
{
	const struct ifx_cat1_pwm_config *config = dev->config;
	const struct ifx_tcpwm_pwm_config *config = dev->config;

	*cycles = Cy_SysClk_PeriphGetFrequency(config->divider_type, config->divider_sel);

	return 0;
}

static DEVICE_API(pwm, ifx_cat1_pwm_api) = {
	.set_cycles = ifx_cat1_pwm_set_cycles,
	.get_cycles_per_sec = ifx_cat1_pwm_get_cycles_per_sec,
static DEVICE_API(pwm, ifx_tcpwm_pwm_api) = {
	.set_cycles = ifx_tcpwm_pwm_set_cycles,
	.get_cycles_per_sec = ifx_tcpwm_pwm_get_cycles_per_sec,
};

#define INFINEON_CAT1_PWM_INIT(n)                                                                  \
#define INFINEON_TCPWM_PWM_INIT(n)                                                                 \
	PINCTRL_DT_INST_DEFINE(n);                                                                 \
                                                                                                   \
	static struct ifx_cat1_pwm_data pwm_cat1_data_##n;                                         \
	static struct ifx_tcpwm_pwm_data pwm_tcpwm_data_##n;                                       \
                                                                                                   \
	static struct ifx_cat1_pwm_config pwm_cat1_config_##n = {                                  \
	static struct ifx_tcpwm_pwm_config pwm_tcpwm_config_##n = {                                \
		.reg_addr = (TCPWM_GRP_CNT_Type *)DT_INST_REG_ADDR(n),                             \
		.pcfg = PINCTRL_DT_INST_DEV_CONFIG_GET(n),                                         \
		.resolution_32_bits = (DT_INST_PROP(n, resolution) == 32) ? true : false,          \
@@ -178,8 +178,8 @@ static DEVICE_API(pwm, ifx_cat1_pwm_api) = {
		.divider_val = DT_INST_PROP(n, divider_val),                                       \
	};                                                                                         \
                                                                                                   \
	DEVICE_DT_INST_DEFINE(n, ifx_cat1_pwm_init, NULL, &pwm_cat1_data_##n,                      \
			      &pwm_cat1_config_##n, POST_KERNEL, CONFIG_PWM_INIT_PRIORITY,         \
			      &ifx_cat1_pwm_api);
	DEVICE_DT_INST_DEFINE(n, ifx_tcpwm_pwm_init, NULL, &pwm_tcpwm_data_##n,                    \
			      &pwm_tcpwm_config_##n, POST_KERNEL, CONFIG_PWM_INIT_PRIORITY,        \
			      &ifx_tcpwm_pwm_api);

DT_INST_FOREACH_STATUS_OKAY(INFINEON_CAT1_PWM_INIT)
DT_INST_FOREACH_STATUS_OKAY(INFINEON_TCPWM_PWM_INIT)
+9 −9
Original line number Diff line number Diff line
@@ -280,7 +280,7 @@
		};

		pwm0_0: pwm@404a0000 {
			compatible = "infineon,cat1-pwm";
			compatible = "infineon,tcpwm-pwm";
			reg = <0x404a0000 0x80>;
			interrupts = <42 4>;
			resolution = <32>;
@@ -288,7 +288,7 @@
			#pwm-cells = <3>;
		};
		pwm0_1: pwm@404a0080 {
			compatible = "infineon,cat1-pwm";
			compatible = "infineon,tcpwm-pwm";
			reg = <0x404a0080 0x80>;
			interrupts = <43 4>;
			resolution = <32>;
@@ -296,7 +296,7 @@
			#pwm-cells = <3>;
		};
		pwm1_0: pwm@404a8000 {
			compatible = "infineon,cat1-pwm";
			compatible = "infineon,tcpwm-pwm";
			reg = <0x404a8000 0x80>;
			interrupts = <44 4>;
			resolution = <16>;
@@ -304,7 +304,7 @@
			#pwm-cells = <3>;
		};
		pwm1_1: pwm@404a8080 {
			compatible = "infineon,cat1-pwm";
			compatible = "infineon,tcpwm-pwm";
			reg = <0x404a8080 0x80>;
			interrupts = <45 4>;
			resolution = <16>;
@@ -312,7 +312,7 @@
			#pwm-cells = <3>;
		};
		pwm1_2: pwm@404a8100 {
			compatible = "infineon,cat1-pwm";
			compatible = "infineon,tcpwm-pwm";
			reg = <0x404a8100 0x80>;
			interrupts = <46 4>;
			resolution = <16>;
@@ -320,7 +320,7 @@
			#pwm-cells = <3>;
		};
		pwm1_3: pwm@404a8180 {
			compatible = "infineon,cat1-pwm";
			compatible = "infineon,tcpwm-pwm";
			reg = <0x404a8180 0x80>;
			interrupts = <47 4>;
			resolution = <16>;
@@ -328,7 +328,7 @@
			#pwm-cells = <3>;
		};
		pwm1_4: pwm@404a8200 {
			compatible = "infineon,cat1-pwm";
			compatible = "infineon,tcpwm-pwm";
			reg = <0x404a8200 0x80>;
			interrupts = <48 4>;
			resolution = <16>;
@@ -336,7 +336,7 @@
			#pwm-cells = <3>;
		};
		pwm1_5: pwm@404a8280 {
			compatible = "infineon,cat1-pwm";
			compatible = "infineon,tcpwm-pwm";
			reg = <0x404a8280 0x80>;
			interrupts = <49 4>;
			resolution = <16>;
@@ -344,7 +344,7 @@
			#pwm-cells = <3>;
		};
		pwm1_6: pwm@404a8300 {
			compatible = "infineon,cat1-pwm";
			compatible = "infineon,tcpwm-pwm";
			reg = <0x404a8300 0x80>;
			interrupts = <50 4>;
			resolution = <16>;
Loading