From patchwork Thu Jun 9 14:51:45 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans de Goede X-Patchwork-Id: 9167239 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 B47816048F for ; Thu, 9 Jun 2016 14:53:48 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A62ED2766D for ; Thu, 9 Jun 2016 14:53:48 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 99B882834F; Thu, 9 Jun 2016 14:53:48 +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, RCVD_IN_DNSWL_MED autolearn=ham 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 091752766D for ; Thu, 9 Jun 2016 14:53:48 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1bB1Jf-000332-Fu; Thu, 09 Jun 2016 14:52:15 +0000 Received: from mx1.redhat.com ([209.132.183.28]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1bB1Jc-0002w9-Op for linux-arm-kernel@lists.infradead.org; Thu, 09 Jun 2016 14:52:13 +0000 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id C4B3DC003574; Thu, 9 Jun 2016 14:51:51 +0000 (UTC) Received: from shalem.localdomain (vpn1-5-128.ams2.redhat.com [10.36.5.128]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u59Epjkk015751 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Thu, 9 Jun 2016 10:51:48 -0400 Subject: Re: [PATCH v3 1/4] USB: Fix of_usb_get_dr_mode_by_phy with a shared phy block To: Bin Liu , Greg Kroah-Hartman , Kishon Vijay Abraham I , Maxime Ripard , Chen-Yu Tsai , linux-usb@vger.kernel.org, linux-arm-kernel@lists.infradead.org, devicetree References: <1465138776-6003-1-git-send-email-hdegoede@redhat.com> <20160609143004.GA2167@uda0271908> From: Hans de Goede Message-ID: <9a05c16a-e8a2-02b7-c093-1131e27bcdd4@redhat.com> Date: Thu, 9 Jun 2016 16:51:45 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.1.0 MIME-Version: 1.0 In-Reply-To: <20160609143004.GA2167@uda0271908> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Thu, 09 Jun 2016 14:51:52 +0000 (UTC) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160609_075212_892144_A9998D37 X-CRM114-Status: GOOD ( 20.43 ) 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: , 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 Hi, On 09-06-16 16:30, Bin Liu wrote: > Hi, > > On Sun, Jun 05, 2016 at 04:59:33PM +0200, Hans de Goede wrote: >> Some SoCs have a single phy-hw-block with multiple phys, this is >> modelled by a single phy dts node, so we end up with multiple >> controller nodes with a phys property pointing to the phy-node >> of the otg-phy. >> >> Only one of these controllers typically is an otg controller, yet we >> were checking the first controller who uses a phy from the block and >> then end up looking for a dr_mode property in e.g. the ehci controller. >> >> This commit fixes this by adding an arg0 parameter to >> of_usb_get_dr_mode_by_phy and make of_usb_get_dr_mode_by_phy >> check that this matches the phandle args[0] value when looking for >> the otg controller. >> >> Signed-off-by: Hans de Goede >> --- >> Changes in v2: >> -Add a args0 parameter instead of looking for nodes with a dr_mode property >> Changes in v3: >> -No changes >> --- >> drivers/usb/common/common.c | 31 ++++++++++++++++++------------- >> drivers/usb/phy/phy-am335x.c | 2 +- >> include/linux/usb/of.h | 4 ++-- >> 3 files changed, 21 insertions(+), 16 deletions(-) > > This breaks am335x. > > [ 17.433166] /ocp/usb@47400000/usb@47401000: could not get #phy-cells > for /ocp/usb@47400000/usb-phy@47401300 > [ 17.443627] /ocp/usb@47400000/usb@47401800: could not get #phy-cells > for /ocp/usb@47400000/usb-phy@47401b00 > [ 17.454005] am335x-phy-driver 47401300.usb-phy: dr_mode 0 > [ 17.460518] 47401300.usb-phy supply vcc not found, using dummy > regulator > [ 17.469685] /ocp/usb@47400000/usb@47401000: could not get #phy-cells > for /ocp/usb@47400000/usb-phy@47401300 > [ 17.479998] /ocp/usb@47400000/usb@47401800: could not get #phy-cells > for /ocp/usb@47400000/usb-phy@47401b00 > [ 17.490342] am335x-phy-driver 47401b00.usb-phy: dr_mode 0 That is weird, quoting: drivers/phy/phy-core.c: _of_phy_get(): ret = of_parse_phandle_with_args(np, "phys", "#phy-cells", index, &args); if (ret) return ERR_PTR(-ENODEV); So if #phy-cells is not defined, then the phy core should not be able to work with the dts files in question at all. All my patch does is make the way of_usb_get_dr_mode_by_phy parses phy-handles be identical to how phy-core.c does it. I see that the usb0_phy node in arch/arm/boot/dts/am33xx.dtsi indeed lacks a "#phy-cells = <0>;" line. Quoting: Documentation/devicetree/bindings/phy/phy-bindings.txt PHY device node Regards, Hans =============== Required Properties: #phy-cells: Number of cells in a PHY specifier; The meaning of all those cells is defined by the binding for the phy node. The PHY provider can use the values in cells to find the appropriate PHY. So not having #phy-cells defined for a phy-node clearly is a bug. A patch like the following should fix this: diff --git a/arch/arm/boot/dts/am33xx.dtsi b/arch/arm/boot/dts/am33xx.dtsi index 52be48b..c4ff788d 100644 --- a/arch/arm/boot/dts/am33xx.dtsi +++ b/arch/arm/boot/dts/am33xx.dtsi @@ -557,6 +557,7 @@ }; usb0_phy: usb-phy@47401300 { + #phy-cells = <0>; compatible = "ti,am335x-usb-phy"; reg = <0x47401300 0x100>; reg-names = "phy";