Commit 9ca6a912 authored by Bruno Gomes's avatar Bruno Gomes

AIR PMK: Update AIR version + share sparc timer structs to be used in libiop

refs #112663
parent 17892d49
......@@ -732,36 +732,18 @@ int iop_grcan_device_init(iop_device_driver_t *iop_dev)
iop_can_device_t *device = (iop_can_device_t *) iop_dev;
grcan_priv *pDev = (grcan_priv*) (device->dev.driver);
amba_apb_dev_t grcandev;
amba_apb_dev_t gptimer;
timer_regmap_t *tregs;
// int dev_count = 0;
struct amba_dev_id {
unsigned short vendor;
unsigned short device;
/* Version ? */
};
struct amba_dev_id grcan_ids[] =
{
{VENDOR_GAISLER, GAISLER_GRCAN},
{VENDOR_GAISLER, GAISLER_GRHCAN},
{0, 0} /* Mark end of table */
};
FUNCDBG();
amba_confarea_t * ambabus = (amba_confarea_t *)air_syscall_get_ambaconf();
memset(&grcandev, 0, sizeof(amba_apb_dev_t));
// dev_count = ambapp_find_apbslv(&amba_confarea,
// VENDOR_GAISLER,
// GAISLER_GRCAN,
// &grcandev);
if(amba_get_apb_slave(&amba_confarea,
grcan_ids[0].vendor,
grcan_ids[0].device,
device->can_core,
&grcandev) != 1)
{
return AIR_DEVICE_NOT_FOUND;
}
if(!amba_get_apb_slave(ambabus, VENDOR_GAISLER, GAISLER_GRCAN,device->can_core, &grcandev))
return AIR_DEVICE_NOT_FOUND;
#if 0
iop_debug("Start: 0x%04x - IRQ 0x%04x - bus_id 0x%04x\n",
......@@ -776,16 +758,30 @@ int iop_grcan_device_init(iop_device_driver_t *iop_dev)
/* Get frequency in Hz */
// pDev->corefreq_hz = amba_confarea.ahbs[grcandev.ahbidx].freq_hz;
pDev->corefreq_hz = 250000000;
/*
* Auto Detect the CAN core frequency by assuming that the system frequency is
* is the same as the CAN core frequency.
*/
if (amba_get_apb_slave(ambabus,VENDOR_GAISLER,GAISLER_GPTIMER,0,&gptimer))
{
/*Timer memory mapped registers*/
tregs = (timer_regmap_t*)gptimer.start;
DBG("GRCAN frequency: %d Hz\n", pDev->corefreq_hz);
/*Calculate System frequency based on the timer register*/
pDev->corefreq_hz = (tregs->scaler_reload+1)*1000000;
}
else
{
pDev->corefreq_hz = 250000000;
iop_debug("GRCAN: Failed to detect system frequency\n\r");
}
/* Reset Hardware*/
grcan_hw_reset(pDev->regs);
// iop_debug("GRCAN: System frequency set at: %dHz\n", pDev->corefreq_hz);
DBG("Registers are set\n");
iop_debug("GRCAN: System frequency set at: %dHz\n", pDev->corefreq_hz);
/* TODO compute grcan_timing from clock frequency and configured baudrate
* from iop config */
#if 0
......
......@@ -151,22 +151,6 @@ void set_sys_freq(){
/* Get System clock frequency */
sys_freq_khz = 0;
/* 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];
};
/*
* Auto Detect the SPW core frequency by assuming that the system frequency is
* is the same as the SPW core frequency.
......@@ -174,13 +158,13 @@ void set_sys_freq(){
#ifndef SYS_FREQ_KHZ
/* LEON3: find timer address via AMBA Plug&Play info */
amba_apb_dev_t gptimer;
struct gptimer_regs *tregs;
timer_regmap_t *tregs;
/*search for gaisler timer in the amba bus*/
if ( amba_get_apb_slave(amba_bus,VENDOR_GAISLER,GAISLER_GPTIMER,0,&gptimer) == 1 ){
/*Timer memory mapped registers*/
tregs = (struct gptimer_regs*)gptimer.start;
tregs = (timer_regmap_t*)gptimer.start;
/*Calculate System frequency based on the timer register*/
sys_freq_khz = (tregs->scaler_reload+1)*1000;
......
......@@ -47,31 +47,6 @@ void pmk_ipc_handler(void *isf, pmk_core_ctrl_t *core);
*/
#define TIMER_IRQEN (0x00000008u)
/**
* @brief LEON registers per timer
*/
typedef struct {
volatile air_u32_t value;
volatile air_u32_t reload;
volatile air_u32_t conf;
volatile air_u32_t dummy;
} timer_subtype_t;
/**
* @brief LEON timer register map
*/
typedef struct {
volatile air_u32_t scaler_value;
volatile air_u32_t scaler_reload;
volatile air_u32_t status;
volatile air_u32_t dummy;
timer_subtype_t timer[8];
} timer_regmap_t;
/**
* @brief Timer control
*/
......
......@@ -9,7 +9,7 @@
/**
* @file
* @author
* @brief
* @brief SPARC clock init function and register structs
*/
#ifndef __CLOCK_H__
......@@ -28,12 +28,37 @@
*/
typedef struct {
volatile void *regs; /**< Base register */
air_u32_t irq; /**< IRQ number */
air_u32_t frequency; /**< Frequency */
volatile void *regs; /**< Base register*/
air_u32_t irq; /**< IRQ number */
air_u32_t frequency; /**< Frequency */
} timer_ctrl_t;
/**
* @brief LEON registers per timer
*/
typedef struct {
volatile air_u32_t value;
volatile air_u32_t reload;
volatile air_u32_t conf;
volatile air_u32_t dummy;
} timer_subtype_t;
/**
* @brief LEON timer register map
*/
typedef struct {
volatile air_u32_t scaler_value;
volatile air_u32_t scaler_reload;
volatile air_u32_t status;
volatile air_u32_t dummy;
timer_subtype_t timer[8];
} timer_regmap_t;
/**
* @brief Timer control structure
*/
......
......@@ -56,7 +56,7 @@ void pmk_init(void) {
printk(
"\033[0m"
"-------------------------------------------------------------------------------\n" \
" ** AIR OS v5.2.0 \n" \
" ** AIR OS v5.3.0 \n" \
"-------------------------------------------------------------------------------\n");
/* USR configuration initialization */
......
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