2005-04-17 02:20:36 +04:00
|
|
|
|
|
|
|
/*
|
|
|
|
*
|
2012-02-20 07:52:38 +04:00
|
|
|
Copyright (c) Eicon Networks, 2002.
|
2005-04-17 02:20:36 +04:00
|
|
|
*
|
2012-02-20 07:52:38 +04:00
|
|
|
This source file is supplied for the use with
|
|
|
|
Eicon Networks range of DIVA Server Adapters.
|
2005-04-17 02:20:36 +04:00
|
|
|
*
|
2012-02-20 07:52:38 +04:00
|
|
|
Eicon File Revision : 2.1
|
2005-04-17 02:20:36 +04:00
|
|
|
*
|
2012-02-20 07:52:38 +04:00
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation; either version 2, or (at your option)
|
|
|
|
any later version.
|
2005-04-17 02:20:36 +04:00
|
|
|
*
|
2012-02-20 07:52:38 +04:00
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY OF ANY KIND WHATSOEVER INCLUDING ANY
|
|
|
|
implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
See the GNU General Public License for more details.
|
2005-04-17 02:20:36 +04:00
|
|
|
*
|
2012-02-20 07:52:38 +04:00
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program; if not, write to the Free Software
|
|
|
|
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
2005-04-17 02:20:36 +04:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
#include "platform.h"
|
|
|
|
#include "di_defs.h"
|
|
|
|
#include "pc.h"
|
|
|
|
#include "pr_pc.h"
|
|
|
|
#include "di.h"
|
|
|
|
#include "mi_pc.h"
|
|
|
|
#include "pc_maint.h"
|
|
|
|
#include "divasync.h"
|
|
|
|
#include "pc_init.h"
|
|
|
|
#include "io.h"
|
|
|
|
#include "helpers.h"
|
|
|
|
#include "dsrv4bri.h"
|
|
|
|
#include "dsp_defs.h"
|
|
|
|
#include "sdp_hdr.h"
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
#define MAX_XLOG_SIZE (64 * 1024)
|
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------
|
2012-02-20 07:52:38 +04:00
|
|
|
Recovery XLOG from QBRI Card
|
|
|
|
-------------------------------------------------------------------------- */
|
|
|
|
static void qBri_cpu_trapped(PISDN_ADAPTER IoAdapter) {
|
|
|
|
byte __iomem *base;
|
|
|
|
word *Xlog;
|
|
|
|
dword regs[4], TrapID, offset, size;
|
|
|
|
Xdesc xlogDesc;
|
2005-04-17 02:20:36 +04:00
|
|
|
int factor = (IoAdapter->tasks == 1) ? 1 : 2;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* check for trapped MIPS 46xx CPU, dump exception frame
|
|
|
|
*/
|
|
|
|
|
|
|
|
base = DIVA_OS_MEM_ATTACH_CONTROL(IoAdapter);
|
2012-02-20 07:52:38 +04:00
|
|
|
offset = IoAdapter->ControllerNumber * (IoAdapter->MemorySize >> factor);
|
2005-04-17 02:20:36 +04:00
|
|
|
|
2012-02-20 07:52:38 +04:00
|
|
|
TrapID = READ_DWORD(&base[0x80]);
|
2005-04-17 02:20:36 +04:00
|
|
|
|
2012-02-20 07:52:38 +04:00
|
|
|
if ((TrapID == 0x99999999) || (TrapID == 0x99999901))
|
2005-04-17 02:20:36 +04:00
|
|
|
{
|
2012-02-20 07:52:38 +04:00
|
|
|
dump_trap_frame(IoAdapter, &base[0x90]);
|
|
|
|
IoAdapter->trapped = 1;
|
2005-04-17 02:20:36 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
regs[0] = READ_DWORD((base + offset) + 0x70);
|
|
|
|
regs[1] = READ_DWORD((base + offset) + 0x74);
|
|
|
|
regs[2] = READ_DWORD((base + offset) + 0x78);
|
|
|
|
regs[3] = READ_DWORD((base + offset) + 0x7c);
|
2012-02-20 07:52:38 +04:00
|
|
|
regs[0] &= IoAdapter->MemorySize - 1;
|
2005-04-17 02:20:36 +04:00
|
|
|
|
2012-02-20 07:52:38 +04:00
|
|
|
if ((regs[0] >= offset)
|
|
|
|
&& (regs[0] < offset + (IoAdapter->MemorySize >> factor) - 1))
|
2005-04-17 02:20:36 +04:00
|
|
|
{
|
2012-02-20 07:52:38 +04:00
|
|
|
if (!(Xlog = (word *)diva_os_malloc(0, MAX_XLOG_SIZE))) {
|
2005-04-17 02:20:36 +04:00
|
|
|
DIVA_OS_MEM_DETACH_CONTROL(IoAdapter, base);
|
2012-02-20 07:52:38 +04:00
|
|
|
return;
|
2005-04-17 02:20:36 +04:00
|
|
|
}
|
|
|
|
|
2012-02-20 07:52:38 +04:00
|
|
|
size = offset + (IoAdapter->MemorySize >> factor) - regs[0];
|
|
|
|
if (size > MAX_XLOG_SIZE)
|
|
|
|
size = MAX_XLOG_SIZE;
|
|
|
|
memcpy_fromio(Xlog, &base[regs[0]], size);
|
|
|
|
xlogDesc.buf = Xlog;
|
|
|
|
xlogDesc.cnt = READ_WORD(&base[regs[1] & (IoAdapter->MemorySize - 1)]);
|
|
|
|
xlogDesc.out = READ_WORD(&base[regs[2] & (IoAdapter->MemorySize - 1)]);
|
|
|
|
dump_xlog_buffer(IoAdapter, &xlogDesc);
|
|
|
|
diva_os_free(0, Xlog);
|
|
|
|
IoAdapter->trapped = 2;
|
2005-04-17 02:20:36 +04:00
|
|
|
}
|
|
|
|
DIVA_OS_MEM_DETACH_CONTROL(IoAdapter, base);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------
|
2012-02-20 07:52:38 +04:00
|
|
|
Reset QBRI Hardware
|
|
|
|
-------------------------------------------------------------------------- */
|
|
|
|
static void reset_qBri_hardware(PISDN_ADAPTER IoAdapter) {
|
|
|
|
word volatile __iomem *qBriReset;
|
|
|
|
byte volatile __iomem *qBriCntrl;
|
|
|
|
byte volatile __iomem *p;
|
2005-04-17 02:20:36 +04:00
|
|
|
|
|
|
|
qBriReset = (word volatile __iomem *)DIVA_OS_MEM_ATTACH_PROM(IoAdapter);
|
2012-02-20 07:52:38 +04:00
|
|
|
WRITE_WORD(qBriReset, READ_WORD(qBriReset) | PLX9054_SOFT_RESET);
|
|
|
|
diva_os_wait(1);
|
|
|
|
WRITE_WORD(qBriReset, READ_WORD(qBriReset) & ~PLX9054_SOFT_RESET);
|
|
|
|
diva_os_wait(1);
|
|
|
|
WRITE_WORD(qBriReset, READ_WORD(qBriReset) | PLX9054_RELOAD_EEPROM);
|
|
|
|
diva_os_wait(1);
|
|
|
|
WRITE_WORD(qBriReset, READ_WORD(qBriReset) & ~PLX9054_RELOAD_EEPROM);
|
|
|
|
diva_os_wait(1);
|
2005-04-17 02:20:36 +04:00
|
|
|
DIVA_OS_MEM_DETACH_PROM(IoAdapter, qBriReset);
|
|
|
|
|
|
|
|
qBriCntrl = DIVA_OS_MEM_ATTACH_CTLREG(IoAdapter);
|
|
|
|
p = &qBriCntrl[DIVA_4BRI_REVISION(IoAdapter) ? (MQ2_BREG_RISC) : (MQ_BREG_RISC)];
|
2012-02-20 07:52:38 +04:00
|
|
|
WRITE_DWORD(p, 0);
|
2005-04-17 02:20:36 +04:00
|
|
|
DIVA_OS_MEM_DETACH_CTLREG(IoAdapter, qBriCntrl);
|
|
|
|
|
|
|
|
DBG_TRC(("resetted board @ reset addr 0x%08lx", qBriReset))
|
2012-02-20 07:52:38 +04:00
|
|
|
DBG_TRC(("resetted board @ cntrl addr 0x%08lx", p))
|
|
|
|
}
|
2005-04-17 02:20:36 +04:00
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------
|
2012-02-20 07:52:38 +04:00
|
|
|
Start Card CPU
|
|
|
|
-------------------------------------------------------------------------- */
|
|
|
|
void start_qBri_hardware(PISDN_ADAPTER IoAdapter) {
|
|
|
|
byte volatile __iomem *qBriReset;
|
|
|
|
byte volatile __iomem *p;
|
2005-04-17 02:20:36 +04:00
|
|
|
|
|
|
|
p = DIVA_OS_MEM_ATTACH_CTLREG(IoAdapter);
|
|
|
|
qBriReset = &p[(DIVA_4BRI_REVISION(IoAdapter)) ? (MQ2_BREG_RISC) : (MQ_BREG_RISC)];
|
2012-02-20 07:52:38 +04:00
|
|
|
WRITE_DWORD(qBriReset, MQ_RISC_COLD_RESET_MASK);
|
|
|
|
diva_os_wait(2);
|
|
|
|
WRITE_DWORD(qBriReset, MQ_RISC_WARM_RESET_MASK | MQ_RISC_COLD_RESET_MASK);
|
|
|
|
diva_os_wait(10);
|
2005-04-17 02:20:36 +04:00
|
|
|
DIVA_OS_MEM_DETACH_CTLREG(IoAdapter, p);
|
|
|
|
|
|
|
|
DBG_TRC(("started processor @ addr 0x%08lx", qBriReset))
|
2012-02-20 07:52:38 +04:00
|
|
|
}
|
2005-04-17 02:20:36 +04:00
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------
|
2012-02-20 07:52:38 +04:00
|
|
|
Stop Card CPU
|
|
|
|
-------------------------------------------------------------------------- */
|
|
|
|
static void stop_qBri_hardware(PISDN_ADAPTER IoAdapter) {
|
|
|
|
byte volatile __iomem *p;
|
|
|
|
dword volatile __iomem *qBriReset;
|
|
|
|
dword volatile __iomem *qBriIrq;
|
|
|
|
dword volatile __iomem *qBriIsacDspReset;
|
2005-04-17 02:20:36 +04:00
|
|
|
int rev2 = DIVA_4BRI_REVISION(IoAdapter);
|
|
|
|
int reset_offset = rev2 ? (MQ2_BREG_RISC) : (MQ_BREG_RISC);
|
|
|
|
int irq_offset = rev2 ? (MQ2_BREG_IRQ_TEST) : (MQ_BREG_IRQ_TEST);
|
|
|
|
int hw_offset = rev2 ? (MQ2_ISAC_DSP_RESET) : (MQ_ISAC_DSP_RESET);
|
|
|
|
|
2012-02-20 07:52:38 +04:00
|
|
|
if (IoAdapter->ControllerNumber > 0)
|
|
|
|
return;
|
2005-04-17 02:20:36 +04:00
|
|
|
p = DIVA_OS_MEM_ATTACH_CTLREG(IoAdapter);
|
|
|
|
qBriReset = (dword volatile __iomem *)&p[reset_offset];
|
|
|
|
qBriIsacDspReset = (dword volatile __iomem *)&p[hw_offset];
|
|
|
|
/*
|
|
|
|
* clear interrupt line (reset Local Interrupt Test Register)
|
|
|
|
*/
|
2012-02-20 07:52:38 +04:00
|
|
|
WRITE_DWORD(qBriReset, 0);
|
|
|
|
WRITE_DWORD(qBriIsacDspReset, 0);
|
2005-04-17 02:20:36 +04:00
|
|
|
DIVA_OS_MEM_DETACH_CTLREG(IoAdapter, p);
|
2012-02-20 07:52:38 +04:00
|
|
|
|
2005-04-17 02:20:36 +04:00
|
|
|
p = DIVA_OS_MEM_ATTACH_RESET(IoAdapter);
|
|
|
|
WRITE_BYTE(&p[PLX9054_INTCSR], 0x00); /* disable PCI interrupts */
|
|
|
|
DIVA_OS_MEM_DETACH_RESET(IoAdapter, p);
|
2012-02-20 07:52:38 +04:00
|
|
|
|
2005-04-17 02:20:36 +04:00
|
|
|
p = DIVA_OS_MEM_ATTACH_CTLREG(IoAdapter);
|
|
|
|
qBriIrq = (dword volatile __iomem *)&p[irq_offset];
|
2012-02-20 07:52:38 +04:00
|
|
|
WRITE_DWORD(qBriIrq, MQ_IRQ_REQ_OFF);
|
2005-04-17 02:20:36 +04:00
|
|
|
DIVA_OS_MEM_DETACH_CTLREG(IoAdapter, p);
|
|
|
|
|
|
|
|
DBG_TRC(("stopped processor @ addr 0x%08lx", qBriReset))
|
|
|
|
|
2012-02-20 07:52:38 +04:00
|
|
|
}
|
2005-04-17 02:20:36 +04:00
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------
|
2012-02-20 07:52:38 +04:00
|
|
|
FPGA download
|
|
|
|
-------------------------------------------------------------------------- */
|
2005-04-17 02:20:36 +04:00
|
|
|
#define FPGA_NAME_OFFSET 0x10
|
|
|
|
|
2012-02-20 07:52:38 +04:00
|
|
|
static byte *qBri_check_FPGAsrc(PISDN_ADAPTER IoAdapter, char *FileName,
|
|
|
|
dword *Length, dword *code) {
|
|
|
|
byte *File;
|
|
|
|
char *fpgaFile, *fpgaType, *fpgaDate, *fpgaTime;
|
|
|
|
dword fpgaFlen, fpgaTlen, fpgaDlen, cnt, year, i;
|
2005-04-17 02:20:36 +04:00
|
|
|
|
2012-02-20 07:52:38 +04:00
|
|
|
if (!(File = (byte *)xdiLoadFile(FileName, Length, 0))) {
|
|
|
|
return (NULL);
|
2005-04-17 02:20:36 +04:00
|
|
|
}
|
|
|
|
/*
|
|
|
|
* scan file until FF and put id string into buffer
|
|
|
|
*/
|
2012-02-20 07:52:38 +04:00
|
|
|
for (i = 0; File[i] != 0xff;)
|
2005-04-17 02:20:36 +04:00
|
|
|
{
|
2012-02-20 07:52:38 +04:00
|
|
|
if (++i >= *Length)
|
2005-04-17 02:20:36 +04:00
|
|
|
{
|
|
|
|
DBG_FTL(("FPGA download: start of data header not found"))
|
2012-02-20 07:52:38 +04:00
|
|
|
xdiFreeFile(File);
|
|
|
|
return (NULL);
|
2005-04-17 02:20:36 +04:00
|
|
|
}
|
|
|
|
}
|
2012-02-20 07:52:38 +04:00
|
|
|
*code = i++;
|
2005-04-17 02:20:36 +04:00
|
|
|
|
2012-02-20 07:52:38 +04:00
|
|
|
if ((File[i] & 0xF0) != 0x20)
|
2005-04-17 02:20:36 +04:00
|
|
|
{
|
|
|
|
DBG_FTL(("FPGA download: data header corrupted"))
|
2012-02-20 07:52:38 +04:00
|
|
|
xdiFreeFile(File);
|
|
|
|
return (NULL);
|
2005-04-17 02:20:36 +04:00
|
|
|
}
|
2012-02-20 07:52:38 +04:00
|
|
|
fpgaFlen = (dword)File[FPGA_NAME_OFFSET - 1];
|
|
|
|
if (fpgaFlen == 0)
|
|
|
|
fpgaFlen = 12;
|
|
|
|
fpgaFile = (char *)&File[FPGA_NAME_OFFSET];
|
|
|
|
fpgaTlen = (dword)fpgaFile[fpgaFlen + 2];
|
|
|
|
if (fpgaTlen == 0)
|
|
|
|
fpgaTlen = 10;
|
|
|
|
fpgaType = (char *)&fpgaFile[fpgaFlen + 3];
|
|
|
|
fpgaDlen = (dword) fpgaType[fpgaTlen + 2];
|
|
|
|
if (fpgaDlen == 0)
|
|
|
|
fpgaDlen = 11;
|
|
|
|
fpgaDate = (char *)&fpgaType[fpgaTlen + 3];
|
|
|
|
fpgaTime = (char *)&fpgaDate[fpgaDlen + 3];
|
|
|
|
cnt = (dword)(((File[i] & 0x0F) << 20) + (File[i + 1] << 12)
|
|
|
|
+ (File[i + 2] << 4) + (File[i + 3] >> 4));
|
|
|
|
|
|
|
|
if ((dword)(i + (cnt / 8)) > *Length)
|
2005-04-17 02:20:36 +04:00
|
|
|
{
|
|
|
|
DBG_FTL(("FPGA download: '%s' file too small (%ld < %ld)",
|
2012-02-20 07:52:38 +04:00
|
|
|
FileName, *Length, code + ((cnt + 7) / 8)))
|
|
|
|
xdiFreeFile(File);
|
|
|
|
return (NULL);
|
2005-04-17 02:20:36 +04:00
|
|
|
}
|
2012-02-20 07:52:38 +04:00
|
|
|
i = 0;
|
2005-04-17 02:20:36 +04:00
|
|
|
do
|
|
|
|
{
|
2012-02-20 07:52:38 +04:00
|
|
|
while ((fpgaDate[i] != '\0')
|
|
|
|
&& ((fpgaDate[i] < '0') || (fpgaDate[i] > '9')))
|
2005-04-17 02:20:36 +04:00
|
|
|
{
|
|
|
|
i++;
|
|
|
|
}
|
2012-02-20 07:52:38 +04:00
|
|
|
year = 0;
|
|
|
|
while ((fpgaDate[i] >= '0') && (fpgaDate[i] <= '9'))
|
|
|
|
year = year * 10 + (fpgaDate[i++] - '0');
|
|
|
|
} while ((year < 2000) && (fpgaDate[i] != '\0'));
|
2005-04-17 02:20:36 +04:00
|
|
|
|
|
|
|
switch (IoAdapter->cardType) {
|
2012-02-20 07:52:38 +04:00
|
|
|
case CARDTYPE_DIVASRV_B_2F_PCI:
|
|
|
|
break;
|
2005-04-17 02:20:36 +04:00
|
|
|
|
2012-02-20 07:52:38 +04:00
|
|
|
default:
|
|
|
|
if (year >= 2001) {
|
|
|
|
IoAdapter->fpga_features |= PCINIT_FPGA_PLX_ACCESS_SUPPORTED;
|
|
|
|
}
|
2005-04-17 02:20:36 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
DBG_LOG(("FPGA[%s] file %s (%s %s) len %d",
|
2012-02-20 07:52:38 +04:00
|
|
|
fpgaType, fpgaFile, fpgaDate, fpgaTime, cnt))
|
|
|
|
return (File);
|
2005-04-17 02:20:36 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************/
|
|
|
|
|
|
|
|
#define FPGA_PROG 0x0001 /* PROG enable low */
|
|
|
|
#define FPGA_BUSY 0x0002 /* BUSY high, DONE low */
|
|
|
|
#define FPGA_CS 0x000C /* Enable I/O pins */
|
|
|
|
#define FPGA_CCLK 0x0100
|
|
|
|
#define FPGA_DOUT 0x0400
|
|
|
|
#define FPGA_DIN FPGA_DOUT /* bidirectional I/O */
|
|
|
|
|
2012-02-20 07:52:38 +04:00
|
|
|
int qBri_FPGA_download(PISDN_ADAPTER IoAdapter) {
|
|
|
|
int bit;
|
|
|
|
byte *File;
|
|
|
|
dword code, FileLength;
|
2005-04-17 02:20:36 +04:00
|
|
|
word volatile __iomem *addr = (word volatile __iomem *)DIVA_OS_MEM_ATTACH_PROM(IoAdapter);
|
2012-02-20 07:52:38 +04:00
|
|
|
word val, baseval = FPGA_CS | FPGA_PROG;
|
2005-04-17 02:20:36 +04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (DIVA_4BRI_REVISION(IoAdapter))
|
|
|
|
{
|
2012-02-20 07:52:38 +04:00
|
|
|
char *name;
|
2005-04-17 02:20:36 +04:00
|
|
|
|
|
|
|
switch (IoAdapter->cardType) {
|
2012-02-20 07:52:38 +04:00
|
|
|
case CARDTYPE_DIVASRV_B_2F_PCI:
|
|
|
|
name = "dsbri2f.bit";
|
|
|
|
break;
|
2005-04-17 02:20:36 +04:00
|
|
|
|
2012-02-20 07:52:38 +04:00
|
|
|
case CARDTYPE_DIVASRV_B_2M_V2_PCI:
|
|
|
|
case CARDTYPE_DIVASRV_VOICE_B_2M_V2_PCI:
|
|
|
|
name = "dsbri2m.bit";
|
|
|
|
break;
|
2005-04-17 02:20:36 +04:00
|
|
|
|
2012-02-20 07:52:38 +04:00
|
|
|
default:
|
|
|
|
name = "ds4bri2.bit";
|
2005-04-17 02:20:36 +04:00
|
|
|
}
|
|
|
|
|
2012-02-20 07:52:38 +04:00
|
|
|
File = qBri_check_FPGAsrc(IoAdapter, name,
|
|
|
|
&FileLength, &code);
|
2005-04-17 02:20:36 +04:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2012-02-20 07:52:38 +04:00
|
|
|
File = qBri_check_FPGAsrc(IoAdapter, "ds4bri.bit",
|
|
|
|
&FileLength, &code);
|
2005-04-17 02:20:36 +04:00
|
|
|
}
|
2012-02-20 07:52:38 +04:00
|
|
|
if (!File) {
|
2005-04-17 02:20:36 +04:00
|
|
|
DIVA_OS_MEM_DETACH_PROM(IoAdapter, addr);
|
2012-02-20 07:52:38 +04:00
|
|
|
return (0);
|
2005-04-17 02:20:36 +04:00
|
|
|
}
|
|
|
|
/*
|
|
|
|
* prepare download, pulse PROGRAM pin down.
|
|
|
|
*/
|
2012-02-20 07:52:38 +04:00
|
|
|
WRITE_WORD(addr, baseval & ~FPGA_PROG); /* PROGRAM low pulse */
|
|
|
|
WRITE_WORD(addr, baseval); /* release */
|
|
|
|
diva_os_wait(50); /* wait until FPGA finished internal memory clear */
|
2005-04-17 02:20:36 +04:00
|
|
|
/*
|
|
|
|
* check done pin, must be low
|
|
|
|
*/
|
2012-02-20 07:52:38 +04:00
|
|
|
if (READ_WORD(addr) & FPGA_BUSY)
|
2005-04-17 02:20:36 +04:00
|
|
|
{
|
|
|
|
DBG_FTL(("FPGA download: acknowledge for FPGA memory clear missing"))
|
2012-02-20 07:52:38 +04:00
|
|
|
xdiFreeFile(File);
|
2005-04-17 02:20:36 +04:00
|
|
|
DIVA_OS_MEM_DETACH_PROM(IoAdapter, addr);
|
2012-02-20 07:52:38 +04:00
|
|
|
return (0);
|
2005-04-17 02:20:36 +04:00
|
|
|
}
|
|
|
|
/*
|
|
|
|
* put data onto the FPGA
|
|
|
|
*/
|
2012-02-20 07:52:38 +04:00
|
|
|
while (code < FileLength)
|
2005-04-17 02:20:36 +04:00
|
|
|
{
|
2012-02-20 07:52:38 +04:00
|
|
|
val = ((word)File[code++]) << 3;
|
2005-04-17 02:20:36 +04:00
|
|
|
|
2012-02-20 07:52:38 +04:00
|
|
|
for (bit = 8; bit-- > 0; val <<= 1) /* put byte onto FPGA */
|
2005-04-17 02:20:36 +04:00
|
|
|
{
|
2012-02-20 07:52:38 +04:00
|
|
|
baseval &= ~FPGA_DOUT; /* clr data bit */
|
|
|
|
baseval |= (val & FPGA_DOUT); /* copy data bit */
|
|
|
|
WRITE_WORD(addr, baseval);
|
|
|
|
WRITE_WORD(addr, baseval | FPGA_CCLK); /* set CCLK hi */
|
|
|
|
WRITE_WORD(addr, baseval | FPGA_CCLK); /* set CCLK hi */
|
|
|
|
WRITE_WORD(addr, baseval); /* set CCLK lo */
|
2005-04-17 02:20:36 +04:00
|
|
|
}
|
|
|
|
}
|
2012-02-20 07:52:38 +04:00
|
|
|
xdiFreeFile(File);
|
|
|
|
diva_os_wait(100);
|
|
|
|
val = READ_WORD(addr);
|
2005-04-17 02:20:36 +04:00
|
|
|
|
|
|
|
DIVA_OS_MEM_DETACH_PROM(IoAdapter, addr);
|
|
|
|
|
2012-02-20 07:52:38 +04:00
|
|
|
if (!(val & FPGA_BUSY))
|
2005-04-17 02:20:36 +04:00
|
|
|
{
|
|
|
|
DBG_FTL(("FPGA download: chip remains in busy state (0x%04x)", val))
|
2012-02-20 07:52:38 +04:00
|
|
|
return (0);
|
2005-04-17 02:20:36 +04:00
|
|
|
}
|
|
|
|
|
2012-02-20 07:52:38 +04:00
|
|
|
return (1);
|
2005-04-17 02:20:36 +04:00
|
|
|
}
|
|
|
|
|
2012-02-20 07:52:38 +04:00
|
|
|
static int load_qBri_hardware(PISDN_ADAPTER IoAdapter) {
|
2005-04-17 02:20:36 +04:00
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------
|
2012-02-20 07:52:38 +04:00
|
|
|
Card ISR
|
|
|
|
-------------------------------------------------------------------------- */
|
|
|
|
static int qBri_ISR(struct _ISDN_ADAPTER *IoAdapter) {
|
|
|
|
dword volatile __iomem *qBriIrq;
|
2005-04-17 02:20:36 +04:00
|
|
|
|
2012-02-20 07:52:38 +04:00
|
|
|
PADAPTER_LIST_ENTRY QuadroList = IoAdapter->QuadroList;
|
2005-04-17 02:20:36 +04:00
|
|
|
|
2012-02-20 07:52:38 +04:00
|
|
|
word i;
|
|
|
|
int serviced = 0;
|
2005-04-17 02:20:36 +04:00
|
|
|
byte __iomem *p;
|
|
|
|
|
|
|
|
p = DIVA_OS_MEM_ATTACH_RESET(IoAdapter);
|
|
|
|
|
2012-02-20 07:52:38 +04:00
|
|
|
if (!(READ_BYTE(&p[PLX9054_INTCSR]) & 0x80)) {
|
2005-04-17 02:20:36 +04:00
|
|
|
DIVA_OS_MEM_DETACH_RESET(IoAdapter, p);
|
2012-02-20 07:52:38 +04:00
|
|
|
return (0);
|
2005-04-17 02:20:36 +04:00
|
|
|
}
|
|
|
|
DIVA_OS_MEM_DETACH_RESET(IoAdapter, p);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* clear interrupt line (reset Local Interrupt Test Register)
|
|
|
|
*/
|
|
|
|
p = DIVA_OS_MEM_ATTACH_CTLREG(IoAdapter);
|
|
|
|
qBriIrq = (dword volatile __iomem *)(&p[DIVA_4BRI_REVISION(IoAdapter) ? (MQ2_BREG_IRQ_TEST) : (MQ_BREG_IRQ_TEST)]);
|
2012-02-20 07:52:38 +04:00
|
|
|
WRITE_DWORD(qBriIrq, MQ_IRQ_REQ_OFF);
|
2005-04-17 02:20:36 +04:00
|
|
|
DIVA_OS_MEM_DETACH_CTLREG(IoAdapter, p);
|
|
|
|
|
2012-02-20 07:52:38 +04:00
|
|
|
for (i = 0; i < IoAdapter->tasks; ++i)
|
2005-04-17 02:20:36 +04:00
|
|
|
{
|
2012-02-20 07:52:38 +04:00
|
|
|
IoAdapter = QuadroList->QuadroAdapter[i];
|
2005-04-17 02:20:36 +04:00
|
|
|
|
2012-02-20 07:52:38 +04:00
|
|
|
if (IoAdapter && IoAdapter->Initialized
|
|
|
|
&& IoAdapter->tst_irq(&IoAdapter->a))
|
2005-04-17 02:20:36 +04:00
|
|
|
{
|
2012-02-20 07:52:38 +04:00
|
|
|
IoAdapter->IrqCount++;
|
|
|
|
serviced = 1;
|
|
|
|
diva_os_schedule_soft_isr(&IoAdapter->isr_soft_isr);
|
2005-04-17 02:20:36 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-02-20 07:52:38 +04:00
|
|
|
return (serviced);
|
2005-04-17 02:20:36 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------
|
2012-02-20 07:52:38 +04:00
|
|
|
Does disable the interrupt on the card
|
|
|
|
-------------------------------------------------------------------------- */
|
|
|
|
static void disable_qBri_interrupt(PISDN_ADAPTER IoAdapter) {
|
|
|
|
dword volatile __iomem *qBriIrq;
|
2005-04-17 02:20:36 +04:00
|
|
|
byte __iomem *p;
|
|
|
|
|
2012-02-20 07:52:38 +04:00
|
|
|
if (IoAdapter->ControllerNumber > 0)
|
|
|
|
return;
|
2005-04-17 02:20:36 +04:00
|
|
|
/*
|
|
|
|
* clear interrupt line (reset Local Interrupt Test Register)
|
|
|
|
*/
|
|
|
|
p = DIVA_OS_MEM_ATTACH_RESET(IoAdapter);
|
|
|
|
WRITE_BYTE(&p[PLX9054_INTCSR], 0x00); /* disable PCI interrupts */
|
|
|
|
DIVA_OS_MEM_DETACH_RESET(IoAdapter, p);
|
|
|
|
|
|
|
|
p = DIVA_OS_MEM_ATTACH_CTLREG(IoAdapter);
|
|
|
|
qBriIrq = (dword volatile __iomem *)(&p[DIVA_4BRI_REVISION(IoAdapter) ? (MQ2_BREG_IRQ_TEST) : (MQ_BREG_IRQ_TEST)]);
|
2012-02-20 07:52:38 +04:00
|
|
|
WRITE_DWORD(qBriIrq, MQ_IRQ_REQ_OFF);
|
2005-04-17 02:20:36 +04:00
|
|
|
DIVA_OS_MEM_DETACH_CTLREG(IoAdapter, p);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------
|
2012-02-20 07:52:38 +04:00
|
|
|
Install Adapter Entry Points
|
|
|
|
-------------------------------------------------------------------------- */
|
|
|
|
static void set_common_qBri_functions(PISDN_ADAPTER IoAdapter) {
|
2005-04-17 02:20:36 +04:00
|
|
|
ADAPTER *a;
|
|
|
|
|
2012-02-20 07:52:38 +04:00
|
|
|
a = &IoAdapter->a;
|
2005-04-17 02:20:36 +04:00
|
|
|
|
2012-02-20 07:52:38 +04:00
|
|
|
a->ram_in = mem_in;
|
|
|
|
a->ram_inw = mem_inw;
|
|
|
|
a->ram_in_buffer = mem_in_buffer;
|
|
|
|
a->ram_look_ahead = mem_look_ahead;
|
|
|
|
a->ram_out = mem_out;
|
|
|
|
a->ram_outw = mem_outw;
|
|
|
|
a->ram_out_buffer = mem_out_buffer;
|
|
|
|
a->ram_inc = mem_inc;
|
2005-04-17 02:20:36 +04:00
|
|
|
|
2012-02-20 07:52:38 +04:00
|
|
|
IoAdapter->out = pr_out;
|
|
|
|
IoAdapter->dpc = pr_dpc;
|
|
|
|
IoAdapter->tst_irq = scom_test_int;
|
|
|
|
IoAdapter->clr_irq = scom_clear_int;
|
|
|
|
IoAdapter->pcm = (struct pc_maint *)MIPS_MAINT_OFFS;
|
2005-04-17 02:20:36 +04:00
|
|
|
|
2012-02-20 07:52:38 +04:00
|
|
|
IoAdapter->load = load_qBri_hardware;
|
2005-04-17 02:20:36 +04:00
|
|
|
|
2012-02-20 07:52:38 +04:00
|
|
|
IoAdapter->disIrq = disable_qBri_interrupt;
|
|
|
|
IoAdapter->rstFnc = reset_qBri_hardware;
|
|
|
|
IoAdapter->stop = stop_qBri_hardware;
|
|
|
|
IoAdapter->trapFnc = qBri_cpu_trapped;
|
2005-04-17 02:20:36 +04:00
|
|
|
|
|
|
|
IoAdapter->diva_isr_handler = qBri_ISR;
|
|
|
|
|
2012-02-20 07:52:38 +04:00
|
|
|
IoAdapter->a.io = (void *)IoAdapter;
|
2005-04-17 02:20:36 +04:00
|
|
|
}
|
|
|
|
|
2012-02-20 07:52:38 +04:00
|
|
|
static void set_qBri_functions(PISDN_ADAPTER IoAdapter) {
|
2005-04-17 02:20:36 +04:00
|
|
|
if (!IoAdapter->tasks) {
|
|
|
|
IoAdapter->tasks = MQ_INSTANCE_COUNT;
|
|
|
|
}
|
2012-02-20 07:52:38 +04:00
|
|
|
IoAdapter->MemorySize = MQ_MEMORY_SIZE;
|
|
|
|
set_common_qBri_functions(IoAdapter);
|
|
|
|
diva_os_set_qBri_functions(IoAdapter);
|
2005-04-17 02:20:36 +04:00
|
|
|
}
|
|
|
|
|
2012-02-20 07:52:38 +04:00
|
|
|
static void set_qBri2_functions(PISDN_ADAPTER IoAdapter) {
|
2005-04-17 02:20:36 +04:00
|
|
|
if (!IoAdapter->tasks) {
|
|
|
|
IoAdapter->tasks = MQ_INSTANCE_COUNT;
|
|
|
|
}
|
|
|
|
IoAdapter->MemorySize = (IoAdapter->tasks == 1) ? BRI2_MEMORY_SIZE : MQ2_MEMORY_SIZE;
|
2012-02-20 07:52:38 +04:00
|
|
|
set_common_qBri_functions(IoAdapter);
|
|
|
|
diva_os_set_qBri2_functions(IoAdapter);
|
2005-04-17 02:20:36 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************/
|
|
|
|
|
2012-02-20 07:52:38 +04:00
|
|
|
void prepare_qBri_functions(PISDN_ADAPTER IoAdapter) {
|
2005-04-17 02:20:36 +04:00
|
|
|
|
2012-02-20 07:52:38 +04:00
|
|
|
set_qBri_functions(IoAdapter->QuadroList->QuadroAdapter[0]);
|
|
|
|
set_qBri_functions(IoAdapter->QuadroList->QuadroAdapter[1]);
|
|
|
|
set_qBri_functions(IoAdapter->QuadroList->QuadroAdapter[2]);
|
|
|
|
set_qBri_functions(IoAdapter->QuadroList->QuadroAdapter[3]);
|
2005-04-17 02:20:36 +04:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2012-02-20 07:52:38 +04:00
|
|
|
void prepare_qBri2_functions(PISDN_ADAPTER IoAdapter) {
|
2005-04-17 02:20:36 +04:00
|
|
|
if (!IoAdapter->tasks) {
|
|
|
|
IoAdapter->tasks = MQ_INSTANCE_COUNT;
|
|
|
|
}
|
|
|
|
|
2012-02-20 07:52:38 +04:00
|
|
|
set_qBri2_functions(IoAdapter->QuadroList->QuadroAdapter[0]);
|
2005-04-17 02:20:36 +04:00
|
|
|
if (IoAdapter->tasks > 1) {
|
2012-02-20 07:52:38 +04:00
|
|
|
set_qBri2_functions(IoAdapter->QuadroList->QuadroAdapter[1]);
|
|
|
|
set_qBri2_functions(IoAdapter->QuadroList->QuadroAdapter[2]);
|
|
|
|
set_qBri2_functions(IoAdapter->QuadroList->QuadroAdapter[3]);
|
2005-04-17 02:20:36 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/* -------------------------------------------------------------------------- */
|