Changeset d5f5432 in rtems


Ignore:
Timestamp:
Aug 22, 2014, 6:53:10 AM (6 years ago)
Author:
Christian Mauderer <Christian.Mauderer@…>
Branches:
4.11, 5, master
Children:
a68cc1b
Parents:
66f1ca6
git-author:
Christian Mauderer <Christian.Mauderer@…> (08/22/14 06:53:10)
git-committer:
Sebastian Huber <sebastian.huber@…> (08/22/14 09:48:27)
Message:

libchip/dwmac: Make PHY address user configurable

This patch allows the user to configure the PHY address for the DWMAC
driver by giving a pointer to a dwmac_user_cfg structure to network
stack via rtems_bsdnet_ifconfig::drv_ctrl.

Location:
c/src
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • c/src/lib/libbsp/arm/altera-cyclone-v/README

    r66f1ca6 rd5f5432  
    1515Additional there has to be one free file descriptor to access the i2c. Set the
    1616CONFIGURE_LIBIO_MAXIMUM_FILE_DESCRIPTORS accordingly.
     17
     18Network
     19-------
     20The default PHY address can be overwritten by the application. To do this, the
     21drv_ctrl pointer of the rtems_bsdnet_ifconfig structure should point to a
     22dwmac_ifconfig_drv_ctrl object with the appropriate settings before the
     23rtems_bsdnet_initialize_network() is called. E.g.:
     24
     25  #include <libchip/dwmac.h>
     26  #include <bsp.h>
     27
     28  static dwmac_ifconfig_drv_ctrl drv_ctrl = {
     29    .phy_addr = 1
     30  };
     31
     32  ...
     33
     34  static struct rtems_bsdnet_ifconfig some_ifconfig = {
     35    .name = RTEMS_BSP_NETWORK_DRIVER_NAME,
     36    .attach = RTEMS_BSP_NETWORK_DRIVER_ATTACH,
     37    .drv_ctrl = &drv_ctrl
     38  };
     39
     40  ...
     41
     42  rtems_bsdnet_initialize_network();
     43
     44If drv_ctrl is the NULL pointer, default values will be used instead.
  • c/src/libchip/network/dwmac-common.h

    r66f1ca6 rd5f5432  
    228228  struct mbuf **mbuf_addr_tx;
    229229  const dwmac_cfg *CFG;
     230  int MDIO_BUS_ADDR;
    230231} dwmac_common_context;
    231232
  • c/src/libchip/network/dwmac.c

    r66f1ca6 rd5f5432  
    132132    reg_value = MACGRP_GMII_ADDRESS_PHYSICAL_LAYER_ADDRESS_SET(
    133133      reg_value,
    134       self->CFG->MDIO_BUS_ADDR
     134      self->MDIO_BUS_ADDR
    135135      );
    136136  } else {
     
    188188    reg_value = MACGRP_GMII_ADDRESS_PHYSICAL_LAYER_ADDRESS_SET(
    189189      reg_value,
    190       self->CFG->MDIO_BUS_ADDR
     190      self->MDIO_BUS_ADDR
    191191      );
    192192  } else {
     
    348348  int                   media    = 0;
    349349  bool                  media_ok = dwmac_if_media_status(
    350     self, &media, self->CFG->MDIO_BUS_ADDR );
     350    self, &media, self->MDIO_BUS_ADDR );
    351351  uint32_t              oui;
    352352  uint8_t               model;
     
    365365    eno = dwmac_get_phy_info(
    366366      self,
    367       self->CFG->MDIO_BUS_ADDR,
     367      self->MDIO_BUS_ADDR,
    368368      &oui,
    369369      &model,
     
    373373      printf( "PHY 0x%02x: OUI = 0x%04" PRIX32 ", Model = 0x%02" PRIX8 ", Rev = "
    374374              "0x%02" PRIX8 "\n",
    375               self->CFG->MDIO_BUS_ADDR,
     375              self->MDIO_BUS_ADDR,
    376376              oui,
    377377              model,
     
    388388    }
    389389  } else {
    390     printf( "PHY %d communication error\n", self->CFG->MDIO_BUS_ADDR );
     390    printf( "PHY %d communication error\n", self->MDIO_BUS_ADDR );
    391391  }
    392392
     
    12511251  int      media    = 0;
    12521252  bool     media_ok = dwmac_if_media_status(
    1253     self, &media, self->CFG->MDIO_BUS_ADDR );
     1253    self, &media, self->MDIO_BUS_ADDR );
    12541254
    12551255
     
    20662066  const dwmac_common_desc_ops *DESC_OPS =
    20672067    (const dwmac_common_desc_ops *) driver_config->DESC_OPS->ops;
    2068 
     2068  const dwmac_ifconfig_drv_ctrl *drv_ctrl =
     2069    (const dwmac_ifconfig_drv_ctrl *) bsd_config->drv_ctrl;
    20692070
    20702071  assert( self != NULL );
     
    21362137
    21372138  if ( eno == 0 ) {
    2138     assert( 32 >= driver_config->MDIO_BUS_ADDR );
    2139 
    2140     if ( 32 < driver_config->MDIO_BUS_ADDR ) {
     2139    if ( drv_ctrl == NULL ) {
     2140      self->MDIO_BUS_ADDR = driver_config->MDIO_BUS_ADDR;
     2141    } else {
     2142      self->MDIO_BUS_ADDR = drv_ctrl->phy_addr;
     2143    }
     2144
     2145    assert( 32 >= self->MDIO_BUS_ADDR );
     2146
     2147    if ( 32 < self->MDIO_BUS_ADDR ) {
    21412148      eno = EINVAL;
    21422149    }
     
    23182325  if ( arg != NULL ) {
    23192326    eno = dwmac_if_mdio_read(
    2320       self->CFG->MDIO_BUS_ADDR,
     2327      self->MDIO_BUS_ADDR,
    23212328      self,
    23222329      phy_reg,
     
    23422349  if ( arg != NULL ) {
    23432350    eno = dwmac_if_mdio_write(
    2344       self->CFG->MDIO_BUS_ADDR,
     2351      self->MDIO_BUS_ADDR,
    23452352      self,
    23462353      phy_reg,
  • c/src/libchip/network/dwmac.h

    r66f1ca6 rd5f5432  
    3131extern "C" {
    3232#endif /* __cplusplus */
     33
     34/** @brief DWMAC user configuration structure.
     35 *
     36 * Gives the user the possibility to overwrite some configuration data by
     37 * setting the drv_ctrl pointer of the @ref rtems_bsdnet_ifconfig structure to a
     38 * object with this type.
     39 */
     40typedef struct {
     41  int phy_addr;
     42} dwmac_ifconfig_drv_ctrl;
    3343
    3444/** @brief PHY event.
Note: See TracChangeset for help on using the changeset viewer.