Mailing List Archive

[PATCH -mm 4/5] Blackfin: patch add blackfin support in smc91x ethernet controller driver
Hi folks,

As SMC91X ethernet controller are used in blackfin STAMP 533 development
board, this patch add blackfin support to the smc91x linux driver.

It's name is blackfin-driver-net-stamp533.patch.

[PATCH] Blackfin: patch add blackfin support in smc91x ethernet
controller driver

Signed-off-by: Bryan Wu <bryan.wu@analog.com>
---

drivers/net/Kconfig | 2 +-
drivers/net/smc91x.h | 47 +++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 48 insertions(+), 1 deletion(-)

Index: linux-2.6/drivers/net/Kconfig
===================================================================
--- linux-2.6.orig/drivers/net/Kconfig 2007-03-01 11:33:24.000000000 +0800
+++ linux-2.6/drivers/net/Kconfig 2007-03-01 11:39:14.000000000 +0800
@@ -822,7 +822,7 @@
tristate "SMC 91C9x/91C1xxx support"
select CRC32
select MII
- depends on NET_ETHERNET && (ARM || REDWOOD_5 || REDWOOD_6 || M32R || SUPERH || SOC_AU1X00)
+ depends on NET_ETHERNET && (ARM || REDWOOD_5 || REDWOOD_6 || M32R || SUPERH || SOC_AU1X00 || BFIN)
help
This is a driver for SMC's 91x series of Ethernet chipsets,
including the SMC91C94 and the SMC91C111. Say Y if you want it
Index: linux-2.6/drivers/net/smc91x.h
===================================================================
--- linux-2.6.orig/drivers/net/smc91x.h 2007-03-01 11:33:18.000000000 +0800
+++ linux-2.6/drivers/net/smc91x.h 2007-03-01 11:39:14.000000000 +0800
@@ -55,6 +55,53 @@
#define SMC_insw(a, r, p, l) readsw((a) + (r), p, l)
#define SMC_outsw(a, r, p, l) writesw((a) + (r), p, l)

+#elif defined(CONFIG_BFIN)
+
+#define SMC_IRQ_FLAGS IRQF_TRIGGER_HIGH
+
+# if defined (CONFIG_BFIN561_EZKIT)
+#define SMC_CAN_USE_8BIT 0
+#define SMC_CAN_USE_16BIT 1
+#define SMC_CAN_USE_32BIT 1
+#define SMC_IO_SHIFT 0
+#define SMC_NOWAIT 1
+#define SMC_USE_BFIN_DMA 0
+
+
+#define SMC_inw(a, r) readw((a) + (r))
+#define SMC_outw(v, a, r) writew(v, (a) + (r))
+#define SMC_inl(a, r) readl((a) + (r))
+#define SMC_outl(v, a, r) writel(v, (a) + (r))
+#define SMC_outsl(a, r, p, l) outsl((unsigned long *)((a) + (r)), p, l)
+#define SMC_insl(a, r, p, l) insl ((unsigned long *)((a) + (r)), p, l)
+# else
+#define SMC_CAN_USE_8BIT 0
+#define SMC_CAN_USE_16BIT 1
+#define SMC_CAN_USE_32BIT 0
+#define SMC_IO_SHIFT 0
+#define SMC_NOWAIT 1
+#define SMC_USE_BFIN_DMA 0
+
+
+#define SMC_inw(a, r) readw((a) + (r))
+#define SMC_outw(v, a, r) writew(v, (a) + (r))
+#define SMC_outsw(a, r, p, l) outsw((unsigned long *)((a) + (r)), p, l)
+#define SMC_insw(a, r, p, l) insw ((unsigned long *)((a) + (r)), p, l)
+# endif
+/* check if the mac in reg is valid */
+#define SMC_GET_MAC_ADDR(addr) \
+ do { \
+ unsigned int __v; \
+ __v = SMC_inw( ioaddr, ADDR0_REG ); \
+ addr[0] = __v; addr[1] = __v >> 8; \
+ __v = SMC_inw( ioaddr, ADDR1_REG ); \
+ addr[2] = __v; addr[3] = __v >> 8; \
+ __v = SMC_inw( ioaddr, ADDR2_REG ); \
+ addr[4] = __v; addr[5] = __v >> 8; \
+ if (*(u32 *)(&addr[0]) == 0xFFFFFFFF) { \
+ random_ether_addr(addr); \
+ } \
+ } while (0)
#elif defined(CONFIG_REDWOOD_5) || defined(CONFIG_REDWOOD_6)

/* We can only do 16-bit reads and writes in the static memory space. */
---

Thanks,
-Bryan
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH -mm 4/5] Blackfin: patch add blackfin support in smc91x ethernet controller driver [ In reply to ]
On Thu, 01 Mar 2007 12:15:29 +0800 "Wu, Bryan" <bryan.wu@analog.com> wrote:

> +/* check if the mac in reg is valid */
> +#define SMC_GET_MAC_ADDR(addr) \
> + do { \
> + unsigned int __v; \
> + __v = SMC_inw( ioaddr, ADDR0_REG ); \
> + addr[0] = __v; addr[1] = __v >> 8; \
> + __v = SMC_inw( ioaddr, ADDR1_REG ); \
> + addr[2] = __v; addr[3] = __v >> 8; \
> + __v = SMC_inw( ioaddr, ADDR2_REG ); \
> + addr[4] = __v; addr[5] = __v >> 8; \
> + if (*(u32 *)(&addr[0]) == 0xFFFFFFFF) { \
> + random_ether_addr(addr); \
> + } \
> + } while (0)

Please follow kernel coding style:

__v = SMC_inw(ioaddr, ADDR2_REG);


Can this not be implemented as a C function?
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH -mm 4/5] Blackfin: patch add blackfin support in smc91x ethernet controller driver [ In reply to ]
On Thu, 2007-03-01 at 00:54 -0800, Andrew Morton wrote:
> On Thu, 01 Mar 2007 12:15:29 +0800 "Wu, Bryan" <bryan.wu@analog.com> wrote:
>
> > +/* check if the mac in reg is valid */
> > +#define SMC_GET_MAC_ADDR(addr) \
> > + do { \
> > + unsigned int __v; \
> > + __v = SMC_inw( ioaddr, ADDR0_REG ); \
> > + addr[0] = __v; addr[1] = __v >> 8; \
> > + __v = SMC_inw( ioaddr, ADDR1_REG ); \
> > + addr[2] = __v; addr[3] = __v >> 8; \
> > + __v = SMC_inw( ioaddr, ADDR2_REG ); \
> > + addr[4] = __v; addr[5] = __v >> 8; \
> > + if (*(u32 *)(&addr[0]) == 0xFFFFFFFF) { \
> > + random_ether_addr(addr); \
> > + } \
> > + } while (0)
>
> Please follow kernel coding style:
>
> __v = SMC_inw(ioaddr, ADDR2_REG);
>
>
> Can this not be implemented as a C function?

Thanks, Fixed in the new one.

Signed-off-by: Bryan Wu <bryan.wu@analog.com>
Cc: Jeff Garzik <jeff@garzik.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
---

drivers/net/Kconfig | 2 +-
drivers/net/smc91x.h | 47 +++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 48 insertions(+), 1 deletion(-)

Index: linux-2.6/drivers/net/Kconfig
===================================================================
--- linux-2.6.orig/drivers/net/Kconfig 2007-03-01 10:31:52.000000000 +0800
+++ linux-2.6/drivers/net/Kconfig 2007-03-01 17:07:49.000000000 +0800
@@ -822,7 +822,7 @@
tristate "SMC 91C9x/91C1xxx support"
select CRC32
select MII
- depends on NET_ETHERNET && (ARM || REDWOOD_5 || REDWOOD_6 || M32R || SUPERH || SOC_AU1X00)
+ depends on NET_ETHERNET && (ARM || REDWOOD_5 || REDWOOD_6 || M32R || SUPERH || SOC_AU1X00 || BFIN)
help
This is a driver for SMC's 91x series of Ethernet chipsets,
including the SMC91C94 and the SMC91C111. Say Y if you want it
Index: linux-2.6/drivers/net/smc91x.h
===================================================================
--- linux-2.6.orig/drivers/net/smc91x.h 2007-03-01 10:31:52.000000000 +0800
+++ linux-2.6/drivers/net/smc91x.h 2007-03-01 17:08:35.000000000 +0800
@@ -55,6 +55,53 @@
#define SMC_insw(a, r, p, l) readsw((a) + (r), p, l)
#define SMC_outsw(a, r, p, l) writesw((a) + (r), p, l)

+#elif defined(CONFIG_BFIN)
+
+#define SMC_IRQ_FLAGS IRQF_TRIGGER_HIGH
+
+# if defined (CONFIG_BFIN561_EZKIT)
+#define SMC_CAN_USE_8BIT 0
+#define SMC_CAN_USE_16BIT 1
+#define SMC_CAN_USE_32BIT 1
+#define SMC_IO_SHIFT 0
+#define SMC_NOWAIT 1
+#define SMC_USE_BFIN_DMA 0
+
+
+#define SMC_inw(a, r) readw((a) + (r))
+#define SMC_outw(v, a, r) writew(v, (a) + (r))
+#define SMC_inl(a, r) readl((a) + (r))
+#define SMC_outl(v, a, r) writel(v, (a) + (r))
+#define SMC_outsl(a, r, p, l) outsl((unsigned long *)((a) + (r)), p, l)
+#define SMC_insl(a, r, p, l) insl ((unsigned long *)((a) + (r)), p, l)
+# else
+#define SMC_CAN_USE_8BIT 0
+#define SMC_CAN_USE_16BIT 1
+#define SMC_CAN_USE_32BIT 0
+#define SMC_IO_SHIFT 0
+#define SMC_NOWAIT 1
+#define SMC_USE_BFIN_DMA 0
+
+
+#define SMC_inw(a, r) readw((a) + (r))
+#define SMC_outw(v, a, r) writew(v, (a) + (r))
+#define SMC_outsw(a, r, p, l) outsw((unsigned long *)((a) + (r)), p, l)
+#define SMC_insw(a, r, p, l) insw ((unsigned long *)((a) + (r)), p, l)
+# endif
+/* check if the mac in reg is valid */
+#define SMC_GET_MAC_ADDR(addr) \
+ do { \
+ unsigned int __v; \
+ __v = SMC_inw(ioaddr, ADDR0_REG); \
+ addr[0] = __v; addr[1] = __v >> 8; \
+ __v = SMC_inw(ioaddr, ADDR1_REG); \
+ addr[2] = __v; addr[3] = __v >> 8; \
+ __v = SMC_inw(ioaddr, ADDR2_REG); \
+ addr[4] = __v; addr[5] = __v >> 8; \
+ if (*(u32 *)(&addr[0]) == 0xFFFFFFFF) { \
+ random_ether_addr(addr); \
+ } \
+ } while (0)
#elif defined(CONFIG_REDWOOD_5) || defined(CONFIG_REDWOOD_6)

/* We can only do 16-bit reads and writes in the static memory space. */
_

Best Regards,
-Bryan Wu
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH -mm 4/5] Blackfin: patch add blackfin support in smc91x ethernet controller driver [ In reply to ]
On Thu, 01 Mar 2007 17:23:23 +0800 "Wu, Bryan" <bryan.wu@analog.com> wrote:

> On Thu, 2007-03-01 at 00:54 -0800, Andrew Morton wrote:
> > On Thu, 01 Mar 2007 12:15:29 +0800 "Wu, Bryan" <bryan.wu@analog.com> wrote:
> >
> > > +/* check if the mac in reg is valid */
> > > +#define SMC_GET_MAC_ADDR(addr) \
> > > + do { \
> > > + unsigned int __v; \
> > > + __v = SMC_inw( ioaddr, ADDR0_REG ); \
> > > + addr[0] = __v; addr[1] = __v >> 8; \
> > > + __v = SMC_inw( ioaddr, ADDR1_REG ); \
> > > + addr[2] = __v; addr[3] = __v >> 8; \
> > > + __v = SMC_inw( ioaddr, ADDR2_REG ); \
> > > + addr[4] = __v; addr[5] = __v >> 8; \
> > > + if (*(u32 *)(&addr[0]) == 0xFFFFFFFF) { \
> > > + random_ether_addr(addr); \
> > > + } \
> > > + } while (0)
> >
> > Please follow kernel coding style:
> >
> > __v = SMC_inw(ioaddr, ADDR2_REG);
> >

You skipped this:

> > Can this not be implemented as a C function?

> +#define SMC_GET_MAC_ADDR(addr) \
> + do { \
> + unsigned int __v; \
> + __v = SMC_inw(ioaddr, ADDR0_REG); \
> + addr[0] = __v; addr[1] = __v >> 8; \
> + __v = SMC_inw(ioaddr, ADDR1_REG); \
> + addr[2] = __v; addr[3] = __v >> 8; \
> + __v = SMC_inw(ioaddr, ADDR2_REG); \
> + addr[4] = __v; addr[5] = __v >> 8; \
> + if (*(u32 *)(&addr[0]) == 0xFFFFFFFF) { \
> + random_ether_addr(addr); \
> + } \
> + } while (0)

It can be, I think...

Please always prefer coding in C over coding in cpp.
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH -mm 4/5] Blackfin: patch add blackfin support in smc91x ethernet controller driver [ In reply to ]
On Thu, 2007-03-01 at 01:32 -0800, Andrew Morton wrote:
> On Thu, 01 Mar 2007 17:23:23 +0800 "Wu, Bryan" <bryan.wu@analog.com> wrote:
>
> > On Thu, 2007-03-01 at 00:54 -0800, Andrew Morton wrote:
> > > On Thu, 01 Mar 2007 12:15:29 +0800 "Wu, Bryan" <bryan.wu@analog.com> wrote:
> > >
> > > > +/* check if the mac in reg is valid */
> > > > +#define SMC_GET_MAC_ADDR(addr) \
> > > > + do { \
> > > > + unsigned int __v; \
> > > > + __v = SMC_inw( ioaddr, ADDR0_REG ); \
> > > > + addr[0] = __v; addr[1] = __v >> 8; \
> > > > + __v = SMC_inw( ioaddr, ADDR1_REG ); \
> > > > + addr[2] = __v; addr[3] = __v >> 8; \
> > > > + __v = SMC_inw( ioaddr, ADDR2_REG ); \
> > > > + addr[4] = __v; addr[5] = __v >> 8; \
> > > > + if (*(u32 *)(&addr[0]) == 0xFFFFFFFF) { \
> > > > + random_ether_addr(addr); \
> > > > + } \
> > > > + } while (0)
> > >
> > > Please follow kernel coding style:
> > >
> > > __v = SMC_inw(ioaddr, ADDR2_REG);
> > >
>
> You skipped this:
>
> > > Can this not be implemented as a C function?
>
> > +#define SMC_GET_MAC_ADDR(addr) \
> > + do { \
> > + unsigned int __v; \
> > + __v = SMC_inw(ioaddr, ADDR0_REG); \
> > + addr[0] = __v; addr[1] = __v >> 8; \
> > + __v = SMC_inw(ioaddr, ADDR1_REG); \
> > + addr[2] = __v; addr[3] = __v >> 8; \
> > + __v = SMC_inw(ioaddr, ADDR2_REG); \
> > + addr[4] = __v; addr[5] = __v >> 8; \
> > + if (*(u32 *)(&addr[0]) == 0xFFFFFFFF) { \
> > + random_ether_addr(addr); \
> > + } \
> > + } while (0)
>
> It can be, I think...
>
> Please always prefer coding in C over coding in cpp.

Yes, it can be writen as a C function.
We just follow other implementation in the drivers/net/smc91x.h

start at line 1156 of
---
#ifndef SMC_GET_MAC_ADDR
#define SMC_GET_MAC_ADDR(addr) \
do { \
unsigned int __v; \
__v = SMC_inw( ioaddr, ADDR0_REG ); \
addr[0] = __v; addr[1] = __v >> 8; \
__v = SMC_inw( ioaddr, ADDR1_REG ); \
addr[2] = __v; addr[3] = __v >> 8; \
__v = SMC_inw( ioaddr, ADDR2_REG ); \
addr[4] = __v; addr[5] = __v >> 8; \
} while (0)
#endif
_

If you think this is necessary, we may rewrite it in C function.

Thanks
-Bryan
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH -mm 4/5] Blackfin: patch add blackfin support in smc91x ethernet controller driver [ In reply to ]
oh, and please consider removing all the CVS control strings from the
blackfin code. Because they become meaningless once the code is
merged into mainline.
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH -mm 4/5] Blackfin: patch add blackfin support in smc91x ethernet controller driver [ In reply to ]
On Thu, 01 Mar 2007 17:52:48 +0800 "Wu, Bryan" <bryan.wu@analog.com> wrote:

> > Please always prefer coding in C over coding in cpp.
>
> Yes, it can be writen as a C function.
> We just follow other implementation in the drivers/net/smc91x.h
>
> start at line 1156 of
> ---
> #ifndef SMC_GET_MAC_ADDR
> #define SMC_GET_MAC_ADDR(addr) \
> do { \
> unsigned int __v; \
> __v = SMC_inw( ioaddr, ADDR0_REG ); \
> addr[0] = __v; addr[1] = __v >> 8; \
> __v = SMC_inw( ioaddr, ADDR1_REG ); \
> addr[2] = __v; addr[3] = __v >> 8; \
> __v = SMC_inw( ioaddr, ADDR2_REG ); \
> addr[4] = __v; addr[5] = __v >> 8; \
> } while (0)
> #endif
> _

Please don't treat ghastly old driver code as a model for new kernel code.

> If you think this is necessary, we may rewrite it in C function.

hm, well, if it's copied and pasted from somewhere else then there is some
merit in leaving it as it is.

It would of course be better to pull it out into a shared header file, avoid the
duplication.
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH -mm 4/5] Blackfin: patch add blackfin support in smc91x ethernet controller driver [ In reply to ]
On Thu, 2007-03-01 at 02:03 -0800, Andrew Morton wrote:
> On Thu, 01 Mar 2007 17:52:48 +0800 "Wu, Bryan" <bryan.wu@analog.com> wrote:
>
> > > Please always prefer coding in C over coding in cpp.
> >
> > Yes, it can be writen as a C function.
> > We just follow other implementation in the drivers/net/smc91x.h
> >
> > start at line 1156 of
> > ---
> > #ifndef SMC_GET_MAC_ADDR
> > #define SMC_GET_MAC_ADDR(addr) \
> > do { \
> > unsigned int __v; \
> > __v = SMC_inw( ioaddr, ADDR0_REG ); \
> > addr[0] = __v; addr[1] = __v >> 8; \
> > __v = SMC_inw( ioaddr, ADDR1_REG ); \
> > addr[2] = __v; addr[3] = __v >> 8; \
> > __v = SMC_inw( ioaddr, ADDR2_REG ); \
> > addr[4] = __v; addr[5] = __v >> 8; \
> > } while (0)
> > #endif
> > _
>
> Please don't treat ghastly old driver code as a model for new kernel code.
>
> > If you think this is necessary, we may rewrite it in C function.
>
> hm, well, if it's copied and pasted from somewhere else then there is some
> merit in leaving it as it is.
>
> It would of course be better to pull it out into a shared header file, avoid the
> duplication.

Exactly, this is a better solution. Because smc91x driver is widely used
in embedded linux world, we just want to add our arch support into this
common driver.

Maybe Nico can help us on this.

Thanks
-Bryan Wu
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/