AnsweredAssumed Answered

Using RMII(LAN8720A) on iMx6Q

Question asked by Sober Peng on Sep 15, 2015
Latest reply on Jul 19, 2016 by 承 王

Hello,

We use LAN8720A as RMII phy on i.Mx6q, now we can set its IP but don't transfer data.

RMII_REF_CLK_50M is connected to GPIO_16.

 

board-mx6q_sabresd.h

  MX6Q_PAD_ENET_MDIO__ENET_MDIO,

  MX6Q_PAD_ENET_MDC__ENET_MDC,

  MX6Q_PAD_ENET_RXD0__ENET_RDATA_0,

  MX6Q_PAD_ENET_RXD1__ENET_RDATA_1,

  MX6Q_PAD_ENET_CRS_DV__ENET_RX_EN,

  MX6Q_PAD_ENET_RX_ER__ENET_RX_ER,

  MX6Q_PAD_ENET_TXD0__ENET_TDATA_0,

  MX6Q_PAD_ENET_TXD1__ENET_TDATA_1,

  MX6Q_PAD_ENET_TX_EN__ENET_TX_EN,

  MX6Q_PAD_GPIO_16__ENET_ANATOP_ETHERNET_REF_OUT,/* Internal connect for 1588 TS Clock  50M clock*/

  MX6Q_PAD_RGMII_TD3__GPIO_6_23,         /* RMII reset */

  //MX6Q_PAD_GPIO_5__GPIO_1_5,   /* PHY interrupt */

 

board-mx6q_sabresd.c

  mxc_iomux_set_gpr_register(1, 21, 1, 1);

 

static int mx6q_sabresd_fec_phy_init(struct phy_device *phydev)

{

  unsigned short val;

  /* reset phy */

  gpio_request(SABRESD_RMII_RST, "phy-rst");

  gpio_direction_output(SABRESD_RMII_RST, 0);

  mdelay(10);

  gpio_direction_output(SABRESD_RMII_RST, 1);

 

  val = phy_read(phydev, 0x0);

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

  msleep(500);

 

  /* check phy power */

  val = phy_read(phydev, 0x0);

  if (val & BMCR_PDOWN)

  {

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

  }

  return 0;

}

 

static struct fec_platform_data fec_data __initdata = {

  .init = mx6q_sabresd_fec_phy_init,

  .phy = PHY_INTERFACE_MODE_RMII,

#ifdef CONFIG_MX6_ENET_IRQ_TO_GPIO

  .gpio_irq = MX6_ENET_IRQ,

#endif

};

Outcomes