source: rtems/bsps/sparc/leon3/net/leon_smc91111.c @ 31720925

5
Last change on this file since 31720925 was 31720925, checked in by Sebastian Huber <sebastian.huber@…>, on 12/22/18 at 06:13:44

grlib: Move header files

Update #3678.

  • Property mode set to 100644
File size: 2.8 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 <machine/rtems-bsd-kernel-space.h>
17
18#include <bsp.h>
19#include <libchip/smc91111exp.h>
20#include <rtems/bspIo.h>
21#include <grlib/ambapp.h>
22
23#define SMC91111_BASE_ADDR (void*)0x20000300
24#define SMC91111_BASE_IRQ  4
25#define SMC91111_BASE_PIO  4
26
27scmv91111_configuration_t leon_scmv91111_configuration = {
28  SMC91111_BASE_ADDR,                 /* base address */
29  SMC91111_BASE_IRQ,                  /* IRQ number (on LEON vector is irq) */
30  SMC91111_BASE_PIO,                  /* PIO */
31  100,                                /* 100b */
32  1,                                  /* fulldx */
33  1                                   /* autoneg */
34};
35
36/*
37 * Attach an SMC91111 driver to the system
38 */
39int
40rtems_smc91111_driver_attach_leon3 (struct rtems_bsdnet_ifconfig *config,
41    int attach)
42{
43  unsigned long addr_mctrl = 0;
44  struct grgpio_regs *io;
45  struct ambapp_apb_info apbpio;
46  struct ambapp_apb_info apbmctrl;
47
48  if (ambapp_find_apbslv(&ambapp_plb, VENDOR_GAISLER, GAISLER_GPIO, &apbpio)
49      != 1) {
50    printk("SMC9111_leon3: didn't find PIO\n");
51    return 0;
52  }
53
54  /* In order to access the SMC controller the memory controller must have
55   * I/O bus enabled. Find first memory controller.
56   */
57  if (ambapp_find_apbslv(&ambapp_plb, VENDOR_ESA, ESA_MCTRL, &apbmctrl) != 1) {
58    if (ambapp_find_apbslv(&ambapp_plb, VENDOR_GAISLER, GAISLER_FTMCTRL,
59                           &apbmctrl) != 1) {
60      if (ambapp_find_apbslv(&ambapp_plb, VENDOR_GAISLER, GAISLER_FTSRCTRL,
61                             &apbmctrl) != 1) {
62        if (ambapp_find_apbslv(&ambapp_plb, VENDOR_GAISLER, GAISLER_FTSRCTRL8,
63                               &apbmctrl) != 1) {
64          printk("SMC9111_leon3: didn't find any memory controller\n");
65          return 0;
66        }
67      }
68    }
69  }
70
71  /* Get  controller address */
72  addr_mctrl = (unsigned long) apbmctrl.start;
73  io = (struct grgpio_regs *) apbpio.start;
74
75  printk("Activating Leon3 io port for smsc_lan91cxx (pio:%x mctrl:%x)\n",
76      (unsigned int)io, (unsigned int)addr_mctrl);
77
78  /* Setup PIO IRQ */
79  io->imask |= (1 << leon_scmv91111_configuration.pio);
80  io->ipol |= (1 << leon_scmv91111_configuration.pio);
81  io->iedge |= (1 << leon_scmv91111_configuration.pio);
82  io->dir &= ~(1 << leon_scmv91111_configuration.pio);
83
84  /* Setup memory controller I/O waitstates */
85  *((volatile unsigned int *) addr_mctrl) |=
86      0x10f80000; /* enable I/O area access */
87
88  return _rtems_smc91111_driver_attach(config, &leon_scmv91111_configuration);
89};
Note: See TracBrowser for help on using the repository browser.