From 20f795881f4f186fd98d9425053d575b2e577ff5 Mon Sep 17 00:00:00 2001 From: Tony Lindgren Date: Sun, 24 Mar 2019 16:26:54 -0700 Subject: phy: phy-twl4030-usb: Fix cable state handling With the recent regulator changes I noticed new warnings on doing rmmod of phy-twl4030-usb: WARNING: CPU: 0 PID: 1080 at drivers/regulator/core.c:2046 _regulator_put ... Turns out we can currently miss disconnect at least for cases where status is 0 and linkstat is 0. And in that case doing rmmod phy-twl4030-usb will produce the regulator_put() warning. This is because the missed disconnect causes unbalanced PM runtime calls and the regulators will be on exit. Let's fix the issue by using an atomic flag for the cable state to make sure that PM runtime won't get out of sync with the cable state. That way we can also simplify the code a bit. Note that we can also drop the old comments, those relate to issues that the battery charger driver and musb driver is dealing with rather than the USB PHY driver. Cc: NeilBrown Signed-off-by: Tony Lindgren Signed-off-by: Kishon Vijay Abraham I --- drivers/phy/ti/phy-twl4030-usb.c | 35 +++++++++++++---------------------- 1 file changed, 13 insertions(+), 22 deletions(-) (limited to 'drivers/phy') diff --git a/drivers/phy/ti/phy-twl4030-usb.c b/drivers/phy/ti/phy-twl4030-usb.c index c267afb68f07..176e16a36553 100644 --- a/drivers/phy/ti/phy-twl4030-usb.c +++ b/drivers/phy/ti/phy-twl4030-usb.c @@ -172,6 +172,7 @@ struct twl4030_usb { int irq; enum musb_vbus_id_status linkstat; + atomic_t connected; bool vbus_supplied; bool musb_mailbox_pending; @@ -575,39 +576,29 @@ static irqreturn_t twl4030_usb_irq(int irq, void *_twl) { struct twl4030_usb *twl = _twl; enum musb_vbus_id_status status; - bool status_changed = false; int err; status = twl4030_usb_linkstat(twl); mutex_lock(&twl->lock); - if (status >= 0 && status != twl->linkstat) { - status_changed = - cable_present(twl->linkstat) != - cable_present(status); - twl->linkstat = status; - } + twl->linkstat = status; mutex_unlock(&twl->lock); - if (status_changed) { - /* FIXME add a set_power() method so that B-devices can - * configure the charger appropriately. It's not always - * correct to consume VBUS power, and how much current to - * consume is a function of the USB configuration chosen - * by the host. - * - * REVISIT usb_gadget_vbus_connect(...) as needed, ditto - * its disconnect() sibling, when changing to/from the - * USB_LINK_VBUS state. musb_hdrc won't care until it - * starts to handle softconnect right. - */ - if (cable_present(status)) { + if (cable_present(status)) { + if (atomic_add_unless(&twl->connected, 1, 1)) { + dev_dbg(twl->dev, "%s: cable connected %i\n", + __func__, status); pm_runtime_get_sync(twl->dev); - } else { + twl->musb_mailbox_pending = true; + } + } else { + if (atomic_add_unless(&twl->connected, -1, 0)) { + dev_dbg(twl->dev, "%s: cable disconnected %i\n", + __func__, status); pm_runtime_mark_last_busy(twl->dev); pm_runtime_put_autosuspend(twl->dev); + twl->musb_mailbox_pending = true; } - twl->musb_mailbox_pending = true; } if (twl->musb_mailbox_pending) { err = musb_mailbox(status); -- cgit v1.2.3-59-g8ed1b From f7f6ed925d9fc050911a417804524d2bbfa4b4ac Mon Sep 17 00:00:00 2001 From: YueHaibing Date: Tue, 19 Mar 2019 23:30:28 +0800 Subject: phy: rockchip-typec: Make usb3_pll_cfg and dp_pll_cfg static Fix sparse warning: drivers/phy/rockchip/phy-rockchip-typec.c:403:16: warning: symbol 'usb3_pll_cfg' was not declared. Should it be static? drivers/phy/rockchip/phy-rockchip-typec.c:420:16: warning: symbol 'dp_pll_cfg' was not declared. Should it be static? Signed-off-by: YueHaibing Reviewed-by: Heiko Stuebner Signed-off-by: Kishon Vijay Abraham I --- drivers/phy/rockchip/phy-rockchip-typec.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'drivers/phy') diff --git a/drivers/phy/rockchip/phy-rockchip-typec.c b/drivers/phy/rockchip/phy-rockchip-typec.c index e32edeebcd63..8ad366ee6ada 100644 --- a/drivers/phy/rockchip/phy-rockchip-typec.c +++ b/drivers/phy/rockchip/phy-rockchip-typec.c @@ -400,7 +400,7 @@ struct phy_reg { u32 addr; }; -struct phy_reg usb3_pll_cfg[] = { +static struct phy_reg usb3_pll_cfg[] = { { 0xf0, CMN_PLL0_VCOCAL_INIT }, { 0x18, CMN_PLL0_VCOCAL_ITER }, { 0xd0, CMN_PLL0_INTDIV }, @@ -417,7 +417,7 @@ struct phy_reg usb3_pll_cfg[] = { { 0x8, CMN_DIAG_PLL0_LF_PROG }, }; -struct phy_reg dp_pll_cfg[] = { +static struct phy_reg dp_pll_cfg[] = { { 0xf0, CMN_PLL1_VCOCAL_INIT }, { 0x18, CMN_PLL1_VCOCAL_ITER }, { 0x30b9, CMN_PLL1_VCOCAL_START }, -- cgit v1.2.3-59-g8ed1b From e0c546fa72a9b66deb80a2623ffc8b5237840e1b Mon Sep 17 00:00:00 2001 From: YueHaibing Date: Tue, 19 Mar 2019 23:27:38 +0800 Subject: phy: qcom-ufs: Make ufs_qcom_phy_disable_iface_clk static Fix sparse warning: drivers/phy/qualcomm/phy-qcom-ufs.c:462:6: warning: symbol 'ufs_qcom_phy_disable_iface_clk' was not declared. Should it be static? Signed-off-by: YueHaibing Signed-off-by: Kishon Vijay Abraham I --- drivers/phy/qualcomm/phy-qcom-ufs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/phy') diff --git a/drivers/phy/qualcomm/phy-qcom-ufs.c b/drivers/phy/qualcomm/phy-qcom-ufs.c index f2979ccad00a..78c339b2fc8b 100644 --- a/drivers/phy/qualcomm/phy-qcom-ufs.c +++ b/drivers/phy/qualcomm/phy-qcom-ufs.c @@ -459,7 +459,7 @@ out: } /* Turn OFF M-PHY RMMI interface clocks */ -void ufs_qcom_phy_disable_iface_clk(struct ufs_qcom_phy *phy) +static void ufs_qcom_phy_disable_iface_clk(struct ufs_qcom_phy *phy) { if (phy->is_iface_clk_enabled) { clk_disable_unprepare(phy->tx_iface_clk); -- cgit v1.2.3-59-g8ed1b From e03213b9a6eab6456de174afa071af4381e4f2d5 Mon Sep 17 00:00:00 2001 From: Arnd Bergmann Date: Mon, 4 Mar 2019 21:23:56 +0100 Subject: phy: allwinner: allow compile testing Some allwinner specific drivers can be built for testing purposes on non-sunxi configurations, which then results in a harmless warning: WARNING: unmet direct dependencies detected for PHY_SUN6I_MIPI_DPHY Depends on [n]: ARCH_SUNXI [=n] && HAS_IOMEM [=y] && OF [=y] && RESET_CONTROLLER [=y] Selected by [y]: - DRM_SUN6I_DSI [=y] && HAS_IOMEM [=y] && DRM_SUN4I [=y] Allow compile-test here as well to avoid the warning, and improve overall build coverage. Fixes: 5d134abf9530 ("phy: Move Allwinner A31 D-PHY driver to drivers/phy/") Signed-off-by: Arnd Bergmann Acked-by: Maxime Ripard Signed-off-by: Kishon Vijay Abraham I --- drivers/phy/allwinner/Kconfig | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'drivers/phy') diff --git a/drivers/phy/allwinner/Kconfig b/drivers/phy/allwinner/Kconfig index fb1204bcc454..53772d35b36e 100644 --- a/drivers/phy/allwinner/Kconfig +++ b/drivers/phy/allwinner/Kconfig @@ -3,7 +3,8 @@ # config PHY_SUN4I_USB tristate "Allwinner sunxi SoC USB PHY driver" - depends on ARCH_SUNXI && HAS_IOMEM && OF + depends on ARCH_SUNXI || COMPILE_TEST + depends on HAS_IOMEM depends on RESET_CONTROLLER depends on EXTCON depends on POWER_SUPPLY @@ -19,7 +20,8 @@ config PHY_SUN4I_USB config PHY_SUN6I_MIPI_DPHY tristate "Allwinner A31 MIPI D-PHY Support" - depends on ARCH_SUNXI && HAS_IOMEM && OF + depends on ARCH_SUNXI || COMPILE_TEST + depends on HAS_IOMEM depends on RESET_CONTROLLER select GENERIC_PHY select GENERIC_PHY_MIPI_DPHY @@ -31,7 +33,8 @@ config PHY_SUN6I_MIPI_DPHY config PHY_SUN9I_USB tristate "Allwinner sun9i SoC USB PHY driver" - depends on ARCH_SUNXI && HAS_IOMEM && OF + depends on ARCH_SUNXI || COMPILE_TEST + depends on HAS_IOMEM depends on RESET_CONTROLLER depends on USB_SUPPORT select USB_COMMON -- cgit v1.2.3-59-g8ed1b From d41ce98a122c13ea77938af04ef06fb12ae0c69e Mon Sep 17 00:00:00 2001 From: Arnd Bergmann Date: Mon, 4 Mar 2019 21:23:57 +0100 Subject: phy: ti: usb2: fix OMAP_CONTROL_PHY dependency With randconfig build testing on arm64, we can run into a configuration that has CONFIG_OMAP_CONTROL_PHY=m and CONFIG_OMAP_USB2=y, which in turn causes a link failure: drivers/phy/ti/phy-omap-usb2.o: In function `omap_usb_phy_power': phy-omap-usb2.c:(.text+0x17c): undefined reference to `omap_control_phy_power' I could not come up with a good way to correctly describe the relation of the two symbols, but if we just select CONFIG_OMAP_CONTROL_PHY during compile testing, we can no longer run into the broken configuration. Fixes: 6777cee3a872 ("phy: ti: usb2: Add support for AM654 USB2 PHY") Signed-off-by: Arnd Bergmann Signed-off-by: Kishon Vijay Abraham I --- drivers/phy/ti/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/phy') diff --git a/drivers/phy/ti/Kconfig b/drivers/phy/ti/Kconfig index 103efc456a12..022ac16f626c 100644 --- a/drivers/phy/ti/Kconfig +++ b/drivers/phy/ti/Kconfig @@ -37,7 +37,7 @@ config OMAP_USB2 depends on USB_SUPPORT select GENERIC_PHY select USB_PHY - select OMAP_CONTROL_PHY if ARCH_OMAP2PLUS + select OMAP_CONTROL_PHY if ARCH_OMAP2PLUS || COMPILE_TEST help Enable this to support the transceiver that is part of SOC. This driver takes care of all the PHY functionality apart from comparator. -- cgit v1.2.3-59-g8ed1b From 208d3423ee463ab257908456f6bbca4024ab63f7 Mon Sep 17 00:00:00 2001 From: Arnd Bergmann Date: Mon, 4 Mar 2019 21:23:58 +0100 Subject: phy: mapphone-mdm6600: add gpiolib dependency gcc points out that when CONFIG_GPIOLIB is disabled, gpiod_get_array_value_cansleep() returns 0 but fails to set its output: drivers/phy/motorola/phy-mapphone-mdm6600.c: In function 'phy_mdm6600_status': drivers/phy/motorola/phy-mapphone-mdm6600.c:220:24: error: 'values[0]' is used uninitialized in this function [-Werror=uninitialized] This could be fixed more generally in gpiolib by returning a failure code, but for this specific case, the easier workaround is to add a gpiolib dependency. Fixes: 5d1ebbda0318 ("phy: mapphone-mdm6600: Add USB PHY driver for MDM6600 on Droid 4") Signed-off-by: Arnd Bergmann Acked-by: Tony Lindgren Signed-off-by: Kishon Vijay Abraham I --- drivers/phy/motorola/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/phy') diff --git a/drivers/phy/motorola/Kconfig b/drivers/phy/motorola/Kconfig index 82651524ffb9..718f8729701d 100644 --- a/drivers/phy/motorola/Kconfig +++ b/drivers/phy/motorola/Kconfig @@ -13,7 +13,7 @@ config PHY_CPCAP_USB config PHY_MAPPHONE_MDM6600 tristate "Motorola Mapphone MDM6600 modem USB PHY driver" - depends on OF && USB_SUPPORT + depends on OF && USB_SUPPORT && GPIOLIB select GENERIC_PHY help Enable this for MDM6600 USB modem to work on Motorola phones -- cgit v1.2.3-59-g8ed1b From 9dc211c6139b6680db8904547f7c5e23faec7eb5 Mon Sep 17 00:00:00 2001 From: YueHaibing Date: Thu, 14 Feb 2019 01:51:17 +0000 Subject: phy: fix platform_no_drv_owner.cocci warnings Remove .owner field if calls are used which set it automatically Generated by: scripts/coccinelle/api/platform_no_drv_owner.cocci Signed-off-by: YueHaibing Signed-off-by: Kishon Vijay Abraham I --- drivers/phy/marvell/phy-mvebu-a3700-utmi.c | 1 - 1 file changed, 1 deletion(-) (limited to 'drivers/phy') diff --git a/drivers/phy/marvell/phy-mvebu-a3700-utmi.c b/drivers/phy/marvell/phy-mvebu-a3700-utmi.c index 94a29dea57af..ded900b06f5a 100644 --- a/drivers/phy/marvell/phy-mvebu-a3700-utmi.c +++ b/drivers/phy/marvell/phy-mvebu-a3700-utmi.c @@ -266,7 +266,6 @@ static struct platform_driver mvebu_a3700_utmi_driver = { .probe = mvebu_a3700_utmi_phy_probe, .driver = { .name = "mvebu-a3700-utmi-phy", - .owner = THIS_MODULE, .of_match_table = mvebu_a3700_utmi_of_match, }, }; -- cgit v1.2.3-59-g8ed1b From e6f32efb1b128344a2c7df9875bc1a1abaa1d395 Mon Sep 17 00:00:00 2001 From: Paul Kocialkowski Date: Thu, 14 Mar 2019 14:05:18 +0100 Subject: phy: sun4i-usb: Make sure to disable PHY0 passby for peripheral mode On platforms where the MUSB and HCI controllers share PHY0, PHY passby is required when using the HCI controller with the PHY, but it must be disabled when the MUSB controller is used instead. Without this, PHY0 passby is always enabled, which results in broken peripheral mode on such platforms (e.g. H3/H5). Fixes: ba4bdc9e1dc0 ("PHY: sunxi: Add driver for sunxi usb phy") Signed-off-by: Paul Kocialkowski Signed-off-by: Kishon Vijay Abraham I --- drivers/phy/allwinner/phy-sun4i-usb.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'drivers/phy') diff --git a/drivers/phy/allwinner/phy-sun4i-usb.c b/drivers/phy/allwinner/phy-sun4i-usb.c index 5163097b43df..7b23920e0068 100644 --- a/drivers/phy/allwinner/phy-sun4i-usb.c +++ b/drivers/phy/allwinner/phy-sun4i-usb.c @@ -551,6 +551,7 @@ static void sun4i_usb_phy0_id_vbus_det_scan(struct work_struct *work) struct sun4i_usb_phy_data *data = container_of(work, struct sun4i_usb_phy_data, detect.work); struct phy *phy0 = data->phys[0].phy; + struct sun4i_usb_phy *phy = phy_get_drvdata(phy0); bool force_session_end, id_notify = false, vbus_notify = false; int id_det, vbus_det; @@ -607,6 +608,9 @@ static void sun4i_usb_phy0_id_vbus_det_scan(struct work_struct *work) mutex_unlock(&phy0->mutex); } + /* Enable PHY0 passby for host mode only. */ + sun4i_usb_phy_passby(phy, !id_det); + /* Re-route PHY0 if necessary */ if (data->cfg->phy0_dual_route) sun4i_usb_phy0_reroute(data, id_det); -- cgit v1.2.3-59-g8ed1b