phy-sun4i-usb: 3 misc. fixes
Subsystems (2)
cover phy-sun4i-usb: 3 misc. fixes
Hi Kishon,
Here are 3 small patches for the phy-sun4i-usb code.
The first patch is a small bugfix for building the sun4i musb code as module which seems to have fallen through the cracks.
The second patch is a preparation patch for the third patch which fixes the case of boards with a working VBus regulator, but broken VBus detection support, yes unfortunately such boards exist.
Can you please merge these 3 into linux-phy/next ?
Thanks & Regards,
Hans
PATCH 1/3 phy-sun4i-usb: Add missing EXPORT_SYMBOL for sun4i_usb_phy_set_squelch_detect
sun4i_usb_phy_set_squelch_detect is used by other code, which may be built as a module, so it should be exported.
---
Changes in v6:
-New patch in v6 of the sunxi musb support series
--- drivers/phy/phy-sun4i-usb.c | 1 + 1 file changed, 1 insertion(+)
drivers/phy/phy-sun4i-usb.c +1 -0
@@ -347,6 +347,7 @@ void sun4i_usb_phy_set_squelch_detect(struct phy *_phy, bool enabled)sun4i_usb_phy_write (phy,PHY_SQUELCH_DETECT , enabled ?0 :2 ,2 ); } +EXPORT_SYMBOL (sun4i_usb_phy_set_squelch_detect);static struct phy_ops sun4i_usb_phy_ops = { .init = sun4i_usb_phy_init,
Signature · 1 line
2.4.3
PATCH 1/3 phy-sun4i-usb: Add missing EXPORT_SYMBOL for sun4i_usb_phy_set_squelch_detect
Hi,
Quoted 16 lines · Hans de Goede
sun4i_usb_phy_set_squelch_detectis used by other code, which may be built as a module, so it should be exported.Signed-off-by Hans de Goede <[email protected]>---
Changes in v6:(quoted diff) +0
-2-New patch in v6 of the sunxi musb support series --- drivers/phy/phy-sun4i-usb.c | 1 + 1 file changed, 1 insertion(+)drivers/phy/phy-sun4i-usb.c +0
-0
drivers/phy/phy-sun4i-usb.c void sun4i_usb_phy_set_squelch_detect(struct phy *_phy, bool enabled) · line 350
Quoted 4 lines
drivers/phy/phy-sun4i-usb.c +1
-0@@ -347,6 +347,7 @@ void sun4i_usb_phy_set_squelch_detect(struct phy *_phy, bool enabled)sun4i_usb_phy_write (phy,PHY_SQUELCH_DETECT , enabled ?0 :2 ,2 ); } +EXPORT_SYMBOL (sun4i_usb_phy_set_squelch_detect);
changed it to EXPORT_SYMBOL_GPL and merged it.
Thanks
Kishon
PATCH 2/3 phy-sun4i-sub: Move vbus-detect helper functions up in the file
In reply to Hans de GoedeMove vbus-detect helper functions up in the file, just moving some code around, no functional changes what so ever.
--- drivers/phy/phy-sun4i-usb.c | 48 ++++++++++++++++++++++----------------------- 1 file changed, 24 insertions(+), 24 deletions(-)
drivers/phy/phy-sun4i-usb.c +24 -24
@@ -294,6 +294,30 @@ static int sun4i_usb_phy_exit(struct phy *_phy)return 0 ; } +static int sun4i_usb_phy0_get_vbus_det (struct sun4i_usb_phy_data *data) +{ +if (data->vbus_det_gpio) +return gpiod_get_value_cansleep (data->vbus_det_gpio); + +if (data->vbus_power_supply) { +union power_supply_propval val; +int r; + + r =power_supply_get_property (data->vbus_power_supply, +POWER_SUPPLY_PROP_PRESENT , &val); +if (r ==0 ) +return val.intval; + } + +/* Fallback: report vbus as high */ +return 1 ; +} + +static bool sun4i_usb_phy0_have_vbus_det (struct sun4i_usb_phy_data *data) +{ +return data->vbus_det_gpio || data->vbus_power_supply; +} +static int sun4i_usb_phy_power_on (struct phy *_phy) {struct sun4i_usb_phy *phy =phy_get_drvdata (_phy);
@@ -357,30 +381,6 @@ static struct phy_ops sun4i_usb_phy_ops = { .owner = THIS_MODULE, }; -static int sun4i_usb_phy0_get_vbus_det (struct sun4i_usb_phy_data *data) -{ -if (data->vbus_det_gpio) -return gpiod_get_value_cansleep (data->vbus_det_gpio); - -if (data->vbus_power_supply) { -union power_supply_propval val; -int r; - - r =power_supply_get_property (data->vbus_power_supply, -POWER_SUPPLY_PROP_PRESENT , &val); -if (r ==0 ) -return val.intval; - } - -/* Fallback: report vbus as high */ -return 1 ; -} - -static bool sun4i_usb_phy0_have_vbus_det (struct sun4i_usb_phy_data *data) -{ -return data->vbus_det_gpio || data->vbus_power_supply; -} -static void sun4i_usb_phy0_id_vbus_det_scan (struct work_struct *work) { struct sun4i_usb_phy_data *data =
Signature · 1 line
2.4.3
PATCH 3/3 phy-sun4i-usb: Only check vbus-det on power-on on boards with vbus-det
In reply to Hans de Goededata->vbus_det is always 1 on boards without a (working) vbus-det, skip the vbus_det test on such boards.
This fixes the sun4i usb phy code never turning on Vbus on such boards.
--- drivers/phy/phy-sun4i-usb.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/phy/phy-sun4i-usb.c +2 -1
@@ -328,7 +328,8 @@ static int sun4i_usb_phy_power_on(struct phy *_phy)return 0 ;/* For phy0 only turn on Vbus if we don't have an ext. Vbus */ -if (phy->index ==0 && data->vbus_det) +if (phy->index ==0 &&sun4i_usb_phy0_have_vbus_det (data) && + data->vbus_det)return 0 ; ret =regulator_enable (phy->vbus);
Signature · 1 line
2.4.3