public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [U-Boot-Users] [PATCH 08/13] SPARC: added SMC91111 driver in and out macros for LEON processors.
@ 2008-03-31 14:25 Daniel Hellstrom
  2008-03-31 14:21 ` Ben Warren
  0 siblings, 1 reply; 7+ messages in thread
From: Daniel Hellstrom @ 2008-03-31 14:25 UTC (permalink / raw)
  To: u-boot

Ben Warren wrote:
> I haven't looked at how all the funky macros in this patch are called, but it's generally considered good form to wrap multi-line macros with do {...} while(0) in order to avoid compiler issues. I'll NAK the patch for now based on this.

The Macros are used to read/write 8-,16-,32-bit words from the I/O bus where the SMC MAC is. 
LEON2/3 is bigendian, so the macros swaps the read and written data as well. The I/O bus is
non-cacheable so no force cache miss is needed here.

I have made the do{}while(0) you asked for and updated patch 8 and my repository:



Signed-off-by: Daniel Hellstrom <daniel@gaisler.com>
---
 drivers/net/smc91111.h |   73 ++++++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 71 insertions(+), 2 deletions(-)

diff --git a/drivers/net/smc91111.h b/drivers/net/smc91111.h
index 8dcbb3e..ef325d2 100644
--- a/drivers/net/smc91111.h
+++ b/drivers/net/smc91111.h
@@ -79,7 +79,7 @@ typedef unsigned long int 		dword;
 #ifdef CONFIG_XSENGINE
 #define	SMC_inl(r) 	(*((volatile dword *)(SMC_BASE_ADDRESS+(r<<1))))
 #define	SMC_inw(r) 	(*((volatile word *)(SMC_BASE_ADDRESS+(r<<1))))
-#define SMC_inb(p)	({ \
+#define SMC_inb(p)  ({ \
 	unsigned int __p = (unsigned int)(SMC_BASE_ADDRESS + (p<<1)); \
 	unsigned int __v = *(volatile unsigned short *)((__p) & ~2); \
 	if (__p & 2) __v >>= 8; \
@@ -176,7 +176,76 @@ typedef unsigned long int 		dword;
 					};  \
 				})
 
-#else /* if not CONFIG_PXA250 */
+#elif defined(CONFIG_LEON)	/* if not CONFIG_PXA250 */
+
+#define SMC_LEON_SWAP16(_x_) ({ word _x = (_x_); ((_x << 8) | (_x >> 8)); })
+
+#define SMC_LEON_SWAP32(_x_)			\
+    ({ dword _x = (_x_);			\
+       ((_x << 24) |				\
+       ((0x0000FF00UL & _x) <<  8) |		\
+       ((0x00FF0000UL & _x) >>  8) |		\
+       (_x  >> 24)); })
+			 
+#define	SMC_inl(r) 	(SMC_LEON_SWAP32((*(volatile dword *)(SMC_BASE_ADDRESS+((r)<<0)))))
+#define	SMC_inl_nosw(r) 	((*(volatile dword *)(SMC_BASE_ADDRESS+((r)<<0))))
+#define	SMC_inw(r) 	(SMC_LEON_SWAP16((*(volatile word *)(SMC_BASE_ADDRESS+((r)<<0)))))
+#define	SMC_inw_nosw(r) 	((*(volatile word *)(SMC_BASE_ADDRESS+((r)<<0))))
+#define SMC_inb(p)	({ \
+	word ___v = SMC_inw((p) & ~1); \
+	if ((p) & 1) ___v >>= 8; \
+	else ___v &= 0xff; \
+	___v; })
+
+#define	SMC_outl(d,r)	(*(volatile dword *)(SMC_BASE_ADDRESS+((r)<<0))=SMC_LEON_SWAP32(d))
+#define	SMC_outl_nosw(d,r)	(*(volatile dword *)(SMC_BASE_ADDRESS+((r)<<0))=(d))
+#define	SMC_outw(d,r)	(*(volatile word *)(SMC_BASE_ADDRESS+((r)<<0))=SMC_LEON_SWAP16(d))
+#define	SMC_outw_nosw(d,r)	(*(volatile word *)(SMC_BASE_ADDRESS+((r)<<0))=(d))
+#define	SMC_outb(d,r)	do{	word __d = (byte)(d);  \
+				word __w = SMC_inw((r)&~1);  \
+				__w &= ((r)&1) ? 0x00FF : 0xFF00;  \
+				__w |= ((r)&1) ? __d<<8 : __d;  \
+				SMC_outw(__w,(r)&~1);  \
+			}while(0)
+#define SMC_outsl(r,b,l)	do{	int __i; \
+					dword *__b2; \
+					__b2 = (dword *) b; \
+					for (__i = 0; __i < l; __i++) { \
+					    SMC_outl_nosw( *(__b2 + __i), r); \
+					} \
+				}while(0)
+#define SMC_outsw(r,b,l)	do{	int __i; \
+					word *__b2; \
+					__b2 = (word *) b; \
+					for (__i = 0; __i < l; __i++) { \
+					    SMC_outw_nosw( *(__b2 + __i), r); \
+					} \
+				}while(0)
+#define SMC_insl(r,b,l) 	do{	int __i ;  \
+					dword *__b2;  \
+			    		__b2 = (dword *) b;  \
+			    		for (__i = 0; __i < l; __i++) {  \
+					  *(__b2 + __i) = SMC_inl_nosw(r);  \
+					};  \
+				}while(0)
+
+#define SMC_insw(r,b,l) 	do{	int __i ;  \
+					word *__b2;  \
+			    		__b2 = (word *) b;  \
+			    		for (__i = 0; __i < l; __i++) {  \
+					  *(__b2 + __i) = SMC_inw_nosw(r);  \
+					};  \
+				}while(0)
+
+#define SMC_insb(r,b,l) 	do{	int __i ;  \
+					byte *__b2;  \
+			    		__b2 = (byte *) b;  \
+			    		for (__i = 0; __i < l; __i++) {  \
+					  *(__b2 + __i) = SMC_inb(r);  \
+					};  \
+				}while(0)
+
+#else				/* if not CONFIG_PXA250 and not CONFIG_LEON */
 
 #ifndef CONFIG_SMC_USE_IOFUNCS /* these macros don't work on some boards */
 /*
-- 
1.5.4

^ permalink raw reply related	[flat|nested] 7+ messages in thread
* [U-Boot-Users] [PATCH 01/13] SPARC: Added generic support for SPARC architecture.
@ 2008-03-28 19:22 Daniel Hellstrom
  2008-03-28 19:22 ` [U-Boot-Users] [PATCH 08/13] SPARC: added SMC91111 driver in and out macros for LEON processors Daniel Hellstrom
  0 siblings, 1 reply; 7+ messages in thread
From: Daniel Hellstrom @ 2008-03-28 19:22 UTC (permalink / raw)
  To: u-boot

Not much to say, tested on LEON2 simulator and LEON3.

ABOUT SPARC-ELF COMPILER
------------------------
Compiling u-boot for LEON3 and LEON2 has only been has been tested 
with GCC 3.4.4 compiler with added LEON2 and LEON3 support available from 
www.gaisler.com or 
ftp://ftp.gaisler.com/gaisler.com/bcc/bin/linux/sparc-elf-3.4.4-1.0.30.tar.bz2, 
installation instructions can be found in bcc/doc/bcc.pdf. (extract to /opt/ 
and add /opt/sparc-elf-3.4.4/bin to PATH).

U-BOOT support tested
---------------------
- LEON3 (and LEON3FT Fault tolerant version)
- LEON3 Simulator (GRSIM and TSIM)
- LEON2 Simulator (GRSIM and TSIM)
- Network (GRETH and SMC91111)
- USB 1.1 (UHCI)
- Linux and RTEMS booting
- booting UBOOT from RAM and FLASH by changing board/gaisler/xxx/config.mk
- DDR, DDR2, SRAM, FT-SRAM
- UART, IRQ, Timer

This patch is available at ftp://ftp.gaisler.com/gaisler.com/u-boot/patches/1_sparc.patch.

Best Regards,
Daniel Hellstrom

Signed-off-by: Daniel Hellstrom <daniel@gaisler.com>
---
 MAKEALL                         |    7 +
 Makefile                        |    9 +-
 README                          |    1 +
 examples/Makefile               |    3 +
 examples/sparc.lds              |   61 +++++
 examples/stubs.c                |   16 ++
 include/asm-sparc/asi.h         |   32 +++
 include/asm-sparc/asmmacro.h    |   45 ++++
 include/asm-sparc/atomic.h      |   29 +++
 include/asm-sparc/bitops.h      |   29 +++
 include/asm-sparc/byteorder.h   |   37 +++
 include/asm-sparc/cache.h       |   31 +++
 include/asm-sparc/errno.h       |  162 ++++++++++++
 include/asm-sparc/global_data.h |   85 +++++++
 include/asm-sparc/io.h          |   94 +++++++
 include/asm-sparc/irq.h         |   49 ++++
 include/asm-sparc/machines.h    |   92 +++++++
 include/asm-sparc/page.h        |   43 ++++
 include/asm-sparc/posix_types.h |  139 +++++++++++
 include/asm-sparc/processor.h   |  109 ++++++++
 include/asm-sparc/prom.h        |  297 ++++++++++++++++++++++
 include/asm-sparc/psr.h         |   97 ++++++++
 include/asm-sparc/ptrace.h      |  181 ++++++++++++++
 include/asm-sparc/srmmu.h       |  301 ++++++++++++++++++++++
 include/asm-sparc/stack.h       |  162 ++++++++++++
 include/asm-sparc/string.h      |   55 ++++
 include/asm-sparc/types.h       |   71 ++++++
 include/asm-sparc/u-boot.h      |   74 ++++++
 include/asm-sparc/winmacro.h    |  151 +++++++++++
 lib_sparc/Makefile              |   45 ++++
 lib_sparc/board.c               |  521 +++++++++++++++++++++++++++++++++++++++
 lib_sparc/bootm.c               |  226 +++++++++++++++++
 lib_sparc/cache.c               |   33 +++
 lib_sparc/interrupts.c          |  122 +++++++++
 lib_sparc/time.c                |   78 ++++++
 sparc_config.mk                 |   24 ++
 36 files changed, 3510 insertions(+), 1 deletions(-)
 create mode 100644 examples/sparc.lds
 create mode 100644 include/asm-sparc/asi.h
 create mode 100644 include/asm-sparc/asmmacro.h
 create mode 100644 include/asm-sparc/atomic.h
 create mode 100644 include/asm-sparc/bitops.h
 create mode 100644 include/asm-sparc/byteorder.h
 create mode 100644 include/asm-sparc/cache.h
 create mode 100644 include/asm-sparc/errno.h
 create mode 100644 include/asm-sparc/global_data.h
 create mode 100644 include/asm-sparc/io.h
 create mode 100644 include/asm-sparc/irq.h
 create mode 100644 include/asm-sparc/machines.h
 create mode 100644 include/asm-sparc/page.h
 create mode 100644 include/asm-sparc/posix_types.h
 create mode 100644 include/asm-sparc/processor.h
 create mode 100644 include/asm-sparc/prom.h
 create mode 100644 include/asm-sparc/psr.h
 create mode 100644 include/asm-sparc/ptrace.h
 create mode 100644 include/asm-sparc/srmmu.h
 create mode 100644 include/asm-sparc/stack.h
 create mode 100644 include/asm-sparc/string.h
 create mode 100644 include/asm-sparc/types.h
 create mode 100644 include/asm-sparc/u-boot.h
 create mode 100644 include/asm-sparc/winmacro.h
 create mode 100644 lib_sparc/Makefile
 create mode 100644 lib_sparc/board.c
 create mode 100644 lib_sparc/bootm.c
 create mode 100644 lib_sparc/cache.c
 create mode 100644 lib_sparc/interrupts.c
 create mode 100644 lib_sparc/time.c
 create mode 100644 sparc_config.mk

-- 
1.5.4

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2008-03-31 14:53 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-03-31 14:25 [U-Boot-Users] [PATCH 08/13] SPARC: added SMC91111 driver in and out macros for LEON processors Daniel Hellstrom
2008-03-31 14:21 ` Ben Warren
2008-03-31 14:40   ` Daniel Hellstrom
2008-03-31 14:53     ` Ben Warren
  -- strict thread matches above, loose matches on Subject: below --
2008-03-28 19:22 [U-Boot-Users] [PATCH 01/13] SPARC: Added generic support for SPARC architecture Daniel Hellstrom
2008-03-28 19:22 ` [U-Boot-Users] [PATCH 08/13] SPARC: added SMC91111 driver in and out macros for LEON processors Daniel Hellstrom
2008-03-30  4:29   ` Ben Warren
     [not found]   ` <20080331111242.GA29923@mail.gnudd.com>
2008-03-31 14:15     ` Ben Warren

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox