From patchwork Sun Jul 26 01:35:51 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thinh Nguyen X-Patchwork-Id: 11685395 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C0F6B1709 for ; Sun, 26 Jul 2020 01:35:59 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 9D169206D7 for ; Sun, 26 Jul 2020 01:35:59 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=synopsys.com header.i=@synopsys.com header.b="Hw9N2mCe" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727013AbgGZBf5 (ORCPT ); Sat, 25 Jul 2020 21:35:57 -0400 Received: from smtprelay-out1.synopsys.com ([149.117.87.133]:44704 "EHLO smtprelay-out1.synopsys.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726870AbgGZBf4 (ORCPT ); Sat, 25 Jul 2020 21:35:56 -0400 Received: from mailhost.synopsys.com (sv1-mailhost2.synopsys.com [10.205.2.132]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by smtprelay-out1.synopsys.com (Postfix) with ESMTPS id 8FBD8C00A4; Sun, 26 Jul 2020 01:35:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=synopsys.com; s=mail; t=1595727356; bh=iTGwTIakwO2wPklsQCqfd8dwj5JlgJ0LzsAMUzYaE94=; h=Date:From:Subject:To:Cc:From; b=Hw9N2mCeeN1O0nk07w5TlrtqtwQQXg7ksDNidoYsYACgEhiNubO8eEnA3MvbsElkh /4FVFChHo/GhtIlXA8sv1H44Y8/xaZFf/JRMRgmyKLy0wLB90S+NKSscmlfIrqRNI+ EvWbGGka1sM5ccmJRuK3gcB0ZPRnIbVY/WmjSAsCGD0T4ny/ggKTx4cFhk8XCrLrl8 1RR4bFyTfo7iBvjPtA3ZSZKPUWzho4bACtCapUR0l4kUcsnEbVNgpETFkFul5C69lo cpp9DW3vZXrT0HhTd9cIuaKkuIJ4IvnaT7rfGV9GQ6WO1o2zRx2TDfueZjpNx9HiCM ParlaBNHpECoA== Received: from te-lab16 (nanobot.internal.synopsys.com [10.10.186.99]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mailhost.synopsys.com (Postfix) with ESMTPSA id 2B6EFA0070; Sun, 26 Jul 2020 01:35:51 +0000 (UTC) Received: by te-lab16 (sSMTP sendmail emulation); Sat, 25 Jul 2020 18:35:51 -0700 Date: Sat, 25 Jul 2020 18:35:51 -0700 Message-Id: X-SNPS-Relay: synopsys.com From: Thinh Nguyen Subject: [PATCH v4 00/12] usb: Handle different sublink speeds To: Felipe Balbi , Greg Kroah-Hartman , Thinh Nguyen , linux-usb@vger.kernel.org, devicetree@vger.kernel.org, Rob Herring , Peter Chen , Lee Jones , Alan Stern , Dejin Zheng , Roger Quadros Cc: John Youn Sender: linux-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org A USB super-speed-plus device may operate at different sublink speed and lane count (e.g. gen2x2, gen1x2, or gen2x1). The usb gadget stack needs to be able to handle a couple things: 1) Report the sublink speed attributes the device support 2) Select the sublink speed attribute This series introduces sublink speed attribute structure to ch9.h to capture the device capability of the gadget. It also introduces a new gadget ops udc_set_num_lanes_and_speed to select a specific sublink speed. DWC3 needs this support for DWC_usb32 IP. Implement the new changes for DWC3. Changes in v4: - Instead of using a single function to parse "maximum-speed" property for speed, gen X, and number of lanes, split those tasks to separate common functions - Revise DWC3 driver to use those new common functions - Fix checkpatch warnings for using "unsigned" rather than "unsigned int" and missing identifier name in udc_set_num_lanes_and_speed gadget ops Changes in v3: - Remove "num-lanes" and "lane-speed-mantissa-gbps" common properties - Remove "num-lanes" and "lane-speed-mantissa-gbps" properties validation in dwc3 - Update "maximum-speed" to support variations of SSP Gen X x Y - Update common function to parse new strings for "maximum-speed" - Update commit messages for the new changes Changes in v2: - Move usb_sublink_speed attribute struct and enum to include/linux/usb/ch9.h - Use "num-lanes" and "lane-speed-mantissa-gbps" as common properties instead - Add common functions to get num-lanes and lsm properties - Fix missing gen1x2 sublink speed attribute check report in dwc3 Thinh Nguyen (12): usb: ch9: Add sublink speed struct usb: gadget: composite: Avoid using magic numbers usb: gadget: Expose sublink speed attributes usb: gadget: Set max speed for SSP devices usb: composite: Properly report sublink speed usb: devicetree: Include USB SSP Gen X x Y usb: common: Add and update common functions for SSP speeds usb: dwc3: Initialize lane count and sublink speed usb: dwc3: gadget: Report sublink speed capability usb: dwc3: gadget: Implement setting of sublink speed usb: dwc3: gadget: Track connected lane and sublink speed usb: dwc3: gadget: Set speed only up to the max supported Documentation/devicetree/bindings/usb/generic.txt | 11 +- drivers/usb/common/common.c | 46 ++++++- drivers/usb/dwc3/core.c | 29 +++++ drivers/usb/dwc3/core.h | 14 +++ drivers/usb/dwc3/gadget.c | 143 +++++++++++++++++++++- drivers/usb/gadget/composite.c | 81 ++++++++---- drivers/usb/gadget/udc/core.c | 24 +++- include/linux/usb/ch9.h | 73 +++++++++++ include/linux/usb/gadget.h | 23 ++++ 9 files changed, 403 insertions(+), 41 deletions(-) base-commit: a1ff2f6769e39055e973b068070aeea0b3bcd90f