source: rtems/c/src/lib/libbsp/sparc/leon3/leon_smc91111/leon_smc91111.c @ 0f04edd

4.115
Last change on this file since 0f04edd was 0f04edd, checked in by Daniel Hellstrom <daniel@…>, on 04/05/12 at 15:23:16

SMC91111: updated to use shared IRQ service

Signed-off-by: Daniel Hellstrom <daniel@…>

  • Property mode set to 100644
File size: 2.2 KB
Line 
1/*
2 *  $Id$
3 */
4
5#include <bsp.h>
6#include <libchip/smc91111exp.h>
7#include <rtems/bspIo.h>
8
9
10#define SMC91111_BASE_ADDR (void*)0x20000300
11#define SMC91111_BASE_IRQ  4
12#define SMC91111_BASE_PIO  4
13
14scmv91111_configuration_t leon_scmv91111_configuration = {
15  SMC91111_BASE_ADDR,                 /* base address */
16  SMC91111_BASE_IRQ,                  /* IRQ number (on LEON vector is irq) */
17  SMC91111_BASE_PIO,                  /* PIO */
18  100,                                /* 100b */
19  1,                                  /* fulldx */
20  1                                   /* autoneg */
21};
22
23int _rtems_smc91111_driver_attach (struct rtems_bsdnet_ifconfig *config,
24                                   scmv91111_configuration_t * scm_config);
25
26/*
27 * Attach an SMC91111 driver to the system
28 */
29int
30rtems_smc91111_driver_attach_leon3 (struct rtems_bsdnet_ifconfig *config,
31                                    int attach)
32{
33  unsigned long addr_mctrl = 0;
34  LEON3_IOPORT_Regs_Map *io;
35
36  amba_apb_device apbpio;
37  amba_ahb_device apbmctrl;
38
39  if ( amba_find_apbslv(&amba_conf,VENDOR_GAISLER,GAISLER_PIOPORT,&apbpio) != 1 ){
40    printk("SMC9111_leon3: didn't find PIO\n");
41    return 0;
42  }
43
44  /* Find LEON2 memory controller */
45  if ( amba_find_ahbslv(&amba_conf,VENDOR_ESA,ESA_MCTRL,&apbmctrl) != 1 ){
46    /* LEON2 memory controller not found, search for fault tolerant memory controller */
47    if ( amba_find_ahbslv(&amba_conf,VENDOR_GAISLER,GAISLER_FTMCTRL,&apbmctrl) != 1 ) {
48      printk("SMC9111_leon3: didn't find any memory controller\n");
49      return 0;
50    }
51  }
52
53  /* Get  controller address */
54  addr_mctrl = (unsigned long) apbmctrl.start;
55  io = (LEON3_IOPORT_Regs_Map *) apbpio.start;
56
57  printk(
58        "Activating Leon3 io port for smsc_lan91cxx (pio:%x mctrl:%x)\n",
59        (unsigned int)io,
60        (unsigned int)addr_mctrl);
61
62  /* Setup PIO IRQ */
63  io->irqmask |= (1 << leon_scmv91111_configuration.pio);
64  io->irqpol |= (1 << leon_scmv91111_configuration.pio);
65  io->irqedge |= (1 << leon_scmv91111_configuration.pio);
66  io->iodir &= ~(1 << leon_scmv91111_configuration.pio);
67
68  /* Setup memory controller I/O waitstates */
69  *((volatile unsigned int *) addr_mctrl) |= 0x10f80000;        /* enable I/O area access */
70
71    return _rtems_smc91111_driver_attach (config,
72            &leon_scmv91111_configuration);
73};
Note: See TracBrowser for help on using the repository browser.