From patchwork Mon Feb 22 09:58:02 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yoshihiro Shimoda X-Patchwork-Id: 8374481 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 836D09F372 for ; Mon, 22 Feb 2016 09:58:38 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id CD47120382 for ; Mon, 22 Feb 2016 09:58:37 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 0C0EE2035D for ; Mon, 22 Feb 2016 09:58:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751614AbcBVJ6g (ORCPT ); Mon, 22 Feb 2016 04:58:36 -0500 Received: from relmlor2.renesas.com ([210.160.252.172]:15022 "EHLO relmlie1.idc.renesas.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1753099AbcBVJ6f (ORCPT ); Mon, 22 Feb 2016 04:58:35 -0500 Received: from unknown (HELO relmlir4.idc.renesas.com) ([10.200.68.154]) by relmlie1.idc.renesas.com with ESMTP; 22 Feb 2016 18:58:34 +0900 Received: from relmlac3.idc.renesas.com (relmlac3.idc.renesas.com [10.200.69.23]) by relmlir4.idc.renesas.com (Postfix) with ESMTP id 3F06D4CC3B; Mon, 22 Feb 2016 18:58:34 +0900 (JST) Received: by relmlac3.idc.renesas.com (Postfix, from userid 0) id 1D2D31806F; Mon, 22 Feb 2016 18:58:34 +0900 (JST) Received: from relmlac3.idc.renesas.com (localhost [127.0.0.1]) by relmlac3.idc.renesas.com (Postfix) with ESMTP id 13F461800A; Mon, 22 Feb 2016 18:58:34 +0900 (JST) Received: from relmlii2.idc.renesas.com [10.200.68.66] by relmlac3.idc.renesas.com with ESMTP id UAD09972; Mon, 22 Feb 2016 18:58:34 +0900 X-IronPort-AV: E=Sophos;i="5.22,483,1449500400"; d="scan'";a="206147975" Received: from mail-pu1apc01lp0023.outbound.protection.outlook.com (HELO APC01-PU1-obe.outbound.protection.outlook.com) ([65.55.88.23]) by relmlii2.idc.renesas.com with ESMTP/TLS/AES256-SHA; 22 Feb 2016 18:58:32 +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=61x73NyLCbWBLnY1Su/UZMWO+W9+9SgRVULn/KB58yo=; b=HVaqvfYlMo9Yp5/eRV58Vas/OozPqstZiW4VzK22BdOrJsBZtEHcpwvoaznS6ZcmI9hrP6YVl911dIQUjvXgLgmdsXujDj+ExQO/3rRtd5B7Trx2j8zZDyiOIqEOTYzHCWXGBEnn7cwzO63p/MhSE4rbPejRzrF2jHIZxzjmAww= Authentication-Results: verge.net.au; dkim=none (message not signed) header.d=none; verge.net.au; dmarc=none action=none header.from=renesas.com; Received: from localhost (211.11.155.141) by TY1PR06MB0928.apcprd06.prod.outlook.com (10.164.99.154) with Microsoft SMTP Server (TLS) id 15.1.409.15; Mon, 22 Feb 2016 09:58:31 +0000 From: Yoshihiro Shimoda To: , , , , , , CC: , , Yoshihiro Shimoda Subject: [PATCH/RFC v2 3/9] phy: rcar-gen3-usb2: add extcon support Date: Mon, 22 Feb 2016 18:58:02 +0900 Message-ID: <1456135088-7976-4-git-send-email-yoshihiro.shimoda.uh@renesas.com> X-Mailer: git-send-email 1.9.4.msysgit.1 In-Reply-To: <1456135088-7976-1-git-send-email-yoshihiro.shimoda.uh@renesas.com> References: <1456135088-7976-1-git-send-email-yoshihiro.shimoda.uh@renesas.com> MIME-Version: 1.0 X-Originating-IP: [211.11.155.141] X-ClientProxiedBy: TY1PR06CA0023.apcprd06.prod.outlook.com (25.164.91.33) To TY1PR06MB0928.apcprd06.prod.outlook.com (25.164.99.154) X-Microsoft-Exchange-Diagnostics: 1; TY1PR06MB0928; 2:A87ph6xcFyceBO9gKpKfxoTLNoxffPcOSvSTKtFGMkuDgOcQlDG+SdHKh6c7T/j5rDC9+8YGPg0NRJa2a25pFOYffO8nM0B3RrtAjBeOPKNKN0/7awiyhQYMETa+MnR1KJeownE6W177nhDNgUMnMA==; 3:uUDKV4x4Q7cpFiTMtdQfQY2KLQ1bbwdoVA4N+SJJ+UY319ryrkEhRefJEIx4zbcFSgO1OH/Vy5H6186JVEwYISq0ur7KMbP30pRi1E85+BniqvlzYZqUw0rM7hzHE6yS; 25:Cd5yIRFwMsyK3pcEj4Kyy8tYtSjQIMjqwSeTV/P4iS4ECsgALfGpSxdrP5IoAO6RmJKm7n4RXZVu7a7crWR1AI9d0BDIB4arEbMhfVlKR6bQsMcEWqGkByJgiizULAOscFTHmiyXY3is0wvJTBWt/9Ol2cS4NCD0V24F71On0BkXnTw3BszUaElyrQJzl0i8aPYyTNG5KENrHtWwnCOYqdBZZSLvaw+6TKRHrAN7mTOYW21Y0T6b1AExWhmx5gmeP6ZmChXuoefcVJI8RA2kKhjutLPKoyKUIO99340KIZfax9RxWnlzeWHbbEz6nRhVwpUG+bAxyWAQy61KeH/ArpODHXI3zoBp/p4HUiAjV/o= X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:TY1PR06MB0928; X-MS-Office365-Filtering-Correlation-Id: 702b20fc-d36d-49b0-8999-08d33b6eb82f X-Microsoft-Exchange-Diagnostics: 1; TY1PR06MB0928; 20:32+1i1tsl6YWQmhFstlZkUdTVBFmGQiKaCqmhUrvibTVVH9uPZZfMd3LQo4T5EI5ixYrtd0icr7mAuv0JjAQKS5OfhNi70G5iMbeY5ifBQbAiXqXxn5/G1Q+5zW1Q0cX4aLc9a2AnF/Me0EB99jJoCZehx82G8bbjtE9VjZtEN1NZI1hzgEOisEX1U0gp79fzNMRFJqSutA4uovPY3ucSZdqvWzszdAQPi5tTH0XMhIn+xwH3hMTNXwzR2RVop4jkfmoKODvOb2ViiPjpVsTqjhFOadthI2eVRRAq87FY2Ao5nzgs9463VXmHvvuV9OzGBHZvus/fYUSClXf8j+UYEDsgGfeD4yJxFfYSt6ZI0/z/WsxBI8XQSeJhcnh7KHePzqaXy2RJDApbeBD4Dgz/6jYNj3c4k54stlaDoQvpbJJdvlKOV+sFhNseiVOQL4iSPvgYCE4/cV1mtyyDQR24n4S1BjVHdE7eWeJP3+on1PivPK+JZgVqDv9EovVzbO3; 4:MMy3IuMv9h47rvPVmlt59PtCJ9E9AHdua8fxQr9wi5J228rxyC6dXDgaUREiOf8tupgk5vThC9hsEoyP7nBkIupPqEw+ns+9wBF9DDU+fvG58RZsV8vdtkvhbDRGANSwIOEQOMO29IUFoQz+X9RTJ4q08metE9/Th7Udo22Ba1Ta0WMYdFtq2P5wSkjdTf9IDScytex8H3BHpjYm7s5WBLBdMBqF9auIHCoZstdKPHzEvcD91DPAJ1+LUf5gfev2T++Us1uhdCl/UjjMV4gns5X47LZe5i31LXu2bOLmRB7BUZfJtcVWYdtMNavu8Xt64fyVqPhzrIhNOGTbLpcQoDTqbkI2MG45iB/YCYbX8uJnnS/RMKQyKHp4uoQoJLPp X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(601004)(2401047)(8121501046)(5005006)(10201501046)(3002001); SRVR:TY1PR06MB0928; BCL:0; PCL:0; RULEID:; SRVR:TY1PR06MB0928; X-Forefront-PRVS: 0860FE717F X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10019020)(4630300001)(6009001)(6069001)(5001770100001)(33646002)(107886002)(76176999)(5001960100002)(50986999)(2950100001)(77096005)(42382002)(36756003)(50466002)(229853001)(50226001)(230783001)(87976001)(5004730100002)(2906002)(4326007)(76506005)(92566002)(5008740100001)(586003)(48376002)(6116002)(3846002)(1096002)(78352003)(42186005)(66066001)(47776003)(4001430100002)(40100003)(189998001)(19580405001)(122386002)(19580395003)(2004002); DIR:OUT; SFP:1102; SCL:1; SRVR:TY1PR06MB0928; H:localhost; FPR:; SPF:None; MLV:sfv; LANG:en; X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; TY1PR06MB0928; 23:6zaPFW410gnm/CcDJJvVyi7PH1jJi+W2V51hOA5Rv?= =?us-ascii?Q?sEJjF19//nHUU4Qv6n+qaw57uqubUGwjyVsDwIWu3N5Wiju79cSTr14icg0j?= =?us-ascii?Q?9Y1pWyb4FYZLNpnp5J6eieq2/bSOcsdashMILplABREfdIbq4ElhuBCrMccT?= =?us-ascii?Q?+33BZQX24u6b6H/OvIobjHuxWA10gFGRg9UCHJtvm8opg9Sp2axuIEiC/Pq6?= =?us-ascii?Q?Xk9j7qpV/mdLFfw8gz92hSqMaxbsjEJmVjJ3nUlIGYS4voA/BYodB/6CxMR2?= =?us-ascii?Q?bzJcNaYb/jxmHiAAmnlwJ3r5nKiF6siYXi/lgLBdziBcuyKIKQ2LigsLQRse?= =?us-ascii?Q?s5Z+EmrOOyiT80dWJrAoLBDDwyQumKyti9Tr8rwf7UViqscWTiE2UMzUkeRq?= =?us-ascii?Q?NIcJW0Hz11O6SIOHwMDz9668/sk6oCvn3P1QxTY+y+L3OPQ1Vqz5O5srgvrz?= =?us-ascii?Q?Yzd+RH0UYHgJMgfij7zHsKnNyGQXWRu3HQx1BTvom/ZbGK/T2EVwpVX2tn5U?= =?us-ascii?Q?+6cNVBR4igLmpE6k+NPoSQPOB52ydrA9COXxv+J2pOzdr0FqTKEmAM6Ehxuw?= =?us-ascii?Q?+sJ5dp5y+swAocc1SgOgO69c2z/Tc453cE5ADs5cxAoc2r9CppX0sy6rTFNj?= =?us-ascii?Q?MeiqwdgUks19ChWEMK88Zje61txM58SHhl17jC0HID/0kqNU80tHeFiOpiEB?= =?us-ascii?Q?pHc0Ad/WWwXshkW0ibaeYPM4NaZmRO/SKmgJkZ8uIHSKRtNAUvGzzrmWIL3D?= =?us-ascii?Q?aHBXLHi9NGKCNa0shkVyOQlwKGEEJwRzyaePE6MsMVKJaWu1+P2yxSjBRZPN?= =?us-ascii?Q?V7IT47C3PH9QcdHw75zYNMeSSesRAkQ+h54vH0oz1T+w8MRPxn73FTjJ6epj?= =?us-ascii?Q?dhGHM62z1gDMWqZT1+UtAmqbVU3CJCVmK713pEpYLfACN+JYXoXpN10Dth40?= =?us-ascii?Q?CplkAecA7plMVoU1TlMRaNSE4fnBMT+Ql72PnRqyN2DbFHuySJph7+XOvgfg?= =?us-ascii?Q?rl7gqHcu29oplDf9FrmOHJ2ZsGKypG/pgCILSvBn4AF57gSXx0hntB/GHaIc?= =?us-ascii?Q?JnEFV2hL4jl41QcHhkHiFJwZzsZ?= X-Microsoft-Exchange-Diagnostics: 1; TY1PR06MB0928; 5:fLNS8ZOr3L7L4wj77LKarqLiRclGq/qX8sqZpyGwbbb5LcqUodfG0+fZaRuFa464iIEA2TGEEGUJmdBX3x+1ABvSxf5crhGbuwtJjJ5APS77BK6VSgE/NDENeJ8BA2b5GXjDPouV5lgFuZpNTSKr5w==; 24:outnE9mDM0OSTkQhWLmUcaLKcipr58dxFey7G4HNzNxiQ3au1gMMmCh7zZW6yuKtYWKZzU1/0CvsmwOEfipSkxb+SY9s1bGtWGT+YYT9eco=; 20:iTV2pdnz/pShAk9ak/nbikOLysYy7KSIPPTKBClZTrQoXdt5mou8FdGUcJkZgN7CYhhxBRcAKDWeYddjc+sWE2FHFPmYCMzREBl80UzJQI/L+j3+11XRmKuIjtmdqZXKqc3d5K9q76PI63I+BICfC1+mTUE3CGPNDoZB5nZbolA= SpamDiagnosticOutput: 1:23 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: renesas.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Feb 2016 09:58:31.1623 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: TY1PR06MB0928 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 --- 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 0124d17..32c7088 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_SHMOBILE + 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 c2bfde8..d4af4dc 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) @@ -271,6 +279,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; @@ -296,11 +310,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); */