net: Update eQos driver and FEC driver to use eth phy interfaces
Update eQoS and fec ethernet drivers to support shared MDIO framework Signed-off-by: Ye Li <ye.li@nxp.com> Signed-off-by: Peng Fan <peng.fan@nxp.com>
This commit is contained in:
		
							parent
							
								
									5fe419ef2a
								
							
						
					
					
						commit
						6a895d039b
					
				|  | @ -41,6 +41,7 @@ | ||||||
| #include <wait_bit.h> | #include <wait_bit.h> | ||||||
| #include <asm/gpio.h> | #include <asm/gpio.h> | ||||||
| #include <asm/io.h> | #include <asm/io.h> | ||||||
|  | #include <eth_phy.h> | ||||||
| 
 | 
 | ||||||
| /* Core registers */ | /* Core registers */ | ||||||
| 
 | 
 | ||||||
|  | @ -1083,7 +1084,14 @@ static int eqos_start(struct udevice *dev) | ||||||
| 	 * don't need to reconnect/reconfigure again | 	 * don't need to reconnect/reconfigure again | ||||||
| 	 */ | 	 */ | ||||||
| 	if (!eqos->phy) { | 	if (!eqos->phy) { | ||||||
| 		eqos->phy = phy_connect(eqos->mii, eqos->phyaddr, dev, | 		int addr = -1; | ||||||
|  | #ifdef CONFIG_DM_ETH_PHY | ||||||
|  | 		addr = eth_phy_get_addr(dev); | ||||||
|  | #endif | ||||||
|  | #ifdef DWC_NET_PHYADDR | ||||||
|  | 		addr = DWC_NET_PHYADDR; | ||||||
|  | #endif | ||||||
|  | 		eqos->phy = phy_connect(eqos->mii, addr, dev, | ||||||
| 					eqos->config->interface(dev)); | 					eqos->config->interface(dev)); | ||||||
| 		if (!eqos->phy) { | 		if (!eqos->phy) { | ||||||
| 			pr_err("phy_connect() failed"); | 			pr_err("phy_connect() failed"); | ||||||
|  | @ -1820,6 +1828,10 @@ static int eqos_probe(struct udevice *dev) | ||||||
| 		goto err_remove_resources_core; | 		goto err_remove_resources_core; | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
|  | #ifdef CONFIG_DM_ETH_PHY | ||||||
|  | 	eqos->mii = eth_phy_get_mdio_bus(dev); | ||||||
|  | #endif | ||||||
|  | 	if (!eqos->mii) { | ||||||
| 		eqos->mii = mdio_alloc(); | 		eqos->mii = mdio_alloc(); | ||||||
| 		if (!eqos->mii) { | 		if (!eqos->mii) { | ||||||
| 			pr_err("mdio_alloc() failed"); | 			pr_err("mdio_alloc() failed"); | ||||||
|  | @ -1836,6 +1848,11 @@ static int eqos_probe(struct udevice *dev) | ||||||
| 			pr_err("mdio_register() failed: %d", ret); | 			pr_err("mdio_register() failed: %d", ret); | ||||||
| 			goto err_free_mdio; | 			goto err_free_mdio; | ||||||
| 		} | 		} | ||||||
|  | 	} | ||||||
|  | 
 | ||||||
|  | #ifdef CONFIG_DM_ETH_PHY | ||||||
|  | 	eth_phy_set_mdio_bus(dev, eqos->mii); | ||||||
|  | #endif | ||||||
| 
 | 
 | ||||||
| 	debug("%s: OK\n", __func__); | 	debug("%s: OK\n", __func__); | ||||||
| 	return 0; | 	return 0; | ||||||
|  |  | ||||||
|  | @ -28,6 +28,7 @@ | ||||||
| #include <asm-generic/gpio.h> | #include <asm-generic/gpio.h> | ||||||
| 
 | 
 | ||||||
| #include "fec_mxc.h" | #include "fec_mxc.h" | ||||||
|  | #include <eth_phy.h> | ||||||
| 
 | 
 | ||||||
| DECLARE_GLOBAL_DATA_PTR; | DECLARE_GLOBAL_DATA_PTR; | ||||||
| 
 | 
 | ||||||
|  | @ -1444,16 +1445,27 @@ static int fecmxc_probe(struct udevice *dev) | ||||||
| 	fec_reg_setup(priv); | 	fec_reg_setup(priv); | ||||||
| 
 | 
 | ||||||
| 	priv->dev_id = dev->seq; | 	priv->dev_id = dev->seq; | ||||||
|  | 
 | ||||||
|  | #ifdef CONFIG_DM_ETH_PHY | ||||||
|  | 	bus = eth_phy_get_mdio_bus(dev); | ||||||
|  | #endif | ||||||
|  | 
 | ||||||
|  | 	if (!bus) { | ||||||
| #ifdef CONFIG_FEC_MXC_MDIO_BASE | #ifdef CONFIG_FEC_MXC_MDIO_BASE | ||||||
| 		bus = fec_get_miibus((ulong)CONFIG_FEC_MXC_MDIO_BASE, dev->seq); | 		bus = fec_get_miibus((ulong)CONFIG_FEC_MXC_MDIO_BASE, dev->seq); | ||||||
| #else | #else | ||||||
| 		bus = fec_get_miibus((ulong)priv->eth, dev->seq); | 		bus = fec_get_miibus((ulong)priv->eth, dev->seq); | ||||||
| #endif | #endif | ||||||
|  | 	} | ||||||
| 	if (!bus) { | 	if (!bus) { | ||||||
| 		ret = -ENOMEM; | 		ret = -ENOMEM; | ||||||
| 		goto err_mii; | 		goto err_mii; | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
|  | #ifdef CONFIG_DM_ETH_PHY | ||||||
|  | 	eth_phy_set_mdio_bus(dev, bus); | ||||||
|  | #endif | ||||||
|  | 
 | ||||||
| 	priv->bus = bus; | 	priv->bus = bus; | ||||||
| 	priv->interface = pdata->phy_interface; | 	priv->interface = pdata->phy_interface; | ||||||
| 	switch (priv->interface) { | 	switch (priv->interface) { | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue