1 1.4 thorpej /* $NetBSD: dwiic_var.h,v 1.4 2025/09/15 15:18:42 thorpej 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 int sc_poll; 51 1.1 bouyer kmutex_t sc_int_lock; 52 1.1 bouyer kcondvar_t sc_int_readwait; 53 1.1 bouyer kcondvar_t sc_int_writewait; 54 1.2 jakllsch kcondvar_t sc_int_stopwait; 55 1.1 bouyer 56 1.1 bouyer uint32_t master_cfg; 57 1.1 bouyer uint16_t ss_hcnt, ss_lcnt, fs_hcnt, fs_lcnt; 58 1.1 bouyer uint32_t sda_hold_time; 59 1.1 bouyer int tx_fifo_depth; 60 1.1 bouyer int rx_fifo_depth; 61 1.1 bouyer 62 1.1 bouyer struct i2c_controller sc_i2c_tag; 63 1.1 bouyer kmutex_t sc_i2c_lock; 64 1.1 bouyer struct { 65 1.1 bouyer i2c_op_t op; 66 1.1 bouyer void *buf; 67 1.1 bouyer size_t len; 68 1.1 bouyer int flags; 69 1.1 bouyer volatile int error; 70 1.1 bouyer } sc_i2c_xfer; 71 1.3 riastrad 72 1.3 riastrad volatile bool sc_attached; 73 1.1 bouyer }; 74 1.1 bouyer 75 1.1 bouyer bool dwiic_attach(struct dwiic_softc *); 76 1.1 bouyer int dwiic_detach(device_t, int); 77 1.1 bouyer bool dwiic_suspend(device_t, const pmf_qual_t *); 78 1.1 bouyer bool dwiic_resume(device_t, const pmf_qual_t *); 79 1.1 bouyer 80 1.1 bouyer int dwiic_intr(void *); 81