All of lore.kernel.org
 help / color / mirror / Atom feed
From: Stefan Althoefer <stefan.althoefer@web.de>
To: u-boot@lists.denx.de
Subject: [U-Boot] [Bug] IXP425 and e1000 network driver
Date: Sat, 20 Dec 2008 19:31:43 +0100	[thread overview]
Message-ID: <gijdmd$vhk$1@ger.gmane.org> (raw)

Hi,

I found that IXP425 (big endian ARM) did not work with e1000 network
driver. The reason is broken access to controller registers.

I get it working with this patch:

--------
--- a/drivers/net/e1000.c
+++ b/drivers/net/e1000.c
@@ -105,12 +105,15 @@ static void e1000_phy_hw_reset(struct e1000_hw *hw);
 static int e1000_phy_reset(struct e1000_hw *hw);
 static int e1000_detect_gig_phy(struct e1000_hw *hw);

-#define E1000_WRITE_REG(a, reg, value) (writel((value), ((a)->hw_addr + E1000_##reg)))
-#define E1000_READ_REG(a, reg) (readl((a)->hw_addr + E1000_##reg))
-#define E1000_WRITE_REG_ARRAY(a, reg, offset, value) (\
-			writel((value), ((a)->hw_addr + E1000_##reg + ((offset) << 2))))
-#define E1000_READ_REG_ARRAY(a, reg, offset) ( \
-	readl((a)->hw_addr + E1000_##reg + ((offset) << 2)))
+#define E1000_WRITE_REG(a, reg, value) \
+	(writel(cpu_to_le32(value), ((a)->hw_addr + E1000_##reg)))
+#define E1000_READ_REG(a, reg) \
+	(le32_to_cpu(readl((a)->hw_addr + E1000_##reg)))
+#define E1000_WRITE_REG_ARRAY(a, reg, offset, value) \
+	(writel(cpu_to_le32(value),\
+		((a)->hw_addr + E1000_##reg + ((offset) << 2))))
+#define E1000_READ_REG_ARRAY(a, reg, offset) \
+	(le32_to_cpu(readl((a)->hw_addr + E1000_##reg + ((offset) << 2))))
 #define E1000_WRITE_FLUSH(a) {uint32_t x; x = E1000_READ_REG(a, STATUS);}

 #ifndef CONFIG_AP1000 /* remove for warnings */
---------

However, I'm not sure it this is the correct fix.

Is readl supposed to read raw data?

Is le32_to_cpu/cpu_to_le32 a function or a macro? In the later case the
code is not save or slow due to multiple argument expansion.

-- Stefan

             reply	other threads:[~2008-12-20 18:31 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-12-20 18:31 Stefan Althoefer [this message]
2009-04-03 21:18 ` [U-Boot] [Bug] IXP425 and e1000 network driver Wolfgang Denk
2009-04-03 21:43   ` Ben Warren
2009-04-27 22:05     ` Wolfgang Denk
2009-08-05 20:26     ` Wolfgang Denk
2009-08-10  5:50       ` Ben Warren
2009-08-10  7:44         ` Wolfgang Denk
2009-05-02 11:56 ` Jean-Christophe PLAGNIOL-VILLARD
2009-05-03  2:56   ` Ben Warren
2009-06-03 21:36     ` Wolfgang Denk

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='gijdmd$vhk$1@ger.gmane.org' \
    --to=stefan.althoefer@web.de \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.