Skip to content

Commit f84b1f6

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 <[email protected]>
1 parent 2e7fdd1 commit f84b1f6

File tree

9 files changed

+190
-0
lines changed

9 files changed

+190
-0
lines changed

drivers/misc/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,6 @@ 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(interconn)

drivers/misc/Kconfig

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

2526
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 DRW (D/AVE 2D) 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: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
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
8+
default y
9+
help
10+
Enable config options for Renesas DRW driver
11+
12+
if RENESAS_RA_DRW
13+
config RENESAS_DAVE2D_RUNTIME_HEAP_SIZE
14+
int "Renesas DAVE2D runtime heap size"
15+
default 8192
16+
help
17+
Set the size of the runtime heap for DAVE2D driver.
18+
This heap is used for dynamic memory allocation during runtime.
19+
20+
endif # RENESAS_RA_DRW
Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
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 BIT(1)
16+
#define DRW_PRV_IRQCTL_ENUMIRQ_CLEAR BIT(2)
17+
#define DRW_PRV_IRQCTL_DLISTIRQ_CLEAR BIT(3)
18+
#define DRW_PRV_IRQCTL_BUSIRQ_CLEAR BIT(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+
#if DT_NODE_HAS_STATUS(DT_NODELABEL(drw), okay)
26+
#define VECTOR_NUMBER_DRW_INT DT_IRQN(DT_NODELABEL(drw))
27+
#else
28+
#error "Device tree node 'drw' not found or disabled (status != okay)"
29+
#endif
30+
31+
static struct k_sem d1_queryirq_sem;
32+
K_HEAP_DEFINE(drw_heap_runtime, CONFIG_RENESAS_DAVE2D_RUNTIME_HEAP_SIZE);
33+
34+
d1_int_t d1_initirq_intern(d1_device_flex *handle)
35+
{
36+
if (VECTOR_NUMBER_DRW_INT >= 0) {
37+
/* Clear all the D/AVE 2D IRQs and enable Display list IRQ. */
38+
R_FSP_IsrContextSet((IRQn_Type)VECTOR_NUMBER_DRW_INT, handle);
39+
irq_enable(VECTOR_NUMBER_DRW_INT);
40+
R_DRW->IRQCTL = DRW_PRV_IRQCTL_ALLIRQ_CLEAR_AND_DLISTIRQ_ENABLE;
41+
}
42+
43+
return (k_sem_init(&d1_queryirq_sem, 0, 1) == 0);
44+
}
45+
46+
d1_int_t d1_shutdownirq_intern(d1_device_flex *handle)
47+
{
48+
ARG_UNUSED(handle);
49+
50+
/* Disable D/AVE 2D interrupt in NVIC. */
51+
irq_disable(VECTOR_NUMBER_DRW_INT);
52+
53+
/* Clear all the D/AVE 2D IRQs and disable Display list IRQ. */
54+
R_DRW->IRQCTL = DRW_PRV_IRQCTL_ALLIRQ_DISABLE_AND_CLEAR;
55+
56+
return 1;
57+
}
58+
59+
d1_int_t d1_queryirq(d1_device *handle, d1_int_t irqmask, d1_int_t timeout)
60+
{
61+
/* Wait for dlist processing to complete. */
62+
return (k_sem_take(&d1_queryirq_sem, K_MSEC(timeout)) == 0);
63+
}
64+
65+
void *d1_malloc(d1_uint_t size)
66+
{
67+
return k_heap_alloc(&drw_heap_runtime, size, K_NO_WAIT);
68+
}
69+
70+
void d1_free(void *ptr)
71+
{
72+
k_heap_free(&drw_heap_runtime, ptr);
73+
}
74+
75+
void drw_zephyr_irq_handler(const struct device *dev)
76+
{
77+
uint32_t int_status;
78+
IRQn_Type irq = R_FSP_CurrentIrqGet(); /* Get current IRQ number */
79+
80+
int_status = R_DRW->STATUS; /* Read D/AVE 2D interrupt status */
81+
/* Clear all D/AVE 2D interrupts except for Display List IRQ enable */
82+
R_DRW->IRQCTL = DRW_PRV_IRQCTL_ALLIRQ_CLEAR_AND_DLISTIRQ_ENABLE;
83+
84+
if (int_status & DRW_PRV_STATUS_DLISTIRQ_TRIGGERED) {
85+
d1_device_flex *p_d1_handle = (d1_device_flex *)R_FSP_IsrContextGet(irq);
86+
87+
if (p_d1_handle != NULL) {
88+
uint32_t **pp_dlist_indirect_start =
89+
(uint32_t **)p_d1_handle->pp_dlist_indirect_start;
90+
if (p_d1_handle->dlist_indirect_enable &&
91+
*pp_dlist_indirect_start != NULL) {
92+
R_DRW->DLISTSTART = *pp_dlist_indirect_start;
93+
p_d1_handle->pp_dlist_indirect_start++;
94+
} else {
95+
k_sem_give(&d1_queryirq_sem);
96+
}
97+
}
98+
}
99+
/* Clear IRQ status. */
100+
R_BSP_IrqStatusClear(irq);
101+
}
102+
103+
#define DRW_INIT(inst) \
104+
static int drw_renesas_ra_configure_func_##inst(void) \
105+
{ \
106+
R_ICU->IELSR[DT_INST_IRQ_BY_NAME(inst, drw, irq)] = ELC_EVENT_DRW_INT; \
107+
IRQ_CONNECT(DT_INST_IRQ_BY_NAME(inst, drw, irq), \
108+
DT_INST_IRQ_BY_NAME(inst, drw, priority), drw_zephyr_irq_handler, \
109+
DEVICE_DT_INST_GET(inst), 0); \
110+
return 0; \
111+
} \
112+
static int renesas_drw_init_##inst(const struct device *dev) \
113+
{ \
114+
ARG_UNUSED(dev); \
115+
return drw_renesas_ra_configure_func_##inst(); \
116+
} \
117+
DEVICE_DT_INST_DEFINE(inst, renesas_drw_init_##inst, NULL, NULL, NULL, POST_KERNEL, \
118+
CONFIG_RENESAS_DRW_INIT_PRIORITY, NULL);
119+
120+
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+
imply 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)