[PATCH v2 4/7] staging: octeon-usb: cvmx-usbcx-defs.h: clean up macros

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Use helper macros to avoid copy-paste and too long lines.

Signed-off-by: Aaro Koskinen <aaro.koskinen@xxxxxx>
---
 drivers/staging/octeon-usb/cvmx-usbcx-defs.h |   55 +++++++++++++++-----------
 1 file changed, 31 insertions(+), 24 deletions(-)

diff --git a/drivers/staging/octeon-usb/cvmx-usbcx-defs.h b/drivers/staging/octeon-usb/cvmx-usbcx-defs.h
index b27c42b..b8088db 100644
--- a/drivers/staging/octeon-usb/cvmx-usbcx-defs.h
+++ b/drivers/staging/octeon-usb/cvmx-usbcx-defs.h
@@ -51,30 +51,37 @@
 #ifndef __CVMX_USBCX_TYPEDEFS_H__
 #define __CVMX_USBCX_TYPEDEFS_H__
 
-#define CVMX_USBCX_GAHBCFG(block_id) (CVMX_ADD_IO_SEG(0x00016F0010000008ull) + ((block_id) & 1) * 0x100000000000ull)
-#define CVMX_USBCX_GHWCFG3(block_id) (CVMX_ADD_IO_SEG(0x00016F001000004Cull) + ((block_id) & 1) * 0x100000000000ull)
-#define CVMX_USBCX_GINTMSK(block_id) (CVMX_ADD_IO_SEG(0x00016F0010000018ull) + ((block_id) & 1) * 0x100000000000ull)
-#define CVMX_USBCX_GINTSTS(block_id) (CVMX_ADD_IO_SEG(0x00016F0010000014ull) + ((block_id) & 1) * 0x100000000000ull)
-#define CVMX_USBCX_GNPTXFSIZ(block_id) (CVMX_ADD_IO_SEG(0x00016F0010000028ull) + ((block_id) & 1) * 0x100000000000ull)
-#define CVMX_USBCX_GNPTXSTS(block_id) (CVMX_ADD_IO_SEG(0x00016F001000002Cull) + ((block_id) & 1) * 0x100000000000ull)
-#define CVMX_USBCX_GOTGCTL(block_id) (CVMX_ADD_IO_SEG(0x00016F0010000000ull) + ((block_id) & 1) * 0x100000000000ull)
-#define CVMX_USBCX_GRSTCTL(block_id) (CVMX_ADD_IO_SEG(0x00016F0010000010ull) + ((block_id) & 1) * 0x100000000000ull)
-#define CVMX_USBCX_GRXFSIZ(block_id) (CVMX_ADD_IO_SEG(0x00016F0010000024ull) + ((block_id) & 1) * 0x100000000000ull)
-#define CVMX_USBCX_GRXSTSPH(block_id) (CVMX_ADD_IO_SEG(0x00016F0010000020ull) + ((block_id) & 1) * 0x100000000000ull)
-#define CVMX_USBCX_GUSBCFG(block_id) (CVMX_ADD_IO_SEG(0x00016F001000000Cull) + ((block_id) & 1) * 0x100000000000ull)
-#define CVMX_USBCX_HAINT(block_id) (CVMX_ADD_IO_SEG(0x00016F0010000414ull) + ((block_id) & 1) * 0x100000000000ull)
-#define CVMX_USBCX_HAINTMSK(block_id) (CVMX_ADD_IO_SEG(0x00016F0010000418ull) + ((block_id) & 1) * 0x100000000000ull)
-#define CVMX_USBCX_HCCHARX(offset, block_id) (CVMX_ADD_IO_SEG(0x00016F0010000500ull) + (((offset) & 7) + ((block_id) & 1) * 0x8000000000ull) * 32)
-#define CVMX_USBCX_HCFG(block_id) (CVMX_ADD_IO_SEG(0x00016F0010000400ull) + ((block_id) & 1) * 0x100000000000ull)
-#define CVMX_USBCX_HCINTMSKX(offset, block_id) (CVMX_ADD_IO_SEG(0x00016F001000050Cull) + (((offset) & 7) + ((block_id) & 1) * 0x8000000000ull) * 32)
-#define CVMX_USBCX_HCINTX(offset, block_id) (CVMX_ADD_IO_SEG(0x00016F0010000508ull) + (((offset) & 7) + ((block_id) & 1) * 0x8000000000ull) * 32)
-#define CVMX_USBCX_HCSPLTX(offset, block_id) (CVMX_ADD_IO_SEG(0x00016F0010000504ull) + (((offset) & 7) + ((block_id) & 1) * 0x8000000000ull) * 32)
-#define CVMX_USBCX_HCTSIZX(offset, block_id) (CVMX_ADD_IO_SEG(0x00016F0010000510ull) + (((offset) & 7) + ((block_id) & 1) * 0x8000000000ull) * 32)
-#define CVMX_USBCX_HFIR(block_id) (CVMX_ADD_IO_SEG(0x00016F0010000404ull) + ((block_id) & 1) * 0x100000000000ull)
-#define CVMX_USBCX_HFNUM(block_id) (CVMX_ADD_IO_SEG(0x00016F0010000408ull) + ((block_id) & 1) * 0x100000000000ull)
-#define CVMX_USBCX_HPRT(block_id) (CVMX_ADD_IO_SEG(0x00016F0010000440ull) + ((block_id) & 1) * 0x100000000000ull)
-#define CVMX_USBCX_HPTXFSIZ(block_id) (CVMX_ADD_IO_SEG(0x00016F0010000100ull) + ((block_id) & 1) * 0x100000000000ull)
-#define CVMX_USBCX_HPTXSTS(block_id) (CVMX_ADD_IO_SEG(0x00016F0010000410ull) + ((block_id) & 1) * 0x100000000000ull)
+#define CVMX_USBBASE 0x00016F0010000000ull
+#define CVMX_USBREG_A(reg, bid) \
+	(CVMX_ADD_IO_SEG(CVMX_USBBASE | reg) + ((bid) & 1) * 0x100000000000ull)
+#define CVMX_USBREG_B(reg, bid, off) \
+	(CVMX_ADD_IO_SEG(CVMX_USBBASE | reg) + \
+	 (((off) & 7) + ((bid) & 1) * 0x8000000000ull) * 32)
+
+#define CVMX_USBCX_GAHBCFG(bid)		CVMX_USBREG_A(0x008, bid)
+#define CVMX_USBCX_GHWCFG3(bid)		CVMX_USBREG_A(0x04c, bid)
+#define CVMX_USBCX_GINTMSK(bid)		CVMX_USBREG_A(0x018, bid)
+#define CVMX_USBCX_GINTSTS(bid)		CVMX_USBREG_A(0x014, bid)
+#define CVMX_USBCX_GNPTXFSIZ(bid)	CVMX_USBREG_A(0x028, bid)
+#define CVMX_USBCX_GNPTXSTS(bid)	CVMX_USBREG_A(0x02c, bid)
+#define CVMX_USBCX_GOTGCTL(bid)		CVMX_USBREG_A(0x000, bid)
+#define CVMX_USBCX_GRSTCTL(bid)		CVMX_USBREG_A(0x010, bid)
+#define CVMX_USBCX_GRXFSIZ(bid)		CVMX_USBREG_A(0x024, bid)
+#define CVMX_USBCX_GRXSTSPH(bid)	CVMX_USBREG_A(0x020, bid)
+#define CVMX_USBCX_GUSBCFG(bid)		CVMX_USBREG_A(0x00c, bid)
+#define CVMX_USBCX_HAINT(bid)		CVMX_USBREG_A(0x414, bid)
+#define CVMX_USBCX_HAINTMSK(bid)	CVMX_USBREG_A(0x418, bid)
+#define CVMX_USBCX_HCCHARX(off, bid)	CVMX_USBREG_B(0x500, bid, off)
+#define CVMX_USBCX_HCFG(bid)		CVMX_USBREG_A(0x400, bid)
+#define CVMX_USBCX_HCINTMSKX(off, bid)	CVMX_USBREG_B(0x50c, bid, off)
+#define CVMX_USBCX_HCINTX(off, bid)	CVMX_USBREG_B(0x508, bid, off)
+#define CVMX_USBCX_HCSPLTX(off, bid)	CVMX_USBREG_B(0x504, bid, off)
+#define CVMX_USBCX_HCTSIZX(off, bid)	CVMX_USBREG_B(0x510, bid, off)
+#define CVMX_USBCX_HFIR(bid)		CVMX_USBREG_A(0x404, bid)
+#define CVMX_USBCX_HFNUM(bid)		CVMX_USBREG_A(0x408, bid)
+#define CVMX_USBCX_HPRT(bid)		CVMX_USBREG_A(0x440, bid)
+#define CVMX_USBCX_HPTXFSIZ(bid)	CVMX_USBREG_A(0x100, bid)
+#define CVMX_USBCX_HPTXSTS(bid)		CVMX_USBREG_A(0x410, bid)
 
 /**
  * cvmx_usbc#_daint
-- 
1.7.10.4

_______________________________________________
devel mailing list
devel@xxxxxxxxxxxxxxxxxxxxxx
http://driverdev.linuxdriverproject.org/mailman/listinfo/devel




[Index of Archives]     [Linux Driver Backports]     [DMA Engine]     [Linux GPIO]     [Linux SPI]     [Video for Linux]     [Linux USB Devel]     [Linux Coverity]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]
  Powered by Linux