This document simply introduce how to change uboot for porting new PHY on imx7D customized board
Background:
Current imx7D Sabresd board uses BCM54220B0KFBG PHY, the customized board wants to use KSZ9031 as PHY on the yocto 4.9.88 version, the customized board uses only one ethernet port on ENET2 port according to the imx7D Sabresd board
Requirement:
Refer to the yocto user guide of 4.9.88 version, built your own image, for simple, you can built core-image-minimal, and download the 4.9.88 mfgtool to program
https://www.nxp.com/webapp/Download?colCode=L4.9.88_2.0.0_LINUX_DOCS
adding customized code in u-boot head file:
refer to the customized board schematic as below:
This board use eth2 as ethernet port, the code mx7dsabresd.h(path: yocto-L4.9.88_2.0/build-x11/tmp/work/imx7dsabresd-poky-linux-gnueabi/u-boot-imx/2017.03-r0/git/include/configs)
/* Network */
#ifdef CONFIG_DM_ETH
#define CONFIG_FEC_MXC
#define CONFIG_MII
#define CONFIG_FEC_XCV_TYPE RGMII
#define CONFIG_FEC_ENET_DEV 0
#define CONFIG_PHYLIB
#define CONFIG_PHY_BROADCOM
/* ENET1 */
#if (CONFIG_FEC_ENET_DEV == 0)
#define IMX_FEC_BASE ENET_IPS_BASE_ADDR
#define CONFIG_FEC_MXC_PHYADDR 0x0
#ifdef CONFIG_DM_ETH
#define CONFIG_ETHPRIME "eth0"
#else
#define CONFIG_ETHPRIME "FEC0"
#endif
#elif (CONFIG_FEC_ENET_DEV == 1)
#define IMX_FEC_BASE ENET2_IPS_BASE_ADDR
#define CONFIG_FEC_MXC_PHYADDR 0x1
#ifdef CONFIG_DM_ETH
#define CONFIG_ETHPRIME "eth1"
#else
#define CONFIG_ETHPRIME "FEC1"
#endif
#endif
Change the source code as below, add two macro definition and change the PHY address according to the schematic:
/* Network */
#define CONFIG_PHY_MICREL
#define CONFIG_PHY_MICREL_KSZ9031
#ifdef CONFIG_DM_ETH
#define CONFIG_FEC_MXC
#define CONFIG_MII
#define CONFIG_FEC_XCV_TYPE RGMII
#define CONFIG_FEC_ENET_DEV 0
#define CONFIG_PHYLIB
#define CONFIG_PHY_BROADCOM
/* ENET1 */
#if (CONFIG_FEC_ENET_DEV == 0)
#define IMX_FEC_BASE ENET_IPS_BASE_ADDR
#define CONFIG_FEC_MXC_PHYADDR 0x1
#ifdef CONFIG_DM_ETH
#define CONFIG_ETHPRIME "eth0"
#else
#define CONFIG_ETHPRIME "FEC0"
#endif
#elif (CONFIG_FEC_ENET_DEV == 1)
#define IMX_FEC_BASE ENET2_IPS_BASE_ADDR
#define CONFIG_FEC_MXC_PHYADDR 0x2
#ifdef CONFIG_DM_ETH
#define CONFIG_ETHPRIME "eth1"
#else
#define CONFIG_ETHPRIME "FEC1"
#endif
#endif
adding customized code in u-boot source file:
the source code named mx7dsabresd.c (path: yocto-L4.9.88_2.0/build-x11/tmp/work/imx7dsabresd-poky-linux-gnueabi/u-boot-imx/2017.03-r0/git/board/freescale/mx7dsabresd)
Imx7d Sabresd board uses gpio_spi 5 as reset pin so the source code as below:
ret = gpio_lookup_name("gpio_spi@0_5", NULL, NULL, &gpio)
if (ret) {
printf("GPIO: 'gpio_spi@0_5' not found\n");
The customized board uses GPIO1_IO03 as reset pin, so the source code was changed to :
imx_iomux_v3_setup_pad(MX7D_PAD_GPIO1_IO03__GPIO1_IO3 | MUX_PAD_CTRL(NO_PAD_CTRL));
ret = gpio_request(IMX_GPIO_NR(1, 3), "enet_phy_rst");
gpio_direction_output(IMX_GPIO_NR(1, 3), 0);
mdelay(20);
gpio_direction_output(IMX_GPIO_NR(1, 3), 1);
udelay(100);
Use this function to set the phy rx, tx data pad skew and clock pad skew, for ksz9031, can refer to the UDOO board, then change the setting source code as below:
/* control data pad skew - devaddr = 0x02, register = 0x04 */
ksz9031_phy_extended_write(phydev, 0x02,
MII_KSZ9031_EXT_RGMII_CTRL_SIG_SKEW,
MII_KSZ9031_MOD_DATA_NO_POST_INC, 0x0000);
/* rx data pad skew - devaddr = 0x02, register = 0x05 */
ksz9031_phy_extended_write(phydev, 0x02,
MII_KSZ9031_EXT_RGMII_RX_DATA_SKEW,
MII_KSZ9031_MOD_DATA_NO_POST_INC, 0x0000);
/* tx data pad skew - devaddr = 0x02, register = 0x05 */
ksz9031_phy_extended_write(phydev, 0x02,
MII_KSZ9031_EXT_RGMII_TX_DATA_SKEW,
MII_KSZ9031_MOD_DATA_NO_POST_INC, 0x0000);
/* gtx and rx clock pad skew - devaddr = 0x02, register = 0x08 */
ksz9031_phy_extended_write(phydev, 0x02,
MII_KSZ9031_EXT_RGMII_CLOCK_SKEW,
MII_KSZ9031_MOD_DATA_NO_POST_INC, 0x03FF);
U-Boot 2017.03-imx_v2017.03_4.9.88_2.0.0_ga+gb76bb1b (Apr 20 2019 - 17:51:51 +0800)
CPU: Freescale i.MX7D rev1.3 996 MHz (running at 792 MHz)
CPU: Commercial temperature grade (0C to 95C) at 32C
Reset cause: POR
Model: Freescale i.MX7D SabreSD Board
Board: i.MX7D SABRESD RevC in secure mode
DRAM: 1 GiB
PMIC: PFUZE3000 DEV_ID=0x30 REV_ID=0x11
MMC: FSL_SDHC: 0, FSL_SDHC: 1
Display: TFT43AB (480x272)
Video: 480x272x24
In: serial
Out: serial
Err: serial
switch to partitions #0, OK
mmc1(part 0) is current device
Net:
Error: ethernet@30bf0000 address not set.
eth0: ethernet@30be0000
Error: ethernet@30bf0000 address not set.
Ending:
Don’t worry about this error message, because you don’t set correct mac address, one has two option to set this,
For one, you can add mac address in the uboot manually, like
setenv ethaddr 00:11:22:33:44:55
another option is add CONFIG_NET_RANDOM_ETHADDR=y in the configure file, then you don’t need to set mac address manually, would get a random mac address
this document just simply introduce how to change the source code in the u-boot, you also need to change the kernel dts file and kernel file to support the new PHY, the kernel has the same process, the phy address, the phy settings, and the gpio pins, hope this document give you some hints to port the new PHY