2007-09-05 Daniel Hellstrom <daniel@gaisler.com>

* clock/ckinit.c, console/console.c, leon_greth/leon_greth.c,
	leon_smc91111/leon_smc91111.c: LEON3 BSP drivers updated to use new
	AMBA PnP scanning functions. Affected drivers:
	amba/amba.c,clock/ckinit.c,console/console.c,
	leon_greth/leon_greth.c, leon_smc9111.c.
This commit is contained in:
Joel Sherrill
2007-09-06 00:07:44 +00:00
parent 3d0d969b7a
commit 921bb59a83
5 changed files with 106 additions and 124 deletions

View File

@@ -1,3 +1,11 @@
2007-09-05 Daniel Hellstrom <daniel@gaisler.com>
* clock/ckinit.c, console/console.c, leon_greth/leon_greth.c,
leon_smc91111/leon_smc91111.c: LEON3 BSP drivers updated to use new
AMBA PnP scanning functions. Affected drivers:
amba/amba.c,clock/ckinit.c,console/console.c,
leon_greth/leon_greth.c, leon_smc9111.c.
2007-09-05 Daniel Hellstrom <daniel@gaisler.com>
* include/bsp.h, startup/bspstart.c: LEON2 and LEON3 Data cache

View File

@@ -44,29 +44,20 @@ static int clkirq;
#define Clock_driver_support_at_tick()
#define Clock_driver_support_find_timer() \
do { \
int i; \
unsigned int iobar, conf; \
do { \
int cnt; \
amba_apb_device dev; \
\
/* Find GP Timer */ \
i = 0; \
while (i < amba_conf.apbslv.devnr) { \
conf = amba_get_confword(amba_conf.apbslv, i, 0); \
if ((amba_vendor(conf) == VENDOR_GAISLER) && \
(amba_device(conf) == GAISLER_GPTIMER)) { \
iobar = amba_apb_get_membar(amba_conf.apbslv, i); \
LEON3_Timer_Regs = (volatile LEON3_Timer_Regs_Map *) \
amba_iobar_start(amba_conf.apbmst, iobar); \
break; \
/* Find LEON3 Interrupt controler */ \
cnt = amba_find_apbslv(&amba_conf,VENDOR_GAISLER,GAISLER_IRQMP,&dev); \
if ( cnt > 0 ){ \
/* Found APB IRQ_MP Interrupt Controller */ \
LEON3_IrqCtrl_Regs = (volatile LEON3_IrqCtrl_Regs_Map *) dev.start; \
clkirq = (LEON3_Timer_Regs->status & 0xfc) >> 3; \
\
if (Configuration.User_multiprocessing_table != NULL) { \
clkirq += LEON3_Cpu_Index; \
} \
i++; \
} \
\
clkirq = (LEON3_Timer_Regs->status & 0xfc) >> 3; \
\
/* MP */ \
if (Configuration.User_multiprocessing_table != NULL) { \
clkirq += LEON3_Cpu_Index; \
} \
} while (0)

View File

@@ -22,6 +22,7 @@
#include <stdlib.h>
#include <assert.h>
#include <rtems/bspIo.h>
#include <amba.h>
/*
* Should we use a polled or interrupt drived console?
@@ -85,8 +86,26 @@ int console_write_support (int minor, const char *buf, int len)
* Console Device Driver Entry Points
*
*/
int uarts = 0;
static int isinit = 0;
volatile LEON3_UART_Regs_Map *LEON3_Console_Uart[LEON3_APBUARTS];
volatile LEON3_UART_Regs_Map *LEON3_Console_Uart[LEON3_APBUARTS];
int scan_uarts() {
unsigned int iobar, conf;
int i;
amba_apb_device apbuarts[LEON3_APBUARTS];
if (isinit == 0) {
i = 0; uarts = 0;
uarts = amba_find_apbslvs(&amba_conf,VENDOR_GAISLER,GAISLER_APBUART,apbuarts,LEON3_APBUARTS);
for(i=0; i<uarts; i++){
LEON3_Console_Uart[i] = apbuarts[i].start;
}
isinit = 1;
}
return uarts;
}
rtems_device_driver console_initialize(
rtems_device_major_number major,
@@ -95,37 +114,30 @@ rtems_device_driver console_initialize(
)
{
rtems_status_code status;
unsigned int iobar, conf;
int i, uarts;
char *console_name = "/dev/console_a";
int i, uart0;
char console_name[16];
extern rtems_configuration_table Configuration;
rtems_termios_initialize();
/* Find UARTs */
i = 0; uarts = 0;
while (i < amba_conf.apbslv.devnr)
{
conf = amba_get_confword(amba_conf.apbslv, i, 0);
if ((amba_vendor(conf) == VENDOR_GAISLER) && (amba_device(conf) == GAISLER_APBUART))
{
iobar = amba_apb_get_membar(amba_conf.apbslv, i);
LEON3_Console_Uart[uarts] = (volatile LEON3_UART_Regs_Map *) amba_iobar_start(amba_conf.apbmst, iobar);
uarts++;
}
i++;
}
scan_uarts();
if (Configuration.User_multiprocessing_table != NULL)
uart0 = LEON3_Cpu_Index;
else
uart0 = 0;
/* Register Device Names */
if (uarts)
if (uarts && (uart0 < uarts))
{
status = rtems_io_register_name( "/dev/console", major, 0 );
if (status != RTEMS_SUCCESSFUL)
rtems_fatal_error_occurred(status);
for (i = 1; i < uarts; i++)
strcpy(console_name,"/dev/console_a");
for (i = uart0+1; i < uarts; i++)
{
console_name[13]++;
status = rtems_io_register_name( console_name, major, i);
@@ -136,11 +148,14 @@ rtems_device_driver console_initialize(
/*
* Initialize Hardware
*/
for (i = 0; i < uarts; i++)
if ((Configuration.User_multiprocessing_table == NULL) ||
((Configuration.User_multiprocessing_table)->node == 1))
{
LEON3_Console_Uart[i]->ctrl |= LEON_REG_UART_CTRL_RE | LEON_REG_UART_CTRL_TE;
LEON3_Console_Uart[i]->status = 0;
for (i = uart0; i < uarts; i++)
{
LEON3_Console_Uart[i]->ctrl |= LEON_REG_UART_CTRL_RE | LEON_REG_UART_CTRL_TE;
LEON3_Console_Uart[i]->status = 0;
}
}
return RTEMS_SUCCESSFUL;

View File

@@ -36,24 +36,15 @@ int rtems_leon_greth_driver_attach(
unsigned int conf, iobar;
unsigned int base_addr = 0; /* avoid warnings */
unsigned int eth_irq = 0; /* avoid warnings */
amba_apb_device apbgreth;
/* Scan for MAC AHB slave interface */
for (i = 0; i < amba_conf.apbslv.devnr; i++)
{
conf = amba_get_confword(amba_conf.apbslv, i, 0);
if ((amba_vendor(conf) == VENDOR_GAISLER) &&
(amba_device(conf) == GAISLER_ETHMAC))
{
iobar = amba_apb_get_membar(amba_conf.apbslv, i);
base_addr = amba_iobar_start(amba_conf.apbmst, iobar);
eth_irq = amba_irq(conf) + 0x10;
device_found = 1;
break;
}
}
if (device_found)
device_found = amba_find_apbslv(&amba_conf,VENDOR_GAISLER,GAISLER_ETHMAC,&apbgreth);
if (device_found == 1)
{
base_addr = apbgreth.start;
eth_irq = apbgreth.irq + 0x10;
/* clear control register and reset NIC */
*(volatile int *) base_addr = 0;
*(volatile int *) base_addr = GRETH_CTRL_RST;

View File

@@ -13,83 +13,60 @@
scmv91111_configuration_t leon_scmv91111_configuration = {
SMC91111_BASE_ADDR, /* base address */
LEON_TRAP_TYPE(SMC91111_BASE_IRQ), /* vector number */
LEON_TRAP_TYPE (SMC91111_BASE_IRQ), /* vector number */
SMC91111_BASE_PIO, /* PIO */
10, /* 10b */
100, /* 100b */
1, /* fulldx */
1 /* autoneg */
};
int _rtems_smc91111_driver_attach(
struct rtems_bsdnet_ifconfig *config,
scmv91111_configuration_t *scm_config
);
int _rtems_smc91111_driver_attach (struct rtems_bsdnet_ifconfig *config,
scmv91111_configuration_t * scm_config);
/*
* Attach an SMC91111 driver to the system
*/
int rtems_smc91111_driver_attach_leon3 (
struct rtems_bsdnet_ifconfig *config,
int attach
)
int
rtems_smc91111_driver_attach_leon3 (struct rtems_bsdnet_ifconfig *config,
int attach)
{
unsigned int iobar, conf,i;
unsigned long addr_mctrl = 0;
LEON3_IOPORT_Regs_Map *io;
{
unsigned long irq_pio, irq_mctrl, addr_pio = 0;
unsigned long addr_mctrl = 0, addr_timer = 0;
i = 0;
while (i < amba_conf.apbslv.devnr)
{
conf = amba_get_confword(amba_conf.apbslv, i, 0);
if ((amba_vendor(conf) == VENDOR_GAISLER) &&
(amba_device(conf) == GAISLER_PIOPORT))
{
irq_pio = amba_irq(conf);
iobar = amba_apb_get_membar(amba_conf.apbslv, i);
addr_pio = (unsigned long) amba_iobar_start(amba_conf.apbmst, iobar);
}
else if ((amba_vendor(conf) == VENDOR_ESA) &&
(amba_device(conf) == ESA_MCTRL))
{
irq_mctrl = amba_irq(conf);
iobar = amba_apb_get_membar(amba_conf.apbslv, i);
addr_mctrl = (unsigned long) amba_iobar_start(amba_conf.apbmst, iobar);
}
else if ((amba_vendor(conf) == VENDOR_GAISLER) &&
(amba_device(conf) == GAISLER_GPTIMER))
{
iobar = amba_apb_get_membar(amba_conf.apbslv, i);
addr_timer = (unsigned long) amba_iobar_start(amba_conf.apbmst, iobar);
}
i++;
}
if (addr_timer) {
LEON3_Timer_Regs_Map *timer = (LEON3_Timer_Regs_Map *)addr_timer;
if (timer->scaler_reload >= 49)
leon_scmv91111_configuration.ctl_rspeed = 100;
}
if (addr_pio && addr_mctrl) {
LEON3_IOPORT_Regs_Map *io = (LEON3_IOPORT_Regs_Map *) addr_pio;
printk(
"Activating Leon3 io port for smsc_lan91cxx (pio:%x mctrl:%x)\n",
(unsigned int)addr_pio,
(unsigned int)addr_mctrl);
*((volatile unsigned int *)addr_mctrl) |= 0x10f80000; /*mctrl ctrl 1 */
io->irqmask |= (1 << leon_scmv91111_configuration.pio);
io->irqpol |= (1 << leon_scmv91111_configuration.pio);
io->irqedge |= (1 << leon_scmv91111_configuration.pio);
io->iodir &= ~(1 << leon_scmv91111_configuration.pio);
} else {
amba_apb_device apbpio, apbmctrl;
if ( amba_find_ahbslv(&amba_conf,VENDOR_GAISLER,GAISLER_PIOPORT,&apbpio) != 1 ){
printk("SMC9111_leon3: didn't find PIO\n");
return 0;
}
/* Find LEON2 memory controller */
if ( amba_find_ahbslv(&amba_conf,VENDOR_ESA,ESA_MCTRL,&apbmctrl) != 1 ){
/* LEON2 memory controller not found, search for fault tolerant memory controller */
if ( amba_find_ahbslv(&amba_conf,VENDOR_GAISLER,GAISLER_FTMCTRL,&apbmctrl) != 1 ) {
printk("SMC9111_leon3: didn't find any memory controller\n");
return 0;
}
}
return _rtems_smc91111_driver_attach(config,&leon_scmv91111_configuration);
};
/* Get controller address */
addr_mctrl = (unsigned long) apbmctrl.start;
io = (LEON3_IOPORT_Regs_Map *) 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->irqmask |= (1 << leon_scmv91111_configuration.pio);
io->irqpol |= (1 << leon_scmv91111_configuration.pio);
io->irqedge |= (1 << leon_scmv91111_configuration.pio);
io->iodir &= ~(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);
};