License cleanup: add SPDX GPL-2.0 license identifier to files with no license
Many source files in the tree are missing licensing information, which
makes it harder for compliance tools to determine the correct license.
By default all files without license information are under the default
license of the kernel, which is GPL version 2.
Update the files which contain no license information with the 'GPL-2.0'
SPDX license identifier. The SPDX identifier is a legally binding
shorthand, which can be used instead of the full boiler plate text.
This patch is based on work done by Thomas Gleixner and Kate Stewart and
Philippe Ombredanne.
How this work was done:
Patches were generated and checked against linux-4.14-rc6 for a subset of
the use cases:
- file had no licensing information it it.
- file was a */uapi/* one with no licensing information in it,
- file was a */uapi/* one with existing licensing information,
Further patches will be generated in subsequent months to fix up cases
where non-standard license headers were used, and references to license
had to be inferred by heuristics based on keywords.
The analysis to determine which SPDX License Identifier to be applied to
a file was done in a spreadsheet of side by side results from of the
output of two independent scanners (ScanCode & Windriver) producing SPDX
tag:value files created by Philippe Ombredanne. Philippe prepared the
base worksheet, and did an initial spot review of a few 1000 files.
The 4.13 kernel was the starting point of the analysis with 60,537 files
assessed. Kate Stewart did a file by file comparison of the scanner
results in the spreadsheet to determine which SPDX license identifier(s)
to be applied to the file. She confirmed any determination that was not
immediately clear with lawyers working with the Linux Foundation.
Criteria used to select files for SPDX license identifier tagging was:
- Files considered eligible had to be source code files.
- Make and config files were included as candidates if they contained >5
lines of source
- File already had some variant of a license header in it (even if <5
lines).
All documentation files were explicitly excluded.
The following heuristics were used to determine which SPDX license
identifiers to apply.
- when both scanners couldn't find any license traces, file was
considered to have no license information in it, and the top level
COPYING file license applied.
For non */uapi/* files that summary was:
SPDX license identifier # files
---------------------------------------------------|-------
GPL-2.0 11139
and resulted in the first patch in this series.
If that file was a */uapi/* path one, it was "GPL-2.0 WITH
Linux-syscall-note" otherwise it was "GPL-2.0". Results of that was:
SPDX license identifier # files
---------------------------------------------------|-------
GPL-2.0 WITH Linux-syscall-note 930
and resulted in the second patch in this series.
- if a file had some form of licensing information in it, and was one
of the */uapi/* ones, it was denoted with the Linux-syscall-note if
any GPL family license was found in the file or had no licensing in
it (per prior point). Results summary:
SPDX license identifier # files
---------------------------------------------------|------
GPL-2.0 WITH Linux-syscall-note 270
GPL-2.0+ WITH Linux-syscall-note 169
((GPL-2.0 WITH Linux-syscall-note) OR BSD-2-Clause) 21
((GPL-2.0 WITH Linux-syscall-note) OR BSD-3-Clause) 17
LGPL-2.1+ WITH Linux-syscall-note 15
GPL-1.0+ WITH Linux-syscall-note 14
((GPL-2.0+ WITH Linux-syscall-note) OR BSD-3-Clause) 5
LGPL-2.0+ WITH Linux-syscall-note 4
LGPL-2.1 WITH Linux-syscall-note 3
((GPL-2.0 WITH Linux-syscall-note) OR MIT) 3
((GPL-2.0 WITH Linux-syscall-note) AND MIT) 1
and that resulted in the third patch in this series.
- when the two scanners agreed on the detected license(s), that became
the concluded license(s).
- when there was disagreement between the two scanners (one detected a
license but the other didn't, or they both detected different
licenses) a manual inspection of the file occurred.
- In most cases a manual inspection of the information in the file
resulted in a clear resolution of the license that should apply (and
which scanner probably needed to revisit its heuristics).
- When it was not immediately clear, the license identifier was
confirmed with lawyers working with the Linux Foundation.
- If there was any question as to the appropriate license identifier,
the file was flagged for further research and to be revisited later
in time.
In total, over 70 hours of logged manual review was done on the
spreadsheet to determine the SPDX license identifiers to apply to the
source files by Kate, Philippe, Thomas and, in some cases, confirmation
by lawyers working with the Linux Foundation.
Kate also obtained a third independent scan of the 4.13 code base from
FOSSology, and compared selected files where the other two scanners
disagreed against that SPDX file, to see if there was new insights. The
Windriver scanner is based on an older version of FOSSology in part, so
they are related.
Thomas did random spot checks in about 500 files from the spreadsheets
for the uapi headers and agreed with SPDX license identifier in the
files he inspected. For the non-uapi files Thomas did random spot checks
in about 15000 files.
In initial set of patches against 4.14-rc6, 3 files were found to have
copy/paste license identifier errors, and have been fixed to reflect the
correct identifier.
Additionally Philippe spent 10 hours this week doing a detailed manual
inspection and review of the 12,461 patched files from the initial patch
version early this week with:
- a full scancode scan run, collecting the matched texts, detected
license ids and scores
- reviewing anything where there was a license detected (about 500+
files) to ensure that the applied SPDX license was correct
- reviewing anything where there was no detection but the patch license
was not GPL-2.0 WITH Linux-syscall-note to ensure that the applied
SPDX license was correct
This produced a worksheet with 20 files needing minor correction. This
worksheet was then exported into 3 different .csv files for the
different types of files to be modified.
These .csv files were then reviewed by Greg. Thomas wrote a script to
parse the csv files and add the proper SPDX tag to the file, in the
format that the file expected. This script was further refined by Greg
based on the output to detect more types of files automatically and to
distinguish between header and source .c files (which need different
comment types.) Finally Greg ran the script using the .csv files to
generate the patches.
Reviewed-by: Kate Stewart <kstewart@linuxfoundation.org>
Reviewed-by: Philippe Ombredanne <pombredanne@nexb.com>
Reviewed-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-11-01 22:07:57 +08:00
|
|
|
// SPDX-License-Identifier: GPL-2.0
|
2005-04-17 06:20:36 +08:00
|
|
|
/* $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"
|
2006-01-08 17:05:15 +08:00
|
|
|
#include "dsrv_pri.h"
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------
|
|
|
|
OS Dependent part of XDI driver for DIVA PRI Adapter
|
|
|
|
|
|
|
|
DSP detection/validation by Anthony Booth (Eicon Networks, www.eicon.com)
|
2012-02-20 11:52:38 +08:00
|
|
|
-------------------------------------------------------------------------- */
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
#define DIVA_PRI_NO_PCI_BIOS_WORKAROUND 1
|
|
|
|
|
2012-02-20 11:52:38 +08:00
|
|
|
extern int diva_card_read_xlog(diva_os_xdi_adapter_t *a);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
/*
|
|
|
|
** 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);
|
|
|
|
|
2012-02-20 11:52:38 +08:00
|
|
|
static int diva_pri_cleanup_adapter(diva_os_xdi_adapter_t *a);
|
2005-04-17 06:20:36 +08:00
|
|
|
static int diva_pri_cmd_card_proc(struct _diva_os_xdi_adapter *a,
|
2012-02-20 11:52:38 +08:00
|
|
|
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);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
/*
|
|
|
|
** 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);
|
|
|
|
}
|
|
|
|
|
2012-02-20 11:52:38 +08:00
|
|
|
static void diva_pri_set_addresses(diva_os_xdi_adapter_t *a)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
|
|
|
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;
|
2012-02-20 11:52:38 +08:00
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
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
|
|
|
|
*/
|
2012-02-20 11:52:38 +08:00
|
|
|
int diva_pri_init_card(diva_os_xdi_adapter_t *a)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
/*
|
2012-02-20 11:52:38 +08:00
|
|
|
Set properties
|
|
|
|
*/
|
2005-04-17 06:20:36 +08:00
|
|
|
a->xdi_adapter.Properties = CardProperties[a->CardOrdinal];
|
|
|
|
DBG_LOG(("Load %s", a->xdi_adapter.Properties.Name))
|
|
|
|
|
2012-02-20 11:52:38 +08:00
|
|
|
/*
|
|
|
|
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 (!a->resources.pci.bar[bar]
|
|
|
|
|| (a->resources.pci.bar[bar] == 0xFFFFFFF0)) {
|
|
|
|
DBG_ERR(("A: invalid bar[%d]=%08x", bar,
|
|
|
|
a->resources.pci.bar[bar]))
|
|
|
|
return (-1);
|
|
|
|
}
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
a->resources.pci.irq =
|
2012-02-20 11:52:38 +08:00
|
|
|
(byte) divasa_get_pci_irq(a->resources.pci.bus,
|
|
|
|
a->resources.pci.func,
|
|
|
|
a->resources.pci.hdev);
|
2005-04-17 06:20:36 +08:00
|
|
|
if (!a->resources.pci.irq) {
|
|
|
|
DBG_ERR(("A: invalid irq"));
|
|
|
|
return (-1);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2012-02-20 11:52:38 +08:00
|
|
|
Map all BAR's
|
|
|
|
*/
|
2005-04-17 06:20:36 +08:00
|
|
|
for (bar = 0; bar < 5; bar++) {
|
|
|
|
a->resources.pci.addr[bar] =
|
2012-02-20 11:52:38 +08:00
|
|
|
divasa_remap_pci_bar(a, bar, a->resources.pci.bar[bar],
|
|
|
|
bar_length[bar]);
|
2005-04-17 06:20:36 +08:00
|
|
|
if (!a->resources.pci.addr[bar]) {
|
|
|
|
DBG_ERR(("A: A(%d), can't map bar[%d]",
|
|
|
|
a->controller, bar))
|
2012-02-20 11:52:38 +08:00
|
|
|
diva_pri_cleanup_adapter(a);
|
2005-04-17 06:20:36 +08:00
|
|
|
return (-1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2012-02-20 11:52:38 +08:00
|
|
|
Set all memory areas
|
|
|
|
*/
|
2005-04-17 06:20:36 +08:00
|
|
|
diva_pri_set_addresses(a);
|
|
|
|
|
|
|
|
/*
|
2012-02-20 11:52:38 +08:00
|
|
|
Get Serial Number of this adapter
|
|
|
|
*/
|
2005-04-17 06:20:36 +08:00
|
|
|
if (pri_get_serial_number(a)) {
|
|
|
|
dword serNo;
|
|
|
|
serNo = a->resources.pci.bar[1] & 0xffff0000;
|
|
|
|
serNo |= ((dword) a->resources.pci.bus) << 8;
|
|
|
|
serNo += (a->resources.pci.func + a->controller + 1);
|
|
|
|
a->xdi_adapter.serialNo = serNo & ~0xFF000000;
|
|
|
|
DBG_ERR(("A: A(%d) can't get Serial Number, generated serNo=%ld",
|
|
|
|
a->controller, a->xdi_adapter.serialNo))
|
2012-02-20 11:52:38 +08:00
|
|
|
}
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
|
|
|
|
/*
|
2012-02-20 11:52:38 +08:00
|
|
|
Initialize os objects
|
|
|
|
*/
|
2005-04-17 06:20:36 +08:00
|
|
|
if (diva_os_initialize_spin_lock(&a->xdi_adapter.isr_spin_lock, "isr")) {
|
|
|
|
diva_pri_cleanup_adapter(a);
|
|
|
|
return (-1);
|
|
|
|
}
|
|
|
|
if (diva_os_initialize_spin_lock
|
|
|
|
(&a->xdi_adapter.data_spin_lock, "data")) {
|
|
|
|
diva_pri_cleanup_adapter(a);
|
|
|
|
return (-1);
|
|
|
|
}
|
|
|
|
|
|
|
|
strcpy(a->xdi_adapter.req_soft_isr.dpc_thread_name, "kdivasprid");
|
|
|
|
|
|
|
|
if (diva_os_initialize_soft_isr(&a->xdi_adapter.req_soft_isr,
|
|
|
|
DIDpcRoutine, &a->xdi_adapter)) {
|
|
|
|
diva_pri_cleanup_adapter(a);
|
|
|
|
return (-1);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2012-02-20 11:52:38 +08:00
|
|
|
Do not initialize second DPC - only one thread will be created
|
|
|
|
*/
|
2005-04-17 06:20:36 +08:00
|
|
|
a->xdi_adapter.isr_soft_isr.object =
|
2012-02-20 11:52:38 +08:00
|
|
|
a->xdi_adapter.req_soft_isr.object;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
/*
|
2012-02-20 11:52:38 +08:00
|
|
|
Next step of card initialization:
|
|
|
|
set up all interface pointers
|
|
|
|
*/
|
2005-04-17 06:20:36 +08:00
|
|
|
a->xdi_adapter.Channels = CardProperties[a->CardOrdinal].Channels;
|
|
|
|
a->xdi_adapter.e_max = CardProperties[a->CardOrdinal].E_info;
|
|
|
|
|
|
|
|
a->xdi_adapter.e_tbl =
|
2012-02-20 11:52:38 +08:00
|
|
|
diva_os_malloc(0, a->xdi_adapter.e_max * sizeof(E_INFO));
|
2005-04-17 06:20:36 +08:00
|
|
|
if (!a->xdi_adapter.e_tbl) {
|
|
|
|
diva_pri_cleanup_adapter(a);
|
|
|
|
return (-1);
|
|
|
|
}
|
|
|
|
memset(a->xdi_adapter.e_tbl, 0x00, a->xdi_adapter.e_max * sizeof(E_INFO));
|
|
|
|
|
|
|
|
a->xdi_adapter.a.io = &a->xdi_adapter;
|
|
|
|
a->xdi_adapter.DIRequest = request;
|
|
|
|
a->interface.cleanup_adapter_proc = diva_pri_cleanup_adapter;
|
|
|
|
a->interface.cmd_proc = diva_pri_cmd_card_proc;
|
|
|
|
|
|
|
|
if (pri_rev_2) {
|
|
|
|
prepare_pri2_functions(&a->xdi_adapter);
|
|
|
|
} else {
|
|
|
|
prepare_pri_functions(&a->xdi_adapter);
|
|
|
|
}
|
|
|
|
|
|
|
|
a->dsp_mask = diva_pri_detect_dsps(a);
|
|
|
|
|
|
|
|
/*
|
2012-02-20 11:52:38 +08:00
|
|
|
Allocate DMA map
|
|
|
|
*/
|
2005-04-17 06:20:36 +08:00
|
|
|
if (pri_rev_2) {
|
|
|
|
diva_init_dma_map(a->resources.pci.hdev,
|
|
|
|
(struct _diva_dma_map_entry **) &a->xdi_adapter.dma_map, 32);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2012-02-20 11:52:38 +08:00
|
|
|
Set IRQ handler
|
|
|
|
*/
|
2005-04-17 06:20:36 +08:00
|
|
|
a->xdi_adapter.irq_info.irq_nr = a->resources.pci.irq;
|
|
|
|
sprintf(a->xdi_adapter.irq_info.irq_name,
|
|
|
|
"DIVA PRI %ld", (long) a->xdi_adapter.serialNo);
|
|
|
|
|
|
|
|
if (diva_os_register_irq(a, a->xdi_adapter.irq_info.irq_nr,
|
|
|
|
a->xdi_adapter.irq_info.irq_name)) {
|
|
|
|
diva_pri_cleanup_adapter(a);
|
|
|
|
return (-1);
|
|
|
|
}
|
|
|
|
a->xdi_adapter.irq_info.registered = 1;
|
|
|
|
|
|
|
|
diva_log_info("%s IRQ:%d SerNo:%d", a->xdi_adapter.Properties.Name,
|
|
|
|
a->resources.pci.irq, a->xdi_adapter.serialNo);
|
|
|
|
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
2012-02-20 11:52:38 +08:00
|
|
|
static int diva_pri_cleanup_adapter(diva_os_xdi_adapter_t *a)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
|
|
|
int bar = 0;
|
|
|
|
|
|
|
|
/*
|
2012-02-20 11:52:38 +08:00
|
|
|
Stop Adapter if adapter is running
|
|
|
|
*/
|
2005-04-17 06:20:36 +08:00
|
|
|
if (a->xdi_adapter.Initialized) {
|
|
|
|
diva_pri_stop_adapter(a);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2012-02-20 11:52:38 +08:00
|
|
|
Remove ISR Handler
|
|
|
|
*/
|
2005-04-17 06:20:36 +08:00
|
|
|
if (a->xdi_adapter.irq_info.registered) {
|
|
|
|
diva_os_remove_irq(a, a->xdi_adapter.irq_info.irq_nr);
|
|
|
|
}
|
|
|
|
a->xdi_adapter.irq_info.registered = 0;
|
|
|
|
|
|
|
|
/*
|
2012-02-20 11:52:38 +08:00
|
|
|
Step 1: unmap all BAR's, if any was mapped
|
|
|
|
*/
|
2005-04-17 06:20:36 +08:00
|
|
|
for (bar = 0; bar < 5; bar++) {
|
|
|
|
if (a->resources.pci.bar[bar]
|
|
|
|
&& a->resources.pci.addr[bar]) {
|
|
|
|
divasa_unmap_pci_bar(a->resources.pci.addr[bar]);
|
|
|
|
a->resources.pci.bar[bar] = 0;
|
|
|
|
a->resources.pci.addr[bar] = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2012-02-20 11:52:38 +08:00
|
|
|
Free OS objects
|
|
|
|
*/
|
2005-04-17 06:20:36 +08:00
|
|
|
diva_os_cancel_soft_isr(&a->xdi_adapter.isr_soft_isr);
|
|
|
|
diva_os_cancel_soft_isr(&a->xdi_adapter.req_soft_isr);
|
|
|
|
|
|
|
|
diva_os_remove_soft_isr(&a->xdi_adapter.req_soft_isr);
|
|
|
|
a->xdi_adapter.isr_soft_isr.object = NULL;
|
|
|
|
|
|
|
|
diva_os_destroy_spin_lock(&a->xdi_adapter.isr_spin_lock, "rm");
|
|
|
|
diva_os_destroy_spin_lock(&a->xdi_adapter.data_spin_lock, "rm");
|
|
|
|
|
|
|
|
/*
|
2012-02-20 11:52:38 +08:00
|
|
|
Free memory accupied by XDI adapter
|
|
|
|
*/
|
2005-04-17 06:20:36 +08:00
|
|
|
if (a->xdi_adapter.e_tbl) {
|
|
|
|
diva_os_free(0, a->xdi_adapter.e_tbl);
|
|
|
|
a->xdi_adapter.e_tbl = NULL;
|
|
|
|
}
|
|
|
|
a->xdi_adapter.Channels = 0;
|
|
|
|
a->xdi_adapter.e_max = 0;
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
2012-02-20 11:52:38 +08:00
|
|
|
Free adapter DMA map
|
|
|
|
*/
|
2005-04-17 06:20:36 +08:00
|
|
|
diva_free_dma_map(a->resources.pci.hdev,
|
|
|
|
(struct _diva_dma_map_entry *) a->xdi_adapter.
|
|
|
|
dma_map);
|
|
|
|
a->xdi_adapter.dma_map = NULL;
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
2012-02-20 11:52:38 +08:00
|
|
|
Detach this adapter from debug driver
|
|
|
|
*/
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
** Activate On Board Boot Loader
|
|
|
|
*/
|
|
|
|
static int diva_pri_reset_adapter(PISDN_ADAPTER IoAdapter)
|
|
|
|
{
|
|
|
|
dword i;
|
|
|
|
struct mp_load __iomem *boot;
|
|
|
|
|
|
|
|
if (!IoAdapter->Address || !IoAdapter->reset) {
|
|
|
|
return (-1);
|
|
|
|
}
|
|
|
|
if (IoAdapter->Initialized) {
|
|
|
|
DBG_ERR(("A: A(%d) can't reset PRI adapter - please stop first",
|
|
|
|
IoAdapter->ANum))
|
2012-02-20 11:52:38 +08:00
|
|
|
return (-1);
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
boot = (struct mp_load __iomem *) DIVA_OS_MEM_ATTACH_ADDRESS(IoAdapter);
|
|
|
|
WRITE_DWORD(&boot->err, 0);
|
|
|
|
DIVA_OS_MEM_DETACH_ADDRESS(IoAdapter, boot);
|
|
|
|
|
|
|
|
IoAdapter->rstFnc(IoAdapter);
|
|
|
|
|
|
|
|
diva_os_wait(10);
|
|
|
|
|
|
|
|
boot = (struct mp_load __iomem *) DIVA_OS_MEM_ATTACH_ADDRESS(IoAdapter);
|
|
|
|
i = READ_DWORD(&boot->live);
|
|
|
|
|
|
|
|
diva_os_wait(10);
|
|
|
|
if (i == READ_DWORD(&boot->live)) {
|
|
|
|
DIVA_OS_MEM_DETACH_ADDRESS(IoAdapter, boot);
|
|
|
|
DBG_ERR(("A: A(%d) CPU on PRI %ld is not alive!",
|
|
|
|
IoAdapter->ANum, IoAdapter->serialNo))
|
2012-02-20 11:52:38 +08:00
|
|
|
return (-1);
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
if (READ_DWORD(&boot->err)) {
|
|
|
|
DBG_ERR(("A: A(%d) PRI %ld Board Selftest failed, error=%08lx",
|
|
|
|
IoAdapter->ANum, IoAdapter->serialNo,
|
|
|
|
READ_DWORD(&boot->err)))
|
2012-02-20 11:52:38 +08:00
|
|
|
DIVA_OS_MEM_DETACH_ADDRESS(IoAdapter, boot);
|
2005-04-17 06:20:36 +08:00
|
|
|
return (-1);
|
|
|
|
}
|
|
|
|
DIVA_OS_MEM_DETACH_ADDRESS(IoAdapter, boot);
|
|
|
|
|
|
|
|
/*
|
2012-02-20 11:52:38 +08:00
|
|
|
Forget all outstanding entities
|
|
|
|
*/
|
2005-04-17 06:20:36 +08:00
|
|
|
IoAdapter->e_count = 0;
|
|
|
|
if (IoAdapter->e_tbl) {
|
|
|
|
memset(IoAdapter->e_tbl, 0x00,
|
|
|
|
IoAdapter->e_max * sizeof(E_INFO));
|
|
|
|
}
|
|
|
|
IoAdapter->head = 0;
|
|
|
|
IoAdapter->tail = 0;
|
|
|
|
IoAdapter->assign = 0;
|
|
|
|
IoAdapter->trapped = 0;
|
|
|
|
|
|
|
|
memset(&IoAdapter->a.IdTable[0], 0x00,
|
|
|
|
sizeof(IoAdapter->a.IdTable));
|
|
|
|
memset(&IoAdapter->a.IdTypeTable[0], 0x00,
|
|
|
|
sizeof(IoAdapter->a.IdTypeTable));
|
|
|
|
memset(&IoAdapter->a.FlowControlIdTable[0], 0x00,
|
|
|
|
sizeof(IoAdapter->a.FlowControlIdTable));
|
|
|
|
memset(&IoAdapter->a.FlowControlSkipTable[0], 0x00,
|
|
|
|
sizeof(IoAdapter->a.FlowControlSkipTable));
|
|
|
|
memset(&IoAdapter->a.misc_flags_table[0], 0x00,
|
|
|
|
sizeof(IoAdapter->a.misc_flags_table));
|
|
|
|
memset(&IoAdapter->a.rx_stream[0], 0x00,
|
|
|
|
sizeof(IoAdapter->a.rx_stream));
|
|
|
|
memset(&IoAdapter->a.tx_stream[0], 0x00,
|
|
|
|
sizeof(IoAdapter->a.tx_stream));
|
|
|
|
memset(&IoAdapter->a.tx_pos[0], 0x00, sizeof(IoAdapter->a.tx_pos));
|
|
|
|
memset(&IoAdapter->a.rx_pos[0], 0x00, sizeof(IoAdapter->a.rx_pos));
|
|
|
|
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
diva_pri_write_sdram_block(PISDN_ADAPTER IoAdapter,
|
|
|
|
dword address,
|
2012-02-20 11:52:38 +08:00
|
|
|
const byte *data, dword length, dword limit)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
|
|
|
byte __iomem *p = DIVA_OS_MEM_ATTACH_ADDRESS(IoAdapter);
|
|
|
|
byte __iomem *mem = p;
|
|
|
|
|
|
|
|
if (((address + length) >= limit) || !mem) {
|
|
|
|
DIVA_OS_MEM_DETACH_ADDRESS(IoAdapter, p);
|
|
|
|
DBG_ERR(("A: A(%d) write PRI address=0x%08lx",
|
|
|
|
IoAdapter->ANum, address + length))
|
2012-02-20 11:52:38 +08:00
|
|
|
return (-1);
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
mem += address;
|
|
|
|
|
|
|
|
/* memcpy_toio(), maybe? */
|
|
|
|
while (length--) {
|
|
|
|
WRITE_BYTE(mem++, *data++);
|
|
|
|
}
|
|
|
|
|
|
|
|
DIVA_OS_MEM_DETACH_ADDRESS(IoAdapter, p);
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
diva_pri_start_adapter(PISDN_ADAPTER IoAdapter,
|
|
|
|
dword start_address, dword features)
|
|
|
|
{
|
|
|
|
dword i;
|
|
|
|
int started = 0;
|
|
|
|
byte __iomem *p;
|
|
|
|
struct mp_load __iomem *boot = (struct mp_load __iomem *) DIVA_OS_MEM_ATTACH_ADDRESS(IoAdapter);
|
|
|
|
ADAPTER *a = &IoAdapter->a;
|
|
|
|
|
|
|
|
if (IoAdapter->Initialized) {
|
|
|
|
DIVA_OS_MEM_DETACH_ADDRESS(IoAdapter, boot);
|
|
|
|
DBG_ERR(("A: A(%d) pri_start_adapter, adapter already running",
|
|
|
|
IoAdapter->ANum))
|
2012-02-20 11:52:38 +08:00
|
|
|
return (-1);
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
if (!boot) {
|
|
|
|
DIVA_OS_MEM_DETACH_ADDRESS(IoAdapter, boot);
|
|
|
|
DBG_ERR(("A: PRI %ld can't start, adapter not mapped",
|
|
|
|
IoAdapter->serialNo))
|
2012-02-20 11:52:38 +08:00
|
|
|
return (-1);
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
sprintf(IoAdapter->Name, "A(%d)", (int) IoAdapter->ANum);
|
|
|
|
DBG_LOG(("A(%d) start PRI at 0x%08lx", IoAdapter->ANum,
|
|
|
|
start_address))
|
|
|
|
|
2012-02-20 11:52:38 +08:00
|
|
|
WRITE_DWORD(&boot->addr, start_address);
|
2005-04-17 06:20:36 +08:00
|
|
|
WRITE_DWORD(&boot->cmd, 3);
|
|
|
|
|
|
|
|
for (i = 0; i < 300; ++i) {
|
|
|
|
diva_os_wait(10);
|
|
|
|
if ((READ_DWORD(&boot->signature) >> 16) == 0x4447) {
|
|
|
|
DBG_LOG(("A(%d) Protocol startup time %d.%02d seconds",
|
|
|
|
IoAdapter->ANum, (i / 100), (i % 100)))
|
2012-02-20 11:52:38 +08:00
|
|
|
started = 1;
|
2005-04-17 06:20:36 +08:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!started) {
|
|
|
|
byte __iomem *p = (byte __iomem *)boot;
|
|
|
|
dword TrapId;
|
|
|
|
dword debug;
|
|
|
|
TrapId = READ_DWORD(&p[0x80]);
|
|
|
|
debug = READ_DWORD(&p[0x1c]);
|
|
|
|
DBG_ERR(("A(%d) Adapter start failed 0x%08lx, TrapId=%08lx, debug=%08lx",
|
|
|
|
IoAdapter->ANum, READ_DWORD(&boot->signature),
|
|
|
|
TrapId, debug))
|
2012-02-20 11:52:38 +08:00
|
|
|
DIVA_OS_MEM_DETACH_ADDRESS(IoAdapter, boot);
|
2005-04-17 06:20:36 +08:00
|
|
|
if (IoAdapter->trapFnc) {
|
|
|
|
(*(IoAdapter->trapFnc)) (IoAdapter);
|
|
|
|
}
|
|
|
|
IoAdapter->stop(IoAdapter);
|
|
|
|
return (-1);
|
|
|
|
}
|
|
|
|
DIVA_OS_MEM_DETACH_ADDRESS(IoAdapter, boot);
|
|
|
|
|
2007-02-12 16:53:24 +08:00
|
|
|
IoAdapter->Initialized = true;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
/*
|
2012-02-20 11:52:38 +08:00
|
|
|
Check Interrupt
|
|
|
|
*/
|
2005-04-17 06:20:36 +08:00
|
|
|
IoAdapter->IrqCount = 0;
|
|
|
|
p = DIVA_OS_MEM_ATTACH_CFG(IoAdapter);
|
2012-02-20 11:52:38 +08:00
|
|
|
WRITE_DWORD(p, (dword)~0x03E00000);
|
2005-04-17 06:20:36 +08:00
|
|
|
DIVA_OS_MEM_DETACH_CFG(IoAdapter, p);
|
|
|
|
a->ReadyInt = 1;
|
|
|
|
a->ram_out(a, &PR_RAM->ReadyInt, 1);
|
|
|
|
|
|
|
|
for (i = 100; !IoAdapter->IrqCount && (i-- > 0); diva_os_wait(10));
|
|
|
|
|
|
|
|
if (!IoAdapter->IrqCount) {
|
|
|
|
DBG_ERR(("A: A(%d) interrupt test failed",
|
|
|
|
IoAdapter->ANum))
|
2012-02-20 11:52:38 +08:00
|
|
|
IoAdapter->Initialized = false;
|
2005-04-17 06:20:36 +08:00
|
|
|
IoAdapter->stop(IoAdapter);
|
|
|
|
return (-1);
|
|
|
|
}
|
|
|
|
|
|
|
|
IoAdapter->Properties.Features = (word) features;
|
|
|
|
|
|
|
|
diva_xdi_display_adapter_features(IoAdapter->ANum);
|
|
|
|
|
2009-01-08 10:09:16 +08:00
|
|
|
DBG_LOG(("A(%d) PRI adapter successfully started", IoAdapter->ANum))
|
2012-02-20 11:52:38 +08:00
|
|
|
/*
|
|
|
|
Register with DIDD
|
|
|
|
*/
|
|
|
|
diva_xdi_didd_register_adapter(IoAdapter->ANum);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
2012-02-20 11:52:38 +08:00
|
|
|
static void diva_pri_clear_interrupts(diva_os_xdi_adapter_t *a)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
|
|
|
PISDN_ADAPTER IoAdapter = &a->xdi_adapter;
|
|
|
|
|
|
|
|
/*
|
2012-02-20 11:52:38 +08:00
|
|
|
clear any pending interrupt
|
|
|
|
*/
|
2005-04-17 06:20:36 +08:00
|
|
|
IoAdapter->disIrq(IoAdapter);
|
|
|
|
|
|
|
|
IoAdapter->tst_irq(&IoAdapter->a);
|
|
|
|
IoAdapter->clr_irq(&IoAdapter->a);
|
|
|
|
IoAdapter->tst_irq(&IoAdapter->a);
|
|
|
|
|
|
|
|
/*
|
2012-02-20 11:52:38 +08:00
|
|
|
kill pending dpcs
|
|
|
|
*/
|
2005-04-17 06:20:36 +08:00
|
|
|
diva_os_cancel_soft_isr(&IoAdapter->req_soft_isr);
|
|
|
|
diva_os_cancel_soft_isr(&IoAdapter->isr_soft_isr);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
** Stop Adapter, but do not unmap/unregister - adapter
|
|
|
|
** will be restarted later
|
|
|
|
*/
|
2012-02-20 11:52:38 +08:00
|
|
|
static int diva_pri_stop_adapter(diva_os_xdi_adapter_t *a)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
|
|
|
PISDN_ADAPTER IoAdapter = &a->xdi_adapter;
|
|
|
|
int i = 100;
|
|
|
|
|
|
|
|
if (!IoAdapter->ram) {
|
|
|
|
return (-1);
|
|
|
|
}
|
|
|
|
if (!IoAdapter->Initialized) {
|
|
|
|
DBG_ERR(("A: A(%d) can't stop PRI adapter - not running",
|
|
|
|
IoAdapter->ANum))
|
2012-02-20 11:52:38 +08:00
|
|
|
return (-1); /* nothing to stop */
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
IoAdapter->Initialized = 0;
|
|
|
|
|
|
|
|
/*
|
2012-02-20 11:52:38 +08:00
|
|
|
Disconnect Adapter from DIDD
|
|
|
|
*/
|
2005-04-17 06:20:36 +08:00
|
|
|
diva_xdi_didd_remove_adapter(IoAdapter->ANum);
|
|
|
|
|
|
|
|
/*
|
2012-02-20 11:52:38 +08:00
|
|
|
Stop interrupts
|
|
|
|
*/
|
2005-04-17 06:20:36 +08:00
|
|
|
a->clear_interrupts_proc = diva_pri_clear_interrupts;
|
|
|
|
IoAdapter->a.ReadyInt = 1;
|
|
|
|
IoAdapter->a.ram_inc(&IoAdapter->a, &PR_RAM->ReadyInt);
|
|
|
|
do {
|
|
|
|
diva_os_sleep(10);
|
|
|
|
} while (i-- && a->clear_interrupts_proc);
|
|
|
|
|
|
|
|
if (a->clear_interrupts_proc) {
|
|
|
|
diva_pri_clear_interrupts(a);
|
|
|
|
a->clear_interrupts_proc = NULL;
|
|
|
|
DBG_ERR(("A: A(%d) no final interrupt from PRI adapter",
|
|
|
|
IoAdapter->ANum))
|
2012-02-20 11:52:38 +08:00
|
|
|
}
|
2005-04-17 06:20:36 +08:00
|
|
|
IoAdapter->a.ReadyInt = 0;
|
|
|
|
|
|
|
|
/*
|
2012-02-20 11:52:38 +08:00
|
|
|
Stop and reset adapter
|
|
|
|
*/
|
2005-04-17 06:20:36 +08:00
|
|
|
IoAdapter->stop(IoAdapter);
|
|
|
|
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
** Process commands form configuration/download framework and from
|
|
|
|
** user mode
|
|
|
|
**
|
|
|
|
** return 0 on success
|
|
|
|
*/
|
|
|
|
static int
|
|
|
|
diva_pri_cmd_card_proc(struct _diva_os_xdi_adapter *a,
|
2012-02-20 11:52:38 +08:00
|
|
|
diva_xdi_um_cfg_cmd_t *cmd, int length)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
|
|
|
int ret = -1;
|
|
|
|
|
|
|
|
if (cmd->adapter != a->controller) {
|
|
|
|
DBG_ERR(("A: pri_cmd, invalid controller=%d != %d",
|
|
|
|
cmd->adapter, a->controller))
|
2012-02-20 11:52:38 +08:00
|
|
|
return (-1);
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
switch (cmd->command) {
|
|
|
|
case DIVA_XDI_UM_CMD_GET_CARD_ORDINAL:
|
|
|
|
a->xdi_mbox.data_length = sizeof(dword);
|
|
|
|
a->xdi_mbox.data =
|
2012-02-20 11:52:38 +08:00
|
|
|
diva_os_malloc(0, a->xdi_mbox.data_length);
|
2005-04-17 06:20:36 +08:00
|
|
|
if (a->xdi_mbox.data) {
|
|
|
|
*(dword *) a->xdi_mbox.data =
|
2012-02-20 11:52:38 +08:00
|
|
|
(dword) a->CardOrdinal;
|
2005-04-17 06:20:36 +08:00
|
|
|
a->xdi_mbox.status = DIVA_XDI_MBOX_BUSY;
|
|
|
|
ret = 0;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case DIVA_XDI_UM_CMD_GET_SERIAL_NR:
|
|
|
|
a->xdi_mbox.data_length = sizeof(dword);
|
|
|
|
a->xdi_mbox.data =
|
2012-02-20 11:52:38 +08:00
|
|
|
diva_os_malloc(0, a->xdi_mbox.data_length);
|
2005-04-17 06:20:36 +08:00
|
|
|
if (a->xdi_mbox.data) {
|
|
|
|
*(dword *) a->xdi_mbox.data =
|
2012-02-20 11:52:38 +08:00
|
|
|
(dword) a->xdi_adapter.serialNo;
|
2005-04-17 06:20:36 +08:00
|
|
|
a->xdi_mbox.status = DIVA_XDI_MBOX_BUSY;
|
|
|
|
ret = 0;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case DIVA_XDI_UM_CMD_GET_PCI_HW_CONFIG:
|
|
|
|
a->xdi_mbox.data_length = sizeof(dword) * 9;
|
|
|
|
a->xdi_mbox.data =
|
2012-02-20 11:52:38 +08:00
|
|
|
diva_os_malloc(0, a->xdi_mbox.data_length);
|
2005-04-17 06:20:36 +08:00
|
|
|
if (a->xdi_mbox.data) {
|
|
|
|
int i;
|
|
|
|
dword *data = (dword *) a->xdi_mbox.data;
|
|
|
|
|
|
|
|
for (i = 0; i < 8; i++) {
|
|
|
|
*data++ = a->resources.pci.bar[i];
|
|
|
|
}
|
|
|
|
*data++ = (dword) a->resources.pci.irq;
|
|
|
|
a->xdi_mbox.status = DIVA_XDI_MBOX_BUSY;
|
|
|
|
ret = 0;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case DIVA_XDI_UM_CMD_RESET_ADAPTER:
|
|
|
|
ret = diva_pri_reset_adapter(&a->xdi_adapter);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case DIVA_XDI_UM_CMD_WRITE_SDRAM_BLOCK:
|
|
|
|
ret = diva_pri_write_sdram_block(&a->xdi_adapter,
|
|
|
|
cmd->command_data.
|
|
|
|
write_sdram.offset,
|
2012-02-20 11:52:38 +08:00
|
|
|
(byte *)&cmd[1],
|
2005-04-17 06:20:36 +08:00
|
|
|
cmd->command_data.
|
|
|
|
write_sdram.length,
|
|
|
|
pri_is_rev_2_card(a->
|
|
|
|
CardOrdinal)
|
|
|
|
? MP2_MEMORY_SIZE :
|
|
|
|
MP_MEMORY_SIZE);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case DIVA_XDI_UM_CMD_STOP_ADAPTER:
|
|
|
|
ret = diva_pri_stop_adapter(a);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case DIVA_XDI_UM_CMD_START_ADAPTER:
|
|
|
|
ret = diva_pri_start_adapter(&a->xdi_adapter,
|
|
|
|
cmd->command_data.start.
|
|
|
|
offset,
|
|
|
|
cmd->command_data.start.
|
|
|
|
features);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case DIVA_XDI_UM_CMD_SET_PROTOCOL_FEATURES:
|
|
|
|
a->xdi_adapter.features =
|
2012-02-20 11:52:38 +08:00
|
|
|
cmd->command_data.features.features;
|
2005-04-17 06:20:36 +08:00
|
|
|
a->xdi_adapter.a.protocol_capabilities =
|
2012-02-20 11:52:38 +08:00
|
|
|
a->xdi_adapter.features;
|
2005-04-17 06:20:36 +08:00
|
|
|
DBG_TRC(("Set raw protocol features (%08x)",
|
|
|
|
a->xdi_adapter.features))
|
2012-02-20 11:52:38 +08:00
|
|
|
ret = 0;
|
2005-04-17 06:20:36 +08:00
|
|
|
break;
|
|
|
|
|
|
|
|
case DIVA_XDI_UM_CMD_GET_CARD_STATE:
|
|
|
|
a->xdi_mbox.data_length = sizeof(dword);
|
|
|
|
a->xdi_mbox.data =
|
2012-02-20 11:52:38 +08:00
|
|
|
diva_os_malloc(0, a->xdi_mbox.data_length);
|
2005-04-17 06:20:36 +08:00
|
|
|
if (a->xdi_mbox.data) {
|
|
|
|
dword *data = (dword *) a->xdi_mbox.data;
|
|
|
|
if (!a->xdi_adapter.ram ||
|
2012-02-20 11:52:38 +08:00
|
|
|
!a->xdi_adapter.reset ||
|
2005-04-17 06:20:36 +08:00
|
|
|
!a->xdi_adapter.cfg) {
|
|
|
|
*data = 3;
|
|
|
|
} else if (a->xdi_adapter.trapped) {
|
|
|
|
*data = 2;
|
|
|
|
} else if (a->xdi_adapter.Initialized) {
|
|
|
|
*data = 1;
|
|
|
|
} else {
|
|
|
|
*data = 0;
|
|
|
|
}
|
|
|
|
a->xdi_mbox.status = DIVA_XDI_MBOX_BUSY;
|
|
|
|
ret = 0;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case DIVA_XDI_UM_CMD_READ_XLOG_ENTRY:
|
|
|
|
ret = diva_card_read_xlog(a);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case DIVA_XDI_UM_CMD_READ_SDRAM:
|
|
|
|
if (a->xdi_adapter.Address) {
|
|
|
|
if (
|
2012-02-20 11:52:38 +08:00
|
|
|
(a->xdi_mbox.data_length =
|
|
|
|
cmd->command_data.read_sdram.length)) {
|
2005-04-17 06:20:36 +08:00
|
|
|
if (
|
2012-02-20 11:52:38 +08:00
|
|
|
(a->xdi_mbox.data_length +
|
|
|
|
cmd->command_data.read_sdram.offset) <
|
|
|
|
a->xdi_adapter.MemorySize) {
|
2005-04-17 06:20:36 +08:00
|
|
|
a->xdi_mbox.data =
|
2012-02-20 11:52:38 +08:00
|
|
|
diva_os_malloc(0,
|
|
|
|
a->xdi_mbox.
|
|
|
|
data_length);
|
2005-04-17 06:20:36 +08:00
|
|
|
if (a->xdi_mbox.data) {
|
|
|
|
byte __iomem *p = DIVA_OS_MEM_ATTACH_ADDRESS(&a->xdi_adapter);
|
|
|
|
byte __iomem *src = p;
|
|
|
|
byte *dst = a->xdi_mbox.data;
|
|
|
|
dword len = a->xdi_mbox.data_length;
|
|
|
|
|
|
|
|
src += cmd->command_data.read_sdram.offset;
|
|
|
|
|
|
|
|
while (len--) {
|
|
|
|
*dst++ = READ_BYTE(src++);
|
|
|
|
}
|
|
|
|
a->xdi_mbox.status = DIVA_XDI_MBOX_BUSY;
|
|
|
|
DIVA_OS_MEM_DETACH_ADDRESS(&a->xdi_adapter, p);
|
|
|
|
ret = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
DBG_ERR(("A: A(%d) invalid cmd=%d", a->controller,
|
|
|
|
cmd->command))
|
2012-02-20 11:52:38 +08:00
|
|
|
}
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
return (ret);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
** Get Serial Number
|
|
|
|
*/
|
2012-02-20 11:52:38 +08:00
|
|
|
static int pri_get_serial_number(diva_os_xdi_adapter_t *a)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
|
|
|
byte data[64];
|
|
|
|
int i;
|
|
|
|
dword len = sizeof(data);
|
|
|
|
volatile byte __iomem *config;
|
|
|
|
volatile byte __iomem *flash;
|
|
|
|
byte c;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* First set some GT6401x config registers before accessing the BOOT-ROM
|
|
|
|
*/
|
2012-02-20 11:52:38 +08:00
|
|
|
config = DIVA_OS_MEM_ATTACH_CONFIG(&a->xdi_adapter);
|
2005-04-17 06:20:36 +08:00
|
|
|
c = READ_BYTE(&config[0xc3c]);
|
|
|
|
if (!(c & 0x08)) {
|
|
|
|
WRITE_BYTE(&config[0xc3c], c); /* Base Address enable register */
|
|
|
|
}
|
|
|
|
WRITE_BYTE(&config[LOW_BOOTCS_DREG], 0x00);
|
|
|
|
WRITE_BYTE(&config[HI_BOOTCS_DREG], 0xFF);
|
2012-02-20 11:52:38 +08:00
|
|
|
DIVA_OS_MEM_DETACH_CONFIG(&a->xdi_adapter, config);
|
2005-04-17 06:20:36 +08:00
|
|
|
/*
|
|
|
|
* Read only the last 64 bytes of manufacturing data
|
|
|
|
*/
|
|
|
|
memset(data, '\0', len);
|
2012-02-20 11:52:38 +08:00
|
|
|
flash = DIVA_OS_MEM_ATTACH_PROM(&a->xdi_adapter);
|
2005-04-17 06:20:36 +08:00
|
|
|
for (i = 0; i < len; i++) {
|
|
|
|
data[i] = READ_BYTE(&flash[0x8000 - len + i]);
|
|
|
|
}
|
2012-02-20 11:52:38 +08:00
|
|
|
DIVA_OS_MEM_DETACH_PROM(&a->xdi_adapter, flash);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2012-02-20 11:52:38 +08:00
|
|
|
config = DIVA_OS_MEM_ATTACH_CONFIG(&a->xdi_adapter);
|
2005-04-17 06:20:36 +08:00
|
|
|
WRITE_BYTE(&config[LOW_BOOTCS_DREG], 0xFC); /* Disable FLASH EPROM access */
|
|
|
|
WRITE_BYTE(&config[HI_BOOTCS_DREG], 0xFF);
|
2012-02-20 11:52:38 +08:00
|
|
|
DIVA_OS_MEM_DETACH_CONFIG(&a->xdi_adapter, config);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
if (memcmp(&data[48], "DIVAserverPR", 12)) {
|
|
|
|
#if !defined(DIVA_PRI_NO_PCI_BIOS_WORKAROUND) /* { */
|
|
|
|
word cmd = 0, cmd_org;
|
|
|
|
void *addr;
|
|
|
|
dword addr1, addr3, addr4;
|
|
|
|
byte Bus, Slot;
|
|
|
|
void *hdev;
|
|
|
|
addr4 = a->resources.pci.bar[4];
|
|
|
|
addr3 = a->resources.pci.bar[3]; /* flash */
|
|
|
|
addr1 = a->resources.pci.bar[1]; /* unused */
|
|
|
|
|
|
|
|
DBG_ERR(("A: apply Compaq BIOS workaround"))
|
2012-02-20 11:52:38 +08:00
|
|
|
DBG_LOG(("%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x",
|
|
|
|
data[0], data[1], data[2], data[3],
|
|
|
|
data[4], data[5], data[6], data[7]))
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2012-02-20 11:52:38 +08:00
|
|
|
Bus = a->resources.pci.bus;
|
2005-04-17 06:20:36 +08:00
|
|
|
Slot = a->resources.pci.func;
|
|
|
|
hdev = a->resources.pci.hdev;
|
|
|
|
PCIread(Bus, Slot, 0x04, &cmd_org, sizeof(cmd_org), hdev);
|
|
|
|
PCIwrite(Bus, Slot, 0x04, &cmd, sizeof(cmd), hdev);
|
|
|
|
|
|
|
|
PCIwrite(Bus, Slot, 0x14, &addr4, sizeof(addr4), hdev);
|
|
|
|
PCIwrite(Bus, Slot, 0x20, &addr1, sizeof(addr1), hdev);
|
|
|
|
|
|
|
|
PCIwrite(Bus, Slot, 0x04, &cmd_org, sizeof(cmd_org), hdev);
|
|
|
|
|
|
|
|
addr = a->resources.pci.addr[1];
|
|
|
|
a->resources.pci.addr[1] = a->resources.pci.addr[4];
|
|
|
|
a->resources.pci.addr[4] = addr;
|
|
|
|
|
|
|
|
addr1 = a->resources.pci.bar[1];
|
|
|
|
a->resources.pci.bar[1] = a->resources.pci.bar[4];
|
|
|
|
a->resources.pci.bar[4] = addr1;
|
|
|
|
|
|
|
|
/*
|
2012-02-20 11:52:38 +08:00
|
|
|
Try to read Flash again
|
|
|
|
*/
|
2005-04-17 06:20:36 +08:00
|
|
|
len = sizeof(data);
|
|
|
|
|
2012-02-20 11:52:38 +08:00
|
|
|
config = DIVA_OS_MEM_ATTACH_CONFIG(&a->xdi_adapter);
|
2005-04-17 06:20:36 +08:00
|
|
|
if (!(config[0xc3c] & 0x08)) {
|
|
|
|
config[0xc3c] |= 0x08; /* Base Address enable register */
|
|
|
|
}
|
|
|
|
config[LOW_BOOTCS_DREG] = 0x00;
|
|
|
|
config[HI_BOOTCS_DREG] = 0xFF;
|
2012-02-20 11:52:38 +08:00
|
|
|
DIVA_OS_MEM_DETACH_CONFIG(&a->xdi_adapter, config);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
memset(data, '\0', len);
|
2012-02-20 11:52:38 +08:00
|
|
|
flash = DIVA_OS_MEM_ATTACH_PROM(&a->xdi_adapter);
|
2005-04-17 06:20:36 +08:00
|
|
|
for (i = 0; i < len; i++) {
|
|
|
|
data[i] = flash[0x8000 - len + i];
|
|
|
|
}
|
2012-02-20 11:52:38 +08:00
|
|
|
DIVA_OS_MEM_ATTACH_PROM(&a->xdi_adapter, flash);
|
|
|
|
config = DIVA_OS_MEM_ATTACH_CONFIG(&a->xdi_adapter);
|
2005-04-17 06:20:36 +08:00
|
|
|
config[LOW_BOOTCS_DREG] = 0xFC;
|
|
|
|
config[HI_BOOTCS_DREG] = 0xFF;
|
2012-02-20 11:52:38 +08:00
|
|
|
DIVA_OS_MEM_DETACH_CONFIG(&a->xdi_adapter, config);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
if (memcmp(&data[48], "DIVAserverPR", 12)) {
|
|
|
|
DBG_ERR(("A: failed to read serial number"))
|
2012-02-20 11:52:38 +08:00
|
|
|
DBG_LOG(("%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x",
|
|
|
|
data[0], data[1], data[2], data[3],
|
|
|
|
data[4], data[5], data[6], data[7]))
|
|
|
|
return (-1);
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
#else /* } { */
|
|
|
|
DBG_ERR(("A: failed to read DIVA signature word"))
|
2012-02-20 11:52:38 +08:00
|
|
|
DBG_LOG(("%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x",
|
|
|
|
data[0], data[1], data[2], data[3],
|
|
|
|
data[4], data[5], data[6], data[7]))
|
|
|
|
DBG_LOG(("%02x:%02x:%02x:%02x", data[47], data[46],
|
|
|
|
data[45], data[44]))
|
2005-04-17 06:20:36 +08:00
|
|
|
#endif /* } */
|
2012-02-20 11:52:38 +08:00
|
|
|
}
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
a->xdi_adapter.serialNo =
|
2012-02-20 11:52:38 +08:00
|
|
|
(data[47] << 24) | (data[46] << 16) | (data[45] << 8) |
|
|
|
|
data[44];
|
2005-04-17 06:20:36 +08:00
|
|
|
if (!a->xdi_adapter.serialNo
|
|
|
|
|| (a->xdi_adapter.serialNo == 0xffffffff)) {
|
|
|
|
a->xdi_adapter.serialNo = 0;
|
|
|
|
DBG_ERR(("A: failed to read serial number"))
|
2012-02-20 11:52:38 +08:00
|
|
|
return (-1);
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
DBG_LOG(("Serial No. : %ld", a->xdi_adapter.serialNo))
|
2012-02-20 11:52:38 +08:00
|
|
|
DBG_TRC(("Board Revision : %d.%02d", (int) data[41],
|
|
|
|
(int) data[40]))
|
|
|
|
DBG_TRC(("PLD revision : %d.%02d", (int) data[33],
|
|
|
|
(int) data[32]))
|
|
|
|
DBG_TRC(("Boot loader version : %d.%02d", (int) data[37],
|
|
|
|
(int) data[36]))
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2012-02-20 11:52:38 +08:00
|
|
|
DBG_TRC(("Manufacturing Date : %d/%02d/%02d (yyyy/mm/dd)",
|
|
|
|
(int) ((data[28] > 90) ? 1900 : 2000) +
|
|
|
|
(int) data[28], (int) data[29], (int) data[30]))
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2012-02-20 11:52:38 +08:00
|
|
|
return (0);
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void diva_os_prepare_pri2_functions(PISDN_ADAPTER IoAdapter)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void diva_os_prepare_pri_functions(PISDN_ADAPTER IoAdapter)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
** Checks presence of DSP on board
|
|
|
|
*/
|
|
|
|
static int
|
2012-02-20 11:52:38 +08:00
|
|
|
dsp_check_presence(volatile byte __iomem *addr, volatile byte __iomem *data, int dsp)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
|
|
|
word pattern;
|
|
|
|
|
|
|
|
WRITE_WORD(addr, 0x4000);
|
|
|
|
WRITE_WORD(data, DSP_SIGNATURE_PROBE_WORD);
|
|
|
|
|
|
|
|
WRITE_WORD(addr, 0x4000);
|
|
|
|
pattern = READ_WORD(data);
|
|
|
|
|
|
|
|
if (pattern != DSP_SIGNATURE_PROBE_WORD) {
|
|
|
|
DBG_TRC(("W: DSP[%d] %04x(is) != %04x(should)",
|
|
|
|
dsp, pattern, DSP_SIGNATURE_PROBE_WORD))
|
2012-02-20 11:52:38 +08:00
|
|
|
return (-1);
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
WRITE_WORD(addr, 0x4000);
|
|
|
|
WRITE_WORD(data, ~DSP_SIGNATURE_PROBE_WORD);
|
|
|
|
|
|
|
|
WRITE_WORD(addr, 0x4000);
|
|
|
|
pattern = READ_WORD(data);
|
|
|
|
|
2012-02-20 11:52:38 +08:00
|
|
|
if (pattern != (word)~DSP_SIGNATURE_PROBE_WORD) {
|
2005-04-17 06:20:36 +08:00
|
|
|
DBG_ERR(("A: DSP[%d] %04x(is) != %04x(should)",
|
2012-02-20 11:52:38 +08:00
|
|
|
dsp, pattern, (word)~DSP_SIGNATURE_PROBE_WORD))
|
|
|
|
return (-2);
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
DBG_TRC(("DSP[%d] present", dsp))
|
|
|
|
|
2012-02-20 11:52:38 +08:00
|
|
|
return (0);
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
** Check if DSP's are present and operating
|
|
|
|
** Information about detected DSP's is returned as bit mask
|
|
|
|
** Bit 0 - DSP1
|
|
|
|
** ...
|
|
|
|
** ...
|
|
|
|
** ...
|
|
|
|
** Bit 29 - DSP30
|
|
|
|
*/
|
2012-02-20 11:52:38 +08:00
|
|
|
static dword diva_pri_detect_dsps(diva_os_xdi_adapter_t *a)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
|
|
|
byte __iomem *base;
|
|
|
|
byte __iomem *p;
|
|
|
|
dword ret = 0;
|
|
|
|
dword row_offset[7] = {
|
|
|
|
0x00000000,
|
|
|
|
0x00000800, /* 1 - ROW 1 */
|
|
|
|
0x00000840, /* 2 - ROW 2 */
|
|
|
|
0x00001000, /* 3 - ROW 3 */
|
|
|
|
0x00001040, /* 4 - ROW 4 */
|
|
|
|
0x00000000 /* 5 - ROW 0 */
|
|
|
|
};
|
|
|
|
|
|
|
|
byte __iomem *dsp_addr_port;
|
|
|
|
byte __iomem *dsp_data_port;
|
|
|
|
byte row_state;
|
|
|
|
int dsp_row = 0, dsp_index, dsp_num;
|
|
|
|
|
|
|
|
if (!a->xdi_adapter.Control || !a->xdi_adapter.reset) {
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
|
|
|
p = DIVA_OS_MEM_ATTACH_RESET(&a->xdi_adapter);
|
|
|
|
WRITE_BYTE(p, _MP_RISC_RESET | _MP_DSP_RESET);
|
|
|
|
DIVA_OS_MEM_DETACH_RESET(&a->xdi_adapter, p);
|
|
|
|
diva_os_wait(5);
|
|
|
|
|
|
|
|
base = DIVA_OS_MEM_ATTACH_CONTROL(&a->xdi_adapter);
|
|
|
|
|
|
|
|
for (dsp_num = 0; dsp_num < 30; dsp_num++) {
|
|
|
|
dsp_row = dsp_num / 7 + 1;
|
|
|
|
dsp_index = dsp_num % 7;
|
|
|
|
|
|
|
|
dsp_data_port = base;
|
|
|
|
dsp_addr_port = base;
|
|
|
|
|
|
|
|
dsp_data_port += row_offset[dsp_row];
|
|
|
|
dsp_addr_port += row_offset[dsp_row];
|
|
|
|
|
|
|
|
dsp_data_port += (dsp_index * 8);
|
|
|
|
dsp_addr_port += (dsp_index * 8) + 0x80;
|
|
|
|
|
|
|
|
if (!dsp_check_presence
|
|
|
|
(dsp_addr_port, dsp_data_port, dsp_num + 1)) {
|
|
|
|
ret |= (1 << dsp_num);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
DIVA_OS_MEM_DETACH_CONTROL(&a->xdi_adapter, base);
|
|
|
|
|
|
|
|
p = DIVA_OS_MEM_ATTACH_RESET(&a->xdi_adapter);
|
|
|
|
WRITE_BYTE(p, _MP_RISC_RESET | _MP_LED1 | _MP_LED2);
|
|
|
|
DIVA_OS_MEM_DETACH_RESET(&a->xdi_adapter, p);
|
|
|
|
diva_os_wait(5);
|
|
|
|
|
|
|
|
/*
|
2012-02-20 11:52:38 +08:00
|
|
|
Verify modules
|
|
|
|
*/
|
2005-04-17 06:20:36 +08:00
|
|
|
for (dsp_row = 0; dsp_row < 4; dsp_row++) {
|
|
|
|
row_state = ((ret >> (dsp_row * 7)) & 0x7F);
|
|
|
|
if (row_state && (row_state != 0x7F)) {
|
|
|
|
for (dsp_index = 0; dsp_index < 7; dsp_index++) {
|
|
|
|
if (!(row_state & (1 << dsp_index))) {
|
|
|
|
DBG_ERR(("A: MODULE[%d]-DSP[%d] failed",
|
|
|
|
dsp_row + 1,
|
|
|
|
dsp_index + 1))
|
2012-02-20 11:52:38 +08:00
|
|
|
}
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!(ret & 0x10000000)) {
|
|
|
|
DBG_ERR(("A: ON BOARD-DSP[1] failed"))
|
2012-02-20 11:52:38 +08:00
|
|
|
}
|
2005-04-17 06:20:36 +08:00
|
|
|
if (!(ret & 0x20000000)) {
|
|
|
|
DBG_ERR(("A: ON BOARD-DSP[2] failed"))
|
2012-02-20 11:52:38 +08:00
|
|
|
}
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
/*
|
2012-02-20 11:52:38 +08:00
|
|
|
Print module population now
|
|
|
|
*/
|
2005-04-17 06:20:36 +08:00
|
|
|
DBG_LOG(("+-----------------------+"))
|
2012-02-20 11:52:38 +08:00
|
|
|
DBG_LOG(("| DSP MODULE POPULATION |"))
|
|
|
|
DBG_LOG(("+-----------------------+"))
|
|
|
|
DBG_LOG(("| 1 | 2 | 3 | 4 |"))
|
|
|
|
DBG_LOG(("+-----------------------+"))
|
|
|
|
DBG_LOG(("| %s | %s | %s | %s |",
|
|
|
|
((ret >> (0 * 7)) & 0x7F) ? "Y" : "N",
|
|
|
|
((ret >> (1 * 7)) & 0x7F) ? "Y" : "N",
|
|
|
|
((ret >> (2 * 7)) & 0x7F) ? "Y" : "N",
|
|
|
|
((ret >> (3 * 7)) & 0x7F) ? "Y" : "N"))
|
|
|
|
DBG_LOG(("+-----------------------+"))
|
|
|
|
|
|
|
|
DBG_LOG(("DSP's(present-absent):%08x-%08x", ret,
|
|
|
|
~ret & 0x3fffffff))
|
|
|
|
|
|
|
|
return (ret);
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|