Skip to content

Commit

Permalink
Update EVB-LAN8670-USB kernel driver to latest version released on Fe…
Browse files Browse the repository at this point in the history
…bruary 16th 2024.
  • Loading branch information
aentinger committed Mar 11, 2024
1 parent 204f906 commit 09cbd7a
Show file tree
Hide file tree
Showing 2 changed files with 68 additions and 6 deletions.
51 changes: 51 additions & 0 deletions extras/evb-lan8670-usb-linux-6.1.21/load.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
#!/bin/bash

enable=1
node_id=0
node_count=8
max_bc=0
burst_timer=128
to_timer=32

if [[ $1 == "" ]]
then
echo Proceeding with node id: 0
else
node_id=$1
fi

if [ "$node_id" -ge 0 ] && [ "$node_id" -le 254 ]
then
echo PLCA Parameters:
echo ----------------
echo PLCA: $enable
echo Node id: $node_id
echo Node count: $node_count
echo Max BC: $max_bc
echo Burst Timer: $burst_timer
echo TO Timer: $to_timer
echo ----------------
else
echo Invalid node id: "$node_id"
exit 0
fi

devices=$(ls /sys/bus/usb/drivers/smsc95xx | grep "^[1-9]")
for i in $devices; do
echo Unlinking device: "$i"
echo "$i" | sudo tee /sys/bus/usb/drivers/smsc95xx/unbind > /dev/null
done

if [[ -n $(lsmod | grep microchip_t1s) ]]
then
echo Unloading microchip_t1s driver...
sudo rmmod microchip_t1s
fi

echo Loading microchip_t1s driver...
sudo insmod microchip_t1s.ko enable=$enable node_id=$node_id node_count=$node_count max_bc=$max_bc burst_timer=$burst_timer to_timer=$to_timer

for i in $devices; do
echo Linking device: "$i"
echo "$i" | sudo tee /sys/bus/usb/drivers/smsc95xx/bind > /dev/null
done
23 changes: 17 additions & 6 deletions extras/evb-lan8670-usb-linux-6.1.21/microchip_t1s.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Driver for Microchip 10BASE-T1S PHYs
*
* Support: Microchip Phys:
* lan8670/1/2 Rev.B1, Rev.C0, Rev.C1
* lan8670/1/2 Rev.B1, Rev.C0, Rev.C1, Rev.C2
* lan8650/1 Rev.B0 Internal PHYs
*/

Expand All @@ -14,6 +14,7 @@
#define PHY_ID_LAN867X_REVB1 0x0007C162
#define PHY_ID_LAN867X_REVC0 0x0007C163
#define PHY_ID_LAN867X_REVC1 0x0007C164
#define PHY_ID_LAN867X_REVC2 0x0007C165
#define PHY_ID_LAN865X_REVB0 0x0007C1B3

#define LAN867X_REG_STS2 0x0019
Expand All @@ -34,7 +35,8 @@
#define LAN865X_CFGPARAM_READ_ENABLE BIT(1)

#define LAN86XX_DISABLE_COL_DET 0x0000
#define LAN86XX_ENABLE_COL_DET 0x0083
#define LAN86XX_ENABLE_COL_DET 0x8000
#define LAN86XX_COL_DET_MASK 0x8000
#define LAN86XX_REG_COL_DET_CTRL0 0x0087

/* PLCA enable - Could be configured by parameter */
Expand Down Expand Up @@ -162,14 +164,16 @@ static int lan86xx_configure_plca(struct phy_device *phydev)
return ret;
}
if (plca_enable) {
ret = phy_write_mmd(phydev, MDIO_MMD_VEND2, LAN86XX_REG_COL_DET_CTRL0, LAN86XX_DISABLE_COL_DET);
if (ret < 0)
ret = phy_modify_mmd(phydev, MDIO_MMD_VEND2, LAN86XX_REG_COL_DET_CTRL0,
LAN86XX_COL_DET_MASK, LAN86XX_DISABLE_COL_DET);
if (ret)
return ret;
phydev_info(phydev, "PLCA mode enabled. Node Id: %d, Node Count: %d, Max BC: %d, Burst Timer: %d, TO Timer: %d\n",
plca_node_id, plca_node_count, max_bc, burst_timer, to_timer);
} else {
ret = phy_write_mmd(phydev, MDIO_MMD_VEND2, LAN86XX_REG_COL_DET_CTRL0, LAN86XX_ENABLE_COL_DET);
if (ret < 0)
ret = phy_modify_mmd(phydev, MDIO_MMD_VEND2, LAN86XX_REG_COL_DET_CTRL0,
LAN86XX_COL_DET_MASK, LAN86XX_ENABLE_COL_DET);
if (ret)
return ret;
phydev_info(phydev, "CSMA/CD mode enabled\n");
}
Expand Down Expand Up @@ -521,6 +525,12 @@ static struct phy_driver microchip_t1s_driver[] = {
.config_init = lan867x_revc_config_init,
.read_status = lan86xx_read_status,
},
{
PHY_ID_MATCH_EXACT(PHY_ID_LAN867X_REVC2),
.name = "LAN867X Rev.C2",
.config_init = lan867x_revc_config_init,
.read_status = lan86xx_read_status,
},
{
PHY_ID_MATCH_EXACT(PHY_ID_LAN865X_REVB0),
.name = "LAN865X Rev.B0 Internal Phy",
Expand All @@ -535,6 +545,7 @@ static struct mdio_device_id __maybe_unused tbl[] = {
{ PHY_ID_MATCH_EXACT(PHY_ID_LAN867X_REVB1) },
{ PHY_ID_MATCH_EXACT(PHY_ID_LAN867X_REVC0) },
{ PHY_ID_MATCH_EXACT(PHY_ID_LAN867X_REVC1) },
{ PHY_ID_MATCH_EXACT(PHY_ID_LAN867X_REVC2) },
{ PHY_ID_MATCH_EXACT(PHY_ID_LAN865X_REVB0) },
{ }
};
Expand Down

0 comments on commit 09cbd7a

Please sign in to comment.