Skip to content

Commit be6abc3

Browse files
nhutnguyenkckartben
authored andcommitted
drivers: pinctrl: Add support for RZ/T2L
This is the initial commit to support PINCTRL driver for Renesas RZ/T2L Signed-off-by: Nhut Nguyen <[email protected]> Signed-off-by: Hieu Nguyen <[email protected]>
1 parent ba02843 commit be6abc3

File tree

6 files changed

+238
-1
lines changed

6 files changed

+238
-1
lines changed
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
/*
2+
* Copyright (c) 2025 Renesas Electronics Corporation
3+
* SPDX-License-Identifier: Apache-2.0
4+
*/
5+
6+
#include <zephyr/dt-bindings/gpio/gpio.h>
7+
#include <zephyr/dt-bindings/pinctrl/renesas/pinctrl-rzt-common.h>
8+
9+
&pinctrl {
10+
/omit-if-no-ref/ sci0_default: sci0_default {
11+
sci0-pinmux {
12+
pinmux = <RZT_PINMUX(PORT_16, 0, 2)>, /* TXD */
13+
<RZT_PINMUX(PORT_16, 1, 3)>; /* RXD */
14+
};
15+
};
16+
17+
/omit-if-no-ref/ irq7_default: irq7_default {
18+
irq7-pinmux {
19+
pinmux = <RZT_PINMUX(PORT_16, 3, 0)>;
20+
input-enable;
21+
};
22+
};
23+
};

drivers/pinctrl/renesas/rz/Kconfig

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@ config PINCTRL_RZT2M
1212
config PINCTRL_RENESAS_RZ
1313
bool "Renesas RZ pin controller driver"
1414
default y
15-
depends on DT_HAS_RENESAS_RZG_PINCTRL_ENABLED || DT_HAS_RENESAS_RZN_PINCTRL_ENABLED
15+
depends on DT_HAS_RENESAS_RZG_PINCTRL_ENABLED \
16+
|| DT_HAS_RENESAS_RZN_PINCTRL_ENABLED \
17+
|| DT_HAS_RENESAS_RZT_PINCTRL_ENABLED
1618
select USE_RZ_FSP_IOPORT
1719
help
1820
Enable Renesas RZ pinctrl driver.

dts/arm/renesas/rz/rzt/r9a07g074.dtsi

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,5 +88,10 @@
8888
};
8989
};
9090
};
91+
92+
pinctrl: pinctrl@800a0000 {
93+
compatible = "renesas,rzt-pinctrl";
94+
reg = <0x800a0000 0x1000 0x81030c00 0x1000>;
95+
};
9196
};
9297
};
Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
# Copyright (c) 2025 Renesas Electronics Corporation
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
description: |
5+
The Renesas RZ/T2L pin controller is a node responsible for controlling
6+
pin function selection and pin properties, such as routing the TX and RX of UART0
7+
to pin 5 and pin 6 of port 16.
8+
9+
The node has the 'pinctrl' node label set in your SoC's devicetree,
10+
so you can modify it like this:
11+
12+
&pinctrl {
13+
/* your modifications go here */
14+
};
15+
16+
All device pin configurations should be placed in child nodes of the
17+
'pinctrl' node, as shown in this example:
18+
19+
/* You can put this in places like a board-pinctrl.dtsi file in
20+
* your board directory, or a devicetree overlay in your application.
21+
*/
22+
23+
/* include pre-defined combinations for the SoC variant used by the board */
24+
#include <zephyr/dt-bindings/pinctrl/renesas/pinctrl-rzt-common.h>
25+
26+
&pinctrl {
27+
uart0_default: uart0_default {
28+
group1 {
29+
pinmux = <RZT_PINMUX(PORT_16, 5, 1)>;
30+
};
31+
group2 {
32+
pinmux = <RZT_PINMUX(PORT_16, 6, 2)>;
33+
input-enable;
34+
};
35+
};
36+
};
37+
38+
The 'uart0_default' child node encodes the pin configurations for a
39+
particular state of a device; in this case, the default (that is, active)
40+
state.
41+
42+
As shown, pin configurations are organized in groups within each child node.
43+
Each group can specify a list of pin function selections in the 'pinmux'
44+
property.
45+
46+
A group can also specify shared pin properties common to all the specified
47+
pins, such as the 'input-enable' property in group 2.
48+
49+
compatible: "renesas,rzt-pinctrl"
50+
51+
include: base.yaml
52+
53+
child-binding:
54+
description: |
55+
Definitions for a pinctrl state.
56+
child-binding:
57+
58+
include:
59+
- name: pincfg-node.yaml
60+
property-allowlist:
61+
- input-enable
62+
- output-enable
63+
- output-high
64+
- bias-pull-up
65+
- bias-pull-down
66+
- input-schmitt-enable
67+
68+
properties:
69+
pinmux:
70+
required: true
71+
type: array
72+
description: |
73+
An array of pins sharing the same group properties. Each
74+
element of the array is an integer constructed from the
75+
pin number and the alternative function of the pin.
76+
drive-strength:
77+
type: string
78+
enum:
79+
- "low"
80+
- "middle"
81+
- "high"
82+
- "ultrahigh"
83+
default: "low"
84+
description: |
85+
The drive strength of a pin, relative to full-driver strength.
86+
The default value is "low", which is the reset value.
87+
slew-rate:
88+
type: string
89+
enum:
90+
- "slow"
91+
- "fast"
92+
default: "slow"
93+
description: |
94+
Select slew rate for a pin. The default is slow, which is the reset value.
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
/*
2+
* Copyright (c) 2025 Renesas Electronics Corporation
3+
* SPDX-License-Identifier: Apache-2.0
4+
*/
5+
6+
#ifndef ZEPHYR_INCLUDE_DT_BINDINGS_PINCTRL_RENESAS_PINCTRL_RZT_COMMON_H_
7+
#define ZEPHYR_INCLUDE_DT_BINDINGS_PINCTRL_RENESAS_PINCTRL_RZT_COMMON_H_
8+
9+
/* Superset list of all possible IO ports. */
10+
#define PORT_00 0x0000 /* IO port 0 */
11+
#define PORT_01 0x0100 /* IO port 1 */
12+
#define PORT_02 0x0200 /* IO port 2 */
13+
#define PORT_03 0x0300 /* IO port 3 */
14+
#define PORT_04 0x0400 /* IO port 4 */
15+
#define PORT_05 0x0500 /* IO port 5 */
16+
#define PORT_06 0x0600 /* IO port 6 */
17+
#define PORT_07 0x0700 /* IO port 7 */
18+
#define PORT_08 0x0800 /* IO port 8 */
19+
#define PORT_09 0x0900 /* IO port 9 */
20+
#define PORT_10 0x0A00 /* IO port 10 */
21+
#define PORT_11 0x0B00 /* IO port 11 */
22+
#define PORT_12 0x0C00 /* IO port 12 */
23+
#define PORT_13 0x0D00 /* IO port 13 */
24+
#define PORT_14 0x0E00 /* IO port 14 */
25+
#define PORT_15 0x0F00 /* IO port 15 */
26+
#define PORT_16 0x1000 /* IO port 16 */
27+
#define PORT_17 0x1100 /* IO port 17 */
28+
#define PORT_18 0x1200 /* IO port 18 */
29+
#define PORT_19 0x1300 /* IO port 19 */
30+
#define PORT_20 0x1400 /* IO port 20 */
31+
#define PORT_21 0x1500 /* IO port 21 */
32+
#define PORT_22 0x1600 /* IO port 22 */
33+
#define PORT_23 0x1700 /* IO port 23 */
34+
#define PORT_24 0x1800 /* IO port 24 */
35+
36+
/*
37+
* Create the value contain port/pin/function information
38+
*
39+
* port: port number BSP_IO_PORT_00..BSP_IO_PORT_24
40+
* pin: pin number
41+
* func: pin function
42+
*/
43+
#define RZT_PINMUX(port, pin, func) (port | pin | (func << 4))
44+
45+
#endif /*ZEPHYR_INCLUDE_DT_BINDINGS_PINCTRL_RENESAS_PINCTRL_RZT_COMMON_H_*/
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
/*
2+
* Copyright (c) 2025 Renesas Electronics Corporation
3+
* SPDX-License-Identifier: Apache-2.0
4+
*/
5+
#ifndef ZEPHYR_SOC_RENESAS_RZ_COMMON_PINCTRL_RZT_H_
6+
#define ZEPHYR_SOC_RENESAS_RZ_COMMON_PINCTRL_RZT_H_
7+
8+
#include <zephyr/types.h>
9+
#include <zephyr/devicetree.h>
10+
#include "r_ioport.h"
11+
12+
#ifdef __cplusplus
13+
extern "C" {
14+
#endif
15+
16+
#define RZT_GET_PORT_PIN(pinmux) (pinmux & ~(0xF << 4))
17+
#define RZT_GET_FUNC(pinmux) ((pinmux & 0xF0) >> 4)
18+
19+
/*Porting*/
20+
typedef struct pinctrl_cfg_data_t {
21+
uint32_t p_reg: 1;
22+
uint32_t pm_reg: 2;
23+
uint32_t pmc_reg: 1;
24+
uint32_t pfc_reg: 4;
25+
uint32_t drct_reg: 6;
26+
uint32_t rsel_reg: 1;
27+
uint32_t reserved: 17;
28+
} pinctrl_cfg_data_t;
29+
30+
typedef struct pinctrl_soc_pin_t {
31+
bsp_io_port_pin_t port_pin;
32+
pinctrl_cfg_data_t config;
33+
} pinctrl_soc_pin_t;
34+
35+
#define Z_PINCTRL_STATE_PIN_INIT(node_id, prop, idx) \
36+
{ \
37+
.port_pin = RZT_GET_PORT_PIN(DT_PROP_BY_IDX(node_id, prop, idx)), \
38+
.config = \
39+
{ \
40+
.p_reg = DT_PROP(node_id, output_high), \
41+
.pm_reg = DT_PROP(node_id, input_enable) == 1 \
42+
? 1U \
43+
: (DT_PROP(node_id, output_enable) == 1 ? 2U \
44+
: 0U), \
45+
.pmc_reg = 1, \
46+
.pfc_reg = RZT_GET_FUNC(DT_PROP_BY_IDX(node_id, prop, idx)), \
47+
.drct_reg = \
48+
(DT_ENUM_IDX(node_id, drive_strength)) | \
49+
((DT_PROP(node_id, bias_pull_up) == 1 \
50+
? 1U \
51+
: (DT_PROP(node_id, bias_pull_down) == 1 ? 2U \
52+
: 0)) \
53+
<< 2) | \
54+
(DT_PROP(node_id, input_schmitt_enable) << 4) | \
55+
(DT_ENUM_IDX(node_id, slew_rate) << 5), \
56+
.rsel_reg = 1, \
57+
.reserved = 0, \
58+
}, \
59+
},
60+
#define Z_PINCTRL_STATE_PINS_INIT(node_id, prop) \
61+
{DT_FOREACH_CHILD_VARGS(DT_PHANDLE(node_id, prop), DT_FOREACH_PROP_ELEM, pinmux, \
62+
Z_PINCTRL_STATE_PIN_INIT)}
63+
64+
#ifdef __cplusplus
65+
}
66+
#endif
67+
68+
#endif /*ZEPHYR_SOC_RENESAS_RZ_COMMON_PINCTRL_RZT_H_*/

0 commit comments

Comments
 (0)