Scroll to navigation

SMB(4) Device Drivers Manual SMB(4)

NAME

smb
SMB generic I/O device driver

SYNOPSIS

device smb

DESCRIPTION

The smb character device driver provides generic I/O to any smbus(4) instance. To control SMB devices, use /dev/smb? with the ioctls described below. Any of these ioctl commands takes a pointer to struct smbcmd as its argument.
#include <sys/types.h>

struct smbcmd {
	u_char cmd;
	u_char reserved;
	u_short op;
	union {
		char    byte;
		char    buf[2];
		short   word;
	} wdata;
	union {
		char    byte;
		char    buf[2];
		short   word;
	} rdata;
	int  slave;
	char *wbuf;     /* use wdata if NULL */
	int  wcount;
	char *rbuf;     /* use rdata if NULL */
	int  rcount;
};

The slave field is always used, and provides the address of the SMBus slave device. The slave address is specified in the seven most significant bits (i.e., “left-justified”). The least significant bit of the slave address must be zero.

Ioctl Description

QuickWrite does not transfer any data. It just issues the device address with write intent to the bus.
QuickRead does not transfer any data. It just issues the device address with read intent to the bus.
SendByte sends the byte provided in cmd to the device.
ReceiveByte reads a single byte from the device which is returned in cmd.
WriteByte first sends the byte from cmd to the device, followed by the byte given in wdata.byte.
WriteWord first sends the byte from cmd to the device, followed by the word given in wdata.word. Note that the SMBus byte-order is little-endian by definition.
ReadByte first sends the byte from cmd to the device, then reads one byte of data from the device. Returned data is stored in rdata.byte.
ReadWord first sends the byte from cmd to the device, then reads one word of data from the device. Returned data is stored in rdata.word.
ProcedureCall first sends the byte from cmd to the device, followed by the word provided in wdata.word. It then reads one word of data from the device and returns it in rdata.word.
BlockWrite first sends the byte from cmd to the device, followed by wcount bytes of data that are taken from the buffer pointed to by wbuf. The SMBus specification mandates that no more than 32 bytes of data can be transferred in a single block read or write command, but since smbus(4) is also used to access I2C devices, the limit has been increased to 1024. This value can be read from the constant SMB_MAXBLOCKSIZE.
BlockRead first sends the byte from cmd to the device, then reads rcount bytes of data that from the device. This data is returned in the buffer pointed to by rbuf.
Trans sends an SMB roll-up transaction with flags that also allow it to be used for (mostly) I2C pass-through and with 10-bit addresses. This function can be utilized to roll up all of the above functions. It first sends the byte from cmd to the device, followed by wcount bytes of data that are taken from the buffer pointed to by wbuf, then reads rcount bytes of data that from the device. This data is returned in the buffer pointed to by rbuf.

The following flags are allowed in op:

SMB_TRANS_NOSTOP  Do not send STOP at end
SMB_TRANS_NOCMD   Ignore cmd field (do not tx)
SMB_TRANS_NOCNT   Do not tx or rx count field
SMB_TRANS_7BIT    Change address mode to 7-bit
SMB_TRANS_10BIT   Change address mode to 10-bit
    

The read(2) and write(2) system calls are not implemented by this driver.

ERRORS

The ioctl(2) commands can cause the following driver-specific errors:
[]
Device did not respond to selection.
[]
Device still in use.
[]
Operation not supported by device (not supposed to happen).
[]
General argument error.
[]
SMBus transaction timed out.

SEE ALSO

ioctl(2), smbus(4)

HISTORY

The smb manual page first appeared in FreeBSD 3.0.

AUTHORS

This manual page was written by Nicolas Souchu and extended by
Michael Gmelin ⟨freebsd@grem.de⟩.
April 25, 2015 Linux 4.9.0-9-amd64