drivers: serial: enable pin control for lpc11u6x serial driver
Enable pin control api for lpc11u6x serial driver, and remove pinmux api usage. Signed-off-by: Daniel DeGrasse <daniel.degrasse@nxp.com>
This commit is contained in:
parent
069280c8a4
commit
7e89ce9f19
5 changed files with 24 additions and 70 deletions
|
@ -51,8 +51,6 @@
|
||||||
};
|
};
|
||||||
|
|
||||||
&uart0 {
|
&uart0 {
|
||||||
pinmuxs = <&pinmux0 18 IOCON_FUNC1>, <&pinmux0 19 IOCON_FUNC1>;
|
|
||||||
pinmux-names = "RXD", "TXD";
|
|
||||||
pinctrl-0 = <&uart0_default>;
|
pinctrl-0 = <&uart0_default>;
|
||||||
pinctrl-names = "default";
|
pinctrl-names = "default";
|
||||||
current-speed = <115200>;
|
current-speed = <115200>;
|
||||||
|
|
|
@ -89,8 +89,6 @@
|
||||||
};
|
};
|
||||||
|
|
||||||
&uart0 {
|
&uart0 {
|
||||||
pinmuxs = <&pinmux1 26 IOCON_FUNC2>, <&pinmux1 27 IOCON_FUNC2>;
|
|
||||||
pinmux-names = "RXD", "TXD";
|
|
||||||
pinctrl-0 = <&uart0_default>;
|
pinctrl-0 = <&uart0_default>;
|
||||||
pinctrl-names = "default";
|
pinctrl-names = "default";
|
||||||
current-speed = <115200>;
|
current-speed = <115200>;
|
||||||
|
@ -98,8 +96,6 @@
|
||||||
};
|
};
|
||||||
|
|
||||||
arduino_serial: &uart4 {
|
arduino_serial: &uart4 {
|
||||||
pinmuxs = <&pinmux2 11 IOCON_FUNC1>, <&pinmux2 12 IOCON_FUNC1>;
|
|
||||||
pinmux-names = "RXD", "TXD";
|
|
||||||
pinctrl-0 = <&uart4_default>;
|
pinctrl-0 = <&uart4_default>;
|
||||||
pinctrl-names = "default";
|
pinctrl-names = "default";
|
||||||
current-speed = <115200>;
|
current-speed = <115200>;
|
||||||
|
|
|
@ -8,7 +8,6 @@
|
||||||
#include <zephyr/arch/arm/aarch32/cortex_m/cmsis.h>
|
#include <zephyr/arch/arm/aarch32/cortex_m/cmsis.h>
|
||||||
|
|
||||||
#include <zephyr/drivers/uart.h>
|
#include <zephyr/drivers/uart.h>
|
||||||
#include <zephyr/drivers/pinmux.h>
|
|
||||||
#include <zephyr/drivers/clock_control.h>
|
#include <zephyr/drivers/clock_control.h>
|
||||||
|
|
||||||
#include "uart_lpc11u6x.h"
|
#include "uart_lpc11u6x.h"
|
||||||
|
@ -345,20 +344,14 @@ static int lpc11u6x_uart0_init(const struct device *dev)
|
||||||
{
|
{
|
||||||
const struct lpc11u6x_uart0_config *cfg = dev->config;
|
const struct lpc11u6x_uart0_config *cfg = dev->config;
|
||||||
struct lpc11u6x_uart0_data *data = dev->data;
|
struct lpc11u6x_uart0_data *data = dev->data;
|
||||||
const struct device *clk_drv, *rx_pinmux_drv, *tx_pinmux_drv;
|
const struct device *clk_drv;
|
||||||
|
int err;
|
||||||
|
|
||||||
/* Configure RX and TX pin via the pinmux driver */
|
/* Apply default pin control state to select RX and TX pins */
|
||||||
rx_pinmux_drv = device_get_binding(cfg->rx_pinmux_drv_name);
|
err = pinctrl_apply_state(cfg->pincfg, PINCTRL_STATE_DEFAULT);
|
||||||
if (!rx_pinmux_drv) {
|
if (err) {
|
||||||
return -EINVAL;
|
return err;
|
||||||
}
|
}
|
||||||
pinmux_pin_set(rx_pinmux_drv, cfg->rx_pin, cfg->rx_func);
|
|
||||||
|
|
||||||
tx_pinmux_drv = device_get_binding(cfg->tx_pinmux_drv_name);
|
|
||||||
if (!tx_pinmux_drv) {
|
|
||||||
return -EINVAL;
|
|
||||||
}
|
|
||||||
pinmux_pin_set(tx_pinmux_drv, cfg->tx_pin, cfg->tx_func);
|
|
||||||
|
|
||||||
/* Call clock driver to initialize uart0 clock */
|
/* Call clock driver to initialize uart0 clock */
|
||||||
clk_drv = device_get_binding(cfg->clock_drv_name);
|
clk_drv = device_get_binding(cfg->clock_drv_name);
|
||||||
|
@ -392,19 +385,14 @@ static int lpc11u6x_uart0_init(const struct device *dev)
|
||||||
static void lpc11u6x_uart0_isr_config(const struct device *dev);
|
static void lpc11u6x_uart0_isr_config(const struct device *dev);
|
||||||
#endif /* CONFIG_UART_INTERRUPT_DRIVEN */
|
#endif /* CONFIG_UART_INTERRUPT_DRIVEN */
|
||||||
|
|
||||||
|
PINCTRL_DT_DEFINE(DT_NODELABEL(uart0));
|
||||||
|
|
||||||
static const struct lpc11u6x_uart0_config uart0_config = {
|
static const struct lpc11u6x_uart0_config uart0_config = {
|
||||||
.uart0 = (struct lpc11u6x_uart0_regs *)
|
.uart0 = (struct lpc11u6x_uart0_regs *)
|
||||||
DT_REG_ADDR(DT_NODELABEL(uart0)),
|
DT_REG_ADDR(DT_NODELABEL(uart0)),
|
||||||
.clock_drv_name = DT_LABEL(DT_PHANDLE(DT_NODELABEL(uart0), clocks)),
|
.clock_drv_name = DT_LABEL(DT_PHANDLE(DT_NODELABEL(uart0), clocks)),
|
||||||
.rx_pinmux_drv_name =
|
.pincfg = PINCTRL_DT_DEV_CONFIG_GET(DT_NODELABEL(uart0)),
|
||||||
DT_LABEL(DT_PHANDLE_BY_NAME(DT_NODELABEL(uart0), pinmuxs, rxd)),
|
|
||||||
.tx_pinmux_drv_name =
|
|
||||||
DT_LABEL(DT_PHANDLE_BY_NAME(DT_NODELABEL(uart0), pinmuxs, txd)),
|
|
||||||
.clkid = DT_PHA_BY_IDX(DT_NODELABEL(uart0), clocks, 0, clkid),
|
.clkid = DT_PHA_BY_IDX(DT_NODELABEL(uart0), clocks, 0, clkid),
|
||||||
.rx_pin = DT_PHA_BY_NAME(DT_NODELABEL(uart0), pinmuxs, rxd, pin),
|
|
||||||
.rx_func = DT_PHA_BY_NAME(DT_NODELABEL(uart0), pinmuxs, rxd, function),
|
|
||||||
.tx_pin = DT_PHA_BY_NAME(DT_NODELABEL(uart0), pinmuxs, txd, pin),
|
|
||||||
.tx_func = DT_PHA_BY_NAME(DT_NODELABEL(uart0), pinmuxs, txd, function),
|
|
||||||
.baudrate = DT_PROP(DT_NODELABEL(uart0), current_speed),
|
.baudrate = DT_PROP(DT_NODELABEL(uart0), current_speed),
|
||||||
#ifdef CONFIG_UART_INTERRUPT_DRIVEN
|
#ifdef CONFIG_UART_INTERRUPT_DRIVEN
|
||||||
.irq_config_func = lpc11u6x_uart0_isr_config,
|
.irq_config_func = lpc11u6x_uart0_isr_config,
|
||||||
|
@ -791,20 +779,14 @@ static int lpc11u6x_uartx_init(const struct device *dev)
|
||||||
{
|
{
|
||||||
const struct lpc11u6x_uartx_config *cfg = dev->config;
|
const struct lpc11u6x_uartx_config *cfg = dev->config;
|
||||||
struct lpc11u6x_uartx_data *data = dev->data;
|
struct lpc11u6x_uartx_data *data = dev->data;
|
||||||
const struct device *clk_drv, *rx_pinmux_drv, *tx_pinmux_drv;
|
const struct device *clk_drv;
|
||||||
|
int err;
|
||||||
|
|
||||||
/* Configure RX and TX pin via the pinmux driver */
|
/* Apply default pin control state to select RX and TX pins */
|
||||||
rx_pinmux_drv = device_get_binding(cfg->rx_pinmux_drv_name);
|
err = pinctrl_apply_state(cfg->pincfg, PINCTRL_STATE_DEFAULT);
|
||||||
if (!rx_pinmux_drv) {
|
if (err) {
|
||||||
return -EINVAL;
|
return err;
|
||||||
}
|
}
|
||||||
pinmux_pin_set(rx_pinmux_drv, cfg->rx_pin, cfg->rx_func);
|
|
||||||
|
|
||||||
tx_pinmux_drv = device_get_binding(cfg->tx_pinmux_drv_name);
|
|
||||||
if (!tx_pinmux_drv) {
|
|
||||||
return -EINVAL;
|
|
||||||
}
|
|
||||||
pinmux_pin_set(tx_pinmux_drv, cfg->tx_pin, cfg->tx_func);
|
|
||||||
|
|
||||||
/* Call clock driver to initialize uart0 clock */
|
/* Call clock driver to initialize uart0 clock */
|
||||||
clk_drv = device_get_binding(cfg->clock_drv_name);
|
clk_drv = device_get_binding(cfg->clock_drv_name);
|
||||||
|
@ -874,25 +856,15 @@ static const struct uart_driver_api uartx_api = {
|
||||||
|
|
||||||
|
|
||||||
#define LPC11U6X_UARTX_INIT(idx) \
|
#define LPC11U6X_UARTX_INIT(idx) \
|
||||||
|
PINCTRL_DT_DEFINE(DT_NODELABEL(uart##idx)); \
|
||||||
\
|
\
|
||||||
static const struct lpc11u6x_uartx_config uart_cfg_##idx = { \
|
static const struct lpc11u6x_uartx_config uart_cfg_##idx = { \
|
||||||
.base = (struct lpc11u6x_uartx_regs *) \
|
.base = (struct lpc11u6x_uartx_regs *) \
|
||||||
DT_REG_ADDR(DT_NODELABEL(uart##idx)), \
|
DT_REG_ADDR(DT_NODELABEL(uart##idx)), \
|
||||||
.clock_drv_name = \
|
.clock_drv_name = \
|
||||||
DT_LABEL(DT_PHANDLE(DT_NODELABEL(uart##idx), clocks)), \
|
DT_LABEL(DT_PHANDLE(DT_NODELABEL(uart##idx), clocks)), \
|
||||||
.rx_pinmux_drv_name = \
|
|
||||||
DT_LABEL(DT_PHANDLE_BY_NAME(DT_NODELABEL(uart##idx), pinmuxs, rxd)), \
|
|
||||||
.tx_pinmux_drv_name = \
|
|
||||||
DT_LABEL(DT_PHANDLE_BY_NAME(DT_NODELABEL(uart##idx), pinmuxs, txd)), \
|
|
||||||
.clkid = DT_PHA_BY_IDX(DT_NODELABEL(uart##idx), clocks, 0, clkid), \
|
.clkid = DT_PHA_BY_IDX(DT_NODELABEL(uart##idx), clocks, 0, clkid), \
|
||||||
.rx_pin = DT_PHA_BY_NAME(DT_NODELABEL(uart##idx), pinmuxs, rxd, pin), \
|
.pincfg = PINCTRL_DT_DEV_CONFIG_GET(DT_NODELABEL(uart##idx)), \
|
||||||
.rx_func = DT_PHA_BY_NAME(DT_NODELABEL(uart##idx), \
|
|
||||||
pinmuxs, rxd, function), \
|
|
||||||
.rx_func = DT_PHA_BY_NAME(DT_NODELABEL(uart##idx), pinmuxs, \
|
|
||||||
rxd, function), \
|
|
||||||
.tx_pin = DT_PHA_BY_NAME(DT_NODELABEL(uart##idx), pinmuxs, txd, pin), \
|
|
||||||
.tx_func = DT_PHA_BY_NAME(DT_NODELABEL(uart##idx), pinmuxs, \
|
|
||||||
txd, function), \
|
|
||||||
.baudrate = DT_PROP(DT_NODELABEL(uart##idx), current_speed), \
|
.baudrate = DT_PROP(DT_NODELABEL(uart##idx), current_speed), \
|
||||||
}; \
|
}; \
|
||||||
\
|
\
|
||||||
|
|
|
@ -7,6 +7,8 @@
|
||||||
#ifndef ZEPHYR_DRIVERS_SERIAL_UART_LPC11U6X_H_
|
#ifndef ZEPHYR_DRIVERS_SERIAL_UART_LPC11U6X_H_
|
||||||
#define ZEPHYR_DRIVERS_SERIAL_UART_LPC11U6X_H_
|
#define ZEPHYR_DRIVERS_SERIAL_UART_LPC11U6X_H_
|
||||||
|
|
||||||
|
#include <zephyr/drivers/pinctrl.h>
|
||||||
|
|
||||||
#define LPC11U6X_UART0_CLK 14745600
|
#define LPC11U6X_UART0_CLK 14745600
|
||||||
|
|
||||||
#define LPC11U6X_UART0_LCR_WLS_5BITS 0
|
#define LPC11U6X_UART0_LCR_WLS_5BITS 0
|
||||||
|
@ -127,14 +129,9 @@ struct lpc11u6x_uart0_regs {
|
||||||
struct lpc11u6x_uart0_config {
|
struct lpc11u6x_uart0_config {
|
||||||
struct lpc11u6x_uart0_regs *uart0;
|
struct lpc11u6x_uart0_regs *uart0;
|
||||||
const char *clock_drv_name;
|
const char *clock_drv_name;
|
||||||
const char *rx_pinmux_drv_name;
|
|
||||||
const char *tx_pinmux_drv_name;
|
|
||||||
uint32_t baudrate;
|
uint32_t baudrate;
|
||||||
uint32_t clkid;
|
uint32_t clkid;
|
||||||
uint8_t rx_pin;
|
const struct pinctrl_dev_config *pincfg;
|
||||||
uint8_t rx_func;
|
|
||||||
uint8_t tx_pin;
|
|
||||||
uint8_t tx_func;
|
|
||||||
#ifdef CONFIG_UART_INTERRUPT_DRIVEN
|
#ifdef CONFIG_UART_INTERRUPT_DRIVEN
|
||||||
void (*irq_config_func)(const struct device *dev);
|
void (*irq_config_func)(const struct device *dev);
|
||||||
#endif /* CONFIG_UART_INTERRUPT_DRIVEN */
|
#endif /* CONFIG_UART_INTERRUPT_DRIVEN */
|
||||||
|
@ -171,14 +168,9 @@ struct lpc11u6x_uartx_regs {
|
||||||
struct lpc11u6x_uartx_config {
|
struct lpc11u6x_uartx_config {
|
||||||
struct lpc11u6x_uartx_regs *base;
|
struct lpc11u6x_uartx_regs *base;
|
||||||
const char *clock_drv_name;
|
const char *clock_drv_name;
|
||||||
const char *rx_pinmux_drv_name;
|
|
||||||
const char *tx_pinmux_drv_name;
|
|
||||||
uint32_t baudrate;
|
uint32_t baudrate;
|
||||||
uint32_t clkid;
|
uint32_t clkid;
|
||||||
uint8_t rx_pin;
|
const struct pinctrl_dev_config *pincfg;
|
||||||
uint8_t rx_func;
|
|
||||||
uint8_t tx_pin;
|
|
||||||
uint8_t tx_func;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
struct lpc11u6x_uartx_data {
|
struct lpc11u6x_uartx_data {
|
||||||
|
|
|
@ -2,7 +2,7 @@ description: LPC11U6X UART
|
||||||
|
|
||||||
compatible: "nxp,lpc11u6x-uart"
|
compatible: "nxp,lpc11u6x-uart"
|
||||||
|
|
||||||
include: uart-controller.yaml
|
include: [uart-controller.yaml, pinctrl-device.yaml]
|
||||||
|
|
||||||
properties:
|
properties:
|
||||||
reg:
|
reg:
|
||||||
|
@ -14,12 +14,8 @@ properties:
|
||||||
clocks:
|
clocks:
|
||||||
required: true
|
required: true
|
||||||
|
|
||||||
pinmuxs:
|
pinctrl-0:
|
||||||
type: phandle-array
|
|
||||||
required: true
|
required: true
|
||||||
description: RX and TX pinmux
|
|
||||||
|
|
||||||
pinmux-names:
|
pinctrl-names:
|
||||||
type: string-array
|
|
||||||
required: true
|
required: true
|
||||||
description: UART pins names
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue