#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include "evrmemmap.h" static u32 IntEvent[256] = { /* 0x00 */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0x10 */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0x20 */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0x30 */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0x40 */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0x50 */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0x60 */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0x70 */ 1<Control); int code; int i; /* Disable the ram, and select ram 0 */ ctrl &= ~((1 << C_EVR_CTRL_MAP_RAM_ENABLE) | (1 << C_EVR_CTRL_MAP_RAM_SELECT)); pEr->Control = be32_to_cpu(ctrl); for (i = 1; i > 0; i--) { for(code=0; code < EVR_MAX_EVENT_CODE; code++) { pEr->MapRam[i][code].IntEvent = be32_to_cpu(IntEvent[code]); pEr->MapRam[i][code].PulseSet = 0; pEr->MapRam[i][code].PulseClear = 0; pEr->MapRam[i][code].PulseTrigger = 0; } if (i) { /* Select ram 1, albeit still disabled. Do we really need this? */ ctrl |= (1 << C_EVR_CTRL_MAP_RAM_SELECT); pEr->Control = be32_to_cpu(ctrl); } } } void ErUpdateRam(volatile struct MrfErRegs *pEr, u16 *RamBuf) { u32 ctrl = be32_to_cpu(pEr->Control); int newram; int code; u32 mask; if ((ctrl>>C_EVR_CTRL_MAP_RAM_SELECT) & 1) newram = 0; else newram = 1; for(code=0; code < EVR_MAX_EVENT_CODE; code++) { mask = IntEvent[code]; if (RamBuf[code] & (1<<15)) mask |= 1<MapRam[newram][code].IntEvent = be32_to_cpu(mask); pEr->MapRam[newram][code].PulseTrigger = be32_to_cpu(RamBuf[code] & 0x3fff); } ctrl &= ~((1 << C_EVR_CTRL_MAP_RAM_ENABLE) | (1 << C_EVR_CTRL_MAP_RAM_SELECT)); ctrl |= (1 << C_EVR_CTRL_MAP_RAM_ENABLE); if (newram == 1) ctrl |= (1 << C_EVR_CTRL_MAP_RAM_SELECT); pEr->Control = be32_to_cpu(ctrl); }