drivers: serial: sy1xx add support for pinctrl

Add pin ctrl to the serial driver.

Signed-off-by: Sven Ginka <s.ginka@sensry.de>
This commit is contained in:
Sven Ginka 2024-12-10 16:29:01 +01:00 committed by Benjamin Cabé
parent 2931ad70de
commit a89b81b110
3 changed files with 11 additions and 22 deletions

View file

@ -6,5 +6,6 @@ config UART_SY1XX
default y default y
depends on DT_HAS_SENSRY_SY1XX_UART_ENABLED depends on DT_HAS_SENSRY_SY1XX_UART_ENABLED
select SERIAL_HAS_DRIVER select SERIAL_HAS_DRIVER
select PINCTRL
help help
Driver for Sensry Sy1xx series uart. Driver for Sensry Sy1xx series uart.

View file

@ -11,10 +11,12 @@
#include <zephyr/sys/printk.h> #include <zephyr/sys/printk.h>
#include <udma.h> #include <udma.h>
#include <pad_ctrl.h> #include <pad_ctrl.h>
#include <zephyr/drivers/pinctrl.h>
struct sy1xx_uart_config { struct sy1xx_uart_config {
uint32_t base; uint32_t base;
uint32_t inst; uint32_t inst;
const struct pinctrl_dev_config *pcfg;
}; };
typedef struct { typedef struct {
@ -259,28 +261,11 @@ static int sy1xx_uart_init(const struct device *dev)
sy1xx_udma_enable_clock(SY1XX_UDMA_MODULE_UART, config->inst); sy1xx_udma_enable_clock(SY1XX_UDMA_MODULE_UART, config->inst);
/* PAD config */ /* PAD config */
uint32_t pad_config_tx = int32_t ret = pinctrl_apply_state(config->pcfg, PINCTRL_STATE_DEFAULT);
SY1XX_PAD_CONFIG(0, SY1XX_PAD_SMT_DISABLE, SY1XX_PAD_SLEW_LOW, SY1XX_PAD_PULLUP_DIS,
SY1XX_PAD_PULLDOWN_DIS, SY1XX_PAD_DRIVE_2PF, SY1XX_PAD_PMOD_NORMAL,
SY1XX_PAD_DIR_OUTPUT);
uint32_t pad_config_rx = if (ret < 0) {
SY1XX_PAD_CONFIG(8, SY1XX_PAD_SMT_DISABLE, SY1XX_PAD_SLEW_LOW, SY1XX_PAD_PULLUP_DIS, return ret;
SY1XX_PAD_PULLDOWN_DIS, SY1XX_PAD_DRIVE_2PF, SY1XX_PAD_PMOD_NORMAL, }
SY1XX_PAD_DIR_INPUT);
uint32_t pad_config_cts =
SY1XX_PAD_CONFIG(16, SY1XX_PAD_SMT_DISABLE, SY1XX_PAD_SLEW_LOW, SY1XX_PAD_PULLUP_EN,
SY1XX_PAD_PULLDOWN_DIS, SY1XX_PAD_DRIVE_2PF, SY1XX_PAD_PMOD_NORMAL,
SY1XX_PAD_DIR_INPUT);
uint32_t pad_config_rts =
SY1XX_PAD_CONFIG(24, SY1XX_PAD_SMT_DISABLE, SY1XX_PAD_SLEW_LOW,
SY1XX_PAD_PULLUP_DIS, SY1XX_PAD_PULLDOWN_DIS, SY1XX_PAD_DRIVE_2PF,
SY1XX_PAD_PMOD_NORMAL, SY1XX_PAD_DIR_OUTPUT);
sys_write32((pad_config_tx | pad_config_rx | pad_config_cts | pad_config_rts),
SY1XX_PAD_CONFIG_ADDR_UART + (config->inst * 4 + 0));
sy1xx_uartConfig_t default_config = { sy1xx_uartConfig_t default_config = {
.baudrate = 1000000, .baudrate = 1000000,
@ -306,9 +291,12 @@ static DEVICE_API(uart, sy1xx_uart_driver_api) = {
#define SYS1XX_UART_INIT(n) \ #define SYS1XX_UART_INIT(n) \
\ \
PINCTRL_DT_INST_DEFINE(n); \
\
static const struct sy1xx_uart_config sy1xx_uart_##n##_cfg = { \ static const struct sy1xx_uart_config sy1xx_uart_##n##_cfg = { \
.base = (uint32_t)DT_INST_REG_ADDR(n), \ .base = (uint32_t)DT_INST_REG_ADDR(n), \
.inst = (uint32_t)DT_INST_PROP(n, instance), \ .inst = (uint32_t)DT_INST_PROP(n, instance), \
.pcfg = PINCTRL_DT_INST_DEV_CONFIG_GET(n), \
}; \ }; \
\ \
static struct sy1xx_uart_data __attribute__((section(".udma_access"))) \ static struct sy1xx_uart_data __attribute__((section(".udma_access"))) \

View file

@ -5,7 +5,7 @@ description: Sensry SY1xx UART
compatible: "sensry,sy1xx-uart" compatible: "sensry,sy1xx-uart"
include: uart-controller.yaml include: [uart-controller.yaml, pinctrl-device.yaml]
properties: properties:
reg: reg: