#include "tms9914.h"
#include "gpibP.h"
enum hp_82341_hardware_version {
HW_VERSION_UNKNOWN,
HW_VERSION_82341C,
HW_VERSION_82341D,
};
struct hp_82341_priv {
struct tms9914_priv tms9914_priv;
unsigned int irq;
unsigned short config_control_bits;
unsigned short mode_control_bits;
unsigned short event_status_bits;
struct pnp_dev *pnp_dev;
unsigned long iobase[4];
unsigned long io_region_offset;
enum hp_82341_hardware_version hw_version;
};
static const int hp_82341_region_iosize = 0x8;
static const int hp_82341_num_io_regions = 4;
static const int hp_82341_fifo_size = 0xffe;
static const int hp_82341c_firmware_length = 5764;
static const int hp_82341d_firmware_length = 5302;
enum hp_82341_region_0_registers {
CONFIG_CONTROL_STATUS_REG = 0x0,
MODE_CONTROL_STATUS_REG = 0x1,
MONITOR_REG = 0x2,
XILINX_DATA_REG = 0x2,
INTERRUPT_ENABLE_REG = 0x3,
EVENT_STATUS_REG = 0x4,
EVENT_ENABLE_REG = 0x5,
STREAM_STATUS_REG = 0x7,
};
enum hp_82341_region_1_registers {
ID0_REG = 0x2,
ID1_REG = 0x3,
TRANSFER_COUNT_LOW_REG = 0x4,
TRANSFER_COUNT_MID_REG = 0x5,
TRANSFER_COUNT_HIGH_REG = 0x6,
};
enum hp_82341_region_3_registers {
BUFFER_PORT_LOW_REG = 0x0,
BUFFER_PORT_HIGH_REG = 0x1,
ID2_REG = 0x2,
ID3_REG = 0x3,
BUFFER_FLUSH_REG = 0x4,
BUFFER_CONTROL_REG = 0x7
};
enum config_control_status_bits {
IRQ_SELECT_MASK = 0x7,
DMA_CONFIG_MASK = 0x18,
ENABLE_DMA_CONFIG_BIT = 0x20,
XILINX_READY_BIT = 0x40,
DONE_PGL_BIT = 0x80
};
static inline unsigned int IRQ_SELECT_BITS(int irq)
{
switch (irq) {
case 3:
return 0x3;
case 5:
return 0x2;
case 7:
return 0x1;
case 9:
return 0x0;
case 10:
return 0x7;
case 11:
return 0x6;
case 12:
return 0x5;
case 15:
return 0x4;
default:
return 0x0;
}
};
enum mode_control_status_bits {
SLOT8_BIT = 0x1,
ACTIVE_CONTROLLER_BIT = 0x2,
ENABLE_DMA_BIT = 0x4,
SYSTEM_CONTROLLER_BIT = 0x8,
MONITOR_BIT = 0x10,
ENABLE_IRQ_CONFIG_BIT = 0x20,
ENABLE_TI_STREAM_BIT = 0x40
};
enum monitor_bits {
MONITOR_INTERRUPT_PENDING_BIT = 0x1,
MONITOR_CLEAR_HOLDOFF_BIT = 0x2,
MONITOR_PPOLL_BIT = 0x4,
MONITOR_SRQ_BIT = 0x8,
MONITOR_IFC_BIT = 0x10,
MONITOR_REN_BIT = 0x20,
MONITOR_END_BIT = 0x40,
MONITOR_DAV_BIT = 0x80
};
enum interrupt_enable_bits {
ENABLE_TI_INTERRUPT_BIT = 0x1,
ENABLE_POINTERS_EQUAL_INTERRUPT_BIT = 0x4,
ENABLE_BUFFER_END_INTERRUPT_BIT = 0x10,
ENABLE_TERMINAL_COUNT_INTERRUPT_BIT = 0x20,
ENABLE_DMA_TERMINAL_COUNT_INTERRUPT_BIT = 0x80,
};
enum event_status_bits {
TI_INTERRUPT_EVENT_BIT = 0x1,
INTERRUPT_PENDING_EVENT_BIT = 0x2,
POINTERS_EQUAL_EVENT_BIT = 0x4,
BUFFER_END_EVENT_BIT = 0x10,
TERMINAL_COUNT_EVENT_BIT = 0x20,
DMA_TERMINAL_COUNT_EVENT_BIT = 0x80,
};
enum event_enable_bits {
ENABLE_TI_INTERRUPT_EVENT_BIT = 0x1,
ENABLE_POINTERS_EQUAL_EVENT_BIT = 0x4,
ENABLE_BUFFER_END_EVENT_BIT = 0x10,
ENABLE_TERMINAL_COUNT_EVENT_BIT = 0x20,
ENABLE_DMA_TERMINAL_COUNT_EVENT_BIT = 0x80,
};
enum stream_status_bits {
HALTED_STATUS_BIT = 0x1,
RESTART_STREAM_BIT = 0x1
};
enum buffer_control_bits {
DIRECTION_GPIB_TO_HOST_BIT = 0x20,
ENABLE_TI_BUFFER_BIT = 0x40,
FAST_WR_EN_BIT = 0x80,
};
enum hp_82341d_pnp_registers {
PIO_DATA_REG = 0x20,
PIO_DIRECTION_REG = 0x21,
};
enum hp_82341d_pnp_pio_bits {
HP_82341D_XILINX_READY_BIT = 0x1,
HP_82341D_XILINX_DONE_BIT = 0x2,
HP_82341D_LEGACY_MODE_BIT = 0x4,
HP_82341D_NOT_PROG_BIT = 0x8,
};