SL351x (Gemini) ethernet driver
Subsystems (5)
cover SL351x (Gemini) ethernet driver
This is a driver for SL351x (Gemini) SoC ethernet peripheral. Based on work by Paulius Zaleckas and GPLd code from Raidsonic and other NAS vendors.
This is work in progress. Please comment and test if you can. Patches are against 2.6.37-rc (current Linus' tree) but should apply to 2.6.36. You probably also need patches for PATA from
git://git.berlios.de/gemini-board ib4220
Known bugs:
- repeatable bad HW calculated TCP csum
happens for only some packets in a TCP stream
looks like it doesn't like some data pattern or timing (difference between correct and generated csum is the same when the packet is retransmitted with changed header/TCP tstamp)
- TX DMA hangs sometimes (needs module reload when that happens) with debugging printks disabled and HW TX csum enabled
- unsynced counters
I started to work on Paulius' code to find out why the TX DMA hangs happen, but then I realized that complete rewrite was a better way to understand how the hardware works and why it doesn't. As a "bonus" this got some additional features:
- ethtool support
- 64-bit counters
- proper cleanup on ifdown/module unload
- better DMA API usage
- cleaned up code
- a lot of tx/rx debugging printks
- based on 2.6.36 DMA and netdev interfaces
TODO:
- NAPI
- MTU changing
For normal use tx-csum and tso have to be disabled:
ethtool -K eth0 tso off tx off
Tested on Raidsonic IcyBox 4220-B (dual SATA NAS).
I'm also interested in getting copies of various GPL packages for StorLink SL3516. I already have following packages (md5sum):
89991e543eb2e473e3d380ac9a4cd8b4 GPL_source_code(Raidsonic).zip 6ba8b833c429794315f0a73ce2961bd8 Gemini_v2_6_0-n.tgz fe87e97a33554bcab8284d25ff86e383 n299_n199_1.00.24_GPL.tar.bz2 eca8994354368304ca3b5bd1429c20bb sl-boot_1.0.9.tgz eafd6497074fe0651459bf38c39d66bd vt4kern-1.5.tar.bz2.tar
Best Regards,
Micha? Miros?aw
---
Micha? Miros?aw (2):
Gemini: create platform device for ethernet in Raidsonic IB-4220B
Gemini: SL351x Ethernet driver
arch/arm/mach-gemini/board-nas4220b.c | 53 + arch/arm/mach-gemini/common.h | 2 + arch/arm/mach-gemini/devices.c | 52 + arch/arm/mach-gemini/include/mach/gmac.h | 21 + drivers/net/Kconfig | 7 + drivers/net/Makefile | 1 + drivers/net/sl351x.c | 1706 ++++++++++++++++++++++++++++++ drivers/net/sl351x_hw.h | 1423 +++++++++++++++++++++++++ 8 files changed, 3265 insertions(+), 0 deletions(-) create mode 100644 arch/arm/mach-gemini/include/mach/gmac.h create mode 100644 drivers/net/sl351x.c create mode 100644 drivers/net/sl351x_hw.h
RFC PATCH 1/2 Gemini: create platform device for ethernet in Raidsonic IB-4220B
This is cherry-picked from:
git://git.berlios.de/gemini-board ib4220
Code by Paulius Zaleckas <[email protected]> and Janos Laube <[email protected]>.
---
arch/arm/mach-gemini/board-nas4220b.c | 53 ++++++++++++++++++++++++++++++ arch/arm/mach-gemini/common.h | 2 + arch/arm/mach-gemini/devices.c | 52 +++++++++++++++++++++++++++++ arch/arm/mach-gemini/include/mach/gmac.h | 21 ++++++++++++ 4 files changed, 128 insertions(+), 0 deletions(-) create mode 100644 arch/arm/mach-gemini/include/mach/gmac.h
arch/arm/mach-gemini/board-nas4220b.c +53 -0
@@ -26,6 +26,7 @@#include <asm/mach/arch.h> #include <asm/mach/time.h> +#include <mach/gmac.h> #include <mach/hardware.h> #include <mach/global_reg.h>
@@ -91,13 +92,65 @@ static struct platform_device ib4220b_key_device = { }, }; +static struct mdio_gpio_platform_data ib4220b_mdio = { + .mdc =22 , + .mdio =21 , + .phy_mask = ~(1 <<1 ), +}; + +static struct platform_device ib4220b_phy_device = { + .name ="mdio-gpio" , + .id =0 , + .dev = { + .platform_data = &ib4220b_mdio, + }, +}; + +static struct gemini_gmac_platform_data ib4220b_gmac_data = { + .bus_id[0 ] ="0:01" , + .interface[0 ] =PHY_INTERFACE_MODE_RGMII , +}; + +static void __init gmac_ib4220b_init (void ) +{ +unsigned int val; + + val =__raw_readl (IO_ADDRESS (GEMINI_GLOBAL_BASE ) + +GLOBAL_IO_DRIVING_CTRL ); + val |= (0x3 <<GMAC0_PADS_SHIFT ) | (0x3 <<GMAC1_PADS_SHIFT ); +__raw_writel (val,IO_ADDRESS (GEMINI_GLOBAL_BASE ) + +GLOBAL_IO_DRIVING_CTRL ); + + val = (0x0 <<GMAC0_RXDV_SKEW_SHIFT ) | (0xf <<GMAC0_RXC_SKEW_SHIFT ) | + (0x7 <<GMAC0_TXEN_SKEW_SHIFT ) | (0xa <<GMAC0_TXC_SKEW_SHIFT ) | + (0x0 <<GMAC1_RXDV_SKEW_SHIFT ) | (0xf <<GMAC1_RXC_SKEW_SHIFT ) | + (0x7 <<GMAC1_TXEN_SKEW_SHIFT ) | (0xa <<GMAC1_TXC_SKEW_SHIFT ); +__raw_writel (val,IO_ADDRESS (GEMINI_GLOBAL_BASE ) + +GLOBAL_GMAC_CTRL_SKEW_CTRL ); + +__raw_writel (0x77777777 ,IO_ADDRESS (GEMINI_GLOBAL_BASE ) + +GLOBAL_GMAC0_DATA_SKEW_CTRL ); +__raw_writel (0x77777777 ,IO_ADDRESS (GEMINI_GLOBAL_BASE ) + +GLOBAL_GMAC1_DATA_SKEW_CTRL ); + + val =__raw_readl (IO_ADDRESS (GEMINI_GLOBAL_BASE ) + +GLOBAL_ARBITRATION1_CTRL ) & ~BURST_LENGTH_MASK ; + val |= (0x20 <<BURST_LENGTH_SHIFT ); +__raw_writel (val,IO_ADDRESS (GEMINI_GLOBAL_BASE ) + +GLOBAL_ARBITRATION1_CTRL ); +} +static void __init ib4220b_init (void ) {gemini_gpio_init (); +gmac_ib4220b_init (); +platform_register_uart ();platform_register_pflash (SZ_16M ,NULL ,0 );platform_device_register (&ib4220b_led_device);platform_device_register (&ib4220b_key_device); +platform_device_register (&ib4220b_phy_device); +platform_register_ethernet (&ib4220b_gmac_data); }MACHINE_START (NAS4220B ,"Raidsonic NAS IB-4220-B" )
arch/arm/mach-gemini/common.h +2 -0
@@ -13,6 +13,7 @@#define __GEMINI_COMMON_H__struct mtd_partition ; +struct gemini_gmac_platform_data ;extern void gemini_map_io (void );extern void gemini_init_irq (void );
@@ -21,6 +22,7 @@ extern void gemini_gpio_init(void);/* Common platform devices registration functions */ extern int platform_register_uart (void ); +extern int platform_register_ethernet (struct gemini_gmac_platform_data *pdata);extern int platform_register_pflash (unsigned int size,struct mtd_partition *parts,unsigned int nr_parts);
arch/arm/mach-gemini/devices.c +52 -0
64 lines not on this page · raw message
arch/arm/mach-gemini/include/mach/gmac.h new file +21 -0
@@ -0,0 +1,21 @@ +/* +* Gemini GMAC specific defines +* +* Copyright (C) 2008, Paulius Zaleckas <[email protected]> +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation; either version 2 of the License, or +* (at your option) any later version. +*/ +#ifndef __MACH_GMAC_H__ +#define __MACH_GMAC_H__ + +#include <linux/phy.h> + +struct gemini_gmac_platform_data { +char *bus_id[2 ];/* NULL means that this port is not used */ +phy_interface_t interface[2 ]; +}; + +#endif /* __MACH_GMAC_H__ */
Signature · 1 line
1.7.1
RFC PATCH 2/2 Gemini: SL351x Ethernet driver
In reply to Michał MirosławDriver for SL351x (Gemini) SoC ethernet peripheral. Based on work by Paulius Zaleckas and GPLd code from Raidsonic and other NAS vendors.
Tested on Raidsonic IcyBox 4220-B (dual SATA NAS).
--- drivers/net/Kconfig | 7 + drivers/net/Makefile | 1 + drivers/net/sl351x.c | 1706 +++++++++++++++++++++++++++++++++++++++++++++++ drivers/net/sl351x_hw.h | 1423 +++++++++++++++++++++++++++++++++++++++ 4 files changed, 3137 insertions(+), 0 deletions(-) create mode 100644 drivers/net/sl351x.c create mode 100644 drivers/net/sl351x_hw.h
drivers/net/Kconfig +7 -0
@@ -2068,6 +2068,13 @@ config ACENIC_OMIT_TIGON_I The safe and default value for this is N. +config GEMINI_SL351X + tristate "StorLink SL351x Gigabit Ethernet support" + depends on ARCH_GEMINI + select PHYLIB + help + This driver supports StorLink SL351x (Gemini) dual Gigabit Ethernet. + config DL2K tristate "DL2000/TC902x-based Gigabit Ethernet support" depends on PCI
drivers/net/Makefile +1 -0
@@ -257,6 +257,7 @@ obj-$(CONFIG_MLX4_CORE) += mlx4/ obj-$(CONFIG_ENC28J60) += enc28j60.o obj-$(CONFIG_ETHOC) += ethoc.o obj-$(CONFIG_GRETH) += greth.o +obj-$(CONFIG_GEMINI_SL351X) += sl351x.o obj-$(CONFIG_XTENSA_XT2000_SONIC) += xtsonic.o
drivers/net/sl351x.c new file +1706 -0
1,706 lines not on this page · raw message
drivers/net/sl351x_hw.h new file +1423 -0
1,274 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
Signature · 1 line
1.7.1
Part of the diff is not shown here. View the raw message.
2010/10/29 Micha? Miros?aw <[email protected]>:
Quoted 8 lines
This is a driver for SL351x (Gemini) SoC ethernet peripheral. Based on work by Paulius Zaleckas and GPLd code from Raidsonic and other NAS vendors.
This is work in progress. Please comment and test if you can. Patches are against 2.6.37-rc (current Linus' tree) but should apply to 2.6.36. You probably also need patches for PATA from ? ? ? ?git://git.berlios.de/gemini-board ib4220
Nice to hear!
Quoted 8 lines
Known bugs:
?- repeatable bad HW calculated TCP csum
? ?happens for only some packets in a TCP stream
? ?looks like it doesn't like some data pattern or timing ? ?(difference between correct and generated csum is the same ? ?when the packet is retransmitted with changed header/TCP tstamp) ?- TX DMA hangs sometimes (needs module reload when that happens) ? ?with debugging printks disabled and HW TX csum enabled
AFAIK DMA hangs are associated with HW checksum errors. So generally disabling HW csum is the best solution so far. If I am not wrong, OpenWRT does just this in their patches.
DMA hangs happen for other reasons as well and main cause seems to be MII interface. If timing is wrong or some noise gets onto PCB tracks it is very likely
that DMA will hang. Also using both ports at one time increases posibility of hang.
Quoted 14 lines
?- unsynced counters
I started to work on Paulius' code to find out why the TX DMA hangs happen, but then I realized that complete rewrite was a better way to understand how the hardware works and why it doesn't. As a "bonus" this got some additional features:
?- ethtool support
?- 64-bit counters
?- proper cleanup on ifdown/module unload
?- better DMA API usage
?- cleaned up code
?- a lot of tx/rx debugging printks
?- based on 2.6.36 DMA and netdev interfaces
Quoted 3 lines
TODO:
?- NAPI
?- MTU changing
Super cool! NAPI shouldn't be very hard...
Quoted 5 lines
For normal use tx-csum and tso have to be disabled:
? ethtool -K eth0 tso off tx offTested on Raidsonic IcyBox 4220-B (dual SATA NAS).
Quoted 8 lines
I'm also interested in getting copies of various GPL packages for StorLink SL3516. I already have following packages (md5sum):
89991e543eb2e473e3d380ac9a4cd8b4?GPL_source_code(Raidsonic).zip6ba8b833c429794315f0a73ce2961bd8?Gemini_v2_6_0-n.tgzfe87e97a33554bcab8284d25ff86e383?n299_n199_1.00.24_GPL.tar.bz2eca8994354368304ca3b5bd1429c20bb?sl-boot_1.0.9.tgzeafd6497074fe0651459bf38c39d66bd?vt4kern-1.5.tar.bz2.tar
I will see what I can provide you when I get home.
Quoted 24 lines
Best Regards,
Micha? Miros?aw---
Micha? Miros?aw (2):
?Gemini: create platform device for ethernet in Raidsonic IB-4220B ?Gemini: SL351x Ethernet driver?arch/arm/mach-gemini/board-nas4220b.c ? ?| ? 53 + ?arch/arm/mach-gemini/common.h ? ? ? ? ? ?| ? ?2 + ?arch/arm/mach-gemini/devices.c ? ? ? ? ? | ? 52 + ?arch/arm/mach-gemini/include/mach/gmac.h | ? 21 + ?drivers/net/Kconfig ? ? ? ? ? ? ? ? ? ? ?| ? ?7 + ?drivers/net/Makefile ? ? ? ? ? ? ? ? ? ? | ? ?1 + ?drivers/net/sl351x.c ? ? ? ? ? ? ? ? ? ? | 1706 ++++++++++++++++++++++++++++++ ?drivers/net/sl351x_hw.h ? ? ? ? ? ? ? ? ?| 1423 +++++++++++++++++++++++++?8 files changed, 3265 insertions(+), 0 deletions(-) ?create mode 100644
arch/arm/mach-gemini/include/mach/gmac.h?create mode 100644drivers/net/sl351x.c
?create mode 100644drivers/net/sl351x_hw.h
Re: [RFC PATCH 1/2] Gemini: create platform device for ethernet in Raidsonic IB-4220B
In reply to Michał Mirosław2010/10/29 Micha? Miros?aw <[email protected]>:
Quoted 17 lines
This is cherry-picked from:
git://git.berlios.de/gemini-boardib4220Code by Paulius Zaleckas <[email protected]> and Janos Laube <[email protected]>.
Signed-off-by Micha? Miros?aw <[email protected]>---
?arch/arm/mach-gemini/board-nas4220b.c ? ?| ? 53 ++++++++++++++++++++++++++++++ ?arch/arm/mach-gemini/common.h ? ? ? ? ? ?| ? ?2 + ?arch/arm/mach-gemini/devices.c ? ? ? ? ? | ? 52 +++++++++++++++++++++++++++++ ?arch/arm/mach-gemini/include/mach/gmac.h | ? 21 ++++++++++++?4 files changed, 128 insertions(+), 0 deletions(-) ?create mode 100644
arch/arm/mach-gemini/include/mach/gmac.h
[...]
arch/arm/mach-gemini/include/mach/gmac.h line 4
Quoted 10 lines
arch/arm/mach-gemini/include/mach/gmac.h new file +4
-0@@ -0,0 +1,21 @@ +/* +* Gemini GMAC specific defines +* +* Copyright (C) 2008, Paulius Zaleckas <[email protected]>
This e-mail is dead. Please change it to gmail one.
Quoted 21 lines
arch/arm/mach-gemini/include/mach/gmac.h new file +17
-1+* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation; either version 2 of the License, or +* (at your option) any later version. +*/ +#ifndef __MACH_GMAC_H__ +#define __MACH_GMAC_H__ + +#include <linux/phy.h> + +struct gemini_gmac_platform_data { + ? ? ? char *bus_id[2]; /* NULL means that this port is not used */ + ? ? ? phy_interface_t interface[2]; +}; + +#endif /* __MACH_GMAC_H__ */ --1.7.1