Skip to content

Commit 26597b5

Browse files
committed
drivers: misc: Initial support for drw driver on Renesas RA
First commit to add support for Renesas RA drw driver Signed-off-by: Duy Nguyen <duy.nguyen.xa@renesas.com>
1 parent 5322a18 commit 26597b5

File tree

9 files changed

+208
-0
lines changed

9 files changed

+208
-0
lines changed

drivers/misc/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ add_subdirectory_ifdef(CONFIG_RENESAS_RA_EXTERNAL_INTERRUPT renesas_ra_external_
1414
add_subdirectory_ifdef(CONFIG_RENESAS_RX_EXTERNAL_INTERRUPT renesas_rx_external_interrupt)
1515
add_subdirectory_ifdef(CONFIG_NXP_RTXXX_DSP_CTRL nxp_rtxxx_dsp_ctrl)
1616
add_subdirectory_ifdef(CONFIG_STM32N6_AXISRAM stm32n6_axisram)
17+
add_subdirectory_ifdef(CONFIG_RENESAS_DRW renesas_drw)
1718

1819
add_subdirectory(coresight)
1920
add_subdirectory(interconn)

drivers/misc/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,5 +22,6 @@ source "drivers/misc/renesas_rx_external_interrupt/Kconfig"
2222
source "drivers/misc/nxp_rtxxx_dsp_ctrl/Kconfig"
2323
source "drivers/misc/stm32n6_axisram/Kconfig"
2424
source "drivers/misc/nxp_inputmux/Kconfig"
25+
source "drivers/misc/renesas_drw/Kconfig"
2526

2627
endmenu
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# SPDX-License-Identifier: Apache-2.0
2+
3+
zephyr_library()
4+
5+
zephyr_library_sources_ifdef(CONFIG_RENESAS_RA_DRW renesas_ra_drw.c)

drivers/misc/renesas_drw/Kconfig

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# Copyright (c) 2025 Renesas Electronics Corporation
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
# Renesas Event Link Controller config options
5+
6+
menuconfig RENESAS_DRW
7+
bool "Renesas DRW Driver"
8+
depends on SOC_FAMILY_RENESAS_RA
9+
help
10+
Enable config options for Renesas DRW driver
11+
12+
if RENESAS_DRW
13+
14+
config RENESAS_DRW_INIT_PRIORITY
15+
int "Renesas DRW initialization priority"
16+
default KERNEL_INIT_PRIORITY_DEVICE
17+
help
18+
System initialization priority for Renesas DRW drivers.
19+
20+
source "drivers/misc/renesas_drw/Kconfig.renesas_ra_drw"
21+
22+
endif # RENESAS_DRW
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Copyright (c) 2025 Renesas Electronics Corporation
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
config RENESAS_RA_DRW
5+
bool "Renesas RA DRW Driver"
6+
depends on DT_HAS_RENESAS_RA_DRW_ENABLED
7+
select USE_RA_FSP_DRW if SOC_FAMILY_RENESAS_RA
8+
select USE_RENESAS_DAVE2D_LIB
9+
default y
10+
help
11+
Enable config options for Renesas DRW driver
12+
13+
if RENESAS_RA_DRW
14+
config RENESAS_DAVE2D_RUNTIME_HEAP_SIZE
15+
int "Renesas DAVE2D runtime heap size"
16+
default 8192
17+
help
18+
Set the size of the runtime heap for DAVE2D driver.
19+
This heap is used for dynamic meory allocation during runtime.
20+
21+
endif # RENESAS_RA_DRW
Lines changed: 137 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,137 @@
1+
/*
2+
* Copyright (c) 2025 Renesas Electronics Corporation
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
#define DT_DRV_COMPAT renesas_ra_drw
8+
9+
#include <zephyr/kernel.h>
10+
#include <zephyr/irq.h>
11+
#include <soc.h>
12+
#include <r_drw_base.h>
13+
#include <r_drw_cfg.h>
14+
15+
#define DRW_PRV_IRQCTL_DLISTIRQ_ENABLE (1U << 1)
16+
#define DRW_PRV_IRQCTL_ENUMIRQ_CLEAR (1U << 2)
17+
#define DRW_PRV_IRQCTL_DLISTIRQ_CLEAR (1U << 3)
18+
#define DRW_PRV_IRQCTL_BUSIRQ_CLEAR (1U << 5)
19+
#define DRW_PRV_IRQCTL_ALLIRQ_DISABLE_AND_CLEAR \
20+
(DRW_PRV_IRQCTL_BUSIRQ_CLEAR | DRW_PRV_IRQCTL_DLISTIRQ_CLEAR | DRW_PRV_IRQCTL_ENUMIRQ_CLEAR)
21+
#define DRW_PRV_IRQCTL_ALLIRQ_CLEAR_AND_DLISTIRQ_ENABLE \
22+
(DRW_PRV_IRQCTL_BUSIRQ_CLEAR | DRW_PRV_IRQCTL_DLISTIRQ_CLEAR | \
23+
DRW_PRV_IRQCTL_ENUMIRQ_CLEAR | DRW_PRV_IRQCTL_DLISTIRQ_ENABLE)
24+
#define DRW_PRV_STATUS_DLISTIRQ_TRIGGERED (1U << 5)
25+
#define VECTOR_NUMBER_DRW_INT DT_IRQN(DT_NODELABEL(drw))
26+
#if defined(VECTOR_NUMBER_DRW_INT)
27+
#define DRW_CFG_INT_IRQ VECTOR_NUMBER_DRW_INT
28+
#endif
29+
30+
static struct k_sem d1_queryirq_sem;
31+
K_HEAP_DEFINE(drw_heap_runtime, CONFIG_RENESAS_DAVE2D_RUNTIME_HEAP_SIZE);
32+
33+
d1_int_t d1_initirq_intern(d1_device_flex *handle)
34+
{
35+
d1_int_t ret = 1;
36+
37+
if (DRW_CFG_INT_IRQ >= 0) {
38+
/* Clear all the D/AVE 2D IRQs and enable Display list IRQ. */
39+
R_DRW->IRQCTL = DRW_PRV_IRQCTL_ALLIRQ_CLEAR_AND_DLISTIRQ_ENABLE;
40+
R_FSP_IsrContextSet((IRQn_Type)DRW_CFG_INT_IRQ, handle);
41+
}
42+
43+
/* Initialize semaphore for use in d1_queryirq() */
44+
if (0 != k_sem_init(&d1_queryirq_sem, 0, 1)) {
45+
ret = 0;
46+
}
47+
48+
return ret;
49+
}
50+
51+
d1_int_t d1_shutdownirq_intern(d1_device_flex *handle)
52+
{
53+
ARG_UNUSED(handle);
54+
55+
/* Disable D/AVE 2D interrupt in NVIC. */
56+
irq_disable(DRW_CFG_INT_IRQ);
57+
58+
/* Clear all the D/AVE 2D IRQs and disable Display list IRQ. */
59+
R_DRW->IRQCTL = DRW_PRV_IRQCTL_ALLIRQ_DISABLE_AND_CLEAR;
60+
61+
return 1;
62+
}
63+
64+
d1_int_t d1_queryirq(d1_device *handle, d1_int_t irqmask, d1_int_t timeout)
65+
{
66+
d1_int_t ret = 1;
67+
68+
/* Wait for dlist processing to complete. */
69+
int err = k_sem_take(&d1_queryirq_sem, K_MSEC(timeout));
70+
71+
/* If the wait timed out return 0. */
72+
if (err != 0) {
73+
ret = 0;
74+
}
75+
76+
return ret;
77+
}
78+
79+
void *d1_malloc(d1_uint_t size)
80+
{
81+
return k_heap_alloc(&drw_heap_runtime, size, K_NO_WAIT);
82+
}
83+
84+
void d1_free(void *ptr)
85+
{
86+
k_heap_free(&drw_heap_runtime, ptr);
87+
}
88+
89+
void drw_zephyr_irq_handler(const struct device *dev)
90+
{
91+
uint32_t int_status;
92+
IRQn_Type irq = R_FSP_CurrentIrqGet();
93+
/* Read D/AVE 2D interrupt status */
94+
int_status = R_DRW->STATUS;
95+
/* Get current IRQ number */
96+
/* Clear all D/AVE 2D interrupts except for Display List IRQ enable */
97+
R_DRW->IRQCTL = DRW_PRV_IRQCTL_ALLIRQ_CLEAR_AND_DLISTIRQ_ENABLE;
98+
99+
if (int_status & DRW_PRV_STATUS_DLISTIRQ_TRIGGERED) {
100+
#if DRW_CFG_USE_DLIST_INDIRECT
101+
d1_device_flex *p_context = (d1_device_flex *)R_FSP_IsrContextGet(irq);
102+
103+
if (p_context->dlist_indirect_enable &&
104+
(NULL != (uint32_t *)*(p_context->pp_dlist_indirect_start))) {
105+
R_DRW->DLISTSTART = *(p_context->pp_dlist_indirect_start);
106+
p_context->pp_dlist_indirect_start++;
107+
} else
108+
#endif
109+
{
110+
k_sem_give(&d1_queryirq_sem);
111+
}
112+
}
113+
/* Clear IRQ status. */
114+
R_BSP_IrqStatusClear(irq);
115+
116+
/* No explicit irq_clear needed unless your platform requires it */
117+
}
118+
119+
#define DRW_INIT(inst) \
120+
static int drw_renesas_ra_configure_func_##inst(void) \
121+
{ \
122+
R_ICU->IELSR[DT_INST_IRQ_BY_NAME(inst, drw, irq)] = ELC_EVENT_DRW_INT; \
123+
IRQ_CONNECT(DT_INST_IRQ_BY_NAME(inst, drw, irq), \
124+
DT_INST_IRQ_BY_NAME(inst, drw, priority), drw_zephyr_irq_handler, \
125+
DEVICE_DT_INST_GET(inst), 0); \
126+
irq_enable(DT_INST_IRQ_BY_NAME(inst, drw, irq)); \
127+
return 0; \
128+
} \
129+
static int renesas_drw_init_##inst(const struct device *dev) \
130+
{ \
131+
ARG_UNUSED(dev); \
132+
return drw_renesas_ra_configure_func_##inst(); \
133+
} \
134+
DEVICE_DT_INST_DEFINE(inst, renesas_drw_init_##inst, NULL, NULL, NULL, POST_KERNEL, \
135+
CONFIG_RENESAS_DRW_INIT_PRIORITY, NULL);
136+
137+
DT_INST_FOREACH_STATUS_OKAY(DRW_INIT)
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# Copyright (c) 2025 Renesas Electronics Corporation
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
description: Renesas RA DRW
5+
6+
compatible: "renesas,ra-drw"
7+
8+
include: base.yaml
9+
10+
properties:
11+
interrupts:
12+
required: true

modules/Kconfig.renesas

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,11 @@ config USE_RA_FSP_IPC
243243
help
244244
Enable RA FSP IPC driver
245245

246+
config USE_RA_FSP_DRW
247+
bool
248+
help
249+
Enable RA FSP DRW driver
250+
246251
endif # HAS_RENESAS_RA_FSP
247252

248253
if HAS_RENESAS_RZ_FSP

modules/lvgl/Kconfig

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,10 @@ config LV_DRAW_DMA2D_HAL_INCLUDE
198198
Must be defined to include path of CMSIS header of target processor
199199
e.g. "stm32f769xx.h" or "stm32f429xx.h"
200200

201+
config LV_USE_DRAW_DAVE2D
202+
bool
203+
select RENESAS_DRW
204+
201205
config LV_Z_USE_OSAL
202206
bool "Use OSAL enabling parallel rendering"
203207
depends on DYNAMIC_THREAD

0 commit comments

Comments
 (0)