From patchwork Thu Aug 22 04:22:03 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nobuhiro Iwamatsu X-Patchwork-Id: 268948 X-Patchwork-Delegate: joe.hershberger@gmail.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from theia.denx.de (theia.denx.de [85.214.87.163]) by ozlabs.org (Postfix) with ESMTP id 62A3C2C00B3 for ; Thu, 22 Aug 2013 14:22:58 +1000 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 55FA24A0DB; Thu, 22 Aug 2013 06:22:53 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at theia.denx.de Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id jobg21j8TPv5; Thu, 22 Aug 2013 06:22:53 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 85F964A0AE; Thu, 22 Aug 2013 06:22:44 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 276D44A067 for ; Thu, 22 Aug 2013 06:22:34 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at theia.denx.de Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 8ZHePqMWTUVO for ; Thu, 22 Aug 2013 06:22:29 +0200 (CEST) X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 BL_NJABL=SKIP(-1.5) (only DNSBL check requested) Received: from mail-pb0-f53.google.com (mail-pb0-f53.google.com [209.85.160.53]) by theia.denx.de (Postfix) with ESMTPS id 2DA454A098 for ; Thu, 22 Aug 2013 06:22:26 +0200 (CEST) Received: by mail-pb0-f53.google.com with SMTP id up15so1264274pbc.12 for ; Wed, 21 Aug 2013 21:22:25 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=zp3betu/soDULK9/fYymNy9t5PleRX1ULQ6C5w1ijEE=; b=ANIdX1+vCKcMoDFZqXIaIsaPu2ogSOBbMRNzIMPSIrY7Zf3NH4K8XsgupOsYxtH8zM zbgAVrRfEwtnK6jhjpgQE2f/YUx8FaSEyHLmTCsY9m7Az/vr5GngYtqwdT6VZwibHOGy Ivtj+Vlo7HVzn99gYv+nabTYFMbKZ4M6XBS0r6MoYWAwkEsm6rrYzt28jkJb1MNvTzdj qeQl6u9DRM05+0Thv//K0IZK9gVXryUkORlyAhscRa8wv9hlaZB3ezGvS2Jn1mvXY3xX q/72MoGvKa+GG1c6ymgasKZYP76k8x2CzyBXn8ESbAh2z9jxqHttSfXDlpSKYp1kJyvq JJvQ== X-Gm-Message-State: ALoCoQmFoYjSU2DF6jJAWwtyJ3EkcWkHpKNzHO7jUakUgrlyUnosK0ATX5WQzt+QflnZYwkGjyOp X-Received: by 10.66.219.68 with SMTP id pm4mr3127745pac.161.1377145344990; Wed, 21 Aug 2013 21:22:24 -0700 (PDT) Received: from xps-iwamatsu.renesas.com (49.14.32.202.bf.2iij.net. [202.32.14.49]) by mx.google.com with ESMTPSA id os4sm11984747pbb.25.1969.12.31.16.00.00 (version=TLSv1.2 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 21 Aug 2013 21:22:23 -0700 (PDT) From: Nobuhiro Iwamatsu To: joe.hershberger@gmail.com Date: Thu, 22 Aug 2013 13:22:03 +0900 Message-Id: <1377145324-30015-3-git-send-email-nobuhiro.iwamatsu.yj@renesas.com> X-Mailer: git-send-email 1.8.3.2 In-Reply-To: <1377145324-30015-1-git-send-email-nobuhiro.iwamatsu.yj@renesas.com> References: <1377145324-30015-1-git-send-email-nobuhiro.iwamatsu.yj@renesas.com> Cc: u-boot@lists.denx.de, Nobuhiro Iwamatsu , Hisashi Nakamura Subject: [U-Boot] [PATCH 3/4] net: sh-eth: Add invalidate cache control for rmobile (ARM SoC) X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.11 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: u-boot-bounces@lists.denx.de Errors-To: u-boot-bounces@lists.denx.de The sh-eth of rmobile needs to use invalidate_cache* function. This patch adds invalidate_cache* function. Signed-off-by: Hisashi Nakamura Signed-off-by: Nobuhiro Iwamatsu --- drivers/net/sh_eth.c | 31 ++++++++++++++++++++++++++----- 1 file changed, 26 insertions(+), 5 deletions(-) diff --git a/drivers/net/sh_eth.c b/drivers/net/sh_eth.c index c038929..b7dc625 100644 --- a/drivers/net/sh_eth.c +++ b/drivers/net/sh_eth.c @@ -26,13 +26,30 @@ # error "Please define CONFIG_SH_ETHER_PHY_ADDR" #endif -#ifdef CONFIG_SH_ETHER_CACHE_WRITEBACK -#define flush_cache_wback(addr, len) \ - flush_dcache_range((u32)addr, (u32)(addr + len - 1)) +#if defined(CONFIG_SH_ETHER_CACHE_WRITEBACK) && !defined(CONFIG_SYS_DCACHE_OFF) +#define flush_cache_wback(addr, len) \ + flush_dcache_range((u32)addr, (u32)(addr + len - 1)) #else #define flush_cache_wback(...) #endif +#if defined(CONFIG_SH_ETHER_CACHE_INVALIDATE) && defined(CONFIG_ARM) +#define invalidate_cache(addr, len) \ + { \ + u32 line_size = CONFIG_SH_ETHER_ALIGNE_SIZE; \ + u32 start, end; \ + \ + start = (u32)addr; \ + end = start + len; \ + start &= ~(line_size - 1); \ + end = ((end + line_size - 1) & ~(line_size - 1)); \ + \ + invalidate_dcache_range(start, end); \ + } +#else +#define invalidate_cache(...) +#endif + #define TIMEOUT_CNT 1000 int sh_eth_send(struct eth_device *dev, void *packet, int len) @@ -70,8 +87,11 @@ int sh_eth_send(struct eth_device *dev, void *packet, int len) /* Wait until packet is transmitted */ timeout = TIMEOUT_CNT; - while (port_info->tx_desc_cur->td0 & TD_TACT && timeout--) + do { + invalidate_cache(port_info->tx_desc_cur, + sizeof(struct tx_desc_s)); udelay(100); + } while (port_info->tx_desc_cur->td0 & TD_TACT && timeout--); if (timeout < 0) { printf(SHETHER_NAME ": transmit timeout\n"); @@ -95,12 +115,14 @@ int sh_eth_recv(struct eth_device *dev) uchar *packet; /* Check if the rx descriptor is ready */ + invalidate_cache(port_info->rx_desc_cur, sizeof(struct rx_desc_s)); if (!(port_info->rx_desc_cur->rd0 & RD_RACT)) { /* Check for errors */ if (!(port_info->rx_desc_cur->rd0 & RD_RFE)) { len = port_info->rx_desc_cur->rd1 & 0xffff; packet = (uchar *) ADDR_TO_P2(port_info->rx_desc_cur->rd2); + invalidate_cache(packet, len); NetReceive(packet, len); } @@ -109,7 +131,6 @@ int sh_eth_recv(struct eth_device *dev) port_info->rx_desc_cur->rd0 = RD_RACT | RD_RDLE; else port_info->rx_desc_cur->rd0 = RD_RACT; - /* Point to the next descriptor */ port_info->rx_desc_cur++; if (port_info->rx_desc_cur >=