Skip to content

Commit 25ed9c9

Browse files
nhutnguyenkckartben
authored andcommitted
drivers: pinctrl: Add support for RZ/G3S
This is the initial commit to support pinctrl driver for Renesas RZ/G3S Signed-off-by: Quang Le <[email protected]> Signed-off-by: Nhut Nguyen <[email protected]>
1 parent f479a23 commit 25ed9c9

File tree

11 files changed

+406
-0
lines changed

11 files changed

+406
-0
lines changed
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
/*
2+
* Copyright (c) 2024 EPAM Systems
3+
* Copyright (c) 2024 Renesas Electronics Corporation
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
#include <zephyr/dt-bindings/gpio/gpio.h>
8+
#include <zephyr/dt-bindings/pinctrl/renesas/pinctrl-rzg-common.h>
9+
10+
&pinctrl {
11+
/omit-if-no-ref/ scif0_pins: scif0 {
12+
scif0-pinmux {
13+
pinmux = <RZG_PINMUX(PORT_06, 3, 1)>, /* TXD */
14+
<RZG_PINMUX(PORT_06, 4, 1)>; /* RXD */
15+
};
16+
};
17+
18+
/omit-if-no-ref/ scif1_pins: scif1 {
19+
scif1-pinmux {
20+
pinmux = <RZG_PINMUX(PORT_14, 0, 1)>, /* TXD */
21+
<RZG_PINMUX(PORT_14, 1, 1)>; /* RXD */
22+
};
23+
};
24+
25+
/omit-if-no-ref/ scif3_pins: scif3 {
26+
scif3-pinmux {
27+
pinmux = <RZG_PINMUX(PORT_17, 3, 7)>, /* TXD */
28+
<RZG_PINMUX(PORT_17, 2, 7)>; /* RXD */
29+
};
30+
};
31+
32+
/omit-if-no-ref/ scif5_pins: scif5 {
33+
scif5-pinmux {
34+
pinmux = <RZG_PINMUX(PORT_15, 1, 6)>, /* RXD */
35+
<RZG_PINMUX(PORT_15, 2, 6)>; /* TXD */
36+
};
37+
};
38+
};

drivers/pinctrl/renesas/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,6 @@
55
zephyr_library_sources_ifdef(CONFIG_PINCTRL_RENESAS_RA_PFS ra/pinctrl_ra.c)
66
zephyr_library_sources_ifdef(CONFIG_PINCTRL_RZT2M rz/pinctrl_rzt2m.c)
77
zephyr_library_sources_ifdef(CONFIG_PINCTRL_SMARTBOND smartbond/pinctrl_smartbond.c)
8+
zephyr_library_sources_ifdef(CONFIG_PINCTRL_RENESAS_RZ rz/pinctrl_renesas_rz.c)
89

910
add_subdirectory_ifdef(CONFIG_PINCTRL_RCAR_PFC rcar)

drivers/pinctrl/renesas/rz/Kconfig

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
# Copyright (c) 2023 Antmicro <www.antmicro.com>
2+
# Copyright (c) 2024 Renesas Electronics Corporation
23
# SPDX-License-Identifier: Apache-2.0
34

45
config PINCTRL_RZT2M
@@ -7,3 +8,11 @@ config PINCTRL_RZT2M
78
depends on DT_HAS_RENESAS_RZT2M_PINCTRL_ENABLED
89
help
910
Renesas RZ/T2M pinctrl driver
11+
12+
config PINCTRL_RENESAS_RZ
13+
bool "Renesas RZ pin controller driver"
14+
default y
15+
depends on DT_HAS_RENESAS_RZG_PINCTRL_ENABLED
16+
select USE_RZ_FSP_IOPORT
17+
help
18+
Enable Renesas RZ pinctrl driver.
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
/*
2+
* Copyright (c) 2024 Renesas Electronics Corporation
3+
* SPDX-License-Identifier: Apache-2.0
4+
*/
5+
6+
#include <zephyr/drivers/pinctrl.h>
7+
#include "r_ioport.h"
8+
9+
static void pinctrl_configure_pin(const pinctrl_soc_pin_t *pin)
10+
{
11+
uint32_t cfg = *(uint32_t *)&pin->config;
12+
13+
R_IOPORT_PinCfg(NULL, pin->port_pin, cfg);
14+
}
15+
16+
int pinctrl_configure_pins(const pinctrl_soc_pin_t *pins, uint8_t pin_cnt, uintptr_t reg)
17+
{
18+
ARG_UNUSED(reg);
19+
20+
for (uint8_t i = 0U; i < pin_cnt; i++) {
21+
pinctrl_configure_pin(pins++);
22+
}
23+
24+
return 0;
25+
}

dts/arm/renesas/rz/rzg/r9a08g045.dtsi

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,14 @@
3030
};
3131
};
3232
};
33+
34+
soc {
35+
pinctrl: pin-controller@41030000 {
36+
compatible = "renesas,rzg-pinctrl";
37+
reg = <0x41030000 DT_SIZE_K(64)>;
38+
reg-names = "pinctrl";
39+
};
40+
};
3341
};
3442

3543
&nvic {
Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
# Copyright (c) 2024 Epam Systems
2+
# Copyright (c) 2024 Renesas Electronics Corporation
3+
# SPDX-License-Identifier: Apache-2.0
4+
5+
description: |
6+
Below generic example shows of supported pinctrl definitions:
7+
8+
#include <zephyr/dt-bindings/pinctrl/renesas/pinctrl_rzg3s.h>
9+
example_pins: device_pin {
10+
device-pinmux {
11+
pinmux = <RZG_PINMUX(PORT_08, 1, 5)>,
12+
<RZG_PINMUX(PORT_08, 2, 5)>;
13+
bias_pull_up;
14+
renesas,filter = RZG_FILTER_SET(RZG_FILNUM_8_STAGE,RZG_FILCLKSEL_DIV_18000);
15+
drive-strength = <1>;
16+
};
17+
18+
device-spins {
19+
pins = <BSP_IO_XSPI_IO0>, <BSP_IO_XSPI_IO4>;
20+
input-enable;
21+
renesas,filter = RZG_FILTER_SET(RZG_FILNUM_8_STAGE,RZG_FILCLKSEL_DIV_18000);
22+
drive-strength = <2>;
23+
};
24+
};
25+
26+
27+
compatible: renesas,rzg-pinctrl
28+
29+
include: base.yaml
30+
properties:
31+
reg:
32+
required: true
33+
34+
reg-names:
35+
required: true
36+
37+
child-binding:
38+
description: |
39+
This RZG pins mux/cfg nodes description.
40+
41+
child-binding:
42+
description: |
43+
The RZG pinmux/pincfg configuration nodes description.
44+
45+
include:
46+
- name: pincfg-node.yaml
47+
property-allowlist:
48+
- bias-disable
49+
- bias-high-impedance
50+
- bias-pull-down
51+
- bias-pull-up
52+
- bias-pull-pin-default
53+
- drive-strength
54+
- input-enable
55+
- input-disable
56+
- output-enable
57+
- power-source
58+
- low-power-enable
59+
- low-power-disable
60+
61+
properties:
62+
pinmux:
63+
type: array
64+
description: |
65+
Pinmux configuration node.
66+
Values are constructed from GPIO port number, pin number, and
67+
alternate function configuration number using the RZG_PINMUX()
68+
helper macro in pinctrl_rzg.h
69+
70+
pins:
71+
type: array
72+
description: |
73+
Special Purpose pins configuration node.
74+
Values are define in pinctrl_rzg.h.
75+
Ex: BSP_IO_XSPI_IO0,BSP_IO_I3C_SCL,...
76+
77+
drive-strength:
78+
type: int
79+
default: 0
80+
description: |
81+
Maximum sink or source current in mA for pin which shell be selected
82+
depending on device and pin group.
83+
84+
renesas,filter:
85+
type: int
86+
default: 0
87+
description: |
88+
Digital Noise Filter configuration for a pin which shell be defined
89+
using RZG_FILTER_SET() helper macro in pinctrl_rzg.h to specify
90+
FILNUM_m and FILCLKSEL_m. With 24Mhz external clock:
91+
- min debounce time will be 166.666ns for FILNUM_m=0 and FILCLKSEL_m=0
92+
- max debounce time will be 24ms for FILNUM_m=3 and FILCLKSEL_m=3.
93+
This property intentionally redefined to avoid unnecessary conversation from usec to
94+
FILNUM_m and FILCLKSEL_m values depending on external clock value as this configuration
95+
is static.
Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
/*
2+
* Copyright (c) 2024 Renesas Electronics Corporation
3+
* SPDX-License-Identifier: Apache-2.0
4+
*/
5+
6+
#ifndef ZEPHYR_INCLUDE_DT_BINDINGS_PINCTRL_RENESAS_PINCTRL_RZG_COMMON_H_
7+
#define ZEPHYR_INCLUDE_DT_BINDINGS_PINCTRL_RENESAS_PINCTRL_RZG_COMMON_H_
8+
9+
/* Superset list of all possible IO ports. */
10+
#define PORT_00 0x0000 /* IO port 0 */
11+
#define PORT_01 0x1000 /* IO port 1 */
12+
#define PORT_02 0x1100 /* IO port 2 */
13+
#define PORT_03 0x1200 /* IO port 3 */
14+
#define PORT_04 0x1300 /* IO port 4 */
15+
#define PORT_05 0x0100 /* IO port 5 */
16+
#define PORT_06 0x0200 /* IO port 6 */
17+
#define PORT_07 0x1400 /* IO port 7 */
18+
#define PORT_08 0x1500 /* IO port 8 */
19+
#define PORT_09 0x1600 /* IO port 9 */
20+
#define PORT_10 0x1700 /* IO port 10 */
21+
#define PORT_11 0x0300 /* IO port 11 */
22+
#define PORT_12 0x0400 /* IO port 12 */
23+
#define PORT_13 0x0500 /* IO port 13 */
24+
#define PORT_14 0x0600 /* IO port 14 */
25+
#define PORT_15 0x0700 /* IO port 15 */
26+
#define PORT_16 0x0800 /* IO port 16 */
27+
#define PORT_17 0x0900 /* IO port 17 */
28+
#define PORT_18 0x0A00 /* IO port 18 */
29+
30+
/*
31+
* Create the value contain port/pin/function information
32+
*
33+
* port: port number BSP_IO_PORT_00..BSP_IO_PORT_18
34+
* pin: pin number
35+
* func: pin function
36+
*/
37+
#define RZG_PINMUX(port, pin, func) (port | pin | (func << 4))
38+
39+
/* Special purpose port */
40+
#define BSP_IO_NMI 0xFFFF0000 /* NMI */
41+
42+
#define BSP_IO_TMS_SWDIO 0xFFFF0100 /* TMS_SWDIO */
43+
#define BSP_IO_TDO 0xFFFF0101 /* TDO */
44+
45+
#define BSP_IO_AUDIO_CLK1 0xFFFF0200 /* AUDIO_CLK1 */
46+
#define BSP_IO_AUDIO_CLK2 0xFFFF0201 /* AUDIO_CLK2 */
47+
48+
#define BSP_IO_XSPI_SPCLK 0xFFFF0400 /* XSPI_SPCLK */
49+
#define BSP_IO_XSPI_RESET_N 0xFFFF0401 /* XSPI_RESET_N */
50+
#define BSP_IO_XSPI_WP_N 0xFFFF0402 /* XSPI_WP_N */
51+
#define BSP_IO_XSPI_DS 0xFFFF0403 /* XSPI_DS */
52+
#define BSP_IO_XSPI_CS0_N 0xFFFF0404 /* XSPI_CS0_N */
53+
#define BSP_IO_XSPI_CS1_N 0xFFFF0405 /* XSPI_CS1_N */
54+
55+
#define BSP_IO_XSPI_IO0 0xFFFF0500 /* XSPI_IO0 */
56+
#define BSP_IO_XSPI_IO1 0xFFFF0501 /* XSPI_IO1 */
57+
#define BSP_IO_XSPI_IO2 0xFFFF0502 /* XSPI_IO2 */
58+
#define BSP_IO_XSPI_IO3 0xFFFF0503 /* XSPI_IO3 */
59+
#define BSP_IO_XSPI_IO4 0xFFFF0504 /* XSPI_IO4 */
60+
#define BSP_IO_XSPI_IO5 0xFFFF0505 /* XSPI_IO5 */
61+
#define BSP_IO_XSPI_IO6 0xFFFF0506 /* XSPI_IO6 */
62+
#define BSP_IO_XSPI_IO7 0xFFFF0507 /* XSPI_IO7 */
63+
64+
#define BSP_IO_WDTOVF_PERROUT 0xFFFF0600 /* WDTOVF_PERROUT */
65+
66+
#define BSP_IO_I3C_SDA 0xFFFF0900 /* I3C_SDA */
67+
#define BSP_IO_I3C_SCL 0xFFFF0901 /* I3C_SCL */
68+
69+
#define BSP_IO_SD0_CLK 0xFFFF1000 /* CD0_CLK */
70+
#define BSP_IO_SD0_CMD 0xFFFF1001 /* CD0_CMD */
71+
#define BSP_IO_SD0_RST_N 0xFFFF1002 /* CD0_RST_N */
72+
73+
#define BSP_IO_SD0_DATA0 0xFFFF1100 /* SD0_DATA0 */
74+
#define BSP_IO_SD0_DATA1 0xFFFF1101 /* SD0_DATA1 */
75+
#define BSP_IO_SD0_DATA2 0xFFFF1102 /* SD0_DATA2 */
76+
#define BSP_IO_SD0_DATA3 0xFFFF1103 /* SD0_DATA3 */
77+
#define BSP_IO_SD0_DATA4 0xFFFF1104 /* SD0_DATA4 */
78+
#define BSP_IO_SD0_DATA5 0xFFFF1105 /* SD0_DATA5 */
79+
#define BSP_IO_SD0_DATA6 0xFFFF1106 /* SD0_DATA6 */
80+
#define BSP_IO_SD0_DATA7 0xFFFF1107 /* SD0_DATA7 */
81+
82+
#define BSP_IO_SD1_CLK 0xFFFF1200 /* SD1_CLK */
83+
#define BSP_IO_SD1_CMD 0xFFFF1201 /* SD1_CMD */
84+
85+
#define BSP_IO_SD1_DATA0 0xFFFF1300 /* SD1_DATA0 */
86+
#define BSP_IO_SD1_DATA1 0xFFFF1301 /* SD1_DATA1 */
87+
#define BSP_IO_SD1_DATA2 0xFFFF1302 /* SD1_DATA2 */
88+
#define BSP_IO_SD1_DATA3 0xFFFF1303 /* SD1_DATA3 */
89+
90+
/*FILNUM*/
91+
#define RZG_FILNUM_4_STAGE 0
92+
#define RZG_FILNUM_8_STAGE 1
93+
#define RZG_FILNUM_12_STAGE 2
94+
#define RZG_FILNUM_16_STAGE 3
95+
96+
/*FILCLKSEL*/
97+
#define RZG_FILCLKSEL_NOT_DIV 0
98+
#define RZG_FILCLKSEL_DIV_9000 1
99+
#define RZG_FILCLKSEL_DIV_18000 2
100+
#define RZG_FILCLKSEL_DIV_36000 3
101+
102+
#define RZG_FILTER_SET(filnum, filclksel) (((filnum) & 0x3) << 0x2) | (filclksel & 0x3)
103+
104+
#endif /*ZEPHYR_INCLUDE_DT_BINDINGS_PINCTRL_RENESAS_PINCTRL_RZG_COMMON_H_*/

modules/Kconfig.renesas_fsp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,3 +104,12 @@ config USE_RA_FSP_ETHER
104104
Enable RA FSP Ethernet driver
105105

106106
endif # HAS_RENESAS_RA_FSP
107+
108+
if HAS_RENESAS_RZ_FSP
109+
110+
config USE_RZ_FSP_IOPORT
111+
bool
112+
help
113+
Enable RZ FSP IOPORT driver
114+
115+
endif

soc/renesas/rz/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
# Copyright (c) 2024 Renesas Electronics Corporation
22
# SPDX-License-Identifier: Apache-2.0
33

4+
zephyr_include_directories_ifdef(CONFIG_HAS_RENESAS_RZ_FSP common)
5+
46
add_subdirectory(${SOC_SERIES})

0 commit comments

Comments
 (0)