smc911x: add 16 bit support
authorJens Gehrlein <sew_s@tqs.de>
Mon, 5 May 2008 12:06:11 +0000 (14:06 +0200)
committerBen Warren <biggerbadderben@gmail.com>
Fri, 23 May 2008 06:10:01 +0000 (23:10 -0700)
Signed-off-by: Jens Gehrlein <sew_s@tqs.de>
Signed-off-by: Ben Warren <biggerbadderben@gmail.com>
README
drivers/net/smc911x.c

diff --git a/README b/README
index f14fb7b..f3957f1 100644 (file)
--- a/README
+++ b/README
@@ -786,6 +786,21 @@ The following options need to be configured:
                        Define this to use i/o functions instead of macros
                        (some hardware wont work with macros)
 
+               CONFIG_DRIVER_SMC911X
+               Support for SMSC's LAN911x and LAN921x chips
+
+                       CONFIG_DRIVER_SMC911X_BASE
+                       Define this to hold the physical address
+                       of the device (I/O space)
+
+                       CONFIG_DRIVER_SMC911X_32_BIT
+                       Define this if data bus is 32 bits
+
+                       CONFIG_DRIVER_SMC911X_16_BIT
+                       Define this if data bus is 16 bits. If your processor
+                       automatically converts one 32 bit word to two 16 bit
+                       words you may also try CONFIG_DRIVER_SMC911X_32_BIT.
+
 - USB Support:
                At the moment only the UHCI host controller is
                supported (PIP405, MIP405, MPC5200); define
index 5302cb5..6d93bf0 100644 (file)
 #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 +45,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 bus width"
+#endif /* CONFIG_DRIVER_SMC911X_16_BIT */
 
 #define mdelay(n)       udelay((n)*1000)