Commit aa428c0e authored by yoogx's avatar yoogx
Browse files

* Adjustments for RTEMS 5 / RCC 1.3

	For openaadl/ocarina#146
parent c7d61621
......@@ -8,15 +8,15 @@
* Copyright (C) 2010-2018 ESA & ISAE.
*/
#include <deployment.h>
/* Generated code header */
#if ((defined __PO_HI_NEED_DRIVER_SPACEWIRE_RASTA) || \
(defined __PO_HI_NEED_DRIVER_SERIAL_RASTA) || \
(defined __PO_HI_NEED_DRIVER_ETH_LEON ))
#include <stdlib.h>
#include <deployment.h>
/* Generated code header */
#include <rtems.h>
#include <rtems/bspIo.h>
#include <ambapp.h>
......@@ -30,7 +30,7 @@
/* Rasta includes from GAISLER drivers */
#if defined GRLEON3 && defined RTEMS412
#if defined GRLEON3 && defined RTEMS412
#include <amba.h>
#include <ambapp.h>
#include <drvmgr/drvmgr.h>
......@@ -40,57 +40,58 @@
struct drvmgr_key grlib_grspw0_res[] =
{
{"txDesc", DRVMGR_KT_INT, {(unsigned int)16}},
{"rxDesc", DRVMGR_KT_INT, {(unsigned int)32}},
DRVMGR_KEY_EMPTY
{"txDesc", DRVMGR_KT_INT, {(unsigned int)16}},
{"rxDesc", DRVMGR_KT_INT, {(unsigned int)32}},
DRVMGR_KEY_EMPTY
};
/* GRSPW1 and GRSPW2 resources */
struct drvmgr_key grlib_grspw1_res[] =
{
{"txDesc", DRVMGR_KT_INT, {(unsigned int)16}},
{"rxDesc", DRVMGR_KT_INT, {(unsigned int)32}},
DRVMGR_KEY_EMPTY
{"txDesc", DRVMGR_KT_INT, {(unsigned int)16}},
{"rxDesc", DRVMGR_KT_INT, {(unsigned int)32}},
DRVMGR_KEY_EMPTY
};
/* GRSPW1 and GRSPW2 resources */
struct drvmgr_key grlib_grspw2_res[] =
{
{"txDesc", DRVMGR_KT_INT, {(unsigned int)16}},
{"rxDesc", DRVMGR_KT_INT, {(unsigned int)32}},
DRVMGR_KEY_EMPTY
{"txDesc", DRVMGR_KT_INT, {(unsigned int)16}},
{"rxDesc", DRVMGR_KT_INT, {(unsigned int)32}},
DRVMGR_KEY_EMPTY
};
struct drvmgr_key grlib_greth0_res[] =
{
{"txDescs", DRVMGR_KT_INT, {(unsigned int)16}},
{"rxDescs", DRVMGR_KT_INT, {(unsigned int)32}},
DRVMGR_KEY_EMPTY
{"txDescs", DRVMGR_KT_INT, {(unsigned int)16}},
{"rxDescs", DRVMGR_KT_INT, {(unsigned int)32}},
DRVMGR_KEY_EMPTY
};
struct drvmgr_key grlib_grcan0_res[] =
{
{"txDescs", DRVMGR_KT_INT, {(unsigned int)16}},
{"rxDescs", DRVMGR_KT_INT, {(unsigned int)32}},
DRVMGR_KEY_EMPTY
{"txDescs", DRVMGR_KT_INT, {(unsigned int)16}},
{"rxDescs", DRVMGR_KT_INT, {(unsigned int)32}},
DRVMGR_KEY_EMPTY
};
/* GRLIB Plug & Play bus driver resources */
struct drvmgr_drv_res grlib_drv_resources[] =
{
{DRIVER_AMBAPP_GAISLER_GRSPW2_ID, 0, &grlib_grspw0_res[0]},
{DRIVER_AMBAPP_GAISLER_GRSPW2_ID, 1, &grlib_grspw1_res[0]},
{DRIVER_AMBAPP_GAISLER_GRSPW2_ID, 2, &grlib_grspw2_res[0]},
{DRIVER_AMBAPP_GAISLER_GRCAN_ID, 0, &grlib_grcan0_res[0]},
{DRIVER_AMBAPP_GAISLER_GRETH_ID, 0, &grlib_greth0_res[0]},
DRVMGR_RES_EMPTY
{DRIVER_AMBAPP_GAISLER_GRSPW2_ID, 0, &grlib_grspw0_res[0]},
{DRIVER_AMBAPP_GAISLER_GRSPW2_ID, 1, &grlib_grspw1_res[0]},
{DRIVER_AMBAPP_GAISLER_GRSPW2_ID, 2, &grlib_grspw2_res[0]},
{DRIVER_AMBAPP_GAISLER_GRCAN_ID, 0, &grlib_grcan0_res[0]},
{DRIVER_AMBAPP_GAISLER_GRETH_ID, 0, &grlib_greth0_res[0]},
DRVMGR_RES_EMPTY
};
struct grlib_config grlib_bus_config =
{
&ambapp_plb, /* AMBAPP bus setup */
&grlib_drv_resources, /* Driver configuration */
};
/* The following is defined in amba.c, as of RCC 1.3rc4 */
//struct grlib_config grlib_bus_config =
//{
// &ambapp_plb, /* AMBAPP bus setup */
// &grlib_drv_resources, /* Driver configuration */
//};
#endif
#include <po_hi_debug.h>
......@@ -173,25 +174,25 @@ void __po_hi_rasta_interrrupt_register(void *handler, int irqno, void *arg)
DBG("RASTA: Registering uart0 handler: 0x%x, arg: 0x%x\n",handler,arg);
uart0_int_handler = handler;
uart0_int_arg = arg;
irq->iclear = UART0_IRQ;
irq->mask[0] |= UART0_IRQ;
}
if ( irqno == UART1_IRQNO ){
DBG("RASTA: Registering uart1 handler: 0x%x, arg: 0x%x\n",handler,arg);
uart1_int_handler = handler;
uart1_int_arg = arg;
irq->iclear = UART1_IRQ;
irq->mask[0] |= UART1_IRQ;
}
if ( irqno == SPW0_IRQNO ){
DBG("RASTA: Registering spw0 handler: 0x%x, arg: 0x%x\n",handler,arg);
spw0_int_handler = handler;
spw0_int_arg = arg;
irq->iclear = SPW0_IRQ;
irq->mask[0] |= SPW0_IRQ;
}
......@@ -200,50 +201,50 @@ void __po_hi_rasta_interrrupt_register(void *handler, int irqno, void *arg)
DBG("RASTA: Registering spw1 handler: 0x%x, arg: 0x%x\n",handler,arg);
spw1_int_handler = handler;
spw1_int_arg = arg;
irq->iclear = SPW1_IRQ;
irq->mask[0] |= SPW1_IRQ;
}
if ( irqno == SPW2_IRQNO ){
DBG("RASTA: Registering spw2 handler: 0x%x, arg: 0x%x\n",handler,arg);
spw2_int_handler = handler;
spw2_int_arg = arg;
irq->iclear = SPW2_IRQ;
irq->mask[0] |= SPW2_IRQ;
}
if ( irqno == GRCAN_IRQNO ){
DBG("RASTA: Registering GRCAN handler: 0x%x, arg: 0x%x\n",handler,arg);
grcan_int_handler = handler;
grcan_int_arg = arg;
irq->iclear = GRCAN_IRQ;
irq->mask[0] |= GRCAN_IRQ;
}
if ( irqno == BRM_IRQNO ){
DBG("RASTA: Registering BRM handler: 0x%x, arg: 0x%x\n",handler,arg);
brm_int_handler = handler;
brm_int_arg = arg;
irq->iclear = BRM_IRQ;
irq->mask[0] |= BRM_IRQ;
}
}
}
static rtems_isr __po_hi_rasta_interrupt_handler (rtems_vector_number v)
{
unsigned int status;
status = irq->ipend;
if ( (status & GRCAN_IRQ) && grcan_int_handler ) {
grcan_int_handler(GRCAN_IRQNO,grcan_int_arg);
}
if (status & SPW_IRQ) {
if ( (status & SPW0_IRQ) && spw0_int_handler ){
spw0_int_handler(SPW0_IRQNO,spw0_int_arg);
......@@ -252,12 +253,12 @@ static rtems_isr __po_hi_rasta_interrupt_handler (rtems_vector_number v)
if ( (status & SPW1_IRQ) && spw1_int_handler ){
spw1_int_handler(SPW1_IRQNO,spw1_int_arg);
}
if ( (status & SPW2_IRQ) && spw2_int_handler ){
spw2_int_handler(SPW2_IRQNO,spw2_int_arg);
}
}
if ((status & BRM_IRQ) && brm_int_handler ){
if ((status & BRM_IRQ) && brm_int_handler ){
brm_int_handler(BRM_IRQNO,brm_int_arg);
}
if ( (status & UART0_IRQ) && uart0_int_handler ) {
......@@ -266,41 +267,41 @@ static rtems_isr __po_hi_rasta_interrupt_handler (rtems_vector_number v)
if ( (status & UART1_IRQ) && uart1_int_handler) {
uart1_int_handler(UART1_IRQNO,uart1_int_arg);
}
DBG("RASTA-IRQ: 0x%x\n",status);
irq->iclear = status;
}
int __po_hi_rasta_register(void)
int __po_hi_rasta_register(void)
{
unsigned int bar0, bar1, data;
unsigned int *page0 = NULL;
unsigned int *apb_base = NULL;
int found=0;
DBG("Searching for RASTA board ...");
if (BSP_pciFindDevice(0x1AC8, 0x0010, 0, &bus, &dev, &fun) == 0) {
found = 1;
}
if ( (!found) && (BSP_pciFindDevice(0x16E3, 0x0210, 0, &bus, &dev, &fun) == 0) ) {
found = 1;
}
if ( !found )
return -1;
DBG(" found it (dev/fun: %d/%d).\n", dev, fun);
pci_read_config_dword(bus, dev, fun, 0x10, &bar0);
pci_read_config_dword(bus, dev, fun, 0x14, &bar1);
page0 = (unsigned int *)(bar0 + 0x400000);
page0 = (unsigned int *)(bar0 + 0x400000);
*page0 = 0x80000000;
apb_base = (unsigned int *)(bar0+APB2_OFFSET);
......@@ -309,12 +310,12 @@ int __po_hi_rasta_register(void)
apb_base[0] = 0x000002ff;
apb_base[1] = 0x00001260;
apb_base[2] = 0x000e8000;
#else
#else
apb_base[0] = 0x000002ff;
apb_base[1] = 0x82206000;
apb_base[2] = 0x000e8000;
#endif
irq = (LEON3_IrqCtrl_Regs_Map *) (bar0+IRQ_OFFSET);
irq = (LEON3_IrqCtrl_Regs_Map *) (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);
......@@ -325,10 +326,10 @@ int __po_hi_rasta_register(void)
apb_base[0x100] |= 0x40000000;
apb_base[0x104] = 0x40000000;
pci_read_config_dword(bus, dev, fun, 0x4, &data);
pci_write_config_dword(bus, dev, fun, 0x4, data|0x40);
pci_master_enable(bus, dev, fun);
set_vector(__po_hi_rasta_interrupt_handler, RASTA_IRQ+0x10, 1);
......@@ -344,11 +345,11 @@ int __po_hi_rasta_register(void)
amba_maps[2].size=0;
amba_maps[2].cpu_adr = 0;
amba_maps[2].remote_amba_adr = 0;
memset(&abus,0,sizeof(abus));
amba_scan(&abus,bar0+(AHB1_IOAREA_BASE_ADDR&~0xf0000000),&amba_maps[0]);
printk("Registering RASTA BRM driver\n\r");
b1553brm_rasta_int_reg=__po_hi_rasta_interrrupt_register;
......@@ -356,7 +357,7 @@ int __po_hi_rasta_register(void)
printk("Failed to register BRM RASTA driver\n");
return -1;
}
grspw_rasta_int_reg=__po_hi_rasta_interrrupt_register;
if ( grspw_rasta_register(&abus,bar1) ){
printk("Failed to register RASTA GRSPW driver\n\r");
......@@ -373,12 +374,12 @@ int __po_hi_rasta_register(void)
printk("Failed to get address for RASTA GPIO0\n\r");
return -1;
}
if ( rasta_get_gpio(&abus,1,&gpio1,NULL) ){
printk("Failed to get address for RASTA GPIO1\n\r");
return -1;
}
return 0;
}
*/
......@@ -394,9 +395,9 @@ void __po_hi_c_driver_rasta_common_init ()
#if defined GRLEON3 && defined RTEMS412
/* Register GRLIB root bus */
ambapp_grlib_root_register(&grlib_bus_config);
// ambapp_grlib_root_register(&grlib_bus_config);
/* Initializing Driver Manager if not alread performed by BSP */
/* Initializing Driver Manager if not already performed by BSP */
__PO_HI_DEBUG_DEBUG("Initializing Driver manager...\n");
if ( drvmgr_init() ) {
__PO_HI_DEBUG_DEBUG ("Driver manager Failed to initialize\n");
......@@ -409,7 +410,7 @@ void __po_hi_c_driver_rasta_common_init ()
#endif
#elif GRLEON2
__PO_HI_DEBUG_DEBUG ("[RASTA COMMON] Init\n");
init_pci();
__PO_HI_DEBUG_DEBUG ("[RASTA COMMON] Initializing RASTA ...");
......@@ -424,7 +425,7 @@ void __po_hi_c_driver_rasta_common_init ()
__PO_HI_DEBUG_DEBUG(" ERROR !\n");
return;
}
#endif
#endif
__PO_HI_DEBUG_DEBUG (" OK !\n");
__po_hi_c_driver_rasta_common_is_init = 1;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment