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

@ -1,6 +0,0 @@
#
# Copyright (c) 2020 ITE Corporation. All Rights Reserved.
#
# SPDX-License-Identifier: Apache-2.0
zephyr_library()
zephyr_library_sources(pinmux.c)

View file

@ -8,6 +8,7 @@
#include <dt-bindings/gpio/gpio.h>
#include <it8xxx2.dtsi>
#include <it8xxx2-alts-map.dtsi>
#include <ite/it8xxx2-pinctrl-map.dtsi>
/ {
model = "IT8XXX2 EV-Board";
@ -91,9 +92,15 @@
};
&ite_uart1_wrapper {
status = "okay";
pinctrl-0 = <&uart1_rx_gpb0_default
&uart1_tx_gpb1_default>;
pinctrl-names = "default";
};
&ite_uart2_wrapper {
status = "okay";
pinctrl-0 = <&uart2_rx_gph1_default
&uart2_tx_gph2_default>;
pinctrl-names = "default";
};
/* pwm for test */
&pwm0 {

View file

@ -1,47 +0,0 @@
/*
* Copyright (c) 2020 ITE Corporation. All Rights Reserved.
*
* SPDX-License-Identifier: Apache-2.0
*
*/
#include <init.h>
#include <drivers/pinmux.h>
#include <dt-bindings/pinctrl/it8xxx2-pinctrl.h>
static int it8xxx2_evb_pinmux_init(const struct device *dev)
{
ARG_UNUSED(dev);
#if DT_NODE_HAS_STATUS(DT_NODELABEL(pinmuxb), okay)
const struct device *portb = DEVICE_DT_GET(DT_NODELABEL(pinmuxb));
__ASSERT_NO_MSG(device_is_ready(portb));
#endif
#if DT_NODE_HAS_STATUS(DT_NODELABEL(pinmuxh), okay)
const struct device *porth = DEVICE_DT_GET(DT_NODELABEL(pinmuxh));
__ASSERT_NO_MSG(device_is_ready(porth));
#endif
#if DT_NODE_HAS_STATUS(DT_NODELABEL(uart1), okay)
/* SIN0 */
pinmux_pin_set(portb, 0, IT8XXX2_PINMUX_FUNC_3);
/* SOUT0 */
pinmux_pin_set(portb, 1, IT8XXX2_PINMUX_FUNC_3);
/* Pullup SIN0 to received data */
pinmux_pin_pullup(portb, 0, PINMUX_PULLUP_ENABLE);
#endif /* DT_NODE_HAS_STATUS(DT_NODELABEL(uart1), okay) */
#if DT_NODE_HAS_STATUS(DT_NODELABEL(uart2), okay)
/* SIN1 */
pinmux_pin_set(porth, 1, IT8XXX2_PINMUX_FUNC_4);
/* SOUT1 */
pinmux_pin_set(porth, 2, IT8XXX2_PINMUX_FUNC_4);
/* Pullup SIN1 to received data */
pinmux_pin_pullup(porth, 1, PINMUX_PULLUP_ENABLE);
#endif /* DT_NODE_HAS_STATUS(DT_NODELABEL(uart2), okay) */
return 0;
}
SYS_INIT(it8xxx2_evb_pinmux_init, PRE_KERNEL_1, CONFIG_PINMUX_INIT_PRIORITY);

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; \

View file

@ -5,7 +5,7 @@ description: ITE, IT8XXX2-UART node
compatible: "ite,it8xxx2-uart"
include: uart-controller.yaml
include: [uart-controller.yaml, pinctrl-device.yaml]
properties:
reg:
@ -24,3 +24,9 @@ properties:
type: phandle
required: true
description: Get the handle of the UART device
pinctrl-0:
required: true
pinctrl-names:
required: true

View file

@ -0,0 +1,24 @@
/*
* Copyright (c) 2022 ITE Corporation. All Rights Reserved.
*
* SPDX-License-Identifier: Apache-2.0
*/
#include <dt-bindings/pinctrl/it8xxx2-pinctrl.h>
&pinctrl {
/* UART alternate function */
uart1_rx_gpb0_default: uart1_rx_gpb0_default {
pinmuxs = <&pinctrlb 0 IT8XXX2_ALT_FUNC_3>;
};
uart1_tx_gpb1_default: uart1_tx_gpb1_default {
pinmuxs = <&pinctrlb 1 IT8XXX2_ALT_FUNC_3>;
};
uart2_rx_gph1_default: uart2_rx_gph1_default {
pinmuxs = <&pinctrlh 1 IT8XXX2_ALT_FUNC_4>;
};
uart2_tx_gph2_default: uart2_tx_gph2_default {
pinmuxs = <&pinctrlh 2 IT8XXX2_ALT_FUNC_4>;
};
};