net: phy: don't require PHY interface mode during PHY creation

Currently we require PHY interface mode to be known when
finding/creating the PHY - the functions
  * phy_connect_phy_id()
  * phy_device_create()
  * create_phy_by_mask()
  * search_for_existing_phy()
  * get_phy_device_by_mask()
  * phy_find_by_mask()
all require the interface parameter, but the only thing done with it is
that it is assigned to phydev->interface.

This makes it impossible to find a PHY device without overwriting the
set mode.

Since the interface mode is not used during .probe() and should be used
at first in .config(), drop the interface parameter from these
functions. Make the default value of phydev->interface (in
phy_device_create()) to be PHY_INTERFACE_MODE_NA. Move the interface
parameter to phy_connect_dev(), where it should be.

Change all occurrences treewide. In occurrences where we don't call
phy_connect_dev() for some reason (they only configure the PHY without
connecting it to an ethernet controller), set
  phydev->interface = value from phy_find_by_mask call.

Signed-off-by: Marek BehĂșn <marek.behun@nic.cz>
Reviewed-by: Ramon Fried <rfried.dev@gmail.com>
Reviewed-by: Vladimir Oltean <vladimir.oltean@nxp.com>
diff --git a/include/phy.h b/include/phy.h
index c7fa0ff..30af8bf 100644
--- a/include/phy.h
+++ b/include/phy.h
@@ -388,11 +388,9 @@
  *
  * @bus:	MII/MDIO bus to scan
  * @phy_mask:	bitmap of PYH addresses to scan
- * @interface:	type of MAC-PHY interface
  * @return: pointer to phy_device if a PHY is found, or NULL otherwise
  */
-struct phy_device *phy_find_by_mask(struct mii_dev *bus, unsigned phy_mask,
-		phy_interface_t interface);
+struct phy_device *phy_find_by_mask(struct mii_dev *bus, unsigned phy_mask);
 
 #ifdef CONFIG_PHY_FIXED
 
@@ -421,8 +419,10 @@
  * phy_connect_dev() - Associates the given pair of PHY and Ethernet devices
  * @phydev:	PHY device
  * @dev:	Ethernet device
+ * @interface:	type of MAC-PHY interface
  */
-void phy_connect_dev(struct phy_device *phydev, struct udevice *dev);
+void phy_connect_dev(struct phy_device *phydev, struct udevice *dev,
+		     phy_interface_t interface);
 
 /**
  * phy_connect() - Creates a PHY device for the Ethernet interface
@@ -449,12 +449,10 @@
  * @addr:		PHY address on MDIO bus
  * @phy_id:		where to store the ID retrieved
  * @is_c45:		Device Identifiers if is_c45
- * @interface:		interface between the MAC and PHY
  * @return: pointer to phy_device if a PHY is found, or NULL otherwise
  */
 struct phy_device *phy_device_create(struct mii_dev *bus, int addr,
-				     u32 phy_id, bool is_c45,
-				     phy_interface_t interface);
+				     u32 phy_id, bool is_c45);
 
 /**
  * phy_connect_phy_id() - Connect to phy device by reading PHY id
@@ -462,12 +460,10 @@
  *
  * @bus:		MII/MDIO bus that hosts the PHY
  * @dev:		Ethernet device to associate to the PHY
- * @interface:		Interface between the MAC and PHY
  * @return:		pointer to phy_device if a PHY is found,
  *			or NULL otherwise
  */
-struct phy_device *phy_connect_phy_id(struct mii_dev *bus, struct udevice *dev,
-				      phy_interface_t interface);
+struct phy_device *phy_connect_phy_id(struct mii_dev *bus, struct udevice *dev);
 
 static inline ofnode phy_get_ofnode(struct phy_device *phydev)
 {
@@ -482,8 +478,10 @@
  * phy_connect_dev() - Associates the given pair of PHY and Ethernet devices
  * @phydev:	PHY device
  * @dev:	Ethernet device
+ * @interface:	type of MAC-PHY interface
  */
-void phy_connect_dev(struct phy_device *phydev, struct eth_device *dev);
+void phy_connect_dev(struct phy_device *phydev, struct eth_device *dev,
+		     phy_interface_t interface);
 
 /**
  * phy_connect() - Creates a PHY device for the Ethernet interface