linux/sound/pci/asihpi/hpi6000.c

// SPDX-License-Identifier: GPL-2.0-only
/******************************************************************************

    AudioScience HPI driver
    Copyright (C) 1997-2011  AudioScience Inc. <[email protected]>


 Hardware Programming Interface (HPI) for AudioScience ASI6200 series adapters.
 These PCI bus adapters are based on the TI C6711 DSP.

 Exported functions:
 void HPI_6000(struct hpi_message *phm, struct hpi_response *phr)

 #defines
 HIDE_PCI_ASSERTS to show the PCI asserts
 PROFILE_DSP2 get profile data from DSP2 if present (instead of DSP 1)

(C) Copyright AudioScience Inc. 1998-2003
*******************************************************************************/
#define SOURCEFILE_NAME

#include "hpi_internal.h"
#include "hpimsginit.h"
#include "hpidebug.h"
#include "hpi6000.h"
#include "hpidspcd.h"
#include "hpicmn.h"

#define HPI_HIF_BASE
#define HPI_HIF_ADDR(member)
#define HPI_HIF_ERROR_MASK

/* HPI6000 specific error codes */
#define HPI6000_ERROR_BASE

/* operational/messaging errors */
#define HPI6000_ERROR_MSG_RESP_IDLE_TIMEOUT
#define HPI6000_ERROR_RESP_GET_LEN
#define HPI6000_ERROR_MSG_RESP_GET_RESP_ACK
#define HPI6000_ERROR_MSG_GET_ADR
#define HPI6000_ERROR_RESP_GET_ADR
#define HPI6000_ERROR_MSG_RESP_BLOCKWRITE32
#define HPI6000_ERROR_MSG_RESP_BLOCKREAD32

#define HPI6000_ERROR_CONTROL_CACHE_PARAMS

#define HPI6000_ERROR_SEND_DATA_IDLE_TIMEOUT
#define HPI6000_ERROR_SEND_DATA_ACK
#define HPI6000_ERROR_SEND_DATA_ADR
#define HPI6000_ERROR_SEND_DATA_TIMEOUT
#define HPI6000_ERROR_SEND_DATA_CMD
#define HPI6000_ERROR_SEND_DATA_WRITE
#define HPI6000_ERROR_SEND_DATA_IDLECMD

#define HPI6000_ERROR_GET_DATA_IDLE_TIMEOUT
#define HPI6000_ERROR_GET_DATA_ACK
#define HPI6000_ERROR_GET_DATA_CMD
#define HPI6000_ERROR_GET_DATA_READ
#define HPI6000_ERROR_GET_DATA_IDLECMD

#define HPI6000_ERROR_CONTROL_CACHE_ADDRLEN
#define HPI6000_ERROR_CONTROL_CACHE_READ
#define HPI6000_ERROR_CONTROL_CACHE_FLUSH

#define HPI6000_ERROR_MSG_RESP_GETRESPCMD
#define HPI6000_ERROR_MSG_RESP_IDLECMD

/* Initialisation/bootload errors */
#define HPI6000_ERROR_UNHANDLED_SUBSYS_ID

/* can't access PCI2040 */
#define HPI6000_ERROR_INIT_PCI2040
/* can't access DSP HPI i/f */
#define HPI6000_ERROR_INIT_DSPHPI
/* can't access internal DSP memory */
#define HPI6000_ERROR_INIT_DSPINTMEM
/* can't access SDRAM - test#1 */
#define HPI6000_ERROR_INIT_SDRAM1
/* can't access SDRAM - test#2 */
#define HPI6000_ERROR_INIT_SDRAM2

#define HPI6000_ERROR_INIT_VERIFY

#define HPI6000_ERROR_INIT_NOACK

#define HPI6000_ERROR_INIT_PLDTEST1
#define HPI6000_ERROR_INIT_PLDTEST2

/* local defines */

#define HIDE_PCI_ASSERTS
#define PROFILE_DSP2

/* for PCI2040 i/f chip */
/* HPI CSR registers */
/* word offsets from CSR base */
/* use when io addresses defined as u32 * */

#define INTERRUPT_EVENT_SET
#define INTERRUPT_EVENT_CLEAR
#define INTERRUPT_MASK_SET
#define INTERRUPT_MASK_CLEAR
#define HPI_ERROR_REPORT
#define HPI_RESET
#define HPI_DATA_WIDTH

#define MAX_DSPS
/* HPI registers, spaced 8K bytes = 2K words apart */
#define DSP_SPACING

#define CONTROL
#define ADDRESS
#define DATA_AUTOINC
#define DATA

#define TIMEOUT

struct dsp_obj {};

struct hpi_hw_obj {};

static u16 hpi6000_dsp_block_write32(struct hpi_adapter_obj *pao,
	u16 dsp_index, u32 hpi_address, u32 *source, u32 count);
static u16 hpi6000_dsp_block_read32(struct hpi_adapter_obj *pao,
	u16 dsp_index, u32 hpi_address, u32 *dest, u32 count);

static short hpi6000_adapter_boot_load_dsp(struct hpi_adapter_obj *pao,
	u32 *pos_error_code);
static short hpi6000_check_PCI2040_error_flag(struct hpi_adapter_obj *pao,
	u16 read_or_write);
#define H6READ
#define H6WRITE

static short hpi6000_update_control_cache(struct hpi_adapter_obj *pao,
	struct hpi_message *phm);
static short hpi6000_message_response_sequence(struct hpi_adapter_obj *pao,
	u16 dsp_index, struct hpi_message *phm, struct hpi_response *phr);

static void hw_message(struct hpi_adapter_obj *pao, struct hpi_message *phm,
	struct hpi_response *phr);

static short hpi6000_wait_dsp_ack(struct hpi_adapter_obj *pao, u16 dsp_index,
	u32 ack_value);

static short hpi6000_send_host_command(struct hpi_adapter_obj *pao,
	u16 dsp_index, u32 host_cmd);

static void hpi6000_send_dsp_interrupt(struct dsp_obj *pdo);

static short hpi6000_send_data(struct hpi_adapter_obj *pao, u16 dsp_index,
	struct hpi_message *phm, struct hpi_response *phr);

static short hpi6000_get_data(struct hpi_adapter_obj *pao, u16 dsp_index,
	struct hpi_message *phm, struct hpi_response *phr);

static void hpi_write_word(struct dsp_obj *pdo, u32 address, u32 data);

static u32 hpi_read_word(struct dsp_obj *pdo, u32 address);

static void hpi_write_block(struct dsp_obj *pdo, u32 address, u32 *pdata,
	u32 length);

static void hpi_read_block(struct dsp_obj *pdo, u32 address, u32 *pdata,
	u32 length);

static void subsys_create_adapter(struct hpi_message *phm,
	struct hpi_response *phr);

static void adapter_delete(struct hpi_adapter_obj *pao,
	struct hpi_message *phm, struct hpi_response *phr);

static void adapter_get_asserts(struct hpi_adapter_obj *pao,
	struct hpi_message *phm, struct hpi_response *phr);

static short create_adapter_obj(struct hpi_adapter_obj *pao,
	u32 *pos_error_code);

static void delete_adapter_obj(struct hpi_adapter_obj *pao);

/* local globals */

static u16 gw_pci_read_asserts;	/* used to count PCI2040 errors */
static u16 gw_pci_write_asserts;	/* used to count PCI2040 errors */

static void subsys_message(struct hpi_message *phm, struct hpi_response *phr)
{}

static void control_message(struct hpi_adapter_obj *pao,
	struct hpi_message *phm, struct hpi_response *phr)
{}

static void adapter_message(struct hpi_adapter_obj *pao,
	struct hpi_message *phm, struct hpi_response *phr)
{}

static void outstream_message(struct hpi_adapter_obj *pao,
	struct hpi_message *phm, struct hpi_response *phr)
{}

static void instream_message(struct hpi_adapter_obj *pao,
	struct hpi_message *phm, struct hpi_response *phr)
{}

/************************************************************************/
/** HPI_6000()
 * Entry point from HPIMAN
 * All calls to the HPI start here
 */
void HPI_6000(struct hpi_message *phm, struct hpi_response *phr)
{}

/************************************************************************/
/* SUBSYSTEM */

/* create an adapter object and initialise it based on resource information
 * passed in the message
 * NOTE - you cannot use this function AND the FindAdapters function at the
 * same time, the application must use only one of them to get the adapters
 */
static void subsys_create_adapter(struct hpi_message *phm,
	struct hpi_response *phr)
{}

static void adapter_delete(struct hpi_adapter_obj *pao,
	struct hpi_message *phm, struct hpi_response *phr)
{}

/* this routine is called from SubSysFindAdapter and SubSysCreateAdapter */
static short create_adapter_obj(struct hpi_adapter_obj *pao,
	u32 *pos_error_code)
{}

static void delete_adapter_obj(struct hpi_adapter_obj *pao)
{}

/************************************************************************/
/* ADAPTER */

static void adapter_get_asserts(struct hpi_adapter_obj *pao,
	struct hpi_message *phm, struct hpi_response *phr)
{}

/************************************************************************/
/* LOW-LEVEL */

static short hpi6000_adapter_boot_load_dsp(struct hpi_adapter_obj *pao,
	u32 *pos_error_code)
{}

#define PCI_TIMEOUT

static int hpi_set_address(struct dsp_obj *pdo, u32 address)
{}

/* write one word to the HPI port */
static void hpi_write_word(struct dsp_obj *pdo, u32 address, u32 data)
{}

/* read one word from the HPI port */
static u32 hpi_read_word(struct dsp_obj *pdo, u32 address)
{}

/* write a block of 32bit words to the DSP HPI port using auto-inc mode */
static void hpi_write_block(struct dsp_obj *pdo, u32 address, u32 *pdata,
	u32 length)
{}

/** read a block of 32bit words from the DSP HPI port using auto-inc mode
 */
static void hpi_read_block(struct dsp_obj *pdo, u32 address, u32 *pdata,
	u32 length)
{}

static u16 hpi6000_dsp_block_write32(struct hpi_adapter_obj *pao,
	u16 dsp_index, u32 hpi_address, u32 *source, u32 count)
{}

static u16 hpi6000_dsp_block_read32(struct hpi_adapter_obj *pao,
	u16 dsp_index, u32 hpi_address, u32 *dest, u32 count)
{}

static short hpi6000_message_response_sequence(struct hpi_adapter_obj *pao,
	u16 dsp_index, struct hpi_message *phm, struct hpi_response *phr)
{}

/* have to set up the below defines to match stuff in the MAP file */

#define MSG_ADDRESS
#define MSG_LENGTH
#define RESP_ADDRESS
#define RESP_LENGTH
#define QUEUE_START
#define QUEUE_SIZE

static short hpi6000_send_data_check_adr(u32 address, u32 length_in_dwords)
{}

static short hpi6000_send_data(struct hpi_adapter_obj *pao, u16 dsp_index,
	struct hpi_message *phm, struct hpi_response *phr)
{}

static short hpi6000_get_data(struct hpi_adapter_obj *pao, u16 dsp_index,
	struct hpi_message *phm, struct hpi_response *phr)
{}

static void hpi6000_send_dsp_interrupt(struct dsp_obj *pdo)
{}

static short hpi6000_send_host_command(struct hpi_adapter_obj *pao,
	u16 dsp_index, u32 host_cmd)
{}

/* if the PCI2040 has recorded an HPI timeout, reset the error and return 1 */
static short hpi6000_check_PCI2040_error_flag(struct hpi_adapter_obj *pao,
	u16 read_or_write)
{}

static short hpi6000_wait_dsp_ack(struct hpi_adapter_obj *pao, u16 dsp_index,
	u32 ack_value)
{}

static short hpi6000_update_control_cache(struct hpi_adapter_obj *pao,
	struct hpi_message *phm)
{}

/** Get dsp index for multi DSP adapters only */
static u16 get_dsp_index(struct hpi_adapter_obj *pao, struct hpi_message *phm)
{}

/** Complete transaction with DSP

Send message, get response, send or get stream data if any.
*/
static void hw_message(struct hpi_adapter_obj *pao, struct hpi_message *phm,
	struct hpi_response *phr)
{}