From patchwork Thu Mar 3 10:09:06 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yoshihiro Shimoda X-Patchwork-Id: 8490871 X-Patchwork-Delegate: geert@linux-m68k.org Return-Path: X-Original-To: patchwork-linux-renesas-soc@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id DE8D49F314 for ; Thu, 3 Mar 2016 10:09:59 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 32AAA201F4 for ; Thu, 3 Mar 2016 10:09:59 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 5D3C8202AE for ; Thu, 3 Mar 2016 10:09:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757346AbcCCKJu (ORCPT ); Thu, 3 Mar 2016 05:09:50 -0500 Received: from relmlor4.renesas.com ([210.160.252.174]:57857 "EHLO relmlie3.idc.renesas.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751256AbcCCKJn (ORCPT ); Thu, 3 Mar 2016 05:09:43 -0500 Received: from unknown (HELO relmlir1.idc.renesas.com) ([10.200.68.151]) by relmlie3.idc.renesas.com with ESMTP; 03 Mar 2016 19:09:41 +0900 Received: from relmlac2.idc.renesas.com (relmlac2.idc.renesas.com [10.200.69.22]) by relmlir1.idc.renesas.com (Postfix) with ESMTP id 4608B514BF; Thu, 3 Mar 2016 19:09:40 +0900 (JST) Received: by relmlac2.idc.renesas.com (Postfix, from userid 0) id 42A622806E; Thu, 3 Mar 2016 19:09:40 +0900 (JST) Received: from relmlac2.idc.renesas.com (localhost [127.0.0.1]) by relmlac2.idc.renesas.com (Postfix) with ESMTP id 3DCEC2806D; Thu, 3 Mar 2016 19:09:40 +0900 (JST) Received: from relmlii2.idc.renesas.com [10.200.68.66] by relmlac2.idc.renesas.com with ESMTP id VAC12964; Thu, 3 Mar 2016 19:09:40 +0900 X-IronPort-AV: E=Sophos;i="5.22,531,1449500400"; d="scan'";a="206911691" Received: from mail-hk2apc01lp0216.outbound.protection.outlook.com (HELO APC01-HK2-obe.outbound.protection.outlook.com) ([65.55.88.216]) by relmlii2.idc.renesas.com with ESMTP/TLS/AES256-SHA; 03 Mar 2016 19:09:38 +0900 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=renesasgroup.onmicrosoft.com; s=selector1-renesasgroup-onmicrosoft-com; h=From:To:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=IE2jrcLxCBkWL1tJxlY2+8ljaZjxhZURepm6JrYjPVA=; b=HyLzCAA6EvSKv2BTzeliRM3f4loXs7LdD/b++z1iCl9ud8HoEEUs+tg0BrogmiNjArhAoLix0HU1rL7NNCIRmU2K8vK63LGUnmTdMrTkQqZFe1OTfGDFFRSikTszYfOReEdrnybmHsBag/4aDd5kOTbDnkl/kbYJfnP4WUXVmQY= Authentication-Results: ti.com; dkim=none (message not signed) header.d=none; ti.com; dmarc=none action=none header.from=renesas.com; Received: from localhost (211.11.155.144) by SG2PR06MB0918.apcprd06.prod.outlook.com (10.162.201.158) with Microsoft SMTP Server (TLS) id 15.1.415.20; Thu, 3 Mar 2016 10:09:36 +0000 From: Yoshihiro Shimoda To: , , , , , CC: , , , Yoshihiro Shimoda Subject: [PATCH 3/3] phy: rcar-gen3-usb2: add extcon support Date: Thu, 3 Mar 2016 19:09:06 +0900 Message-ID: <1456999746-2800-4-git-send-email-yoshihiro.shimoda.uh@renesas.com> X-Mailer: git-send-email 1.9.4.msysgit.1 In-Reply-To: <1456999746-2800-1-git-send-email-yoshihiro.shimoda.uh@renesas.com> References: <1456999746-2800-1-git-send-email-yoshihiro.shimoda.uh@renesas.com> MIME-Version: 1.0 X-Originating-IP: [211.11.155.144] X-ClientProxiedBy: KAWPR01CA0039.jpnprd01.prod.outlook.com (25.165.48.149) To SG2PR06MB0918.apcprd06.prod.outlook.com (25.162.201.158) X-Microsoft-Exchange-Diagnostics: 1; SG2PR06MB0918; 2:T2Zoo7Yq9h3T3Q21WKAKlDx8qTInB+CXXWfh+PLl6hJWJibtfiSFwnHsIeoY1BnefEgA7vP0NCoWAva6sl2dJkWkgcAgZAi8zbRkz+Fq+4VjNboPHW/14bVoCRn08mAdEp1OkUM5Y2MCf91We3T6gA==; 3:5GbPCw+ELHAt6oHc1Zfum0t81TQij0U6CAc6hytP5nHuSM4d1aoX9Qay0vVfyxNAIQhc0K9OXT/7j7bvkwmQv4gX4U6/tWGRn07Q0AqA2U7UiGbDnfxUlnboFtQlkNMD; 25:7Iw13rmZHms8x6hgGmvNKUV4jZ45cF10h8tWEfvfvxt3Wsry7FTlouts7y+4d9mV1kbNkckJ53iMOywf5sz8plDjT6FATjBLixzhMmS5X8raEp81QqaaXwvNFU/8K8WsHQQbO/aQLF1yejzl/sdIeTbcWpR3hUG5JDkxlnsej90fXsj2ff3BbKyVKzBBi6CsCUIJFGULRoHfMd8ybACPWJWDAP/5ROWmPqMyk95jNKjHQWiZr9wKatS7554vZ4uapwbw+QNJEWjBwg6UOjR4YMmd9CBLX8vpIRdT9NWbYc6S9KzKy8Sc4GCaD77MvGBWve+AAX5vWA0HnA5IkAfwLgXvXB1bxhdSp2rPkxIBEyi8PHNx/J5YZxU0fJfCpnPvp6aFi8lUbYAW/KYR6py3lw== X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:SG2PR06MB0918; X-MS-Office365-Filtering-Correlation-Id: 88fe5043-8a6b-4c84-4a5d-08d3434becfc X-Microsoft-Exchange-Diagnostics: 1; SG2PR06MB0918; 20:cbbfid2nL22wdbPVS6oEMwkdPAeG59GMifwa/OzWtn4XpBk7uInStGSRu2LuTAKeqY7wQCh0B8WizCGOoeXF/KrEDGQG4AUg345tshDUav1WFY+NZnxeuitCXCShtme38N1xZeKWWAkR5SlTAmPYnZJVAa4IVMZe2PW6rcF4Lcp4UonP099RBnVLg/afokSzqIKd/jizHZg/1tDI6XwpUULgxhsIkgYDtBYM+I6woZT1yvQyTwdamLz0ZHWmrqoC/QUI8HAr+ihkgZDbplFVrFSFeiZ/sLw4+715kfYRQc0uevkui7m4UcOocAfCMVqXIuu3QW6PMC8CYCs8fLyv6Wze78uoy2S4tCHyRzPZ4D7ldcYqOLA3mJ0oqZo/ooEEVUDZqXtdpRd1setDHpPjJujcFGStsemjd2wMDmrcwhAmkIv0c5L/lr2C7W3NThJGwZioVwP9fqLv7bbzmxinbjAMPjwF6jAY0XqWDBDm7rkA954NiuvbC4+Czth0LaeO; 4:glNiY/8ZaQ2lPoJgx4CqAmJ33QYaxTaO0Z3Q1upOi/4oQ12E6dilQeVeWUxYSZkek9BlOzo0m4inFq3/+mRiIaemTzQ5MJhQfZgZj0LodSH0f79fOW82WeuzwuNsl8+VgLxEhHi9H1gFeE67T2KlNQCd8Dlvyx4kVegSydGenrCnt+lqa+oHAR9G73vKpjjaKhUCEi2KaiZuBTynHKZ6FHZyJGZzgjMxL1ACuu7LTdk0jRbTbA+qV6ksLceycltsFB6BqV6qL0THzlo0ZxCEHwjlsxuqoS2qUx4QqibfcXJ3ciPqv6B4WhZyjgQKSx8EidYEy2zW0mE6xvbIDR2mXQb511JoCqjxo+Uz7YwgRS/pMD8gPT2okXfI5h6IcWPJ X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(601004)(2401047)(5005006)(8121501046)(3002001)(10201501046); SRVR:SG2PR06MB0918; BCL:0; PCL:0; RULEID:; SRVR:SG2PR06MB0918; X-Forefront-PRVS: 0870212862 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10019020)(4630300001)(6069001)(6009001)(76506005)(50466002)(47776003)(40100003)(5001770100001)(230783001)(42186005)(33646002)(122386002)(5003940100001)(2950100001)(4326007)(5001960100004)(66066001)(229853001)(42382002)(2906002)(189998001)(586003)(19580395003)(78352003)(19580405001)(36756003)(1096002)(3846002)(77096005)(4001430100002)(6116002)(107886002)(87976001)(92566002)(5004730100002)(50226001)(76176999)(5008740100001)(48376002)(50986999)(2004002); DIR:OUT; SFP:1102; SCL:1; SRVR:SG2PR06MB0918; H:localhost; FPR:; SPF:None; MLV:sfv; LANG:en; X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; SG2PR06MB0918; 23:Me63LrZokxJp9znToedvpGQPxZIZzOIkobgPRX0HR?= =?us-ascii?Q?iZIvdjlE7z2DuXtSXlS+EI4b5WGGPYYEwiwIvi5cYRDwyx1lQ8GDcYJLuhFN?= =?us-ascii?Q?nngZ/tUzQACWDJaK9dqGvXP5ji6n6RtIvvhgJxBkRLTCzb9LlBnfd6yPxVQd?= =?us-ascii?Q?WrOymmYo8R+9tYFJzUIut5IE+UxwSdlRA/ZxHucsfeYG8T7lGh+rv/VpQ17W?= =?us-ascii?Q?3w0RZz+kTgfb6QYLKOYPnCCeHFgaQ+62Pw6JoX4zaiPUNEst3+Poh4cNl9a/?= =?us-ascii?Q?SO0c9vXyTVpGLFZaAGnU/vzxwiPoVg1Yh0aNnHh2Tt854C1TUD1+OIhNasYE?= =?us-ascii?Q?6SZbcGoMBsxH+rOlh2SFtEi8O7NU01ADBHFPzrJ9Qx+GV893ZFEF5EAumqsZ?= =?us-ascii?Q?aEa3VcgTaC1fRXV03uHYOT/5cMaZWMxC6+KLRVOBCCG4l5oopDRX905MXMMq?= =?us-ascii?Q?RydhrBL1xBq+ZkpM+kKp99P1PaAElkaNwmOpGWOvX+0wK2UIMrpAo4hZW8TO?= =?us-ascii?Q?sJN5F5tB2luloO3OdGr6EzIqK1WWPT1hb+3fxTfrbG35A3EbjHjZ+gW2Jl01?= =?us-ascii?Q?eWEE+nS4Tj1bPOmUCPM92V8oiTbxofUD3lmlVyCepDAXAFbW0fO4qAThoQoJ?=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Nqxa4v6VsSai/Lmm4Zad+WGIlsFI= SpamDiagnosticOutput: 1:23 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: renesas.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Mar 2016 10:09:36.3499 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: SG2PR06MB0918 Sender: linux-renesas-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-renesas-soc@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,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 This patch adds extcon support for otg related channel. Signed-off-by: Yoshihiro Shimoda Reviewed-by: Chanwoo Choi --- drivers/phy/Kconfig | 1 + drivers/phy/phy-rcar-gen3-usb2.c | 26 ++++++++++++++++++++++++++ 2 files changed, 27 insertions(+) diff --git a/drivers/phy/Kconfig b/drivers/phy/Kconfig index ba68f14..db57d6c 100644 --- a/drivers/phy/Kconfig +++ b/drivers/phy/Kconfig @@ -121,6 +121,7 @@ config PHY_RCAR_GEN2 config PHY_RCAR_GEN3_USB2 tristate "Renesas R-Car generation 3 USB 2.0 PHY driver" depends on OF && ARCH_RENESAS + depends on EXTCON select GENERIC_PHY help Support for USB 2.0 PHY found on Renesas R-Car generation 3 SoCs. diff --git a/drivers/phy/phy-rcar-gen3-usb2.c b/drivers/phy/phy-rcar-gen3-usb2.c index 7b14244..76bb88f 100644 --- a/drivers/phy/phy-rcar-gen3-usb2.c +++ b/drivers/phy/phy-rcar-gen3-usb2.c @@ -12,6 +12,7 @@ * published by the Free Software Foundation. */ +#include #include #include #include @@ -77,6 +78,7 @@ struct rcar_gen3_chan { void __iomem *base; + struct extcon_dev *extcon; struct phy *phy; struct regulator *vbus; bool has_otg; @@ -127,6 +129,9 @@ static void rcar_gen3_init_for_host(struct rcar_gen3_chan *ch) rcar_gen3_set_linectrl(ch, 1, 1); rcar_gen3_set_host_mode(ch, 1); rcar_gen3_enable_vbus_ctrl(ch, 1); + + extcon_set_cable_state_(ch->extcon, EXTCON_USB_HOST, true); + extcon_set_cable_state_(ch->extcon, EXTCON_USB, false); } static void rcar_gen3_init_for_peri(struct rcar_gen3_chan *ch) @@ -134,6 +139,9 @@ static void rcar_gen3_init_for_peri(struct rcar_gen3_chan *ch) rcar_gen3_set_linectrl(ch, 0, 1); rcar_gen3_set_host_mode(ch, 0); rcar_gen3_enable_vbus_ctrl(ch, 0); + + extcon_set_cable_state_(ch->extcon, EXTCON_USB_HOST, false); + extcon_set_cable_state_(ch->extcon, EXTCON_USB, true); } static bool rcar_gen3_check_vbus(struct rcar_gen3_chan *ch) @@ -272,6 +280,12 @@ static const struct of_device_id rcar_gen3_phy_usb2_match_table[] = { }; MODULE_DEVICE_TABLE(of, rcar_gen3_phy_usb2_match_table); +static const unsigned int rcar_gen3_phy_cable[] = { + EXTCON_USB, + EXTCON_USB_HOST, + EXTCON_NONE, +}; + static int rcar_gen3_phy_usb2_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; @@ -297,11 +311,23 @@ static int rcar_gen3_phy_usb2_probe(struct platform_device *pdev) /* call request_irq for OTG */ irq = platform_get_irq(pdev, 0); if (irq >= 0) { + int ret; + irq = devm_request_irq(dev, irq, rcar_gen3_phy_usb2_irq, IRQF_SHARED, dev_name(dev), channel); if (irq < 0) dev_err(dev, "No irq handler (%d)\n", irq); channel->has_otg = true; + channel->extcon = devm_extcon_dev_allocate(dev, + rcar_gen3_phy_cable); + if (IS_ERR(channel->extcon)) + return PTR_ERR(channel->extcon); + + ret = devm_extcon_dev_register(dev, channel->extcon); + if (ret < 0) { + dev_err(dev, "Failed to register extcon\n"); + return ret; + } } /* devm_phy_create() will call pm_runtime_enable(dev); */