Skip to content

Commit

Permalink
usb: musb: jz4740: obtain USB PHY from devicetree
Browse files Browse the repository at this point in the history
Fall back to devm_usb_get_phy() if devicetree is not available.

Signed-off-by: Paul Cercueil <paul@crapouillou.net>
Signed-off-by: Bin Liu <b-liu@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
Paul Cercueil authored and Greg Kroah-Hartman committed Apr 30, 2019
1 parent 82257c7 commit afbdbd3
Showing 1 changed file with 7 additions and 10 deletions.
17 changes: 7 additions & 10 deletions drivers/usb/musb/jz4740.c
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,14 @@ static struct musb_hdrc_platform_data jz4740_musb_platform_data = {

static int jz4740_musb_init(struct musb *musb)
{
musb->xceiv = usb_get_phy(USB_PHY_TYPE_USB2);
struct device *dev = musb->controller->parent;

if (dev->of_node)
musb->xceiv = devm_usb_get_phy_by_phandle(dev, "phys", 0);
else
musb->xceiv = devm_usb_get_phy(dev, USB_PHY_TYPE_USB2);
if (IS_ERR(musb->xceiv)) {
pr_err("HS UDC: no transceiver configured\n");
dev_err(dev, "No transceiver configured\n");
return PTR_ERR(musb->xceiv);
}

Expand All @@ -90,13 +95,6 @@ static int jz4740_musb_init(struct musb *musb)
return 0;
}

static int jz4740_musb_exit(struct musb *musb)
{
usb_put_phy(musb->xceiv);

return 0;
}

/*
* DMA has not been confirmed to work with CONFIG_USB_INVENTRA_DMA,
* so let's not set up the dma function pointers yet.
Expand All @@ -105,7 +103,6 @@ static const struct musb_platform_ops jz4740_musb_ops = {
.quirks = MUSB_DMA_INVENTRA | MUSB_INDEXED_EP,
.fifo_mode = 2,
.init = jz4740_musb_init,
.exit = jz4740_musb_exit,
};

static int jz4740_probe(struct platform_device *pdev)
Expand Down

0 comments on commit afbdbd3

Please sign in to comment.