summaryrefslogtreecommitdiff
path: root/drivers/phy
diff options
context:
space:
mode:
authorAndre Przywara <[email protected]>2025-03-30 17:13:23 +0100
committerTom Rini <[email protected]>2025-04-28 12:45:44 -0600
commitaf24fbb24a35cd892c27fbbea3caed726211f018 (patch)
treea6ffdb816e1f187c5d29bc26d11c3e77bddb82ad /drivers/phy
parent01658ef333b9e1a92daa35de8f4052bed98e0d47 (diff)
phy: sun4i-usb: Determine VBUS detection pin from devicetree
So far Allwinner boards controlled the USB VBUS detection via the respective GPIO pin specified in Kconfig, as a string. All boards should have the same GPIO already specified in the devicetree, in the usb0_vbus_det-gpios property. Convert the usage of the Kconfig configured GPIO over to query that information from the devicetree, then use the existing DM GPIO infrastructure to request the GPIO. Only PHY0 supports USB-OTG, so limit the GPIO request to that PHY, to avoid claiming it multiple times. This removes the need to name that GPIO in the defconfig file. Signed-off-by: Andre Przywara <[email protected]> Reviewed-by: Jernej Skrabec <[email protected]>
Diffstat (limited to 'drivers/phy')
-rw-r--r--drivers/phy/allwinner/phy-sun4i-usb.c24
1 files changed, 9 insertions, 15 deletions
diff --git a/drivers/phy/allwinner/phy-sun4i-usb.c b/drivers/phy/allwinner/phy-sun4i-usb.c
index 2def87897d4..42e67b47328 100644
--- a/drivers/phy/allwinner/phy-sun4i-usb.c
+++ b/drivers/phy/allwinner/phy-sun4i-usb.c
@@ -86,23 +86,18 @@ struct sun4i_usb_phy_cfg {
};
struct sun4i_usb_phy_info {
- const char *gpio_vbus_det;
const char *gpio_id_det;
} phy_info[] = {
{
- .gpio_vbus_det = CONFIG_USB0_VBUS_DET,
.gpio_id_det = CONFIG_USB0_ID_DET,
},
{
- .gpio_vbus_det = NULL,
.gpio_id_det = NULL,
},
{
- .gpio_vbus_det = NULL,
.gpio_id_det = NULL,
},
{
- .gpio_vbus_det = NULL,
.gpio_id_det = NULL,
},
};
@@ -494,17 +489,16 @@ static int sun4i_usb_phy_probe(struct udevice *dev)
return ret;
}
- ret = dm_gpio_lookup_name(info->gpio_vbus_det,
- &phy->gpio_vbus_det);
- if (ret == 0) {
- ret = dm_gpio_request(&phy->gpio_vbus_det,
- "usb_vbus_det");
- if (ret)
- return ret;
- ret = dm_gpio_set_dir_flags(&phy->gpio_vbus_det,
- GPIOD_IS_IN);
- if (ret)
+ if (i == 0) {
+ ret = gpio_request_by_name(dev, "usb0_vbus_det-gpios",
+ 0, &phy->gpio_vbus_det,
+ GPIOD_IS_IN);
+ if (ret && ret != -ENOENT) {
+ dev_err(dev,
+ "failed to get VBUS detect GPIO: %d\n",
+ ret);
return ret;
+ }
}
ret = dm_gpio_lookup_name(info->gpio_id_det, &phy->gpio_id_det);