From patchwork Mon Nov 7 13:58:19 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Herve Codina X-Patchwork-Id: 16421 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp2065854wru; Mon, 7 Nov 2022 06:00:48 -0800 (PST) X-Google-Smtp-Source: AMsMyM53wXlJQHFWXOShUV4aQChSJN7eu3rSSQqslPcLEDEwwDZpS0Q3NEcXHTG5JSj0na3NMhqa X-Received: by 2002:a17:90b:1a8f:b0:213:f880:8c31 with SMTP id ng15-20020a17090b1a8f00b00213f8808c31mr38124740pjb.137.1667829647534; Mon, 07 Nov 2022 06:00:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1667829647; cv=none; d=google.com; s=arc-20160816; b=FT0qVxK4HtUB1fcBGa2WQ13eBLscIlb6vu2IDWsn98GfazJLe/KHecrnAed1MEL4/k mpLfC7Y+MaTWt1EEe47HvXhFD4RIa7O2zoKY9QJWyv/2tdSpSmp3SrHyncRIGHlgNItY wl7zRD83h/eMF3RcKEfbRj3hTSiZJYJ03K5dsn9zKtfNZ1s5DYqgkpaYql8ISQLRjOpc X/qAmR3qG7kuBVlqDO3aCUIuiwUHXsJC+V8NLAbfhS08he/83P6TqQiPsiN6uBHY5/tt PlYPQJzQbiNsDNbcQOGlnQgNqDk1Ni2ZLqMp64mHUc7b5QxwFb/vLAxWv/14/GK3uQz0 hmhQ== 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=/XeTPzP6Y4Gj/XYPtWuOUx4qjJonbX3OpxaDrJOsO+A=; b=z0upoLYTBAA47wcui94+bHikRqcAuIXJ4KiZVs3bcb0Y3DTL9Wq5jMmQWwt2t/BAEJ xHrdCNipqFZee/Fv8SvuJUoGMOmXreA5bI33x8ZhOTBpUP9RtIUES8w5hCRm87Z7BpNz ynD0KZSSH0nkoetpBj4O5CxqNiXqQ1H1aPChxP+JLOcw0mAy8EmNgeIuEUBX+/0Bepr9 9nOq02eUSSd/Sg3Yl3sIOFGvtZlNRe3T5p3X4bGmHPDwLPB6ws7wQ4rQinIFMj8pzv6q OygohN+OgJXDTPp2we9AIlp3sfxzJWPI3lS/J5929Y6grNWWbnqyH7fy9ChQrrUJw2qn Pkqw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=dTtruHqg; 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 e17-20020a656791000000b0044034f2c3b8si10472151pgr.310.2022.11.07.06.00.33; Mon, 07 Nov 2022 06:00:47 -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=dTtruHqg; 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 S232016AbiKGN7x (ORCPT + 99 others); Mon, 7 Nov 2022 08:59:53 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47540 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231920AbiKGN7t (ORCPT ); Mon, 7 Nov 2022 08:59:49 -0500 Received: from relay2-d.mail.gandi.net (relay2-d.mail.gandi.net [IPv6:2001:4b98:dc4:8::222]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ADBF0323; Mon, 7 Nov 2022 05:59:47 -0800 (PST) Received: (Authenticated sender: herve.codina@bootlin.com) by mail.gandi.net (Postfix) with ESMTPA id D8C0F4000E; Mon, 7 Nov 2022 13:59:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1667829586; 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=/XeTPzP6Y4Gj/XYPtWuOUx4qjJonbX3OpxaDrJOsO+A=; b=dTtruHqgtHo0yJwdj/3+/6gCE5AcGDWgU2GOXru8I0N+fjzQgeb+YRyrzU77vhyr5SXuos TOhievX5VWnLOXY4rWR2RIM5WNb+tw0nFVHuix5epDgypJhkX9LKkn0Xh/Rz4AtjqQRr9W EZ/ik5F+HcfdN9XuHb2yXynjCAm6NCHP4tn6Mh51JqvKQkxWPtmhdN4nnvYEyQRgW6pNS7 0LMtC2uoshsDrefWXK17HXaBY0Epw9PedkeT9aBQTuuEFljufc3Pi0rshqBKXGhv9Q5Tm6 f0JzH8WGNuNXtRtNkOXbqbE9IaXMWbjE5H413nAxeP7HP1QqYa8g8SgYlMRjdw== 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 1/7] soc: renesas: r9a06g032-sysctrl: Export function to get H2MODE from CFG_USB register Date: Mon, 7 Nov 2022 14:58:19 +0100 Message-Id: <20221107135825.583877-2-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 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,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?1748846140391641676?= X-GMAIL-MSGID: =?utf-8?q?1748846140391641676?= 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 --- drivers/clk/renesas/r9a06g032-clocks.c | 18 ++++++++++++++++++ include/linux/soc/renesas/r9a06g032-sysctrl.h | 2 ++ 2 files changed, 20 insertions(+) diff --git a/drivers/clk/renesas/r9a06g032-clocks.c b/drivers/clk/renesas/r9a06g032-clocks.c index 1488c9d6e639..c07131c47a9f 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 { @@ -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; +} +EXPORT_SYMBOL_GPL(r9a06g032_sysctrl_get_usb_h2mode); + /* register/bit pairs are encoded as an uint16_t */ static void clk_rdesc_set(struct r9a06g032_priv *clocks, diff --git a/include/linux/soc/renesas/r9a06g032-sysctrl.h b/include/linux/soc/renesas/r9a06g032-sysctrl.h index 066dfb15cbdd..095e00f27309 100644 --- a/include/linux/soc/renesas/r9a06g032-sysctrl.h +++ b/include/linux/soc/renesas/r9a06g032-sysctrl.h @@ -4,8 +4,10 @@ #ifdef CONFIG_CLK_R9A06G032 int r9a06g032_sysctrl_set_dmamux(u32 mask, u32 val); +int r9a06g032_sysctrl_get_usb_h2mode(bool *h2mode); #else static inline int r9a06g032_sysctrl_set_dmamux(u32 mask, u32 val) { return -ENODEV; } +static inline int r9a06g032_sysctrl_get_usb_h2mode(bool *h2mode) { return -ENODEV; } #endif #endif /* __LINUX_SOC_RENESAS_R9A06G032_SYSCTRL_H__ */