xref: /freebsd/sys/dev/ow/own_if.m (revision 031beb4e239bfce798af17f5fe8dba8bcaf13d99)
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, this list of conditions and the following disclaimer.
9ae1f3df4SWarner Losh# 2. Redistributions in binary form must reproduce the above copyright
10ae1f3df4SWarner Losh#    notice, this list of conditions and the following disclaimer in the
11ae1f3df4SWarner Losh#    documentation and/or other materials provided with the distribution.
12ae1f3df4SWarner Losh#
13ae1f3df4SWarner Losh# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
14ae1f3df4SWarner Losh# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15ae1f3df4SWarner Losh# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
16ae1f3df4SWarner Losh# ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
17ae1f3df4SWarner Losh# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
18ae1f3df4SWarner Losh# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
19ae1f3df4SWarner Losh# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
20ae1f3df4SWarner Losh# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
21ae1f3df4SWarner Losh# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
22ae1f3df4SWarner Losh# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
23ae1f3df4SWarner Losh# SUCH DAMAGE.
24ae1f3df4SWarner Losh#
25ae1f3df4SWarner Losh#
26ae1f3df4SWarner Losh
27ae1f3df4SWarner Losh#include <sys/bus.h>
28ae1f3df4SWarner Losh#include <dev/ow/ow.h>
29ae1f3df4SWarner Losh
30ae1f3df4SWarner LoshINTERFACE own;
31ae1f3df4SWarner Losh
32ae1f3df4SWarner Losh#
33ae1f3df4SWarner Losh# Dallas Semiconductor 1-Wire bus network and transport layer (own)
34ae1f3df4SWarner Losh#
35ae1f3df4SWarner Losh# See Maxim Application Note AN937: Book of iButton Standards for the
36ae1f3df4SWarner Losh# 1-Wire protocol specification.
37ae1f3df4SWarner Losh# http://pdfserv.maximintegrated.com/en/an/AN937.pdf
38ae1f3df4SWarner Losh#
39ae1f3df4SWarner Losh# Note: 1-Wire is a registered trademark of Maxim Integrated Products, Inc.
40ae1f3df4SWarner Losh#
41ae1f3df4SWarner Losh
42ae1f3df4SWarner Losh#
43ae1f3df4SWarner Losh# Send a command up the stack.
44ae1f3df4SWarner Losh#
45ae1f3df4SWarner LoshMETHOD int send_command {
46ae1f3df4SWarner Losh	device_t	ndev;		/* Network (bus) level device */
47ae1f3df4SWarner Losh	device_t	pdev;		/* Device to send command for */
48ae1f3df4SWarner Losh	struct ow_cmd   *cmd;		/* Pointer to filled in command */
49ae1f3df4SWarner Losh};
50ae1f3df4SWarner Losh
51ae1f3df4SWarner Losh#
52ae1f3df4SWarner Losh# Grab exclusive use of the bus (advisory)
53ae1f3df4SWarner Losh#
54ae1f3df4SWarner LoshMETHOD int acquire_bus {
55ae1f3df4SWarner Losh	device_t	ndev;
56ae1f3df4SWarner Losh	device_t	pdev;
57ae1f3df4SWarner Losh	int		how;
58ae1f3df4SWarner Losh};
59ae1f3df4SWarner Losh
60ae1f3df4SWarner Losh#
61ae1f3df4SWarner Losh# Release exclusive use of the bus (advisory)
62ae1f3df4SWarner Losh#
63ae1f3df4SWarner LoshMETHOD void release_bus {
64ae1f3df4SWarner Losh	device_t	ndev;
65ae1f3df4SWarner Losh	device_t	pdev;
66ae1f3df4SWarner Losh};
67ae1f3df4SWarner Losh
68ae1f3df4SWarner Losh#
69ae1f3df4SWarner Losh# Compute a CRC for a given range of bytes
70ae1f3df4SWarner Losh#
71ae1f3df4SWarner LoshMETHOD uint8_t crc {
72ae1f3df4SWarner Losh	device_t	ndev;
73ae1f3df4SWarner Losh	device_t	pdev;
74ae1f3df4SWarner Losh	uint8_t		*buffer;
75ae1f3df4SWarner Losh	size_t		len;
76ae1f3df4SWarner Losh};
77