dwiic_var.h revision 1.3 1 1.3 riastrad /* $NetBSD: dwiic_var.h,v 1.3 2022/10/19 22:34:10 riastradh Exp $ */
2 1.1 bouyer
3 1.1 bouyer /*-
4 1.1 bouyer * Copyright (c) 2017 The NetBSD Foundation, Inc.
5 1.1 bouyer * All rights reserved.
6 1.1 bouyer *
7 1.1 bouyer * This code is derived from software contributed to The NetBSD Foundation
8 1.1 bouyer * by Manuel Bouyer.
9 1.1 bouyer *
10 1.1 bouyer * Redistribution and use in source and binary forms, with or without
11 1.1 bouyer * modification, are permitted provided that the following conditions
12 1.1 bouyer * are met:
13 1.1 bouyer * 1. Redistributions of source code must retain the above copyright
14 1.1 bouyer * notice, this list of conditions and the following disclaimer.
15 1.1 bouyer * 2. Redistributions in binary form must reproduce the above copyright
16 1.1 bouyer * notice, this list of conditions and the following disclaimer in the
17 1.1 bouyer * documentation and/or other materials provided with the distribution.
18 1.1 bouyer *
19 1.1 bouyer * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
20 1.1 bouyer * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 1.1 bouyer * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 1.1 bouyer * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23 1.1 bouyer * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 1.1 bouyer * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 1.1 bouyer * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 1.1 bouyer * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 1.1 bouyer * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 1.1 bouyer * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 1.1 bouyer * POSSIBILITY OF SUCH DAMAGE.
30 1.1 bouyer */
31 1.1 bouyer
32 1.1 bouyer #include <dev/i2c/i2cvar.h>
33 1.1 bouyer
34 1.1 bouyer enum dwiic_type {
35 1.1 bouyer dwiic_type_generic,
36 1.1 bouyer dwiic_type_sunrisepoint
37 1.1 bouyer };
38 1.1 bouyer
39 1.1 bouyer struct dwiic_softc {
40 1.1 bouyer device_t sc_dev;
41 1.1 bouyer
42 1.1 bouyer bus_space_tag_t sc_iot;
43 1.1 bouyer bus_space_handle_t sc_ioh;
44 1.1 bouyer void *sc_ih;
45 1.1 bouyer
46 1.1 bouyer enum dwiic_type sc_type;
47 1.1 bouyer
48 1.1 bouyer bool (*sc_power)(struct dwiic_softc *, bool);
49 1.1 bouyer
50 1.1 bouyer struct i2cbus_attach_args sc_iba;
51 1.1 bouyer device_t sc_iic;
52 1.1 bouyer
53 1.1 bouyer int sc_poll;
54 1.1 bouyer kmutex_t sc_int_lock;
55 1.1 bouyer kcondvar_t sc_int_readwait;
56 1.1 bouyer kcondvar_t sc_int_writewait;
57 1.2 jakllsch kcondvar_t sc_int_stopwait;
58 1.1 bouyer
59 1.1 bouyer uint32_t master_cfg;
60 1.1 bouyer uint16_t ss_hcnt, ss_lcnt, fs_hcnt, fs_lcnt;
61 1.1 bouyer uint32_t sda_hold_time;
62 1.1 bouyer int tx_fifo_depth;
63 1.1 bouyer int rx_fifo_depth;
64 1.1 bouyer
65 1.1 bouyer struct i2c_controller sc_i2c_tag;
66 1.1 bouyer kmutex_t sc_i2c_lock;
67 1.1 bouyer struct {
68 1.1 bouyer i2c_op_t op;
69 1.1 bouyer void *buf;
70 1.1 bouyer size_t len;
71 1.1 bouyer int flags;
72 1.1 bouyer volatile int error;
73 1.1 bouyer } sc_i2c_xfer;
74 1.3 riastrad
75 1.3 riastrad volatile bool sc_attached;
76 1.1 bouyer };
77 1.1 bouyer
78 1.1 bouyer bool dwiic_attach(struct dwiic_softc *);
79 1.1 bouyer int dwiic_detach(device_t, int);
80 1.1 bouyer bool dwiic_suspend(device_t, const pmf_qual_t *);
81 1.1 bouyer bool dwiic_resume(device_t, const pmf_qual_t *);
82 1.1 bouyer
83 1.1 bouyer int dwiic_intr(void *);
84