From patchwork Tue Aug 5 07:51:09 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vivek Gautam X-Patchwork-Id: 4676271 Return-Path: X-Original-To: patchwork-linux-samsung-soc@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 6F4819F373 for ; Tue, 5 Aug 2014 07:51:28 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id B028C20127 for ; Tue, 5 Aug 2014 07:51:24 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id DCF7F20125 for ; Tue, 5 Aug 2014 07:51:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756621AbaHEHvT (ORCPT ); Tue, 5 Aug 2014 03:51:19 -0400 Received: from mail-pd0-f181.google.com ([209.85.192.181]:41759 "EHLO mail-pd0-f181.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753999AbaHEHvT (ORCPT ); Tue, 5 Aug 2014 03:51:19 -0400 Received: by mail-pd0-f181.google.com with SMTP id g10so878148pdj.40 for ; Tue, 05 Aug 2014 00:51:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:date:message-id; bh=509tioM5rsnAsXLXY3VOWg498OoXwTvtvLDtZa32sno=; b=l643XizJqU0KRYSjCpzO6Fb86zE1F1Jlwro70gNm86cFiSvTluM7Dilh0cpiIE8mG7 XJh3GU0/mQ88t19GByPvRHDOfpT9v1DtY6lPnYELyoN5/U3v7zLCb+sYJUdY5iSn7T8d Sw9v4GBcx4p1HN3Tq9rkBv8BYkLE7gSUbuhbNMxF02TA9fjYYm3+GemUIqvSh2sWiveE HU+hrBrYAz6JRRrBcv7OwpNsuMNY0f90aiaDafveKutnZzJFXvuSoDN4I4aG/pwVKCUo 8UlmOCi7P88jW2rDnMXs9yo4C3ro+AIA96d3+JNS+Ajt4Y9eBnMtDfI6TVmD5Tsld+bB BOPA== X-Received: by 10.68.115.48 with SMTP id jl16mr1351311pbb.78.1407225078377; Tue, 05 Aug 2014 00:51:18 -0700 (PDT) Received: from vivek-linuxpc.sisodomain.com ([14.140.216.146]) by mx.google.com with ESMTPSA id g6sm3652273pat.2.2014.08.05.00.51.13 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 05 Aug 2014 00:51:17 -0700 (PDT) From: Vivek Gautam To: linux-usb@vger.kernel.org Cc: gregkh@linuxfoundation.org, linux-arm-kernel@lists.infradead.org, linux-samsung-soc@vger.kernel.org, linux-kernel@vger.kernel.org, kgene.kim@samsung.com, Vivek Gautam , Alan Stern , Jingoo Han Subject: [PATCH] usb: ehci/ohci-exynos: Fix PHY getting sequence Date: Tue, 5 Aug 2014 13:21:09 +0530 Message-Id: <1407225069-28443-1-git-send-email-gautam.vivek@samsung.com> X-Mailer: git-send-email 1.7.10.4 Sender: linux-samsung-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-samsung-soc@vger.kernel.org X-Spam-Status: No, score=-7.5 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,RP_MATCHES_RCVD,T_DKIM_INVALID,UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Since we want to keep support for both older usb-phys as well as the newer generic phys, lets first get the generic PHYs and fallback to older USB-PHYs only when we fail to get the former. This should fix the issue with ehci-exynos and ohci-exynos, wherein in the absence of SAMSUNG_USB2PHY config symbol, we end up getting the NOP_USB_XCEIV phy when the same is enabled. And thus the PHYs are not configured properly. Signed-off-by: Vivek Gautam Cc: Alan Stern Cc: Jingoo Han --- drivers/usb/host/ehci-exynos.c | 40 +++++++++++++++++----------------- drivers/usb/host/ohci-exynos.c | 47 +++++++++++++++++++--------------------- 2 files changed, 42 insertions(+), 45 deletions(-) diff --git a/drivers/usb/host/ehci-exynos.c b/drivers/usb/host/ehci-exynos.c index cda0a2f..2eed9a4 100644 --- a/drivers/usb/host/ehci-exynos.c +++ b/drivers/usb/host/ehci-exynos.c @@ -62,18 +62,6 @@ static int exynos_ehci_get_phy(struct device *dev, int phy_number; int ret = 0; - exynos_ehci->phy = devm_usb_get_phy(dev, USB_PHY_TYPE_USB2); - if (IS_ERR(exynos_ehci->phy)) { - ret = PTR_ERR(exynos_ehci->phy); - if (ret != -ENXIO && ret != -ENODEV) { - dev_err(dev, "no usb2 phy configured\n"); - return ret; - } - dev_dbg(dev, "Failed to get usb2 phy\n"); - } else { - exynos_ehci->otg = exynos_ehci->phy->otg; - } - for_each_available_child_of_node(dev->of_node, child) { ret = of_property_read_u32(child, "reg", &phy_number); if (ret) { @@ -90,15 +78,27 @@ static int exynos_ehci_get_phy(struct device *dev, phy = devm_of_phy_get(dev, child, NULL); of_node_put(child); - if (IS_ERR(phy)) { - ret = PTR_ERR(phy); - if (ret != -ENOSYS && ret != -ENODEV) { - dev_err(dev, "no usb2 phy configured\n"); - return ret; - } - dev_dbg(dev, "Failed to get usb2 phy\n"); - } + if (IS_ERR(phy)) + /* Lets fallback to older USB-PHYs */ + goto usb_phy_old; exynos_ehci->phy_g[phy_number] = phy; + /* Make the older PHYs unavailable */ + exynos_ehci->phy = ERR_PTR(-ENXIO); + } + + return 0; + +usb_phy_old: + exynos_ehci->phy = devm_usb_get_phy(dev, USB_PHY_TYPE_USB2); + if (IS_ERR(exynos_ehci->phy)) { + ret = PTR_ERR(exynos_ehci->phy); + if (ret != -ENXIO && ret != -ENODEV) { + dev_err(dev, "no usb2 phy configured\n"); + return ret; + } + dev_dbg(dev, "Failed to get usb2 phy\n"); + } else { + exynos_ehci->otg = exynos_ehci->phy->otg; } return ret; diff --git a/drivers/usb/host/ohci-exynos.c b/drivers/usb/host/ohci-exynos.c index a72ab8f..7c48e3f 100644 --- a/drivers/usb/host/ohci-exynos.c +++ b/drivers/usb/host/ohci-exynos.c @@ -51,27 +51,12 @@ static int exynos_ohci_get_phy(struct device *dev, int phy_number; int ret = 0; - exynos_ohci->phy = devm_usb_get_phy(dev, USB_PHY_TYPE_USB2); - if (IS_ERR(exynos_ohci->phy)) { - ret = PTR_ERR(exynos_ohci->phy); - if (ret != -ENXIO && ret != -ENODEV) { - dev_err(dev, "no usb2 phy configured\n"); - return ret; - } - dev_dbg(dev, "Failed to get usb2 phy\n"); - } else { - exynos_ohci->otg = exynos_ohci->phy->otg; - } - /* * Getting generic phy: * We are keeping both types of phys as a part of transiting OHCI * to generic phy framework, so as to maintain backward compatibilty - * with old DTB. - * If there are existing devices using DTB files built from them, - * to remove the support for old bindings in this driver, - * we need to make sure that such devices have their DTBs - * updated to ones built from new DTS. + * with old DTB too. + * We fallback to older USB-PHYs when we fail to get generic PHYs. */ for_each_available_child_of_node(dev->of_node, child) { ret = of_property_read_u32(child, "reg", &phy_number); @@ -89,15 +74,27 @@ static int exynos_ohci_get_phy(struct device *dev, phy = devm_of_phy_get(dev, child, NULL); of_node_put(child); - if (IS_ERR(phy)) { - ret = PTR_ERR(phy); - if (ret != -ENOSYS && ret != -ENODEV) { - dev_err(dev, "no usb2 phy configured\n"); - return ret; - } - dev_dbg(dev, "Failed to get usb2 phy\n"); - } + if (IS_ERR(phy)) + /* Lets fallback to older USB-PHYs */ + goto usb_phy_old; exynos_ohci->phy_g[phy_number] = phy; + /* Make the older PHYs unavailable */ + exynos_ohci->phy = ERR_PTR(-ENXIO); + } + + return 0; + +usb_phy_old: + exynos_ohci->phy = devm_usb_get_phy(dev, USB_PHY_TYPE_USB2); + if (IS_ERR(exynos_ohci->phy)) { + ret = PTR_ERR(exynos_ohci->phy); + if (ret != -ENXIO && ret != -ENODEV) { + dev_err(dev, "no usb2 phy configured\n"); + return ret; + } + dev_dbg(dev, "Failed to get usb2 phy\n"); + } else { + exynos_ohci->otg = exynos_ohci->phy->otg; } return ret;