Skip to contentSkip to conversation

smc911x: add 16 bit support

PATCH Superseded Jens Gehrlein 3 participants 3 messages Apr 30, 2008 Network drivers

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 smc911x: add 16 bit support

Incorporated Ben's, Magnus's and Guennadi's proposals. Thank you for reviewing.

---

 drivers/net/smc911x.c |   19 +++++++++++++++++--
 1 files changed, 17 insertions(+), 2 deletions(-)
drivers/net/smc911x.c +17 -2
index d22c889..bd82cf7 100644
@@ -30,6 +30,10 @@
 #include <net.h>
 #include <miiphy.h>
 
+#if defined (CONFIG_DRIVER_SMC911X_32_BIT) && defined (CONFIG_DRIVER_SMC911X_16_BIT)
+#error "SMC911X: Only one of CONFIG_DRIVER_SMC911X_32_BIT and CONFIG_DRIVER_SMC911X_16_BIT shall be set"
+#endif
+
 #ifdef CONFIG_DRIVER_SMC911X_32_BIT
 static inline u32 reg_read(u32 addr)
 {
@@ -39,9 +43,20 @@ static inline void reg_write(u32 addr, u32 val)
 {
 	*(volatile u32*)addr = val;
 }
+#elif CONFIG_DRIVER_SMC911X_16_BIT
+static inline u32 reg_read(u32 addr)
+{
+	volatile u16 *addr_16 = (u16 *)addr;
+	return ((*addr_16 & 0x0000ffff) | (*(addr_16 + 1) << 16));
+}
+static inline void reg_write(u32 addr, u32 val)
+{
+	*(volatile u16*)addr = (u16)val;
+	*(volatile u16*)(addr + 2) = (u16)(val >> 16);
+}
 #else
-#error "SMC911X: Only 32-bit bus is supported"
-#endif
+#error "SMC911X: undefined buswidth"
+#endif /* CONFIG_DRIVER_SMC911X_16_BIT */
 
 #define mdelay(n)       udelay((n)*1000)
 
#1 lore raw

PATCH v2 1/1 smc911x: add 16 bit support

Hi Jens,

Quoted 3 lines · Jens Gehrlein

Incorporated Ben's, Magnus's and Guennadi's proposals.
Thank you for reviewing.

Almost there. This comment needs to go below the '---' line so that it doesn't become part of the commit message. Also, please add a meaningful comment here (above your SOB line). The patch title contains all the useful information, so you may want to just copy it, but there needs to be something.

Quoted 15 lines

---

  drivers/net/smc911x.c |   19 +++++++++++++++++--
  1 files changed, 17 insertions(+), 2 deletions(-)

diff --git a/drivers/net/smc911x.c b/drivers/net/smc911x.c index d22c889..bd82cf7 100644
--- a/drivers/net/smc911x.c
+++ b/drivers/net/smc911x.c
@@ -30,6 +30,10 @@
#include <net.h>
#include <miiphy.h>

Quoted 2 lines

+#if defined (CONFIG_DRIVER_SMC911X_32_BIT) && defined (CONFIG_DRIVER_SMC911X_16_BIT) +#error "SMC911X: Only one of CONFIG_DRIVER_SMC911X_32_BIT and CONFIG_DRIVER_SMC911X_16_BIT shall be set"

Both of these lines are too long. I suggest:

+#if defined (CONFIG_DRIVER_SMC911X_32_BIT) && \
+ defined (CONFIG_DRIVER_SMC911X_16_BIT)
+#error "SMC911X: Only one of CONFIG_DRIVER_SMC911X_32_BIT and \
+ CONFIG_DRIVER_SMC911X_16_BIT shall be set"

NOTE: I wrote this in gmail's web interface, so don't cut & paste - do it right!

Quoted 8 lines

+#endif
+
#ifdef CONFIG_DRIVER_SMC911X_32_BIT
static inline u32 reg_read(u32 addr)
{
@@ -39,9 +43,20 @@ static inline void reg_write(u32 addr, u32 val)

  {
        *(volatile u32*)addr = val;
Quoted 16 lines

}
+#elif CONFIG_DRIVER_SMC911X_16_BIT
+static inline u32 reg_read(u32 addr)
+{
+ volatile u16 *addr_16 = (u16 *)addr;
+ return ((*addr_16 & 0x0000ffff) | (*(addr_16 + 1) << 16));
+}
+static inline void reg_write(u32 addr, u32 val)
+{
+ *(volatile u16*)addr = (u16)val;
+ *(volatile u16*)(addr + 2) = (u16)(val >> 16);
+}
#else
-#error "SMC911X: Only 32-bit bus is supported"
-#endif
+#error "SMC911X: undefined buswidth"

s/buswidth/bus\ width/

Quoted 4 lines

+#endif /* CONFIG_DRIVER_SMC911X_16_BIT */

  #define mdelay(n)       udelay((n)*1000)

Also, would you mind putting an entry into the README file for this driver? There's already one there for the SMC91111 driver, so this should be really fast.

Thanks for your help!

regards,
Ben

#2 lore raw

PATCH v2 1/1 smc911x: add 16 bit support

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

Almost there. This comment needs to go below the '---' line so that it doesn't become part of the commit message. Also, please add a

That's correct.

Quoted 3 lines

meaningful comment here (above your SOB line). The patch title contains all the useful information, so you may want to just copy it, but there needs to be something.

No, please don't, or the line will end up twice in the commit message.

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
Quote from the Boss... "I didn't say it was your fault.  I said I was
going to blame it on you."