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

4.115
Last change on this file since fc6f872 was fc6f872, checked in by Daniel Hellstrom <daniel@…>, on 04/17/12 at 14:25:41

LEON3: Network initialization code updated to new AMBAPP layer

Updated SMC91111, GRETH and open_eth driver registration
code to use new AMBAPP Layer.

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

  • Property mode set to 100644
File size: 2.8 KB
Line 
1/*  LEON3 BSP SMC91111 registration and low-level initialization
2 *
3 *  The license and distribution terms for this file may be
4 *  found in the file LICENSE in this distribution or at
5 *  http://www.rtems.com/license/LICENSE.
6 */
7
8#include <bsp.h>
9#include <libchip/smc91111exp.h>
10#include <rtems/bspIo.h>
11#include <ambapp.h>
12
13#define SMC91111_BASE_ADDR (void*)0x20000300
14#define SMC91111_BASE_IRQ  4
15#define SMC91111_BASE_PIO  4
16
17scmv91111_configuration_t leon_scmv91111_configuration = {
18  SMC91111_BASE_ADDR,                 /* base address */
19  SMC91111_BASE_IRQ,                  /* IRQ number (on LEON vector is irq) */
20  SMC91111_BASE_PIO,                  /* PIO */
21  100,                                /* 100b */
22  1,                                  /* fulldx */
23  1                                   /* autoneg */
24};
25
26int _rtems_smc91111_driver_attach (struct rtems_bsdnet_ifconfig *config,
27                                   scmv91111_configuration_t * scm_config);
28
29/*
30 * Attach an SMC91111 driver to the system
31 */
32int
33rtems_smc91111_driver_attach_leon3 (struct rtems_bsdnet_ifconfig *config,
34                                    int attach)
35{
36  unsigned long addr_mctrl = 0;
37  LEON3_IOPORT_Regs_Map *io;
38  struct ambapp_apb_info apbpio;
39  struct ambapp_apb_info apbmctrl;
40
41  if (ambapp_find_apbslv(&ambapp_plb, VENDOR_GAISLER, GAISLER_GPIO, &apbpio)
42      != 1) {
43    printk("SMC9111_leon3: didn't find PIO\n");
44    return 0;
45  }
46
47  /* In order to access the SMC controller the memory controller must have
48   * I/O bus enabled. Find first memory controller.
49   */
50  if (ambapp_find_apbslv(&ambapp_plb, VENDOR_ESA, ESA_MCTRL, &apbmctrl) != 1) {
51    if (ambapp_find_apbslv(&ambapp_plb, VENDOR_GAISLER, GAISLER_FTMCTRL,
52                           &apbmctrl) != 1) {
53      if (ambapp_find_apbslv(&ambapp_plb, VENDOR_GAISLER, GAISLER_FTSRCTRL,
54                             &apbmctrl) != 1) {
55        if (ambapp_find_apbslv(&ambapp_plb, VENDOR_GAISLER, GAISLER_FTSRCTRL8,
56                               &apbmctrl) != 1) {
57          printk("SMC9111_leon3: didn't find any memory controller\n");
58          return 0;
59        }
60      }
61    }
62  }
63
64  /* Get  controller address */
65  addr_mctrl = (unsigned long) apbmctrl.start;
66  io = (LEON3_IOPORT_Regs_Map *) apbpio.start;
67
68  printk(
69        "Activating Leon3 io port for smsc_lan91cxx (pio:%x mctrl:%x)\n",
70        (unsigned int)io,
71        (unsigned int)addr_mctrl);
72
73  /* Setup PIO IRQ */
74  io->irqmask |= (1 << leon_scmv91111_configuration.pio);
75  io->irqpol |= (1 << leon_scmv91111_configuration.pio);
76  io->irqedge |= (1 << leon_scmv91111_configuration.pio);
77  io->iodir &= ~(1 << leon_scmv91111_configuration.pio);
78
79  /* Setup memory controller I/O waitstates */
80  *((volatile unsigned int *) addr_mctrl) |= 0x10f80000;        /* enable I/O area access */
81
82  return _rtems_smc91111_driver_attach(config, &leon_scmv91111_configuration);
83};
Note: See TracBrowser for help on using the repository browser.