Implementation of the SMI interface of the network port Chip

Source: Internet
Author: User

Recently, p178g is used, and internal registers need to be controlled to implement the switch and VLAN configuration of each Phy. In order to replace the "pseudo" Switch implemented by the original analog switch, you can use the SMI interface to read and write registers through ds to control the IC operation status.

Time Series and format



The prefix code of this chip is different from the 32-bit high level of many other chips. It can also be implemented by 32-bit. The common SMI bit fields are described as follows:

Pre:The frame prefix domain is 32 "1" bits. This frame prefix domain is not required. Some Physical layer chips do not have this domain for mdio operation.

OP:Frame control code. Bits "10" indicates that this frame is a read control frame, and bits "01" indicates that this frame is a write control frame.

Phyad:Physical Layer Chip address, 5 bits;

Regad:Used to select the address of one of the 32 physical layer chips;

Ta:Status conversion domain. For read operations, mdio is in high-impedance mode during the first session, and the physical layer chip sets mdio to "0" during the second session ". For write operations, mdio is still controlled by the Mac chip and outputs "10" bits.

Data:The data domain of the frame storage device, which is 16 bits. For read operations, the data sent from the physical layer to the MAC layer. For write operations, the data sent from the MAC layer to the physical layer.

Idle:After the frame is stopped, the mdio passive drive, high resistance, but generally use the pull resistance to make it at a high level, that is, the mdio pin needs to pull the resistance.


Sample Code:

void SMI_Write(unsigned char phy_add, unsigned char reg_add, unsigned int data){unsigned int i;ISR_DIS();      //interrupt disabled   for (i = 0; i<32; i++)//send preamble,32 1   {SMI_1();}{//01            //send start   SMI_0();SMI_1();}{//01            //send op code,write   SMI_0();SMI_1();}for (i = 0; i<5; i++)//send phy address   {if (phy_add & 0x10)SMI_1();//1   elseSMI_0();//0   phy_add <<= 1;}for (i = 0; i<5; i++)//send reg address   {if (reg_add & 0x10)SMI_1();//1   elseSMI_0();//0   reg_add <<= 1;}{//10           //send turn around   SMI_1();//1    SMI_0();//0   }for (i = 0; i<16; i++)//send data   {if (data & 0x8000)SMI_1();//1   elseSMI_0();//0   data <<= 1;}<pre name="code" class="cpp">      ISR_EN()<span style="font-family: Arial, Helvetica, sans-serif;">;     //interrupt enabled   </span>
}

 



Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.