From patchwork Mon Nov 17 23:19:54 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jorge Ramirez-Ortiz X-Patchwork-Id: 40981 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wi0-f200.google.com (mail-wi0-f200.google.com [209.85.212.200]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 5479321F5F for ; Mon, 17 Nov 2014 23:20:03 +0000 (UTC) Received: by mail-wi0-f200.google.com with SMTP id ex7sf3853862wid.11 for ; Mon, 17 Nov 2014 15:20:02 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:message-id:date:from:user-agent :mime-version:to:subject:sender:precedence:list-id:x-original-sender :x-original-authentication-results:mailing-list:list-post:list-help :list-archive:list-unsubscribe:content-type :content-transfer-encoding; bh=oB8RctI6ZJEcQhqpHUojbCm/nksWW71IaAUSt1v5FJA=; b=Is244yzJaa2ZGFUc9W0oEXRPOfHqfNrwmH3BYcHVi6AUg/9P+uPMl92I5byZMZBYIS qmoeVO5Tjve/N76XMrFFXjhZPTvudW4i6wUmpa0brrv15NuVshEYj10DP6cWPlqfOInK NTVQSqnW+6W/Nso2Bko3Q4tWe0TgOhN4E3TLE6waSdGT7h26YLrUuWy8hcWv44+ano4L x4wqO37gN74hn+ToICRxCrfF3nD60seiCOuD8tEtdahzWRKj+f4e3hqrIRmaJfkEtwMA 6+TnFMDViOpn5gjV4tCOIcNs7YZc1HXC0udtsULmfawWve1VwTAlRaanFRAuEG7s6al6 GPxg== X-Gm-Message-State: ALoCoQmZEp+Qg5RtN4j/IiYO+5ZLNi0OTioMlXWmca3N2NA6Er1b+MBfR5ATfiSn35GxWOaJG96k X-Received: by 10.112.147.131 with SMTP id tk3mr8209204lbb.2.1416266402529; Mon, 17 Nov 2014 15:20:02 -0800 (PST) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.202.166 with SMTP id kj6ls1034115lac.73.gmail; Mon, 17 Nov 2014 15:20:02 -0800 (PST) X-Received: by 10.112.57.227 with SMTP id l3mr31309912lbq.68.1416266402193; Mon, 17 Nov 2014 15:20:02 -0800 (PST) Received: from mail-lb0-f181.google.com (mail-lb0-f181.google.com. [209.85.217.181]) by mx.google.com with ESMTPS id j6si53619969laa.71.2014.11.17.15.20.01 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 17 Nov 2014 15:20:01 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.181 as permitted sender) client-ip=209.85.217.181; Received: by mail-lb0-f181.google.com with SMTP id l4so16611774lbv.40 for ; Mon, 17 Nov 2014 15:20:01 -0800 (PST) X-Received: by 10.152.37.69 with SMTP id w5mr30913965laj.67.1416266401712; Mon, 17 Nov 2014 15:20:01 -0800 (PST) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.184.201 with SMTP id ew9csp1247098lbc; Mon, 17 Nov 2014 15:20:00 -0800 (PST) X-Received: by 10.68.68.227 with SMTP id z3mr11734997pbt.3.1416266399979; Mon, 17 Nov 2014 15:19:59 -0800 (PST) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id sa1si36289873pbc.195.2014.11.17.15.19.59 for ; Mon, 17 Nov 2014 15:19:59 -0800 (PST) Received-SPF: none (google.com: linux-usb-owner@vger.kernel.org does not designate permitted sender hosts) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753220AbaKQXT6 (ORCPT + 3 others); Mon, 17 Nov 2014 18:19:58 -0500 Received: from mail-ie0-f177.google.com ([209.85.223.177]:58317 "EHLO mail-ie0-f177.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753018AbaKQXT5 (ORCPT ); Mon, 17 Nov 2014 18:19:57 -0500 Received: by mail-ie0-f177.google.com with SMTP id tr6so3807192ieb.8 for ; Mon, 17 Nov 2014 15:19:56 -0800 (PST) X-Received: by 10.107.150.9 with SMTP id y9mr8841723iod.25.1416266396222; Mon, 17 Nov 2014 15:19:56 -0800 (PST) Received: from [192.168.1.167] (cpe-67-247-86-207.rochester.res.rr.com. [67.247.86.207]) by mx.google.com with ESMTPSA id kb7sm6686794igb.16.2014.11.17.15.19.55 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 17 Nov 2014 15:19:55 -0800 (PST) Message-ID: <546A829A.8030106@linaro.org> Date: Mon, 17 Nov 2014 18:19:54 -0500 From: Jorge Ramirez-Ortiz User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.2.0 MIME-Version: 1.0 To: linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] usb: gadget: USB3 support to the legacy printer driver Sender: linux-usb-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-usb@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: jorge.ramirez-ortiz@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.181 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , Hi, This patch adds USB3 support to the legacy gadget printer driver. Applies cleanly on fc14f9c Linux 3.18-rc5. Please could it be considered for inclusion? regards, Jorge >From f46d9b0d2160b30f14dee104657de865e9e2bc38 Mon Sep 17 00:00:00 2001 From: Jorge Ramirez-Ortiz Date: Thu, 25 Sep 2014 16:17:20 -0400 Subject: [PATCH] usb: gadget: add USB3 support to the printer driver Add SS descriptors to support the capabilities provided by USB3 controller drivers; unit tests run using PLX 3380 [max transfer speed measured of 1Gbps] This driver will fallback to lower operating modes when the higher ones are not available. Signed-off-by: Jorge Ramirez-Ortiz --- drivers/usb/gadget/legacy/printer.c | 66 +++++++++++++++++++++++++++++++++---- 1 file changed, 60 insertions(+), 6 deletions(-) diff --git a/drivers/usb/gadget/legacy/printer.c b/drivers/usb/gadget/legacy/printer.c index 6474081..625d905 100644 --- a/drivers/usb/gadget/legacy/printer.c +++ b/drivers/usb/gadget/legacy/printer.c @@ -3,6 +3,7 @@ * * Copyright (C) 2003-2005 David Brownell * Copyright (C) 2006 Craig W. Nadler + * Copyright (C) 2014 Linaro.org * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -208,6 +209,43 @@ static struct usb_descriptor_header *hs_printer_function[] = { NULL }; +/* + * Added endpoint descriptors for 3.0 devices + */ + +static struct usb_endpoint_descriptor ss_ep_in_desc = { + .bLength = USB_DT_ENDPOINT_SIZE, + .bDescriptorType = USB_DT_ENDPOINT, + .bmAttributes = USB_ENDPOINT_XFER_BULK, + .wMaxPacketSize = cpu_to_le16(1024), +}; + +struct usb_ss_ep_comp_descriptor ss_ep_in_comp_desc = { + .bLength = sizeof(ss_ep_in_comp_desc), + .bDescriptorType = USB_DT_SS_ENDPOINT_COMP, +}; + +static struct usb_endpoint_descriptor ss_ep_out_desc = { + .bLength = USB_DT_ENDPOINT_SIZE, + .bDescriptorType = USB_DT_ENDPOINT, + .bmAttributes = USB_ENDPOINT_XFER_BULK, + .wMaxPacketSize = cpu_to_le16(1024), +}; + +struct usb_ss_ep_comp_descriptor ss_ep_out_comp_desc = { + .bLength = sizeof(ss_ep_out_comp_desc), + .bDescriptorType = USB_DT_SS_ENDPOINT_COMP, +}; + +static struct usb_descriptor_header *ss_printer_function[] = { + (struct usb_descriptor_header *) &intf_desc, + (struct usb_descriptor_header *) &ss_ep_in_desc, + (struct usb_descriptor_header *) &ss_ep_in_comp_desc, + (struct usb_descriptor_header *) &ss_ep_out_desc, + (struct usb_descriptor_header *) &ss_ep_out_comp_desc, + NULL +}; + static struct usb_otg_descriptor otg_descriptor = { .bLength = sizeof otg_descriptor, .bDescriptorType = USB_DT_OTG, @@ -220,7 +258,20 @@ static const struct usb_descriptor_header *otg_desc[] = { }; /* maxpacket and other transfer characteristics vary by speed. */ -#define ep_desc(g, hs, fs) (((g)->speed == USB_SPEED_HIGH)?(hs):(fs)) +static inline struct usb_endpoint_descriptor *ep_desc(struct usb_gadget *gadget, + struct usb_endpoint_descriptor *fs, + struct usb_endpoint_descriptor *hs, + struct usb_endpoint_descriptor *ss) +{ + struct usb_endpoint_descriptor *d = fs; + + if (gadget->speed == USB_SPEED_SUPER) + d = ss; + else if (gadget->speed == USB_SPEED_HIGH) + d = hs; + + return d; +} /*-------------------------------------------------------------------------*/ @@ -793,11 +844,12 @@ set_printer_interface(struct printer_dev *dev) { int result = 0; - dev->in_ep->desc = ep_desc(dev->gadget, &hs_ep_in_desc, &fs_ep_in_desc); + dev->in_ep->desc = ep_desc(dev->gadget, &fs_ep_in_desc, &hs_ep_in_desc, + &ss_ep_in_desc); dev->in_ep->driver_data = dev; - dev->out_ep->desc = ep_desc(dev->gadget, &hs_ep_out_desc, - &fs_ep_out_desc); + dev->out_ep->desc = ep_desc(dev->gadget, &fs_ep_out_desc, + &hs_ep_out_desc, &ss_ep_out_desc); dev->out_ep->driver_data = dev; result = usb_ep_enable(dev->in_ep); @@ -1016,9 +1068,11 @@ autoconf_fail: /* assumes that all endpoints are dual-speed */ hs_ep_in_desc.bEndpointAddress = fs_ep_in_desc.bEndpointAddress; hs_ep_out_desc.bEndpointAddress = fs_ep_out_desc.bEndpointAddress; + ss_ep_in_desc.bEndpointAddress = fs_ep_in_desc.bEndpointAddress; + ss_ep_out_desc.bEndpointAddress = fs_ep_out_desc.bEndpointAddress; ret = usb_assign_descriptors(f, fs_printer_function, - hs_printer_function, NULL); + hs_printer_function, ss_printer_function); if (ret) return ret; @@ -1253,7 +1307,7 @@ static __refdata struct usb_composite_driver printer_driver = { .name = shortname, .dev = &device_desc, .strings = dev_strings, - .max_speed = USB_SPEED_HIGH, + .max_speed = USB_SPEED_SUPER, .bind = printer_bind, .unbind = printer_unbind, };