From patchwork Mon Jan 8 02:17:28 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Lechner X-Patchwork-Id: 10148855 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 37EDE601BE for ; Mon, 8 Jan 2018 02:51:13 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 281D6284F9 for ; Mon, 8 Jan 2018 02:51:13 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1B49928607; Mon, 8 Jan 2018 02:51:13 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_MED autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id ADD59284F9 for ; Mon, 8 Jan 2018 02:51:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=Luf7WtPVpXJpaUNTYDoM/YkKzyIEKFg1kLP+0/O/0d0=; b=qW9OXZT/kJpNJL65xjTLmzWotn TMR7A6rteGeoGDgl+YWSsWXZ+OGcaopdsdlN3JiE/l0+fsR5ABRsOet9JEEF4hrN6N69IqFJQ7J7X TKOmNQ4z+xAi3N459nPDq5hJpEu8N+Y8QCjomdd5lQHVJAM3c/dSuHSWWLsuaQ2y2RmLaM3vAktWr V8z1o/5B0vXzx1kH6JGRcpAcaEA0ub3FyZUkocTxZwJjDvtpWOoK4KAaxhYJtjbXgr9JS4812VXEj pgbm/tx7FF9HhxOTK5jaCxOTuvUgnd7P/s3mvYOC1lwdo6Xxyxv0QUgeIBc4AsvyYz/dYu5q5BiHW a8GX7shg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.89 #1 (Red Hat Linux)) id 1eYNWl-00068x-Qd; Mon, 08 Jan 2018 02:51:07 +0000 Received: from casper.infradead.org ([2001:8b0:10b:1236::1]) by bombadil.infradead.org with esmtps (Exim 4.89 #1 (Red Hat Linux)) id 1eYNOc-0007cX-8a for linux-arm-kernel@bombadil.infradead.org; Mon, 08 Jan 2018 02:42:42 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=References:In-Reply-To:Message-Id:Date: Subject:Cc:To:From:Sender:Reply-To:MIME-Version:Content-Type: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=vFQvisscvRrnF6HYVfz73xi8dAOrLyGX+X2maqrFyEQ=; b=ovANDww/freTcQ6ciA3JwENAx XJFe5x6dE3W7wjMRhJnXZEcz6m23xvFC2WCJbelb58O3ow28aUpu6RObDpA40yVZt8xWXOog+NOEz W/StHgmnj3zPIDF0C7cLJUmM59g2ekXSxzC9jnGdvj7fEYOXeYCySZNxQG0kvs8RUQkuW97d9fWaj bDfq4DUvGbOyQoBwTwTtERLvdVUxXHdYiUFGzzGxA8yTENwo5gVyP7fsVu8jyVLheeCzOWuTTLPq9 aok7rKw+Y/5duZgJymLP3KkMlPaMP/L+/FLwk4uL0pjbrbaBNsZb2ANOJ3x1UlnC+PRgiVVxtYOTs NoqjlfRuw==; Received: from vern.gendns.com ([206.190.152.46]) by casper.infradead.org with esmtps (Exim 4.89 #1 (Red Hat Linux)) id 1eYN2i-0006ol-3R for linux-arm-kernel@lists.infradead.org; Mon, 08 Jan 2018 02:20:07 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lechnology.com; s=default; h=References:In-Reply-To:Message-Id:Date:Subject :Cc:To:From:Sender:Reply-To:MIME-Version:Content-Type: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=vFQvisscvRrnF6HYVfz73xi8dAOrLyGX+X2maqrFyEQ=; b=xY1q3ZnQYKYyLSK4rWtQf7GsL BsxC+HuKRiY2/AlFLt6yBgG6sQ6Olx17jXgAe8BWaNcVFRvANFuQHhPo7RiXK1B601mCvADx0SFdF kU5OssSn6tg1oYFTuReeuGt7dHt71y/neAFRok/Wql6uC1X+XpUMbDM8Rc8HPmUodhAi/SyOfoSQO N24LE0ZNItbS9a+1v5Sv+ucqx4ZL2Yo0E3IuHOOjrvZ8LMcBaTRLQaoCh3SepUf5rznwFMdJ4pjZI rsthHAjHDUxyEh0a9mwXabgpWVxq3DoWdmNx3QSW+eR/dh5A4A82GDb9wjuNz5EcF9S8v/g+xvgvu cCltjQf2Q==; Received: from 108-198-5-147.lightspeed.okcbok.sbcglobal.net ([108.198.5.147]:53904 helo=freyr.lechnology.com) by vern.gendns.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES128-SHA256:128) (Exim 4.89) (envelope-from ) id 1eYN1d-0009GR-6q; Sun, 07 Jan 2018 21:18:57 -0500 From: David Lechner To: linux-clk@vger.kernel.org, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH v5 29/44] ARM: da8xx: add new USB PHY clock init using common clock framework Date: Sun, 7 Jan 2018 20:17:28 -0600 Message-Id: <1515377863-20358-30-git-send-email-david@lechnology.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1515377863-20358-1-git-send-email-david@lechnology.com> References: <1515377863-20358-1-git-send-email-david@lechnology.com> X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - vern.gendns.com X-AntiAbuse: Original Domain - lists.infradead.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - lechnology.com X-Get-Message-Sender-Via: vern.gendns.com: authenticated_id: davidmain+lechnology.com/only user confirmed/virtual account not confirmed X-Authenticated-Sender: vern.gendns.com: davidmain@lechnology.com X-Source: X-Source-Args: X-Source-Dir: X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180108_022004_334415_A2C933CF X-CRM114-Status: GOOD ( 14.08 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mark Rutland , David Lechner , Kevin Hilman , Stephen Boyd , Michael Turquette , Sekhar Nori , linux-kernel@vger.kernel.org, Rob Herring , Adam Ford MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP This adds the new USB PHY clock init in mach-davinci/usb-da8xx.c using the new common clock framework drivers. The #ifdefs are needed to prevent compile errors until the entire ARCH_DAVINCI is converted. Signed-off-by: David Lechner --- arch/arm/mach-davinci/usb-da8xx.c | 84 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 83 insertions(+), 1 deletion(-) diff --git a/arch/arm/mach-davinci/usb-da8xx.c b/arch/arm/mach-davinci/usb-da8xx.c index d480a02..d7340670 100644 --- a/arch/arm/mach-davinci/usb-da8xx.c +++ b/arch/arm/mach-davinci/usb-da8xx.c @@ -2,28 +2,36 @@ /* * DA8xx USB */ +#include #include +#include +#include #include #include #include #include +#include #include #include #include #include -#include #include #include #include #include +#ifndef CONFIG_COMMON_CLK +#include #include "clock.h" +#endif #define DA8XX_USB0_BASE 0x01e00000 #define DA8XX_USB1_BASE 0x01e25000 +#ifndef CONFIG_COMMON_CLK static struct clk *usb20_clk; +#endif static struct platform_device da8xx_usb_phy = { .name = "da8xx-usb-phy", @@ -128,6 +136,7 @@ int __init da8xx_register_usb11(struct da8xx_ohci_root_hub *pdata) return platform_device_register(&da8xx_usb11_device); } +#ifndef CONFIG_COMMON_CLK static struct clk usb_refclkin = { .name = "usb_refclkin", .set_rate = davinci_simple_set_rate, @@ -354,3 +363,76 @@ int __init da8xx_register_usb11_phy_clk(bool use_usb_refclkin) return ret; } +#else +/** + * da8xx_register_usb20_phy_clk - register USB0PHYCLKMUX clock + * + * @use_usb_refclkin: Selects the parent clock - either "usb_refclkin" if true + * or "pll0_aux_clk" if false. + */ +int __init da8xx_register_usb20_phy_clk(bool use_usb_refclkin) +{ + struct regmap *cfgchip; + struct clk *usb0_psc_clk, *clk; + struct clk_hw *parent; + + cfgchip = syscon_regmap_lookup_by_compatible("ti,da830-cfgchip"); + if (IS_ERR(cfgchip)) + cfgchip = syscon_regmap_lookup_by_pdevname("syscon"); + if (IS_ERR(cfgchip)) + return PTR_ERR(cfgchip); + + usb0_psc_clk = clk_get_sys("musb-da8xx", NULL); + if (IS_ERR(usb0_psc_clk)) + return PTR_ERR(usb0_psc_clk); + + clk = da8xx_usb0_phy_clk_register("usb0_phy_clk", "usb_refclkin", + "pll0_aux_clk", usb0_psc_clk, cfgchip); + if (IS_ERR(clk)) { + clk_put(usb0_psc_clk); + return PTR_ERR(clk); + } + + parent = clk_hw_get_parent_by_index(__clk_get_hw(clk), + use_usb_refclkin ? 0 : 1); + if (parent) + clk_set_parent(clk, parent->clk); + else + pr_warn("%s: Failed to find parent clock\n", __func__); + + return clk_register_clkdev(clk, "usb20_phy", "da8xx-usb-phy"); +} + +/** + * da8xx_register_usb11_phy_clk - register USB1PHYCLKMUX clock + * + * @use_usb_refclkin: Selects the parent clock - either "usb_refclkin" if true + * or "usb0_phy_clk" if false. + */ +int __init da8xx_register_usb11_phy_clk(bool use_usb_refclkin) +{ + struct regmap *cfgchip; + struct clk *clk; + struct clk_hw *parent; + + cfgchip = syscon_regmap_lookup_by_compatible("ti,da830-cfgchip"); + if (IS_ERR(cfgchip)) + cfgchip = syscon_regmap_lookup_by_pdevname("syscon"); + if (IS_ERR(cfgchip)) + return PTR_ERR(cfgchip); + + clk = da8xx_usb1_phy_clk_register("usb1_phy_clk", "usb0_phy_clk", + "usb_refclkin", cfgchip); + if (IS_ERR(clk)) + return PTR_ERR(clk); + + parent = clk_hw_get_parent_by_index(__clk_get_hw(clk), + use_usb_refclkin ? 1 : 0); + if (parent) + clk_set_parent(clk, parent->clk); + else + pr_warn("%s: Failed to find parent clock\n", __func__); + + return clk_register_clkdev(clk, "usb11_phy", "da8xx-usb-phy"); +} +#endif