Commit c84f433e authored by Paolo Abeni's avatar Paolo Abeni

Merge branch 'generic-implementation-of-phy-interface-and-fixed_phy-support-for-the-lan743x-device'

Pavithra Sathyanarayanan says:

====================
generic implementation of phy interface and fixed_phy support for the LAN743x device

This patch series includes the following changes:

- Remove the unwanted interface settings in the LAN743x driver as
  it is preset in EEPROM configurations.

- Handle generic implementation for the phy interfaces for different
  devices LAN7430/31 and pci11x1x.

- Add new feature for fixed_phy support at 1Gbps full duplex for the
  LAN7431 device if a phy not found over MDIO. Includes support for
  communication between a MAC in a LAN7431 device and custom phys
  without an MDIO interface.
====================

Link: https://lore.kernel.org/r/20230117141614.4411-1-Pavithra.Sathyanarayanan@microchip.comSigned-off-by: default avatarPaolo Abeni <pabeni@redhat.com>
parents 3c107f36 624864fb
...@@ -1418,14 +1418,6 @@ static void lan743x_phy_link_status_change(struct net_device *netdev) ...@@ -1418,14 +1418,6 @@ static void lan743x_phy_link_status_change(struct net_device *netdev)
data = lan743x_csr_read(adapter, MAC_CR); data = lan743x_csr_read(adapter, MAC_CR);
/* set interface mode */
if (phy_interface_is_rgmii(phydev))
/* RGMII */
data &= ~MAC_CR_MII_EN_;
else
/* GMII */
data |= MAC_CR_MII_EN_;
/* set duplex mode */ /* set duplex mode */
if (phydev->duplex) if (phydev->duplex)
data |= MAC_CR_DPX_; data |= MAC_CR_DPX_;
...@@ -1477,10 +1469,33 @@ static void lan743x_phy_close(struct lan743x_adapter *adapter) ...@@ -1477,10 +1469,33 @@ 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;
struct lan743x_phy *phy = &adapter->phy; struct lan743x_phy *phy = &adapter->phy;
struct fixed_phy_status fphy_status = {
.link = 1,
.speed = SPEED_1000,
.duplex = DUPLEX_FULL,
};
struct phy_device *phydev; struct phy_device *phydev;
int ret = -EIO; int ret = -EIO;
...@@ -1491,17 +1506,25 @@ static int lan743x_phy_open(struct lan743x_adapter *adapter) ...@@ -1491,17 +1506,25 @@ static int lan743x_phy_open(struct lan743x_adapter *adapter)
if (!phydev) { if (!phydev) {
/* try internal phy */ /* try internal phy */
phydev = phy_find_first(adapter->mdiobus); phydev = phy_find_first(adapter->mdiobus);
if (!phydev) if (!phydev) {
goto return_error; if ((adapter->csr.id_rev & ID_REV_ID_MASK_) ==
ID_REV_ID_LAN7431_) {
phydev = fixed_phy_register(PHY_POLL,
&fphy_status, NULL);
if (IS_ERR(phydev)) {
netdev_err(netdev, "No PHY/fixed_PHY found\n");
return -EIO;
}
} else {
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%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment