Skip to content

Commit 885525c

Browse files
miquelraynalvinodkoul
authored andcommitted
clk: renesas: r9a06g032: Export function to set dmamux
The dmamux register is located within the system controller. Without syscon, we need an extra helper in order to give write access to this register to a dmamux driver. Signed-off-by: Miquel Raynal <[email protected]> Acked-by: Stephen Boyd <[email protected]> Reviewed-by: Geert Uytterhoeven <[email protected]> Acked-by: Geert Uytterhoeven <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Vinod Koul <[email protected]>
1 parent 7ac9226 commit 885525c

File tree

2 files changed

+45
-1
lines changed

2 files changed

+45
-1
lines changed

drivers/clk/renesas/r9a06g032-clocks.c

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,12 @@
2020
#include <linux/pm_clock.h>
2121
#include <linux/pm_domain.h>
2222
#include <linux/slab.h>
23+
#include <linux/soc/renesas/r9a06g032-sysctrl.h>
2324
#include <linux/spinlock.h>
2425
#include <dt-bindings/clock/r9a06g032-sysctrl.h>
2526

27+
#define R9A06G032_SYSCTRL_DMAMUX 0xA0
28+
2629
struct r9a06g032_gate {
2730
u16 gate, reset, ready, midle,
2831
scon, mirack, mistat;
@@ -315,6 +318,30 @@ struct r9a06g032_priv {
315318
void __iomem *reg;
316319
};
317320

321+
static struct r9a06g032_priv *sysctrl_priv;
322+
323+
/* Exported helper to access the DMAMUX register */
324+
int r9a06g032_sysctrl_set_dmamux(u32 mask, u32 val)
325+
{
326+
unsigned long flags;
327+
u32 dmamux;
328+
329+
if (!sysctrl_priv)
330+
return -EPROBE_DEFER;
331+
332+
spin_lock_irqsave(&sysctrl_priv->lock, flags);
333+
334+
dmamux = readl(sysctrl_priv->reg + R9A06G032_SYSCTRL_DMAMUX);
335+
dmamux &= ~mask;
336+
dmamux |= val & mask;
337+
writel(dmamux, sysctrl_priv->reg + R9A06G032_SYSCTRL_DMAMUX);
338+
339+
spin_unlock_irqrestore(&sysctrl_priv->lock, flags);
340+
341+
return 0;
342+
}
343+
EXPORT_SYMBOL_GPL(r9a06g032_sysctrl_set_dmamux);
344+
318345
/* register/bit pairs are encoded as an uint16_t */
319346
static void
320347
clk_rdesc_set(struct r9a06g032_priv *clocks,
@@ -963,7 +990,13 @@ static int __init r9a06g032_clocks_probe(struct platform_device *pdev)
963990
if (error)
964991
return error;
965992

966-
return r9a06g032_add_clk_domain(dev);
993+
error = r9a06g032_add_clk_domain(dev);
994+
if (error)
995+
return error;
996+
997+
sysctrl_priv = clocks;
998+
999+
return 0;
9671000
}
9681001

9691002
static const struct of_device_id r9a06g032_match[] = {
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
/* SPDX-License-Identifier: GPL-2.0 */
2+
#ifndef __LINUX_SOC_RENESAS_R9A06G032_SYSCTRL_H__
3+
#define __LINUX_SOC_RENESAS_R9A06G032_SYSCTRL_H__
4+
5+
#ifdef CONFIG_CLK_R9A06G032
6+
int r9a06g032_sysctrl_set_dmamux(u32 mask, u32 val);
7+
#else
8+
static inline int r9a06g032_sysctrl_set_dmamux(u32 mask, u32 val) { return -ENODEV; }
9+
#endif
10+
11+
#endif /* __LINUX_SOC_RENESAS_R9A06G032_SYSCTRL_H__ */

0 commit comments

Comments
 (0)