LEON: moved register definitions into grlib header file

Some register layout definitions for LEON3 reside in ambapp.h which
does not really has anything to do with device registers. The
register structures has been incorrectly named LEON3_*, the cores
are not only used on LEON3 but on LEON4 and perhaps on LEON5 when
that day comes. Some structures has been renamed according to the
GRLIB core name instead, which CPU that actually use it is not
relevant. Drivers has been updated with the new names.

Signed-off-by: Daniel Hellstrom <daniel@gaisler.com>
This commit is contained in:
Daniel Hellstrom
2012-05-16 17:20:35 +02:00
committed by Gedare Bloom
parent ca764e66ea
commit 226d48d826
21 changed files with 153 additions and 134 deletions

View File

@@ -44,6 +44,7 @@ libbsp_a_SOURCES += gnatsupp/gnatsupp.c ../../sparc/shared/gnatcommon.c
include_HEADERS += include/amba.h
include_HEADERS += ../../sparc/shared/include/ambapp.h
include_HEADERS += ../../sparc/shared/include/ambapp_ids.h
include_HEADERS += ../../sparc/shared/include/grlib.h
libbsp_a_SOURCES += amba/amba.c
libbsp_a_SOURCES += ../../sparc/shared/amba/ambapp.c
libbsp_a_SOURCES += ../../sparc/shared/amba/ambapp_alloc.c

View File

@@ -25,7 +25,7 @@ struct ambapp_bus ambapp_plb;
extern void leon3_ext_irq_init(void);
/* Pointers to Interrupt Controller configuration registers */
volatile LEON3_IrqCtrl_Regs_Map *LEON3_IrqCtrl_Regs;
volatile struct irqmp_regs *LEON3_IrqCtrl_Regs;
/*
* amba_initialize
@@ -61,8 +61,7 @@ void amba_initialize(void)
asm volatile( "mov 1, %g1; ta 0x0" );
}
LEON3_IrqCtrl_Regs = (volatile LEON3_IrqCtrl_Regs_Map *)
DEV_TO_APB(adev)->start;
LEON3_IrqCtrl_Regs = (volatile struct irqmp_regs *)DEV_TO_APB(adev)->start;
if ((LEON3_IrqCtrl_Regs->ampctrl >> 28) > 0) {
/* IRQ Controller has support for multiple IRQ Controllers, each
* CPU can be routed to different Controllers, we find out which
@@ -85,7 +84,7 @@ void amba_initialize(void)
VENDOR_GAISLER, GAISLER_GPTIMER,
ambapp_find_by_idx, NULL);
if (adev) {
LEON3_Timer_Regs = (volatile LEON3_Timer_Regs_Map *)DEV_TO_APB(adev)->start;
LEON3_Timer_Regs = (volatile struct gptimer_regs *)DEV_TO_APB(adev)->start;
/* Register AMBA Bus Frequency */
ambapp_freq_init(&ambapp_plb, adev,

View File

@@ -38,7 +38,7 @@
#endif
volatile LEON3_Timer_Regs_Map *LEON3_Timer_Regs = 0;
volatile struct gptimer_regs *LEON3_Timer_Regs = 0;
static int clkirq;
#define CLOCK_VECTOR LEON_TRAP_TYPE( clkirq )
@@ -65,9 +65,9 @@ static int clkirq;
VENDOR_GAISLER, GAISLER_GPTIMER, ambapp_find_by_idx, NULL); \
if (adev) { \
/* Found APB GPTIMER Timer */ \
LEON3_Timer_Regs = (volatile LEON3_Timer_Regs_Map *) \
LEON3_Timer_Regs = (volatile struct gptimer_regs *) \
DEV_TO_APB(adev)->start; \
clkirq = (LEON3_Timer_Regs->status & 0xf8) >> 3; \
clkirq = (LEON3_Timer_Regs->cfg & 0xf8) >> 3; \
\
Adjust_clkirq_for_node(); \
} \
@@ -83,7 +83,7 @@ static int clkirq;
LEON3_Timer_Regs->timer[LEON3_CLOCK_INDEX].reload = \
rtems_configuration_get_microseconds_per_tick() - 1; \
\
LEON3_Timer_Regs->timer[LEON3_CLOCK_INDEX].conf = \
LEON3_Timer_Regs->timer[LEON3_CLOCK_INDEX].ctrl = \
LEON3_GPTIMER_EN | LEON3_GPTIMER_RL | \
LEON3_GPTIMER_LD | LEON3_GPTIMER_IRQEN; \
} while (0)
@@ -91,7 +91,7 @@ static int clkirq;
#define Clock_driver_support_shutdown_hardware() \
do { \
LEON_Mask_interrupt(LEON_TRAP_TYPE(clkirq)); \
LEON3_Timer_Regs->timer[LEON3_CLOCK_INDEX].conf = 0; \
LEON3_Timer_Regs->timer[LEON3_CLOCK_INDEX].ctrl = 0; \
} while (0)
uint32_t bsp_clock_nanoseconds_since_last_tick(void)

View File

@@ -49,14 +49,14 @@ int syscon_uart_index __attribute__((weak)) = 0;
*/
extern void apbuart_outbyte_polled(
ambapp_apb_uart *regs,
struct apbuart_regs *regs,
unsigned char ch,
int do_cr_on_newline,
int wait_sent
);
/* body is in debugputs.c */
/* body is in printk_support.c */
/*
* apbuart_inbyte_nonblocking
@@ -64,12 +64,12 @@ extern void apbuart_outbyte_polled(
* This routine polls for a character.
*/
extern int apbuart_inbyte_nonblocking(ambapp_apb_uart *regs);
extern int apbuart_inbyte_nonblocking(struct apbuart_regs *regs);
/* body is in debugputs.c */
struct apbuart_priv {
ambapp_apb_uart *regs;
struct apbuart_regs *regs;
unsigned int freq_hz;
#if CONSOLE_USE_INTERRUPTS
int irq;
@@ -252,7 +252,7 @@ int find_matching_apbuart(struct ambapp_dev *dev, int index, void *arg)
struct ambapp_apb_info *apb = (struct ambapp_apb_info *)dev->devinfo;
/* Extract needed information of one APBUART */
apbuarts[uarts].regs = (ambapp_apb_uart *)apb->start;
apbuarts[uarts].regs = (struct apbuart_regs *)apb->start;
#if CONSOLE_USE_INTERRUPTS
apbuarts[uarts].irq = apb->irq;
#endif

View File

@@ -29,7 +29,7 @@
* ...
*/
int debug_uart_index __attribute__((weak)) = 0;
ambapp_apb_uart *dbg_uart = NULL;
struct apbuart_regs *dbg_uart = NULL;
/* Before UART driver has registered (or when no UART is available), calls to
* printk that gets to bsp_out_char() will be filling data into the
@@ -74,7 +74,7 @@ int bsp_debug_uart_init(void)
* for printk
*/
apb = (struct ambapp_apb_info *)adev->devinfo;
dbg_uart = (ambapp_apb_uart *)apb->start;
dbg_uart = (struct apbuart_regs *)apb->start;
dbg_uart->ctrl |= LEON_REG_UART_CTRL_RE | LEON_REG_UART_CTRL_TE;
dbg_uart->status = 0;
return 1;
@@ -88,7 +88,7 @@ int bsp_debug_uart_init(void)
* This routine transmits a character using polling.
*/
void apbuart_outbyte_polled(
ambapp_apb_uart *regs,
struct apbuart_regs *regs,
unsigned char ch,
int do_cr_on_newline,
int wait_sent
@@ -121,7 +121,7 @@ send:
*
* This routine polls for a character.
*/
int apbuart_inbyte_nonblocking(ambapp_apb_uart *regs)
int apbuart_inbyte_nonblocking(struct apbuart_regs *regs)
{
/* Clear errors */
if (regs->status & LEON_REG_UART_STATUS_ERR)

View File

@@ -25,6 +25,7 @@
#define LEON3_APB_SLAVES 16
#include <ambapp.h>
#include <grlib.h>
#ifdef __cplusplus
extern "C" {

View File

@@ -44,30 +44,6 @@ extern "C" {
( (_trap) >= 0x11 && \
(_trap) <= 0x1F )
typedef struct {
volatile unsigned int value;
volatile unsigned int reload;
volatile unsigned int conf;
volatile unsigned int notused;
} LEON3_Timer_SubType;
typedef struct {
volatile unsigned int scaler_value; /* common timer registers */
volatile unsigned int scaler_reload;
volatile unsigned int status;
volatile unsigned int notused;
LEON3_Timer_SubType timer[8];
} LEON3_Timer_Regs_Map;
typedef struct {
volatile unsigned int iodata;
volatile unsigned int ioout;
volatile unsigned int iodir;
volatile unsigned int irqmask;
volatile unsigned int irqpol;
volatile unsigned int irqedge;
} LEON3_IOPORT_Regs_Map;
/* /\* */
/* * This is used to manipulate the on-chip registers. */
/* * */
@@ -137,8 +113,8 @@ typedef struct {
#define LEON_REG_UART_CTRL_FL 0x00000040 /* Flow control enable */
#define LEON_REG_UART_CTRL_LB 0x00000080 /* Loop Back enable */
extern volatile LEON3_IrqCtrl_Regs_Map *LEON3_IrqCtrl_Regs; /* LEON3 Interrupt Controller */
extern volatile LEON3_Timer_Regs_Map *LEON3_Timer_Regs; /* LEON3 GP Timer */
extern volatile struct irqmp_regs *LEON3_IrqCtrl_Regs; /* LEON3 Interrupt Controller */
extern volatile struct gptimer_regs *LEON3_Timer_Regs; /* LEON3 GP Timer */
/* LEON3 CPU Index of boot CPU */
extern int LEON3_Cpu_Index;

View File

@@ -34,7 +34,7 @@ rtems_smc91111_driver_attach_leon3 (struct rtems_bsdnet_ifconfig *config,
int attach)
{
unsigned long addr_mctrl = 0;
LEON3_IOPORT_Regs_Map *io;
struct grgpio_regs *io;
struct ambapp_apb_info apbpio;
struct ambapp_apb_info apbmctrl;
@@ -63,7 +63,7 @@ rtems_smc91111_driver_attach_leon3 (struct rtems_bsdnet_ifconfig *config,
/* Get controller address */
addr_mctrl = (unsigned long) apbmctrl.start;
io = (LEON3_IOPORT_Regs_Map *) apbpio.start;
io = (struct grgpio_regs *) apbpio.start;
printk(
"Activating Leon3 io port for smsc_lan91cxx (pio:%x mctrl:%x)\n",
@@ -71,10 +71,10 @@ rtems_smc91111_driver_attach_leon3 (struct rtems_bsdnet_ifconfig *config,
(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);
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 */

View File

@@ -89,6 +89,10 @@ $(PROJECT_INCLUDE)/ambapp_ids.h: ../../sparc/shared/include/ambapp_ids.h $(PROJE
$(INSTALL_DATA) $< $(PROJECT_INCLUDE)/ambapp_ids.h
PREINSTALL_FILES += $(PROJECT_INCLUDE)/ambapp_ids.h
$(PROJECT_INCLUDE)/grlib.h: ../../sparc/shared/include/grlib.h $(PROJECT_INCLUDE)/$(dirstamp)
$(INSTALL_DATA) $< $(PROJECT_INCLUDE)/grlib.h
PREINSTALL_FILES += $(PROJECT_INCLUDE)/grlib.h
$(PROJECT_INCLUDE)/bsp/irq-generic.h: ../../shared/include/irq-generic.h $(PROJECT_INCLUDE)/bsp/$(dirstamp)
$(INSTALL_DATA) $< $(PROJECT_INCLUDE)/bsp/irq-generic.h
PREINSTALL_FILES += $(PROJECT_INCLUDE)/bsp/irq-generic.h

View File

@@ -33,7 +33,7 @@ bool benchmark_timer_find_average_overhead;
bool benchmark_timer_is_initialized = false;
extern volatile LEON3_Timer_Regs_Map *LEON3_Timer_Regs;
extern volatile struct gptimer_regs *LEON3_Timer_Regs;
void benchmark_timer_initialize(void)
{
@@ -48,7 +48,7 @@ void benchmark_timer_initialize(void)
} else {
benchmark_timer_is_initialized = true;
}
LEON3_Timer_Regs->timer[LEON3_TIMER_INDEX].conf = LEON3_GPTIMER_EN | LEON3_GPTIMER_LD;
LEON3_Timer_Regs->timer[LEON3_TIMER_INDEX].ctrl = LEON3_GPTIMER_EN | LEON3_GPTIMER_LD;
}
}