From patchwork Wed Dec 7 16:24:32 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Herve Codina X-Patchwork-Id: 30926 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp280969wrr; Wed, 7 Dec 2022 08:27:17 -0800 (PST) X-Google-Smtp-Source: AA0mqf6i5TaQGqfYFb4DXNajdASf5YARke9VYifBN6V8+QszU7Ui2nB9Zo/Q2sTq3ic+SUqPnN0T X-Received: by 2002:a17:903:22ca:b0:189:cca6:3971 with SMTP id y10-20020a17090322ca00b00189cca63971mr18931441plg.89.1670430437670; Wed, 07 Dec 2022 08:27:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670430437; cv=none; d=google.com; s=arc-20160816; b=j4qa9G2OeMX/n86vRnwgQdKHaHBAhP4jTUrQGZxY70IVLn3KXJrl7lDcbYV8DcDjWN AAN7OPjJly+twtVGN1qULbihW41WXWhNaMaiY6uZWiaK/4W3pQI6Z7PKmAayWpYhcyBy cgslc/CPyVBanOtv/cQg892YQzxLxi8SRaazcMbJR0tH+JuXKcDvDlONXQsOEP5MiEG6 RSO1hF03ogYW9YEVe73KW8xpkY0ZudO9yVWiDA6PJqb8ykRpZ7oA8igFEL65qSaXwhvB 1ZJXeSOSFGIOFzQOxpXtEJN69nYfmUDfd83N0k93m0bVR5P5bF6gGAo+I2UUFGeICkVu Yp4Q== 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=pHU0aD1tbBdA8rWIMWA9fVO3ryqaSawRTAzH+m73la0=; b=QZmPDyVBoqIn0JUFHBuWORRAAXcWS39IaOmxda0Ss5BNsC9IUGGS9gOrinY21Xhv1+ ZlIanpcYzGLFF1I3W/fYi3U4FXK1rleiLmX6nvn4urTlpo3EtBNTCPiaD3XkgzNUBH1K aydPeonqZKi2NGefDwMyCXgRrt6A6LQ36hoSbqQp40dfdShxZK8D8CjkVWsaor7i7Lsm H5zbGBswWPZxnN70o1LgV2NBuRejIlO1SURd0oaWK1MCwV8QWHVBh6RFpAFvfl5OK6ck l1gwGpqR5OCihuv7FnAWdKo0gqJbrYXTbyBbRZwrIoOeEFqPLxEsCEjk3pN73pzulPs3 8kkQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=HDim3kUS; 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 d10-20020a056a00244a00b0056aff71af29si21665942pfj.209.2022.12.07.08.27.04; Wed, 07 Dec 2022 08:27:17 -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=HDim3kUS; 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 S230103AbiLGQZM (ORCPT + 99 others); Wed, 7 Dec 2022 11:25:12 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48712 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229806AbiLGQZA (ORCPT ); Wed, 7 Dec 2022 11:25:00 -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 37B6266C96; Wed, 7 Dec 2022 08:24:56 -0800 (PST) Received: (Authenticated sender: herve.codina@bootlin.com) by mail.gandi.net (Postfix) with ESMTPA id 8507840006; Wed, 7 Dec 2022 16:24:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1670430295; 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=pHU0aD1tbBdA8rWIMWA9fVO3ryqaSawRTAzH+m73la0=; b=HDim3kUSIZzhrx35P/B82PmcbWhVElumWfFO2GVmRyvUjJK61FAyp9vVU9VeYIxHSLq4Zv 0dJa+VF3gZ7vmh/j4A6OfjwAznqaZqAgYgUzlmdahgO7wNl+Nv59HDfKWgF93yHs8wEXI0 qZs20lPadclrnVqzNtACyxir5UVDVZIjlxHBgfPotVwYgu+E9jfqpv+WtU7E1SaPLNh+7z 5/TwZ/WUYhhn3vPgUU3kLFEFa0DybBDEkR4yfs5A16FpOI2WRjLdL8YmUdk5nwR8S3nc4O HCuX/nRzAXT7U6wolbjBRyW+H4LQZr4rD7KcWCCqIg42evLgA8+m7fruRc+2Vg== From: Herve Codina To: Geert Uytterhoeven , Michael Turquette , Stephen Boyd , Rob Herring , Krzysztof Kozlowski , Herve Codina , Greg Kroah-Hartman , Magnus Damm , Gareth Williams 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 , Miquel Raynal Subject: [PATCH v3 6/9] soc: renesas: r9a06g032-sysctrl: Handle h2mode setting based on USBF presence Date: Wed, 7 Dec 2022 17:24:32 +0100 Message-Id: <20221207162435.1001782-7-herve.codina@bootlin.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221207162435.1001782-1-herve.codina@bootlin.com> References: <20221207162435.1001782-1-herve.codina@bootlin.com> MIME-Version: 1.0 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: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1751573266419585192?= X-GMAIL-MSGID: =?utf-8?q?1751573266419585192?= 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 Reviewed-by: Geert Uytterhoeven --- drivers/clk/renesas/r9a06g032-clocks.c | 28 ++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/drivers/clk/renesas/r9a06g032-clocks.c b/drivers/clk/renesas/r9a06g032-clocks.c index 1488c9d6e639..8a09ba79b97f 100644 --- a/drivers/clk/renesas/r9a06g032-clocks.c +++ b/drivers/clk/renesas/r9a06g032-clocks.c @@ -25,6 +25,8 @@ #include #include +#define R9A06G032_SYSCTRL_USB 0x00 +#define R9A06G032_SYSCTRL_USB_H2MODE (1<<1) #define R9A06G032_SYSCTRL_DMAMUX 0xA0 struct r9a06g032_gate { @@ -919,6 +921,29 @@ static void r9a06g032_clocks_del_clk_provider(void *data) of_clk_del_provider(data); } +static void __init r9a06g032_init_h2mode(struct r9a06g032_priv *clocks) +{ + struct device_node *usbf_np = NULL; + u32 usb; + + while ((usbf_np = of_find_compatible_node(usbf_np, NULL, + "renesas,rzn1-usbf"))) { + if (of_device_is_available(usbf_np)) + break; + } + + usb = readl(clocks->reg + R9A06G032_SYSCTRL_USB); + if (usbf_np) { + /* 1 host and 1 device mode */ + usb &= ~R9A06G032_SYSCTRL_USB_H2MODE; + of_node_put(usbf_np); + } else { + /* 2 hosts mode */ + usb |= R9A06G032_SYSCTRL_USB_H2MODE; + } + writel(usb, clocks->reg + R9A06G032_SYSCTRL_USB); +} + static int __init r9a06g032_clocks_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; @@ -948,6 +973,9 @@ static int __init r9a06g032_clocks_probe(struct platform_device *pdev) clocks->reg = of_iomap(np, 0); if (WARN_ON(!clocks->reg)) return -ENOMEM; + + r9a06g032_init_h2mode(clocks); + for (i = 0; i < ARRAY_SIZE(r9a06g032_clocks); ++i) { const struct r9a06g032_clkdesc *d = &r9a06g032_clocks[i]; const char *parent_name = d->source ?