Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

phy: allwinner: sun4i-usb: poll vbus changes on A23/A33 when driving VBUS

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: <stable@vger.kernel.org> # 4.3.x: 68dbc2ce77bb phy-sun4i-usb:
Use of_match_node to get model specific config data
Cc: <stable@vger.kernel.org> # 4.3.x: 5cf700ac9d50 phy: phy-sun4i-usb:
Fix optional gpios failing probe
Cc: <stable@vger.kernel.org> # 4.3.x: 04e59a0211ff phy-sun4i-usb:
Fix irq free conditions to match request conditions
Cc: <stable@vger.kernel.org> # 4.3.x: 91d96f06a760 phy-sun4i-usb:
Add workaround for missing Vbus det interrupts on A31
Cc: <stable@vger.kernel.org> # 4.3.x
Signed-off-by: Chen-Yu Tsai <wens@csie.org>
Acked-by: Maxime Ripard <maxime.ripard@free-electrons.com>
Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>

Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>

authored by

Chen-Yu Tsai and committed by
Kishon Vijay Abraham I
d7119224 ae91a799

+6 -4
+6 -4
drivers/phy/allwinner/phy-sun4i-usb.c
··· 411 411 return true; 412 412 413 413 /* 414 - * The A31 companion pmic (axp221) does not generate vbus change 415 - * interrupts when the board is driving vbus, so we must poll 414 + * The A31/A23/A33 companion pmics (AXP221/AXP223) do not 415 + * generate vbus change interrupts when the board is driving 416 + * vbus using the N_VBUSEN pin on the pmic, so we must poll 416 417 * when using the pmic for vbus-det _and_ we're driving vbus. 417 418 */ 418 - if (data->cfg->type == sun6i_a31_phy && 419 + if ((data->cfg->type == sun6i_a31_phy || 420 + data->cfg->type == sun8i_a33_phy) && 419 421 data->vbus_power_supply && data->phys[0].regulator_on) 420 422 return true; 421 423 ··· 888 886 889 887 static const struct sun4i_usb_phy_cfg sun8i_a23_cfg = { 890 888 .num_phys = 2, 891 - .type = sun4i_a10_phy, 889 + .type = sun6i_a31_phy, 892 890 .disc_thresh = 3, 893 891 .phyctl_offset = REG_PHYCTL_A10, 894 892 .dedicated_clocks = true,