Add ethernet support for MT7622
Subsystems (3)
cover Add ethernet support for MT7622
This patch series adds and enable ethernet support for MT7622, including
1. add sgmii mode support in mediatek eth driver
2. add mt7622 support in mediatek eth driver
3. add ethernet and sgmii dts node for mt7622
4. enable mt7622 ethernet support in defconfig
MarkLee (4):
eth: mtk-eth: add sgmii mode support in mediatek eth driver
eth: mtk-eth: add mt7622 support in mediatek eth driver
arm: dts: mediatek: add ethernet and sgmii dts node for mt7622
configs: mediatek: enable mt7622 ethernet support
arch/arm/dts/mt7622-rfb.dts | 13 ++++++++++ arch/arm/dts/mt7622.dtsi | 45 +++++++++++++++++++++++++++++++++ configs/mt7622_rfb_defconfig | 4 +++ drivers/net/mtk_eth.c | 49 +++++++++++++++++++++++++++++++++++- drivers/net/mtk_eth.h | 15 +++++++++++ 5 files changed, 125 insertions(+), 1 deletion(-)
Signature · 1 line
2.17.1
PATCH 1/4 eth: mtk-eth: add sgmii mode support in mediatek eth driver
This patch add sgmii init part for the mediatek SoC that support sgmii mode. It is a must for mt7622.
--- drivers/net/mtk_eth.c | 44 +++++++++++++++++++++++++++++++++++++++++++ drivers/net/mtk_eth.h | 15 +++++++++++++++ 2 files changed, 59 insertions(+)
drivers/net/mtk_eth.c +44 -0
@@ -151,6 +151,7 @@ struct mtk_eth_priv {void __iomem *fe_base;void __iomem *gmac_base;void __iomem *ethsys_base; +void __iomem *sgmii_base;struct mii_dev *mdio_bus;int (*mii_read)(struct mtk_eth_priv *priv,u8 phy,u8 reg);
@@ -750,6 +751,24 @@ static int mtk_phy_probe(struct udevice *dev)return 0 ; } +static void mtk_sgmii_init (struct mtk_eth_priv *priv) +{ +/* Set SGMII GEN2 speed(2.5G) */ +clrsetbits_le32 (priv->sgmii_base +SGMSYS_GEN2_SPEED , +SGMSYS_SPEED_2500 ,SGMSYS_SPEED_2500 ); + +/* Disable SGMII AN */ +clrsetbits_le32 (priv->sgmii_base +SGMSYS_PCS_CONTROL_1 , +SGMII_AN_ENABLE ,0 ); + +/* SGMII force mode setting */ +writel (SGMII_FORCE_MODE , priv->sgmii_base +SGMSYS_SGMII_MODE ); + +/* Release PHYA power down state */ +clrsetbits_le32 (priv->sgmii_base +SGMSYS_QPHY_PWR_STATE_CTRL , +SGMII_PHYA_PWD ,0 ); +} +static void mtk_mac_init (struct mtk_eth_priv *priv) {int i, ge_mode =0 ;
@@ -758,8 +777,13 @@ static void mtk_mac_init(struct mtk_eth_priv *priv)switch (priv->phy_interface) {case PHY_INTERFACE_MODE_RGMII_RXID :case PHY_INTERFACE_MODE_RGMII : + ge_mode =GE_MODE_RGMII ; +break ;case PHY_INTERFACE_MODE_SGMII : ge_mode =GE_MODE_RGMII ; +mtk_ethsys_rmw (priv,ETHSYS_SYSCFG0_REG ,SYSCFG0_SGMII_SEL_M , +SYSCFG0_SGMII_SEL (priv->gmac_id)); +mtk_sgmii_init (priv);break ;case PHY_INTERFACE_MODE_MII :case PHY_INTERFACE_MODE_GMII :
@@ -1104,6 +1128,26 @@ static int mtk_eth_ofdata_to_platdata(struct udevice *dev) } } +if (priv->phy_interface ==PHY_INTERFACE_MODE_SGMII ) { +/* get corresponding sgmii phandle */ + ret =dev_read_phandle_with_args (dev,"mediatek,sgmiisys" , +NULL ,0 ,0 , &args); +if (ret) +return ret; + + regmap =syscon_node_to_regmap (args.node); + +if (IS_ERR (regmap)) +return PTR_ERR (regmap); + + priv->sgmii_base =regmap_get_range (regmap,0 ); + +if (!priv->sgmii_base) { +dev_err (dev,"Unable to find sgmii\n" ); +return -ENODEV ; + } + } +/* check for switch first, otherwise phy will be used */ priv->sw =SW_NONE ; priv->switch_init =NULL ;
drivers/net/mtk_eth.h +15 -0
@@ -20,6 +20,8 @@#define ETHSYS_SYSCFG0_REG 0x14#define SYSCFG0_GE_MODE_S (n) (12 + ((n) * 2))#define SYSCFG0_GE_MODE_M 0x3 +#define SYSCFG0_SGMII_SEL_M (0x3 << 8) +#define SYSCFG0_SGMII_SEL (gmac) ((!(gmac)) ? BIT(9) : BIT(8))#define ETHSYS_CLKCFG0_REG 0x2c#define ETHSYS_TRGMII_CLK_SEL362_5 BIT(11)
@@ -30,6 +32,19 @@#define GE_MODE_MII_PHY 2#define GE_MODE_RMII 3 +/* SGMII subsystem config registers */ +#define SGMSYS_PCS_CONTROL_1 0x0 +#define SGMII_AN_ENABLE BIT(12) + +#define SGMSYS_SGMII_MODE 0x20 +#define SGMII_FORCE_MODE 0x31120019 + +#define SGMSYS_QPHY_PWR_STATE_CTRL 0xe8 +#define SGMII_PHYA_PWD BIT(4) + +#define SGMSYS_GEN2_SPEED 0x2028 +#define SGMSYS_SPEED_2500 BIT(2) +/* Frame Engine Registers */ /* PDMA */
Signature · 1 line
2.17.1
PATCH 1/4 eth: mtk-eth: add sgmii mode support in mediatek eth driver
Quoted 4 lines · MarkLee
This patch add sgmii init part for the mediatek SoC that support sgmii mode. It is a must for mt7622.
Signed-off-by MarkLee <[email protected]>
Applied to u-boot/master, thanks!
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 833 bytes Desc: not available URL: <https://lists.denx.de/pipermail/u-boot/attachments/20200207/56925056/attachment.sig>
PATCH 2/4 eth: mtk-eth: add mt7622 support in mediatek eth driver
In reply to MarkLeeThis patch add mt7622 support in mediatek eth driver
--- drivers/net/mtk_eth.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/net/mtk_eth.c +3 -1
@@ -136,7 +136,8 @@ enum mtk_switch {enum mtk_soc {SOC_MT7623 , -SOC_MT7629 +SOC_MT7629 , +SOC_MT7622 };struct mtk_eth_priv {
@@ -1196,6 +1197,7 @@ static int mtk_eth_ofdata_to_platdata(struct udevice *dev)static const struct udevice_id mtk_eth_ids[] = { { .compatible ="mediatek,mt7629-eth" , .data =SOC_MT7629 }, { .compatible ="mediatek,mt7623-eth" , .data =SOC_MT7623 }, + { .compatible ="mediatek,mt7622-eth" , .data =SOC_MT7622 }, {} };
Signature · 1 line
2.17.1
PATCH 2/4 eth: mtk-eth: add mt7622 support in mediatek eth driver
Quoted 3 lines · MarkLee
This patch add mt7622 support in mediatek eth driver
Signed-off-by MarkLee <[email protected]>
Applied to u-boot/master, thanks!
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 833 bytes Desc: not available URL: <https://lists.denx.de/pipermail/u-boot/attachments/20200207/1bee8d71/attachment.sig>
PATCH 3/4 arm: dts: mediatek: add ethernet and sgmii dts node for mt7622
In reply to MarkLeeThis patch add eth and sgmii dts node for mt7622 to support ethernet
--- arch/arm/dts/mt7622-rfb.dts | 13 +++++++++++ arch/arm/dts/mt7622.dtsi | 45 +++++++++++++++++++++++++++++++++++++ 2 files changed, 58 insertions(+)
arch/arm/dts/mt7622-rfb.dts +13 -0
@@ -178,3 +178,16 @@ pinctrl-0 = <&watchdog_pins>; status = "okay"; }; + +ð { + status = "okay"; + mediatek,gmac-id = <0>; + phy-mode = "sgmii"; + mediatek,switch = "mt7531"; + reset-gpios = <&gpio 54 GPIO_ACTIVE_HIGH>; + + fixed-link { + speed = <1000>; + full-duplex; + }; +};
arch/arm/dts/mt7622.dtsi +45 -0
55 lines not on this page · raw message
Signature · 1 line
2.17.1
PATCH 3/4 arm: dts: mediatek: add ethernet and sgmii dts node for mt7622
Quoted 3 lines · MarkLee
This patch add eth and sgmii dts node for mt7622 to support ethernet
Signed-off-by MarkLee <[email protected]>
Applied to u-boot/master, thanks!
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 833 bytes Desc: not available URL: <https://lists.denx.de/pipermail/u-boot/attachments/20200207/5eea21b4/attachment.sig>
PATCH 4/4 configs: mediatek: enable mt7622 ethernet support
In reply to MarkLeeThis patch enable mt7622 ethernet support in its defconfig
--- configs/mt7622_rfb_defconfig | 4 ++++ 1 file changed, 4 insertions(+)
configs/mt7622_rfb_defconfig +4 -0
@@ -34,6 +34,10 @@ CONFIG_SPI_FLASH_SPANSION=y CONFIG_SPI_FLASH_STMICRO=y CONFIG_SPI_FLASH_WINBOND=y CONFIG_DM_ETH=y +CONFIG_PHY_FIXED=y +CONFIG_MEDIATEK_ETH=y +CONFIG_NET_RANDOM_ETHADDR=y +CONFIG_CMD_PING=y CONFIG_PINCTRL=y CONFIG_PINCONF=y CONFIG_PINCTRL_MT7622=y
Signature · 1 line
2.17.1
PATCH 4/4 configs: mediatek: enable mt7622 ethernet support
Quoted 12 lines · MarkLee
This patch enable mt7622 ethernet support in its defconfig
Signed-off-by MarkLee <[email protected]>--- configs/mt7622_rfb_defconfig | 4 ++++ 1 file changed, 4 insertions(+)configs/mt7622_rfb_defconfig +0
-0
configs/mt7622_rfb_defconfig CONFIG_SPI_FLASH_SPANSION=y · line 43
Quoted 10 lines
configs/mt7622_rfb_defconfig +4
-0@@ -34,6 +34,10 @@ CONFIG_SPI_FLASH_SPANSION=y CONFIG_SPI_FLASH_STMICRO=y CONFIG_SPI_FLASH_WINBOND=y CONFIG_DM_ETH=y +CONFIG_PHY_FIXED=y +CONFIG_MEDIATEK_ETH=y +CONFIG_NET_RANDOM_ETHADDR=y +CONFIG_CMD_PING=y CONFIG_PINCTRL=y CONFIG_PINCONF=y CONFIG_PINCTRL_MT7622=y
This leads to warnings in the ethernet driver:drivers/net/mtk_eth.c: In function 'mtk_eth_fifo_init':drivers/net/mtk_eth.c:856:21: error: cast from pointer to integer of different size [-Werror=pointer-to-int-cast]
flush_dcache_range((u32)pkt_base, (u32)(pkt_base + TOTAL_PKT_BUF_SIZE));
^
drivers/net/mtk_eth.c:856:36: error: cast from pointer to integer of different size [-Werror=pointer-to-int-cast]
^drivers/net/mtk_eth.c: In function 'mtk_eth_send':drivers/net/mtk_eth.c:968:21: error: cast from pointer to integer of different size [-Werror=pointer-to-int-cast]
flush_dcache_range((u32)pkt_base, (u32)pkt_base +drivers/net/mtk_eth.c:968:36: error: cast from pointer to integer of different size [-Werror=pointer-to-int-cast] drivers/net/mtk_eth.c: In function 'mtk_eth_recv':drivers/net/mtk_eth.c:994:26: error: cast from pointer to integer of different size [-Werror=pointer-to-int-cast]
invalidate_dcache_range((u32)pkt_base, (u32)pkt_base +
^
drivers/net/mtk_eth.c:994:41: error: cast from pointer to integer of different size [-Werror=pointer-to-int-cast]
^
drivers/net/mtk_eth.c: In function 'mtk_eth_probe':
drivers/net/mtk_eth.c:1026:18: error: cast to pointer from integer of different size [-Werror=int-to-pointer-cast]
priv->fe_base = (void *)iobase;
^drivers/net/mtk_eth.c:1029:20: error: cast to pointer from integer of different size [-Werror=int-to-pointer-cast]
priv->gmac_base = (void *)(iobase + GMAC_BASE);
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 833 bytes Desc: not available URL: <https://lists.denx.de/pipermail/u-boot/attachments/20200127/9bf5dc26/attachment.sig>
Aw: Re: [U-boot,4/4] configs: mediatek: enable mt7622 ethernet support
Hi tom,
thanks for testing
imho the first 3 can be fixed by this:
drivers/net/mtk_eth.c +4 -4
@@ -853,7 +853,7 @@ static void mtk_eth_fifo_init(struct mtk_eth_priv *priv)memset (priv->rx_ring_noc,0 ,NUM_RX_DESC *sizeof (struct pdma_rxdesc ));memset (priv->pkt_pool,0 ,TOTAL_PKT_BUF_SIZE ); -flush_dcache_range ((u32 )pkt_base, (u32)(pkt_base +TOTAL_PKT_BUF_SIZE )); +flush_dcache_range ((int )pkt_base, (int )(pkt_base +TOTAL_PKT_BUF_SIZE )); priv->rx_dma_owner_idx0 =0 ; priv->tx_cpu_owner_idx0 =0 ;
@@ -965,7 +965,7 @@ static int mtk_eth_send(struct udevice *dev, void *packet, int length) pkt_base = (void *)phys_to_virt (priv->tx_ring_noc[idx].txd_info1.SDP0);memcpy (pkt_base, packet, length); -flush_dcache_range ((u32 )pkt_base, (u32 )pkt_base + +flush_dcache_range ((int )pkt_base, (int )pkt_base +roundup (length,ARCH_DMA_MINALIGN )); priv->tx_ring_noc[idx].txd_info2.SDL0 = length;
@@ -991,8 +991,8 @@ static int mtk_eth_recv(struct udevice *dev, int flags, uchar **packetp) length = priv->rx_ring_noc[idx].rxd_info2.PLEN0; pkt_base = (void *)phys_to_virt (priv->rx_ring_noc[idx].rxd_info1.PDP0); -invalidate_dcache_range ((u32 )pkt_base, (u32 )pkt_base + -roundup (length,ARCH_DMA_MINALIGN )); +invalidate_dcache_range ((int )pkt_base, (unsigned int )(pkt_base + +roundup (length,ARCH_DMA_MINALIGN )));if (packetp) *packetp = pkt_base;
did not get the last 2 (after fixing the first 3)...
i can send full patch if it's ok
regards Frank
Quoted 58 lines
Gesendet: Montag, 27. Januar 2020 um 19:49 Uhr
Von: "Tom Rini" <[email protected]>
An: MarkLee <[email protected]>
Cc: "Albert Aribaud" <[email protected]>, "Ryder Lee" <[email protected]>, "Steven Liu" <[email protected]>, "Joe Hershberger" <[email protected]>, u-boot at lists.denx.de,GSS_MTK_Uboot_upstream<[email protected]>
Betreff: Re: [U-boot,4/4] configs: mediatek: enable mt7622 ethernet supportQuoted 12 lines · MarkLee
This patch enable mt7622 ethernet support in its defconfig
Signed-off-by MarkLee <[email protected]>--- configs/mt7622_rfb_defconfig | 4 ++++ 1 file changed, 4 insertions(+)configs/mt7622_rfb_defconfig +0
-0configs/mt7622_rfb_defconfig CONFIG_SPI_FLASH_SPANSION=y · line 43
Quoted 10 lines
configs/mt7622_rfb_defconfig +4
-0@@ -34,6 +34,10 @@ CONFIG_SPI_FLASH_SPANSION=y CONFIG_SPI_FLASH_STMICRO=y CONFIG_SPI_FLASH_WINBOND=y CONFIG_DM_ETH=y +CONFIG_PHY_FIXED=y +CONFIG_MEDIATEK_ETH=y +CONFIG_NET_RANDOM_ETHADDR=y +CONFIG_CMD_PING=y CONFIG_PINCTRL=y CONFIG_PINCONF=y CONFIG_PINCTRL_MT7622=yThis leads to warnings in the ethernet driver:
drivers/net/mtk_eth.c: In function 'mtk_eth_fifo_init':drivers/net/mtk_eth.c:856:21: error: cast from pointer to integer of different size [-Werror=pointer-to-int-cast]flush_dcache_range((u32)pkt_base, (u32)(pkt_base + TOTAL_PKT_BUF_SIZE)); ^ drivers/net/mtk_eth.c:856:36: error: cast from pointer to integer of different size [-Werror=pointer-to-int-cast] ^
drivers/net/mtk_eth.c: In function 'mtk_eth_send':drivers/net/mtk_eth.c:968:21: error: cast from pointer to integer of different size [-Werror=pointer-to-int-cast]
flush_dcache_range((u32)pkt_base, (u32)pkt_base +drivers/net/mtk_eth.c:968:36: error: cast from pointer to integer of different size [-Werror=pointer-to-int-cast]drivers/net/mtk_eth.c: In function 'mtk_eth_recv':drivers/net/mtk_eth.c:994:26: error: cast from pointer to integer of different size [-Werror=pointer-to-int-cast]
invalidate_dcache_range((u32)pkt_base, (u32)pkt_base +^ drivers/net/mtk_eth.c:994:41: error: cast from pointer to integer of different size [-Werror=pointer-to-int-cast] ^ drivers/net/mtk_eth.c: In function 'mtk_eth_probe': drivers/net/mtk_eth.c:1026:18: error: cast to pointer from integer of different size [-Werror=int-to-pointer-cast] priv->fe_base = (void *)iobase; ^
drivers/net/mtk_eth.c:1029:20: error: cast to pointer from integer of different size [-Werror=int-to-pointer-cast]
priv->gmac_base= (void *)(iobase +GMAC_BASE);--
Tom
PATCH 4/4 configs: mediatek: enable mt7622 ethernet support
In reply to MarkLeeQuoted 3 lines · MarkLee
This patch enable mt7622 ethernet support in its defconfig
Signed-off-by MarkLee <[email protected]>
Applied to u-boot/master, thanks!
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 833 bytes Desc: not available URL: <https://lists.denx.de/pipermail/u-boot/attachments/20200207/37773e3c/attachment.sig>
Hi Mark,
does it depend on another patch(set)?
i got unsupported switch, because in eth-driver [1] there is a check only for mt7530 (else print this error) and in dts [2], mediatek,switch is set to mt7531 (which is right, but trigger the error).
i found no patch adding check for mt7531 (or change this check) in patchwork
[1] https://github.com/frank-w/u-boot/blob/aed9e2af65651d036d742b30f8b4ce2d5f4d215a/drivers/net/mtk_eth.c#L1162
[2] https://github.com/frank-w/u-boot/blob/29464fe9546c83ad34fdcc395f6e45a9a8538631/arch/arm/dts/mt7622-rfb.dts#L186
regards Frank
Quoted 4 lines · Frank Wunderlich
Hi Mark,
does it depend on another patch(set)?
Quoted 8 lines
i got unsupported switch, because in eth-driver [1] there is a check only for mt7530 (else print this error) and in dts [2], mediatek,switch is set to mt7531 (which is right, but trigger the error).
i found no patch adding check for mt7531 (or change this check) in patchwork
[1] https://github.com/frank-w/u-boot/blob/aed9e2af65651d036d742b30f8b4ce2d5f4d215a/drivers/net/mtk_eth.c#L1162
[2] https://github.com/frank-w/u-boot/blob/29464fe9546c83ad34fdcc395f6e45a9a8538631/arch/arm/dts/mt7622-rfb.dts#L186regards Frank
Hi Frank :
This patches set just focus on adding mt7622 into mtk eth MAC driver
with sgmii support, and yes for some mt7622 product(bpi-r64..etc) that has a internal switch(mt7531) still need patches to support mt7531 to make networking function work fully.
We do have plan to send a separate patches for mt7531 switch once this
mt7622 eth patch set accepted by uBoot. Thanks to you put a big spotlight on mt7622 development, we will do it asap.
Mark
Hi
Quoted 7 lines
Gesendet: Mittwoch, 22. Januar 2020 um 09:43 Uhr
Von: "mtk15127" <[email protected]>This patches set just focus on adding mt7622 into mtk eth MAC driver
with sgmii support, and yes for some mt7622 product(bpi-r64..etc) that has a internal switch(mt7531) still need patches to support mt7531 to make networking function work fully.
i wondered about changes in ref-board dts. does it contain also mt7531 as switch? imho we need an extra dts for bpi-r64 because ram is different (1G instead of 256M) and for future changes which are only for r64.
Quoted 2 lines
We do have plan to send a separate patches for mt7531 switch once this mt7622 eth patch set accepted by uBoot.
@tom is this Patchset ok or does it need any changes? any way to merge it in actual merge-window, so mark can work on switch-part?
@Mark, is there any pre-release of switch-driver that i can try before you post to mailinglist?
regards Frank