diff mbox series

ARM: imx6: DHCOM i.MX6 PDK: Convert to DM_ETH

Message ID 20200415140137.252222-1-hws@denx.de
State New
Headers show
Series ARM: imx6: DHCOM i.MX6 PDK: Convert to DM_ETH | expand

Commit Message

Harald Seiler April 15, 2020, 2:01 p.m. UTC
Use DM_ETH instead of legacy networking.

Signed-off-by: Harald Seiler <hws at denx.de>
---

Notes:
    I am unsure whether I converted 'enough' of the board_eth_init()
    function to DM.  I think the reset GPIO in particular could be handled
    by the DM driver if I add the following to the device-tree (did not try
    it yet):
    
    	phy-reset-gpios = <&gpio5 0 GPIO_ACTIVE_LOW>;
    	phy-reset-duration = <1>;
    	phy-reset-post-delay = <10>;
    
    Is it preferred to change the device-tree here or should I keep the reset
    from board_init() like I have it now?  If I should use the dt, is there
    a similar way for dealing with VIO?

 board/dhelectronics/dh_imx6/dh_imx6.c | 26 +++++---------------------
 configs/dh_imx6_defconfig             |  2 ++
 2 files changed, 7 insertions(+), 21 deletions(-)

Comments

Marek Vasut April 15, 2020, 2:06 p.m. UTC | #1
On 4/15/20 4:01 PM, Harald Seiler wrote:
> Use DM_ETH instead of legacy networking.
> 
> Signed-off-by: Harald Seiler <hws at denx.de>
> ---
> 
> Notes:
>     I am unsure whether I converted 'enough' of the board_eth_init()
>     function to DM.  I think the reset GPIO in particular could be handled
>     by the DM driver if I add the following to the device-tree (did not try
>     it yet):
>     
>     	phy-reset-gpios = <&gpio5 0 GPIO_ACTIVE_LOW>;
>     	phy-reset-duration = <1>;
>     	phy-reset-post-delay = <10>;

That's how PHY reset should be done, yes.

>     Is it preferred to change the device-tree here or should I keep the reset
>     from board_init() like I have it now?  If I should use the dt, is there
>     a similar way for dealing with VIO?

VIO is likely a fixed regulator-always-on regulator for now.

>  board/dhelectronics/dh_imx6/dh_imx6.c | 26 +++++---------------------
>  configs/dh_imx6_defconfig             |  2 ++
>  2 files changed, 7 insertions(+), 21 deletions(-)
> 
> diff --git a/board/dhelectronics/dh_imx6/dh_imx6.c b/board/dhelectronics/dh_imx6/dh_imx6.c
> index 33ce7e8ff115..aafb9f1b341f 100644
> --- a/board/dhelectronics/dh_imx6/dh_imx6.c
> +++ b/board/dhelectronics/dh_imx6/dh_imx6.c
> @@ -28,10 +28,7 @@
>  #include <fsl_esdhc_imx.h>
>  #include <fuse.h>
>  #include <i2c_eeprom.h>
> -#include <miiphy.h>
>  #include <mmc.h>
> -#include <net.h>
> -#include <netdev.h>
>  #include <usb.h>
>  #include <usb/ehci-ci.h>
>  
> @@ -80,31 +77,14 @@ static int setup_fec_clock(void)
>  	return enable_fec_anatop_clock(0, ENET_50MHZ);
>  }
>  
> -int board_eth_init(bd_t *bis)
> +static void setup_fec(void)
>  {
> -	uint32_t base = IMX_FEC_BASE;
> -	struct mii_dev *bus = NULL;
> -	struct phy_device *phydev = NULL;
> -
>  	gpio_request(IMX_GPIO_NR(5, 0), "PHY-reset");
>  	gpio_request(IMX_GPIO_NR(1, 7), "VIO");
>  
>  	setup_fec_clock();
>  
>  	eth_phy_reset();
> -
> -	bus = fec_get_miibus(base, -1);
> -	if (!bus)
> -		return -EINVAL;
> -
> -	/* Scan PHY 0 */
> -	phydev = phy_find_by_mask(bus, 0xf, PHY_INTERFACE_MODE_RGMII);
> -	if (!phydev) {
> -		printf("Ethernet PHY not found!\n");
> -		return -EINVAL;
> -	}
> -
> -	return fec_probe(bis, -1, base, bus, phydev);
>  }
>  #endif
>  
> @@ -190,6 +170,10 @@ int board_init(void)
>  
>  	setup_dhcom_mac_from_fuse();
>  
> +#ifdef CONFIG_FEC_MXC

You probably want to init the clock either way, not only if the FEC is
enabled, so drop the ifdef.

> +	setup_fec();
> +#endif

[...]
diff mbox series

Patch

diff --git a/board/dhelectronics/dh_imx6/dh_imx6.c b/board/dhelectronics/dh_imx6/dh_imx6.c
index 33ce7e8ff115..aafb9f1b341f 100644
--- a/board/dhelectronics/dh_imx6/dh_imx6.c
+++ b/board/dhelectronics/dh_imx6/dh_imx6.c
@@ -28,10 +28,7 @@ 
 #include <fsl_esdhc_imx.h>
 #include <fuse.h>
 #include <i2c_eeprom.h>
-#include <miiphy.h>
 #include <mmc.h>
-#include <net.h>
-#include <netdev.h>
 #include <usb.h>
 #include <usb/ehci-ci.h>
 
@@ -80,31 +77,14 @@  static int setup_fec_clock(void)
 	return enable_fec_anatop_clock(0, ENET_50MHZ);
 }
 
-int board_eth_init(bd_t *bis)
+static void setup_fec(void)
 {
-	uint32_t base = IMX_FEC_BASE;
-	struct mii_dev *bus = NULL;
-	struct phy_device *phydev = NULL;
-
 	gpio_request(IMX_GPIO_NR(5, 0), "PHY-reset");
 	gpio_request(IMX_GPIO_NR(1, 7), "VIO");
 
 	setup_fec_clock();
 
 	eth_phy_reset();
-
-	bus = fec_get_miibus(base, -1);
-	if (!bus)
-		return -EINVAL;
-
-	/* Scan PHY 0 */
-	phydev = phy_find_by_mask(bus, 0xf, PHY_INTERFACE_MODE_RGMII);
-	if (!phydev) {
-		printf("Ethernet PHY not found!\n");
-		return -EINVAL;
-	}
-
-	return fec_probe(bis, -1, base, bus, phydev);
 }
 #endif
 
@@ -190,6 +170,10 @@  int board_init(void)
 
 	setup_dhcom_mac_from_fuse();
 
+#ifdef CONFIG_FEC_MXC
+	setup_fec();
+#endif
+
 	return 0;
 }
 
diff --git a/configs/dh_imx6_defconfig b/configs/dh_imx6_defconfig
index cbfc3c394e7d..40de1d82031b 100644
--- a/configs/dh_imx6_defconfig
+++ b/configs/dh_imx6_defconfig
@@ -74,6 +74,8 @@  CONFIG_SPI_FLASH_MTD=y
 CONFIG_PHYLIB=y
 CONFIG_PHY_MICREL=y
 CONFIG_PHY_MICREL_KSZ90X1=y
+CONFIG_DM_ETH=y
+CONFIG_DM_MDIO=y
 CONFIG_FEC_MXC=y
 CONFIG_MII=y
 CONFIG_PINCTRL=y