From patchwork Mon Aug 5 00:43:01 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kuninori Morimoto X-Patchwork-Id: 2838496 Return-Path: X-Original-To: patchwork-linux-sh@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id E1E049F485 for ; Mon, 5 Aug 2013 00:43:06 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id E785620173 for ; Mon, 5 Aug 2013 00:43:05 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id E3BEB20168 for ; Mon, 5 Aug 2013 00:43:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754047Ab3HEAnE (ORCPT ); Sun, 4 Aug 2013 20:43:04 -0400 Received: from mail-pd0-f170.google.com ([209.85.192.170]:57334 "EHLO mail-pd0-f170.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754041Ab3HEAnE (ORCPT ); Sun, 4 Aug 2013 20:43:04 -0400 Received: by mail-pd0-f170.google.com with SMTP id x10so2596914pdj.15 for ; Sun, 04 Aug 2013 17:43:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=date:sender:message-id:to:cc:in-reply-to:references:from:subject :user-agent:mime-version:content-type; bh=s/7/vMm6o9vrqyx4l1lUYw0zwEvctpYDH8R5Xu2BbVM=; b=fN2U2nwcZ2+2qSsnJCttIjpLF3QExsKitlyGGnbBD0/TrRKyONsJ6NKsVXvW0oUIiS 9XjrWrEA89RSCr10KT1P4sWG0In5ygdci2jRydEPyBijmhYNmpqo5pIiU+Px8/gHZCHC Tn+3b1yfXPlDYezXxh089vyKsIT+GFM56fVppnnmn5jdaJ0Bm/vY5UjXjhTvrGGb1Amj d2taGb+MziDlpNS7i1MTtluPRVFIAa7sphO0MHs4JnmOmh5tnmoRN1B/ND56EkAwGxfL p5eVykkxoDQoeGw9u88YFUKvzutL3OQATTBNRj+iM7igjlFr95kx4QpcJQLNCjH2lkC7 lY9A== X-Received: by 10.69.8.65 with SMTP id di1mr19248569pbd.32.1375663382852; Sun, 04 Aug 2013 17:43:02 -0700 (PDT) Received: from morimoto-Dell-XPS420.gmail.com (49.14.32.202.bf.2iij.net. [202.32.14.49]) by mx.google.com with ESMTPSA id om2sm21586838pbb.34.2013.08.04.17.43.00 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Sun, 04 Aug 2013 17:43:01 -0700 (PDT) Date: Sun, 04 Aug 2013 17:43:01 -0700 (PDT) Message-ID: <878v0ht1bh.wl%kuninori.morimoto.gx@renesas.com> To: Simon Cc: Magnus , linux-sh@vger.kernel.org, Kuninori Morimoto In-Reply-To: <87a9kxt1dg.wl%kuninori.morimoto.gx@renesas.com> References: <87oba9fqsg.wl%kuninori.morimoto.gx@renesas.com> <87a9kxt1dg.wl%kuninori.morimoto.gx@renesas.com> From: Kuninori Morimoto Subject: [PATCH 1/3 v4] ARM: shmobile: r8a7778: add usb phy power control function User-Agent: Wanderlust/2.14.0 Emacs/23.3 Mule/6.0 MIME-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka") Sender: linux-sh-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-sh@vger.kernel.org X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,RP_MATCHES_RCVD,T_DKIM_INVALID,UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 --- v3 -> v4 - "it doesn't have..." -> "kernel doesn't have" arch/arm/mach-shmobile/include/mach/r8a7778.h | 2 ++ arch/arm/mach-shmobile/setup-r8a7778.c | 37 +++++++++++++++++-------- 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 41fd6da..b5706fb 100644 --- a/arch/arm/mach-shmobile/include/mach/r8a7778.h +++ b/arch/arm/mach-shmobile/include/mach/r8a7778.h @@ -32,4 +32,6 @@ extern void r8a7778_clock_init(void); extern void r8a7778_init_irq_extpin(int irlm); extern void r8a7778_pinmux_init(void); +extern int r8a7778_usb_phy_power(bool enable); + #endif /* __ASM_R8A7778_H__ */ diff --git a/arch/arm/mach-shmobile/setup-r8a7778.c b/arch/arm/mach-shmobile/setup-r8a7778.c index 1a154d4..5beda1c 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 = { &sh_tmu##idx##_platform_data, \ sizeof(sh_tmu##idx##_platform_data)) -/* USB */ -static struct usb_phy *phy; +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("kernel 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(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(false)) return; - usb_phy_shutdown(phy); - pm_runtime_put_sync(&pdev->dev); pm_runtime_disable(&pdev->dev); } @@ -319,8 +336,6 @@ void __init r8a7778_add_standard_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); }