1/*	$NetBSD: pcf8584reg.h,v 1.2 2016/01/03 17:32:17 jdc Exp $ */
2
3/* Written by Tobias Nygren. Released into the public domain. */
4
5/* SCL clock frequency */
6#define	PCF8584_SCL_90		0 	/* 90 kHz */
7#define	PCF8584_SCL_45		1 	/* 45 kHz */
8#define	PCF8584_SCL_11		2	/* 11 kHz */
9#define	PCF8584_SCL_1_5		3	/* 1.5 kHz */
10
11/* Internal clock frequency */
12#define	PCF8584_CLK_3		0	/* 3 MHz */
13#define	PCF8584_CLK_4_43	0x10	/* 4.43 MHz */
14#define	PCF8584_CLK_6		0x14	/* 6 MHz */
15#define	PCF8584_CLK_8		0x18	/* 8 MHz */
16#define	PCF8584_CLK_12		0x1C	/* 12 MHz */
17
18/* Control register bits (write only) */
19#define	PCF8584_CTRL_ACK	(1<<0)	/* send ACK */
20#define	PCF8584_CTRL_STO	(1<<1)	/* send STOP */
21#define	PCF8584_CTRL_STA	(1<<2)	/* send START */
22#define	PCF8584_CTRL_ENI	(1<<3)	/* Enable Interrupt */
23#define	PCF8584_CTRL_ES2	(1<<4)	/* alternate register selection */
24#define	PCF8584_CTRL_ES1	(1<<5)	/* alternate register selection */
25#define	PCF8584_CTRL_ESO	(1<<6)	/* Enable Serial Output */
26#define	PCF8584_CTRL_PIN	(1<<7)	/* Pending Interrupt Not */
27
28/* Status register bits (read only) */
29#define	PCF8584_STATUS_BBN	(1<<0)	/* Bus Busy Not */
30#define	PCF8584_STATUS_LAB	(1<<1)	/* Lost Arbitration */
31#define	PCF8584_STATUS_AAS	(1<<2)	/* Adressed As Slave */
32#define	PCF8584_STATUS_LRB	(1<<3)	/* Last Received Bit (NAK+bcast det.) */
33#define	PCF8584_STATUS_BER	(1<<4)	/* Bus error */
34#define	PCF8584_STATUS_STS	(1<<5)	/* external STOP condition detected */
35#define	PCF8584_STATUS_INI	(1<<6)	/* 0 if initialized */
36#define	PCF8584_STATUS_PIN	(1<<7)	/* Pending Interrupt Not */
37
38#define	PCF8584_REG_S0_		0			/* S0' own address */
39#define	PCF8584_REG_S2		PCF8584_CTRL_ES1	/* clock register */
40#define	PCF8584_REG_S3		PCF8584_CTRL_ES2	/* Interrupt vector */
41
42#define PCF8584_CMD_START	(PCF8584_CTRL_PIN | PCF8584_CTRL_ESO | \
43    PCF8584_CTRL_STA | PCF8584_CTRL_ACK)
44#define PCF8584_CMD_STOP	(PCF8584_CTRL_PIN | PCF8584_CTRL_ESO | \
45    PCF8584_CTRL_STO | PCF8584_CTRL_ACK)
46#define PCF8584_CMD_REPSTART    (PCF8584_CTRL_ESO | PCF8584_CTRL_STA | \
47    PCF8584_CTRL_ACK)
48#define PCF8584_CMD_IDLE        (PCF8584_CTRL_PIN | PCF8584_CTRL_ESO | \
49    PCF8584_CTRL_ACK)
50#define PCF8584_CMD_NAK (PCF8584_CTRL_ESO)
51