lkml.org 
[lkml]   [2022]   [Nov]   [7]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
Date
SubjectRe: [PATCH 1/7] soc: renesas: r9a06g032-sysctrl: Export function to get H2MODE from CFG_USB register
Hi Hervé,

On Mon, Nov 7, 2022 at 2:59 PM Herve Codina <herve.codina@bootlin.com> wrote:
> The CFG_USB register is located within the system controller.
>
> We need a helper to get the H2MODE value from the CFG_USB register
> without syscon.
>
> Signed-off-by: Herve Codina <herve.codina@bootlin.com>

> --- a/drivers/clk/renesas/r9a06g032-clocks.c
> +++ b/drivers/clk/renesas/r9a06g032-clocks.c
> @@ -25,6 +25,8 @@
> #include <linux/spinlock.h>
> #include <dt-bindings/clock/r9a06g032-sysctrl.h>
>
> +#define R9A06G032_SYSCTRL_USB 0x00
> +#define R9A06G032_SYSCTRL_USB_H2MODE (1<<1)
> #define R9A06G032_SYSCTRL_DMAMUX 0xA0
>
> struct r9a06g032_gate {
> @@ -341,6 +343,22 @@ int r9a06g032_sysctrl_set_dmamux(u32 mask, u32 val)
> }
> EXPORT_SYMBOL_GPL(r9a06g032_sysctrl_set_dmamux);
>
> +
> +/* Exported helper to get the H2MODE bit from USB register */
> +int r9a06g032_sysctrl_get_usb_h2mode(bool *h2mode)
> +{
> + u32 usb;
> +
> + if (!sysctrl_priv)
> + return -EPROBE_DEFER;
> +
> + usb = readl(sysctrl_priv->reg + R9A06G032_SYSCTRL_USB);
> + *h2mode = (usb & R9A06G032_SYSCTRL_USB_H2MODE) ? true : false;
> +
> + return 0;

Perhaps not pass *h2mode, but just return USB_ROLE_{HOST,DEVICE}
(enum usb_role in <linux/usb/role.h>), or a negative error code?

Gr{oetje,eeting}s,

Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds

\
 
 \ /
  Last update: 2022-11-07 15:41    [W:0.113 / U:0.340 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site