From patchwork Tue Oct 29 15:15:14 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Roger Quadros X-Patchwork-Id: 178029 Delivered-To: patch@linaro.org Received: by 2002:a92:409a:0:0:0:0:0 with SMTP id d26csp5017881ill; Tue, 29 Oct 2019 08:15:36 -0700 (PDT) X-Google-Smtp-Source: APXvYqycUs3UItKnW57u2EgvF4wyd+80Gftv/ELNd5A0boMsQ5xD00Jkn+/6NbGZ+gf6wXuUgH/u X-Received: by 2002:a17:906:318e:: with SMTP id 14mr3875350ejy.5.1572362136216; Tue, 29 Oct 2019 08:15:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1572362136; cv=none; d=google.com; s=arc-20160816; b=bXbv8mHXQDKPH/VwYnUx2tH8tIBYPCCxoQmLlJK3FqcJ2iPPsLSG8arjenypjJsB2/ nQZ5OshyF5WLEWlvdIVjtHxxmxoTbeAKB4wNe/0uBxUVcDqfGVXeigb73xhUD9eipqeM wJyng5ogTKwfw8RnYAH6wK6ymsIELs/edKcgZ/Cp2y9ZwsEVBbwiVjwXpvRHOJDQAvCj KHk3IquSGEJE4OItpm6mPKO2ILA+FlOrR9GCCjmrc8XLOdVrf3pmsPytOtzvyJZiSNPj zULxACcvT9d/Vv004l50B3Asm4vlcak5tbbwkwF4KTMOdymOtNkLZ9tf9wLOnBAD6v9u sfHg== 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:dkim-signature; bh=EjyBteXlv8fFNuD+sDu3/51WIDE97L/GH2r4eM1/VIU=; b=xuRRLPjdHFLJneCdxLUrJ51EyCaz2d/mQGec+zYZd0rxpeowDEiuiR4/7518GuUJji 1C/148Kjre+qC5WuLnnfjteRJ1NZOAA3qeFi3+QiC9uMY2R8Nc8mCFK8eM6aWA0eS7h5 2K6rRx4c/YotSZkLekE0skoxFdNA6ZVMPQnzJoxvr1nzsN+ewc9n2jZZXdHA2xk1vlii HINjhd3dsaKgOsp+fK02LPK02mS+zFexzJgh9vNUz8xG+7L1IsD3Dwy9N9kwYwLLlQmM FGw94BVWm9imTsfucqrWafmP8qrER5W/ugRZLP3zZMGo3T7w4rQl4NPjXlUGZrgHp4eC pX3Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=oot3PFX6; 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; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h49si10386882edh.2.2019.10.29.08.15.36; Tue, 29 Oct 2019 08:15:36 -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; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=oot3PFX6; 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; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2390003AbfJ2PPd (ORCPT + 26 others); Tue, 29 Oct 2019 11:15:33 -0400 Received: from lelv0143.ext.ti.com ([198.47.23.248]:60130 "EHLO lelv0143.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388595AbfJ2PPc (ORCPT ); Tue, 29 Oct 2019 11:15:32 -0400 Received: from lelv0266.itg.ti.com ([10.180.67.225]) by lelv0143.ext.ti.com (8.15.2/8.15.2) with ESMTP id x9TFFIwF009724; Tue, 29 Oct 2019 10:15:18 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1572362118; bh=EjyBteXlv8fFNuD+sDu3/51WIDE97L/GH2r4eM1/VIU=; h=From:To:CC:Subject:Date; b=oot3PFX6k2ql4kj9akf+Gf/1g4iR7nF+EYl8sI88me50D9T1lhZI2VVVoERoLPMqt rga57zbqLJqLxxc81xK0rrF/dJivmucyjFYT91RKO3vNFCrtPAc03GQpgl3JAenbcX 2kOMkIJJie6MhoCNeuOObkX+uk3kFGMPH6W/GMug= Received: from DFLE113.ent.ti.com (dfle113.ent.ti.com [10.64.6.34]) by lelv0266.itg.ti.com (8.15.2/8.15.2) with ESMTPS id x9TFFIZe085994 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Tue, 29 Oct 2019 10:15:18 -0500 Received: from DFLE115.ent.ti.com (10.64.6.36) by DFLE113.ent.ti.com (10.64.6.34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1713.5; Tue, 29 Oct 2019 10:15:06 -0500 Received: from fllv0039.itg.ti.com (10.64.41.19) by DFLE115.ent.ti.com (10.64.6.36) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1713.5 via Frontend Transport; Tue, 29 Oct 2019 10:15:05 -0500 Received: from lta0400828a.ti.com (ileax41-snat.itg.ti.com [10.172.224.153]) by fllv0039.itg.ti.com (8.15.2/8.15.2) with ESMTP id x9TFFF3J127253; Tue, 29 Oct 2019 10:15:16 -0500 From: Roger Quadros To: , CC: , , , , , , Roger Quadros Subject: [PATCH] usb: cdns3: gadget: Fix g_audio use case when connected to Super-Speed host Date: Tue, 29 Oct 2019 17:15:14 +0200 Message-ID: <20191029151514.28495-1-rogerq@ti.com> X-Mailer: git-send-email 2.17.1 MIME-Version: 1.0 X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Take into account gadget driver's speed limit when programming controller speed. Signed-off-by: Roger Quadros --- Hi Greg, Please apply this for -rc. Without this, g_audio is broken on cdns3 USB controller is connected to a Super-Speed host. cheers, -roger drivers/usb/cdns3/gadget.c | 31 ++++++++++++++++++++++++++----- 1 file changed, 26 insertions(+), 5 deletions(-) -- Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki. Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki Acked-by: Peter Chen diff --git a/drivers/usb/cdns3/gadget.c b/drivers/usb/cdns3/gadget.c index 40dad4e8d0dc..1c724c20d468 100644 --- a/drivers/usb/cdns3/gadget.c +++ b/drivers/usb/cdns3/gadget.c @@ -2338,9 +2338,35 @@ static int cdns3_gadget_udc_start(struct usb_gadget *gadget, { struct cdns3_device *priv_dev = gadget_to_cdns3_device(gadget); unsigned long flags; + enum usb_device_speed max_speed = driver->max_speed; spin_lock_irqsave(&priv_dev->lock, flags); priv_dev->gadget_driver = driver; + + /* limit speed if necessary */ + max_speed = min(driver->max_speed, gadget->max_speed); + + switch (max_speed) { + case USB_SPEED_FULL: + writel(USB_CONF_SFORCE_FS, &priv_dev->regs->usb_conf); + writel(USB_CONF_USB3DIS, &priv_dev->regs->usb_conf); + break; + case USB_SPEED_HIGH: + writel(USB_CONF_USB3DIS, &priv_dev->regs->usb_conf); + break; + case USB_SPEED_SUPER: + break; + default: + dev_err(priv_dev->dev, + "invalid maximum_speed parameter %d\n", + max_speed); + /* fall through */ + case USB_SPEED_UNKNOWN: + /* default to superspeed */ + max_speed = USB_SPEED_SUPER; + break; + } + cdns3_gadget_config(priv_dev); spin_unlock_irqrestore(&priv_dev->lock, flags); return 0; @@ -2570,12 +2596,7 @@ static int cdns3_gadget_start(struct cdns3 *cdns) /* Check the maximum_speed parameter */ switch (max_speed) { case USB_SPEED_FULL: - writel(USB_CONF_SFORCE_FS, &priv_dev->regs->usb_conf); - writel(USB_CONF_USB3DIS, &priv_dev->regs->usb_conf); - break; case USB_SPEED_HIGH: - writel(USB_CONF_USB3DIS, &priv_dev->regs->usb_conf); - break; case USB_SPEED_SUPER: break; default: