Skip to contentSkip to conversation

IXP425 and e1000 network driver

U-Boot Stefan Althoefer 4 participants 10 messages Dec 20, 2008 – Aug 10, 2009 Network drivers

lore
Share & tools
lore
#0 lore 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:

--------

drivers/net/e1000.c +9 -6
@@ -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

#1 lore raw

Dear Ben,

Quoted 34 lines · In message <[email protected]> Stefan Althoefer wrote:

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:

--------

drivers/net/e1000.c +9 -7
@@ -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 */
---------
Quoted 8 lines

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

I have never seen any comments on this. Could you please have a look at it?

Best regards,

Wolfgang Denk

Signature · 6 lines
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
Unix is like a toll road on which you have to stop every 50  feet  to
pay another nickel. But hey! You only feel 5 cents poorer each time.
                 - Larry Wall in <[email protected]>
#2 lore raw
Quoted 51 lines · Wolfgang Denk

Dear Ben,

Quoted 34 lines · In message <[email protected]> Stefan Althoefer wrote:

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:

--------

drivers/net/e1000.c +9 -7
@@ -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 */
---------
Quoted 9 lines

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

I have never seen any comments on this. Could you please have a look at it?

Quoted 5 lines

Best regards,

Wolfgang Denk

Sure thing.

regards,
Ben

#3 lore raw

Dear Ben,

Quoted 52 lines · In message <[email protected]> you wrote:
Quoted 51 lines · Wolfgang Denk

Dear Ben,

Quoted 34 lines · In message <[email protected]> Stefan Althoefer wrote:

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:

--------

drivers/net/e1000.c +9 -7
@@ -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 */
---------
Quoted 9 lines

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

I have never seen any comments on this. Could you please have a look at it?

Quoted 6 lines
Quoted 5 lines

Best regards,

Wolfgang Denk

Sure thing.

And what was the result of you having a look at thispatch?

Best regards,

Wolfgang Denk

Signature · 6 lines
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
In the beginning there was nothing.
And the Lord said "Let There Be Light!"
And still there was nothing, but at least now you could see it.
#4 lore raw
In reply to Ben Warren

Dear Ben Warren,

Quoted 52 lines · In message <[email protected]> you wrote:
Quoted 51 lines · Wolfgang Denk

Dear Ben,

Quoted 34 lines · In message <[email protected]> Stefan Althoefer wrote:

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:

--------

drivers/net/e1000.c +9 -7
@@ -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 */
---------
Quoted 9 lines

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

I have never seen any comments on this. Could you please have a look at it?

Quoted 6 lines
Quoted 5 lines

Best regards,

Wolfgang Denk

Sure thing.

That was 4 months ago, but I did not see anything happen. Can you please re-check?

Best regards,

Wolfgang Denk

Signature · 7 lines
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
Niklaus Wirth has lamented that, whereas Europeans pronounce his name
correctly  (Ni-klows  Virt),  Americans  invariably  mangle  it  into
(Nick-les  Worth).  Which  is to say that Europeans call him by name,
but Americans call him by value.
#5 lore raw

Hi Wolfgang,

Quoted 67 lines · Wolfgang Denk

Dear Ben Warren,

Quoted 54 lines · In message <[email protected]> you wrote:
Quoted 52 lines · Wolfgang Denk

Dear Ben,

Quoted 34 lines · In message <[email protected]> Stefan Althoefer wrote:

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:

--------

drivers/net/e1000.c +9 -7
@@ -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 */
---------
Quoted 10 lines

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

I have never seen any comments on this. Could you please have a look at it?

Quoted 8 lines
Quoted 6 lines

Best regards,

Wolfgang Denk

Sure thing.

Quoted 8 lines

That was 4 months ago, but I did not see anything happen. Can you please re-check?

Best regards,

Wolfgang Denk

I thought I brought this up already, but maybe not. Won't this break PowerPC? I'm pretty sure (value) != (cpu_to_le32(value)), isn't it? Isn't the problem that writel() and readl() aren't byte-swapped on BE ARM?

regards,
Ben

#6 lore raw

Dear Ben,

Quoted 3 lines · In message <[email protected]> you wrote:

I thought I brought this up already, but maybe not. Won't this break PowerPC? I'm pretty sure (value) != (cpu_to_le32(value)), isn't it?

Right.

Quoted 1 line

Isn't the problem that writel() and readl() aren't byte-swapped on BE ARM?

Right. writel() and readl() are not a good choice for architecture independent code. AFAIK ioreadX(), iowriteX() are supposed to be architecture independent I/O accessors, but unfortunately not all architectures implement these yet.

Best regards,

Wolfgang Denk

Signature · 7 lines
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
Computers make excellent and efficient servants, but I have  no  wish
to  serve under them. Captain, a starship also runs on loyalty to one
man. And nothing can replace it or him.
	-- Spock, "The Ultimate Computer", stardate 4729.4
#8 lore raw
Quoted 6 lines · Jean-Christophe PLAGNIOL-VILLARD
Quoted 5 lines · Stefan Althoefer

Hi,

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

Quoted 7 lines
Quoted 1 line

I get it working with this patch:

Ben
Ping

Best Regards,
J.

Sorry, I let another month slip by. This looks reasonable to me, but isn't a properly-formatted patch.

Stefan - if you don't have time to re-submit, just let me know and I'll do it for you.

regards,
Ben

#9 lore raw

Dear Ben,

Quoted 15 lines · In message <[email protected]> you…
Quoted 7 lines · Stefan Althoefer
Quoted 5 lines

Hi,

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

Quoted 7 lines
Quoted 1 line

I get it working with this patch:

Ben
Ping

Best Regards,
J.

Quoted 5 lines

Sorry, I let another month slip by. This looks reasonable to me, but isn't a properly-formatted patch.

Stefan - if you don't have time to re-submit, just let me know and I'll do it for you.

Seems Stefan has no time. Could you please take care of this, then? Thanks.

Best regards,

Wolfgang Denk

Signature · 5 lines
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
A direct quote from the Boss: "We passed over a lot of good people to
get the ones we hired."