Changeset afcecbf7 in rtems


Ignore:
Timestamp:
Jul 29, 2009, 7:06:53 PM (10 years ago)
Author:
Joel Sherrill <joel.sherrill@…>
Branches:
4.10, 4.11, master
Children:
330e858c
Parents:
634adfe
Message:

2009-07-29 Joel Sherrill <joel.sherrill@…>

  • network/network.c: Add csb637 PHY code based upon that in MicroMonitor? 1.17.
Location:
c/src/lib/libbsp/arm/csb337
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • c/src/lib/libbsp/arm/csb337/ChangeLog

    r634adfe rafcecbf7  
     12009-07-29      Joel Sherrill <joel.sherrill@oarcorp.com>
     2
     3        * network/network.c: Add csb637 PHY code based upon that in
     4        MicroMonitor 1.17.
     5
    162009-07-16      Joel Sherrill <joel.sherrill@oarcorp.com>
    27
  • c/src/lib/libbsp/arm/csb337/network/network.c

    r634adfe rafcecbf7  
    66 *         and Jay Monkman <jtm@lopingdog.com>
    77 *
     8 *
     9 *  July 2009: Joel Sherrill merged csb637 PHY differences from
     10 *             MicroMonitor 1.17.
     11 *
    812 *  $Id$
    913 */
     
    3438#include <irq.h>
    3539#include <bspopts.h>
     40
     41/* enable debugging of the PHY code */
     42#define PHY_DBG
     43
     44/* enable debugging of the EMAC code */
     45/* #define EMAC_DBG */
    3646
    3747#if csb637
     
    217227  rtems_task_wake_after(1);
    218228
    219   #if EMAC_DBG
     229  #if defined(EMAC_DBG)
    220230    printk(
    221231      "EMAC: Phy 0, Reg %d, Read 0x%04lx.\n",
     
    239249             | 0x02 << 16          /* must be 0x02 for turn around field */
    240250             | data);
    241   #if EMAC_DBG
    242     printf("EMAC: Phy 0, Reg %d, Write 0x%04x.\n", reg, data);
     251  #if defined(EMAC_DBG)
     252    printk("EMAC: Phy 0, Reg %d, Write 0x%04x.\n", reg, data);
    243253  #endif
    244254
     
    278288     */
    279289    if (unitnumber != 0) {
    280         printf ("Bad AT91RM9200 EMAC unit number.\n");
     290        printk ("Bad AT91RM9200 EMAC unit number.\n");
    281291        return 0;
    282292    }
    283293    ifp = &softc.arpcom.ac_if;
    284294    if (ifp->if_softc != NULL) {
    285         printf ("Driver already in use.\n");
     295        printk ("Driver already in use.\n");
    286296        return 0;
    287297    }
     
    379389    /* EMAC doesn't support promiscuous, so ignore requests */
    380390    if (ifp->if_flags & IFF_PROMISC) {
    381         printf ("Warning - AT91RM9200 Ethernet driver"
     391        printk ("Warning - AT91RM9200 Ethernet driver"
    382392                " doesn't support Promiscuous Mode!\n");
    383393    }
     
    459469    EMAC_REG(EMAC_CTL) = EMAC_CTL_MPE;
    460470
    461     /* Set PHY LED2 to combined Link/Activity and enable pulse stretching */
    462471    #if csb637
    463      /* Set PHY LED modes.  Traffic Meter Mode for ACTLED
    464       * Set Bit 6 - Traffic Mode on
    465       */
    466      phywrite(0x1b, PHY_AUX_MODE2_TRAFFIC_LED);
     472    {
     473      int      timeout;
     474      uint32_t emac_link_status;
     475
     476      #if defined(PHY_DBG)
     477        printk("EMAC: Getting Link Status.\n");
     478      #endif
     479      /* read the PHY ID registers */
     480      emac_link_status = phyread(0x02);
     481      emac_link_status = phyread(0x03);
     482
     483      /* Get the link status - wait for done with a timeout */
     484      for (timeout = 10000 ; timeout ; ) {
     485        for (i = 0; i < 100; i++)
     486          ;
     487        emac_link_status = phyread(0x01);
     488        if (!(emac_link_status & PHY_STAT_AUTO_NEG_ABLE)) {
     489          #if defined(PHY_DBG)
     490            printk("EMAC: PHY is unable to Auto-Negotatiate!\n");
     491          #endif
     492          timeout = 0;
     493          break;
     494        }
     495        if (emac_link_status & PHY_STAT_AUTO_NEG_DONE) {
     496          #if defined(PHY_DBG)
     497            printk("EMAC: Auto-Negotiate Complete, Link = ");
     498          #endif
     499          break;
     500        }
     501        timeout-- ;
     502      }
     503      if (!timeout) {
     504        #if defined(PHY_DBG)
     505          printk(
     506           "EMAC: Auto-Negotatiate Failed, Status = 0x%04lx!\n"
     507           "EMAC: Initialization Halted.\n",
     508           emac_link_status
     509          );
     510        #endif
     511        /* if autonegotiation fails, just force to 10HD... */
     512        emac_link_status = PHY_STAT_10BASE_HDX;
     513      }
     514
     515      /* Set SPD and FD based on the return link status */
     516      if (emac_link_status & (PHY_STAT_100BASE_X_FDX | PHY_STAT_100BASE_X_HDX)){
     517        EMAC_REG(EMAC_CFG) |= EMAC_CFG_SPD;
     518        #if defined(PHY_DBG)
     519          printk("100MBIT, ");
     520        #endif
     521      } else {
     522        EMAC_REG(EMAC_CFG) &= ~EMAC_CFG_SPD;
     523        #if defined(PHY_DBG)
     524          printk("10MBIT, ");
     525        #endif
     526      }               
     527                       
     528      if (emac_link_status & (PHY_STAT_100BASE_X_FDX | PHY_STAT_10BASE_FDX)) {
     529        EMAC_REG(EMAC_CFG) |= EMAC_CFG_FD;
     530        #if defined(PHY_DBG)
     531          printk("Full Duplex.\n");
     532        #endif
     533      } else {
     534        EMAC_REG(EMAC_CFG) &= ~EMAC_CFG_FD;
     535        #if defined(PHY_DBG)
     536          printk("Half Duplex.\n");
     537        #endif
     538      }               
     539
     540      /* Set PHY LED modes.  Traffic Meter Mode for ACTLED
     541       * Set Bit 6 - Traffic Mode on
     542       */
     543      phywrite(0x1b, PHY_AUX_MODE2_TRAFFIC_LED);
     544    }
    467545    #else
    468546      /* must be csb337 */
     547      /* Set PHY LED2 to combined Link/Activity and enable pulse stretching */
    469548      phywrite( 18, 0x0d0a );
    470549    #endif
     
    541620    unsigned int pkt_offset = 0;
    542621    delay_cnt = 0;
    543     /* printf("at91rm9200_emac_sendpacket %p\n", m); */
     622    /* printk("at91rm9200_emac_sendpacket %p\n", m); */
    544623
    545624    /* Wait for EMAC Transmit Queue to become available. */
     
    601680
    602681        if (EMAC_REG(EMAC_RSR) & EMAC_RSR_BNA) {
    603             printf("1: EMAC_BNA\n");
     682            printk("1: EMAC_BNA\n");
    604683        }
    605684
    606685        if (EMAC_REG(EMAC_RSR) & EMAC_RSR_OVR) {
    607             printf("1: EMAC_OVR\n");
     686            printk("1: EMAC_OVR\n");
    608687        }
    609688
     
    655734
    656735        if (EMAC_REG(EMAC_RSR) & EMAC_RSR_BNA) {
    657             printf("2:EMAC_BNA\n");
     736            printk("2:EMAC_BNA\n");
    658737        }
    659738        if (EMAC_REG(EMAC_RSR) & EMAC_RSR_OVR) {
    660             printf("2:EMAC_OVR\n");
     739            printk("2:EMAC_OVR\n");
    661740        }
    662741
Note: See TracChangeset for help on using the changeset viewer.