From patchwork Tue Apr 28 07:32:16 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Magnus Damm X-Patchwork-Id: 26532 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@bilbo.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from ozlabs.org (ozlabs.org [203.10.76.45]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "mx.ozlabs.org", Issuer "CA Cert Signing Authority" (verified OK)) by bilbo.ozlabs.org (Postfix) with ESMTPS id E17DDB6F44 for ; Tue, 28 Apr 2009 17:35:12 +1000 (EST) Received: by ozlabs.org (Postfix) id CDFB4DDDF9; Tue, 28 Apr 2009 17:35:12 +1000 (EST) Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by ozlabs.org (Postfix) with ESMTP id 70D29DDDF6 for ; Tue, 28 Apr 2009 17:35:12 +1000 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753113AbZD1HfF (ORCPT ); Tue, 28 Apr 2009 03:35:05 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1751860AbZD1HfE (ORCPT ); Tue, 28 Apr 2009 03:35:04 -0400 Received: from wa-out-1112.google.com ([209.85.146.178]:44722 "EHLO wa-out-1112.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751455AbZD1HfC (ORCPT ); Tue, 28 Apr 2009 03:35:02 -0400 Received: by wa-out-1112.google.com with SMTP id j5so206232wah.21 for ; Tue, 28 Apr 2009 00:35:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:from:to:cc:date:message-id :subject; bh=9dCG7w1loScRyjebhBW08eYfxLRh0sOBzRhC6jKIZxc=; b=SM7bTs66M1LE3xmZ6tddUX6iw41bxssgafx8m0pGr5V+t1YqaPBQJq1RaChfB9akPa HRHgKCe6fC58XKkVcveml4xcfccIV0MeZkXZ2CgKktNpNGXrUJ09L07iv3BT6yZdCWg0 FrrEQGdmlrXB9wnJPSfwdSrDSI/sO4MLXR0tQ= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=from:to:cc:date:message-id:subject; b=wfowklpP+V7uxZ5oxp8nkWzdH7WlNbzYeAJuYLnINi4xcxOP6yTv/zjl4Ci4peGfae fvkQpkrj1YwatJ3vkfTtT9dlAN5NRrE0p+sBPH12Wq9RLQkYqsVISiE5HzBno/7yf4/p AxGNGVduTXeCkEwgpo5L1wCpxnsYBxnG57Z+U= Received: by 10.114.182.1 with SMTP id e1mr2951397waf.22.1240904102272; Tue, 28 Apr 2009 00:35:02 -0700 (PDT) Received: from rx1.opensource.se (210.5.32.202.bf.2iij.net [202.32.5.210]) by mx.google.com with ESMTPS id j39sm3438748waf.45.2009.04.28.00.35.00 (version=TLSv1/SSLv3 cipher=RC4-MD5); Tue, 28 Apr 2009 00:35:01 -0700 (PDT) From: Magnus Damm To: netdev@vger.kernel.org Cc: iwamatsu@nigauri.org, lethal@linux-sh.org, Ian.Saturley@smsc.com, steve.glendinning@smsc.com, Magnus Damm , davem@davemloft.net Date: Tue, 28 Apr 2009 16:32:16 +0900 Message-Id: <20090428073216.16015.15940.sendpatchset@rx1.opensource.se> Subject: [PATCH] smsc911x: add fifo byteswap support V2 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Magnus Damm This is V2 of the smsc911x fifo byteswap patch. The smsc911x hardware supports both big and little and endian hardware configurations, and the linux smsc911x driver currently detects word order. For correct operation on big endian platforms lacking swapped byte lanes the following patch is needed. Only fifo data is swapped, register data does not require any swapping. Signed-off-by: Magnus Damm Acked-by: Steve Glendinning --- Changes since V1: - Added SMSC911X_SWAP_FIFO comment to header file, thanks Steve! Platform data for the rsk7203 board will be posted separately to the linux-sh list in the near future. drivers/net/smsc911x.c | 13 +++++++++++++ include/linux/smsc911x.h | 10 ++++++++++ 2 files changed, 23 insertions(+) -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html --- 0001/drivers/net/smsc911x.c +++ work/drivers/net/smsc911x.c 2009-04-28 15:34:56.000000000 +0900 @@ -47,6 +47,7 @@ #include #include #include +#include #include #include #include "smsc911x.h" @@ -175,6 +176,12 @@ static inline void smsc911x_tx_writefifo(struct smsc911x_data *pdata, unsigned int *buf, unsigned int wordcount) { + if (pdata->config.flags & SMSC911X_SWAP_FIFO) { + while (wordcount--) + smsc911x_reg_write(pdata, TX_DATA_FIFO, swab32(*buf++)); + return; + } + if (pdata->config.flags & SMSC911X_USE_32BIT) { writesl(pdata->ioaddr + TX_DATA_FIFO, buf, wordcount); return; @@ -194,6 +201,12 @@ static inline void smsc911x_rx_readfifo(struct smsc911x_data *pdata, unsigned int *buf, unsigned int wordcount) { + if (pdata->config.flags & SMSC911X_SWAP_FIFO) { + while (wordcount--) + *buf++ = swab32(smsc911x_reg_read(pdata, RX_DATA_FIFO)); + return; + } + if (pdata->config.flags & SMSC911X_USE_32BIT) { readsl(pdata->ioaddr + RX_DATA_FIFO, buf, wordcount); return; --- 0001/include/linux/smsc911x.h +++ work/include/linux/smsc911x.h 2009-04-28 15:31:07.000000000 +0900 @@ -47,4 +47,14 @@ struct smsc911x_platform_config { #define SMSC911X_FORCE_EXTERNAL_PHY (BIT(3)) #define SMSC911X_SAVE_MAC_ADDRESS (BIT(4)) +/* + * SMSC911X_SWAP_FIFO: + * Enables software byte swap for fifo data. Should only be used as a + * "last resort" in the case of big endian mode on boards with incorrectly + * routed data bus to older devices such as LAN9118. Newer devices such as + * LAN9221 can handle this in hardware, there are registers to control + * this swapping but the driver doesn't currently use them. + */ +#define SMSC911X_SWAP_FIFO (BIT(5)) + #endif /* __LINUX_SMSC911X_H__ */