Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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 <miquel.raynal@bootlin.com>
Acked-by: Stephen Boyd <sboyd@kernel.org>
Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
Acked-by: Geert Uytterhoeven <geert+renesas@glider.be>
Link: https://lore.kernel.org/r/20220427095653.91804-5-miquel.raynal@bootlin.com
Signed-off-by: Vinod Koul <vkoul@kernel.org>

authored by

Miquel Raynal and committed by
Vinod Koul
885525c1 7ac92262

+45 -1
+34 -1
drivers/clk/renesas/r9a06g032-clocks.c
··· 20 20 #include <linux/pm_clock.h> 21 21 #include <linux/pm_domain.h> 22 22 #include <linux/slab.h> 23 + #include <linux/soc/renesas/r9a06g032-sysctrl.h> 23 24 #include <linux/spinlock.h> 24 25 #include <dt-bindings/clock/r9a06g032-sysctrl.h> 26 + 27 + #define R9A06G032_SYSCTRL_DMAMUX 0xA0 25 28 26 29 struct r9a06g032_gate { 27 30 u16 gate, reset, ready, midle, ··· 317 314 spinlock_t lock; /* protects concurrent access to gates */ 318 315 void __iomem *reg; 319 316 }; 317 + 318 + static struct r9a06g032_priv *sysctrl_priv; 319 + 320 + /* Exported helper to access the DMAMUX register */ 321 + int r9a06g032_sysctrl_set_dmamux(u32 mask, u32 val) 322 + { 323 + unsigned long flags; 324 + u32 dmamux; 325 + 326 + if (!sysctrl_priv) 327 + return -EPROBE_DEFER; 328 + 329 + spin_lock_irqsave(&sysctrl_priv->lock, flags); 330 + 331 + dmamux = readl(sysctrl_priv->reg + R9A06G032_SYSCTRL_DMAMUX); 332 + dmamux &= ~mask; 333 + dmamux |= val & mask; 334 + writel(dmamux, sysctrl_priv->reg + R9A06G032_SYSCTRL_DMAMUX); 335 + 336 + spin_unlock_irqrestore(&sysctrl_priv->lock, flags); 337 + 338 + return 0; 339 + } 340 + EXPORT_SYMBOL_GPL(r9a06g032_sysctrl_set_dmamux); 320 341 321 342 /* register/bit pairs are encoded as an uint16_t */ 322 343 static void ··· 990 963 if (error) 991 964 return error; 992 965 993 - return r9a06g032_add_clk_domain(dev); 966 + error = r9a06g032_add_clk_domain(dev); 967 + if (error) 968 + return error; 969 + 970 + sysctrl_priv = clocks; 971 + 972 + return 0; 994 973 } 995 974 996 975 static const struct of_device_id r9a06g032_match[] = {
+11
include/linux/soc/renesas/r9a06g032-sysctrl.h
··· 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__ */