From patchwork Tue May 31 12:47:17 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yoshihiro Shimoda X-Patchwork-Id: 9144739 X-Patchwork-Delegate: geert@linux-m68k.org Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id BBE4860757 for ; Tue, 31 May 2016 12:47:34 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AE9D0272D8 for ; Tue, 31 May 2016 12:47:34 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A1F5E27B89; Tue, 31 May 2016 12:47:34 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E308D272D8 for ; Tue, 31 May 2016 12:47:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752725AbcEaMrc (ORCPT ); Tue, 31 May 2016 08:47:32 -0400 Received: from relmlor2.renesas.com ([210.160.252.172]:20847 "EHLO relmlie1.idc.renesas.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752542AbcEaMra (ORCPT ); Tue, 31 May 2016 08:47:30 -0400 Received: from unknown (HELO relmlir3.idc.renesas.com) ([10.200.68.153]) by relmlie1.idc.renesas.com with ESMTP; 31 May 2016 21:47:28 +0900 Received: from relmlac3.idc.renesas.com (relmlac3.idc.renesas.com [10.200.69.23]) by relmlir3.idc.renesas.com (Postfix) with ESMTP id 7FB46620D2; Tue, 31 May 2016 21:47:28 +0900 (JST) Received: by relmlac3.idc.renesas.com (Postfix, from userid 0) id 67DFE1806F; Tue, 31 May 2016 21:47:28 +0900 (JST) Received: from relmlac3.idc.renesas.com (localhost [127.0.0.1]) by relmlac3.idc.renesas.com (Postfix) with ESMTP id 5C1671800A; Tue, 31 May 2016 21:47:28 +0900 (JST) Received: from relmlii2.idc.renesas.com [10.200.68.66] by relmlac3.idc.renesas.com with ESMTP id XBK04573; Tue, 31 May 2016 21:47:28 +0900 X-IronPort-AV: E=Sophos;i="5.22,559,1449500400"; d="scan'";a="212444787" Received: from mail-pu1apc01lp0017.outbound.protection.outlook.com (HELO APC01-PU1-obe.outbound.protection.outlook.com) ([65.55.88.17]) by relmlii2.idc.renesas.com with ESMTP/TLS/AES256-SHA; 31 May 2016 21:47:27 +0900 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=renesasgroup.onmicrosoft.com; s=selector1-renesas-com; h=From:To:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=T990x0H5axr6ntHXvqogTp0oOC5SLxo8hv/y87ncGeA=; b=iwdG2LA1ku6LVvwxjqycyS81QmPKs8wTrGxPNuItEPG1EqpFXDVr7BgiJGdYDaxBWsvd2U4qVSB/xnpl0ThhqwipeYMg+ML+i+1A0uyK+kj2imsHbB4IOBALoxLqQkTxvZyXsLocNWkhGS6s4NGGlyAq//Egu0Hlapv2FyF1tKU= Authentication-Results: ti.com; dkim=none (message not signed) header.d=none; ti.com; dmarc=none action=none header.from=renesas.com; Received: from localhost (211.11.155.144) by SIXPR06MB0922.apcprd06.prod.outlook.com (10.162.173.157) with Microsoft SMTP Server (TLS) id 15.1.506.9; Tue, 31 May 2016 12:47:26 +0000 From: Yoshihiro Shimoda To: CC: , , , Yoshihiro Shimoda Subject: [PATCH] phy: rcar-gen3-usb2: fix unexpected repeat interrupts of VBUS change Date: Tue, 31 May 2016 21:47:17 +0900 Message-ID: <1464698837-7556-1-git-send-email-yoshihiro.shimoda.uh@renesas.com> X-Mailer: git-send-email 1.9.4.msysgit.1 MIME-Version: 1.0 X-Originating-IP: [211.11.155.144] X-ClientProxiedBy: TY1PR01CA0024.jpnprd01.prod.outlook.com (10.161.131.162) To SIXPR06MB0922.apcprd06.prod.outlook.com (10.162.173.157) X-MS-Office365-Filtering-Correlation-Id: a9cc4695-24f8-4e40-a47c-08d38951b848 X-Microsoft-Exchange-Diagnostics: 1; SIXPR06MB0922; 2:zAIyy7ji2wA1k3aEWZu276c4+5SotORFgGq66k6pUg44bYt/jxyQi0YRkOe2BKDuqSVBmdyMsftiKw2MfxvGtWBopvnr6vIqKnRKEpsee3s+/KGWfaHTjUbFgc8Ms1BohUAthdlbkMiY6NdOQDhRnK+m5jiREm4ZHdHZXji+dQ7a6Vbx3HNvbJ43Y5UU1ygp; 3:iBdH2fw9TIIxC2LZ8o3owt2JN3twaYvsIi5l54kGkaxVrXsi+rqTBpifvZ/WMN7I8RuGMiVRmJyFlFkDtr8Oo4lxpl/F2/fPIKD+QvdvFC0JIguHCD5SAEDqv4tcyOjn; 25:5VM+rxfZONmlDe4ZfKujLtCtX9Gp3V90PDmvBOTOe+J6fyWTQB+BSru09zP3YfTTFxfLMurO2e6t+MV5bhFaku54nMnRT2rPRIyTlLBT2hp/i9XhahCWN1jeNWaLvl0NttuyUHlTstf3N1vC02BA0AxVSZBQq7YI14qkpOm/7iz+5cP4TANipRInpLCHlPOXiQViKUvw0LSOyLd/YLi/ho+HHko3UULCM653lIGJIMhEhFfOHU3F/0TT1mHle/RFkukusq9iBNgaw7fXL+4Sujpp5aiTyzPm6cmnuoMAzEOpYTznIEqlvRw8Nz28a/lKtCteSTjZj7wOyxeaXPgOrt/uhtfWTd6nLyFW7LxTmrDl3U86piwAmTaVwBqe0vFneH/6RWljLAvJ6Pok3ICMjqyB7wC8lLMvLuXEeplYXzA= X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:SIXPR06MB0922; X-Microsoft-Exchange-Diagnostics: 1; SIXPR06MB0922; 20:/SJLYcQ6BHPHQTA02Tr8GmKAyOQXvLDbltmVfy8LwqwvNT8ltgHWmqZdL85kojTSpJ/ep4X+9S7C5vn8AXjErDcVuLQ5nfpWfLKePju99Sp/FoP8T7a3gGsXNnZIEbutAKDw2SD6GVnN23ryuVTHrUDSkybQwoCWzt6YPbmxwnKYeGKSfNbpsjFTB4tFBVeKhfl2phybtGd6BTGFRihmL0gepSmgZcOFmWpGxdvtN3X5RWjvvq63yGU3nTxc7oUM5C4XVhYBr3XUtzs85r9+wmZyQtjk1Av2CNhDnwbwv1TDRKvwseDNUXPIC5Ym9QYHDxKLWsG3Tb6ceLG0urwpw+zxD5q3kY0+QcZp2bSdK5Pk3edo8HG3sGmLMC9+BRYFrVCi2wfq24LnPicTpWA/MU4lg7OFfb7qmJhcyG61bdGpGonZHR/lOp6EvrMEYjNQwDIy5mP5zgKMsGcg/tjQlrYgVL2bwsx4nleDsaHPmmew6qQLbPxMUL5XBgnDPSF3; 4:2XEz41nKQVF1dLX6DsUlRmd/bKxV//aq0TwCdzEQyjyALxC6QJrsRDAfBZalabyqfqnYH72hGLSVCGoNV+wTJQfzljLHNpFIvZGYGe+UrxaYNb0qddx473jcPCP4UYGQNAeTTSkpYtp6K++6E6UM0crnq8EOAscWEHOw98kmWJsmlpv8NWJn7sUiGb2KtOvpJhTpkMmzhz0oxbeUogsAbcmU8wDK5Mi7WHYCpCMLIUnyohZcdt4sMZNfc8kOuWCOSJUGvOYUGVwmFXQpM5DsL6gxgvbwOefApu/78xopT7RUXD38nB2sXzpOlePArv0ufx3XXeXyGpOAhSaUInaYJM8TFOg6/OF1X5LEeFExaAS1PlFgCxLvP2F+mOWs1Epxu6Ipva8KLlvgVTD3ZNMpmjY8nXdHm6F5UK0I6f pavvDe+cO3MWPzSaE4ix677Khu X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(9452136761055); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(601004)(2401047)(8121501046)(5005006)(10201501046)(3002001)(6055026); SRVR:SIXPR06MB0922; BCL:0; PCL:0; RULEID:; SRVR:SIXPR06MB0922; X-Forefront-PRVS: 095972DF2F X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10019020)(4630300001)(6069001)(6009001)(107886002)(586003)(230783001)(110136002)(77096005)(6116002)(3846002)(189998001)(76506005)(5003940100001)(78352004)(42186005)(97736004)(8676002)(81166006)(92566002)(47776003)(50986999)(66066001)(48376002)(50226002)(4001430100002)(50466002)(36756003)(33646002)(2906002)(229853001)(4326007)(2351001)(5004730100002)(5008740100001)(19580395003)(19580405001); DIR:OUT; SFP:1102; SCL:1; SRVR:SIXPR06MB0922; H:localhost; FPR:; SPF:None; MLV:ovrnspm; PTR:InfoNoRecords; LANG:en; X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; SIXPR06MB0922; 23:7IDgSLlskX5ymW0fWNzJNBQ7syiXVXlwvQnsxeXQ/?= =?us-ascii?Q?8jHO99x+oY+W6xebCXMhabKTfhQe4L5M1uCIfdC4/OrdEoWKygUn+NJ47+kI?= =?us-ascii?Q?TAbjNGoGQdX414i4V1hDHaQdLxgd+X2ybcB5Z/bEfLYmpAfBBbA+UGkSdDoE?= =?us-ascii?Q?bCuepnUTcutYEMPxmkTUAo2sUbJ2pnRzntgoiL+knszfLpq+MsWFxBVWO3vl?= =?us-ascii?Q?sW5TJrrqZXYxsPbAd+k9XyyJHvF2EKKtWRFmH0I9sdiH4FR3jxowaZshUrju?= =?us-ascii?Q?2Ynm6oLIpJxnP0ske8ioV5nyjCA6/45QIa0120KP3Q2CUHt58ll0A0RmA0iY?= =?us-ascii?Q?cUEnbihBjlzjbCAw8eMRNoKe/srNf3kC1NEkJAHOEOWqZRJ+FraobYN1jDg+?= =?us-ascii?Q?uv1DPPy1d/Ktzf2WIzsvhVuKS7Wq77/eQDxo3+Ce1Kkt5d3DxGVVQfNl2GtU?= =?us-ascii?Q?Vnu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TXSVyrT5Rsvusb93dVWH9pl6LybZNjrHWFtXpxrdbC/9mHEtdORGHYMsKAYvr8QCzPnFSUmXKFwTfB1kFwbBmYdKulrc; 20:0eYPCtiu76UbszOoB17tB1Dpr/0TOXHEN83JsTlZb1FxDbgDePTCWlmeDfTt4Dl8oozmcUTznVBiJc47LuiA4aM83/i66qIUDuQTHYGvvTZcAgLVewrvqcVDhASANj+1ygSWMlivLUGjK3MTtulvZjLIh0BeBSCg4IhNu6oKhAE= SpamDiagnosticOutput: 1:23 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: renesas.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 31 May 2016 12:47:26.3527 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: SIXPR06MB0922 Sender: linux-renesas-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-renesas-soc@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This patch fixes an issue that the driver is possible to cause unexpected repeat interrupts if a board condition is wrong (e.g. even if the ID pin is as function, a board supplies the VBUS.) The reason why unexpected repeat interrupts happen is: 1) The driver changed the mode to function if it detected the ID pin is high and the VBUS is high. 2) After the driver changed function mode, it disabled the "VBUS control" feature. Then, the VBUS signal will be low. 3) Since the VBUS change interruption happened, the driver checked the ID pin and VBUS. 4) Since VBUS was low, the driver changed the mode to host and enabled the "VBUS control" feature. Then the VBUS signal will be high. 5) Since the VBUS change interruption happened, the driver did 1) above. So, this patch modified the condition in rcar_gen3_device_recognition() to check the ID pin only. Fixes: 1114e2d (phy: rcar-gen3-usb2: change the mode to OTG on the combined channel) Cc: # v4.5+ Reported-by: Simon Horman Signed-off-by: Yoshihiro Shimoda --- drivers/phy/phy-rcar-gen3-usb2.c | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-) diff --git a/drivers/phy/phy-rcar-gen3-usb2.c b/drivers/phy/phy-rcar-gen3-usb2.c index 76bb88f..4be3f5d 100644 --- a/drivers/phy/phy-rcar-gen3-usb2.c +++ b/drivers/phy/phy-rcar-gen3-usb2.c @@ -144,12 +144,6 @@ static void rcar_gen3_init_for_peri(struct rcar_gen3_chan *ch) extcon_set_cable_state_(ch->extcon, EXTCON_USB, true); } -static bool rcar_gen3_check_vbus(struct rcar_gen3_chan *ch) -{ - return !!(readl(ch->base + USB2_ADPCTRL) & - USB2_ADPCTRL_OTGSESSVLD); -} - static bool rcar_gen3_check_id(struct rcar_gen3_chan *ch) { return !!(readl(ch->base + USB2_ADPCTRL) & USB2_ADPCTRL_IDDIG); @@ -157,13 +151,7 @@ static bool rcar_gen3_check_id(struct rcar_gen3_chan *ch) static void rcar_gen3_device_recognition(struct rcar_gen3_chan *ch) { - bool is_host = true; - - /* B-device? */ - if (rcar_gen3_check_id(ch) && rcar_gen3_check_vbus(ch)) - is_host = false; - - if (is_host) + if (!rcar_gen3_check_id(ch)) rcar_gen3_init_for_host(ch); else rcar_gen3_init_for_peri(ch);