Skip to content

Commit

Permalink
usb: otg: support for multiple transceivers by a single controller
Browse files Browse the repository at this point in the history
Add a linked list for keeping multiple PHY instances with different
types so that we can have separate USB2 and USB3 PHYs on one single
board. _get_phy_ has been changed so that the controller gets
the transceiver by type. _remove_phy_ has been added to let the phy
be removed from the phy list.

Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
  • Loading branch information
Kishon Vijay Abraham I authored and Felipe Balbi committed Jun 25, 2012
1 parent 721002e commit 662dca5
Show file tree
Hide file tree
Showing 35 changed files with 152 additions and 57 deletions.
2 changes: 1 addition & 1 deletion drivers/power/ab8500_charger.c
Original file line number Diff line number Diff line change
Expand Up @@ -2688,7 +2688,7 @@ static int __devinit ab8500_charger_probe(struct platform_device *pdev)
goto free_ac;
}

di->usb_phy = usb_get_phy();
di->usb_phy = usb_get_phy(USB_PHY_TYPE_USB2);
if (!di->usb_phy) {
dev_err(di->dev, "failed to get usb transceiver\n");
ret = -EINVAL;
Expand Down
2 changes: 1 addition & 1 deletion drivers/power/isp1704_charger.c
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,7 @@ static int __devinit isp1704_charger_probe(struct platform_device *pdev)
if (!isp)
return -ENOMEM;

isp->phy = usb_get_phy();
isp->phy = usb_get_phy(USB_PHY_TYPE_USB2);
if (!isp->phy)
goto fail0;

Expand Down
2 changes: 1 addition & 1 deletion drivers/power/pda_power.c
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,7 @@ static int pda_power_probe(struct platform_device *pdev)
}

#ifdef CONFIG_USB_OTG_UTILS
transceiver = usb_get_phy();
transceiver = usb_get_phy(USB_PHY_TYPE_USB2);
if (transceiver && !pdata->is_usb_online) {
pdata->is_usb_online = otg_is_usb_online;
}
Expand Down
2 changes: 1 addition & 1 deletion drivers/power/twl4030_charger.c
Original file line number Diff line number Diff line change
Expand Up @@ -479,7 +479,7 @@ static int __init twl4030_bci_probe(struct platform_device *pdev)

INIT_WORK(&bci->work, twl4030_bci_usb_work);

bci->transceiver = usb_get_phy();
bci->transceiver = usb_get_phy(USB_PHY_TYPE_USB2);
if (bci->transceiver != NULL) {
bci->usb_nb.notifier_call = twl4030_bci_usb_ncb;
usb_register_notifier(bci->transceiver, &bci->usb_nb);
Expand Down
2 changes: 1 addition & 1 deletion drivers/usb/chipidea/udc.c
Original file line number Diff line number Diff line change
Expand Up @@ -1687,7 +1687,7 @@ static int udc_start(struct ci13xxx *udc)

udc->gadget.ep0 = &udc->ep0in->ep;

udc->transceiver = usb_get_phy();
udc->transceiver = usb_get_phy(USB_PHY_TYPE_USB2);

if (udc->udc_driver->flags & CI13XXX_REQUIRE_TRANSCEIVER) {
if (udc->transceiver == NULL) {
Expand Down
2 changes: 1 addition & 1 deletion drivers/usb/gadget/fsl_udc_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -2455,7 +2455,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 = usb_get_phy();
udc_controller->transceiver = usb_get_phy(USB_PHY_TYPE_USB2);
if (!udc_controller->transceiver) {
ERR("Can't find OTG driver!\n");
ret = -ENODEV;
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 @@ -2180,7 +2180,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 = usb_get_phy();
udc->transceiver = usb_get_phy(USB_PHY_TYPE_USB2);
#endif

udc->clknum = pdata->clknum;
Expand Down
2 changes: 1 addition & 1 deletion drivers/usb/gadget/omap_udc.c
Original file line number Diff line number Diff line change
Expand Up @@ -2865,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 = usb_get_phy();
xceiv = usb_get_phy(USB_PHY_TYPE_USB2);
if (xceiv)
type = xceiv->label;
else if (config->otg) {
Expand Down
2 changes: 1 addition & 1 deletion drivers/usb/gadget/pxa25x_udc.c
Original file line number Diff line number Diff line change
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 = usb_get_phy();
dev->transceiver = usb_get_phy(USB_PHY_TYPE_USB2);

if (gpio_is_valid(dev->mach->gpio_pullup)) {
if ((retval = gpio_request(dev->mach->gpio_pullup,
Expand Down
2 changes: 1 addition & 1 deletion drivers/usb/gadget/pxa27x_udc.c
Original file line number Diff line number Diff line change
Expand Up @@ -2464,7 +2464,7 @@ static int __init pxa_udc_probe(struct platform_device *pdev)

udc->dev = &pdev->dev;
udc->mach = pdev->dev.platform_data;
udc->transceiver = usb_get_phy();
udc->transceiver = usb_get_phy(USB_PHY_TYPE_USB2);

gpio = udc->mach->gpio_pullup;
if (gpio_is_valid(gpio)) {
Expand Down
2 changes: 1 addition & 1 deletion drivers/usb/gadget/s3c-hsudc.c
Original file line number Diff line number Diff line change
Expand Up @@ -1282,7 +1282,7 @@ static int __devinit s3c_hsudc_probe(struct platform_device *pdev)
hsudc->dev = dev;
hsudc->pd = pdev->dev.platform_data;

hsudc->transceiver = usb_get_phy();
hsudc->transceiver = usb_get_phy(USB_PHY_TYPE_USB2);

for (i = 0; i < ARRAY_SIZE(hsudc->supplies); i++)
hsudc->supplies[i].supply = s3c_hsudc_supply_names[i];
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 = usb_get_phy();
ehci->transceiver = usb_get_phy(USB_PHY_TYPE_USB2);
dev_dbg(&pdev->dev, "hcd=0x%p ehci=0x%p, transceiver=0x%p\n",
hcd, ehci, ehci->transceiver);

Expand Down
2 changes: 1 addition & 1 deletion drivers/usb/host/ehci-msm.c
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ static int ehci_msm_probe(struct platform_device *pdev)
* powering up VBUS, mapping of registers address space and power
* management.
*/
phy = usb_get_phy();
phy = usb_get_phy(USB_PHY_TYPE_USB2);
if (!phy) {
dev_err(&pdev->dev, "unable to find transceiver\n");
ret = -ENODEV;
Expand Down
2 changes: 1 addition & 1 deletion 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 = usb_get_phy();
ehci_mv->otg = usb_get_phy(USB_PHY_TYPE_USB2);
if (!ehci_mv->otg) {
dev_err(&pdev->dev,
"unable to find transceiver\n");
Expand Down
2 changes: 1 addition & 1 deletion drivers/usb/host/ehci-tegra.c
Original file line number Diff line number Diff line change
Expand Up @@ -749,7 +749,7 @@ static int tegra_ehci_probe(struct platform_device *pdev)

#ifdef CONFIG_USB_OTG_UTILS
if (pdata->operating_mode == TEGRA_USB_OTG) {
tegra->transceiver = usb_get_phy();
tegra->transceiver = usb_get_phy(USB_PHY_TYPE_USB2);
if (tegra->transceiver)
otg_set_host(tegra->transceiver->otg, &hcd->self);
}
Expand Down
2 changes: 1 addition & 1 deletion drivers/usb/host/ohci-omap.c
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ static int ohci_omap_init(struct usb_hcd *hcd)

#ifdef CONFIG_USB_OTG
if (need_transceiver) {
ohci->transceiver = usb_get_phy();
ohci->transceiver = usb_get_phy(USB_PHY_TYPE_USB2);
if (ohci->transceiver) {
int status = otg_set_host(ohci->transceiver->otg,
&ohci_to_hcd(ohci)->self);
Expand Down
2 changes: 1 addition & 1 deletion drivers/usb/musb/am35x.c
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,7 @@ static int am35x_musb_init(struct musb *musb)
return -ENODEV;

usb_nop_xceiv_register();
musb->xceiv = usb_get_phy();
musb->xceiv = usb_get_phy(USB_PHY_TYPE_USB2);
if (!musb->xceiv)
return -ENODEV;

Expand Down
2 changes: 1 addition & 1 deletion drivers/usb/musb/blackfin.c
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,7 @@ static int bfin_musb_init(struct musb *musb)
gpio_direction_output(musb->config->gpio_vrsel, 0);

usb_nop_xceiv_register();
musb->xceiv = usb_get_phy();
musb->xceiv = usb_get_phy(USB_PHY_TYPE_USB2);
if (!musb->xceiv) {
gpio_free(musb->config->gpio_vrsel);
return -ENODEV;
Expand Down
2 changes: 1 addition & 1 deletion drivers/usb/musb/da8xx.c
Original file line number Diff line number Diff line change
Expand Up @@ -425,7 +425,7 @@ static int da8xx_musb_init(struct musb *musb)
goto fail;

usb_nop_xceiv_register();
musb->xceiv = usb_get_phy();
musb->xceiv = usb_get_phy(USB_PHY_TYPE_USB2);
if (!musb->xceiv)
goto fail;

Expand Down
2 changes: 1 addition & 1 deletion drivers/usb/musb/davinci.c
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,7 @@ static int davinci_musb_init(struct musb *musb)
u32 revision;

usb_nop_xceiv_register();
musb->xceiv = usb_get_phy();
musb->xceiv = usb_get_phy(USB_PHY_TYPE_USB2);
if (!musb->xceiv)
goto unregister;

Expand Down
2 changes: 1 addition & 1 deletion drivers/usb/musb/musb_dsps.c
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,7 @@ static int dsps_musb_init(struct musb *musb)

/* NOP driver needs change if supporting dual instance */
usb_nop_xceiv_register();
musb->xceiv = usb_get_phy();
musb->xceiv = usb_get_phy(USB_PHY_TYPE_USB2);
if (!musb->xceiv)
return -ENODEV;

Expand Down
2 changes: 1 addition & 1 deletion drivers/usb/musb/omap2430.c
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ static int omap2430_musb_init(struct musb *musb)
* up through ULPI. TWL4030-family PMICs include one,
* which needs a driver, drivers aren't always needed.
*/
musb->xceiv = usb_get_phy();
musb->xceiv = usb_get_phy(USB_PHY_TYPE_USB2);
if (!musb->xceiv) {
pr_err("HS USB OTG: no transceiver configured\n");
return -ENODEV;
Expand Down
2 changes: 1 addition & 1 deletion drivers/usb/musb/tusb6010.c
Original file line number Diff line number Diff line change
Expand Up @@ -1078,7 +1078,7 @@ static int tusb_musb_init(struct musb *musb)
int ret;

usb_nop_xceiv_register();
musb->xceiv = usb_get_phy();
musb->xceiv = usb_get_phy(USB_PHY_TYPE_USB2);
if (!musb->xceiv)
return -ENODEV;

Expand Down
2 changes: 1 addition & 1 deletion drivers/usb/musb/ux500.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ struct ux500_glue {

static int ux500_musb_init(struct musb *musb)
{
musb->xceiv = usb_get_phy();
musb->xceiv = usb_get_phy(USB_PHY_TYPE_USB2);
if (!musb->xceiv) {
pr_err("HS USB OTG: no transceiver configured\n");
return -ENODEV;
Expand Down
4 changes: 2 additions & 2 deletions drivers/usb/otg/ab8500-usb.c
Original file line number Diff line number Diff line change
Expand Up @@ -529,7 +529,7 @@ static int __devinit ab8500_usb_probe(struct platform_device *pdev)
if (err < 0)
goto fail0;

err = usb_add_phy(&ab->phy);
err = usb_add_phy(&ab->phy, USB_PHY_TYPE_USB2);
if (err) {
dev_err(&pdev->dev, "Can't register transceiver\n");
goto fail1;
Expand All @@ -556,7 +556,7 @@ static int __devexit ab8500_usb_remove(struct platform_device *pdev)

cancel_work_sync(&ab->phy_dis_work);

usb_add_phy(NULL);
usb_remove_phy(&ab->phy);

ab8500_usb_host_phy_dis(ab);
ab8500_usb_peri_phy_dis(ab);
Expand Down
6 changes: 3 additions & 3 deletions drivers/usb/otg/fsl_otg.c
Original file line number Diff line number Diff line change
Expand Up @@ -806,7 +806,7 @@ static int fsl_otg_conf(struct platform_device *pdev)
fsl_otg_dev = fsl_otg_tc;

/* Store the otg transceiver */
status = usb_add_phy(&fsl_otg_tc->phy);
status = usb_add_phy(&fsl_otg_tc->phy, USB_PHY_TYPE_USB2);
if (status) {
pr_warn(FSL_OTG_NAME ": unable to register OTG transceiver.\n");
goto err;
Expand All @@ -824,7 +824,7 @@ static int fsl_otg_conf(struct platform_device *pdev)
int usb_otg_start(struct platform_device *pdev)
{
struct fsl_otg *p_otg;
struct usb_phy *otg_trans = usb_get_phy();
struct usb_phy *otg_trans = usb_get_phy(USB_PHY_TYPE_USB2);
struct otg_fsm *fsm;
int status;
struct resource *res;
Expand Down Expand Up @@ -1134,7 +1134,7 @@ static int __devexit fsl_otg_remove(struct platform_device *pdev)
{
struct fsl_usb2_platform_data *pdata = pdev->dev.platform_data;

usb_add_phy(NULL);
usb_remove_phy(&fsl_otg_dev->phy);
free_irq(fsl_otg_dev->irq, fsl_otg_dev);

iounmap((void *)usb_dr_regs);
Expand Down
4 changes: 2 additions & 2 deletions drivers/usb/otg/gpio_vbus.c
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@ static int __init gpio_vbus_probe(struct platform_device *pdev)
}

/* only active when a gadget is registered */
err = usb_add_phy(&gpio_vbus->phy);
err = usb_add_phy(&gpio_vbus->phy, USB_PHY_TYPE_USB2);
if (err) {
dev_err(&pdev->dev, "can't register transceiver, err: %d\n",
err);
Expand Down Expand Up @@ -354,7 +354,7 @@ static int __exit gpio_vbus_remove(struct platform_device *pdev)
cancel_delayed_work_sync(&gpio_vbus->work);
regulator_put(gpio_vbus->vbus_draw);

usb_add_phy(NULL);
usb_remove_phy(&gpio_vbus->phy);

free_irq(gpio_vbus->irq, pdev);
if (gpio_is_valid(pdata->gpio_pullup))
Expand Down
4 changes: 2 additions & 2 deletions drivers/usb/otg/isp1301_omap.c
Original file line number Diff line number Diff line change
Expand Up @@ -1611,7 +1611,7 @@ isp1301_probe(struct i2c_client *i2c, const struct i2c_device_id *id)
dev_dbg(&i2c->dev, "scheduled timer, %d min\n", TIMER_MINUTES);
#endif

status = usb_add_phy(&isp->phy);
status = usb_add_phy(&isp->phy, USB_PHY_TYPE_USB2);
if (status < 0)
dev_err(&i2c->dev, "can't register transceiver, %d\n",
status);
Expand Down Expand Up @@ -1650,7 +1650,7 @@ subsys_initcall(isp_init);
static void __exit isp_exit(void)
{
if (the_transceiver)
usb_add_phy(NULL);
usb_remove_phy(&the_transceiver->phy);
i2c_del_driver(&isp1301_driver);
}
module_exit(isp_exit);
Expand Down
4 changes: 2 additions & 2 deletions drivers/usb/otg/msm_otg.c
Original file line number Diff line number Diff line change
Expand Up @@ -1555,7 +1555,7 @@ static int __init msm_otg_probe(struct platform_device *pdev)
phy->otg->set_host = msm_otg_set_host;
phy->otg->set_peripheral = msm_otg_set_peripheral;

ret = usb_add_phy(&motg->phy);
ret = usb_add_phy(&motg->phy, USB_PHY_TYPE_USB2);
if (ret) {
dev_err(&pdev->dev, "usb_add_phy failed\n");
goto free_irq;
Expand Down Expand Up @@ -1624,7 +1624,7 @@ static int __devexit msm_otg_remove(struct platform_device *pdev)
device_init_wakeup(&pdev->dev, 0);
pm_runtime_disable(&pdev->dev);

usb_add_phy(NULL);
usb_remove_phy(phy);
free_irq(motg->irq, motg);

/*
Expand Down
6 changes: 3 additions & 3 deletions drivers/usb/otg/mv_otg.c
Original file line number Diff line number Diff line change
Expand Up @@ -690,7 +690,7 @@ int mv_otg_remove(struct platform_device *pdev)
for (clk_i = 0; clk_i <= mvotg->clknum; clk_i++)
clk_put(mvotg->clk[clk_i]);

usb_add_phy(NULL);
usb_remove_phy(&mvotg->phy);
platform_set_drvdata(pdev, NULL);

kfree(mvotg->phy.otg);
Expand Down Expand Up @@ -853,7 +853,7 @@ static int mv_otg_probe(struct platform_device *pdev)
goto err_disable_clk;
}

retval = usb_add_phy(&mvotg->phy);
retval = usb_add_phy(&mvotg->phy, USB_PHY_TYPE_USB2);
if (retval < 0) {
dev_err(&pdev->dev, "can't register transceiver, %d\n",
retval);
Expand All @@ -880,7 +880,7 @@ static int mv_otg_probe(struct platform_device *pdev)
return 0;

err_set_transceiver:
usb_add_phy(NULL);
usb_remove_phy(&mvotg->phy);
err_free_irq:
free_irq(mvotg->irq, mvotg);
err_disable_clk:
Expand Down
4 changes: 2 additions & 2 deletions drivers/usb/otg/nop-usb-xceiv.c
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ static int __devinit nop_usb_xceiv_probe(struct platform_device *pdev)
nop->phy.otg->set_host = nop_set_host;
nop->phy.otg->set_peripheral = nop_set_peripheral;

err = usb_add_phy(&nop->phy);
err = usb_add_phy(&nop->phy, USB_PHY_TYPE_USB2);
if (err) {
dev_err(&pdev->dev, "can't register transceiver, err: %d\n",
err);
Expand All @@ -139,7 +139,7 @@ static int __devexit nop_usb_xceiv_remove(struct platform_device *pdev)
{
struct nop_usb_xceiv *nop = platform_get_drvdata(pdev);

usb_add_phy(NULL);
usb_remove_phy(&nop->phy);

platform_set_drvdata(pdev, NULL);
kfree(nop->phy.otg);
Expand Down
Loading

0 comments on commit 662dca5

Please sign in to comment.