Skip to content

Commit 9002b75

Browse files
Fabrizio Castrovinodkoul
authored andcommitted
irqchip/renesas-rzv2h: Add rzv2h_icu_register_dma_req()
On the Renesas RZ/V2H(P) family of SoCs, DMAC IPs are connected to the Interrupt Control Unit (ICU). For DMA transfers, a request number must be registered with the ICU, which means that the DMAC driver has to be able to instruct the ICU driver with the registration of such id. Export rzv2h_icu_register_dma_req() so that the DMAC driver can register the DMAC request number. Signed-off-by: Fabrizio Castro <[email protected]> Reviewed-by: Thomas Gleixner <[email protected]> Reviewed-by: Lad Prabhakar <[email protected]> Reviewed-by: Geert Uytterhoeven <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Vinod Koul <[email protected]>
1 parent 22228b9 commit 9002b75

File tree

2 files changed

+58
-0
lines changed

2 files changed

+58
-0
lines changed

drivers/irqchip/irq-renesas-rzv2h.c

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#include <linux/err.h>
1616
#include <linux/io.h>
1717
#include <linux/irqchip.h>
18+
#include <linux/irqchip/irq-renesas-rzv2h.h>
1819
#include <linux/irqdomain.h>
1920
#include <linux/of_address.h>
2021
#include <linux/of_platform.h>
@@ -41,6 +42,8 @@
4142
#define ICU_TSCLR 0x24
4243
#define ICU_TITSR(k) (0x28 + (k) * 4)
4344
#define ICU_TSSR(k) (0x30 + (k) * 4)
45+
#define ICU_DMkSELy(k, y) (0x420 + (k) * 0x20 + (y) * 4)
46+
#define ICU_DMACKSELk(k) (0x500 + (k) * 4)
4447

4548
/* NMI */
4649
#define ICU_NMI_EDGE_FALLING 0
@@ -103,6 +106,15 @@ struct rzv2h_hw_info {
103106
u8 field_width;
104107
};
105108

109+
/* DMAC */
110+
#define ICU_DMAC_DkRQ_SEL_MASK GENMASK(9, 0)
111+
112+
#define ICU_DMAC_DMAREQ_SHIFT(up) ((up) * 16)
113+
#define ICU_DMAC_DMAREQ_MASK(up) (ICU_DMAC_DkRQ_SEL_MASK \
114+
<< ICU_DMAC_DMAREQ_SHIFT(up))
115+
#define ICU_DMAC_PREP_DMAREQ(sel, up) (FIELD_PREP(ICU_DMAC_DkRQ_SEL_MASK, (sel)) \
116+
<< ICU_DMAC_DMAREQ_SHIFT(up))
117+
106118
/**
107119
* struct rzv2h_icu_priv - Interrupt Control Unit controller private data structure.
108120
* @base: Controller's base address
@@ -117,6 +129,27 @@ struct rzv2h_icu_priv {
117129
const struct rzv2h_hw_info *info;
118130
};
119131

132+
void rzv2h_icu_register_dma_req(struct platform_device *icu_dev, u8 dmac_index, u8 dmac_channel,
133+
u16 req_no)
134+
{
135+
struct rzv2h_icu_priv *priv = platform_get_drvdata(icu_dev);
136+
u32 icu_dmksely, dmareq, dmareq_mask;
137+
u8 y, upper;
138+
139+
y = dmac_channel / 2;
140+
upper = dmac_channel % 2;
141+
142+
dmareq = ICU_DMAC_PREP_DMAREQ(req_no, upper);
143+
dmareq_mask = ICU_DMAC_DMAREQ_MASK(upper);
144+
145+
guard(raw_spinlock_irqsave)(&priv->lock);
146+
147+
icu_dmksely = readl(priv->base + ICU_DMkSELy(dmac_index, y));
148+
icu_dmksely = (icu_dmksely & ~dmareq_mask) | dmareq;
149+
writel(icu_dmksely, priv->base + ICU_DMkSELy(dmac_index, y));
150+
}
151+
EXPORT_SYMBOL_GPL(rzv2h_icu_register_dma_req);
152+
120153
static inline struct rzv2h_icu_priv *irq_data_to_priv(struct irq_data *data)
121154
{
122155
return data->domain->host_data;
@@ -483,6 +516,8 @@ static int rzv2h_icu_init_common(struct device_node *node, struct device_node *p
483516
if (!rzv2h_icu_data)
484517
return -ENOMEM;
485518

519+
platform_set_drvdata(pdev, rzv2h_icu_data);
520+
486521
rzv2h_icu_data->base = devm_of_iomap(&pdev->dev, pdev->dev.of_node, 0, NULL);
487522
if (IS_ERR(rzv2h_icu_data->base))
488523
return PTR_ERR(rzv2h_icu_data->base);
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
/* SPDX-License-Identifier: GPL-2.0 */
2+
/*
3+
* Renesas RZ/V2H(P) Interrupt Control Unit (ICU)
4+
*
5+
* Copyright (C) 2025 Renesas Electronics Corporation.
6+
*/
7+
8+
#ifndef __LINUX_IRQ_RENESAS_RZV2H
9+
#define __LINUX_IRQ_RENESAS_RZV2H
10+
11+
#include <linux/platform_device.h>
12+
13+
#define RZV2H_ICU_DMAC_REQ_NO_DEFAULT 0x3ff
14+
15+
#ifdef CONFIG_RENESAS_RZV2H_ICU
16+
void rzv2h_icu_register_dma_req(struct platform_device *icu_dev, u8 dmac_index, u8 dmac_channel,
17+
u16 req_no);
18+
#else
19+
static inline void rzv2h_icu_register_dma_req(struct platform_device *icu_dev, u8 dmac_index,
20+
u8 dmac_channel, u16 req_no) { }
21+
#endif
22+
23+
#endif /* __LINUX_IRQ_RENESAS_RZV2H */

0 commit comments

Comments
 (0)