Skip to content

Commit d463864

Browse files
hcodinageertu
authored andcommitted
clk: renesas: r9a06g032: Handle h2mode setting based on USBF presence
The CFG_USB[H2MODE] allows to switch the USB configuration. The configuration supported are: - One host and one device or - Two hosts Set CFG_USB[H2MODE] based on the USBF controller (USB device) availability. Signed-off-by: Herve Codina <[email protected]> Reviewed-by: Geert Uytterhoeven <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Geert Uytterhoeven <[email protected]>
1 parent fbfd614 commit d463864

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

drivers/clk/renesas/r9a06g032-clocks.c

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@
2525
#include <linux/spinlock.h>
2626
#include <dt-bindings/clock/r9a06g032-sysctrl.h>
2727

28+
#define R9A06G032_SYSCTRL_USB 0x00
29+
#define R9A06G032_SYSCTRL_USB_H2MODE (1<<1)
2830
#define R9A06G032_SYSCTRL_DMAMUX 0xA0
2931

3032
struct r9a06g032_gate {
@@ -918,6 +920,29 @@ static void r9a06g032_clocks_del_clk_provider(void *data)
918920
of_clk_del_provider(data);
919921
}
920922

923+
static void __init r9a06g032_init_h2mode(struct r9a06g032_priv *clocks)
924+
{
925+
struct device_node *usbf_np = NULL;
926+
u32 usb;
927+
928+
while ((usbf_np = of_find_compatible_node(usbf_np, NULL,
929+
"renesas,rzn1-usbf"))) {
930+
if (of_device_is_available(usbf_np))
931+
break;
932+
}
933+
934+
usb = readl(clocks->reg + R9A06G032_SYSCTRL_USB);
935+
if (usbf_np) {
936+
/* 1 host and 1 device mode */
937+
usb &= ~R9A06G032_SYSCTRL_USB_H2MODE;
938+
of_node_put(usbf_np);
939+
} else {
940+
/* 2 hosts mode */
941+
usb |= R9A06G032_SYSCTRL_USB_H2MODE;
942+
}
943+
writel(usb, clocks->reg + R9A06G032_SYSCTRL_USB);
944+
}
945+
921946
static int __init r9a06g032_clocks_probe(struct platform_device *pdev)
922947
{
923948
struct device *dev = &pdev->dev;
@@ -947,6 +972,9 @@ static int __init r9a06g032_clocks_probe(struct platform_device *pdev)
947972
clocks->reg = of_iomap(np, 0);
948973
if (WARN_ON(!clocks->reg))
949974
return -ENOMEM;
975+
976+
r9a06g032_init_h2mode(clocks);
977+
950978
for (i = 0; i < ARRAY_SIZE(r9a06g032_clocks); ++i) {
951979
const struct r9a06g032_clkdesc *d = &r9a06g032_clocks[i];
952980
const char *parent_name = d->source ?

0 commit comments

Comments
 (0)