#ifndef _TMS9914_H
#define _TMS9914_H
#include <linux/types.h>
#include <linux/interrupt.h>
#include "gpib_state_machines.h"
#include "gpib_types.h"
enum tms9914_holdoff_mode {
TMS9914_HOLDOFF_NONE,
TMS9914_HOLDOFF_EOI,
TMS9914_HOLDOFF_ALL,
};
struct tms9914_priv {
#ifdef CONFIG_HAS_IOPORT
u32 iobase;
#endif
void __iomem *mmiobase;
unsigned int offset;
unsigned int dma_channel;
u8 imr0_bits, imr1_bits;
u8 admr_bits;
u8 auxa_bits;
unsigned long state;
u8 eos;
short eos_flags;
u8 spoll_status;
enum tms9914_holdoff_mode holdoff_mode;
unsigned int ppoll_line;
enum talker_function_state talker_state;
enum listener_function_state listener_state;
unsigned ppoll_sense : 1;
unsigned ppoll_enable : 1;
unsigned ppoll_configure_state : 1;
unsigned primary_listen_addressed : 1;
unsigned primary_talk_addressed : 1;
unsigned holdoff_on_end : 1;
unsigned holdoff_on_all : 1;
unsigned holdoff_active : 1;
u8 (*read_byte)(struct tms9914_priv *priv, unsigned int register_number);
void (*write_byte)(struct tms9914_priv *priv, u8 byte, unsigned int
register_number);
};
static inline u8 read_byte(struct tms9914_priv *priv, unsigned int register_number)
{
return priv->read_byte(priv, register_number);
}
static inline void write_byte(struct tms9914_priv *priv, u8 byte, unsigned int register_number)
{
priv->write_byte(priv, byte, register_number);
}
enum {
PIO_IN_PROGRESS_BN,
DMA_READ_IN_PROGRESS_BN,
DMA_WRITE_IN_PROGRESS_BN,
READ_READY_BN,
WRITE_READY_BN,
COMMAND_READY_BN,
RECEIVED_END_BN,
BUS_ERROR_BN,
DEV_CLEAR_BN,
};
int tms9914_read(struct gpib_board *board, struct tms9914_priv *priv, u8 *buffer,
size_t length, int *end, size_t *bytes_read);
int tms9914_write(struct gpib_board *board, struct tms9914_priv *priv, u8 *buffer,
size_t length, int send_eoi, size_t *bytes_written);
int tms9914_command(struct gpib_board *board, struct tms9914_priv *priv, u8 *buffer,
size_t length, size_t *bytes_written);
int tms9914_take_control(struct gpib_board *board, struct tms9914_priv *priv, int syncronous);
int tms9914_take_control_workaround(struct gpib_board *board, struct tms9914_priv *priv,
int syncronous);
int tms9914_go_to_standby(struct gpib_board *board, struct tms9914_priv *priv);
int tms9914_request_system_control(struct gpib_board *board, struct tms9914_priv *priv,
int request_control);
void tms9914_interface_clear(struct gpib_board *board, struct tms9914_priv *priv, int assert);
void tms9914_remote_enable(struct gpib_board *board, struct tms9914_priv *priv, int enable);
int tms9914_enable_eos(struct gpib_board *board, struct tms9914_priv *priv, u8 eos_bytes,
int compare_8_bits);
void tms9914_disable_eos(struct gpib_board *board, struct tms9914_priv *priv);
unsigned int tms9914_update_status(struct gpib_board *board, struct tms9914_priv *priv,
unsigned int clear_mask);
int tms9914_primary_address(struct gpib_board *board,
struct tms9914_priv *priv, unsigned int address);
int tms9914_secondary_address(struct gpib_board *board, struct tms9914_priv *priv,
unsigned int address, int enable);
int tms9914_parallel_poll(struct gpib_board *board, struct tms9914_priv *priv, u8 *result);
void tms9914_parallel_poll_configure(struct gpib_board *board,
struct tms9914_priv *priv, u8 config);
void tms9914_parallel_poll_response(struct gpib_board *board,
struct tms9914_priv *priv, int ist);
void tms9914_serial_poll_response(struct gpib_board *board,
struct tms9914_priv *priv, u8 status);
u8 tms9914_serial_poll_status(struct gpib_board *board, struct tms9914_priv *priv);
int tms9914_line_status(const struct gpib_board *board, struct tms9914_priv *priv);
unsigned int tms9914_t1_delay(struct gpib_board *board, struct tms9914_priv *priv,
unsigned int nano_sec);
void tms9914_return_to_local(const struct gpib_board *board, struct tms9914_priv *priv);
void tms9914_board_reset(struct tms9914_priv *priv);
void tms9914_online(struct gpib_board *board, struct tms9914_priv *priv);
void tms9914_release_holdoff(struct tms9914_priv *priv);
void tms9914_set_holdoff_mode(struct tms9914_priv *priv, enum tms9914_holdoff_mode mode);
u8 tms9914_ioport_read_byte(struct tms9914_priv *priv, unsigned int register_num);
void tms9914_ioport_write_byte(struct tms9914_priv *priv, u8 data, unsigned int register_num);
u8 tms9914_iomem_read_byte(struct tms9914_priv *priv, unsigned int register_num);
void tms9914_iomem_write_byte(struct tms9914_priv *priv, u8 data, unsigned int register_num);
irqreturn_t tms9914_interrupt(struct gpib_board *board, struct tms9914_priv *priv);
irqreturn_t tms9914_interrupt_have_status(struct gpib_board *board, struct tms9914_priv *priv,
int status1, int status2);
enum {
ms9914_num_registers = 8,
};
enum {
IMR0 = 0,
IMR1 = 1,
AUXCR = 3,
ADR = 4,
SPMR = 5,
PPR = 6,
CDOR = 7,
};
enum {
ISR0 = 0,
ISR1 = 1,
ADSR = 2,
BSR = 3,
CPTR = 6,
DIR = 7,
};
enum isr0_bits {
HR_MAC = (1 << 0),
HR_RLC = (1 << 1),
HR_SPAS = (1 << 2),
HR_END = (1 << 3),
HR_BO = (1 << 4),
HR_BI = (1 << 5),
};
enum imr0_bits {
HR_MACIE = (1 << 0),
HR_RLCIE = (1 << 1),
HR_SPASIE = (1 << 2),
HR_ENDIE = (1 << 3),
HR_BOIE = (1 << 4),
HR_BIIE = (1 << 5),
};
enum isr1_bits {
HR_IFC = (1 << 0),
HR_SRQ = (1 << 1),
HR_MA = (1 << 2),
HR_DCAS = (1 << 3),
HR_APT = (1 << 4),
HR_UNC = (1 << 5),
HR_ERR = (1 << 6),
HR_GET = (1 << 7),
};
enum imr1_bits {
HR_IFCIE = (1 << 0),
HR_SRQIE = (1 << 1),
HR_MAIE = (1 << 2),
HR_DCASIE = (1 << 3),
HR_APTIE = (1 << 4),
HR_UNCIE = (1 << 5),
HR_ERRIE = (1 << 6),
HR_GETIE = (1 << 7),
};
enum adsr_bits {
HR_ULPA = (1 << 0),
HR_TA = (1 << 1),
HR_LA = (1 << 2),
HR_TPAS = (1 << 3),
HR_LPAS = (1 << 4),
HR_ATN = (1 << 5),
HR_LLO = (1 << 6),
HR_REM = (1 << 7),
};
enum adr_bits {
ADDRESS_MASK = 0x1f,
HR_DAT = (1 << 5),
HR_DAL = (1 << 6),
HR_EDPA = (1 << 7),
};
enum bus_status_bits {
BSR_REN_BIT = 0x1,
BSR_IFC_BIT = 0x2,
BSR_SRQ_BIT = 0x4,
BSR_EOI_BIT = 0x8,
BSR_NRFD_BIT = 0x10,
BSR_NDAC_BIT = 0x20,
BSR_DAV_BIT = 0x40,
BSR_ATN_BIT = 0x80,
};
enum aux_cmd_bits {
AUX_CS = 0x80,
AUX_CHIP_RESET = 0x0,
AUX_INVAL = 0x1,
AUX_VAL = (AUX_INVAL | AUX_CS),
AUX_RHDF = 0x2,
AUX_HLDA = 0x3,
AUX_HLDE = 0x4,
AUX_NBAF = 0x5,
AUX_FGET = 0x6,
AUX_RTL = 0x7,
AUX_SEOI = 0x8,
AUX_LON = 0x9,
AUX_TON = 0xa,
AUX_GTS = 0xb,
AUX_TCA = 0xc,
AUX_TCS = 0xd,
AUX_RPP = 0xe,
AUX_SIC = 0xf,
AUX_SRE = 0x10,
AUX_RQC = 0x11,
AUX_RLC = 0x12,
AUX_DAI = 0x13,
AUX_PTS = 0x14,
AUX_STDL = 0x15,
AUX_SHDW = 0x16,
AUX_VSTDL = 0x17,
AUX_RSV2 = 0x18,
};
#endif