1/* $NetBSD: scmdvar.h,v 1.1 2021/12/07 17:39:54 brad Exp $ */ 2 3/* 4 * Copyright (c) 2021 Brad Spencer <brad@anduin.eldar.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#ifndef _DEV_SCMDVAR_H_ 20#define _DEV_SCMDVAR_H_ 21 22struct scmd_sc { 23 int sc_scmddebug; 24 device_t sc_dev; 25 i2c_tag_t sc_tag; 26 i2c_addr_t sc_addr; 27 struct spi_handle *sc_sh; 28 kmutex_t sc_mutex; /* for reading the i2c or spi bus */ 29 kmutex_t sc_dying_mutex; /* for cleaning up */ 30 kmutex_t sc_condmutex; /* for waiting a long time */ 31 kcondvar_t sc_condvar; 32 kcondvar_t sc_cond_dying; /* interlock when cleaning up */ 33 struct sysctllog *sc_scmdlog; 34 uint8_t sc_topaddr; 35 bool sc_dying; 36 bool sc_opened; 37 void (*sc_func_attach)(struct scmd_sc *); 38 int (*sc_func_acquire_bus)(struct scmd_sc *); 39 void (*sc_func_release_bus)(struct scmd_sc *); 40 int (*sc_func_read_register)(struct scmd_sc *, uint8_t, uint8_t *); 41 int (*sc_func_write_register)(struct scmd_sc *, uint8_t, uint8_t); 42}; 43 44#endif 45