diff options
Diffstat (limited to 'drivers/usb/musb/omap2430.c')
| -rw-r--r-- | drivers/usb/musb/omap2430.c | 62 | 
1 files changed, 44 insertions, 18 deletions
diff --git a/drivers/usb/musb/omap2430.c b/drivers/usb/musb/omap2430.c index 59d2245db1c..d369bf1f393 100644 --- a/drivers/usb/musb/omap2430.c +++ b/drivers/usb/musb/omap2430.c @@ -37,7 +37,8 @@  #include <linux/err.h>  #include <linux/delay.h>  #include <linux/usb/musb-omap.h> -#include <linux/usb/omap_control_usb.h> +#include <linux/phy/omap_control_phy.h> +#include <linux/of_platform.h>  #include "musb_core.h"  #include "omap2430.h" @@ -305,6 +306,9 @@ static void omap_musb_set_mailbox(struct omap2430_glue *glue)  	default:  		dev_dbg(dev, "ID float\n");  	} + +	atomic_notifier_call_chain(&musb->xceiv->notifier, +			musb->xceiv->last_event, NULL);  } @@ -312,7 +316,13 @@ static void omap_musb_mailbox_work(struct work_struct *mailbox_work)  {  	struct omap2430_glue *glue = container_of(mailbox_work,  				struct omap2430_glue, omap_musb_mailbox_work); +	struct musb *musb = glue_to_musb(glue); +	struct device *dev = musb->controller; + +	pm_runtime_get_sync(dev);  	omap_musb_set_mailbox(glue); +	pm_runtime_mark_last_busy(dev); +	pm_runtime_put_autosuspend(dev);  }  static irqreturn_t omap2430_musb_interrupt(int irq, void *__hci) @@ -348,11 +358,21 @@ 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.  	 */ -	if (dev->parent->of_node) +	if (dev->parent->of_node) { +		musb->phy = devm_phy_get(dev->parent, "usb2-phy"); + +		/* We can't totally remove musb->xceiv as of now because +		 * musb core uses xceiv.state and xceiv.otg. Once we have +		 * a separate state machine to handle otg, these can be moved +		 * out of xceiv and then we can start using the generic PHY +		 * framework +		 */  		musb->xceiv = devm_usb_get_phy_by_phandle(dev->parent,  		    "usb-phy", 0); -	else +	} else {  		musb->xceiv = devm_usb_get_phy_dev(dev, 0); +		musb->phy = devm_phy_get(dev, "usb"); +	}  	if (IS_ERR(musb->xceiv)) {  		status = PTR_ERR(musb->xceiv); @@ -364,6 +384,10 @@ static int omap2430_musb_init(struct musb *musb)  		return -EPROBE_DEFER;  	} +	if (IS_ERR(musb->phy)) { +		pr_err("HS USB OTG: no PHY configured\n"); +		return PTR_ERR(musb->phy); +	}  	musb->isr = omap2430_musb_interrupt;  	status = pm_runtime_get_sync(dev); @@ -397,7 +421,8 @@ static int omap2430_musb_init(struct musb *musb)  	if (glue->status != OMAP_MUSB_UNKNOWN)  		omap_musb_set_mailbox(glue); -	usb_phy_init(musb->xceiv); +	phy_init(musb->phy); +	phy_power_on(musb->phy);  	pm_runtime_put_noidle(musb->controller);  	return 0; @@ -460,6 +485,8 @@ static int omap2430_musb_exit(struct musb *musb)  	del_timer_sync(&musb_idle_timer);  	omap2430_low_level_exit(musb); +	phy_power_off(musb->phy); +	phy_exit(musb->phy);  	return 0;  } @@ -509,8 +536,12 @@ static int omap2430_probe(struct platform_device *pdev)  	glue->dev			= &pdev->dev;  	glue->musb			= musb;  	glue->status			= OMAP_MUSB_UNKNOWN; +	glue->control_otghs = ERR_PTR(-ENODEV);  	if (np) { +		struct device_node *control_node; +		struct platform_device *control_pdev; +  		pdata = devm_kzalloc(&pdev->dev, sizeof(*pdata), GFP_KERNEL);  		if (!pdata) {  			dev_err(&pdev->dev, @@ -539,22 +570,20 @@ static int omap2430_probe(struct platform_device *pdev)  		of_property_read_u32(np, "ram-bits", (u32 *)&config->ram_bits);  		of_property_read_u32(np, "power", (u32 *)&pdata->power);  		config->multipoint = of_property_read_bool(np, "multipoint"); -		pdata->has_mailbox = of_property_read_bool(np, -		    "ti,has-mailbox");  		pdata->board_data	= data;  		pdata->config		= config; -	} -	if (pdata->has_mailbox) { -		glue->control_otghs = omap_get_control_dev(); -		if (IS_ERR(glue->control_otghs)) { -			dev_vdbg(&pdev->dev, "Failed to get control device\n"); -			ret = PTR_ERR(glue->control_otghs); -			goto err2; +		control_node = of_parse_phandle(np, "ctrl-module", 0); +		if (control_node) { +			control_pdev = of_find_device_by_node(control_node); +			if (!control_pdev) { +				dev_err(&pdev->dev, "Failed to get control device\n"); +				ret = -EINVAL; +				goto err2; +			} +			glue->control_otghs = &control_pdev->dev;  		} -	} else { -		glue->control_otghs = ERR_PTR(-ENODEV);  	}  	pdata->platform_ops		= &omap2430_ops; @@ -638,7 +667,6 @@ static int omap2430_runtime_suspend(struct device *dev)  				OTG_INTERFSEL);  		omap2430_low_level_exit(musb); -		usb_phy_set_suspend(musb->xceiv, 1);  	}  	return 0; @@ -653,8 +681,6 @@ static int omap2430_runtime_resume(struct device *dev)  		omap2430_low_level_init(musb);  		musb_writel(musb->mregs, OTG_INTERFSEL,  				musb->context.otg_interfsel); - -		usb_phy_set_suspend(musb->xceiv, 0);  	}  	return 0;  | 
