aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKuninori Morimoto <kuninori.morimoto.gx@renesas.com>2013-08-04 20:43:01 -0400
committerSimon Horman <horms+renesas@verge.net.au>2013-09-30 03:11:23 -0400
commitf39d35fcc2cd7a24ec3128adffd7876953999e1f (patch)
treeb15398b77886618cc42a91cb1a502227882908d4
parent84ea52885ebb298231b9577dd8b53fdfa692c0b7 (diff)
ARM: shmobile: r8a7778: add usb phy power control function
USB phy initialisation function is needed from not only USB Host but also USB Function too. This patch adds usb phy common control function. Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> Signed-off-by: Simon Horman <horms+renesas@verge.net.au>
-rw-r--r--arch/arm/mach-shmobile/include/mach/r8a7778.h2
-rw-r--r--arch/arm/mach-shmobile/setup-r8a7778.c37
2 files changed, 28 insertions, 11 deletions
diff --git a/arch/arm/mach-shmobile/include/mach/r8a7778.h b/arch/arm/mach-shmobile/include/mach/r8a7778.h
index adfcf51b163d..ea1dca6880f4 100644
--- a/arch/arm/mach-shmobile/include/mach/r8a7778.h
+++ b/arch/arm/mach-shmobile/include/mach/r8a7778.h
@@ -35,4 +35,6 @@ extern void r8a7778_clock_init(void);
35extern void r8a7778_init_irq_extpin(int irlm); 35extern void r8a7778_init_irq_extpin(int irlm);
36extern void r8a7778_pinmux_init(void); 36extern void r8a7778_pinmux_init(void);
37 37
38extern int r8a7778_usb_phy_power(bool enable);
39
38#endif /* __ASM_R8A7778_H__ */ 40#endif /* __ASM_R8A7778_H__ */
diff --git a/arch/arm/mach-shmobile/setup-r8a7778.c b/arch/arm/mach-shmobile/setup-r8a7778.c
index 6a2657ebd197..e484d1420a01 100644
--- a/arch/arm/mach-shmobile/setup-r8a7778.c
+++ b/arch/arm/mach-shmobile/setup-r8a7778.c
@@ -95,29 +95,46 @@ static struct sh_timer_config sh_tmu1_platform_data __initdata = {
95 &sh_tmu##idx##_platform_data, \ 95 &sh_tmu##idx##_platform_data, \
96 sizeof(sh_tmu##idx##_platform_data)) 96 sizeof(sh_tmu##idx##_platform_data))
97 97
98/* USB */ 98int r8a7778_usb_phy_power(bool enable)
99static struct usb_phy *phy; 99{
100 static struct usb_phy *phy = NULL;
101 int ret = 0;
102
103 if (!phy)
104 phy = usb_get_phy(USB_PHY_TYPE_USB2);
105
106 if (IS_ERR(phy)) {
107 pr_err("kernel doesn't have usb phy driver\n");
108 return PTR_ERR(phy);
109 }
110
111 if (enable)
112 ret = usb_phy_init(phy);
113 else
114 usb_phy_shutdown(phy);
100 115
116 return ret;
117}
118
119/* USB */
101static int usb_power_on(struct platform_device *pdev) 120static int usb_power_on(struct platform_device *pdev)
102{ 121{
103 if (IS_ERR(phy)) 122 int ret = r8a7778_usb_phy_power(true);
104 return PTR_ERR(phy); 123
124 if (ret)
125 return ret;
105 126
106 pm_runtime_enable(&pdev->dev); 127 pm_runtime_enable(&pdev->dev);
107 pm_runtime_get_sync(&pdev->dev); 128 pm_runtime_get_sync(&pdev->dev);
108 129
109 usb_phy_init(phy);
110
111 return 0; 130 return 0;
112} 131}
113 132
114static void usb_power_off(struct platform_device *pdev) 133static void usb_power_off(struct platform_device *pdev)
115{ 134{
116 if (IS_ERR(phy)) 135 if (r8a7778_usb_phy_power(false))
117 return; 136 return;
118 137
119 usb_phy_shutdown(phy);
120
121 pm_runtime_put_sync(&pdev->dev); 138 pm_runtime_put_sync(&pdev->dev);
122 pm_runtime_disable(&pdev->dev); 139 pm_runtime_disable(&pdev->dev);
123} 140}
@@ -353,8 +370,6 @@ void __init r8a7778_add_standard_devices(void)
353 370
354void __init r8a7778_init_late(void) 371void __init r8a7778_init_late(void)
355{ 372{
356 phy = usb_get_phy(USB_PHY_TYPE_USB2);
357
358 platform_device_register_full(&ehci_info); 373 platform_device_register_full(&ehci_info);
359 platform_device_register_full(&ohci_info); 374 platform_device_register_full(&ohci_info);
360} 375}