Skip to content

Commit

Permalink
soc: renesas: rzn1-sysc: Export function to set dmamux
Browse files Browse the repository at this point in the history
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 <miquel.raynal@bootlin.com>
  • Loading branch information
miquelraynal authored and intel-lab-lkp committed Feb 20, 2022
1 parent 5443537 commit ed9b880
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 0 deletions.
27 changes: 27 additions & 0 deletions drivers/clk/renesas/r9a06g032-clocks.c
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,27 @@ struct r9a06g032_priv {
void __iomem *reg;
};

/* Exported helper to access the DMAMUX register */
static struct r9a06g032_priv *syscon_priv;
int r9a06g032_syscon_set_dmamux(u32 mask, u32 val)
{
u32 dmamux;

if (!syscon_priv)
return -EPROBE_DEFER;

spin_lock(&syscon_priv->lock);

dmamux = readl(syscon_priv->reg + R9A06G032_SYSCON_DMAMUX);
dmamux &= ~mask;
dmamux |= val & mask;
writel(dmamux, syscon_priv->reg + R9A06G032_SYSCON_DMAMUX);

spin_unlock(&syscon_priv->lock);

return 0;
}

/* register/bit pairs are encoded as an uint16_t */
static void
clk_rdesc_set(struct r9a06g032_priv *clocks,
Expand Down Expand Up @@ -922,6 +943,12 @@ static int __init r9a06g032_clocks_probe(struct platform_device *pdev)
clocks->reg = of_iomap(np, 0);
if (WARN_ON(!clocks->reg))
return -ENOMEM;

if (syscon_priv)
return -EBUSY;

syscon_priv = clocks;

for (i = 0; i < ARRAY_SIZE(r9a06g032_clocks); ++i) {
const struct r9a06g032_clkdesc *d = &r9a06g032_clocks[i];
const char *parent_name = d->source ?
Expand Down
2 changes: 2 additions & 0 deletions include/dt-bindings/clock/r9a06g032-sysctrl.h
Original file line number Diff line number Diff line change
Expand Up @@ -145,4 +145,6 @@
#define R9A06G032_CLK_UART6 152
#define R9A06G032_CLK_UART7 153

#define R9A06G032_SYSCON_DMAMUX 0xA0

#endif /* __DT_BINDINGS_R9A06G032_SYSCTRL_H__ */
11 changes: 11 additions & 0 deletions include/linux/soc/renesas/r9a06g032-syscon.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/* SPDX-License-Identifier: GPL-2.0 */
#ifndef __LINUX_SOC_RENESAS_R9A06G032_SYSCON_H__
#define __LINUX_SOC_RENESAS_R9A06G032_SYSCON_H__

#ifdef CONFIG_CLK_R9A06G032
int r9a06g032_syscon_set_dmamux(u32 mask, u32 val);
#else
static inline int r9a06g032_syscon_set_dmamux(u32 mask, u32 val) { return -ENODEV; }
#endif

#endif /* __LINUX_SOC_RENESAS_R9A06G032_SYSCON_H__ */

0 comments on commit ed9b880

Please sign in to comment.