Skip to content

Commit 774a62e

Browse files
sreeramIfxkartben
authored andcommitted
drivers: serial: Update UART driver to support XMC7200
Update UART driver to support XMC7200 Signed-off-by: Sreeram Tatapudi <[email protected]>
1 parent 1fe5cb5 commit 774a62e

File tree

2 files changed

+32
-11
lines changed

2 files changed

+32
-11
lines changed

drivers/serial/Kconfig.ifx_cat1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ config UART_INFINEON_CAT1
1010
depends on DT_HAS_INFINEON_CAT1_UART_ENABLED
1111
select SERIAL_HAS_DRIVER
1212
select SERIAL_SUPPORT_INTERRUPT
13-
select SERIAL_SUPPORT_ASYNC
13+
select SERIAL_SUPPORT_ASYNC if !SOC_FAMILY_INFINEON_CAT1C
1414
select USE_INFINEON_UART
1515
select PINCTRL
1616
select DMA if UART_ASYNC_API

drivers/serial/uart_ifx_cat1.c

Lines changed: 31 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@
2323
#include <zephyr/logging/log.h>
2424
LOG_MODULE_REGISTER(uart_ifx_cat1, CONFIG_UART_LOG_LEVEL);
2525

26+
#if (CONFIG_SOC_FAMILY_INFINEON_CAT1C)
27+
extern void cyhal_uart_irq_handler(cyhal_uart_t *cyhal_uart_irq_obj);
28+
#endif
29+
2630
#ifdef CONFIG_UART_ASYNC_API
2731
#include <zephyr/drivers/dma.h>
2832
#include <cyhal_dma.h>
@@ -84,6 +88,9 @@ struct ifx_cat1_uart_config {
8488
const struct pinctrl_dev_config *pcfg;
8589
CySCB_Type *reg_addr;
8690
struct uart_config dt_cfg;
91+
#if (CONFIG_SOC_FAMILY_INFINEON_CAT1C)
92+
uint16_t irq_num;
93+
#endif
8794
uint8_t irq_priority;
8895
};
8996

@@ -355,7 +362,7 @@ static void ifx_cat1_uart_irq_tx_enable(const struct device *dev)
355362
const struct ifx_cat1_uart_config *const config = dev->config;
356363

357364
cyhal_uart_enable_event(&data->obj, (cyhal_uart_event_t)CYHAL_UART_IRQ_TX_EMPTY,
358-
config->irq_priority, 1);
365+
config->irq_priority, true);
359366
}
360367

361368
/* Disable TX interrupt */
@@ -365,7 +372,7 @@ static void ifx_cat1_uart_irq_tx_disable(const struct device *dev)
365372
const struct ifx_cat1_uart_config *const config = dev->config;
366373

367374
cyhal_uart_enable_event(&data->obj, (cyhal_uart_event_t)CYHAL_UART_IRQ_TX_EMPTY,
368-
config->irq_priority, 0);
375+
config->irq_priority, false);
369376
}
370377

371378
/* Check if UART TX buffer can accept a new char */
@@ -392,7 +399,7 @@ static void ifx_cat1_uart_irq_rx_enable(const struct device *dev)
392399
const struct ifx_cat1_uart_config *const config = dev->config;
393400

394401
cyhal_uart_enable_event(&data->obj, (cyhal_uart_event_t)CYHAL_UART_IRQ_RX_NOT_EMPTY,
395-
config->irq_priority, 1);
402+
config->irq_priority, true);
396403
}
397404

398405
/* Disable TX interrupt */
@@ -402,7 +409,7 @@ static void ifx_cat1_uart_irq_rx_disable(const struct device *dev)
402409
const struct ifx_cat1_uart_config *const config = dev->config;
403410

404411
cyhal_uart_enable_event(&data->obj, (cyhal_uart_event_t)CYHAL_UART_IRQ_RX_NOT_EMPTY,
405-
config->irq_priority, 0);
412+
config->irq_priority, false);
406413
}
407414

408415
/* Check if UART RX buffer has a received char */
@@ -421,7 +428,7 @@ static void ifx_cat1_uart_irq_err_enable(const struct device *dev)
421428

422429
cyhal_uart_enable_event(
423430
&data->obj, (cyhal_uart_event_t)(CYHAL_UART_IRQ_TX_ERROR | CYHAL_UART_IRQ_RX_ERROR),
424-
config->irq_priority, 1);
431+
config->irq_priority, true);
425432
}
426433

427434
/* Disable Error interrupts */
@@ -432,7 +439,7 @@ static void ifx_cat1_uart_irq_err_disable(const struct device *dev)
432439

433440
cyhal_uart_enable_event(
434441
&data->obj, (cyhal_uart_event_t)(CYHAL_UART_IRQ_TX_ERROR | CYHAL_UART_IRQ_RX_ERROR),
435-
config->irq_priority, 0);
442+
config->irq_priority, false);
436443
}
437444

438445
/* Check if any IRQs is pending */
@@ -968,6 +975,12 @@ static int ifx_cat1_uart_init(const struct device *dev)
968975
return -ENOTSUP;
969976
}
970977

978+
#if (CONFIG_SOC_FAMILY_INFINEON_CAT1C && CONFIG_UART_INTERRUPT_DRIVEN)
979+
/* Enable the UART interrupt */
980+
enable_sys_int(config->irq_num, config->irq_priority,
981+
(void (*)(const void *))(void *)cyhal_uart_irq_handler, &data->obj);
982+
#endif
983+
971984
/* Perform initial Uart configuration */
972985
data->obj.is_clock_owned = true;
973986
ret = ifx_cat1_uart_configure(dev, &config->dt_cfg);
@@ -1102,6 +1115,14 @@ static DEVICE_API(uart, ifx_cat1_uart_driver_api) = {
11021115
#define UART_DMA_CHANNEL(index, dir, ch_dir, src_data_size, dst_data_size)
11031116
#endif /* CONFIG_UART_ASYNC_API */
11041117

1118+
#if (CONFIG_SOC_FAMILY_INFINEON_CAT1C)
1119+
#define IRQ_INFO(n) \
1120+
.irq_num = DT_INST_PROP_BY_IDX(n, system_interrupts, SYS_INT_NUM), \
1121+
.irq_priority = DT_INST_PROP_BY_IDX(n, system_interrupts, SYS_INT_PRI)};
1122+
#else
1123+
#define IRQ_INFO(n) .irq_priority = DT_INST_IRQ(n, priority)};
1124+
#endif
1125+
11051126
#define INFINEON_CAT1_UART_INIT(n) \
11061127
PINCTRL_DT_INST_DEFINE(n); \
11071128
static struct ifx_cat1_uart_data ifx_cat1_uart##n##_data = { \
@@ -1110,13 +1131,13 @@ static DEVICE_API(uart, ifx_cat1_uart_driver_api) = {
11101131
\
11111132
static struct ifx_cat1_uart_config ifx_cat1_uart##n##_cfg = { \
11121133
.dt_cfg.baudrate = DT_INST_PROP(n, current_speed), \
1113-
.dt_cfg.parity = DT_INST_ENUM_IDX(n, parity), \
1114-
.dt_cfg.stop_bits = DT_INST_ENUM_IDX(n, stop_bits), \
1115-
.dt_cfg.data_bits = DT_INST_ENUM_IDX(n, data_bits), \
1134+
.dt_cfg.parity = DT_INST_ENUM_IDX(n, parity), \
1135+
.dt_cfg.stop_bits = DT_INST_ENUM_IDX(n, stop_bits), \
1136+
.dt_cfg.data_bits = DT_INST_ENUM_IDX(n, data_bits), \
11161137
.dt_cfg.flow_ctrl = DT_INST_PROP(n, hw_flow_control), \
11171138
.pcfg = PINCTRL_DT_INST_DEV_CONFIG_GET(n), \
11181139
.reg_addr = (CySCB_Type *)DT_INST_REG_ADDR(n), \
1119-
.irq_priority = DT_INST_IRQ(n, priority)}; \
1140+
IRQ_INFO(n) \
11201141
\
11211142
DEVICE_DT_INST_DEFINE(n, &ifx_cat1_uart_init, NULL, &ifx_cat1_uart##n##_data, \
11221143
&ifx_cat1_uart##n##_cfg, PRE_KERNEL_1, CONFIG_SERIAL_INIT_PRIORITY, \

0 commit comments

Comments
 (0)