Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp5377305ybi; Wed, 12 Jun 2019 01:16:14 -0700 (PDT) X-Google-Smtp-Source: APXvYqxbg4R5FontBEL1gK0J0eCX+VtcEAnjds5cC3aGWJG3wu6MOFY1dM2ykAEixlT85qq+FUwA X-Received: by 2002:a17:902:e312:: with SMTP id cg18mr13619219plb.212.1560327374625; Wed, 12 Jun 2019 01:16:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560327374; cv=none; d=google.com; s=arc-20160816; b=bMJooWl4g8H4ZGmnx58kunPmI5X3W3UxsFGWvZFu/2SSIYfUBvPbdwyUtnAewck2OH mEWoVQmA82ZfL3TkZ5op/mtUUTrZRJI3QL+ZleBdqgSQIAvanOv7j0ZeyzJayBt+ElSX ATRvk3WUoa59yQuvsxo1P0saS5jrk+a+MSWvL0wj3X6Y6/gCPqY+NJH09AUFnw0PDip0 Q3SlrUxTkoDkt3gUg29d9gbk/Yi/B/S1eMARcmExN/YamfqK83EPYGaGfC6ggJjBP11g TFefcH7+zwbD645unZODbO5jL7O+DVC5MwIVeXnzvDhKi+YwmK6vEihnlgmrq10loKMe 0b2w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:date:subject:cc :to:from; bh=x1cVnvQ0M7xIF9MRNRvdj7dBbUIs5P/iGJojBf5o93Q=; b=sLn4POTZpB3na5yGoZMdn7wI5tqdY0nyasisIl87l+0cYTtgTr4N17t1uxmLunReYs ERYR47Aenhdp7acx0rbUKHTUE/lJXcmNT6RZXziJl951P7Jzwf2BBzqqJLEuqiwKo6Af sCn1r+0qfp959HVefZuuS+HkpD/CxPuVVZdzwfedX/Hhs9MILX7BQwMDJsY6v5nwetTA Uu4xUHttnRZljsMpCSb74mnNuTeG4naHCP+GaBNVAAwikAXSeNmFJ+dIM5oKdWZ/NEP2 NuxBNj1qUgWuhh4qh6Ofn3a0rOwwfB+7KB8/+sYvWIFjbwigZgKPJnGlC0MHf6ABBjPv gqQQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a22si14961076plm.343.2019.06.12.01.15.59; Wed, 12 Jun 2019 01:16:14 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731093AbfFLG2a (ORCPT + 99 others); Wed, 12 Jun 2019 02:28:30 -0400 Received: from mailgw02.mediatek.com ([210.61.82.184]:44590 "EHLO mailgw02.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1726010AbfFLG2a (ORCPT ); Wed, 12 Jun 2019 02:28:30 -0400 X-UUID: ee68a5836ab848e7bba4d9c3af397e7a-20190612 X-UUID: ee68a5836ab848e7bba4d9c3af397e7a-20190612 Received: from mtkcas09.mediatek.inc [(172.21.101.178)] by mailgw02.mediatek.com (envelope-from ) (mhqrelay.mediatek.com ESMTP with TLS) with ESMTP id 653344176; Wed, 12 Jun 2019 14:28:16 +0800 Received: from MTKCAS06.mediatek.inc (172.21.101.30) by mtkmbs08n2.mediatek.inc (172.21.101.56) with Microsoft SMTP Server (TLS) id 15.0.1395.4; Wed, 12 Jun 2019 14:28:14 +0800 Received: from mtkswgap22.mediatek.inc (172.21.77.33) by MTKCAS06.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1395.4 via Frontend Transport; Wed, 12 Jun 2019 14:28:15 +0800 From: Macpaul Lin To: Chunfeng Yun , Greg Kroah-Hartman , Matthias Brugger , Macpaul Lin , , , , CC: Subject: [PATCH] mtu3: fix setup packet response for HNP and SRP request Date: Wed, 12 Jun 2019 14:28:07 +0800 Message-ID: <1560320892-30551-1-git-send-email-macpaul.lin@mediatek.com> X-Mailer: git-send-email 1.7.9.5 MIME-Version: 1.0 Content-Type: text/plain X-TM-SNTS-SMTP: CE1AD9F9C4AB7DD47709BB3955B3B7E2FF4BB35A299C25F5C5745B5492155FC12000:8 X-MTK: N Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 1. Add OTG_HNP_REQD and OTG_SRP_REQD definitions in ch9.h. 2. When OTG_HNP_REQD and OTG_SRP_REQD has been received, usb hardware must not enter TEST mode but need to response setup packet. 3. Add otg_srp_reqd and otg_hnp_reqd in struct ssusb_mtk for futher implementation. Signed-off-by: Macpaul Lin --- drivers/usb/mtu3/mtu3.h | 4 ++++ drivers/usb/mtu3/mtu3_gadget_ep0.c | 13 +++++++++++++ include/uapi/linux/usb/ch9.h | 5 +++++ 3 files changed, 22 insertions(+) diff --git a/drivers/usb/mtu3/mtu3.h b/drivers/usb/mtu3/mtu3.h index 76ecf12fdf62..bb8a31bc6e4d 100644 --- a/drivers/usb/mtu3/mtu3.h +++ b/drivers/usb/mtu3/mtu3.h @@ -226,6 +226,8 @@ struct otg_switch_mtk { * @dma_clk: dma_bus_ck clock for AXI bus etc * @dr_mode: works in which mode: * host only, device only or dual-role mode + * @otg_srp_reqd: used for SRP request handling. + * @otg_hnp_reqd: used for HNP request handling. * @u2_ports: number of usb2.0 host ports * @u3_ports: number of usb3.0 host ports * @u3p_dis_msk: mask of disabling usb3 ports, for example, bit0==1 to @@ -252,6 +254,8 @@ struct ssusb_mtk { /* otg */ struct otg_switch_mtk otg_switch; enum usb_dr_mode dr_mode; + bool otg_srp_reqd; + bool otg_hnp_reqd; bool is_host; int u2_ports; int u3_ports; diff --git a/drivers/usb/mtu3/mtu3_gadget_ep0.c b/drivers/usb/mtu3/mtu3_gadget_ep0.c index 4da216c99726..1247c43a63e6 100644 --- a/drivers/usb/mtu3/mtu3_gadget_ep0.c +++ b/drivers/usb/mtu3/mtu3_gadget_ep0.c @@ -285,11 +285,24 @@ static int handle_test_mode(struct mtu3 *mtu, struct usb_ctrlrequest *setup) dev_dbg(mtu->dev, "TEST_PACKET\n"); mtu->test_mode_nr = TEST_PACKET_MODE; break; + case OTG_SRP_REQD: + dev_dbg(mtu->dev, "OTG_SRP_REQD\n"); + mtu->ssusb->otg_srp_reqd = 1; + break; + case OTG_HNP_REQD: + dev_dbg(mtu->dev, "OTG_HNP_REQD\n"); + mtu->ssusb->otg_hnp_reqd = 1; + break; default: handled = -EINVAL; goto out; } + if (mtu->ssusb->otg_srp_reqd || mtu->ssusb->otg_hnp_reqd) { + mtu->ep0_state = MU3D_EP0_STATE_SETUP; + goto out; + } + mtu->test_mode = true; /* no TX completion interrupt, and need restart platform after test */ diff --git a/include/uapi/linux/usb/ch9.h b/include/uapi/linux/usb/ch9.h index d5a5caec8fbc..545918c83fd1 100644 --- a/include/uapi/linux/usb/ch9.h +++ b/include/uapi/linux/usb/ch9.h @@ -143,6 +143,11 @@ #define TEST_SE0_NAK 3 #define TEST_PACKET 4 #define TEST_FORCE_EN 5 +/* + * OTG HNP and SRP REQD + */ +#define OTG_SRP_REQD 6 +#define OTG_HNP_REQD 7 /* Status Type */ #define USB_STATUS_TYPE_STANDARD 0 -- 2.18.0