[PATCH 35 v3] LEON: moved register definitions into grlib header file

Daniel Hellstrom daniel at gaisler.com
Wed May 16 15:19:34 UTC 2012


On 05/16/2012 04:59 PM, Joel Sherrill wrote:
> Daniel
>
> Since there was no patch in this email, I am unsure
> which is current. Could you resend it please?

Actually I found a reference in a comment, perhaps that was the problem. Resending a new patch to the list as [PATCH 35 v4].

Thanks,
Daniel


>
> Thanks.
>
> -joel
>
> On 05/16/2012 06:24 AM, Daniel Hellstrom wrote:
>> On 04/20/2012 01:19 PM, Joel Sherrill wrote:
>>> Grrr... ok but reference to debugputs.c which is renamed now.
>>>
>>> Ok to commit if a quick follow up addresses that
>> This patch was regenerated after the rename to printk_support.c (see patch summary below), v2 did refer to it but not this patch. Or perhaps I'm missing something. I think this patch is ready to be
>> applied.
>>
>> Daniel
>>
>>> Daniel Hellstrom<daniel at gaisler.com>   wrote:
>>>
>>>> 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 at gaisler.com>
>>>> ---
>>>> c/src/lib/libbsp/sparc/Makefile.am                 |    1 +
>>>> c/src/lib/libbsp/sparc/leon2/Makefile.am           |    1 +
>>>> c/src/lib/libbsp/sparc/leon2/preinstall.am         |    4 +
>>>> c/src/lib/libbsp/sparc/leon2/rasta/rasta.c         |   29 +------
>>>> c/src/lib/libbsp/sparc/leon3/Makefile.am           |    1 +
>>>> c/src/lib/libbsp/sparc/leon3/amba/amba.c           |    7 +-
>>>> c/src/lib/libbsp/sparc/leon3/clock/ckinit.c        |   10 +-
>>>> c/src/lib/libbsp/sparc/leon3/console/console.c     |    8 +-
>>>> .../libbsp/sparc/leon3/console/printk_support.c    |    8 +-
>>>> c/src/lib/libbsp/sparc/leon3/include/amba.h        |    1 +
>>>> c/src/lib/libbsp/sparc/leon3/include/leon.h        |   28 +------
>>>> .../sparc/leon3/leon_smc91111/leon_smc91111.c      |   12 ++--
>>>> c/src/lib/libbsp/sparc/leon3/preinstall.am         |    4 +
>>>> c/src/lib/libbsp/sparc/leon3/timer/timer.c         |    4 +-
>>>> c/src/lib/libbsp/sparc/shared/can/grcan.c          |    5 +-
>>>> c/src/lib/libbsp/sparc/shared/can/occan.c          |    5 +-
>>>> c/src/lib/libbsp/sparc/shared/i2c/i2cmst.c         |    5 +-
>>>> c/src/lib/libbsp/sparc/shared/include/ambapp.h     |   43 ---------
>>>> c/src/lib/libbsp/sparc/shared/include/grlib.h      |   91 ++++++++++++++++++++
>>>> c/src/lib/libbsp/sparc/shared/spw/grspw.c          |    5 +-
>>>> c/src/lib/libbsp/sparc/shared/uart/apbuart.c       |   13 ++--
>>>> 21 files changed, 152 insertions(+), 133 deletions(-)
>>>> create mode 100644 c/src/lib/libbsp/sparc/shared/include/grlib.h
>>>>
>>>> diff --git a/c/src/lib/libbsp/sparc/Makefile.am b/c/src/lib/libbsp/sparc/Makefile.am
>>>> index 2b9909c..e0c7de6 100644
>>>> --- a/c/src/lib/libbsp/sparc/Makefile.am
>>>> +++ b/c/src/lib/libbsp/sparc/Makefile.am
>>>> @@ -18,6 +18,7 @@ EXTRA_DIST += shared/irq/irq-shared.c
>>>> # AMBA Plug&Play bus
>>>> EXTRA_DIST += shared/include/ambapp.h
>>>> EXTRA_DIST += shared/include/ambapp_ids.h
>>>> +EXTRA_DIST += shared/include/grlib.h
>>>> EXTRA_DIST += shared/amba/ambapp.c
>>>> EXTRA_DIST += shared/amba/ambapp_alloc.c
>>>> EXTRA_DIST += shared/amba/ambapp_count.c
>>>> diff --git a/c/src/lib/libbsp/sparc/leon2/Makefile.am b/c/src/lib/libbsp/sparc/leon2/Makefile.am
>>>> index c2310bc..d4135fa 100644
>>>> --- a/c/src/lib/libbsp/sparc/leon2/Makefile.am
>>>> +++ b/c/src/lib/libbsp/sparc/leon2/Makefile.am
>>>> @@ -82,6 +82,7 @@ libbsp_a_SOURCES += \
>>>> # AMBA bus
>>>> 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 += ../../sparc/shared/amba/ambapp.c
>>>> libbsp_a_SOURCES += ../../sparc/shared/amba/ambapp_alloc.c
>>>> libbsp_a_SOURCES += ../../sparc/shared/amba/ambapp_count.c
>>>> diff --git a/c/src/lib/libbsp/sparc/leon2/preinstall.am b/c/src/lib/libbsp/sparc/leon2/preinstall.am
>>>> index 2978d58..84aa2b4 100644
>>>> --- a/c/src/lib/libbsp/sparc/leon2/preinstall.am
>>>> +++ b/c/src/lib/libbsp/sparc/leon2/preinstall.am
>>>> @@ -161,6 +161,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)/i2cmst.h: ../../sparc/shared/include/i2cmst.h $(PROJECT_INCLUDE)/$(dirstamp)
>>>>          $(INSTALL_DATA) $<   $(PROJECT_INCLUDE)/i2cmst.h
>>>> PREINSTALL_FILES += $(PROJECT_INCLUDE)/i2cmst.h
>>>> diff --git a/c/src/lib/libbsp/sparc/leon2/rasta/rasta.c b/c/src/lib/libbsp/sparc/leon2/rasta/rasta.c
>>>> index 0be7e4b..087f9be 100644
>>>> --- a/c/src/lib/libbsp/sparc/leon2/rasta/rasta.c
>>>> +++ b/c/src/lib/libbsp/sparc/leon2/rasta/rasta.c
>>>> @@ -10,6 +10,7 @@
>>>> #include<pci.h>
>>>> #include<rasta.h>
>>>> #include<ambapp.h>
>>>> +#include<grlib.h>
>>>> #include<grcan_rasta.h>
>>>> #include<grspw_rasta.h>
>>>> #include<b1553brm_rasta.h>
>>>> @@ -41,32 +42,10 @@
>>>> #define DBG(x...)
>>>> #endif
>>>>
>>>> -/*
>>>> -typedef struct {
>>>> -  volatile unsigned int ilevel;
>>>> -  volatile unsigned int ipend;
>>>> -  volatile unsigned int iforce;
>>>> -  volatile unsigned int iclear;
>>>> -  volatile unsigned int mpstat;
>>>> -  volatile unsigned int notused01;
>>>> -  volatile unsigned int notused02;
>>>> -  volatile unsigned int notused03;
>>>> -  volatile unsigned int notused10;
>>>> -  volatile unsigned int notused11;
>>>> -  volatile unsigned int notused12;
>>>> -  volatile unsigned int notused13;
>>>> -  volatile unsigned int notused20;
>>>> -  volatile unsigned int notused21;
>>>> -  volatile unsigned int notused22;
>>>> -  volatile unsigned int notused23;
>>>> -  volatile unsigned int mask[16];
>>>> -  volatile unsigned int force[16];
>>>> -} LEON3_IrqCtrl_Regs_Map;
>>>> -*/
>>>> static int bus, dev, fun;
>>>>
>>>> -LEON3_IrqCtrl_Regs_Map *irq = NULL;
>>>> -LEON_Register_Map      *regs = (LEON_Register_Map *)0x80000000;
>>>> +struct irqmp_regs *irq = NULL;
>>>> +LEON_Register_Map *regs = (LEON_Register_Map *)0x80000000;
>>>>
>>>> struct gpio_reg *gpio0, *gpio1;
>>>>
>>>> @@ -291,7 +270,7 @@ int rasta_register(void)
>>>>       apb_base[2] = 0x000e8000;
>>>> #endif
>>>>       /* Set up rasta irq controller */
>>>> -    irq = (LEON3_IrqCtrl_Regs_Map *) (bar0+IRQ_OFFSET);
>>>> +    irq = (struct irqmp_regs *) (bar0+IRQ_OFFSET);
>>>>       irq->iclear = 0xffff;
>>>>       irq->ilevel = 0;
>>>>       irq->mask[0] = 0xffff&   ~(UART0_IRQ|UART1_IRQ|SPW0_IRQ|SPW1_IRQ|SPW2_IRQ|GRCAN_IRQ|BRM_IRQ);
>>>> diff --git a/c/src/lib/libbsp/sparc/leon3/Makefile.am b/c/src/lib/libbsp/sparc/leon3/Makefile.am
>>>> index f3153f1..e6a04d9 100644
>>>> --- a/c/src/lib/libbsp/sparc/leon3/Makefile.am
>>>> +++ b/c/src/lib/libbsp/sparc/leon3/Makefile.am
>>>> @@ -48,6 +48,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
>>>> diff --git a/c/src/lib/libbsp/sparc/leon3/amba/amba.c b/c/src/lib/libbsp/sparc/leon3/amba/amba.c
>>>> index 60281f3..d782d76 100644
>>>> --- a/c/src/lib/libbsp/sparc/leon3/amba/amba.c
>>>> +++ b/c/src/lib/libbsp/sparc/leon3/amba/amba.c
>>>> @@ -27,7 +27,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
>>>> @@ -63,8 +63,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
>>>> @@ -87,7 +86,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,
>>>> diff --git a/c/src/lib/libbsp/sparc/leon3/clock/ckinit.c b/c/src/lib/libbsp/sparc/leon3/clock/ckinit.c
>>>> index 2a75a35..ce47cb6 100644
>>>> --- a/c/src/lib/libbsp/sparc/leon3/clock/ckinit.c
>>>> +++ b/c/src/lib/libbsp/sparc/leon3/clock/ckinit.c
>>>> @@ -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)
>>>> diff --git a/c/src/lib/libbsp/sparc/leon3/console/console.c b/c/src/lib/libbsp/sparc/leon3/console/console.c
>>>> index 0575468..94ad50c 100644
>>>> --- a/c/src/lib/libbsp/sparc/leon3/console/console.c
>>>> +++ b/c/src/lib/libbsp/sparc/leon3/console/console.c
>>>> @@ -49,7 +49,7 @@ 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
>>>> @@ -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
>>>> diff --git a/c/src/lib/libbsp/sparc/leon3/console/printk_support.c b/c/src/lib/libbsp/sparc/leon3/console/printk_support.c
>>>> index 080d4fa..9815053 100644
>>>> --- a/c/src/lib/libbsp/sparc/leon3/console/printk_support.c
>>>> +++ b/c/src/lib/libbsp/sparc/leon3/console/printk_support.c
>>>> @@ -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)
>>>> diff --git a/c/src/lib/libbsp/sparc/leon3/include/amba.h b/c/src/lib/libbsp/sparc/leon3/include/amba.h
>>>> index 32b4a42..a4a0ac9 100644
>>>> --- a/c/src/lib/libbsp/sparc/leon3/include/amba.h
>>>> +++ b/c/src/lib/libbsp/sparc/leon3/include/amba.h
>>>> @@ -27,6 +27,7 @@
>>>> #define LEON3_APB_SLAVES 16
>>>>
>>>> #include<ambapp.h>
>>>> +#include<grlib.h>
>>>>
>>>> #ifdef __cplusplus
>>>> extern "C" {
>>>> diff --git a/c/src/lib/libbsp/sparc/leon3/include/leon.h b/c/src/lib/libbsp/sparc/leon3/include/leon.h
>>>> index da752b2..96a4262 100644
>>>> --- a/c/src/lib/libbsp/sparc/leon3/include/leon.h
>>>> +++ b/c/src/lib/libbsp/sparc/leon3/include/leon.h
>>>> @@ -46,30 +46,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. */
>>>> /*  * */
>>>> @@ -139,8 +115,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;
>>>> diff --git a/c/src/lib/libbsp/sparc/leon3/leon_smc91111/leon_smc91111.c b/c/src/lib/libbsp/sparc/leon3/leon_smc91111/leon_smc91111.c
>>>> index 9e582fb..9b9961d 100644
>>>> --- a/c/src/lib/libbsp/sparc/leon3/leon_smc91111/leon_smc91111.c
>>>> +++ b/c/src/lib/libbsp/sparc/leon3/leon_smc91111/leon_smc91111.c
>>>> @@ -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 */
>>>> diff --git a/c/src/lib/libbsp/sparc/leon3/preinstall.am b/c/src/lib/libbsp/sparc/leon3/preinstall.am
>>>> index 540e37b..dffbb5a 100644
>>>> --- a/c/src/lib/libbsp/sparc/leon3/preinstall.am
>>>> +++ b/c/src/lib/libbsp/sparc/leon3/preinstall.am
>>>> @@ -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
>>>> diff --git a/c/src/lib/libbsp/sparc/leon3/timer/timer.c b/c/src/lib/libbsp/sparc/leon3/timer/timer.c
>>>> index f747dd6..241ecb8 100644
>>>> --- a/c/src/lib/libbsp/sparc/leon3/timer/timer.c
>>>> +++ b/c/src/lib/libbsp/sparc/leon3/timer/timer.c
>>>> @@ -35,7 +35,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)
>>>> {
>>>> @@ -50,7 +50,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;
>>>>     }
>>>> }
>>>>
>>>> diff --git a/c/src/lib/libbsp/sparc/shared/can/grcan.c b/c/src/lib/libbsp/sparc/shared/can/grcan.c
>>>> index 3b0a14a..d592fba 100644
>>>> --- a/c/src/lib/libbsp/sparc/shared/can/grcan.c
>>>> +++ b/c/src/lib/libbsp/sparc/shared/can/grcan.c
>>>> @@ -26,6 +26,7 @@
>>>>
>>>> #include<grcan.h>
>>>> #include<ambapp.h>
>>>> +#include<grlib.h>
>>>>
>>>> #define WRAP_AROUND_TX_MSGS 1
>>>> #define WRAP_AROUND_RX_MSGS 2
>>>> @@ -1097,11 +1098,11 @@ static rtems_device_driver grcan_initialize(
>>>>     /* LEON3: find timer address via AMBA Plug&Play info */
>>>>     {
>>>>       struct ambapp_apb_info gptimer;
>>>> -    LEON3_Timer_Regs_Map *tregs;
>>>> +    struct gptimer_regs *tregs;
>>>>
>>>>       if (ambapp_find_apbslv (&ambapp_plb, VENDOR_GAISLER, GAISLER_GPTIMER,&gptimer)
>>>>           == 1) {
>>>> -      tregs = (LEON3_Timer_Regs_Map *) gptimer.start;
>>>> +      tregs = (struct gptimer_regs *) gptimer.start;
>>>>         sys_freq_hz = (tregs->scaler_reload + 1) * 1000 * 1000;
>>>>         DBG("GRCAN: detected %dHZ system frequency\n\r", sys_freq_hz);
>>>>       } else {
>>>> diff --git a/c/src/lib/libbsp/sparc/shared/can/occan.c b/c/src/lib/libbsp/sparc/shared/can/occan.c
>>>> index 4fb932d..b1bf54e 100644
>>>> --- a/c/src/lib/libbsp/sparc/shared/can/occan.c
>>>> +++ b/c/src/lib/libbsp/sparc/shared/can/occan.c
>>>> @@ -19,6 +19,7 @@
>>>>
>>>> #include<leon.h>
>>>> #include<ambapp.h>
>>>> +#include<grlib.h>
>>>> #include<occan.h>
>>>>
>>>> /* RTEMS ->   ERRNO decoding table
>>>> @@ -936,11 +937,11 @@ static rtems_device_driver occan_initialize(rtems_device_major_number major, rte
>>>>          /* LEON3: find timer address via AMBA Plug&Play info */
>>>>          {
>>>>                  struct ambapp_apb_info gptimer;
>>>> -               LEON3_Timer_Regs_Map *tregs;
>>>> +               struct gptimer_regs *tregs;
>>>>
>>>>                  if ( ambapp_find_apbslv(&ambapp_plb, VENDOR_GAISLER,
>>>>                                           GAISLER_GPTIMER,&gptimer) == 1 ){
>>>> -                       tregs = (LEON3_Timer_Regs_Map *)gptimer.start;
>>>> +                       tregs = (struct gptimer_regs *)gptimer.start;
>>>>                          sys_freq_hz = (tregs->scaler_reload+1)*1000*1000;
>>>>                          DBG("OCCAN: detected %dHZ system frequency\n\r",sys_freq_hz);
>>>>                  }else{
>>>> diff --git a/c/src/lib/libbsp/sparc/shared/i2c/i2cmst.c b/c/src/lib/libbsp/sparc/shared/i2c/i2cmst.c
>>>> index 7ba7208..7acf17d 100644
>>>> --- a/c/src/lib/libbsp/sparc/shared/i2c/i2cmst.c
>>>> +++ b/c/src/lib/libbsp/sparc/shared/i2c/i2cmst.c
>>>> @@ -17,6 +17,7 @@
>>>> #include<bsp.h>
>>>> #include<i2cmst.h>
>>>> #include<ambapp.h>
>>>> +#include<grlib.h>
>>>> #include<rtems/libi2c.h>
>>>>
>>>> /* Enable debug printks? */
>>>> @@ -318,11 +319,11 @@ rtems_status_code leon_register_i2c(struct ambapp_bus *abus)
>>>>          /* LEON3: find timer address via AMBA Plug&Play info */
>>>>          {
>>>>            struct ambapp_apb_info gptimer;
>>>> -         LEON3_Timer_Regs_Map *tregs;
>>>> +         struct gptimer_regs *tregs;
>>>>
>>>>            if (ambapp_find_apbslv(abus, VENDOR_GAISLER,
>>>>                                   GAISLER_GPTIMER,&gptimer) == 1 ) {
>>>> -           tregs = (LEON3_Timer_Regs_Map *)gptimer.start;
>>>> +           tregs = (struct gptimer_regs *)gptimer.start;
>>>>              gr_i2cmst_desc.prv.sysfreq = (tregs->scaler_reload+1)*1000;
>>>>            } else {
>>>>              gr_i2cmst_desc.prv.sysfreq = 40000; /* Default to 40MHz */
>>>> diff --git a/c/src/lib/libbsp/sparc/shared/include/ambapp.h b/c/src/lib/libbsp/sparc/shared/include/ambapp.h
>>>> index 5eb3f2a..c3fd13a 100644
>>>> --- a/c/src/lib/libbsp/sparc/shared/include/ambapp.h
>>>> +++ b/c/src/lib/libbsp/sparc/shared/include/ambapp.h
>>>> @@ -355,49 +355,6 @@ extern int ambapp_find_ahbslvs(
>>>>          int maxno);
>>>>
>>>>
>>>> -/******** AMBA DEVICES *******/
>>>> -
>>>> -/* ESA MEMORY CONTROLLER */
>>>> -typedef struct {
>>>> -  unsigned int mcfg1;
>>>> -  unsigned int mcfg2;
>>>> -  unsigned int mcfg3;
>>>> -} ambapp_regmap_mctrl;
>>>> -
>>>> -/* APB UART */
>>>> -typedef struct {
>>>> -  volatile unsigned int data;
>>>> -  volatile unsigned int status;
>>>> -  volatile unsigned int ctrl;
>>>> -  volatile unsigned int scaler;
>>>> -} ambapp_apb_uart;
>>>> -
>>>> -typedef struct {
>>>> -  volatile unsigned int ilevel;
>>>> -  volatile unsigned int ipend;
>>>> -  volatile unsigned int iforce;
>>>> -  volatile unsigned int iclear;
>>>> -  volatile unsigned int mpstat;
>>>> -  volatile unsigned int notused01;
>>>> -  volatile unsigned int notused02;
>>>> -  volatile unsigned int notused03;
>>>> -  volatile unsigned int ampctrl;
>>>> -  volatile unsigned int icsel[2];
>>>> -  volatile unsigned int notused13;
>>>> -  volatile unsigned int notused20;
>>>> -  volatile unsigned int notused21;
>>>> -  volatile unsigned int notused22;
>>>> -  volatile unsigned int notused23;
>>>> -  volatile unsigned int mask[16];
>>>> -  volatile unsigned int force[16];
>>>> -  /* Extended IRQ registers */
>>>> -  volatile unsigned int intid[16];
>>>> -  /* 0x100, align to 4Kb boundary */
>>>> -  volatile unsigned int resv1[(0x1000-0x100)/4];
>>>> -} LEON3_IrqCtrl_Regs_Map;
>>>> -
>>>> -/*****************************/
>>>> -
>>>> #ifdef __cplusplus
>>>> }
>>>> #endif
>>>> diff --git a/c/src/lib/libbsp/sparc/shared/include/grlib.h b/c/src/lib/libbsp/sparc/shared/include/grlib.h
>>>> new file mode 100644
>>>> index 0000000..7f1f7d0
>>>> --- /dev/null
>>>> +++ b/c/src/lib/libbsp/sparc/shared/include/grlib.h
>>>> @@ -0,0 +1,91 @@
>>>> +/*
>>>> + *  Common GRLIB AMBA Core Register definitions
>>>> + *
>>>> + *  COPYRIGHT (c) 2012
>>>> + *  Aeroflex Gaisler
>>>> + *
>>>> + *  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.
>>>> + */
>>>> +
>>>> +#ifndef __GRLIB_H__
>>>> +#define __GRLIB_H__
>>>> +
>>>> +#ifdef __cplusplus
>>>> +extern "C" {
>>>> +#endif
>>>> +
>>>> +/* ESA MEMORY CONTROLLER */
>>>> +struct mctrl_regs {
>>>> +  unsigned int mcfg1;
>>>> +  unsigned int mcfg2;
>>>> +  unsigned int mcfg3;
>>>> +};
>>>> +
>>>> +/* APB UART */
>>>> +struct apbuart_regs {
>>>> +  volatile unsigned int data;
>>>> +  volatile unsigned int status;
>>>> +  volatile unsigned int ctrl;
>>>> +  volatile unsigned int scaler;
>>>> +};
>>>> +
>>>> +/* IRQMP and IRQAMP interrupt controllers */
>>>> +struct irqmp_regs {
>>>> +  volatile unsigned int ilevel;      /* 0x00 */
>>>> +  volatile unsigned int ipend;       /* 0x04 */
>>>> +  volatile unsigned int iforce;      /* 0x08 */
>>>> +  volatile unsigned int iclear;      /* 0x0c */
>>>> +  volatile unsigned int mpstat;      /* 0x10 */
>>>> +  volatile unsigned int bcast;       /* 0x14 */
>>>> +  volatile unsigned int notused02;   /* 0x18 */
>>>> +  volatile unsigned int notused03;   /* 0x1c */
>>>> +  volatile unsigned int ampctrl;     /* 0x20 */
>>>> +  volatile unsigned int icsel[2];    /* 0x24,0x28 */
>>>> +  volatile unsigned int notused13;   /* 0x2c */
>>>> +  volatile unsigned int notused20;   /* 0x30 */
>>>> +  volatile unsigned int notused21;   /* 0x34 */
>>>> +  volatile unsigned int notused22;   /* 0x38 */
>>>> +  volatile unsigned int notused23;   /* 0x3c */
>>>> +  volatile unsigned int mask[16];    /* 0x40 */
>>>> +  volatile unsigned int force[16];   /* 0x80 */
>>>> +  /* Extended IRQ registers */
>>>> +  volatile unsigned int intid[16];   /* 0xc0 */
>>>> +  /* 0x100, align to 4Kb boundary */
>>>> +  volatile unsigned int resv1[(0x1000-0x100)/4];
>>>> +};
>>>> +
>>>> +/* GPTIMER Timer instance */
>>>> +struct gptimer_timer_regs {
>>>> +  volatile unsigned int value;
>>>> +  volatile unsigned int reload;
>>>> +  volatile unsigned int ctrl;
>>>> +  volatile unsigned int notused;
>>>> +};
>>>> +
>>>> +/* GPTIMER common registers */
>>>> +struct gptimer_regs {
>>>> +  volatile unsigned int scaler_value;   /* common timer registers */
>>>> +  volatile unsigned int scaler_reload;
>>>> +  volatile unsigned int cfg;
>>>> +  volatile unsigned int notused;
>>>> +  struct gptimer_timer_regs timer[7];
>>>> +};
>>>> +
>>>> +/* GRGPIO GPIO */
>>>> +struct grgpio_regs {
>>>> +  volatile unsigned int data;        /* 0x00 I/O port data register */
>>>> +  volatile unsigned int output;      /* 0x04 I/O port output register */
>>>> +  volatile unsigned int dir;         /* 0x08 I/O port direction register */
>>>> +  volatile unsigned int imask;       /* 0x0C Interrupt mask register */
>>>> +  volatile unsigned int ipol;        /* 0x10 Interrupt polarity register */
>>>> +  volatile unsigned int iedge;       /* 0x14 Interrupt edge register */
>>>> +  volatile unsigned int bypass;      /* 0x18 Bypass register */
>>>> +};
>>>> +
>>>> +#ifdef __cplusplus
>>>> +}
>>>> +#endif
>>>> +
>>>> +#endif
>>>> diff --git a/c/src/lib/libbsp/sparc/shared/spw/grspw.c b/c/src/lib/libbsp/sparc/shared/spw/grspw.c
>>>> index 8ab5020..55986ba 100644
>>>> --- a/c/src/lib/libbsp/sparc/shared/spw/grspw.c
>>>> +++ b/c/src/lib/libbsp/sparc/shared/spw/grspw.c
>>>> @@ -83,6 +83,7 @@
>>>> #include<ctype.h>
>>>> #include<rtems/bspIo.h>
>>>> #include<ambapp.h>
>>>> +#include<grlib.h>
>>>> #include<grspw.h>
>>>>
>>>> #define DBGSPW_IOCALLS 1
>>>> @@ -390,11 +391,11 @@ int GRSPW_PREFIX(_register)(struct ambapp_bus *bus)
>>>>          /* LEON3: find timer address via AMBA Plug&Play info */
>>>>          {
>>>>                  struct ambapp_apb_info gptimer;
>>>> -               LEON3_Timer_Regs_Map *tregs;
>>>> +               struct gptimer_regs *tregs;
>>>>
>>>>                  if ( ambapp_find_apbslv(&ambapp_plb, VENDOR_GAISLER,
>>>>                                           GAISLER_GPTIMER,&gptimer) == 1 ) {
>>>> -                       tregs = (LEON3_Timer_Regs_Map *)gptimer.start;
>>>> +                       tregs = (struct gptimer_regs *)gptimer.start;
>>>>                          sys_freq_khz = (tregs->scaler_reload+1)*1000;
>>>>                          SPACEWIRE_DBG("GRSPW: detected %dkHZ system frequency\n\r",sys_freq_khz);
>>>>                  }else{
>>>> diff --git a/c/src/lib/libbsp/sparc/shared/uart/apbuart.c b/c/src/lib/libbsp/sparc/shared/uart/apbuart.c
>>>> index d442e80..25d0373 100644
>>>> --- a/c/src/lib/libbsp/sparc/shared/uart/apbuart.c
>>>> +++ b/c/src/lib/libbsp/sparc/shared/uart/apbuart.c
>>>> @@ -22,6 +22,7 @@
>>>> #include<string.h>
>>>>
>>>> #include<ambapp.h>
>>>> +#include<grlib.h>
>>>> #include<apbuart.h>
>>>>
>>>> #ifndef DEFAULT_TXBUF_SIZE
>>>> @@ -79,7 +80,7 @@ static rtems_device_driver apbuart_write(rtems_device_major_number major, rtems_
>>>> static rtems_device_driver apbuart_control(rtems_device_major_number major, rtems_device_minor_number minor, void *arg);
>>>>
>>>> typedef struct {
>>>> -       ambapp_apb_uart *regs;
>>>> +       struct apbuart_regs *regs;
>>>>          int irq;
>>>>          int minor;
>>>>          int scaler;
>>>> @@ -153,7 +154,7 @@ static void apbuart_hw_open(apbuart_priv *uart);
>>>> #endif
>>>>
>>>> #if 0
>>>> -static int apbuart_outbyte_try(ambapp_apb_uart *regs,  unsigned char ch)
>>>> +static int apbuart_outbyte_try(struct apbuart_regs *regs, unsigned char ch)
>>>> {
>>>>          if ( (READ_REG(&regs->status)&   LEON_REG_UART_STATUS_THE) == 0 )
>>>>                  return -1; /* Failed */
>>>> @@ -164,7 +165,7 @@ static int apbuart_outbyte_try(ambapp_apb_uart *regs,  unsigned char ch)
>>>> }
>>>>
>>>>
>>>> -static int apbuart_inbyte_try(ambapp_apb_uart *regs)
>>>> +static int apbuart_inbyte_try(struct apbuart_regs *regs)
>>>> {
>>>>          unsigned int status;
>>>>          /* Clear errors if any */
>>>> @@ -386,11 +387,11 @@ static rtems_device_driver apbuart_initialize(rtems_device_major_number  major,
>>>>          /* LEON3: find timer address via AMBA Plug&Play info */
>>>>          {
>>>>                  struct ambapp_apb_info gptimer;
>>>> -               LEON3_Timer_Regs_Map *tregs;
>>>> +               struct gptimer_regs *tregs;
>>>>
>>>>                  if ( ambapp_find_apbslv(&ambapp_plb, VENDOR_GAISLER,
>>>>                                          GAISLER_GPTIMER,&gptimer) == 1 ){
>>>> -                       tregs = (LEON3_Timer_Regs_Map *)gptimer.start;
>>>> +                       tregs = (struct gptimer_regs *)gptimer.start;
>>>>                          sys_freq_hz = (tregs->scaler_reload+1)*1000*1000;
>>>>                          DBG("APBUART: detected %dHZ system frequency\n\r",sys_freq_hz);
>>>>                  }else{
>>>> @@ -419,7 +420,7 @@ static rtems_device_driver apbuart_initialize(rtems_device_major_number  major,
>>>>
>>>>                  printk("APBUART[%d]: at 0x%x irq %d (0x%x)\n\r",i,dev.start,dev.irq,(unsigned int)&apbuarts[i]);
>>>>
>>>> -               apbuarts[i].regs = (ambapp_apb_uart *)dev.start;
>>>> +               apbuarts[i].regs = (struct apbuart_regs *)dev.start;
>>>>                  apbuarts[i].irq = dev.irq;
>>>>                  apbuarts[i].minor = i;
>>>>
>>>> -- 
>>>> 1.7.0.4
>>>>
>
>




More information about the devel mailing list