From patchwork Thu Sep 6 05:50:14 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yoshihiro Shimoda X-Patchwork-Id: 10589899 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id AF0F26CB for ; Thu, 6 Sep 2018 05:52:04 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A01B12A556 for ; Thu, 6 Sep 2018 05:52:04 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 945772A55B; Thu, 6 Sep 2018 05:52:04 +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=-7.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 321982A582 for ; Thu, 6 Sep 2018 05:52:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726354AbeIFKZs (ORCPT ); Thu, 6 Sep 2018 06:25:48 -0400 Received: from relmlor4.renesas.com ([210.160.252.174]:49404 "EHLO relmlie3.idc.renesas.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726031AbeIFKZr (ORCPT ); Thu, 6 Sep 2018 06:25:47 -0400 Received: from unknown (HELO relmlir1.idc.renesas.com) ([10.200.68.151]) by relmlie3.idc.renesas.com with ESMTP; 06 Sep 2018 14:51:56 +0900 Received: from relmlii1.idc.renesas.com (relmlii1.idc.renesas.com [10.200.68.65]) by relmlir1.idc.renesas.com (Postfix) with ESMTP id B12D777F9D; Thu, 6 Sep 2018 14:51:56 +0900 (JST) X-IronPort-AV: E=Sophos;i="5.53,334,1531753200"; d="scan'208";a="290148651" Received: from mail-ty1jpn01lp0183.outbound.protection.outlook.com (HELO JPN01-TY1-obe.outbound.protection.outlook.com) ([23.103.139.183]) by relmlii1.idc.renesas.com with ESMTP/TLS/AES256-SHA256; 06 Sep 2018 14:51:56 +0900 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=renesasgroup.onmicrosoft.com; s=selector1-renesas-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=XRfmzUF+zLjFJKMOaKoCmpNporJRSQ4m+FQWL6bT3pw=; b=h3i5hGHW+syBZsi5hL+XEsAh+62Beo8//0QuFkzGjLjzioSXCLyIumOhmCqfu0NXkM3ez6fR9EwRW/krU0yHFtnOvlEIzW+V5I4kIMk0jakFkQR+dknoph1y5Ezy+RKhIldTtCzNwwmBr+f8jM6ftB96JCiX4ZqjzJ3+JTFSj2A= Received: from localhost.localdomain (211.11.155.144) by TYAPR01MB2304.jpnprd01.prod.outlook.com (2603:1096:404:8::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1101.16; Thu, 6 Sep 2018 05:51:54 +0000 From: Yoshihiro Shimoda To: balbi@kernel.org, robh+dt@kernel.org, mark.rutland@arm.com Cc: gregkh@linuxfoundation.org, linux-usb@vger.kernel.org, linux-renesas-soc@vger.kernel.org, devicetree@vger.kernel.org, Yoshihiro Shimoda Subject: [PATCH v3 3/3] usb: renesas_usbhs: Add multiple clocks management Date: Thu, 6 Sep 2018 14:50:14 +0900 Message-Id: <1536213014-1325-4-git-send-email-yoshihiro.shimoda.uh@renesas.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1536213014-1325-1-git-send-email-yoshihiro.shimoda.uh@renesas.com> References: <1536213014-1325-1-git-send-email-yoshihiro.shimoda.uh@renesas.com> MIME-Version: 1.0 X-Originating-IP: [211.11.155.144] X-ClientProxiedBy: OSAPR01CA0158.jpnprd01.prod.outlook.com (2603:1096:604:d::26) To TYAPR01MB2304.jpnprd01.prod.outlook.com (2603:1096:404:8::18) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: fc0b7298-7bca-4cda-c9b0-08d613bcd996 X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: BCL:0;PCL:0;RULEID:(7020095)(4652040)(8989137)(4534165)(4627221)(201703031133081)(8559020)(8990107)(5600074)(711020)(4618075)(2017052603328)(7153060)(7193020);SRVR:TYAPR01MB2304; X-Microsoft-Exchange-Diagnostics: 1;TYAPR01MB2304;3:LsLK71rFvK48lou3qjk2gB8/lzWdvJ4BTw/fbCgVcER7qZ/s/E5NOgTRMc076ow7UL5jv0svE3dctEpSygSDf6golVSkMdRtmClAYKjLGP+DDI8REdzk19foUKlPNNDfx4zOMjvs/SvfO1weaMkBUv9yr6VbFaY/eLQIROKtE7YnPv1Xyb+hVkmIcr0rgVPCQRKuBNUrs6rXIkbOHUIS3hhO0SWoN3HQtDI00dQZw11hQVQ2MiUSSPoJUc5SjtHY;25:t3pZapxnJXeyzK+kvsgNL781ckiG14UTCdriFm6hWSv0/wUZ9K3dxBMdWxaAzSEkvTA7Fr7zmYfXR+vYieGx212/P2nc6YR1tMuTs63Tz7h0+CDvQNQipKv/yaYRF2dxrMoLfpGkVx27mHckHbZ+3qLXcI9JpcoY1ttbFqmAnYeYLXKfWeRrXr5/Gl78C91p8TPr+BRvLBqPO1cUCa+l8G2acnJy3k0s+qndT/Ni8Ok4VUHT5trHmpExuks/yK//xotaKAbuxiPqEUUP/xJbObXMEgk7mYGyrpUCFDpP/bVcd1p52sXH6yo7eqEb0EcKBG6RFeZBqxM5pukkzOVDsQ==;31:YCiPaavC6S3cni8w6wEnRH0lw+RYj6rhS4fBa4bMJxjF65sVh5dsQYFC8RME6/q44PGzI8NwPfnn/3ipsDegzAHaCJcEBJT0Gcvsx6e6JHg+nKYptGDspZtaaS3yb74k6z8BxIc7u943zTLwwnJUXtr/BewI57mcXV7igMDftpc68WW195j63EDh8Cs62NwNHyEcn+JZfq8yS4ubRMthe9sON8Iyu+2sfJUkRHHaglY= X-MS-TrafficTypeDiagnostic: TYAPR01MB2304: X-Microsoft-Exchange-Diagnostics: 1;TYAPR01MB2304;20:GqldncdHQqckcSLv8LniT7MrpT54f3pdDPAUebNODVvkAItY9EgEPxfQ012quSmjV3w32F5fBTGWI0BHdGcqWyiI74csCDwFtMP/CrZMBTlu+scDbcpswzuX03jOx9WAK3x4Q5jNlsqWUkWBJxc5xNUi+ggKp3l6B96CYbWweChtYVFxAm1YBB99INaahRmlkMq6xA20QS6ks33KtdK8wr/CmDQpTxKAY8Qy7Sq0yb0B6gAahl08QM1+TymIGeVbRPv6SNwwoXQOn5dX219VUv0ETpBq5kp5185kgB9UdupFinB5D37uYDRCD9eH4edWtHK5pXRenoguxLld3EOHM8Gg3wLG9pGlDpNcIfTWZlFRL1CIUkVJy7/0hpdgmbnwDWiWPf6I8Y8n800PXMz+8YQjprdNLoFdpYQX9+ynrCqbqDKPvRWND1X4Vp3zwmul5D8Y6G+6GxmKklhs3jNVI9EyqxBZzHshKja/7xhYM113dQcyned5UwN9Gz0JERG0;4:raFVCJaYI1GLEv1T2yI3Sw5pLW0HDM11IQN73bKGV4eO06K9MiIryQoG+eH/EWgxXhCPNCdse2y0Jzbvoqdyiy26tqeDW+wSWu+jW8bm8UR/AWUIfBaSILQEHu3Zprw+RCuF98ZCELxFAJoQCM0qg/sCMLzREek8whbA4G6FGkiLFD12lVPfySsx7/cWAMKewQFj5Q9tiddpjBGQTs5OfYGSRo6Z6JkiKp0F8d59M44SR0XVrBcBQen+pcIF0fYFsL58aHGPE5k9PWq/twa7UA== X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-MS-Exchange-SenderADCheck: 1 X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(8211001083)(6040522)(2401047)(8121501046)(5005006)(823301075)(10201501046)(3002001)(3231344)(944501410)(52105095)(93006095)(6055026)(149027)(150027)(6041310)(20161123558120)(20161123562045)(20161123564045)(20161123560045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061750153)(201708071742011)(7699016);SRVR:TYAPR01MB2304;BCL:0;PCL:0;RULEID:;SRVR:TYAPR01MB2304; X-Forefront-PRVS: 0787459938 X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10019020)(6069001)(366004)(346002)(136003)(39860400002)(376002)(396003)(189003)(199004)(76176011)(52116002)(2616005)(2906002)(106356001)(16526019)(476003)(105586002)(6506007)(386003)(498600001)(6666003)(6346003)(51416003)(50466002)(5660300001)(3846002)(6116002)(68736007)(26005)(316002)(16586007)(25786009)(78352004)(66066001)(4326008)(107886003)(7736002)(305945005)(81166006)(48376002)(36756003)(42882007)(50226002)(47776003)(8936002)(53936002)(11346002)(8676002)(6486002)(6512007)(446003)(69590400006)(486006)(97736004)(956004)(81156014)(3720700003);DIR:OUT;SFP:1102;SCL:1;SRVR:TYAPR01MB2304;H:localhost.localdomain;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;MX:0;A:0; Received-SPF: None (protection.outlook.com: localhost.localdomain does not designate permitted sender hosts) Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=<>; X-Microsoft-Exchange-Diagnostics: 1;TYAPR01MB2304;23:h1K7kptQ4gQeW7kwGA1aONDlH42t2bU+QkY+q+JfN4bbTuLAMK/dQUl5HdwpMfs5AhHYyBr70O9IbGIe3frq//zHYtAQ1/ZA02rwlX5mwyguoSkP57H1RQDCgwMlSqELmb/oBej5KzO0N/R0v8fN+yM+ad3+6IerHxd85L43ZDnL7GqwPzIi3K9itDIPyOzqsMVPvkMyCrpFjJn2jSj2n7CD0ZdlAaHqHSK9LRcKZMSPyVXEdxZOXcByblzWtTSy+hztT9rQjeA5T2zMiKQ4ExZ2OWMWa/2Bn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LuT9gaWmWGyfShRIom8W6rPW9hH6d227MxFGJVDRPju+A8P2CRQqbtFfGiKFPvtninjMXZNGgHzAl1bYrYzNB6jvg/tU2CDAwqCsNq4ev9kyKW62Jk0VndNQ6RH8+VHpTyHAEWEs2/lJ/PypLSvSOOpE/nmJ9ditEr SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1;TYAPR01MB2304;20:HUScuOIzAl4AzG5qwIijU/Pou11gGusM0lmyJ0wtSLmtR0SWq/mAIj0WhCDdor9aBLDqgWD+ejA+inB7FY1lzqyEGYtkGhgvgB6J/qY8SHCDoupycl148SNXgKU5LNFUgXlP85fjhk4XqGLvVUSnZ8EHxvJj+Klp9if+jQq3amU= X-OriginatorOrg: renesas.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Sep 2018 05:51:54.2633 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: fc0b7298-7bca-4cda-c9b0-08d613bcd996 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 53d82571-da19-47e4-9cb4-625a166a4a2a X-MS-Exchange-Transport-CrossTenantHeadersStamped: TYAPR01MB2304 Sender: linux-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP R-Car Gen3 needs to enable clocks of both host and peripheral. Since [eo]hci-platform disables the reset(s) when the drivers are removed, renesas_usbhs driver doesn't work correctly. To fix this issue, this patch adds multiple clocks management on this renesas_usbhs driver. Signed-off-by: Yoshihiro Shimoda --- drivers/usb/renesas_usbhs/common.c | 25 +++++++++++++++++++++++++ drivers/usb/renesas_usbhs/common.h | 3 +++ 2 files changed, 28 insertions(+) diff --git a/drivers/usb/renesas_usbhs/common.c b/drivers/usb/renesas_usbhs/common.c index 1d355d5..d1e37cc 100644 --- a/drivers/usb/renesas_usbhs/common.c +++ b/drivers/usb/renesas_usbhs/common.c @@ -5,6 +5,7 @@ * Copyright (C) 2011 Renesas Solutions Corp. * Kuninori Morimoto */ +#include #include #include #include @@ -341,6 +342,11 @@ static void usbhsc_power_ctrl(struct usbhs_priv *priv, int enable) /* enable PM */ pm_runtime_get_sync(dev); + /* enable clks if exist */ + if (priv->num_clks && + clk_bulk_prepare_enable(priv->num_clks, priv->clks)) + return; + /* enable platform power */ usbhs_platform_call(priv, power_ctrl, pdev, priv->base, enable); @@ -353,6 +359,10 @@ static void usbhsc_power_ctrl(struct usbhs_priv *priv, int enable) /* disable platform power */ usbhs_platform_call(priv, power_ctrl, pdev, priv->base, enable); + /* disable clks if exist */ + if (priv->num_clks) + clk_bulk_disable_unprepare(priv->num_clks, priv->clks); + /* disable PM */ pm_runtime_put_sync(dev); } @@ -620,6 +630,13 @@ static int usbhs_probe(struct platform_device *pdev) break; } + if (priv->dparam.type == USBHS_TYPE_RCAR_GEN3 || + priv->dparam.type == USBHS_TYPE_RCAR_GEN3_WITH_PLL) { + priv->clks[0].id = "hsusb"; + priv->clks[1].id = "ehci/ohci"; + priv->num_clks = ARRAY_SIZE(priv->clks); + }; + /* set driver callback functions for platform */ dfunc = &info->driver_callback; dfunc->notify_hotplug = usbhsc_drvcllbck_notify_hotplug; @@ -667,6 +684,12 @@ static int usbhs_probe(struct platform_device *pdev) if (ret) goto probe_fail_rst; + if (priv->num_clks) { + ret = clk_bulk_get(&pdev->dev, priv->num_clks, priv->clks); + if (ret == -EPROBE_DEFER) + goto probe_fail_clks; + } + /* * deviece reset here because * USB device might be used in boot loader. @@ -720,6 +743,8 @@ static int usbhs_probe(struct platform_device *pdev) return ret; probe_end_mod_exit: + clk_bulk_put(priv->num_clks, priv->clks); +probe_fail_clks: reset_control_assert(priv->rsts); probe_fail_rst: usbhs_mod_remove(priv); diff --git a/drivers/usb/renesas_usbhs/common.h b/drivers/usb/renesas_usbhs/common.h index bce7d35..6e7c5f2 100644 --- a/drivers/usb/renesas_usbhs/common.h +++ b/drivers/usb/renesas_usbhs/common.h @@ -8,6 +8,7 @@ #ifndef RENESAS_USB_DRIVER_H #define RENESAS_USB_DRIVER_H +#include #include #include #include @@ -279,6 +280,8 @@ struct usbhs_priv { struct phy *phy; struct reset_control *rsts; + struct clk_bulk_data clks[2]; + int num_clks; }; /*