In my iMX28 project I use Linux 2.6.35 + single port ethernet (iMX287 have 2 ethernet port). Ethernet transceiver is LAN8720A connectet to ENET0.
Only in some boards I have this problem: during Linux boot, system may reboot (sometimes forever). Below there is a small log of this event:
[...] boot [...]
mxs-spi mxs-spi.0: Max possible speed 24000 = 24000000/2 kHz
mxs-spi mxs-spi.0: at 0x80014000 mapped to 0xF0014000, irq=84, bus 1, DMA ver_major 4
vcan: Virtual CAN interface driver
Freescale FlexCAN Driver
CAN device driver interface
FEC Ethernet Driver
fec.c: fec_probe start init
fec.c: fec_probe get_resource
fec.c: fec_probe request_mem_region
fec.c: fec_probe alloc_etherdev
fec.c: fec_probe memset
fec.c: fec_probe memcpy2
fec.c: fec_probe i=0
fec.c: fec_probe i=1
fec.c: fec_probe dopo il for
fec.c: fec_probe clk_get
fec.c: fec_probe clk_enable
HTLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLFLC
PowerPrep start initialize power...
Configured for 5v only power source. Battery powered operation disabled.
[...] reboot forever or for 2 times [...]
NOTE: all fec.c ... are my comments
In a system go well the log is:
fec.c: fec_probe register_netdev:0
fec.c: fec_probe fine
fec.c: fec_probe start init
fec.c: fec_probe get_resource
fec.c: fec_probe request_mem_region
fec.c: fec_probe alloc_etherdev
fec.c: fec_probe memset
fec.c: fec_probe memcpy2
fec.c: fec_probe i=0
fec.c: fec_probe i=1
fec.c: fec_probe dopo il for
fec.c: fec_probe clk_get
fec.c: fec_probe clk_enable <<<<< this is the "crash point" in the fail case
----- FEC GPIO INIT (start) -----
----- ENET_PWR OK -----
----- ENET_PHY_RESET OK -----
----- FEC GPIO INIT (end) -----
fec.c: fec_probe pdata->init: 0
----- FEC GPIO INIT (start) -----
----- ENET_PWR OK -----
----- ENET_PHY_RESET OK -----
----- FEC GPIO INIT (end) -----
fec.c: fec_probe fec_enet_init:0
fec.c: fec_probe mii_init
fec.c: fec_probe register_netdev:0
fec.c: fec_probe fine
ehci_hcd: USB 2.0 'Enhanced' Host Controller (EHCI) Driver
I debugged the init functions ad I used printk for tracing. Crash I think born in the function fec_probe in fec.c file. The exact point is here (in the fec_probe function):
clk_enable(fep->clk);
printk(KERN_ERR "fec.c: fec_probe clk_enable\n");
/* PHY reset should be done during clock on */
if (pdata && pdata->init)
ret = pdata->init(); <<<< crash!!!
printk(KERN_ERR "fec.c: fec_probe pdata->init: %d\n",ret);
//printk("----- FEC GPIO INIT (start) -----\n");
Exploding pdata->init() the function is implemented in mx28evk_pins.c: mx28evk_enet_gpio_init.
I traced also this function:
/* pwr */
gpio_request(MXS_PIN_TO_GPIO(PINID_SSP1_DATA3), "ENET_PWR");
gpio_direction_output(MXS_PIN_TO_GPIO(PINID_SSP1_DATA3), 0);
printk("----- ENET_PWR OK -----\n");
/* reset phy */
gpio_request(MXS_PIN_TO_GPIO(PINID_ENET0_RX_CLK), "PHY_RESET");
gpio_direction_output(MXS_PIN_TO_GPIO(PINID_ENET0_RX_CLK), 0);
printk("----- ENET_PHY_RESET OK -----\n"); <<<< critical comment!!!!!
/*
* Before timer bug fix(set wrong match value of timer),
* mdelay(10) delay 50ms actually.
* So change delay to 50ms after timer issue fix.
*/
mdelay(50);
gpio_direction_output(MXS_PIN_TO_GPIO(PINID_ENET0_RX_CLK), 1);
printk("----- FEC GPIO INIT (end) -----\n");
So, if i use all the comment printk like shown above the system runs well; but if I delete the comment in bold the system restarts (one or more times or forever).
I tried to add a mdelay(100) but without effects.
May be this an hardware dependent problem? May be only due to timeouts to wait some signal? Do someone have some suggestions?
The system seems to work well (for now) with this workaround (workaround: adding by printk comments!!!) but I would like to undenstand what does it appens...
Thanks in advance.
Emanuele