/* $Id: os_pri.c,v 1.32 2004/03/21 17:26:01 armin Exp $ */
#include "platform.h"
#include "debuglib.h"
#include "cardtype.h"
#include "pc.h"
#include "pr_pc.h"
#include "di_defs.h"
#include "dsp_defs.h"
#include "di.h"
#include "io.h"
#include "xdi_msg.h"
#include "xdi_adapter.h"
#include "os_pri.h"
#include "diva_pci.h"
#include "mi_pc.h"
#include "pc_maint.h"
#include "dsp_tst.h"
#include "diva_dma.h"
#include "dsrv_pri.h"
/* --------------------------------------------------------------------------
OS Dependent part of XDI driver for DIVA PRI Adapter
DSP detection/validation by Anthony Booth (Eicon Networks, www.eicon.com)
-------------------------------------------------------------------------- */
#define DIVA_PRI_NO_PCI_BIOS_WORKAROUND 1
extern int diva_card_read_xlog(diva_os_xdi_adapter_t * a);
/*
** IMPORTS
*/
extern void prepare_pri_functions(PISDN_ADAPTER IoAdapter);
extern void prepare_pri2_functions(PISDN_ADAPTER IoAdapter);
extern void diva_xdi_display_adapter_features(int card);
static int diva_pri_cleanup_adapter(diva_os_xdi_adapter_t * a);
static int diva_pri_cmd_card_proc(struct _diva_os_xdi_adapter *a,
diva_xdi_um_cfg_cmd_t * cmd, int length);
static int pri_get_serial_number(diva_os_xdi_adapter_t * a);
static int diva_pri_stop_adapter(diva_os_xdi_adapter_t * a);
static dword diva_pri_detect_dsps(diva_os_xdi_adapter_t * a);
/*
** Check card revision
*/
static int pri_is_rev_2_card(int card_ordinal)
{
switch (card_ordinal) {
case CARDTYPE_DIVASRV_P_30M_V2_PCI:
case CARDTYPE_DIVASRV_VOICE_P_30M_V2_PCI:
return (1);
}
return (0);
}
static void diva_pri_set_addresses(diva_os_xdi_adapter_t * a)
{
a->resources.pci.mem_type_id[MEM_TYPE_ADDRESS] = 0;
a->resources.pci.mem_type_id[MEM_TYPE_CONTROL] = 2;
a->resources.pci.mem_type_id[MEM_TYPE_CONFIG] = 4;
a->resources.pci.mem_type_id[MEM_TYPE_RAM] = 0;
a->resources.pci.mem_type_id[MEM_TYPE_RESET] = 2;
a->resources.pci.mem_type_id[MEM_TYPE_CFG] = 4;
a->resources.pci.mem_type_id[MEM_TYPE_PROM] = 3;
a->xdi_adapter.Address = a->resources.pci.addr[0];
a->xdi_adapter.Control = a->resources.pci.addr[2];
a->xdi_adapter.Config = a->resources.pci.addr[4];
a->xdi_adapter.ram = a->resources.pci.addr[0];
a->xdi_adapter.ram += MP_SHARED_RAM_OFFSET;
a->xdi_adapter.reset = a->resources.pci.addr[2];
a->xdi_adapter.reset += MP_RESET;
a->xdi_adapter.cfg = a->resources.pci.addr[4];
a->xdi_adapter.cfg += MP_IRQ_RESET;
a->xdi_adapter.sdram_bar = a->resources.pci.bar[0];
a->xdi_adapter.prom = a->resources.pci.addr[3];
}
/*
** BAR0 - SDRAM, MP_MEMORY_SIZE, MP2_MEMORY_SIZE by Rev.2
** BAR1 - DEVICES, 0x1000
** BAR2 - CONTROL (REG), 0x2000
** BAR3 - FLASH (REG), 0x8000
** BAR4 - CONFIG (CFG), 0x1000
*/
int diva_pri_init_card(diva_os_xdi_adapter_t * a)
{
int bar = 0;
int pri_rev_2;
unsigned long bar_length[5] = {
MP_MEMORY_SIZE,
0x1000,
0x2000,
0x8000,
0x1000
};
pri_rev_2 = pri_is_rev_2_card(a->CardOrdinal);
if (pri_rev_2) {
bar_length[0] = MP2_MEMORY_SIZE;
}
/*
Set properties
*/
a->xdi_adapter.Properties = CardProperties[a->CardOrdinal];
DBG_LOG(("Load %s", a->xdi_adapter.Properties.Name))
/*
First initialization step: get and check hardware resoures.
Do not map resources and do not acecess card at this step
*/
for (bar = 0; bar < 5; bar++) {
a->resources.pci.bar[bar] =
divasa_get_pci_bar(a->resources.pci.bus,
a->resources.pci.func, bar,
a->resources.pci.hdev);
if