From patchwork Mon Jun 2 14:53:55 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexey Brodkin X-Patchwork-Id: 354957 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 135B61400AB for ; Tue, 3 Jun 2014 00:54:30 +1000 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755206AbaFBOyO (ORCPT ); Mon, 2 Jun 2014 10:54:14 -0400 Received: from smtprelay.synopsys.com ([198.182.44.111]:35503 "EHLO smtprelay.synopsys.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754627AbaFBOyM (ORCPT ); Mon, 2 Jun 2014 10:54:12 -0400 Received: from us02secmta2.synopsys.com (us02secmta2.synopsys.com [10.12.235.98]) by smtprelay.synopsys.com (Postfix) with ESMTP id 8B05A24E0F46; Mon, 2 Jun 2014 07:54:11 -0700 (PDT) Received: from us02secmta2.internal.synopsys.com (us02secmta2.internal.synopsys.com [127.0.0.1]) by us02secmta2.internal.synopsys.com (Service) with ESMTP id 4F01055F15; Mon, 2 Jun 2014 07:54:11 -0700 (PDT) Received: from mailhost.synopsys.com (mailhost1.synopsys.com [10.12.238.239]) by us02secmta2.internal.synopsys.com (Service) with ESMTP id 0AAB355F02; Mon, 2 Jun 2014 07:54:11 -0700 (PDT) Received: from mailhost.synopsys.com (localhost [127.0.0.1]) by mailhost.synopsys.com (Postfix) with ESMTP id E85E1F7; Mon, 2 Jun 2014 07:54:10 -0700 (PDT) Received: from abrodkin-8560l.internal.synopsys.com (abrodkin-8560l.internal.synopsys.com [10.121.8.62]) by mailhost.synopsys.com (Postfix) with ESMTP id 623FCEA; Mon, 2 Jun 2014 07:54:07 -0700 (PDT) From: Alexey Brodkin To: netdev@vger.kernel.org Cc: Alexey Brodkin , "David S. Miller" , Hans de Goede , Giuseppe Cavallaro , Chen-Yu Tsai , linux-kernel@vger.kernel.org, devicetree-discuss@lists.ozlabs.org, Vineet Gupta Subject: [PATCH] stmmac: add DMA initialization delay to device tree Date: Mon, 2 Jun 2014 18:53:55 +0400 Message-Id: <1401720835-21507-1-git-send-email-abrodkin@synopsys.com> X-Mailer: git-send-email 1.9.3 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org On some platforms existing 100 msecond delay is not enough for DMA block to recover after reset. For example MAC DMA waits for all PHY input clocks are present and depending on the board reset bit deassertion may take different amount of time. Having this parameter easily configurable allows each board to have its own value, while all exisiting boards will continue to use current default value of 100 msec. Signed-off-by: Alexey Brodkin Cc: David S. Miller Cc: Hans de Goede Cc: Giuseppe Cavallaro Cc: Chen-Yu Tsai Cc: linux-kernel@vger.kernel.org Cc: devicetree-discuss@lists.ozlabs.org Cc: Vineet Gupta --- Documentation/devicetree/bindings/net/stmmac.txt | 2 ++ drivers/net/ethernet/stmicro/stmmac/common.h | 5 ++++- drivers/net/ethernet/stmicro/stmmac/dwmac1000_dma.c | 5 ++--- drivers/net/ethernet/stmicro/stmmac/dwmac100_dma.c | 5 ++--- drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 3 ++- drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c | 8 ++++++++ include/linux/stmmac.h | 1 + 7 files changed, 21 insertions(+), 8 deletions(-) diff --git a/Documentation/devicetree/bindings/net/stmmac.txt b/Documentation/devicetree/bindings/net/stmmac.txt index a2acd2b..1e28772 100644 --- a/Documentation/devicetree/bindings/net/stmmac.txt +++ b/Documentation/devicetree/bindings/net/stmmac.txt @@ -20,6 +20,7 @@ Required properties: - snps,pbl Programmable Burst Length - snps,fixed-burst Program the DMA to use the fixed burst mode - snps,mixed-burst Program the DMA to use the mixed burst mode +- snps,dma-init-delay Maximum delay for DMA initialization in milliseconds - snps,force_thresh_dma_mode Force DMA to use the threshold mode for both tx and rx - snps,force_sf_dma_mode Force DMA to use the Store and Forward @@ -49,4 +50,5 @@ Examples: phy-mode = "gmii"; clocks = <&clock>; clock-names = "stmmaceth">; + dma-init-delay = <1000>; }; diff --git a/drivers/net/ethernet/stmicro/stmmac/common.h b/drivers/net/ethernet/stmicro/stmmac/common.h index 74610f3..1a17080 100644 --- a/drivers/net/ethernet/stmicro/stmmac/common.h +++ b/drivers/net/ethernet/stmicro/stmmac/common.h @@ -294,6 +294,8 @@ struct dma_features { #define JUMBO_LEN 9000 +#define DMA_INIT_DELAY 100 + struct stmmac_desc_ops { /* DMA RX descriptor ring initialization */ void (*init_rx_desc) (struct dma_desc *p, int disable_rx_ic, int mode, @@ -344,7 +346,8 @@ struct stmmac_desc_ops { struct stmmac_dma_ops { /* DMA core initialization */ int (*init) (void __iomem *ioaddr, int pbl, int fb, int mb, - int burst_len, u32 dma_tx, u32 dma_rx, int atds); + int burst_len, u32 dma_tx, u32 dma_rx, int atds, + int init_delay); /* Dump DMA registers */ void (*dump_regs) (void __iomem *ioaddr); /* Set tx/rx threshold in the csr6 register diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac1000_dma.c b/drivers/net/ethernet/stmicro/stmmac/dwmac1000_dma.c index 0c2058a..adaa1d3 100644 --- a/drivers/net/ethernet/stmicro/stmmac/dwmac1000_dma.c +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac1000_dma.c @@ -31,15 +31,14 @@ #include "dwmac_dma.h" static int dwmac1000_dma_init(void __iomem *ioaddr, int pbl, int fb, int mb, - int burst_len, u32 dma_tx, u32 dma_rx, int atds) + int burst_len, u32 dma_tx, u32 dma_rx, int atds, + int limit) { u32 value = readl(ioaddr + DMA_BUS_MODE); - int limit; /* DMA SW reset */ value |= DMA_BUS_MODE_SFT_RESET; writel(value, ioaddr + DMA_BUS_MODE); - limit = 10; while (limit--) { if (!(readl(ioaddr + DMA_BUS_MODE) & DMA_BUS_MODE_SFT_RESET)) break; diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac100_dma.c b/drivers/net/ethernet/stmicro/stmmac/dwmac100_dma.c index 7d1dce9..595e450 100644 --- a/drivers/net/ethernet/stmicro/stmmac/dwmac100_dma.c +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac100_dma.c @@ -33,15 +33,14 @@ #include "dwmac_dma.h" static int dwmac100_dma_init(void __iomem *ioaddr, int pbl, int fb, int mb, - int burst_len, u32 dma_tx, u32 dma_rx, int atds) + int burst_len, u32 dma_tx, u32 dma_rx, int atds, + int limit) { u32 value = readl(ioaddr + DMA_BUS_MODE); - int limit; /* DMA SW reset */ value |= DMA_BUS_MODE_SFT_RESET; writel(value, ioaddr + DMA_BUS_MODE); - limit = 10; while (limit--) { if (!(readl(ioaddr + DMA_BUS_MODE) & DMA_BUS_MODE_SFT_RESET)) break; diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c index 110ca1c..79b7d64 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c @@ -1567,7 +1567,8 @@ static int stmmac_init_dma_engine(struct stmmac_priv *priv) return priv->hw->dma->init(priv->ioaddr, pbl, fixed_burst, mixed_burst, burst_len, priv->dma_tx_phy, - priv->dma_rx_phy, atds); + priv->dma_rx_phy, atds, + priv->plat->dma_cfg->init_delay); } /** diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c index 46aef510..e5743c9 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c @@ -153,6 +153,14 @@ static int stmmac_probe_config_dt(struct platform_device *pdev, of_property_read_bool(np, "snps,fixed-burst"); dma_cfg->mixed_burst = of_property_read_bool(np, "snps,mixed-burst"); + + if (of_property_read_u32(np, "dma-init-delay", + &dma_cfg->init_delay)) + dma_cfg->init_delay = DMA_INIT_DELAY; + dma_cfg->init_delay /= 10; + if (!dma_cfg->init_delay) + dma_cfg->init_delay = 1; + } plat->force_thresh_dma_mode = of_property_read_bool(np, "snps,force_thresh_dma_mode"); if (plat->force_thresh_dma_mode) { diff --git a/include/linux/stmmac.h b/include/linux/stmmac.h index 6f27d4f..3d7f3e7 100644 --- a/include/linux/stmmac.h +++ b/include/linux/stmmac.h @@ -91,6 +91,7 @@ struct stmmac_dma_cfg { int fixed_burst; int mixed_burst; int burst_len; + int init_delay; }; struct plat_stmmacenet_data {