1/* $NetBSD: onewirevar.h,v 1.6 2019/11/30 23:04:12 ad Exp $ */ 2/* $OpenBSD: onewirevar.h,v 1.1 2006/03/04 16:27:03 grange Exp $ */ 3 4/* 5 * Copyright (c) 2006 Alexander Yurchenko <grange@openbsd.org> 6 * 7 * Permission to use, copy, modify, and distribute this software for any 8 * purpose with or without fee is hereby granted, provided that the above 9 * copyright notice and this permission notice appear in all copies. 10 * 11 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 12 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 13 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 14 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 15 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 16 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 17 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 18 */ 19 20#ifndef _DEV_ONEWIRE_ONEWIREVAR_H_ 21#define _DEV_ONEWIRE_ONEWIREVAR_H_ 22 23/* 24 * 1-Wire bus interface. 25 */ 26 27/* Bus master interface */ 28struct onewire_bus { 29 void * bus_cookie; 30 31 int (*bus_reset)(void *); 32 int (*bus_read_bit)(void *); 33 void (*bus_write_bit)(void *, int); 34 int (*bus_read_byte)(void *); 35 void (*bus_write_byte)(void *, int); 36 int (*bus_triplet)(void *, int); 37}; 38 39/* Bus methods */ 40void onewire_lock(void *); 41void onewire_unlock(void *); 42int onewire_reset(void *); 43int onewire_read_bit(void *); 44void onewire_write_bit(void *, int); 45int onewire_read_byte(void *); 46void onewire_write_byte(void *, int); 47int onewire_triplet(void *, int); 48void onewire_read_block(void *, void *, int); 49void onewire_write_block(void *, const void *, int); 50void onewire_matchrom(void *, u_int64_t); 51 52/* Bus attachment */ 53struct onewirebus_attach_args { 54 struct onewire_bus * oba_bus; 55}; 56 57int onewirebus_print(void *, const char *); 58 59/* Device attachment */ 60struct onewire_attach_args { 61 void * oa_onewire; 62 u_int64_t oa_rom; 63}; 64 65/* Family matching */ 66struct onewire_matchfam { 67 int om_type; 68}; 69 70/* Miscellaneous routines */ 71int onewire_crc(const void *, int); 72const char * onewire_famname(int); 73int onewire_matchbyfam(struct onewire_attach_args *, 74 const struct onewire_matchfam *, int); 75 76/* Bus bit-banging */ 77struct onewire_bbops { 78 void (*bb_rx)(void *); 79 void (*bb_tx)(void *); 80 int (*bb_get)(void *); 81 void (*bb_set)(void *, int); 82}; 83 84int onewire_bb_reset(const struct onewire_bbops *, void *); 85int onewire_bb_read_bit(const struct onewire_bbops *, void *); 86void onewire_bb_write_bit(const struct onewire_bbops *, void *, int); 87 88#endif /* !_DEV_ONEWIRE_ONEWIREVAR_H_ */ 89