I'm debugging eht phy LAN8720 driver, and i met the problem the eth0 can not get ip address, and can not ping ip after i set the ip address manually.

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

I'm debugging eht phy LAN8720 driver, and i met the problem the eth0 can not get ip address, and can not ping ip after i set the ip address manually.

Jump to solution
4,632 Views
wenjingwang
Contributor II

My develop env is :

               IMX6DL board

               Linux kernel 3.0.35

  and my pin config is :

MX6DL_PAD_ENET_MDIO__ENET_MDIO,

  MX6DL_PAD_ENET_MDC__ENET_MDC,

MX6DL_PAD_ENET_CRS_DV__ENET_RX_EN,

MX6DL_PAD_ENET_RXD1__ENET_RDATA_1,

MX6DL_PAD_ENET_RXD0__ENET_RDATA_0,

MX6DL_PAD_RGMII_TX_CTL__ENET_ANATOP_ETHERNET_REF_OUT,

  MX6DL_PAD_ENET_REF_CLK__ENET_TX_CLK,

MX6DL_PAD_ENET_TXD1__ENET_TDATA_1,

MX6DL_PAD_ENET_TXD0__ENET_TDATA_0,

MX6DL_PAD_ENET_TX_EN__ENET_TX_EN,

in the board-mx6q_sabresd.c file:

          static struct fec_platform_data fec_data __initdata = {    

            .init = mx6q_8720_fec_phy_init, //WWJ add    

            .phy = PHY_INTERFACE_MODE_RMII,     

            .gpio_irq = MX6_ENET_IRQ,  //WWJ add

          };

#define SABRESD_LAN8720_RST IMX_GPIO_NR(1, 1)

static int mx6q_8720_fec_phy_init(struct phy_device *phydev)

{

     int val;

     printk("WWJ============%s start\n", __FUNCTION__);//WWJ

     gpio_request(SABRESD_LAN8720_RST, "lan-reset");

     gpio_direction_output(SABRESD_LAN8720_RST, 0);

     msleep(10);

     gpio_set_value(SABRESD_LAN8720_RST, 1);

     //mxc_iomux_set_gpr_register(1, 21, 1, 1);

     /* reset phy */

  

     val = phy_read(phydev, 0x0);

     msleep(500);

     printk("phydev->addr = %x\n", phydev->addr);

   

     phy_write(phydev, 0x0, (val |BMCR_RESET));

     msleep(10);

     val = phy_read(phydev, 0x0);

     if (val & BMCR_PDOWN) {

       phy_write(phydev, 0x0, (val & ~BMCR_PDOWN));    

     }

     return 0;

}

and i added the follow function:

          mxc_iomux_set_gpr_register(1, 21, 1, 1);//WWJ add for FEC_RMII_CLK

in  static void __init mx6_sabresd_board_init(void);

the attachment is my hardware env.

Labels (1)
Tags (2)
0 Kudos
1 Solution
2,083 Views
wenjingwang
Contributor II

my issue is the MDC clock too hight and the pin_iomux was configued wrong by me, so the issue is fixed. Thank you!

View solution in original post

0 Kudos
5 Replies
2,082 Views
deepajosephine
Contributor II

Hi,

Have you fixed the issue? We are encoutering similar issue with our custom board. Can you share the fix that worked for you?

Thanks,
Deepa

0 Kudos
2,083 Views
wenjingwang
Contributor II

hi, i have not fix the issue. my change is follow:

diff --git a/arch/arm/mach-mx6/board-mx6dl_sabresd.h b/arch/arm/mach-mx6/board-mx6dl_sabresd.h

index 12d9700..8aae892 100644

--- a/arch/arm/mach-mx6/board-mx6dl_sabresd.h

+++ b/arch/arm/mach-mx6/board-mx6dl_sabresd.h

@@ -52,25 +52,33 @@ static iomux_v3_cfg_t mx6dl_sabresd_pads[] = {

  /* ENET */

  MX6DL_PAD_ENET_MDIO__ENET_MDIO,

  MX6DL_PAD_ENET_MDC__ENET_MDC,

+ /*

  MX6DL_PAD_RGMII_TXC__ENET_RGMII_TXC,

  MX6DL_PAD_RGMII_TD0__ENET_RGMII_TD0,

  MX6DL_PAD_RGMII_TD1__ENET_RGMII_TD1,

  MX6DL_PAD_RGMII_TD2__ENET_RGMII_TD2,

  MX6DL_PAD_RGMII_TD3__ENET_RGMII_TD3,

  MX6DL_PAD_RGMII_TX_CTL__ENET_RGMII_TX_CTL,

+ */

+ MX6DL_PAD_RGMII_TX_CTL__ENET_ANATOP_ETHERNET_REF_OUT, //WWJ add

  MX6DL_PAD_ENET_REF_CLK__ENET_TX_CLK,

+ /*

  MX6DL_PAD_RGMII_RXC__ENET_RGMII_RXC,

  MX6DL_PAD_RGMII_RD0__ENET_RGMII_RD0,

  MX6DL_PAD_RGMII_RD1__ENET_RGMII_RD1,

  MX6DL_PAD_RGMII_RD2__ENET_RGMII_RD2,

  MX6DL_PAD_RGMII_RD3__ENET_RGMII_RD3,

  MX6DL_PAD_RGMII_RX_CTL__ENET_RGMII_RX_CTL,

+ */

  /* RGMII_nRST */

- MX6DL_PAD_ENET_CRS_DV__GPIO_1_25,

+ // MX6DL_PAD_ENET_CRS_DV__GPIO_1_25,  WWJ delete

+ MX6DL_PAD_ENET_CRS_DV__ENET_RX_EN, //WWJ add

  /* IEEE 1588 clock */

//use to mic MX6DL_PAD_GPIO_16__ENET_ANATOP_ETHERNET_REF_OUT,

  /* RGMII Interrupt */

- MX6DL_PAD_ENET_RXD1__GPIO_1_26,

+ //MX6DL_PAD_ENET_RXD1__GPIO_1_26, WWJ delete

+ MX6DL_PAD_ENET_RXD1__ENET_RDATA_1, //WWJ add

+ MX6DL_PAD_GPIO_16__ENET_ANATOP_ETHERNET_REF_OUT, //WWJ add

  /* I2C1 */

  MX6DL_PAD_CSI0_DAT8__I2C1_SDA,

@@ -84,7 +92,7 @@ static iomux_v3_cfg_t mx6dl_sabresd_pads[] = {

  /* I2C3 */

  MX6DL_PAD_GPIO_3__I2C3_SCL,

- MX6DL_PAD_GPIO_6__I2C3_SDA,

+ //MX6DL_PAD_GPIO_6__I2C3_SDA, WWJ delete

  /* DISPLAY */

  MX6DL_PAD_DI0_DISP_CLK__IPU1_DI0_DISP_CLK,

@@ -141,13 +149,16 @@ static iomux_v3_cfg_t mx6dl_sabresd_pads[] = {

  MX6DL_PAD_EIM_D27__UART2_RXD,

  /* USB */

- MX6DL_PAD_ENET_RX_ER__ANATOP_USBOTG_ID,

+ //MX6DL_PAD_ENET_RX_ER__ANATOP_USBOTG_ID, WWJ delete

+ MX6DL_PAD_ENET_RX_ER__ENET_RX_ER, //WWJ add

+ MX6DL_PAD_ENET_TX_EN__ENET_TX_EN, //WWJ add

// MX6DL_PAD_EIM_D21__USBOH3_USBOTG_OC,

  /* USB_OTG_PWR_EN */

  MX6DL_PAD_EIM_D22__GPIO_3_22,

  MX6DL_PAD_EIM_D30__USBOH3_USBH1_OC,

  /*USB_H1 PWR EN*/

- MX6DL_PAD_ENET_TXD1__GPIO_1_29,

+ //MX6DL_PAD_ENET_TXD1__GPIO_1_29, //WWJ delete

+ MX6DL_PAD_ENET_TXD1__ENET_TDATA_1, //WWJ add

  /*SD1*/

  MX6DL_PAD_SD1_CLK__USDHC1_CLK_50MHZ_40OHM,

@@ -235,7 +246,8 @@ static iomux_v3_cfg_t mx6dl_sabresd_pads[] = {

  /* DISP_PWM */

// MX6DL_PAD_SD1_DAT3__PWM1_PWMO,

  /* DISP0 power enable */

- MX6DL_PAD_ENET_TXD0__GPIO_1_30,

+ //MX6DL_PAD_ENET_TXD0__GPIO_1_30, WWJ delete

+ MX6DL_PAD_ENET_TXD0__ENET_TDATA_0, //WWJ add

  /* DISP0_RD */

// MX6DL_PAD_EIM_D28__GPIO_3_28,

  /* DISP_RST_B */

@@ -296,7 +308,8 @@ static iomux_v3_cfg_t mx6dl_sabresd_pads[] = {

  MX6DL_PAD_EIM_DA13__GPIO_3_13, /* CHG_2_B  */

  MX6DL_PAD_EIM_DA14__GPIO_3_14, /* FLT_2_B */

- MX6DL_PAD_ENET_RXD0__GPIO_1_27, /* UOK_B */

+ //MX6DL_PAD_ENET_RXD0__GPIO_1_27, /* UOK_B */ WWJ delete

+ MX6DL_PAD_ENET_RXD0__ENET_RDATA_0, //WWJ add

  MX6DL_PAD_EIM_CS1__GPIO_2_24,   /* DOK_B */

  /* TS_INT - MAX11801 */

diff --git a/arch/arm/mach-mx6/board-mx6q_sabresd.c b/arch/arm/mach-mx6/board-mx6q_sabresd.c

index 0b8d144..3d748a9 100644

--- a/arch/arm/mach-mx6/board-mx6q_sabresd.c

+++ b/arch/arm/mach-mx6/board-mx6q_sabresd.c

@@ -211,6 +211,7 @@

#define SABRESD_EPDC_VCOM IMX_GPIO_NR(3, 17)

#define SABRESD_CHARGE_NOW IMX_GPIO_NR(1, 2)

#define SABRESD_CHARGE_DONE IMX_GPIO_NR(1, 1)

+#define SABRESD_LAN8720_RST IMX_GPIO_NR(1, 1)

// Frank Lee #define SABRESD_ELAN_CE IMX_GPIO_NR(2, 18)

// Frank Lee #define SABRESD_ELAN_RST IMX_GPIO_NR(3, 8)

// Frank Lee #define SABRESD_ELAN_INT IMX_GPIO_NR(3, 28)

@@ -327,10 +328,44 @@ static int mx6q_sabresd_fec_phy_init(struct phy_device *phydev)

  return 0;

}

+//WWJ add begin

+//#define BMCR_RESET (1 << 15)

+//#define BMCR_PDOWN ~(1 << 11)

+static int mx6q_8720_fec_phy_init(struct phy_device *phydev)

+{

+     int val;

+

+      /* reset phy */

+     printk("WWJ============%s start\n", __FUNCTION__);//WWJ

+     gpio_request(SABRESD_LAN8720_RST, "lan-reset");

+     gpio_direction_output(SABRESD_LAN8720_RST, 0);

+     msleep(10);

+     gpio_set_value(SABRESD_LAN8720_RST, 1);

+  

+     val = phy_read(phydev, 0x0);

+     if (val & BMCR_PDOWN) {

+ phy_write(phydev, 0x0, (val & ~BMCR_PDOWN));

+     }

+

+ //printk("TX_EN = %x\n", __raw_readl(ioremap(0x020e04fc, 4)));//WWJ

+ //printk("TXD1 = %x\n", __raw_readl(ioremap(0x020e0500, 4)));//WWJ

+ //printk("TXD0 = %x\n", __raw_readl(ioremap(0x020e0504, 4)));//WWJ

+ printk("MDIO_SELECT = %x\n", __raw_readl(ioremap(0x020e0810, 4)));//WWJ

+ printk("RXEN_SELECT = %x\n", __raw_readl(ioremap(0x020e0828, 4)));//WWJ

+ printk("RXDATA_0 = %x\n", __raw_readl(ioremap(0x020e0818, 4)));//WWJ

+ printk("RXDATA_1 = %x\n", __raw_readl(ioremap(0x020e081c, 4)));//WWJ

+ printk("WWJ============%s end\n", __FUNCTION__);//WWJ

+ printk("");

+     return 0;

+}

+//WWJ add end

+

static struct fec_platform_data fec_data __initdata = {

- .init = mx6q_sabresd_fec_phy_init,

- .phy = PHY_INTERFACE_MODE_RGMII,

-// .gpio_irq = MX6_ENET_IRQ,

+ //.init = mx6q_sabresd_fec_phy_init, WWJ delete

+ .init = mx6q_8720_fec_phy_init, //WWJ add

+ //.phy = PHY_INTERFACE_MODE_RGMII, WWJ delete

+ .phy = PHY_INTERFACE_MODE_RMII, //WWJ add

+ .gpio_irq = MX6_ENET_IRQ,  //WWJ add

};

#if 0

@@ -1976,6 +2011,7 @@ static void __init mx6_sabresd_board_init(void)

  ARRAY_SIZE(mx6dl_sabresd_pads));

  if (enet_to_gpio_6) {

+ printk("enet_to_gpio_6 is true============WWJ\n");

  iomux_v3_cfg_t enet_gpio_pad =

  MX6DL_PAD_GPIO_6__ENET_IRQ_TO_GPIO_6;

  mxc_iomux_v3_setup_pad(enet_gpio_pad);

@@ -2025,6 +2061,7 @@ static void __init mx6_sabresd_board_init(void)

  mxc_iomux_set_gpr_register(1, 21, 1, 1);

#endif

+

  gp_reg_id = sabresd_dvfscore_data.reg_id;

  soc_reg_id = sabresd_dvfscore_data.soc_id;

  mx6q_sabresd_init_uart();

@@ -2088,8 +2125,10 @@ static void __init mx6_sabresd_board_init(void)

  imx6q_add_imx_i2c(0, &mx6q_sabresd_i2c_data);

  imx6q_add_imx_i2c(1, &mx6q_sabresd_i2c_data);

  imx6q_add_imx_i2c(2, &mx6q_sabresd_i2c_data);

+ /* WWJ delete

  if (cpu_is_mx6dl())

  imx6q_add_imx_i2c(3, &mx6q_sabresd_i2c_data);

+ */

  i2c_register_board_info(0, mxc_i2c0_board_info,

  ARRAY_SIZE(mxc_i2c0_board_info));

  i2c_register_board_info(1, mxc_i2c1_board_info,

@@ -2113,6 +2152,7 @@ static void __init mx6_sabresd_board_init(void)

  imx6q_add_mxc_hdmi(&hdmi_data);

  imx6q_add_anatop_thermal_imx(1, &mx6q_sabresd_anatop_thermal_data);

+ mxc_iomux_set_gpr_register(1, 21, 1, 1);//WWJ add for FEC_RMII_CLK

  if (enet_to_gpio_6)

  /* Make sure the IOMUX_OBSRV_MUX1 is set to ENET_IRQ. */

diff --git a/arch/arm/plat-mxc/include/mach/iomux-mx6dl.h b/arch/arm/plat-mxc/include/mach/iomux-mx6dl.h

index 59f8399..1e04205 100644

--- a/arch/arm/plat-mxc/include/mach/iomux-mx6dl.h

+++ b/arch/arm/plat-mxc/include/mach/iomux-mx6dl.h

@@ -55,7 +55,7 @@

  PAD_CTL_DSE_34ohm   | PAD_CTL_SRE_FAST   | PAD_CTL_HYS)

#define MX6DL_ENET_PAD_CTRL (PAD_CTL_PKE | PAD_CTL_PUE  | \

- PAD_CTL_PUS_100K_UP | PAD_CTL_SPEED_MED | \

+ PAD_CTL_PUS_100K_UP | PAD_CTL_SPEED_LOW | \

  PAD_CTL_DSE_40ohm   | PAD_CTL_HYS)

#define MX6DL_ENET_REF_CLK_PAD_CTRL     (PAD_CTL_PUE |  \

@@ -2232,7 +2232,7 @@

  IOMUX_PAD(0x05B0, 0x01E0, 7, 0x0000, 0, NO_PAD_CTRL)

#define MX6DL_PAD_ENET_CRS_DV__ENET_RX_EN                                      \

- IOMUX_PAD(0x05B4, 0x01E4, 1, 0x0828, 0, NO_PAD_CTRL)

+ IOMUX_PAD(0x05B4, 0x01E4, 1, 0x0828, 1, MX6DL_ENET_PAD_CTRL)

#define MX6DL_PAD_ENET_CRS_DV__ESAI1_SCKT                                      \

  IOMUX_PAD(0x05B4, 0x01E4, 2, 0x0840, 0, MX6DL_ESAI_PAD_CTRL)

#define MX6DL_PAD_ENET_CRS_DV__SPDIF_SPDIF_EXTCLK                              \

@@ -2286,7 +2286,7 @@

#define MX6DL_PAD_ENET_RX_ER__ANATOP_USBOTG_ID                                 \

  IOMUX_PAD(0x05C4, 0x01F4, 0, 0x0790, 0, NO_PAD_CTRL)

#define MX6DL_PAD_ENET_RX_ER__ENET_RX_ER                                       \

- IOMUX_PAD(0x05C4, 0x01F4, 1, 0x0000, 0, NO_PAD_CTRL)

+ IOMUX_PAD(0x05C4, 0x01F4, 1, 0x0000, 0, MX6DL_ENET_PAD_CTRL)

#define MX6DL_PAD_ENET_RX_ER__ESAI1_HCKR                                       \

  IOMUX_PAD(0x05C4, 0x01F4, 2, 0x0834, 0, MX6DL_ESAI_PAD_CTRL)

#define MX6DL_PAD_ENET_RX_ER__SPDIF_IN1                                        \

@@ -2303,7 +2303,7 @@

#define MX6DL_PAD_ENET_RXD0__OSC32K_32K_OUT                                    \

  IOMUX_PAD(0x05C8, 0x01F8, 0, 0x0000, 0, NO_PAD_CTRL)

#define MX6DL_PAD_ENET_RXD0__ENET_RDATA_0                                      \

- IOMUX_PAD(0x05C8, 0x01F8, 1, 0x0818, 0, NO_PAD_CTRL)

+ IOMUX_PAD(0x05C8, 0x01F8, 1, 0x0818, 1, MX6DL_ENET_PAD_CTRL)

#define MX6DL_PAD_ENET_RXD0__ESAI1_HCKT                                        \

  IOMUX_PAD(0x05C8, 0x01F8, 2, 0x0838, 0, MX6DL_ESAI_PAD_CTRL)

#define MX6DL_PAD_ENET_RXD0__SPDIF_OUT1                                        \

@@ -2318,7 +2318,7 @@

#define MX6DL_PAD_ENET_RXD1__MLB_MLBSIG                                        \

  IOMUX_PAD(0x05CC, 0x01FC, 0, 0x08E4, 0, NO_PAD_CTRL)

#define MX6DL_PAD_ENET_RXD1__ENET_RDATA_1                                      \

- IOMUX_PAD(0x05CC, 0x01FC, 1, 0x081C, 0, NO_PAD_CTRL)

+ IOMUX_PAD(0x05CC, 0x01FC, 1, 0x081C, 1, MX6DL_ENET_PAD_CTRL)

#define MX6DL_PAD_ENET_RXD1__ESAI1_FST                                         \

  IOMUX_PAD(0x05CC, 0x01FC, 2, 0x0830, 0, MX6DL_ESAI_PAD_CTRL)

#define MX6DL_PAD_ENET_RXD1__ENET_1588_EVENT3_OUT                              \

@@ -2331,7 +2331,7 @@

  IOMUX_PAD(0x05CC, 0x01FC, 7, 0x0000, 0, NO_PAD_CTRL)

#define MX6DL_PAD_ENET_TX_EN__ENET_TX_EN                                       \

- IOMUX_PAD(0x05D0, 0x0200, 1, 0x0000, 0, NO_PAD_CTRL)

+ IOMUX_PAD(0x05D0, 0x0200, 1, 0x0000, 0, MX6DL_ENET_PAD_CTRL)

#define MX6DL_PAD_ENET_TX_EN__ESAI1_TX3_RX2                                    \

  IOMUX_PAD(0x05D0, 0x0200, 2, 0x0850, 0, MX6DL_ESAI_PAD_CTRL)

#define MX6DL_PAD_ENET_TX_EN__GPIO_1_28                                        \

@@ -2342,7 +2342,7 @@

  IOMUX_PAD(0x05D0, 0x0200, 9 | IOMUX_CONFIG_SION, 0x0880, 0, MX6DL_I2C_PAD_CTRL)

#define MX6DL_PAD_ENET_TXD0__ENET_TDATA_0                                      \

- IOMUX_PAD(0x05D4, 0x0204, 1, 0x0000, 0, NO_PAD_CTRL)

+ IOMUX_PAD(0x05D4, 0x0204, 1, 0x0000, 0, MX6DL_ENET_PAD_CTRL)

#define MX6DL_PAD_ENET_TXD0__ESAI1_TX4_RX1                                     \

  IOMUX_PAD(0x05D4, 0x0204, 2, 0x0854, 0, MX6DL_ESAI_PAD_CTRL)

#define MX6DL_PAD_ENET_TXD0__GPIO_1_30                                         \

@@ -2353,7 +2353,7 @@

#define MX6DL_PAD_ENET_TXD1__MLB_MLBCLK                                        \

  IOMUX_PAD(0x05D8, 0x0208, 0, 0x08DC, 0, NO_PAD_CTRL)

#define MX6DL_PAD_ENET_TXD1__ENET_TDATA_1                                      \

- IOMUX_PAD(0x05D8, 0x0208, 1, 0x0000, 0, NO_PAD_CTRL)

+ IOMUX_PAD(0x05D8, 0x0208, 1, 0x0000, 0, MX6DL_ENET_PAD_CTRL)

#define MX6DL_PAD_ENET_TXD1__ESAI1_TX2_RX3                                     \

  IOMUX_PAD(0x05D8, 0x0208, 2, 0x084C, 0, MX6DL_ESAI_PAD_CTRL)

#define MX6DL_PAD_ENET_TXD1__ENET_1588_EVENT0_IN                               \

@@ -2402,7 +2402,7 @@

#define MX6DL_PAD_GPIO_16__ENET_1588_EVENT2_IN                                 \

  IOMUX_PAD(0x05E4, 0x0214, 1, 0x0000, 0, NO_PAD_CTRL)

#define MX6DL_PAD_GPIO_16__ENET_ANATOP_ETHERNET_REF_OUT                        \

- IOMUX_PAD(0x05E4, 0x0214, 0x12, 0x080C, 0, NO_PAD_CTRL)

+ IOMUX_PAD(0x05E4, 0x0214, 0x12, 0x080C, 1, NO_PAD_CTRL)

#define MX6DL_PAD_GPIO_16__USDHC1_LCTL                                         \

  IOMUX_PAD(0x05E4, 0x0214, 3, 0x0000, 0, MX6DL_USDHC_PAD_CTRL)

#define MX6DL_PAD_GPIO_16__SPDIF_IN1                                           \

@@ -3206,7 +3206,7 @@

#define MX6DL_PAD_RGMII_TX_CTL__MIPI_CORE_DPHY_TEST_IN_7                       \

  IOMUX_PAD(0x06BC, 0x02D4, 6, 0x0000, 0, NO_PAD_CTRL)

#define MX6DL_PAD_RGMII_TX_CTL__ENET_ANATOP_ETHERNET_REF_OUT                   \

- IOMUX_PAD(0x06BC, 0x02D4, 7, 0x080C, 1, NO_PAD_CTRL)

+ IOMUX_PAD(0x06BC, 0x02D4, 0x17, 0x080C, 1, NO_PAD_CTRL)

#define MX6DL_PAD_RGMII_TXC__USBOH3_H2_DATA                                    \

  IOMUX_PAD(0x06C0, 0x02D8, 0 | IOMUX_CONFIG_SION, 0x0000, 0, MX6DL_USB_HSIC_PAD_CTRL)

diff --git a/drivers/misc/ds28e10.c b/drivers/misc/ds28e10.c

index 1df31ea..faef97e 100755

--- a/drivers/misc/ds28e10.c

+++ b/drivers/misc/ds28e10.c

@@ -7,6 +7,8 @@

#include <linux/interrupt.h>

//#include <mach/gpio_sf02.h>

#include <mach/gpio.h>

+#include <linux/socket.h>

+#include <linux/netdevice.h>

#define DRIVER_NAME "ds28e10"

#define EdbgOutputDebugString printk

@@ -90,7 +92,7 @@ unsigned char     ExtensionSecret[28] =    //OTP memory data 0x00~0x1B can be as

//define basic 64-bit secret for DS28E10

//unsigned char DeviceSecret[8] = {0x12,0x29,0xfd,0x23,0x43,0x22,0x44,0x52};

-#if 1

+#if 0

unsigned char   DeviceSecret1[8] = {0x20,0x12,0x41,0xd0,0x40,0x22,0x41,0x51};

unsigned char DeviceSecret3[8] = {0x12,0x29,0xfd,0x23,0x43,0x22,0x44,0x52};

unsigned char   DeviceSecret2[8] = {0x11,0x04,0x48,0x0a,0x1a,0x02,0x32,0x14};

@@ -98,6 +100,13 @@ unsigned char DeviceSecret4[8] = {0x12,0x29,0xfd,0x23,0x43,0x22,0x44,0x52};

unsigned char   DeviceSecret[8]; //  = {0x31,0x16,0x89,0xda,0x5a,0x24,0x73,0x65};

#endif

+unsigned char   DeviceSecret1[8] = {0x20,0x12,0x41,0xc9,0x40,0x22,0x41,0x51};

+unsigned char   DeviceSecret3[8] = {0x12,0x29,0xfd,0x23,0x43,0x22,0x44,0x52};

+unsigned char   DeviceSecret2[8] = {0x22,0x07,0x37,0x00,0x08,0x14,0x21,0x03};

+unsigned char   DeviceSecret4[8] = {0x12,0x29,0xfd,0x23,0x43,0x22,0x44,0x52};

+unsigned char   DeviceSecret[8]; //  = {0x42,0x19,0x78,0xc9,0x48,0x36,0x62,0x54};

+

+

//define for opening I/O

//int fd;

unsigned int get;

@@ -736,6 +745,30 @@ static int Authenticate_DS28E10_By_64bitSecret(unsigned char *Challenge, unsigne

         if( i==20 ){ return Match_MAC;}

         else return UnMatch_MAC;

}

+

+extern struct net_device *mxc_fec_ndev;

+extern void mxc_set_mac_address(void *p);

+static struct delayed_work dwork;

+

+static void set_mac_address_work(struct work_struct *work)

+{

+ struct sockaddr p;

+

+ if( mxc_fec_ndev != NULL )

+ {

+ printk("set_mac_address_work: hahahaha.........................\n");

+ p.sa_data[5] = OW_RomID[7];

+ p.sa_data[4] = OW_RomID[3];

+ p.sa_data[3] = OW_RomID[2];

+ p.sa_data[2] = OW_RomID[1];

+ p.sa_data[1] = OW_RomID[0];

+ p.sa_data[0] = 0x1E;

+ mxc_set_mac_address(&p);

+ }

+ else

+ schedule_delayed_work(&dwork, msecs_to_jiffies(10));

+}

+

static int ds28e10_probe(struct platform_device* device)

{

  int i, ret;

@@ -780,6 +813,9 @@ static int ds28e10_probe(struct platform_device* device)

  panic("keyboard error");

  }

+// INIT_DELAYED_WORK(&dwork, set_mac_address_work);

+

+// schedule_delayed_work(&dwork, msecs_to_jiffies(10));

// gpio_free(res->start);

  return 0;

}

diff --git a/drivers/net/fec.c b/drivers/net/fec.c

index 009db54..acb4752 100755

--- a/drivers/net/fec.c

+++ b/drivers/net/fec.c

@@ -145,6 +145,7 @@ MODULE_PARM_DESC(macaddr, "FEC Ethernet MAC address");

#define FEC_ENET_TS_AVAIL       ((uint)0x00010000)

#define FEC_ENET_TS_TIMER       ((uint)0x00008000)

#define FEC_ENET_MII_CLK       ((uint)2500000)

+//#define FEC_ENET_MII_CLK       ((uint)5000000) /*WWJ add*/

#define FEC_ENET_HOLD_TIME     ((uint)0x100)  /* 2 internal clock cycle*/

#define FEC_DEFAULT_IMASK (FEC_ENET_TXF | FEC_ENET_RXF | FEC_ENET_MII)

@@ -288,12 +289,15 @@ void *fec_enet_get_pre_txbd(struct net_device *ndev)

{

  struct fec_enet_private *fep = netdev_priv(ndev);

  struct bufdesc *bdp = fep->cur_tx;

-

- if (bdp == fep->tx_bd_base)

+ printk("WWJ==========%s start\n", __FUNCTION__);

+ if (bdp == fep->tx_bd_base){

+ printk("bdp == fep->tx_bd_base == %x\n", bdp);

  return bdp + TX_RING_SIZE;

- else

+ }

+ else{

+ printk("bdp = %x fep->tx_bd_base = %x\n", bdp, fep->tx_bd_base);

  return bdp - 1;

-

+ }

}

/* MTIP enet IP have one IC issue recorded at PDM ticket:TKT168103

@@ -326,6 +330,7 @@ fec_enet_start_xmit(struct sk_buff *skb, struct net_device *ndev)

  unsigned long   estatus;

  unsigned long flags;

+ printk("WWJ=========%s start\n", __FUNCTION__);//WWJ add

  spin_lock_irqsave(&fep->hw_lock, flags);

  if (!fep->link) {

  /* Link is down or autonegotiation is in progress. */

@@ -429,6 +434,7 @@ fec_enet_start_xmit(struct sk_buff *skb, struct net_device *ndev)

  spin_unlock_irqrestore(&fep->hw_lock, flags);

+ printk("WWJ=========%s end ok\n", __FUNCTION__);//WWJ add

  return NETDEV_TX_OK;

}

@@ -439,6 +445,7 @@ fec_timeout(struct net_device *ndev)

  ndev->stats.tx_errors++;

+ printk("WWJ=========%s start\n", __FUNCTION__);//WWJ add

  netif_device_detach(ndev);

  fec_stop(ndev);

@@ -447,6 +454,7 @@ fec_timeout(struct net_device *ndev)

  ndev->trans_start = jiffies; /* prevent tx timeout */

  if (fep->link && !fep->tx_full)

  netif_wake_queue(ndev);

+ printk("WWJ=========%s end ok\n", __FUNCTION__);//WWJ add

}

static void

@@ -466,9 +474,11 @@ fec_rx_int_is_enabled(struct net_device *ndev, bool enabled)

#ifdef CONFIG_NET_POLL_CONTROLLER

static void fec_enet_netpoll(struct net_device *ndev)

{

+ printk("WWJ=========%s start\n", __FUNCTION__);//WWJ add

  disable_irq(ndev->irq);

  fec_enet_interrupt(ndev->irq, ndev);

  enable_irq(ndev->irq);

+ printk("WWJ=========%s end\n", __FUNCTION__);//WWJ add

}

#endif

@@ -486,7 +496,10 @@ fec_enet_tx(struct net_device *ndev)

  spin_lock(&fep->hw_lock);

  bdp = fep->dirty_tx;

+ printk("WWJ===========%s start bdp->cbd_sc = %x\n", __FUNCTION__, bdp->cbd_sc);

  while (((status = bdp->cbd_sc) & BD_ENET_TX_READY) == 0) {

+ printk("WWJ=========== in the while fep->cur_tx = %x, bdp = %x, fep->tx_full = %x",

+ fep->cur_tx, bdp, fep->tx_full);//WWJ add

  if (bdp == fep->cur_tx && fep->tx_full == 0)

  break;

@@ -837,15 +850,20 @@ fec_enet_interrupt(int irq, void *dev_id)

  uint int_events;

  ulong flags;

  irqreturn_t ret = IRQ_NONE;

+ printk("WWJ=========%s start\n", __FUNCTION__);//WWJ

  do {

  int_events = readl(fep->hwp + FEC_IEVENT);

  writel(int_events, fep->hwp + FEC_IEVENT);

+ printk("int_events = %x\n", int_events);

+ printk(" RX FEC_ENET_RXF= %x\n", FEC_ENET_RXF);//WWJ

  if (int_events & FEC_ENET_RXF) {

+ printk("enter RX FEC_ENET_RXF= %x\n", FEC_ENET_RXF);//WWJ

  ret = IRQ_HANDLED;

  spin_lock_irqsave(&fep->hw_lock, flags);

+ printk("fep->use_napi = %d\n", fep->use_napi);

  if (fep->use_napi) {

  /* Disable the RX interrupt */

  if (napi_schedule_prep(&fep->napi)) {

@@ -862,18 +880,25 @@ fec_enet_interrupt(int irq, void *dev_id)

  * descriptors. FEC handles all errors, we just discover

  * them as part of the transmit process.

  */

+ printk(" TX FEC_ENET_TXF = %x\n", FEC_ENET_TXF);//WWJ

+

  if (int_events & FEC_ENET_TXF) {

+ printk("enter TX FEC_ENET_TXF = %x\n", FEC_ENET_TXF);//WWJ

  ret = IRQ_HANDLED;

  fec_enet_tx(ndev);

  }

+ printk(" FEC_ENET_TS_TIMER = %x\n", FEC_ENET_TS_TIMER);

  if (int_events & FEC_ENET_TS_TIMER) {

+ printk("enter FEC_ENET_TS_TIMER = %x\n", FEC_ENET_TS_TIMER);

  ret = IRQ_HANDLED;

  if (fep->ptimer_present && fpp)

  fpp->prtc++;

  }

+ printk(" FEC_ENET_MII = %x\n", FEC_ENET_MII);

  if (int_events & FEC_ENET_MII) {

+ printk("enter FEC_ENET_MII = %x\n", FEC_ENET_MII);

  ret = IRQ_HANDLED;

  complete(&fep->mdio_done);

  }

@@ -944,10 +969,13 @@ static void fec_enet_adjust_link(struct net_device *ndev)

  int status_change = 0;

+ printk("WWJ==========%s start\n", __FUNCTION__);//WWJ add

  spin_lock_irqsave(&fep->hw_lock, flags);

  /* Prevent a state halted on mii error */

  if (fep->mii_timeout && phy_dev->state == PHY_HALTED) {

+ printk("fep->mii_timeout = %d, phy_dev->state = %d, PHY_HALTED = %d\n",

+ fep->mii_timeout, phy_dev->state, PHY_HALTED);//WWJ

  phy_dev->state = PHY_RESUMING;

  goto spin_unlock;

  }

@@ -987,6 +1015,8 @@ static int fec_enet_mdio_read(struct mii_bus *bus, int mii_id, int regnum)

  struct fec_enet_private *fep = bus->priv;

  unsigned long time_left;

+

+ printk("WWJ=========%s start\n", __FUNCTION__);//WWJ

  fep->mii_timeout = 0;

  init_completion(&fep->mdio_done);

@@ -1004,6 +1034,8 @@ static int fec_enet_mdio_read(struct mii_bus *bus, int mii_id, int regnum)

  return -ETIMEDOUT;

  }

+ printk("WWJ=========%s end\n", __FUNCTION__);//WWJ

+ printk("FEC_MII_DATA = %x\n", readl(fep->hwp + FEC_MII_DATA));//WWJ

  /* return value */

  return FEC_MMFR_DATA(readl(fep->hwp + FEC_MII_DATA));

}

@@ -1014,6 +1046,7 @@ static int fec_enet_mdio_write(struct mii_bus *bus, int mii_id, int regnum,

  struct fec_enet_private *fep = bus->priv;

  unsigned long time_left;

+ printk("WWJ==============%s start\n", __FUNCTION__);//WWJ add

  fep->mii_timeout = 0;

  init_completion(&fep->mdio_done);

@@ -1051,6 +1084,7 @@ static int fec_enet_mii_probe(struct net_device *ndev)

  fep->phy_dev = NULL;

+ printk("WWJ============%s start\n", __FUNCTION__);//WWJ

  /* check for attached phy */

  for (phy_id = 0; (phy_id < PHY_MAX_ADDR); phy_id++) {

  if ((fep->mii_bus->phy_mask & (1 << phy_id)))

@@ -1066,12 +1100,15 @@ static int fec_enet_mii_probe(struct net_device *ndev)

  }

  if (phy_id >= PHY_MAX_ADDR) {

+ printk("WWJ ==========phy_id = %x\n", phy_id); //WWJ

  printk(KERN_INFO "%s: no PHY, assuming direct connection "

  "to switch\n", ndev->name);

  strncpy(mdio_bus_id, "0", MII_BUS_ID_SIZE);

  phy_id = 0;

  }

+ printk("phy_id = %x\n", phy_id); //WWJ

+

  snprintf(phy_name, MII_BUS_ID_SIZE, PHY_ID_FMT, mdio_bus_id, phy_id);

  phy_dev = phy_connect(ndev, phy_name, &fec_enet_adjust_link, 0,

  fep->phy_interface);

@@ -1083,7 +1120,7 @@ static int fec_enet_mii_probe(struct net_device *ndev)

  /* mask with MAC supported features */

  if (cpu_is_mx6q() || cpu_is_mx6dl())

- phy_dev->supported &= PHY_GBIT_FEATURES;

+ phy_dev->supported &= PHY_BASIC_FEATURES;

  else

  phy_dev->supported &= PHY_BASIC_FEATURES;

@@ -1101,6 +1138,7 @@ static int fec_enet_mii_probe(struct net_device *ndev)

  fep->phy_dev->drv->name, dev_name(&fep->phy_dev->dev),

  fep->phy_dev->irq);

+ printk("WWJ============%s end ok\n", __FUNCTION__);//WWJ

  return 0;

}

@@ -1113,6 +1151,7 @@ static int fec_enet_mii_init(struct platform_device *pdev)

  platform_get_device_id(fep->pdev);

  int err = -ENXIO, i;

+ printk("WWJ=============%s start\n", __FUNCTION__);

  /*

  * The dual fec interfaces are not equivalent with enet-mac.

  * Here are the differences:

@@ -1146,7 +1185,14 @@ static int fec_enet_mii_init(struct platform_device *pdev)

  if (cpu_is_mx6q() || cpu_is_mx6dl())

  fep->phy_speed |= FEC_ENET_HOLD_TIME;

+ //WWJ add bein

+ fep->phy_speed &= ~(0x3F << 1);

+ fep->phy_speed |= (0xC << 1);

+ //WWJ add end

+

  writel(fep->phy_speed, fep->hwp + FEC_MII_SPEED);

+ printk("mdc_clk rate = %d\n", clk_get_rate(fep->mdc_clk));//WWJ

+ printk("FEC_MII_SPEED = %x\n", readl(fep->hwp + FEC_MII_SPEED)); //WWJ add

  fep->mii_bus = mdiobus_alloc();

  if (fep->mii_bus == NULL) {

@@ -1178,6 +1224,7 @@ static int fec_enet_mii_init(struct platform_device *pdev)

  if (id_entry->driver_data & FEC_QUIRK_ENET_MAC)

  fec0_mii_bus = fep->mii_bus;

+ printk("WWJ=============%s end ok\n", __FUNCTION__);

  return 0;

err_out_free_mdio_irq:

@@ -1185,6 +1232,7 @@ err_out_free_mdio_irq:

err_out_free_mdiobus:

  mdiobus_free(fep->mii_bus);

err_out:

+ printk("WWJ=========%s failed err = %d\n", __FUNCTION__, err);//WWJ

  return err;

}

@@ -1245,11 +1293,16 @@ static int fec_enet_ioctl(struct net_device *ndev, struct ifreq *rq, int cmd)

  struct phy_device *phydev = fep->phy_dev;

  int retVal = 0;

- if (!netif_running(ndev))

+ printk("WWJ=========%s start\n", __FUNCTION__);//WWJ add

+ if (!netif_running(ndev)){

+ printk("WWJ============netif_running failed ndev->state = %u\n", ndev->state);//WWJ add

  return -EINVAL;

+ }

- if (!phydev)

+ if (!phydev){

+ printk("WWJ============phydev is null\n");//WWJ add

  return -ENODEV;

+ }

  if ((cmd >= PTP_ENBL_TXTS_IOCTL) &&

  (cmd <= PTP_FLUSH_TIMESTAMP)) {

@@ -1260,6 +1313,8 @@ static int fec_enet_ioctl(struct net_device *ndev, struct ifreq *rq, int cmd)

  } else

  retVal = phy_mii_ioctl(phydev, rq, cmd);

+ printk("WWJ=========%s end retVal= %d\n", __FUNCTION__, retVal);//WWJ add

+

  return retVal;

}

@@ -1346,6 +1401,7 @@ fec_enet_open(struct net_device *ndev)

  struct fec_platform_data *pdata = fep->pdev->dev.platform_data;

  int ret;

+ printk("WWJ=========%s start\n", __FUNCTION__);//WWJ add

  if (fep->use_napi)

  napi_enable(&fep->napi);

@@ -1369,9 +1425,12 @@ fec_enet_open(struct net_device *ndev)

  fep->opened = 1;

  ret = -EINVAL;

- if (pdata->init && pdata->init(fep->phy_dev))

+ if (pdata->init && pdata->init(fep->phy_dev)){

+ printk("pdata->init = %x, pdata->init(fep->phy_dev) = %d\n", pdata->init);//WWJ add

  return ret;

+ }

+ printk("WWJ=========%s end ok\n", __FUNCTION__);//WWJ add

  return 0;

}

@@ -1419,6 +1478,7 @@ static void set_multicast_list(struct net_device *ndev)

  unsigned int i, bit, data, crc, tmp;

  unsigned char hash;

+ printk("WWJ=========%s start\n", __FUNCTION__);//WWJ add

  if (ndev->flags & IFF_PROMISC) {

  tmp = readl(fep->hwp + FEC_R_CNTRL);

  tmp |= 0x8;

@@ -1476,6 +1536,8 @@ static void set_multicast_list(struct net_device *ndev)

  writel(tmp, fep->hwp + FEC_GRP_HASH_TABLE_LOW);

  }

  }

+

+ printk("WWJ=========%s end ok\n", __FUNCTION__);//WWJ add

}

/* Set a MAC change in hardware. */

@@ -1486,7 +1548,7 @@ fec_set_mac_address(struct net_device *ndev, void *p)

  struct sockaddr *addr = p;

  int i=0;

- printk("fec_set_mac_address: ============== \n");

+ printk("WWJ=========%s start\n", __FUNCTION__);//WWJ add

  for( i=0; i<6; i++ )

  {

  printk("%d=0x%02x\n", i, addr->sa_data[i]);

@@ -1505,6 +1567,8 @@ fec_set_mac_address(struct net_device *ndev, void *p)

  fep->hwp + FEC_ADDR_LOW);

  writel((ndev->dev_addr[5] << 16) | (ndev->dev_addr[4] << 24),

  fep->hwp + FEC_ADDR_HIGH);

+

+ printk("WWJ=========%s end ok\n", __FUNCTION__);//WWJ add

  return 0;

}

@@ -1512,7 +1576,10 @@ struct net_device *mxc_fec_ndev=0;

void mxc_set_mac_address(struct sockaddr *p)

{

+ printk("WWJ=======%s start\n", __FUNCTION__);//WWJ add

  fec_set_mac_address(mxc_fec_ndev, (void*)p);

+

+ printk("WWJ=========%s end ok\n", __FUNCTION__);//WWJ add

}

static const struct net_device_ops fec_netdev_ops = {

@@ -1629,6 +1696,7 @@ fec_restart(struct net_device *dev, int duplex)

  int i, ret;

  u32 val, temp_mac[2], reg = 0;

+ printk("WWJ=========%s start\n", __FUNCTION__);//WWJ add

  /* Whack a reset.  We should wait for this. */

  writel(1, fep->hwp + FEC_ECNTRL);

  udelay(10);

@@ -1697,6 +1765,8 @@ fec_restart(struct net_device *dev, int duplex)

  if (id_entry->driver_data & FEC_QUIRK_ENET_MAC) {

  val = readl(fep->hwp + FEC_R_CNTRL);

+ printk("fep->phy_interface = %d, PHY_INTERFACE_MODE_RMII = %d, PHY_INTERFACE_MODE_RGMII = %d\n",

+ fep->phy_interface, PHY_INTERFACE_MODE_RMII, PHY_INTERFACE_MODE_RGMII);

  /* MII or RMII */

  if (fep->phy_interface == PHY_INTERFACE_MODE_RGMII)

  val |= (1 << 6);

@@ -1711,6 +1781,13 @@ fec_restart(struct net_device *dev, int duplex)

  else

  val |= (1 << 9);

+ //WWJ add begin

+ if(fep->phy_dev)

+ printk("fep->phy_dev->speed = %d\n", fep->phy_dev->speed);

+ else

+ printk("fep->phy_dev is null\n");

+ //WWJ add end

+

  /* Enable pause frame

  * ENET pause frame has two issues as ticket TKT116501

  * The issues have been fixed on Rigel TO1.1 and Arik TO1.2

@@ -1720,8 +1797,10 @@ fec_restart(struct net_device *dev, int duplex)

  (cpu_is_mx6dl() &&

  (mx6dl_revision() >= IMX_CHIP_REVISION_1_1)))

  val |= FEC_ENET_FCE;

-

+ printk("val = %x, reg = %x\n", val, FEC_R_CNTRL);

  writel(val, fep->hwp + FEC_R_CNTRL);

+

+ printk("FEC_R_CNTRL = %x\n", readl(fep->hwp + FEC_R_CNTRL));//WWJ

  }

  if (fep->ptimer_present) {

@@ -1797,7 +1876,11 @@ fec_restart(struct net_device *dev, int duplex)

  /* enable ENET store and forward mode */

  writel(0x1 << 8, fep->hwp + FEC_X_WMRK);

  }

+

+

  writel(val, fep->hwp + FEC_ECNTRL);

+ printk("val = %x\n", val);

+ printk("FEC_ECNTRL = %x\n", readl(fep->hwp + FEC_ECNTRL)); //WWJ add

  writel(0, fep->hwp + FEC_R_DES_ACTIVE);

@@ -1807,6 +1890,8 @@ fec_restart(struct net_device *dev, int duplex)

  else

  val = FEC_DEFAULT_IMASK;

  writel(val, fep->hwp + FEC_IMASK);

+

+ printk("WWJ=========%s end\n", __FUNCTION__);//WWJ add

}

static void

@@ -1814,6 +1899,7 @@ fec_stop(struct net_device *dev)

{

  struct fec_enet_private *fep = netdev_priv(dev);

+ printk("WWJ==========%s start\n", __FUNCTION__);//WWJ add

  /* We cannot expect a graceful transmit stop without link !!! */

  if (fep->link) {

  writel(1, fep->hwp + FEC_X_CNTRL); /* Graceful transmit stop */

@@ -1850,6 +1936,7 @@ fec_probe(struct platform_device *pdev)

  int i, irq, ret = 0;

  struct resource *r;

+ printk("WWJ===========%s start\n", __FUNCTION__);//WWJ add

  r = platform_get_resource(pdev, IORESOURCE_MEM, 0);

  if (!r)

  return -ENXIO;

@@ -1884,7 +1971,9 @@ fec_probe(struct platform_device *pdev)

  if (pdata)

  fep->phy_interface = pdata->phy;

+ printk("pdata->gpio_irq = %d\n", pdata->gpio_irq);//WWJ add

  if (pdata->gpio_irq > 0) {

+ printk("pdata->gpio_irq > 0\n");//WWJ add

  gpio_request(pdata->gpio_irq, "gpio_enet_irq");

  gpio_direction_input(pdata->gpio_irq);

@@ -1932,6 +2021,8 @@ fec_probe(struct platform_device *pdev)

  if (ret)

  goto failed_mii_init;

+ printk("FEC_MII_SPEED = %x\n", readl(fep->hwp + FEC_MII_SPEED)); //WWJ

+

  if (fec_ptp_malloc_priv(&(fep->ptp_priv))) {

  if (fep->ptp_priv) {

  fep->ptp_priv->hwp = fep->hwp;

@@ -1955,6 +2046,7 @@ fec_probe(struct platform_device *pdev)

  goto failed_register;

  mxc_fec_ndev = ndev;

+ printk("WWJ===========fec_probe ok\n");//WWJ add

  return 0;

@@ -1964,6 +2056,7 @@ failed_register:

  fec_ptp_cleanup(fep->ptp_priv);

  kfree(fep->ptp_priv);

failed_mii_init:

+ printk("failed_mii_init failed\n"); //WWJ

failed_init:

  clk_disable(fep->clk);

  clk_put(fep->clk);

@@ -1985,6 +2078,8 @@ failed_ioremap:

failed_alloc_etherdev:

  release_mem_region(r->start, resource_size(r));

+

+ printk("WWJ=========%s failed ret = %d\n", __FUNCTION__ ,ret);

  return ret;

}

diff --git a/drivers/net/phy/mdio_bus.c b/drivers/net/phy/mdio_bus.c

index 6c58da2..1136d2f 100644

--- a/drivers/net/phy/mdio_bus.c

+++ b/drivers/net/phy/mdio_bus.c

@@ -88,6 +88,7 @@ int mdiobus_register(struct mii_bus *bus)

{

  int i, err;

+ printk("WWJ===========%s start bus = %x, bus->name = %s, bus->read = %x, bus->write = %x\n", __FUNCTION__, bus, bus->name, bus->read, bus->write);//WWJ add

  if (NULL == bus || NULL == bus->name ||

  NULL == bus->read ||

  NULL == bus->write)

@@ -187,7 +188,7 @@ struct phy_device *mdiobus_scan(struct mii_bus *bus, int addr)

  phydev = get_phy_device(bus, addr);

  if (IS_ERR(phydev) || phydev == NULL)

  return phydev;

-

+ printk("phy_device_register phy_id = %d, speed = %d, addr = %d\n", phydev->phy_id, phydev->speed, phydev->addr);//WJ add

  err = phy_device_register(phydev);

  if (err) {

  phy_device_free(phydev);

diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c

index a475957..1d0c96b 100644

--- a/drivers/net/phy/phy.c

+++ b/drivers/net/phy/phy.c

@@ -317,15 +317,18 @@ int phy_mii_ioctl(struct phy_device *phydev,

  switch (cmd) {

  case SIOCGMIIPHY:

+ printk("WWJ============SIOCGMIIPHY cmd\n");

  mii_data->phy_id = phydev->addr;

  /* fall through */

  case SIOCGMIIREG:

+ printk("WWJ============SIOCGMIIREG cmd\n");

  mii_data->val_out = mdiobus_read(phydev->bus, mii_data->phy_id,

  mii_data->reg_num);

  break;

  case SIOCSMIIREG:

+ printk("WWJ============SIOCSMIIREG cmd\n");

  if (mii_data->phy_id == phydev->addr) {

  switch(mii_data->reg_num) {

  case MII_BMCR:

@@ -365,6 +368,7 @@ int phy_mii_ioctl(struct phy_device *phydev,

  break;

  case SIOCSHWTSTAMP:

+ printk("WWJ============SIOCSHWTSTAMP cmd\n");

  if (phydev->drv->hwtstamp)

  return phydev->drv->hwtstamp(phydev, ifr);

  /* fall through */

@@ -390,6 +394,7 @@ int phy_start_aneg(struct phy_device *phydev)

{

  int err;

+ printk("WWJ=========%s start\n", __FUNCTION__);//WWJ add

  mutex_lock(&phydev->lock);

  if (AUTONEG_DISABLE == phydev->autoneg)

@@ -400,6 +405,7 @@ int phy_start_aneg(struct phy_device *phydev)

  if (err < 0)

  goto out_unlock;

+ printk("WWJ=========phydev->state = %d, PHY_HALTED = %d\n", phydev->state, PHY_HALTED);//WWJ add

  if (phydev->state != PHY_HALTED) {

  if (AUTONEG_ENABLE == phydev->autoneg) {

  phydev->state = PHY_AN;

@@ -410,9 +416,12 @@ int phy_start_aneg(struct phy_device *phydev)

  }

  }

+ printk("WWJ=========%s end\n", __FUNCTION__);//WWJ add

out_unlock:

  mutex_unlock(&phydev->lock);

  return err;

+

+ printk("WWJ=========%s end wront err = %d\n", __FUNCTION__, err);//WWJ add

}

EXPORT_SYMBOL(phy_start_aneg);

@@ -435,6 +444,7 @@ static void phy_change(struct work_struct *work);

void phy_start_machine(struct phy_device *phydev,

  void (*handler)(struct net_device *))

{

+ printk("WWJ=========%s start\n", __FUNCTION__);//WWJ add

  phydev->adjust_state = handler;

  schedule_delayed_work(&phydev->state_queue, HZ);

@@ -593,6 +603,7 @@ int phy_start_interrupts(struct phy_device *phydev)

  INIT_WORK(&phydev->phy_queue, phy_change);

+ printk("WWJ=========%s start\n", __FUNCTION__);//WWJ add

  atomic_set(&phydev->irq_disable, 0);

  if (request_irq(phydev->irq, phy_interrupt,

  IRQF_SHARED,

@@ -601,6 +612,7 @@ int phy_start_interrupts(struct phy_device *phydev)

  printk(KERN_WARNING "%s: Can't get IRQ %d (PHY)\n",

  phydev->bus->name,

  phydev->irq);

+ printk("WWJ========set phydev->irq to PHY_POLL in %d\n", __LINE__); //WWJ add

  phydev->irq = PHY_POLL;

  return 0;

  }

@@ -744,6 +756,7 @@ void phy_start(struct phy_device *phydev)

{

  mutex_lock(&phydev->lock);

+ printk("WWJ==========%s start phydev->state = %d\n", __FUNCTION__, phydev->state);//WWJ add

  switch (phydev->state) {

  case PHY_STARTING:

  phydev->state = PHY_PENDING;

@@ -757,6 +770,8 @@ void phy_start(struct phy_device *phydev)

  break;

  }

  mutex_unlock(&phydev->lock);

+

+ printk("WWJ==========%s end ok\n", __FUNCTION__);//WWJ add

}

EXPORT_SYMBOL(phy_stop);

EXPORT_SYMBOL(phy_start);

@@ -778,6 +793,7 @@ void phy_state_machine(struct work_struct *work)

  if (phydev->adjust_state)

  phydev->adjust_state(phydev->attached_dev);

+ printk("phydev->state = %d\n", phydev->state); //WWJ add

  switch(phydev->state) {

  case PHY_DOWN:

  case PHY_STARTING:

@@ -791,11 +807,13 @@ void phy_state_machine(struct work_struct *work)

  break;

  case PHY_AN:

+ printk("PHY_AN(%d) state start\n", PHY_AN);

  err = phy_read_status(phydev);

  if (err < 0)

  break;

+ printk("phydev->link = %d\n", phydev->link);

  /* If the link is down, give up on

  * negotiation for now */

  if (!phydev->link) {

@@ -843,6 +861,7 @@ void phy_state_machine(struct work_struct *work)

  phydev->duplex ?

  "FULL" : "HALF");

  }

+ printk("PHY_AN(%d) state end\n", PHY_AN);

  break;

  case PHY_NOLINK:

  err = phy_read_status(phydev);

diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c

index ff109fe..98a1165 100644

--- a/drivers/net/phy/phy_device.c

+++ b/drivers/net/phy/phy_device.c

@@ -247,6 +247,7 @@ struct phy_device * get_phy_device(struct mii_bus *bus, int addr)

  int r;

  r = get_phy_id(bus, addr, &phy_id);

+ printk("WWJ=======%s, phy_id = %x, r = %d\n", __FUNCTION__, phy_id, r);

  if (r)

  return ERR_PTR(r);

@@ -274,6 +275,9 @@ int phy_device_register(struct phy_device *phydev)

  return -EINVAL;

  phydev->bus->phy_map[phydev->addr] = phydev;

+ printk("phy_device_register phy_id = %x, speed = %d, addr = %x\n",

+ phydev->phy_id, phydev->speed, phydev->addr);//WJ add

+

  /* Run all of the fixups for this PHY */

  phy_scan_fixups(phydev);

@@ -322,6 +326,7 @@ EXPORT_SYMBOL(phy_find_first);

static void phy_prepare_link(struct phy_device *phydev,

  void (*handler)(struct net_device *))

{

+ printk("WWJ=======%s start handler = %x\n", __FUNCTION__, handler); //WWJ add

  phydev->adjust_link = handler;

}

@@ -339,6 +344,7 @@ int phy_connect_direct(struct net_device *dev, struct phy_device *phydev,

{

  int rc;

+ printk("WWJ=======%s start\n", __FUNCTION__);//WWJ add

  rc = phy_attach_direct(dev, phydev, flags, interface);

  if (rc)

  return rc;

@@ -348,6 +354,7 @@ int phy_connect_direct(struct net_device *dev, struct phy_device *phydev,

  if (phydev->irq > 0)

  phy_start_interrupts(phydev);

+ printk("WWJ=======%s end ok\n", __FUNCTION__);//WWJ add

  return 0;

}

EXPORT_SYMBOL(phy_connect_direct);

@@ -376,6 +383,7 @@ struct phy_device * phy_connect(struct net_device *dev, const char *bus_id,

  struct device *d;

  int rc;

+ printk("WWJ==========%s start \n", __FUNCTION__);//WWJ add

  /* Search the list of PHY devices on the mdio bus for the

  * PHY with the requested name */

  d = bus_find_device_by_name(&mdio_bus_type, NULL, bus_id);

@@ -389,6 +397,7 @@ struct phy_device * phy_connect(struct net_device *dev, const char *bus_id,

  if (rc)

  return ERR_PTR(rc);

+ printk("WWJ==========%s end ok \n", __FUNCTION__);//WWJ add

  return phydev;

}

EXPORT_SYMBOL(phy_connect);

@@ -677,7 +686,10 @@ EXPORT_SYMBOL(genphy_restart_aneg);

int genphy_config_aneg(struct phy_device *phydev)

{

  int result;

+ int i; //WWJ add

+ u32 val; //WWJ add

+ printk("WWJ===========%s start\n", __FUNCTION__);//WWJ add

  if (AUTONEG_ENABLE != phydev->autoneg)

  return genphy_setup_forced(phydev);

@@ -703,6 +715,14 @@ int genphy_config_aneg(struct phy_device *phydev)

  if (result > 0)

  result = genphy_restart_aneg(phydev);

+ //WWJ begin

+ for(i = 0; i < 32; i++){

+ val = phy_read(phydev, i);

+ printk("reg[%d] = %x\n", i, val);

+ }

+ //WWJ end

+

+ printk("WWJ===========%s end result=%d \n", __FUNCTION__, result);//WWJ add

  return result;

}

EXPORT_SYMBOL(genphy_config_aneg);

@@ -758,11 +778,16 @@ int genphy_read_status(struct phy_device *phydev)

  /* Update the link, but return if there

  * was an error */

+

+ printk("WWJ============%s line %d start\n", __FUNCTION__, __LINE__);//WWJ add

  err = genphy_update_link(phydev);

  if (err)

  return err;

+ printk("WWJ======phydev->phy_id = %x\n", phydev->phy_id);//WWJ

  if (AUTONEG_ENABLE == phydev->autoneg) {

+ printk("phydev->supported = %x, SUPPORTED_1000baseT_Half = %x, SUPPORTED_1000baseT_Full= %x\n",

+ phydev->supported, SUPPORTED_1000baseT_Half, SUPPORTED_1000baseT_Full);

  if (phydev->supported & (SUPPORTED_1000baseT_Half

  | SUPPORTED_1000baseT_Full)) {

  lpagb = phy_read(phydev, MII_STAT1000);

@@ -794,6 +819,10 @@ int genphy_read_status(struct phy_device *phydev)

  phydev->duplex = DUPLEX_HALF;

  phydev->pause = phydev->asym_pause = 0;

+ printk("lpagb = %x, LPA_1000FULL = %x, LPA_1000HALF = %x\n", lpagb, LPA_1000FULL,

+ LPA_1000HALF);

+

+ printk("lpa = %x, LPA_1000FULL = %x, LPA_1000HALF = %x\n", lpa, LPA_1000FULL, LPA_1000HALF);

  if (lpagb & (LPA_1000FULL | LPA_1000HALF)) {

  phydev->speed = SPEED_1000;

@@ -808,6 +837,7 @@ int genphy_read_status(struct phy_device *phydev)

  if (lpa & LPA_10FULL)

  phydev->duplex = DUPLEX_FULL;

+ printk("phydev->duplex = %x\n", phydev->duplex);//WWJ

  if (phydev->duplex == DUPLEX_FULL){

  phydev->pause = lpa & LPA_PAUSE_CAP ? 1 : 0;

  phydev->asym_pause = lpa & LPA_PAUSE_ASYM ? 1 : 0;

@@ -832,6 +862,7 @@ int genphy_read_status(struct phy_device *phydev)

  phydev->pause = phydev->asym_pause = 0;

  }

+ printk("WWJ============%s end ok\n", __FUNCTION__);//WWJ add

  return 0;

}

EXPORT_SYMBOL(genphy_read_status);

@@ -841,6 +872,7 @@ static int genphy_config_init(struct phy_device *phydev)

  int val;

  u32 features;

+ printk("WWJ==========%s start\n", __FUNCTION__); //WWJ add

  /* For now, I'll claim that the generic driver supports

  * all possible port types */

  features = (SUPPORTED_TP | SUPPORTED_MII

@@ -849,6 +881,7 @@ static int genphy_config_init(struct phy_device *phydev)

  /* Do we support autonegotiation? */

  val = phy_read(phydev, MII_BMSR);

+ printk("phydev->phy_id = %x\n", phydev->phy_id);//WWJ add

  if (val < 0)

  return val;

@@ -880,6 +913,7 @@ static int genphy_config_init(struct phy_device *phydev)

  phydev->supported = features;

  phydev->advertising = features;

+ printk("WWJ==========%s end\n", __FUNCTION__); //WWJ add

  return 0;

}

int genphy_suspend(struct phy_device *phydev)

@@ -927,6 +961,7 @@ static int phy_probe(struct device *dev)

  struct device_driver *drv;

  int err = 0;

+ printk("WWJ========%s start\n", __FUNCTION__ );//WWJ add

  phydev = to_phy_device(dev);

  /* Make sure the driver is held.

@@ -934,10 +969,13 @@ static int phy_probe(struct device *dev)

  drv = get_driver(phydev->dev.driver);

  phydrv = to_phy_driver(drv);

  phydev->drv = phydrv;

+ printk("WWJ=========driver name = %s\n", phydrv->name);

  /* Disable the interrupt if the PHY doesn't support it */

- if (!(phydrv->flags & PHY_HAS_INTERRUPT))

+ if (!(phydrv->flags & PHY_HAS_INTERRUPT)){

+ printk("WWJ========set phydev->irq to PHY_POLL in %d\n", __LINE__);//WWJ add

  phydev->irq = PHY_POLL;

+ }

  mutex_lock(&phydev->lock);

diff --git a/drivers/net/phy/smsc.c b/drivers/net/phy/smsc.c

index 342505c..02d4a3b 100644

--- a/drivers/net/phy/smsc.c

+++ b/drivers/net/phy/smsc.c

@@ -45,23 +45,28 @@

static int smsc_phy_config_intr(struct phy_device *phydev)

{

+ printk("WWJ============%s start\n", __FUNCTION__);//WWJ add

  int rc = phy_write (phydev, MII_LAN83C185_IM,

  ((PHY_INTERRUPT_ENABLED == phydev->interrupts)

  ? MII_LAN83C185_ISF_INT_PHYLIB_EVENTS

  : 0));

+ printk("WWJ============%s start rc = %d\n", __FUNCTION__, rc);//WWJ add

  return rc < 0 ? rc : 0;

}

static int smsc_phy_ack_interrupt(struct phy_device *phydev)

{

+ printk("WWJ============%s start\n", __FUNCTION__);//WWJ add

  int rc = phy_read (phydev, MII_LAN83C185_ISF);

+ printk("WWJ============%s end rc = %x\n", __FUNCTION__, rc);//WWJ add

  return rc < 0 ? rc : 0;

}

static int smsc_phy_config_init(struct phy_device *phydev)

{

+ printk("WWJ============%s start\n", __FUNCTION__);//WWJ add

  int rc = phy_read(phydev, MII_LAN83C185_CTRL_STATUS);

  if (rc < 0)

  return rc;

@@ -69,9 +74,11 @@ static int smsc_phy_config_init(struct phy_device *phydev)

  /* Enable energy detect mode for this SMSC Transceivers */

  rc = phy_write(phydev, MII_LAN83C185_CTRL_STATUS,

        rc | MII_LAN83C185_EDPWRDOWN);

+ printk("%s phydev->phy_id = %x rc = %d", __FUNCTION__, phydev->phy_id, rc);

  if (rc < 0)

  return rc;

+ printk("WWJ============%s end\n", __FUNCTION__);//WWJ add

  return smsc_phy_ack_interrupt (phydev);

}

@@ -204,6 +211,7 @@ static int __init smsc_init(void)

{

  int ret;

+ printk("WWJ=========%s start\n", __FUNCTION__);//WWJ add

  ret = phy_driver_register (&lan83c185_driver);

  if (ret)

  goto err1;

@@ -221,9 +229,10 @@ static int __init smsc_init(void)

  goto err4;

  ret = phy_driver_register (&lan8710_driver);

+ printk("&lan8710_driver register ret = %d\n", ret);

  if (ret)

  goto err5;

-

+ printk("WWJ=========%s end ok\n", __FUNCTION__);//WWJ add

  return 0;

err5:

@@ -235,6 +244,7 @@ err3:

err2:

  phy_driver_unregister (&lan83c185_driver);

err1:

+ printk("failed phy_driver_register ret = %d\n", ret);

  return ret;

}

diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h

index 056c45b..c8b511e 100644

--- a/include/linux/netdevice.h

+++ b/include/linux/netdevice.h

@@ -1804,6 +1804,7 @@ static inline void netif_tx_start_queue(struct netdev_queue *dev_queue)

  */

static inline void netif_start_queue(struct net_device *dev)

{

+ printk("WWJ============%s start\n", __FUNCTION__);//WWJ add

  netif_tx_start_queue(netdev_get_tx_queue(dev, 0));

}

@@ -1911,6 +1912,7 @@ static inline int netif_tx_queue_frozen_or_stopped(const struct netdev_queue *de

  */

static inline int netif_running(const struct net_device *dev)

{

+ printk("WWJ==========%s start dev->state = %lu\n", __FUNCTION__, dev->state); //WWJ

  return test_bit(__LINK_STATE_START, &dev->state);

}

diff --git a/net/core/dev.c b/net/core/dev.c

index a71eafc..e0be16b 100644

--- a/net/core/dev.c

+++ b/net/core/dev.c

@@ -1184,6 +1184,7 @@ int dev_open(struct net_device *dev)

{

  int ret;

+ printk("WWJ================%s start, dev->flags = %x\n", __FUNCTION__, dev->flags);//WWJ add

  if (dev->flags & IFF_UP)

  return 0;

diff --git a/net/core/link_watch.c b/net/core/link_watch.c

index 357bd4e..eea05b9 100644

--- a/net/core/link_watch.c

+++ b/net/core/link_watch.c

@@ -234,13 +234,18 @@ static void linkwatch_event(struct work_struct *dummy)

void linkwatch_fire_event(struct net_device *dev)

{

+ printk("WWJ=============%s start\n", __FUNCTION__);

  bool urgent = linkwatch_urgent_event(dev);

+ printk("urgent = %d\n", urgent);

+ printk("WWJ=======dev->state = %x, __LINK_STATE_LINKWATCH_PENDING = %x\n", dev->state,  __LINK_STATE_LINKWATCH_PENDING);

  if (!test_and_set_bit(__LINK_STATE_LINKWATCH_PENDING, &dev->state)) {

+ printk("test_and_set_bit ok\n", __FUNCTION__);

  linkwatch_add_event(dev);

  } else if (!urgent)

  return;

  linkwatch_schedule_work(urgent);

+ printk("WWJ=============%s end\n", __FUNCTION__);

}

EXPORT_SYMBOL(linkwatch_fire_event);

diff --git a/net/sched/sch_generic.c b/net/sched/sch_generic.c

index b4c6809..abc5d37 100644

--- a/net/sched/sch_generic.c

+++ b/net/sched/sch_generic.c

@@ -298,12 +298,17 @@ static void dev_watchdog_down(struct net_device *dev)

  */

void netif_carrier_on(struct net_device *dev)

{

+ printk("WWJ========%s start, __LINK_STATE_NOCARRIER = %x, dev->state = %x\n", __FUNCTION__, __LINK_STATE_NOCARRIER, dev->state);//WWJ

+ printk("dev->reg_state = %x\n", dev->reg_state);

  if (test_and_clear_bit(__LINK_STATE_NOCARRIER, &dev->state)) {

+ printk("NETREG_UNINITIALIZED = %x\n", NETREG_UNINITIALIZED);

  if (dev->reg_state == NETREG_UNINITIALIZED)

  return;

  linkwatch_fire_event(dev);

- if (netif_running(dev))

+ if (netif_running(dev)){

+ printk("netif_running ok\n");

  __netdev_watchdog_up(dev);

+ }

  }

}

EXPORT_SYMBOL(netif_carrier_on);

@@ -316,6 +321,7 @@ EXPORT_SYMBOL(netif_carrier_on);

  */

void netif_carrier_off(struct net_device *dev)

{

+ printk("WWJ============%s start\n", __FUNCTION__);

  if (!test_and_set_bit(__LINK_STATE_NOCARRIER, &dev->state)) {

  if (dev->reg_state == NETREG_UNINITIALIZED)

  return;

0 Kudos
2,083 Views
deepajosephine
Contributor II

Hi,

Our issue is fixed. It seemed to be due to the 50MHz ref clock not being looped to MAC. It required change in device tree.

Thanks,
Deepa

2,083 Views
承王
Contributor I

hello,can you describle the solution detailly?

0 Kudos
2,084 Views
wenjingwang
Contributor II

my issue is the MDC clock too hight and the pin_iomux was configued wrong by me, so the issue is fixed. Thank you!

0 Kudos