linux内核phy1,为AM335x移植Linux内核主线代码(13)使用MDIO查看PHY芯片AR8031

使用phy_id=4来查询PHY所有的32个寄存器,在MDIOUSERACCESS0中能够获得如下数据:

20043100 20247949 2044004d 2064d074 20841de1 20a40000 20c40004 20e42801

21040000 21240200 21440000 21640000 21840000 21a40000 21c40000 21e4a000

22040862 22240010 22440000 22640000 2284082c 22a40000 22c404e8 22e40000

23043200 23243000 23440000 23640600 23840000 23a40000 23c482ee 23e48100

从这32个值可以看出,它们的PHY地址均为0x04,REG地址从0递增到0x1f。

接下来依次分析:

=========> Offset: 0x00 Value: 0x3100 <=========

Control Register - Copper Page

RESET = 0,不在复位状态,Normal operation;写1将使芯片软件复位;

LOOPBACK = 0,不使用Loopback;

SPEED SELECTION = 1,它和bit6(此处为0)组成speed选择,所以是100Mbps;

AUTO_NEGOTIATION = 1,采用Auto-Negotiation Process;

POWER_DOWN = 0,不在Power down状态,Normal operation;

ISOLATE = 0,不使用Isolate,Normal operation;

RESTART_AUTO_NEGOTIATION = 0,不使用Restart Auto-Negotiation Process;

DUPLEX_MODE = 1,使用FULL Duplex;

COLLISION_TEST = 0,禁用COL signal test;

SPEED_SELECTION = 0,它和bit13(此处为1)组成speed选择,所以是100Mbps;

RES = 00000,总是为00000;

=========> Offset: 0x01 Value: 0x7949 <=========

Status Register - Copper Page

100BASE-T4 = 0,不具备100BASE-T4功能;

100BASE-X Full-Duplex = 1,具备100-Tx Full Duplex功能;

100BASE-X Half-Duplex = 1,具备100-Tx Half Duplex功能;

10Mbps Full-Duplex = 1,具备10Base-T full duplex功能;

10Mbps Half-Duplex = 1,具备10Base-T half duplex功能;

100BASE-T2 Full-Duplex = 0,不具备100BASE-T2功能;

100BASE-T2 Half-Duplex = 0,不具备100BASE-T2功能;

Extended Status = 1,Extended status information in register15(总为0?);

Reserved = 0;

MF Preamble Suppression = 1,使用management frames with preamble suppressed;

Auto-Negotiation Complete = 0,未完成自动谈判;

Remote Fault = 0,未检测到fault condition;

Auto-Negotiation Ability = 1,具备auto negotiation功能;

Link Status = 0,没有建立Link;

Jabber Detect = 0,未检测到Jabber condition;

Extended Capbility = 1,Extended register capabilities;

=========> Offset: 0x02 Value: 0x004d  <=========

PHY Identifier

Organizationally Unique Identifier Bit 3:18. Always 16'h004d;

=========> Offset: 0x03 Value: 0xd074  <=========

PHY Identifier2

Organizationally Unique Identifier Bit 3:18. Always 16'hd0xx;

=========> Offset: 0x04 Value: 0x1de1  <=========

Auto-Negotiation Advertisement Register - Copper Page

Next Page = 0. Not advertised.

Ack = 0. Must be 0.

Remote Fault = 0. Do not set Remote Fault bit.

xnp_able = 1. Local device supports transmission of extended next pages.

Asymmetric Pause = 1. Asymmetric Pause;

PAUSE = 1. MAC PAUSE implemented.

100BASE-T4 = 0. Not able to perform 100BASE-T4.

100BASE-TX Full Duplex = 1. Advertised.

100BASE-TX Half Duplex = 1. Advertised.

10BASE-TX Full Duplex = 1. Advertised.

10BASE-TX Half Duplex = 1. Advertised.

Selector field = 00001. 802.3. Always 00001.

=========> Offset: 0x05 Value: 0x0000  <=========

Link Partner Ability Register - Copper Page

Next Page = 0. Link partner not capable of next page.

Ack = 0. Link parter does not have Next Page ability.

Remote Fault = 0. Link partner has not detected remote fault.

Reserved = 0.

Asymmetric Pause = 0. Link partner does not request asymmetirc pause.

PAUSE = 0. Link partner is not capable of pause operation.

100BASE-T4 = 0. Link partner is not 100BASE-T4 capable.

100BASE-TX Full Duplex = 0. Link partner is not 100BASE-TX full-duplex capable.

100BASE-TX Half Duplex = 0. Link partner is not 100BASE-TX half-duplex capable.

10BASE-TX Full Duplex = 0. Link partner is not 10BASE-T full-duplex capable.

10BASE-TX Half Duplex = 0. Link partner is not 10BASE-T half-duplex capable.

Selector Field = 00000. Received Code Word Bit 4:0.

=========> Offset: 0x06 Value: 0004  <=========

Auto-Negotiation Expansion Register - Copper Page

Reserved = 00000000000B. Must be 00000000000B.

Paraller Detection fault = 0. No fault has been detected.

Link partner next page able = 0. Link partner is not next page able.

Local Next Page able = 1. Local Device is Next Page able.

Page received = 0. No new page has been received.

Link Partner Auto-negotiation able = 0. Link partner is not auto negotiation able.

=========> Offset: 0x07 Value: 0x2801  <=========

Next Page Transmit Register - Copper Page

Next Page = 0.

Reserved = 0.

Message page mode = 1.

Ack2 = 0.

Toggle = 1.

Message/Unformatted Field = 00000000001B.

=========> Offset: 0x08 Value: 0x0000  <=========

Link Partner Next Page Register - Copper Page

Next Page = 0.

Reserved = 0.

Message page mode = 0.

Ack2 = 0.

Toggle = 0.

Message/Unformatted Field = 00000000000B.

=========> Offset: 0x09 Value: 0x0200  <=========

1000Base-T Control Register

Test mode = 000B. Normal Mode.

Master/Slave Manual configuration Enable = 0. Automatic configuration.

Master/Slave configuration = 0. Manual configure as SLAVE.

Port Type = 0. Prefer single port device.

1000BASE-T Full Duplex = 1. Advertise.

1000BASE-T Half-Duplex = 0. Not advertised.

Reserved = 00000000B.

=========> Offset: 0x0A Value: 0x0000  <=========

1000Base-T Status Register

Master/Slave Configuration Fault = 0. No fault detected.

Master/Slave Configuration Resolution = 0. Local PHY configuration resolved to Slave.

Local Receiver Status = 0. Local Receiver Not OK.

Remote Receive Status = 0. Remote Receiver not OK.

Link Partner 1000Base-T Full Duplex Capability = 0. Not capable.

Link Partner 1000Bsse-T Half Duplex Capability = 0. Not capable.

Reserved = 00B.

Idle Error Count = 00000000B. MSB of Idle Error Counter. Not roll over.

=========> Offset: 0x0D Value: 0x0000  <=========

MMD Access Control Register

Function = 00B. address.

Reservid = 000000000B.

DEVAD = 00000B. Device address.

=========> Offset: 0x0E Value: 0x0000  <=========

MMD Access Address Data Register

Address data = 00B.

=========> Offset: 0x0F Value: 0xa000  <=========

Extended status Register

1000BASE-X Full Duplex = 1. PHY not able to perform 1000BASE-X Full Duplex.

1000BASE-X Half Duplex = 0. PHY not able to perform 1000BASE-X Half Duplex.

1000BAST-T Full Duplex = 1. PHY able to perform 1000BASE-T Full Duplex.

1000BASE-T Half-Duplex = 0. PHY not able to perform 1000BASE-T Half Duplex.

Reserved = 000000000000B.

=========> Offset: 0x10 Value: 0x0862  <=========

Function control Register

Reserved = 0000B.

Assert CRS on Transmit = 1. assert on Transmitting or receiving.

Force_link = 0. Normal mode.

Reserved = 000B.

MDI Crossover Mode = 11B. Enable automatic crossover for all modes.

Reserved = 00B.

SQE Test = 0. SQE test disabled.

Polarity Reversal = 1. Polarity Reversal Disbled.

Disable Jabber = 0. Enable jabber function.

=========> Offset: 0x11 Value: 0x0010  <=========

PHY-Specific Status Regiter - Copper Page

Speed = 00B. 10Mbps.

Duplex = 0. Half-duplex.

Page Received (real-time) = 0. Page not received.

Speed and Duplex Resolved = 0. Not resolved.

Link = 0.  Link down.

Reserved = 000B.

MDI Crossover Status = 0. MDI.

Wirespeed downgrade = 0.

Reserved = 1.

Transmit Pause Enable = 0. Transmit pause disabled.

Receive Pause Enable = 0. Receive pause disabled.

Polarity (real time) = 0. Normal.

Jabber (real time) = 0. No jabber.

=========> Offset: 0x12 Value: 0x0000  <=========

Interrupt Enable Register

Auto-Negotiation Error = 0.

Speed Changed = 0.

Reserved = 0.

Page Received = 0.

Link Fail Interrupt = 0.

Link Success Interrupt = 0.

Reserved = 0.

Link_fail_bx = 0.

Link_success_bx = 0.

MDI Crossover Changed = 0.

Wirespeed-downgrade Interrupt = 0.

int_10ms_ptx = 0.

Int_rx_ptp = 0.

Int_tx_ptp = 0.

Polarity Changed = 0.

int_wol_ptp = 0.

=========> Offset: 0x13 Value: 0x0000  <=========

Interrupt Status Register

Auto-Negotiation = 0.

Speed Changed = 0.

Reserved = 0.

Page Received = 0.

Link Fail Interrupt = 0.

Link Success Interrupt = 0.

Reserved = 0.

Link_fail_bx = 0.

Link_success_bx = 0.

MDI Crossover Changed = 0.

Wirespeed downgrade Interrupt = 0.

int_10ms_ptx = 0.

Int_rx_ptp = 0.

Int_tx_ptp = 0.

Polarity Changed= 0.

int_wol_ptp = 0.

=========> Offset: 0x14 Value: 0x082c  <=========

Smart Speed Register

Reserved = 00001B.

aneg_now_qual = 0.

Rev_aneg_qual = 0.

Giga_dis_qual = 0.

Cfg_pad_en = 0.

Mr_Itdis = 0.

Smartspeed_en = 1.

Smartspeed_retry_limit = 011B. Which is 011 by default.

Bypass_smartspeed_timer = 0.

reserved = 0.

=========> Offset: 0x16 Value: 0x04e8  <=========

Virtual Cable Tester Control Register

Reserved = 000001B. (* Which should be 00000B.)

MDI Pair Select = 00B. MDI[0] pair.

Reserved = 1110100B. (* Which should be 0000000B.)

Enable Test = 0. Disable VCT Test.

=========> Offset: 0x18 Value: 0x3200  <=========

LED Control

Disable LED = 0. Enable.

Led on time = 011B. 42ms.

Force Interrupt = 0. Always 0.

Led off time = 010B. 84ms.

Reserved = 000B.

LED_LINK control = 00B. Direct LED mode.

LED_DUPLEX control = 0. Duplex.

LED_RX control = 0. Receive activety/Link.

LED_TX Control = 0. Activity/Link.

=========> Offset: 0x19 Value: 0x3000  <=========

Manual LED override register

Conv_led_sel = 00B. LED pins controlled by fiber.

Reserved = 11B. (* Which should be 00B.)

LED_DUPLEX = 00B. Normal.

LED_LINK10 = 00B. Normal.

LED_LINK100 = 00B. Normal.

LED_LINK1000 = 00B. Normal.

LED_RX = 00B. Normal.

LED_TX = 00B. Normal.

=========> Offset: 0x1B Value: 0x0600  <=========

Copper/Fiber Status Register

Reserved = 00B.

Transmit_pause_en_bx = 0.

Receive_pause_en_bx = 0.

Link_established_bx = 0.

fd_mode_bx = 1. duplex mode of fiber.

speed_mode_bx = 10B. Speed_mode of fiber: 1000Bx.

Reserved = 00B.

Transmit_pause_en_bt = 0.

Receive_pause_en_bt = 0.

Link_established_bt = 0.

fd_mode_bt = 0.

speed_mode_bt = 00B. 10BT.

=========> Offset: 0x1C Value: 0x0000  <=========

Virtual Cable Tester Status

Reserved = 000000B.

Status = 00B. Valid test, normal cable (no short or open in cable)

Delta_Time = 00000000B.

=========> Offset: 0x1D Value: 0x0000  <=========

Debug port (Address offset set)

Reserved = 0000000000B.

Address Offset = 000000B.

=========> Offset: 0x1E Value: 0x82ee  <=========

Debug port2 (R/W port)

Debug data port = 0x82ee.

=========> Offset: 0x1F Value: 0x8100  <=========

Chip Configure Register

Bt_bx_reg_sel = 1. select copper page register.

Reserved = 0.

Sgmii_rximp = 0. 50ohm.

Sgmii_tximp = 0. 50ohm.

Prbs_en = 0. Control prbs test in sgmii.

Reserved = 0010000B. (* Which should be 0000000B.)

Mode_cfg = 0000B. BASET_RGMII.

能够通过MDIO获得AR8031的数据之后,就能够通过观察它们获取CPSW功能的信息,从而了解RJ45的状态。

因此,调试的下一步是理解AM335x的如何通过MDIO注册设备,以及如何通过PHY芯片与局域网通信。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Linux 中的 mdio 是一种管理数据输入/输出 (MDIO) 协议,用于与以太网物理层器件 (PHY) 进行通信。PHY 是用来将以太网数据转换为传输介质能够接受的信号的一种芯片,它与主处理器相连,并通过 MDIO 接口进行通信。 在 Linux 中,MDIO 的读取过程通常需要以下步骤: 1. 获取 mdio_bus 结构体:首先,我们需要获取一个 mdio_bus 结构体,它表示 MDIO 控制器的总线,该总线上连接了一个或多个 PHY。我们可以使用函数 `mdio_bus_alloc()` 来动态分配一个 mdio_bus 结构体。 2. 注册 mdio_bus:分配好 mdio_bus 结构体后,需要注册该总线以向 Linux 内核进行注册,并通过 MDIO 物理设备进行访问。可以使用函数 `mdiobus_register()` 注册该总线。 3. 查找并注册 PHY:成功注册总线后,需要通过函数 `phy_find_first()` 或 `phy_find_by_mask()` 查找连接到总线的第一个 PHY,或者按照指定的位掩码查找 PHY。找到 PHY 后,可以使用函数 `phy_connect()` 来为该 PHY 注册一个控制器。 4. 读取 PHY 寄存器:成功连接到 PHY 后,可以使用函数 `phy_read()` 来读取 PHY 的寄存器。需要提供 PHY 的地址和寄存器的编号来指定要读取的寄存器。 5. 取消注册:当不再需要使用 MDIO 总线和 PHY 时,需要使用函数 `mdiobus_unregister()` 和 `phy_disconnect()` 来取消注册和断开连接。 以上是在 Linux使用 mdio 读取 PHY 的基本步骤。通过这些步骤,我们可以通过 MDIO 总线与 PHY 进行通信,并读取或修改 PHY 的寄存器值,以满足特定的需求。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值