1ae1f3df4SWarner Losh /*- 2*f86e6000SWarner Losh * Copyright (c) 2015 M. Warner Losh <imp@FreeBSD.org> 3ae1f3df4SWarner Losh * 4ae1f3df4SWarner Losh * Redistribution and use in source and binary forms, with or without 5ae1f3df4SWarner Losh * modification, are permitted provided that the following conditions 6ae1f3df4SWarner Losh * are met: 7ae1f3df4SWarner Losh * 1. Redistributions of source code must retain the above copyright 8ae1f3df4SWarner Losh * notice unmodified, this list of conditions, and the following 9ae1f3df4SWarner Losh * disclaimer. 10ae1f3df4SWarner Losh * 2. Redistributions in binary form must reproduce the above copyright 11ae1f3df4SWarner Losh * notice, this list of conditions and the following disclaimer in the 12ae1f3df4SWarner Losh * documentation and/or other materials provided with the distribution. 13ae1f3df4SWarner Losh * 14ae1f3df4SWarner Losh * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 15ae1f3df4SWarner Losh * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 16ae1f3df4SWarner Losh * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 17ae1f3df4SWarner Losh * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 18ae1f3df4SWarner Losh * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 19ae1f3df4SWarner Losh * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 20ae1f3df4SWarner Losh * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 21ae1f3df4SWarner Losh * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 22ae1f3df4SWarner Losh * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 23ae1f3df4SWarner Losh * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24ae1f3df4SWarner Losh */ 25ae1f3df4SWarner Losh 26ae1f3df4SWarner Losh #ifndef DEV_OW_OW_H 27ae1f3df4SWarner Losh #define DEV_OW_OW_H 1 28ae1f3df4SWarner Losh 29ae1f3df4SWarner Losh enum ow_device_ivars { 30ae1f3df4SWarner Losh OW_IVAR_FAMILY, 31ae1f3df4SWarner Losh OW_IVAR_ROMID 32ae1f3df4SWarner Losh }; 33ae1f3df4SWarner Losh 34ae1f3df4SWarner Losh #define OW_ACCESSOR(var, ivar, type) \ 35ae1f3df4SWarner Losh __BUS_ACCESSOR(ow, var, OW, ivar, type); 36ae1f3df4SWarner Losh 37ae1f3df4SWarner Losh OW_ACCESSOR(family, FAMILY, uint8_t) 38ae1f3df4SWarner Losh OW_ACCESSOR(romid, ROMID, uint8_t *) 39ae1f3df4SWarner Losh 40ae1f3df4SWarner Losh #undef OW_ACCSSOR 41ae1f3df4SWarner Losh 42ae1f3df4SWarner Losh /* 43ae1f3df4SWarner Losh * The following likely should be in the own.h file, but needs to be here to 44ae1f3df4SWarner Losh * avoid recursive issues when defining the own_if.m interface. 45ae1f3df4SWarner Losh */ 46ae1f3df4SWarner Losh 47ae1f3df4SWarner Losh /* 48ae1f3df4SWarner Losh * Generalized command structure for a 1wire bus transaction. Not all possible 49ae1f3df4SWarner Losh * transactions on the 1wire bus can be represented here (a notable exception 50ae1f3df4SWarner Losh * being both the search ROM commands), but most of them can be, allowing for 51ae1f3df4SWarner Losh * general transactions from userland. A lower-level interface to the link 52ae1f3df4SWarner Losh * layer is also provided. 53ae1f3df4SWarner Losh */ 54ae1f3df4SWarner Losh #define MAX_ROM 10 55ae1f3df4SWarner Losh #define MAX_XPT 32 56ae1f3df4SWarner Losh #define MAX_READ 32 57ae1f3df4SWarner Losh struct ow_cmd 58ae1f3df4SWarner Losh { 59ae1f3df4SWarner Losh uint32_t flags; /* Various flags */ 60ae1f3df4SWarner Losh #define OW_FLAG_OVERDRIVE 1 /* Send xpt stuff overdrive speed */ 61ae1f3df4SWarner Losh #define OW_FLAG_READ_BIT 2 /* Read a single bit after xpt_cmd */ 62ae1f3df4SWarner Losh uint8_t rom_len; /* Number of ROM bytes to send */ 63ae1f3df4SWarner Losh uint8_t rom_cmd[MAX_ROM]; /* Rom command to send */ 64ae1f3df4SWarner Losh uint8_t rom_read_len; /* Number of bytes to read */ 65ae1f3df4SWarner Losh uint8_t rom_read[MAX_ROM]; /* Extra bytes read */ 66ae1f3df4SWarner Losh uint8_t xpt_len; /* Total transport bytes to send */ 67ae1f3df4SWarner Losh uint8_t xpt_cmd[MAX_XPT]; /* Device specific command to send, if flagged */ 68ae1f3df4SWarner Losh uint8_t xpt_read_len; /* Number of bytes to read after */ 69ae1f3df4SWarner Losh uint8_t xpt_read[MAX_READ]; /* Buffer for read bytes */ 70ae1f3df4SWarner Losh }; 71ae1f3df4SWarner Losh 72ae1f3df4SWarner Losh typedef uint64_t romid_t; 73ae1f3df4SWarner Losh 74ae1f3df4SWarner Losh #endif /* DEV_OW_OW_H */ 75