At present the GEM ethernet on SiFive Unleashed board can only work
Subsystems (3)
v2 cover At present the GEM ethernet on SiFive Unleashed board can only work
in 1000 Mbps mode. With a 10/100 Mbps connection it just fails to do any network communication.
This adds a new GEMGXL clock driver to adjust the clock settings per the connection speed so that 10/100 Mbps works.
Changes in v2:
- rename driver name to "sifive-gemgxl-mgmt"
- add a comment for getting "tx_clk" via clk_get_by_name()
- does not change anything in the default case
- check the return value of clk_set_rate()
Bin Meng (4):
clk: sifive: Add clock driver for GEMGXL MGMT
dm: net: macb: Update macb_linkspd_cb() signature
dm: net: macb: Implement link speed change callback
riscv: sifive: fu540: Enable GEMGXL MGMT driver
board/sifive/fu540/Kconfig | 1 + drivers/clk/sifive/Kconfig | 7 +++++ drivers/clk/sifive/Makefile | 2 ++ drivers/clk/sifive/gemgxl-mgmt.c | 60 ++++++++++++++++++++++++++++++++++++++++ drivers/net/macb.c | 57 +++++++++++++++++++++++++++++++++++++- 5 files changed, 126 insertions(+), 1 deletion(-) create mode 100644 drivers/clk/sifive/gemgxl-mgmt.c
Signature · 1 line
2.7.4
PATCH v2 1/4 clk: sifive: Add clock driver for GEMGXL MGMT
This adds a clock driver to support the GEMGXL management IP block found in FU540 SoCs to control GEM TX clock operation mode for 10/100/1000 Mbps.
---
Changes in v2:
- rename driver name to "sifive-gemgxl-mgmt"
drivers/clk/sifive/Kconfig | 7 +++++ drivers/clk/sifive/Makefile | 2 ++ drivers/clk/sifive/gemgxl-mgmt.c | 60 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 69 insertions(+) create mode 100644 drivers/clk/sifive/gemgxl-mgmt.c
drivers/clk/sifive/Kconfig +7 -0
@@ -17,3 +17,10 @@ config CLK_SIFIVE_FU540_PRCI Supports the Power Reset Clock interface (PRCI) IP block found in FU540 SoCs. If this kernel is meant to run on a SiFive FU540 SoC, enable this driver. + +config CLK_SIFIVE_GEMGXL_MGMT + bool "GEMGXL management for SiFive FU540 SoCs" + depends on CLK_SIFIVE + help + Supports the GEMGXL management IP block found in FU540 SoCs to + control GEM TX clock operation mode for 10/100/1000 Mbps.
drivers/clk/sifive/Makefile +2 -0
@@ -3,3 +3,5 @@ obj-$(CONFIG_CLK_ANALOGBITS_WRPLL_CLN28HPC) += wrpll-cln28hpc.o obj-$(CONFIG_CLK_SIFIVE_FU540_PRCI) += fu540-prci.o + +obj-$(CONFIG_CLK_SIFIVE_GEMGXL_MGMT) += gemgxl-mgmt.o
drivers/clk/sifive/gemgxl-mgmt.c new file +60 -0
60 lines not on this page · raw message
Signature · 1 line
2.7.4
[U-Boot] clk: sifive: Add clock driver for GEMGXL MGMT
Hi Bin,
https://patchwork.ozlabs.org/patch/1103216/ was applied to http://git.denx.de/?p=u-boot/u-boot-net.git
Thanks!
-Joe
PATCH v2 2/4 dm: net: macb: Update macb_linkspd_cb() signature
In reply to Bin MengThis updates DM version macb_linkspd_cb() signature for future expansion, eg: adding an implementation for link speed changes.
---
Changes in v2: None
drivers/net/macb.c | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-)
drivers/net/macb.c +21 -1
@@ -488,15 +488,23 @@ static int macb_phy_find(struct macb_device *macb, const char *name)/** * macb_linkspd_cb - Linkspeed change callback function -* @regs: Base Register of MACB devices +* @dev/@regs: MACB udevice (DM version) or +* Base Register of MACB devices (non-DM version) * @speed: Linkspeed * Returns 0 when operation success and negative errno number * when operation failed. */ +#ifdef CONFIG_DM_ETH +int __weak macb_linkspd_cb (struct udevice *dev,unsigned int speed) +{ +return 0 ; +} +#else int __weak macb_linkspd_cb (void *regs,unsigned int speed) {return 0 ; } +#endif #ifdef CONFIG_DM_ETH static int macb_phy_init (struct udevice *dev,const char *name)
@@ -589,7 +597,11 @@ static int macb_phy_init(struct macb_device *macb, const char *name)macb_writel (macb,NCFGR , ncfgr); +#ifdef CONFIG_DM_ETH + ret =macb_linkspd_cb (dev, _1000BASET); +#else ret =macb_linkspd_cb (macb->regs, _1000BASET); +#endif if (ret)return ret;
@@ -614,9 +626,17 @@ static int macb_phy_init(struct macb_device *macb, const char *name) ncfgr &= ~(MACB_BIT (SPD ) |MACB_BIT (FD ) |GEM_BIT (GBE ));if (speed) { ncfgr |=MACB_BIT (SPD ); +#ifdef CONFIG_DM_ETH + ret =macb_linkspd_cb (dev, _100BASET); +#else ret =macb_linkspd_cb (macb->regs, _100BASET); +#endif }else { +#ifdef CONFIG_DM_ETH + ret =macb_linkspd_cb (dev, _10BASET); +#else ret =macb_linkspd_cb (macb->regs, _10BASET); +#endif }if (ret)
Signature · 1 line
2.7.4
PATCH v2 2/4 dm: net: macb: Update macb_linkspd_cb() signature
Quoted 6 lines · Bin Meng
This updates DM version
macb_linkspd_cb()signature for future expansion, eg: adding an implementation for link speed changes.Signed-off-by Bin Meng <[email protected]>Reviewed-by Lukas Auer <[email protected]>
[U-Boot] dm: net: macb: Update macb_linkspd_cb() signature
In reply to Bin MengHi Bin,
https://patchwork.ozlabs.org/patch/1103219/ was applied to http://git.denx.de/?p=u-boot/u-boot-net.git
Thanks!
-Joe
PATCH v2 3/4 dm: net: macb: Implement link speed change callback
In reply to Bin MengAt present the link speed change callback is a nop. According to macb device tree bindings, an optional "tx_clk" is used to clock the ethernet controller's TX_CLK under different link speed.
In 10/100 MII mode, transmit logic must be clocked from a free running clock generated by the external PHY. In gigabit GMII mode, the controller, not the external PHY, must generate the 125 MHz transmit clock towards the PHY.
---
Changes in v2:
- add a comment for getting "tx_clk" via clk_get_by_name()
- does not change anything in the default case
- check the return value of clk_set_rate()
drivers/net/macb.c | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+)
drivers/net/macb.c +35 -0
@@ -497,6 +497,41 @@ static int macb_phy_find(struct macb_device *macb, const char *name)#ifdef CONFIG_DM_ETH int __weak macb_linkspd_cb (struct udevice *dev,unsigned int speed) { +#ifdef CONFIG_CLK +struct clk tx_clk; +ulong rate; +int ret; + +/* +* "tx_clk" is an optional clock source for MACB. +* Ignore if it does not exist in DT. +*/ + ret =clk_get_by_name (dev,"tx_clk" , &tx_clk); +if (ret) +return 0 ; + +switch (speed) { +case _10BASET: + rate =2500000 ;/* 2.5 MHz */ +break ; +case _100BASET: + rate =25000000 ;/* 25 MHz */ +break ; +case _1000BASET: + rate =125000000 ;/* 125 MHz */ +break ; +default : +/* does not change anything */ +return 0 ; + } + +if (tx_clk.dev) { + ret =clk_set_rate (&tx_clk, rate); +if (ret) +return ret; + } +#endif +return 0 ; }#else
Signature · 1 line
2.7.4
Auer
PATCH v2 3/4 dm: net: macb: Implement link speed change callback
Quoted 13 lines · Bin Meng
At present the link speed change callback is a nop. According to macb device tree bindings, an optional "
tx_clk" is used to clock the ethernet controller'sTX_CLKunder different link speed.In 10/100 MII mode, transmit logic must be clocked from a free running clock generated by the external PHY. In gigabit GMII mode, the controller, not the external PHY, must generate the 125 MHz transmit clock towards the PHY.
Signed-off-by Bin Meng <[email protected]>---
Quoted 8 lines
Changes in v2:
- add a comment for getting "tx_clk" viaclk_get_by_name()
- does not change anything in the default case
- check the return value ofclk_set_rate()drivers/net/macb.c | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+)
Successfully tested the series on a SiFive HiFive Unleashed board at 1000, 100, and 10 Mbps link rates.
PATCH v2 3/4 dm: net: macb: Implement link speed change callback
In reply to Bin MengQuoted 11 lines · Bin Meng
At present the link speed change callback is a nop. According to macb device tree bindings, an optional "
tx_clk" is used to clock the ethernet controller'sTX_CLKunder different link speed.In 10/100 MII mode, transmit logic must be clocked from a free running clock generated by the external PHY. In gigabit GMII mode, the controller, not the external PHY, must generate the 125 MHz transmit clock towards the PHY.
Signed-off-by Bin Meng <[email protected]>
[U-Boot] dm: net: macb: Implement link speed change callback
In reply to Bin MengHi Bin,
https://patchwork.ozlabs.org/patch/1103218/ was applied to http://git.denx.de/?p=u-boot/u-boot-net.git
Thanks!
-Joe
PATCH v2 4/4 riscv: sifive: fu540: Enable GEMGXL MGMT driver
In reply to Bin MengEnable the new GEMGXL MGMT driver so that GEM 10/100 Mbps works now.
---
Changes in v2: None
board/sifive/fu540/Kconfig | 1 + 1 file changed, 1 insertion(+)
board/sifive/fu540/Kconfig +1 -0
@@ -28,6 +28,7 @@ config BOARD_SPECIFIC_OPTIONS # dummy imply CMD_PING imply CLK_SIFIVE imply CLK_SIFIVE_FU540_PRCI + imply CLK_SIFIVE_GEMGXL_MGMT imply DOS_PARTITION imply EFI_PARTITION imply IP_DYN
Signature · 1 line
2.7.4
[U-Boot] riscv: sifive: fu540: Enable GEMGXL MGMT driver
Hi Bin,
https://patchwork.ozlabs.org/patch/1103220/ was applied to http://git.denx.de/?p=u-boot/u-boot-net.git
Thanks!
-Joe
v2 cover At present the GEM ethernet on SiFive Unleashed board can only work
In reply to Bin MengHi Joe,
Quoted 7 lines · Bin Meng
in 1000 Mbps mode. With a 10/100 Mbps connection it just fails to do any network communication.
This adds a new GEMGXL clock driver to adjust the clock settings per the connection speed so that 10/100 Mbps works.
Lukas has reviewed and tested this series (thanks Lukas!)
Would you please apply this series for v2019.07?
Regards,
Bin