提交 e86c7210 编写于 作者: P Pavithra Sathyanarayanan 提交者: Paolo Abeni

net: lan743x: add generic implementation for phy interface selection

Add logic to read the Phy interface from MAC_CR register for LAN743x
driver.

Checks for the LAN7430/31 or pci11x1x devices and the adapter
interface is updated accordingly. For LAN7431, adapter interface is set
based on Bit 19 of MAC_CR register as MII or RGMII which removes the
forced RGMII/GMII configurations in lan743x_phy_open().
Signed-off-by: NPavithra Sathyanarayanan <Pavithra.Sathyanarayanan@microchip.com>
Signed-off-by: NPaolo Abeni <pabeni@redhat.com>
上级 1c9bb442
...@@ -1469,6 +1469,24 @@ static void lan743x_phy_close(struct lan743x_adapter *adapter) ...@@ -1469,6 +1469,24 @@ static void lan743x_phy_close(struct lan743x_adapter *adapter)
netdev->phydev = NULL; netdev->phydev = NULL;
} }
static void lan743x_phy_interface_select(struct lan743x_adapter *adapter)
{
u32 id_rev;
u32 data;
data = lan743x_csr_read(adapter, MAC_CR);
id_rev = adapter->csr.id_rev & ID_REV_ID_MASK_;
if (adapter->is_pci11x1x && adapter->is_sgmii_en)
adapter->phy_interface = PHY_INTERFACE_MODE_SGMII;
else if (id_rev == ID_REV_ID_LAN7430_)
adapter->phy_interface = PHY_INTERFACE_MODE_GMII;
else if ((id_rev == ID_REV_ID_LAN7431_) && (data & MAC_CR_MII_EN_))
adapter->phy_interface = PHY_INTERFACE_MODE_MII;
else
adapter->phy_interface = PHY_INTERFACE_MODE_RGMII;
}
static int lan743x_phy_open(struct lan743x_adapter *adapter) static int lan743x_phy_open(struct lan743x_adapter *adapter)
{ {
struct net_device *netdev = adapter->netdev; struct net_device *netdev = adapter->netdev;
...@@ -1486,14 +1504,11 @@ static int lan743x_phy_open(struct lan743x_adapter *adapter) ...@@ -1486,14 +1504,11 @@ static int lan743x_phy_open(struct lan743x_adapter *adapter)
if (!phydev) if (!phydev)
goto return_error; goto return_error;
if (adapter->is_pci11x1x) lan743x_phy_interface_select(adapter);
ret = phy_connect_direct(netdev, phydev,
lan743x_phy_link_status_change, ret = phy_connect_direct(netdev, phydev,
PHY_INTERFACE_MODE_RGMII); lan743x_phy_link_status_change,
else adapter->phy_interface);
ret = phy_connect_direct(netdev, phydev,
lan743x_phy_link_status_change,
PHY_INTERFACE_MODE_GMII);
if (ret) if (ret)
goto return_error; goto return_error;
} }
......
...@@ -1042,6 +1042,7 @@ struct lan743x_adapter { ...@@ -1042,6 +1042,7 @@ struct lan743x_adapter {
#define LAN743X_ADAPTER_FLAG_OTP BIT(0) #define LAN743X_ADAPTER_FLAG_OTP BIT(0)
u32 flags; u32 flags;
u32 hw_cfg; u32 hw_cfg;
phy_interface_t phy_interface;
}; };
#define LAN743X_COMPONENT_FLAG_RX(channel) BIT(20 + (channel)) #define LAN743X_COMPONENT_FLAG_RX(channel) BIT(20 + (channel))
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册