From patchwork Tue Aug 9 09:16:51 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jamie Iles X-Patchwork-Id: 1048632 Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) by demeter1.kernel.org (8.14.4/8.14.4) with ESMTP id p799Ke04015601 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Tue, 9 Aug 2011 09:21:03 GMT Received: from canuck.infradead.org ([2001:4978:20e::1]) by merlin.infradead.org with esmtps (Exim 4.76 #1 (Red Hat Linux)) id 1QqiTz-0005BZ-E5; Tue, 09 Aug 2011 09:20:20 +0000 Received: from localhost ([127.0.0.1] helo=canuck.infradead.org) by canuck.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1QqiTu-0001d2-LH; Tue, 09 Aug 2011 09:20:14 +0000 Received: from mail-ww0-f49.google.com ([74.125.82.49]) by canuck.infradead.org with esmtps (Exim 4.76 #1 (Red Hat Linux)) id 1QqiS2-0000qf-MI for linux-arm-kernel@lists.infradead.org; Tue, 09 Aug 2011 09:18:20 +0000 Received: by mail-ww0-f49.google.com with SMTP id 10so2748480wwf.18 for ; Tue, 09 Aug 2011 02:18:18 -0700 (PDT) Received: by 10.227.164.133 with SMTP id e5mr168596wby.88.1312881498298; Tue, 09 Aug 2011 02:18:18 -0700 (PDT) Received: from localhost (cpc3-chap8-2-0-cust205.aztw.cable.virginmedia.com [94.171.253.206]) by mx.google.com with ESMTPS id ff6sm5152678wbb.32.2011.08.09.02.18.16 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 09 Aug 2011 02:18:17 -0700 (PDT) From: Jamie Iles To: netdev@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [PATCHv3 9/9] macb: allow GEM to have configurable receive buffer size Date: Tue, 9 Aug 2011 10:16:51 +0100 Message-Id: <1312881411-2376-10-git-send-email-jamie@jamieiles.com> X-Mailer: git-send-email 1.7.4.1 In-Reply-To: <1312881411-2376-1-git-send-email-jamie@jamieiles.com> References: <1312881411-2376-1-git-send-email-jamie@jamieiles.com> X-CRM114-Version: 20090807-BlameThorstenAndJenny ( TRE 0.7.6 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20110809_051818_949609_3C0E02C2 X-CRM114-Status: GOOD ( 12.97 ) X-Spam-Score: -0.7 (/) X-Spam-Report: SpamAssassin version 3.3.1 on canuck.infradead.org summary: Content analysis details: (-0.7 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [74.125.82.49 listed in list.dnswl.org] Cc: Jamie Iles , plagnioj@jcrosoft.com X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: linux-arm-kernel-bounces@lists.infradead.org Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter1.kernel.org [140.211.167.41]); Tue, 09 Aug 2011 09:21:03 +0000 (UTC) GEM has configurable receive buffer sizes so requires this to be programmed up. Any size < 2048 and a multiple of 64 bytes is permitted. Signed-off-by: Jamie Iles Acked-by: David S. Miller Acked-by: Nicolas Ferre Acked-by: Jean-Christophe PLAGNIOL-VILLARD --- drivers/net/macb.c | 17 +++++++++++++++++ drivers/net/macb.h | 5 +++++ 2 files changed, 22 insertions(+), 0 deletions(-) diff --git a/drivers/net/macb.c b/drivers/net/macb.c index a8a9b4b..69c9808 100644 --- a/drivers/net/macb.c +++ b/drivers/net/macb.c @@ -857,6 +857,21 @@ static u32 macb_dbw(struct macb *bp) } } +/* + * Configure the receive DMA engine to use the correct receive buffer size. + * This is a configurable parameter for GEM. + */ +static void macb_configure_dma(struct macb *bp) +{ + u32 dmacfg; + + if (macb_is_gem(bp)) { + dmacfg = gem_readl(bp, DMACFG) & ~GEM_BF(RXBS, -1L); + dmacfg |= GEM_BF(RXBS, RX_BUFFER_SIZE / 64); + gem_writel(bp, DMACFG, dmacfg); + } +} + static void macb_init_hw(struct macb *bp) { u32 config; @@ -875,6 +890,8 @@ static void macb_init_hw(struct macb *bp) config |= macb_dbw(bp); macb_writel(bp, NCFGR, config); + macb_configure_dma(bp); + /* Initialize TX and RX buffers */ macb_writel(bp, RBQP, bp->rx_ring_dma); macb_writel(bp, TBQP, bp->tx_ring_dma); diff --git a/drivers/net/macb.h b/drivers/net/macb.h index 71424aa..1931078 100644 --- a/drivers/net/macb.h +++ b/drivers/net/macb.h @@ -64,6 +64,7 @@ /* GEM register offsets. */ #define GEM_NCFGR 0x0004 #define GEM_USRIO 0x000c +#define GEM_DMACFG 0x0010 #define GEM_HRB 0x0080 #define GEM_HRT 0x0084 #define GEM_SA1B 0x0088 @@ -154,6 +155,10 @@ #define GEM_DBW64 1 #define GEM_DBW128 2 +/* Bitfields in DMACFG. */ +#define GEM_RXBS_OFFSET 16 +#define GEM_RXBS_SIZE 8 + /* Bitfields in NSR */ #define MACB_NSR_LINK_OFFSET 0 #define MACB_NSR_LINK_SIZE 1