forked from opnsense/src
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Expand SMBUS API to add smbus_trans() function.
Differential Revision: https://reviews.freebsd.org/D1955 Reviewed by: adrian, jhb, wblock Approved by: adrian, jhb
- Loading branch information
Showing
8 changed files
with
333 additions
and
116 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
.\" Copyright (c) 1998, Nicolas Souchu | ||
.\" Copyright (c) 2004, Joerg Wunsch | ||
.\" Copyright (c) 2015, Michael Gmelin <[email protected]> | ||
.\" All rights reserved. | ||
.\" | ||
.\" Redistribution and use in source and binary forms, with or without | ||
|
@@ -25,7 +26,7 @@ | |
.\" | ||
.\" $FreeBSD$ | ||
.\" | ||
.Dd February 6, 2009 | ||
.Dd April 25, 2015 | ||
.Dt SMB 4 | ||
.Os | ||
.Sh NAME | ||
|
@@ -49,21 +50,24 @@ as its argument. | |
#include <sys/types.h> | ||
|
||
struct smbcmd { | ||
char cmd; | ||
int count; | ||
u_char slave; | ||
u_char cmd; | ||
u_char reserved; | ||
u_short op; | ||
union { | ||
char byte; | ||
short word; | ||
|
||
char *byte_ptr; | ||
short *word_ptr; | ||
|
||
struct { | ||
short sdata; | ||
short *rdata; | ||
} process; | ||
} data; | ||
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; | ||
}; | ||
.Ed | ||
.Pp | ||
|
@@ -107,14 +111,14 @@ The | |
command first sends the byte from the | ||
.Fa cmd | ||
field to the device, followed by the byte given in | ||
.Fa data.byte . | ||
.Fa wdata.byte . | ||
.It Dv SMB_WRITEW Ta | ||
The | ||
.Em WriteWord | ||
command first sends the byte from the | ||
.Fa cmd | ||
field to the device, followed by the word given in | ||
.Fa data.word . | ||
.Fa wdata.word . | ||
Note that the SMBus byte-order is little-endian by definition. | ||
.It Dv SMB_READB Ta | ||
The | ||
|
@@ -123,38 +127,42 @@ command first sends the byte from the | |
.Fa cmd | ||
field to the device, and then reads one byte of data from | ||
the device. | ||
The returned data will be stored in the location pointed to by | ||
.Fa data.byte_ptr . | ||
The returned data will be stored in | ||
.Fa rdata.byte . | ||
.It Dv SMB_READW Ta | ||
The | ||
.Em ReadWord | ||
command first sends the byte from the | ||
.Fa cmd | ||
field to the device, and then reads one word of data from | ||
the device. | ||
The returned data will be stored in the location pointed to by | ||
.Fa data.word_ptr . | ||
The returned data will be stored in | ||
.Fa rdata.word . | ||
.It Dv SMB_PCALL Ta | ||
The | ||
.Em ProcedureCall | ||
command first sends the byte from the | ||
.Fa cmd | ||
field to the device, followed by the word provided in | ||
.Fa data.process.sdata . | ||
.Fa wdata.word . | ||
It then reads one word of data from the device, and returns it | ||
in the location pointed to by | ||
.Fa data.process.rdata . | ||
in | ||
.Fa rdata.word . | ||
.It Dv SMB_BWRITE Ta | ||
The | ||
.Em BlockWrite | ||
command first sends the byte from the | ||
.Fa cmd | ||
field to the device, followed by | ||
.Fa count | ||
.Fa wcount | ||
bytes of data that are taken from the buffer pointed to by | ||
.Fa data.byte_ptr . | ||
.Fa wbuf . | ||
The SMBus specification mandates that no more than 32 bytes of | ||
data can be transferred in a single block read or write command. | ||
data can be transferred in a single block read or write command, | ||
but since | ||
.Xr smbus 4 | ||
is also used to access I2C devices, the limit has been increased | ||
to 1024. | ||
This value is available in the constant | ||
.Dv SMB_MAXBLOCKSIZE . | ||
.It Dv SMB_BREAD Ta | ||
|
@@ -163,10 +171,38 @@ The | |
command first sends the byte from the | ||
.Fa cmd | ||
field to the device, and then reads | ||
.Fa count | ||
.Fa rcount | ||
bytes of data that from the device. | ||
These data will be returned in the buffer pointed to by | ||
.Fa rbuf . | ||
.It Dv SMB_TRANS Ta | ||
The | ||
.Em Trans | ||
command sends an SMB roll-up transaction with flags that also allow it to | ||
be used for (mostly) I2C pass-through and with with 10-bit addresses. | ||
This function can be used to roll up all of the above functions. | ||
It first sends the byte from the | ||
.Fa cmd | ||
field to the device, followed by | ||
.Fa wcount | ||
bytes of data that are taken from the buffer pointed to by | ||
.Fa wbuf , | ||
then reads | ||
.Fa rcount | ||
bytes of data that from the device. | ||
These data will be returned in the buffer pointed to by | ||
.Fa data.byte_ptr . | ||
.Fa rbuf . | ||
.Pp | ||
The following flags are allowed in | ||
.Fa op : | ||
.Pp | ||
.Bd -literal -compact | ||
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 | ||
.Ed | ||
.El | ||
.Pp | ||
The | ||
|
@@ -201,4 +237,7 @@ manual page first appeared in | |
.Sh AUTHORS | ||
This | ||
manual page was written by | ||
.An Nicolas Souchu . | ||
.An Nicolas Souchu | ||
and extended by | ||
.An Michael Gmelin Aq [email protected] | ||
. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.