xref: /freebsd/share/man/man4/smb.4 (revision 8aac90f18aef7c9eea906c3ff9a001ca7b94f375)
1.\"-
2.\" SPDX-License-Identifer: BSD-2-Clause
3.\"
4.\" Copyright (c) 1998, Nicolas Souchu
5.\" Copyright (c) 2004, Joerg Wunsch
6.\" Copyright (c) 2015, Michael Gmelin <freebsd@grem.de>
7.\" All rights reserved.
8.\"
9.\" Redistribution and use in source and binary forms, with or without
10.\" modification, are permitted provided that the following conditions
11.\" are met:
12.\" 1. Redistributions of source code must retain the above copyright
13.\"    notice, this list of conditions and the following disclaimer.
14.\" 2. Redistributions in binary form must reproduce the above copyright
15.\"    notice, this list of conditions and the following disclaimer in the
16.\"    documentation and/or other materials provided with the distribution.
17.\"
18.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
19.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
22.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
24.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
26.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
27.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28.\" SUCH DAMAGE.
29.\"
30.Dd April 25, 2015
31.Dt SMB 4
32.Os
33.Sh NAME
34.Nm smb
35.Nd System Management Bus generic I/O device driver
36.Sh SYNOPSIS
37.Cd "device smb"
38.Sh DESCRIPTION
39The
40.Em smb
41character device driver provides generic I/O to any
42.Xr smbus 4
43instance.
44To control SMB devices, use
45.Pa /dev/smb?
46with the ioctls described below.
47Any of these ioctl commands takes a pointer to
48.Vt struct smbcmd
49as its argument.
50.Bd -literal
51#include <sys/types.h>
52
53struct smbcmd {
54	u_char cmd;
55	u_char reserved;
56	u_short op;
57	union {
58		char    byte;
59		char    buf[2];
60		short   word;
61	} wdata;
62	union {
63		char    byte;
64		char    buf[2];
65		short   word;
66	} rdata;
67	int  slave;
68	char *wbuf;     /* use wdata if NULL */
69	int  wcount;
70	char *rbuf;     /* use rdata if NULL */
71	int  rcount;
72};
73.Ed
74.Pp
75The
76.Fa slave
77field is always used, and provides the address of the
78SMBus slave device.
79The slave address is specified in the seven most significant bits
80.Pq i.e., Dq "left-justified" .
81The least significant bit of the slave address must be zero.
82.Pp
83.Bl -column ".Dv SMB_QUICK_WRITE" -compact
84.It Em Ioctl Ta Em Description
85.Pp
86.It Dv SMB_QUICK_WRITE Ta
87.Em QuickWrite
88does not transfer any data.
89It just issues the device address with write intent to the bus.
90.It Dv SMB_QUICK_READ Ta
91.Em QuickRead
92does not transfer any data.
93It just issues the device address with read intent to the bus.
94.It Dv SMB_SENDB Ta
95.Em SendByte
96sends the byte provided in
97.Fa cmd
98to the device.
99.It Dv SMB_RECVB Ta
100.Em ReceiveByte
101reads a single byte from the device which is returned in
102.Fa cmd .
103.It Dv SMB_WRITEB Ta
104.Em WriteByte
105first sends the byte from
106.Fa cmd
107to the device, followed by the byte given in
108.Fa wdata.byte .
109.It Dv SMB_WRITEW Ta
110.Em WriteWord
111first sends the byte from
112.Fa cmd
113to the device, followed by the word given in
114.Fa wdata.word .
115Note that the SMBus byte-order is little-endian by definition.
116.It Dv SMB_READB Ta
117.Em ReadByte
118first sends the byte from
119.Fa cmd
120to the device, then reads one byte of data from
121the device.
122Returned data is stored in
123.Fa rdata.byte .
124.It Dv SMB_READW Ta
125.Em ReadWord
126first sends the byte from
127.Fa cmd
128to the device, then reads one word of data from
129the device.
130Returned data is stored in
131.Fa rdata.word .
132.It Dv SMB_PCALL Ta
133.Em ProcedureCall
134first sends the byte from
135.Fa cmd
136to the device, followed by the word provided in
137.Fa wdata.word .
138It then reads one word of data from the device and returns it
139in
140.Fa rdata.word .
141.It Dv SMB_BWRITE Ta
142.Em BlockWrite
143first sends the byte from
144.Fa cmd
145to the device, then the byte from
146.Fa wcount
147followed by
148.Fa wcount
149bytes of data that are taken from the buffer pointed to by
150.Fa wbuf .
151The SMBus specification mandates that no more than 32 bytes of
152data can be transferred in a single block read or write command.
153This value can be read from the constant
154.Dv SMB_MAXBLOCKSIZE .
155.It Dv SMB_BREAD Ta
156.Em BlockRead
157first sends the byte from
158.Fa cmd
159to the device, then reads a count of data bytes that the device
160is going to provide and then reads that many bytes.
161The count is returned in
162.Fa rcount .
163The data is returned in the buffer pointed to by
164.Fa rbuf .
165.El
166.Pp
167The
168.Xr read 2
169and
170.Xr write 2
171system calls are not implemented by this driver.
172.Sh ERRORS
173The
174.Xr ioctl 2
175commands can cause the following driver-specific errors:
176.Bl -tag -width Er
177.It Bq Er ENXIO
178Device did not respond to selection.
179.It Bq Er EBUSY
180Device still in use.
181.It Bq Er ENODEV
182Operation not supported by device (not supposed to happen).
183.It Bq Er EINVAL
184General argument error.
185.It Bq Er EWOULDBLOCK
186SMBus transaction timed out.
187.El
188.Sh SEE ALSO
189.Xr ioctl 2 ,
190.Xr smbus 4
191.Sh HISTORY
192The
193.Nm
194manual page first appeared in
195.Fx 3.0 .
196.Sh AUTHORS
197This
198manual page was written by
199.An Nicolas Souchu
200and extended by
201.An Michael Gmelin Aq freebsd@grem.de .
202