Changeset e6fbd26 in rtems


Ignore:
Timestamp:
Apr 24, 2017, 2:32:17 PM (2 years ago)
Author:
Daniel Hellstrom <daniel@…>
Branches:
master
Children:
8ac070a
Parents:
12718134
git-author:
Daniel Hellstrom <daniel@…> (04/24/17 14:32:17)
git-committer:
Daniel Hellstrom <daniel@…> (05/14/17 10:31:56)
Message:

leon, greth: speed modes advertising now configurable

Location:
c/src/lib/libbsp/sparc/shared
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • c/src/lib/libbsp/sparc/shared/include/greth.h

    r12718134 re6fbd26  
    8282#define GRETH_CTRL_PRO          0x00000020 /* Promiscuous (receive all) */
    8383#define GRETH_CTRL_RST          0x00000040 /* Reset MAC */
     84#define GRETH_CTRL_SP           0x00000080 /* 100MBit speed mode */
     85#define GRETH_CTRL_GB           0x00000100 /* 1GBit speed mode */
    8486#define GRETH_CTRL_DD           0x00001000 /* Disable EDCL Duplex Detection */
    8587#define GRETH_CTRL_ED           0x00004000 /* EDCL Disable */
     
    134136};
    135137
     138/* Limit speed modes advertised during auto-negotiation */
     139#define GRETH_ADV_10_HD    0x0001
     140#define GRETH_ADV_10_FD    0x0002
     141#define GRETH_ADV_100_HD   0x0004
     142#define GRETH_ADV_100_FD   0x0008
     143#define GRETH_ADV_1000_HD  0x0010
     144#define GRETH_ADV_1000_FD  0x0020
     145#define GRETH_ADV_ALL      0x003f
    136146/*
    137147#ifdef CPU_U32_FIX
  • c/src/lib/libbsp/sparc/shared/net/greth.c

    r12718134 re6fbd26  
    189189   int gbit_mac;
    190190   int auto_neg;
     191   unsigned int advmodes; /* advertise ethernet speed modes. 0 = all modes. */
    191192   struct timespec auto_neg_time;
    192193
     
    353354    struct timespec tstart, tnow;
    354355    greth_regs *regs;
     356    unsigned int advmodes;
    355357
    356358    regs = sc->regs;
     
    395397    while ((phyctrl = read_mii(sc, phyaddr, 0)) & 0x8000) {}
    396398
     399    /* Set up PHY advertising modes for auto-negotiation */
     400    advmodes = sc->advmodes;
     401    if (advmodes == 0)
     402        advmodes = GRETH_ADV_ALL;
     403    if (!sc->gbit_mac)
     404        advmodes &= ~(GRETH_ADV_1000_FD | GRETH_ADV_1000_HD);
     405
    397406    /* Enable/Disable GBit auto-neg advetisement so that the link partner
    398407     * know that we have/haven't GBit capability. The MAC may not support
     
    402411    if (phystatus & 0x0100) {
    403412        tmp1 = read_mii(sc, phyaddr, 9);
    404         if (sc->gbit_mac)
    405             write_mii(sc, phyaddr, 9, tmp1 | 0x300);
    406         else
    407             write_mii(sc, phyaddr, 9, tmp1 & ~(0x300));
    408     }
     413        tmp1 &= ~0x300;
     414        if (advmodes & GRETH_ADV_1000_FD)
     415            tmp1 |= 0x200;
     416        if (advmodes & GRETH_ADV_1000_HD)
     417            tmp1 |= 0x100;
     418        write_mii(sc, phyaddr, 9, tmp1);
     419    }
     420
     421    /* Optionally limit the 10/100 modes as configured by user */
     422    tmp1 = read_mii(sc, phyaddr, 4);
     423    tmp1 &= ~0x1e0;
     424    if (advmodes & GRETH_ADV_100_FD)
     425        tmp1 |= 0x100;
     426    if (advmodes & GRETH_ADV_100_HD)
     427        tmp1 |= 0x080;
     428    if (advmodes & GRETH_ADV_10_FD)
     429        tmp1 |= 0x040;
     430    if (advmodes & GRETH_ADV_10_HD)
     431        tmp1 |= 0x020;
     432    write_mii(sc, phyaddr, 4, tmp1);
    409433
    410434    /* If autonegotiation implemented we start it */
     
    14811505        sc->phyaddr = value->i;
    14821506
     1507    value = drvmgr_dev_key_get(sc->dev, "advModes", DRVMGR_KT_INT);
     1508    if ( value )
     1509        sc->advmodes = value->i;
     1510
    14831511    return 0;
    14841512}
Note: See TracChangeset for help on using the changeset viewer.