注册 登录  
 加关注
   显示下一条  |  关闭
温馨提示!由于新浪微博认证机制调整,您的新浪微博帐号绑定已过期,请重新绑定!立即重新绑定新浪微博》  |  关闭

dp: 生活的脚步,进步的点滴...

Cam、DSP、FPGA、PM、Life、More ...

 
 
 

日志

 
 

TMS320C6455的千兆网开发之二:NDK对不同PHY的支持  

2011-12-15 09:11:15|  分类: 专业 |  标签: |举报 |字号 订阅

  下载LOFTER 我的照片书  |

2、NDK对不同PHY的支持

对于TMS320C6455,TI提供了NDK用以开发以太网,同事TI也为自己的EVM板子提供了hal(hardware abstract level)库,因此开发来说是较为方便的。

TI的C6455的EVM板子上的DSK主板子是100M网,PHY芯片是intel的LXT971;mezz板(小板)上面提供的是1000M网,使用芯片为broadcom的BCM5464【这个芯片的资料极其难以获取】。使用NDK提供的hal,可以方便的对上面的两款PHY进行开发。本人也成功的在EVM上跑过100M和1000M程序,并且在自己开发的C6455板子上设计和应用100M网。

 

因为项目需求,接下来本人要开发GbE。因此考虑了各方面的需求(芯片级别(Commercial、Industrial),资料完整性,资料获取难易,开发板参考资料,NDK支持情况,PHY电源开发复杂度等),暂时决定还是使用博通的BCM5464。LSI的ET1101C具备工业级别的,但是好像使用这一款PHY需要修改NDK的hal。还有NI的DP83865,可以知道它的开发资料NS提供的还是很全面的,可能仍然需要修改NDK的hal。

 

TMS320C6455的千兆网开发(02)

关于这个问题请看下面的文章。

Guidelines when porting NDK to different PHYs

 http://processors.wiki.ti.com/index.php/Guidelines_when_porting_NDK_to_different_PHYs


This page is intended to provide general guidelines about NDK device drivers' source code and highlight specific points necessary to adapt it to custom EMAC/PHY combinations.

Contents

[hide]

Introduction

Since the beginning, NDK was designed to abstract the environment by using two layers of software that require minimum changes depending on the OS and the hardware used. These layers are the Operating System Abstraction Layer (<os.lib>) and the Hardware Abstraction Layer (all the libraries of type <hal_device_name.lib>).

Typically no changes are required to the OSAL, which runs on top of DSP/BIOS. However, the HAL is a source of frequent questions asking to port to specific hardware configurations or different PHYs. Since it is impossible to foresee all the custom hardware implementations or PHY devices available on the marketplace today, the source code for the drivers is available with the NDK distributions since release 1.92.

In addition to the source code availability, the great number of source files in a typical NDK project are usually confusing for anyone that is trying to make modifications to adapt for custom hardware.

Therefore the information below is given to help pinpoint the places where device drivers' code should be carefully examined and modified. Note that several of the PHY manufacturers do not open detailed datasheets or configuration information unless under a non-disclosure agreement, therefore any changes are of entire responsibility of the customer.

Useful information

For NDK 1.9x releases, each Network Support Package (NSP) contains a design document for the Ethernet device driver that covers the basic architecture and file organization. These files are usually installed under %NDK_INSTALL_DIR%\packages\ti\ndk\docs\<device_name>

For NDK 2.00, the NSP Ethernet Driver Design Guide (SPRUFP2) contains the information for all the device drivers and is typically installed under %NDK_INSTALL_DIR%\packages\ti\ndk\docs\stack

The NDK Programmer's Guide for NDK 1.94 and 2.00 contains additional information in the sections A.14 (for NDK 1.94) and A.15 (for NDK 2.00).

Note: The information in these two last references can also be applied to the NSPs for C6455 and DM642 running with NDK 1.94.

Due to performance and added features, it is highly recommended to use the NIMU driver architecture consolidated in NDK release 2.00. Please note that there are also several driver-stack API changes that render it backward incompatible with previous versions.

Tips to modify device drivers

llPacket

The llPacket source code location varies depending on the installation but is typically located at %NDK_INSTALL_DIR%\packages\ti\ndk\src\hal\<device_name>

1) Hardware Independent Low-Level Ethernet Driver. This layer is provided in the file named <llpacket.c> and does not require changes to adapt to different PHYs.

2) Hardware Specific Low-Level Ethernet (mini) Driver. As the name says, this layer contains the hardware dependent information and changes should be done to specific files.

  • The EMAC configuration files may require just minimal changes (if any), since they mostly change EMAC-only settings. Some examples of these files are <dm642.c>, <c6455.c>, <c64lc.c>, <cpsw3g_core.c>
  • The MDIO configuration files need to be carefully inspected and modified, since they perform the functions of PHY initialization, configuration (MDIO_initPHY() or cpsw_MDIO_Init() functions) and polling (MDIO_timerTick() or cpsw_MDIO_Tic() functions). Some examples of these files are: <c6455_mdio.c>, <64lcmdio.c> and <cpsw_miimdio.c>

For example, the code below starting at line 582 of the file <c6455_mdio.c> might have to be modified to properly initialize a different PHY:

  if ( macsel == CSL_DEV_DEVSTAT_MACSEL_RGMII )  {  //Put phy in copper mode 
 PHYREG_write( PHYREG_ACCESS, phyAddr, PHYREG_ACCESS_COPPER );  
 PHYREG_waitResultsAck( i, ack );  if( !ack ) 
 return(0);  
  PHYREG_write( 0x10, phyAddr, 0x0000 ); //GMII Interface  
 PHYREG_wait();  
  // Put phy in RGMII mode/in-band status data for PG 2.0  
 if (EMAC_REGS->TXIDVER != 0x000C1207) {  
 PHYREG_write(PHYREG_SHADOW, phyAddr, PHYREG_SHADOW_INBAND);  
 PHYREG_waitResultsAck( i, ack );  
  if( !ack )  
 return(0);  
  }  
 }  

3) The hardware initialization file in each example project. These files contain functions called before main() and read or configure some initial parameters for the hardware. These files are usually located in the example project directories. For example, at the end of the file <dsk6455init.c> the code below may have to be modified:

void C6455EMAC_linkStatus( uint phy, uint linkStatus )  
{  
 Uint16 pData; 
  printf("Link Status: %s on PHY %d\n",LinkStr[linkStatus],phy);  
  MDIO_phyRegRead( phy, 0x2, &pData );  
  // Program the LEDs for the Intel phy  
 if (pData ==0x13)  
 MDIO_phyRegWrite( phy, 0x14, 0xd5d0 );  
  // Program the LEDs for the Broadcom phy  
 if (pData ==0x20)  
 MDIO_phyRegWrite( phy, 0x1C, 0xa418 );  
}  

NIMU

The NIMU source drivers are usually located in the directory %NDK_INSTALL_DIR%\packages\ti\ndk\src\hal\<board_name>\eth_<device_name>

1) Layer 1 – NDK stack interaction layer (NIMU layer). Since it encapsulates all interactions between the stack and the NIMU layer, it has no PHY or hardware dependency. Please check section 2.2 of the NSP Ethernet Design Guide above. Typically the usage example of this layer is shown in the file <nimu_eth.c>

2) Layer 2 – Ethernet mini-driver layer. This layer configures the EMAC using the data structures exposed by underlying CSL layers data structures and APIs. Despite directly communicating with the hardware (cache, interrupts, etc) its code is mostly contained into the DSP itself, thus requiring minor (if any) changes to accomodate a different PHY. This layer is usually shown in the file <ethdriver.c>. For example, check the code below starting at line 401 of the file <ethdriver.c> for C6455; if the use of Jumbo Frames is desired but the PHY supports a MTU value smaller than 10200 bytes, an adjustment is required to the value of ecfg.PktMTU.

#ifndef _INCLUDE_JUMBOFRAME_SUPPORT  
 ecfg.PktMTU = 1514;  
#else  
 ecfg.PktMTU = 10200;  
#endif  

3) Layer 3 – CSL EMAC / MDIO layer. External hardware dependent layer. Defines data structures and APIs required to configure and control the EMAC and PHY. Changes to this layer can be split in two categories:

  • CSL EMAC configuration. Despite the fact that CSL itself directly interacts with the hardware, very little is needed to be changed to the EMAC configuration file since it is tailored for the DSP. Such configuration is usually located in the file named <csl_emac.c>.
  • CSL MDIO configuration. Similarly to the MDIO configuration files for llPacket interface, the code requires careful inspection and modification to match the PHY - the names of the functions also match the ones listed for llPacket MDIO configuration. Such configuration is performed by the file <csl_mdio.c>

For example, the code below starting at line 618 of the file <csl_mdio.c> might require modifications to be adjusted to a different PHY.

 if ( macsel == RGMII )  
 {  
 PHYREG_write( PHYREG_ACCESS, phyAddr, PHYREG_ACCESS_COPPER );  
 PHYREG_waitResultsAck( i, ack );  
  if( !ack )  
 return(0);  
  PHYREG_write( 0x10, phyAddr, 0x0000 ); //GMII Interface  
 PHYREG_wait();  
  // Put phy in RGMII mode/in-band status data  
 if (EMAC_REGS->TXIDVER != 0x000C1207) {  
 PHYREG_write(PHYREG_SHADOW, phyAddr, PHYREG_SHADOW_INBAND);  
 PHYREG_waitResultsAck( i, ack );  
 }  
  // If the PHY did not ACK the write, return zero  
 if( !ack )  
 return(0);  
  #if 0   
 // Override gtxcdly so it's low - it's still needed on EVM  
 PHYREG_write( PHYREG_ACCESS, phyAddr, 0x8C00 );  
 PHYREG_waitResultsAck( i, ack );  
  // If the PHY did not ACK the write, return zero  
 if( !ack )  
 return(0);  
#endif   
  }  

4) At last, verify the hardware initialization files in each example project. Its names, locations and functionality are identical as shown in the llPacket interface above.


Emac layer

C647x specific: verify the phy setup in comparison with the NDK evm configuration. On the on the 6474 evm the connection between the phy and the device has a polarity setting which is specific for a hw workaround.

The schematics of the board can be seen at: http://support.spectrumdigital.com/boards/evmc6474/revb/

When using your own board, assuming you connected the phy properly, you will likely have to rebuild the ethernet driver which is generating the library

NDK_2_0\lib\hal\evm6474\hal_eth_c6474.lib


Basically you will need to edit the file NDK_2_0\src\hal\evm6474\eth_c6474\ethdriver.c at line 601 to make sure you specify the correct polarity for the SGMII connection between the device and the PHY

the value to be edited / checked is:

SgmiiCfg.txConfig = 0x00000ea1;  

for the actual meaning of the bit fields, refer to the emac user guide of the device


For technical support please post your questions at http://e2e.ti.com. Please post only comments about the article Guidelines when porting NDK to different PHYs here.
 
下面的是一篇文章,可以参考一下。
TMS320C6455的千兆网开发(02)
 
全文查看地址:
 
  评论这张
 
阅读(2662)| 评论(0)
推荐

历史上的今天

在LOFTER的更多文章

评论

<#--最新日志,群博日志--> <#--推荐日志--> <#--引用记录--> <#--博主推荐--> <#--随机阅读--> <#--首页推荐--> <#--历史上的今天--> <#--被推荐日志--> <#--上一篇,下一篇--> <#-- 热度 --> <#-- 网易新闻广告 --> <#--右边模块结构--> <#--评论模块结构--> <#--引用模块结构--> <#--博主发起的投票-->
 
 
 
 
 
 
 
 
 
 
 
 
 
 

页脚

网易公司版权所有 ©1997-2016