From patchwork Sun Nov 18 10:09:11 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pawel Laszczak X-Patchwork-Id: 10687717 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 94725109C for ; Sun, 18 Nov 2018 10:11:52 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7B41829D31 for ; Sun, 18 Nov 2018 10:11:52 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 695D829D3E; Sun, 18 Nov 2018 10:11:52 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,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 A075129D31 for ; Sun, 18 Nov 2018 10:11:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727382AbeKRUbA (ORCPT ); Sun, 18 Nov 2018 15:31:00 -0500 Received: from mx0b-0014ca01.pphosted.com ([208.86.201.193]:41278 "EHLO mx0a-0014ca01.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727330AbeKRUbA (ORCPT ); Sun, 18 Nov 2018 15:31:00 -0500 Received: from pps.filterd (m0042333.ppops.net [127.0.0.1]) by mx0b-0014ca01.pphosted.com (8.16.0.27/8.16.0.27) with SMTP id wAIA8fNS007685; Sun, 18 Nov 2018 02:10:52 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cadence.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-type; s=proofpoint; bh=rLIi4STjcy2dAVqkHNE3xAx2tlETUrDL/Z3vZN4VWck=; b=pfvMduyExmqv9Q7II32+TaEtaQDfOXLYUuWeyfLgi63n6FBBe0wNou7JQkYiUp0ocA8V 5cGE6LhH1V/pKPlmoIWi/6zWgqdUAoKzh14Xw4g9OnaYXUL/a9i8AmPl6O1tlnb8U70h lPsANa0wvKG1Dhe6i5Q2J5pu6RJFyp1h0QoOa+btz1vOt30rpxHx2gsOdvD8Srs2bpXh LXjseyN23y45eYb43rBPNnICITs0l5dOl83AemRiZD1iBteG09R//SchQnftY5mxZsfg Fka2ReZqNEXug2VpAvvKUW2iPOZsu+Ai5hoE+Ys2mC5khMgFBYDLAcQXCzk6ekQqrMs6 AA== Authentication-Results: cadence.com; spf=pass smtp.mailfrom=pawell@cadence.com Received: from nam01-sn1-obe.outbound.protection.outlook.com (mail-sn1nam01lp0111.outbound.protection.outlook.com [207.46.163.111]) by mx0b-0014ca01.pphosted.com with ESMTP id 2ntff7w455-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Sun, 18 Nov 2018 02:10:52 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cadence.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=rLIi4STjcy2dAVqkHNE3xAx2tlETUrDL/Z3vZN4VWck=; b=lxVqWZ37wC5CtcS9a2qxce4ayrXWgNcd7zNtbMhTJGNQqqg8bQDZAspVY3NuwfL/YvEwxWTd/5qUPxKfcBpipme6F5JoVT8SRMdL/pLgPNUR0kmQD2cka2E/vdVvDhSTvyKc+3RAFeyFsJyZcOa0j9RQb3gGsHlMwMAp0CHb0hE= Received: from CY1PR07CA0009.namprd07.prod.outlook.com (2a01:111:e400:c60a::19) by MW2PR07MB4107.namprd07.prod.outlook.com (2603:10b6:907:7::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1294.26; Sun, 18 Nov 2018 10:10:49 +0000 Received: from DM3NAM05FT059.eop-nam05.prod.protection.outlook.com (2a01:111:f400:7e51::209) by CY1PR07CA0009.outlook.office365.com (2a01:111:e400:c60a::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1339.21 via Frontend Transport; Sun, 18 Nov 2018 10:10:48 +0000 Received-SPF: SoftFail (protection.outlook.com: domain of transitioning cadence.com discourages use of 158.140.1.28 as permitted sender) Received: from sjmaillnx2.cadence.com (158.140.1.28) by DM3NAM05FT059.mail.protection.outlook.com (10.152.98.176) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1339.3 via Frontend Transport; Sun, 18 Nov 2018 10:10:47 +0000 Received: from maileu3.global.cadence.com (maileu3.cadence.com [10.160.88.99]) by sjmaillnx2.cadence.com (8.14.4/8.14.4) with ESMTP id wAIAAb5X029622 (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=FAIL); Sun, 18 Nov 2018 02:10:47 -0800 X-CrossPremisesHeadersFilteredBySendConnector: maileu3.global.cadence.com Received: from maileu3.global.cadence.com (10.160.88.99) by maileu3.global.cadence.com (10.160.88.99) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Sun, 18 Nov 2018 11:10:45 +0100 Received: from lvlogina.cadence.com (10.165.176.102) by maileu3.global.cadence.com (10.160.88.99) with Microsoft SMTP Server id 15.0.1367.3 via Frontend Transport; Sun, 18 Nov 2018 11:10:45 +0100 Received: from lvlogina.cadence.com (localhost.localdomain [127.0.0.1]) by lvlogina.cadence.com (8.14.4/8.14.4) with ESMTP id wAIAAfHb032620; Sun, 18 Nov 2018 10:10:41 GMT Received: (from pawell@localhost) by lvlogina.cadence.com (8.14.4/8.14.4/Submit) id wAIAAfWN032542; Sun, 18 Nov 2018 10:10:41 GMT From: Pawel Laszczak To: CC: , , , , , , , , , , , , "Pawel Laszczak" Subject: [RFC PATCH v2 15/15] usb:cdns3: Feature for changing role Date: Sun, 18 Nov 2018 10:09:11 +0000 Message-ID: <1542535751-16079-16-git-send-email-pawell@cadence.com> X-Mailer: git-send-email 1.7.11.2 In-Reply-To: <1542535751-16079-1-git-send-email-pawell@cadence.com> References: <1542535751-16079-1-git-send-email-pawell@cadence.com> MIME-Version: 1.0 X-OrganizationHeadersPreserved: maileu3.global.cadence.com X-EOPAttributedMessage: 0 X-Forefront-Antispam-Report: CIP:158.140.1.28;IPV:CAL;SCL:-1;CTRY:US;EFV:NLI;SFV:NSPM;SFS:(10009020)(396003)(39860400002)(136003)(346002)(376002)(2980300002)(189003)(199004)(36092001)(8676002)(8936002)(86362001)(107886003)(6916009)(105596002)(26826003)(14444005)(11346002)(476003)(446003)(426003)(42186006)(316002)(106466001)(486006)(126002)(217873002)(4720700003)(2616005)(246002)(51416003)(336012)(16586007)(5660300001)(54906003)(7636002)(186003)(50226002)(36756003)(26005)(47776003)(87636003)(76176011)(478600001)(4326008)(48376002)(2906002)(6666004)(356004)(50466002)(2351001)(305945005);DIR:OUT;SFP:1101;SCL:1;SRVR:MW2PR07MB4107;H:sjmaillnx2.cadence.com;FPR:;SPF:SoftFail;LANG:en;PTR:corp.cadence.com;MX:1;A:1; X-Microsoft-Exchange-Diagnostics: 1;DM3NAM05FT059;1:LYaV5q0GwMfd9dpYeD2DNcnJVDMPoFWAVSAugzx4iPljT4VUm+oHdczUfOcFqgQCbmNtgICnJlr1uBx4yPFWooZkHXOpupbdgEMaVkavEKp6tTx2AStIz9K7139X1+sn X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 6442047b-6bfe-458b-5e21-08d64d3e1cbe X-Microsoft-Antispam: BCL:0;PCL:0;RULEID:(2390098)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600074)(711020)(2017052603328)(7153060);SRVR:MW2PR07MB4107; X-Microsoft-Exchange-Diagnostics: 1;MW2PR07MB4107;3:iyx/npAYnBYh9C/iqWDGTHqWqFxEnar8cVe0WSbmC7FYAyXVxfa7d73XBc1zqguSbeQmnAfkCT+5cMP/XVnW2lwSmkpwwNxWE38QRT4WmUcP/ppYmFZxANZhFSFmjC2KDpTkMp1N18g7DeobNttML4ZsrlGDe2sDT+y8CVMqF5ueShF52V0o7EzC+Ff50aNj3HpcaYQNhasaNwEFyn0b/dGPBRrWqtGjPvATuB2XAMcFBNZt6fZ3u9U1Ndb8pw1FdMBL03Du2cQtCeWqLietgBQxAqsagt7l31vUKqHL6IbDGgk6BunvmYy9lTryTdhKC3gTnRD8OPvEVIHyV9qvFT0E6syhwdpAmaEoKaSIf+E=;25:rRidzHGVuJiqs0Efkjf2A7Ro17eGCKVcmj3zpdoJqt7s+IN0iaZjXa1l9SLs3TsYo+8P+RS2k3zMT35nnZJAh3fIArhP+4z0uHtO3WYf4BtYiDUf2/DluFjD4yzejMHSiE67TpB9uBR5T9d9TGQG9TMbRXW0GyBD2LKYVkTrO8rW5m40K2PAwn/Htw9TRgdZGE/+3A2reCplcyOmfrEkpaXWDhL0/AGYRK7LDFCf4vXfTMlrNdRldNHT3qbXGJLK8ShryDCwV/yYyfoT1fVGVRT+ZLm0qNP21FmPxr7dESj76qJ2incYeX3OUViL98xwbD/84cI9NO0087t+5nIytzt7r0ZanL9Ni7GYsyz7Tu0= X-MS-TrafficTypeDiagnostic: MW2PR07MB4107: X-Microsoft-Exchange-Diagnostics: 1;MW2PR07MB4107;31:Guip2tXq240e3/ZoqiMrSkbCmnUNuIc21Ry7FlL95BQuE3wWNjKdxlp2K486YYTtrNiEkQYulJ2XZ+5AyJpFo78/mHBxWsIXNYIh+nDI/me9OYjIYvQGxR/c4ukO6q7rZsl354MF1TIP70RISZp5MuCH49AWNFZkI8Vat79OEovmAr84P3RajQitGxHdltA931s/W/G73lsw3O2XJ0yPsiYI1POfKURXBlgymRHFV7s=;20:v5+4Ja++1WKSu47QLpznQ8WL/MWotVIJsWHjtVLIqAv6oCLtN7pi6Q0pd33a7WG/9WJPYCARuBovXNkYf48DmAd4KsOJOT4l2wiXJgIlJW8gmNyd4Vj2zpDu9xVnnYAWgHJiksaQnoS0Y67la6TGe9Q7AYKYfBQMAJYiVEQeJeWzaLlbEeWM5GOVV4anpMOhbmMiCcDULcUYP6A68h/id3gsmtj8c1CjWqNlVoTdACvP/nYnUWLAEurOR5PcoaWBSUkCXEkZRTdOT+0LCmaywQvOAMxYXjYUEDYYeVjl2IwyDsLw+6IKePp+3DYGJFFJxIFR3/5trHcjYlUImYdVfdvzrEoM/4DK+f6QHU5TmzfA92byPw1+3Co+iXm7ligUACSInO5oaHkGVuEQXfqubDP+U6/5gHksKUDwNdMbkrOymvbK8Bda4QQdINhMje8+sYpvTd/9ZDlx3fXhuNBMEPnzIg7KrFZWrQBgQY9qIM8mIZ50DFe3dzSCt8DMv+F7 X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(72806322054110); X-MS-Exchange-SenderADCheck: 1 X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(8211001083)(6040522)(2401047)(5005006)(8121501046)(3231415)(944501410)(52105112)(3002001)(10201501046)(93006095)(93003095)(148016)(149066)(150057)(6041310)(20161123558120)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123560045)(20161123564045)(20161123562045)(201708071742011)(7699051)(76991095);SRVR:MW2PR07MB4107;BCL:0;PCL:0;RULEID:;SRVR:MW2PR07MB4107; X-Microsoft-Exchange-Diagnostics: 1;MW2PR07MB4107;4:DHlhKz1wdJxieYKA4zBX/J5ihod5c36yQtuzyiXtfXsejlCGqiRQL6uFcbMrmklx4/nZJ5sDGr07pO/LhA0ts4liT2XkQiEdXSRnnqTABILl82Vmd6FESbl/0bZR2hn5Q8/Dkp2vy50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3Ptw4Lo6PYovdizkyzo8dTpnZ8XVHvcUJWalnq6OeeKF+WO02MZ4zgcvzPymJmX9dhVwDgcIhQz/fC1x4mUY5Qw1ls4KInqguzBVkkKMfVAQ/+w==;5:lVWvV1lH1hJRrvDKvEmAnC9k8Bw7KYABc2ZEfBBTQ4zySAb9jXwzlVQQMQ9OXO+mPWPYo5v+jMbmyeN1dcSlY+pNgu7WnWhrlT7H1Z9FuzcRdQv2tI2puyAra04M4lPnbqQcERdt+zPtt9K6Wu9w2vYqjxTsbZmxDWiwlk9kqhw=;7:JtmhUy4r1kzGJQdgD5y15iiKQy18C96kRea3a6+t1DHW3SAgk4Iqbx9qF/lpgUJ/3sJ31Ec9sF/ajkJJJ7EBr45/iWKQujkHe1s4+NK4yKvWLMsE6CqNOcmUzLUQSjKFnH0b4o3/w6UaMQHsOEtbhg== SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1;MW2PR07MB4107;20:fT1mt9SXxwKtjqQ/W8OigCGWGcyEkqfy4D/z7GBfpwbjK8o6P3G4TnsYJpuIPUTve4i1r47k9nAoBNDKypbHJUgWDspXAxtTXYvHmhWswDcw5Y9jr2yN1TmrMcBiUzyGPL5i4jC6HZ+f/z/V2wXVS81UBGLDTObg5hqt4OHE4OIn2q2K7aef1kAtoSeJ+Oap8+1I4/Z1ZfIWll2R3JMa8w5hvRWlstrga1lBgbtmW8QUx7astLCeruDO4iEeFWcO X-OriginatorOrg: cadence.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Nov 2018 10:10:47.9584 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 6442047b-6bfe-458b-5e21-08d64d3e1cbe X-MS-Exchange-CrossTenant-Id: d36035c5-6ce6-4662-a3dc-e762e61ae4c9 X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=d36035c5-6ce6-4662-a3dc-e762e61ae4c9;Ip=[158.140.1.28];Helo=[sjmaillnx2.cadence.com] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW2PR07MB4107 X-Proofpoint-SPF-Result: pass X-Proofpoint-SPF-Record: v=spf1 a:mx-sanjose2.Cadence.COM a:mx-sanjose4.Cadence.COM a:mx-sanjose5.Cadence.COM include:mktomail.com include:spf-0014ca01.pphosted.com include:spf.protection.outlook.com include:auth.msgapp.com include:spf.mandrillapp.com ~all X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2018-11-18_03:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_check_notspam policy=outbound_check score=0 priorityscore=1501 malwarescore=0 suspectscore=1 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=840 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1811180097 Sender: linux-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Patch adds feature that allow to change role from user space. Signed-off-by: Pawel Laszczak --- drivers/usb/cdns3/Makefile | 2 +- drivers/usb/cdns3/core.c | 2 + drivers/usb/cdns3/debugfs.c | 93 +++++++++++++++++++++++++++++++++++++ drivers/usb/cdns3/drd.h | 3 ++ 4 files changed, 99 insertions(+), 1 deletion(-) create mode 100644 drivers/usb/cdns3/debugfs.c diff --git a/drivers/usb/cdns3/Makefile b/drivers/usb/cdns3/Makefile index 34e60d03c4ec..08e6cdbebd46 100644 --- a/drivers/usb/cdns3/Makefile +++ b/drivers/usb/cdns3/Makefile @@ -1,7 +1,7 @@ obj-$(CONFIG_USB_CDNS3) += cdns3.o obj-$(CONFIG_USB_CDNS3_PCI_WRAP) += cdns3-pci.o -cdns3-y := core.o drd.o +cdns3-y := core.o drd.o debugfs.o cdns3-$(CONFIG_USB_CDNS3_GADGET) += gadget.o ep0.o debug.o cdns3-$(CONFIG_USB_CDNS3_HOST) += host.o cdns3-pci-y := cdns3-pci-wrap.o diff --git a/drivers/usb/cdns3/core.c b/drivers/usb/cdns3/core.c index 1fa233415901..304323b643f2 100644 --- a/drivers/usb/cdns3/core.c +++ b/drivers/usb/cdns3/core.c @@ -323,6 +323,7 @@ static int cdns3_probe(struct platform_device *pdev) goto err2; } + cdns3_debugfs_init(cdns); device_set_wakeup_capable(dev, true); pm_runtime_set_active(dev); pm_runtime_enable(dev); @@ -358,6 +359,7 @@ static int cdns3_remove(struct platform_device *pdev) pm_runtime_get_sync(&pdev->dev); pm_runtime_disable(&pdev->dev); pm_runtime_put_noidle(&pdev->dev); + cdns3_debugfs_exit(cdns); cdns3_remove_roles(cdns); return 0; diff --git a/drivers/usb/cdns3/debugfs.c b/drivers/usb/cdns3/debugfs.c new file mode 100644 index 000000000000..189b12d96cbf --- /dev/null +++ b/drivers/usb/cdns3/debugfs.c @@ -0,0 +1,93 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Cadence USBSS DRD Controller DebugFS filer. + * + * Copyright (C) 2018 Cadence. + * + * Author: Pawel Laszczak + */ + +#include +#include +#include +#include + +#include "core.h" +#include "gadget.h" + +static int cdns3_mode_show(struct seq_file *s, void *unused) +{ + struct cdns3 *cdns = s->private; + + switch (cdns->current_dr_mode) { + case USB_DR_MODE_HOST: + seq_puts(s, "host\n"); + break; + case USB_DR_MODE_PERIPHERAL: + seq_puts(s, "device\n"); + break; + case USB_DR_MODE_OTG: + seq_puts(s, "otg\n"); + break; + default: + seq_puts(s, "UNKNOWN mode\n"); + } + + return 0; +} + +static int cdns3_mode_open(struct inode *inode, struct file *file) +{ + return single_open(file, cdns3_mode_show, inode->i_private); +} + +static ssize_t cdns3_mode_write(struct file *file, + const char __user *ubuf, + size_t count, loff_t *ppos) +{ + struct seq_file *s = file->private_data; + struct cdns3 *cdns = s->private; + u32 mode = 0; + char buf[32]; + + if (copy_from_user(&buf, ubuf, min_t(size_t, sizeof(buf) - 1, count))) + return -EFAULT; + + if (!strncmp(buf, "host", 4)) + mode = USB_DR_MODE_HOST; + + if (!strncmp(buf, "device", 6)) + mode = USB_DR_MODE_PERIPHERAL; + + if (!strncmp(buf, "otg", 3)) + mode = USB_DR_MODE_OTG; + + cdns->desired_dr_mode = mode; + queue_work(system_freezable_wq, &cdns->role_switch_wq); + return count; +} + +static const struct file_operations cdns3_mode_fops = { + .open = cdns3_mode_open, + .write = cdns3_mode_write, + .read = seq_read, + .llseek = seq_lseek, + .release = single_release, +}; + +void cdns3_debugfs_init(struct cdns3 *cdns) +{ + struct dentry *root; + + root = debugfs_create_dir(dev_name(cdns->dev), NULL); + cdns->root = root; + if (IS_ENABLED(CONFIG_USB_CDNS3_GADGET) && + IS_ENABLED(CONFIG_USB_CDNS3_HOST)) + debugfs_create_file("mode", 0644, root, cdns, + &cdns3_mode_fops); +} + +void cdns3_debugfs_exit(struct cdns3 *cdns) +{ + debugfs_remove_recursive(cdns->root); +} diff --git a/drivers/usb/cdns3/drd.h b/drivers/usb/cdns3/drd.h index 0faa7520ecac..8367032e12a3 100644 --- a/drivers/usb/cdns3/drd.h +++ b/drivers/usb/cdns3/drd.h @@ -119,4 +119,7 @@ int cdns3_drd_init(struct cdns3 *cdns); int cdns3_drd_update_mode(struct cdns3 *cdns); irqreturn_t cdns3_drd_irq(struct cdns3 *cdns); +void cdns3_debugfs_init(struct cdns3 *cdns); +void cdns3_debugfs_exit(struct cdns3 *cdns); + #endif /* __LINUX_CDNS3_DRD */