Received: by 10.223.176.46 with SMTP id f43csp769795wra; Fri, 19 Jan 2018 01:29:34 -0800 (PST) X-Google-Smtp-Source: ACJfBou1rcqmQdCEmIaWR+cbX0597tkpJFt1NOIi/oRVlu5gX7uGJLzaAzMVcSz3rg5MgivVp76f X-Received: by 10.98.76.150 with SMTP id e22mr4372614pfj.28.1516354174234; Fri, 19 Jan 2018 01:29:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1516354174; cv=none; d=google.com; s=arc-20160816; b=nOsm43hnSvUio0qKZlFOOomgJDZhhNwhOW4lq//SAWU/aswZaEJp84CmFVJCG7sSRO 48/ze1yVeJ6MHnO+x3bj3a6UtkL1GYVTr4YPNWg57Nm5R+Wnf4Hyry0gxTIIvp+qZZAQ 2HM+H7F0v+KUlHZ0uyzbKTEwD0x5XnKzVpGN9IVeog+TtF15l5yUouVLuFiQsyjHHch2 0WHBQw9U1JPMpwDijiaqMaPq6f/Ll/oV+3bhC7eI26Bq77aZ7CyNZa8pOg5x1JzD/xnh zhp1jA4e/zGwOqObN1xrrjMsz+ebqBOAsFzvxHquB7Cxifvt5vgf79YX0+ZzdLNLVB3y cQeg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :arc-authentication-results; bh=6hy+P7n/aPTufGkjjE4HjGCg+lVKH7zhEp8wOns12Bw=; b=VND4Svqph2fyJ+G6H611doMx+75eot7b4JKGdn5EU1103MrlTm7742ML6dFfxslzIz G9dF3dka2PyjCrpi0pIDxebLlIqI+rF2E7DdyzhI/XQeSBV6iucn7dREKeCrgsHHpBzd pgHnNxIzsMU6U13j+cUcRpmS+mND+RdTYlBgXIJrYYu3rUgpnoY4av4VVjMY9dnSRYy5 QEEXYKcPND8ZfGBlgYpRVgjNbTDbeFCOwxOA+XAYYrT0awTHtrQ7mQKq95T7n21oqZLO hctTp7ESM2cLTDKnw1D6Rf0WvLLZr9NTSJOsv38e6lvuDCfm8kEZGkcMG155+QJsQbtV 95wQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x13si4764493pgp.281.2018.01.19.01.29.20; Fri, 19 Jan 2018 01:29:34 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755289AbeASJ1R (ORCPT + 99 others); Fri, 19 Jan 2018 04:27:17 -0500 Received: from mirror2.csie.ntu.edu.tw ([140.112.30.76]:42600 "EHLO wens.csie.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755398AbeASJZu (ORCPT ); Fri, 19 Jan 2018 04:25:50 -0500 Received: by wens.csie.org (Postfix, from userid 1000) id 08B525FE89; Fri, 19 Jan 2018 17:25:44 +0800 (CST) From: Chen-Yu Tsai To: Kishon Vijay Abraham I , Maxime Ripard Cc: Chen-Yu Tsai , Hans de Goede , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-sunxi@googlegroups.com, stable@vger.kernel.org Subject: [PATCH] phy: allwinner: sun4i-usb: poll vbus changes on A23/A33 when driving VBUS Date: Fri, 19 Jan 2018 17:25:41 +0800 Message-Id: <20180119092541.7508-1-wens@csie.org> X-Mailer: git-send-email 2.15.1 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The AXP223 PMIC, like the AXP221, does not generate VBUS change interrupts when N_VBUSEN is used to drive VBUS for the OTG port on the board. This was not noticed until recently, as most A23/A33 boards use a GPIO pin that does not support interrupts for OTG ID detection. This forces the driver to use polling. However the A33-OlinuXino uses a pin that does support interrupts, so the driver uses them. However the VBUS interrupt never fires, and the driver never gets to update the VBUS status. This results in musb timing out waiting for VBUS to rise. This was worked around for the AXP221 by resorting to polling changes in commit 91d96f06a760 ("phy-sun4i-usb: Add workaround for missing Vbus det interrupts on A31"). This patch adds the A23 and A33 to the list of SoCs that need the workaround. Fixes: fc1f45ed3043 ("phy-sun4i-usb: Add support for the usb-phys on the sun8i-a33 SoC") Fixes: 123dfdbcfaf5 ("phy-sun4i-usb: Add support for the usb-phys on the sun8i-a23 SoC") Cc: # 4.3.x: 68dbc2ce77bb phy-sun4i-usb: Use of_match_node to get model specific config data Cc: # 4.3.x: 5cf700ac9d50 phy: phy-sun4i-usb: Fix optional gpios failing probe Cc: # 4.3.x: 04e59a0211ff phy-sun4i-usb: Fix irq free conditions to match request conditions Cc: # 4.3.x: 91d96f06a760 phy-sun4i-usb: Add workaround for missing Vbus det interrupts on A31 Cc: # 4.3.x Signed-off-by: Chen-Yu Tsai --- This list might get longer if the newer AXP8xx PMICs also have this behavior. We could switch to a boolean in the per-compatible data, or just always use polling. The yet-merged R40 support will have this issue as well, as the R40 is paired with the AXP221. But for now, I'd like to have something that is easier to backport to stable, so we can at least fix this for the A23 and A33. Also, checkpatch.pl doesn't like the stable kernel prerequisite lines. --- drivers/phy/allwinner/phy-sun4i-usb.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/drivers/phy/allwinner/phy-sun4i-usb.c b/drivers/phy/allwinner/phy-sun4i-usb.c index aa857be692cf..d5ae307ef4e1 100644 --- a/drivers/phy/allwinner/phy-sun4i-usb.c +++ b/drivers/phy/allwinner/phy-sun4i-usb.c @@ -410,11 +410,13 @@ static bool sun4i_usb_phy0_poll(struct sun4i_usb_phy_data *data) return true; /* - * The A31 companion pmic (axp221) does not generate vbus change - * interrupts when the board is driving vbus, so we must poll + * The A31/A23/A33 companion pmics (AXP221/AXP223) do not + * generate vbus change interrupts when the board is driving + * vbus using the N_VBUSEN pin on the pmic, so we must poll * when using the pmic for vbus-det _and_ we're driving vbus. */ - if (data->cfg->type == sun6i_a31_phy && + if ((data->cfg->type == sun6i_a31_phy || + data->cfg->type == sun8i_a33_phy) && data->vbus_power_supply && data->phys[0].regulator_on) return true; @@ -885,7 +887,7 @@ static const struct sun4i_usb_phy_cfg sun7i_a20_cfg = { static const struct sun4i_usb_phy_cfg sun8i_a23_cfg = { .num_phys = 2, - .type = sun4i_a10_phy, + .type = sun6i_a31_phy, .disc_thresh = 3, .phyctl_offset = REG_PHYCTL_A10, .dedicated_clocks = true, -- 2.15.1