From patchwork Thu Sep 8 20:42:22 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kevin Hilman X-Patchwork-Id: 9322039 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 A29B860752 for ; Thu, 8 Sep 2016 20:44:11 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9215B299DA for ; Thu, 8 Sep 2016 20:44:11 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 861D4299F1; Thu, 8 Sep 2016 20:44:11 +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.1 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED, T_DKIM_INVALID autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 12280299DA for ; Thu, 8 Sep 2016 20:44:11 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.85_2 #1 (Red Hat Linux)) id 1bi69x-0001dZ-NO; Thu, 08 Sep 2016 20:42:57 +0000 Received: from mail-oi0-x232.google.com ([2607:f8b0:4003:c06::232]) by bombadil.infradead.org with esmtps (Exim 4.85_2 #1 (Red Hat Linux)) id 1bi69o-0001Xf-Rw for linux-arm-kernel@lists.infradead.org; Thu, 08 Sep 2016 20:42:50 +0000 Received: by mail-oi0-x232.google.com with SMTP id s131so89284438oie.2 for ; Thu, 08 Sep 2016 13:42:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:organization:references:date:in-reply-to :message-id:user-agent:mime-version; bh=G9Z+OCROSbJmJtosNX26Ls9LxTFMT2zZO9inzaUndug=; b=anaIFb/sAQbnr0MU6U3RbWjH4dHrcjSGjEI+WMpcp8jHAdQO9c2tyOSLzvU8fhlOSE W+nQxrZ8Xd9hmqTLk27WV+4onv+zIBDsvGyHbPU5J8hXG7ZwFEcNe829f4m8QBUj4/Fg TP+MFVYlgElcHj1CSV2CjDQKXkU8+ksGvXj2LKozI/FrK4Ved2FOHvWIO19avrpJ7OOG 0s9me6rh7t3aMnrpzmnevl0U3WE6JNn7wu6I4nCbxW4Xkwd8SpsNMV4VeGnkao3moko5 qAJ01ajkle7Rt5aSFOcK/mKGA9QT62nRJHBlkbCsb78sQSKEU6oz/p18AsOCZK8byHXE +u5w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:organization:references:date :in-reply-to:message-id:user-agent:mime-version; bh=G9Z+OCROSbJmJtosNX26Ls9LxTFMT2zZO9inzaUndug=; b=R03AphKs0iUwJilYjUqiDh2bFodlhRlafMtUWLXPrxo6Zg2yWHv2ShAJG5KPgxWA8Y 6Xcd8zvpTCQLbLN+auysBc5RSXwtsO2Ep5ClMwTTQQMUsdOYe/dSZnp6IAnd4qHP7GLl jktvutfEphszVFtCHSAju9rP0KHbENgBDChygKfnaVVIudSFQtj99GzpF1pRPYiuRzkk bCzy0ldhEtj04TI7ZapKQfe6hn8OD1tLh4g0sGKJ6ygQyTn3476FqT2lhY5bPkP/658M nKxsSvOjJKDIzAEo8NjPKzUf+iWG7hrhJFu8kI8cc89bCDInetWUL3yfoFM0aodEzdqA elgA== X-Gm-Message-State: AE9vXwMWxDjNl2raom9Dk7Q/gyW1X+wkfMwdgh+bXoDNzNU90xrmsuyQYB7tMtaHoykPPqQN X-Received: by 10.202.197.7 with SMTP id v7mr2180429oif.165.1473367345646; Thu, 08 Sep 2016 13:42:25 -0700 (PDT) Received: from localhost (c-98-203-232-209.hsd1.wa.comcast.net. [98.203.232.209]) by smtp.gmail.com with ESMTPSA id k131sm202458ioe.27.2016.09.08.13.42.24 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 08 Sep 2016 13:42:25 -0700 (PDT) From: Kevin Hilman To: Ben Dooks Subject: Re: [PATCH 4/7] phy: meson: add USB2 PHY support for Meson8b and GXBB Organization: BayLibre References: <20160904213152.25837-1-martin.blumenstingl@googlemail.com> <20160904213152.25837-5-martin.blumenstingl@googlemail.com> Date: Thu, 08 Sep 2016 13:42:22 -0700 In-Reply-To: (Ben Dooks's message of "Thu, 8 Sep 2016 21:20:12 +0100") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.5 (darwin) MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160908_134249_002189_5FEE3ADD X-CRM114-Status: GOOD ( 18.84 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: mark.rutland@arm.com, devicetree@vger.kernel.org, linux-clk@vger.kernel.org, Martin Blumenstingl , gregkh@linuxfoundation.org, mturquette@baylibre.com, linux-usb@vger.kernel.org, will.deacon@arm.com, kishon@ti.com, johnyoun@synopsys.com, robh+dt@kernel.org, catalin.marinas@arm.com, carlo@caione.org, linux-amlogic@lists.infradead.org, sboyd@codeaurora.org, linux-arm-kernel@lists.infradead.org, jbrunet@baylibre.com 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 Ben Dooks writes: > On 08/09/16 20:52, Martin Blumenstingl wrote: >> On Thu, Sep 8, 2016 at 9:35 PM, Kevin Hilman wrote: >>>> + phy = devm_phy_create(&pdev->dev, NULL, &phy_meson_usb2_ops); >>>> + if (IS_ERR(phy)) { >>>> + dev_err(&pdev->dev, "failed to create PHY\n"); >>>> + return PTR_ERR(phy); >>>> + } >>>> + >>>> + if (usb_reset_refcnt++ == 0) { >>>> + ret = device_reset(&pdev->dev); >>>> + if (ret) { >>>> + dev_err(&phy->dev, "Failed to reset USB PHY\n"); >>>> + return ret; >>>> + } >>>> + } >>> >>> The ref count + reset here looks like something that could/should be >>> handled in a runtime PM callback. >> Unfortunately that doesn't work (as Jerome found out) because both >> PHYs are sharing the same reset line. >> So if the second PHY would call device_reset then it would also reset >> the first PHY! >> >> There's a comment above the declaration of usb_reset_refcnt which >> tries to explain this: >> "The PHYs are sharing a common reset line -> we are only allowed to >> reset once for all PHYs." >> Maybe I should move this comment to the "if (usb_reset_refcnt++ == 0) >> {" line to make it easier to see? >> > > pm-runtime has refcounting in it. When one of the nodes turns on, > the pm-runtime will call your driver to say there is a user when > this first use turns up. > > If all the sub-phys turn off and drop their refcount then the driver > is called to say there are no more users and you can go to sleep. After a chat w/Martin on IRC, It turns out runtime PM wont help here. The reason is because there are physically two PHY devices[1]. Those 2 devices will be treated independely by runtime PM, and have separate use-counting, which means doing what I proposed would cause a reset to happen when either device was probed. So, I think it's OK as it is. Kevin [1] from the DT patch: linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel diff --git a/arch/arm64/boot/dts/amlogic/meson-gxbb.dtsi b/arch/arm64/boot/dts/amlogic/meson-gxbb.dtsi index 2e8a3d9..02dfc54 100644 --- a/arch/arm64/boot/dts/amlogic/meson-gxbb.dtsi +++ b/arch/arm64/boot/dts/amlogic/meson-gxbb.dtsi @@ -151,6 +151,34 @@ #size-cells = <2>; ranges; + usb-phys@c0000000 { + compatible = "simple-bus"; + reg = <0x0 0xc0000000 0x0 0x40>; + #address-cells = <2>; + #size-cells = <2>; + ranges = <0x0 0x0 0x0 0xc0000000 0x0 0x40>; + + usb0_phy: usb_phy@0 { + compatible = "amlogic,meson-gxbb-usb2-phy"; + #phy-cells = <0>; + reg = <0x0 0x0 0x0 0x20>; + resets = <&reset 34>; + clocks = <&clkc CLKID_USB &clkc CLKID_USB0>; + clock-names = "usb_general", "usb"; + status = "disabled"; + }; + + usb1_phy: usb_phy@20 { + compatible = "amlogic,meson-gxbb-usb2-phy"; + #phy-cells = <0>; + reg = <0x0 0x20 0x0 0x20>; + resets = <&reset 34>; + clocks = <&clkc CLKID_USB &clkc CLKID_USB1>; + clock-names = "usb_general", "usb"; + status = "disabled"; + }; + }; + _______________________________________________ linux-arm-kernel mailing list