From patchwork Wed Oct 30 12:16:07 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Roger Quadros X-Patchwork-Id: 178103 Delivered-To: patch@linaro.org Received: by 2002:a92:409a:0:0:0:0:0 with SMTP id d26csp1192514ill; Wed, 30 Oct 2019 05:16:31 -0700 (PDT) X-Google-Smtp-Source: APXvYqy/KtKYCsfGPigepLR0CrsG5mDS6txRXi9Wh8z6qVa/YwHdBwHgCzWdkLP7Q9lrGY/EAjSj X-Received: by 2002:aa7:d60c:: with SMTP id c12mr30870333edr.14.1572437791373; Wed, 30 Oct 2019 05:16:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1572437791; cv=none; d=google.com; s=arc-20160816; b=Hc8d0IEm9txKYGG6KRCR0HIzB81D9p4ZGOpnwiOP0IttGrHhSL8BgNEtnVwq93KM5G xzurKiOOqRiq8BqykywM8FI+TYt0sHyRtVX0HOO6/vTqz6ox3rzyhZ292R1CGWW06Z6W ruMwnNznX0g5GwTAM7tqpPpz7tsvZbu5uyOYANU2pBHVIIt5noWqD15Fbl6FapgAMcWR FIT2U7f6TeO80sZKke82YYPXjRzdj6/NiGTR989rHpHSuh6Gt6nETVE9icFu5uw49VNO CICd0IRvcoZ/m+oF6P+cTL0E7/d53jjQZ3Eh19HKSG910JNjMOucnhhcJmnCinFBQWnI ZPlQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=Q6fJp/D85GCtxw/JAkXw+eDiNJA5WY/u3vdZ6m5FFrI=; b=P8zynQlX86sugj4sPTjJAiQrh4mwRaNXAUOdRiCwu5UPwnvWzs+4TmG6d4cQsEV5W4 mcDnSSWMO/0/kXY1gfDeGsDhYWlSn1KB311BmdNcyKE0zPk0pWhT0g0tB7GweTgieaXk PTqElmFSJC7RZ20CFkXjaiCiq5meX7cfFKQKXGHIIESu7Tycg4UI3hcWn1Y3UVjZwj7w fXSFPyq8weEK7R1lCCSS9IX9uo3X8nKjAGNTuq71KgPq1wRE6cq/kV1gvv3D5xhKWjvO +FgOfDoo/DQQKIEbdd7U4FsuACOubknv+7JS73yyGBjZV/OdZPilxS7V3gfH9c67mrCT BCSQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=II6ACmzI; 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 h12si1105689ejd.17.2019.10.30.05.16.31; Wed, 30 Oct 2019 05:16:31 -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=II6ACmzI; 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 S1726859AbfJ3MQ0 (ORCPT + 26 others); Wed, 30 Oct 2019 08:16:26 -0400 Received: from fllv0015.ext.ti.com ([198.47.19.141]:44116 "EHLO fllv0015.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726088AbfJ3MQ0 (ORCPT ); Wed, 30 Oct 2019 08:16:26 -0400 Received: from lelv0266.itg.ti.com ([10.180.67.225]) by fllv0015.ext.ti.com (8.15.2/8.15.2) with ESMTP id x9UCGETt070977; Wed, 30 Oct 2019 07:16:14 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1572437774; bh=Q6fJp/D85GCtxw/JAkXw+eDiNJA5WY/u3vdZ6m5FFrI=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=II6ACmzIya4JLZKfOrRJdQDfE6CwpW4T5yU4qEj/6uRApb8jt7vUMLq5WzjzuElSZ rkGvKIse5Bg17YntxpM2ZKyAp3q+uUm70lJicmQNmEoNUvqrOkVbnNKZZhJPXdbnKK hLZI+rtsG+tgzzHqzoKpxaY9WAVJ1bG6cBHAy/Tw= Received: from DLEE115.ent.ti.com (dlee115.ent.ti.com [157.170.170.26]) by lelv0266.itg.ti.com (8.15.2/8.15.2) with ESMTPS id x9UCGDRZ003977 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Wed, 30 Oct 2019 07:16:13 -0500 Received: from DLEE104.ent.ti.com (157.170.170.34) by DLEE115.ent.ti.com (157.170.170.26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1713.5; Wed, 30 Oct 2019 07:16:12 -0500 Received: from fllv0040.itg.ti.com (10.64.41.20) by DLEE104.ent.ti.com (157.170.170.34) 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; Wed, 30 Oct 2019 07:16:00 -0500 Received: from lta0400828a.ti.com (ileax41-snat.itg.ti.com [10.172.224.153]) by fllv0040.itg.ti.com (8.15.2/8.15.2) with ESMTP id x9UCG9vT062301; Wed, 30 Oct 2019 07:16:10 -0500 From: Roger Quadros To: , CC: , , , , , , Roger Quadros Subject: [PATCH v2] usb: cdns3: gadget: Fix g_audio use case when connected to Super-Speed host Date: Wed, 30 Oct 2019 14:16:07 +0200 Message-ID: <20191030121607.21739-1-rogerq@ti.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191029151514.28495-1-rogerq@ti.com> References: <20191029151514.28495-1-rogerq@ti.com> 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. Fixes: commit 7733f6c32e36 ("usb: cdns3: Add Cadence USB3 DRD Driver") Signed-off-by: Roger Quadros Acked-by: Peter Chen --- Changelog: v2 - Add Fixes line 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 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: