aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/skge.h
diff options
context:
space:
mode:
authorStephen Hemminger <shemminger@osdl.org>2005-06-27 14:33:04 -0400
committerJeff Garzik <jgarzik@pobox.com>2005-06-27 18:05:05 -0400
commit6b0c1480491a9e2d9d34368e09e6acddbb173515 (patch)
tree178df55e99fa18e7b8ad5f757b4953c2691b174c /drivers/net/skge.h
parent275834d1095dcd52d0fefd0d3f7d0320552fe277 (diff)
[PATCH] skge: function amd macro name change
The inlines and macro's needed some cleanup's and fixes: * change name of macro SKGEMAC_REG to SK_REG to better reflect usage and fix comments * ditto for SK_GEXM_REG -> SK_XMAC_REG and SKGEGMA_REG -> SK_GMA_REG * change skge_gm_ to just gm_ since it is just a local function and long names look ugly. * change skge_xm_ to just xm_ * fix xm_write32 to write as two u16's with correct byte order * fix xm_outaddr to correctly use offset Signed-off-by: Stephen Hemminger <shemminger@osdl.org>
Diffstat (limited to 'drivers/net/skge.h')
-rw-r--r--drivers/net/skge.h113
1 files changed, 43 insertions, 70 deletions
diff --git a/drivers/net/skge.h b/drivers/net/skge.h
index aad3aece30b5..2669b80b2de8 100644
--- a/drivers/net/skge.h
+++ b/drivers/net/skge.h
@@ -488,7 +488,7 @@ enum {
488 PA_ENA_TO_TX1 | PA_ENA_TO_TX2) 488 PA_ENA_TO_TX1 | PA_ENA_TO_TX2)
489 489
490 490
491/* Transmit Arbiter Registers MAC 1 and 2, use MR_ADDR() to access */ 491/* Transmit Arbiter Registers MAC 1 and 2, use SK_REG() to access */
492/* TXA_ITI_INI 32 bit Tx Arb Interval Timer Init Val */ 492/* TXA_ITI_INI 32 bit Tx Arb Interval Timer Init Val */
493/* TXA_ITI_VAL 32 bit Tx Arb Interval Timer Value */ 493/* TXA_ITI_VAL 32 bit Tx Arb Interval Timer Value */
494/* TXA_LIM_INI 32 bit Tx Arb Limit Counter Init Val */ 494/* TXA_LIM_INI 32 bit Tx Arb Limit Counter Init Val */
@@ -511,7 +511,7 @@ enum {
511/* 511/*
512 * Bank 4 - 5 512 * Bank 4 - 5
513 */ 513 */
514/* Transmit Arbiter Registers MAC 1 and 2, use MR_ADDR() to access */ 514/* Transmit Arbiter Registers MAC 1 and 2, use SK_REG() to access */
515enum { 515enum {
516 TXA_ITI_INI = 0x0200,/* 32 bit Tx Arb Interval Timer Init Val*/ 516 TXA_ITI_INI = 0x0200,/* 32 bit Tx Arb Interval Timer Init Val*/
517 TXA_ITI_VAL = 0x0204,/* 32 bit Tx Arb Interval Timer Value */ 517 TXA_ITI_VAL = 0x0204,/* 32 bit Tx Arb Interval Timer Value */
@@ -2892,114 +2892,87 @@ static inline void skge_write8(const struct skge_hw *hw, int reg, u8 val)
2892} 2892}
2893 2893
2894/* MAC Related Registers inside the device. */ 2894/* MAC Related Registers inside the device. */
2895#define SKGEMAC_REG(port,reg) (((port)<<7)+(reg)) 2895#define SK_REG(port,reg) (((port)<<7)+(reg))
2896 2896#define SK_XMAC_REG(port, reg) \
2897/* PCI config space can be accessed via memory mapped space */
2898#define SKGEPCI_REG(reg) ((reg)+ 0x380)
2899
2900#define SKGEXM_REG(port, reg) \
2901 ((BASE_XMAC_1 + (port) * (BASE_XMAC_2 - BASE_XMAC_1)) | (reg) << 1) 2897 ((BASE_XMAC_1 + (port) * (BASE_XMAC_2 - BASE_XMAC_1)) | (reg) << 1)
2902 2898
2903static inline u32 skge_xm_read32(const struct skge_hw *hw, int port, int reg) 2899static inline u32 xm_read32(const struct skge_hw *hw, int port, int reg)
2904{
2905 return skge_read32(hw, SKGEXM_REG(port,reg));
2906}
2907
2908static inline u16 skge_xm_read16(const struct skge_hw *hw, int port, int reg)
2909{
2910 return skge_read16(hw, SKGEXM_REG(port,reg));
2911}
2912
2913static inline u8 skge_xm_read8(const struct skge_hw *hw, int port, int reg)
2914{ 2900{
2915 return skge_read8(hw, SKGEXM_REG(port,reg)); 2901 u32 v;
2902 v = skge_read16(hw, SK_XMAC_REG(port, reg));
2903 v |= (u32)skge_read16(hw, SK_XMAC_REG(port, reg+2)) << 16;
2904 return v;
2916} 2905}
2917 2906
2918static inline void skge_xm_write32(const struct skge_hw *hw, int port, int r, u32 v) 2907static inline u16 xm_read16(const struct skge_hw *hw, int port, int reg)
2919{ 2908{
2920 skge_write32(hw, SKGEXM_REG(port,r), v); 2909 return skge_read16(hw, SK_XMAC_REG(port,reg));
2921} 2910}
2922 2911
2923static inline void skge_xm_write16(const struct skge_hw *hw, int port, int r, u16 v) 2912static inline void xm_write32(const struct skge_hw *hw, int port, int r, u32 v)
2924{ 2913{
2925 skge_write16(hw, SKGEXM_REG(port,r), v); 2914 skge_write16(hw, SK_XMAC_REG(port,r), v & 0xffff);
2915 skge_write16(hw, SK_XMAC_REG(port,r+2), v >> 16);
2926} 2916}
2927 2917
2928static inline void skge_xm_write8(const struct skge_hw *hw, int port, int r, u8 v) 2918static inline void xm_write16(const struct skge_hw *hw, int port, int r, u16 v)
2929{ 2919{
2930 skge_write8(hw, SKGEXM_REG(port,r), v); 2920 skge_write16(hw, SK_XMAC_REG(port,r), v);
2931} 2921}
2932 2922
2933static inline void skge_xm_outhash(const struct skge_hw *hw, int port, int reg, 2923static inline void xm_outhash(const struct skge_hw *hw, int port, int reg,
2934 const u8 *hash) 2924 const u8 *hash)
2935{ 2925{
2936 skge_xm_write16(hw, port, reg, 2926 xm_write16(hw, port, reg, (u16)hash[0] | ((u16)hash[1] << 8));
2937 (u16)hash[0] | ((u16)hash[1] << 8)); 2927 xm_write16(hw, port, reg+2, (u16)hash[2] | ((u16)hash[3] << 8));
2938 skge_xm_write16(hw, port, reg+2, 2928 xm_write16(hw, port, reg+4, (u16)hash[4] | ((u16)hash[5] << 8));
2939 (u16)hash[2] | ((u16)hash[3] << 8)); 2929 xm_write16(hw, port, reg+6, (u16)hash[6] | ((u16)hash[7] << 8));
2940 skge_xm_write16(hw, port, reg+4,
2941 (u16)hash[4] | ((u16)hash[5] << 8));
2942 skge_xm_write16(hw, port, reg+6,
2943 (u16)hash[6] | ((u16)hash[7] << 8));
2944} 2930}
2945 2931
2946static inline void skge_xm_outaddr(const struct skge_hw *hw, int port, int reg, 2932static inline void xm_outaddr(const struct skge_hw *hw, int port, int reg,
2947 const u8 *addr) 2933 const u8 *addr)
2948{ 2934{
2949 skge_xm_write16(hw, port, reg, 2935 xm_write16(hw, port, reg, (u16)addr[0] | ((u16)addr[1] << 8));
2950 (u16)addr[0] | ((u16)addr[1] << 8)); 2936 xm_write16(hw, port, reg+2, (u16)addr[2] | ((u16)addr[3] << 8));
2951 skge_xm_write16(hw, port, reg, 2937 xm_write16(hw, port, reg+4, (u16)addr[4] | ((u16)addr[5] << 8));
2952 (u16)addr[2] | ((u16)addr[3] << 8));
2953 skge_xm_write16(hw, port, reg,
2954 (u16)addr[4] | ((u16)addr[5] << 8));
2955} 2938}
2956 2939
2940#define SK_GMAC_REG(port,reg) \
2941 (BASE_GMAC_1 + (port) * (BASE_GMAC_2-BASE_GMAC_1) + (reg))
2957 2942
2958#define SKGEGMA_REG(port,reg) \ 2943static inline u16 gma_read16(const struct skge_hw *hw, int port, int reg)
2959 ((reg) + BASE_GMAC_1 + \
2960 (port) * (BASE_GMAC_2-BASE_GMAC_1))
2961
2962static inline u16 skge_gma_read16(const struct skge_hw *hw, int port, int reg)
2963{
2964 return skge_read16(hw, SKGEGMA_REG(port,reg));
2965}
2966
2967static inline u32 skge_gma_read32(const struct skge_hw *hw, int port, int reg)
2968{ 2944{
2969 return (u32) skge_read16(hw, SKGEGMA_REG(port,reg)) 2945 return skge_read16(hw, SK_GMAC_REG(port,reg));
2970 | ((u32)skge_read16(hw, SKGEGMA_REG(port,reg+4)) << 16);
2971} 2946}
2972 2947
2973static inline u8 skge_gma_read8(const struct skge_hw *hw, int port, int reg) 2948static inline u32 gma_read32(const struct skge_hw *hw, int port, int reg)
2974{ 2949{
2975 return skge_read8(hw, SKGEGMA_REG(port,reg)); 2950 return (u32) skge_read16(hw, SK_GMAC_REG(port,reg))
2951 | ((u32)skge_read16(hw, SK_GMAC_REG(port,reg+4)) << 16);
2976} 2952}
2977 2953
2978static inline void skge_gma_write16(const struct skge_hw *hw, int port, int r, u16 v) 2954static inline void gma_write16(const struct skge_hw *hw, int port, int r, u16 v)
2979{ 2955{
2980 skge_write16(hw, SKGEGMA_REG(port,r), v); 2956 skge_write16(hw, SK_GMAC_REG(port,r), v);
2981} 2957}
2982 2958
2983static inline void skge_gma_write32(const struct skge_hw *hw, int port, int r, u32 v) 2959static inline void gma_write32(const struct skge_hw *hw, int port, int r, u32 v)
2984{ 2960{
2985 skge_write16(hw, SKGEGMA_REG(port, r), (u16) v); 2961 skge_write16(hw, SK_GMAC_REG(port, r), (u16) v);
2986 skge_write32(hw, SKGEGMA_REG(port, r+4), (u16)(v >> 16)); 2962 skge_write32(hw, SK_GMAC_REG(port, r+4), (u16)(v >> 16));
2987} 2963}
2988 2964
2989static inline void skge_gma_write8(const struct skge_hw *hw, int port, int r, u8 v) 2965static inline void gma_write8(const struct skge_hw *hw, int port, int r, u8 v)
2990{ 2966{
2991 skge_write8(hw, SKGEGMA_REG(port,r), v); 2967 skge_write8(hw, SK_GMAC_REG(port,r), v);
2992} 2968}
2993 2969
2994static inline void skge_gm_set_addr(struct skge_hw *hw, int port, int reg, 2970static inline void gma_set_addr(struct skge_hw *hw, int port, int reg,
2995 const u8 *addr) 2971 const u8 *addr)
2996{ 2972{
2997 skge_gma_write16(hw, port, reg, 2973 gma_write16(hw, port, reg, (u16) addr[0] | ((u16) addr[1] << 8));
2998 (u16) addr[0] | ((u16) addr[1] << 8)); 2974 gma_write16(hw, port, reg+4,(u16) addr[2] | ((u16) addr[3] << 8));
2999 skge_gma_write16(hw, port, reg+4, 2975 gma_write16(hw, port, reg+8,(u16) addr[4] | ((u16) addr[5] << 8));
3000 (u16) addr[2] | ((u16) addr[3] << 8));
3001 skge_gma_write16(hw, port, reg+8,
3002 (u16) addr[4] | ((u16) addr[5] << 8));
3003} 2976}
3004 2977
3005#endif 2978#endif