From patchwork Fri Aug 31 10:32:59 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yoshihiro Shimoda X-Patchwork-Id: 10583573 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 BD3D617DE for ; Fri, 31 Aug 2018 10:34:52 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9B47F2B780 for ; Fri, 31 Aug 2018 10:34:52 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8ED192B795; Fri, 31 Aug 2018 10:34:52 +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 1653F2B780 for ; Fri, 31 Aug 2018 10:34:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727879AbeHaOll (ORCPT ); Fri, 31 Aug 2018 10:41:41 -0400 Received: from relmlor3.renesas.com ([210.160.252.173]:58991 "EHLO relmlie2.idc.renesas.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727360AbeHaOlk (ORCPT ); Fri, 31 Aug 2018 10:41:40 -0400 Received: from unknown (HELO relmlir4.idc.renesas.com) ([10.200.68.154]) by relmlie2.idc.renesas.com with ESMTP; 31 Aug 2018 19:34:45 +0900 Received: from relmlii1.idc.renesas.com (relmlii1.idc.renesas.com [10.200.68.65]) by relmlir4.idc.renesas.com (Postfix) with ESMTP id 14CD87FC50; Fri, 31 Aug 2018 19:34:45 +0900 (JST) X-IronPort-AV: E=Sophos;i="5.53,311,1531753200"; d="scan'208";a="289630543" Received: from mail-os2jpn01lp0152.outbound.protection.outlook.com (HELO JPN01-OS2-obe.outbound.protection.outlook.com) ([23.103.139.152]) by relmlii1.idc.renesas.com with ESMTP/TLS/AES256-SHA256; 31 Aug 2018 19:34:44 +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=Eqj+AukKYkt3v39Vq760dXrBOjn1KdV9gFF16cezPLs=; b=JCByXA4UDrnKvjfPcR2Ly6p+abevt9ZZBT8AuYZt46xrQ6QLVpaHktl3+2jYodU1WlIU/EUtaIqhSulINETojhkPKgX57TF82Wg0TRP7aKtJPZNyZPe96ZPEFr6hrl+h/ufsvsE1fw+D9Finxfp/iByBkOUfwN1VRegM9oC2NUg= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=<>; Received: from localhost.localdomain (211.11.155.144) by OSAPR01MB2289.jpnprd01.prod.outlook.com (2603:1096:603:1c::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1101.13; Fri, 31 Aug 2018 10:34:41 +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 v2 3/3] usb: renesas_usbhs: Add multiple clocks management Date: Fri, 31 Aug 2018 19:32:59 +0900 Message-Id: <1535711579-15169-4-git-send-email-yoshihiro.shimoda.uh@renesas.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1535711579-15169-1-git-send-email-yoshihiro.shimoda.uh@renesas.com> References: <1535711579-15169-1-git-send-email-yoshihiro.shimoda.uh@renesas.com> MIME-Version: 1.0 X-Originating-IP: [211.11.155.144] X-ClientProxiedBy: TYAPR01CA0073.jpnprd01.prod.outlook.com (2603:1096:404:2c::13) To OSAPR01MB2289.jpnprd01.prod.outlook.com (2603:1096:603:1c::12) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: add43085-7922-4e14-4fe1-08d60f2d5c42 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:OSAPR01MB2289; X-Microsoft-Exchange-Diagnostics: 1;OSAPR01MB2289;3:zyUdmhwviKrwa1OccKIMkt4FNZhTxpr4VZsyYIWARuOEcGWySXDhDn31nZxjou6avShNmOw/5GvPt4mT3WKXaYItl9m9zfW9Sr/HjYW1qNyQQsU5urqI7Kg4aw2z4rwGRtyYiPtF18xjf0hoF8SryDbRTVED68iN09hydEbPvXbppi5VgZZ/ndx+GqYZnvvfgsFI+Do6hk2qnhlbyL4IlnERxahbMAISd62IxOOiFdVDCCf8hgVhFhOxFfA2HNVX;25:s5Q4XZdl74dp0XicwIQYWGdREgTmvGBA9VL57zYvGQMBhQfdEwtJUUgFvKcYiFbEihM7tlvnoYTntFnOW69jzjTvrek2SAf//LTv1+k5RmGXt4420bR7f6djNuZbvGYOoh9IIkXLkSYjVb7C9maTGCEv67oKahxNVT1Zkq0H160oCJQKEs3vl9bADdSlqr5P9jwdP7FoIH11sqK36wQ+CTm60+DsMlCjNa7c7BTTO5mJu0/i7STNbTXyf2cKMcHVQevntx3IjlfgR3aCX2umTnGc5cMtAfcAH+reUjWvd8CCzVV0aZdEdQ7q93VW8qtLeb9wrnVkH2Lli68Jg/Gtvg==;31:oTAx8deqc662a4oWWmMDR6Jys7GF1lkwGGBfeoO7p9zRjGFS+wVGUzmE1wrRP44jApjuqEeNg8yM5tDr3V2IfXiQpBI09G+KJkjwDpF4XzNroYmQtzfCOfTlHE+S+1MiDe9xqBHP54/ALH6lzs2wko0kx3Caz9ds0xPxrRTV2+0DeijBZ0cZQp0M08NzDFQre+bVp1yPL+qql6PUjw8cD7q7qCRYyVNYW656wrU9r9k= X-MS-TrafficTypeDiagnostic: OSAPR01MB2289: X-Microsoft-Exchange-Diagnostics: 1;OSAPR01MB2289;20:2BNccCdlvTuJMSc4cL5CIjT3WZTqB3kP0leRpFA5TFZEPa5Xvp5E1h5PAlBwkpuiasRMLfx47HHdC3Pq5IhKBPUCoPGZlq6C2Y7SE4EHC4DxjaaDiTeHl9lvT4G02QeigB9LCog1afERpztXfn4+vI2zUUKD5IWDCWKc4L2pXRGes6YDGm0kkmxT5dF36dmiXKODJNqTcK0OlcIR0wV6lhHPymeieNmfCmhT0osckiRKVSmHGMwwYigOpMoFcloO44fz30bUKRH9Tjl1QF4Q1ykXxXIzr1FcuUqt/tJhNCm+8Ucy7g0GsAi5fl4Jva7h+Cu+rP+/15eZkMvcZuOGbEfZguq4j3efB1rkff8yf/EqMNiDYruAUFZHYzGF/kC4sCKTGHXkUag5fGLzfy+gQfFl/z1N/NSKAzVTIV3MxwSU0v7SfFWXwuq8Cdoo55PWvpvt8hY/81r9tb9rNOXX5nZF8b7E60B0ZqjJhVpXLYoeRjAr0/dLPgCfX9LV//Q1;4:XrjO504FKTAj5rmPBdTq/LzLwMIcVwlhzbzXDJVzznjYvV+P8awLV1Z12yuib2ChiBBiiWjrrPuA41mhOlUsIbXFe4ye+Cgl2zWeY6qVgHUyP7pHtQYqnPmZniefzz997yWDspYiSkwAqMaObil1clR6GAI0hdvsQp3+sgFAWb9Y+ssjufah0MjqHBetGmDvXA9dO8wX+upYU+83yxqia0U4UsvxIPXeCJOVBcoz6IL1ZmYANBBxXj0u4UWGD6w/je4cLbV/vfRHQHKP/rH6uQ== 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)(5005006)(8121501046)(823301075)(10201501046)(3002001)(93006095)(3231311)(944501410)(52105095)(6055026)(149027)(150027)(6041310)(20161123558120)(20161123560045)(20161123562045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061750153)(20161123564045)(201708071742011)(7699016);SRVR:OSAPR01MB2289;BCL:0;PCL:0;RULEID:;SRVR:OSAPR01MB2289; X-Forefront-PRVS: 07817FCC2D X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10019020)(6069001)(396003)(39860400002)(366004)(346002)(136003)(376002)(189003)(199004)(446003)(6666003)(26005)(3846002)(6116002)(50466002)(106356001)(5660300001)(16586007)(105586002)(78352004)(6506007)(316002)(386003)(2906002)(11346002)(25786009)(498600001)(956004)(2616005)(48376002)(76176011)(7736002)(476003)(50226002)(51416003)(52116002)(47776003)(66066001)(6486002)(8936002)(305945005)(81166006)(81156014)(53936002)(486006)(16526019)(36756003)(4326008)(8676002)(42882007)(107886003)(6512007)(68736007)(97736004)(69590400005)(3720700003);DIR:OUT;SFP:1102;SCL:1;SRVR:OSAPR01MB2289;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) X-Microsoft-Exchange-Diagnostics: 1;OSAPR01MB2289;23:I6F91SL3X/z8LwJRzRNA/1F0IYH4HVcgjdj5FJQwBJ22Q0xkqlqkv5uAEzyS8slZXC6sJpWuBBNtt0iIaxj7xfvox2u0UHgsOh3E2ldekuNRVRCv+lVDXUdB5IJ44gMHdNgaHlq8I8Lec7HMEgS63MMC0w9Auk2XfR3WNt8Rr2CsHoh97AYYDJS7QcqAZyL56onJzSSsDgLKsic0jJ0PGNEUtZJ3WwNCg5kyxRULPk8lpGUpXb6F28ppPMxZb0slyHMAItzenyGmOohGWrp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ms643dHFm2C174/a8riea2upZgPVBovKOCxoryxBEExWG7ZrpeybszYYCkS7+mp8kY9wvyaWjUwE7Q9whlCvDMEGEZo0FPfrf0yIye5xANqT059BZtaTPP2ZU65qdOlgOlPIe4MoIimhkKqn6ig5xxkqjz3n5HO2ZW7VzrnuWmCv3GhKb SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1;OSAPR01MB2289;20:0WnbmwiQF4QrAHESUXBISepuIFvIscEcdtm3cxaCNFz6PtaOcVB0hFP52sb6aFLZeJQIp1RlqsI3aIT0/OCKXkjEgfquQxO4JMMgYQ8xnHzaVZ3lr6TbY0kVp9rvvnPj1ZZcWTXqqqQO1NL/ZTojL+L7woaSgJzcEVTe6AsE5wM= X-OriginatorOrg: renesas.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 31 Aug 2018 10:34:41.3579 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: add43085-7922-4e14-4fe1-08d60f2d5c42 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 53d82571-da19-47e4-9cb4-625a166a4a2a X-MS-Exchange-Transport-CrossTenantHeadersStamped: OSAPR01MB2289 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 | 35 +++++++++++++++++++++++++++++++++++ drivers/usb/renesas_usbhs/common.h | 3 +++ 2 files changed, 38 insertions(+) diff --git a/drivers/usb/renesas_usbhs/common.c b/drivers/usb/renesas_usbhs/common.c index 1d355d5..39ed714 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 @@ -336,11 +337,26 @@ static void usbhsc_power_ctrl(struct usbhs_priv *priv, int enable) { struct platform_device *pdev = usbhs_priv_to_pdev(priv); struct device *dev = usbhs_priv_to_dev(priv); + int ret; if (enable) { /* enable PM */ pm_runtime_get_sync(dev); + /* enable clks if exist */ + if (priv->num_clks) { + ret = clk_bulk_prepare(priv->num_clks, priv->clks); + if (!ret) { + ret = clk_bulk_enable(priv->num_clks, + priv->clks); + if (ret) { + clk_bulk_unprepare(priv->num_clks, + priv->clks); + return; + } + } + } + /* enable platform power */ usbhs_platform_call(priv, power_ctrl, pdev, priv->base, enable); @@ -353,6 +369,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 +640,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 +694,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 +753,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; }; /*