From patchwork Tue Feb 2 10:18:52 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yoshihiro Shimoda X-Patchwork-Id: 8188321 X-Patchwork-Delegate: horms@verge.net.au 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 86A689FBE9 for ; Tue, 2 Feb 2016 10:19:48 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id DA9B220263 for ; Tue, 2 Feb 2016 10:19:47 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 1C4BE2021F for ; Tue, 2 Feb 2016 10:19:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754494AbcBBKTq (ORCPT ); Tue, 2 Feb 2016 05:19:46 -0500 Received: from relmlor2.renesas.com ([210.160.252.172]:9736 "EHLO relmlie1.idc.renesas.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1754408AbcBBKTp (ORCPT ); Tue, 2 Feb 2016 05:19:45 -0500 Received: from unknown (HELO relmlir1.idc.renesas.com) ([10.200.68.151]) by relmlie1.idc.renesas.com with ESMTP; 02 Feb 2016 19:19:44 +0900 Received: from relmlac1.idc.renesas.com (relmlac1.idc.renesas.com [10.200.69.21]) by relmlir1.idc.renesas.com (Postfix) with ESMTP id 326D241AC4; Tue, 2 Feb 2016 19:19:44 +0900 (JST) Received: by relmlac1.idc.renesas.com (Postfix, from userid 0) id 2CE9F8002E; Tue, 2 Feb 2016 19:19:44 +0900 (JST) Received: from relmlac1.idc.renesas.com (localhost [127.0.0.1]) by relmlac1.idc.renesas.com (Postfix) with ESMTP id 25D808002D; Tue, 2 Feb 2016 19:19:44 +0900 (JST) Received: from relmlii2.idc.renesas.com [10.200.68.66] by relmlac1.idc.renesas.com with ESMTP id VAA06497; Tue, 2 Feb 2016 19:19:44 +0900 X-IronPort-AV: E=Sophos;i="5.22,384,1449500400"; d="scan'";a="204834392" Received: from mail-hk2apc01lp0212.outbound.protection.outlook.com (HELO APC01-HK2-obe.outbound.protection.outlook.com) ([65.55.88.212]) by relmlii2.idc.renesas.com with ESMTP/TLS/AES256-SHA; 02 Feb 2016 19:19:42 +0900 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.144) by SIXPR06MB0921.apcprd06.prod.outlook.com (10.162.173.13) with Microsoft SMTP Server (TLS) id 15.1.396.15; Tue, 2 Feb 2016 10:19:41 +0000 From: Yoshihiro Shimoda To: , , , , , , CC: , , Yoshihiro Shimoda Subject: [PATCH/RFC 04/10] phy: rcar-gen3-usb2: add extcon support Date: Tue, 2 Feb 2016 19:18:52 +0900 Message-ID: <1454408338-4612-5-git-send-email-yoshihiro.shimoda.uh@renesas.com> X-Mailer: git-send-email 1.9.4.msysgit.1 In-Reply-To: <1454408338-4612-1-git-send-email-yoshihiro.shimoda.uh@renesas.com> References: <1454408338-4612-1-git-send-email-yoshihiro.shimoda.uh@renesas.com> MIME-Version: 1.0 X-Originating-IP: [211.11.155.144] X-ClientProxiedBy: OS1PR01CA0005.jpnprd01.prod.outlook.com (25.161.225.143) To SIXPR06MB0921.apcprd06.prod.outlook.com (25.162.173.13) X-Microsoft-Exchange-Diagnostics: 1; SIXPR06MB0921; 2:PTj7ROjKpBR6mgqD2x6CBs8K7ZiRhvJeDzvyVIvIMlEc9EnKFaH63MupLsotdN89YgqV+70qcOzT3m+F4dfpNPGy7tFZo+LNYEj75gqUsnovLCb/8feLjFEzhWktjEsDfCDFAf7VnT6HbJw3kRo+9g==; 3:zimey4QkCspP313ZnLDzUmE0k29E0zkUtJy/dHL1mk2rQf6fc83VHJg34aVjLgw/4q1ffoJpuGZZNCEdPiuBDco15onlI/VEXh5z1204dfHHHMf+H97oPQJfDr8IHDiR; 25:aX7TwTA7K5mfJSRHR5oLvbjtuWqNK0cgNq2HlQujEyHqdz8HfapIRvUJKlpHu/HKymbk8hxWOnau/II/jzKOSN+G5epiQ7TcCXcTnnMSiPclg4M2VxN6I4MOYRpiExsy6U8e2pd9W/enNIVdjGQtqgw/sERhRLPoQn4Biaj205uZoQ812wT0C9Ukv6emgDapBA+lnxcYTeV8B7QdWXFftcNnKCvlaZ1ZUGEEPYW2gGtyV7AuAeawgHXB3i+hPOcd X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:SIXPR06MB0921; X-MS-Office365-Filtering-Correlation-Id: 7e26a48e-41ee-40f8-7456-08d32bba5d45 X-Microsoft-Exchange-Diagnostics: 1; SIXPR06MB0921; 20:4mk8H5fr55pHpKeM05XSdCU66xTcNBmycHwSfNppyx6eJ/w/KAR/dFswKQHATS78lNZYpT6b5VjBzQ4N57Zm3q6I91KLQqOqYd2FnEmRApGWtLDk3JQys0BBthgur0Vu0k6PuOiu2hh2Ys3qOn4J7PTWkbq7N4WfrXestqfQId3odnEif7m9iVT6ttnxzjSnWVQgTNzdIR56XMrJHw5q6FB22LG0T/JE8QtsTrx1cOvAqPj7Axau3nYX0tr7M+lOtP8+bCoE8dwwMMND7//8c3wgieJfk199Lwxn1LE2ptUNFrH21QCXYA+nfvzrERKSA3qrOL+5naAQyDAVEwkilAd2AneCHd+8QGTGyFQs/EPznA0KW1JndTLli6CVCjngFle6VxCfSQtjNrXy+E3rorEf3juAcOARUp29r4Nwjw7yraejqUco7WxH73TcCx+pHaxtd8AL980H1FdHDbMZ/k0y8tSqy6ymqM8xchTGw/kmjh6kbzsCmBFJxKm6Qcxg; 4:/EnD4YPqUVXInYI7IFHzmy6xmsVvlTDjxWRyxIDHIPG7QaRGKAsofCN8iuyCn6Zv2kfZIcWvkey+ejNr5fIze75GZb9dywgRxlTjS4N4DqkoCylq2nWwkcChFqv56V49q5bPjBE5WKsiXqnfv5HjxXKayyuEgOko0tifZkHbV1YF9/p5wbFz8UtZpM99+XE/6ccXT6vLZdDX+DZJ75xdJaDhczQ2dIsaw4vtoJLGrGis+XuaRjh4o7pulh8ab135DQ1bK0zeZv1qG8jXyEccGHDNLKwHfFDPzbiXvxEiTJRR9iQ3EJnVrU82eM/YYdZ9nKRh9egpiKJ0hS11vrocGktntllTxoiQfvJkLTOw+b6E+Fsl9LceDJKHy0ldFPlkQeJMG7E5GxOwWXlyHO7U3NeA4p3SK4mRLvHsV/ YRD0k= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(85106069007906); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(601004)(2401047)(5005006)(8121501046)(3002001)(10201501046); SRVR:SIXPR06MB0921; BCL:0; PCL:0; RULEID:; SRVR:SIXPR06MB0921; X-Forefront-PRVS: 084080FC15 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10019020)(6009001)(6069001)(92566002)(50466002)(5003940100001)(19580395003)(19580405001)(47776003)(3470700001)(42382002)(50226001)(5001770100001)(48376002)(229853001)(87976001)(4326007)(230783001)(122386002)(5004730100002)(2906002)(575784001)(189998001)(76176999)(40100003)(107886002)(5001960100002)(78352003)(50986999)(36756003)(586003)(3846002)(77096005)(5008740100001)(76506005)(6116002)(1096002)(66066001)(33646002)(42186005)(4001430100002)(2950100001); DIR:OUT; SFP:1102; SCL:1; SRVR:SIXPR06MB0921; H:localhost; FPR:; SPF:None; MLV:sfv; LANG:en; X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; SIXPR06MB0921; 23:BN/I2RRwMqf5EYICMp2Y9RR/OYzvjne6orpbKKr+P?= =?us-ascii?Q?RmZIhjb+OP5ZirbOMLOXe6jEJbt3bASpj4e0speO2z7vR5JbSIyihjszWryU?= =?us-ascii?Q?mVL36W2BVTqJKi0paBY5V+Frdg0kVX5BM+R9Y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Og/VEo82UrreU56GjheVQFvuttN4+CSs8XKM1vUCHv0iP6Wm6ymaIg+B?= =?us-ascii?Q?CPWciqVvXQ/naq/HgAZM5WJVAS9AqTsp4Gtx6hhJLv/3s0yqLL2VwtCVVDlM?= =?us-ascii?Q?NEloNxQeoo=3D?= X-Microsoft-Exchange-Diagnostics: 1; SIXPR06MB0921; 5:n2XxjOI7T8fmxie1Q1XT2dTiRR9/pWKkIIxNAj76jv7Tfj3/K9p/QB572frLzZd14w+jKD8a4aEzGKNGwR4Hhp+AY88R0bX1eDzGGLjyAL6zG5RoNLu7mP03xiNI2EbkBRCXEVBr4oTwwg7CBp7ckA==; 24:HVhju9HKD3G65Oz12+1FaXz8t6UOPQ/g2Hn09USnmho+saC/ztVBqw8UJ+5oVIlc2P9G06aNNhkuZKkLG24e9YaiJb1bd/DW3HcKEebo2Dk=; 20:1whLCCwRdzzE9Xgg5G0RoHkbyGkJjXPPuF00q8GMUe4Q2R5qSrrYCv3XItKrAWQC93QYdAGvXEHI29E+Fv713G7qnfUDEuFve/Op38zkRhMA4njgomR3nlZ4EaWEuLmK4HwZKgDRD5QXPKknIgfvcTQ6rIysDIWBZkCiqiqXsdM= SpamDiagnosticOutput: 1:23 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: renesas.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Feb 2016 10:19:41.4990 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: SIXPR06MB0921 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=-7.3 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 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 e7e117d..6d0e625 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 2da2148..5ff5653 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 @@ -76,6 +77,7 @@ struct rcar_gen3_chan { void __iomem *base; + struct extcon_dev *extcon; struct phy *phy; bool has_otg; }; @@ -125,6 +127,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) @@ -132,6 +137,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) @@ -250,6 +258,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; @@ -275,11 +289,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); */