From patchwork Thu May 29 01:32:08 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yoshihiro Shimoda X-Patchwork-Id: 4258491 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 EFB189F32B for ; Thu, 29 May 2014 01:32:19 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 1579B2018E for ; Thu, 29 May 2014 01:32:19 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 1BACD201FA for ; Thu, 29 May 2014 01:32:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754741AbaE2BcR (ORCPT ); Wed, 28 May 2014 21:32:17 -0400 Received: from relmlor2.renesas.com ([210.160.252.172]:64599 "EHLO relmlie1.idc.renesas.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751941AbaE2BcQ (ORCPT ); Wed, 28 May 2014 21:32:16 -0400 Received: from unknown (HELO relmlir1.idc.renesas.com) ([10.200.68.151]) by relmlie1.idc.renesas.com with ESMTP; 29 May 2014 10:32:15 +0900 Received: from relmlac3.idc.renesas.com (relmlac3.idc.renesas.com [10.200.69.23]) by relmlir1.idc.renesas.com (Postfix) with ESMTP id 3E3824B862; Thu, 29 May 2014 10:32:15 +0900 (JST) Received: by relmlac3.idc.renesas.com (Postfix, from userid 0) id 2EB80180A0; Thu, 29 May 2014 10:32:15 +0900 (JST) Received: from relmlac3.idc.renesas.com (localhost [127.0.0.1]) by relmlac3.idc.renesas.com (Postfix) with ESMTP id 243CE180A5; Thu, 29 May 2014 10:32:15 +0900 (JST) Received: from relmlii1.idc.renesas.com [10.200.68.65] by relmlac3.idc.renesas.com with ESMTP id LAB10197; Thu, 29 May 2014 10:32:15 +0900 X-IronPort-AV: E=Sophos;i="4.98,931,1392130800"; d="scan'208";a="160844197" Received: from mail-hk1lp0117.outbound.protection.outlook.com (HELO APAC01-HK1-obe.outbound.protection.outlook.com) ([207.46.51.117]) by relmlii1.idc.renesas.com with ESMTP/TLS/AES128-SHA; 29 May 2014 10:32:13 +0900 Received: from [10.161.20.55] (211.11.155.147) by SINPR06MB332.apcprd06.prod.outlook.com (10.141.110.18) with Microsoft SMTP Server (TLS) id 15.0.954.9; Thu, 29 May 2014 01:32:12 +0000 Message-ID: <53868E18.7090805@renesas.com> Date: Thu, 29 May 2014 10:32:08 +0900 From: Yoshihiro Shimoda User-Agent: Mozilla/5.0 (Windows NT 6.1; rv:24.0) Gecko/20100101 Thunderbird/24.5.0 MIME-Version: 1.0 To: "mathias.nyman@intel.com" , Greg Kroah-Hartman , "linux-usb@vger.kernel.org" , Gregory CLEMENT CC: SH-Linux , Magnus Damm , Geert Uytterhoeven , Grant Likely , Rob Herring , "devicetree@vger.kernel.org" Subject: [PATCH v3 1/2] usb: host: xhci-plat: add optional PHY support X-Originating-IP: [211.11.155.147] X-ClientProxiedBy: HKXPR03CA013.apcprd03.prod.outlook.com (10.141.129.23) To SINPR06MB332.apcprd06.prod.outlook.com (10.141.110.18) X-Forefront-PRVS: 022649CC2C X-Forefront-Antispam-Report: SFV:NSPM; SFS:(6009001)(6049001)(428001)(199002)(189002)(81542001)(76482001)(102836001)(81342001)(79102001)(64706001)(77982001)(87976001)(54356999)(50986999)(36756003)(20776003)(47776003)(59896001)(23756003)(87266999)(66066001)(65956001)(83072002)(85852003)(99136001)(83322001)(4396001)(46102001)(99396002)(50466002)(65816999)(80316001)(33656002)(80022001)(19580395003)(19580405001)(21056001)(83506001)(92726001)(86362001)(31966008)(92566001)(74662001)(74502001)(101416001)(42186004)(64126003); DIR:OUT; SFP:; SCL:1; SRVR:SINPR06MB332; H:[10.161.20.55]; FPR:; MLV:sfv; PTR:InfoNoRecords; A:1; MX:1; LANG:en; Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=yoshihiro.shimoda.uh@renesas.com; X-OriginatorOrg: renesas.com Sender: linux-sh-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-sh@vger.kernel.org X-Spam-Status: No, score=-7.5 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable 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 From: Gregory CLEMENT This commit extends the xhci-plat so that it can optionally be passed a reference to a PHY through the Device Tree. It will be useful for the Armada 375 SoCs. If no PHY is provided then the behavior of the driver is unchanged. As for the clock, to achieve this, it adds a 'struct phy *' member in xhci_hcd. While only used for now in xhci-plat, here again, it might be used by other drivers in the future. Signed-off-by: Gregory CLEMENT Signed-off-by: Yoshihiro Shimoda --- drivers/usb/host/xhci-plat.c | 27 ++++++++++++++++++++++++++- drivers/usb/host/xhci.h | 2 ++ 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/drivers/usb/host/xhci-plat.c b/drivers/usb/host/xhci-plat.c index 29d8adb..1389370 100644 --- a/drivers/usb/host/xhci-plat.c +++ b/drivers/usb/host/xhci-plat.c @@ -15,6 +15,7 @@ #include #include #include +#include #include #include @@ -99,6 +100,7 @@ static int xhci_plat_probe(struct platform_device *pdev) struct resource *res; struct usb_hcd *hcd; struct clk *clk; + struct phy *phy; int ret; int irq; @@ -165,9 +167,23 @@ static int xhci_plat_probe(struct platform_device *pdev) goto unmap_registers; } + phy = devm_phy_optional_get(&pdev->dev, "usb"); + if (IS_ERR(phy)) { + ret = PTR_ERR(phy); + goto disable_clk; + } else { + ret = phy_init(phy); + if (ret) + goto disable_clk; + + ret = phy_power_on(phy); + if (ret) + goto disable_phy; + } + ret = usb_add_hcd(hcd, irq, IRQF_SHARED); if (ret) - goto disable_clk; + goto power_off_phy; device_wakeup_enable(hcd->self.controller); @@ -203,6 +219,12 @@ put_usb3_hcd: dealloc_usb2_hcd: usb_remove_hcd(hcd); +power_off_phy: + phy_power_off(phy); + +disable_phy: + phy_exit(phy); + disable_clk: if (!IS_ERR(clk)) clk_disable_unprepare(clk); @@ -224,6 +246,7 @@ static int xhci_plat_remove(struct platform_device *dev) struct usb_hcd *hcd = platform_get_drvdata(dev); struct xhci_hcd *xhci = hcd_to_xhci(hcd); struct clk *clk = xhci->clk; + struct phy *phy = xhci->phy; usb_remove_hcd(xhci->shared_hcd); usb_put_hcd(xhci->shared_hcd); @@ -231,6 +254,8 @@ static int xhci_plat_remove(struct platform_device *dev) usb_remove_hcd(hcd); if (!IS_ERR(clk)) clk_disable_unprepare(clk); + phy_power_off(phy); + phy_exit(phy); iounmap(hcd->regs); release_mem_region(hcd->rsrc_start, hcd->rsrc_len); usb_put_hcd(hcd); diff --git a/drivers/usb/host/xhci.h b/drivers/usb/host/xhci.h index 9ffecd5..fa4bf17 100644 --- a/drivers/usb/host/xhci.h +++ b/drivers/usb/host/xhci.h @@ -1474,6 +1474,8 @@ struct xhci_hcd { struct msix_entry *msix_entries; /* optional clock */ struct clk *clk; + /* optional phy */ + struct phy *phy; /* data structures */ struct xhci_device_context_array *dcbaa; struct xhci_ring *cmd_ring;