LL TEMAC V7 refactored
Subsystems (2)
Back to the discussion from August and November I have refactored the LL TEMAC driver. Just in version V7 it is ready to next review. Thanks to Marek and Wolfgang to review V4..6.
Note: To use the driver on Microblaze, you will need additional platform patches by Michal Simek:
- http://patchwork.ozlabs.org/patch/112535/
- http://patchwork.ozlabs.org/patch/112534/
- http://patchwork.ozlabs.org/patch/112532/
I will collect all related patches on a public bundle:
- http://patchwork.ozlabs.org/bundle/rexut/net-ll_temac/
PATCH v7 1/1 net: ll_temac: Add LL TEMAC driver to u-boot
Xilinx LocalLink Tri-Mode Ether MAC driver can be
used by Xilinx Microblaze or Xilinx ppc405/440 in
SDMA and FIFO mode. DCR or XPS bus can be used.
The driver uses and requires MII and PHYLIB.
CP: 4 warnings: 'Use of volatile is usually wrong' I won't fix this, because it depends on the network driver subsystem.
---
v7: Call udelay() in polling loops to avoid unintended watchdog reset
Define well known timeout values in usec
Handle timeouts as error situations
Reduce duplicated code in SDMA operations
Add a real and plausible PHY detect mask
Remove ETH_HALTING code exclusion
Code cleanup as recommended
Fix typos
v6: Code cleanup with ./tools/checkpatch.pl
v5: Remove more endless loops
Remove useless parenthesis in pointer operations Move phyaddr predefinition on top
Remove supernumerary newlines
Remove parenthesis around numbers (globally)
v4: Separate fifo and sdma code from driver core
Split sdma code into separate DCR and XPS bus access code Add extensive register struct definitions and enumerations Add new callbacks into fifo an sdma code
Prepare CDMAC buffer handling to be unique for every instance Separate Xilinx specific indirect DCR access, so we can move to arch Remove useless 'emac' parameter from indirect access helper functions Correct MDIO clock setup.
Remove endless loops
Common code beautifying
v3: Use helper functions for fifo mode
Use helper functions for indirect accesses
Code cleanup
Add comments for MAGIC values
Simplify code in fifo mode
v2: Remove helper function for access to temac
Remove SDMA/FIFO/DCR macros and configure it in board Setup mac by write_hwaddr
--- drivers/net/Makefile | 2 + drivers/net/xilinx_ll_temac.c | 459 ++++++++++++++++++++++++++++++++++++ drivers/net/xilinx_ll_temac.h | 313 ++++++++++++++++++++++++ drivers/net/xilinx_ll_temac_fifo.c | 99 ++++++++ drivers/net/xilinx_ll_temac_fifo.h | 116 +++++++++ drivers/net/xilinx_ll_temac_sdma.c | 318 +++++++++++++++++++++++++ drivers/net/xilinx_ll_temac_sdma.h | 286 ++++++++++++++++++++++ include/netdev.h | 2 + 8 files changed, 1595 insertions(+), 0 deletions(-) create mode 100644 drivers/net/xilinx_ll_temac.c create mode 100644 drivers/net/xilinx_ll_temac.h create mode 100644 drivers/net/xilinx_ll_temac_fifo.c create mode 100644 drivers/net/xilinx_ll_temac_fifo.h create mode 100644 drivers/net/xilinx_ll_temac_sdma.c create mode 100644 drivers/net/xilinx_ll_temac_sdma.h
drivers/net/Makefile +2 -0
@@ -76,6 +76,8 @@ COBJS-$(CONFIG_ULI526X) += uli526x.o COBJS-$(CONFIG_VSC7385_ENET) += vsc7385.o COBJS-$(CONFIG_XILINX_AXIEMAC) += xilinx_axi_emac.o COBJS-$(CONFIG_XILINX_EMACLITE) += xilinx_emaclite.o +COBJS-$(CONFIG_XILINX_LL_TEMAC) += xilinx_ll_temac.o \ + xilinx_ll_temac_fifo.o xilinx_ll_temac_sdma.o COBJS := $(sort $(COBJS-y)) SRCS := $(COBJS:.o=.c)
drivers/net/xilinx_ll_temac.c new file +459 -0
459 lines not on this page · raw message
drivers/net/xilinx_ll_temac.h new file +313 -0
313 lines not on this page · raw message
drivers/net/xilinx_ll_temac_fifo.c new file +99 -0
99 lines not on this page · raw message
drivers/net/xilinx_ll_temac_fifo.h new file +116 -0
116 lines not on this page · raw message
drivers/net/xilinx_ll_temac_sdma.c new file +318 -0
318 lines not on this page · raw message
drivers/net/xilinx_ll_temac_sdma.h new file +286 -0
286 lines not on this page · raw message
include/netdev.h +2 -0
@@ -100,6 +100,8 @@ int xilinx_axiemac_initialize(bd_t *bis, unsigned long base_addr, unsigned long dma_addr);int xilinx_emaclite_initialize (bd_t *bis,unsigned long base_addr,int txpp,int rxpp); +int xilinx_ll_temac_initialize (bd_t *bis,unsigned long base_addr, +int mode,unsigned long ctrl);/* Boards with PCI network controllers can call this from their board_eth_init() * function to initialize whatever's on board.
Signature · 1 line
1.7.0.4
PATCH v7 1/1 net: ll_temac: Add LL TEMAC driver to u-boot
Dear Stephan Linz,
Quoted 11 lines · In message <[email protected]> you wrote:
Xilinx LocalLink Tri-Mode Ether MAC driver can be used by Xilinx Microblaze or Xilinx ppc405/440 in SDMA and FIFO mode. DCR or XPS bus can be used.
The driver uses and requires MII and PHYLIB.
CP: 4 warnings: 'Use of volatile is usually wrong' I won't fix this, because it depends on the network driver subsystem.
Signed-off-by Stephan Linz <[email protected]>
Are there going to be any users for this code?
Best regards,
Wolfgang Denk
Signature · 4 lines
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de panic: kernel trap (ignored)
PATCH v7 1/1 net: ll_temac: Add LL TEMAC driver to u-boot
Am Dienstag, den 20.12.2011, 23:56 +0100 schrieb Wolfgang Denk:
Quoted 1 line
Dear Stephan Linz,
Hello Wolfgang,
Quoted 8 lines
Quoted 6 lines · In message <[email protected]> you wrote:
Xilinx LocalLink Tri-Mode Ether MAC driver can be used by Xilinx Microblaze or Xilinx ppc405/440 in SDMA and FIFO mode. DCR or XPS bus can be used.
The driver uses and requires MII and PHYLIB.
Quoted 7 lines
Quoted 5 lines
CP: 4 warnings: 'Use of volatile is usually wrong' I won't fix this, because it depends on the network driver subsystem.
Signed-off-by Stephan Linz <[email protected]>Are there going to be any users for this code?
Yes, of course. There are three plattform patches by Michal Simek that still waiting to merge in together with the v7 ll_temac driver. This patches enable the ll_temac driver for the microblaze-generic plattform. See patchwork public bundle:
http://patchwork.ozlabs.org/bundle/rexut/net-ll_temac/
I'll rebase all three patches and post it on this thread ...
Signature · 2 lines
Best regards, Stephan Linz
PATCH 1/3 microblaze: Enable several ethernet driver compilation
In reply to Wolfgang DenkFrom: Michal Simek <[email protected]>
NET_MULTI enables to use several ethernet drivers but microblaze-generic platform config file select only one driver.
--- include/configs/microblaze-generic.h | 9 +++++---- 1 files changed, 5 insertions(+), 4 deletions(-)
include/configs/microblaze-generic.h +5 -4
@@ -65,11 +65,12 @@/* ethernet */ #undef CONFIG_SYS_ENET -#ifdef XILINX_EMACLITE_BASEADDR -# define CONFIG_XILINX_EMACLITE 1 +#if defined(XILINX_EMACLITE_BASEADDR ) +# define CONFIG_XILINX_EMACLITE 1# define CONFIG_SYS_ENET -#elif XILINX_LLTEMAC_BASEADDR -# define CONFIG_XILINX_LL_TEMAC 1 +#endif +#if defined(XILINX_LLTEMAC_BASEADDR ) +# define CONFIG_XILINX_LL_TEMAC 1# define CONFIG_SYS_ENET #endif #if defined(XILINX_AXIEMAC_BASEADDR )
Signature · 1 line
1.7.0.4
PATCH 2/3 microblaze: Enable phylib and mii support
In reply to Wolfgang DenkFrom: Michal Simek <[email protected]>
--- include/configs/microblaze-generic.h | 21 +++++++++++++++++++++ 1 files changed, 21 insertions(+), 0 deletions(-)
include/configs/microblaze-generic.h +21 -0
@@ -339,4 +339,25 @@#define CONFIG_FIT 1#define CONFIG_OF_LIBFDT 1 +#if defined(CONFIG_XILINX_LL_TEMAC ) || defined(CONFIG_XILINX_AXIEMAC ) +# define CONFIG_MII 1 +# define CONFIG_CMD_MII 1 +# define CONFIG_PHY_GIGE 1 +# define CONFIG_SYS_FAULT_ECHO_LINK_DOWN 1 +# define CONFIG_PHYLIB 1 +# define CONFIG_PHY_ATHEROS 1 +# define CONFIG_PHY_BROADCOM 1 +# define CONFIG_PHY_DAVICOM 1 +# define CONFIG_PHY_LXT 1 +# define CONFIG_PHY_MARVELL 1 +# define CONFIG_PHY_MICREL 1 +# define CONFIG_PHY_NATSEMI 1 +# define CONFIG_PHY_REALTEK 1 +# define CONFIG_PHY_VITESSE 1 +#else +# undef CONFIG_MII +# undef CONFIG_CMD_MII +# undef CONFIG_PHYLIB +#endif +#endif /* __CONFIG_H */
Signature · 1 line
1.7.0.4
PATCH 3/3 microblaze: Wire up LL_TEMAC driver initialization
In reply to Wolfgang DenkFrom: Michal Simek <[email protected]>
Initialize ll_temac driver.
--- .../xilinx/microblaze-generic/microblaze-generic.c | 16 ++++++++++++++++ 1 files changed, 16 insertions(+), 0 deletions(-)
board/xilinx/microblaze-generic/microblaze-generic.c +16 -0
@@ -90,5 +90,21 @@ int board_eth_init(bd_t *bis) ret |=xilinx_emaclite_initialize (bis,XILINX_EMACLITE_BASEADDR , txpp, rxpp);#endif + +#ifdef CONFIG_XILINX_LL_TEMAC +# ifdef XILINX_LLTEMAC_FIFO_BASEADDR + ret |=xilinx_ll_temac_initialize (bis,XILINX_LLTEMAC_BASEADDR , +0 ,XILINX_LLTEMAC_FIFO_BASEADDR ); +# elif XILINX_LLTEMAC_SDMA_CTRL_BASEADDR +# if XILINX_LLTEMAC_SDMA_USE_DCR ==1 + ret |=xilinx_ll_temac_initialize (bis,XILINX_LLTEMAC_BASEADDR , +3 ,XILINX_LLTEMAC_SDMA_CTRL_BASEADDR ); +# else + ret |=xilinx_ll_temac_initialize (bis,XILINX_LLTEMAC_BASEADDR , +1 ,XILINX_LLTEMAC_SDMA_CTRL_BASEADDR ); +# endif +# endif +#endif +return ret; }
Signature · 1 line
1.7.0.4
PATCH v7 1/1 net: ll_temac: Add LL TEMAC driver to u-boot
In reply to Wolfgang DenkQuoted 9 lines · Wolfgang Denk
Dear Stephan Linz,
Quoted 6 lines · In message <[email protected]> you wrote:
Xilinx LocalLink Tri-Mode Ether MAC driver can be used by Xilinx Microblaze or Xilinx ppc405/440 in SDMA and FIFO mode. DCR or XPS bus can be used.
The driver uses and requires MII and PHYLIB.
Quoted 8 lines
Quoted 5 lines
CP: 4 warnings: 'Use of volatile is usually wrong' I won't fix this, because it depends on the network driver subsystem.
Signed-off-by Stephan Linz <[email protected]>Are there going to be any users for this code?
Sure. This driver lies out of mainline code for quite some times. ll_temac is IP core which is used by Microblaze and xilinx ppc. There are two options for network IP. The first is emaclite driver which is in the mainline and high speed and especially 1Gb/s LAN ll_temac driver.
Regards,
Michal
Signature · 4 lines
Michal Simek, Ing. (M.Eng) w: www.monstr.eu p: +42-0-721842854 Maintainer of Linux kernel 2.6 Microblaze Linux - http://www.monstr.eu/fdt/ Microblaze U-BOOT custodian
PATCH v7 1/1 net: ll_temac: Add LL TEMAC driver to u-boot
Dear Michal Simek,
Quoted 7 lines · In message <[email protected]> you wrote:
Quoted 2 lines
Are there going to be any users for this code?
Sure. This driver lies out of mainline code for quite some times.
ll_temacis IP core which is used by Microblaze and xilinx ppc. There are two options for network IP. The first is emaclite driver which is in the mainline and high speed and especially 1Gb/s LANll_temacdriver.
Then let's add it when the first board gets submitted that uses it.
Best regards,
Wolfgang Denk
Signature · 6 lines
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de Nobody trips over mountains. It is the small pebble that causes you to stumble. Pass all the pebbles in your path and you will find you have crossed the mountain.
PATCH v7 1/1 net: ll_temac: Add LL TEMAC driver to u-boot
Am Donnerstag, den 05.01.2012, 17:10 +0100 schrieb Wolfgang Denk:
Quoted 4 lines
Dear Michal Simek,
Quoted 1 line · In message <[email protected]> you wrote:
Quoted 8 lines
Quoted 6 lines
Quoted 1 line
Are there going to be any users for this code?
Sure. This driver lies out of mainline code for quite some times.
ll_temacis IP core which is used by Microblaze and xilinx ppc. There are two options for network IP. The first is emaclite driver which is in the mainline and high speed and especially 1Gb/s LANll_temacdriver.Then let's add it when the first board gets submitted that uses it.
Michals latest Microblaze platform patches will enable this driver for board/xilinx/microblaze-generic and we know about a success story on a propietary Virtex5 FX board (ppc440) -- tested by Ricardo Ribalda.
So it could be save to add the driver together with Michals platform patches. It works fine to me on different ML605 (Virtex 6) and SP3ADSP1800 (Spartan 3) Microblaze systems but ...
Last week, I received hints from Andy Fleming to improve the PHYLIB handling and avoid deprecated code. So I'll rework the driver and present a new v8 patch as soon as possible.
Signature · 8 lines
Best regards, Stephan Linz ______________________________________________________________________________ MB-Ref: http://www.li-pro.de/xilinx_mb:mbref:start OpenDCC: http://www.li-pro.net/opendcc.phtml PC/M: http://www.li-pro.net/pcm.phtml Sourceforge: http://sourceforge.net/users/slz Gitorious: https://gitorious.org/~slz
PATCH v7 1/1 net: ll_temac: Add LL TEMAC driver to u-boot
Dear Stephan Linz,
Quoted 8 lines · In message <1325783490.7827.45.camel@keto> you wrote:
Michals latest Microblaze platform patches will enable this driver for board/xilinx/microblaze-generic and we know about a success story on a propietary Virtex5 FX board (ppc440) -- tested by Ricardo Ribalda.
So it could be save to add the driver together with Michals platform patches. It works fine to me on different ML605 (Virtex 6) and SP3ADSP1800 (Spartan 3) Microblaze systems but ...
Frankly, I don't care at all about reports that it is working for this or that out of tree port. As long as there is no code in mainline that will use the driver and thus profide a way to test if it's actually compile clean, I will not add it.
Quoted 3 lines
Last week, I received hints from Andy Fleming to improve the PHYLIB handling and avoid deprecated code. So I'll rework the driver and present a new v8 patch as soon as possible.
OK. Please submit it only if it comes with code that references the driver.
Best regards,
Wolfgang Denk
Signature · 5 lines
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de History tends to exaggerate. -- Col. Green, "The Savage Curtain", stardate 5906.4
PATCH v7 1/1 net: ll_temac: Add LL TEMAC driver to u-boot
Am Donnerstag, den 05.01.2012, 20:19 +0100 schrieb Wolfgang Denk:
Quoted 8 lines
Dear Stephan Linz,
Quoted 5 lines · In message <1325783490.7827.45.camel@keto> you wrote:
Michals latest Microblaze platform patches will enable this driver for board/xilinx/microblaze-generic and we know about a success story on a propietary Virtex5 FX board (ppc440) -- tested by Ricardo Ribalda.
Quoted 6 lines
Quoted 1 line
-- snip --
So I'll rework the driver and
Quoted 1 line
present a new v8 patch as soon as possible.
OK. Please submit it only if it comes with code that references the driver.
Hi Wolfgang,
I understand your opinions to stick together all the different code fragments. Unfortunately, this driver will be used by systems with synthesized hardware (FPGA SoftCPU systems). The target board (hardware around the FPGA) will be fixed but the content (CPU, controller, busses, interfacess, addresses, ...) will be variable and not fixed. That's why we use a so named microblaze-generic board configuration controlled by the header xparameters.h in board directory. The default content of xparameters.h is really only basic and enables not nearly half of all possibilities. For example the default configuration in xparameters.h will enable the Xilinx EMAC-Lite driver (with XILINX_EMACLITE_BASEADDR) but do nothing to enable the Xilinx AXI-EMAC driver (with XILINX_AXIEMAC_BASEADDR) -- it makes no sense to enable both at the same time.
I'll provide the same way for the Xilinx LL_TEMAC driver as for the Xilinx AXI-EMAC driver. I prepare the microblaze-generic board code to support all potential Ethernet drivers but leave out the specific usage. You are right when you say that there is no code that refere to the new driver code -- there are also no configuration for this. And yes we adapt/change the xparameters.h out of mainline tree to enable the driver code -- but I think, that is not really a "out of tree port".
But what would be the best implementation for unspecified targets here?
@Michal: Is there anybody who use the current default configuration from microblaze-generic/xparameters.h on a real FPGA system design? If not we could expand xparameters.h with a fantasy configuration to enable all potential drivers used on a Microblaze system. So we have a reference to driver code and can test the rebuild again and again with a simple 'make microblaze-generic'. What do you mean?
Signature · 8 lines
Best regards, Stephan Linz ______________________________________________________________________________ MB-Ref: http://www.li-pro.de/xilinx_mb:mbref:start OpenDCC: http://www.li-pro.net/opendcc.phtml PC/M: http://www.li-pro.net/pcm.phtml Sourceforge: http://sourceforge.net/users/slz Gitorious: https://gitorious.org/~slz
PATCH v7 1/1 net: ll_temac: Add LL TEMAC driver to u-boot
Quoted 16 lines · Stephan Linz
Am Donnerstag, den 05.01.2012, 20:19 +0100 schrieb Wolfgang Denk:
Quoted 7 lines
Dear Stephan Linz,
Quoted 4 lines · In message <1325783490.7827.45.camel@keto> you wrote:
Michals latest Microblaze platform patches will enable this driver for board/xilinx/microblaze-generic and we know about a success story on a propietary Virtex5 FX board (ppc440) -- tested by Ricardo Ribalda.
Quoted 5 lines
Quoted 1 line
-- snip --
So I'll rework the driver and
Quoted 1 line
present a new v8 patch as soon as possible.
OK. Please submit it only if it comes with code that references the driver.
Hi Wolfgang,
Quoted 13 lines
I understand your opinions to stick together all the different code fragments. Unfortunately, this driver will be used by systems with synthesized hardware (FPGA SoftCPU systems). The target board (hardware around the FPGA) will be fixed but the content (CPU, controller, busses, interfacess, addresses, ...) will be variable and not fixed. That's why we use a so named microblaze-generic board configuration controlled by the header
xparameters.hin board directory. The default content ofxparameters.his really only basic and enables not nearly half of all possibilities. For example the default configuration inxparameters.hwill enable the Xilinx EMAC-Lite driver (withXILINX_EMACLITE_BASEADDR) but do nothing to enable the Xilinx AXI-EMAC driver (withXILINX_AXIEMAC_BASEADDR) -- it makes no sense to enable both at the same time.
Every fpga system is different that's why I have created microblaze-generic board and BSP generator to generate xparameters.h and config.mk for specific configurations. Make no sense to create new board for every configuration.
The same arguments is valid for xilinx ppc405/ppc440 systems where I am still don't like that there are avnet boards and maybe others.
Quoted 8 lines
I'll provide the same way for the Xilinx
LL_TEMACdriver as for the Xilinx AXI-EMAC driver. I prepare the microblaze-generic board code to support all potential Ethernet drivers but leave out the specific usage. You are right when you say that there is no code that refere to the new driver code -- there are also no configuration for this. And yes we adapt/change thexparameters.hout of mainline tree to enable the driver code -- but I think, that is not really a "out of tree port".
Quoted 8 lines
But what would be the best implementation for unspecified targets here?
@Michal: Is there anybody who use the current default configuration from
microblaze-generic/xparameters.hon a real FPGA system design? If not we could expandxparameters.hwith a fantasy configuration to enable all potential drivers used on a Microblaze system. So we have a reference to driver code and can test the rebuild again and again with a simple 'make microblaze-generic'. What do you mean?
It is the same situation as is for axi-emac and even emaclite. xparamters.h/config.mk are for any old platform which none uses it.
IMHO Stephan suggestion could work - enable all drivers in xparameters.h and enable code compilation.
I can also extend my testing system to compile u-boot with ll_temac and test it on qemu every day.
Thanks,
Michal
Signature · 4 lines
Michal Simek, Ing. (M.Eng) w: www.monstr.eu p: +42-0-721842854 Maintainer of Linux kernel 2.6 Microblaze Linux - http://www.monstr.eu/fdt/ Microblaze U-BOOT custodian
PATCH v7 1/1 net: ll_temac: Add LL TEMAC driver to u-boot
In reply to Stephan LinzDear Stephan Linz,
Quoted 10 lines · In message <1325956366.18981.47.camel@keto> you wrote:
I'll provide the same way for the Xilinx
LL_TEMACdriver as for the Xilinx AXI-EMAC driver. I prepare the microblaze-generic board code to support all potential Ethernet drivers but leave out the specific usage. You are right when you say that there is no code that refere to the new driver code -- there are also no configuration for this. And yes we adapt/change thexparameters.hout of mainline tree to enable the driver code -- but I think, that is not really a "out of tree port".But what would be the best implementation for unspecified targets here?
The question is actually a very simple one here: is there any board configuration in mainline that will actually compile and link against this driver? If yes, then everything is fine. If not, we would not even know if there were gross syntax errors in that code, and we would never notce when changes to other parts break compatibility with it.
This is why I will not add any code that is not used in mainline - out-of-tree users don't help a bit.
Best regards,
Wolfgang Denk
Signature · 5 lines
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de The human mind ordinarily operates at only ten percent of its capaci- ty - the rest is overhead for the operating system.
PATCH v7 1/1 net: ll_temac: Add LL TEMAC driver to u-boot
Quoted 13 lines · Wolfgang Denk
Dear Stephan Linz,
Quoted 9 lines · In message <1325956366.18981.47.camel@keto> you wrote:
I'll provide the same way for the Xilinx
LL_TEMACdriver as for the Xilinx AXI-EMAC driver. I prepare the microblaze-generic board code to support all potential Ethernet drivers but leave out the specific usage. You are right when you say that there is no code that refere to the new driver code -- there are also no configuration for this. And yes we adapt/change thexparameters.hout of mainline tree to enable the driver code -- but I think, that is not really a "out of tree port".But what would be the best implementation for unspecified targets here?
Quoted 8 lines
The question is actually a very simple one here: is there any board configuration in mainline that will actually compile and link against this driver? If yes, then everything is fine. If not, we would not even know if there were gross syntax errors in that code, and we would never notce when changes to other parts break compatibility with it.
This is why I will not add any code that is not used in mainline - out-of-tree users don't help a bit.
OK. Stephan, please send v8 with suggested changes with all patches or link to patches which are necessary to use.
Please also define fake address XILINX_LLTEMAC_BASEADDR in xparameters.h to be compiled. The same we will do for axi emac driver.
Stephan if you like I can add that changes to my custodian git tree and do final testing before we ask Wolfgang to merge.
Thanks,
Michal
Signature · 4 lines
Michal Simek, Ing. (M.Eng) w: www.monstr.eu p: +42-0-721842854 Maintainer of Linux kernel 2.6 Microblaze Linux - http://www.monstr.eu/fdt/ Microblaze U-BOOT custodian
PATCH v7 1/1 net: ll_temac: Add LL TEMAC driver to u-boot
Am Donnerstag, den 12.01.2012, 11:53 +0100 schrieb Michal Simek:
Quoted 14 lines
Quoted 4 lines · Wolfgang Denk
Dear Stephan Linz,
Quoted 1 line
Quoted 1 line
But what would be the best implementation for unspecified targets here?
Quoted 8 lines
The question is actually a very simple one here: is there any board configuration in mainline that will actually compile and link against this driver? If yes, then everything is fine. If not, we would not even know if there were gross syntax errors in that code, and we would never notce when changes to other parts break compatibility with it.
This is why I will not add any code that is not used in mainline - out-of-tree users don't help a bit.
Quoted 7 lines
OK. Stephan, please send v8 with suggested changes with all patches or link to patches which are necessary to use.
Please also define fake addressXILINX_LLTEMAC_BASEADDRinxparameters.hto be compiled. The same we will do for axi emac driver.Stephan if you like I can add that changes to my custodian git tree and do final testing before we ask Wolfgang to merge.
I can release the v8 patch next week. I will do some tests on weekend before I post the results here on list. The next release will be prepared to support more than one TEMAC cores (LL_TEMAC0 nad LL_TEMAC1). So I need a little bit more time to test ....
Signature · 8 lines
Best regards, Stephan Linz ______________________________________________________________________________ MB-Ref: http://www.li-pro.de/xilinx_mb:mbref:start OpenDCC: http://www.li-pro.net/opendcc.phtml PC/M: http://www.li-pro.net/pcm.phtml Sourceforge: http://sourceforge.net/users/slz Gitorious: https://gitorious.org/~slz
PATCH v7 1/1 net: ll_temac: Add LL TEMAC driver to u-boot
In reply to Stephan LinzQuoted 17 lines · Stephan Linz
drivers/net/xilinx_ll_temac.c new file +17
-0+static int phywrite (struct eth_device *dev,u8 phy_addr, + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? u8 reg_addr, u16 phy_data) +{ + ? ? ? struct temac_reg *regs = (struct temac_reg *)dev->iobase; + + ? ? ? out_be32(®s->lsw, (phy_data & LSW_REGDAT_MASK)); + ? ? ? out_be32(®s->ctl, CTL_WEN | TEMAC_MIIMWD); + + ? ? ? out_be32(®s->lsw, + ? ? ? ? ? ? ? ((phy_addr << LSW_PHYAD_POS) & LSW_PHYAD_MASK) | + ? ? ? ? ? ? ? (reg_addr & LSW_REGAD_MASK)); + ? ? ? out_be32(®s->ctl, CTL_WEN | TEMAC_MIIMAI); + + ? ? ? if (check_status(regs, RSE_MIIM_WR)) + ? ? ? ? ? ? ? return 1; + + ? ? ? return 0;
drivers/net/xilinx_ll_temac.c
Quoted 10 lines
drivers/net/xilinx_ll_temac.c new file +10
-0+} + +/* +* Indirect MII PHY read via ll_temac. +* +* http://www.xilinx.com/support/documentation/ip_documentation/xps_ll_temac.pdf +* page 67, Using the MII Management to Access PHY Registers +*/ +static int phyread (struct eth_device *dev,u8 phy_addr, + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? u8 reg_addr, u16 *value)
phywrite() and phyread() are very generic function names that nearly override the PHY Lib's phy_read() and phy_write(). I also notice that these functions don't appear to implement the PHY Lib read/write interface.
drivers/net/xilinx_ll_temac.c
Quoted 12 lines
drivers/net/xilinx_ll_temac.c new file +12
-0+ +/* setting sub-controller and ll_temac to proper setting */ +static int setup_ctrl (struct eth_device *dev) +{ + ? ? ? struct ll_temac *ll_temac = dev->priv; + + ? ? ? if (ll_temac->ctrlreset) { + + ? ? ? ? ? ? ? if (ll_temac->ctrlreset(dev)) + ? ? ? ? ? ? ? ? ? ? ? return 0; + + ? ? ? }
Minor nit - this could be:
if (ll_temac->ctrlreset && ll_temac->ctrlreset(dev))
return 0;
Certainly it needs neither the 2 empty lines, nor the braces.
Review
Quoted 7 lines
(quoted diff) +7
-0+ + ? ? ? if (ll_temac->ctrlinit) { + + ? ? ? ? ? ? ? if (ll_temac->ctrlinit(dev)) + ? ? ? ? ? ? ? ? ? ? ? return 0; + + ? ? ? }
Same here.
Quoted 9 lines
(quoted diff) +9
-0+static int ll_temac_miiphy_read(const char *devname, unsigned char addr, + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? unsigned char reg, unsigned short *value) +{ + ? ? ? int ret; + ? ? ? struct eth_device *dev = eth_get_dev(); + + ? ? ? ret = phyread(dev, addr, reg, value); + ? ? ? debug("%s 0x%x, 0x%x, 0x%x\n", __func__, addr, reg, *value); + ? ? ? return ret;
Review
Quoted 10 lines
(quoted diff) +10
-0+} + +static int ll_temac_miiphy_write(const char *devname, unsigned char addr, + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? unsigned char reg, unsigned short value) +{ + ? ? ? struct eth_device *dev = eth_get_dev(); + + ? ? ? debug("%s 0x%x, 0x%x, 0x%x\n", __func__, addr, reg, value); + ? ? ? return phywrite(dev, addr, reg, value); +}
Please don't implement these functions. They are deprecated. This way of doing things will cause problems if eth_get_dev() doesn't return the ethernet interface you want, and makes it very difficult to do MDIO via something that's not an ethernet interface (Like gpio pins).
Quoted 62 lines
(quoted diff) +62
-0+ +/* + * bis: ? ? ? ? ? ? ? ?board information + * base_addr: ?LL TEMAC register bank + * ctrl_addr: ?LL TEMAC sub-controller register bank (FIFO or SDMA) + * mode: ? ? ? driver mode bit flags (see xilinx_ll_temac.h) + */ +int xilinx_ll_temac_initialize(bd_t *bis, unsigned long base_addr, + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? int mode, unsigned long ctrl_addr) +{ + ? ? ? struct eth_device *dev; + ? ? ? struct ll_temac *ll_temac; + + ? ? ? dev = calloc(1, sizeof(*dev)); + ? ? ? if (dev == NULL) + ? ? ? ? ? ? ? return -1; + + ? ? ? dev->priv = calloc(1, sizeof(struct ll_temac)); + ? ? ? if (dev->priv == NULL) { + ? ? ? ? ? ? ? free(dev); + ? ? ? ? ? ? ? return -1; + ? ? ? } + + ? ? ? ll_temac = dev->priv; + + ? ? ? sprintf(dev->name, "Xlltem.%lx", base_addr); + + ? ? ? dev->iobase = base_addr; + ? ? ? ll_temac->ctrladdr = ctrl_addr; + ? ? ? ll_temac->rx_bp = rx_buffer; + ? ? ? ll_temac->tx_bp = tx_buffer; + ? ? ? ll_temac->rx_dp = &rx_descr; + ? ? ? ll_temac->tx_dp = &tx_descr; + ? ? ? ll_temac->phyaddr = CONFIG_PHY_ADDR; + + ? ? ? dev->init = ll_temac_init; + ? ? ? dev->halt = ll_temac_halt; + ? ? ? dev->write_hwaddr = ll_temac_addr_setup; + + ? ? ? if (mode & M_SDMA) { +#if defined(CONFIG_XILINX_440) || defined(CONFIG_XILINX_405) + ? ? ? ? ? ? ? if (mode & M_DCR) { + ? ? ? ? ? ? ? ? ? ? ? ll_temac_collect_xldcr_sdma_reg_addr(dev); + ? ? ? ? ? ? ? ? ? ? ? ll_temac->in32 = ll_temac_xldcr_in32; + ? ? ? ? ? ? ? ? ? ? ? ll_temac->out32 = ll_temac_xldcr_out32; + ? ? ? ? ? ? ? } else +#endif + ? ? ? ? ? ? ? { + ? ? ? ? ? ? ? ? ? ? ? ll_temac_collect_xlplb_sdma_reg_addr(dev); + ? ? ? ? ? ? ? ? ? ? ? ll_temac->in32 = ll_temac_xlplb_in32; + ? ? ? ? ? ? ? ? ? ? ? ll_temac->out32 = ll_temac_xlplb_out32; + ? ? ? ? ? ? ? } + ? ? ? ? ? ? ? ll_temac->ctrlinit = ll_temac_init_sdma; + ? ? ? ? ? ? ? ll_temac->ctrlhalt = ll_temac_halt_sdma; + ? ? ? ? ? ? ? ll_temac->ctrlreset = ll_temac_reset_sdma; + ? ? ? ? ? ? ? dev->recv = ll_temac_recv_sdma; + ? ? ? ? ? ? ? dev->send = ll_temac_send_sdma; + ? ? ? } else { + ? ? ? ? ? ? ? ll_temac->in32 = NULL; + ? ? ? ? ? ? ? ll_temac->out32 = NULL; + ? ? ? ? ? ? ? ll_temac->ctrlinit = NULL; + ? ? ? ? ? ? ? ll_temac->ctrlhalt = NULL;
Review
Quoted 10 lines
(quoted diff) +10
-0+ ? ? ? ? ? ? ? ll_temac->ctrlreset = ll_temac_reset_fifo; + ? ? ? ? ? ? ? dev->recv = ll_temac_recv_fifo; + ? ? ? ? ? ? ? dev->send = ll_temac_send_fifo; + ? ? ? } + + ? ? ? eth_register(dev); + + ? ? ? miiphy_register(dev->name, ll_temac_miiphy_read, ll_temac_miiphy_write); + ? ? ? ll_temac->bus = miiphy_get_dev_by_name(dev->name); + ? ? ? ll_temac->bus->reset = NULL;
This is fairly broken. miiphy_register() is a deprecated interface, and to use it with PHYLIB is backwards. Use the mdio_register() function, and implement the proper PHY read/write callbacks which are passed a bus handle instead of an ethernet name.
Andy