Deleted Added
full compact
pcfvar.h (131575) pcfvar.h (133522)
1/*-
2 * Copyright (c) 1998 Nicolas Souchu, Marc Bouget
3 * Copyright (c) 2004 Joerg Wunsch
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:

--- 10 unchanged lines hidden (view full) ---

19 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
21 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25 * SUCH DAMAGE.
26 *
1/*-
2 * Copyright (c) 1998 Nicolas Souchu, Marc Bouget
3 * Copyright (c) 2004 Joerg Wunsch
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:

--- 10 unchanged lines hidden (view full) ---

19 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
21 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25 * SUCH DAMAGE.
26 *
27 * $FreeBSD: head/sys/dev/pcf/pcfvar.h 131575 2004-07-04 16:11:03Z stefanf $
27 * $FreeBSD: head/sys/dev/pcf/pcfvar.h 133522 2004-08-11 21:19:31Z marius $
28 */
29
30#define IO_PCFSIZE 2
31
32#define TIMEOUT 9999 /* XXX */
33
34/* Status bits of S1 register (read only) */
35#define nBB 0x01 /* busy when low set/reset by STOP/START*/

--- 25 unchanged lines hidden (view full) ---

61 u_char pcf_addr; /* interface I2C address */
62 int pcf_flags; /* IIC_POLLED? */
63 int pcf_slave_mode; /* receiver or transmitter */
64 int pcf_started; /* 1 if start condition sent */
65
66 device_t iicbus; /* the corresponding iicbus */
67
68 /* Resource handling stuff. */
28 */
29
30#define IO_PCFSIZE 2
31
32#define TIMEOUT 9999 /* XXX */
33
34/* Status bits of S1 register (read only) */
35#define nBB 0x01 /* busy when low set/reset by STOP/START*/

--- 25 unchanged lines hidden (view full) ---

61 u_char pcf_addr; /* interface I2C address */
62 int pcf_flags; /* IIC_POLLED? */
63 int pcf_slave_mode; /* receiver or transmitter */
64 int pcf_started; /* 1 if start condition sent */
65
66 device_t iicbus; /* the corresponding iicbus */
67
68 /* Resource handling stuff. */
69 void *intr_cookie;
70 int rid_ioport;
71 int rid_irq;
72 struct resource *res_ioport;
73 struct resource *res_irq;
69 struct resource *res_ioport;
70 int rid_ioport;
71 bus_space_tag_t bt_ioport;
72 bus_space_handle_t bh_ioport;
73 struct resource *res_irq;
74 int rid_irq;
75 void *intr_cookie;
74};
75#define DEVTOSOFTC(dev) ((struct pcf_softc *)device_get_softc(dev))
76
77/*
78 * PCF8584 datasheet : when operate at 8 MHz or more, a minimun time of
79 * 6 clocks cycles must be left between two consecutives access
80 */
81#define pcf_nops() DELAY(10)
82
83#define dummy_read(sc) pcf_get_S0(sc)
84#define dummy_write(sc) pcf_set_S0(sc, 0)
85
86/*
87 * Specific register access to PCF8584
88 */
89static __inline void
90pcf_set_S0(struct pcf_softc *sc, int data)
91{
76};
77#define DEVTOSOFTC(dev) ((struct pcf_softc *)device_get_softc(dev))
78
79/*
80 * PCF8584 datasheet : when operate at 8 MHz or more, a minimun time of
81 * 6 clocks cycles must be left between two consecutives access
82 */
83#define pcf_nops() DELAY(10)
84
85#define dummy_read(sc) pcf_get_S0(sc)
86#define dummy_write(sc) pcf_set_S0(sc, 0)
87
88/*
89 * Specific register access to PCF8584
90 */
91static __inline void
92pcf_set_S0(struct pcf_softc *sc, int data)
93{
92 bus_space_write_1(sc->res_ioport->r_bustag,
93 sc->res_ioport->r_bushandle,
94 0, data);
94
95 bus_space_write_1(sc->bt_ioport, sc->bh_ioport, 0, data);
95 pcf_nops();
96}
97
98static __inline void
99pcf_set_S1(struct pcf_softc *sc, int data)
100{
96 pcf_nops();
97}
98
99static __inline void
100pcf_set_S1(struct pcf_softc *sc, int data)
101{
101 bus_space_write_1(sc->res_ioport->r_bustag,
102 sc->res_ioport->r_bushandle,
103 1, data);
102
103 bus_space_write_1(sc->bt_ioport, sc->bh_ioport, 1, data);
104 pcf_nops();
105}
106
107static __inline char
108pcf_get_S0(struct pcf_softc *sc)
109{
110 char data;
111
104 pcf_nops();
105}
106
107static __inline char
108pcf_get_S0(struct pcf_softc *sc)
109{
110 char data;
111
112 data = bus_space_read_1(sc->res_ioport->r_bustag,
113 sc->res_ioport->r_bushandle, 0);
112 data = bus_space_read_1(sc->bt_ioport, sc->bh_ioport, 0);
114 pcf_nops();
115
116 return (data);
117}
118
119static __inline char
120pcf_get_S1(struct pcf_softc *sc)
121{
122 char data;
123
113 pcf_nops();
114
115 return (data);
116}
117
118static __inline char
119pcf_get_S1(struct pcf_softc *sc)
120{
121 char data;
122
124 data = bus_space_read_1(sc->res_ioport->r_bustag,
125 sc->res_ioport->r_bushandle, 1);
123 data = bus_space_read_1(sc->bt_ioport, sc->bh_ioport, 1);
126 pcf_nops();
127
128 return (data);
129}
130
131extern int pcf_repeated_start(device_t, u_char, int);
132extern int pcf_start(device_t, u_char, int);
133extern int pcf_stop(device_t);
134extern int pcf_write(device_t, char *, int, int *, int);
135extern int pcf_read(device_t, char *, int, int *, int, int);
136extern int pcf_rst_card(device_t, u_char, u_char, u_char *);
137extern driver_intr_t pcf_intr;
138
139#define PCF_MODVER 1
140#define PCF_MINVER 1
141#define PCF_MAXVER 1
142#define PCF_PREFVER PCF_MODVER
124 pcf_nops();
125
126 return (data);
127}
128
129extern int pcf_repeated_start(device_t, u_char, int);
130extern int pcf_start(device_t, u_char, int);
131extern int pcf_stop(device_t);
132extern int pcf_write(device_t, char *, int, int *, int);
133extern int pcf_read(device_t, char *, int, int *, int, int);
134extern int pcf_rst_card(device_t, u_char, u_char, u_char *);
135extern driver_intr_t pcf_intr;
136
137#define PCF_MODVER 1
138#define PCF_MINVER 1
139#define PCF_MAXVER 1
140#define PCF_PREFVER PCF_MODVER