Ignore:
Timestamp:
Sep 6, 2007, 12:07:44 AM (14 years ago)
Author:
Joel Sherrill <joel.sherrill@…>
Branches:
4.10, 4.11, 4.8, 4.9, 5, master
Children:
28f3f511
Parents:
3d0d969
Message:

2007-09-05 Daniel Hellstrom <daniel@…>

  • clock/ckinit.c, console/console.c, leon_greth/leon_greth.c, leon_smc91111/leon_smc91111.c: LEON3 BSP drivers updated to use new AMBA PnP scanning functions. Affected drivers: amba/amba.c,clock/ckinit.c,console/console.c, leon_greth/leon_greth.c, leon_smc9111.c.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • c/src/lib/libbsp/sparc/leon3/leon_smc91111/leon_smc91111.c

    r3d0d969 r921bb59  
    1414scmv91111_configuration_t leon_scmv91111_configuration = {
    1515  SMC91111_BASE_ADDR,                 /* base address */
    16   LEON_TRAP_TYPE(SMC91111_BASE_IRQ),  /* vector number */
     16    LEON_TRAP_TYPE (SMC91111_BASE_IRQ), /* vector number */
    1717  SMC91111_BASE_PIO,                  /* PIO */
    18   10,                                 /* 10b */
     18    100,                        /* 100b */
    1919  1,                                  /* fulldx */
    2020  1                                   /* autoneg */
    2121};
    2222
    23 int _rtems_smc91111_driver_attach(
    24   struct rtems_bsdnet_ifconfig *config,
    25   scmv91111_configuration_t    *scm_config
    26 );
     23int _rtems_smc91111_driver_attach (struct rtems_bsdnet_ifconfig *config,
     24                                   scmv91111_configuration_t * scm_config);
    2725
    2826/*
    2927 * Attach an SMC91111 driver to the system
    3028 */
    31 int rtems_smc91111_driver_attach_leon3 (
    32   struct rtems_bsdnet_ifconfig *config,
    33   int                           attach
    34 )
     29int
     30rtems_smc91111_driver_attach_leon3 (struct rtems_bsdnet_ifconfig *config,
     31                                    int attach)
    3532{
    36   unsigned int iobar, conf,i;
     33  unsigned long addr_mctrl = 0;
     34  LEON3_IOPORT_Regs_Map *io;
    3735
    38   {
    39     unsigned long irq_pio, irq_mctrl, addr_pio = 0;
    40     unsigned long addr_mctrl = 0, addr_timer = 0;
    41 
    42     i = 0;
    43     while (i < amba_conf.apbslv.devnr)
    44       {
    45         conf = amba_get_confword(amba_conf.apbslv, i, 0);
    46         if ((amba_vendor(conf) == VENDOR_GAISLER) &&
    47             (amba_device(conf) == GAISLER_PIOPORT))
    48     {
    49       irq_pio = amba_irq(conf);
    50       iobar = amba_apb_get_membar(amba_conf.apbslv, i);     
    51       addr_pio = (unsigned long) amba_iobar_start(amba_conf.apbmst, iobar);
    52     }
    53         else if ((amba_vendor(conf) == VENDOR_ESA) &&
    54                  (amba_device(conf) == ESA_MCTRL))
    55     {
    56       irq_mctrl = amba_irq(conf);
    57       iobar = amba_apb_get_membar(amba_conf.apbslv, i);     
    58       addr_mctrl = (unsigned long) amba_iobar_start(amba_conf.apbmst, iobar);
    59     }
    60         else if ((amba_vendor(conf) == VENDOR_GAISLER) &&
    61                  (amba_device(conf) == GAISLER_GPTIMER))
    62     {
    63       iobar = amba_apb_get_membar(amba_conf.apbslv, i);     
    64       addr_timer = (unsigned long) amba_iobar_start(amba_conf.apbmst, iobar);
    65     }
    66         i++;
    67       }
    68 
    69     if (addr_timer) {
    70       LEON3_Timer_Regs_Map *timer = (LEON3_Timer_Regs_Map *)addr_timer;
    71       if (timer->scaler_reload >= 49)
    72         leon_scmv91111_configuration.ctl_rspeed = 100;
    73     }
    74    
    75     if (addr_pio && addr_mctrl) {
    76      
    77       LEON3_IOPORT_Regs_Map *io = (LEON3_IOPORT_Regs_Map *) addr_pio;
    78       printk(
    79         "Activating Leon3 io port for smsc_lan91cxx (pio:%x mctrl:%x)\n",
    80         (unsigned int)addr_pio,
    81         (unsigned int)addr_mctrl);
    82      
    83       *((volatile unsigned int *)addr_mctrl) |= 0x10f80000;  /*mctrl ctrl 1 */
    84       io->irqmask |= (1 << leon_scmv91111_configuration.pio);
    85       io->irqpol |= (1 << leon_scmv91111_configuration.pio);
    86       io->irqedge |= (1 << leon_scmv91111_configuration.pio);
    87       io->iodir &= ~(1 << leon_scmv91111_configuration.pio);
    88     } else {
     36  amba_apb_device apbpio, apbmctrl;
     37 
     38  if ( amba_find_ahbslv(&amba_conf,VENDOR_GAISLER,GAISLER_PIOPORT,&apbpio) != 1 ){
     39    printk("SMC9111_leon3: didn't find PIO\n");
     40    return 0;
     41  }
     42 
     43  /* Find LEON2 memory controller */
     44  if ( amba_find_ahbslv(&amba_conf,VENDOR_ESA,ESA_MCTRL,&apbmctrl) != 1 ){
     45    /* LEON2 memory controller not found, search for fault tolerant memory controller */
     46    if ( amba_find_ahbslv(&amba_conf,VENDOR_GAISLER,GAISLER_FTMCTRL,&apbmctrl) != 1 ) {
     47      printk("SMC9111_leon3: didn't find any memory controller\n");
    8948      return 0;
    9049    }
    9150  }
    9251 
    93   return _rtems_smc91111_driver_attach(config,&leon_scmv91111_configuration);
     52  /* Get  controller address */
     53  addr_mctrl = (unsigned long) apbmctrl.start;
     54  io = (LEON3_IOPORT_Regs_Map *) apbpio.start;
     55 
     56  printk(
     57        "Activating Leon3 io port for smsc_lan91cxx (pio:%x mctrl:%x)\n",
     58        (unsigned int)io,
     59        (unsigned int)addr_mctrl);
     60 
     61  /* Setup PIO IRQ */
     62  io->irqmask |= (1 << leon_scmv91111_configuration.pio);
     63  io->irqpol |= (1 << leon_scmv91111_configuration.pio);
     64  io->irqedge |= (1 << leon_scmv91111_configuration.pio);
     65  io->iodir &= ~(1 << leon_scmv91111_configuration.pio);
     66
     67  /* Setup memory controller I/O waitstates */
     68  *((volatile unsigned int *) addr_mctrl) |= 0x10f80000;        /* enable I/O area access */
     69
     70    return _rtems_smc91111_driver_attach (config,
     71            &leon_scmv91111_configuration);
    9472};
    95 
Note: See TracChangeset for help on using the changeset viewer.