Received: by 10.223.176.46 with SMTP id f43csp1031088wra; Sat, 20 Jan 2018 09:20:37 -0800 (PST) X-Google-Smtp-Source: AH8x2276vciUSZ7v667Vqin5bysuldjDWbSlhvanHkfzidft2plcvV6Kpi1x4J1qqWNla8OaK0u/ X-Received: by 10.98.215.70 with SMTP id v6mr3019166pfl.83.1516468836922; Sat, 20 Jan 2018 09:20:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1516468836; cv=none; d=google.com; s=arc-20160816; b=ZAi4XCNLWExp7FCo37OuEuEHm30FyZmBHrY+kM4ci6Gp0Vxv4T51FjStKbVSbYE4Ox D0jyFv08b0mThOg4oqm1Qig/X1Z6imNBTb7Kyv1hq69ly/pqf4cq1sS7wNt8BVF4mUXY ZViUjUU2g6JvY6L4WwYs+/hOSijV221QSLTlNwfUbJY3cYVwLJiazz/GcOu2R8Gtd4hA kVtd/Zz/ypMdMdPRxl510IeqTRbKZ/t6odP6RL+yveRcojtbhcNa9KyxtckCW2exaqaA rc73Vy/djaak4w9Dbp+Ox8uoa45HmyvyHYBNdrT6PKDX2ogilTI/TEg+L2cxKDhbaTCu 75Tw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=b9qffZ2t6CmuL8sfSbzyQOnW5eS+D8h94FzsAHuMMnQ=; b=HThFoGFXlAtQHZMUkmd50gVrcAhWXIJdepHIvm6L2k40YHy/yO5p2PoXf00kbrnAhe wKvPj39t7XHj/5bWuZnkyP+JuzOFutVQocCZULIx1BohWtKY0kl4hsw+oqz26eNjkKPb FDkBpHuR6ARvQmxY75n8GmD46RTOlBKtxeK7KFLfGGLCtpt1PsOB9/ZP9YuJsGOYvVY4 XifvwsMF+exX0YS5jkQoEuslVBfd5lP5JogV/Wq4OxJySTcjuHZilWOJgAFJ4HowsCY9 19gIP7ycb5Nb9J2iiC88wdTKdoxGmL76a+HS6ONcZk8C4OjZhxYN09qzmzxClbsdyqCx zDkw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@lechnology.com header.s=default header.b=cKihxe2e; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c22si10468146pgn.460.2018.01.20.09.20.23; Sat, 20 Jan 2018 09:20:36 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=fail header.i=@lechnology.com header.s=default header.b=cKihxe2e; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756719AbeATRS5 (ORCPT + 99 others); Sat, 20 Jan 2018 12:18:57 -0500 Received: from vern.gendns.com ([206.190.152.46]:42826 "EHLO vern.gendns.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756651AbeATRPr (ORCPT ); Sat, 20 Jan 2018 12:15:47 -0500 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 Cc: Michael Turquette , Stephen Boyd , Rob Herring , Mark Rutland , Sekhar Nori , Kevin Hilman , Bartosz Golaszewski , Adam Ford , linux-kernel@vger.kernel.org, David Lechner 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 - vger.kernel.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: Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 -- 2.7.4