From patchwork Sat Jan 20 17:14:05 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Lechner X-Patchwork-Id: 10176449 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 B3A976056F for ; Sat, 20 Jan 2018 17:17:38 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9862C2856E for ; Sat, 20 Jan 2018 17:17:38 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8D13F28812; Sat, 20 Jan 2018 17:17:38 +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=ham 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 F21DD2856E for ; Sat, 20 Jan 2018 17:17:37 +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=glLi99hz7MBElHSeY+XhjIuMlgI56ez/i1Udh7q6tWI=; b=B7wu/Uamzp2EkuixEkSJRb4EPz vQNbDYNRkHeCQF3+AY+XSVmTJq/0Ad/aPKRexkTjU/utvZynZnU8rVslEjTU5+vmNFUsJSIxce4T8 +qUY4GYD0RYUHQOdoeRk0NBokQnQ6Rm4b+Cox6RQ8UKowMqxPoF2lbyUMs5P6dptsJ1LpB5V2RZL8 DUBY+6TRF3K6HhjHYwT9ukamyZZnbDxKZC24h8bOLRdaCNg4d5RhosTHe0W9HvrjEUPUE4NBS/8mG kvFWbECv6LbX6YacTm1IscmqTYAosuhqy8aexzCq3SWM4jy77te8mp4C2MBObMH3vFkEqjAlBlM/W 4F4BGbZQ==; 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 1ecwlo-0007Zl-NT; Sat, 20 Jan 2018 17:17:32 +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 1ecwkS-0006AH-2z for linux-arm-kernel@bombadil.infradead.org; Sat, 20 Jan 2018 17:16:08 +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=b9qffZ2t6CmuL8sfSbzyQOnW5eS+D8h94FzsAHuMMnQ=; b=LJiZWKT6517ITMKZD6G8hITY3 Ob5KLe3toqYLDQ1A7U8C+J9wg4Zh0zggKcf0Ogg2oCuzUyF4UEwIXS5GkHK1aE0PAQIx7XYqZw5ci 2jQkbVsp0LwX4GsAjBvc7baRrYUpSkl8PjpyoKsgJNAB4aYN0oo7btlg4k+S8Yv0NPBvFu9ADu3kb Ab3fjG+Ac6VeQIOwnJvaKX/EZ+QpuEDgRGOsjm9t+BnP1i4ptP7+b3z9EzoOuH87HAV6ntG1Bb84t eu+uC+hT0yJH/+y7dS571FxtzZPjAew51+Dxwq8Md50OfMmAYod+tcc1KwFtD14t439ZAuRbvf89w VDewbUZBQ==; Received: from vern.gendns.com ([206.190.152.46]) by casper.infradead.org with esmtps (Exim 4.89 #1 (Red Hat Linux)) id 1ecwkM-0005Gr-Ni for linux-arm-kernel@lists.infradead.org; Sat, 20 Jan 2018 17:16:05 +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=b9qffZ2t6CmuL8sfSbzyQOnW5eS+D8h94FzsAHuMMnQ=; b=cKihxe2eaoduMoq9d6c9M5BwM WgyAsKYOezZ/EBlMSGtiX7iCBzFr09NiCpeThqg5AJtVlZKfguBusKgulSoEBoNRZJrVb0bzfAVbp XlJSPRGkyDphXx2ktYmcgKk6rCQ5Mt9c0j/1mP837ob7FSGE7Yuf6QO59j6l7rFB5Y+XAXOEX6j+v LcGd7UKsk99Cyrt8DfrWbkGuMLqsiBKpWuJ2MkMERi32lzKXSMHhoWiGfXdx++UKCSHFmaeNxoIN5 N/TprY6bqFofZzIyzdH6SY1YH2Mf/JASpN5Ne23QhO0h5M8eCh8UUsiQoCNVfurXxAbOY292aK0CY IK7w2M5+A==; Received: from 108-198-5-147.lightspeed.okcbok.sbcglobal.net ([108.198.5.147]:53590 helo=freyr.lechnology.com) by vern.gendns.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES128-SHA256:128) (Exim 4.89_1) (envelope-from ) id 1ecwjb-00059q-9C; Sat, 20 Jan 2018 12:15:15 -0500 From: David Lechner To: linux-clk@vger.kernel.org, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH v6 26/41] ARM: da8xx: add new USB PHY clock init using common clock framework Date: Sat, 20 Jan 2018 11:14:05 -0600 Message-Id: <1516468460-4908-27-git-send-email-david@lechnology.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1516468460-4908-1-git-send-email-david@lechnology.com> References: <1516468460-4908-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-20180120_171602_923341_8AABDF32 X-CRM114-Status: GOOD ( 14.68 ) 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, Bartosz Golaszewski , 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 --- v6 changes: - rename stuff to match changes in "clk: davinci: New driver for TI DA8XX USB PHY clocks" - take advantage of syscon lookup changes in "mfd: syscon: Add syscon_register() function" arch/arm/mach-davinci/usb-da8xx.c | 78 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 77 insertions(+), 1 deletion(-) diff --git a/arch/arm/mach-davinci/usb-da8xx.c b/arch/arm/mach-davinci/usb-da8xx.c index fb31f6e..b960609 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,70 @@ 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 *fck_clk, *clk; + struct clk_hw *parent; + + cfgchip = syscon_regmap_lookup_by_compatible("ti,da830-cfgchip"); + if (IS_ERR(cfgchip)) + return PTR_ERR(cfgchip); + + fck_clk = clk_get_sys("musb-da8xx", NULL); + if (IS_ERR(fck_clk)) + return PTR_ERR(fck_clk); + + clk = da8xx_cfgchip_register_usb0_clk48(cfgchip, fck_clk); + if (IS_ERR(clk)) { + clk_put(fck_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, "usb0_clk48", "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)) + return PTR_ERR(cfgchip); + + clk = da8xx_cfgchip_register_usb1_clk48(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, "usb1_clk48", "da8xx-usb-phy"); +} +#endif