From patchwork Wed Apr 25 09:39:08 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Neil Armstrong X-Patchwork-Id: 904086 X-Patchwork-Delegate: marek.vasut@gmail.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=baylibre.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=baylibre-com.20150623.gappssmtp.com header.i=@baylibre-com.20150623.gappssmtp.com header.b="hziXBInV"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 40WFXC4xh6z9ryk for ; Wed, 25 Apr 2018 19:39:23 +1000 (AEST) Received: by lists.denx.de (Postfix, from userid 105) id 2D655C21FA0; Wed, 25 Apr 2018 09:39:22 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=-0.0 required=5.0 tests=RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id AB7C5C21F02; Wed, 25 Apr 2018 09:39:19 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 75E2AC21E75; Wed, 25 Apr 2018 09:39:18 +0000 (UTC) Received: from mail-wm0-f67.google.com (mail-wm0-f67.google.com [74.125.82.67]) by lists.denx.de (Postfix) with ESMTPS id 2133DC21E13 for ; Wed, 25 Apr 2018 09:39:18 +0000 (UTC) Received: by mail-wm0-f67.google.com with SMTP id t67so6002528wmt.0 for ; Wed, 25 Apr 2018 02:39:18 -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:date:message-id; bh=5l+YEtG+HTr18JWUpbiHEYRh9EI4Ivy9UQNGmpjM1r4=; b=hziXBInV3QcuzmtN0YpfBl/g5AqLuR14EVF5HGtudga516hLMGPKNueoz/i1RQ16la jiovExp0A4neWBJjO4xf7M1q717VeJhQyuSgvVowpaFew9aA35ZdHRmEiDw+bFz00rgp ovU37q6LVtm8me0smysy8CgPqNKaDjMgyY6gq4BxD/8AF080/P4dckV+Qy+7breCgfTa /SUIb32LPli92Bb2ec6J0DgZESKnWKlVily8pCvxB1kclturtNdKOl1GFMBfKiRt/KYU Vfik2RS7/mas6XYxkFjBAwo+lWNCX3FG8lqej70h2Fxu9VxUrGuAr36ryHddOKMb5wN8 aQ9w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=5l+YEtG+HTr18JWUpbiHEYRh9EI4Ivy9UQNGmpjM1r4=; b=IflMQW3dePq5LZLPn9EZ2XHryjVbLshxRMr4Pr570xZiLx5ZgSCOku5OEn3xy1/OX+ ew1lRhfR9BrHXdjx+tDGvwoErRhTEHV/XU5McB1icP+GsQSs/kCxjDiDc/MzZ2xcXI8j M4H5J2R5rNVPPfW6hM8NHr9FX6CHRpw914VkyC9LdyeUxuT1HgPrkLJ3X2dyoqXlq3u6 kUyoYVG271tzyAr4QjsZP1PxfcZ2dfbsss7A7Y3I4UkLYmhjrATxxz/n+qz9NYvD5XlB MMf/H2VWC5Wsp3E/mkmZjmQGzN5tw/bkgH7qX/E9GaLO9yNPc0GWk8aL7WMIEBMQYyLt LJvg== X-Gm-Message-State: ALQs6tD/uefCxZLas4/Pov7gfWkHgMWczW6MV5O/MD7SsveBba2+YwL5 B1rx6U927SWyG9kFtooUSHPIs6OxZtM= X-Google-Smtp-Source: AB8JxZqQQfyHY0/kiE2qLxOgOvBERvbD/wiCpJ8wo5DS1hvIF6ReyurcyXVo7fl8ZzBkX1tGiOxFbw== X-Received: by 10.28.68.137 with SMTP id r131mr4435345wma.140.1524649157253; Wed, 25 Apr 2018 02:39:17 -0700 (PDT) Received: from bender.baylibre.local ([90.63.244.31]) by smtp.gmail.com with ESMTPSA id h81sm983268wmd.0.2018.04.25.02.39.16 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 25 Apr 2018 02:39:16 -0700 (PDT) From: Neil Armstrong To: u-boot@lists.denx.de, marek.vasut@gmail.com Date: Wed, 25 Apr 2018 11:39:08 +0200 Message-Id: <1524649148-27897-1-git-send-email-narmstrong@baylibre.com> X-Mailer: git-send-email 2.7.4 Cc: suzuki.katsuhiro@socionext.com, jaswinder.singh@linaro.org, mhiramat@kernel.org Subject: [U-Boot] [PATCH] usb: host: dwc3: fix phys init X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" When no PHYs are declared in the dwc3 node, the phy init fails. This patch checks if the "phys" property is presend and reports the error returned by dev_count_phandle_with_args(). This patchs also fixes the styles issues added in last commit. This patch should fix the DWC3 support on the UniPhier SoC family. Fixes: 7c839ea70c49 ("usb: host: dwc3: Add support for multiple PHYs") Reported-by: Masahiro Yamada Signed-off-by: Neil Armstrong Tested-by: Masahiro Yamada Reviewed-by: Bin Meng --- drivers/usb/host/xhci-dwc3.c | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/drivers/usb/host/xhci-dwc3.c b/drivers/usb/host/xhci-dwc3.c index c100735..adfa4a7 100644 --- a/drivers/usb/host/xhci-dwc3.c +++ b/drivers/usb/host/xhci-dwc3.c @@ -113,16 +113,21 @@ void dwc3_set_fladj(struct dwc3 *dwc3_reg, u32 val) } #ifdef CONFIG_DM_USB -static int xhci_dwc3_setup_phy(struct udevice *dev, int count) +static int xhci_dwc3_setup_phy(struct udevice *dev) { struct xhci_dwc3_platdata *plat = dev_get_platdata(dev); - int i, ret; + int i, ret, count; - if (!count) + /* Return if no phy declared */ + if (!dev_read_prop(dev, "phys", NULL)) return 0; + count = dev_count_phandle_with_args(dev, "phys", "#phy-cells"); + if (count <= 0) + return count; + plat->usb_phys = devm_kcalloc(dev, count, sizeof(struct phy), - GFP_KERNEL); + GFP_KERNEL); if (!plat->usb_phys) return -ENOMEM; @@ -136,7 +141,7 @@ static int xhci_dwc3_setup_phy(struct udevice *dev, int count) ++plat->num_phys; } - + for (i = 0; i < plat->num_phys; i++) { ret = generic_phy_init(&plat->usb_phys[i]); if (ret) { @@ -145,7 +150,7 @@ static int xhci_dwc3_setup_phy(struct udevice *dev, int count) goto phys_init_err; } } - + for (i = 0; i < plat->num_phys; i++) { ret = generic_phy_power_on(&plat->usb_phys[i]); if (ret) { @@ -157,7 +162,6 @@ static int xhci_dwc3_setup_phy(struct udevice *dev, int count) return 0; - phys_poweron_err: for (; i >= 0; i--) generic_phy_power_off(&plat->usb_phys[i]); @@ -187,7 +191,7 @@ static int xhci_dwc3_shutdown_phy(struct udevice *dev) ret |= generic_phy_exit(&plat->usb_phys[i]); if (ret) { pr_err("Can't shutdown USB PHY%d for %s\n", - i, dev->name); + i, dev->name); } } @@ -206,8 +210,7 @@ static int xhci_dwc3_probe(struct udevice *dev) hcor = (struct xhci_hcor *)((uintptr_t)hccr + HC_LENGTH(xhci_readl(&(hccr)->cr_capbase))); - ret = xhci_dwc3_setup_phy(dev, dev_count_phandle_with_args( - dev, "phys", "#phy-cells")); + ret = xhci_dwc3_setup_phy(dev); if (ret) return ret;