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> 2007-09-05 Daniel Hellstrom <daniel@gaisler.com>
* include/bsp.h, startup/bspstart.c: LEON2 and LEON3 Data cache * include/bsp.h, startup/bspstart.c: LEON2 and LEON3 Data cache

View File

@@ -45,29 +45,20 @@ static int clkirq;
#define Clock_driver_support_find_timer() \ #define Clock_driver_support_find_timer() \
do { \ do { \
int i; \ int cnt; \
unsigned int iobar, conf; \ 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; \
} \
i++; \
} \
\ \
/* 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; \ clkirq = (LEON3_Timer_Regs->status & 0xfc) >> 3; \
\ \
/* MP */ \
if (Configuration.User_multiprocessing_table != NULL) { \ if (Configuration.User_multiprocessing_table != NULL) { \
clkirq += LEON3_Cpu_Index; \ clkirq += LEON3_Cpu_Index; \
} \ } \
} \
} while (0) } while (0)
#define Clock_driver_support_install_isr( _new, _old ) \ #define Clock_driver_support_install_isr( _new, _old ) \

View File

@@ -22,6 +22,7 @@
#include <stdlib.h> #include <stdlib.h>
#include <assert.h> #include <assert.h>
#include <rtems/bspIo.h> #include <rtems/bspIo.h>
#include <amba.h>
/* /*
* Should we use a polled or interrupt drived console? * Should we use a polled or interrupt drived console?
@@ -85,9 +86,27 @@ int console_write_support (int minor, const char *buf, int len)
* Console Device Driver Entry Points * 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_driver console_initialize(
rtems_device_major_number major, rtems_device_major_number major,
rtems_device_minor_number minor, rtems_device_minor_number minor,
@@ -95,37 +114,30 @@ rtems_device_driver console_initialize(
) )
{ {
rtems_status_code status; rtems_status_code status;
unsigned int iobar, conf; int i, uart0;
int i, uarts; char console_name[16];
char *console_name = "/dev/console_a"; extern rtems_configuration_table Configuration;
rtems_termios_initialize(); rtems_termios_initialize();
/* Find UARTs */ /* Find UARTs */
scan_uarts();
i = 0; uarts = 0; if (Configuration.User_multiprocessing_table != NULL)
while (i < amba_conf.apbslv.devnr) uart0 = LEON3_Cpu_Index;
{ else
conf = amba_get_confword(amba_conf.apbslv, i, 0); uart0 = 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++;
}
/* Register Device Names */ /* Register Device Names */
if (uarts) if (uarts && (uart0 < uarts))
{ {
status = rtems_io_register_name( "/dev/console", major, 0 ); status = rtems_io_register_name( "/dev/console", major, 0 );
if (status != RTEMS_SUCCESSFUL) if (status != RTEMS_SUCCESSFUL)
rtems_fatal_error_occurred(status); 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]++; console_name[13]++;
status = rtems_io_register_name( console_name, major, i); status = rtems_io_register_name( console_name, major, i);
@@ -136,12 +148,15 @@ rtems_device_driver console_initialize(
/* /*
* Initialize Hardware * Initialize Hardware
*/ */
if ((Configuration.User_multiprocessing_table == NULL) ||
for (i = 0; i < uarts; i++) ((Configuration.User_multiprocessing_table)->node == 1))
{
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]->ctrl |= LEON_REG_UART_CTRL_RE | LEON_REG_UART_CTRL_TE;
LEON3_Console_Uart[i]->status = 0; LEON3_Console_Uart[i]->status = 0;
} }
}
return RTEMS_SUCCESSFUL; return RTEMS_SUCCESSFUL;
} }

View File

@@ -36,24 +36,15 @@ int rtems_leon_greth_driver_attach(
unsigned int conf, iobar; 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 */
amba_apb_device apbgreth;
/* Scan for MAC AHB slave interface */ /* Scan for MAC AHB slave interface */
for (i = 0; i < amba_conf.apbslv.devnr; i++) device_found = amba_find_apbslv(&amba_conf,VENDOR_GAISLER,GAISLER_ETHMAC,&apbgreth);
if (device_found == 1)
{ {
conf = amba_get_confword(amba_conf.apbslv, i, 0); base_addr = apbgreth.start;
if ((amba_vendor(conf) == VENDOR_GAISLER) && eth_irq = apbgreth.irq + 0x10;
(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)
{
/* 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 = GRETH_CTRL_RST; *(volatile int *) base_addr = GRETH_CTRL_RST;

View File

@@ -13,83 +13,60 @@
scmv91111_configuration_t leon_scmv91111_configuration = { scmv91111_configuration_t leon_scmv91111_configuration = {
SMC91111_BASE_ADDR, /* base address */ 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 */ SMC91111_BASE_PIO, /* PIO */
10, /* 10b */ 100, /* 100b */
1, /* fulldx */ 1, /* fulldx */
1 /* autoneg */ 1 /* autoneg */
}; };
int _rtems_smc91111_driver_attach( int _rtems_smc91111_driver_attach (struct rtems_bsdnet_ifconfig *config,
struct rtems_bsdnet_ifconfig *config, scmv91111_configuration_t * scm_config);
scmv91111_configuration_t *scm_config
);
/* /*
* Attach an SMC91111 driver to the system * Attach an SMC91111 driver to the system
*/ */
int rtems_smc91111_driver_attach_leon3 ( int
struct rtems_bsdnet_ifconfig *config, rtems_smc91111_driver_attach_leon3 (struct rtems_bsdnet_ifconfig *config,
int attach int attach)
)
{ {
unsigned int iobar, conf,i; unsigned long addr_mctrl = 0;
LEON3_IOPORT_Regs_Map *io;
{ amba_apb_device apbpio, apbmctrl;
unsigned long irq_pio, irq_mctrl, addr_pio = 0;
unsigned long addr_mctrl = 0, addr_timer = 0;
i = 0; if ( amba_find_ahbslv(&amba_conf,VENDOR_GAISLER,GAISLER_PIOPORT,&apbpio) != 1 ){
while (i < amba_conf.apbslv.devnr) printk("SMC9111_leon3: didn't find PIO\n");
{ return 0;
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) { /* Find LEON2 memory controller */
LEON3_Timer_Regs_Map *timer = (LEON3_Timer_Regs_Map *)addr_timer; if ( amba_find_ahbslv(&amba_conf,VENDOR_ESA,ESA_MCTRL,&apbmctrl) != 1 ){
if (timer->scaler_reload >= 49) /* LEON2 memory controller not found, search for fault tolerant memory controller */
leon_scmv91111_configuration.ctl_rspeed = 100; if ( amba_find_ahbslv(&amba_conf,VENDOR_GAISLER,GAISLER_FTMCTRL,&apbmctrl) != 1 ) {
} printk("SMC9111_leon3: didn't find any memory controller\n");
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 {
return 0; 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);
};