Changeset 921bb59 in rtems


Ignore:
Timestamp:
Sep 6, 2007, 12:07:44 AM (12 years ago)
Author:
Joel Sherrill <joel.sherrill@…>
Branches:
4.10, 4.11, 4.8, 4.9, 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.
Location:
c/src/lib/libbsp/sparc/leon3
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • c/src/lib/libbsp/sparc/leon3/ChangeLog

    r3d0d969 r921bb59  
     12007-09-05      Daniel Hellstrom <daniel@gaisler.com>
     2
     3        * clock/ckinit.c, console/console.c, leon_greth/leon_greth.c,
     4        leon_smc91111/leon_smc91111.c: LEON3 BSP drivers updated to use new
     5        AMBA PnP scanning functions. Affected drivers:
     6        amba/amba.c,clock/ckinit.c,console/console.c,
     7        leon_greth/leon_greth.c, leon_smc9111.c.
     8
    192007-09-05      Daniel Hellstrom <daniel@gaisler.com>
    210
  • c/src/lib/libbsp/sparc/leon3/clock/ckinit.c

    r3d0d969 r921bb59  
    4545
    4646#define Clock_driver_support_find_timer() \
    47   do {  \
    48     int i; \
    49     unsigned int iobar, conf; \
     47  do { \
     48    int cnt; \
     49    amba_apb_device dev; \
    5050    \
    51     /* Find GP Timer */ \
    52     i = 0; \
    53     while (i < amba_conf.apbslv.devnr) { \
    54       conf = amba_get_confword(amba_conf.apbslv, i, 0); \
    55       if ((amba_vendor(conf) == VENDOR_GAISLER) && \
    56           (amba_device(conf) == GAISLER_GPTIMER)) { \
    57         iobar = amba_apb_get_membar(amba_conf.apbslv, i);       \
    58         LEON3_Timer_Regs = (volatile LEON3_Timer_Regs_Map *) \
    59            amba_iobar_start(amba_conf.apbmst, iobar); \
    60         break; \
     51    /* Find LEON3 Interrupt controler */ \
     52    cnt = amba_find_apbslv(&amba_conf,VENDOR_GAISLER,GAISLER_IRQMP,&dev); \
     53    if ( cnt > 0 ){ \
     54      /* Found APB IRQ_MP Interrupt Controller */ \
     55      LEON3_IrqCtrl_Regs = (volatile LEON3_IrqCtrl_Regs_Map *) dev.start; \
     56      clkirq = (LEON3_Timer_Regs->status & 0xfc) >> 3; \
     57      \
     58      if (Configuration.User_multiprocessing_table != NULL) { \
     59        clkirq += LEON3_Cpu_Index; \
    6160      } \
    62       i++; \
    63     } \
    64     \
    65     clkirq = (LEON3_Timer_Regs->status & 0xfc) >> 3; \
    66     \
    67     /* MP */ \
    68     if (Configuration.User_multiprocessing_table != NULL) { \
    69       clkirq += LEON3_Cpu_Index; \
    7061    } \
    7162  } while (0)
  • c/src/lib/libbsp/sparc/leon3/console/console.c

    r3d0d969 r921bb59  
    2323#include <assert.h>
    2424#include <rtems/bspIo.h>
     25#include <amba.h>
    2526
    2627/*
     
    8687 *
    8788 */
    88 
    89 volatile LEON3_UART_Regs_Map *LEON3_Console_Uart[LEON3_APBUARTS]; 
     89int uarts = 0;
     90static int isinit = 0;
     91volatile LEON3_UART_Regs_Map *LEON3_Console_Uart[LEON3_APBUARTS];
     92
     93int scan_uarts() {     
     94  unsigned int iobar, conf;
     95  int i;
     96        amba_apb_device apbuarts[LEON3_APBUARTS];
     97       
     98  if (isinit == 0) {
     99    i = 0; uarts = 0;
     100   
     101    uarts = amba_find_apbslvs(&amba_conf,VENDOR_GAISLER,GAISLER_APBUART,apbuarts,LEON3_APBUARTS);
     102    for(i=0; i<uarts; i++){
     103                        LEON3_Console_Uart[i] = apbuarts[i].start;
     104                }
     105    isinit = 1;
     106  }
     107  return uarts;
     108}
    90109
    91110rtems_device_driver console_initialize(
     
    96115{
    97116  rtems_status_code status;
    98   unsigned int iobar, conf;
    99   int i, uarts;
    100   char *console_name = "/dev/console_a";
    101 
     117  int i, uart0;
     118  char console_name[16];
     119  extern rtems_configuration_table Configuration;
    102120
    103121  rtems_termios_initialize();
    104122
    105123  /* Find UARTs */
    106  
    107   i = 0; uarts = 0;
    108   while (i < amba_conf.apbslv.devnr)
    109   {
    110     conf = amba_get_confword(amba_conf.apbslv, i, 0);
    111     if ((amba_vendor(conf) == VENDOR_GAISLER) && (amba_device(conf) == GAISLER_APBUART))
    112     {
    113       iobar = amba_apb_get_membar(amba_conf.apbslv, i);     
    114       LEON3_Console_Uart[uarts] = (volatile LEON3_UART_Regs_Map *) amba_iobar_start(amba_conf.apbmst, iobar);
    115       uarts++;
    116     }
    117     i++;
    118   }
     124  scan_uarts();
     125       
     126  if (Configuration.User_multiprocessing_table != NULL)
     127    uart0 =  LEON3_Cpu_Index;
     128  else
     129    uart0 = 0; 
    119130
    120131  /*  Register Device Names */
    121132 
    122   if (uarts)
     133  if (uarts && (uart0 < uarts))
    123134  { 
    124135    status = rtems_io_register_name( "/dev/console", major, 0 );
     
    126137      rtems_fatal_error_occurred(status);
    127138
    128     for (i = 1; i < uarts; i++)
     139    strcpy(console_name,"/dev/console_a");
     140    for (i = uart0+1; i < uarts; i++)
    129141    {
    130142      console_name[13]++;
     
    137149   *  Initialize Hardware
    138150   */
    139 
    140   for (i = 0; i < uarts; i++)
     151  if ((Configuration.User_multiprocessing_table == NULL) ||
     152      ((Configuration.User_multiprocessing_table)->node == 1))
    141153  {
    142     LEON3_Console_Uart[i]->ctrl |= LEON_REG_UART_CTRL_RE | LEON_REG_UART_CTRL_TE;
    143     LEON3_Console_Uart[i]->status = 0; 
     154    for (i = uart0; i < uarts; i++)
     155    {
     156      LEON3_Console_Uart[i]->ctrl |= LEON_REG_UART_CTRL_RE | LEON_REG_UART_CTRL_TE;
     157      LEON3_Console_Uart[i]->status = 0; 
     158    }
    144159  }
    145160
  • c/src/lib/libbsp/sparc/leon3/leon_greth/leon_greth.c

    r3d0d969 r921bb59  
    3737  unsigned int base_addr = 0; /* avoid warnings */
    3838  unsigned int eth_irq = 0;   /* avoid warnings */
     39        amba_apb_device apbgreth;
    3940
    4041  /* Scan for MAC AHB slave interface */
    41   for (i = 0; i < amba_conf.apbslv.devnr; i++)
     42        device_found = amba_find_apbslv(&amba_conf,VENDOR_GAISLER,GAISLER_ETHMAC,&apbgreth);
     43  if (device_found == 1)
    4244  {
    43     conf = amba_get_confword(amba_conf.apbslv, i, 0);
    44     if ((amba_vendor(conf) == VENDOR_GAISLER) &&
    45         (amba_device(conf) == GAISLER_ETHMAC))
    46     {
    47       iobar = amba_apb_get_membar(amba_conf.apbslv, i);
    48       base_addr = amba_iobar_start(amba_conf.apbmst, iobar);
    49       eth_irq = amba_irq(conf) + 0x10;
    50       device_found = 1;
    51       break;
    52     }
    53   }
    54 
    55   if (device_found)
    56   {
     45                base_addr = apbgreth.start;
     46                eth_irq = apbgreth.irq + 0x10;
     47               
    5748    /* clear control register and reset NIC */
    5849    *(volatile int *) base_addr = 0;
  • 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.