Martin Latal

Re: support for taking  dump of MII register and Eth_phy register dump

Discussion created by Martin Latal Employee on Apr 4, 2013
Latest reply on Apr 5, 2013 by vallinath s
Branched from an earlier discussion

Hi vallinath,

 

for PHY registers, I used ipcfg_phy_registers():

 

uint_32 phy_reg[2];
   ENET_get_mac_address (ENET_DEVICE, ENET_IPADDR, enet_address);
   error = ipcfg_init_device (ENET_DEVICE, enet_address);
   if (error != RTCS_OK) 
   {
      printf("\nFailed to initialize ethernet device, error = %X", error);
      _task_block();
   }
           
   error = ipcfg_phy_registers(ENET_DEVICE, 32, phy_reg);
   if(TRUE == error)
   {
     printf("\nPHY reg 0x1e: 0x%08x", phy_reg[0]);
     printf("\nPHY reg 0x1f: 0x%08x", phy_reg[1]);
     printf("\nLink bits: 0x%x", (phy_reg[1]&0x1C)>>2);
   }
   else
   {
     printf("\nPhy registers failed.");
   }
   printf("\nWaiting for ethernet cable plug in ... ");
   while(!ipcfg_get_link_active(ENET_DEVICE)) {};
   printf("Cable connected\n");

 

It makes call to ENET_phy_registers() in enutil.c, by default it prints 32 PHY registers. For my purposes I need only registers 0x1e and 0x1f, so I modified also this function as below:

 

boolean ENET_phy_registers
   (
      _enet_handle handle,
      uint_32      num_regs,
      uint_32_ptr  regs_ptr
   )
{
   ENET_CONTEXT_STRUCT_PTR enet_ptr = (ENET_CONTEXT_STRUCT_PTR)handle;
   uint_32  i;
   boolean  all_read=TRUE;
   for (i=30;i<num_regs;i++) { /* orig i=0. (i=30 for 0x1e and 0x1f regs only) */
      *regs_ptr=0;
      if (!(*enet_ptr->PARAM_PTR->ENET_IF->MAC_IF->PHY_READ)(enet_ptr, i, regs_ptr, 0x1000))
      {
         all_read=FALSE;
      }
      regs_ptr++;
   }
   return all_read;
}

 

Note the phy_reg[] has only two 32-bit uints as I read two PHY registers. In case you read all 32 registers you would change to uint_32 phy_reg[32].

Outcomes