1eb8752d5SNicolas Souchu.\" Copyright (c) 1998, Nicolas Souchu 27d2d5f80SJoerg Wunsch.\" Copyright (c) 2004, Joerg Wunsch 3eb8752d5SNicolas Souchu.\" All rights reserved. 4eb8752d5SNicolas Souchu.\" 5eb8752d5SNicolas Souchu.\" Redistribution and use in source and binary forms, with or without 6eb8752d5SNicolas Souchu.\" modification, are permitted provided that the following conditions 7eb8752d5SNicolas Souchu.\" are met: 8eb8752d5SNicolas Souchu.\" 1. Redistributions of source code must retain the above copyright 9eb8752d5SNicolas Souchu.\" notice, this list of conditions and the following disclaimer. 10eb8752d5SNicolas Souchu.\" 2. Redistributions in binary form must reproduce the above copyright 11eb8752d5SNicolas Souchu.\" notice, this list of conditions and the following disclaimer in the 12eb8752d5SNicolas Souchu.\" documentation and/or other materials provided with the distribution. 13eb8752d5SNicolas Souchu.\" 14eb8752d5SNicolas Souchu.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 15eb8752d5SNicolas Souchu.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16eb8752d5SNicolas Souchu.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17eb8752d5SNicolas Souchu.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 18eb8752d5SNicolas Souchu.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19eb8752d5SNicolas Souchu.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20eb8752d5SNicolas Souchu.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21eb8752d5SNicolas Souchu.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22eb8752d5SNicolas Souchu.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23eb8752d5SNicolas Souchu.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24eb8752d5SNicolas Souchu.\" SUCH DAMAGE. 25eb8752d5SNicolas Souchu.\" 267f3dea24SPeter Wemm.\" $FreeBSD$ 27eb8752d5SNicolas Souchu.\" 28eb8752d5SNicolas Souchu.Dd October 25, 1998 29eb8752d5SNicolas Souchu.Dt SMB 4 303d45e180SRuslan Ermilov.Os 31eb8752d5SNicolas Souchu.Sh NAME 32eb8752d5SNicolas Souchu.Nm smb 33eb083802SRuslan Ermilov.Nd SMB generic I/O device driver 34eb8752d5SNicolas Souchu.Sh SYNOPSIS 35b9781e20SJeroen Ruigrok van der Werven.Cd "device smb" 36eb8752d5SNicolas Souchu.Sh DESCRIPTION 37eb8752d5SNicolas SouchuThe 38eb8752d5SNicolas Souchu.Em smb 39eb8752d5SNicolas Souchucharacter device driver provides generic i/o to any 40eb8752d5SNicolas Souchu.Xr smbus 4 416d249eeeSSheldon Hearninstance. 427d2d5f80SJoerg WunschIn order to control SMB devices, use 437d2d5f80SJoerg Wunsch.Pa /dev/smb Ns Em ? 447d2d5f80SJoerg Wunschwith the ioctls described below. 457d2d5f80SJoerg WunschAny of these ioctl commands takes a pointer to 467d2d5f80SJoerg Wunsch.Vt struct smbcmd 477d2d5f80SJoerg Wunschas its argument. 48eb8752d5SNicolas Souchu.Pp 497d2d5f80SJoerg Wunsch.Bd -literal 507d2d5f80SJoerg Wunsch#include <sys/types.h> 517d2d5f80SJoerg Wunsch 527d2d5f80SJoerg Wunschstruct smbcmd { 537d2d5f80SJoerg Wunsch char cmd; 547d2d5f80SJoerg Wunsch int count; 557d2d5f80SJoerg Wunsch u_char slave; 567d2d5f80SJoerg Wunsch union { 577d2d5f80SJoerg Wunsch char byte; 587d2d5f80SJoerg Wunsch short word; 597d2d5f80SJoerg Wunsch 607d2d5f80SJoerg Wunsch char *byte_ptr; 617d2d5f80SJoerg Wunsch short *word_ptr; 627d2d5f80SJoerg Wunsch 637d2d5f80SJoerg Wunsch struct { 647d2d5f80SJoerg Wunsch short sdata; 657d2d5f80SJoerg Wunsch short *rdata; 667d2d5f80SJoerg Wunsch } process; 677d2d5f80SJoerg Wunsch } data; 687d2d5f80SJoerg Wunsch}; 697d2d5f80SJoerg Wunsch.Ed 707d2d5f80SJoerg Wunsch.Pp 717d2d5f80SJoerg WunschThe 727d2d5f80SJoerg Wunsch.Fa slave 737d2d5f80SJoerg Wunschfield is always used, and provides the address of the 747d2d5f80SJoerg WunschSMBus slave device to talk to. 757d2d5f80SJoerg Wunsch.Pp 767d2d5f80SJoerg Wunsch.Bl -column ".Sy SMB_QUICK_WRITE" -compact 77eb8752d5SNicolas Souchu.It Em Ioctl Ta Em Description 787d2d5f80SJoerg Wunsch.Pp 797d2d5f80SJoerg Wunsch.It Sy SMB_QUICK_WRITE Ta 807d2d5f80SJoerg WunschThe 817d2d5f80SJoerg Wunsch.Em QuickWrite 827d2d5f80SJoerg Wunschcommand just issues the device address with write intent 837d2d5f80SJoerg Wunschto the bus, without transferring any data. 847d2d5f80SJoerg Wunsch.It Sy SMB_QUICK_READ Ta 857d2d5f80SJoerg WunschThe 867d2d5f80SJoerg Wunsch.Em QuickRead 877d2d5f80SJoerg Wunschcommand just issues the device address with read intent 887d2d5f80SJoerg Wunschto the bus, without transferring any data. 897d2d5f80SJoerg Wunsch.It Sy SMB_SENDB Ta 907d2d5f80SJoerg WunschThe 917d2d5f80SJoerg Wunsch.Em SendByte 927d2d5f80SJoerg Wunschcommand sends the byte provided in the 937d2d5f80SJoerg Wunsch.Fa cmd 947d2d5f80SJoerg Wunschfield to the device. 957d2d5f80SJoerg Wunsch.It Sy SMB_RECVB Ta 967d2d5f80SJoerg WunschThe 977d2d5f80SJoerg Wunsch.Em ReceiveByte 987d2d5f80SJoerg Wunschcommand reads a single byte from the device which will 997d2d5f80SJoerg Wunschbe returned in the 1007d2d5f80SJoerg Wunsch.Fa cmd 1017d2d5f80SJoerg Wunschfield. 1027d2d5f80SJoerg Wunsch.It Sy SMB_WRITEB Ta 1037d2d5f80SJoerg WunschThe 1047d2d5f80SJoerg Wunsch.Em WriteByte 1057d2d5f80SJoerg Wunschcommand first sends the byte from the 1067d2d5f80SJoerg Wunsch.Fa cmd 1077d2d5f80SJoerg Wunschfield to the device, followed by the byte given in 1087d2d5f80SJoerg Wunsch.Fa data.byte . 1097d2d5f80SJoerg Wunsch.It Sy SMB_WRITEW Ta 1107d2d5f80SJoerg WunschThe 1117d2d5f80SJoerg Wunsch.Em WriteWord 1127d2d5f80SJoerg Wunschcommand first sends the byte from the 1137d2d5f80SJoerg Wunsch.Fa cmd 1147d2d5f80SJoerg Wunschfield to the device, followed by the word given in 1157d2d5f80SJoerg Wunsch.Fa data.word . 1167d2d5f80SJoerg WunschNote that the SMBus byte-order is little-endian by definition. 1177d2d5f80SJoerg Wunsch.It Sy SMB_READB Ta 1187d2d5f80SJoerg WunschThe 1197d2d5f80SJoerg Wunsch.Em ReadByte 1207d2d5f80SJoerg Wunschcommand first sends the byte from the 1217d2d5f80SJoerg Wunsch.Fa cmd 1227d2d5f80SJoerg Wunschfield to the device, and then reads one byte of data from 1237d2d5f80SJoerg Wunschthe device. 1247d2d5f80SJoerg WunschThe returned data will be stored in the location pointed to by 1257d2d5f80SJoerg Wunsch.Fa data.byte_ptr . 1267d2d5f80SJoerg Wunsch.It Sy SMB_READW Ta 1277d2d5f80SJoerg WunschThe 1287d2d5f80SJoerg Wunsch.Em ReadWord 1297d2d5f80SJoerg Wunschcommand first sends the byte from the 1307d2d5f80SJoerg Wunsch.Fa cmd 1317d2d5f80SJoerg Wunschfield to the device, and then reads one word of data from 1327d2d5f80SJoerg Wunschthe device. 1337d2d5f80SJoerg WunschThe returned data will be stored in the location pointed to by 1347d2d5f80SJoerg Wunsch.Fa data.word_ptr . 1357d2d5f80SJoerg Wunsch.It Sy SMB_PCALL Ta 1367d2d5f80SJoerg WunschThe 1377d2d5f80SJoerg Wunsch.Em ProcedureCall 1387d2d5f80SJoerg Wunschcommand first sends the byte from the 1397d2d5f80SJoerg Wunsch.Fa cmd 1407d2d5f80SJoerg Wunschfield to the device, followed by the word provided in 1417d2d5f80SJoerg Wunsch.Fa data.process.sdata . 1427d2d5f80SJoerg WunschIt then reads one word of data from the device, and returns it 1437d2d5f80SJoerg Wunschin the location pointed to by 1447d2d5f80SJoerg Wunsch.Fa data.process.rdata . 1457d2d5f80SJoerg Wunsch.It Sy SMB_BWRITE Ta 1467d2d5f80SJoerg WunschThe 1477d2d5f80SJoerg Wunsch.Em BlockWrite 1487d2d5f80SJoerg Wunschcommand first sends the byte from the 1497d2d5f80SJoerg Wunsch.Fa cmd 1507d2d5f80SJoerg Wunschfield to the device, followed by 1517d2d5f80SJoerg Wunsch.Fa count 1527d2d5f80SJoerg Wunschbytes of data that are taken from the buffer pointed to by 1537d2d5f80SJoerg Wunsch.Fa data.byte_ptr . 1547d2d5f80SJoerg WunschThe SMBus specification mandates that no more than 32 bytes of 1557d2d5f80SJoerg Wunschdata can be transferred in a single block read or write command. 1567d2d5f80SJoerg WunschThis value is available in the constant 1577d2d5f80SJoerg Wunsch.Dv SMB_MAXBLOCKSIZE . 1587d2d5f80SJoerg Wunsch.It Sy SMB_BREAD Ta 1597d2d5f80SJoerg WunschThe 1607d2d5f80SJoerg Wunsch.Em BlockRead 1617d2d5f80SJoerg Wunschcommand first sends the byte from the 1627d2d5f80SJoerg Wunsch.Fa cmd 1637d2d5f80SJoerg Wunschfield to the device, and then reads 1647d2d5f80SJoerg Wunsch.Fa count 1657d2d5f80SJoerg Wunschbytes of data that from the device. 1667d2d5f80SJoerg WunschThese data will be returned in the buffer pointed to by 1677d2d5f80SJoerg Wunsch.Fa data.byte_ptr . 168eb8752d5SNicolas Souchu.El 169eb8752d5SNicolas Souchu.Pp 1707d2d5f80SJoerg WunschThe 1717d2d5f80SJoerg Wunsch.Xr read 2 1727d2d5f80SJoerg Wunschand 1737d2d5f80SJoerg Wunsch.Xr write 2 1747d2d5f80SJoerg Wunschsystem calls are not implemented by this driver. 1757d2d5f80SJoerg Wunsch.Sh ERRORS 1767d2d5f80SJoerg WunschThe 1777d2d5f80SJoerg Wunsch.Xr ioctl 1787d2d5f80SJoerg Wunschcommands can cause the following driver-specific errors: 1797d2d5f80SJoerg Wunsch.Bl -tag -width Er 1807d2d5f80SJoerg Wunsch.It Bq Er ENXIO 1817d2d5f80SJoerg WunschDevice did not respond to selection. 1827d2d5f80SJoerg Wunsch.It Bq Er EBUSY 1837d2d5f80SJoerg WunschDevice still in use. 1847d2d5f80SJoerg Wunsch.It Bq Er ENODEV 1857d2d5f80SJoerg WunschOperation not supported by device (not supposed to happen). 1867d2d5f80SJoerg Wunsch.It Bq Er EINVAL 1877d2d5f80SJoerg WunschGeneral argument error. 1887d2d5f80SJoerg Wunsch.It Bq Er EWOULDBLOCK 1897d2d5f80SJoerg WunschSMBus transaction timed out. 1907d2d5f80SJoerg Wunsch.El 191eb8752d5SNicolas Souchu.Sh SEE ALSO 1927d2d5f80SJoerg Wunsch.Xr ioctl 2 , 193eb8752d5SNicolas Souchu.Xr smbus 4 194eb8752d5SNicolas Souchu.Sh HISTORY 195eb8752d5SNicolas SouchuThe 196eb8752d5SNicolas Souchu.Nm 197eb8752d5SNicolas Souchumanual page first appeared in 198eb8752d5SNicolas Souchu.Fx 3.0 . 199def37e7cSMike Pritchard.Sh AUTHORS 200eb8752d5SNicolas SouchuThis 201eb8752d5SNicolas Souchumanual page was written by 202eb8752d5SNicolas Souchu.An Nicolas Souchu . 203