From patchwork Thu Oct 2 08:02:33 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yoshihiro Shimoda X-Patchwork-Id: 5016771 Return-Path: X-Original-To: patchwork-linux-sh@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 2DD64BEEA6 for ; Thu, 2 Oct 2014 08:02:58 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 53B8C20200 for ; Thu, 2 Oct 2014 08:02:57 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 71DE6201FA for ; Thu, 2 Oct 2014 08:02:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752005AbaJBICx (ORCPT ); Thu, 2 Oct 2014 04:02:53 -0400 Received: from relmlor2.renesas.com ([210.160.252.172]:20268 "EHLO relmlie1.idc.renesas.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752027AbaJBICu (ORCPT ); Thu, 2 Oct 2014 04:02:50 -0400 Received: from unknown (HELO relmlir4.idc.renesas.com) ([10.200.68.154]) by relmlie1.idc.renesas.com with ESMTP; 02 Oct 2014 17:02:49 +0900 Received: from relmlac3.idc.renesas.com (relmlac3.idc.renesas.com [10.200.69.23]) by relmlir4.idc.renesas.com (Postfix) with ESMTP id E45A941997; Thu, 2 Oct 2014 17:02:49 +0900 (JST) Received: by relmlac3.idc.renesas.com (Postfix, from userid 0) id DAAE6180A1; Thu, 2 Oct 2014 17:02:49 +0900 (JST) Received: from relmlac3.idc.renesas.com (localhost [127.0.0.1]) by relmlac3.idc.renesas.com (Postfix) with ESMTP id D40D0180A0; Thu, 2 Oct 2014 17:02:49 +0900 (JST) Received: from relmlii1.idc.renesas.com [10.200.68.65] by relmlac3.idc.renesas.com with ESMTP id TAC26891; Thu, 2 Oct 2014 17:02:49 +0900 X-IronPort-AV: E=Sophos;i="5.04,637,1406559600"; d="scan'208";a="170462318" Received: from mail-sg1lp0093.outbound.protection.outlook.com (HELO APAC01-SG1-obe.outbound.protection.outlook.com) ([207.46.51.93]) by relmlii1.idc.renesas.com with ESMTP/TLS/AES256-SHA; 02 Oct 2014 17:02:48 +0900 Received: from localhost (211.11.155.147) by HKNPR06MB322.apcprd06.prod.outlook.com (10.141.38.16) with Microsoft SMTP Server (TLS) id 15.0.1044.10; Thu, 2 Oct 2014 08:02:46 +0000 From: Yoshihiro Shimoda To: , CC: , , , Yoshihiro Shimoda Subject: [PATCH 2/2] usb: renesas_usbhs: add support for generic PHY Date: Thu, 2 Oct 2014 17:02:33 +0900 Message-ID: <1412236953-1084-3-git-send-email-yoshihiro.shimoda.uh@renesas.com> X-Mailer: git-send-email 1.9.4.msysgit.1 In-Reply-To: <1412236953-1084-1-git-send-email-yoshihiro.shimoda.uh@renesas.com> References: <1412236953-1084-1-git-send-email-yoshihiro.shimoda.uh@renesas.com> MIME-Version: 1.0 X-Originating-IP: [211.11.155.147] X-ClientProxiedBy: HK2PR01CA0022.apcprd01.prod.exchangelabs.com (25.160.175.32) To HKNPR06MB322.apcprd06.prod.outlook.com (10.141.38.16) X-Microsoft-Antispam: UriScan:; X-Microsoft-Antispam: BCL:0;PCL:0;RULEID:;SRVR:HKNPR06MB322; X-Forefront-PRVS: 03524FBD26 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10019020)(6069001)(6009001)(189002)(199003)(76482002)(42382002)(36756003)(105586002)(76506005)(50986999)(76176999)(77156001)(89996001)(99396003)(120916001)(85306004)(229853001)(33646002)(10300001)(77096002)(62966002)(107046002)(48376002)(4396001)(42186005)(95666004)(50226001)(106356001)(21056001)(93916002)(575784001)(92566001)(20776003)(47776003)(92726001)(64706001)(50466002)(19580395003)(80022003)(19580405001)(85852003)(88136002)(46102003)(66066001)(87286001)(87976001)(102836001)(31966008)(104166001)(78352002)(101416001)(97736003)(88662002); DIR:OUT; SFP:1102; SCL:1; SRVR:HKNPR06MB322; H:localhost; FPR:; MLV:sfv; PTR:InfoNoRecords; MX:0; A:0; LANG:; 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.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, 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 This patch adds support for the generic PHY. The generic PHY will be used in multiplatform environment. Signed-off-by: Yoshihiro Shimoda --- drivers/usb/renesas_usbhs/common.h | 1 + drivers/usb/renesas_usbhs/rcar2.c | 29 +++++++++++++++++++++++++++++ 2 files changed, 30 insertions(+) diff --git a/drivers/usb/renesas_usbhs/common.h b/drivers/usb/renesas_usbhs/common.h index e0d53c5..c45667f 100644 --- a/drivers/usb/renesas_usbhs/common.h +++ b/drivers/usb/renesas_usbhs/common.h @@ -270,6 +270,7 @@ struct usbhs_priv { struct usbhs_fifo_info fifo_info; struct usb_phy *usb_phy; + struct phy *phy; }; /* diff --git a/drivers/usb/renesas_usbhs/rcar2.c b/drivers/usb/renesas_usbhs/rcar2.c index 485b889..8fc15c0 100644 --- a/drivers/usb/renesas_usbhs/rcar2.c +++ b/drivers/usb/renesas_usbhs/rcar2.c @@ -12,6 +12,7 @@ #include #include +#include #include #include #include "common.h" @@ -21,6 +22,16 @@ static int usbhs_rcar2_hardware_init(struct platform_device *pdev) { struct usbhs_priv *priv = usbhs_pdev_to_priv(pdev); + if (IS_ENABLED(CONFIG_GENERIC_PHY)) { + struct phy *phy = phy_get(&pdev->dev, "usb"); + + if (IS_ERR(phy)) + return PTR_ERR(phy); + + priv->phy = phy; + return 0; + } + if (IS_ENABLED(CONFIG_USB_PHY)) { struct usb_phy *usb_phy = usb_get_phy_dev(&pdev->dev, 0); @@ -38,6 +49,11 @@ static int usbhs_rcar2_hardware_exit(struct platform_device *pdev) { struct usbhs_priv *priv = usbhs_pdev_to_priv(pdev); + if (priv->phy) { + phy_put(priv->phy); + priv->phy = NULL; + } + if (priv->usb_phy) { usb_put_phy(priv->usb_phy); priv->usb_phy = NULL; @@ -52,6 +68,19 @@ static int usbhs_rcar2_power_ctrl(struct platform_device *pdev, struct usbhs_priv *priv = usbhs_pdev_to_priv(pdev); int retval = -ENODEV; + if (priv->phy) { + if (enable) { + retval = phy_init(priv->phy); + + if (!retval) + retval = phy_power_on(priv->phy); + } else { + phy_power_off(priv->phy); + phy_exit(priv->phy); + retval = 0; + } + } + if (priv->usb_phy) { if (enable) { retval = usb_phy_init(priv->usb_phy);