From patchwork Mon Jan 25 13:43:54 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peng Fan X-Patchwork-Id: 370232 Delivered-To: patch@linaro.org Received: by 2002:a02:a60d:0:0:0:0:0 with SMTP id c13csp3993912jam; Mon, 25 Jan 2021 05:28:50 -0800 (PST) X-Google-Smtp-Source: ABdhPJzkWeWuFGe9dUGLnDGpz7rCKiH6SFZlNB7O1ZKzdLKETZUHZb9DO0HpH6Fjch6Du0oFrhlM X-Received: by 2002:a50:9ee9:: with SMTP id a96mr431767edf.343.1611581330787; Mon, 25 Jan 2021 05:28:50 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1611581330; cv=pass; d=google.com; s=arc-20160816; b=zWG8CtnbkY+6klyH++azEoeprMYNsh07IqA9QBjksKaYaRLrR6tBdGP2h4Tx0VNCF9 t67Bzu8BMt5OvHloDt+tQq4p+gXEJn8/xk8UVxsOkG/j3eANyCxKcJoY8esaGwG8OmYK Wwdxzk5L+2DyEIpXRmECxTNqpC1GFmz88e6CYdchUX7Cl2qV7f4gaqrzZRIDEOp5wj7b ZQHMYY9ATnxR6SncB863jUDsDREuVA/3gbRmqaLzxidXLNIrOlCIk09oixurgJHxeUBw YTQ9+WBpEStv+VKqe0WaEx56q+70p8gzJhhKn3HQQoHycUKwIZtvuT7NxlAhPQfJJpVf JWeQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:mime-version :content-transfer-encoding:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=25t/RNTpe4zOUqY8lHdRiplKnv+fKjRjhI0OurJ6ElE=; b=jXx7vSgHLwr9oNebRtDJfODezcAJeVchP1XsS+Um8jOSY31Rc7ZJ3Qvnb4jtLXK3LL 0tSo+NshsQBfBGroLJASfnK27VcHcvRn3qhPfWpWEl7/GbE6IY3jftbgxvdy4XyVEsmk Izi78cK/zI9iTcFQpTlzQRgZGV74NGV5XchC2V9E5CI4r45e8DQROT57nOOZDM8daRGi Lz7g4Eavbw03Cimq2BvTcjQZmf3kgC1Q8VX+jcctmwjfFRWHEnmNJ5/iGO8XO0LipRVi xfVTNKM2mQn71s5SF7+1gUKwrSuaMN63yDRTbIAm+EYICkOgyqkaq0wlboa/BHCl37rI 7nnQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@nxp.com header.s=selector2 header.b=cLdxglvO; arc=pass (i=1 spf=pass spfdomain=nxp.com dkim=pass dkdomain=nxp.com dmarc=pass fromdomain=nxp.com); spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=nxp.com Return-Path: Received: from phobos.denx.de (phobos.denx.de. [2a01:238:438b:c500:173d:9f52:ddab:ee01]) by mx.google.com with ESMTPS id l14si7508483edb.407.2021.01.25.05.28.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Jan 2021 05:28:50 -0800 (PST) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; Authentication-Results: mx.google.com; dkim=pass header.i=@nxp.com header.s=selector2 header.b=cLdxglvO; arc=pass (i=1 spf=pass spfdomain=nxp.com dkim=pass dkdomain=nxp.com dmarc=pass fromdomain=nxp.com); spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=nxp.com Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id A666182777; Mon, 25 Jan 2021 14:26:58 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=nxp.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=nxp.com header.i=@nxp.com header.b="cLdxglvO"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id F124D826B2; Mon, 25 Jan 2021 14:15:11 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=0.3 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FORGED_SPF_HELO,MSGID_FROM_MTA_HEADER, SPF_HELO_PASS autolearn=no autolearn_force=no version=3.4.2 Received: from EUR02-VE1-obe.outbound.protection.outlook.com (mail-ve1eur02on0624.outbound.protection.outlook.com [IPv6:2a01:111:f400:fe06::624]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 4718B82679 for ; Mon, 25 Jan 2021 14:15:06 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=nxp.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=peng.fan@nxp.com ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=gg33xU4QBJZMbEwHc2YdqUn6lI6OVYqegEODI9SoIj6pvoGDz7D3GZ0BWQm4VtWkGV7J7JYOetuWF8VjbYQXjr7O+p7BA4QU6KqVBiNQxaGOKm+/xQwtlangp4JRvYJSuxCdaP5sdl+DT5tAo8Ni5ZUKsGt1YZOLhQ/EU/FYGnxc3BOGOOhgskT8FsGhu5EZVhOKMBQAf7JBx324arQHb5NaHE2NURBI6htd+E7ZQslR2Fa+L4aj5F+YUIdYXQh9W+8MWe/7r848pD5gFGGKNnr6FzODt6/+R1GO0dFmDxBrD+yp5g6DGgVGAgCKo+szf1CuxKJStFRDISsT55Xj5A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=25t/RNTpe4zOUqY8lHdRiplKnv+fKjRjhI0OurJ6ElE=; b=bpxbuS98UNTQaJInVkmtAvfj9JwmgWaMIYIU6v91FJg2hw7PyvcmwGSUjQgjSGT5PNJ7uwkeM2sAdgd65mcX43d1HVfEyF/gkReF8obU8Aqcwi1XGytYTvB3an/8ddO8c1HvgyU+2t9/ZJpsz0Q9xJ+u4yUbKlByaJWpA11mpVtdy7Wmy2K3aBCpZ2rFslUU0vvvgIQ80Ma0b30ZuT7t8HoJ8CegukwGdMRalY978kx4A07R3t6qpu4b4egF82yyu2Bs5M0rA8D57NgN8g6ajZ3uDo0HvEME7ar27x93j3z5gCUdUtqoQWkrR+eBIKZr+fq1Y3oeD2d5EaWHfWR4Pw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=25t/RNTpe4zOUqY8lHdRiplKnv+fKjRjhI0OurJ6ElE=; b=cLdxglvOCxTMPm0v8kpeH89TvKObfdLw8RVW2JYiBX4/xf1IzaGnpShBPbhVpLMZkJGyEr6XmUte5KQKZ1ApYmq/TiAbcAW5Sgz87XEnh3u06q95UaJjTRF55i/wxh5A+PElu1ZqlcrknKJ0iWITw85yZM8KNXMe1pULMadORUM= Authentication-Results: denx.de; dkim=none (message not signed) header.d=none;denx.de; dmarc=none action=none header.from=nxp.com; Received: from DB6PR0402MB2760.eurprd04.prod.outlook.com (2603:10a6:4:a1::14) by DBBPR04MB7930.eurprd04.prod.outlook.com (2603:10a6:10:1ea::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3784.17; Mon, 25 Jan 2021 13:15:05 +0000 Received: from DB6PR0402MB2760.eurprd04.prod.outlook.com ([fe80::d58c:d479:d094:43d0]) by DB6PR0402MB2760.eurprd04.prod.outlook.com ([fe80::d58c:d479:d094:43d0%9]) with mapi id 15.20.3784.019; Mon, 25 Jan 2021 13:15:05 +0000 From: peng.fan@nxp.com To: sbabic@denx.de, lukma@denx.de, marex@denx.de Cc: uboot-imx@nxp.com, u-boot@lists.denx.de, Li Jun , Ye Li , Peter Chen , "faqiang . zhu" , Peng Fan Subject: [PATCH V2 11/17] usb: gadget: add super speed support Date: Mon, 25 Jan 2021 21:43:54 +0800 Message-Id: <20210125134400.780-12-peng.fan@nxp.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20210125134400.780-1-peng.fan@nxp.com> References: <20210125134400.780-1-peng.fan@nxp.com> X-Originating-IP: [119.31.174.71] X-ClientProxiedBy: SG2PR03CA0117.apcprd03.prod.outlook.com (2603:1096:4:91::21) To DB6PR0402MB2760.eurprd04.prod.outlook.com (2603:10a6:4:a1::14) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from linux-1xn6.ap.freescale.net (119.31.174.71) by SG2PR03CA0117.apcprd03.prod.outlook.com (2603:1096:4:91::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3805.6 via Frontend Transport; Mon, 25 Jan 2021 13:15:01 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 15a9a445-fccd-45c2-42e1-08d8c1333ade X-MS-TrafficTypeDiagnostic: DBBPR04MB7930: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:255; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 9tenmYZ1aKXOboVNOho/bCEhg2KfdimLXIyasCGTnGpVWbsrZyIqAVhJaCnpPejDRTkZAjcBMQ5fl3PoG7gIVISSloDyBti1jIn2YcaGABVRP5Bo4N+MLSD7aqNTG0VMyu4csynti8WhPNIJfZPyDmCQCT5CwDKjjNm2AYDl+jI9E3sq+ByI+ELPDeuhpsbWXwnuYOMrUM1/k6qxDQwXVvDOwLLPfxwMvbjRRkNaxq1dNWGMTYONqRj3OjBhYPDxIPMXIJOd1OPrD7OpQtN/oAQcgt7cpuKtoJGNwbhF3g2/qLB8Ye0c5mopiyG5vxOsmN6sgTmFXUF7vNKG8nEM0afWvWoZV7WTDa9vPXSKGjKI06uVdmKywTvXPMYYJGTrY5qcmAlLGl7zSo81GcfurQ== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DB6PR0402MB2760.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(366004)(396003)(346002)(39860400002)(376002)(136003)(2906002)(66476007)(66556008)(8936002)(186003)(4326008)(16526019)(83380400001)(8676002)(478600001)(66946007)(5660300002)(6666004)(9686003)(2616005)(36756003)(54906003)(1076003)(956004)(6512007)(19627235002)(6486002)(6506007)(86362001)(316002)(52116002)(26005); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: fQp6D5ZOHPXA7KrxCXE4coWVj5J+8m/ykSlVZvEZMRw9g/9flulp91FfNxuo3e2u+PbSJnw6o8lgSnUyJdgiPjw06YpqtPlP7dxkouWowOQMjeIC5rf+FTZ++BkOtXDip6JkoMjdi0qJ5c0d/5FLQO1LMHcjZAyQ86uW7UOx/pFaETUm5F+1ZIq7grKiAkOpvmWH6Y1bUAAPFA1frk3MeEcNP3V9rtwnAovvgefsbTnuygJPQUbCF+bnx1CZc3wfT5+S5V+Vi/SxBGGg3rEKaS8YBJJYu7c6+XLXG1IG8NlVBw+Ageu1W6mNaVRTmywEbxaVpzmjtKzWcirg3Bxe1luKKaoLXjO4d65ou1A8NmLNBkEtZV06IbuVuKfWcGHffb8Iqq9GQWCLwrNaoZYhnBRmwIYwhaYlu3FCybnOcmsj+l3cpQHw+Lgt9t3/qAyVJtZiGw8H8WQNGE68U2rNgPRqhtAvMbBq4Ym9w2uW/4kqPz2AlHMTorEu85MZZfB+qwXPZSjusEMxd3iMsv1oVgcfyB8h8DBlHIlxFiaRyDOq4yY/GpkDYF2wRZwgYQnXYblFgZnYVnrNJ4Y1/PzO1YLq53/WCUW9hc1XyU4gy/VFu/7rrc0MlPMKS9zrLXQQzbrq2+ILQSeiqwsccBfAsudRhdSXQn0Xwv8jU6L+g3P+TUGEieR4HFF1tX1F9AlHeekf3dOIsc3mUfX7T4O9NInnd8xsFnGnqE/+D7ZkdtLSAt5K/IzGmA1LcJfuk/wzakqBVlOsnhvuvobt+E9HCJfBMnJOWJiteHyW4HAnX3kv6YBMQOW0GRkJ4JLD9pjUgEji+1oWcap9o68+5MegeQ0xdwxigzTbTnaTWSje6qFK+u0ACusfa9713MOwuMZ+uFC3HVThtl0lPagTrqcwNztkJZGMIhTJoSlWLgYxV91IejgFnqGPgP+ExGjdjEnW5FWXdKpRRCNBm5idzJqJnb4//IF359p32RCicTBDFjYoGMdqkoK+uT3h+aKARLtP X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 15a9a445-fccd-45c2-42e1-08d8c1333ade X-MS-Exchange-CrossTenant-AuthSource: DB6PR0402MB2760.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Jan 2021 13:15:05.2970 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 2V1NufDY+yWIVyr4LPl+fD3E8KxDcpYgB5kK+bKx8ZCgry0OkaUNUq3iOE/GXRX23YkpQ63sW3x7rwlhsm11Rg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DBBPR04MB7930 X-Mailman-Approved-At: Mon, 25 Jan 2021 14:26:22 +0100 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.102.3 at phobos.denx.de X-Virus-Status: Clean From: Li Jun This patch is to add usb gadget super speed support in common driver, including BOS descriptor and select the super speed descriptor from function driver. Reviewed-by: Ye Li Reviewed-by: Peter Chen Tested-by: faqiang.zhu Signed-off-by: Li Jun Signed-off-by: Peng Fan --- drivers/usb/gadget/composite.c | 85 ++++++++++++++++++++++++---------- include/linux/usb/composite.h | 4 ++ include/linux/usb/gadget.h | 6 +++ 3 files changed, 70 insertions(+), 25 deletions(-) -- 2.28.0 diff --git a/drivers/usb/gadget/composite.c b/drivers/usb/gadget/composite.c index 404da12754..1063c571d8 100644 --- a/drivers/usb/gadget/composite.c +++ b/drivers/usb/gadget/composite.c @@ -88,6 +88,8 @@ int usb_add_function(struct usb_configuration *config, config->fullspeed = 1; if (!config->highspeed && function->hs_descriptors) config->highspeed = 1; + if (!config->superspeed && function->ss_descriptors) + config->superspeed = 1; done: if (value) @@ -223,7 +225,9 @@ static int config_buf(struct usb_configuration *config, /* add each function's descriptors */ list_for_each_entry(f, &config->functions, list) { - if (speed == USB_SPEED_HIGH) + if (speed == USB_SPEED_SUPER) + descriptors = f->ss_descriptors; + else if (speed == USB_SPEED_HIGH) descriptors = f->hs_descriptors; else descriptors = f->descriptors; @@ -251,7 +255,9 @@ static int config_desc(struct usb_composite_dev *cdev, unsigned w_value) struct usb_configuration *c; struct list_head *pos; - if (gadget_is_dualspeed(gadget)) { + if (gadget_is_superspeed(gadget)) { + speed = gadget->speed; + } else if (gadget_is_dualspeed(gadget)) { if (gadget->speed == USB_SPEED_HIGH) hs = 1; if (type == USB_DT_OTHER_SPEED_CONFIG) @@ -275,7 +281,10 @@ static int config_desc(struct usb_composite_dev *cdev, unsigned w_value) continue; check_config: - if (speed == USB_SPEED_HIGH) { + if (speed == USB_SPEED_SUPER) { + if (!c->superspeed) + continue; + } else if (speed == USB_SPEED_HIGH) { if (!c->highspeed) continue; } else { @@ -294,8 +303,12 @@ static int count_configs(struct usb_composite_dev *cdev, unsigned type) struct usb_gadget *gadget = cdev->gadget; unsigned count = 0; int hs = 0; + int ss = 0; struct usb_configuration *c; + if (gadget->speed == USB_SPEED_SUPER) + ss = 1; + if (gadget_is_dualspeed(gadget)) { if (gadget->speed == USB_SPEED_HIGH) hs = 1; @@ -304,7 +317,10 @@ static int count_configs(struct usb_composite_dev *cdev, unsigned type) } list_for_each_entry(c, &cdev->configs, list) { /* ignore configs that won't work at this speed */ - if (hs) { + if (ss) { + if (!c->superspeed) + continue; + } else if (hs) { if (!c->highspeed) continue; } else { @@ -388,6 +404,9 @@ static int set_config(struct usb_composite_dev *cdev, case USB_SPEED_HIGH: speed = "high"; break; + case USB_SPEED_SUPER: + speed = "super"; + break; default: speed = "?"; break; @@ -412,7 +431,9 @@ static int set_config(struct usb_composite_dev *cdev, * function's setup callback instead of the current * configuration's setup callback. */ - if (gadget->speed == USB_SPEED_HIGH) + if (gadget->speed == USB_SPEED_SUPER) + descriptors = f->ss_descriptors; + else if (gadget->speed == USB_SPEED_HIGH) descriptors = f->hs_descriptors; else descriptors = f->descriptors; @@ -492,8 +513,9 @@ int usb_add_config(struct usb_composite_dev *cdev, list_del(&config->list); config->cdev = NULL; } else { - debug("cfg %d/%p speeds:%s%s\n", + debug("cfg %d/%p speeds:%s%s%s\n", config->bConfigurationValue, config, + config->superspeed ? " super" : "", config->highspeed ? " high" : "", config->fullspeed ? (gadget_is_dualspeed(cdev->gadget) @@ -751,6 +773,7 @@ static void composite_setup_complete(struct usb_ep *ep, struct usb_request *req) static int bos_desc(struct usb_composite_dev *cdev) { struct usb_ext_cap_descriptor *usb_ext; + struct usb_dcd_config_params dcd_config_params; struct usb_bos_descriptor *bos = cdev->req->buf; bos->bLength = USB_DT_BOS_SIZE; @@ -794,9 +817,19 @@ static int bos_desc(struct usb_composite_dev *cdev) USB_HIGH_SPEED_OPERATION | USB_5GBPS_OPERATION); ss_cap->bFunctionalitySupport = USB_LOW_SPEED_OPERATION; - ss_cap->bU1devExitLat = USB_DEFAULT_U1_DEV_EXIT_LAT; - ss_cap->bU2DevExitLat = - cpu_to_le16(USB_DEFAULT_U2_DEV_EXIT_LAT); + + /* Get Controller configuration */ + if (cdev->gadget->ops->get_config_params) { + cdev->gadget->ops->get_config_params( + &dcd_config_params); + } else { + dcd_config_params.bU1devExitLat = + USB_DEFAULT_U1_DEV_EXIT_LAT; + dcd_config_params.bU2DevExitLat = + cpu_to_le16(USB_DEFAULT_U2_DEV_EXIT_LAT); + } + ss_cap->bU1devExitLat = dcd_config_params.bU1devExitLat; + ss_cap->bU2DevExitLat = dcd_config_params.bU2DevExitLat; } return le16_to_cpu(bos->wTotalLength); } @@ -999,32 +1032,28 @@ composite_setup(struct usb_gadget *gadget, const struct usb_ctrlrequest *ctrl) cdev->desc.bNumConfigurations = count_configs(cdev, USB_DT_DEVICE); - /* - * If the speed is Super speed, then the supported - * max packet size is 512 and it should be sent as - * exponent of 2. So, 9(2^9=512) should be filled in - * bMaxPacketSize0. Also fill USB version as 3.0 - * if speed is Super speed. - */ - if (cdev->gadget->speed == USB_SPEED_SUPER) { + cdev->desc.bMaxPacketSize0 = + cdev->gadget->ep0->maxpacket; + if (gadget->speed >= USB_SPEED_SUPER) { + cdev->desc.bcdUSB = cpu_to_le16(0x0310); cdev->desc.bMaxPacketSize0 = 9; - cdev->desc.bcdUSB = cpu_to_le16(0x0300); } else { - cdev->desc.bMaxPacketSize0 = - cdev->gadget->ep0->maxpacket; + cdev->desc.bcdUSB = cpu_to_le16(0x0200); } value = min(w_length, (u16) sizeof cdev->desc); memcpy(req->buf, &cdev->desc, value); break; case USB_DT_DEVICE_QUALIFIER: - if (!gadget_is_dualspeed(gadget)) + if (!gadget_is_dualspeed(gadget) || + gadget->speed >= USB_SPEED_SUPER) break; device_qual(cdev); value = min_t(int, w_length, sizeof(struct usb_qualifier_descriptor)); break; case USB_DT_OTHER_SPEED_CONFIG: - if (!gadget_is_dualspeed(gadget)) + if (!gadget_is_dualspeed(gadget) || + gadget->speed >= USB_SPEED_SUPER) break; case USB_DT_CONFIG: @@ -1039,10 +1068,16 @@ composite_setup(struct usb_gadget *gadget, const struct usb_ctrlrequest *ctrl) value = min(w_length, (u16) value); break; case USB_DT_BOS: - if (gadget_is_superspeed(cdev->gadget)) + /* + * Super speed connection should support BOS, and + * USB compliance test (USB 2.0 Command Verifier) + * also issues this request, return for now for + * USB 2.0 connection. + */ + if (gadget->speed >= USB_SPEED_SUPER) { value = bos_desc(cdev); - if (value >= 0) value = min(w_length, (u16)value); + } break; default: goto unknown; @@ -1421,7 +1456,7 @@ composite_resume(struct usb_gadget *gadget) } static struct usb_gadget_driver composite_driver = { - .speed = USB_SPEED_HIGH, + .speed = USB_SPEED_SUPER, .bind = composite_bind, .unbind = composite_unbind, diff --git a/include/linux/usb/composite.h b/include/linux/usb/composite.h index d75a0bc4c4..935e5c0cbb 100644 --- a/include/linux/usb/composite.h +++ b/include/linux/usb/composite.h @@ -146,6 +146,7 @@ struct usb_function { struct usb_gadget_strings **strings; struct usb_descriptor_header **descriptors; struct usb_descriptor_header **hs_descriptors; + struct usb_descriptor_header **ss_descriptors; struct usb_configuration *config; @@ -279,6 +280,7 @@ struct usb_configuration { u8 next_interface_id; unsigned highspeed:1; unsigned fullspeed:1; + unsigned superspeed:1; struct usb_function *interface[MAX_CONFIG_INTERFACES]; }; @@ -292,6 +294,7 @@ int usb_add_config(struct usb_composite_dev *, * identifiers. * @strings: tables of strings, keyed by identifiers assigned during bind() * and language IDs provided in control requests + * @max_speed: Highest speed the driver supports. * @bind: (REQUIRED) Used to allocate resources that are shared across the * whole device, such as string IDs, and add its configurations using * @usb_add_config(). This may fail by returning a negative errno @@ -319,6 +322,7 @@ struct usb_composite_driver { const char *name; const struct usb_device_descriptor *dev; struct usb_gadget_strings **strings; + enum usb_device_speed max_speed; /* REVISIT: bind() functions can be marked __init, which * makes trouble for section mismatch analysis. See if diff --git a/include/linux/usb/gadget.h b/include/linux/usb/gadget.h index 8d54b91734..7e6d329e54 100644 --- a/include/linux/usb/gadget.h +++ b/include/linux/usb/gadget.h @@ -449,6 +449,11 @@ static inline void usb_ep_fifo_flush(struct usb_ep *ep) /*-------------------------------------------------------------------------*/ +struct usb_dcd_config_params { + __u8 bU1devExitLat; /* U1 Device exit Latency */ + __le16 bU2DevExitLat; /* U2 Device exit Latency */ +}; + struct usb_gadget; struct usb_gadget_driver; @@ -464,6 +469,7 @@ struct usb_gadget_ops { int (*pullup) (struct usb_gadget *, int is_on); int (*ioctl)(struct usb_gadget *, unsigned code, unsigned long param); + void (*get_config_params)(struct usb_dcd_config_params *); int (*udc_start)(struct usb_gadget *, struct usb_gadget_driver *); int (*udc_stop)(struct usb_gadget *);