コード例 #1
0
/* Get first nr AHB Slave devices, put them into dev (which is an array of nr length) */
int
amba_find_ahbmsts (amba_confarea_type * amba_conf, int vendor, int device,
                   amba_ahb_device * devs, int maxno)
{
  unsigned int conf, mbar, addr;
  int i, j, cnt;

  for (cnt = i = 0; (i < amba_conf->ahbmst.devnr) && (maxno < cnt); i++) {
    conf = amba_get_confword (amba_conf->ahbslv, i, 0);
    if ((amba_vendor (conf) == vendor) && (amba_device (conf) == device)) {
      for (j = 0; j < 4; j++) {
        mbar = amba_ahb_get_membar (amba_conf->ahbmst, i, j);
        addr = amba_membar_start (mbar);
        if (amba_membar_type (mbar) == AMBA_TYPE_AHBIO) {
          addr = AMBA_TYPE_AHBIO_ADDR (addr, amba_conf->ioarea);
        } else {
          /* convert address if needed */
          if ((addr = addr_from (amba_conf->mmaps, addr)) == 1) {
            addr = 0;           /* no available memory translation available, will not be able to access
                                 * Plug&Play information for this AHB address. Skip it.
                                 */
          }
        }
        devs[cnt].start[j] = addr;
      }
      devs[cnt].irq = amba_irq (conf);
      devs[cnt].ver = amba_ver (conf);
      cnt++;
    }
  }
  return cnt;
}
コード例 #2
0
void
amba_scan (amba_confarea_type * amba_conf, unsigned int ioarea,
           struct amba_mmap *mmaps)
{
  unsigned int *cfg_area;       /* address to configuration area */
  unsigned int mbar, conf, custom;
  int i, j;
  unsigned int apbmst;
  int maxloops = amba_conf->notroot ? 16 : 64; /* scan first bus for 64 devices, rest for 16 devices */

  amba_conf->ahbmst.devnr = 0;
  amba_conf->ahbslv.devnr = 0;
  amba_conf->apbslv.devnr = 0;
  cfg_area = (unsigned int *) (ioarea | AMBA_CONF_AREA);
  amba_conf->ioarea = ioarea;
  amba_conf->mmaps = mmaps;

  for (i = 0; i < maxloops; i++) {
    amba_insert_device (&amba_conf->ahbmst, cfg_area);
    cfg_area += AMBA_AHB_CONF_WORDS;
  }

  cfg_area =
    (unsigned int *) (ioarea | AMBA_CONF_AREA | AMBA_AHB_SLAVE_CONF_AREA);
  for (i = 0; i < maxloops; i++) {
    amba_insert_device (&amba_conf->ahbslv, cfg_area);
    cfg_area += AMBA_AHB_CONF_WORDS;
  }

  for (i = 0; i < amba_conf->ahbslv.devnr; i++){
    conf = amba_get_confword(amba_conf->ahbslv, i, 0);
    mbar = amba_ahb_get_membar(amba_conf->ahbslv, i, 0);
    if ( (amba_vendor(conf) == VENDOR_GAISLER) && (amba_device(conf) == GAISLER_AHB2AHB) ){
      /* Found AHB->AHB bus bridge, scan it if more free amba_confarea_type:s available
       * Custom config 1 contain ioarea.
       */
      custom = amba_ahb_get_custom(amba_conf->ahbslv,i,1);

      if ( amba_ver(conf) && amba_conf->next ){
        amba_conf->next->notroot = 1;
        amba_scan(amba_conf->next,custom,mmaps);
      }
    }else if ((amba_vendor(conf) == VENDOR_GAISLER) && (amba_device(conf) == GAISLER_APBMST))
    {
      apbmst = amba_membar_start(mbar);
			if ( (apbmst=addr_from(mmaps,apbmst)) == 1 )
				continue; /* no available memory translation available, will not be able to access
				           * Plug&Play information for this AHB/APB bridge. Skip it.
				           */
			cfg_area = (unsigned int *)( apbmst | AMBA_CONF_AREA);
      for (j=0; (amba_conf->apbslv.devnr<AMBA_APB_SLAVES) && (j<AMBA_APB_SLAVES); j++){
        amba_insert_apb_device(&amba_conf->apbslv, cfg_area, apbmst);
        cfg_area += AMBA_APB_CONF_WORDS;
      }
    }
  }
}
コード例 #3
0
/* Return number of AHB Slave devices which has given vendor and device */
int
amba_get_number_ahbmst_devices (amba_confarea_type * amba_conf, int vendor,
                                int device)
{
  unsigned int conf;
  int cnt, i;

  for (cnt = i = 0; i < amba_conf->ahbmst.devnr; i++) {
    conf = amba_get_confword (amba_conf->ahbmst, i, 0);
    if ((amba_vendor (conf) == vendor) && (amba_device (conf) == device))
      cnt++;
  }
  return cnt;
}
コード例 #4
0
/* Print AMBA Plug&Play info on terminal */
void
amba_print_conf (amba_confarea_type * amba_conf)
{
	int i,base=0;
	unsigned int conf, iobar, address;
	unsigned int apbmst;

	/* print all ahb masters */
	printk("--- AMBA AHB Masters ---\n");
	for(i=0; i<amba_conf->ahbmst.devnr; i++){
		conf = amba_get_confword(amba_conf->ahbmst, i, 0);
		amba_print_dev(i,conf);
	}

	/* print all ahb slaves */
	printk("--- AMBA AHB Slaves ---\n");
	for(i=0; i<amba_conf->ahbslv.devnr; i++){
		conf = amba_get_confword(amba_conf->ahbslv, i, 0);
		amba_print_dev(i,conf);
	}

	/* print all apb slaves */
	apbmst = 0;
	for(i=0; i<amba_conf->apbslv.devnr; i++){
		if ( apbmst != amba_conf->apbslv.apbmst[i] ){
			apbmst = amba_conf->apbslv.apbmst[i];
			printk("--- AMBA APB Slaves on 0x%x ---\n",apbmst);
			base=i;
		}
		conf = amba_get_confword(amba_conf->apbslv, i, 0);
    iobar = amba_apb_get_membar(amba_conf->apbslv, i);
    address = amba_iobar_start(amba_conf->apbslv.apbmst[i], iobar);
		amba_apb_print_dev(i-base,conf,address);
	}

}
コード例 #5
0
int rtems_leon_open_eth_driver_attach(
  struct rtems_bsdnet_ifconfig *config,
  int attach
)
{
  int device_found = 0;
  int i;
  unsigned int conf, iobar;
  unsigned int base_addr = 0; /* avoid warnings */
  unsigned int eth_irq = 0;   /* avoid warnings */


  /* Scan for MAC AHB slave interface */
  for (i = 0; i < amba_conf.ahbslv.devnr; i++)
  {
    conf = amba_get_confword(amba_conf.ahbslv, i, 0);
    if (((amba_vendor(conf) == VENDOR_OPENCORES) && (amba_device(conf) == OPENCORES_ETHMAC)) ||
        ((amba_vendor(conf) == VENDOR_GAISLER) && (amba_device(conf) == GAISLER_ETHAHB)))
    {
      iobar = amba_ahb_get_membar(amba_conf.ahbslv, i, 0);
      base_addr = amba_iobar_start(LEON3_IO_AREA, iobar);
      eth_irq = amba_irq(conf) + 0x10;
      device_found = 1;
      break;
    }
  }


  if (device_found) 
  {
    /* 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;
    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(leon_open_eth_configuration.vector);
      LEON_Unmask_interrupt(leon_open_eth_configuration.vector);
    } 
  }
  return 0;
}
コード例 #6
0
/* Get First APB Slave device of this vendor&device id */
int
amba_find_apbslv (amba_confarea_type * amba_conf, int vendor, int device,
                  amba_apb_device * dev)
{
  unsigned int conf, iobar;
  int i;

  for (i = 0; i < amba_conf->apbslv.devnr; i++) {
    conf = amba_get_confword (amba_conf->apbslv, i, 0);
    if ((amba_vendor (conf) == vendor) && (amba_device (conf) == device)) {
      iobar = amba_apb_get_membar (amba_conf->apbslv, i);
      dev->start = amba_iobar_start (amba_conf->apbslv.apbmst[i], iobar);
      dev->irq = amba_irq (conf);
      return 1;
    }
  }
  return 0;
}
コード例 #7
0
/* Get first nr APB Slave devices, put them into dev (which is an array of nr length) */
int
amba_find_apbslvs (amba_confarea_type * amba_conf, int vendor, int device,
                   amba_apb_device * devs, int maxno)
{
  unsigned int conf, iobar;
  int cnt, i;

  for (cnt = i = 0; (i < amba_conf->apbslv.devnr) && (cnt < maxno); i++) {
    conf = amba_get_confword (amba_conf->apbslv, i, 0);
    if ((amba_vendor (conf) == vendor) && (amba_device (conf) == device)) {
      /* found device */
      iobar = amba_apb_get_membar (amba_conf->apbslv, i);
      devs[cnt].start = amba_iobar_start (amba_conf->apbslv.apbmst[i], iobar);
      devs[cnt].irq = amba_irq (conf);
      cnt++;
    }
  }
  return cnt;
}
コード例 #8
0
ファイル: ambalist.c プロジェクト: socrocket/core
void amba_prinf_config(void) {
  char devbuf[128];
  char vendorbuf[128];
  unsigned int conf;
  int i = 0;
  int j = 0;
  unsigned int addr;
  unsigned int m;
  printf("             Vendors         Slaves\n");
  printf("Ahb masters:\n");
  i = 0;
  while (i < amba_conf.ahbmst.devnr) {
    conf = amba_get_confword(amba_conf.ahbmst, i, 0);
    vendor_dev_string(conf, vendorbuf, devbuf);
    printf("%2i(%2x:%3x|%2i): %16s %16s \n", i, amba_vendor(conf),
           amba_device(conf), amba_irq(conf), vendorbuf, devbuf);
    for (j = 0; j < 4; j++) {
      m = amba_ahb_get_membar(amba_conf.ahbmst, i, j);
      if (m) {
        addr = amba_membar_start(m);
        printf(" +%i: 0x%x \n", j, addr);
      }
    }
    i++;
  }
  printf("Ahb slaves:\n");
  i = 0;
  while (i < amba_conf.ahbslv.devnr) {
    conf = amba_get_confword(amba_conf.ahbslv, i, 0);
    vendor_dev_string(conf, vendorbuf, devbuf);
    printf("%2i(%2x:%3x|%2i): %16s %16s \n", i, amba_vendor(conf),
           amba_device(conf), amba_irq(conf), vendorbuf, devbuf);
    for (j = 0; j < 4; j++) {
      m = amba_ahb_get_membar(amba_conf.ahbslv, i, j);
      if (m) {
        addr = amba_membar_start(m);
        if (amba_membar_type(m) == AMBA_TYPE_AHBIO) {
          addr = AMBA_TYPE_AHBIO_ADDR(addr);
        } else if (amba_membar_type(m) ==
             AMBA_TYPE_APBIO) {
          printf("Warning: apbio membar\n");
        }
        printf(" +%i: 0x%x (raw:0x%x)\n", j, addr, m);
      }
    }
    i++;
  }
  printf("Apb slaves:\n");
  i = 0;
  while (i < amba_conf.apbslv.devnr) {

    conf = amba_get_confword(amba_conf.apbslv, i, 0);
    vendor_dev_string(conf, vendorbuf, devbuf);
    printf("%2i(%2x:%3x|%2i): %16s %16s \n", i, amba_vendor(conf),
           amba_device(conf), amba_irq(conf), vendorbuf, devbuf);

    m = amba_apb_get_membar(amba_conf.apbslv, i);
    addr = amba_iobar_start(amba_conf.apbslv.apbmst[i], m);
    printf(" +%2i: 0x%x (raw:0x%x) \n", 0, addr, m);

    i++;
  }
}