#ifndef _PCF8584_H
#define _PCF8584_H
#pragma ident "%Z%%M% %I% %E% SMI"
#ifdef __cplusplus
extern "C" {
#endif
#include <sys/promif.h>
#define S1_ACK 0x01
#define S1_STO 0x02
#define S1_STA 0x04
#define S1_ENI 0x08
#define S1_ES2 0x10
#define S1_ES1 0x20
#define S1_ESO 0x40
#define S1_BBN 0x01
#define S1_LAB 0x02
#define S1_AAS 0x04
#define S1_AD0 0x08
#define S1_LRB 0x08
#define S1_BER 0x10
#define S1_STS 0x20
#define S1_PIN 0x80
#define I2C_READ 0x01
#define S0_OWN 0x55
#define S0_CLK 0x1C
#define PCF8584_INIT_WAIT 200000
#define DUMMY_ADDR 0x20
#define DUMMY_DATA 0x00
#define MONITOR_ADDRESS 0x0
#define S1_START (S1_PIN | S1_ESO | S1_STA | S1_ACK)
#define S1_STOP (S1_PIN | S1_ESO | S1_STO | S1_ACK)
#define S1_START2 (S1_ESO | S1_STA | S1_ACK)
#define PRT_SELECT 0x01
#define PRT_INTR 0x02
#define PRT_INIT 0x04
#define PRT_TRAN 0x08
#define PRT_POLL 0x10
#define PRT_BUFFONLY 0x100
#define PRT_PROM 0x200
enum tran_state {
TRAN_STATE_NULL,
TRAN_STATE_WR,
TRAN_STATE_RD,
TRAN_STATE_WR_RD,
TRAN_STATE_START,
TRAN_STATE_DUMMY_DATA,
TRAN_STATE_DUMMY_RD
};
enum impl_type {
GENERIC,
BBC,
PIC16F747
};
typedef struct pcf8584_regs {
uint8_t *pcf8584_regs_s0;
uint8_t *pcf8584_regs_s1;
} pcf8584_regs_t;
typedef struct pcf8584 {
dev_info_t *pcf8584_dip;
int pcf8584_attachflags;
kcondvar_t pcf8584_cv;
kmutex_t pcf8584_imutex;
kcondvar_t pcf8584_icv;
ddi_iblock_cookie_t pcf8584_icookie;
int pcf8584_mode;
int pcf8584_open;
int pcf8584_busy;
int pcf8584_bus;
int pcf8584_cur_status;
dev_info_t *pcf8584_nexus_dip;
i2c_transfer_t *pcf8584_cur_tran;
dev_info_t *pcf8584_cur_dip;
pcf8584_regs_t pcf8584_regs;
ddi_acc_handle_t pcf8584_rhandle;
uint8_t *pcf8584_b_reg;
ddi_acc_handle_t pcf8584_b_rhandle;
enum tran_state pcf8584_tran_state;
char pcf8584_name[12];
enum impl_type pcf8584_impl_type;
uint32_t pcf8584_impl_delay;
} pcf8584_t;
typedef struct pcf8584_ppvt {
int pcf8584_ppvt_bus;
int pcf8584_ppvt_addr;
} pcf8584_ppvt_t;
#define PCF8584_PIL 4
#define PCF8584_POLL_MODE 1
#define PCF8584_INTR_MODE 2
#define PCF8584_INITIAL_SOFT_SPACE 4
#define PCF8584_GENERIC_DELAY 0
#define PCF8584_PIC16F747_DELAY 10
#define I2C_COMPLETE 2
#define I2C_PENDING 3
#define PCF8584_TRANSFER_NEW 1
#define PCF8584_TRANSFER_ON 2
#define PCF8584_TRANSFER_OVER 3
#define ADD_INTR 0x01
#define ADD_PVT 0x02
#define SETUP_REGS 0x04
#define NEXUS_REGISTER 0x08
#define PROP_CREATE 0x10
#define IMUTEX 0x20
#define ALLOCATE_PVT 0x40
#define MINOR_NODE 0x80
#ifdef __cplusplus
}
#endif
#endif