drivers: serial: cc32xx: add support for pinctrl
Driver will configure pins using the pinctrl API now. Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
This commit is contained in:
parent
a3ab08b7ce
commit
ecc241e0ce
2 changed files with 11 additions and 0 deletions
|
@ -6,5 +6,6 @@ config UART_CC32XX
|
||||||
depends on DT_HAS_TI_CC32XX_UART_ENABLED
|
depends on DT_HAS_TI_CC32XX_UART_ENABLED
|
||||||
select SERIAL_HAS_DRIVER
|
select SERIAL_HAS_DRIVER
|
||||||
select SERIAL_SUPPORT_INTERRUPT
|
select SERIAL_SUPPORT_INTERRUPT
|
||||||
|
select PINCTRL
|
||||||
help
|
help
|
||||||
This option enables the CC32XX UART driver, for UART_0.
|
This option enables the CC32XX UART driver, for UART_0.
|
||||||
|
|
|
@ -9,6 +9,7 @@
|
||||||
#include <zephyr/kernel.h>
|
#include <zephyr/kernel.h>
|
||||||
#include <zephyr/arch/cpu.h>
|
#include <zephyr/arch/cpu.h>
|
||||||
#include <zephyr/drivers/uart.h>
|
#include <zephyr/drivers/uart.h>
|
||||||
|
#include <zephyr/drivers/pinctrl.h>
|
||||||
|
|
||||||
/* Driverlib includes */
|
/* Driverlib includes */
|
||||||
#include <inc/hw_types.h>
|
#include <inc/hw_types.h>
|
||||||
|
@ -21,6 +22,7 @@
|
||||||
struct uart_cc32xx_dev_config {
|
struct uart_cc32xx_dev_config {
|
||||||
unsigned long base;
|
unsigned long base;
|
||||||
uint32_t sys_clk_freq;
|
uint32_t sys_clk_freq;
|
||||||
|
const struct pinctrl_dev_config *pcfg;
|
||||||
#ifdef CONFIG_UART_INTERRUPT_DRIVEN
|
#ifdef CONFIG_UART_INTERRUPT_DRIVEN
|
||||||
uart_irq_config_func_t irq_config_func;
|
uart_irq_config_func_t irq_config_func;
|
||||||
#endif
|
#endif
|
||||||
|
@ -53,12 +55,18 @@ static int uart_cc32xx_init(const struct device *dev)
|
||||||
{
|
{
|
||||||
const struct uart_cc32xx_dev_config *config = dev->config;
|
const struct uart_cc32xx_dev_config *config = dev->config;
|
||||||
const struct uart_cc32xx_dev_data_t *data = dev->data;
|
const struct uart_cc32xx_dev_data_t *data = dev->data;
|
||||||
|
int ret;
|
||||||
|
|
||||||
MAP_PRCMPeripheralClkEnable(data->prcm,
|
MAP_PRCMPeripheralClkEnable(data->prcm,
|
||||||
PRCM_RUN_MODE_CLK | PRCM_SLP_MODE_CLK);
|
PRCM_RUN_MODE_CLK | PRCM_SLP_MODE_CLK);
|
||||||
|
|
||||||
MAP_PRCMPeripheralReset(data->prcm);
|
MAP_PRCMPeripheralReset(data->prcm);
|
||||||
|
|
||||||
|
ret = pinctrl_apply_state(config->pcfg, PINCTRL_STATE_DEFAULT);
|
||||||
|
if (ret < 0) {
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
/* This also calls MAP_UARTEnable() to enable the FIFOs: */
|
/* This also calls MAP_UARTEnable() to enable the FIFOs: */
|
||||||
MAP_UARTConfigSetExpClk(config->base,
|
MAP_UARTConfigSetExpClk(config->base,
|
||||||
MAP_PRCMPeripheralClockGet(data->prcm),
|
MAP_PRCMPeripheralClockGet(data->prcm),
|
||||||
|
@ -305,6 +313,7 @@ static const struct uart_driver_api uart_cc32xx_driver_api = {
|
||||||
};
|
};
|
||||||
|
|
||||||
#define UART_32XX_DEVICE(idx) \
|
#define UART_32XX_DEVICE(idx) \
|
||||||
|
PINCTRL_DT_INST_DEFINE(idx); \
|
||||||
IF_ENABLED(CONFIG_UART_INTERRUPT_DRIVEN, \
|
IF_ENABLED(CONFIG_UART_INTERRUPT_DRIVEN, \
|
||||||
(static void uart_cc32xx_cfg_func_##idx(const struct device *dev) \
|
(static void uart_cc32xx_cfg_func_##idx(const struct device *dev) \
|
||||||
{ \
|
{ \
|
||||||
|
@ -319,6 +328,7 @@ IF_ENABLED(CONFIG_UART_INTERRUPT_DRIVEN, \
|
||||||
static const struct uart_cc32xx_dev_config uart_cc32xx_dev_cfg_##idx = { \
|
static const struct uart_cc32xx_dev_config uart_cc32xx_dev_cfg_##idx = { \
|
||||||
.base = DT_INST_REG_ADDR(idx), \
|
.base = DT_INST_REG_ADDR(idx), \
|
||||||
.sys_clk_freq = DT_INST_PROP_BY_PHANDLE(idx, clocks, clock_frequency),\
|
.sys_clk_freq = DT_INST_PROP_BY_PHANDLE(idx, clocks, clock_frequency),\
|
||||||
|
.pcfg = PINCTRL_DT_INST_DEV_CONFIG_GET(idx), \
|
||||||
IF_ENABLED(CONFIG_UART_INTERRUPT_DRIVEN, \
|
IF_ENABLED(CONFIG_UART_INTERRUPT_DRIVEN, \
|
||||||
(.irq_config_func = uart_cc32xx_cfg_func_##idx,)) \
|
(.irq_config_func = uart_cc32xx_cfg_func_##idx,)) \
|
||||||
}; \
|
}; \
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue