public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [U-Boot] [PATCH] drivers/net/ax88796.h revised
@ 2008-11-29 17:47 Daniel Mack
  2008-12-01  6:36 ` Ben Warren
  0 siblings, 1 reply; 2+ messages in thread
From: Daniel Mack @ 2008-11-29 17:47 UTC (permalink / raw)
  To: u-boot

Hi,

I overhauled drivers/net/ax88796.h a bit to make some more settings
board-dependend that used to be hard-coded.

There is also a new settings block for the chip to be used on the
Colibri PXA300 board.

Signed-off-by: Daniel Mack <daniel@caiaq.de>


diff --git a/drivers/net/ax88796.h b/drivers/net/ax88796.h
index 43a1639..60469c0 100644
--- a/drivers/net/ax88796.h
+++ b/drivers/net/ax88796.h
@@ -23,7 +23,6 @@
 #ifndef __DRIVERS_AX88796L_H__
 #define __DRIVERS_AX88796L_H__
 
-#define DP_DATA		(0x10 << 1)
 #define START_PG	0x40	/* First page of TX buffer */
 #define START_PG2	0x48
 #define STOP_PG		0x80	/* Last page +1 of RX ring */
@@ -32,8 +31,47 @@
 #define RX_END		STOP_PG
 
 #define AX88796L_BASE_ADDRESS	CONFIG_DRIVER_NE2000_BASE
-#define AX88796L_BYTE_ACCESS	0x00001000
-#define AX88796L_OFFSET		0x00000400
+
+/* R7780MP Specific code */
+#if defined(CONFIG_R7780MP)
+	#define DP_DATA			(0x10 << 1)
+	#define ISA_OFFSET		0x1400
+	#define AX88796L_BYTE_ACCESS	0x00001000
+	#define AX88796L_OFFSET		0x00000400
+	
+	#define DP_IN(_b_, _o_, _d_)	(_d_) = \
+		*( (vu_short *) ((_b_) + ((_o_) * 2) + ISA_OFFSET))
+	#define DP_OUT(_b_, _o_, _d_) \
+		*((vu_short *)((_b_) + ((_o_) * 2) + ISA_OFFSET)) = (_d_)
+	#define DP_IN_DATA(_b_, _d_)	(_d_) = *( (vu_short *) ((_b_) + ISA_OFFSET))
+	#define DP_OUT_DATA(_b_, _d_)	*( (vu_short *) ((_b_)+ISA_OFFSET)) = (_d_)
+/* Colribri PXA300 specific code */
+#elif defined(CONFIG_COLIBRI_PXA300)
+	#define ISA_OFFSET		0
+	#define DP_DATA			(1 << 11)
+	#define AX88796L_BYTE_ACCESS	0
+	#define AX88796L_OFFSET		0
+
+	#define DP_IN(_b_, _o_, _d_)	(_d_) = \
+		*( (vu_char *) ((_b_) + ((_o_) * 2) + ISA_OFFSET))
+	#define DP_OUT(_b_, _o_, _d_) \
+		*((vu_char *)((_b_) + ((_o_) * 2) + ISA_OFFSET)) = (_d_)
+	#define DP_IN_DATA(_b_, _d_)	(_d_) = *( (vu_char *) ((_b_) + ISA_OFFSET))
+	#define DP_OUT_DATA(_b_, _d_)	*( (vu_char *) ((_b_)+ISA_OFFSET)) = (_d_)
+#else
+/* Please change for your target boards */
+	#warning PLEASE DEFINE AX88796 SETTINGS!
+	#define ISA_OFFSET		0
+	#define DP_DATA			0
+	#define AX88796L_BYTE_ACCESS	0
+	#define AX88796L_OFFSET		0
+	
+	#define DP_IN(_b_, _o_, _d_)	(_d_) = *( (vu_short *)((_b_)+(_o_ )+ISA_OFFSET))
+	#define DP_OUT(_b_, _o_, _d_)	*((vu_short *)((_b_)+(_o_)+ISA_OFFSET)) = (_d_)
+	#define DP_IN_DATA(_b_, _d_)	(_d_) = *( (vu_short *) ((_b_)+ISA_OFFSET))
+	#define DP_OUT_DATA(_b_, _d_)	*( (vu_short *) ((_b_)+ISA_OFFSET)) = (_d_)
+#endif
+
 #define AX88796L_ADDRESS_BYTE	AX88796L_BASE_ADDRESS + \
 		AX88796L_BYTE_ACCESS + AX88796L_OFFSET
 #define AX88796L_REG_MEMR	AX88796L_ADDRESS_BYTE + (0x14<<1)
@@ -60,22 +98,5 @@
 #define MAC_EEP_EWEN	4
 #define MAC_EEP_EWDS	5
 
-/* R7780MP Specific code */
-#if defined(CONFIG_R7780MP)
-#define ISA_OFFSET	0x1400
-#define DP_IN(_b_, _o_, _d_)	(_d_) = \
-	*( (vu_short *) ((_b_) + ((_o_) * 2) + ISA_OFFSET))
-#define DP_OUT(_b_, _o_, _d_) \
-	*((vu_short *)((_b_) + ((_o_) * 2) + ISA_OFFSET)) = (_d_)
-#define DP_IN_DATA(_b_, _d_)	(_d_) = *( (vu_short *) ((_b_) + ISA_OFFSET))
-#define DP_OUT_DATA(_b_, _d_)	*( (vu_short *) ((_b_)+ISA_OFFSET)) = (_d_)
-#else
-/* Please change for your target boards */
-#define ISA_OFFSET	0x0000
-#define DP_IN(_b_, _o_, _d_)	(_d_) = *( (vu_short *)((_b_)+(_o_ )+ISA_OFFSET))
-#define DP_OUT(_b_, _o_, _d_)	*((vu_short *)((_b_)+(_o_)+ISA_OFFSET)) = (_d_)
-#define DP_IN_DATA(_b_, _d_)	(_d_) = *( (vu_short *) ((_b_)+ISA_OFFSET))
-#define DP_OUT_DATA(_b_, _d_)	*( (vu_short *) ((_b_)+ISA_OFFSET)) = (_d_)
-#endif
-
 #endif /* __DRIVERS_AX88796L_H__ */
+

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

* [U-Boot] [PATCH] drivers/net/ax88796.h revised
  2008-11-29 17:47 [U-Boot] [PATCH] drivers/net/ax88796.h revised Daniel Mack
@ 2008-12-01  6:36 ` Ben Warren
  0 siblings, 0 replies; 2+ messages in thread
From: Ben Warren @ 2008-12-01  6:36 UTC (permalink / raw)
  To: u-boot

Hi Daniel,

On Sat, Nov 29, 2008 at 9:47 AM, Daniel Mack <daniel@caiaq.de> wrote:

> Hi,
>
> I overhauled drivers/net/ax88796.h a bit to make some more settings
> board-dependend that used to be hard-coded.
>
No board-specific code in drivers please.  Ignore the existing mess and
strive to do better.

>
> There is also a new settings block for the chip to be used on the
> Colibri PXA300 board.
>
> Signed-off-by: Daniel Mack <daniel@caiaq.de>
>
>
> diff --git a/drivers/net/ax88796.h b/drivers/net/ax88796.h
> index 43a1639..60469c0 100644
> --- a/drivers/net/ax88796.h
> +++ b/drivers/net/ax88796.h
> @@ -23,7 +23,6 @@
>  #ifndef __DRIVERS_AX88796L_H__
>  #define __DRIVERS_AX88796L_H__
>
> -#define DP_DATA                (0x10 << 1)
>  #define START_PG       0x40    /* First page of TX buffer */
>  #define START_PG2      0x48
>  #define STOP_PG                0x80    /* Last page +1 of RX ring */
> @@ -32,8 +31,47 @@
>  #define RX_END         STOP_PG
>
>  #define AX88796L_BASE_ADDRESS  CONFIG_DRIVER_NE2000_BASE
> -#define AX88796L_BYTE_ACCESS   0x00001000
> -#define AX88796L_OFFSET                0x00000400
> +
> +/* R7780MP Specific code */
> +#if defined(CONFIG_R7780MP)
> +       #define DP_DATA                 (0x10 << 1)
> +       #define ISA_OFFSET              0x1400
> +       #define AX88796L_BYTE_ACCESS    0x00001000
> +       #define AX88796L_OFFSET         0x00000400
> +
> +       #define DP_IN(_b_, _o_, _d_)    (_d_) = \
> +               *( (vu_short *) ((_b_) + ((_o_) * 2) + ISA_OFFSET))
> +       #define DP_OUT(_b_, _o_, _d_) \
> +               *((vu_short *)((_b_) + ((_o_) * 2) + ISA_OFFSET)) = (_d_)
> +       #define DP_IN_DATA(_b_, _d_)    (_d_) = *( (vu_short *) ((_b_) +
> ISA_OFFSET))
> +       #define DP_OUT_DATA(_b_, _d_)   *( (vu_short *) ((_b_)+ISA_OFFSET))
> = (_d_)
> +/* Colribri PXA300 specific code */
> +#elif defined(CONFIG_COLIBRI_PXA300)
> +       #define ISA_OFFSET              0
> +       #define DP_DATA                 (1 << 11)
> +       #define AX88796L_BYTE_ACCESS    0
> +       #define AX88796L_OFFSET         0
> +
> +       #define DP_IN(_b_, _o_, _d_)    (_d_) = \
> +               *( (vu_char *) ((_b_) + ((_o_) * 2) + ISA_OFFSET))
> +       #define DP_OUT(_b_, _o_, _d_) \
> +               *((vu_char *)((_b_) + ((_o_) * 2) + ISA_OFFSET)) = (_d_)
> +       #define DP_IN_DATA(_b_, _d_)    (_d_) = *( (vu_char *) ((_b_) +
> ISA_OFFSET))
> +       #define DP_OUT_DATA(_b_, _d_)   *( (vu_char *) ((_b_)+ISA_OFFSET))
> = (_d_)
> +#else
> +/* Please change for your target boards */
> +       #warning PLEASE DEFINE AX88796 SETTINGS!
> +       #define ISA_OFFSET              0
> +       #define DP_DATA                 0
> +       #define AX88796L_BYTE_ACCESS    0
> +       #define AX88796L_OFFSET         0
> +
> +       #define DP_IN(_b_, _o_, _d_)    (_d_) = *( (vu_short *)((_b_)+(_o_
> )+ISA_OFFSET))
> +       #define DP_OUT(_b_, _o_, _d_)   *((vu_short
> *)((_b_)+(_o_)+ISA_OFFSET)) = (_d_)
> +       #define DP_IN_DATA(_b_, _d_)    (_d_) = *( (vu_short *)
> ((_b_)+ISA_OFFSET))
> +       #define DP_OUT_DATA(_b_, _d_)   *( (vu_short *) ((_b_)+ISA_OFFSET))
> = (_d_)
> +#endif
> +

Please have a look at the smc911x driver to see a preferable way of handling
different bus widths.  Use static inlines instead of these hideous macros (I
know you've only cut&pasted so aren't responsible for the originals)

>
>  #define AX88796L_ADDRESS_BYTE  AX88796L_BASE_ADDRESS + \
>                AX88796L_BYTE_ACCESS + AX88796L_OFFSET
>  #define AX88796L_REG_MEMR      AX88796L_ADDRESS_BYTE + (0x14<<1)
> @@ -60,22 +98,5 @@
>  #define MAC_EEP_EWEN   4
>  #define MAC_EEP_EWDS   5
>
> -/* R7780MP Specific code */
> -#if defined(CONFIG_R7780MP)
> -#define ISA_OFFSET     0x1400
> -#define DP_IN(_b_, _o_, _d_)   (_d_) = \
> -       *( (vu_short *) ((_b_) + ((_o_) * 2) + ISA_OFFSET))
> -#define DP_OUT(_b_, _o_, _d_) \
> -       *((vu_short *)((_b_) + ((_o_) * 2) + ISA_OFFSET)) = (_d_)
> -#define DP_IN_DATA(_b_, _d_)   (_d_) = *( (vu_short *) ((_b_) +
> ISA_OFFSET))
> -#define DP_OUT_DATA(_b_, _d_)  *( (vu_short *) ((_b_)+ISA_OFFSET)) = (_d_)
> -#else
> -/* Please change for your target boards */
> -#define ISA_OFFSET     0x0000
> -#define DP_IN(_b_, _o_, _d_)   (_d_) = *( (vu_short *)((_b_)+(_o_
> )+ISA_OFFSET))
> -#define DP_OUT(_b_, _o_, _d_)  *((vu_short *)((_b_)+(_o_)+ISA_OFFSET)) =
> (_d_)
> -#define DP_IN_DATA(_b_, _d_)   (_d_) = *( (vu_short *) ((_b_)+ISA_OFFSET))
> -#define DP_OUT_DATA(_b_, _d_)  *( (vu_short *) ((_b_)+ISA_OFFSET)) = (_d_)
> -#endif
> -
>  #endif /* __DRIVERS_AX88796L_H__ */
> +
> ___________

regards,
Ben

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

end of thread, other threads:[~2008-12-01  6:36 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-11-29 17:47 [U-Boot] [PATCH] drivers/net/ax88796.h revised Daniel Mack
2008-12-01  6:36 ` Ben Warren

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