Changeset 6d4d934 in rtems


Ignore:
Timestamp:
Dec 16, 2010, 1:35:26 PM (11 years ago)
Author:
Sebastian Huber <sebastian.huber@…>
Branches:
4.11, 5, master
Children:
861ff1e
Parents:
cfe13cb
Message:

2010-12-16 Sebastian Huber <sebastian.huber@…>

  • shared/lpc/include/lpc-i2s.h: Documentation. Fixed defines.
  • shared/lpc/include/lpc-timer.h: Documentation.
  • shared/lpc/network/lpc-ethernet.c: Added support for 10MBit/s links.
Location:
c/src/lib/libbsp/arm
Files:
4 edited

Legend:

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

    rcfe13cb r6d4d934  
     12010-12-16      Sebastian Huber <sebastian.huber@embedded-brains.de>
     2
     3        * shared/lpc/include/lpc-i2s.h: Documentation.  Fixed defines.
     4        * shared/lpc/include/lpc-timer.h: Documentation.
     5        * shared/lpc/network/lpc-ethernet.c: Added support for 10MBit/s links.
     6
    172010-12-03      Sebastian Huber <sebastian.huber@embedded-brains.de>
    28
  • c/src/lib/libbsp/arm/shared/lpc/include/lpc-i2s.h

    rcfe13cb r6d4d934  
    3131
    3232/**
    33  * @defgroup lpc_dma I2S Support
     33 * @defgroup lpc_i2s I2S Support
    3434 *
    35  * @ingroup lpc
     35 * @ingroup lpc24xx
     36 * @ingroup lpc32xx
    3637 *
    3738 * @brief I2S support.
     
    118119
    119120#define LPC24XX_I2S_RATE(val) BSP_FLD32(val, 0, 9)
    120 #define LPC32XX_I2S_RATE_X_DIVIDER BSP_FLD32(val, 0, 7)
    121 #define LPC32XX_I2S_RATE_Y_DIVIDER BSP_FLD32(val, 8, 15)
     121#define LPC32XX_I2S_RATE_X_DIVIDER(val) BSP_FLD32(val, 0, 7)
     122#define LPC32XX_I2S_RATE_Y_DIVIDER(val) BSP_FLD32(val, 8, 15)
    122123
    123124/** @} */
  • c/src/lib/libbsp/arm/shared/lpc/include/lpc-timer.h

    rcfe13cb r6d4d934  
    3232 * @defgroup lpc_timer Timer Support
    3333 *
    34  * @ingroup lpc
     34 * @ingroup lpc24xx
     35 * @ingroup lpc32xx
    3536 *
    3637 * @brief Timer support.
  • c/src/lib/libbsp/arm/shared/lpc/network/lpc-ethernet.c

    rcfe13cb r6d4d934  
    4848#include <bsp/irq.h>
    4949#include <bsp/lpc-ethernet-config.h>
     50#include <bsp/utility.h>
    5051
    5152#include <rtems/status-checks.h>
     
    6061  #define LPC_ETH_CONFIG_TX_BUF_SIZE 1518U
    6162#endif
     63
     64#define DEFAULT_PHY 0
     65#define WATCHDOG_TIMEOUT 5
    6266
    6367typedef struct {
     
    217221#define ETH_STAT_TX_ACTIVE 0x00000002U
    218222
     223/* ETH_MAC2 */
     224
     225#define ETH_MAC2_FULL_DUPLEX BSP_BIT32(8)
     226
     227/* ETH_SUPP */
     228
     229#define ETH_SUPP_SPEED BSP_BIT32(8)
     230
     231/* ETH_MCFG */
     232
     233#define ETH_MCFG_CLOCK_SELECT(val) BSP_FLD32(val, 2, 4)
     234
     235/* ETH_MCMD */
     236
     237#define ETH_MCMD_READ BSP_BIT32(0)
     238#define ETH_MCMD_SCAN BSP_BIT32(1)
     239
     240/* ETH_MADR */
     241
     242#define ETH_MADR_REG(val) BSP_FLD32(val, 0, 4)
     243#define ETH_MADR_PHY(val) BSP_FLD32(val, 8, 12)
     244
     245/* ETH_MIND */
     246
     247#define ETH_MIND_BUSY BSP_BIT32(0)
     248#define ETH_MIND_SCANNING BSP_BIT32(1)
     249#define ETH_MIND_NOT_VALID BSP_BIT32(2)
     250#define ETH_MIND_MII_LINK_FAIL BSP_BIT32(3)
     251
    219252/* Events */
    220253
     
    267300typedef struct {
    268301  struct arpcom arpcom;
    269   struct rtems_mdio_info mdio_info;
    270302  lpc_eth_state state;
     303  struct rtems_mdio_info mdio;
     304  uint32_t anlpar;
    271305  rtems_id receive_task;
    272306  rtems_id transmit_task;
     
    10421076}
    10431077
     1078static void lpc_eth_mdio_wait_for_not_busy(void)
     1079{
     1080  while ((lpc_eth->mind & ETH_MIND_BUSY) != 0) {
     1081    rtems_task_wake_after(2);
     1082  }
     1083}
     1084
     1085static uint32_t lpc_eth_mdio_read_anlpar(void)
     1086{
     1087  uint32_t madr = ETH_MADR_REG(MII_ANLPAR) | ETH_MADR_PHY(DEFAULT_PHY);
     1088  uint32_t anlpar = 0;
     1089
     1090  if (lpc_eth->madr != madr) {
     1091    lpc_eth->madr = madr;
     1092  }
     1093
     1094  if (lpc_eth->mcmd != ETH_MCMD_READ) {
     1095    lpc_eth->mcmd = 0;
     1096    lpc_eth->mcmd = ETH_MCMD_READ;
     1097  }
     1098
     1099  lpc_eth_mdio_wait_for_not_busy();
     1100
     1101  anlpar = lpc_eth->mrdd;
     1102
     1103  /* Start next read */
     1104  lpc_eth->mcmd = 0;
     1105  lpc_eth->mcmd = ETH_MCMD_READ;
     1106
     1107  return anlpar;
     1108}
     1109
     1110static int lpc_eth_mdio_read(
     1111  int phy __attribute__((unused)),
     1112  void *arg __attribute__((unused)),
     1113  unsigned reg,
     1114  uint32_t *val
     1115)
     1116{
     1117  int eno = 0;
     1118
     1119  if (phy == -1 || phy == 0) {
     1120    lpc_eth->madr = ETH_MADR_REG(reg) | ETH_MADR_PHY(DEFAULT_PHY);
     1121    lpc_eth->mcmd = 0;
     1122    lpc_eth->mcmd = ETH_MCMD_READ;
     1123    lpc_eth_mdio_wait_for_not_busy();
     1124    *val = lpc_eth->mrdd;
     1125  } else {
     1126    eno = EINVAL;
     1127  }
     1128
     1129  return eno;
     1130}
     1131
     1132static int lpc_eth_mdio_write(
     1133  int phy __attribute__((unused)),
     1134  void *arg __attribute__((unused)),
     1135  unsigned reg,
     1136  uint32_t val
     1137)
     1138{
     1139  int eno = 0;
     1140
     1141  if (phy == -1 || phy == 0) {
     1142    lpc_eth->madr = ETH_MADR_REG(reg) | ETH_MADR_PHY(DEFAULT_PHY);
     1143    lpc_eth->mwtd = val;
     1144    lpc_eth_mdio_wait_for_not_busy();
     1145  } else {
     1146    eno = EINVAL;
     1147  }
     1148
     1149  return eno;
     1150}
     1151
    10441152static void lpc_eth_interface_init(void *arg)
    10451153{
     
    10611169
    10621170    /* Initialize PHY */
     1171    lpc_eth->mcfg = ETH_MCFG_CLOCK_SELECT(0x7);
    10631172    /* TODO */
    10641173
     
    10691178    lpc_eth->clrt = 0x370f;
    10701179    lpc_eth->maxf = 0x0600;
    1071     lpc_eth->supp = 0x0100;
     1180    lpc_eth->supp = ETH_SUPP_SPEED;
    10721181    lpc_eth->test = 0;
    10731182    #ifdef LPC_ETH_CONFIG_RMII
     
    11411250}
    11421251
    1143 static void lpc_eth_interface_stats(const lpc_eth_driver_entry *e)
    1144 {
     1252static void lpc_eth_interface_stats(lpc_eth_driver_entry *e)
     1253{
     1254  int media = IFM_MAKEWORD(0, 0, 0, 0);
     1255  int eno = rtems_mii_ioctl(&e->mdio, e, SIOCGIFMEDIA, &media);
     1256
    11451257  rtems_bsdnet_semaphore_release();
     1258
     1259  if (eno == 0) {
     1260    rtems_ifmedia2str(media, NULL, 0);
     1261    printf("\n");
     1262  }
    11461263
    11471264  printf("received frames:                     %u\n", e->received_frames);
     
    11821299    case SIOCGIFMEDIA:
    11831300    case SIOCSIFMEDIA:
    1184       rtems_mii_ioctl(&e->mdio_info, e, (int) command, (int *) data);
     1301      rtems_mii_ioctl(&e->mdio, e, command, (int *) data);
    11851302      break;
    11861303    case SIOCGIFADDR:
     
    12211338static void lpc_eth_interface_watchdog(struct ifnet *ifp __attribute__((unused)))
    12221339{
    1223   LPC_ETH_PRINTF("%s\n", __func__);
     1340  lpc_eth_driver_entry *e = (lpc_eth_driver_entry *) ifp->if_softc;
     1341  uint32_t anlpar = lpc_eth_mdio_read_anlpar();
     1342
     1343  if (e->anlpar != anlpar) {
     1344    bool full_duplex = false;
     1345    bool speed = false;
     1346
     1347    e->anlpar = anlpar;
     1348
     1349    if ((anlpar & ANLPAR_TX_FD) != 0) {
     1350      full_duplex = true;
     1351      speed = true;
     1352    } else if ((anlpar & ANLPAR_T4) != 0) {
     1353      speed = true;
     1354    } else if ((anlpar & ANLPAR_TX) != 0) {
     1355      speed = true;
     1356    } else if ((anlpar & ANLPAR_10_FD) != 0) {
     1357      full_duplex = true;
     1358    }
     1359
     1360    if (full_duplex) {
     1361      lpc_eth->mac2 |= ETH_MAC2_FULL_DUPLEX;
     1362    } else {
     1363      lpc_eth->mac2 &= ~ETH_MAC2_FULL_DUPLEX;
     1364    }
     1365
     1366    if (speed) {
     1367      lpc_eth->supp |= ETH_SUPP_SPEED;
     1368    } else {
     1369      lpc_eth->supp &= ~ETH_SUPP_SPEED;
     1370    }
     1371  }
     1372
     1373  ifp->if_timer = WATCHDOG_TIMEOUT;
    12241374}
    12251375
     
    12611411    RTEMS_DO_CLEANUP(cleanup, "already attached");
    12621412  }
     1413
     1414  /* MDIO */
     1415  e->mdio.mdio_r = lpc_eth_mdio_read;
     1416  e->mdio.mdio_w = lpc_eth_mdio_write;
     1417  e->mdio.has_gmii = 0;
     1418  e->anlpar = 0;
    12631419
    12641420  /* Interrupt number */
Note: See TracChangeset for help on using the changeset viewer.