8
8
#define ZEPHYR_DRIVERS_GPIO_RENESAS_RZ_H_
9
9
10
10
#include "r_ioport.h"
11
+ #include <zephyr/drivers/interrupt_controller/gic.h>
11
12
12
13
#define GPIO_RZ_INT_UNSUPPORTED 0xF
13
14
14
15
#if defined(CONFIG_SOC_SERIES_RZG3S ) || defined(CONFIG_SOC_SERIES_RZA3UL ) || \
15
- defined(CONFIG_SOC_SERIES_RZV2L ) || defined(CONFIG_SOC_SERIES_RZG2L )
16
+ defined(CONFIG_SOC_SERIES_RZV2L ) || defined(CONFIG_SOC_SERIES_RZG2L ) || \
17
+ defined(CONFIG_SOC_SERIES_RZV2H )
16
18
#include <zephyr/dt-bindings/gpio/renesas-rz-gpio.h>
17
19
18
20
#if defined(CONFIG_SOC_SERIES_RZG3S )
19
- #define GPIO_RZ_P_REG_BASE_GET (&R_GPIO->P_20)
20
- #define GPIO_RZ_PM_REG_BASE_GET (&R_GPIO->PM_20)
21
- #define GPIO_RZ_PFC_REG_BASE_GET (&R_GPIO->PFC_20)
22
- #define GPIO_RZ_MAX_PORT_NUM 19
23
- #define GPIO_RZ_TINT_IRQ_OFFSET 429
24
- #define R_INTC R_INTC_IM33
21
+ #define GPIO_RZ_P_REG_BASE_GET (&R_GPIO->P_20)
22
+ #define GPIO_RZ_PM_REG_BASE_GET (&R_GPIO->PM_20)
23
+ #define GPIO_RZ_PFC_REG_BASE_GET (&R_GPIO->PFC_20)
24
+ #define GPIO_RZ_MAX_PORT_NUM 19
25
+ #define GPIO_RZ_TINT_IRQ_OFFSET 429
26
+ #define R_INTC R_INTC_IM33
27
+ #define GPIO_RZ_TINT_STATUS_REG_CLEAR (tint_num ) (R_INTC_IM33->TSCR &= ~BIT(tint_num))
25
28
static const uint8_t gpio_rz_int [GPIO_RZ_MAX_PORT_NUM ] = {0 , 4 , 9 , 13 , 17 , 23 , 28 , 33 , 38 , 43 ,
26
29
47 , 52 , 56 , 58 , 63 , 66 , 70 , 72 , 76 };
27
30
28
31
#elif defined(CONFIG_SOC_SERIES_RZA3UL )
29
- #define GPIO_RZ_P_REG_BASE_GET (&R_GPIO->P10)
30
- #define GPIO_RZ_PM_REG_BASE_GET (&R_GPIO->PM10)
31
- #define GPIO_RZ_PFC_REG_BASE_GET (&R_GPIO->PFC10)
32
- #define GPIO_RZ_MAX_PORT_NUM 19
33
- #define GPIO_RZ_TINT_IRQ_OFFSET 476
34
- #define R_INTC R_INTC_IA55
32
+ #define GPIO_RZ_P_REG_BASE_GET (&R_GPIO->P10)
33
+ #define GPIO_RZ_PM_REG_BASE_GET (&R_GPIO->PM10)
34
+ #define GPIO_RZ_PFC_REG_BASE_GET (&R_GPIO->PFC10)
35
+ #define GPIO_RZ_MAX_PORT_NUM 19
36
+ #define GPIO_RZ_TINT_IRQ_OFFSET 476
37
+ #define R_INTC R_INTC_IA55
38
+ #define GPIO_RZ_TINT_STATUS_REG_CLEAR (tint_num ) (R_INTC_IA55->TSCR &= ~BIT(tint_num))
35
39
static const uint8_t gpio_rz_int [GPIO_RZ_MAX_PORT_NUM ] = {0 , 4 , 9 , 13 , 17 , 23 , 28 , 33 , 38 , 43 ,
36
40
47 , 52 , 56 , 58 , 63 , 66 , 70 , 72 , 76 };
37
41
42
+ #elif defined(CONFIG_SOC_SERIES_RZV2H )
43
+ #define GPIO_RZ_P_REG_BASE_GET (&R_GPIO->P20)
44
+ #define GPIO_RZ_PM_REG_BASE_GET (&R_GPIO->PM20)
45
+ #define GPIO_RZ_PFC_REG_BASE_GET (&R_GPIO->PFC20)
46
+ #define GPIO_RZ_TINT_STATUS_REG_GET (&R_INTC->TSCTR)
47
+
48
+ #ifdef CONFIG_CPU_CORTEX_M
49
+ #define GPIO_RZ_TINT_IRQ_OFFSET 353
50
+ #define GPIO_RZ_TINT_SPURIOUS_HANDLE 0
51
+ #define GPIO_RZ_TINT_SELECT_SOURCE_REG_GET (&R_INTC->INTM33SEL0)
52
+ #else /* Cortex-R */
53
+ #define GPIO_RZ_TINT_IRQ_OFFSET (GIC_SPI_INT_BASE + 353)
54
+ #define GPIO_RZ_TINT_SELECT_SOURCE_REG_GET (&R_INTC->INTR8SEL0)
55
+ #endif
56
+
57
+ #define GPIO_RZ_MAX_PORT_NUM 12
58
+ #define GPIO_RZ_TINT_STATUS_REG_CLEAR (tint_num ) (R_INTC->TSCLR |= BIT(tint_num))
59
+ #define GPIO_RZ_TINT_SELECT_SOURCE_REG_CLEAR (tint_num ) \
60
+ GPIO_RZ_TINT_SELECT_SOURCE_REG_GET[int_num / 3] &= ~(0x3FF << ((int_num % 3) * 10));
61
+ #define GPIO_RZ_TINT_SELECT_SOURCE_REG_SET (tint_num ) \
62
+ GPIO_RZ_TINT_SELECT_SOURCE_REG_GET[int_num / 3] |= (int_num << ((int_num % 3) * 10));
63
+ static const uint8_t gpio_rz_int [GPIO_RZ_MAX_PORT_NUM ] = {0 , 8 , 14 , 16 , 24 , 32 ,
64
+ 40 , 48 , 56 , 64 , 72 , 80 };
65
+
38
66
#elif defined(CONFIG_SOC_SERIES_RZV2L ) || defined(CONFIG_SOC_SERIES_RZG2L )
39
- #define GPIO_RZ_P_REG_BASE_GET (&R_GPIO->P10)
40
- #define GPIO_RZ_PM_REG_BASE_GET (&R_GPIO->PM10)
41
- #define GPIO_RZ_PFC_REG_BASE_GET (&R_GPIO->PFC10)
42
- #define GPIO_RZ_MAX_PORT_NUM 49
43
- #define GPIO_RZ_TINT_IRQ_OFFSET 444
44
- #define R_INTC R_INTC_IM33
67
+ #define GPIO_RZ_P_REG_BASE_GET (&R_GPIO->P10)
68
+ #define GPIO_RZ_PM_REG_BASE_GET (&R_GPIO->PM10)
69
+ #define GPIO_RZ_PFC_REG_BASE_GET (&R_GPIO->PFC10)
70
+ #define GPIO_RZ_MAX_PORT_NUM 49
71
+ #define GPIO_RZ_TINT_IRQ_OFFSET 444
72
+ #define R_INTC R_INTC_IM33
73
+ #define GPIO_RZ_TINT_STATUS_REG_CLEAR (tint_num ) (R_INTC_IM33->TSCR &= ~BIT(tint_num))
45
74
static const uint8_t gpio_rz_int [GPIO_RZ_MAX_PORT_NUM ] = {
46
75
0 , 2 , 4 , 6 , 8 , 10 , 13 , 15 , 18 , 21 , 24 , 25 , 27 , 29 , 32 , 34 , 36 ,
47
76
38 , 41 , 43 , 45 , 48 , 50 , 52 , 54 , 56 , 58 , 60 , 62 , 64 , 66 , 68 , 70 , 72 ,
48
77
74 , 76 , 78 , 80 , 83 , 85 , 88 , 91 , 93 , 98 , 102 , 106 , 110 , 114 , 118 };
49
78
#endif
50
79
80
+ #ifndef GPIO_RZ_TINT_SELECT_SOURCE_REG_CLEAR
81
+ #define GPIO_RZ_TINT_SELECT_SOURCE_REG_CLEAR (tint_num )
82
+ #define GPIO_RZ_TINT_SELECT_SOURCE_REG_SET (tint_num )
83
+ #endif
84
+
85
+ #ifndef GPIO_RZ_TINT_STATUS_REG_GET
86
+ #define GPIO_RZ_TINT_STATUS_REG_GET (&R_INTC->TSCR)
87
+ #endif
88
+
89
+ #ifndef GPIO_RZ_TINT_SPURIOUS_HANDLE
90
+ #define GPIO_RZ_TINT_SPURIOUS_HANDLE 1
91
+ #endif
92
+
51
93
#define GPIO_RZ_P_REG_GET (port , pin ) (&GPIO_RZ_P_REG_BASE_GET[port])
52
94
#define GPIO_RZ_PM_REG_GET (port , pin ) (&GPIO_RZ_PM_REG_BASE_GET[port])
53
95
#define GPIO_RZ_PFC_REG_GET (port , pin ) (&GPIO_RZ_PFC_REG_BASE_GET[port])
@@ -60,7 +102,8 @@ static const uint8_t gpio_rz_int[GPIO_RZ_MAX_PORT_NUM] = {
60
102
61
103
#define GPIO_RZ_MAX_INT_NUM 32
62
104
63
- #define GPIO_RZ_TINT_IRQ_GET (tint_num ) (tint_num + GPIO_RZ_TINT_IRQ_OFFSET)
105
+ #define GPIO_RZ_TINT_IRQ_GET (tint_num ) (tint_num + GPIO_RZ_TINT_IRQ_OFFSET)
106
+ #define GPIO_RZ_TINT_CLEAR_PENDING (tint_num ) R_BSP_IrqClearPending(GPIO_RZ_TINT_IRQ_GET(tint_num))
64
107
65
108
#define GPIO_RZ_INT_EDGE_RISING 0x0
66
109
#define GPIO_RZ_INT_EDGE_FALLING 0x1
@@ -116,6 +159,7 @@ static const uint8_t gpio_rz_int[GPIO_RZ_MAX_PORT_NUM] = {
116
159
#define GPIO_RZ_INT_LEVEL_HIGH GPIO_RZ_INT_UNSUPPORTED
117
160
#define GPIO_RZ_INT_ENABLE (1U << 3)
118
161
#define GPIO_RZ_INT_DISABLE (~(1U << 3))
162
+ #define GPIO_RZ_TINT_CLEAR_PENDING (int_num )
119
163
120
164
#define GPIO_RZ_FLAG_GET_CONFIG (flag ) (((flag >> RZTN_GPIO_DRCTL_SHIFT) & 0x33) << 8U)
121
165
#define GPIO_RZ_FLAG_SET_PFC (value ) (value << 4)
0 commit comments