From patchwork Mon Jan 6 01:33:57 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Osipenko X-Patchwork-Id: 11318617 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C2FA41398 for ; Mon, 6 Jan 2020 01:34:47 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id A025B215A4 for ; Mon, 6 Jan 2020 01:34:47 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="jf0asTzG" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727368AbgAFBep (ORCPT ); Sun, 5 Jan 2020 20:34:45 -0500 Received: from mail-lf1-f68.google.com ([209.85.167.68]:37176 "EHLO mail-lf1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727331AbgAFBeo (ORCPT ); Sun, 5 Jan 2020 20:34:44 -0500 Received: by mail-lf1-f68.google.com with SMTP id b15so35352542lfc.4; Sun, 05 Jan 2020 17:34:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=+Ys0tzVmoHrFmSSc5qitpcji+ruTEJL6SzwhqsUjqgw=; b=jf0asTzGPKdmQ1tarA9D8fk4rIJRpIU323nKyXaHOBPf46lx8M85FLfaCsAe8RAhMS tXjAfJ6G4DBNJtU7vm7sfRGJ6BCRa5TGpYROjnynKSVvTWEySQzPDU9peGDk9xXF+z9z nqlcr4jcw555t9AddHN2m22leeAA1i5Cmo5+oPgA6yonJNjue4hlOIVMnGoTA6Su6tV6 0ihECe6YKOnnN3xfhuhjKyAuDf7SZpqFptN3kwC7CA2vQThDgLU02hCIGdLetaZL01bY PUztdJWXTilZFNQZHhoToQmGJfYeKqb0lKciEnndWv53NQxwTUx1u+a08Vu1sBO+3Raa RzIw== 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=+Ys0tzVmoHrFmSSc5qitpcji+ruTEJL6SzwhqsUjqgw=; b=BrTmk62nu5xX7Z/Yi8UEvuE8Sn+ajaEmI+nS04BFtS70DxauUwTxO0p1W8u/Up7AGp tlaLeS+G+zQWavlFfuSzzj6EPDgPs+SMzfFDPcjbDV6gQHCTiHKCkBhHRmX7w5jF0wyT yFcE4m1Rz2mEzUDJwBeg38GZtp+IVm7A66dNAhJzbolFXS0IfLx67TakD+uEcsMYRWu3 v7DWsxhzWdqUIs+dSlR4lRkM33QQJuw8UBQOh0VxlIT2M78y3EhQlpBPwvkG6T5OSS1a HaMXe3csXcV+uTERPPiLDJ18yaFKCQriMqcWuZa6GCpCgguWiq/DsO+hIGj6a+sO7pNZ ozQw== X-Gm-Message-State: APjAAAU/uTEWbGDG2KS7/74a78z3seKk47eKSDAsOH39JCOOnccB4ePu 98oJnqiLw0k3iGeiM+qXuWk= X-Google-Smtp-Source: APXvYqyCTYR6RkaTQrJpMs5Kuhsa7hg7AiHmnc1dp8TrLfTa6zDhaT5O2wOXP1xYL9OAAScFzki70w== X-Received: by 2002:a19:4901:: with SMTP id w1mr55338942lfa.168.1578274481881; Sun, 05 Jan 2020 17:34:41 -0800 (PST) Received: from localhost.localdomain (79-139-233-37.dynamic.spd-mgts.ru. [79.139.233.37]) by smtp.gmail.com with ESMTPSA id h10sm28235739ljc.39.2020.01.05.17.34.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 05 Jan 2020 17:34:41 -0800 (PST) From: Dmitry Osipenko To: Greg Kroah-Hartman , Peter Chen , Thierry Reding , Jonathan Hunter , Felipe Balbi , =?utf-8?b?TWljaGHFgiBNaXJvc8WCYXc=?= Cc: linux-usb@vger.kernel.org, linux-tegra@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v4 01/20] dt-binding: usb: ci-hdrc-usb2: Document NVIDIA Tegra support Date: Mon, 6 Jan 2020 04:33:57 +0300 Message-Id: <20200106013416.9604-2-digetx@gmail.com> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20200106013416.9604-1-digetx@gmail.com> References: <20200106013416.9604-1-digetx@gmail.com> MIME-Version: 1.0 Sender: linux-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org NVIDIA Tegra SoCs use ChipIdea silicon IP for the USB controllers. Acked-by: Peter Chen Acked-by: Thierry Reding Acked-by: Rob Herring Signed-off-by: Dmitry Osipenko --- Documentation/devicetree/bindings/usb/ci-hdrc-usb2.txt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Documentation/devicetree/bindings/usb/ci-hdrc-usb2.txt b/Documentation/devicetree/bindings/usb/ci-hdrc-usb2.txt index cfc9f40ab641..51376cbe5f3d 100644 --- a/Documentation/devicetree/bindings/usb/ci-hdrc-usb2.txt +++ b/Documentation/devicetree/bindings/usb/ci-hdrc-usb2.txt @@ -15,6 +15,10 @@ Required properties: "qcom,ci-hdrc" "chipidea,usb2" "xlnx,zynq-usb-2.20a" + "nvidia,tegra20-udc" + "nvidia,tegra30-udc" + "nvidia,tegra114-udc" + "nvidia,tegra124-udc" - reg: base address and length of the registers - interrupts: interrupt for the USB controller From patchwork Mon Jan 6 01:33:58 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Osipenko X-Patchwork-Id: 11318619 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id ED1E9184C for ; Mon, 6 Jan 2020 01:34:47 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id CBEE9215A4 for ; Mon, 6 Jan 2020 01:34:47 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="diw6i3sV" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727377AbgAFBeq (ORCPT ); Sun, 5 Jan 2020 20:34:46 -0500 Received: from mail-lj1-f195.google.com ([209.85.208.195]:34457 "EHLO mail-lj1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727332AbgAFBep (ORCPT ); Sun, 5 Jan 2020 20:34:45 -0500 Received: by mail-lj1-f195.google.com with SMTP id z22so44495598ljg.1; Sun, 05 Jan 2020 17:34:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Q36Rx1HqG9QFhtgtFtgGy7DR3UMN7/3uy9mm0NXYh6Y=; b=diw6i3sV5f3C61XJ4c0ZQke2kiqje9WKIWC1LH1vkGurf+oicKeVbFBa86oH3VPYTQ d5cEykx2iP9TSA+NSRJH6jmqBP9lsB0CQPJxErMdTZtR9kfsldoMdRLzqPSN0DjCW+sG GzV5NU9y9oTE8Cn3dlXVsyBYpxlKaMzM/j5qvzBi08Y2V93Vyn+RmNFoX5J4DwXF/tBK iR7LbShJIqE+4iWDXCPyHqfaEigdNby9qodthiljiHUXtVEQGsgSMNUXkvkdVKKnmAhy hZnzBRjFoN386Q7qaOg1neCNSDgk8ObrQtCzr2UY7X9jOAs4yE4vIk8zVsaiHsUx93UP vdkg== 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=Q36Rx1HqG9QFhtgtFtgGy7DR3UMN7/3uy9mm0NXYh6Y=; b=NWZFYcKPyPXsQyH4+KwEyZzMAA9ezirPGisusAqecaeUBskGxq0aU/G0fFCJQxSONy uArsYmJElWPQ5K3y9FaKS5xwqSbWCd+06k51JSSFI3NjYh6RdPSMXTdXFOWkU33uFNTE zjzoHYPS/H+pdmVRAXf2goWjE0zfaq00wAqfHQagaw19M6bQKrwrBqufCFS0FCI+hpwa XNF4Gr7aAKfhGpNpsn3pSZzJNjWwoCCeUKeMgWeufWy41QGu70L0RKUg584Uo1Q/d5OJ RbogZLiiqN26Jdj+Fv+mtyzja68tV+VEHUp/gq7yxIuiaenkKC6rakOXLfxSsRWDNbD+ LWag== X-Gm-Message-State: APjAAAUts5I2nUY0/PSo9lqNa+9qP+3uj5TPBeU+LJno5Ecz6ShtDJNf PHFGQPH5TCH/Sm/FBWmAoXA1pe7v X-Google-Smtp-Source: APXvYqygDStSxl8jQemf3oG0no8vmjdUwOPne9jsXKqjtxqJHmaFhFXcVUD6lptxDJUXTN59/PeTRQ== X-Received: by 2002:a2e:9248:: with SMTP id v8mr52711104ljg.189.1578274482705; Sun, 05 Jan 2020 17:34:42 -0800 (PST) Received: from localhost.localdomain (79-139-233-37.dynamic.spd-mgts.ru. [79.139.233.37]) by smtp.gmail.com with ESMTPSA id h10sm28235739ljc.39.2020.01.05.17.34.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 05 Jan 2020 17:34:42 -0800 (PST) From: Dmitry Osipenko To: Greg Kroah-Hartman , Peter Chen , Thierry Reding , Jonathan Hunter , Felipe Balbi , =?utf-8?b?TWljaGHFgiBNaXJvc8WCYXc=?= Cc: linux-usb@vger.kernel.org, linux-tegra@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v4 02/20] usb: host: ehci-tegra: Correct teardown order of driver's removal Date: Mon, 6 Jan 2020 04:33:58 +0300 Message-Id: <20200106013416.9604-3-digetx@gmail.com> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20200106013416.9604-1-digetx@gmail.com> References: <20200106013416.9604-1-digetx@gmail.com> MIME-Version: 1.0 Sender: linux-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org I found that PHY's enable refcounting was broken and after fixing it I also found that machine started to hang after EHCI driver module removal. Turned out that the teardown order is incorrect because HCD must be unregistered *before* PHY's disabling. Note that it is also not correct to assert the shared reset during of driver's removal because PHY takes care of resetting shared pads and thus it's better to remove that part from the EHCI driver. Signed-off-by: Dmitry Osipenko --- drivers/usb/host/ehci-tegra.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/drivers/usb/host/ehci-tegra.c b/drivers/usb/host/ehci-tegra.c index 4d2cdec4cb78..32483bef046b 100644 --- a/drivers/usb/host/ehci-tegra.c +++ b/drivers/usb/host/ehci-tegra.c @@ -521,16 +521,10 @@ static int tegra_ehci_remove(struct platform_device *pdev) struct tegra_ehci_hcd *tegra = (struct tegra_ehci_hcd *)hcd_to_ehci(hcd)->priv; + usb_remove_hcd(hcd); otg_set_host(hcd->usb_phy->otg, NULL); - usb_phy_shutdown(hcd->usb_phy); - usb_remove_hcd(hcd); - - reset_control_assert(tegra->rst); - udelay(1); - clk_disable_unprepare(tegra->clk); - usb_put_hcd(hcd); return 0; From patchwork Mon Jan 6 01:33:59 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Osipenko X-Patchwork-Id: 11318655 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id ABC0A139A for ; Mon, 6 Jan 2020 01:36:16 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 8971121734 for ; Mon, 6 Jan 2020 01:36:16 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="iWANhkqc" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727488AbgAFBgM (ORCPT ); Sun, 5 Jan 2020 20:36:12 -0500 Received: from mail-lf1-f65.google.com ([209.85.167.65]:39684 "EHLO mail-lf1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727349AbgAFBeq (ORCPT ); Sun, 5 Jan 2020 20:34:46 -0500 Received: by mail-lf1-f65.google.com with SMTP id y1so35320839lfb.6; Sun, 05 Jan 2020 17:34:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=EVv25b7UbdH8MSdwvAWkrRlinknRcU0zNyku2LR0yFY=; b=iWANhkqcsEmapSS1Dv70dSEUIJndQo9oGFny+ntOBn+ZTZ0X7WcisS+7ztVZtGp4eM wzaSYWL9CEcphhcgYW2wj9wnzovFdJ4vDrlx2TnprgoQ7pAdiGvRpU1nrl17tup56hYR bQBTOQPgkf2j999gmn0Ct3zabVWt/KC/zJJ7EU5dyU2f73FmZXbtCo+jLUb43HrOhV8Z 8bEvfsh7lHkaXDkueGTdGMbbLPacoM4j0t/ZyjKnID5H5xAWz5Tq30Wft7MOd4Hsshd4 hbW8I19jZhnLiS+84Y4Bsj4rzz8qn7JNoQzx47T0k4OvvnoDuTostgdmb/aN9dTmMKvi fZFg== 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=EVv25b7UbdH8MSdwvAWkrRlinknRcU0zNyku2LR0yFY=; b=kREGXofkfqqFFIxS3JvNWT6CQeTj6CzRR0Z6T1IoDMWgmESqJ85iUKe8C2ZBnmK1xp V/COOSu7tSuO8vQYd5QKC6kmd+YeSNrvkM/Wg7Dc/diCywuFsY7EoKXIpx8741Ga8xCm UJnwu6KauBjptNT7pGlmwhjgZvBpsYu22IkBSUeiN8Jlm3w1P9wNAziBrmzfE4GpdkZI 229Jxmnb6jiNRr5buMX1xgxEuf7Q1Qx3Kkpv1YQv0MWZ7o5DPH0PoHJ/Q+LB/RQUvbwc AwwOnjE8mJItBE9ZahqYihBC32dUHcp+pP2tB77OoaSrvBj2fzJHnJMwxfIfjL8hJ+VH bWGA== X-Gm-Message-State: APjAAAUHDcXx1tioljB2JZTwuYtnUEY7UGvBmuVEh4qMLFLW7L9lom8y 11lhe0d33O9RWKUNettPPOM= X-Google-Smtp-Source: APXvYqxJvMjgHQITK1cRLuczzMw1hlzhnfwwWKjIsTNuV852q8iqzceypqY+7ir4l4qVQFaIs4Lwcw== X-Received: by 2002:a19:9157:: with SMTP id y23mr59543548lfj.74.1578274483517; Sun, 05 Jan 2020 17:34:43 -0800 (PST) Received: from localhost.localdomain (79-139-233-37.dynamic.spd-mgts.ru. [79.139.233.37]) by smtp.gmail.com with ESMTPSA id h10sm28235739ljc.39.2020.01.05.17.34.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 05 Jan 2020 17:34:43 -0800 (PST) From: Dmitry Osipenko To: Greg Kroah-Hartman , Peter Chen , Thierry Reding , Jonathan Hunter , Felipe Balbi , =?utf-8?b?TWljaGHFgiBNaXJvc8WCYXc=?= Cc: linux-usb@vger.kernel.org, linux-tegra@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v4 03/20] usb: phy: tegra: Clean up ulpi_phy_power_off Date: Mon, 6 Jan 2020 04:33:59 +0300 Message-Id: <20200106013416.9604-4-digetx@gmail.com> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20200106013416.9604-1-digetx@gmail.com> References: <20200106013416.9604-1-digetx@gmail.com> MIME-Version: 1.0 Sender: linux-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org Firstly, the PHY's clock needs to unprepared to keep prepare count balanced. Secondly, downstream code suggests that reset is synchronous and thus it should be asserted before disabling clock. Signed-off-by: Dmitry Osipenko --- drivers/usb/phy/phy-tegra-usb.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/drivers/usb/phy/phy-tegra-usb.c b/drivers/usb/phy/phy-tegra-usb.c index ea7ef1dc0b42..99acfde4ab8d 100644 --- a/drivers/usb/phy/phy-tegra-usb.c +++ b/drivers/usb/phy/phy-tegra-usb.c @@ -757,8 +757,19 @@ static int ulpi_phy_power_on(struct tegra_usb_phy *phy) static int ulpi_phy_power_off(struct tegra_usb_phy *phy) { - clk_disable(phy->clk); - return gpio_direction_output(phy->reset_gpio, 0); + int err; + + err = gpio_direction_output(phy->reset_gpio, 0); + if (err) { + dev_err(phy->u_phy.dev, "reset GPIO not asserted: %d\n", err); + return err; + } + + usleep_range(5000, 6000); + + clk_disable_unprepare(phy->clk); + + return 0; } static void tegra_usb_phy_close(struct tegra_usb_phy *phy) From patchwork Mon Jan 6 01:34:00 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Osipenko X-Patchwork-Id: 11318653 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 015561398 for ; Mon, 6 Jan 2020 01:36:11 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id D428521775 for ; Mon, 6 Jan 2020 01:36:10 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="gEXPB5wZ" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727630AbgAFBgG (ORCPT ); Sun, 5 Jan 2020 20:36:06 -0500 Received: from mail-lf1-f68.google.com ([209.85.167.68]:39687 "EHLO mail-lf1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727296AbgAFBeq (ORCPT ); Sun, 5 Jan 2020 20:34:46 -0500 Received: by mail-lf1-f68.google.com with SMTP id y1so35320857lfb.6; Sun, 05 Jan 2020 17:34:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=CkOxMb8MLB/z4Q/y2dHyNNeQ96KLRUp7GW5wicnZ/Co=; b=gEXPB5wZoCjRBYNpi5yemWO85whmF6IFyO7yOxC3A00Kv8UpN0HX9SMsLg3ksCFpV1 mNCi73WMakKkwcerlaoHZRVx5gnT8TbdXs4QQtDHDWP2jMaQKq1NSzl51IpovaOu8Yfu pQcI6d6a95zMGeRdYJy5DEuJTzMD69/1b0dl3U253RneD/egE3D4wR+BQumgLWkap3O8 PBPpKFyKv2lPUcglmGxjLQNSbdUHixRpuk4wscsIUDBGMTasax2gnRrDUbr9XiIj/p7B Ka7/shjJtiW1cVzYFgINJol9k+ulCceoaX/k9ngICvmSuImjj8L2pUqEf1oUVF2arO9p FBUA== 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=CkOxMb8MLB/z4Q/y2dHyNNeQ96KLRUp7GW5wicnZ/Co=; b=aMepnaVkNlIpqVUoGc/P3xSA1cgExfVAmSuvwimAmQQCqNRFqZNEhDXQt3KlkglkYa 8DHeKgTHN2MTgBnloaFaDuTCrwvqJ3veEY4ZblN0WOAGF7KAABjO4a/BJTY7tNHUDaL/ S+HlWJRXbHdlhGMkEjh1e3S4zyukeKx4xPfin+q1EDw9en88D66UExJLeyOd8+0xQCP0 aee3Y+QwmVgmFboRsuLBkZBbq3Ee73g+VBOX9YM75Ghc7oQB5cmxQ8Arb76MBa+ExrET x4UfYirWegreuRaTOfm4u+2imQgdfY8ANrot8KqVAWgPxNoiS2nIhK3K8N4T9uaAF3Et cRNQ== X-Gm-Message-State: APjAAAVVAUGFmaz0zYDU+PFMRRkIU5nZxNFv0NRD1SwTrxCm9SnMx5gY zrVOa6qC0MKM4tIB5/EcyuW8Rg69 X-Google-Smtp-Source: APXvYqznR+oyJpYX509o8r8Sw5SiTXqU+JN9HQTo/g0PhBrrGBJWw0KgiqOzDzxer3ZO1aw0SQXIiA== X-Received: by 2002:a05:6512:244:: with SMTP id b4mr54406085lfo.85.1578274484369; Sun, 05 Jan 2020 17:34:44 -0800 (PST) Received: from localhost.localdomain (79-139-233-37.dynamic.spd-mgts.ru. [79.139.233.37]) by smtp.gmail.com with ESMTPSA id h10sm28235739ljc.39.2020.01.05.17.34.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 05 Jan 2020 17:34:43 -0800 (PST) From: Dmitry Osipenko To: Greg Kroah-Hartman , Peter Chen , Thierry Reding , Jonathan Hunter , Felipe Balbi , =?utf-8?b?TWljaGHFgiBNaXJvc8WCYXc=?= Cc: linux-usb@vger.kernel.org, linux-tegra@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v4 04/20] usb: phy: tegra: Keep track of power on-off state Date: Mon, 6 Jan 2020 04:34:00 +0300 Message-Id: <20200106013416.9604-5-digetx@gmail.com> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20200106013416.9604-1-digetx@gmail.com> References: <20200106013416.9604-1-digetx@gmail.com> MIME-Version: 1.0 Sender: linux-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org The PHY driver should keep track of the enable state, otherwise enable refcount is screwed if USB driver tries to enable PHY when it is already enabled. This will be the case for ChipIdea and Tegra EHCI drivers once PHY driver will gain support for the init/shutdown callbacks. Signed-off-by: Dmitry Osipenko --- drivers/usb/phy/phy-tegra-usb.c | 30 ++++++++++++++++++++++++++---- include/linux/usb/tegra_usb_phy.h | 1 + 2 files changed, 27 insertions(+), 4 deletions(-) diff --git a/drivers/usb/phy/phy-tegra-usb.c b/drivers/usb/phy/phy-tegra-usb.c index 99acfde4ab8d..88466c7f13e6 100644 --- a/drivers/usb/phy/phy-tegra-usb.c +++ b/drivers/usb/phy/phy-tegra-usb.c @@ -785,18 +785,40 @@ static void tegra_usb_phy_close(struct tegra_usb_phy *phy) static int tegra_usb_phy_power_on(struct tegra_usb_phy *phy) { + int err; + + if (phy->powered_on) + return 0; + if (phy->is_ulpi_phy) - return ulpi_phy_power_on(phy); + err = ulpi_phy_power_on(phy); else - return utmi_phy_power_on(phy); + err = utmi_phy_power_on(phy); + if (err) + return err; + + phy->powered_on = true; + + return 0; } static int tegra_usb_phy_power_off(struct tegra_usb_phy *phy) { + int err; + + if (!phy->powered_on) + return 0; + if (phy->is_ulpi_phy) - return ulpi_phy_power_off(phy); + err = ulpi_phy_power_off(phy); else - return utmi_phy_power_off(phy); + err = utmi_phy_power_off(phy); + if (err) + return err; + + phy->powered_on = false; + + return 0; } static int tegra_usb_phy_suspend(struct usb_phy *x, int suspend) diff --git a/include/linux/usb/tegra_usb_phy.h b/include/linux/usb/tegra_usb_phy.h index 0c5c3ea8b2d7..3ae73bdc6245 100644 --- a/include/linux/usb/tegra_usb_phy.h +++ b/include/linux/usb/tegra_usb_phy.h @@ -78,6 +78,7 @@ struct tegra_usb_phy { bool is_ulpi_phy; int reset_gpio; struct reset_control *pad_rst; + bool powered_on; }; void tegra_usb_phy_preresume(struct usb_phy *phy); From patchwork Mon Jan 6 01:34:01 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Osipenko X-Patchwork-Id: 11318651 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id BF072139A for ; Mon, 6 Jan 2020 01:36:04 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 8A0DB222C4 for ; Mon, 6 Jan 2020 01:36:04 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="eUD7jClG" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727399AbgAFBgA (ORCPT ); Sun, 5 Jan 2020 20:36:00 -0500 Received: from mail-lj1-f196.google.com ([209.85.208.196]:33008 "EHLO mail-lj1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727370AbgAFBes (ORCPT ); Sun, 5 Jan 2020 20:34:48 -0500 Received: by mail-lj1-f196.google.com with SMTP id y6so41290950lji.0; Sun, 05 Jan 2020 17:34:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=42H5eN8aWJh5DHzggTgG8y5oMLx4033Tu59SdMlqJBs=; b=eUD7jClGBRRkc7ghzaysDaprEcnXC275+awcQm/u4B+6d1cVJ5OZ0YgFer1ITESmLF 8eb5f3xky9aX3DxDJpsOTOMvD7KDm1E8Vr4vc1z1DnBHe3dT/nKtUEa9BPPwllWJbbNV G8E6G3BNqC7t7WPbXwmaTgzX6+UNN+V134hn73C9APTZOBkDLjy7kt60mReiweuiQF50 UgocCB1TTrkMpDWWTzM+eHl4rxsB5UZgoiMc7RKTd1LZQMAcgMRpt6ybrqD69j8zPB8D qJz71M9kcmYYlPQgwIk9znIP8aIBVrxqROW0/+2839j9jtm/gdOKI8K3P47nYWaVA9OP 6Tkw== 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=42H5eN8aWJh5DHzggTgG8y5oMLx4033Tu59SdMlqJBs=; b=mI7ChXs/Iu8Wk/ayAt6QN7xlt8xdfskDBpbnTTuxdj2mLePAaX2z8YoJFjMLaDW79a RvaatMQW63nt+QB1U05LyesRbNpqTDTkhLyGCAdzZUyla0rJx1hAFkyyXEzuDXDVwutQ p1KWx5jeBTe3Q266HqjZjpDJEjBNMAU95Aa1U3s1vGAz7ewrf4jUFkYnUVHLiUMoQUIC oVqPAYkorIMCrXfby0aBCCLVDCIdFrdpJVmRorsouAYLpsFiavR+5qbDHidHslMH6MJy xcI27oRhUDVVakjqugCz/pWr7iUdkKP5QnvzhZShiiaGlm4GJBPNOgoCfwPohzqp0jSR Hsag== X-Gm-Message-State: APjAAAVYsYobcSocsaVTyVuEFpL5cJ9vYJysfnc6b31NlbmZcMrXXI08 KOVnOiyGKCH9opPTPIWFInl6X+Rl X-Google-Smtp-Source: APXvYqynss6RaFMvXCpVZtJSV0khbhiEEW1YlZYTgyAvU+oMFclc8NPmCxOSCoeK/RClVs+rVYceOA== X-Received: by 2002:a2e:9243:: with SMTP id v3mr50807373ljg.73.1578274485223; Sun, 05 Jan 2020 17:34:45 -0800 (PST) Received: from localhost.localdomain (79-139-233-37.dynamic.spd-mgts.ru. [79.139.233.37]) by smtp.gmail.com with ESMTPSA id h10sm28235739ljc.39.2020.01.05.17.34.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 05 Jan 2020 17:34:44 -0800 (PST) From: Dmitry Osipenko To: Greg Kroah-Hartman , Peter Chen , Thierry Reding , Jonathan Hunter , Felipe Balbi , =?utf-8?b?TWljaGHFgiBNaXJvc8WCYXc=?= Cc: linux-usb@vger.kernel.org, linux-tegra@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v4 05/20] usb: phy: tegra: Hook up init/shutdown callbacks Date: Mon, 6 Jan 2020 04:34:01 +0300 Message-Id: <20200106013416.9604-6-digetx@gmail.com> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20200106013416.9604-1-digetx@gmail.com> References: <20200106013416.9604-1-digetx@gmail.com> MIME-Version: 1.0 Sender: linux-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org Generic PHY provides init/shutdown callbacks which allow USB-host drivers to abstract PHY's hardware management in a common way. This change allows to remove Tegra-specific PHY handling from the ChipIdea driver. Note that ChipIdea's driver shall be changed at the same time because it turns PHY ON without the PHY's initialization and this doesn't work now, resulting in a NULL dereference of phy->freq because it's set during of the PHY's initialization. Acked-by: Peter Chen Acked-by: Thierry Reding Signed-off-by: Dmitry Osipenko --- drivers/usb/phy/phy-tegra-usb.c | 180 +++++++++++++++++++------------- 1 file changed, 110 insertions(+), 70 deletions(-) diff --git a/drivers/usb/phy/phy-tegra-usb.c b/drivers/usb/phy/phy-tegra-usb.c index 88466c7f13e6..664259d74658 100644 --- a/drivers/usb/phy/phy-tegra-usb.c +++ b/drivers/usb/phy/phy-tegra-usb.c @@ -238,23 +238,6 @@ static int utmip_pad_open(struct tegra_usb_phy *phy) { int ret; - phy->pad_clk = devm_clk_get(phy->u_phy.dev, "utmi-pads"); - if (IS_ERR(phy->pad_clk)) { - ret = PTR_ERR(phy->pad_clk); - dev_err(phy->u_phy.dev, - "Failed to get UTMIP pad clock: %d\n", ret); - return ret; - } - - phy->pad_rst = devm_reset_control_get_optional_shared( - phy->u_phy.dev, "utmi-pads"); - if (IS_ERR(phy->pad_rst)) { - ret = PTR_ERR(phy->pad_rst); - dev_err(phy->u_phy.dev, - "Failed to get UTMI-pads reset: %d\n", ret); - return ret; - } - ret = clk_prepare_enable(phy->pad_clk); if (ret) { dev_err(phy->u_phy.dev, @@ -772,17 +755,6 @@ static int ulpi_phy_power_off(struct tegra_usb_phy *phy) return 0; } -static void tegra_usb_phy_close(struct tegra_usb_phy *phy) -{ - if (!IS_ERR(phy->vbus)) - regulator_disable(phy->vbus); - - if (!phy->is_ulpi_phy) - utmip_pad_close(phy); - - clk_disable_unprepare(phy->pll_u); -} - static int tegra_usb_phy_power_on(struct tegra_usb_phy *phy) { int err; @@ -821,9 +793,34 @@ static int tegra_usb_phy_power_off(struct tegra_usb_phy *phy) return 0; } -static int tegra_usb_phy_suspend(struct usb_phy *x, int suspend) +static void tegra_usb_phy_shutdown(struct usb_phy *u_phy) +{ + struct tegra_usb_phy *phy = container_of(u_phy, struct tegra_usb_phy, + u_phy); + + if (WARN_ON(!phy->freq)) + return; + + tegra_usb_phy_power_off(phy); + + if (!phy->is_ulpi_phy) + utmip_pad_close(phy); + + if (!IS_ERR(phy->vbus)) + regulator_disable(phy->vbus); + + clk_disable_unprepare(phy->pll_u); + + phy->freq = NULL; +} + +static int tegra_usb_phy_set_suspend(struct usb_phy *x, int suspend) { struct tegra_usb_phy *phy = container_of(x, struct tegra_usb_phy, u_phy); + + if (WARN_ON(!phy->freq)) + return -EINVAL; + if (suspend) return tegra_usb_phy_power_off(phy); else @@ -834,53 +831,27 @@ static int ulpi_open(struct tegra_usb_phy *phy) { int err; - phy->clk = devm_clk_get(phy->u_phy.dev, "ulpi-link"); - if (IS_ERR(phy->clk)) { - err = PTR_ERR(phy->clk); - dev_err(phy->u_phy.dev, "Failed to get ULPI clock: %d\n", err); - return err; - } - - err = devm_gpio_request(phy->u_phy.dev, phy->reset_gpio, - "ulpi_phy_reset_b"); - if (err < 0) { - dev_err(phy->u_phy.dev, "Request failed for GPIO %d: %d\n", - phy->reset_gpio, err); - return err; - } - err = gpio_direction_output(phy->reset_gpio, 0); if (err < 0) { dev_err(phy->u_phy.dev, - "GPIO %d direction not set to output: %d\n", + "ULPI reset GPIO %d direction not asserted: %d\n", phy->reset_gpio, err); return err; } - phy->ulpi = otg_ulpi_create(&ulpi_viewport_access_ops, 0); - if (!phy->ulpi) { - dev_err(phy->u_phy.dev, "Failed to create ULPI OTG\n"); - err = -ENOMEM; - return err; - } - - phy->ulpi->io_priv = phy->regs + ULPI_VIEWPORT; return 0; } -static int tegra_usb_phy_init(struct tegra_usb_phy *phy) +static int tegra_usb_phy_init(struct usb_phy *u_phy) { + struct tegra_usb_phy *phy = container_of(u_phy, struct tegra_usb_phy, + u_phy); unsigned long parent_rate; int i; int err; - phy->pll_u = devm_clk_get(phy->u_phy.dev, "pll_u"); - if (IS_ERR(phy->pll_u)) { - err = PTR_ERR(phy->pll_u); - dev_err(phy->u_phy.dev, - "Failed to get pll_u clock: %d\n", err); - return err; - } + if (WARN_ON(phy->freq)) + return 0; err = clk_prepare_enable(phy->pll_u); if (err) @@ -917,10 +888,20 @@ static int tegra_usb_phy_init(struct tegra_usb_phy *phy) if (err < 0) goto fail; + err = tegra_usb_phy_power_on(phy); + if (err) + goto close_phy; + return 0; +close_phy: + if (!phy->is_ulpi_phy) + utmip_pad_close(phy); fail: clk_disable_unprepare(phy->pll_u); + + phy->freq = NULL; + return err; } @@ -1167,22 +1148,77 @@ static int tegra_usb_phy_probe(struct platform_device *pdev) tegra_phy->vbus = ERR_PTR(-ENODEV); } - tegra_phy->u_phy.dev = &pdev->dev; - err = tegra_usb_phy_init(tegra_phy); - if (err < 0) + tegra_phy->pll_u = devm_clk_get(&pdev->dev, "pll_u"); + err = PTR_ERR_OR_ZERO(tegra_phy->pll_u); + if (err) { + dev_err(&pdev->dev, "Failed to get pll_u clock: %d\n", err); return err; + } + + if (tegra_phy->is_ulpi_phy) { + tegra_phy->clk = devm_clk_get(&pdev->dev, "ulpi-link"); + err = PTR_ERR_OR_ZERO(tegra_phy->clk); + if (err) { + dev_err(&pdev->dev, + "Failed to get ULPI clock: %d\n", err); + return err; + } - tegra_phy->u_phy.set_suspend = tegra_usb_phy_suspend; + err = devm_gpio_request(&pdev->dev, tegra_phy->reset_gpio, + "ulpi_phy_reset_b"); + if (err < 0) { + dev_err(&pdev->dev, "Request failed for GPIO %d: %d\n", + tegra_phy->reset_gpio, err); + return err; + } + + tegra_phy->ulpi = otg_ulpi_create(&ulpi_viewport_access_ops, 0); + if (!tegra_phy->ulpi) { + dev_err(&pdev->dev, "Failed to create ULPI OTG\n"); + err = -ENOMEM; + return err; + } + + tegra_phy->ulpi->io_priv = tegra_phy->regs + ULPI_VIEWPORT; + } else { + tegra_phy->pad_clk = devm_clk_get(&pdev->dev, "utmi-pads"); + err = PTR_ERR_OR_ZERO(tegra_phy->pad_clk); + if (err) { + dev_err(&pdev->dev, + "Failed to get UTMIP pad clock: %d\n", err); + return err; + } + + tegra_phy->pad_rst = devm_reset_control_get_optional_shared( + &pdev->dev, "utmi-pads"); + err = PTR_ERR_OR_ZERO(tegra_phy->pad_rst); + if (err) { + dev_err(&pdev->dev, + "Failed to get UTMI-pads reset: %d\n", err); + return err; + } + } + + tegra_phy->u_phy.dev = &pdev->dev; + tegra_phy->u_phy.init = tegra_usb_phy_init; + tegra_phy->u_phy.shutdown = tegra_usb_phy_shutdown; + tegra_phy->u_phy.set_suspend = tegra_usb_phy_set_suspend; platform_set_drvdata(pdev, tegra_phy); err = usb_add_phy_dev(&tegra_phy->u_phy); - if (err < 0) { - tegra_usb_phy_close(tegra_phy); - return err; - } + if (err < 0) + goto free_ulpi; return 0; + +free_ulpi: + if (tegra_phy->ulpi) { + kfree(tegra_phy->ulpi->otg); + kfree(tegra_phy->ulpi); + } + + return err; } static int tegra_usb_phy_remove(struct platform_device *pdev) @@ -1190,7 +1226,11 @@ static int tegra_usb_phy_remove(struct platform_device *pdev) struct tegra_usb_phy *tegra_phy = platform_get_drvdata(pdev); usb_remove_phy(&tegra_phy->u_phy); - tegra_usb_phy_close(tegra_phy); + + if (tegra_phy->ulpi) { + kfree(tegra_phy->ulpi->otg); + kfree(tegra_phy->ulpi); + } return 0; } From patchwork Mon Jan 6 01:34:02 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Osipenko X-Patchwork-Id: 11318649 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 06A07139A for ; Mon, 6 Jan 2020 01:35:58 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id BB8F4218AC for ; Mon, 6 Jan 2020 01:35:57 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="VcIEPEvb" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727420AbgAFBeu (ORCPT ); Sun, 5 Jan 2020 20:34:50 -0500 Received: from mail-lj1-f194.google.com ([209.85.208.194]:41122 "EHLO mail-lj1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727381AbgAFBet (ORCPT ); Sun, 5 Jan 2020 20:34:49 -0500 Received: by mail-lj1-f194.google.com with SMTP id h23so49323494ljc.8; Sun, 05 Jan 2020 17:34:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=mmTkY5lNoQdYXYGLKiHcRswy3YwaEjyFrHAyFDTh16A=; b=VcIEPEvb4cMbkC4dAXMc0nVtB1YBzwFMT3/QVk9Bt3vfjkAevbc/sSL4bFM9130T9c EmDgTb74D9d3B8Dg1FqF5oCtC2UmaIznI6wJhYHzJF/ajDcaBsXWu13gNvW7PChoybwh Q0x39Udo5AtA5QIGl8vP2JkTORuiPHE8CMxDDl1vWLIi88YM2vHtolB/wUn4ErPGwD4m i06GLJIaypSJtyQnfKzFd/pxcPnplxKIFz61QnPbvVJe8788OGADj0/0gy7QQcRvE/d5 UaPSfDKaAwa0aZRQhIRx2KI5tobmlrHs+CohWKeNgp1VEe0nwxOh+oltxojibJYZQXrN yYIg== 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=mmTkY5lNoQdYXYGLKiHcRswy3YwaEjyFrHAyFDTh16A=; b=rJkbkcIK7yprQJ4ou92DXtn0FUSFp8Duqepf+ar4uZKSqMaEtNbUc3zzVHKQI6eiEJ Lci/3dJK2kLdEwsQpVQLAGXbjc9PhHw1yRMStyKp3Rdm7UbLrUpRj+vy62HhhaUCxOo5 f6kFg0iU1AI2RnDAHjeFOdjl7E49KTppmWnTLS/GiHtdoHIIBhcS7xa+P3fI6xJXEeFQ c4MIely9wE0SUGjc52JjiIiv+M1LvtXjeoE7MoqGiN9mnqV5i2VuPpfWJhZUaCEaa9Qb BJZntvZSp//uM3qnY9V9PQt6IVVlcXA0CueF+RR/HvRM0dXFJxkI2iUDCSUUlT7aBIF0 aRQg== X-Gm-Message-State: APjAAAWjvinZkIyByO4subBuVQbJRDQUpvSAY7iAAzPXA9wb8RZn8AHy GXpR5IEWlXHjyAwbJ2Z2ZKo= X-Google-Smtp-Source: APXvYqzgJfv1IS9iGAECTTZsUnkBf/VBROxeL4+V6eCNQkdjJRCqLLun026/Ov+u1UxCvgeZ9oG+JQ== X-Received: by 2002:a2e:94c8:: with SMTP id r8mr56863443ljh.28.1578274486204; Sun, 05 Jan 2020 17:34:46 -0800 (PST) Received: from localhost.localdomain (79-139-233-37.dynamic.spd-mgts.ru. [79.139.233.37]) by smtp.gmail.com with ESMTPSA id h10sm28235739ljc.39.2020.01.05.17.34.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 05 Jan 2020 17:34:45 -0800 (PST) From: Dmitry Osipenko To: Greg Kroah-Hartman , Peter Chen , Thierry Reding , Jonathan Hunter , Felipe Balbi , =?utf-8?b?TWljaGHFgiBNaXJvc8WCYXc=?= Cc: linux-usb@vger.kernel.org, linux-tegra@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v4 06/20] usb: phy: tegra: Perform general clean up of the code Date: Mon, 6 Jan 2020 04:34:02 +0300 Message-Id: <20200106013416.9604-7-digetx@gmail.com> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20200106013416.9604-1-digetx@gmail.com> References: <20200106013416.9604-1-digetx@gmail.com> MIME-Version: 1.0 Sender: linux-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org This patch fixes few dozens of legit checkpatch warnings, adds missed handling of potential error-cases and prettifies code where makes sense. All these clean-up changes are quite minor and do not fix any real problems. Acked-by: Thierry Reding Signed-off-by: Dmitry Osipenko --- drivers/usb/phy/phy-tegra-usb.c | 485 +++++++++++++++++--------------- 1 file changed, 254 insertions(+), 231 deletions(-) diff --git a/drivers/usb/phy/phy-tegra-usb.c b/drivers/usb/phy/phy-tegra-usb.c index 664259d74658..c045f44ea964 100644 --- a/drivers/usb/phy/phy-tegra-usb.c +++ b/drivers/usb/phy/phy-tegra-usb.c @@ -28,35 +28,35 @@ #include #include -#define ULPI_VIEWPORT 0x170 +#define ULPI_VIEWPORT 0x170 /* PORTSC PTS/PHCD bits, Tegra20 only */ -#define TEGRA_USB_PORTSC1 0x184 -#define TEGRA_USB_PORTSC1_PTS(x) (((x) & 0x3) << 30) -#define TEGRA_USB_PORTSC1_PHCD (1 << 23) +#define TEGRA_USB_PORTSC1 0x184 +#define TEGRA_USB_PORTSC1_PTS(x) (((x) & 0x3) << 30) +#define TEGRA_USB_PORTSC1_PHCD BIT(23) /* HOSTPC1 PTS/PHCD bits, Tegra30 and above */ -#define TEGRA_USB_HOSTPC1_DEVLC 0x1b4 -#define TEGRA_USB_HOSTPC1_DEVLC_PTS(x) (((x) & 0x7) << 29) -#define TEGRA_USB_HOSTPC1_DEVLC_PHCD (1 << 22) +#define TEGRA_USB_HOSTPC1_DEVLC 0x1b4 +#define TEGRA_USB_HOSTPC1_DEVLC_PTS(x) (((x) & 0x7) << 29) +#define TEGRA_USB_HOSTPC1_DEVLC_PHCD BIT(22) /* Bits of PORTSC1, which will get cleared by writing 1 into them */ #define TEGRA_PORTSC1_RWC_BITS (PORT_CSC | PORT_PEC | PORT_OCC) -#define USB_SUSP_CTRL 0x400 -#define USB_WAKE_ON_CNNT_EN_DEV (1 << 3) -#define USB_WAKE_ON_DISCON_EN_DEV (1 << 4) -#define USB_SUSP_CLR (1 << 5) -#define USB_PHY_CLK_VALID (1 << 7) -#define UTMIP_RESET (1 << 11) -#define UHSIC_RESET (1 << 11) -#define UTMIP_PHY_ENABLE (1 << 12) -#define ULPI_PHY_ENABLE (1 << 13) -#define USB_SUSP_SET (1 << 14) -#define USB_WAKEUP_DEBOUNCE_COUNT(x) (((x) & 0x7) << 16) - -#define USB1_LEGACY_CTRL 0x410 -#define USB1_NO_LEGACY_MODE (1 << 0) +#define USB_SUSP_CTRL 0x400 +#define USB_WAKE_ON_CNNT_EN_DEV BIT(3) +#define USB_WAKE_ON_DISCON_EN_DEV BIT(4) +#define USB_SUSP_CLR BIT(5) +#define USB_PHY_CLK_VALID BIT(7) +#define UTMIP_RESET BIT(11) +#define UHSIC_RESET BIT(11) +#define UTMIP_PHY_ENABLE BIT(12) +#define ULPI_PHY_ENABLE BIT(13) +#define USB_SUSP_SET BIT(14) +#define USB_WAKEUP_DEBOUNCE_COUNT(x) (((x) & 0x7) << 16) + +#define USB1_LEGACY_CTRL 0x410 +#define USB1_NO_LEGACY_MODE BIT(0) #define USB1_VBUS_SENSE_CTL_MASK (3 << 1) #define USB1_VBUS_SENSE_CTL_VBUS_WAKEUP (0 << 1) #define USB1_VBUS_SENSE_CTL_AB_SESS_VLD_OR_VBUS_WAKEUP \ @@ -64,94 +64,94 @@ #define USB1_VBUS_SENSE_CTL_AB_SESS_VLD (2 << 1) #define USB1_VBUS_SENSE_CTL_A_SESS_VLD (3 << 1) -#define ULPI_TIMING_CTRL_0 0x424 -#define ULPI_OUTPUT_PINMUX_BYP (1 << 10) -#define ULPI_CLKOUT_PINMUX_BYP (1 << 11) +#define ULPI_TIMING_CTRL_0 0x424 +#define ULPI_OUTPUT_PINMUX_BYP BIT(10) +#define ULPI_CLKOUT_PINMUX_BYP BIT(11) -#define ULPI_TIMING_CTRL_1 0x428 -#define ULPI_DATA_TRIMMER_LOAD (1 << 0) -#define ULPI_DATA_TRIMMER_SEL(x) (((x) & 0x7) << 1) -#define ULPI_STPDIRNXT_TRIMMER_LOAD (1 << 16) -#define ULPI_STPDIRNXT_TRIMMER_SEL(x) (((x) & 0x7) << 17) -#define ULPI_DIR_TRIMMER_LOAD (1 << 24) -#define ULPI_DIR_TRIMMER_SEL(x) (((x) & 0x7) << 25) +#define ULPI_TIMING_CTRL_1 0x428 +#define ULPI_DATA_TRIMMER_LOAD BIT(0) +#define ULPI_DATA_TRIMMER_SEL(x) (((x) & 0x7) << 1) +#define ULPI_STPDIRNXT_TRIMMER_LOAD BIT(16) +#define ULPI_STPDIRNXT_TRIMMER_SEL(x) (((x) & 0x7) << 17) +#define ULPI_DIR_TRIMMER_LOAD BIT(24) +#define ULPI_DIR_TRIMMER_SEL(x) (((x) & 0x7) << 25) -#define UTMIP_PLL_CFG1 0x804 +#define UTMIP_PLL_CFG1 0x804 #define UTMIP_XTAL_FREQ_COUNT(x) (((x) & 0xfff) << 0) #define UTMIP_PLLU_ENABLE_DLY_COUNT(x) (((x) & 0x1f) << 27) -#define UTMIP_XCVR_CFG0 0x808 +#define UTMIP_XCVR_CFG0 0x808 #define UTMIP_XCVR_SETUP(x) (((x) & 0xf) << 0) #define UTMIP_XCVR_SETUP_MSB(x) ((((x) & 0x70) >> 4) << 22) #define UTMIP_XCVR_LSRSLEW(x) (((x) & 0x3) << 8) #define UTMIP_XCVR_LSFSLEW(x) (((x) & 0x3) << 10) -#define UTMIP_FORCE_PD_POWERDOWN (1 << 14) -#define UTMIP_FORCE_PD2_POWERDOWN (1 << 16) -#define UTMIP_FORCE_PDZI_POWERDOWN (1 << 18) -#define UTMIP_XCVR_LSBIAS_SEL (1 << 21) +#define UTMIP_FORCE_PD_POWERDOWN BIT(14) +#define UTMIP_FORCE_PD2_POWERDOWN BIT(16) +#define UTMIP_FORCE_PDZI_POWERDOWN BIT(18) +#define UTMIP_XCVR_LSBIAS_SEL BIT(21) #define UTMIP_XCVR_HSSLEW(x) (((x) & 0x3) << 4) #define UTMIP_XCVR_HSSLEW_MSB(x) ((((x) & 0x1fc) >> 2) << 25) -#define UTMIP_BIAS_CFG0 0x80c -#define UTMIP_OTGPD (1 << 11) -#define UTMIP_BIASPD (1 << 10) -#define UTMIP_HSSQUELCH_LEVEL(x) (((x) & 0x3) << 0) -#define UTMIP_HSDISCON_LEVEL(x) (((x) & 0x3) << 2) -#define UTMIP_HSDISCON_LEVEL_MSB(x) ((((x) & 0x4) >> 2) << 24) +#define UTMIP_BIAS_CFG0 0x80c +#define UTMIP_OTGPD BIT(11) +#define UTMIP_BIASPD BIT(10) +#define UTMIP_HSSQUELCH_LEVEL(x) (((x) & 0x3) << 0) +#define UTMIP_HSDISCON_LEVEL(x) (((x) & 0x3) << 2) +#define UTMIP_HSDISCON_LEVEL_MSB(x) ((((x) & 0x4) >> 2) << 24) -#define UTMIP_HSRX_CFG0 0x810 -#define UTMIP_ELASTIC_LIMIT(x) (((x) & 0x1f) << 10) -#define UTMIP_IDLE_WAIT(x) (((x) & 0x1f) << 15) +#define UTMIP_HSRX_CFG0 0x810 +#define UTMIP_ELASTIC_LIMIT(x) (((x) & 0x1f) << 10) +#define UTMIP_IDLE_WAIT(x) (((x) & 0x1f) << 15) -#define UTMIP_HSRX_CFG1 0x814 -#define UTMIP_HS_SYNC_START_DLY(x) (((x) & 0x1f) << 1) +#define UTMIP_HSRX_CFG1 0x814 +#define UTMIP_HS_SYNC_START_DLY(x) (((x) & 0x1f) << 1) -#define UTMIP_TX_CFG0 0x820 -#define UTMIP_FS_PREABMLE_J (1 << 19) -#define UTMIP_HS_DISCON_DISABLE (1 << 8) +#define UTMIP_TX_CFG0 0x820 +#define UTMIP_FS_PREABMLE_J BIT(19) +#define UTMIP_HS_DISCON_DISABLE BIT(8) -#define UTMIP_MISC_CFG0 0x824 -#define UTMIP_DPDM_OBSERVE (1 << 26) -#define UTMIP_DPDM_OBSERVE_SEL(x) (((x) & 0xf) << 27) -#define UTMIP_DPDM_OBSERVE_SEL_FS_J UTMIP_DPDM_OBSERVE_SEL(0xf) -#define UTMIP_DPDM_OBSERVE_SEL_FS_K UTMIP_DPDM_OBSERVE_SEL(0xe) -#define UTMIP_DPDM_OBSERVE_SEL_FS_SE1 UTMIP_DPDM_OBSERVE_SEL(0xd) -#define UTMIP_DPDM_OBSERVE_SEL_FS_SE0 UTMIP_DPDM_OBSERVE_SEL(0xc) -#define UTMIP_SUSPEND_EXIT_ON_EDGE (1 << 22) +#define UTMIP_MISC_CFG0 0x824 +#define UTMIP_DPDM_OBSERVE BIT(26) +#define UTMIP_DPDM_OBSERVE_SEL(x) (((x) & 0xf) << 27) +#define UTMIP_DPDM_OBSERVE_SEL_FS_J UTMIP_DPDM_OBSERVE_SEL(0xf) +#define UTMIP_DPDM_OBSERVE_SEL_FS_K UTMIP_DPDM_OBSERVE_SEL(0xe) +#define UTMIP_DPDM_OBSERVE_SEL_FS_SE1 UTMIP_DPDM_OBSERVE_SEL(0xd) +#define UTMIP_DPDM_OBSERVE_SEL_FS_SE0 UTMIP_DPDM_OBSERVE_SEL(0xc) +#define UTMIP_SUSPEND_EXIT_ON_EDGE BIT(22) -#define UTMIP_MISC_CFG1 0x828 -#define UTMIP_PLL_ACTIVE_DLY_COUNT(x) (((x) & 0x1f) << 18) -#define UTMIP_PLLU_STABLE_COUNT(x) (((x) & 0xfff) << 6) +#define UTMIP_MISC_CFG1 0x828 +#define UTMIP_PLL_ACTIVE_DLY_COUNT(x) (((x) & 0x1f) << 18) +#define UTMIP_PLLU_STABLE_COUNT(x) (((x) & 0xfff) << 6) -#define UTMIP_DEBOUNCE_CFG0 0x82c -#define UTMIP_BIAS_DEBOUNCE_A(x) (((x) & 0xffff) << 0) +#define UTMIP_DEBOUNCE_CFG0 0x82c +#define UTMIP_BIAS_DEBOUNCE_A(x) (((x) & 0xffff) << 0) -#define UTMIP_BAT_CHRG_CFG0 0x830 -#define UTMIP_PD_CHRG (1 << 0) +#define UTMIP_BAT_CHRG_CFG0 0x830 +#define UTMIP_PD_CHRG BIT(0) -#define UTMIP_SPARE_CFG0 0x834 -#define FUSE_SETUP_SEL (1 << 3) +#define UTMIP_SPARE_CFG0 0x834 +#define FUSE_SETUP_SEL BIT(3) -#define UTMIP_XCVR_CFG1 0x838 -#define UTMIP_FORCE_PDDISC_POWERDOWN (1 << 0) -#define UTMIP_FORCE_PDCHRP_POWERDOWN (1 << 2) -#define UTMIP_FORCE_PDDR_POWERDOWN (1 << 4) -#define UTMIP_XCVR_TERM_RANGE_ADJ(x) (((x) & 0xf) << 18) +#define UTMIP_XCVR_CFG1 0x838 +#define UTMIP_FORCE_PDDISC_POWERDOWN BIT(0) +#define UTMIP_FORCE_PDCHRP_POWERDOWN BIT(2) +#define UTMIP_FORCE_PDDR_POWERDOWN BIT(4) +#define UTMIP_XCVR_TERM_RANGE_ADJ(x) (((x) & 0xf) << 18) -#define UTMIP_BIAS_CFG1 0x83c -#define UTMIP_BIAS_PDTRK_COUNT(x) (((x) & 0x1f) << 3) +#define UTMIP_BIAS_CFG1 0x83c +#define UTMIP_BIAS_PDTRK_COUNT(x) (((x) & 0x1f) << 3) /* For Tegra30 and above only, the address is different in Tegra20 */ -#define USB_USBMODE 0x1f8 -#define USB_USBMODE_MASK (3 << 0) -#define USB_USBMODE_HOST (3 << 0) -#define USB_USBMODE_DEVICE (2 << 0) +#define USB_USBMODE 0x1f8 +#define USB_USBMODE_MASK (3 << 0) +#define USB_USBMODE_HOST (3 << 0) +#define USB_USBMODE_DEVICE (2 << 0) static DEFINE_SPINLOCK(utmip_pad_lock); -static int utmip_pad_count; +static unsigned int utmip_pad_count; struct tegra_xtal_freq { - int freq; + unsigned int freq; u8 enable_delay; u8 stable_count; u8 active_delay; @@ -194,6 +194,11 @@ static const struct tegra_xtal_freq tegra_freq_table[] = { }, }; +static inline struct tegra_usb_phy *to_tegra_usb_phy(struct usb_phy *u_phy) +{ + return container_of(u_phy, struct tegra_usb_phy, u_phy); +} + static void set_pts(struct tegra_usb_phy *phy, u8 pts_val) { void __iomem *base = phy->regs; @@ -298,13 +303,16 @@ static int utmip_pad_close(struct tegra_usb_phy *phy) return ret; } -static void utmip_pad_power_on(struct tegra_usb_phy *phy) +static int utmip_pad_power_on(struct tegra_usb_phy *phy) { - unsigned long val, flags; - void __iomem *base = phy->pad_regs; struct tegra_utmip_config *config = phy->config; + void __iomem *base = phy->pad_regs; + unsigned long val, flags; + int err; - clk_prepare_enable(phy->pad_clk); + err = clk_prepare_enable(phy->pad_clk); + if (err) + return err; spin_lock_irqsave(&utmip_pad_lock, flags); @@ -327,19 +335,24 @@ static void utmip_pad_power_on(struct tegra_usb_phy *phy) spin_unlock_irqrestore(&utmip_pad_lock, flags); clk_disable_unprepare(phy->pad_clk); + + return 0; } static int utmip_pad_power_off(struct tegra_usb_phy *phy) { - unsigned long val, flags; void __iomem *base = phy->pad_regs; + unsigned long val, flags; + int err; if (!utmip_pad_count) { dev_err(phy->u_phy.dev, "UTMIP pad already powered off\n"); return -EINVAL; } - clk_prepare_enable(phy->pad_clk); + err = clk_prepare_enable(phy->pad_clk); + if (err) + return err; spin_lock_irqsave(&utmip_pad_lock, flags); @@ -366,8 +379,8 @@ static int utmi_wait_register(void __iomem *reg, u32 mask, u32 result) static void utmi_phy_clk_disable(struct tegra_usb_phy *phy) { - unsigned long val; void __iomem *base = phy->regs; + unsigned long val; /* * The USB driver may have already initiated the phy clock @@ -382,23 +395,24 @@ static void utmi_phy_clk_disable(struct tegra_usb_phy *phy) val |= USB_SUSP_SET; writel(val, base + USB_SUSP_CTRL); - udelay(10); + usleep_range(10, 100); val = readl(base + USB_SUSP_CTRL); val &= ~USB_SUSP_SET; writel(val, base + USB_SUSP_CTRL); - } else + } else { set_phcd(phy, true); + } - if (utmi_wait_register(base + USB_SUSP_CTRL, USB_PHY_CLK_VALID, 0) < 0) + if (utmi_wait_register(base + USB_SUSP_CTRL, USB_PHY_CLK_VALID, 0)) dev_err(phy->u_phy.dev, "Timeout waiting for PHY to stabilize on disable\n"); } static void utmi_phy_clk_enable(struct tegra_usb_phy *phy) { - unsigned long val; void __iomem *base = phy->regs; + unsigned long val; /* * The USB driver may have already initiated the phy clock @@ -414,25 +428,27 @@ static void utmi_phy_clk_enable(struct tegra_usb_phy *phy) val |= USB_SUSP_CLR; writel(val, base + USB_SUSP_CTRL); - udelay(10); + usleep_range(10, 100); val = readl(base + USB_SUSP_CTRL); val &= ~USB_SUSP_CLR; writel(val, base + USB_SUSP_CTRL); - } else + } else { set_phcd(phy, false); + } if (utmi_wait_register(base + USB_SUSP_CTRL, USB_PHY_CLK_VALID, - USB_PHY_CLK_VALID)) + USB_PHY_CLK_VALID)) dev_err(phy->u_phy.dev, "Timeout waiting for PHY to stabilize on enable\n"); } static int utmi_phy_power_on(struct tegra_usb_phy *phy) { - unsigned long val; - void __iomem *base = phy->regs; struct tegra_utmip_config *config = phy->config; + void __iomem *base = phy->regs; + unsigned long val; + int err; val = readl(base + USB_SUSP_CTRL); val |= UTMIP_RESET; @@ -498,7 +514,9 @@ static int utmi_phy_power_on(struct tegra_usb_phy *phy) writel(val, base + UTMIP_BAT_CHRG_CFG0); } - utmip_pad_power_on(phy); + err = utmip_pad_power_on(phy); + if (err) + return err; val = readl(base + UTMIP_XCVR_CFG0); val &= ~(UTMIP_FORCE_PD_POWERDOWN | UTMIP_FORCE_PD2_POWERDOWN | @@ -579,8 +597,8 @@ static int utmi_phy_power_on(struct tegra_usb_phy *phy) static int utmi_phy_power_off(struct tegra_usb_phy *phy) { - unsigned long val; void __iomem *base = phy->regs; + unsigned long val; utmi_phy_clk_disable(phy); @@ -614,8 +632,8 @@ static int utmi_phy_power_off(struct tegra_usb_phy *phy) static void utmi_phy_preresume(struct tegra_usb_phy *phy) { - unsigned long val; void __iomem *base = phy->regs; + unsigned long val; val = readl(base + UTMIP_TX_CFG0); val |= UTMIP_HS_DISCON_DISABLE; @@ -624,8 +642,8 @@ static void utmi_phy_preresume(struct tegra_usb_phy *phy) static void utmi_phy_postresume(struct tegra_usb_phy *phy) { - unsigned long val; void __iomem *base = phy->regs; + unsigned long val; val = readl(base + UTMIP_TX_CFG0); val &= ~UTMIP_HS_DISCON_DISABLE; @@ -635,8 +653,8 @@ static void utmi_phy_postresume(struct tegra_usb_phy *phy) static void utmi_phy_restore_start(struct tegra_usb_phy *phy, enum tegra_usb_phy_port_speed port_speed) { - unsigned long val; void __iomem *base = phy->regs; + unsigned long val; val = readl(base + UTMIP_MISC_CFG0); val &= ~UTMIP_DPDM_OBSERVE_SEL(~0); @@ -645,47 +663,52 @@ static void utmi_phy_restore_start(struct tegra_usb_phy *phy, else val |= UTMIP_DPDM_OBSERVE_SEL_FS_J; writel(val, base + UTMIP_MISC_CFG0); - udelay(1); + usleep_range(1, 10); val = readl(base + UTMIP_MISC_CFG0); val |= UTMIP_DPDM_OBSERVE; writel(val, base + UTMIP_MISC_CFG0); - udelay(10); + usleep_range(10, 100); } static void utmi_phy_restore_end(struct tegra_usb_phy *phy) { - unsigned long val; void __iomem *base = phy->regs; + unsigned long val; val = readl(base + UTMIP_MISC_CFG0); val &= ~UTMIP_DPDM_OBSERVE; writel(val, base + UTMIP_MISC_CFG0); - udelay(10); + usleep_range(10, 100); } static int ulpi_phy_power_on(struct tegra_usb_phy *phy) { - int ret; - unsigned long val; void __iomem *base = phy->regs; + unsigned long val; + int err; - ret = gpio_direction_output(phy->reset_gpio, 0); - if (ret < 0) { + err = gpio_direction_output(phy->reset_gpio, 0); + if (err) { dev_err(phy->u_phy.dev, "GPIO %d not set to 0: %d\n", - phy->reset_gpio, ret); - return ret; + phy->reset_gpio, err); + return err; } - msleep(5); - ret = gpio_direction_output(phy->reset_gpio, 1); - if (ret < 0) { + + err = clk_prepare_enable(phy->clk); + if (err) + return err; + + usleep_range(5000, 6000); + + err = gpio_direction_output(phy->reset_gpio, 1); + if (err) { dev_err(phy->u_phy.dev, "GPIO %d not set to 1: %d\n", - phy->reset_gpio, ret); - return ret; + phy->reset_gpio, err); + goto disable_clk; } - clk_prepare_enable(phy->clk); - msleep(1); + usleep_range(1000, 2000); val = readl(base + USB_SUSP_CTRL); val |= UHSIC_RESET; @@ -706,7 +729,7 @@ static int ulpi_phy_power_on(struct tegra_usb_phy *phy) val |= ULPI_STPDIRNXT_TRIMMER_SEL(4); val |= ULPI_DIR_TRIMMER_SEL(4); writel(val, base + ULPI_TIMING_CTRL_1); - udelay(10); + usleep_range(10, 100); val |= ULPI_DATA_TRIMMER_LOAD; val |= ULPI_STPDIRNXT_TRIMMER_LOAD; @@ -714,28 +737,33 @@ static int ulpi_phy_power_on(struct tegra_usb_phy *phy) writel(val, base + ULPI_TIMING_CTRL_1); /* Fix VbusInvalid due to floating VBUS */ - ret = usb_phy_io_write(phy->ulpi, 0x40, 0x08); - if (ret) { - dev_err(phy->u_phy.dev, "ULPI write failed: %d\n", ret); - return ret; + err = usb_phy_io_write(phy->ulpi, 0x40, 0x08); + if (err) { + dev_err(phy->u_phy.dev, "ULPI write failed: %d\n", err); + goto disable_clk; } - ret = usb_phy_io_write(phy->ulpi, 0x80, 0x0B); - if (ret) { - dev_err(phy->u_phy.dev, "ULPI write failed: %d\n", ret); - return ret; + err = usb_phy_io_write(phy->ulpi, 0x80, 0x0B); + if (err) { + dev_err(phy->u_phy.dev, "ULPI write failed: %d\n", err); + goto disable_clk; } val = readl(base + USB_SUSP_CTRL); val |= USB_SUSP_CLR; writel(val, base + USB_SUSP_CTRL); - udelay(100); + usleep_range(100, 1000); val = readl(base + USB_SUSP_CTRL); val &= ~USB_SUSP_CLR; writel(val, base + USB_SUSP_CTRL); return 0; + +disable_clk: + clk_disable_unprepare(phy->clk); + + return err; } static int ulpi_phy_power_off(struct tegra_usb_phy *phy) @@ -795,8 +823,7 @@ static int tegra_usb_phy_power_off(struct tegra_usb_phy *phy) static void tegra_usb_phy_shutdown(struct usb_phy *u_phy) { - struct tegra_usb_phy *phy = container_of(u_phy, struct tegra_usb_phy, - u_phy); + struct tegra_usb_phy *phy = to_tegra_usb_phy(u_phy); if (WARN_ON(!phy->freq)) return; @@ -814,9 +841,9 @@ static void tegra_usb_phy_shutdown(struct usb_phy *u_phy) phy->freq = NULL; } -static int tegra_usb_phy_set_suspend(struct usb_phy *x, int suspend) +static int tegra_usb_phy_set_suspend(struct usb_phy *u_phy, int suspend) { - struct tegra_usb_phy *phy = container_of(x, struct tegra_usb_phy, u_phy); + struct tegra_usb_phy *phy = to_tegra_usb_phy(u_phy); if (WARN_ON(!phy->freq)) return -EINVAL; @@ -832,7 +859,7 @@ static int ulpi_open(struct tegra_usb_phy *phy) int err; err = gpio_direction_output(phy->reset_gpio, 0); - if (err < 0) { + if (err) { dev_err(phy->u_phy.dev, "ULPI reset GPIO %d direction not asserted: %d\n", phy->reset_gpio, err); @@ -844,10 +871,9 @@ static int ulpi_open(struct tegra_usb_phy *phy) static int tegra_usb_phy_init(struct usb_phy *u_phy) { - struct tegra_usb_phy *phy = container_of(u_phy, struct tegra_usb_phy, - u_phy); + struct tegra_usb_phy *phy = to_tegra_usb_phy(u_phy); unsigned long parent_rate; - int i; + unsigned int i; int err; if (WARN_ON(phy->freq)) @@ -885,7 +911,7 @@ static int tegra_usb_phy_init(struct usb_phy *u_phy) err = ulpi_open(phy); else err = utmip_pad_open(phy); - if (err < 0) + if (err) goto fail; err = tegra_usb_phy_power_on(phy); @@ -905,37 +931,37 @@ static int tegra_usb_phy_init(struct usb_phy *u_phy) return err; } -void tegra_usb_phy_preresume(struct usb_phy *x) +void tegra_usb_phy_preresume(struct usb_phy *u_phy) { - struct tegra_usb_phy *phy = container_of(x, struct tegra_usb_phy, u_phy); + struct tegra_usb_phy *phy = to_tegra_usb_phy(u_phy); if (!phy->is_ulpi_phy) utmi_phy_preresume(phy); } EXPORT_SYMBOL_GPL(tegra_usb_phy_preresume); -void tegra_usb_phy_postresume(struct usb_phy *x) +void tegra_usb_phy_postresume(struct usb_phy *u_phy) { - struct tegra_usb_phy *phy = container_of(x, struct tegra_usb_phy, u_phy); + struct tegra_usb_phy *phy = to_tegra_usb_phy(u_phy); if (!phy->is_ulpi_phy) utmi_phy_postresume(phy); } EXPORT_SYMBOL_GPL(tegra_usb_phy_postresume); -void tegra_ehci_phy_restore_start(struct usb_phy *x, - enum tegra_usb_phy_port_speed port_speed) +void tegra_ehci_phy_restore_start(struct usb_phy *u_phy, + enum tegra_usb_phy_port_speed port_speed) { - struct tegra_usb_phy *phy = container_of(x, struct tegra_usb_phy, u_phy); + struct tegra_usb_phy *phy = to_tegra_usb_phy(u_phy); if (!phy->is_ulpi_phy) utmi_phy_restore_start(phy, port_speed); } EXPORT_SYMBOL_GPL(tegra_ehci_phy_restore_start); -void tegra_ehci_phy_restore_end(struct usb_phy *x) +void tegra_ehci_phy_restore_end(struct usb_phy *u_phy) { - struct tegra_usb_phy *phy = container_of(x, struct tegra_usb_phy, u_phy); + struct tegra_usb_phy *phy = to_tegra_usb_phy(u_phy); if (!phy->is_ulpi_phy) utmi_phy_restore_end(phy); @@ -946,21 +972,25 @@ static int read_utmi_param(struct platform_device *pdev, const char *param, u8 *dest) { u32 value; - int err = of_property_read_u32(pdev->dev.of_node, param, &value); - *dest = (u8)value; - if (err < 0) + int err; + + err = of_property_read_u32(pdev->dev.of_node, param, &value); + if (err) dev_err(&pdev->dev, "Failed to read USB UTMI parameter %s: %d\n", param, err); + else + *dest = value; + return err; } static int utmi_phy_probe(struct tegra_usb_phy *tegra_phy, struct platform_device *pdev) { + struct tegra_utmip_config *config; struct resource *res; int err; - struct tegra_utmip_config *config; tegra_phy->is_ulpi_phy = false; @@ -971,7 +1001,7 @@ static int utmi_phy_probe(struct tegra_usb_phy *tegra_phy, } tegra_phy->pad_regs = devm_ioremap(&pdev->dev, res->start, - resource_size(res)); + resource_size(res)); if (!tegra_phy->pad_regs) { dev_err(&pdev->dev, "Failed to remap UTMI pad regs\n"); return -ENOMEM; @@ -985,49 +1015,49 @@ static int utmi_phy_probe(struct tegra_usb_phy *tegra_phy, config = tegra_phy->config; err = read_utmi_param(pdev, "nvidia,hssync-start-delay", - &config->hssync_start_delay); - if (err < 0) + &config->hssync_start_delay); + if (err) return err; err = read_utmi_param(pdev, "nvidia,elastic-limit", - &config->elastic_limit); - if (err < 0) + &config->elastic_limit); + if (err) return err; err = read_utmi_param(pdev, "nvidia,idle-wait-delay", - &config->idle_wait_delay); - if (err < 0) + &config->idle_wait_delay); + if (err) return err; err = read_utmi_param(pdev, "nvidia,term-range-adj", - &config->term_range_adj); - if (err < 0) + &config->term_range_adj); + if (err) return err; err = read_utmi_param(pdev, "nvidia,xcvr-lsfslew", - &config->xcvr_lsfslew); - if (err < 0) + &config->xcvr_lsfslew); + if (err) return err; err = read_utmi_param(pdev, "nvidia,xcvr-lsrslew", - &config->xcvr_lsrslew); - if (err < 0) + &config->xcvr_lsrslew); + if (err) return err; if (tegra_phy->soc_config->requires_extra_tuning_parameters) { err = read_utmi_param(pdev, "nvidia,xcvr-hsslew", - &config->xcvr_hsslew); - if (err < 0) + &config->xcvr_hsslew); + if (err) return err; err = read_utmi_param(pdev, "nvidia,hssquelch-level", - &config->hssquelch_level); - if (err < 0) + &config->hssquelch_level); + if (err) return err; err = read_utmi_param(pdev, "nvidia,hsdiscon-level", - &config->hsdiscon_level); - if (err < 0) + &config->hsdiscon_level); + if (err) return err; } @@ -1036,8 +1066,8 @@ static int utmi_phy_probe(struct tegra_usb_phy *tegra_phy, if (!config->xcvr_setup_use_fuses) { err = read_utmi_param(pdev, "nvidia,xcvr-setup", - &config->xcvr_setup); - if (err < 0) + &config->xcvr_setup); + if (err) return err; } @@ -1067,23 +1097,18 @@ MODULE_DEVICE_TABLE(of, tegra_usb_phy_id_table); static int tegra_usb_phy_probe(struct platform_device *pdev) { - const struct of_device_id *match; - struct resource *res; - struct tegra_usb_phy *tegra_phy = NULL; struct device_node *np = pdev->dev.of_node; + struct tegra_usb_phy *tegra_phy; enum usb_phy_interface phy_type; + struct reset_control *reset; + struct resource *res; int err; tegra_phy = devm_kzalloc(&pdev->dev, sizeof(*tegra_phy), GFP_KERNEL); if (!tegra_phy) return -ENOMEM; - match = of_match_device(tegra_usb_phy_id_table, &pdev->dev); - if (!match) { - dev_err(&pdev->dev, "Error: No device match found\n"); - return -ENODEV; - } - tegra_phy->soc_config = match->data; + tegra_phy->soc_config = of_device_get_match_data(&pdev->dev); res = platform_get_resource(pdev, IORESOURCE_MEM, 0); if (!res) { @@ -1092,7 +1117,7 @@ static int tegra_usb_phy_probe(struct platform_device *pdev) } tegra_phy->regs = devm_ioremap(&pdev->dev, res->start, - resource_size(res)); + resource_size(res)); if (!tegra_phy->regs) { dev_err(&pdev->dev, "Failed to remap I/O memory\n"); return -ENOMEM; @@ -1101,33 +1126,6 @@ static int tegra_usb_phy_probe(struct platform_device *pdev) tegra_phy->is_legacy_phy = of_property_read_bool(np, "nvidia,has-legacy-mode"); - phy_type = of_usb_get_phy_mode(np); - switch (phy_type) { - case USBPHY_INTERFACE_MODE_UTMI: - err = utmi_phy_probe(tegra_phy, pdev); - if (err < 0) - return err; - break; - - case USBPHY_INTERFACE_MODE_ULPI: - tegra_phy->is_ulpi_phy = true; - - tegra_phy->reset_gpio = - of_get_named_gpio(np, "nvidia,phy-reset-gpio", 0); - if (!gpio_is_valid(tegra_phy->reset_gpio)) { - dev_err(&pdev->dev, - "Invalid GPIO: %d\n", tegra_phy->reset_gpio); - return tegra_phy->reset_gpio; - } - tegra_phy->config = NULL; - break; - - default: - dev_err(&pdev->dev, "phy_type %u is invalid or unsupported\n", - phy_type); - return -EINVAL; - } - if (of_find_property(np, "dr_mode", NULL)) tegra_phy->mode = usb_get_dr_mode(&pdev->dev); else @@ -1155,7 +1153,44 @@ static int tegra_usb_phy_probe(struct platform_device *pdev) return err; } - if (tegra_phy->is_ulpi_phy) { + phy_type = of_usb_get_phy_mode(np); + switch (phy_type) { + case USBPHY_INTERFACE_MODE_UTMI: + err = utmi_phy_probe(tegra_phy, pdev); + if (err) + return err; + + tegra_phy->pad_clk = devm_clk_get(&pdev->dev, "utmi-pads"); + err = PTR_ERR_OR_ZERO(tegra_phy->pad_clk); + if (err) { + dev_err(&pdev->dev, + "Failed to get UTMIP pad clock: %d\n", err); + return err; + } + + reset = devm_reset_control_get_optional_shared(&pdev->dev, + "utmi-pads"); + err = PTR_ERR_OR_ZERO(reset); + if (err) { + dev_err(&pdev->dev, + "Failed to get UTMI-pads reset: %d\n", err); + return err; + } + tegra_phy->pad_rst = reset; + break; + + case USBPHY_INTERFACE_MODE_ULPI: + tegra_phy->is_ulpi_phy = true; + + tegra_phy->reset_gpio = + of_get_named_gpio(np, "nvidia,phy-reset-gpio", 0); + + if (!gpio_is_valid(tegra_phy->reset_gpio)) { + dev_err(&pdev->dev, + "Invalid GPIO: %d\n", tegra_phy->reset_gpio); + return tegra_phy->reset_gpio; + } + tegra_phy->clk = devm_clk_get(&pdev->dev, "ulpi-link"); err = PTR_ERR_OR_ZERO(tegra_phy->clk); if (err) { @@ -1165,8 +1200,8 @@ static int tegra_usb_phy_probe(struct platform_device *pdev) } err = devm_gpio_request(&pdev->dev, tegra_phy->reset_gpio, - "ulpi_phy_reset_b"); - if (err < 0) { + "ulpi_phy_reset_b"); + if (err) { dev_err(&pdev->dev, "Request failed for GPIO %d: %d\n", tegra_phy->reset_gpio, err); return err; @@ -1175,28 +1210,16 @@ static int tegra_usb_phy_probe(struct platform_device *pdev) tegra_phy->ulpi = otg_ulpi_create(&ulpi_viewport_access_ops, 0); if (!tegra_phy->ulpi) { dev_err(&pdev->dev, "Failed to create ULPI OTG\n"); - err = -ENOMEM; - return err; + return -ENOMEM; } tegra_phy->ulpi->io_priv = tegra_phy->regs + ULPI_VIEWPORT; - } else { - tegra_phy->pad_clk = devm_clk_get(&pdev->dev, "utmi-pads"); - err = PTR_ERR_OR_ZERO(tegra_phy->pad_clk); - if (err) { - dev_err(&pdev->dev, - "Failed to get UTMIP pad clock: %d\n", err); - return err; - } + break; - tegra_phy->pad_rst = devm_reset_control_get_optional_shared( - &pdev->dev, "utmi-pads"); - err = PTR_ERR_OR_ZERO(tegra_phy->pad_rst); - if (err) { - dev_err(&pdev->dev, - "Failed to get UTMI-pads reset: %d\n", err); - return err; - } + default: + dev_err(&pdev->dev, "phy_type %u is invalid or unsupported\n", + phy_type); + return -EINVAL; } tegra_phy->u_phy.dev = &pdev->dev; @@ -1207,7 +1230,7 @@ static int tegra_usb_phy_probe(struct platform_device *pdev) platform_set_drvdata(pdev, tegra_phy); err = usb_add_phy_dev(&tegra_phy->u_phy); - if (err < 0) + if (err) goto free_ulpi; return 0; From patchwork Mon Jan 6 01:34:03 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Osipenko X-Patchwork-Id: 11318621 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 7F9331398 for ; Mon, 6 Jan 2020 01:34:53 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 5DD92217F4 for ; Mon, 6 Jan 2020 01:34:53 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="mnpcRc2A" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727426AbgAFBev (ORCPT ); Sun, 5 Jan 2020 20:34:51 -0500 Received: from mail-lj1-f193.google.com ([209.85.208.193]:45999 "EHLO mail-lj1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727386AbgAFBet (ORCPT ); Sun, 5 Jan 2020 20:34:49 -0500 Received: by mail-lj1-f193.google.com with SMTP id j26so49278864ljc.12; Sun, 05 Jan 2020 17:34:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=d+M+D7s06jXgSbN4ZI5MC1X7Q1YDI/iTue4S1s8hLAk=; b=mnpcRc2A1gfrgNJaoDcUskw3FIkQhKyqH0uO1xhvrCt8ttyysBW0WeLGOmBzDoD6if hKwHN8Rb0yq2YrFOeehF8t56LcgP1Erqc8hrvNgp1atT0h3/0QnK4ZU3a2aln2mfkQ9G Oh/3H3b5A1SfkYsU83SoeVZY77fmCH0B18qQQDR7QE0EXhZB4rGfdIQz7J1J8BrxDKYx 4k8b2l7x0k83wwl/T1YO1boUM9RE4C7EVCApSGr87zKv2Eix96O5ErkhYIQzz+yYxvy8 +YAzZEDZMg3JlRDPRumiNssoWxbR+BLIDwkzjs0DUr/jSD8bV69BO55aTgPsQUJq7uc/ 8lcQ== 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=d+M+D7s06jXgSbN4ZI5MC1X7Q1YDI/iTue4S1s8hLAk=; b=jXduwq1Y0M8KzfqKJGtglANhKl0W6bGp0/xYAuCiZFXUWCoBOd4Uyh3LjRBwYD/Ncz Y2SgGq4AFHIA2gdS0Tq4tgEUoMkSLpgcLh6l5KiIS2bndOUhzHcu9EYZznrZVFbF/J/9 XRy7PHDpLX+PiSAuI4mT24bk5mAnvtCD718VzXqm6jHh4KCGiKh2a0FiIGz63HAexOcW oHsxpKe2wlMMlUsnHM1KYe94JCRYKVX+kkieNi1tA43/KDKotJTVP0smNwmc8uX+A3E3 QoaGTYiDWZUH2aWgQ6szr+1s2zfRbQckKF3j6bY/5lBHvtPS3zjNkImJs8pg+XSx/PK8 ciOg== X-Gm-Message-State: APjAAAXkvh9SvvSlpwMDhnMsTdZmvHxdFud4iTyNtihij0ZPO147Iaru qOpWbo9IQxS6kqqHhM1B9bI= X-Google-Smtp-Source: APXvYqxNisSENks7sCdkMmDVjD1IWcirOI/Rk+sIrVJNy8oOywjSiwcn4bfBn6SwKR6SUsbns/x8WA== X-Received: by 2002:a2e:88c4:: with SMTP id a4mr10684183ljk.174.1578274487319; Sun, 05 Jan 2020 17:34:47 -0800 (PST) Received: from localhost.localdomain (79-139-233-37.dynamic.spd-mgts.ru. [79.139.233.37]) by smtp.gmail.com with ESMTPSA id h10sm28235739ljc.39.2020.01.05.17.34.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 05 Jan 2020 17:34:46 -0800 (PST) From: Dmitry Osipenko To: Greg Kroah-Hartman , Peter Chen , Thierry Reding , Jonathan Hunter , Felipe Balbi , =?utf-8?b?TWljaGHFgiBNaXJvc8WCYXc=?= Cc: linux-usb@vger.kernel.org, linux-tegra@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v4 07/20] usb: phy: tegra: Clean up included headers Date: Mon, 6 Jan 2020 04:34:03 +0300 Message-Id: <20200106013416.9604-8-digetx@gmail.com> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20200106013416.9604-1-digetx@gmail.com> References: <20200106013416.9604-1-digetx@gmail.com> MIME-Version: 1.0 Sender: linux-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org Add "spinlock.h", which was included indirectly, and sort includes in alphabet order. Signed-off-by: Dmitry Osipenko --- drivers/usb/phy/phy-tegra-usb.c | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/drivers/usb/phy/phy-tegra-usb.c b/drivers/usb/phy/phy-tegra-usb.c index c045f44ea964..aca1413db0ed 100644 --- a/drivers/usb/phy/phy-tegra-usb.c +++ b/drivers/usb/phy/phy-tegra-usb.c @@ -9,24 +9,26 @@ * Venu Byravarasu */ -#include #include -#include #include #include -#include -#include -#include #include +#include +#include #include #include #include -#include -#include -#include +#include +#include +#include +#include + +#include + #include +#include #include -#include +#include #define ULPI_VIEWPORT 0x170 From patchwork Mon Jan 6 01:34:04 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Osipenko X-Patchwork-Id: 11318647 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 4A7411398 for ; Mon, 6 Jan 2020 01:35:57 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 1515E222C4 for ; Mon, 6 Jan 2020 01:35:57 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="ZqQlt45l" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727593AbgAFBfr (ORCPT ); Sun, 5 Jan 2020 20:35:47 -0500 Received: from mail-lj1-f194.google.com ([209.85.208.194]:43132 "EHLO mail-lj1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727401AbgAFBev (ORCPT ); Sun, 5 Jan 2020 20:34:51 -0500 Received: by mail-lj1-f194.google.com with SMTP id a13so49300414ljm.10; Sun, 05 Jan 2020 17:34:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=0lPFIE2YhwjdRtXxlwqUXK08bGmKBRD8obsZm8zslgU=; b=ZqQlt45lxrzHgsiWzQDDSCK88iIE2RmAmDaEvCa594R3KIFfDvlCMjZpsz9rc37Ef+ e+PDpfnWCHR5wLfnZEvQhPtbJXYdrxdeYdSEt3J8CexSl8ksJ/F+JKf2fMgg7JfuXVY2 /Bk20/8bKr4WskXV+y16MyNce/0SpqgE/rGbpS9EPUe4Me61NbqoWVu318ZUGSqj/X+Z EXkkMdrydsErvCdLvKDQhpw8Ae+ziUBlwMftuMD6HfXe2S5rlX/lUppiOu+9xLGDilZp v5+7P+f6+GOWjtLQT/O473k0qYs+zZgghfUDVWLGvRU93Cf2WjlWUynUAM3REECfAlo9 mOQw== 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=0lPFIE2YhwjdRtXxlwqUXK08bGmKBRD8obsZm8zslgU=; b=p7TBjdBF5Z2K7svQFegGBYAm4Amykgbs+ZXNVXg5KKLHaL2fCqiWTTZ4fb4DCG659d xYCowasZEofj+o7AB/lqPWmD7IVvjlJu0cHZdy5n5Z1qQFxZi+5CMUuS3tbmgydgnleL d24JwB53l8d/2Pw+53D5kv8bUO6GfhJYF69C5eyXgc4YFiAJbdrLeHG2STdvZndp4lqY zG7rkdZkTOTIK4M+y5A745jBb+Ppfkfl13KEdYWRpVjZka9RJqmQioI9QTFCI2WFbOZn zMXV00dyXFsUFAvw00UBY15yvx94wfvppVPZINmAjhq63oOpQP9UGvJncJGUPMeFNncV VR0w== X-Gm-Message-State: APjAAAVSiK1EakLpJN7RCPP59Kh9Sy4mqbx3FOvZUJP1Abn5kiOOh8/K MpgDnMVg5GcCoy/BH8TXjpo= X-Google-Smtp-Source: APXvYqxc0BrbGxJwdKnO3ylP/nAgDHevEpP+dldJykZQken2JKFUb4TryqXWR70Fw4zqTUCp4LOEkw== X-Received: by 2002:a2e:914d:: with SMTP id q13mr58633761ljg.198.1578274488239; Sun, 05 Jan 2020 17:34:48 -0800 (PST) Received: from localhost.localdomain (79-139-233-37.dynamic.spd-mgts.ru. [79.139.233.37]) by smtp.gmail.com with ESMTPSA id h10sm28235739ljc.39.2020.01.05.17.34.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 05 Jan 2020 17:34:47 -0800 (PST) From: Dmitry Osipenko To: Greg Kroah-Hartman , Peter Chen , Thierry Reding , Jonathan Hunter , Felipe Balbi , =?utf-8?b?TWljaGHFgiBNaXJvc8WCYXc=?= Cc: linux-usb@vger.kernel.org, linux-tegra@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v4 08/20] usb: phy: tegra: Use relaxed versions of readl/writel Date: Mon, 6 Jan 2020 04:34:04 +0300 Message-Id: <20200106013416.9604-9-digetx@gmail.com> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20200106013416.9604-1-digetx@gmail.com> References: <20200106013416.9604-1-digetx@gmail.com> MIME-Version: 1.0 Sender: linux-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org There is nothing to synchronize in regards to memory stores, thus all readl/writel occurrences in the code could be replaced with a relaxed versions, for consistency. Acked-by: Thierry Reding Signed-off-by: Dmitry Osipenko --- drivers/usb/phy/phy-tegra-usb.c | 195 ++++++++++++++++---------------- 1 file changed, 98 insertions(+), 97 deletions(-) diff --git a/drivers/usb/phy/phy-tegra-usb.c b/drivers/usb/phy/phy-tegra-usb.c index aca1413db0ed..268b9d9ce57e 100644 --- a/drivers/usb/phy/phy-tegra-usb.c +++ b/drivers/usb/phy/phy-tegra-usb.c @@ -207,15 +207,16 @@ static void set_pts(struct tegra_usb_phy *phy, u8 pts_val) unsigned long val; if (phy->soc_config->has_hostpc) { - val = readl(base + TEGRA_USB_HOSTPC1_DEVLC); + val = readl_relaxed(base + TEGRA_USB_HOSTPC1_DEVLC); val &= ~TEGRA_USB_HOSTPC1_DEVLC_PTS(~0); val |= TEGRA_USB_HOSTPC1_DEVLC_PTS(pts_val); - writel(val, base + TEGRA_USB_HOSTPC1_DEVLC); + writel_relaxed(val, base + TEGRA_USB_HOSTPC1_DEVLC); } else { - val = readl(base + TEGRA_USB_PORTSC1) & ~TEGRA_PORTSC1_RWC_BITS; + val = readl_relaxed(base + TEGRA_USB_PORTSC1); + val &= ~TEGRA_PORTSC1_RWC_BITS; val &= ~TEGRA_USB_PORTSC1_PTS(~0); val |= TEGRA_USB_PORTSC1_PTS(pts_val); - writel(val, base + TEGRA_USB_PORTSC1); + writel_relaxed(val, base + TEGRA_USB_PORTSC1); } } @@ -225,19 +226,19 @@ static void set_phcd(struct tegra_usb_phy *phy, bool enable) unsigned long val; if (phy->soc_config->has_hostpc) { - val = readl(base + TEGRA_USB_HOSTPC1_DEVLC); + val = readl_relaxed(base + TEGRA_USB_HOSTPC1_DEVLC); if (enable) val |= TEGRA_USB_HOSTPC1_DEVLC_PHCD; else val &= ~TEGRA_USB_HOSTPC1_DEVLC_PHCD; - writel(val, base + TEGRA_USB_HOSTPC1_DEVLC); + writel_relaxed(val, base + TEGRA_USB_HOSTPC1_DEVLC); } else { - val = readl(base + TEGRA_USB_PORTSC1) & ~PORT_RWC_BITS; + val = readl_relaxed(base + TEGRA_USB_PORTSC1) & ~PORT_RWC_BITS; if (enable) val |= TEGRA_USB_PORTSC1_PHCD; else val &= ~TEGRA_USB_PORTSC1_PHCD; - writel(val, base + TEGRA_USB_PORTSC1); + writel_relaxed(val, base + TEGRA_USB_PORTSC1); } } @@ -319,7 +320,7 @@ static int utmip_pad_power_on(struct tegra_usb_phy *phy) spin_lock_irqsave(&utmip_pad_lock, flags); if (utmip_pad_count++ == 0) { - val = readl(base + UTMIP_BIAS_CFG0); + val = readl_relaxed(base + UTMIP_BIAS_CFG0); val &= ~(UTMIP_OTGPD | UTMIP_BIASPD); if (phy->soc_config->requires_extra_tuning_parameters) { @@ -331,7 +332,7 @@ static int utmip_pad_power_on(struct tegra_usb_phy *phy) val |= UTMIP_HSDISCON_LEVEL(config->hsdiscon_level); val |= UTMIP_HSDISCON_LEVEL_MSB(config->hsdiscon_level); } - writel(val, base + UTMIP_BIAS_CFG0); + writel_relaxed(val, base + UTMIP_BIAS_CFG0); } spin_unlock_irqrestore(&utmip_pad_lock, flags); @@ -359,9 +360,9 @@ static int utmip_pad_power_off(struct tegra_usb_phy *phy) spin_lock_irqsave(&utmip_pad_lock, flags); if (--utmip_pad_count == 0) { - val = readl(base + UTMIP_BIAS_CFG0); + val = readl_relaxed(base + UTMIP_BIAS_CFG0); val |= UTMIP_OTGPD | UTMIP_BIASPD; - writel(val, base + UTMIP_BIAS_CFG0); + writel_relaxed(val, base + UTMIP_BIAS_CFG0); } spin_unlock_irqrestore(&utmip_pad_lock, flags); @@ -375,8 +376,8 @@ static int utmi_wait_register(void __iomem *reg, u32 mask, u32 result) { u32 tmp; - return readl_poll_timeout(reg, tmp, (tmp & mask) == result, - 2000, 6000); + return readl_relaxed_poll_timeout(reg, tmp, (tmp & mask) == result, + 2000, 6000); } static void utmi_phy_clk_disable(struct tegra_usb_phy *phy) @@ -393,15 +394,15 @@ static void utmi_phy_clk_disable(struct tegra_usb_phy *phy) return; if (phy->is_legacy_phy) { - val = readl(base + USB_SUSP_CTRL); + val = readl_relaxed(base + USB_SUSP_CTRL); val |= USB_SUSP_SET; - writel(val, base + USB_SUSP_CTRL); + writel_relaxed(val, base + USB_SUSP_CTRL); usleep_range(10, 100); - val = readl(base + USB_SUSP_CTRL); + val = readl_relaxed(base + USB_SUSP_CTRL); val &= ~USB_SUSP_SET; - writel(val, base + USB_SUSP_CTRL); + writel_relaxed(val, base + USB_SUSP_CTRL); } else { set_phcd(phy, true); } @@ -426,15 +427,15 @@ static void utmi_phy_clk_enable(struct tegra_usb_phy *phy) return; if (phy->is_legacy_phy) { - val = readl(base + USB_SUSP_CTRL); + val = readl_relaxed(base + USB_SUSP_CTRL); val |= USB_SUSP_CLR; - writel(val, base + USB_SUSP_CTRL); + writel_relaxed(val, base + USB_SUSP_CTRL); usleep_range(10, 100); - val = readl(base + USB_SUSP_CTRL); + val = readl_relaxed(base + USB_SUSP_CTRL); val &= ~USB_SUSP_CLR; - writel(val, base + USB_SUSP_CTRL); + writel_relaxed(val, base + USB_SUSP_CTRL); } else { set_phcd(phy, false); } @@ -452,75 +453,75 @@ static int utmi_phy_power_on(struct tegra_usb_phy *phy) unsigned long val; int err; - val = readl(base + USB_SUSP_CTRL); + val = readl_relaxed(base + USB_SUSP_CTRL); val |= UTMIP_RESET; - writel(val, base + USB_SUSP_CTRL); + writel_relaxed(val, base + USB_SUSP_CTRL); if (phy->is_legacy_phy) { - val = readl(base + USB1_LEGACY_CTRL); + val = readl_relaxed(base + USB1_LEGACY_CTRL); val |= USB1_NO_LEGACY_MODE; - writel(val, base + USB1_LEGACY_CTRL); + writel_relaxed(val, base + USB1_LEGACY_CTRL); } - val = readl(base + UTMIP_TX_CFG0); + val = readl_relaxed(base + UTMIP_TX_CFG0); val |= UTMIP_FS_PREABMLE_J; - writel(val, base + UTMIP_TX_CFG0); + writel_relaxed(val, base + UTMIP_TX_CFG0); - val = readl(base + UTMIP_HSRX_CFG0); + val = readl_relaxed(base + UTMIP_HSRX_CFG0); val &= ~(UTMIP_IDLE_WAIT(~0) | UTMIP_ELASTIC_LIMIT(~0)); val |= UTMIP_IDLE_WAIT(config->idle_wait_delay); val |= UTMIP_ELASTIC_LIMIT(config->elastic_limit); - writel(val, base + UTMIP_HSRX_CFG0); + writel_relaxed(val, base + UTMIP_HSRX_CFG0); - val = readl(base + UTMIP_HSRX_CFG1); + val = readl_relaxed(base + UTMIP_HSRX_CFG1); val &= ~UTMIP_HS_SYNC_START_DLY(~0); val |= UTMIP_HS_SYNC_START_DLY(config->hssync_start_delay); - writel(val, base + UTMIP_HSRX_CFG1); + writel_relaxed(val, base + UTMIP_HSRX_CFG1); - val = readl(base + UTMIP_DEBOUNCE_CFG0); + val = readl_relaxed(base + UTMIP_DEBOUNCE_CFG0); val &= ~UTMIP_BIAS_DEBOUNCE_A(~0); val |= UTMIP_BIAS_DEBOUNCE_A(phy->freq->debounce); - writel(val, base + UTMIP_DEBOUNCE_CFG0); + writel_relaxed(val, base + UTMIP_DEBOUNCE_CFG0); - val = readl(base + UTMIP_MISC_CFG0); + val = readl_relaxed(base + UTMIP_MISC_CFG0); val &= ~UTMIP_SUSPEND_EXIT_ON_EDGE; - writel(val, base + UTMIP_MISC_CFG0); + writel_relaxed(val, base + UTMIP_MISC_CFG0); if (!phy->soc_config->utmi_pll_config_in_car_module) { - val = readl(base + UTMIP_MISC_CFG1); + val = readl_relaxed(base + UTMIP_MISC_CFG1); val &= ~(UTMIP_PLL_ACTIVE_DLY_COUNT(~0) | UTMIP_PLLU_STABLE_COUNT(~0)); val |= UTMIP_PLL_ACTIVE_DLY_COUNT(phy->freq->active_delay) | UTMIP_PLLU_STABLE_COUNT(phy->freq->stable_count); - writel(val, base + UTMIP_MISC_CFG1); + writel_relaxed(val, base + UTMIP_MISC_CFG1); - val = readl(base + UTMIP_PLL_CFG1); + val = readl_relaxed(base + UTMIP_PLL_CFG1); val &= ~(UTMIP_XTAL_FREQ_COUNT(~0) | UTMIP_PLLU_ENABLE_DLY_COUNT(~0)); val |= UTMIP_XTAL_FREQ_COUNT(phy->freq->xtal_freq_count) | UTMIP_PLLU_ENABLE_DLY_COUNT(phy->freq->enable_delay); - writel(val, base + UTMIP_PLL_CFG1); + writel_relaxed(val, base + UTMIP_PLL_CFG1); } if (phy->mode == USB_DR_MODE_PERIPHERAL) { - val = readl(base + USB_SUSP_CTRL); + val = readl_relaxed(base + USB_SUSP_CTRL); val &= ~(USB_WAKE_ON_CNNT_EN_DEV | USB_WAKE_ON_DISCON_EN_DEV); - writel(val, base + USB_SUSP_CTRL); + writel_relaxed(val, base + USB_SUSP_CTRL); - val = readl(base + UTMIP_BAT_CHRG_CFG0); + val = readl_relaxed(base + UTMIP_BAT_CHRG_CFG0); val &= ~UTMIP_PD_CHRG; - writel(val, base + UTMIP_BAT_CHRG_CFG0); + writel_relaxed(val, base + UTMIP_BAT_CHRG_CFG0); } else { - val = readl(base + UTMIP_BAT_CHRG_CFG0); + val = readl_relaxed(base + UTMIP_BAT_CHRG_CFG0); val |= UTMIP_PD_CHRG; - writel(val, base + UTMIP_BAT_CHRG_CFG0); + writel_relaxed(val, base + UTMIP_BAT_CHRG_CFG0); } err = utmip_pad_power_on(phy); if (err) return err; - val = readl(base + UTMIP_XCVR_CFG0); + val = readl_relaxed(base + UTMIP_XCVR_CFG0); val &= ~(UTMIP_FORCE_PD_POWERDOWN | UTMIP_FORCE_PD2_POWERDOWN | UTMIP_FORCE_PDZI_POWERDOWN | UTMIP_XCVR_LSBIAS_SEL | UTMIP_XCVR_SETUP(~0) | UTMIP_XCVR_SETUP_MSB(~0) | @@ -538,57 +539,57 @@ static int utmi_phy_power_on(struct tegra_usb_phy *phy) val |= UTMIP_XCVR_HSSLEW(config->xcvr_hsslew); val |= UTMIP_XCVR_HSSLEW_MSB(config->xcvr_hsslew); } - writel(val, base + UTMIP_XCVR_CFG0); + writel_relaxed(val, base + UTMIP_XCVR_CFG0); - val = readl(base + UTMIP_XCVR_CFG1); + val = readl_relaxed(base + UTMIP_XCVR_CFG1); val &= ~(UTMIP_FORCE_PDDISC_POWERDOWN | UTMIP_FORCE_PDCHRP_POWERDOWN | UTMIP_FORCE_PDDR_POWERDOWN | UTMIP_XCVR_TERM_RANGE_ADJ(~0)); val |= UTMIP_XCVR_TERM_RANGE_ADJ(config->term_range_adj); - writel(val, base + UTMIP_XCVR_CFG1); + writel_relaxed(val, base + UTMIP_XCVR_CFG1); - val = readl(base + UTMIP_BIAS_CFG1); + val = readl_relaxed(base + UTMIP_BIAS_CFG1); val &= ~UTMIP_BIAS_PDTRK_COUNT(~0); val |= UTMIP_BIAS_PDTRK_COUNT(0x5); - writel(val, base + UTMIP_BIAS_CFG1); + writel_relaxed(val, base + UTMIP_BIAS_CFG1); - val = readl(base + UTMIP_SPARE_CFG0); + val = readl_relaxed(base + UTMIP_SPARE_CFG0); if (config->xcvr_setup_use_fuses) val |= FUSE_SETUP_SEL; else val &= ~FUSE_SETUP_SEL; - writel(val, base + UTMIP_SPARE_CFG0); + writel_relaxed(val, base + UTMIP_SPARE_CFG0); if (!phy->is_legacy_phy) { - val = readl(base + USB_SUSP_CTRL); + val = readl_relaxed(base + USB_SUSP_CTRL); val |= UTMIP_PHY_ENABLE; - writel(val, base + USB_SUSP_CTRL); + writel_relaxed(val, base + USB_SUSP_CTRL); } - val = readl(base + USB_SUSP_CTRL); + val = readl_relaxed(base + USB_SUSP_CTRL); val &= ~UTMIP_RESET; - writel(val, base + USB_SUSP_CTRL); + writel_relaxed(val, base + USB_SUSP_CTRL); if (phy->is_legacy_phy) { - val = readl(base + USB1_LEGACY_CTRL); + val = readl_relaxed(base + USB1_LEGACY_CTRL); val &= ~USB1_VBUS_SENSE_CTL_MASK; val |= USB1_VBUS_SENSE_CTL_A_SESS_VLD; - writel(val, base + USB1_LEGACY_CTRL); + writel_relaxed(val, base + USB1_LEGACY_CTRL); - val = readl(base + USB_SUSP_CTRL); + val = readl_relaxed(base + USB_SUSP_CTRL); val &= ~USB_SUSP_SET; - writel(val, base + USB_SUSP_CTRL); + writel_relaxed(val, base + USB_SUSP_CTRL); } utmi_phy_clk_enable(phy); if (phy->soc_config->requires_usbmode_setup) { - val = readl(base + USB_USBMODE); + val = readl_relaxed(base + USB_USBMODE); val &= ~USB_USBMODE_MASK; if (phy->mode == USB_DR_MODE_HOST) val |= USB_USBMODE_HOST; else val |= USB_USBMODE_DEVICE; - writel(val, base + USB_USBMODE); + writel_relaxed(val, base + USB_USBMODE); } if (!phy->is_legacy_phy) @@ -605,29 +606,29 @@ static int utmi_phy_power_off(struct tegra_usb_phy *phy) utmi_phy_clk_disable(phy); if (phy->mode == USB_DR_MODE_PERIPHERAL) { - val = readl(base + USB_SUSP_CTRL); + val = readl_relaxed(base + USB_SUSP_CTRL); val &= ~USB_WAKEUP_DEBOUNCE_COUNT(~0); val |= USB_WAKE_ON_CNNT_EN_DEV | USB_WAKEUP_DEBOUNCE_COUNT(5); - writel(val, base + USB_SUSP_CTRL); + writel_relaxed(val, base + USB_SUSP_CTRL); } - val = readl(base + USB_SUSP_CTRL); + val = readl_relaxed(base + USB_SUSP_CTRL); val |= UTMIP_RESET; - writel(val, base + USB_SUSP_CTRL); + writel_relaxed(val, base + USB_SUSP_CTRL); - val = readl(base + UTMIP_BAT_CHRG_CFG0); + val = readl_relaxed(base + UTMIP_BAT_CHRG_CFG0); val |= UTMIP_PD_CHRG; - writel(val, base + UTMIP_BAT_CHRG_CFG0); + writel_relaxed(val, base + UTMIP_BAT_CHRG_CFG0); - val = readl(base + UTMIP_XCVR_CFG0); + val = readl_relaxed(base + UTMIP_XCVR_CFG0); val |= UTMIP_FORCE_PD_POWERDOWN | UTMIP_FORCE_PD2_POWERDOWN | UTMIP_FORCE_PDZI_POWERDOWN; - writel(val, base + UTMIP_XCVR_CFG0); + writel_relaxed(val, base + UTMIP_XCVR_CFG0); - val = readl(base + UTMIP_XCVR_CFG1); + val = readl_relaxed(base + UTMIP_XCVR_CFG1); val |= UTMIP_FORCE_PDDISC_POWERDOWN | UTMIP_FORCE_PDCHRP_POWERDOWN | UTMIP_FORCE_PDDR_POWERDOWN; - writel(val, base + UTMIP_XCVR_CFG1); + writel_relaxed(val, base + UTMIP_XCVR_CFG1); return utmip_pad_power_off(phy); } @@ -637,9 +638,9 @@ static void utmi_phy_preresume(struct tegra_usb_phy *phy) void __iomem *base = phy->regs; unsigned long val; - val = readl(base + UTMIP_TX_CFG0); + val = readl_relaxed(base + UTMIP_TX_CFG0); val |= UTMIP_HS_DISCON_DISABLE; - writel(val, base + UTMIP_TX_CFG0); + writel_relaxed(val, base + UTMIP_TX_CFG0); } static void utmi_phy_postresume(struct tegra_usb_phy *phy) @@ -647,9 +648,9 @@ static void utmi_phy_postresume(struct tegra_usb_phy *phy) void __iomem *base = phy->regs; unsigned long val; - val = readl(base + UTMIP_TX_CFG0); + val = readl_relaxed(base + UTMIP_TX_CFG0); val &= ~UTMIP_HS_DISCON_DISABLE; - writel(val, base + UTMIP_TX_CFG0); + writel_relaxed(val, base + UTMIP_TX_CFG0); } static void utmi_phy_restore_start(struct tegra_usb_phy *phy, @@ -658,18 +659,18 @@ static void utmi_phy_restore_start(struct tegra_usb_phy *phy, void __iomem *base = phy->regs; unsigned long val; - val = readl(base + UTMIP_MISC_CFG0); + val = readl_relaxed(base + UTMIP_MISC_CFG0); val &= ~UTMIP_DPDM_OBSERVE_SEL(~0); if (port_speed == TEGRA_USB_PHY_PORT_SPEED_LOW) val |= UTMIP_DPDM_OBSERVE_SEL_FS_K; else val |= UTMIP_DPDM_OBSERVE_SEL_FS_J; - writel(val, base + UTMIP_MISC_CFG0); + writel_relaxed(val, base + UTMIP_MISC_CFG0); usleep_range(1, 10); - val = readl(base + UTMIP_MISC_CFG0); + val = readl_relaxed(base + UTMIP_MISC_CFG0); val |= UTMIP_DPDM_OBSERVE; - writel(val, base + UTMIP_MISC_CFG0); + writel_relaxed(val, base + UTMIP_MISC_CFG0); usleep_range(10, 100); } @@ -678,9 +679,9 @@ static void utmi_phy_restore_end(struct tegra_usb_phy *phy) void __iomem *base = phy->regs; unsigned long val; - val = readl(base + UTMIP_MISC_CFG0); + val = readl_relaxed(base + UTMIP_MISC_CFG0); val &= ~UTMIP_DPDM_OBSERVE; - writel(val, base + UTMIP_MISC_CFG0); + writel_relaxed(val, base + UTMIP_MISC_CFG0); usleep_range(10, 100); } @@ -712,31 +713,31 @@ static int ulpi_phy_power_on(struct tegra_usb_phy *phy) usleep_range(1000, 2000); - val = readl(base + USB_SUSP_CTRL); + val = readl_relaxed(base + USB_SUSP_CTRL); val |= UHSIC_RESET; - writel(val, base + USB_SUSP_CTRL); + writel_relaxed(val, base + USB_SUSP_CTRL); - val = readl(base + ULPI_TIMING_CTRL_0); + val = readl_relaxed(base + ULPI_TIMING_CTRL_0); val |= ULPI_OUTPUT_PINMUX_BYP | ULPI_CLKOUT_PINMUX_BYP; - writel(val, base + ULPI_TIMING_CTRL_0); + writel_relaxed(val, base + ULPI_TIMING_CTRL_0); - val = readl(base + USB_SUSP_CTRL); + val = readl_relaxed(base + USB_SUSP_CTRL); val |= ULPI_PHY_ENABLE; - writel(val, base + USB_SUSP_CTRL); + writel_relaxed(val, base + USB_SUSP_CTRL); val = 0; - writel(val, base + ULPI_TIMING_CTRL_1); + writel_relaxed(val, base + ULPI_TIMING_CTRL_1); val |= ULPI_DATA_TRIMMER_SEL(4); val |= ULPI_STPDIRNXT_TRIMMER_SEL(4); val |= ULPI_DIR_TRIMMER_SEL(4); - writel(val, base + ULPI_TIMING_CTRL_1); + writel_relaxed(val, base + ULPI_TIMING_CTRL_1); usleep_range(10, 100); val |= ULPI_DATA_TRIMMER_LOAD; val |= ULPI_STPDIRNXT_TRIMMER_LOAD; val |= ULPI_DIR_TRIMMER_LOAD; - writel(val, base + ULPI_TIMING_CTRL_1); + writel_relaxed(val, base + ULPI_TIMING_CTRL_1); /* Fix VbusInvalid due to floating VBUS */ err = usb_phy_io_write(phy->ulpi, 0x40, 0x08); @@ -751,14 +752,14 @@ static int ulpi_phy_power_on(struct tegra_usb_phy *phy) goto disable_clk; } - val = readl(base + USB_SUSP_CTRL); + val = readl_relaxed(base + USB_SUSP_CTRL); val |= USB_SUSP_CLR; - writel(val, base + USB_SUSP_CTRL); + writel_relaxed(val, base + USB_SUSP_CTRL); usleep_range(100, 1000); - val = readl(base + USB_SUSP_CTRL); + val = readl_relaxed(base + USB_SUSP_CTRL); val &= ~USB_SUSP_CLR; - writel(val, base + USB_SUSP_CTRL); + writel_relaxed(val, base + USB_SUSP_CTRL); return 0; From patchwork Mon Jan 6 01:34:05 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Osipenko X-Patchwork-Id: 11318645 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 93C5B1398 for ; Mon, 6 Jan 2020 01:35:55 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 73B4C218AC for ; Mon, 6 Jan 2020 01:35:55 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="WA025jnm" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727602AbgAFBfs (ORCPT ); Sun, 5 Jan 2020 20:35:48 -0500 Received: from mail-lj1-f194.google.com ([209.85.208.194]:38704 "EHLO mail-lj1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727409AbgAFBev (ORCPT ); Sun, 5 Jan 2020 20:34:51 -0500 Received: by mail-lj1-f194.google.com with SMTP id w1so27340288ljh.5; Sun, 05 Jan 2020 17:34:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=ye27YVubMaQCmULnB2LfyXuyZwZTDB68pe4TarEPntk=; b=WA025jnmWKPyv4ZKB8OL53qeQ+iQ47UlUTuh3ULmPKN/fkCypkqxR0BubI4FYlH7jz IeDUFHA2bx7nWXGLjnnGndq3Jw6ulG3F1326kgBQiwDN4g3kjBB+dZIN+eXs+TUZ9nzk s3FYb0BVWgBgM8L5TgYk3UXJCVjsyb2K1U+S3TOseuKFSOw/to59SniF0EHtYnWKNv2L qb5FaFbL6OSbA6WRoXUlvHLzQ9d6xY0f7kGFvUu8ysfw7VgUHkFAdf7gm7J6edHaaED6 b3xIgqoB+wz8JVNpX/fcmoIA58uuHWIVQULiaW0llIUWDldoEEypgY8meQAX4LEgBE62 n7dQ== 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=ye27YVubMaQCmULnB2LfyXuyZwZTDB68pe4TarEPntk=; b=Ed8pyDypQZaPoLdK5DFI/KLXrW1XM4uGGxeY3sgWI1mMq1Satr1ZrNhwyTeeliWK6w FxjwDNeYMs+7YqU56+x22povAzjdXkfZdd4O8k2Ql3BYwa74Kp9H6MuZrl6kzfLfjmmG QDRmIbkbL5yyWW+RpWmjl8+Az5Y18nZ5iuBo7PypEqQDLkK5YdrgR7tvusjfmIE9nz4v Ew1VSQhglpE9GK0GnixH4vO6nSjaGS2UGtj8vp+9xZS6rE3G3H0PlteJ8qc3cfiSeTA9 B1RwZ9tEh4uz3LWZlpCwYglgdoHAnDt16GA0khe89OFB+JaoTJpmJplbb2NwWxFjhvW5 BX4Q== X-Gm-Message-State: APjAAAVTwWOJNT6SkMgmx4MJz6nMpByp+TBfRf67JN4nD7tm/L+v49WW SN8Fj88meWSvtGNjwXwmoo8= X-Google-Smtp-Source: APXvYqx+v8E82hDHJwYGJQqND5KsevP6qp/z7xGihdr36NAiF8cmBwZ1PCNiLdp9NSKiT36OYQ/fnQ== X-Received: by 2002:a05:651c:1b0:: with SMTP id c16mr58300491ljn.236.1578274489097; Sun, 05 Jan 2020 17:34:49 -0800 (PST) Received: from localhost.localdomain (79-139-233-37.dynamic.spd-mgts.ru. [79.139.233.37]) by smtp.gmail.com with ESMTPSA id h10sm28235739ljc.39.2020.01.05.17.34.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 05 Jan 2020 17:34:48 -0800 (PST) From: Dmitry Osipenko To: Greg Kroah-Hartman , Peter Chen , Thierry Reding , Jonathan Hunter , Felipe Balbi , =?utf-8?b?TWljaGHFgiBNaXJvc8WCYXc=?= Cc: linux-usb@vger.kernel.org, linux-tegra@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v4 09/20] usb: phy: tegra: Use generic stub for a missing VBUS regulator Date: Mon, 6 Jan 2020 04:34:05 +0300 Message-Id: <20200106013416.9604-10-digetx@gmail.com> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20200106013416.9604-1-digetx@gmail.com> References: <20200106013416.9604-1-digetx@gmail.com> MIME-Version: 1.0 Sender: linux-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org Regulator core provides dummy regulator if device-tree doesn't define VBUS regulator. Signed-off-by: Dmitry Osipenko --- drivers/usb/phy/phy-tegra-usb.c | 28 +++++++++------------------- 1 file changed, 9 insertions(+), 19 deletions(-) diff --git a/drivers/usb/phy/phy-tegra-usb.c b/drivers/usb/phy/phy-tegra-usb.c index 268b9d9ce57e..5b9f031619c5 100644 --- a/drivers/usb/phy/phy-tegra-usb.c +++ b/drivers/usb/phy/phy-tegra-usb.c @@ -836,9 +836,7 @@ static void tegra_usb_phy_shutdown(struct usb_phy *u_phy) if (!phy->is_ulpi_phy) utmip_pad_close(phy); - if (!IS_ERR(phy->vbus)) - regulator_disable(phy->vbus); - + regulator_disable(phy->vbus); clk_disable_unprepare(phy->pll_u); phy->freq = NULL; @@ -900,14 +898,11 @@ static int tegra_usb_phy_init(struct usb_phy *u_phy) goto fail; } - if (!IS_ERR(phy->vbus)) { - err = regulator_enable(phy->vbus); - if (err) { - dev_err(phy->u_phy.dev, - "Failed to enable USB VBUS regulator: %d\n", - err); - goto fail; - } + err = regulator_enable(phy->vbus); + if (err) { + dev_err(phy->u_phy.dev, + "Failed to enable USB VBUS regulator: %d\n", err); + goto fail; } if (phy->is_ulpi_phy) @@ -1140,14 +1135,9 @@ static int tegra_usb_phy_probe(struct platform_device *pdev) } /* On some boards, the VBUS regulator doesn't need to be controlled */ - if (of_find_property(np, "vbus-supply", NULL)) { - tegra_phy->vbus = devm_regulator_get(&pdev->dev, "vbus"); - if (IS_ERR(tegra_phy->vbus)) - return PTR_ERR(tegra_phy->vbus); - } else { - dev_notice(&pdev->dev, "no vbus regulator"); - tegra_phy->vbus = ERR_PTR(-ENODEV); - } + tegra_phy->vbus = devm_regulator_get(&pdev->dev, "vbus"); + if (IS_ERR(tegra_phy->vbus)) + return PTR_ERR(tegra_phy->vbus); tegra_phy->pll_u = devm_clk_get(&pdev->dev, "pll_u"); err = PTR_ERR_OR_ZERO(tegra_phy->pll_u); From patchwork Mon Jan 6 01:34:06 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Osipenko X-Patchwork-Id: 11318643 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 80A25139A for ; Mon, 6 Jan 2020 01:35:46 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 5F5B7222C4 for ; Mon, 6 Jan 2020 01:35:46 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="skoNYfQB" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727438AbgAFBew (ORCPT ); Sun, 5 Jan 2020 20:34:52 -0500 Received: from mail-lj1-f195.google.com ([209.85.208.195]:46003 "EHLO mail-lj1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727416AbgAFBew (ORCPT ); Sun, 5 Jan 2020 20:34:52 -0500 Received: by mail-lj1-f195.google.com with SMTP id j26so49278930ljc.12; Sun, 05 Jan 2020 17:34:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Wfs/bL17FYKf1Oxn2bv75LBzwxXdI6zeR8Zv69vdpMc=; b=skoNYfQB9aw6uIo1m5pO29jw3TLOkx6/PFEz6X3LaooSQyx8CvTPElnSOWs9bIlKxY j3ebU1lfte2Ql8DiEd/KEurFjSKIQ9MbSKZ45xT0uInJNRWhjV9Kf3wTxYqyCDLODR4T rmy13XroRwNAWBEeRFhocXg8RZ1byVCNI0t8VkqQAhrZF2XWdQydZbAB6igKxVk8bYS/ Ce8nje6tDWhvzD48yrUTBhRzbhlVFUQQ6RTxFNcjyPpxTQVQ6IPQrboZlQrS+3sCsY9a psPN8ak/OBc6YrI/Ra4nYg8+0ZhvSY1lezMQJZtLlJFLqK/XcdW9Zjj2F0Sw4PXMwLJ6 jvpw== 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=Wfs/bL17FYKf1Oxn2bv75LBzwxXdI6zeR8Zv69vdpMc=; b=k0xNaHeyCuFVfuvDEl1RcgnGD4/XVXjC+JNBDPq3ycrOU/F+XoAqQw2/6QYN4R0vBZ Y2DdEsDfpYBrQDAEqNJyi3YgK9jlYcZhKhAGbdn1pD3MHSQ8nuHFesQhxmlY8W8agL63 pTmHg8n3rngn0Tkikph5rIMOYLGHmpvocEajV/8aUDjABFJXF1OnWl1vzjyK+/JJqO7G kpeFyJIppNfLT1+iMr4zxOMIy7zabVWW39pm9GexVfky7gt3ybiBC80qMQmsw349UPCh BXRtZ9MEhHPpgmAHrhmBKvqeJRIp2zZT/1TCDlET4SbX3raBSqK1ERrpPGvdwztKyikY nX1w== X-Gm-Message-State: APjAAAX51/YPLWNS0o2Ax25iodmdhs9I2RCKVmoR8NHJEPuO+QMRVrZL xDGwAZ3ZUfnDUIcttikOUX8= X-Google-Smtp-Source: APXvYqycE1ZQ18Rrg6fxV6Lw0fluWixV4+zNhF8W14Sl2geJhfHce4vVNsKe1zaOTGsA7dHG1TU93A== X-Received: by 2002:a2e:556:: with SMTP id 83mr60625433ljf.127.1578274489977; Sun, 05 Jan 2020 17:34:49 -0800 (PST) Received: from localhost.localdomain (79-139-233-37.dynamic.spd-mgts.ru. [79.139.233.37]) by smtp.gmail.com with ESMTPSA id h10sm28235739ljc.39.2020.01.05.17.34.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 05 Jan 2020 17:34:49 -0800 (PST) From: Dmitry Osipenko To: Greg Kroah-Hartman , Peter Chen , Thierry Reding , Jonathan Hunter , Felipe Balbi , =?utf-8?b?TWljaGHFgiBNaXJvc8WCYXc=?= Cc: linux-usb@vger.kernel.org, linux-tegra@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v4 10/20] usb: ulpi: Add resource-managed variant of otg_ulpi_create() Date: Mon, 6 Jan 2020 04:34:06 +0300 Message-Id: <20200106013416.9604-11-digetx@gmail.com> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20200106013416.9604-1-digetx@gmail.com> References: <20200106013416.9604-1-digetx@gmail.com> MIME-Version: 1.0 Sender: linux-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org Now drivers (like NVIDIA Tegra USB PHY for example) will be able to benefit from the resource-managed variant, making driver's code a bit cleaner. Suggested-by: Thierry Reding Signed-off-by: Dmitry Osipenko --- drivers/usb/phy/phy-ulpi.c | 48 +++++++++++++++++++++++++++++++------- include/linux/usb/ulpi.h | 11 +++++++++ 2 files changed, 50 insertions(+), 9 deletions(-) diff --git a/drivers/usb/phy/phy-ulpi.c b/drivers/usb/phy/phy-ulpi.c index a43c49369a60..e683a37e3a7a 100644 --- a/drivers/usb/phy/phy-ulpi.c +++ b/drivers/usb/phy/phy-ulpi.c @@ -240,6 +240,21 @@ static int ulpi_set_vbus(struct usb_otg *otg, bool on) return usb_phy_io_write(phy, flags, ULPI_OTG_CTRL); } +static void otg_ulpi_init(struct usb_phy *phy, struct usb_otg *otg, + struct usb_phy_io_ops *ops, + unsigned int flags) +{ + phy->label = "ULPI"; + phy->flags = flags; + phy->io_ops = ops; + phy->otg = otg; + phy->init = ulpi_init; + + otg->usb_phy = phy; + otg->set_host = ulpi_set_host; + otg->set_vbus = ulpi_set_vbus; +} + struct usb_phy * otg_ulpi_create(struct usb_phy_io_ops *ops, unsigned int flags) @@ -257,17 +272,32 @@ otg_ulpi_create(struct usb_phy_io_ops *ops, return NULL; } - phy->label = "ULPI"; - phy->flags = flags; - phy->io_ops = ops; - phy->otg = otg; - phy->init = ulpi_init; - - otg->usb_phy = phy; - otg->set_host = ulpi_set_host; - otg->set_vbus = ulpi_set_vbus; + otg_ulpi_init(phy, otg, ops, flags); return phy; } EXPORT_SYMBOL_GPL(otg_ulpi_create); +struct usb_phy * +devm_otg_ulpi_create(struct device *dev, + struct usb_phy_io_ops *ops, + unsigned int flags) +{ + struct usb_phy *phy; + struct usb_otg *otg; + + phy = devm_kzalloc(dev, sizeof(*phy), GFP_KERNEL); + if (!phy) + return NULL; + + otg = devm_kzalloc(dev, sizeof(*otg), GFP_KERNEL); + if (!otg) { + devm_kfree(dev, phy); + return NULL; + } + + otg_ulpi_init(phy, otg, ops, flags); + + return phy; +} +EXPORT_SYMBOL_GPL(devm_otg_ulpi_create); diff --git a/include/linux/usb/ulpi.h b/include/linux/usb/ulpi.h index c515765adab7..36c2982780ad 100644 --- a/include/linux/usb/ulpi.h +++ b/include/linux/usb/ulpi.h @@ -55,12 +55,23 @@ #if IS_ENABLED(CONFIG_USB_ULPI) struct usb_phy *otg_ulpi_create(struct usb_phy_io_ops *ops, unsigned int flags); + +struct usb_phy *devm_otg_ulpi_create(struct device *dev, + struct usb_phy_io_ops *ops, + unsigned int flags); #else static inline struct usb_phy *otg_ulpi_create(struct usb_phy_io_ops *ops, unsigned int flags) { return NULL; } + +static inline struct usb_phy *devm_otg_ulpi_create(struct device *dev, + struct usb_phy_io_ops *ops, + unsigned int flags) +{ + return NULL; +} #endif #ifdef CONFIG_USB_ULPI_VIEWPORT From patchwork Mon Jan 6 01:34:07 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Osipenko X-Patchwork-Id: 11318623 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 3C9711398 for ; Mon, 6 Jan 2020 01:34:56 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 1AF0C24650 for ; Mon, 6 Jan 2020 01:34:56 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="AmUifnA5" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727455AbgAFBez (ORCPT ); Sun, 5 Jan 2020 20:34:55 -0500 Received: from mail-lf1-f65.google.com ([209.85.167.65]:44953 "EHLO mail-lf1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727260AbgAFBex (ORCPT ); Sun, 5 Jan 2020 20:34:53 -0500 Received: by mail-lf1-f65.google.com with SMTP id v201so35297459lfa.11; Sun, 05 Jan 2020 17:34:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=+7IbWzfPhmBnEreIxXsILwKTpjW90RDh/fEgRDfgjeM=; b=AmUifnA5XnTZGZZ082fVauHQS8xiNyA7i6Pv7uajYxbnxnD5Nd/i6mX6YGkbtIwSAy g02Us0ENuC5NO2XDoeHhVy6rHPqBq7WgoGxgdTHNM1ZmLb0ZxKRywsyxRZN79WuBq6OY 15Rx3a462oTajjSNG77GEDqaOXN0yAEpsVNksCLDnA3z2U3/m6I1POkqASzaADSg7Osq 7pH9ue+tml699F1DO/5FKirmHH7794X2y2YNrUNNMosHVfmamo5CThssalTPxqWVP0KI IOKSWaww3CSJJuEqkZ+0+abQCZauLESsuEwHRLRtG0cMd6PRx/4CWcx8ycr5abr+LF5j uHEw== 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=+7IbWzfPhmBnEreIxXsILwKTpjW90RDh/fEgRDfgjeM=; b=XF6NHneZFAo/prJc/Eye9hRwCEvybMnYoCSc2mBWd3DQDpXovgfpb3iUPy/4MnKVtY QMQxnb1oEaI871r7l+pPXYa9Bp5AuM63SryVTk6V0QShVY1vtV//Ax18snZe+CoStEmJ 3Ww4vnoxK0SnuuJ0oAkIWyQMvKD9Mz7aP0ZOuWzwdNMHSefSunKcz4kqfW5KNNw+QOpV zw+jzYChh9jQ27zx7/63tT2QEue6Q6SUg2LsjGix5iSbHsEvSM4ikFkKjuZkMwLX9gdI sb7F4Ch01ce/CpLdPuLa3BbkFIIyT0HTSjbjRr98ZR4fawJdeBbG82ohqkNWBKjKzJqE W1ww== X-Gm-Message-State: APjAAAUJFpuavxB4BR0kqHaA3YDZRv5no+yjnUA6CzukHuTGk6o0Q4E2 3l+2Rzu6mMlohx2cVRY1WTE= X-Google-Smtp-Source: APXvYqw8vdLhoJtuPi+v3NEjMicxcwkIIvTDQv+HHBM9MAUYnVdcQHr7ETJIuDHVYSThN2WhJ7sm8A== X-Received: by 2002:a19:c697:: with SMTP id w145mr54051507lff.54.1578274490798; Sun, 05 Jan 2020 17:34:50 -0800 (PST) Received: from localhost.localdomain (79-139-233-37.dynamic.spd-mgts.ru. [79.139.233.37]) by smtp.gmail.com with ESMTPSA id h10sm28235739ljc.39.2020.01.05.17.34.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 05 Jan 2020 17:34:50 -0800 (PST) From: Dmitry Osipenko To: Greg Kroah-Hartman , Peter Chen , Thierry Reding , Jonathan Hunter , Felipe Balbi , =?utf-8?b?TWljaGHFgiBNaXJvc8WCYXc=?= Cc: linux-usb@vger.kernel.org, linux-tegra@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v4 11/20] usb: phy: tegra: Use devm_otg_ulpi_create() Date: Mon, 6 Jan 2020 04:34:07 +0300 Message-Id: <20200106013416.9604-12-digetx@gmail.com> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20200106013416.9604-1-digetx@gmail.com> References: <20200106013416.9604-1-digetx@gmail.com> MIME-Version: 1.0 Sender: linux-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org The resource-managed variant removes the necessity for the driver to care about freeing ULPI resources. Suggested-by: Thierry Reding Signed-off-by: Dmitry Osipenko --- drivers/usb/phy/phy-tegra-usb.c | 22 ++++++---------------- 1 file changed, 6 insertions(+), 16 deletions(-) diff --git a/drivers/usb/phy/phy-tegra-usb.c b/drivers/usb/phy/phy-tegra-usb.c index 5b9f031619c5..9adbcdf8d3a1 100644 --- a/drivers/usb/phy/phy-tegra-usb.c +++ b/drivers/usb/phy/phy-tegra-usb.c @@ -1100,6 +1100,7 @@ static int tegra_usb_phy_probe(struct platform_device *pdev) enum usb_phy_interface phy_type; struct reset_control *reset; struct resource *res; + struct usb_phy *phy; int err; tegra_phy = devm_kzalloc(&pdev->dev, sizeof(*tegra_phy), GFP_KERNEL); @@ -1200,12 +1201,14 @@ static int tegra_usb_phy_probe(struct platform_device *pdev) return err; } - tegra_phy->ulpi = otg_ulpi_create(&ulpi_viewport_access_ops, 0); - if (!tegra_phy->ulpi) { + phy = devm_otg_ulpi_create(&pdev->dev, + &ulpi_viewport_access_ops, 0); + if (!phy) { dev_err(&pdev->dev, "Failed to create ULPI OTG\n"); return -ENOMEM; } + tegra_phy->ulpi = phy; tegra_phy->ulpi->io_priv = tegra_phy->regs + ULPI_VIEWPORT; break; @@ -1224,17 +1227,9 @@ static int tegra_usb_phy_probe(struct platform_device *pdev) err = usb_add_phy_dev(&tegra_phy->u_phy); if (err) - goto free_ulpi; + return err; return 0; - -free_ulpi: - if (tegra_phy->ulpi) { - kfree(tegra_phy->ulpi->otg); - kfree(tegra_phy->ulpi); - } - - return err; } static int tegra_usb_phy_remove(struct platform_device *pdev) @@ -1243,11 +1238,6 @@ static int tegra_usb_phy_remove(struct platform_device *pdev) usb_remove_phy(&tegra_phy->u_phy); - if (tegra_phy->ulpi) { - kfree(tegra_phy->ulpi->otg); - kfree(tegra_phy->ulpi); - } - return 0; } From patchwork Mon Jan 6 01:34:08 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Osipenko X-Patchwork-Id: 11318641 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 1BBFA139A for ; Mon, 6 Jan 2020 01:35:42 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id EF8BC217F4 for ; Mon, 6 Jan 2020 01:35:41 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="E9t0YDM4" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727582AbgAFBfl (ORCPT ); Sun, 5 Jan 2020 20:35:41 -0500 Received: from mail-lj1-f194.google.com ([209.85.208.194]:38706 "EHLO mail-lj1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727429AbgAFBey (ORCPT ); Sun, 5 Jan 2020 20:34:54 -0500 Received: by mail-lj1-f194.google.com with SMTP id w1so27340347ljh.5; Sun, 05 Jan 2020 17:34:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=dflUvxh9hQS7NEkqv7qNke7Xes24FVjfSEb+Lpz8tfc=; b=E9t0YDM4Xxsgsty8Mg3J/EVllC/zYTXX7GsP6p1GIdG5XiyVEAQvZXjbf4uQKuRjjR eTm0abx8E0pCe6sFyW8ZPgfBU7dTjPE9tjIM98MF/01GjSiv0lf9Wx+GQP/xHw+3wgzg vrKLZi6e/RZxHRnVtqwXaEJa50YSdmB7QoaO6AWX/fOhwH8ct8apJwGa93/LSZ5O8wib rz0Yoi0S1Iht1cqhzmk7BrDT0N4k6Qhy9rBxJdoj6y77wiUB0zoRQWioa2UNcozKRZzL rBSvnjCo32sxu0MUPQ4ZDNfHbPW2iCUVnnB4ROODXdOJgyx26qvGuVkPBszF+HFWCnXd NSsw== 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=dflUvxh9hQS7NEkqv7qNke7Xes24FVjfSEb+Lpz8tfc=; b=On8vkkNloL1hY/MDoG+o3VITn1gDD5aYJRZFJcmrf1zlznk85nKa/RDif585ZUqWUf fm/MZC/6Rch+AxqU11+1XcAC5YimZXDRZ2NLILRFJ67nbRZbrzY7sTsvz/LKfxKZMzIT LV0n8yYyZLVkAJqC+0NAogTH0kXk/q3plFPfB/B+6BC+r23WpJXgP7atpuvAi1Lw6YYE cV+ruV52oqnmSHY8J+azYMB96vaSkBCbiMWv9+VuXqtzmYT7Gk7E6rltRjtxd9KvyrUx 8Foqi8c/YS03iC+azjsHxCE1kNj21skdKEFxSLx4hQH63IZJMkd7xfYUPz7IB4e6OXWk afXQ== X-Gm-Message-State: APjAAAUm+clEkXkNmNV2mjcnKXpJY2wdoraFpJue50W4qZvmyzZN9GY5 n5XIxEhpDgsKgL098EDE6b2wX9ag X-Google-Smtp-Source: APXvYqxVKSwnEZdwUt2LK4IbiZJQHsEAJMBPngoRdgH1yCopshRt4D4JP8wdnrst7LPaajj+QkYTlg== X-Received: by 2002:a2e:b177:: with SMTP id a23mr54673523ljm.202.1578274491613; Sun, 05 Jan 2020 17:34:51 -0800 (PST) Received: from localhost.localdomain (79-139-233-37.dynamic.spd-mgts.ru. [79.139.233.37]) by smtp.gmail.com with ESMTPSA id h10sm28235739ljc.39.2020.01.05.17.34.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 05 Jan 2020 17:34:51 -0800 (PST) From: Dmitry Osipenko To: Greg Kroah-Hartman , Peter Chen , Thierry Reding , Jonathan Hunter , Felipe Balbi , =?utf-8?b?TWljaGHFgiBNaXJvc8WCYXc=?= Cc: linux-usb@vger.kernel.org, linux-tegra@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v4 12/20] usb: phy: tegra: Use u32 for hardware register variables Date: Mon, 6 Jan 2020 04:34:08 +0300 Message-Id: <20200106013416.9604-13-digetx@gmail.com> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20200106013416.9604-1-digetx@gmail.com> References: <20200106013416.9604-1-digetx@gmail.com> MIME-Version: 1.0 Sender: linux-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org There is a mix of u32/ULONG usage in the driver's code. Let's switch to u32 uniformly, for consistency. Suggested-by: Thierry Reding Signed-off-by: Dmitry Osipenko --- drivers/usb/phy/phy-tegra-usb.c | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/drivers/usb/phy/phy-tegra-usb.c b/drivers/usb/phy/phy-tegra-usb.c index 9adbcdf8d3a1..f9acbab477cf 100644 --- a/drivers/usb/phy/phy-tegra-usb.c +++ b/drivers/usb/phy/phy-tegra-usb.c @@ -204,7 +204,7 @@ static inline struct tegra_usb_phy *to_tegra_usb_phy(struct usb_phy *u_phy) static void set_pts(struct tegra_usb_phy *phy, u8 pts_val) { void __iomem *base = phy->regs; - unsigned long val; + u32 val; if (phy->soc_config->has_hostpc) { val = readl_relaxed(base + TEGRA_USB_HOSTPC1_DEVLC); @@ -223,7 +223,7 @@ static void set_pts(struct tegra_usb_phy *phy, u8 pts_val) static void set_phcd(struct tegra_usb_phy *phy, bool enable) { void __iomem *base = phy->regs; - unsigned long val; + u32 val; if (phy->soc_config->has_hostpc) { val = readl_relaxed(base + TEGRA_USB_HOSTPC1_DEVLC); @@ -310,7 +310,8 @@ static int utmip_pad_power_on(struct tegra_usb_phy *phy) { struct tegra_utmip_config *config = phy->config; void __iomem *base = phy->pad_regs; - unsigned long val, flags; + unsigned long flags; + u32 val; int err; err = clk_prepare_enable(phy->pad_clk); @@ -345,7 +346,8 @@ static int utmip_pad_power_on(struct tegra_usb_phy *phy) static int utmip_pad_power_off(struct tegra_usb_phy *phy) { void __iomem *base = phy->pad_regs; - unsigned long val, flags; + unsigned long flags; + u32 val; int err; if (!utmip_pad_count) { @@ -383,7 +385,7 @@ static int utmi_wait_register(void __iomem *reg, u32 mask, u32 result) static void utmi_phy_clk_disable(struct tegra_usb_phy *phy) { void __iomem *base = phy->regs; - unsigned long val; + u32 val; /* * The USB driver may have already initiated the phy clock @@ -415,7 +417,7 @@ static void utmi_phy_clk_disable(struct tegra_usb_phy *phy) static void utmi_phy_clk_enable(struct tegra_usb_phy *phy) { void __iomem *base = phy->regs; - unsigned long val; + u32 val; /* * The USB driver may have already initiated the phy clock @@ -450,7 +452,7 @@ static int utmi_phy_power_on(struct tegra_usb_phy *phy) { struct tegra_utmip_config *config = phy->config; void __iomem *base = phy->regs; - unsigned long val; + u32 val; int err; val = readl_relaxed(base + USB_SUSP_CTRL); @@ -601,7 +603,7 @@ static int utmi_phy_power_on(struct tegra_usb_phy *phy) static int utmi_phy_power_off(struct tegra_usb_phy *phy) { void __iomem *base = phy->regs; - unsigned long val; + u32 val; utmi_phy_clk_disable(phy); @@ -636,7 +638,7 @@ static int utmi_phy_power_off(struct tegra_usb_phy *phy) static void utmi_phy_preresume(struct tegra_usb_phy *phy) { void __iomem *base = phy->regs; - unsigned long val; + u32 val; val = readl_relaxed(base + UTMIP_TX_CFG0); val |= UTMIP_HS_DISCON_DISABLE; @@ -646,7 +648,7 @@ static void utmi_phy_preresume(struct tegra_usb_phy *phy) static void utmi_phy_postresume(struct tegra_usb_phy *phy) { void __iomem *base = phy->regs; - unsigned long val; + u32 val; val = readl_relaxed(base + UTMIP_TX_CFG0); val &= ~UTMIP_HS_DISCON_DISABLE; @@ -657,7 +659,7 @@ static void utmi_phy_restore_start(struct tegra_usb_phy *phy, enum tegra_usb_phy_port_speed port_speed) { void __iomem *base = phy->regs; - unsigned long val; + u32 val; val = readl_relaxed(base + UTMIP_MISC_CFG0); val &= ~UTMIP_DPDM_OBSERVE_SEL(~0); @@ -677,7 +679,7 @@ static void utmi_phy_restore_start(struct tegra_usb_phy *phy, static void utmi_phy_restore_end(struct tegra_usb_phy *phy) { void __iomem *base = phy->regs; - unsigned long val; + u32 val; val = readl_relaxed(base + UTMIP_MISC_CFG0); val &= ~UTMIP_DPDM_OBSERVE; @@ -688,7 +690,7 @@ static void utmi_phy_restore_end(struct tegra_usb_phy *phy) static int ulpi_phy_power_on(struct tegra_usb_phy *phy) { void __iomem *base = phy->regs; - unsigned long val; + u32 val; int err; err = gpio_direction_output(phy->reset_gpio, 0); From patchwork Mon Jan 6 01:34:09 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Osipenko X-Patchwork-Id: 11318637 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 559FB1398 for ; Mon, 6 Jan 2020 01:35:38 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 29E06217F4 for ; Mon, 6 Jan 2020 01:35:38 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="R5G0Tryz" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727555AbgAFBf1 (ORCPT ); Sun, 5 Jan 2020 20:35:27 -0500 Received: from mail-lj1-f193.google.com ([209.85.208.193]:40815 "EHLO mail-lj1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727442AbgAFBez (ORCPT ); Sun, 5 Jan 2020 20:34:55 -0500 Received: by mail-lj1-f193.google.com with SMTP id u1so49285578ljk.7; Sun, 05 Jan 2020 17:34:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=4vINXXjWj7NDH/p3sklu8i0G1Rq05HWbY0415CgCPEc=; b=R5G0TryzU/+cs7ZEJ29tjY0EFW2INSPUkDnGinDwSbTDO+u83iUxyxYgS4fSjHCirO iP/zuvVpSxKaXAIrFq9bCFMH2qTyuab0PV/2IkiGxzb3hYb7CyrKzs39qOtkZSnLLcg2 XY+gPWEgUHxIqxxiPcvSGSY2n9VqQUM97/AeK1ZDy6v0O4okGZ5/uYshGMqiGrPQvMmR MBJVxUKM9GS7sv4ioEhffoxkFIrqHpr5tURyUDz9lob72Kdm7x4Onu9jfsAc6QTZchAF rC/mwOMJqhOm2c6O3RNK6Y3ZPdg15FO3EjnoidOkZEc9s84RCvrVOiQ+AX/RTIJwV09l lLuQ== 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=4vINXXjWj7NDH/p3sklu8i0G1Rq05HWbY0415CgCPEc=; b=Mc1pPuxoyUt8UR6SIM4JeBF/jE824Y6Ug5DJ9CxQNKiDJuz/JSNGsyTty1jYBTc1IM zLjylVOSoFW4gCURZrCmrNzlKSt39Mmmvs8zanWYHN45WvGH1JBN72Ox32+vfI2dqCJ0 C6649pXa/zc8CgN6C9SHw3f4iV5SdMQ1GGiShk/G8eLczjNYtbtYHUD5TN1zLeKSeOYi 69gW2Q8BLSjKWfhXz8QjMsxS38Knxj9VQlrmuqyDXQ3i97ORI43yPGsE4+qEd9J8Jf8t QYh0lCiyO73rC07FeLSS3d3GdSl+48TiY6uIMrbMkCq0bSUeTCi+HiaEXKhw00u+e5NA oeRw== X-Gm-Message-State: APjAAAVnZAbOHp970KKl3EjaAT8hK8hj4EAp8EX5hkSVTAAlhVJrYPnN sBbgPrwZYsjzDQnWw4Gp2Uc= X-Google-Smtp-Source: APXvYqwdSZIwm8TSvkW0m2RaBego/zmETAbmMkPC01MdQE2lbM+O+/eulZ11xyGubnYjURNETfTetA== X-Received: by 2002:a2e:804c:: with SMTP id p12mr57138112ljg.31.1578274492423; Sun, 05 Jan 2020 17:34:52 -0800 (PST) Received: from localhost.localdomain (79-139-233-37.dynamic.spd-mgts.ru. [79.139.233.37]) by smtp.gmail.com with ESMTPSA id h10sm28235739ljc.39.2020.01.05.17.34.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 05 Jan 2020 17:34:52 -0800 (PST) From: Dmitry Osipenko To: Greg Kroah-Hartman , Peter Chen , Thierry Reding , Jonathan Hunter , Felipe Balbi , =?utf-8?b?TWljaGHFgiBNaXJvc8WCYXc=?= Cc: linux-usb@vger.kernel.org, linux-tegra@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v4 13/20] usb: phy: tegra: Use device-tree notion of reset-GPIO's active-state Date: Mon, 6 Jan 2020 04:34:09 +0300 Message-Id: <20200106013416.9604-14-digetx@gmail.com> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20200106013416.9604-1-digetx@gmail.com> References: <20200106013416.9604-1-digetx@gmail.com> MIME-Version: 1.0 Sender: linux-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org It is much more intuitive if reset is treated as asserted when GPIO value is set to 1. All NVIDIA Tegra device-trees are properly specifying active state of the reset-GPIO since 2013, let's clean up that part of the code. Signed-off-by: Dmitry Osipenko --- drivers/usb/phy/phy-tegra-usb.c | 70 +++++++------------------------ include/linux/usb/tegra_usb_phy.h | 3 +- 2 files changed, 18 insertions(+), 55 deletions(-) diff --git a/drivers/usb/phy/phy-tegra-usb.c b/drivers/usb/phy/phy-tegra-usb.c index f9acbab477cf..c431968d0433 100644 --- a/drivers/usb/phy/phy-tegra-usb.c +++ b/drivers/usb/phy/phy-tegra-usb.c @@ -693,12 +693,7 @@ static int ulpi_phy_power_on(struct tegra_usb_phy *phy) u32 val; int err; - err = gpio_direction_output(phy->reset_gpio, 0); - if (err) { - dev_err(phy->u_phy.dev, "GPIO %d not set to 0: %d\n", - phy->reset_gpio, err); - return err; - } + gpiod_set_value_cansleep(phy->reset_gpio, 1); err = clk_prepare_enable(phy->clk); if (err) @@ -706,12 +701,7 @@ static int ulpi_phy_power_on(struct tegra_usb_phy *phy) usleep_range(5000, 6000); - err = gpio_direction_output(phy->reset_gpio, 1); - if (err) { - dev_err(phy->u_phy.dev, "GPIO %d not set to 1: %d\n", - phy->reset_gpio, err); - goto disable_clk; - } + gpiod_set_value_cansleep(phy->reset_gpio, 0); usleep_range(1000, 2000); @@ -773,16 +763,8 @@ static int ulpi_phy_power_on(struct tegra_usb_phy *phy) static int ulpi_phy_power_off(struct tegra_usb_phy *phy) { - int err; - - err = gpio_direction_output(phy->reset_gpio, 0); - if (err) { - dev_err(phy->u_phy.dev, "reset GPIO not asserted: %d\n", err); - return err; - } - + gpiod_set_value_cansleep(phy->reset_gpio, 1); usleep_range(5000, 6000); - clk_disable_unprepare(phy->clk); return 0; @@ -857,21 +839,6 @@ static int tegra_usb_phy_set_suspend(struct usb_phy *u_phy, int suspend) return tegra_usb_phy_power_on(phy); } -static int ulpi_open(struct tegra_usb_phy *phy) -{ - int err; - - err = gpio_direction_output(phy->reset_gpio, 0); - if (err) { - dev_err(phy->u_phy.dev, - "ULPI reset GPIO %d direction not asserted: %d\n", - phy->reset_gpio, err); - return err; - } - - return 0; -} - static int tegra_usb_phy_init(struct usb_phy *u_phy) { struct tegra_usb_phy *phy = to_tegra_usb_phy(u_phy); @@ -907,12 +874,11 @@ static int tegra_usb_phy_init(struct usb_phy *u_phy) goto fail; } - if (phy->is_ulpi_phy) - err = ulpi_open(phy); - else + if (!phy->is_ulpi_phy) { err = utmip_pad_open(phy); - if (err) - goto fail; + if (err) + goto fail; + } err = tegra_usb_phy_power_on(phy); if (err) @@ -1101,6 +1067,7 @@ static int tegra_usb_phy_probe(struct platform_device *pdev) struct tegra_usb_phy *tegra_phy; enum usb_phy_interface phy_type; struct reset_control *reset; + struct gpio_desc *gpiod; struct resource *res; struct usb_phy *phy; int err; @@ -1178,15 +1145,6 @@ static int tegra_usb_phy_probe(struct platform_device *pdev) case USBPHY_INTERFACE_MODE_ULPI: tegra_phy->is_ulpi_phy = true; - tegra_phy->reset_gpio = - of_get_named_gpio(np, "nvidia,phy-reset-gpio", 0); - - if (!gpio_is_valid(tegra_phy->reset_gpio)) { - dev_err(&pdev->dev, - "Invalid GPIO: %d\n", tegra_phy->reset_gpio); - return tegra_phy->reset_gpio; - } - tegra_phy->clk = devm_clk_get(&pdev->dev, "ulpi-link"); err = PTR_ERR_OR_ZERO(tegra_phy->clk); if (err) { @@ -1195,13 +1153,17 @@ static int tegra_usb_phy_probe(struct platform_device *pdev) return err; } - err = devm_gpio_request(&pdev->dev, tegra_phy->reset_gpio, - "ulpi_phy_reset_b"); + gpiod = devm_gpiod_get_from_of_node(&pdev->dev, np, + "nvidia,phy-reset-gpio", + 0, GPIOD_OUT_HIGH, + "ulpi_phy_reset_b"); + err = PTR_ERR_OR_ZERO(gpiod); if (err) { - dev_err(&pdev->dev, "Request failed for GPIO %d: %d\n", - tegra_phy->reset_gpio, err); + dev_err(&pdev->dev, + "Request failed for reset GPIO: %d\n", err); return err; } + tegra_phy->reset_gpio = gpiod; phy = devm_otg_ulpi_create(&pdev->dev, &ulpi_viewport_access_ops, 0); diff --git a/include/linux/usb/tegra_usb_phy.h b/include/linux/usb/tegra_usb_phy.h index 3ae73bdc6245..c29d1b4c9381 100644 --- a/include/linux/usb/tegra_usb_phy.h +++ b/include/linux/usb/tegra_usb_phy.h @@ -17,6 +17,7 @@ #define __TEGRA_USB_PHY_H #include +#include #include #include @@ -76,7 +77,7 @@ struct tegra_usb_phy { struct usb_phy u_phy; bool is_legacy_phy; bool is_ulpi_phy; - int reset_gpio; + struct gpio_desc *reset_gpio; struct reset_control *pad_rst; bool powered_on; }; From patchwork Mon Jan 6 01:34:10 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Osipenko X-Patchwork-Id: 11318635 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id D2BFE1398 for ; Mon, 6 Jan 2020 01:35:28 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id AFB2D215A4 for ; Mon, 6 Jan 2020 01:35:28 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="ItqQEaqy" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727559AbgAFBf1 (ORCPT ); Sun, 5 Jan 2020 20:35:27 -0500 Received: from mail-lf1-f66.google.com ([209.85.167.66]:38515 "EHLO mail-lf1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727447AbgAFBez (ORCPT ); Sun, 5 Jan 2020 20:34:55 -0500 Received: by mail-lf1-f66.google.com with SMTP id r14so35370410lfm.5; Sun, 05 Jan 2020 17:34:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=wai/IBa7xwSSxkZALdhcvS+HcXKSmruVdy9OLgrA8Wk=; b=ItqQEaqyXUmzvU/jvIe3qhXtXMgjThlwNa2tgEylWtWLGDMth/AXM7ZlWtF/6yVb/h VGkhW2UMNjJQffKXovzmS5LY+/UO/JH26qL7hdmfGNcNvdAIyTjRsC7mO05Jh09gDNur kC+bdYVBB5Atp7EM/HTRXpTNaPfQY2j3mapyQ7+IfUmGYUl609MLSMQ4qf/qvzBDTghR Quc93mS82f0aTJDBzqSfGyoe24UBh/M6joBHBLNpeRCrY8Lumw/W6FY9047Qay5NC4xK QqLd8zwTW4LnjWhTwpdYmieGp+8GcxDWus/c22Popvl3huRiuVra5ZFeacj7ouAvONO3 +7qw== 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=wai/IBa7xwSSxkZALdhcvS+HcXKSmruVdy9OLgrA8Wk=; b=jW7c7bbmEp6zAefWoCIAyM7t92ri+7er8hbCoxRDTAvahx/41C6XqV9eh5eu+qZKWj p8sPr0prVPlciqDIF05Q6MUCjhEM118j6+Egd3IWmmAf3Efe9Hd1cGv2B/3+AxjszIBn 1MzzdB1VPu+u/PvryeWWU+0RyHdTcbxgVXw+LGqSQ3DB+Io0QBCQ4pUImMxDh1wWvCa5 asjoq06FmQGbSdf5Krt/8chYI8y79Co4Lpz6aGtBGincr4ESP0XJTUCuGDxWQP+DcRNo +ojFzv+o80SnzZOkyZMjg4162HxyxXhhrs7Is4MjdhT+svTeJNPVOfWCfNV4/skJo6On cLnA== X-Gm-Message-State: APjAAAVddpgcTyN3di/+WjRpBqGJ7b1QW+YRvMzNVnWTx6w4cycj/7BI pieIA66PF9Qa9SMjuz7Gi14= X-Google-Smtp-Source: APXvYqx7vTuQbwJiqWPtDuOvsV/KoGyFfXeb0igKd/ikCy0C/e6KcP2osqD2nB1hMKC1FhfcF9Dzpw== X-Received: by 2002:a19:c3cc:: with SMTP id t195mr56942352lff.144.1578274493274; Sun, 05 Jan 2020 17:34:53 -0800 (PST) Received: from localhost.localdomain (79-139-233-37.dynamic.spd-mgts.ru. [79.139.233.37]) by smtp.gmail.com with ESMTPSA id h10sm28235739ljc.39.2020.01.05.17.34.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 05 Jan 2020 17:34:52 -0800 (PST) From: Dmitry Osipenko To: Greg Kroah-Hartman , Peter Chen , Thierry Reding , Jonathan Hunter , Felipe Balbi , =?utf-8?b?TWljaGHFgiBNaXJvc8WCYXc=?= Cc: linux-usb@vger.kernel.org, linux-tegra@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v4 14/20] usb: phy: tegra: Disable VBUS regulator on tegra_usb_phy_init failure Date: Mon, 6 Jan 2020 04:34:10 +0300 Message-Id: <20200106013416.9604-15-digetx@gmail.com> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20200106013416.9604-1-digetx@gmail.com> References: <20200106013416.9604-1-digetx@gmail.com> MIME-Version: 1.0 Sender: linux-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org VBUS regulator should be turned off in a case of error. Signed-off-by: Dmitry Osipenko --- drivers/usb/phy/phy-tegra-usb.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/drivers/usb/phy/phy-tegra-usb.c b/drivers/usb/phy/phy-tegra-usb.c index c431968d0433..90b42e963a1e 100644 --- a/drivers/usb/phy/phy-tegra-usb.c +++ b/drivers/usb/phy/phy-tegra-usb.c @@ -864,20 +864,20 @@ static int tegra_usb_phy_init(struct usb_phy *u_phy) dev_err(phy->u_phy.dev, "Invalid pll_u parent rate %ld\n", parent_rate); err = -EINVAL; - goto fail; + goto disable_clk; } err = regulator_enable(phy->vbus); if (err) { dev_err(phy->u_phy.dev, "Failed to enable USB VBUS regulator: %d\n", err); - goto fail; + goto disable_clk; } if (!phy->is_ulpi_phy) { err = utmip_pad_open(phy); if (err) - goto fail; + goto disable_vbus; } err = tegra_usb_phy_power_on(phy); @@ -889,7 +889,11 @@ static int tegra_usb_phy_init(struct usb_phy *u_phy) close_phy: if (!phy->is_ulpi_phy) utmip_pad_close(phy); -fail: + +disable_vbus: + regulator_disable(phy->vbus); + +disable_clk: clk_disable_unprepare(phy->pll_u); phy->freq = NULL; From patchwork Mon Jan 6 01:34:11 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Osipenko X-Patchwork-Id: 11318639 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 9E8131398 for ; Mon, 6 Jan 2020 01:35:39 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 7D5EA217F4 for ; Mon, 6 Jan 2020 01:35:39 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="LdA2yUgB" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727467AbgAFBf1 (ORCPT ); Sun, 5 Jan 2020 20:35:27 -0500 Received: from mail-lj1-f196.google.com ([209.85.208.196]:34470 "EHLO mail-lj1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727452AbgAFBe4 (ORCPT ); Sun, 5 Jan 2020 20:34:56 -0500 Received: by mail-lj1-f196.google.com with SMTP id z22so44495869ljg.1; Sun, 05 Jan 2020 17:34:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=bBOdi+OKZRFZU4WYLXtV3AOw8+qJl80/HyzpZqYt9wQ=; b=LdA2yUgBw+XwewIEmZXjTplQjbHVYwYexhqb2+aPPXi5Lf2HVtsyj5NKf2Xf3JVseD vz9BH+JaKGETzIMbzIYgR18TLL5GL/fiBpN/tcgItror7ZQlCKcVlO9KC99silNsQxJT tFKdbDPt3xybjAPxOw9fHKB8mLR1f0hLws5NmDlfk4DJ/IBdD/MK1oTwchZhfKkZh4jM mzb442V0yuxDuUsZdrzXyjJb7tAkUNC2nr/6GVWasmQPaAhKuBhaoqhkl4mcXZvUnJ8N TEZhBOOnqnKTQdBZfaYycu5j4+yu1Vhb0Mw1dUtF2B3rk4Qagr0hdCKPkxoltClhnygw dmXw== 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=bBOdi+OKZRFZU4WYLXtV3AOw8+qJl80/HyzpZqYt9wQ=; b=HND7NJCHoraQQSGP1gjHBHH3JNCmUyEtS25ePiKvWGLAOSMiEVALFfe2oi/uqWKD5A VPFHn1lBUenT1l10DRayFYnrPQzDi8dgdF9bbVHikmFd8NmP6YlzJF9Xl7krY+X3beMP qS49+u/hUFhY9rYSAC1HeK1SgOb5nSbi069BGps8yFr9LBhWoDHFuOq0n/iDTgkTzqxL GiV0nGhaT4vp9QyMcrFNO84urrT+V1VeWVleJHXPBEMLXANWMnNigNJiScvsTaK4B5H2 03xQ0+9E9h3pLGrEiHVIvwXilIV4zWGyIGQaUWu+1vB9eEo73c50oBV2e55UXfA77nf4 DiTw== X-Gm-Message-State: APjAAAVZYNTk1URQbKJC0NcsGlsaBfC0lK+6Lmylnob8XSpANxMjUAon skuALVVSOmwPe6ZZXLg0+A8= X-Google-Smtp-Source: APXvYqyyhjwg8kpHsnaICuv2fadBZMPDwe4NGNHvRBQiC9YWl4W0NLGRp9laeLFLTQDylXd4CayFuA== X-Received: by 2002:a2e:9ad8:: with SMTP id p24mr58773421ljj.148.1578274494089; Sun, 05 Jan 2020 17:34:54 -0800 (PST) Received: from localhost.localdomain (79-139-233-37.dynamic.spd-mgts.ru. [79.139.233.37]) by smtp.gmail.com with ESMTPSA id h10sm28235739ljc.39.2020.01.05.17.34.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 05 Jan 2020 17:34:53 -0800 (PST) From: Dmitry Osipenko To: Greg Kroah-Hartman , Peter Chen , Thierry Reding , Jonathan Hunter , Felipe Balbi , =?utf-8?b?TWljaGHFgiBNaXJvc8WCYXc=?= Cc: linux-usb@vger.kernel.org, linux-tegra@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v4 15/20] usb: phy: tegra: Move utmip_pad_count checking under lock Date: Mon, 6 Jan 2020 04:34:11 +0300 Message-Id: <20200106013416.9604-16-digetx@gmail.com> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20200106013416.9604-1-digetx@gmail.com> References: <20200106013416.9604-1-digetx@gmail.com> MIME-Version: 1.0 Sender: linux-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org It's unlikely that two drivers could manage PHY's state simultaneously in practice, nevertheless the utmip_pad_count checking should be under lock, for consistency. Signed-off-by: Dmitry Osipenko --- drivers/usb/phy/phy-tegra-usb.c | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/drivers/usb/phy/phy-tegra-usb.c b/drivers/usb/phy/phy-tegra-usb.c index 90b42e963a1e..1b9667b0aa11 100644 --- a/drivers/usb/phy/phy-tegra-usb.c +++ b/drivers/usb/phy/phy-tegra-usb.c @@ -348,30 +348,31 @@ static int utmip_pad_power_off(struct tegra_usb_phy *phy) void __iomem *base = phy->pad_regs; unsigned long flags; u32 val; - int err; + int ret; + + ret = clk_prepare_enable(phy->pad_clk); + if (ret) + return ret; + + spin_lock_irqsave(&utmip_pad_lock, flags); if (!utmip_pad_count) { dev_err(phy->u_phy.dev, "UTMIP pad already powered off\n"); - return -EINVAL; + ret = -EINVAL; + goto ulock; } - err = clk_prepare_enable(phy->pad_clk); - if (err) - return err; - - spin_lock_irqsave(&utmip_pad_lock, flags); - if (--utmip_pad_count == 0) { val = readl_relaxed(base + UTMIP_BIAS_CFG0); val |= UTMIP_OTGPD | UTMIP_BIASPD; writel_relaxed(val, base + UTMIP_BIAS_CFG0); } - +ulock: spin_unlock_irqrestore(&utmip_pad_lock, flags); clk_disable_unprepare(phy->pad_clk); - return 0; + return ret; } static int utmi_wait_register(void __iomem *reg, u32 mask, u32 result) From patchwork Mon Jan 6 01:34:12 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Osipenko X-Patchwork-Id: 11318625 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 41C021398 for ; Mon, 6 Jan 2020 01:34:59 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 2016C218AC for ; Mon, 6 Jan 2020 01:34:59 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="VRVHx06V" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727473AbgAFBe5 (ORCPT ); Sun, 5 Jan 2020 20:34:57 -0500 Received: from mail-lj1-f194.google.com ([209.85.208.194]:37072 "EHLO mail-lj1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727460AbgAFBe5 (ORCPT ); Sun, 5 Jan 2020 20:34:57 -0500 Received: by mail-lj1-f194.google.com with SMTP id o13so37885713ljg.4; Sun, 05 Jan 2020 17:34:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=GxHWs7smKY9c542URAYmUJXKzRbv59ZDpizKO+V3yf8=; b=VRVHx06Vdq1FmBBvykANKRrOTaBaWpW0ceu68mFMZkSaW1MKOTvYtijA7Jfcv9Z+Vy VHT7+Vw39+kILzZ8Fl+IvaGkRY6UErngMeqmXa+LqWSFfgHsydPqgDANeomLVUXGZvol e9QJqSSUqFaPaVEjIVmHlxTfkP6vA2i3MMCutwpsQ021++LZYYEf9ZwVqIgagdCh/SHy +jbHCuUtUhOpv2fyAskwH2eAA2MUlOIW4SlztlFxrBEVovI1Y8smatUy1guroTVGidAA V1omcibhTwdMuBCnzQjPxgfVk2VbsJ2r1nEK7raM4Q6vfCvi622d+IwlIfq14xfxmnvc OHqA== 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=GxHWs7smKY9c542URAYmUJXKzRbv59ZDpizKO+V3yf8=; b=hADt+o4AVd1zzQp6Yk5ccuuFWQmpRgiFvgPF1waGCjwmPaDEggjWWu4W3vJc5fdCK6 OelO4rbVgHG8uc8+D+FhjVL4Rtski+4HxyAMfT0BnEkFj9muUp+IiwfTYBeI6DIjXPkt R+lrfIF1Fj27VdB/JBK4u9ux8rXcne79RKZipsJJRBreg7oXg/5FF8wuBa2em9jAAxU0 xpmERg8stGTda0kIsHktiKYbnXBpUr3uLmFKtvJ11uxJA20TlxA/1gI6KThDXhnqztv8 cWxVsb4TLf7YQzY8+8728pnvP5v2+GeJ73KytY7Tekb3YSBFbIuSeFD+KvbWwYPj0L8R QEyg== X-Gm-Message-State: APjAAAWx2X4GlDkP38H5GNHCXTZzKSh36H6de0vbhkG4oTpJr4IPt01z 5++3XuVIIc6S/rgUSf6WUyA= X-Google-Smtp-Source: APXvYqwdZzmJbOI48HJEEBGpaUjSh004D0logSjpYIG20UUxtX7jJxIu81U4ZvA/91YgmezcYMor4g== X-Received: by 2002:a2e:b0c9:: with SMTP id g9mr57560697ljl.134.1578274494896; Sun, 05 Jan 2020 17:34:54 -0800 (PST) Received: from localhost.localdomain (79-139-233-37.dynamic.spd-mgts.ru. [79.139.233.37]) by smtp.gmail.com with ESMTPSA id h10sm28235739ljc.39.2020.01.05.17.34.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 05 Jan 2020 17:34:54 -0800 (PST) From: Dmitry Osipenko To: Greg Kroah-Hartman , Peter Chen , Thierry Reding , Jonathan Hunter , Felipe Balbi , =?utf-8?b?TWljaGHFgiBNaXJvc8WCYXc=?= Cc: linux-usb@vger.kernel.org, linux-tegra@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v4 16/20] usb: phy: tegra: Keep CPU interrupts enabled Date: Mon, 6 Jan 2020 04:34:12 +0300 Message-Id: <20200106013416.9604-17-digetx@gmail.com> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20200106013416.9604-1-digetx@gmail.com> References: <20200106013416.9604-1-digetx@gmail.com> MIME-Version: 1.0 Sender: linux-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org There is no good reason for disabling of CPU interrupts in order to protect the utmip_pad_count modification. Signed-off-by: Dmitry Osipenko --- drivers/usb/phy/phy-tegra-usb.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/drivers/usb/phy/phy-tegra-usb.c b/drivers/usb/phy/phy-tegra-usb.c index 1b9667b0aa11..037e8eee737d 100644 --- a/drivers/usb/phy/phy-tegra-usb.c +++ b/drivers/usb/phy/phy-tegra-usb.c @@ -310,7 +310,6 @@ static int utmip_pad_power_on(struct tegra_usb_phy *phy) { struct tegra_utmip_config *config = phy->config; void __iomem *base = phy->pad_regs; - unsigned long flags; u32 val; int err; @@ -318,7 +317,7 @@ static int utmip_pad_power_on(struct tegra_usb_phy *phy) if (err) return err; - spin_lock_irqsave(&utmip_pad_lock, flags); + spin_lock(&utmip_pad_lock); if (utmip_pad_count++ == 0) { val = readl_relaxed(base + UTMIP_BIAS_CFG0); @@ -336,7 +335,7 @@ static int utmip_pad_power_on(struct tegra_usb_phy *phy) writel_relaxed(val, base + UTMIP_BIAS_CFG0); } - spin_unlock_irqrestore(&utmip_pad_lock, flags); + spin_unlock(&utmip_pad_lock); clk_disable_unprepare(phy->pad_clk); @@ -346,7 +345,6 @@ static int utmip_pad_power_on(struct tegra_usb_phy *phy) static int utmip_pad_power_off(struct tegra_usb_phy *phy) { void __iomem *base = phy->pad_regs; - unsigned long flags; u32 val; int ret; @@ -354,7 +352,7 @@ static int utmip_pad_power_off(struct tegra_usb_phy *phy) if (ret) return ret; - spin_lock_irqsave(&utmip_pad_lock, flags); + spin_lock(&utmip_pad_lock); if (!utmip_pad_count) { dev_err(phy->u_phy.dev, "UTMIP pad already powered off\n"); @@ -368,7 +366,7 @@ static int utmip_pad_power_off(struct tegra_usb_phy *phy) writel_relaxed(val, base + UTMIP_BIAS_CFG0); } ulock: - spin_unlock_irqrestore(&utmip_pad_lock, flags); + spin_unlock(&utmip_pad_lock); clk_disable_unprepare(phy->pad_clk); From patchwork Mon Jan 6 01:34:13 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Osipenko X-Patchwork-Id: 11318629 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E8D79139A for ; Mon, 6 Jan 2020 01:35:14 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id C74DF24673 for ; Mon, 6 Jan 2020 01:35:14 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="VCWSsV9p" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727483AbgAFBe6 (ORCPT ); Sun, 5 Jan 2020 20:34:58 -0500 Received: from mail-lj1-f195.google.com ([209.85.208.195]:42045 "EHLO mail-lj1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727464AbgAFBe6 (ORCPT ); Sun, 5 Jan 2020 20:34:58 -0500 Received: by mail-lj1-f195.google.com with SMTP id y4so34956309ljj.9; Sun, 05 Jan 2020 17:34:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=RdRgeWTtviiIWS4YZZN2UoUeCEyNPX48xbOaYwnMDFE=; b=VCWSsV9p6paoScf47picv2GV0/m9s9ui2clBeNluJeQyhsCVfUGWzyXl6/btVamdi1 j9dQ6YqYb+iM5lGs34b3WZbPjuD6zFdLhO+NCHlMtKxZuGwZo6DMhkXLCemtE+PhZa9o Is3fWSqW7+y9revc/MuOSVgnReMgWQSckW7mMzTlc/zDYEiEVzlZzm53qKsdqNRl+oG4 srV7d0wkqs2Oy6qQkjNT2xDXpm+AsROsUyAcXt31mrcweL5udZ71RYnXA/I2EqOcgcI2 IfWgcHl6/vxfVroeP0uIjkDmqT3Wda+BwML7OnX1h4qXj/DWF0P4/KS0qhNIjfPw81y/ i1fw== 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=RdRgeWTtviiIWS4YZZN2UoUeCEyNPX48xbOaYwnMDFE=; b=QYehijyK4N/Y4NLS9dkSu5k7kWkMnPVQIxThpQNKzn3JcTqjd8cx5haZxaHIQJSLdi u8vqD4Uii+QnURYtyCSTXsbwUXjoepA7T5JXR3j3rfyi/Xk8XQk5RTkBJQ8XlACRtzzC U4FsX2hQdoZ0XYlPRVfzCMwMIZ4dMJbFI807QqB7g9DvTKM8CPPhhtkT+kAfdXpR8kvz Q2ztMzXMsEazJiNauKxgQScV3/L1v8zUZYKmrlJijTQR9vduhyTXLY8AGus8efXCjuKE LYfVwxlGbM9x2BZLRfzdC7tPGJvj33JM2PuwcLzUNCE9oA64cwSjtVTGO/Yl/l10KPpZ ny4Q== X-Gm-Message-State: APjAAAWkpm7DRlZT9oo4LeJKlGEuq087X3J6OyioaO9FYv+0I8s362FH Zfgr4KaWxG2n4tu/kBwMY/g= X-Google-Smtp-Source: APXvYqzHEdlUrxRnvmi3zmqHLyUKH7nYxSyXMjbS/oTk11srVGo8tTw41DlI83BkiMhsGQE5+5I07g== X-Received: by 2002:a2e:9806:: with SMTP id a6mr57818053ljj.178.1578274495720; Sun, 05 Jan 2020 17:34:55 -0800 (PST) Received: from localhost.localdomain (79-139-233-37.dynamic.spd-mgts.ru. [79.139.233.37]) by smtp.gmail.com with ESMTPSA id h10sm28235739ljc.39.2020.01.05.17.34.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 05 Jan 2020 17:34:55 -0800 (PST) From: Dmitry Osipenko To: Greg Kroah-Hartman , Peter Chen , Thierry Reding , Jonathan Hunter , Felipe Balbi , =?utf-8?b?TWljaGHFgiBNaXJvc8WCYXc=?= Cc: linux-usb@vger.kernel.org, linux-tegra@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v4 17/20] usb: chipidea: tegra: Stop managing PHY's power Date: Mon, 6 Jan 2020 04:34:13 +0300 Message-Id: <20200106013416.9604-18-digetx@gmail.com> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20200106013416.9604-1-digetx@gmail.com> References: <20200106013416.9604-1-digetx@gmail.com> MIME-Version: 1.0 Sender: linux-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org Tegra's USB PHY driver now provides generic PHY init/shutdown callbacks and thus the custom PHY management could be removed from Tegra-specific part of the ChipIdea driver. Signed-off-by: Dmitry Osipenko --- drivers/usb/chipidea/ci_hdrc_tegra.c | 9 --------- 1 file changed, 9 deletions(-) diff --git a/drivers/usb/chipidea/ci_hdrc_tegra.c b/drivers/usb/chipidea/ci_hdrc_tegra.c index 0c9911d44ee5..7455df0ede49 100644 --- a/drivers/usb/chipidea/ci_hdrc_tegra.c +++ b/drivers/usb/chipidea/ci_hdrc_tegra.c @@ -83,13 +83,6 @@ static int tegra_udc_probe(struct platform_device *pdev) return err; } - /* - * Tegra's USB PHY driver doesn't implement optional phy_init() - * hook, so we have to power on UDC controller before ChipIdea - * driver initialization kicks in. - */ - usb_phy_set_suspend(udc->phy, 0); - /* setup and register ChipIdea HDRC device */ udc->data.name = "tegra-udc"; udc->data.flags = soc->flags; @@ -109,7 +102,6 @@ static int tegra_udc_probe(struct platform_device *pdev) return 0; fail_power_off: - usb_phy_set_suspend(udc->phy, 1); clk_disable_unprepare(udc->clk); return err; } @@ -119,7 +111,6 @@ static int tegra_udc_remove(struct platform_device *pdev) struct tegra_udc *udc = platform_get_drvdata(pdev); ci_hdrc_remove_device(udc->dev); - usb_phy_set_suspend(udc->phy, 1); clk_disable_unprepare(udc->clk); return 0; From patchwork Mon Jan 6 01:34:14 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Osipenko X-Patchwork-Id: 11318631 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 2DFF61398 for ; Mon, 6 Jan 2020 01:35:22 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 0D2AF24677 for ; Mon, 6 Jan 2020 01:35:22 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="oH43961Q" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727533AbgAFBfP (ORCPT ); Sun, 5 Jan 2020 20:35:15 -0500 Received: from mail-lf1-f67.google.com ([209.85.167.67]:39695 "EHLO mail-lf1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727467AbgAFBe6 (ORCPT ); Sun, 5 Jan 2020 20:34:58 -0500 Received: by mail-lf1-f67.google.com with SMTP id y1so35321061lfb.6; Sun, 05 Jan 2020 17:34:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=T1tQ+xYAMs7sw/VcDfuwxbYsSSijhyZ3PmmaB8fOUWw=; b=oH43961QjKKwgAhExzWn/iK2ChoNfbyxe4OxPEMFEnRZQ0JdT4EkmHxsln1CAHNqsz laZytevYs5rlRPOFg4XeRHEC3ISBbO+NWHjcHAD4KaPWs+3UZ9ZDpTy8OsyXmZotFtLd 6jj2HnxDVqk+kg54dZnYLBVXScyPnDbWjr/c4mAXiSlO0tUx3winVw/fgcfuzWzUqjb+ sBzlJ+PfprWVzycI99q/kUWlcCiJtwHUyEV5BTtdhLfkN6lJnSjPlV2cdl+q1UQH7JWG ftzEQYaGWFl8VRHLex62iAWwW7ve70SGyciyk9Kr71kgLvJwqNmDMkDBUCHxGH3Nza6C sFxQ== 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=T1tQ+xYAMs7sw/VcDfuwxbYsSSijhyZ3PmmaB8fOUWw=; b=HLjyLYzWwZQc4iaKeHOXjKGLeLnVQABoB3MMDmZq3yUUuGukrb/kx/o4FKJf6YDYRU QuqCuHauzZMUv3BYHBtwzeJEsUSBByKZCb/Rbn7lWvlhWruqXm3ALBcxAv6EbRbY3ab2 2wpCKneT07wI0mn4bB8nStEQJkE7gq53PPJCGkdI7b8sb/zEcVwT9gAcE78B7czaEBow zB8wB/372AMacfPjT6e6mudrXVBvEGwn8Fi6gCjMqPIpJOb+S5IG1G1DG4xvmgdYz+8W i+UbStYfgLd1VWylTwNUQEFvyCl+7gbYfjE7t9qsxzXCIldQGlIYyr7/OhLKTcH76dHg pN6w== X-Gm-Message-State: APjAAAUoZVu1qvR2rotu5R3OJya2BJCy1KYdhNPs8M7vr/JgpUtbeDYT gzbfrNYP4xqhhSm9oKHl6z8= X-Google-Smtp-Source: APXvYqxOOqz5YzjHYMaBGXEd5DcEpONsaBhPPpGksHjhhiXZBiUxSfoSNymLCCopDIg18X+og+5Xsg== X-Received: by 2002:ac2:47ec:: with SMTP id b12mr52883706lfp.162.1578274496528; Sun, 05 Jan 2020 17:34:56 -0800 (PST) Received: from localhost.localdomain (79-139-233-37.dynamic.spd-mgts.ru. [79.139.233.37]) by smtp.gmail.com with ESMTPSA id h10sm28235739ljc.39.2020.01.05.17.34.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 05 Jan 2020 17:34:56 -0800 (PST) From: Dmitry Osipenko To: Greg Kroah-Hartman , Peter Chen , Thierry Reding , Jonathan Hunter , Felipe Balbi , =?utf-8?b?TWljaGHFgiBNaXJvc8WCYXc=?= Cc: linux-usb@vger.kernel.org, linux-tegra@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v4 18/20] usb: chipidea: tegra: Add USB_TEGRA_PHY to driver's dependencies Date: Mon, 6 Jan 2020 04:34:14 +0300 Message-Id: <20200106013416.9604-19-digetx@gmail.com> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20200106013416.9604-1-digetx@gmail.com> References: <20200106013416.9604-1-digetx@gmail.com> MIME-Version: 1.0 Sender: linux-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org Add build dependency on USB_TEGRA_PHY since UDC driver isn't usable without the PHY. Signed-off-by: Dmitry Osipenko --- drivers/usb/chipidea/Kconfig | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/usb/chipidea/Kconfig b/drivers/usb/chipidea/Kconfig index ae850b3fddf2..d53db520e209 100644 --- a/drivers/usb/chipidea/Kconfig +++ b/drivers/usb/chipidea/Kconfig @@ -7,6 +7,7 @@ config USB_CHIPIDEA select RESET_CONTROLLER select USB_ULPI_BUS select USB_ROLE_SWITCH + select USB_TEGRA_PHY if ARCH_TEGRA help Say Y here if your system has a dual role high speed USB controller based on ChipIdea silicon IP. It supports: From patchwork Mon Jan 6 01:34:15 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Osipenko X-Patchwork-Id: 11318633 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id EDB0E139A for ; Mon, 6 Jan 2020 01:35:22 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id CD36124672 for ; Mon, 6 Jan 2020 01:35:22 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="pl+Qvi3r" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727486AbgAFBfP (ORCPT ); Sun, 5 Jan 2020 20:35:15 -0500 Received: from mail-lj1-f193.google.com ([209.85.208.193]:35356 "EHLO mail-lj1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727477AbgAFBe7 (ORCPT ); Sun, 5 Jan 2020 20:34:59 -0500 Received: by mail-lj1-f193.google.com with SMTP id j1so41922066lja.2; Sun, 05 Jan 2020 17:34:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=igfQ1RetbgHAAuHNfFj/g8fEnXKwtVyqbTA8fDE/yUQ=; b=pl+Qvi3r8f1VkmjWjt3l5gq37uNCtLSTCW2MFBVdbip5vWvIWiaFU4HAca0b/NEGO5 xOOlJQO72CYX1XCP9s7ZAZ7MC2mL9rFTNJQOcozf7LjxiWubp24NoWhzIDfs2JMiyTfJ lv7kFoQbl7Hmrx0wfUpatNo3GAAjcsP6P6cfb6TpCyzrJvmHdvCNVnIAF7/JY2qf5Wm5 nQNYRLz7lMb1may7oij8S5Y8t10T1DA2mIIE53Tkg1kmj4LyraBQv1Bk/J/cNfuM8dGt PGKurUgWrAksHfEUd08cwgJibi8UrtoJ4QAAWNFmtgAX1V8+W4NKDi3rUPuYSRZjjkIb Iogg== 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=igfQ1RetbgHAAuHNfFj/g8fEnXKwtVyqbTA8fDE/yUQ=; b=LoUEK0avoEld3E5ag3AR62U7v4mf4es98coUJIsrschrws1rRTZeivLy7TTvDN6h3V u1grBnZ2dkccRRbpJwGH0atrc88+PYjCf2/7uElM8W+QQlMRRcz2U79y1X6NvcVvOFQa MBi5Nof8oCkjGJoi9WCB2wyzkHGvUyHt8FTtyMrIaBdQWYpxqoNv4w52Ie54E+0xX3Ix aaLHREY58fO0oHdGozOodYj+FqeVhwytVdAsclxoxW9iUy7JmFY7HD9Hsbq7q4BJ1ZAP 30WGqP+TWYjXrY05x3AwzTVMgalF4Wa7tW2GvY6vSCWhZWNDSGoFEYC7qtS+PvkMF6By FBog== X-Gm-Message-State: APjAAAXjrIbcau84WmiiSbTW1wrAQ3/uwA4GK54n3UnsPkaUXaRnaMdl 3hnAo5jqstzg0V26kHfZDK5yWZ3Z X-Google-Smtp-Source: APXvYqxDhIqRsg3MSzikSUDbt47DbhhVA9bdwjviZ6+MzOGPFc8wxoZmcmMiNC8ObvicmZLkb7IguQ== X-Received: by 2002:a2e:96c4:: with SMTP id d4mr51194118ljj.225.1578274497366; Sun, 05 Jan 2020 17:34:57 -0800 (PST) Received: from localhost.localdomain (79-139-233-37.dynamic.spd-mgts.ru. [79.139.233.37]) by smtp.gmail.com with ESMTPSA id h10sm28235739ljc.39.2020.01.05.17.34.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 05 Jan 2020 17:34:56 -0800 (PST) From: Dmitry Osipenko To: Greg Kroah-Hartman , Peter Chen , Thierry Reding , Jonathan Hunter , Felipe Balbi , =?utf-8?b?TWljaGHFgiBNaXJvc8WCYXc=?= Cc: linux-usb@vger.kernel.org, linux-tegra@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v4 19/20] usb: host: ehci-tegra: Stop managing PHY's power Date: Mon, 6 Jan 2020 04:34:15 +0300 Message-Id: <20200106013416.9604-20-digetx@gmail.com> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20200106013416.9604-1-digetx@gmail.com> References: <20200106013416.9604-1-digetx@gmail.com> MIME-Version: 1.0 Sender: linux-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org There is no need to use usb_phy_set_suspend during of driver's probe because now PHY driver enables hardware during of PHY's initialization. Signed-off-by: Dmitry Osipenko --- drivers/usb/host/ehci-tegra.c | 6 ------ 1 file changed, 6 deletions(-) diff --git a/drivers/usb/host/ehci-tegra.c b/drivers/usb/host/ehci-tegra.c index 32483bef046b..1eb94205a5ac 100644 --- a/drivers/usb/host/ehci-tegra.c +++ b/drivers/usb/host/ehci-tegra.c @@ -480,12 +480,6 @@ static int tegra_ehci_probe(struct platform_device *pdev) } u_phy->otg->host = hcd_to_bus(hcd); - err = usb_phy_set_suspend(hcd->usb_phy, 0); - if (err) { - dev_err(&pdev->dev, "Failed to power on the phy\n"); - goto cleanup_phy; - } - irq = platform_get_irq(pdev, 0); if (!irq) { dev_err(&pdev->dev, "Failed to get IRQ\n"); From patchwork Mon Jan 6 01:34:16 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Osipenko X-Patchwork-Id: 11318627 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id EBF96139A for ; Mon, 6 Jan 2020 01:35:01 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id C868421775 for ; Mon, 6 Jan 2020 01:35:01 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="SPToMhG8" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727496AbgAFBfA (ORCPT ); Sun, 5 Jan 2020 20:35:00 -0500 Received: from mail-lf1-f68.google.com ([209.85.167.68]:40246 "EHLO mail-lf1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727486AbgAFBfA (ORCPT ); Sun, 5 Jan 2020 20:35:00 -0500 Received: by mail-lf1-f68.google.com with SMTP id i23so35348747lfo.7; Sun, 05 Jan 2020 17:34:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=arvMuYwhC6kmGPqHAkymvpsO/QkvwuD8ZdbKq/fROtw=; b=SPToMhG8xkcHN3DpqL+yC+h8j/VRBtyTdvNPnTRp3Pmti8jOZD5xhKMxOozTu7vV35 z34D1EeQWpdisk7i2L5GSsLd10l0UDYGbju3ibG08bu+M9ttvMu8Q2z5KoFnRufNh+bg 09jPba8Z1LN+cQtq/d0PcCtlmydZut3IYQPSDWeWff/u6LKMi7gfQ/8RvLPzF0gOFKDN 6i7mYSyTyFwrg3VUBQ47RoxLyBCsqxOzIWLf1TVTjasd11prS4yitY6zWDXkeB8s3EJb DZjr2qrLjIo3qgAjSPVK5APKeMwJ07tP2vVgdk6Lii87vV6R9Q9LHTRkRsQ1ORl7QfAc SJsg== 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=arvMuYwhC6kmGPqHAkymvpsO/QkvwuD8ZdbKq/fROtw=; b=EU4N+iXl4esZahWs8vjaJZa6asWAYQiGF4FQ1pKKEnX/CJaNPFWVdGP+omtOqkocgC QX8D6ig6DYqwrDEdVseEAnSpK+dLTMDdc41WHTDAIChthhTY9v5+TYajXuN96MrO/Btx 3gd8wxQm+HJdplVvZS/smY3ToobpehKVPhsDufmj1A5dHIq+fNS/phBJ/ieJVlcqiEvF y52q/hcaT1r4abeeWfkOvK+93UfySgV5Z5JZAqOCueaOdVG3tzqqdY/qXtb/XScG9p12 HEjnZqKPR99WgZP4vvPhqPY6nqtSBO+eFLUD7f6Mjpu5G1WYz+gf7f7sMXRwa79eZVdH FArQ== X-Gm-Message-State: APjAAAW+Cdo+nVtNhiZ6lM842Zvmd99DI0YZKaDOt0eBlyRocJiLR7rY E2GgJUGsZ6TppRZgCVDHDuU= X-Google-Smtp-Source: APXvYqxsh92kdjazmb0pr3lkYmWjoMIy8rIrxs0GKYd9+ZEhHUT9jphMz0O6WndobxVN7VNt02JRrQ== X-Received: by 2002:a19:e011:: with SMTP id x17mr36980429lfg.59.1578274498236; Sun, 05 Jan 2020 17:34:58 -0800 (PST) Received: from localhost.localdomain (79-139-233-37.dynamic.spd-mgts.ru. [79.139.233.37]) by smtp.gmail.com with ESMTPSA id h10sm28235739ljc.39.2020.01.05.17.34.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 05 Jan 2020 17:34:57 -0800 (PST) From: Dmitry Osipenko To: Greg Kroah-Hartman , Peter Chen , Thierry Reding , Jonathan Hunter , Felipe Balbi , =?utf-8?b?TWljaGHFgiBNaXJvc8WCYXc=?= Cc: linux-usb@vger.kernel.org, linux-tegra@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v4 20/20] usb: host: ehci-tegra: Remove unused fields from tegra_ehci_hcd Date: Mon, 6 Jan 2020 04:34:16 +0300 Message-Id: <20200106013416.9604-21-digetx@gmail.com> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20200106013416.9604-1-digetx@gmail.com> References: <20200106013416.9604-1-digetx@gmail.com> MIME-Version: 1.0 Sender: linux-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org There are few stale fields in tegra_ehci_hcd structure, let's remove them. Signed-off-by: Dmitry Osipenko Acked-by: Alan Stern --- drivers/usb/host/ehci-tegra.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/drivers/usb/host/ehci-tegra.c b/drivers/usb/host/ehci-tegra.c index 1eb94205a5ac..d6433f206c17 100644 --- a/drivers/usb/host/ehci-tegra.c +++ b/drivers/usb/host/ehci-tegra.c @@ -42,12 +42,10 @@ struct tegra_ehci_soc_config { }; struct tegra_ehci_hcd { - struct tegra_usb_phy *phy; struct clk *clk; struct reset_control *rst; int port_resuming; bool needs_double_reset; - enum tegra_usb_phy_port_speed port_speed; }; static int tegra_reset_usb_controller(struct platform_device *pdev)