Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Minor networking fixes #332

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions arch/risc-v/src/mpfs/mpfs_ethernet.c
Original file line number Diff line number Diff line change
Expand Up @@ -3390,6 +3390,10 @@ static int mpfs_phyinit(struct mpfs_ethmac_s *priv)
{
ret = ksz9477_i2c_init(bus, KSZ9477_PORT_SGMII);
}
else
{
ret = -EINVAL;
}

#endif

Expand Down
32 changes: 32 additions & 0 deletions drivers/net/ksz9477.c
Original file line number Diff line number Diff line change
Expand Up @@ -640,6 +640,14 @@ int ksz9477_init(ksz9477_port_t master_port)
return ret ? ret : -EINVAL;
}

/* Errata 16: SGMII registers are not initialized by hardware reset
* To ensure clean environment, reset the switch now.
*/

regval16 = SGMII_CONTROL_SOFT_RESET;
ret = ksz9477_sgmii_write_indirect(KSZ9477_SGMII_CONTROL,
&regval16, 1);

/* Check that indirect access to PHY MMD works.
* Write LED mode to single-LED mode and verify access by
* reading back the value.
Expand Down Expand Up @@ -721,13 +729,25 @@ int ksz9477_init(ksz9477_port_t master_port)
ret = ksz9477_sgmii_write_indirect(KSZ9477_SGMII_AUTONEG_CONTROL,
&regval16, 1);

if (ret != OK)
{
nerr("Failed to set SGMII port into PHY mode, ret %d\n", ret);
return ret ? ret : -EINVAL;
}

/* Write to autonegotiation advertisement register activates the new
* setting. Advertise only full duplex.
*/

regval16 = SGMII_AUTONEG_ADVERTISE_FD;
ret = ksz9477_sgmii_write_indirect(KSZ9477_SGMII_AUTONEG_ADVERTISE,
&regval16, 1);

if (ret != OK)
{
nerr("Failed to set autoneg, ret %d\n", ret);
return ret ? ret : -EINVAL;
}
}

/* Configure the static port-based VLANs */
Expand All @@ -747,6 +767,12 @@ int ksz9477_init(ksz9477_port_t master_port)
g_port_vlan_config[i]);
}

if (ret != OK)
{
nerr("Failed to configure VLANs, ret %d\n", ret);
return ret ? ret : -EINVAL;
}

#endif

#ifdef CONFIG_NET_KSZ9477_PORT_SNIFF
Expand All @@ -760,6 +786,12 @@ int ksz9477_init(ksz9477_port_t master_port)
g_port_mirror_config[i]);
}

if (ret != OK)
{
nerr("Failed to configure sniffer port, ret %d\n", ret);
return ret ? ret : -EINVAL;
}

#endif

return ret;
Expand Down
4 changes: 4 additions & 0 deletions drivers/net/ksz9477_reg.h
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,10 @@

/* Register bit definitions */

/* KSZ9477_SGMII_CONTROL */

#define SGMII_CONTROL_SOFT_RESET (1 << 15)

/* KSZ9477_ID2, KSZ9477_ID1 */

#define KSZ9477_ID 0x9477
Expand Down
Loading