xref: /openbsd/sys/dev/ic/pcf8584var.h (revision 09467b48)
1 /*	$OpenBSD: pcf8584var.h,v 1.5 2007/10/20 18:46:21 kettenis Exp $ */
2 
3 /*
4  * Copyright (c) 2006 David Gwynne <dlg@openbsd.org>
5  *
6  * Permission to use, copy, modify, and distribute this software for any
7  * purpose with or without fee is hereby granted, provided that the above
8  * copyright notice and this permission notice appear in all copies.
9  *
10  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17  */
18 
19 struct pcfiic_softc {
20 	struct device		sc_dev;
21 
22 	bus_space_tag_t		sc_iot;
23 	bus_space_handle_t	sc_ioh;
24 	bus_space_handle_t	sc_ioh2;
25 	int			sc_master;
26 	u_int8_t		sc_addr;
27 	u_int8_t		sc_clock;
28 	u_int8_t		sc_regmap[2];
29 
30 	int			sc_poll;
31 
32 	struct i2c_controller	sc_i2c;
33 	struct rwlock		sc_lock;
34 };
35 
36 /* clock divisor settings */
37 #define PCF_CLOCK_3		0x00 /* 3 MHz */
38 #define PCF_CLOCK_4_43		0x10 /* 4.43 MHz */
39 #define PCF_CLOCK_6		0x14 /* 6 MHz */
40 #define PCF_CLOCK_8		0x18 /* 8 MHz */
41 #define PCF_CLOCK_12		0x1c /* 12 MHz */
42 
43 /* SCL frequency settings */
44 #define PCF_FREQ_90		0x00 /* 90 kHz */
45 #define PCF_FREQ_45		0x01 /* 45 kHz */
46 #define PCF_FREQ_11		0x02 /* 11 kHz */
47 #define PCF_FREQ_1_5		0x03 /* 1.5 kHz */
48 
49 void	pcfiic_attach(struct pcfiic_softc *, i2c_addr_t, u_int8_t, int,
50 	    void (*)(struct device *, struct i2cbus_attach_args *, void *),
51 	    void *);
52 int	pcfiic_intr(void *);
53