forked from Imagelibrary/rtems
@@ -1,58 +0,0 @@
|
||||
/*
|
||||
* LEON3 Opencores Ethernet MAC Configuration Information
|
||||
*
|
||||
* COPYRIGHT (c) 2004.
|
||||
* Gaisler Research
|
||||
*
|
||||
* The license and distribution terms for this file may be
|
||||
* found in the file LICENSE in this distribution or at
|
||||
* http://www.rtems.org/license/LICENSE.
|
||||
*/
|
||||
|
||||
#include <machine/rtems-bsd-kernel-space.h>
|
||||
|
||||
#include <bsp.h>
|
||||
#include <libchip/greth.h>
|
||||
/*#if (GRETH_DEBUG & GRETH_DEBUG_PRINT_REGISTERS)*/
|
||||
#include <stdio.h>
|
||||
/*#endif*/
|
||||
|
||||
/*
|
||||
* Default sizes of transmit and receive descriptor areas
|
||||
*/
|
||||
#define RDA_COUNT 32
|
||||
#define TDA_COUNT 32
|
||||
|
||||
greth_configuration_t leon_greth_configuration;
|
||||
|
||||
int rtems_leon_greth_driver_attach(
|
||||
struct rtems_bsdnet_ifconfig *config,
|
||||
int attach
|
||||
)
|
||||
{
|
||||
unsigned int base_addr = 0; /* avoid warnings */
|
||||
unsigned int eth_irq = 0; /* avoid warnings */
|
||||
struct ambapp_dev *adev;
|
||||
struct ambapp_apb_info *apb;
|
||||
|
||||
/* Scan for MAC AHB slave interface */
|
||||
adev = (void *)ambapp_for_each(&ambapp_plb, (OPTIONS_ALL|OPTIONS_APB_SLVS),
|
||||
VENDOR_GAISLER, GAISLER_ETHMAC,
|
||||
ambapp_find_by_idx, NULL);
|
||||
if (adev) {
|
||||
apb = DEV_TO_APB(adev);
|
||||
base_addr = apb->start;
|
||||
eth_irq = apb->common.irq;
|
||||
|
||||
/* clear control register and reset NIC */
|
||||
*(volatile int *) base_addr = 0;
|
||||
*(volatile int *) base_addr = GRETH_CTRL_RST;
|
||||
*(volatile int *) base_addr = 0;
|
||||
leon_greth_configuration.base_address = (void*)base_addr;
|
||||
leon_greth_configuration.vector = eth_irq; /* on LEON vector is IRQ no. */
|
||||
leon_greth_configuration.txd_count = TDA_COUNT;
|
||||
leon_greth_configuration.rxd_count = RDA_COUNT;
|
||||
rtems_greth_driver_attach(config, &leon_greth_configuration);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@@ -1,75 +0,0 @@
|
||||
/**
|
||||
* @file
|
||||
* @ingroup sparc_leon3
|
||||
* @brief LEON3 Opencores Ethernet MAC Configuration Information
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2004.
|
||||
* Aeroflex Gaisler AB.
|
||||
*
|
||||
* The license and distribution terms for this file may be
|
||||
* found in the file LICENSE in this distribution or at
|
||||
* http://www.rtems.org/license/LICENSE.
|
||||
*/
|
||||
|
||||
#include <machine/rtems-bsd-kernel-space.h>
|
||||
|
||||
#include <bsp.h>
|
||||
#include <libchip/open_eth.h>
|
||||
#if (OPEN_ETH_DEBUG & OPEN_ETH_DEBUG_PRINT_REGISTERS)
|
||||
#include <stdio.h>
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Default sizes of transmit and receive descriptor areas
|
||||
*/
|
||||
#define RDA_COUNT 16
|
||||
#define TDA_COUNT 16
|
||||
|
||||
open_eth_configuration_t leon_open_eth_configuration;
|
||||
|
||||
int rtems_leon_open_eth_driver_attach(
|
||||
struct rtems_bsdnet_ifconfig *config,
|
||||
int attach
|
||||
)
|
||||
{
|
||||
unsigned int base_addr = 0; /* avoid warnings */
|
||||
unsigned int eth_irq = 0; /* avoid warnings */
|
||||
struct ambapp_dev *adev;
|
||||
struct ambapp_ahb_info *ahb;
|
||||
|
||||
/* Scan for MAC AHB slave interface */
|
||||
adev = (void *)ambapp_for_each(&ambapp_plb, (OPTIONS_ALL|OPTIONS_AHB_SLVS),
|
||||
VENDOR_OPENCORES, OPENCORES_ETHMAC,
|
||||
ambapp_find_by_idx, NULL);
|
||||
if (!adev) {
|
||||
adev = (void *)ambapp_for_each(&ambapp_plb, (OPTIONS_ALL|OPTIONS_AHB_SLVS),
|
||||
VENDOR_GAISLER, GAISLER_ETHAHB,
|
||||
ambapp_find_by_idx, NULL);
|
||||
}
|
||||
|
||||
if (adev)
|
||||
{
|
||||
ahb = DEV_TO_AHB(adev);
|
||||
base_addr = ahb->start[0];
|
||||
eth_irq = ahb->common.irq;
|
||||
|
||||
/* clear control register and reset NIC */
|
||||
*(volatile int *) base_addr = 0;
|
||||
*(volatile int *) base_addr = 0x800;
|
||||
*(volatile int *) base_addr = 0;
|
||||
leon_open_eth_configuration.base_address = (void *) base_addr;
|
||||
leon_open_eth_configuration.vector = eth_irq + 0x10;
|
||||
leon_open_eth_configuration.txd_count = TDA_COUNT;
|
||||
leon_open_eth_configuration.rxd_count = RDA_COUNT;
|
||||
/* enable 100 MHz operation only if cpu frequency >= 50 MHz */
|
||||
if (LEON3_Timer_Regs->scaler_reload >= 49)
|
||||
leon_open_eth_configuration.en100MHz = 1;
|
||||
if (rtems_open_eth_driver_attach( config, &leon_open_eth_configuration )) {
|
||||
LEON_Clear_interrupt(eth_irq);
|
||||
LEON_Unmask_interrupt(eth_irq);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@@ -1,89 +0,0 @@
|
||||
/**
|
||||
* @file
|
||||
* @ingroup sparc_leon3
|
||||
* @brief LEON3 BSP SMC91111 registration and low-level initialization
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2006.
|
||||
* Aeroflex Gaisler AB.
|
||||
*
|
||||
* The license and distribution terms for this file may be
|
||||
* found in the file LICENSE in this distribution or at
|
||||
* http://www.rtems.org/license/LICENSE.
|
||||
*/
|
||||
|
||||
#include <machine/rtems-bsd-kernel-space.h>
|
||||
|
||||
#include <bsp.h>
|
||||
#include <libchip/smc91111exp.h>
|
||||
#include <rtems/bspIo.h>
|
||||
#include <grlib/ambapp.h>
|
||||
|
||||
#define SMC91111_BASE_ADDR (void*)0x20000300
|
||||
#define SMC91111_BASE_IRQ 4
|
||||
#define SMC91111_BASE_PIO 4
|
||||
|
||||
scmv91111_configuration_t leon_scmv91111_configuration = {
|
||||
SMC91111_BASE_ADDR, /* base address */
|
||||
SMC91111_BASE_IRQ, /* IRQ number (on LEON vector is irq) */
|
||||
SMC91111_BASE_PIO, /* PIO */
|
||||
100, /* 100b */
|
||||
1, /* fulldx */
|
||||
1 /* autoneg */
|
||||
};
|
||||
|
||||
/*
|
||||
* Attach an SMC91111 driver to the system
|
||||
*/
|
||||
int
|
||||
rtems_smc91111_driver_attach_leon3 (struct rtems_bsdnet_ifconfig *config,
|
||||
int attach)
|
||||
{
|
||||
unsigned long addr_mctrl = 0;
|
||||
struct grgpio_regs *io;
|
||||
struct ambapp_apb_info apbpio;
|
||||
struct ambapp_apb_info apbmctrl;
|
||||
|
||||
if (ambapp_find_apbslv(&ambapp_plb, VENDOR_GAISLER, GAISLER_GPIO, &apbpio)
|
||||
!= 1) {
|
||||
printk("SMC9111_leon3: didn't find PIO\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* In order to access the SMC controller the memory controller must have
|
||||
* I/O bus enabled. Find first memory controller.
|
||||
*/
|
||||
if (ambapp_find_apbslv(&ambapp_plb, VENDOR_ESA, ESA_MCTRL, &apbmctrl) != 1) {
|
||||
if (ambapp_find_apbslv(&ambapp_plb, VENDOR_GAISLER, GAISLER_FTMCTRL,
|
||||
&apbmctrl) != 1) {
|
||||
if (ambapp_find_apbslv(&ambapp_plb, VENDOR_GAISLER, GAISLER_FTSRCTRL,
|
||||
&apbmctrl) != 1) {
|
||||
if (ambapp_find_apbslv(&ambapp_plb, VENDOR_GAISLER, GAISLER_FTSRCTRL8,
|
||||
&apbmctrl) != 1) {
|
||||
printk("SMC9111_leon3: didn't find any memory controller\n");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Get controller address */
|
||||
addr_mctrl = (unsigned long) apbmctrl.start;
|
||||
io = (struct grgpio_regs *) apbpio.start;
|
||||
|
||||
printk("Activating Leon3 io port for smsc_lan91cxx (pio:%x mctrl:%x)\n",
|
||||
(unsigned int)io, (unsigned int)addr_mctrl);
|
||||
|
||||
/* Setup PIO IRQ */
|
||||
io->imask |= (1 << leon_scmv91111_configuration.pio);
|
||||
io->ipol |= (1 << leon_scmv91111_configuration.pio);
|
||||
io->iedge |= (1 << leon_scmv91111_configuration.pio);
|
||||
io->dir &= ~(1 << leon_scmv91111_configuration.pio);
|
||||
|
||||
/* Setup memory controller I/O waitstates */
|
||||
*((volatile unsigned int *) addr_mctrl) |=
|
||||
0x10f80000; /* enable I/O area access */
|
||||
|
||||
return _rtems_smc91111_driver_attach(config, &leon_scmv91111_configuration);
|
||||
};
|
||||
Reference in New Issue
Block a user