Skip to content

Commit

Permalink
usb: Convert all users to new usb_phy
Browse files Browse the repository at this point in the history
Use the new usb_phy_* functions with transceiver
operations instead of the old otg functions.

Includes fixes from Sascha Hauer.

Signed-off-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
Acked-by: Sascha Hauer <s.hauer@pengutronix.de>
Acked-by: Pavankumar Kondeti <pkondeti@codeaurora.org>
Acked-by: Li Yang <leoli@freescale.com>
Acked-by: Alan Stern <stern@rowland.harvard.edu>
Reviewed-by: Marek Vasut <marek.vasut@gmail.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
  • Loading branch information
Heikki Krogerus authored and Felipe Balbi committed Feb 27, 2012
1 parent b1c711d commit b96d3b0
Show file tree
Hide file tree
Showing 25 changed files with 86 additions and 83 deletions.
4 changes: 2 additions & 2 deletions arch/arm/mach-tegra/usb_phy.c
Original file line number Diff line number Diff line change
Expand Up @@ -608,13 +608,13 @@ static int ulpi_phy_power_on(struct tegra_usb_phy *phy)
writel(val, base + ULPI_TIMING_CTRL_1);

/* Fix VbusInvalid due to floating VBUS */
ret = otg_io_write(phy->ulpi, 0x40, 0x08);
ret = usb_phy_io_write(phy->ulpi, 0x40, 0x08);
if (ret) {
pr_err("%s: ulpi write failed\n", __func__);
return ret;
}

ret = otg_io_write(phy->ulpi, 0x80, 0x0B);
ret = usb_phy_io_write(phy->ulpi, 0x80, 0x0B);
if (ret) {
pr_err("%s: ulpi write failed\n", __func__);
return ret;
Expand Down
4 changes: 2 additions & 2 deletions drivers/usb/gadget/ci13xxx_msm.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,10 @@ static void ci13xxx_msm_notify_event(struct ci13xxx *udc, unsigned event)
* Put the transceiver in non-driving mode. Otherwise host
* may not detect soft-disconnection.
*/
val = otg_io_read(udc->transceiver, ULPI_FUNC_CTRL);
val = usb_phy_io_read(udc->transceiver, ULPI_FUNC_CTRL);
val &= ~ULPI_FUNC_CTRL_OPMODE_MASK;
val |= ULPI_FUNC_CTRL_OPMODE_NONDRIVING;
otg_io_write(udc->transceiver, val, ULPI_FUNC_CTRL);
usb_phy_io_write(udc->transceiver, val, ULPI_FUNC_CTRL);
break;
default:
dev_dbg(dev, "unknown ci13xxx_udc event\n");
Expand Down
10 changes: 5 additions & 5 deletions drivers/usb/gadget/ci13xxx_udc.c
Original file line number Diff line number Diff line change
Expand Up @@ -2537,7 +2537,7 @@ static int ci13xxx_vbus_draw(struct usb_gadget *_gadget, unsigned mA)
struct ci13xxx *udc = container_of(_gadget, struct ci13xxx, gadget);

if (udc->transceiver)
return otg_set_power(udc->transceiver, mA);
return usb_phy_set_power(udc->transceiver, mA);
return -ENOTSUPP;
}

Expand Down Expand Up @@ -2900,7 +2900,7 @@ static int udc_probe(struct ci13xxx_udc_driver *driver, struct device *dev,
if (retval < 0)
goto free_udc;

udc->transceiver = otg_get_transceiver();
udc->transceiver = usb_get_transceiver();

if (udc->udc_driver->flags & CI13XXX_REQUIRE_TRANSCEIVER) {
if (udc->transceiver == NULL) {
Expand Down Expand Up @@ -2946,7 +2946,7 @@ static int udc_probe(struct ci13xxx_udc_driver *driver, struct device *dev,
remove_trans:
if (udc->transceiver) {
otg_set_peripheral(udc->transceiver, &udc->gadget);
otg_put_transceiver(udc->transceiver);
usb_put_transceiver(udc->transceiver);
}

err("error = %i", retval);
Expand All @@ -2958,7 +2958,7 @@ static int udc_probe(struct ci13xxx_udc_driver *driver, struct device *dev,
device_unregister(&udc->gadget.dev);
put_transceiver:
if (udc->transceiver)
otg_put_transceiver(udc->transceiver);
usb_put_transceiver(udc->transceiver);
free_udc:
kfree(udc);
_udc = NULL;
Expand All @@ -2982,7 +2982,7 @@ static void udc_remove(void)

if (udc->transceiver) {
otg_set_peripheral(udc->transceiver, &udc->gadget);
otg_put_transceiver(udc->transceiver);
usb_put_transceiver(udc->transceiver);
}
#ifdef CONFIG_USB_GADGET_DEBUG_FILES
dbg_remove_files(&udc->gadget.dev);
Expand Down
4 changes: 2 additions & 2 deletions drivers/usb/gadget/fsl_udc_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -1217,7 +1217,7 @@ static int fsl_vbus_draw(struct usb_gadget *gadget, unsigned mA)

udc = container_of(gadget, struct fsl_udc, gadget);
if (udc->transceiver)
return otg_set_power(udc->transceiver, mA);
return usb_phy_set_power(udc->transceiver, mA);
return -ENOTSUPP;
}

Expand Down Expand Up @@ -2430,7 +2430,7 @@ static int __init fsl_udc_probe(struct platform_device *pdev)

#ifdef CONFIG_USB_OTG
if (pdata->operating_mode == FSL_USB2_DR_OTG) {
udc_controller->transceiver = otg_get_transceiver();
udc_controller->transceiver = usb_get_transceiver();
if (!udc_controller->transceiver) {
ERR("Can't find OTG driver!\n");
ret = -ENODEV;
Expand Down
4 changes: 2 additions & 2 deletions drivers/usb/gadget/langwell_udc.c
Original file line number Diff line number Diff line change
Expand Up @@ -1261,9 +1261,9 @@ static int langwell_vbus_draw(struct usb_gadget *_gadget, unsigned mA)
dev_vdbg(&dev->pdev->dev, "---> %s()\n", __func__);

if (dev->transceiver) {
dev_vdbg(&dev->pdev->dev, "otg_set_power\n");
dev_vdbg(&dev->pdev->dev, "usb_phy_set_power\n");
dev_vdbg(&dev->pdev->dev, "<--- %s()\n", __func__);
return otg_set_power(dev->transceiver, mA);
return usb_phy_set_power(dev->transceiver, mA);
}

dev_vdbg(&dev->pdev->dev, "<--- %s()\n", __func__);
Expand Down
2 changes: 1 addition & 1 deletion drivers/usb/gadget/mv_udc_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -2181,7 +2181,7 @@ static int __devinit mv_udc_probe(struct platform_device *dev)

#ifdef CONFIG_USB_OTG_UTILS
if (pdata->mode == MV_USB_MODE_OTG)
udc->transceiver = otg_get_transceiver();
udc->transceiver = usb_get_transceiver();
#endif

udc->clknum = pdata->clknum;
Expand Down
14 changes: 8 additions & 6 deletions drivers/usb/gadget/omap_udc.c
Original file line number Diff line number Diff line change
Expand Up @@ -1345,7 +1345,7 @@ static int omap_vbus_draw(struct usb_gadget *gadget, unsigned mA)

udc = container_of(gadget, struct omap_udc, gadget);
if (udc->transceiver)
return otg_set_power(udc->transceiver, mA);
return usb_phy_set_power(udc->transceiver, mA);
return -EOPNOTSUPP;
}

Expand Down Expand Up @@ -1839,11 +1839,13 @@ static void devstate_irq(struct omap_udc *udc, u16 irq_src)
spin_lock(&udc->lock);
}
if (udc->transceiver)
otg_set_suspend(udc->transceiver, 1);
usb_phy_set_suspend(
udc->transceiver, 1);
} else {
VDBG("resume\n");
if (udc->transceiver)
otg_set_suspend(udc->transceiver, 0);
usb_phy_set_suspend(
udc->transceiver, 0);
if (udc->gadget.speed == USB_SPEED_FULL
&& udc->driver->resume) {
spin_unlock(&udc->lock);
Expand Down Expand Up @@ -2863,7 +2865,7 @@ static int __init omap_udc_probe(struct platform_device *pdev)
* use it. Except for OTG, we don't _need_ to talk to one;
* but not having one probably means no VBUS detection.
*/
xceiv = otg_get_transceiver();
xceiv = usb_get_transceiver();
if (xceiv)
type = xceiv->label;
else if (config->otg) {
Expand Down Expand Up @@ -3009,7 +3011,7 @@ static int __init omap_udc_probe(struct platform_device *pdev)

cleanup0:
if (xceiv)
otg_put_transceiver(xceiv);
usb_put_transceiver(xceiv);

if (cpu_is_omap16xx() || cpu_is_omap24xx() || cpu_is_omap7xx()) {
clk_disable(hhc_clk);
Expand Down Expand Up @@ -3039,7 +3041,7 @@ static int __exit omap_udc_remove(struct platform_device *pdev)

pullup_disable(udc);
if (udc->transceiver) {
otg_put_transceiver(udc->transceiver);
usb_put_transceiver(udc->transceiver);
udc->transceiver = NULL;
}
omap_writew(0, UDC_SYSCON1);
Expand Down
8 changes: 4 additions & 4 deletions drivers/usb/gadget/pxa25x_udc.c
Original file line number Diff line number Diff line change
Expand Up @@ -995,7 +995,7 @@ static int pxa25x_udc_vbus_draw(struct usb_gadget *_gadget, unsigned mA)
udc = container_of(_gadget, struct pxa25x_udc, gadget);

if (udc->transceiver)
return otg_set_power(udc->transceiver, mA);
return usb_phy_set_power(udc->transceiver, mA);
return -EOPNOTSUPP;
}

Expand Down Expand Up @@ -2159,7 +2159,7 @@ static int __init pxa25x_udc_probe(struct platform_device *pdev)
dev->dev = &pdev->dev;
dev->mach = pdev->dev.platform_data;

dev->transceiver = otg_get_transceiver();
dev->transceiver = usb_get_transceiver();

if (gpio_is_valid(dev->mach->gpio_pullup)) {
if ((retval = gpio_request(dev->mach->gpio_pullup,
Expand Down Expand Up @@ -2238,7 +2238,7 @@ static int __init pxa25x_udc_probe(struct platform_device *pdev)
gpio_free(dev->mach->gpio_pullup);
err_gpio_pullup:
if (dev->transceiver) {
otg_put_transceiver(dev->transceiver);
usb_put_transceiver(dev->transceiver);
dev->transceiver = NULL;
}
clk_put(dev->clk);
Expand Down Expand Up @@ -2280,7 +2280,7 @@ static int __exit pxa25x_udc_remove(struct platform_device *pdev)
clk_put(dev->clk);

if (dev->transceiver) {
otg_put_transceiver(dev->transceiver);
usb_put_transceiver(dev->transceiver);
dev->transceiver = NULL;
}

Expand Down
6 changes: 3 additions & 3 deletions drivers/usb/gadget/pxa27x_udc.c
Original file line number Diff line number Diff line change
Expand Up @@ -1666,7 +1666,7 @@ static int pxa_udc_vbus_draw(struct usb_gadget *_gadget, unsigned mA)

udc = to_gadget_udc(_gadget);
if (udc->transceiver)
return otg_set_power(udc->transceiver, mA);
return usb_phy_set_power(udc->transceiver, mA);
return -EOPNOTSUPP;
}

Expand Down Expand Up @@ -2463,7 +2463,7 @@ static int __init pxa_udc_probe(struct platform_device *pdev)

udc->dev = &pdev->dev;
udc->mach = pdev->dev.platform_data;
udc->transceiver = otg_get_transceiver();
udc->transceiver = usb_get_transceiver();

gpio = udc->mach->gpio_pullup;
if (gpio_is_valid(gpio)) {
Expand Down Expand Up @@ -2542,7 +2542,7 @@ static int __exit pxa_udc_remove(struct platform_device *_dev)
if (gpio_is_valid(gpio))
gpio_free(gpio);

otg_put_transceiver(udc->transceiver);
usb_put_transceiver(udc->transceiver);

udc->transceiver = NULL;
platform_set_drvdata(_dev, NULL);
Expand Down
6 changes: 3 additions & 3 deletions drivers/usb/gadget/s3c-hsudc.c
Original file line number Diff line number Diff line change
Expand Up @@ -1243,7 +1243,7 @@ static int s3c_hsudc_vbus_draw(struct usb_gadget *gadget, unsigned mA)
return -ENODEV;

if (hsudc->transceiver)
return otg_set_power(hsudc->transceiver, mA);
return usb_phy_set_power(hsudc->transceiver, mA);

return -EOPNOTSUPP;
}
Expand Down Expand Up @@ -1275,7 +1275,7 @@ static int __devinit s3c_hsudc_probe(struct platform_device *pdev)
hsudc->dev = dev;
hsudc->pd = pdev->dev.platform_data;

hsudc->transceiver = otg_get_transceiver();
hsudc->transceiver = usb_get_transceiver();

for (i = 0; i < ARRAY_SIZE(hsudc->supplies); i++)
hsudc->supplies[i].supply = s3c_hsudc_supply_names[i];
Expand Down Expand Up @@ -1377,7 +1377,7 @@ static int __devinit s3c_hsudc_probe(struct platform_device *pdev)
release_mem_region(res->start, resource_size(res));
err_res:
if (hsudc->transceiver)
otg_put_transceiver(hsudc->transceiver);
usb_put_transceiver(hsudc->transceiver);

regulator_bulk_free(ARRAY_SIZE(hsudc->supplies), hsudc->supplies);
err_supplies:
Expand Down
2 changes: 1 addition & 1 deletion drivers/usb/host/ehci-fsl.c
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ static int usb_hcd_fsl_probe(const struct hc_driver *driver,
if (pdata->operating_mode == FSL_USB2_DR_OTG) {
struct ehci_hcd *ehci = hcd_to_ehci(hcd);

ehci->transceiver = otg_get_transceiver();
ehci->transceiver = usb_get_transceiver();
dev_dbg(&pdev->dev, "hcd=0x%p ehci=0x%p, transceiver=0x%p\n",
hcd, ehci, ehci->transceiver);

Expand Down
14 changes: 7 additions & 7 deletions drivers/usb/host/ehci-msm.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@

#define MSM_USB_BASE (hcd->regs)

static struct usb_phy *otg;
static struct usb_phy *phy;

static int ehci_msm_reset(struct usb_hcd *hcd)
{
Expand Down Expand Up @@ -145,14 +145,14 @@ static int ehci_msm_probe(struct platform_device *pdev)
* powering up VBUS, mapping of registers address space and power
* management.
*/
otg = otg_get_transceiver();
if (!otg) {
phy = usb_get_transceiver();
if (!phy) {
dev_err(&pdev->dev, "unable to find transceiver\n");
ret = -ENODEV;
goto unmap;
}

ret = otg_set_host(otg, &hcd->self);
ret = otg_set_host(phy, &hcd->self);
if (ret < 0) {
dev_err(&pdev->dev, "unable to register with transceiver\n");
goto put_transceiver;
Expand All @@ -169,7 +169,7 @@ static int ehci_msm_probe(struct platform_device *pdev)
return 0;

put_transceiver:
otg_put_transceiver(otg);
usb_put_transceiver(phy);
unmap:
iounmap(hcd->regs);
put_hcd:
Expand All @@ -186,8 +186,8 @@ static int __devexit ehci_msm_remove(struct platform_device *pdev)
pm_runtime_disable(&pdev->dev);
pm_runtime_set_suspended(&pdev->dev);

otg_set_host(otg, NULL);
otg_put_transceiver(otg);
otg_set_host(phy, NULL);
usb_put_transceiver(phy);

usb_put_hcd(hcd);

Expand Down
6 changes: 3 additions & 3 deletions drivers/usb/host/ehci-mv.c
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ static int mv_ehci_probe(struct platform_device *pdev)
ehci_mv->mode = pdata->mode;
if (ehci_mv->mode == MV_USB_MODE_OTG) {
#ifdef CONFIG_USB_OTG_UTILS
ehci_mv->otg = otg_get_transceiver();
ehci_mv->otg = usb_get_transceiver();
if (!ehci_mv->otg) {
dev_err(&pdev->dev,
"unable to find transceiver\n");
Expand Down Expand Up @@ -303,7 +303,7 @@ static int mv_ehci_probe(struct platform_device *pdev)
#ifdef CONFIG_USB_OTG_UTILS
err_put_transceiver:
if (ehci_mv->otg)
otg_put_transceiver(ehci_mv->otg);
usb_put_transceiver(ehci_mv->otg);
#endif
err_disable_clk:
mv_ehci_disable(ehci_mv);
Expand Down Expand Up @@ -333,7 +333,7 @@ static int mv_ehci_remove(struct platform_device *pdev)

if (ehci_mv->otg) {
otg_set_host(ehci_mv->otg, NULL);
otg_put_transceiver(ehci_mv->otg);
usb_put_transceiver(ehci_mv->otg);
}

if (ehci_mv->mode == MV_USB_MODE_HOST) {
Expand Down
10 changes: 6 additions & 4 deletions drivers/usb/host/ehci-mxc.c
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ static int ehci_mxc_drv_probe(struct platform_device *pdev)
/* Initialize the transceiver */
if (pdata->otg) {
pdata->otg->io_priv = hcd->regs + ULPI_VIEWPORT_OFFSET;
ret = otg_init(pdata->otg);
ret = usb_phy_init(pdata->otg);
if (ret) {
dev_err(dev, "unable to init transceiver, probably missing\n");
ret = -ENODEV;
Expand All @@ -247,9 +247,11 @@ static int ehci_mxc_drv_probe(struct platform_device *pdev)
* It's in violation of USB specs
*/
if (machine_is_mx51_efikamx() || machine_is_mx51_efikasb()) {
flags = otg_io_read(pdata->otg, ULPI_OTG_CTRL);
flags = usb_phy_io_read(pdata->otg,
ULPI_OTG_CTRL);
flags |= ULPI_OTG_CTRL_CHRGVBUS;
ret = otg_io_write(pdata->otg, flags, ULPI_OTG_CTRL);
ret = usb_phy_io_write(pdata->otg, flags,
ULPI_OTG_CTRL);
if (ret) {
dev_err(dev, "unable to set CHRVBUS\n");
goto err_add;
Expand Down Expand Up @@ -297,7 +299,7 @@ static int __exit ehci_mxc_drv_remove(struct platform_device *pdev)
pdata->exit(pdev);

if (pdata->otg)
otg_shutdown(pdata->otg);
usb_phy_shutdown(pdata->otg);

usb_remove_hcd(hcd);
iounmap(hcd->regs);
Expand Down
6 changes: 3 additions & 3 deletions drivers/usb/host/ehci-tegra.c
Original file line number Diff line number Diff line change
Expand Up @@ -733,7 +733,7 @@ static int tegra_ehci_probe(struct platform_device *pdev)

#ifdef CONFIG_USB_OTG_UTILS
if (pdata->operating_mode == TEGRA_USB_OTG) {
tegra->transceiver = otg_get_transceiver();
tegra->transceiver = usb_get_transceiver();
if (tegra->transceiver)
otg_set_host(tegra->transceiver, &hcd->self);
}
Expand All @@ -751,7 +751,7 @@ static int tegra_ehci_probe(struct platform_device *pdev)
#ifdef CONFIG_USB_OTG_UTILS
if (tegra->transceiver) {
otg_set_host(tegra->transceiver, NULL);
otg_put_transceiver(tegra->transceiver);
usb_put_transceiver(tegra->transceiver);
}
#endif
tegra_usb_phy_close(tegra->phy);
Expand Down Expand Up @@ -809,7 +809,7 @@ static int tegra_ehci_remove(struct platform_device *pdev)
#ifdef CONFIG_USB_OTG_UTILS
if (tegra->transceiver) {
otg_set_host(tegra->transceiver, NULL);
otg_put_transceiver(tegra->transceiver);
usb_put_transceiver(tegra->transceiver);
}
#endif

Expand Down
Loading

0 comments on commit b96d3b0

Please sign in to comment.