198247Smikeh/* $NetBSD: gttwsivar.h,v 1.6 2020/01/12 17:48:42 thorpej Exp $ */ 279971Sobrien/* 398247Smikeh * Copyright (c) 2008 Eiji Kawauchi. 498247Smikeh * All rights reserved. 598247Smikeh * 698247Smikeh * Redistribution and use in source and binary forms, with or without 798247Smikeh * modification, are permitted provided that the following conditions 898247Smikeh * are met: 998247Smikeh * 1. Redistributions of source code must retain the above copyright 1098247Smikeh * notice, this list of conditions and the following disclaimer. 1198247Smikeh * 2. Redistributions in binary form must reproduce the above copyright 1298247Smikeh * notice, this list of conditions and the following disclaimer in the 1398247Smikeh * documentation and/or other materials provided with the distribution. 1498247Smikeh * 3. All advertising materials mentioning features or use of this software 1579971Sobrien * must display the following acknowledgement: 1679971Sobrien * This product includes software developed for the NetBSD Project by 1779971Sobrien * Eiji Kawauchi. 1879971Sobrien * 4. The name of the author may not be used to endorse or promote products 1979971Sobrien * derived from this software without specific prior written permission 2079971Sobrien * 2179971Sobrien * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 2279971Sobrien * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 2379971Sobrien * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 2479971Sobrien * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 2579971Sobrien * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 26 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 27 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 28 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 30 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 */ 32/* 33 * Copyright (c) 2005 Brocade Communcations, inc. 34 * All rights reserved. 35 * 36 * Written by Matt Thomas for Brocade Communcations, Inc. 37 * 38 * Redistribution and use in source and binary forms, with or without 39 * modification, are permitted provided that the following conditions 40 * are met: 41 * 1. Redistributions of source code must retain the above copyright 42 * notice, this list of conditions and the following disclaimer. 43 * 2. Redistributions in binary form must reproduce the above copyright 44 * notice, this list of conditions and the following disclaimer in the 45 * documentation and/or other materials provided with the distribution. 46 * 3. The name of Brocade Communications, Inc. may not be used to endorse 47 * or promote products derived from this software without specific prior 48 * written permission. 49 * 50 * THIS SOFTWARE IS PROVIDED BY BROCADE COMMUNICATIONS, INC. ``AS IS'' AND 51 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 52 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 53 * ARE DISCLAIMED. IN NO EVENT SHALL EITHER BROCADE COMMUNICATIONS, INC. BE 54 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 55 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 56 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 57 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 58 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 59 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 60 * OF THE POSSIBILITY OF SUCH DAMAGE. 61 */ 62 63#ifndef _DEV_MARVELL_GTTWSIVAR_H_ 64#define _DEV_MARVELL_GTTWSIVAR_H_ 65 66/* 67 * Marvell Two-Wire Serial Interface (aka I2C) master driver 68 */ 69 70#include <sys/param.h> 71#include <sys/bus.h> 72#include <sys/condvar.h> 73#include <sys/device.h> 74#include <sys/errno.h> 75#include <sys/kernel.h> 76#include <sys/mutex.h> 77#include <sys/systm.h> 78 79#include <dev/i2c/i2cvar.h> 80 81struct gttwsi_softc { 82 device_t sc_dev; 83 bus_space_tag_t sc_bust; 84 bus_space_handle_t sc_bush; 85 bool sc_started; 86 struct i2c_controller sc_i2c; 87 kmutex_t sc_buslock; 88 kmutex_t sc_mtx; 89 kcondvar_t sc_cv; 90 91 const bus_size_t *sc_regmap; /* GTTWSI_NREGS entries */ 92 93 bool sc_iflg_rwc; 94}; 95 96void gttwsi_attach_subr(device_t, bus_space_tag_t, bus_space_handle_t, 97 const bus_size_t *); 98void gttwsi_config_children(device_t); 99 100uint32_t gttwsi_read_4(struct gttwsi_softc *, uint32_t); 101void gttwsi_write_4(struct gttwsi_softc *, uint32_t, uint32_t); 102 103int gttwsi_intr(void *); 104 105#endif /* _DEV_MARVELL_GTTSWI_VAR_H_ */ 106