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