diff mbox series

[5/9] board: phytec: phycore_imx8mp: Add fec support

Message ID 20210701094721.3240071-6-t.remmet@phytec.de
State Superseded
Delegated to: Stefano Babic
Headers show
Series phyCORE-i.MX8MP Update | expand

Commit Message

Teresa Remmet July 1, 2021, 9:47 a.m. UTC
Enable support for the fec ethernet on phyCORE-i.MX8MP.

Signed-off-by: Teresa Remmet <t.remmet@phytec.de>
---
 board/phytec/phycore_imx8mp/phycore-imx8mp.c | 14 +++++++++++
 configs/phycore-imx8mp_defconfig             |  7 ++++++
 include/configs/phycore_imx8mp.h             | 25 ++++++++++++++++++++
 3 files changed, 46 insertions(+)

Comments

Fabio Estevam July 1, 2021, 11:24 a.m. UTC | #1
Hi Teresa,

Your series looks great. Just a few comments on this patch.

On Thu, Jul 1, 2021 at 6:47 AM Teresa Remmet <t.remmet@phytec.de> wrote:

> --- a/include/configs/phycore_imx8mp.h
> +++ b/include/configs/phycore_imx8mp.h
> @@ -42,6 +42,8 @@
>         "console=ttymxc0,115200\0" \
>         "fdt_addr=0x48000000\0" \
>         "fdt_file=" CONFIG_DEFAULT_FDT_FILE "\0" \
> +       "ip_dyn=yes\0" \
> +       "serverip=192.168.3.10\0" \

Please do not hardcode the "serverip" variable.

> +/* ENET1 */
> +#define CONFIG_ETHPRIME                 "FEC"
> +#define CONFIG_FEC_XCV_TYPE             RGMII
> +#define CONFIG_FEC_MXC_PHYADDR          0
> +#define FEC_QUIRK_ENET_MAC
> +#define IMX_FEC_BASE                    0x30BE0000

As DM is being used these definitions can be removed. Please test without them.
Teresa Remmet July 2, 2021, 9:53 a.m. UTC | #2
Hello Fabio,

Am Donnerstag, den 01.07.2021, 08:24 -0300 schrieb Fabio Estevam:
> Hi Teresa,
> 
> Your series looks great. Just a few comments on this patch.

thanks for your quick review.

> 
> On Thu, Jul 1, 2021 at 6:47 AM Teresa Remmet <t.remmet@phytec.de>
> wrote:
> 
> > --- a/include/configs/phycore_imx8mp.h
> > +++ b/include/configs/phycore_imx8mp.h
> > @@ -42,6 +42,8 @@
> >         "console=ttymxc0,115200\0" \
> >         "fdt_addr=0x48000000\0" \
> >         "fdt_file=" CONFIG_DEFAULT_FDT_FILE "\0" \
> > +       "ip_dyn=yes\0" \
> > +       "serverip=192.168.3.10\0" \
> 
> Please do not hardcode the "serverip" variable.
> 
> > +/* ENET1 */
> > +#define CONFIG_ETHPRIME                 "FEC"
> > +#define CONFIG_FEC_XCV_TYPE             RGMII
> > +#define CONFIG_FEC_MXC_PHYADDR          0
> > +#define FEC_QUIRK_ENET_MAC
> > +#define IMX_FEC_BASE                    0x30BE0000
> 
> As DM is being used these definitions can be removed. Please test
> without them.

Yes, works without the defines. Will send a v2 with the requested
changes.

Thanks,
Teresa
diff mbox series

Patch

diff --git a/board/phytec/phycore_imx8mp/phycore-imx8mp.c b/board/phytec/phycore_imx8mp/phycore-imx8mp.c
index 67649078c201..a8f082143762 100644
--- a/board/phytec/phycore_imx8mp/phycore-imx8mp.c
+++ b/board/phytec/phycore_imx8mp/phycore-imx8mp.c
@@ -10,11 +10,25 @@ 
 #include <asm/io.h>
 #include <asm/mach-imx/boot_mode.h>
 #include <env.h>
+#include <miiphy.h>
 
 DECLARE_GLOBAL_DATA_PTR;
 
+static int setup_fec(void)
+{
+	struct iomuxc_gpr_base_regs *gpr =
+		(struct iomuxc_gpr_base_regs *)IOMUXC_GPR_BASE_ADDR;
+
+	/* Use 125M anatop REF_CLK1 for ENET1, not from external */
+	clrsetbits_le32(&gpr->gpr[1], 0x2000, 0);
+
+	return 0;
+}
+
 int board_init(void)
 {
+	setup_fec();
+
 	return 0;
 }
 
diff --git a/configs/phycore-imx8mp_defconfig b/configs/phycore-imx8mp_defconfig
index 7f21e8888e0e..a22f5e089d97 100644
--- a/configs/phycore-imx8mp_defconfig
+++ b/configs/phycore-imx8mp_defconfig
@@ -58,6 +58,7 @@  CONFIG_ENV_IS_IN_MMC=y
 CONFIG_SYS_RELOC_GD_ENV_ADDR=y
 CONFIG_SYS_MMC_ENV_DEV=2
 CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG=y
+CONFIG_NET_RANDOM_ETHADDR=y
 CONFIG_SPL_DM=y
 CONFIG_CLK_COMPOSITE_CCF=y
 CONFIG_CLK_IMX8MP=y
@@ -79,7 +80,13 @@  CONFIG_MMC_UHS_SUPPORT=y
 CONFIG_MMC_HS400_ES_SUPPORT=y
 CONFIG_MMC_HS400_SUPPORT=y
 CONFIG_FSL_ESDHC_IMX=y
+CONFIG_PHYLIB=y
+CONFIG_PHY_TI_DP83867=y
 CONFIG_DM_ETH=y
+CONFIG_DM_ETH_PHY=y
+CONFIG_FEC_MXC=y
+CONFIG_RGMII=y
+CONFIG_MII=y
 CONFIG_PINCTRL=y
 CONFIG_SPL_PINCTRL=y
 CONFIG_PINCTRL_IMX8M=y
diff --git a/include/configs/phycore_imx8mp.h b/include/configs/phycore_imx8mp.h
index e24f223c21d3..9de89c58289b 100644
--- a/include/configs/phycore_imx8mp.h
+++ b/include/configs/phycore_imx8mp.h
@@ -42,6 +42,8 @@ 
 	"console=ttymxc0,115200\0" \
 	"fdt_addr=0x48000000\0" \
 	"fdt_file=" CONFIG_DEFAULT_FDT_FILE "\0" \
+	"ip_dyn=yes\0" \
+	"serverip=192.168.3.10\0" \
 	"mmcdev=" __stringify(CONFIG_SYS_MMC_ENV_DEV) "\0" \
 	"mmcpart=" __stringify(CONFIG_SYS_MMC_IMG_LOAD_PART) "\0" \
 	"mmcroot=2\0" \
@@ -57,6 +59,22 @@ 
 		"else " \
 			"echo WARN: Cannot load the DT; " \
 		"fi;\0 " \
+	"nfsroot=/nfs\0" \
+	"netargs=setenv bootargs console=${console} root=/dev/nfs ip=dhcp " \
+		"nfsroot=${serverip}:${nfsroot},v3,tcp\0" \
+	"netboot=echo Booting from net ...; " \
+		"run netargs; " \
+		"if test ${ip_dyn} = yes; then " \
+			"setenv get_cmd dhcp; " \
+		"else " \
+			"setenv get_cmd tftp; " \
+		"fi; " \
+		"${get_cmd} ${loadaddr} ${image}; " \
+		"if ${get_cmd} ${fdt_addr} ${fdt_file}; then " \
+			"booti ${loadaddr} - ${fdt_addr}; " \
+		"else " \
+			"echo WARN: Cannot load the DT; " \
+		"fi;\0" \
 
 #define CONFIG_BOOTCOMMAND \
 	"mmc dev ${mmcdev}; if mmc rescan; then " \
@@ -103,4 +121,11 @@ 
 /* I2C */
 #define CONFIG_SYS_I2C_SPEED		100000
 
+/* ENET1 */
+#define CONFIG_ETHPRIME                 "FEC"
+#define CONFIG_FEC_XCV_TYPE             RGMII
+#define CONFIG_FEC_MXC_PHYADDR          0
+#define FEC_QUIRK_ENET_MAC
+#define IMX_FEC_BASE                    0x30BE0000
+
 #endif /* __PHYCORE_IMX8MP_H */