ITE: drivers/serial: Use pinctrl instead of pinmux driver

Use pinctrl instead of pinmux driver.

Signed-off-by: Tim Lin <tim2.lin@ite.corp-partner.google.com>
This commit is contained in:
Tim Lin 2022-03-30 17:41:17 +08:00 committed by Carles Cufí
commit 07d9a4292d
6 changed files with 53 additions and 55 deletions

View file

@ -8,6 +8,7 @@
#include <device.h>
#include <drivers/gpio.h>
#include <drivers/pinctrl.h>
#include <drivers/uart.h>
#include <kernel.h>
#include <pm/device.h>
@ -27,6 +28,8 @@ struct uart_it8xxx2_config {
struct gpio_dt_spec gpio_wui;
/* UART handle */
const struct device *uart_dev;
/* UART alternate configuration */
const struct pinctrl_dev_config *pcfg;
};
struct uart_it8xxx2_data {
@ -124,8 +127,17 @@ static void uart_it8xxx2_rx_refresh_timeout(struct k_work *work)
static int uart_it8xxx2_init(const struct device *dev)
{
#ifdef CONFIG_PM_DEVICE
const struct uart_it8xxx2_config *const config = dev->config;
int status;
/* Set the pin to UART alternate function. */
status = pinctrl_apply_state(config->pcfg, PINCTRL_STATE_DEFAULT);
if (status < 0) {
LOG_ERR("Failed to configure UART pins");
return status;
}
#ifdef CONFIG_PM_DEVICE
const struct device *uart_console_dev =
DEVICE_DT_GET(DT_CHOSEN(zephyr_console));
int ret = 0;
@ -175,10 +187,12 @@ static int uart_it8xxx2_init(const struct device *dev)
}
#define UART_ITE_IT8XXX2_INIT(inst) \
PINCTRL_DT_INST_DEFINE(inst); \
static const struct uart_it8xxx2_config uart_it8xxx2_cfg_##inst = { \
.port = DT_INST_PROP(inst, port_num), \
.gpio_wui = GPIO_DT_SPEC_INST_GET(inst, gpios), \
.uart_dev = DEVICE_DT_GET(DT_INST_PHANDLE(inst, uart_dev)), \
.pcfg = PINCTRL_DT_INST_DEV_CONFIG_GET(inst), \
}; \
\
static struct uart_it8xxx2_data uart_it8xxx2_data_##inst; \