Received: by 2002:a25:31c3:0:0:0:0:0 with SMTP id x186csp797923ybx; Wed, 30 Oct 2019 05:18:00 -0700 (PDT) X-Google-Smtp-Source: APXvYqwrenGLrZMxMT0vNcN8Iso44QAASdD8xxM9uVr2PsfS82IRovtgjs4raTAZUIFtkjF+Nr+g X-Received: by 2002:a17:907:1189:: with SMTP id uz9mr8545689ejb.201.1572437880352; Wed, 30 Oct 2019 05:18:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1572437880; cv=none; d=google.com; s=arc-20160816; b=LT6WBYpZktCPzvJsP2+AQculR8PLctEvWNx0458dWAb50i6Q+u9oQnrhgZgdXddUa0 Ooop3ZAgxqBJgcJ68I+THr6Racl050irf08624jkdggtPJ+jpauCmjErE1xVxGO2l+R4 d60YLZNMetKIRJhSh9CTVbPN/hpmawLHPVpT5sdQ01CpA3wIz7DsqIKjW/bnEN9AyTlG JD3AMaJfg7OOsk0uFdJKxniENChkCDVXe/lj9SiOZ059m9HZaRM8TNs1hwS7OpHBQUzo FxcLsdyTgv2/P5PIDSOQmqyzJ9aZrEnls4FsvAUDftRxwBldmgdvpGWJwX8dUHvABxrP kJrQ== 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 l15si1056638ejp.114.2019.10.30.05.17.36; Wed, 30 Oct 2019 05:18:00 -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 S1726846AbfJ3MQ0 (ORCPT + 99 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 Content-Type: text/plain 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(-) 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: -- Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki. Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki