1 /* $NetBSD: onewirevar.h,v 1.5 2007/09/05 15:39:22 xtraeme 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 */ 28 struct onewire_bus { 29 void * bus_cookie; 30 31 int (*bus_reset)(void *); 32 int (*bus_bit)(void *, int); 33 int (*bus_read_byte)(void *); 34 void (*bus_write_byte)(void *, int); 35 int (*bus_triplet)(void *, int); 36 }; 37 38 /* Bus methods */ 39 void onewire_lock(void *); 40 void onewire_unlock(void *); 41 int onewire_reset(void *); 42 int onewire_bit(void *, int); 43 int onewire_read_byte(void *); 44 void onewire_write_byte(void *, int); 45 int onewire_triplet(void *, int); 46 void onewire_read_block(void *, void *, int); 47 void onewire_write_block(void *, const void *, int); 48 void onewire_matchrom(void *, u_int64_t); 49 50 /* Bus attachment */ 51 struct onewirebus_attach_args { 52 struct onewire_bus * oba_bus; 53 }; 54 55 int onewirebus_print(void *, const char *); 56 57 /* Device attachment */ 58 struct onewire_attach_args { 59 void * oa_onewire; 60 u_int64_t oa_rom; 61 }; 62 63 /* Family matching */ 64 struct onewire_matchfam { 65 int om_type; 66 }; 67 68 /* Miscellaneous routines */ 69 int onewire_crc(const void *, int); 70 const char * onewire_famname(int); 71 int onewire_matchbyfam(struct onewire_attach_args *, 72 const struct onewire_matchfam *, int); 73 74 /* Bus bit-banging */ 75 struct onewire_bbops { 76 void (*bb_rx)(void *); 77 void (*bb_tx)(void *); 78 int (*bb_get)(void *); 79 void (*bb_set)(void *, int); 80 }; 81 82 int onewire_bb_reset(const struct onewire_bbops *, void *); 83 int onewire_bb_bit(const struct onewire_bbops *, void *, int); 84 85 #endif /* !_DEV_ONEWIRE_ONEWIREVAR_H_ */ 86