devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jingoo Han <jg1.han@samsung.com>
To: 'Vivek Gautam' <gautam.vivek@samsung.com>, linux-usb@vger.kernel.org
Cc: linux-samsung-soc@vger.kernel.org,
	devicetree-discuss@lists.ozlabs.org, gregkh@linuxfoundation.org,
	stern@rowland.harvard.edu, balbi@ti.com, rob.herring@calxeda.com,
	kgene.kim@samsung.com, thomas.abraham@linaro.org, kishon@ti.com,
	p.paneri@samsung.com, yulgon.kim@samsung.com,
	'Jingoo Han' <jg1.han@samsung.com>
Subject: RE: [PATCH 4/4 v2] USB: ohci-exynos: Add phy driver support
Date: Mon, 15 Oct 2012 14:52:46 +0900	[thread overview]
Message-ID: <009001cdaa99$4d4ad340$e7e079c0$%han@samsung.com> (raw)
In-Reply-To: <1349865780-7701-5-git-send-email-gautam.vivek@samsung.com>

On Wednesday, October 10, 2012 7:43 PM Vivek Gautam wrote
> 
> Adding the transceiver to ohci driver. Keeping the platform data
> for continuing the smooth operation for boards which still uses it
> 
> Signed-off-by: Vivek Gautam <gautam.vivek@samsung.com>


It looks good. I have tested this patch with Exynos5250.

Acked-by: Jingoo Han <jg1.han@samsung.com>


Best regards,
Jingoo Han


> ---
>  drivers/usb/host/ohci-exynos.c |   65 +++++++++++++++++++++++++++------------
>  1 files changed, 45 insertions(+), 20 deletions(-)
> 
> diff --git a/drivers/usb/host/ohci-exynos.c b/drivers/usb/host/ohci-exynos.c
> index 20a5008..a1c4eb3 100644
> --- a/drivers/usb/host/ohci-exynos.c
> +++ b/drivers/usb/host/ohci-exynos.c
> @@ -15,14 +15,37 @@
>  #include <linux/of.h>
>  #include <linux/platform_device.h>
>  #include <linux/platform_data/usb-exynos.h>
> +#include <linux/usb/phy.h>
>  #include <plat/usb-phy.h>
> 
>  struct exynos_ohci_hcd {
>  	struct device *dev;
>  	struct usb_hcd *hcd;
>  	struct clk *clk;
> +	struct usb_phy *phy;
> +	struct exynos4_ohci_platdata *pdata;
>  };
> 
> +static void exynos_ohci_phy_enable(struct exynos_ohci_hcd *exynos_ohci)
> +{
> +	struct platform_device *pdev = to_platform_device(exynos_ohci->dev);
> +
> +	if (exynos_ohci->phy)
> +		usb_phy_init(exynos_ohci->phy);
> +	else if (exynos_ohci->pdata->phy_init)
> +		exynos_ohci->pdata->phy_init(pdev, S5P_USB_PHY_HOST);
> +}
> +
> +static void exynos_ohci_phy_disable(struct exynos_ohci_hcd *exynos_ohci)
> +{
> +	struct platform_device *pdev = to_platform_device(exynos_ohci->dev);
> +
> +	if (exynos_ohci->phy)
> +		usb_phy_shutdown(exynos_ohci->phy);
> +	else if (exynos_ohci->pdata->phy_exit)
> +		exynos_ohci->pdata->phy_exit(pdev, S5P_USB_PHY_HOST);
> +}
> +
>  static int ohci_exynos_start(struct usb_hcd *hcd)
>  {
>  	struct ohci_hcd *ohci = hcd_to_ohci(hcd);
> @@ -81,15 +104,10 @@ static int __devinit exynos_ohci_probe(struct platform_device *pdev)
>  	struct usb_hcd *hcd;
>  	struct ohci_hcd *ohci;
>  	struct resource *res;
> +	struct usb_phy *phy;
>  	int irq;
>  	int err;
> 
> -	pdata = pdev->dev.platform_data;
> -	if (!pdata) {
> -		dev_err(&pdev->dev, "No platform data defined\n");
> -		return -EINVAL;
> -	}
> -
>  	/*
>  	 * Right now device-tree probed devices don't get dma_mask set.
>  	 * Since shared usb code relies on it, set it here for now.
> @@ -105,6 +123,20 @@ static int __devinit exynos_ohci_probe(struct platform_device *pdev)
>  	if (!exynos_ohci)
>  		return -ENOMEM;
> 
> +	pdata = pdev->dev.platform_data;
> +	if (!pdata) {
> +		/* Fallback to Phy transceiver */
> +		phy = devm_usb_get_phy(&pdev->dev, USB_PHY_TYPE_USB2);
> +		if (IS_ERR_OR_NULL(phy)) {
> +			dev_err(&pdev->dev, "no platform data or transceiver defined\n");
> +			return -EPROBE_DEFER;
> +		} else {
> +			exynos_ohci->phy = phy;
> +		}
> +	} else {
> +		exynos_ohci->pdata = pdata;
> +	}
> +
>  	exynos_ohci->dev = &pdev->dev;
> 
>  	hcd = usb_create_hcd(&exynos_ohci_hc_driver, &pdev->dev,
> @@ -150,8 +182,7 @@ static int __devinit exynos_ohci_probe(struct platform_device *pdev)
>  		goto fail_io;
>  	}
> 
> -	if (pdata->phy_init)
> -		pdata->phy_init(pdev, S5P_USB_PHY_HOST);
> +	exynos_ohci_phy_enable(exynos_ohci);
> 
>  	ohci = hcd_to_ohci(hcd);
>  	ohci_hcd_init(ohci);
> @@ -159,13 +190,15 @@ static int __devinit exynos_ohci_probe(struct platform_device *pdev)
>  	err = usb_add_hcd(hcd, irq, IRQF_SHARED);
>  	if (err) {
>  		dev_err(&pdev->dev, "Failed to add USB HCD\n");
> -		goto fail_io;
> +		goto fail_add_hcd;
>  	}
> 
>  	platform_set_drvdata(pdev, exynos_ohci);
> 
>  	return 0;
> 
> +fail_add_hcd:
> +	exynos_ohci_phy_disable(exynos_ohci);
>  fail_io:
>  	clk_disable(exynos_ohci->clk);
>  fail_clken:
> @@ -177,14 +210,12 @@ fail_clk:
> 
>  static int __devexit exynos_ohci_remove(struct platform_device *pdev)
>  {
> -	struct exynos4_ohci_platdata *pdata = pdev->dev.platform_data;
>  	struct exynos_ohci_hcd *exynos_ohci = platform_get_drvdata(pdev);
>  	struct usb_hcd *hcd = exynos_ohci->hcd;
> 
>  	usb_remove_hcd(hcd);
> 
> -	if (pdata && pdata->phy_exit)
> -		pdata->phy_exit(pdev, S5P_USB_PHY_HOST);
> +	exynos_ohci_phy_disable(exynos_ohci);
> 
>  	clk_disable(exynos_ohci->clk);
>  	clk_put(exynos_ohci->clk);
> @@ -209,8 +240,6 @@ static int exynos_ohci_suspend(struct device *dev)
>  	struct exynos_ohci_hcd *exynos_ohci = dev_get_drvdata(dev);
>  	struct usb_hcd *hcd = exynos_ohci->hcd;
>  	struct ohci_hcd *ohci = hcd_to_ohci(hcd);
> -	struct platform_device *pdev = to_platform_device(dev);
> -	struct exynos4_ohci_platdata *pdata = pdev->dev.platform_data;
>  	unsigned long flags;
>  	int rc = 0;
> 
> @@ -229,8 +258,7 @@ static int exynos_ohci_suspend(struct device *dev)
> 
>  	clear_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags);
> 
> -	if (pdata && pdata->phy_exit)
> -		pdata->phy_exit(pdev, S5P_USB_PHY_HOST);
> +	exynos_ohci_phy_disable(exynos_ohci);
> 
>  	clk_disable(exynos_ohci->clk);
> 
> @@ -244,13 +272,10 @@ static int exynos_ohci_resume(struct device *dev)
>  {
>  	struct exynos_ohci_hcd *exynos_ohci = dev_get_drvdata(dev);
>  	struct usb_hcd *hcd = exynos_ohci->hcd;
> -	struct platform_device *pdev = to_platform_device(dev);
> -	struct exynos4_ohci_platdata *pdata = pdev->dev.platform_data;
> 
>  	clk_enable(exynos_ohci->clk);
> 
> -	if (pdata && pdata->phy_init)
> -		pdata->phy_init(pdev, S5P_USB_PHY_HOST);
> +	exynos_ohci_phy_enable(exynos_ohci);
> 
>  	/* Mark hardware accessible again as we are out of D3 state by now */
>  	set_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags);
> --
> 1.7.6.5

      reply	other threads:[~2012-10-15  5:52 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-10-10 10:42 [PATCH 0/4 v2] Adding usb2.0 host-phy support for exynos5250 Vivek Gautam
2012-10-10 10:42 ` [PATCH 1/4 v2] usb: phy: samsung: Add host phy support to samsung-phy driver Vivek Gautam
     [not found]   ` <1349865780-7701-2-git-send-email-gautam.vivek-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org>
2012-10-22  4:57     ` Jingoo Han
2012-10-22  5:26       ` Vivek Gautam
2012-10-10 10:42 ` [PATCH 2/4 v2] ARM: Exynos5250: Enabling samsung-usbphy driver Vivek Gautam
2012-10-22  5:03   ` Jingoo Han
2012-10-22  5:18     ` Vivek Gautam
     [not found] ` <1349865780-7701-1-git-send-email-gautam.vivek-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org>
2012-10-10 10:42   ` [PATCH 3/4 v2] USB: ehci-s5p: Add phy driver support Vivek Gautam
     [not found]     ` <1349865780-7701-4-git-send-email-gautam.vivek-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org>
2012-10-15  5:52       ` Jingoo Han
2012-10-10 10:43   ` [PATCH 4/4 v2] USB: ohci-exynos: " Vivek Gautam
2012-10-15  5:52     ` Jingoo Han [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='009001cdaa99$4d4ad340$e7e079c0$%han@samsung.com' \
    --to=jg1.han@samsung.com \
    --cc=balbi@ti.com \
    --cc=devicetree-discuss@lists.ozlabs.org \
    --cc=gautam.vivek@samsung.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=kgene.kim@samsung.com \
    --cc=kishon@ti.com \
    --cc=linux-samsung-soc@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=p.paneri@samsung.com \
    --cc=rob.herring@calxeda.com \
    --cc=stern@rowland.harvard.edu \
    --cc=thomas.abraham@linaro.org \
    --cc=yulgon.kim@samsung.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).