Skip to content

Commit

Permalink
drivers: serial: RCar add pinctrl support
Browse files Browse the repository at this point in the history
Get pin configuration from device tree to
set alternate pin function.

Signed-off-by: Aymeric Aillet <[email protected]>
  • Loading branch information
aaillet authored and nashif committed Jan 18, 2022
1 parent 873607c commit 37f5fe5
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
10 changes: 10 additions & 0 deletions drivers/serial/uart_rcar.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,15 @@
#include <drivers/uart.h>
#include <drivers/clock_control.h>
#include <drivers/clock_control/rcar_clock_control.h>
#include <drivers/pinctrl.h>
#include <spinlock.h>

struct uart_rcar_cfg {
uint32_t reg_addr;
const struct device *clock_dev;
struct rcar_cpg_clk mod_clk;
struct rcar_cpg_clk bus_clk;
const struct pinctrl_dev_config *pcfg;
#ifdef CONFIG_UART_INTERRUPT_DRIVEN
void (*irq_config_func)(const struct device *dev);
#endif
Expand Down Expand Up @@ -271,6 +273,12 @@ static int uart_rcar_init(const struct device *dev)
struct uart_rcar_data *data = DEV_UART_DATA(dev);
int ret;

/* Configure dt provided device signals when available */
ret = pinctrl_apply_state(config->pcfg, PINCTRL_STATE_DEFAULT);
if (ret < 0) {
return ret;
}

ret = clock_control_on(config->clock_dev,
(clock_control_subsys_t *)&config->mod_clk);
if (ret < 0) {
Expand Down Expand Up @@ -527,6 +535,7 @@ static const struct uart_driver_api uart_rcar_driver_api = {

/* Device Instantiation */
#define UART_RCAR_DECLARE_CFG(n, IRQ_FUNC_INIT) \
PINCTRL_DT_INST_DEFINE(n); \
static const struct uart_rcar_cfg uart_rcar_cfg_##n = { \
.reg_addr = DT_INST_REG_ADDR(n), \
.clock_dev = DEVICE_DT_GET(DT_INST_CLOCKS_CTLR(n)), \
Expand All @@ -538,6 +547,7 @@ static const struct uart_driver_api uart_rcar_driver_api = {
DT_INST_CLOCKS_CELL_BY_IDX(n, 1, module), \
.bus_clk.domain = \
DT_INST_CLOCKS_CELL_BY_IDX(n, 1, domain), \
.pcfg = PINCTRL_DT_INST_DEV_CONFIG_GET(n), \
IRQ_FUNC_INIT \
}

Expand Down
2 changes: 1 addition & 1 deletion dts/bindings/serial/renesas,rcar-scif.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ description: Renesas R-Car UART controller

compatible: "renesas,rcar-scif"

include: uart-controller.yaml
include: [uart-controller.yaml, pinctrl-device.yaml]

properties:
reg:
Expand Down

0 comments on commit 37f5fe5

Please sign in to comment.