Zephyr API 3.6.99
Loading...
Searching...
No Matches
SMBus Interface

SMBus Interface . More...

Data Structures

struct  smbus_callback
 SMBus callback structure. More...
 
struct  smbus_dt_spec
 Complete SMBus DT information. More...
 

Macros

#define SMBUS_BLOCK_BYTES_MAX   32
 Maximum number of bytes in SMBus Block protocol.
 
#define SMBUS_DT_SPEC_GET(node_id)
 Structure initializer for smbus_dt_spec from devicetree.
 
#define SMBUS_DT_SPEC_INST_GET(inst)
 Structure initializer for smbus_dt_spec from devicetree instance.
 
#define SMBUS_DEVICE_DT_DEFINE(node_id, init_fn, pm_device, data_ptr, cfg_ptr, level, prio, api_ptr, ...)
 Like DEVICE_DT_DEFINE() with SMBus specifics.
 
#define SMBUS_DEVICE_DT_INST_DEFINE(inst, ...)
 Like SMBUS_DEVICE_DT_DEFINE() for an instance of a DT_DRV_COMPAT compatible.
 

Typedefs

typedef void(* smbus_callback_handler_t) (const struct device *dev, struct smbus_callback *cb, uint8_t addr)
 Define SMBus callback handler function signature.
 

Functions

static void smbus_xfer_stats (const struct device *dev, uint8_t sent, uint8_t recv)
 Updates the SMBus stats.
 
int smbus_configure (const struct device *dev, uint32_t dev_config)
 Configure operation of a SMBus host controller.
 
int smbus_get_config (const struct device *dev, uint32_t *dev_config)
 Get configuration of a SMBus host controller.
 
static int smbus_smbalert_set_cb (const struct device *dev, struct smbus_callback *cb)
 Add SMBUSALERT callback for a SMBus host controller.
 
int smbus_smbalert_remove_cb (const struct device *dev, struct smbus_callback *cb)
 Remove SMBUSALERT callback from a SMBus host controller.
 
static int smbus_host_notify_set_cb (const struct device *dev, struct smbus_callback *cb)
 Add Host Notify callback for a SMBus host controller.
 
int smbus_host_notify_remove_cb (const struct device *dev, struct smbus_callback *cb)
 Remove Host Notify callback from a SMBus host controller.
 
int smbus_quick (const struct device *dev, uint16_t addr, enum smbus_direction direction)
 Perform SMBus Quick operation.
 
int smbus_byte_write (const struct device *dev, uint16_t addr, uint8_t byte)
 Perform SMBus Byte Write operation.
 
int smbus_byte_read (const struct device *dev, uint16_t addr, uint8_t *byte)
 Perform SMBus Byte Read operation.
 
int smbus_byte_data_write (const struct device *dev, uint16_t addr, uint8_t cmd, uint8_t byte)
 Perform SMBus Byte Data Write operation.
 
int smbus_byte_data_read (const struct device *dev, uint16_t addr, uint8_t cmd, uint8_t *byte)
 Perform SMBus Byte Data Read operation.
 
int smbus_word_data_write (const struct device *dev, uint16_t addr, uint8_t cmd, uint16_t word)
 Perform SMBus Word Data Write operation.
 
int smbus_word_data_read (const struct device *dev, uint16_t addr, uint8_t cmd, uint16_t *word)
 Perform SMBus Word Data Read operation.
 
int smbus_pcall (const struct device *dev, uint16_t addr, uint8_t cmd, uint16_t send_word, uint16_t *recv_word)
 Perform SMBus Process Call operation.
 
int smbus_block_write (const struct device *dev, uint16_t addr, uint8_t cmd, uint8_t count, uint8_t *buf)
 Perform SMBus Block Write operation.
 
int smbus_block_read (const struct device *dev, uint16_t addr, uint8_t cmd, uint8_t *count, uint8_t *buf)
 Perform SMBus Block Read operation.
 
int smbus_block_pcall (const struct device *dev, uint16_t addr, uint8_t cmd, uint8_t snd_count, uint8_t *snd_buf, uint8_t *rcv_count, uint8_t *rcv_buf)
 Perform SMBus Block Process Call operation.
 

SMBus read / write direction

enum  smbus_direction { SMBUS_MSG_WRITE = 0 , SMBUS_MSG_READ = 1 }
 SMBus read / write direction. More...
 

SMBus Protocol commands

SMBus Specification defines the following SMBus protocols operations

#define SMBUS_CMD_QUICK   0b000
 SMBus Quick protocol is a very simple command with no data sent or received.
 
#define SMBUS_CMD_BYTE   0b001
 SMBus Byte protocol can send or receive one byte of data.
 
#define SMBUS_CMD_BYTE_DATA   0b010
 SMBus Byte Data protocol sends the first byte (command) followed by read or write one byte.
 
#define SMBUS_CMD_WORD_DATA   0b011
 SMBus Word Data protocol sends the first byte (command) followed by read or write two bytes.
 
#define SMBUS_CMD_PROC_CALL   0b100
 SMBus Process Call protocol is Write Word followed by Read Word.
 
#define SMBUS_CMD_BLOCK   0b101
 SMBus Block protocol reads or writes a block of data up to 32 bytes.
 
#define SMBUS_CMD_BLOCK_PROC   0b111
 SMBus Block Write - Block Read Process Call protocol is Block Write followed by Block Read.
 

SMBus device functionality

The following parameters describe the functionality of the SMBus device

#define SMBUS_MODE_CONTROLLER   BIT(0)
 Peripheral to act as Controller.
 
#define SMBUS_MODE_PEC   BIT(1)
 Support Packet Error Code (PEC) checking.
 
#define SMBUS_MODE_HOST_NOTIFY   BIT(2)
 Support Host Notify functionality.
 
#define SMBUS_MODE_SMBALERT   BIT(3)
 Support SMBALERT signal functionality.
 

SMBus special reserved addresses

The following addresses are reserved by SMBus specification

#define SMBUS_ADDRESS_ARA   0x0c
 Alert Response Address (ARA)
 

Detailed Description

SMBus Interface .

Since
3.4
Version
0.1.0

Macro Definition Documentation

◆ SMBUS_ADDRESS_ARA

#define SMBUS_ADDRESS_ARA   0x0c

#include <zephyr/drivers/smbus.h>

Alert Response Address (ARA)

A broadcast address used by the system host as part of the Alert Response Protocol.

◆ SMBUS_BLOCK_BYTES_MAX

#define SMBUS_BLOCK_BYTES_MAX   32

#include <zephyr/drivers/smbus.h>

Maximum number of bytes in SMBus Block protocol.

◆ SMBUS_CMD_BLOCK

#define SMBUS_CMD_BLOCK   0b101

#include <zephyr/drivers/smbus.h>

SMBus Block protocol reads or writes a block of data up to 32 bytes.

The Count byte specifies the amount of data.

SMBus Block Write
0 1 2
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|S| Periph Addr |W|A| Command code |A| Send Count=N |A|
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Data Write 1 |A| ... |A| Data Write N |A|P|
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
SMBus Block Read
0 1 2
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|S| Periph Addr |W|A| Command code |A|S| Periph Addr |R|
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|A| Recv Count=N |A| Data Read 1 |A| ... |A|
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Data Read N |N|P|
+-+-+-+-+-+-+-+-+-+-+

◆ SMBUS_CMD_BLOCK_PROC

#define SMBUS_CMD_BLOCK_PROC   0b111

#include <zephyr/drivers/smbus.h>

SMBus Block Write - Block Read Process Call protocol is Block Write followed by Block Read.

0 1 2
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|S| Periph Addr |W|A| Command code |A| Count = N |A|
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Data Write 1 |A| ... |A| Data Write N |A|S|
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Periph Addr |R|A| Recv Count=N |A| Data Read 1 |A| |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| ... |A| Data Read N |N|P|
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

◆ SMBUS_CMD_BYTE

#define SMBUS_CMD_BYTE   0b001

#include <zephyr/drivers/smbus.h>

SMBus Byte protocol can send or receive one byte of data.

Byte Write
0 1 2
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|S| Periph Addr |W|A| Command code |A|P|
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
Byte Read
0 1 2
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|S| Periph Addr |R|A| Byte received |N|P|
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

◆ SMBUS_CMD_BYTE_DATA

#define SMBUS_CMD_BYTE_DATA   0b010

#include <zephyr/drivers/smbus.h>

SMBus Byte Data protocol sends the first byte (command) followed by read or write one byte.

Byte Data Write
0 1 2
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|S| Periph Addr |W|A| Command code |A| Data Write |A|P|
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
Byte Data Read
0 1 2
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|S| Periph Addr |W|A| Command code |A|S| Periph Addr |R|A|
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Data Read |N|P|
+-+-+-+-+-+-+-+-+-+-+

◆ SMBUS_CMD_PROC_CALL

#define SMBUS_CMD_PROC_CALL   0b100

#include <zephyr/drivers/smbus.h>

SMBus Process Call protocol is Write Word followed by Read Word.

It is named so because the command sends data and waits for the peripheral to return a reply.

0 1 2
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|S| Periph Addr |W|A| Command code |A| Data Write Low|A|
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Data Write Hi |A|S| Periph Addr |R|A| Data Read Low |A|
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Data Read Hi |N|P|
+-+-+-+-+-+-+-+-+-+-+

◆ SMBUS_CMD_QUICK

#define SMBUS_CMD_QUICK   0b000

#include <zephyr/drivers/smbus.h>

SMBus Quick protocol is a very simple command with no data sent or received.

Peripheral may denote only R/W bit, which can still be used for the peripheral management, for example to switch peripheral On/Off. Quick protocol can also be used for peripheral devices scanning.

0 1
0 1 2 3 4 5 6 7 8 9 0
+-+-+-+-+-+-+-+-+-+-+-+
|S| Periph Addr |D|A|P|
+-+-+-+-+-+-+-+-+-+-+-+

◆ SMBUS_CMD_WORD_DATA

#define SMBUS_CMD_WORD_DATA   0b011

#include <zephyr/drivers/smbus.h>

SMBus Word Data protocol sends the first byte (command) followed by read or write two bytes.

Word Data Write
0 1 2
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|S| Periph Addr |W|A| Command code |A| Data Write Low|A|
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Data Write Hi |A|P|
+-+-+-+-+-+-+-+-+-+-+
Word Data Read
0 1 2
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|S| Periph Addr |W|A| Command code |A|S| Periph Addr |R|
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|A| Data Read Low |A| Data Read Hi |N|P|
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

◆ SMBUS_DEVICE_DT_DEFINE

#define SMBUS_DEVICE_DT_DEFINE ( node_id,
init_fn,
pm_device,
data_ptr,
cfg_ptr,
level,
prio,
api_ptr,
... )

#include <zephyr/drivers/smbus.h>

Value:
Z_SMBUS_DEVICE_STATE_DEFINE(node_id, \
Z_DEVICE_DT_DEV_NAME(node_id)); \
Z_SMBUS_INIT_FN(Z_DEVICE_DT_DEV_NAME(node_id), init_fn) \
Z_DEVICE_DEFINE(node_id, Z_DEVICE_DT_DEV_NAME(node_id), \
DEVICE_DT_NAME(node_id), \
&UTIL_CAT(Z_DEVICE_DT_DEV_NAME(node_id), _init),\
data_ptr, cfg_ptr, level, prio, \
api_ptr, \
&(Z_DEVICE_STATE_NAME(Z_DEVICE_DT_DEV_NAME \
(node_id)).devstate), \
__VA_ARGS__)
#define DEVICE_DT_NAME(node_id)
Return a string name for a devicetree node.
Definition device.h:152
Runtime PM info for device with generic PM.
Definition device.h:163
#define UTIL_CAT(a,...)
Definition util_internal.h:104

Like DEVICE_DT_DEFINE() with SMBus specifics.

Defines a device which implements the SMBus API. May generate a custom device_state container struct and init_fn wrapper when needed depending on SMBus

CONFIG_SMBUS_STATS 

.

Parameters
node_idThe devicetree node identifier.
init_fnName of the init function of the driver.
pm_devicePM device resources reference (NULL if device does not use PM).
data_ptrPointer to the device's private data.
cfg_ptrThe address to the structure containing the configuration information for this instance of the driver.
levelThe initialization level. See SYS_INIT() for details.
prioPriority within the selected initialization level. See SYS_INIT() for details.
api_ptrProvides an initial pointer to the API function struct used by the driver. Can be NULL.

◆ SMBUS_DEVICE_DT_INST_DEFINE

#define SMBUS_DEVICE_DT_INST_DEFINE ( inst,
... )

#include <zephyr/drivers/smbus.h>

Value:
SMBUS_DEVICE_DT_DEFINE(DT_DRV_INST(inst), __VA_ARGS__)
#define DT_DRV_INST(inst)
Node identifier for an instance of a DT_DRV_COMPAT compatible.
Definition devicetree.h:3623
#define SMBUS_DEVICE_DT_DEFINE(node_id, init_fn, pm_device, data_ptr, cfg_ptr, level, prio, api_ptr,...)
Like DEVICE_DT_DEFINE() with SMBus specifics.
Definition smbus.h:504

Like SMBUS_DEVICE_DT_DEFINE() for an instance of a DT_DRV_COMPAT compatible.

Parameters
instinstance number. This is replaced by DT_DRV_COMPAT(inst) in the call to SMBUS_DEVICE_DT_DEFINE().
...other parameters as expected by SMBUS_DEVICE_DT_DEFINE().

◆ SMBUS_DT_SPEC_GET

#define SMBUS_DT_SPEC_GET ( node_id)

#include <zephyr/drivers/smbus.h>

Value:
{ \
.bus = DEVICE_DT_GET(DT_BUS(node_id)), \
.addr = DT_REG_ADDR(node_id) \
}
#define DEVICE_DT_GET(node_id)
Get a device reference from a devicetree node identifier.
Definition device.h:246
#define DT_BUS(node_id)
Node's bus controller.
Definition devicetree.h:3575
#define DT_REG_ADDR(node_id)
Get a node's (only) register block address.
Definition devicetree.h:2276

Structure initializer for smbus_dt_spec from devicetree.

This helper macro expands to a static initializer for a struct smbus_dt_spec by reading the relevant bus and address data from the devicetree.

Parameters
node_idDevicetree node identifier for the SMBus device whose struct smbus_dt_spec to create an initializer for

◆ SMBUS_DT_SPEC_INST_GET

#define SMBUS_DT_SPEC_INST_GET ( inst)

#include <zephyr/drivers/smbus.h>

Value:
#define SMBUS_DT_SPEC_GET(node_id)
Structure initializer for smbus_dt_spec from devicetree.
Definition smbus.h:318

Structure initializer for smbus_dt_spec from devicetree instance.

This is equivalent to SMBUS_DT_SPEC_GET(DT_DRV_INST(inst)).

Parameters
instDevicetree instance number

◆ SMBUS_MODE_CONTROLLER

#define SMBUS_MODE_CONTROLLER   BIT(0)

#include <zephyr/drivers/smbus.h>

Peripheral to act as Controller.

◆ SMBUS_MODE_HOST_NOTIFY

#define SMBUS_MODE_HOST_NOTIFY   BIT(2)

#include <zephyr/drivers/smbus.h>

Support Host Notify functionality.

◆ SMBUS_MODE_PEC

#define SMBUS_MODE_PEC   BIT(1)

#include <zephyr/drivers/smbus.h>

Support Packet Error Code (PEC) checking.

◆ SMBUS_MODE_SMBALERT

#define SMBUS_MODE_SMBALERT   BIT(3)

#include <zephyr/drivers/smbus.h>

Support SMBALERT signal functionality.

Typedef Documentation

◆ smbus_callback_handler_t

typedef void(* smbus_callback_handler_t) (const struct device *dev, struct smbus_callback *cb, uint8_t addr)

#include <zephyr/drivers/smbus.h>

Define SMBus callback handler function signature.

Parameters
devPointer to the device structure for the SMBus driver instance.
cbStructure smbus_callback owning this handler.
addrAddress of the SMBus peripheral device.

Enumeration Type Documentation

◆ smbus_direction

#include <zephyr/drivers/smbus.h>

SMBus read / write direction.

Enumerator
SMBUS_MSG_WRITE 

Write a message to SMBus peripheral.

SMBUS_MSG_READ 

Read a message from SMBus peripheral.

Function Documentation

◆ smbus_block_pcall()

int smbus_block_pcall ( const struct device * dev,
uint16_t addr,
uint8_t cmd,
uint8_t snd_count,
uint8_t * snd_buf,
uint8_t * rcv_count,
uint8_t * rcv_buf )

#include <zephyr/drivers/smbus.h>

Perform SMBus Block Process Call operation.

This routine provides a generic interface to perform SMBus Block Process Call operation. This operation is basically Block Write followed by Block Read.

Parameters
devPointer to the device structure for the SMBus driver instance.
addrAddress of the SMBus peripheral device.
cmdCommand byte which is sent to peripheral device first.
snd_countSize of the data block buffer to send.
snd_bufData block buffer send to the peripheral device.
rcv_countSize of the data peripheral sent.
rcv_bufData block buffer received from the peripheral device.
Return values
0If successful.
-EIOGeneral input / output error.
-ENOSYSIf function smbus_block_pcall() is not implemented by the driver.

◆ smbus_block_read()

int smbus_block_read ( const struct device * dev,
uint16_t addr,
uint8_t cmd,
uint8_t * count,
uint8_t * buf )

#include <zephyr/drivers/smbus.h>

Perform SMBus Block Read operation.

This routine provides a generic interface to perform SMBus Block Read operation.

Parameters
devPointer to the device structure for the SMBus driver instance.
addrAddress of the SMBus peripheral device.
cmdCommand byte which is sent to peripheral device first.
countSize of the data peripheral sent. Maximum 32 bytes.
bufData block buffer received from the peripheral device.
Return values
0If successful.
-EIOGeneral input / output error.
-ENOSYSIf function smbus_block_read() is not implemented by the driver.

◆ smbus_block_write()

int smbus_block_write ( const struct device * dev,
uint16_t addr,
uint8_t cmd,
uint8_t count,
uint8_t * buf )

#include <zephyr/drivers/smbus.h>

Perform SMBus Block Write operation.

This routine provides a generic interface to perform SMBus Block Write operation.

Parameters
devPointer to the device structure for the SMBus driver instance.
addrAddress of the SMBus peripheral device.
cmdCommand byte which is sent to peripheral device first.
countSize of the data block buffer. Maximum 32 bytes.
bufData block buffer to be sent to the peripheral device.
Return values
0If successful.
-EIOGeneral input / output error.
-ENOSYSIf function smbus_block_write() is not implemented by the driver.

◆ smbus_byte_data_read()

int smbus_byte_data_read ( const struct device * dev,
uint16_t addr,
uint8_t cmd,
uint8_t * byte )

#include <zephyr/drivers/smbus.h>

Perform SMBus Byte Data Read operation.

This routine provides a generic interface to perform SMBus Byte Data Read operation.

Parameters
devPointer to the device structure for the SMBus driver instance.
addrAddress of the SMBus peripheral device.
cmdCommand byte which is sent to peripheral device first.
byteByte received from the peripheral device.
Return values
0If successful.
-EIOGeneral input / output error.
-ENOSYSIf function smbus_byte_data_read() is not implemented by the driver.

◆ smbus_byte_data_write()

int smbus_byte_data_write ( const struct device * dev,
uint16_t addr,
uint8_t cmd,
uint8_t byte )

#include <zephyr/drivers/smbus.h>

Perform SMBus Byte Data Write operation.

This routine provides a generic interface to perform SMBus Byte Data Write operation.

Parameters
devPointer to the device structure for the SMBus driver instance.
addrAddress of the SMBus peripheral device.
cmdCommand byte which is sent to peripheral device first.
byteByte to be sent to the peripheral device.
Return values
0If successful.
-EIOGeneral input / output error.
-ENOSYSIf function smbus_byte_data_write() is not implemented by the driver.

◆ smbus_byte_read()

int smbus_byte_read ( const struct device * dev,
uint16_t addr,
uint8_t * byte )

#include <zephyr/drivers/smbus.h>

Perform SMBus Byte Read operation.

This routine provides a generic interface to perform SMBus Byte Read operation.

Parameters
devPointer to the device structure for the SMBus driver instance.
addrAddress of the SMBus peripheral device.
byteByte received from the peripheral device.
Return values
0If successful.
-EIOGeneral input / output error.
-ENOSYSIf function smbus_byte_read() is not implemented by the driver.

◆ smbus_byte_write()

int smbus_byte_write ( const struct device * dev,
uint16_t addr,
uint8_t byte )

#include <zephyr/drivers/smbus.h>

Perform SMBus Byte Write operation.

This routine provides a generic interface to perform SMBus Byte Write operation.

Parameters
devPointer to the device structure for the SMBus driver instance.
addrAddress of the SMBus peripheral device.
byteByte to be sent to the peripheral device.
Return values
0If successful.
-EIOGeneral input / output error.
-ENOSYSIf function smbus_byte_write() is not implemented by the driver.

◆ smbus_configure()

int smbus_configure ( const struct device * dev,
uint32_t dev_config )

#include <zephyr/drivers/smbus.h>

Configure operation of a SMBus host controller.

Parameters
devPointer to the device structure for the SMBus driver instance.
dev_configBit-packed 32-bit value to the device runtime configuration for the SMBus controller.
Return values
0If successful.
-EIOGeneral input / output error.

◆ smbus_get_config()

int smbus_get_config ( const struct device * dev,
uint32_t * dev_config )

#include <zephyr/drivers/smbus.h>

Get configuration of a SMBus host controller.

This routine provides a way to get current configuration. It is allowed to call the function before smbus_configure, because some SMBus ports can be configured during init process. However, if the SMBus port is not configured, smbus_get_config returns an error.

smbus_get_config can return cached config or probe hardware, but it has to be up to date with current configuration.

Parameters
devPointer to the device structure for the SMBus driver instance.
dev_configPointer to return bit-packed 32-bit value of the SMBus controller configuration.
Return values
0If successful.
-EIOGeneral input / output error.
-ENOSYSIf function smbus_get_config() is not implemented by the driver.

◆ smbus_host_notify_remove_cb()

int smbus_host_notify_remove_cb ( const struct device * dev,
struct smbus_callback * cb )

#include <zephyr/drivers/smbus.h>

Remove Host Notify callback from a SMBus host controller.

Parameters
devPointer to the device structure for the SMBus driver instance.
cbPointer to a callback structure.
Return values
0If successful.
-EIOGeneral input / output error.
-ENOSYSIf function smbus_host_notify_remove_cb() is not implemented by the driver.

◆ smbus_host_notify_set_cb()

static int smbus_host_notify_set_cb ( const struct device * dev,
struct smbus_callback * cb )
inlinestatic

#include <zephyr/drivers/smbus.h>

Add Host Notify callback for a SMBus host controller.

Parameters
devPointer to the device structure for the SMBus driver instance.
cbPointer to a callback structure.
Return values
0If successful.
-EIOGeneral input / output error.
-ENOSYSIf function smbus_host_notify_set_cb() is not implemented by the driver.

◆ smbus_pcall()

int smbus_pcall ( const struct device * dev,
uint16_t addr,
uint8_t cmd,
uint16_t send_word,
uint16_t * recv_word )

#include <zephyr/drivers/smbus.h>

Perform SMBus Process Call operation.

This routine provides a generic interface to perform SMBus Process Call operation, which means Write 2 bytes following by Read 2 bytes.

Parameters
devPointer to the device structure for the SMBus driver instance.
addrAddress of the SMBus peripheral device.
cmdCommand byte which is sent to peripheral device first.
send_wordWord (16-bit) to be sent to the peripheral device.
recv_wordWord (16-bit) received from the peripheral device.
Return values
0If successful.
-EIOGeneral input / output error.
-ENOSYSIf function smbus_pcall() is not implemented by the driver.

◆ smbus_quick()

int smbus_quick ( const struct device * dev,
uint16_t addr,
enum smbus_direction direction )

#include <zephyr/drivers/smbus.h>

Perform SMBus Quick operation.

This routine provides a generic interface to perform SMBus Quick operation.

Parameters
devPointer to the device structure for the SMBus driver instance. driver configured in controller mode.
addrAddress of the SMBus peripheral device.
directionDirection Read or Write.
Return values
0If successful.
-EIOGeneral input / output error.
-ENOSYSIf function smbus_quick() is not implemented by the driver.

◆ smbus_smbalert_remove_cb()

int smbus_smbalert_remove_cb ( const struct device * dev,
struct smbus_callback * cb )

#include <zephyr/drivers/smbus.h>

Remove SMBUSALERT callback from a SMBus host controller.

Parameters
devPointer to the device structure for the SMBus driver instance.
cbPointer to a callback structure.
Return values
0If successful.
-EIOGeneral input / output error.
-ENOSYSIf function smbus_smbalert_remove_cb() is not implemented by the driver.

◆ smbus_smbalert_set_cb()

static int smbus_smbalert_set_cb ( const struct device * dev,
struct smbus_callback * cb )
inlinestatic

#include <zephyr/drivers/smbus.h>

Add SMBUSALERT callback for a SMBus host controller.

Parameters
devPointer to the device structure for the SMBus driver instance.
cbPointer to a callback structure.
Return values
0If successful.
-EIOGeneral input / output error.
-ENOSYSIf function smbus_smbalert_set_cb() is not implemented by the driver.

◆ smbus_word_data_read()

int smbus_word_data_read ( const struct device * dev,
uint16_t addr,
uint8_t cmd,
uint16_t * word )

#include <zephyr/drivers/smbus.h>

Perform SMBus Word Data Read operation.

This routine provides a generic interface to perform SMBus Word Data Read operation.

Parameters
devPointer to the device structure for the SMBus driver instance.
addrAddress of the SMBus peripheral device.
cmdCommand byte which is sent to peripheral device first.
wordWord (16-bit) received from the peripheral device.
Return values
0If successful.
-EIOGeneral input / output error.
-ENOSYSIf function smbus_word_data_read() is not implemented by the driver.

◆ smbus_word_data_write()

int smbus_word_data_write ( const struct device * dev,
uint16_t addr,
uint8_t cmd,
uint16_t word )

#include <zephyr/drivers/smbus.h>

Perform SMBus Word Data Write operation.

This routine provides a generic interface to perform SMBus Word Data Write operation.

Parameters
devPointer to the device structure for the SMBus driver instance.
addrAddress of the SMBus peripheral device.
cmdCommand byte which is sent to peripheral device first.
wordWord (16-bit) to be sent to the peripheral device.
Return values
0If successful.
-EIOGeneral input / output error.
-ENOSYSIf function smbus_word_data_write() is not implemented by the driver.

◆ smbus_xfer_stats()

static void smbus_xfer_stats ( const struct device * dev,
uint8_t sent,
uint8_t recv )
inlinestatic

#include <zephyr/drivers/smbus.h>

Updates the SMBus stats.

Parameters
devPointer to the device structure for the SMBus driver instance to update stats for.
sentNumber of bytes sent
recvNumber of bytes received