Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp5644394imm; Mon, 23 Jul 2018 03:34:09 -0700 (PDT) X-Google-Smtp-Source: AAOMgpdDEgWOzvjzyfg9dp9AB7g7DNqePybWJJMJlmSk3AFokI38W0Wnfus4v8Rw9MrrZfD8H1Ra X-Received: by 2002:a62:9bc5:: with SMTP id e66-v6mr12586040pfk.84.1532342048986; Mon, 23 Jul 2018 03:34:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1532342048; cv=none; d=google.com; s=arc-20160816; b=y1LSoahaX+l3uvsVYsZKm534p6I9Cy6pc8kd9iTZc7WRDkztd9WKUj9xY9F/ZkgTNC IkWGzbDEgVi2EBf93MhUTP7ROxNX8HGyoN5NTPEbbuCiwxLTreqJwKlxXoy5UCDy0ARM XITdR7eC7ByYUX/Fr4bfZ0/7xMFhna/hLXV4jrEmstQCQsSfrQUw35UA1ySOxBGknXjH 7cdjz0qs83XNiyMQ0qDcThofykYs7vwXvLjoXhWsaAa7+dXArsoPXPFZYqRSvLlJ5UjG FKzyA+zD82+sW4IL1FGcBhBfBcZdG8KgbjsfB9vSkwyY2aH+7SrGyoWV+1Y0btfUsvHK tHag== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=+SL+DE8aO2S0oS2ZOImHMNK17b/mKZmzoa03PiVV1QU=; b=0/hkkw28o8tN6iZkd/FV79gFulwe8FRVrgh1kuQSb4AUCl0qodXPbmXbQ091pbz2yU gjrLENLhIDSq2BO0H6vIIJ9LXRGVR8ED/ifJRZaOhJtYrQ5CpEK/LbckhOTX655ttEb/ gP89fSmhymTZyFim5GPgdfyhl3iNEs0oQ5gEeV+aoBWukFzgD4YaPXg0vXjFXYwXgY5T KN/ZNmBE+lLe3BBhGZdQDELsJWTphb5b90UekM+tkvsik6/pwc91LQg5IJHUuD7Fyhs/ WkA5rO+ywpYA72YoBZOqflVIMPOrYN6WPXkSkYOV4WR/wURdL1Ad/fuRwvlP5/kbO0C6 Y4cQ== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=nxp.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g6-v6si2743263plo.280.2018.07.23.03.33.54; Mon, 23 Jul 2018 03:34:08 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=nxp.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388209AbeGWLd3 (ORCPT + 99 others); Mon, 23 Jul 2018 07:33:29 -0400 Received: from inva021.nxp.com ([92.121.34.21]:56450 "EHLO inva021.nxp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388056AbeGWLd3 (ORCPT ); Mon, 23 Jul 2018 07:33:29 -0400 Received: from inva021.nxp.com (localhost [127.0.0.1]) by inva021.eu-rdc02.nxp.com (Postfix) with ESMTP id DC93520002E; Mon, 23 Jul 2018 12:32:54 +0200 (CEST) Received: from smtp.na-rdc02.nxp.com (inv1260.us-phx01.nxp.com [134.27.49.11]) by inva021.eu-rdc02.nxp.com (Postfix) with ESMTP id 7971020008A; Mon, 23 Jul 2018 12:32:54 +0200 (CEST) Received: from az84smr01.freescale.net (az84smr01.freescale.net [10.64.34.197]) by inv1260.na-rdc02.nxp.com (Postfix) with ESMTP id E07C740C72; Mon, 23 Jul 2018 03:32:53 -0700 (MST) Received: from mega.am.freescale.net ([10.192.208.232]) by az84smr01.freescale.net (8.14.3/8.14.0) with ESMTP id w6NAWluB028031; Mon, 23 Jul 2018 03:32:51 -0700 From: Pengbo Mu To: Felipe Balbi , Rob Herring , Mark Rutland , Catalin Marinas , Will Deacon , Greg Kroah-Hartman Cc: linux-kernel@vger.kernel.org, linux-usb@vger.kernel.org, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, ran.wang_1@nxp.com, pengbo.mu@nxp.com Subject: [PATCH v6 2/4] usb: dwc3: Enable undefined length INCR burst type Date: Mon, 23 Jul 2018 18:32:37 +0800 Message-Id: <1532341959-3478-2-git-send-email-pengbo.mu@nxp.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1532341959-3478-1-git-send-email-pengbo.mu@nxp.com> References: <1532341959-3478-1-git-send-email-pengbo.mu@nxp.com> X-Virus-Scanned: ClamAV using ClamSMTP Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Enable the undefined length INCR burst type and set INCRx. Different platform may has the different burst size type. In order to get best performance, we need to tune the burst size to one special value, instead of the default value. Signed-off-by: Changming Huang Signed-off-by: Ran Wang Signed-off-by: Pengbo Mu --- Changes in v6: - rename 'dwc3_set_soc_bus_cfg' to 'dwc3_set_incr_burst_type' - modify the codes according to the definition of GSBUSCFG0 - change variables from global to local - add the judgment of 'ntype <= 0' Changes in v5: - no change Changes in v4: - Modify the codes according to the definition of this property. Changes in v3: - add new property for INCR burst in usb node to reset GSBUSCFG0. Changes in v2: - split patch - create one new function to handle soc bus configuration register. --- drivers/usb/dwc3/core.c | 94 +++++++++++++++++++++++++++++++++++++++++++++++++ drivers/usb/dwc3/core.h | 3 ++ 2 files changed, 97 insertions(+) diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c index 1038075..21e4931 100644 --- a/drivers/usb/dwc3/core.c +++ b/drivers/usb/dwc3/core.c @@ -778,6 +778,98 @@ static void dwc3_core_setup_global_control(struct dwc3 *dwc) static int dwc3_core_get_phy(struct dwc3 *dwc); static int dwc3_core_ulpi_init(struct dwc3 *dwc); +/* set global incr burst type configuration registers */ +static void dwc3_set_incr_burst_type(struct dwc3 *dwc) +{ + struct device *dev = dwc->dev; + /* incrx_mode : for INCR burst type. */ + bool incrx_mode; + /* incrx_size : for size of INCRX burst. */ + u32 incrx_size; + u32 *vals; + u32 cfg; + int ntype; + int ret; + int i; + + cfg = dwc3_readl(dwc->regs, DWC3_GSBUSCFG0); + + /* + * Handle property "snps,incr-burst-type-adjustment". + * Get the number of value from this property: + * result <= 0, means this property is not supported. + * result = 1, means INCRx burst mode supported. + * result > 1, means undefined length burst mode supported. + */ + ntype = device_property_read_u32_array(dev, + "snps,incr-burst-type-adjustment", NULL, 0); + if (ntype <= 0) + return; + + vals = kcalloc(ntype, sizeof(u32), GFP_KERNEL); + if (!vals) { + dev_err(dev, "Error to get memory\n"); + return; + } + + /* Get INCR burst type, and parse it */ + ret = device_property_read_u32_array(dev, + "snps,incr-burst-type-adjustment", vals, ntype); + if (ret) { + dev_err(dev, "Error to get property\n"); + return; + } + + incrx_size = *vals; + + if (ntype > 1) { + /* INCRX (undefined length) burst mode */ + incrx_mode = INCRX_UNDEF_LENGTH_BURST_MODE; + for (i = 1; i < ntype; i++) { + if (vals[i] > incrx_size) + incrx_size = vals[i]; + } + } else { + /* INCRX burst mode */ + incrx_mode = INCRX_BURST_MODE; + } + + /* Enable Undefined Length INCR Burst and Enable INCRx Burst */ + cfg &= ~DWC3_GSBUSCFG0_INCRBRST_MASK; + if (incrx_mode) + cfg |= DWC3_GSBUSCFG0_INCRBRSTENA; + switch (incrx_size) { + case 256: + cfg |= DWC3_GSBUSCFG0_INCR256BRSTENA; + break; + case 128: + cfg |= DWC3_GSBUSCFG0_INCR128BRSTENA; + break; + case 64: + cfg |= DWC3_GSBUSCFG0_INCR64BRSTENA; + break; + case 32: + cfg |= DWC3_GSBUSCFG0_INCR32BRSTENA; + break; + case 16: + cfg |= DWC3_GSBUSCFG0_INCR16BRSTENA; + break; + case 8: + cfg |= DWC3_GSBUSCFG0_INCR8BRSTENA; + break; + case 4: + cfg |= DWC3_GSBUSCFG0_INCR4BRSTENA; + break; + case 1: + break; + default: + dev_err(dev, "Invalid property\n"); + break; + } + + dwc3_writel(dwc->regs, DWC3_GSBUSCFG0, cfg); +} + /** * dwc3_core_init - Low-level initialization of DWC3 Core * @dwc: Pointer to our controller context structure @@ -840,6 +932,8 @@ static int dwc3_core_init(struct dwc3 *dwc) /* Adjust Frame Length */ dwc3_frame_length_adjustment(dwc); + dwc3_set_incr_burst_type(dwc); + usb_phy_set_suspend(dwc->usb2_phy, 0); usb_phy_set_suspend(dwc->usb3_phy, 0); ret = phy_power_on(dwc->usb2_generic_phy); diff --git a/drivers/usb/dwc3/core.h b/drivers/usb/dwc3/core.h index 213b939..5f14fb7 100644 --- a/drivers/usb/dwc3/core.h +++ b/drivers/usb/dwc3/core.h @@ -1168,6 +1168,9 @@ struct dwc3 { u16 imod_interval; }; +#define INCRX_BURST_MODE 0 +#define INCRX_UNDEF_LENGTH_BURST_MODE 1 + #define work_to_dwc(w) (container_of((w), struct dwc3, drd_work)) /* -------------------------------------------------------------------------- */ -- 2.7.4