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

4.115
Last change on this file since 9f058fb was 9f058fb, checked in by Daniel Cederman <cederman@…>, on 05/08/14 at 15:08:04

bsps/sparc: Change tabs to spaces.

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