Skip to content

Commit

Permalink
Merge branch 'net-ethernet-mtk_eth_soc-add-basic-support-for-mt7988-soc'
Browse files Browse the repository at this point in the history
Daniel Golle says:

====================
net: ethernet: mtk_eth_soc: add basic support for MT7988 SoC

The MediaTek MT7988 SoC introduces a new version (3) of the NETSYS
block and comes with three instead of two MACs.

The first MAC can be internally connected to a built-in Gigabit
Ethernet switch with four 1000M/100M/10M twisted pair user ports.

The second MAC can be internally connected to a built-in 2500Base-T
Ethernet PHY.

There are two SerDes units which can be operated in USXGMII, 10GBase-(K)R,
5GBase-R, 2500Base-X, 1000Base-X or SGMII interface mode.

This series adds initial support for NETSYS v3 and the first MAC of the
MT7988 SoC connecting the built-in DSA switch.

The switch is supported since commit 110c18b ("net: dsa: mt7530:
introduce driver for MT7988 built-in switch").

Basic support for the 1000M/100M/10M built-in PHYs connected to the
switch ports is present since commit ("98c485eaf509b net: phy: add
driver for MediaTek SoC built-in GE PHYs").
====================

Link: https://lore.kernel.org/r/cover.1690246066.git.daniel@makrotopia.org
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
  • Loading branch information
Jakub Kicinski committed Jul 27, 2023
2 parents ac3cb6d + 445eb64 commit 707116b
Show file tree
Hide file tree
Showing 7 changed files with 668 additions and 226 deletions.
109 changes: 102 additions & 7 deletions Documentation/devicetree/bindings/net/mediatek,net.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,12 @@ properties:
enum:
- mediatek,mt2701-eth
- mediatek,mt7623-eth
- mediatek,mt7621-eth
- mediatek,mt7622-eth
- mediatek,mt7629-eth
- mediatek,mt7981-eth
- mediatek,mt7986-eth
- mediatek,mt7988-eth
- ralink,rt5350-eth

reg:
Expand All @@ -32,7 +34,7 @@ properties:
clock-names: true

interrupts:
minItems: 3
minItems: 1
maxItems: 4

power-domains:
Expand Down Expand Up @@ -60,6 +62,12 @@ properties:
Phandle to the mediatek hifsys controller used to provide various clocks
and reset to the system.

mediatek,infracfg:
$ref: /schemas/types.yaml#/definitions/phandle
description:
Phandle to the syscon node that handles the path from GMAC to
PHY variants.

mediatek,sgmiisys:
$ref: /schemas/types.yaml#/definitions/phandle-array
minItems: 1
Expand Down Expand Up @@ -121,6 +129,8 @@ allOf:
- const: gp1
- const: gp2

mediatek,infracfg: false

mediatek,pctl:
$ref: /schemas/types.yaml#/definitions/phandle
description:
Expand All @@ -131,6 +141,32 @@ allOf:

mediatek,wed-pcie: false

- if:
properties:
compatible:
contains:
enum:
- mediatek,mt7621-eth
then:
properties:
interrupts:
maxItems: 1

clocks:
minItems: 2
maxItems: 2

clock-names:
items:
- const: ethif
- const: fe

mediatek,infracfg: false

mediatek,wed: false

mediatek,wed-pcie: false

- if:
properties:
compatible:
Expand Down Expand Up @@ -159,6 +195,8 @@ allOf:
- const: sgmii_ck
- const: eth2pll

mediatek,infracfg: false

mediatek,sgmiisys:
minItems: 1
maxItems: 1
Expand Down Expand Up @@ -204,12 +242,6 @@ allOf:
- const: sgmii_ck
- const: eth2pll

mediatek,infracfg:
$ref: /schemas/types.yaml#/definitions/phandle
description:
Phandle to the syscon node that handles the path from GMAC to
PHY variants.

mediatek,sgmiisys:
minItems: 2
maxItems: 2
Expand Down Expand Up @@ -250,6 +282,8 @@ allOf:
- const: netsys0
- const: netsys1

mediatek,infracfg: false

mediatek,sgmiisys:
minItems: 2
maxItems: 2
Expand Down Expand Up @@ -286,6 +320,67 @@ allOf:
- const: netsys0
- const: netsys1

mediatek,infracfg: false

mediatek,sgmiisys:
minItems: 2
maxItems: 2

- if:
properties:
compatible:
contains:
const: mediatek,mt7988-eth
then:
properties:
interrupts:
minItems: 4

clocks:
minItems: 34
maxItems: 34

clock-names:
items:
- const: crypto
- const: fe
- const: gp2
- const: gp1
- const: gp3
- const: ethwarp_wocpu2
- const: ethwarp_wocpu1
- const: ethwarp_wocpu0
- const: esw
- const: netsys0
- const: netsys1
- const: sgmii_tx250m
- const: sgmii_rx250m
- const: sgmii2_tx250m
- const: sgmii2_rx250m
- const: top_usxgmii0_sel
- const: top_usxgmii1_sel
- const: top_sgm0_sel
- const: top_sgm1_sel
- const: top_xfi_phy0_xtal_sel
- const: top_xfi_phy1_xtal_sel
- const: top_eth_gmii_sel
- const: top_eth_refck_50m_sel
- const: top_eth_sys_200m_sel
- const: top_eth_sys_sel
- const: top_eth_xgmii_sel
- const: top_eth_mii_sel
- const: top_netsys_sel
- const: top_netsys_500m_sel
- const: top_netsys_pao_2x_sel
- const: top_netsys_sync_250m_sel
- const: top_netsys_ppefb_250m_sel
- const: top_netsys_warp_sel
- const: wocpu1
- const: wocpu0
- const: xgp1
- const: xgp2
- const: xgp3

mediatek,sgmiisys:
minItems: 2
maxItems: 2
Expand Down
36 changes: 19 additions & 17 deletions drivers/net/ethernet/mediatek/mtk_eth_path.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@
struct mtk_eth_muxc {
const char *name;
int cap_bit;
int (*set_path)(struct mtk_eth *eth, int path);
int (*set_path)(struct mtk_eth *eth, u64 path);
};

static const char *mtk_eth_path_name(int path)
static const char *mtk_eth_path_name(u64 path)
{
switch (path) {
case MTK_ETH_PATH_GMAC1_RGMII:
Expand All @@ -40,10 +40,10 @@ static const char *mtk_eth_path_name(int path)
}
}

static int set_mux_gdm1_to_gmac1_esw(struct mtk_eth *eth, int path)
static int set_mux_gdm1_to_gmac1_esw(struct mtk_eth *eth, u64 path)
{
bool updated = true;
u32 val, mask, set;
u32 mask, set, reg;

switch (path) {
case MTK_ETH_PATH_GMAC1_SGMII:
Expand All @@ -59,19 +59,21 @@ static int set_mux_gdm1_to_gmac1_esw(struct mtk_eth *eth, int path)
break;
}

if (updated) {
val = mtk_r32(eth, MTK_MAC_MISC);
val = (val & mask) | set;
mtk_w32(eth, val, MTK_MAC_MISC);
}
if (mtk_is_netsys_v3_or_greater(eth))
reg = MTK_MAC_MISC_V3;
else
reg = MTK_MAC_MISC;

if (updated)
mtk_m32(eth, mask, set, reg);

dev_dbg(eth->dev, "path %s in %s updated = %d\n",
mtk_eth_path_name(path), __func__, updated);

return 0;
}

static int set_mux_gmac2_gmac0_to_gephy(struct mtk_eth *eth, int path)
static int set_mux_gmac2_gmac0_to_gephy(struct mtk_eth *eth, u64 path)
{
unsigned int val = 0;
bool updated = true;
Expand All @@ -94,7 +96,7 @@ static int set_mux_gmac2_gmac0_to_gephy(struct mtk_eth *eth, int path)
return 0;
}

static int set_mux_u3_gmac2_to_qphy(struct mtk_eth *eth, int path)
static int set_mux_u3_gmac2_to_qphy(struct mtk_eth *eth, u64 path)
{
unsigned int val = 0, mask = 0, reg = 0;
bool updated = true;
Expand Down Expand Up @@ -125,7 +127,7 @@ static int set_mux_u3_gmac2_to_qphy(struct mtk_eth *eth, int path)
return 0;
}

static int set_mux_gmac1_gmac2_to_sgmii_rgmii(struct mtk_eth *eth, int path)
static int set_mux_gmac1_gmac2_to_sgmii_rgmii(struct mtk_eth *eth, u64 path)
{
unsigned int val = 0;
bool updated = true;
Expand Down Expand Up @@ -163,7 +165,7 @@ static int set_mux_gmac1_gmac2_to_sgmii_rgmii(struct mtk_eth *eth, int path)
return 0;
}

static int set_mux_gmac12_to_gephy_sgmii(struct mtk_eth *eth, int path)
static int set_mux_gmac12_to_gephy_sgmii(struct mtk_eth *eth, u64 path)
{
unsigned int val = 0;
bool updated = true;
Expand Down Expand Up @@ -218,7 +220,7 @@ static const struct mtk_eth_muxc mtk_eth_muxc[] = {
},
};

static int mtk_eth_mux_setup(struct mtk_eth *eth, int path)
static int mtk_eth_mux_setup(struct mtk_eth *eth, u64 path)
{
int i, err = 0;

Expand Down Expand Up @@ -249,7 +251,7 @@ static int mtk_eth_mux_setup(struct mtk_eth *eth, int path)

int mtk_gmac_sgmii_path_setup(struct mtk_eth *eth, int mac_id)
{
int path;
u64 path;

path = (mac_id == 0) ? MTK_ETH_PATH_GMAC1_SGMII :
MTK_ETH_PATH_GMAC2_SGMII;
Expand All @@ -260,7 +262,7 @@ int mtk_gmac_sgmii_path_setup(struct mtk_eth *eth, int mac_id)

int mtk_gmac_gephy_path_setup(struct mtk_eth *eth, int mac_id)
{
int path = 0;
u64 path = 0;

if (mac_id == 1)
path = MTK_ETH_PATH_GMAC2_GEPHY;
Expand All @@ -274,7 +276,7 @@ int mtk_gmac_gephy_path_setup(struct mtk_eth *eth, int mac_id)

int mtk_gmac_rgmii_path_setup(struct mtk_eth *eth, int mac_id)
{
int path;
u64 path;

path = (mac_id == 0) ? MTK_ETH_PATH_GMAC1_RGMII :
MTK_ETH_PATH_GMAC2_RGMII;
Expand Down
Loading

0 comments on commit 707116b

Please sign in to comment.