mx6d, how to use rmii with lan8720 in uboot ?

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

mx6d, how to use rmii with lan8720 in uboot ?

6,512 Views
ispsubb
Contributor II

platform: mx6d , uboot-2015-04-r0

          rmii + lan8720a (The sch is OK, because rmii (lan8720a) in linux3.14.52 is ok)

List what I have done .

mx6sabresd.c

1,PINs config 

static iomux_v3_cfg_t const enet_pads[] = {
            MX6_PAD_ENET_MDIO__ENET_MDIO                   | MUX_PAD_CTRL(ENET_PAD_CTRL),
            MX6_PAD_ENET_MDC__ENET_MDC                      | MUX_PAD_CTRL(ENET_PAD_CTRL),
            MX6_PAD_ENET_CRS_DV__ENET_RX_EN       | MUX_PAD_CTRL(ENET_PAD_CTRL),
            MX6_PAD_ENET_RX_ER__ENET_RX_ER                     | MUX_PAD_CTRL(ENET_PAD_CTRL),
            MX6_PAD_ENET_TX_EN__ENET_TX_EN                     | MUX_PAD_CTRL(ENET_PAD_CTRL),
            MX6_PAD_ENET_RXD0__ENET_RX_DATA0                | MUX_PAD_CTRL(ENET_PAD_CTRL),
            MX6_PAD_ENET_RXD1__ENET_RX_DATA1                | MUX_PAD_CTRL(ENET_PAD_CTRL),
            MX6_PAD_ENET_TXD0__ENET_TX_DATA0     | MUX_PAD_CTRL(ENET_PAD_CTRL),
            MX6_PAD_ENET_TXD1__ENET_TX_DATA1     | MUX_PAD_CTRL(ENET_PAD_CTRL),
            MX6_PAD_GPIO_16__ENET_REF_CLK | MUX_PAD_CTRL(ENET_PAD_CTRL),
            MX6_PAD_EIM_D21__GPIO3_IO21 | MUX_PAD_CTRL(NO_PAD_CTRL),
};

2,PIN IOMUX  and  PHY reset

static void setup_iomux_enet(void)
{
            imx_iomux_v3_setup_multiple_pads(enet_pads, ARRAY_SIZE(enet_pads));
            // Reset lan8720 PHY
            gpio_direction_output(IMX_GPIO_NR(3, 21) , 1);
            udelay(150);
            gpio_set_value(IMX_GPIO_NR(3, 21), 0);  
            udelay(200);
            gpio_set_value(IMX_GPIO_NR(3, 21), 1);
            udelay(100);
}

3,clk 50MHz , and  run it in board_init()

static int setup_fec(void)

{
    struct iomuxc_base_regs *iomuxc_regs =
                (struct iomuxc_base_regs *)IOMUXC_BASE_ADDR;
    int ret;
    /* set gpr1[21] to select anatop clock */
    clrsetbits_le32(&iomuxc_regs->gpr[1], IOMUXC_GPR1_ENET_CLK_SEL_MASK, 1
<< 21);
            ret = enable_fec_anatop_clock(0, ENET_50MHZ);
            if (ret)
                        return ret;
    return 0;
}

mx6sabre-common.h

4,RMII  CONFIGs

#define CONFIG_CMD_PING
#define CONFIG_CMD_DHCP
#define CONFIG_CMD_MII
#define CONFIG_CMD_NET
#define CONFIG_FEC_MXC
#define CONFIG_MII
#define IMX_FEC_BASE            ENET_BASE_ADDR
#define CONFIG_FEC_XCV_TYPE        RMII
#define CONFIG_ETHPRIME                 "FEC"
#define CONFIG_FEC_MXC_PHYADDR        0

#define CONFIG_PHYLIB
#define CONFIG_PHY_SMSC

5,now ,what we got

a , clk 50MHz is OK ,we can test it .

b, log as below:  (ip is the same 192.168.0.x )

U-Boot 2015.04-imx_v2015.04_3.14.52_1.1.0_ga+g6cf684a (May 10 2016 - 16:42:24)

CPU:   Freescale i.MX6D rev1.2 at 792 MHz
CPU:   Temperature 36 C
Reset cause: POR
Board: MX6-SabreSD
I2C:   ready
DRAM:  1 GiB
MMC:   FSL_SDHC: 0, FSL_SDHC: 1, FSL_SDHC: 2
No panel detected: default to Hannstar-XGA
Display: Hannstar-XGA (1024x768)
In:    serial
Out:   serial
Err:   serial
switch to partitions #0, OK
mmc2(part 0) is current device
Net:   FEC [PRIME]
Normal Boot
Hit any key to stop autoboot:  0
=>
=>
=> ping 192.168.0.1
Using FEC device
error frame: 0x4ef46dc0 0x00000804
error frame: 0x4ef47400 0x00000804
error frame: 0x4ef47a40 0x00000804
error frame: 0x4f24ba40 0x00000884
error frame: 0x4f24c080 0x00000804

ARP Retry count exceeded; starting again
error frame: 0x4ef46dc0 0x00000804
error frame: 0x4ef47400 0x00000804
error frame: 0x4ef47a40 0x00000804
error frame: 0x4f24ba40 0x00000804
error frame: 0x4f24c080 0x00000884

ARP Retry count exceeded; starting again

we found the same problem :

http://bbs.21ic.com/icview-727812-1-1.html

It really have a patch about rmii of uboot ?

WHO CAN help me ?@BiyongSUN

Tags (1)
0 Kudos
24 Replies

2,877 Views
ispsubb
Contributor II

Thanks all .

I solved the problem.

rx_er pin of hardware is wrong

0 Kudos

2,877 Views
程wen
Contributor I

Hi,

"rx_er pin of hardware is wrong", what is the wrong? I have the problem.

thanks!

0 Kudos

2,877 Views
cloundliu
Contributor I

can you share your code for lan8720 ?

thanks !

0 Kudos

2,877 Views
laszlotimko
Contributor III

Hi,

Try to set DAISY[0]=1 in your setup_fec() as:

    reg = (u32 *)(IOMUXC_BASE_ADDR + 0x83c);
   setbits_le32(reg, (1 << 0));

Regards

0 Kudos

2,877 Views
ispsubb
Contributor II

Thanks !

I try to md  IOMUXC_BASE_ADDR + 0x83c , it is right .

I have set it

0 Kudos

2,879 Views
ispsubb
Contributor II

any one can help me ?

0 Kudos

2,879 Views
Sasamy
Contributor IV

Hi,

in the attachment a patch for our board with the processor i.MX6 DUAL, PHY lan8720a, u-boot release 4.1.15_1.1.0_ga  (U-Boot 2015.04), only minimum necessary is enabled.

U-Boot 2015.04 (May 17 2016 - 12:32:03)

CPU:  Freescale i.MX6D rev1.5 at 792 MHz

CPU:  Temperature 35 C

Reset cause: POR

Board: SK-iMX6-SODIMM

DRAM:  1 GiB

MMC:  FSL_SDHC: 0, FSL_SDHC: 1

*** Warning - bad CRC, using default environment

Net:  FEC

Normal Boot

Hit any key to stop autoboot:  0

u-boot > printenv ipaddr

ipaddr=192.168.0.136

u-boot > printenv ethaddr

ethaddr=00:1f:f2:00:00:00

u-boot > ping 192.168.0.2

Using FEC device

host 192.168.0.2 is alive

I haven't noticed - the ping works without problems, but problems appear when using tftp

u-boot > tftp zImage

Using FEC device

TFTP from server 192.168.0.2; our IP address is 192.168.0.136

Filename 'zImage'.

Load address: 0x12000000

Loading: #################################################################

         ###########################error frame: 0x4f58d5c0 0x00000804

######################################

         ################################error frame: 0x4f58c300 0x00000804

###error frame: 0x4f597840 0x00000804

##############################

         #################################################################

         #################################################################

         #################################################################

         ##############error frame: 0x4f587e40 0x00000804

###################################################

         ############error frame: 0x4f583c80 0x00000804

##################################error frame: 0x4f58d5c0 0x00000804

###error frame: 0x4f59aa40 0x00000804

######error frame: 0x4f597e80 0x00000804

##########

         ##########################error frame: 0x4f591440 0x00000804

###############error frame: 0x4f599140 0x00000804

0 Kudos

2,878 Views
ispsubb
Contributor II

can you share your code for lan8720 ?

thanks !

0 Kudos

2,878 Views
ispsubb
Contributor II

Do you mean have a patch for this ?

Can you share it ?

0 Kudos

2,878 Views
Sasamy
Contributor IV

There are no additional patches - the network just works. You can try to ping other host or a similar board ? I think there are some problems with flow control.

0 Kudos

2,878 Views
ispsubb
Contributor II

oh , I got it !

Check my ping other host , and  change another board, i got the same problem .

can you share your mx6sabresd.c and mx6sabre-common.h with me ?

0 Kudos

2,879 Views
Sasamy
Contributor IV

Hi li chao,

we don't use mx6sabresd, the board-file is in the enclosed patch

https://community.freescale.com/servlet/JiveServlet/download/651086-1-378815/uboot_imx_4.1.15_1.1.0_...

possibly you are interested in initialization of ethernet there

#define ENET_PAD_CTRL  (PAD_CTL_PUS_100K_UP | PAD_CTL_SPEED_MED      |    \

            PAD_CTL_DSE_40ohm   | PAD_CTL_HYS)

#define ETH_PHY_RESET   IMX_GPIO_NR(1, 23)

#ifdef CONFIG_FEC_MXC

static iomux_v3_cfg_t const enet_pads[] = {

    MX6_PAD_GPIO_16__ENET_REF_CLK | MUX_PAD_CTRL(ENET_PAD_CTRL),

    MX6_PAD_ENET_MDIO__ENET_MDIO    | MUX_PAD_CTRL(ENET_PAD_CTRL),

    MX6_PAD_ENET_MDC__ENET_MDC      | MUX_PAD_CTRL(ENET_PAD_CTRL),

    MX6_PAD_ENET_CRS_DV__ENET_RX_EN | MUX_PAD_CTRL(ENET_PAD_CTRL),

    MX6_PAD_ENET_RX_ER__ENET_RX_ER  | MUX_PAD_CTRL(ENET_PAD_CTRL),

    MX6_PAD_ENET_TX_EN__ENET_TX_EN  | MUX_PAD_CTRL(ENET_PAD_CTRL),

    MX6_PAD_ENET_RXD0__ENET_RX_DATA0 | MUX_PAD_CTRL(ENET_PAD_CTRL),

    MX6_PAD_ENET_RXD1__ENET_RX_DATA1 | MUX_PAD_CTRL(ENET_PAD_CTRL),

    MX6_PAD_ENET_TXD0__ENET_TX_DATA0 | MUX_PAD_CTRL(ENET_PAD_CTRL),

    MX6_PAD_ENET_TXD1__ENET_TX_DATA1 | MUX_PAD_CTRL(ENET_PAD_CTRL),

    /* PHY Reset */

    MX6_PAD_ENET_REF_CLK__GPIO1_IO23 | MUX_PAD_CTRL(NO_PAD_CTRL),

};

static void setup_iomux_enet(void)

{

    imx_iomux_v3_setup_multiple_pads(enet_pads, ARRAY_SIZE(enet_pads));

    /* Reset PHY */

    gpio_direction_output(ETH_PHY_RESET, 0);

    udelay(500);

    gpio_set_value(ETH_PHY_RESET, 1);

}

int board_eth_init(bd_t *bis)

{

    int ret = 0;

    struct iomuxc *const iomuxc_regs = (struct iomuxc *)IOMUXC_BASE_ADDR;

    ret = enable_fec_anatop_clock(0, ENET_50MHZ);

    if (ret)

        return ret;

    /* set gpr1[ENET_CLK_SEL] */

    setbits_le32(&iomuxc_regs->gpr[1], IOMUXC_GPR1_ENET_CLK_SEL_MASK);

    setup_iomux_enet();

    ret = cpu_eth_init(bis);

    if (ret)

        printf("FEC MXC: %s:failed\n", __func__);

    return ret;

}

#endif /* CONFIG_FEC_MXC */

0 Kudos

2,879 Views
marcocavallini
Contributor V

Hi,

I needed to add a special setup just after reset.

In phy_reset() I added a soft reset MODE[2:0] = 111

phy_write(phydev, devad, MII_DCOUNTER, 0x60E1

--

Marco Cavallini | KOAN sas | Bergamo - Italia

embedded and real-time software engineering

0 Kudos

2,879 Views
ispsubb
Contributor II

Thank you for your reply!

I have try to patch it , but we get the same problem !

I modify 0x60E1 to 0x60E0 , because our phy address is 0 .

0 Kudos

2,879 Views
Yuri
NXP Employee
NXP Employee

Hello,

  is MAC address correct ?

Regards,

Yuri.

0 Kudos

2,879 Views
ispsubb
Contributor II

Thanks!

I think mac address is OK !

=> pri ethaddr

ethaddr=FA:E8:79:7A:B4:B8

it is the same mac in linux , rmii is ok in linux.

=> pri ipaddr

ipaddr=192.168.0.171

=> pri gw_ip

gw_ip=192.168.0.1

=> pri netmask

netmask=255.255.255.0

0 Kudos

2,879 Views
Yuri
NXP Employee
NXP Employee

Hello,

The most significant bit of the MAC is 1 - this means group address.

Is this reasonable ?

Regards,

Yuri.

0 Kudos

2,879 Views
ispsubb
Contributor II

Thanks , I try to modify the MAC , the same problem

0 Kudos

2,879 Views
BiyongSUN
NXP Employee
NXP Employee

suggest you can read the following ticket

RMII interface error on i.MX6Q

0 Kudos

2,879 Views
ispsubb
Contributor II

I have read the ticket . my linux is OK , it is not good in uboot .

0 Kudos