1287225Simp/*- 2287225Simp * Copyright (c) 2015 M. Warner Losh <imp@freebsd.org> 3287225Simp * All rights reserved. 4287225Simp * 5287225Simp * Redistribution and use in source and binary forms, with or without 6287225Simp * modification, are permitted provided that the following conditions 7287225Simp * are met: 8287225Simp * 1. Redistributions of source code must retain the above copyright 9287225Simp * notice unmodified, this list of conditions, and the following 10287225Simp * disclaimer. 11287225Simp * 2. Redistributions in binary form must reproduce the above copyright 12287225Simp * notice, this list of conditions and the following disclaimer in the 13287225Simp * documentation and/or other materials provided with the distribution. 14287225Simp * 15287225Simp * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 16287225Simp * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 17287225Simp * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 18287225Simp * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 19287225Simp * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 20287225Simp * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 21287225Simp * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 22287225Simp * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23287225Simp * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 24287225Simp * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25287225Simp * 26287225Simp * $FreeBSD: releng/11.0/sys/dev/ow/ow.h 287225 2015-08-27 23:33:38Z imp $ 27287225Simp */ 28287225Simp 29287225Simp#ifndef DEV_OW_OW_H 30287225Simp#define DEV_OW_OW_H 1 31287225Simp 32287225Simpenum ow_device_ivars { 33287225Simp OW_IVAR_FAMILY, 34287225Simp OW_IVAR_ROMID 35287225Simp}; 36287225Simp 37287225Simp#define OW_ACCESSOR(var, ivar, type) \ 38287225Simp __BUS_ACCESSOR(ow, var, OW, ivar, type); 39287225Simp 40287225SimpOW_ACCESSOR(family, FAMILY, uint8_t) 41287225SimpOW_ACCESSOR(romid, ROMID, uint8_t *) 42287225Simp 43287225Simp#undef OW_ACCSSOR 44287225Simp 45287225Simp/* 46287225Simp * The following likely should be in the own.h file, but needs to be here to 47287225Simp * avoid recursive issues when defining the own_if.m interface. 48287225Simp */ 49287225Simp 50287225Simp/* 51287225Simp * Generalized command structure for a 1wire bus transaction. Not all possible 52287225Simp * transactions on the 1wire bus can be represented here (a notable exception 53287225Simp * being both the search ROM commands), but most of them can be, allowing for 54287225Simp * general transactions from userland. A lower-level interface to the link 55287225Simp * layer is also provided. 56287225Simp */ 57287225Simp#define MAX_ROM 10 58287225Simp#define MAX_XPT 32 59287225Simp#define MAX_READ 32 60287225Simpstruct ow_cmd 61287225Simp{ 62287225Simp uint32_t flags; /* Various flags */ 63287225Simp#define OW_FLAG_OVERDRIVE 1 /* Send xpt stuff overdrive speed */ 64287225Simp#define OW_FLAG_READ_BIT 2 /* Read a single bit after xpt_cmd */ 65287225Simp uint8_t rom_len; /* Number of ROM bytes to send */ 66287225Simp uint8_t rom_cmd[MAX_ROM]; /* Rom command to send */ 67287225Simp uint8_t rom_read_len; /* Number of bytes to read */ 68287225Simp uint8_t rom_read[MAX_ROM]; /* Extra bytes read */ 69287225Simp uint8_t xpt_len; /* Total transport bytes to send */ 70287225Simp uint8_t xpt_cmd[MAX_XPT]; /* Device specific command to send, if flagged */ 71287225Simp uint8_t xpt_read_len; /* Number of bytes to read after */ 72287225Simp uint8_t xpt_read[MAX_READ]; /* Buffer for read bytes */ 73287225Simp}; 74287225Simp 75287225Simptypedef uint64_t romid_t; 76287225Simp 77287225Simp#endif /* DEV_OW_OW_H */ 78