linux-sh.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/4 v2] ARM: shmobile: r8a7778: add usb phy power control function
@ 2013-07-10  2:28 Kuninori Morimoto
  2013-07-10 11:54 ` Sergei Shtylyov
  0 siblings, 1 reply; 2+ messages in thread
From: Kuninori Morimoto @ 2013-07-10  2:28 UTC (permalink / raw)
  To: linux-sh

USB phy initialisation function is needed from not only
USB Host but also USB Function too.
This patch adds usb phy common control function.

Tested-by: Yusuke Goda <yusuke.goda.sx@renesas.com>
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
---
v1 -> v2

 - int enable => bool enable

 arch/arm/mach-shmobile/setup-r8a7778.c |   37 ++++++++++++++++++++++----------
 1 file changed, 26 insertions(+), 11 deletions(-)

diff --git a/arch/arm/mach-shmobile/setup-r8a7778.c b/arch/arm/mach-shmobile/setup-r8a7778.c
index 08e9fb3..99dd715 100644
--- a/arch/arm/mach-shmobile/setup-r8a7778.c
+++ b/arch/arm/mach-shmobile/setup-r8a7778.c
@@ -109,29 +109,46 @@ void __init r8a7778_add_usb_phy_device(struct rcar_phy_platform_data *pdata)
 					  pdata, sizeof(*pdata));
 }
 
-/* USB */
-static struct usb_phy *phy;
+static int r8a7778_usb_phy_power(bool enable)
+{
+	static struct usb_phy *phy = NULL;
+	int ret = 0;
+
+	if (!phy)
+		phy = usb_get_phy(USB_PHY_TYPE_USB2);
+
+	if (IS_ERR(phy)) {
+		pr_err("it doesn't have usb phy driver\n");
+		return PTR_ERR(phy);
+	}
+
+	if (enable)
+		ret = usb_phy_init(phy);
+	else
+		usb_phy_shutdown(phy);
 
+	return ret;
+}
+
+/* USB */
 static int usb_power_on(struct platform_device *pdev)
 {
-	if (IS_ERR(phy))
-		return PTR_ERR(phy);
+	int ret = r8a7778_usb_phy_power(1);
+
+	if (ret)
+		return ret;
 
 	pm_runtime_enable(&pdev->dev);
 	pm_runtime_get_sync(&pdev->dev);
 
-	usb_phy_init(phy);
-
 	return 0;
 }
 
 static void usb_power_off(struct platform_device *pdev)
 {
-	if (IS_ERR(phy))
+	if (r8a7778_usb_phy_power(0))
 		return;
 
-	usb_phy_shutdown(phy);
-
 	pm_runtime_put_sync(&pdev->dev);
 	pm_runtime_disable(&pdev->dev);
 }
@@ -359,8 +376,6 @@ void __init r8a7778_add_dt_devices(void)
 
 void __init r8a7778_init_late(void)
 {
-	phy = usb_get_phy(USB_PHY_TYPE_USB2);
-
 	platform_device_register_full(&ehci_info);
 	platform_device_register_full(&ohci_info);
 }
-- 
1.7.9.5


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH 1/4 v2] ARM: shmobile: r8a7778: add usb phy power control function
  2013-07-10  2:28 [PATCH 1/4 v2] ARM: shmobile: r8a7778: add usb phy power control function Kuninori Morimoto
@ 2013-07-10 11:54 ` Sergei Shtylyov
  0 siblings, 0 replies; 2+ messages in thread
From: Sergei Shtylyov @ 2013-07-10 11:54 UTC (permalink / raw)
  To: linux-sh

Hello.

On 10-07-2013 6:28, Kuninori Morimoto wrote:

> USB phy initialisation function is needed from not only
> USB Host but also USB Function too.
> This patch adds usb phy common control function.

> Tested-by: Yusuke Goda <yusuke.goda.sx@renesas.com>
> Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
> ---
[...]

> diff --git a/arch/arm/mach-shmobile/setup-r8a7778.c b/arch/arm/mach-shmobile/setup-r8a7778.c
> index 08e9fb3..99dd715 100644
> --- a/arch/arm/mach-shmobile/setup-r8a7778.c
> +++ b/arch/arm/mach-shmobile/setup-r8a7778.c
> @@ -109,29 +109,46 @@ void __init r8a7778_add_usb_phy_device(struct rcar_phy_platform_data *pdata)
>   					  pdata, sizeof(*pdata));
>   }
>
> -/* USB */
> -static struct usb_phy *phy;
> +static int r8a7778_usb_phy_power(bool enable)
> +{
> +	static struct usb_phy *phy = NULL;
> +	int ret = 0;
> +
> +	if (!phy)
> +		phy = usb_get_phy(USB_PHY_TYPE_USB2);
> +
> +	if (IS_ERR(phy)) {
> +		pr_err("it doesn't have usb phy driver\n");
> +		return PTR_ERR(phy);
> +	}
> +
> +	if (enable)
> +		ret = usb_phy_init(phy);
> +	else
> +		usb_phy_shutdown(phy);
>
> +	return ret;
> +}
> +
> +/* USB */
>   static int usb_power_on(struct platform_device *pdev)
>   {
> -	if (IS_ERR(phy))
> -		return PTR_ERR(phy);
> +	int ret = r8a7778_usb_phy_power(1);

    s/1/true/.

> +
> +	if (ret)
> +		return ret;
>
>   	pm_runtime_enable(&pdev->dev);
>   	pm_runtime_get_sync(&pdev->dev);
>
> -	usb_phy_init(phy);
> -
>   	return 0;
>   }
>
>   static void usb_power_off(struct platform_device *pdev)
>   {
> -	if (IS_ERR(phy))
> +	if (r8a7778_usb_phy_power(0))

    s/0/false/.

WBR, Sergei


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2013-07-10 11:54 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-07-10  2:28 [PATCH 1/4 v2] ARM: shmobile: r8a7778: add usb phy power control function Kuninori Morimoto
2013-07-10 11:54 ` Sergei Shtylyov

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).