Internal MAC clock frequency value: 66 MHZ
PHY: Ar8031
1. After I set MDC frequency value(FEC_ENET_MII_CLK) are 1/2.36/2.5 MHZ in fec_enet_mii_init function, I measure the value is about 2.3/1.8/5.5 MHz.
MDC frequency setting value and the actual measured value are big difference between the two.
Can you please tell me how to set this value, the measured value will not differ too much?
2. I find that the formulas of reference manual and program are different.
a) i.MX 6Solo/6DualLite Applications Processor Reference Manual (MII Speed Control Register):
Internal MAC clock frequency / ((MSCR[MII_SPEED]+1)x2) = MDC frequency
Example: 25 MHz / ((4 + 1) x 2) = 2.5 MHz
b) Program (fec_enet_mii_init() in fec.c):
fep->phy_speed = DIV_ROUND_UP(clk_get_rate(fep->mdc_clk),(FEC_ENET_MII_CLK << 2)) << 1;
Can you please tell me which one is correct?
Thank you.
Both formulas should be equivalent provided that the Linux formula should work as it’s the actual implementation of the driver. However, it’s sometimes possible that the code looks deceiving if you do not know where the variables are pointing to etc.
Would you please share the BSP version that you’re using and the location of the file? I’m having problems locating these lines on the latest BSP version. I also looked at the driver on the i.MX6 SDK and couldn't locate these lines.
I use 3.0.35 BSP version. The location of the file is driver/net/fec.c. The function name is fec_enet_mii_init(struct platform_device *pdev).
Then you can see the following message in the program:
fep->phy_speed = DIV_ROUND_UP(clk_get_rate(fep->mdc_clk),(FEC_ENET_MII_CLK << 2)) << 1;
Example: Set MII speed to 1 MHz in program. However, the measurement results is 1.83 MHz.