Merge branch 'next' of https://source.denx.de/u-boot/custodians/u-boot-net

- DM9000 DM support
- tftp server bug fix
- mdio ofnode support functions
- Various phy fixes and improvements.

[trini: Fixup merge conflicts in drivers/net/phy/ethernet_id.c
drivers/net/phy/phy.c include/phy.h]
diff --git a/include/_exports.h b/include/_exports.h
index 8030d70..f6df8b6 100644
--- a/include/_exports.h
+++ b/include/_exports.h
@@ -77,8 +77,7 @@
 	EXPORT_FUNC(mdio_get_current_dev, struct mii_dev *,
 		    mdio_get_current_dev, void)
 	EXPORT_FUNC(phy_find_by_mask, struct phy_device *, phy_find_by_mask,
-		    struct mii_dev *bus, unsigned phy_mask,
-		    phy_interface_t interface)
+		    struct mii_dev *bus, unsigned phy_mask)
 	EXPORT_FUNC(mdio_phydev_for_ethname, struct phy_device *,
 		    mdio_phydev_for_ethname, const char *ethname)
 	EXPORT_FUNC(miiphy_set_current_dev, int, miiphy_set_current_dev,
diff --git a/include/configs/M5253DEMO.h b/include/configs/M5253DEMO.h
index b7fdd71..079675b 100644
--- a/include/configs/M5253DEMO.h
+++ b/include/configs/M5253DEMO.h
@@ -25,7 +25,6 @@
 #	undef CONFIG_LBA48
 #endif
 
-#define CONFIG_DRIVER_DM9000
 #ifdef CONFIG_DRIVER_DM9000
 #	define CONFIG_DM9000_BASE	(CONFIG_SYS_CS1_BASE | 0x300)
 #	define DM9000_IO		CONFIG_DM9000_BASE
diff --git a/include/configs/at91sam9261ek.h b/include/configs/at91sam9261ek.h
index 55ddb38..2089fe5 100644
--- a/include/configs/at91sam9261ek.h
+++ b/include/configs/at91sam9261ek.h
@@ -44,7 +44,6 @@
 #endif
 
 /* Ethernet */
-#define CONFIG_DRIVER_DM9000
 #define CONFIG_DM9000_BASE		0x30000000
 #define DM9000_IO			CONFIG_DM9000_BASE
 #define DM9000_DATA			(CONFIG_DM9000_BASE + 4)
diff --git a/include/configs/ci20.h b/include/configs/ci20.h
index ea9440d..cc70a59 100644
--- a/include/configs/ci20.h
+++ b/include/configs/ci20.h
@@ -24,7 +24,6 @@
 #define CONFIG_SYS_NS16550_CLK		48000000
 
 /* Ethernet: davicom DM9000 */
-#define CONFIG_DRIVER_DM9000		1
 #define CONFIG_DM9000_BASE		0xb6000000
 #define DM9000_IO			CONFIG_DM9000_BASE
 #define DM9000_DATA			(CONFIG_DM9000_BASE + 2)
diff --git a/include/configs/colibri_pxa270.h b/include/configs/colibri_pxa270.h
index a5ba916..809afb7 100644
--- a/include/configs/colibri_pxa270.h
+++ b/include/configs/colibri_pxa270.h
@@ -43,7 +43,6 @@
  */
 #ifdef	CONFIG_CMD_NET
 
-#define	CONFIG_DRIVER_DM9000		1
 #define CONFIG_DM9000_BASE		0x08000000
 #define DM9000_IO			(CONFIG_DM9000_BASE)
 #define DM9000_DATA			(CONFIG_DM9000_BASE + 4)
diff --git a/include/configs/devkit8000.h b/include/configs/devkit8000.h
index 16b3650..5dbd126 100644
--- a/include/configs/devkit8000.h
+++ b/include/configs/devkit8000.h
@@ -35,7 +35,6 @@
 
 /* Hardware drivers */
 /* DM9000 */
-#define	CONFIG_DRIVER_DM9000		1
 #define	CONFIG_DM9000_BASE		0x2c000000
 #define	DM9000_IO			CONFIG_DM9000_BASE
 #define	DM9000_DATA			(CONFIG_DM9000_BASE + 0x400)
diff --git a/include/dm/ofnode.h b/include/dm/ofnode.h
index 6a996d9..2c4d72d 100644
--- a/include/dm/ofnode.h
+++ b/include/dm/ofnode.h
@@ -12,6 +12,7 @@
 #include <dm/of.h>
 #include <dm/of_access.h>
 #include <log.h>
+#include <phy_interface.h>
 
 /* Enable checks to protect against invalid calls */
 #undef OF_CHECKS
@@ -1217,4 +1218,30 @@
  */
 const char *ofnode_conf_read_str(const char *prop_name);
 
+/**
+ * ofnode_get_phy_node() - Get PHY node for a MAC (if not fixed-link)
+ *
+ * This function parses PHY handle from the Ethernet controller's ofnode
+ * (trying all possible PHY handle property names), and returns the PHY ofnode.
+ *
+ * Before this is used, ofnode_phy_is_fixed_link() should be checked first, and
+ * if the result to that is true, this function should not be called.
+ *
+ * @eth_node:	ofnode belonging to the Ethernet controller
+ * Return: ofnode of the PHY, if it exists, otherwise an invalid ofnode
+ */
+ofnode ofnode_get_phy_node(ofnode eth_node);
+
+/**
+ * ofnode_read_phy_mode() - Read PHY connection type from a MAC node
+ *
+ * This function parses the "phy-mode" / "phy-connection-type" property and
+ * returns the corresponding PHY interface type.
+ *
+ * @mac_node:	ofnode containing the property
+ * Return: one of PHY_INTERFACE_MODE_* constants, PHY_INTERFACE_MODE_NA on
+ *	   error
+ */
+phy_interface_t ofnode_read_phy_mode(ofnode mac_node);
+
 #endif
diff --git a/include/dm/read.h b/include/dm/read.h
index 233af3c..1b54b69 100644
--- a/include/dm/read.h
+++ b/include/dm/read.h
@@ -743,6 +743,32 @@
 int dev_decode_display_timing(const struct udevice *dev, int index,
 			      struct display_timing *config);
 
+/**
+ * dev_get_phy_node() - Get PHY node for a MAC (if not fixed-link)
+ *
+ * This function parses PHY handle from the Ethernet controller's ofnode
+ * (trying all possible PHY handle property names), and returns the PHY ofnode.
+ *
+ * Before this is used, ofnode_phy_is_fixed_link() should be checked first, and
+ * if the result to that is true, this function should not be called.
+ *
+ * @dev: device representing the MAC
+ * Return: ofnode of the PHY, if it exists, otherwise an invalid ofnode
+ */
+ofnode dev_get_phy_node(const struct udevice *dev);
+
+/**
+ * dev_read_phy_mode() - Read PHY connection type from a MAC
+ *
+ * This function parses the "phy-mode" / "phy-connection-type" property and
+ * returns the corresponding PHY interface type.
+ *
+ * @dev: device representing the MAC
+ * Return: one of PHY_INTERFACE_MODE_* constants, PHY_INTERFACE_MODE_NA on
+ *	   error
+ */
+phy_interface_t dev_read_phy_mode(const struct udevice *dev);
+
 #else /* CONFIG_DM_DEV_READ_INLINE is enabled */
 #include <asm/global_data.h>
 
@@ -1092,6 +1118,16 @@
 	return ofnode_decode_display_timing(dev_ofnode(dev), index, config);
 }
 
+static inline ofnode dev_get_phy_node(const struct udevice *dev)
+{
+	return ofnode_get_phy_node(dev_ofnode(dev));
+}
+
+static inline phy_interface_t dev_read_phy_mode(const struct udevice *dev)
+{
+	return ofnode_read_phy_mode(dev_ofnode(dev));
+}
+
 #endif /* CONFIG_DM_DEV_READ_INLINE */
 
 /**
diff --git a/include/dm9000.h b/include/dm9000.h
deleted file mode 100644
index f780e51..0000000
--- a/include/dm9000.h
+++ /dev/null
@@ -1,16 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0+ */
-/*
- * NOTE:        DAVICOM DM9000 ethernet driver interface
- *
- * Authors:     Remy Bohmer <linux@bohmer.net>
- */
-#ifndef __DM9000_H__
-#define __DM9000_H__
-
-/******************  function prototypes **********************/
-#if !defined(CONFIG_DM9000_NO_SROM)
-void dm9000_write_srom_word(int offset, u16 val);
-void dm9000_read_srom_word(int offset, u8 *to);
-#endif
-
-#endif /* __DM9000_H__ */
diff --git a/include/exports.h b/include/exports.h
index 550cafd..6f8c9cf 100644
--- a/include/exports.h
+++ b/include/exports.h
@@ -55,8 +55,7 @@
 #endif
 #ifdef CONFIG_PHY_AQUANTIA
 struct mii_dev *mdio_get_current_dev(void);
-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);
 struct phy_device *mdio_phydev_for_ethname(const char *ethname);
 int miiphy_set_current_dev(const char *devname);
 #endif
diff --git a/include/fm_eth.h b/include/fm_eth.h
index 44da014..bf95706 100644
--- a/include/fm_eth.h
+++ b/include/fm_eth.h
@@ -72,7 +72,7 @@
 #define FM_ETH_INFO_INITIALIZER(idx, pregs) \
 	.fm		= idx,						\
 	.phy_regs	= (void *)pregs,				\
-	.enet_if	= PHY_INTERFACE_MODE_NONE,			\
+	.enet_if	= PHY_INTERFACE_MODE_NA,			\
 
 #ifdef CONFIG_SYS_FMAN_V3
 #define FM_DTSEC_INFO_INITIALIZER(idx, n) \
diff --git a/include/miiphy.h b/include/miiphy.h
index 235ae06..110921f 100644
--- a/include/miiphy.h
+++ b/include/miiphy.h
@@ -158,6 +158,37 @@
 void dm_mdio_probe_devices(void);
 
 /**
+ * dm_mdio_read - Wrapper over .read() operation for DM MDIO
+ *
+ * @mdiodev: mdio device
+ * @addr: PHY address on MDIO bus
+ * @devad: device address on PHY if C45; should be MDIO_DEVAD_NONE if C22
+ * @reg: register address
+ * Return: register value if non-negative, -error code otherwise
+ */
+int dm_mdio_read(struct udevice *mdio_dev, int addr, int devad, int reg);
+
+/**
+ * dm_mdio_write - Wrapper over .write() operation for DM MDIO
+ *
+ * @mdiodev: mdio device
+ * @addr: PHY address on MDIO bus
+ * @devad: device address on PHY if C45; should be MDIO_DEVAD_NONE if C22
+ * @reg: register address
+ * @val: value to write
+ * Return: 0 on success, -error code otherwise
+ */
+int dm_mdio_write(struct udevice *mdio_dev, int addr, int devad, int reg, u16 val);
+
+/**
+ * dm_mdio_reset - Wrapper over .reset() operation for DM MDIO
+ *
+ * @mdiodev: mdio device
+ * Return: 0 on success, -error code otherwise
+ */
+int dm_mdio_reset(struct udevice *mdio_dev);
+
+/**
  * dm_mdio_phy_connect - Wrapper over phy_connect for DM MDIO
  *
  * @mdiodev: mdio device the PHY is accesible on
diff --git a/include/phy.h b/include/phy.h
index 528839a..b329595 100644
--- a/include/phy.h
+++ b/include/phy.h
@@ -359,18 +359,6 @@
 
 #ifdef CONFIG_PHYLIB_10G
 extern struct phy_driver gen10g_driver;
-
-/*
- * List all 10G interfaces here, the assumption being that PHYs on these
- * interfaces are C45
- */
-static inline int is_10g_interface(phy_interface_t interface)
-{
-	return interface == PHY_INTERFACE_MODE_XGMII ||
-	       interface == PHY_INTERFACE_MODE_USXGMII ||
-	       interface == PHY_INTERFACE_MODE_10GBASER;
-}
-
 #endif
 
 /**
@@ -400,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
 
@@ -433,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
@@ -461,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
@@ -474,12 +460,11 @@
  *
  * @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,
-				      int phyaddr, phy_interface_t interface);
+				      int phyaddr);
 
 static inline ofnode phy_get_ofnode(struct phy_device *phydev)
 {
@@ -494,8 +479,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
@@ -542,6 +529,7 @@
 
 int phy_b53_init(void);
 int phy_mv88e61xx_init(void);
+int phy_adin_init(void);
 int phy_aquantia_init(void);
 int phy_atheros_init(void);
 int phy_broadcom_init(void);
@@ -572,14 +560,6 @@
 int get_phy_id(struct mii_dev *bus, int addr, int devad, u32 *phy_id);
 
 /**
- * phy_get_interface_by_name() - Look up a PHY interface name
- *
- * @str:	PHY interface name, e.g. "mii"
- * @return: PHY_INTERFACE_MODE_... value, or -1 if not found
- */
-int phy_get_interface_by_name(const char *str);
-
-/**
  * phy_interface_is_rgmii - Convenience function for testing if a PHY interface
  * is RGMII (all variants)
  * @phydev: the phy_device struct
diff --git a/include/phy_interface.h b/include/phy_interface.h
index f075abe..ce3b500 100644
--- a/include/phy_interface.h
+++ b/include/phy_interface.h
@@ -13,6 +13,7 @@
 #include <string.h>
 
 typedef enum {
+	PHY_INTERFACE_MODE_NA, /* don't touch */
 	PHY_INTERFACE_MODE_MII,
 	PHY_INTERFACE_MODE_GMII,
 	PHY_INTERFACE_MODE_SGMII,
@@ -39,12 +40,11 @@
 	PHY_INTERFACE_MODE_NCSI,
 	PHY_INTERFACE_MODE_10GBASER,
 	PHY_INTERFACE_MODE_USXGMII,
-	PHY_INTERFACE_MODE_NONE,	/* Must be last */
-
-	PHY_INTERFACE_MODE_COUNT,
+	PHY_INTERFACE_MODE_MAX,
 } phy_interface_t;
 
 static const char * const phy_interface_strings[] = {
+	[PHY_INTERFACE_MODE_NA]		= "",
 	[PHY_INTERFACE_MODE_MII]		= "mii",
 	[PHY_INTERFACE_MODE_GMII]		= "gmii",
 	[PHY_INTERFACE_MODE_SGMII]		= "sgmii",
@@ -71,7 +71,6 @@
 	[PHY_INTERFACE_MODE_NCSI]		= "NC-SI",
 	[PHY_INTERFACE_MODE_10GBASER]		= "10gbase-r",
 	[PHY_INTERFACE_MODE_USXGMII]		= "usxgmii",
-	[PHY_INTERFACE_MODE_NONE]		= "",
 };
 
 /* Backplane modes:
@@ -86,8 +85,8 @@
 static inline const char *phy_string_for_interface(phy_interface_t i)
 {
 	/* Default to unknown */
-	if (i > PHY_INTERFACE_MODE_NONE)
-		i = PHY_INTERFACE_MODE_NONE;
+	if (i > PHY_INTERFACE_MODE_NA)
+		i = PHY_INTERFACE_MODE_NA;
 
 	return phy_interface_strings[i];
 }
diff --git a/include/vsc9953.h b/include/vsc9953.h
index a9c84b4..fd52c93 100644
--- a/include/vsc9953.h
+++ b/include/vsc9953.h
@@ -691,7 +691,7 @@
 	.phyaddr	= 0,						\
 	.index		= idx,						\
 	.phy_regs	= NULL,						\
-	.enet_if	= PHY_INTERFACE_MODE_NONE,			\
+	.enet_if	= PHY_INTERFACE_MODE_NA,			\
 	.bus		= NULL,						\
 	.phydev		= NULL,						\
 }