forked from Imagelibrary/rtems
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@gaisler.com>
This commit is contained in:
committed by
Gedare Bloom
parent
ddf0d60758
commit
fc6f872d3f
@@ -31,17 +31,19 @@ int rtems_leon_greth_driver_attach(
|
|||||||
int attach
|
int attach
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
int device_found = 0;
|
|
||||||
unsigned int base_addr = 0; /* avoid warnings */
|
unsigned int base_addr = 0; /* avoid warnings */
|
||||||
unsigned int eth_irq = 0; /* avoid warnings */
|
unsigned int eth_irq = 0; /* avoid warnings */
|
||||||
amba_apb_device apbgreth;
|
struct ambapp_dev *adev;
|
||||||
|
struct ambapp_apb_info *apb;
|
||||||
|
|
||||||
/* Scan for MAC AHB slave interface */
|
/* Scan for MAC AHB slave interface */
|
||||||
device_found = amba_find_apbslv(&amba_conf,VENDOR_GAISLER,GAISLER_ETHMAC,&apbgreth);
|
adev = (void *)ambapp_for_each(&ambapp_plb, (OPTIONS_ALL|OPTIONS_APB_SLVS),
|
||||||
if (device_found == 1)
|
VENDOR_GAISLER, GAISLER_ETHMAC,
|
||||||
{
|
ambapp_find_by_idx, NULL);
|
||||||
base_addr = apbgreth.start;
|
if (adev) {
|
||||||
eth_irq = apbgreth.irq;
|
apb = DEV_TO_APB(adev);
|
||||||
|
base_addr = apb->start;
|
||||||
|
eth_irq = apb->irq;
|
||||||
|
|
||||||
/* clear control register and reset NIC */
|
/* clear control register and reset NIC */
|
||||||
*(volatile int *) base_addr = 0;
|
*(volatile int *) base_addr = 0;
|
||||||
|
|||||||
@@ -31,31 +31,27 @@ int rtems_leon_open_eth_driver_attach(
|
|||||||
int attach
|
int attach
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
int device_found = 0;
|
|
||||||
int i;
|
|
||||||
unsigned int conf, iobar;
|
|
||||||
unsigned int base_addr = 0; /* avoid warnings */
|
unsigned int base_addr = 0; /* avoid warnings */
|
||||||
unsigned int eth_irq = 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 */
|
/* Scan for MAC AHB slave interface */
|
||||||
for (i = 0; i < amba_conf.ahbslv.devnr; i++)
|
adev = (void *)ambapp_for_each(&ambapp_plb, (OPTIONS_ALL|OPTIONS_AHB_SLVS),
|
||||||
{
|
VENDOR_OPENCORES, OPENCORES_ETHMAC,
|
||||||
conf = amba_get_confword(amba_conf.ahbslv, i, 0);
|
ambapp_find_by_idx, NULL);
|
||||||
if (((amba_vendor(conf) == VENDOR_OPENCORES) && (amba_device(conf) == OPENCORES_ETHMAC)) ||
|
if (!adev) {
|
||||||
((amba_vendor(conf) == VENDOR_GAISLER) && (amba_device(conf) == GAISLER_ETHAHB)))
|
adev = (void *)ambapp_for_each(&ambapp_plb, (OPTIONS_ALL|OPTIONS_AHB_SLVS),
|
||||||
{
|
VENDOR_GAISLER, GAISLER_ETHAHB,
|
||||||
iobar = amba_ahb_get_membar(amba_conf.ahbslv, i, 0);
|
ambapp_find_by_idx, NULL);
|
||||||
base_addr = amba_iobar_start(LEON3_IO_AREA, iobar);
|
|
||||||
eth_irq = amba_irq(conf);
|
|
||||||
device_found = 1;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (adev)
|
||||||
if (device_found)
|
|
||||||
{
|
{
|
||||||
|
ahb = DEV_TO_AHB(adev);
|
||||||
|
base_addr = ahb->start[0];
|
||||||
|
eth_irq = ahb->irq;
|
||||||
|
|
||||||
/* clear control register and reset NIC */
|
/* clear control register and reset NIC */
|
||||||
*(volatile int *) base_addr = 0;
|
*(volatile int *) base_addr = 0;
|
||||||
*(volatile int *) base_addr = 0x800;
|
*(volatile int *) base_addr = 0x800;
|
||||||
@@ -65,7 +61,8 @@ int rtems_leon_open_eth_driver_attach(
|
|||||||
leon_open_eth_configuration.txd_count = TDA_COUNT;
|
leon_open_eth_configuration.txd_count = TDA_COUNT;
|
||||||
leon_open_eth_configuration.rxd_count = RDA_COUNT;
|
leon_open_eth_configuration.rxd_count = RDA_COUNT;
|
||||||
/* enable 100 MHz operation only if cpu frequency >= 50 MHz */
|
/* enable 100 MHz operation only if cpu frequency >= 50 MHz */
|
||||||
if (LEON3_Timer_Regs->scaler_reload >= 49) leon_open_eth_configuration.en100MHz = 1;
|
if (LEON3_Timer_Regs->scaler_reload >= 49)
|
||||||
|
leon_open_eth_configuration.en100MHz = 1;
|
||||||
if (rtems_open_eth_driver_attach( config, &leon_open_eth_configuration )) {
|
if (rtems_open_eth_driver_attach( config, &leon_open_eth_configuration )) {
|
||||||
LEON_Clear_interrupt(eth_irq);
|
LEON_Clear_interrupt(eth_irq);
|
||||||
LEON_Unmask_interrupt(eth_irq);
|
LEON_Unmask_interrupt(eth_irq);
|
||||||
|
|||||||
@@ -1,11 +1,14 @@
|
|||||||
/*
|
/* LEON3 BSP SMC91111 registration and low-level initialization
|
||||||
* $Id$
|
*
|
||||||
|
* The license and distribution terms for this file may be
|
||||||
|
* found in the file LICENSE in this distribution or at
|
||||||
|
* http://www.rtems.com/license/LICENSE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <bsp.h>
|
#include <bsp.h>
|
||||||
#include <libchip/smc91111exp.h>
|
#include <libchip/smc91111exp.h>
|
||||||
#include <rtems/bspIo.h>
|
#include <rtems/bspIo.h>
|
||||||
|
#include <ambapp.h>
|
||||||
|
|
||||||
#define SMC91111_BASE_ADDR (void*)0x20000300
|
#define SMC91111_BASE_ADDR (void*)0x20000300
|
||||||
#define SMC91111_BASE_IRQ 4
|
#define SMC91111_BASE_IRQ 4
|
||||||
@@ -32,23 +35,31 @@ rtems_smc91111_driver_attach_leon3 (struct rtems_bsdnet_ifconfig *config,
|
|||||||
{
|
{
|
||||||
unsigned long addr_mctrl = 0;
|
unsigned long addr_mctrl = 0;
|
||||||
LEON3_IOPORT_Regs_Map *io;
|
LEON3_IOPORT_Regs_Map *io;
|
||||||
|
struct ambapp_apb_info apbpio;
|
||||||
|
struct ambapp_apb_info apbmctrl;
|
||||||
|
|
||||||
amba_apb_device apbpio;
|
if (ambapp_find_apbslv(&ambapp_plb, VENDOR_GAISLER, GAISLER_GPIO, &apbpio)
|
||||||
amba_ahb_device apbmctrl;
|
!= 1) {
|
||||||
|
|
||||||
if ( amba_find_apbslv(&amba_conf,VENDOR_GAISLER,GAISLER_PIOPORT,&apbpio) != 1 ){
|
|
||||||
printk("SMC9111_leon3: didn't find PIO\n");
|
printk("SMC9111_leon3: didn't find PIO\n");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Find LEON2 memory controller */
|
/* In order to access the SMC controller the memory controller must have
|
||||||
if ( amba_find_ahbslv(&amba_conf,VENDOR_ESA,ESA_MCTRL,&apbmctrl) != 1 ){
|
* I/O bus enabled. Find first memory controller.
|
||||||
/* LEON2 memory controller not found, search for fault tolerant memory controller */
|
*/
|
||||||
if ( amba_find_ahbslv(&amba_conf,VENDOR_GAISLER,GAISLER_FTMCTRL,&apbmctrl) != 1 ) {
|
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");
|
printk("SMC9111_leon3: didn't find any memory controller\n");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* Get controller address */
|
/* Get controller address */
|
||||||
addr_mctrl = (unsigned long) apbmctrl.start;
|
addr_mctrl = (unsigned long) apbmctrl.start;
|
||||||
@@ -68,6 +79,5 @@ rtems_smc91111_driver_attach_leon3 (struct rtems_bsdnet_ifconfig *config,
|
|||||||
/* Setup memory controller I/O waitstates */
|
/* Setup memory controller I/O waitstates */
|
||||||
*((volatile unsigned int *) addr_mctrl) |= 0x10f80000; /* enable I/O area access */
|
*((volatile unsigned int *) addr_mctrl) |= 0x10f80000; /* enable I/O area access */
|
||||||
|
|
||||||
return _rtems_smc91111_driver_attach (config,
|
return _rtems_smc91111_driver_attach(config, &leon_scmv91111_configuration);
|
||||||
&leon_scmv91111_configuration);
|
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user