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

usb: ehci-orion: add optional PHY support

This commit extends the ehci-orion so that it can optionally be passed
a reference to a PHY through the Device Tree. It will be useful for
the Armada 375 SoCs. If no PHY is provided then the behavior of the
driver is unchanged.

[Thomas: use devm_phy_optional_get() so that we handle -EPROBE_DEFER
properly. Also call phy_power_off() when needed, and rename goto
labels.]

Signed-off-by: Gregory CLEMENT <gregory.clement@free-electrons.com>
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Acked-by: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Gregory CLEMENT and committed by
Greg Kroah-Hartman
d445913c ac069662

+28
+28
drivers/usb/host/ehci-orion.c
··· 15 15 #include <linux/clk.h> 16 16 #include <linux/platform_data/usb-ehci-orion.h> 17 17 #include <linux/of.h> 18 + #include <linux/phy/phy.h> 18 19 #include <linux/of_device.h> 19 20 #include <linux/of_irq.h> 20 21 #include <linux/usb.h> ··· 47 46 48 47 struct orion_ehci_hcd { 49 48 struct clk *clk; 49 + struct phy *phy; 50 50 }; 51 51 52 52 static const char hcd_name[] = "ehci-orion"; ··· 223 221 if (!IS_ERR(priv->clk)) 224 222 clk_prepare_enable(priv->clk); 225 223 224 + priv->phy = devm_phy_optional_get(&pdev->dev, "usb"); 225 + if (IS_ERR(priv->phy)) { 226 + err = PTR_ERR(priv->phy); 227 + goto err_phy_get; 228 + } else { 229 + err = phy_init(priv->phy); 230 + if (err) 231 + goto err_phy_init; 232 + 233 + err = phy_power_on(priv->phy); 234 + if (err) 235 + goto err_phy_power_on; 236 + } 237 + 226 238 /* 227 239 * (Re-)program MBUS remapping windows if we are asked to. 228 240 */ ··· 272 256 return 0; 273 257 274 258 err_add_hcd: 259 + if (!IS_ERR(priv->phy)) 260 + phy_power_off(priv->phy); 261 + err_phy_power_on: 262 + if (!IS_ERR(priv->phy)) 263 + phy_exit(priv->phy); 264 + err_phy_init: 265 + err_phy_get: 275 266 if (!IS_ERR(priv->clk)) 276 267 clk_disable_unprepare(priv->clk); 277 268 usb_put_hcd(hcd); ··· 295 272 struct orion_ehci_hcd *priv = hcd_to_orion_priv(hcd); 296 273 297 274 usb_remove_hcd(hcd); 275 + 276 + if (!IS_ERR(priv->phy)) { 277 + phy_power_off(priv->phy); 278 + phy_exit(priv->phy); 279 + } 298 280 299 281 if (!IS_ERR(priv->clk)) 300 282 clk_disable_unprepare(priv->clk);