Message ID | 20221107135825.583877-4-herve.codina@bootlin.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp2066086wru; Mon, 7 Nov 2022 06:01:12 -0800 (PST) X-Google-Smtp-Source: AMsMyM4fAcVXmtkdQAJ9dnbrTMTgAh8El8kqSCglDKMCXCVXXwO+O8He6gtW3Auxfj4qBSB0yJT3 X-Received: by 2002:a63:1c1b:0:b0:46f:7b0f:4fea with SMTP id c27-20020a631c1b000000b0046f7b0f4feamr42083562pgc.423.1667829671790; Mon, 07 Nov 2022 06:01:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1667829671; cv=none; d=google.com; s=arc-20160816; b=0+3CnnVw3D10FV9n1e1O4oryFMBLr2VB4pDzJNFJUqHc1RAI5z+CA9A2byrptDzRR4 9n9jujsioCf9k/923u1n5Gmpm2ZfvlWombOwaZYTwfRH2ARN6VZS5xgvC6xRlhoSImmI eIrYeKA1WnkwfHq+UzrjJTDgbnnCbAOYWLiSmfKxSGCESFjFb8BJvpReb03pz21plS+Z SZjshH3ujGWrxsBggZ1JrE87AIf2GQAhySMC1URFvY5R8DLNhS88UH1PrxUnb3Z5CYH3 ZYDQlBsWOMl6nS2xvESmSdNev0QX5HldB9ZcV0p2Sgm4G4C/e6mGWrQJW9qY7VvWauFy d/cg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=YKoaAUgQsPPuJwz9X1D+0C6IS4Z6KPB6+tN/gbl8R74=; b=l07bi1ucFTHBX8dwOnDparbW/0ClQoGi5RJTqcnZ3EyNHU7gC4/6CSmwo1WSxGIdxp W3FaGtibZSqq6FOjJZKvl1Pxen2KU/XuMnzShBhEU/Gtz1buYkPIErEDNGd40dFxgIq2 E+ZJeb/2rm60zHHQrQRo8ukBlg1Rms7cCdw05iwwCWfP46VtdqegHidVX6x2aKT7x3h7 Ooeb/ajoaquPFyvrmgN4QANTWoNbLXmXR4EpdL07kVBB5ugJvKxKBVPygT6D9tIvTtJy 3J+uDYcfe3/At+yugmYdhK4pS9ZMEJmrLUXErxYgY0GiOvoI+eTosxuwAAoP8P5g3IBO Q//w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=X7yGRTRf; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 23-20020a631657000000b0044cce26fa32si9425467pgw.632.2022.11.07.06.00.56; Mon, 07 Nov 2022 06:01:11 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=X7yGRTRf; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232125AbiKGOAG (ORCPT <rfc822;hjfbswb@gmail.com> + 99 others); Mon, 7 Nov 2022 09:00:06 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47706 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232066AbiKGN77 (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Mon, 7 Nov 2022 08:59:59 -0500 Received: from relay2-d.mail.gandi.net (relay2-d.mail.gandi.net [217.70.183.194]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BBD01B1E; Mon, 7 Nov 2022 05:59:57 -0800 (PST) Received: (Authenticated sender: herve.codina@bootlin.com) by mail.gandi.net (Postfix) with ESMTPA id 5077340014; Mon, 7 Nov 2022 13:59:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1667829596; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=YKoaAUgQsPPuJwz9X1D+0C6IS4Z6KPB6+tN/gbl8R74=; b=X7yGRTRfOv99RzqCWD0z75L907GGwaEL0pl/yBFaaJFBkBW7hxUDPdqZfkzYld4E6wTLpl Iw9rwkgI9Yj79dJGAqWNihgIXzfqTDbt0UXmop5QshNd4U4s2HCp4PwfwcAFaaIpkdjqlP 9wZHIGliMI3Aw5aRmbt82b3uYsXg9GjeAJbnl0i/UzzjvFQ4/TpZInwWFUwc+rMlaT8HsY RyT9bLsniJjhqUhyIknszB2k1AR3aQ1IriR9b9m0MBhCaQ8zTRKprae7ylQFTH3CWPKgZi g+kb6fld1f8IgpgDJOiqxcwxTNAKwcDOj3Dq+EB+A8C1D8c6hMFDJliUdasFdw== From: Herve Codina <herve.codina@bootlin.com> To: Geert Uytterhoeven <geert+renesas@glider.be>, Michael Turquette <mturquette@baylibre.com>, Stephen Boyd <sboyd@kernel.org>, Rob Herring <robh+dt@kernel.org>, Krzysztof Kozlowski <krzysztof.kozlowski+dt@linaro.org>, Herve Codina <herve.codina@bootlin.com>, Greg Kroah-Hartman <gregkh@linuxfoundation.org>, Magnus Damm <magnus.damm@gmail.com>, Gareth Williams <gareth.williams.jx@renesas.com> Cc: linux-renesas-soc@vger.kernel.org, linux-clk@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-usb@vger.kernel.org, Thomas Petazzoni <thomas.petazzoni@bootlin.com>, Miquel Raynal <miquel.raynal@bootlin.com> Subject: [PATCH 3/7] soc: renesas: r9a06g032-sysctrl: Handle h2mode device-tree property Date: Mon, 7 Nov 2022 14:58:21 +0100 Message-Id: <20221107135825.583877-4-herve.codina@bootlin.com> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221107135825.583877-1-herve.codina@bootlin.com> References: <20221107135825.583877-1-herve.codina@bootlin.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1748846165920214170?= X-GMAIL-MSGID: =?utf-8?q?1748846165920214170?= |
Series |
Add the Renesas USBF controller support
|
|
Commit Message
Herve Codina
Nov. 7, 2022, 1:58 p.m. UTC
Handle the h2mode property and forces the CFG_USB[H2MODE] bit
accordingly.
Signed-off-by: Herve Codina <herve.codina@bootlin.com>
---
drivers/clk/renesas/r9a06g032-clocks.c | 21 +++++++++++++++++++++
1 file changed, 21 insertions(+)
Comments
Hi Hervé, On Mon, Nov 7, 2022 at 2:59 PM Herve Codina <herve.codina@bootlin.com> wrote: > Handle the h2mode property and forces the CFG_USB[H2MODE] bit > accordingly. > > Signed-off-by: Herve Codina <herve.codina@bootlin.com> Thanks for your patch! > --- a/drivers/clk/renesas/r9a06g032-clocks.c > +++ b/drivers/clk/renesas/r9a06g032-clocks.c > @@ -946,6 +946,7 @@ static int __init r9a06g032_clocks_probe(struct platform_device *pdev) > struct clk *mclk; > unsigned int i; > u16 uart_group_sel[2]; > + u32 usb, h2mode; > int error; > > clocks = devm_kzalloc(dev, sizeof(*clocks), GFP_KERNEL); > @@ -966,6 +967,26 @@ static int __init r9a06g032_clocks_probe(struct platform_device *pdev) > clocks->reg = of_iomap(np, 0); > if (WARN_ON(!clocks->reg)) > return -ENOMEM; > + > + error = of_property_read_u32(np, "renesas,h2mode", &h2mode); > + if (!error) { > + usb = readl(clocks->reg + R9A06G032_SYSCTRL_USB); > + switch (h2mode) { > + case 0: > + /* 1 host, 1 device */ > + usb &= ~R9A06G032_SYSCTRL_USB_H2MODE; > + break; > + case 1: > + /* 2 hosts */ > + usb |= R9A06G032_SYSCTRL_USB_H2MODE; > + break; > + default: > + dev_err(dev, "invalid h2mode %d\n", h2mode); > + return -EINVAL; > + } > + writel(usb, clocks->reg + R9A06G032_SYSCTRL_USB); Reading the big fat warnings in the documentation about changing this at runtime (disconnect nodes, reset clocks, ...), I'm wondering if the above is sufficient? > + } > + > for (i = 0; i < ARRAY_SIZE(r9a06g032_clocks); ++i) { > const struct r9a06g032_clkdesc *d = &r9a06g032_clocks[i]; > const char *parent_name = d->source ? 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
Hi Geert, On Mon, 7 Nov 2022 16:18:06 +0100 Geert Uytterhoeven <geert@linux-m68k.org> wrote: > Hi Hervé, > > On Mon, Nov 7, 2022 at 2:59 PM Herve Codina <herve.codina@bootlin.com> wrote: > > Handle the h2mode property and forces the CFG_USB[H2MODE] bit > > accordingly. > > > > Signed-off-by: Herve Codina <herve.codina@bootlin.com> > > Thanks for your patch! > > > --- a/drivers/clk/renesas/r9a06g032-clocks.c > > +++ b/drivers/clk/renesas/r9a06g032-clocks.c > > @@ -946,6 +946,7 @@ static int __init r9a06g032_clocks_probe(struct platform_device *pdev) > > struct clk *mclk; > > unsigned int i; > > u16 uart_group_sel[2]; > > + u32 usb, h2mode; > > int error; > > > > clocks = devm_kzalloc(dev, sizeof(*clocks), GFP_KERNEL); > > @@ -966,6 +967,26 @@ static int __init r9a06g032_clocks_probe(struct platform_device *pdev) > > clocks->reg = of_iomap(np, 0); > > if (WARN_ON(!clocks->reg)) > > return -ENOMEM; > > + > > + error = of_property_read_u32(np, "renesas,h2mode", &h2mode); > > + if (!error) { > > + usb = readl(clocks->reg + R9A06G032_SYSCTRL_USB); > > + switch (h2mode) { > > + case 0: > > + /* 1 host, 1 device */ > > + usb &= ~R9A06G032_SYSCTRL_USB_H2MODE; > > + break; > > + case 1: > > + /* 2 hosts */ > > + usb |= R9A06G032_SYSCTRL_USB_H2MODE; > > + break; > > + default: > > + dev_err(dev, "invalid h2mode %d\n", h2mode); > > + return -EINVAL; > > + } > > + writel(usb, clocks->reg + R9A06G032_SYSCTRL_USB); > > Reading the big fat warnings in the documentation about changing > this at runtime (disconnect nodes, reset clocks, ...), I'm wondering if > the above is sufficient? Well, indeed we should "disconnect all module operated by USBPLL clock from the NoC interconnect". I am a bit lost in the sysctrl driver and the clock/reset stuffs. In fact, I don't really know how to do that. I thought that setting the H2MODE value at the clock probe function would be sufficient, expecting that the connections would not be already done and I didn't see any issues on my system. Maybe I missed the bootloader that could have already done some connections. Can someone help ? > > > + } > > + > > for (i = 0; i < ARRAY_SIZE(r9a06g032_clocks); ++i) { > > const struct r9a06g032_clkdesc *d = &r9a06g032_clocks[i]; > > const char *parent_name = d->source ? > > 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 Thanks, Hervé
diff --git a/drivers/clk/renesas/r9a06g032-clocks.c b/drivers/clk/renesas/r9a06g032-clocks.c index c07131c47a9f..562c2aba910b 100644 --- a/drivers/clk/renesas/r9a06g032-clocks.c +++ b/drivers/clk/renesas/r9a06g032-clocks.c @@ -946,6 +946,7 @@ static int __init r9a06g032_clocks_probe(struct platform_device *pdev) struct clk *mclk; unsigned int i; u16 uart_group_sel[2]; + u32 usb, h2mode; int error; clocks = devm_kzalloc(dev, sizeof(*clocks), GFP_KERNEL); @@ -966,6 +967,26 @@ static int __init r9a06g032_clocks_probe(struct platform_device *pdev) clocks->reg = of_iomap(np, 0); if (WARN_ON(!clocks->reg)) return -ENOMEM; + + error = of_property_read_u32(np, "renesas,h2mode", &h2mode); + if (!error) { + usb = readl(clocks->reg + R9A06G032_SYSCTRL_USB); + switch (h2mode) { + case 0: + /* 1 host, 1 device */ + usb &= ~R9A06G032_SYSCTRL_USB_H2MODE; + break; + case 1: + /* 2 hosts */ + usb |= R9A06G032_SYSCTRL_USB_H2MODE; + break; + default: + dev_err(dev, "invalid h2mode %d\n", h2mode); + return -EINVAL; + } + writel(usb, clocks->reg + R9A06G032_SYSCTRL_USB); + } + for (i = 0; i < ARRAY_SIZE(r9a06g032_clocks); ++i) { const struct r9a06g032_clkdesc *d = &r9a06g032_clocks[i]; const char *parent_name = d->source ?