Esempio n. 1
0
int rtems_leon_open_eth_driver_attach(
  struct rtems_bsdnet_ifconfig *config,
  int attach
)
{
  unsigned int base_addr = 0; /* avoid warnings */
  unsigned int eth_irq = 0;   /* avoid warnings */
  struct ambapp_dev *adev;
  struct ambapp_ahb_info *ahb;

  /* Scan for MAC AHB slave interface */
  adev = (void *)ambapp_for_each(&ambapp_plb, (OPTIONS_ALL|OPTIONS_AHB_SLVS),
                                 VENDOR_OPENCORES, OPENCORES_ETHMAC,
                                 ambapp_find_by_idx, NULL);
  if (!adev) {
    adev = (void *)ambapp_for_each(&ambapp_plb, (OPTIONS_ALL|OPTIONS_AHB_SLVS),
                                   VENDOR_GAISLER, GAISLER_ETHAHB,
                                   ambapp_find_by_idx, NULL);
  }

  if (adev)
  {
    ahb = DEV_TO_AHB(adev);
    base_addr = ahb->start[0];
    eth_irq = ahb->irq;

    /* clear control register and reset NIC */
    *(volatile int *) base_addr = 0;
    *(volatile int *) base_addr = 0x800;
    *(volatile int *) base_addr = 0;
    leon_open_eth_configuration.base_address = base_addr;
    leon_open_eth_configuration.vector = eth_irq + 0x10;
    leon_open_eth_configuration.txd_count = TDA_COUNT;
    leon_open_eth_configuration.rxd_count = RDA_COUNT;
    /* enable 100 MHz operation only if cpu frequency >= 50 MHz */
    if (LEON3_Timer_Regs->scaler_reload >= 49)
      leon_open_eth_configuration.en100MHz = 1;
    if (rtems_open_eth_driver_attach( config, &leon_open_eth_configuration )) {
      LEON_Clear_interrupt(eth_irq);
      LEON_Unmask_interrupt(eth_irq);
    }
  }
  return 0;
}
Esempio n. 2
0
static int ambapp_dev_print(struct ambapp_dev *dev, int index, void *arg)
{
  char *dev_str, *ven_str, *type_str;
  struct ambapp_dev_print_arg *p = arg;
  char dp[32];
  int i=0;
  unsigned int basereg;

  if (p->show_depth) {
    for (i=0; i<ambapp_depth(dev)*2; i+=2) {
      dp[i] = ' ';
      dp[i+1] = ' ';
    }
  }
  dp[i] = '\0';

  ven_str = ambapp_vendor_id2str(dev->vendor);
  if (!ven_str) {
    ven_str = unknown;
    dev_str = unknown;
  } else {
    dev_str = ambapp_device_id2str(dev->vendor, dev->device);
    if (!dev_str)
      dev_str = unknown;
  }
  if (dev->dev_type == DEV_APB_SLV) {
    /* APB */
    basereg = DEV_TO_APB(dev)->start;
    type_str = "apb";
  } else {
    /* AHB */
    basereg = DEV_TO_AHB(dev)->start[0];
    type_str = "ahb";
  }
  printf("%s |-> 0x%x:0x%x:0x%x: %s_%s, %s: 0x%x, 0x%x (OWNER: 0x%x)\n",
         dp, index, dev->vendor, dev->device, ven_str, dev_str, type_str,
         basereg, (unsigned int)dev, (unsigned int)dev->owner);

  return 0;
}