From patchwork Sun Nov 18 10:09:07 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pawel Laszczak X-Patchwork-Id: 10687727 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 F0F4513BB for ; Sun, 18 Nov 2018 10:12:26 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E09CC29D38 for ; Sun, 18 Nov 2018 10:12:26 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D3F5E29D47; Sun, 18 Nov 2018 10:12:26 +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 DCD1129D38 for ; Sun, 18 Nov 2018 10:12:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727189AbeKRUay (ORCPT ); Sun, 18 Nov 2018 15:30:54 -0500 Received: from mx0a-0014ca01.pphosted.com ([208.84.65.235]:36320 "EHLO mx0a-0014ca01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726077AbeKRUax (ORCPT ); Sun, 18 Nov 2018 15:30:53 -0500 Received: from pps.filterd (m0042385.ppops.net [127.0.0.1]) by mx0a-0014ca01.pphosted.com (8.16.0.27/8.16.0.27) with SMTP id wAIA6XnW016036; Sun, 18 Nov 2018 02:10:50 -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=GmCP/vlRhYQlwtTkQNa6rLxmtTQ5sIucxHWwCjFi8D4=; b=P8pK2GtxJ3WMf0DRypQ7CPoT7gacDPlBjXbA1bRZXfGxk34yaJIvP+zmBYfdbOlkgUPB VYK/4ivLKIod0An5xj4o0Xu+yjUHJJayzIjejS4YuahwY5kTv9yKwue+Yhnc/8DPRehT MfMsKlImix0pSzdFS0S5PzX5IR09p3SxOQeUjKCqKeD9g3uB9SZDzSqERGdhGonVgAaw 34Ya9at8W3SnNq261ztVjNQaKChJ4lGx87Ncj6C9gWo5CJ98R3Tcv//NJPgXQ+lyJOZp zpKqfcYLhHUS5WE7555XpnyuzGUPA6g0pRLN+8XTTMzLO2cawvpadztHQnIft/pzirYs 7g== Authentication-Results: cadence.com; spf=pass smtp.mailfrom=pawell@cadence.com Received: from nam01-sn1-obe.outbound.protection.outlook.com (mail-sn1nam01lp0118.outbound.protection.outlook.com [207.46.163.118]) by mx0a-0014ca01.pphosted.com with ESMTP id 2ntge14vg8-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Sun, 18 Nov 2018 02:10:49 -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=GmCP/vlRhYQlwtTkQNa6rLxmtTQ5sIucxHWwCjFi8D4=; b=pe0Pmk1mEEul43cIMi6oGuqhpIz9MWqSd9KnRMpFYHesrG4XV/hSiwarny0g3b3XzYEbYu4dP2hjl9HXOHn6JmiqVlG6B8hTOJvY6piKcPMTtrihhn95kwl0dbhxcRyQcO+EtzFFPUG7aFttakYn0raj3IAvv4E7f6nLWgEu+bU= Received: from DM5PR07CA0028.namprd07.prod.outlook.com (2603:10b6:3:16::14) by BN7PR07MB5169.namprd07.prod.outlook.com (2603:10b6:408:25::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1294.27; Sun, 18 Nov 2018 10:10:47 +0000 Received: from DM3NAM05FT006.eop-nam05.prod.protection.outlook.com (2a01:111:f400:7e51::203) by DM5PR07CA0028.outlook.office365.com (2603:10b6:3:16::14) 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:46 +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 DM3NAM05FT006.mail.protection.outlook.com (10.152.98.111) 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:45 +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 wAIAAb5T029622 (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=FAIL); Sun, 18 Nov 2018 02:10:45 -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:43 +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:43 +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 wAIAAeV3032015; Sun, 18 Nov 2018 10:10:40 GMT Received: (from pawell@localhost) by lvlogina.cadence.com (8.14.4/8.14.4/Submit) id wAIAAdVP031955; Sun, 18 Nov 2018 10:10:39 GMT From: Pawel Laszczak To: CC: , , , , , , , , , , , , "Pawel Laszczak" Subject: [RFC PATCH v2 11/15] usb:cdns3: Implements ISR functionality. Date: Sun, 18 Nov 2018 10:09:07 +0000 Message-ID: <1542535751-16079-12-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)(39860400002)(346002)(136003)(396003)(376002)(2980300002)(36092001)(199004)(189003)(26826003)(2351001)(217873002)(575784001)(86362001)(50466002)(50226002)(16586007)(356004)(6666004)(4326008)(54906003)(42186006)(316002)(106466001)(478600001)(87636003)(2906002)(4744004)(48376002)(26005)(51416003)(8936002)(186003)(76176011)(246002)(36756003)(426003)(336012)(446003)(305945005)(7636002)(8676002)(105596002)(4720700003)(6916009)(47776003)(5660300001)(14444005)(486006)(107886003)(2616005)(126002)(11346002)(476003);DIR:OUT;SFP:1101;SCL:1;SRVR:BN7PR07MB5169;H:sjmaillnx2.cadence.com;FPR:;SPF:SoftFail;LANG:en;PTR:corp.cadence.com;A:1;MX:1; X-Microsoft-Exchange-Diagnostics: 1;DM3NAM05FT006;1:Qn2W8ze8pdc/0UEnFBLGhubRU6Q8mEuF25lFoHyJXYdgaHHunFpwbON+SNcGIaIzmfuyUQEl1TMFhQhqySVz9vX2i6IvSapRa14gq3TuAoHKBsdvxzy+XQO/uILCTDij X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 3be6d323-0d59-44e6-b3db-08d64d3e1b94 X-Microsoft-Antispam: BCL:0;PCL:0;RULEID:(2390098)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600074)(711020)(2017052603328)(7153060);SRVR:BN7PR07MB5169; X-Microsoft-Exchange-Diagnostics: 1;BN7PR07MB5169;3:tQgahCP9TXB5ZEL9XV51JJ7n6Sw/iUX00g27sf4UHZ6SgA0OcbaK4VE38fmPX3onhUyQvmcfyeyuOPuzb5S41E79qUDrJzguK5yQwdxnPD+ucxLq7T/wgY1D7F9YYS0F6jscKLmS6G0S078xFLVSUJOHEhdJ0FWq8eIYgDXLFSZ2eARQTAXBU9GP/HTAV8gDbmjsxgJNXlWPKdSFVdWdMLKQdi8ITjkjL5tK/HskZhd+sYJZ7wmRkZYazxN4LzeZpaRYXioQQM2TGcQP6dQuR+etogKiDsN39gDTq/WdfoOOAxfTDLSUr1mRuLKSJso1FFbE1t6uhO646KAdNTRazXoGiZ6rChaRaUBRDjI+FFc=;25:WI4I+orufORDtUZudZXIdiZubS+SpCt/2dvr2iPMfvOUSIFHT8gg4AW/4tqkxGCN3ITja7E9ZsurDJajkbA0T6YznHLoisPjD9G9wEotwRB/BX2zKfvOKzuzV5kX7VNRatqSuwuHP/OcYPzmjdkRamthhFp38kHHqwiFZ1nQ/teJHdEYT6FuR5RayR4GfMQQOJ8ipTdEnps5Vzux2uHkAdmVYkFhp5qeOfXRF6W+lTV7zUFPQOyz0KpAbFBbiNG3Uhrjaks+ZXMS43UdeFJrqkNVeiq4uYfF1JxlIK8nelffLgObZL6sVTUBw89hHJ+EfM7OMHHMK2LP3XGWiNvuww== X-MS-TrafficTypeDiagnostic: BN7PR07MB5169: X-Microsoft-Exchange-Diagnostics: 1;BN7PR07MB5169;31:zhYiraD6RKMhv03P6s9EqqpIWBe3wKD5XHrH5mfvHXiJHGdX9nC5YdtKp4szEPMuBkmydMvyw+B62k2cQlihnESQS4u28NKG2axny4NgjNi4rdqvLLQR86EC9lo3RHluoZRHmNQhG8IBC5z/pFglG4W1R1+IWFepzD8b8LUkrzMoC8aFejPVQ+8INm1+zBLvSUjP1bZe0UeUlslu1/IUKYeIHy9PBs1hxZFFKEeV2Ew=;20:dz0bzh2XPBYFY1PgPYmz5QvqDszcv27n/Yxah7wuwbkzeewG9ZEJk8fCx7FY0vkRgMwijlEWxD0j7f1kubwAWZPMA2Hx22VhZ9iJLGXCyD8y8+MGXLwpEIlgoEE/2NoEDiqLkMO0xpkoX1qGIDAUAZH7fBkQwZnZ+v6KH1zbmVKovHRqa55OPd5av5J/bLFQRJ3ClcUwtE9Qmiq6mC12oAeRe5tuVtZOXHNauqU2yIdbfjGqPhp8u2GpBrH6P3vlYOz++HSbeU85UPf8oTORnuuhlgHm+MV4nSGSCicvEkIKdPrWIeeIRhZnJzMUGbRFNL0oL4KS8MhsGr+HqeAZCr5fmje0I7QiuCeLUe0LBB+UkLnyqnJiSIdbb+XfeEJ6cPbzF6OzRbviRpvaNJVCQHMNn3jX1y3HZaYf4TdhvEMiPNf5rr+0qJLNI/EDSwrgP/gHQMlb7tJpEmeLAgjhc9b+bfe3KEocwfEOlndfKvRvorSjtny3R4SOYoRghGs1 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)(10201501046)(93006095)(93003095)(3002001)(3231415)(944501410)(52105112)(148016)(149066)(150057)(6041310)(20161123558120)(20161123562045)(20161123564045)(20161123560045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(201708071742011)(7699051)(76991095);SRVR:BN7PR07MB5169;BCL:0;PCL:0;RULEID:;SRVR:BN7PR07MB5169; X-Microsoft-Exchange-Diagnostics: 1;BN7PR07MB5169;4:8jET2WkXYntJRq7rMEjpOURbUWQlWR+sgMCR5IyBcFVeEtKOZKQdTFFbexC1whLV43ZwcCdBC3GwxjDCfBDTafRZbBrKxQB05AWnCvVl25kRqUWdc/5N0dgncpg5pgUN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jYt4798QJ8GLI5PO3jvE5hY5VZ9B/vyWvOTJuqJcWOfHSr7u0bCtl4u2yRYQ7PSjO7IkfVD9+QtIhn5zBxTNg0iz/lTwnE2nb102Zejo8zYcS114AKBO+XMKVmnbmQFuBDqPBgFBAEAylSnpN3kIrlaA6/+gUKmILhzFAxig9UR2/wlIjz6M8CS3XhLpXlkszlN2idOpnOPrA==;5:rNg7gdyBZXMU2lr78MEfkvPpBwfKh+SnPiVzcO73BQqPwjsxfNU/t28yzMczMMhRbxqpFuiPPg6XGsf1o2Ptkd86u8X8lLubwnHLKeViKm7/160AW8NnoxmskMnEPhelRBDiSCkdEcJdh9xA5cdESomXe8f3qG9pGV8GoH5MJN0=;7:8KNWHwNOEwjVK2Q1CKYDEq6KBeGuODpNAoIE8TZoY+zIKk22370SwYbHwKt9tpBIyN3BSCkqsHchdPwcmEsIgqHbIElm48TmZU6smo77HX5P6hH3WM4/wmjGeTuK6XgcmByzIEz+HVC2lA/0FqbkwQ== SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1;BN7PR07MB5169;20:53L1rPtKbTpx3885oergDMgrv27xUM0vZTDWKh9UIVxxsZXJk0L7UnUy7UiomHwanj955PelBTrw+/3S42q+m3uEu4wEy4CZW/C7ad6iRQUjQ+g3/q7EbuCBHqXuNx+cUOHP8t3QOBYfxj9HCvFYTWTostLErrEHXbCSb/Kity1/rgtlSPW+7nH2YE0920A40XlHEODt9gKisV9ZFrjl1yKj/VYMBzvi5N27BD54xO+QC0TbkY1zdbLkPCXMls6B X-OriginatorOrg: cadence.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Nov 2018 10:10:45.9607 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 3be6d323-0d59-44e6-b3db-08d64d3e1b94 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: BN7PR07MB5169 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=966 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1811180096 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 set of generic functions used for handling interrupts generated by controller. Interrupt related functions are divided into three groups. The first is related to ep0 and is placed in ep0.c. The second is responsible for non-default endpoints and is implemented in gadget.c file. The last group is not related to endpoints interrupts and is placed in gadget.c. All groups have common entry point in cdns3_irq_handler_thread function. Signed-off-by: Pawel Laszczak --- drivers/usb/cdns3/ep0.c | 63 +++++++++++ drivers/usb/cdns3/gadget.c | 224 ++++++++++++++++++++++++++++++++++++- drivers/usb/cdns3/gadget.h | 1 + 3 files changed, 287 insertions(+), 1 deletion(-) diff --git a/drivers/usb/cdns3/ep0.c b/drivers/usb/cdns3/ep0.c index d05169e73631..eb92fd234bd7 100644 --- a/drivers/usb/cdns3/ep0.c +++ b/drivers/usb/cdns3/ep0.c @@ -90,6 +90,69 @@ static void cdns3_set_hw_configuration(struct cdns3_device *priv_dev) } } +static void __pending_setup_status_handler(struct cdns3_device *priv_dev) +{ + //TODO: Implements this function +} + +/** + * cdns3_ep0_setup_phase - Handling setup USB requests + * @priv_dev: extended gadget object + */ +static void cdns3_ep0_setup_phase(struct cdns3_device *priv_dev) +{ + //TODO: Implements this function. +} + +static void cdns3_transfer_completed(struct cdns3_device *priv_dev) +{ + //TODO: Implements this function +} + +/** + * cdns3_check_ep0_interrupt_proceed - Processes interrupt related to endpoint 0 + * @priv_dev: extended gadget object + * @dir: 1 for IN direction, 0 for OUT direction + */ +void cdns3_check_ep0_interrupt_proceed(struct cdns3_device *priv_dev, int dir) +{ + struct cdns3_usb_regs __iomem *regs = priv_dev->regs; + u32 ep_sts_reg; + + cdns3_select_ep(priv_dev, 0 | (dir ? USB_DIR_IN : USB_DIR_OUT)); + ep_sts_reg = readl(®s->ep_sts); + + __pending_setup_status_handler(priv_dev); + + if ((ep_sts_reg & EP_STS_SETUP) && dir == 0) { + struct usb_ctrlrequest *setup = priv_dev->setup; + + writel(EP_STS_SETUP | EP_STS_IOC | EP_STS_ISP, ®s->ep_sts); + + priv_dev->ep0_data_dir = setup->bRequestType & USB_DIR_IN; + cdns3_ep0_setup_phase(priv_dev); + ep_sts_reg &= ~(EP_STS_SETUP | EP_STS_IOC | EP_STS_ISP); + } + + if (ep_sts_reg & EP_STS_TRBERR) + writel(EP_STS_TRBERR, &priv_dev->regs->ep_sts); + + if (ep_sts_reg & EP_STS_DESCMIS) { + writel(EP_STS_DESCMIS, &priv_dev->regs->ep_sts); + + if (dir == 0 && !priv_dev->setup_pending) { + priv_dev->ep0_data_dir = 0; + cdns3_ep0_run_transfer(priv_dev, priv_dev->setup_dma, + 8, 0); + } + } + + if ((ep_sts_reg & EP_STS_IOC) || (ep_sts_reg & EP_STS_ISP)) { + writel(EP_STS_IOC, &priv_dev->regs->ep_sts); + cdns3_transfer_completed(priv_dev); + } +} + /** * cdns3_gadget_ep0_enable * Function shouldn't be called by gadget driver, diff --git a/drivers/usb/cdns3/gadget.c b/drivers/usb/cdns3/gadget.c index c965da16c0c8..309202474e57 100644 --- a/drivers/usb/cdns3/gadget.c +++ b/drivers/usb/cdns3/gadget.c @@ -58,6 +58,18 @@ void cdns3_set_register_bit(void __iomem *ptr, u32 mask) writel(mask, ptr); } +/** + * cdns3_ep_reg_pos_to_index - Macro converts bit position of ep_ists register + * to index of endpoint object in cdns3_device.eps[] container + * @i: bit position of endpoint for which endpoint object is required + * + * Remember that endpoint container doesn't contain default endpoint + */ +static u8 cdns3_ep_reg_pos_to_index(int i) +{ + return ((i / 16) + (((i % 16) - 2) * 2)); +} + /** * cdns3_next_request - returns next request from list * @list: list containing requests @@ -188,6 +200,21 @@ static void cdns3_ep_stall_flush(struct cdns3_endpoint *priv_ep) priv_ep->flags |= EP_STALL; } +/** + * cdns3_gadget_unconfig - reset device configuration + * @priv_dev: extended gadget object + */ +void cdns3_gadget_unconfig(struct cdns3_device *priv_dev) +{ + /* RESET CONFIGURATION */ + writel(USB_CONF_CFGRST, &priv_dev->regs->usb_conf); + + cdns3_enable_l1(priv_dev, 0); + priv_dev->hw_configured_flag = 0; + priv_dev->onchip_mem_allocated_size = 0; + priv_dev->out_mem_is_allocated = 0; +} + void cdns3_enable_l1(struct cdns3_device *priv_dev, int enable) { if (enable) @@ -196,6 +223,23 @@ void cdns3_enable_l1(struct cdns3_device *priv_dev, int enable) writel(USB_CONF_L1DS, &priv_dev->regs->usb_conf); } +static enum usb_device_speed cdns3_get_speed(struct cdns3_device *priv_dev) +{ + u32 reg; + + reg = readl(&priv_dev->regs->usb_sts); + + if (DEV_SUPERSPEED(reg)) + return USB_SPEED_SUPER; + else if (DEV_HIGHSPEED(reg)) + return USB_SPEED_HIGH; + else if (DEV_FULLSPEED(reg)) + return USB_SPEED_FULL; + else if (DEV_LOWSPEED(reg)) + return USB_SPEED_LOW; + return USB_SPEED_UNKNOWN; +} + /** * cdns3_gadget_giveback - call struct usb_request's ->complete callback * @priv_ep: The endpoint to whom the request belongs to @@ -221,12 +265,136 @@ void cdns3_gadget_giveback(struct cdns3_endpoint *priv_ep, */ int cdns3_ep_run_transfer(struct cdns3_endpoint *priv_ep, struct usb_request *request) +{ + return 0; +} + +static void cdns3_transfer_completed(struct cdns3_device *priv_dev, + struct cdns3_endpoint *priv_ep) { //TODO: Implements this function. +} + +/** + * cdns3_check_ep_interrupt_proceed - Processes interrupt related to endpoint + * @priv_ep: endpoint object + * + * Returns 0 + */ +static int cdns3_check_ep_interrupt_proceed(struct cdns3_endpoint *priv_ep) +{ + struct cdns3_device *priv_dev = priv_ep->cdns3_dev; + struct cdns3_usb_regs __iomem *regs; + u32 ep_sts_reg; + + regs = priv_dev->regs; + + cdns3_select_ep(priv_dev, priv_ep->endpoint.address); + ep_sts_reg = readl(®s->ep_sts); + + if (ep_sts_reg & EP_STS_TRBERR) + writel(EP_STS_TRBERR, ®s->ep_sts); + + if (ep_sts_reg & EP_STS_ISOERR) + writel(EP_STS_ISOERR, ®s->ep_sts); + + if (ep_sts_reg & EP_STS_OUTSMM) + writel(EP_STS_OUTSMM, ®s->ep_sts); + + if (ep_sts_reg & EP_STS_NRDY) + writel(EP_STS_NRDY, ®s->ep_sts); + + if ((ep_sts_reg & EP_STS_IOC) || (ep_sts_reg & EP_STS_ISP)) { + writel(EP_STS_IOC | EP_STS_ISP, ®s->ep_sts); + cdns3_transfer_completed(priv_dev, priv_ep); + } + + if (ep_sts_reg & EP_STS_DESCMIS) + writel(EP_STS_DESCMIS, ®s->ep_sts); return 0; } +/** + * cdns3_check_usb_interrupt_proceed - Processes interrupt related to device + * @priv_dev: extended gadget object + * @usb_ists: bitmap representation of device's reported interrupts + * (usb_ists register value) + */ +static void cdns3_check_usb_interrupt_proceed(struct cdns3_device *priv_dev, + u32 usb_ists) +{ + struct cdns3_usb_regs __iomem *regs; + int speed = 0; + + regs = priv_dev->regs; + + /* Connection detected */ + if (usb_ists & (USB_ISTS_CON2I | USB_ISTS_CONI)) { + writel(USB_ISTS_CON2I | USB_ISTS_CONI, ®s->usb_ists); + speed = cdns3_get_speed(priv_dev); + + dev_dbg(&priv_dev->dev, "Connection detected at speed: %s %d\n", + usb_speed_string(speed), speed); + + priv_dev->gadget.speed = speed; + priv_dev->is_connected = 1; + usb_gadget_set_state(&priv_dev->gadget, USB_STATE_POWERED); + cdns3_ep0_config(priv_dev); + } + + /* SS Disconnection detected */ + if (usb_ists & (USB_ISTS_DIS2I | USB_ISTS_DISI)) { + dev_dbg(&priv_dev->dev, "Disconnection detected\n"); + + writel(USB_ISTS_DIS2I | USB_ISTS_DISI, ®s->usb_ists); + if (priv_dev->gadget_driver && + priv_dev->gadget_driver->disconnect) { + spin_unlock(&priv_dev->lock); + priv_dev->gadget_driver->disconnect(&priv_dev->gadget); + spin_lock(&priv_dev->lock); + } + priv_dev->gadget.speed = USB_SPEED_UNKNOWN; + usb_gadget_set_state(&priv_dev->gadget, USB_STATE_NOTATTACHED); + priv_dev->is_connected = 0; + cdns3_gadget_unconfig(priv_dev); + } + + if (usb_ists & USB_ISTS_L2ENTI) { + dev_dbg(&priv_dev->dev, "Device suspended\n"); + writel(USB_ISTS_L2ENTI, ®s->usb_ists); + } + + /* Exit from standby mode on L2 exit (Suspend in HS/FS or SS) */ + if (usb_ists & USB_ISTS_L2EXTI) { + dev_dbg(&priv_dev->dev, "[Interrupt] L2 exit detected\n"); + writel(USB_ISTS_L2EXTI, ®s->usb_ists); + } + + /* Exit from standby mode on U3 exit (Suspend in HS/FS or SS). */ + if (usb_ists & USB_ISTS_U3EXTI) { + dev_dbg(&priv_dev->dev, "U3 exit detected\n"); + writel(USB_ISTS_U3EXTI, ®s->usb_ists); + } + + /* resets cases */ + if (usb_ists & (USB_ISTS_UWRESI | USB_ISTS_UHRESI | USB_ISTS_U2RESI)) { + writel(USB_ISTS_U2RESI | USB_ISTS_UWRESI | USB_ISTS_UHRESI, + ®s->usb_ists); + + /*read again to check the actuall speed*/ + speed = cdns3_get_speed(priv_dev); + + dev_dbg(&priv_dev->dev, "Reset detected at speed: %s %d\n", + usb_speed_string(speed), speed); + + usb_gadget_set_state(&priv_dev->gadget, USB_STATE_DEFAULT); + priv_dev->gadget.speed = speed; + cdns3_gadget_unconfig(priv_dev); + cdns3_ep0_config(priv_dev); + } +} + /** * cdns3_irq_handler - irq line interrupt handler * @cdns: cdns3 instance @@ -237,8 +405,62 @@ int cdns3_ep_run_transfer(struct cdns3_endpoint *priv_ep, */ static irqreturn_t cdns3_irq_handler_thread(struct cdns3 *cdns) { + struct cdns3_device *priv_dev; irqreturn_t ret = IRQ_NONE; - //TODO: implements this function + unsigned long flags; + u32 reg; + + priv_dev = container_of(cdns->gadget_dev, struct cdns3_device, dev); + spin_lock_irqsave(&priv_dev->lock, flags); + + /* check USB device interrupt */ + reg = readl(&priv_dev->regs->usb_ists); + if (reg) { + dev_dbg(&priv_dev->dev, "IRQ: usb_ists: %08X\n", reg); + cdns3_check_usb_interrupt_proceed(priv_dev, reg); + ret = IRQ_HANDLED; + } + + /* check endpoint interrupt */ + reg = readl(&priv_dev->regs->ep_ists); + if (reg != 0) { + dev_dbg(&priv_dev->dev, "IRQ ep_ists: %08X\n", reg); + } else { + if (USB_STS_CFGSTS(readl(&priv_dev->regs->usb_sts))) + ret = IRQ_HANDLED; + goto irqend; + } + + /* handle default endpoint OUT */ + if (reg & EP_ISTS_EP_OUT0) { + cdns3_check_ep0_interrupt_proceed(priv_dev, 0); + ret = IRQ_HANDLED; + } + + /* handle default endpoint IN */ + if (reg & EP_ISTS_EP_IN0) { + cdns3_check_ep0_interrupt_proceed(priv_dev, 1); + ret = IRQ_HANDLED; + } + + /* check if interrupt from non default endpoint, if no exit */ + reg &= ~(EP_ISTS_EP_OUT0 | EP_ISTS_EP_IN0); + if (!reg) + goto irqend; + + do { + unsigned int bit_pos = ffs(reg); + u32 bit_mask = 1 << (bit_pos - 1); + int index; + + index = cdns3_ep_reg_pos_to_index(bit_pos); + cdns3_check_ep_interrupt_proceed(priv_dev->eps[index]); + reg &= ~bit_mask; + ret = IRQ_HANDLED; + } while (reg); + +irqend: + spin_unlock_irqrestore(&priv_dev->lock, flags); return ret; } diff --git a/drivers/usb/cdns3/gadget.h b/drivers/usb/cdns3/gadget.h index 224f6b830bc9..8c2f363f9340 100644 --- a/drivers/usb/cdns3/gadget.h +++ b/drivers/usb/cdns3/gadget.h @@ -1072,6 +1072,7 @@ int cdns3_handshake(void __iomem *ptr, u32 mask, u32 done, int usec); void cdns3_set_register_bit(void __iomem *ptr, u32 mask); int cdns3_init_ep0(struct cdns3_device *priv_dev); void cdns3_ep0_config(struct cdns3_device *priv_dev); +void cdns3_check_ep0_interrupt_proceed(struct cdns3_device *priv_dev, int dir); void cdns3_select_ep(struct cdns3_device *priv_dev, u32 ep); void cdns3_enable_l1(struct cdns3_device *priv_dev, int enable); struct usb_request *cdns3_next_request(struct list_head *list);