#ifndef _SMBUS_H
#define _SMBUS_H
#pragma ident "%Z%%M% %I% %E% SMI"
#ifdef __cplusplus
extern "C" {
#endif
#include <sys/promif.h>
#define SETUP_REGS 0x01
#define NEXUS_REGISTER 0x02
#define IMUTEX 0x04
#define ADD_INTR 0x08
#define INTERRUPT_PRI 0x10
#define SMB_STS 0x00
#define SMB_TYP 0x01
#define STR_PORT 0x02
#define DEV_ADDR 0x03
#define DEV_DATA0 0x04
#define DEV_DATA1 0x05
#define BLK_DATA 0x06
#define SMB_CMD 0x07
#define FAILED 0x80
#define BUS_ERR 0x40
#define DRV_ERR 0x20
#define CMD_CMPL 0x10
#define HOST_BSY 0x08
#define IDLE 0x04
#define INDEX 0x04
#define TENBITS 0x02
#define ALERT 0x01
#define DEV10B_EN 0x80
#define QUICK_CMD 0x00
#define SEND_BYTE 0x10
#define RCV_BYTE 0x10
#define WR_BYTE 0x20
#define RD_BYTE 0x20
#define WR_WORD 0x30
#define RD_WORD 0x30
#define WR_BLK 0x40
#define RD_BLK 0x40
#define PRC_CALL 0x50
#define T_OUT 0x08
#define KILL 0x04
#define SMBUS_PIL 4
#define MAX_BLK_SEND 32
#define I2C_READ 0x01
#define SMBUS_MAX_RETRIES 10
#define SMBUS_FLUSH 0x01
#define INTR_TIMEOUT 100000
#define SMBUS_TRANS_TIMEOUT 10000000
#define SMBUS_POLL_MODE 1
#define SMBUS_POLL_TIMEOUT 50000
#define SMBUS_POLL_INTERVAL 1
#define SMBUS_POLL_MAX_RETRIES (SMBUS_POLL_TIMEOUT/SMBUS_POLL_INTERVAL)
typedef struct smbus_ppvt {
int smbus_ppvt_addr;
} smbus_ppvt_t;
typedef struct smbus {
dev_info_t *smbus_dip;
int smbus_attachflags;
kmutex_t smbus_mutex;
kmutex_t smbus_imutex;
kcondvar_t smbus_icv;
kcondvar_t smbus_cv;
kcondvar_t smbus_intr_cv;
ddi_iblock_cookie_t smbus_icookie;
int smbus_busy;
int smbus_wait;
int smbus_bus;
i2c_transfer_t *smbus_cur_tran;
dev_info_t *smbus_cur_dip;
char smbus_name[12];
uint8_t *smbus_regaddr;
ddi_acc_handle_t smbus_rhandle;
uint8_t *smbus_configregaddr;
ddi_acc_handle_t smbus_confighandle;
timeout_id_t smbus_timeout;
int smbus_saved_w_resid;
int smbus_retries;
int smbus_bytes_to_read;
int smbus_poll_complete;
int smbus_polling;
int smbus_poll_retries;
} smbus_t;
#define PRT_INIT 0x01
#define PRT_WR 0x02
#define PRT_RD 0x04
#define PRT_PUT 0x08
#define PRT_GET 0x10
#define PRT_ATTACH 0x20
#define PRT_INTR 0x40
#define PRT_INTR_ERR 0x80
#define PRT_TRANS 0x100
#define PRT_SPEC 0x200
#define PRT_BUFFONLY 0x1000
#define PRT_PROM 0x2000
#define SMBUS_PENDING 0x01
#define SMBUS_COMPLETE 0x02
#define SMBUS_FAILURE 0x03
#define SMBUS_SUCCESS 0x04
#define SMBUS_SRC_STATUS 0x48
#define SMBUS_SRC_ENA 0x44
#define SMBUS_SMI 0x80000
#define SMBUS_SMB_INTR_STATUS 0x80000
#define SMBUS_INTR "smbus_intr"
#define SMBUS_TIMEOUT "smbus_timeout"
#define SMBUS_POLL "smbus_poll"
#ifdef DEBUG
#define SMBUS_PRINT(a) smbus_print a
#else
#define SMBUS_PRINT(a)
#endif
int smbus_transfer(dev_info_t *, i2c_transfer_t *);
void smbus_print(int flags, const char *fmt, ...);
#ifdef __cplusplus
}
#endif
#endif