From patchwork Fri Mar 31 03:58:05 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yoshihiro Shimoda X-Patchwork-Id: 9655455 X-Patchwork-Delegate: geert@linux-m68k.org Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 79D6C601D2 for ; Fri, 31 Mar 2017 04:00:22 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 65403284C9 for ; Fri, 31 Mar 2017 04:00:22 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 59E4728681; Fri, 31 Mar 2017 04:00:22 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6057828678 for ; Fri, 31 Mar 2017 04:00:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750740AbdCaEAV (ORCPT ); Fri, 31 Mar 2017 00:00:21 -0400 Received: from relmlor4.renesas.com ([210.160.252.174]:61848 "EHLO relmlie3.idc.renesas.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1750727AbdCaEAU (ORCPT ); Fri, 31 Mar 2017 00:00:20 -0400 Received: from unknown (HELO relmlir4.idc.renesas.com) ([10.200.68.154]) by relmlie3.idc.renesas.com with ESMTP; 31 Mar 2017 13:00:17 +0900 Received: from relmlac3.idc.renesas.com (relmlac3.idc.renesas.com [10.200.69.23]) by relmlir4.idc.renesas.com (Postfix) with ESMTP id CECC863413; Fri, 31 Mar 2017 13:00:16 +0900 (JST) Received: by relmlac3.idc.renesas.com (Postfix, from userid 0) id ADE4E18070; Fri, 31 Mar 2017 13:00:16 +0900 (JST) Received: from relmlac3.idc.renesas.com (localhost [127.0.0.1]) by relmlac3.idc.renesas.com (Postfix) with ESMTP id A623A1806F; Fri, 31 Mar 2017 13:00:16 +0900 (JST) Received: from relmlii2.idc.renesas.com [10.200.68.66] by relmlac3.idc.renesas.com with ESMTP id PAJ09708; Fri, 31 Mar 2017 13:00:16 +0900 X-IronPort-AV: E=Sophos;i="5.36,250,1486393200"; d="scan'208";a="239173229" Received: from mail-pu1apc01lp0024.outbound.protection.outlook.com (HELO APC01-PU1-obe.outbound.protection.outlook.com) ([65.55.88.24]) by relmlii2.idc.renesas.com with ESMTP/TLS/AES256-SHA256; 31 Mar 2017 13:00:16 +0900 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=renesasgroup.onmicrosoft.com; s=selector1-renesas-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=VdlKSJsPtU21MXLIskFNaDDsuHJU2TAeGUVDmMfT2v8=; b=noaPQMsML5TlITBXhSQZF1eWjo0Ge6e9ffT83+gRId8/4Z/YfeKjoy7ExcxiQKG3p0Pt6Ko9Byk2VbpPonsEBMIUo70QYWjapy5FqoYKygL94A9vuuwVpqEedFTwDthoQ6N9Z2c6zjBtR4EzOdXYX3jrfu6ZHqlyXq2NoCQFR4E= Authentication-Results: kernel.org; dkim=none (message not signed) header.d=none; kernel.org; dmarc=none action=none header.from=renesas.com; Received: from localhost.localdomain (211.11.155.144) by HK2PR06MB1682.apcprd06.prod.outlook.com (10.167.73.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1005.10; Fri, 31 Mar 2017 04:00:14 +0000 From: Yoshihiro Shimoda To: CC: , , , Yoshihiro Shimoda Subject: [PATCH v4] usb: gadget: udc: renesas_usb3: add support for usb role swap Date: Fri, 31 Mar 2017 12:58:05 +0900 Message-ID: <1490932685-23115-1-git-send-email-yoshihiro.shimoda.uh@renesas.com> X-Mailer: git-send-email 1.9.1 MIME-Version: 1.0 X-Originating-IP: [211.11.155.144] X-ClientProxiedBy: OS1PR01CA0033.jpnprd01.prod.outlook.com (10.164.162.15) To HK2PR06MB1682.apcprd06.prod.outlook.com (10.167.73.8) X-MS-Office365-Filtering-Correlation-Id: e9bb23bc-0f76-49e7-918d-08d477ea6fc5 X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001)(48565401081)(201703131423075)(201703031133081); SRVR:HK2PR06MB1682; X-Microsoft-Exchange-Diagnostics: 1; HK2PR06MB1682; 3:rYcFeHXCUKfaR28su+ocBTGov8vC4rv3TioBn7hHilgF80Tt0/Fd+eKJL7t3ox4yqKKk/kgXTCbO081E4a+BBg8qPd8j0g+EBbEX6GH5c4cNx+zocEOBccP7iIjwCcOXO1Jh7sK5YcUZDY1AY5Eg//ckLTLOhDU+Ci27pbaCmzqiIXM6DklZTWqmo0W8pIxzwmBZ2CVU22vW2ybS+iwtc2ASJsamZcDQgR+59V2vTVBdQadTsxxQd0CZiUQagdvCNdDPFz3Vn8avCyCIFos/HNS53xOUrMyh1qTmOn3Rqj+yRIqoqIVMkLJ3MloQtsjSS81wB4FNosaYYLiMvYx1LUhgSmWcTWtgvcgWPsGkJS0=; 25:0/yGu1uKBgHtDMib3WOeex4kc9coxejLft38GMdhl6ZbvwVGIoLjCg9gwuwLtJn0ai2bKpJo6vkeIv5QuMAXlZrFg/DehCT6GkwFfKXy2Vi+lHoiF1wPhc45qYYaKr1cIXv+BA2nAgR/3UbFO6yRZ3HnPS0sgDLBgMQhdR4zkqpV3ITEj2ZNmmd67qpWqfqAEb3FtZwRdFSYTWaeKZx/O+suwVazaRIckW1zJuIjFN1ayNuGfYYcCY9U7EbgxZ/HQOhxMvKC/VngP3mNxSLFpc34UpAKiKjqDLLjnzEDQU+B3+Yw7wYwrMLzQCv6l3N8i8tLTGhm+0iAUEDURFJflL9B9axQoEabniKACZ8zPy/s4faNgN7dbTNte3XIUcO00C6HsdPFmF7IbKGbLYbQB0Riepy8Td3Yx+eh+ujNujlZgcjxyWat1rhQN4ABiP5EoMLH7s0CPkgmLUznEMPx1Q== X-Microsoft-Exchange-Diagnostics: 1; HK2PR06MB1682; 31:A2fgUAaXAf07+s0LTF3UFpYQg+5SD2/f1RRiNqEYFSMziHyA7Wpp/4qyMkyEjlMh9elar7yQK7Y9fivzXXX1LuqVTLkP3wkZOVbJIc54DJnbEruil/cQuTifzNYD8L9/7lquw2XyNNPO9y5Ce7oJ88913hpkEsEA7SRGQtC0mvX9KJ80PZdEO5DeZSoAOKpuSb5p7OvWWDybbSD9dvPfGJDsxysjASL2vbsjpVH+O5c=; 20:OHbhA6KaP9leJVlQIfRRgee3GxAiq9IGB+qjwihzWYFq7eOMFPlsVQjdiOEWkzPT8bek07DgX4EsPZiUuYCPVraLS/6i7ms73ePK3vqPx4TOwFHuzPJyfiLQLe7/MrNySR2CRls4gEqnZt7YUX1BfEIGDbg8zymrMpy6ljlNj+9JWK8y0SQir8iuP8Gr7w4Nyup+MNUFXEZmCEj8RDFHqKYj0nhn/v00wRfr1QzFb2E91dxGbSbSvBKqeo/lGvuQP8/F0T+Wvb5ZdRdNfq36yK62FswVD8prS3u5qJxMdEGVdA3TzWKxxgaMeI7w5Bh8GYaPmqhM8M9TYv2tA8+zypkzughews8AzomfevmYybOu4is8ihkwgmzPg0YpLjtd/9od/wrMFcnQ1GfY/Vq/tsNOiPU+l8VTsctukQEPEt5WVOmfC5IqRjCEgoWEQO6Inb8wXB2q15E58xVFltEPgAJfkrzAa1DoEYBckD5m9/DFiF2MyEjDN9RN+e9nHrrd X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(21532816269658); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040450)(601004)(2401047)(5005006)(8121501046)(93006086)(10201501046)(3002001)(6055026)(6041248)(20161123560025)(20161123562025)(20161123564025)(201703131423075)(201702281528075)(201703061421075)(20161123555025)(6072148); SRVR:HK2PR06MB1682; BCL:0; PCL:0; RULEID:; SRVR:HK2PR06MB1682; X-Microsoft-Exchange-Diagnostics: 1; HK2PR06MB1682; 4:i/UblnkaegE65o2gkXwRWjt76PBSu/mS78jK806LwmSYgNeWEgh4GaY9ScaPY/bx5pXMg9/NzDEoBcodEQrowJ2sTLbdrxmDY/FSWK7vho6GZRkBbctkqu7nYS36pvXhOvnTDP+RzAbuWCXRf9CNTZwY1qPJkHcBS0NRwBfnnWapDqRiuDwfhvYy1cjLrCBRlgTHNAR4vhqUOa/rYc7Q12/e6WYLAcmlE7DLo9UkMr1Dm6kZOyJRrI6YiT+4I7HxWlOp/UEHQsFhdLnOX9rtpH796v5ENbPiEn7oVzqAqQHI1SfCFvRXcqKvKtgrmeuYtojqPpLxX0UNzpzkY/vkmlaCmQO4M/TlUF/pdZpng6YWfMDRT89GHP8BFhNRMNpmfyreyY2faRW3YsuZm+v5udyLqVzU7lG8ZgCXA73MdbVRASn2qvufZvElZgAEzm6YztwuMrWzKs5oEydrR75v8efnZdZuasRwb5rBDfC9SOr9dWWXJXQvQ5atYJdK4q2rDIcLq8I3GmQBavFFLJlQrLWLci4atHkTQGW+0XUyZD8KypxLLZrhsyoFRHZxwMdWFN1c1oiTOS1Saf7hLPqmNPge5HEmj/sIzOa0jdtXoQPDoqQ9LFaNjWxNeJy+7+rw0iD/Oa58KdECVuEuu70XLogdM7p5FHRxbtmiJF/qwFtnNegmzyOtKtTxleIcBHTHMwvduRASHSM/YNsam7hb474tI4oQIgHJR3IP2iNVOSWZPoDUEXeMgpkyEx6GT7ph X-Forefront-PRVS: 02638D901B X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10019020)(4630300001)(6009001)(6069001)(39410400002)(39400400002)(39860400002)(39840400002)(39450400003)(39850400002)(50944005)(107886003)(50226002)(66066001)(47776003)(33646002)(36756003)(8676002)(38730400002)(42882006)(6916009)(6116002)(6666003)(2906002)(48376002)(54906002)(50466002)(110136004)(25786009)(4326008)(6486002)(7736002)(305945005)(6512007)(5660300001)(2351001)(6506006)(42186005)(3846002)(189998001)(53936002)(78352004)(5003940100001)(50986999)(81166006); DIR:OUT; SFP:1102; SCL:1; SRVR:HK2PR06MB1682; H:localhost.localdomain; FPR:; SPF:None; MLV:ovrnspm; PTR:InfoNoRecords; LANG:en; X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; HK2PR06MB1682; 23:nSLqR9PWcxax2YkxIQCO90LJ+lFRkmbUHTg2Oq/cm?= =?us-ascii?Q?FSB+3lAOLUDl0fvnJYspv1yRQLWMILx+9Upa1G2AgaT0/K/aZdaSmxOwp5u0?= =?us-ascii?Q?s/orx28Gvs5aNehAwdoOLkA9buhgRx2UWQ7fhzCMrCvwdA5gRoWgLwPjSNeG?= =?us-ascii?Q?kuHArnPglaK4/xFcGDe770WM9LHhF+vJHwujBVrAeb68foLALkG+n1hVHkFC?= =?us-ascii?Q?2WkSOQlziMpcRdD9MftQacj8av57regr6Y6kmOu5gF2b5NfLDO340Ldc6iYN?= =?us-ascii?Q?uaHW9fN6rO0n4JnD6lSfHgSbPPiBhdneQVUvhzDZHFZYzdxSJV5xEkwvERys?= =?us-ascii?Q?/VSxAho5G2L9/LhouLSqp2JDWaIqLl2Kpg2yOBrwskbU8XU4z4fx1/Iq8X4c?= =?us-ascii?Q?YOk8Y8n2LlNd3LCLXkjBxYUsAteAtnOffhBYYuTfiFlBbv5x2uSOo0JG2tQN?= =?us-ascii?Q?nXRoYVPqzsuWlXFZXMUqXjeOBvBrD7JW5Qf7lpYHdtryGoTq9+NWEtANuYXH?= =?us-ascii?Q?TengcbsBo6kIHyknBwFgAyySoflHMzV+xQ6YEOKs6ZilBAL6cmcmY1xTUw7s?= =?us-ascii?Q?zZGOc+KGg/k7lTyvHkWD9EJ2LDtond1WewtuJa6zLbbgS5AqG5WYzT3YHpAO?= =?us-ascii?Q?hAol0VddiC8uOvDhuJGgxPKrFj8cDGB7gPYaT6NFWCRj0swFNkCkcvJYFfGE?= =?us-ascii?Q?GZRsWThZg78h/GRqVIGvAE8kd6tW0QaSCF56bN+n1vXvPsplnuCfty+uyQPF?= =?us-ascii?Q?kSEx6nmybKkZPOdnRQRC3zyOLzH17LPoyJdtBJfeV4EqV8mAOGCnGbT4Md2j?= =?us-ascii?Q?ZMz2y1O4CslnSXmvcAL59bcALjbCg18kU4BdIL2Cabxu6BmhgAh+OZ+uLSdK?= =?us-ascii?Q?zEfwnHS5+npekvpCPCGf30hAqhqw0YtwA1blTWkDyLbc4AoM0baZuYfFXDAZ?= =?us-ascii?Q?yDb+alYWrMXYASZ2H9U5+a7FxWpSHHb32USlnmkhmR47GYefY/S4hm5LLc2Z?= =?us-ascii?Q?RAoFRfB2n6mXrWx6rKc2Rg4to2Tggv/fTVEuZd6nDVQnCyg0WypSBG82Aj7l?= =?us-ascii?Q?YXVTRobkD6k5vk1Mf7Xvo37A0sa7CaNC7b0zAB7kyT8AANL+fLjscLkyr4PA?= =?us-ascii?Q?5mcbyVs8pc=3D?= X-Microsoft-Exchange-Diagnostics: 1; HK2PR06MB1682; 6:B6qc/gNzlgBux9f1tzDbKgy5gzf605qr3NZK/PU07XoTs+M7/aBaTJAErwhhvv/JYrJezlNSmVjzbmBPPTH8vWbeZxJzEu1W+kC9rC67rBTr/Hz0+wlTCs4FSWNsSIyKdRbdJ+wBewpDA1wbtHDe7jbAC7hPoORIYe4n9TNjTMsuzM9oikxwlaxJTaaaCMvpncpFbABwfhVAc3y/nWIBvFOtSwuS0JWdaq3dXcNNNCUSBNi/8MX8gHOG+P1eFMlz/q5sW1QeqZ/mU39PttKp1L2Ly4lgGW+QDGOhUUuJJu9eHGNB1IWsdhDWGuNyghbX638qyl0GogrP/q1iwP8L3/pOFUXwi5t3yal0HnctsDLRPiwPAUYHzkfEotyaQDoR6+XD5nScHMwjJOnSiTZLuo+0wwt6UhABs9El+mQsohA=; 5:d8skfZFK6OEd2N6FxOaK6yhhCXOe6DdA9AZcKGYcUVF+F8Hk+qIbAe39HpeP0ZIjc2pSWBqEEXdRz9bZ4K5bZz2U6107pfaaNGMma7Sp7vAnS9ZJhuAl8kwQmzejl869y0mDpW8cJn8TpTliNCat4TKbsVO4mpIjPgE7QrAlhrs=; 24:RWKgEHHHN3RoveragR67eeEPzqUztLqr86P6jfGjj2hTjtn4ogBGkwX6pP4D7S2U7CubjeyuKbv3xv2cb/9NPRmWHbDzikhheJWlGqOTzDo= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; HK2PR06MB1682; 7:7Px3XP3PaW/NeUr5VClHp4vM9481x53fiw25f0kn4cY1jr5oVI4itYoCpvUCXBKBdGdUvsmZLJAVP5mkr0WsEiMizUzUIT6/G1pJamEMzcnyJxM+qkXTgXytXB0NkKgN8sH4fSxeNOw//jSSM7/4dFliwtt9zPcCbjjoLArE5/S+2qbui2RU7N2Ufybo1JA4XNGw20V7KYzAUGE26tf0QvXN9TVaT7ExGFp+S47hDjKgXJahGq5dtBEcDrTrCpnj1YjKtTHC5QgLnE9Ob8J+h1GmaHNqmEwfSygs7GRtovHfg1znz4hY5ieOpQ52iuyUkfEmcdPKSGjHPIao2jeGGQ==; 20:u+Um4BQ19JJd/+6drT7Mj3Xz11TcD+zanSVXid/v2y5lFyx/NtVExWfpyaiOD3aW9xTNxO+rEQAusN7bpWlhvVelmT54AnuJdVj7ngtJX2FgrwJGRmInsDuioVLKFEsMaJNgu1PDCJJG4bItijq4ZTjzZ0q4TJjA51WkmddPc1E= X-OriginatorOrg: renesas.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 31 Mar 2017 04:00:14.2041 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: HK2PR06MB1682 Sender: linux-renesas-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-renesas-soc@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This patch adds support for usb role swap via sysfs "role". For example: 1) Connect a usb cable using 2 Salvator-X boards. - For A-Device, the cable is connected to CN11 (USB3.0 ch0). - For B-Device, the cable is connected to CN9 (USB2.0 ch0). 2) On A-Device, you input the following command: # echo peripheral > /sys/devices/platform/soc/ee020000.usb/role 3) On B-Device, you input the following command: # echo host > /sys/devices/platform/soc/ee080200.usb-phy/role Then, the A-Device acts as a peripheral and the B-Device acts as a host. Please note that A-Device must input the following command if you want the board to act as a host again. # echo host > /sys/devices/platform/soc/ee020000.usb/role Signed-off-by: Yoshihiro Shimoda --- Changes from v3: - Revise the doc about "What" from "" to "". - Rebase the latest Felipe's usb.git / testing/next branch. .../ABI/testing/sysfs-platform-renesas_usb3 | 15 ++++++ drivers/usb/gadget/udc/renesas_usb3.c | 56 ++++++++++++++++++++++ 2 files changed, 71 insertions(+) create mode 100644 Documentation/ABI/testing/sysfs-platform-renesas_usb3 diff --git a/Documentation/ABI/testing/sysfs-platform-renesas_usb3 b/Documentation/ABI/testing/sysfs-platform-renesas_usb3 new file mode 100644 index 0000000..5621c15 --- /dev/null +++ b/Documentation/ABI/testing/sysfs-platform-renesas_usb3 @@ -0,0 +1,15 @@ +What: /sys/devices/platform//role +Date: March 2017 +KernelVersion: 4.13 +Contact: Yoshihiro Shimoda +Description: + This file can be read and write. + The file can show/change the drd mode of usb. + + Write the following string to change the mode: + "host" - switching mode from peripheral to host. + "peripheral" - switching mode from host to peripheral. + + Read the file, then it shows the following strings: + "host" - The mode is host now. + "peripheral" - The mode is peripheral now. diff --git a/drivers/usb/gadget/udc/renesas_usb3.c b/drivers/usb/gadget/udc/renesas_usb3.c index a1e79fc..5a2d845 100644 --- a/drivers/usb/gadget/udc/renesas_usb3.c +++ b/drivers/usb/gadget/udc/renesas_usb3.c @@ -372,6 +372,11 @@ static void usb3_disable_pipe_irq(struct renesas_usb3 *usb3, int num) usb3_clear_bit(usb3, USB_INT_2_PIPE(num), USB3_USB_INT_ENA_2); } +static bool usb3_is_host(struct renesas_usb3 *usb3) +{ + return !(usb3_read(usb3, USB3_DRD_CON) & DRD_CON_PERI_CON); +} + static void usb3_init_axi_bridge(struct renesas_usb3 *usb3) { /* Set AXI_INT */ @@ -576,8 +581,14 @@ static void usb3_vbus_out(struct renesas_usb3 *usb3, bool enable) static void usb3_mode_config(struct renesas_usb3 *usb3, bool host, bool a_dev) { + unsigned long flags; + + spin_lock_irqsave(&usb3->lock, flags); usb3_set_mode(usb3, host); usb3_vbus_out(usb3, a_dev); + if (!host && a_dev) /* for A-Peripheral */ + usb3_connect(usb3); + spin_unlock_irqrestore(&usb3->lock, flags); } static bool usb3_is_a_device(struct renesas_usb3 *usb3) @@ -1837,11 +1848,49 @@ static int renesas_usb3_set_selfpowered(struct usb_gadget *gadget, int is_self) .set_selfpowered = renesas_usb3_set_selfpowered, }; +static ssize_t role_store(struct device *dev, struct device_attribute *attr, + const char *buf, size_t count) +{ + struct renesas_usb3 *usb3 = dev_get_drvdata(dev); + bool new_mode_is_host; + + if (!usb3->driver) + return -ENODEV; + + if (!strncmp(buf, "host", strlen("host"))) + new_mode_is_host = true; + else if (!strncmp(buf, "peripheral", strlen("peripheral"))) + new_mode_is_host = false; + else + return -EINVAL; + + if (new_mode_is_host == usb3_is_host(usb3)) + return -EINVAL; + + usb3_mode_config(usb3, new_mode_is_host, usb3_is_a_device(usb3)); + + return count; +} + +static ssize_t role_show(struct device *dev, struct device_attribute *attr, + char *buf) +{ + struct renesas_usb3 *usb3 = dev_get_drvdata(dev); + + if (!usb3->driver) + return -ENODEV; + + return sprintf(buf, "%s\n", usb3_is_host(usb3) ? "host" : "peripheral"); +} +static DEVICE_ATTR_RW(role); + /*------- platform_driver ------------------------------------------------*/ static int renesas_usb3_remove(struct platform_device *pdev) { struct renesas_usb3 *usb3 = platform_get_drvdata(pdev); + device_remove_file(&pdev->dev, &dev_attr_role); + pm_runtime_put(&pdev->dev); pm_runtime_disable(&pdev->dev); @@ -2044,6 +2093,10 @@ static int renesas_usb3_probe(struct platform_device *pdev) if (ret < 0) goto err_add_udc; + ret = device_create_file(&pdev->dev, &dev_attr_role); + if (ret < 0) + goto err_dev_create; + usb3->workaround_for_vbus = priv->workaround_for_vbus; pm_runtime_enable(&pdev->dev); @@ -2053,6 +2106,9 @@ static int renesas_usb3_probe(struct platform_device *pdev) return 0; +err_dev_create: + usb_del_gadget_udc(&usb3->gadget); + err_add_udc: __renesas_usb3_ep_free_request(usb3->ep0_req);