Zephyr Project API  3.4.0
A Scalable Open Source RTOS
smbus.h File Reference
#include <zephyr/types.h>
#include <zephyr/device.h>
#include <zephyr/stats/stats.h>
#include <syscalls/smbus.h>

Go to the source code of this file.

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
 
#define SMBUS_DT_SPEC_GET(node_id)
 Structure initializer for smbus_dt_spec from devicetree. More...
 
#define SMBUS_DT_SPEC_INST_GET(inst)   SMBUS_DT_SPEC_GET(DT_DRV_INST(inst))
 Structure initializer for smbus_dt_spec from devicetree instance. More...
 
#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. More...
 
#define SMBUS_DEVICE_DT_INST_DEFINE(inst, ...)    SMBUS_DEVICE_DT_DEFINE(DT_DRV_INST(inst), __VA_ARGS__)
 Like SMBUS_DEVICE_DT_DEFINE() for an instance of a DT_DRV_COMPAT compatible. More...
 
SMBus Protocol commands

SMBus Specification defines the following SMBus protocols operations

#define SMBUS_CMD_QUICK   0b000
 
#define SMBUS_CMD_BYTE   0b001
 
#define SMBUS_CMD_BYTE_DATA   0b010
 
#define SMBUS_CMD_WORD_DATA   0b011
 
#define SMBUS_CMD_PROC_CALL   0b100
 
#define SMBUS_CMD_BLOCK   0b101
 
#define SMBUS_CMD_BLOCK_PROC   0b111
 
SMBus device functionality

The following parameters describe the functionality of the SMBus device

#define SMBUS_MODE_CONTROLLER   BIT(0)
 
#define SMBUS_MODE_PEC   BIT(1)
 
#define SMBUS_MODE_HOST_NOTIFY   BIT(2)
 
#define SMBUS_MODE_SMBALERT   BIT(3)
 
SMBus special reserved addresses

The following addresses are reserved by SMBus specification

#define SMBUS_ADDRESS_ARA   0x0c
 Alert Response Address (ARA) More...
 

Typedefs

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

Enumerations

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

Functions

static void smbus_xfer_stats (const struct device *dev, uint8_t sent, uint8_t recv)
 Updates the SMBus stats. More...
 
int smbus_configure (const struct device *dev, uint32_t dev_config)
 Configure operation of a SMBus host controller. More...
 
int smbus_get_config (const struct device *dev, uint32_t *dev_config)
 Get configuration of a SMBus host controller. More...
 
int smbus_smbalert_set_cb (const struct device *dev, struct smbus_callback *cb)
 Add SMBUSALERT callback for a SMBus host controller. More...
 
int smbus_smbalert_remove_cb (const struct device *dev, struct smbus_callback *cb)
 Remove SMBUSALERT callback from a SMBus host controller. More...
 
int smbus_host_notify_set_cb (const struct device *dev, struct smbus_callback *cb)
 Add Host Notify callback for a SMBus host controller. More...
 
int smbus_host_notify_remove_cb (const struct device *dev, struct smbus_callback *cb)
 Remove Host Notify callback from a SMBus host controller. More...
 
int smbus_quick (const struct device *dev, uint16_t addr, enum smbus_direction direction)
 Perform SMBus Quick operation. More...
 
int smbus_byte_write (const struct device *dev, uint16_t addr, uint8_t byte)
 Perform SMBus Byte Write operation. More...
 
int smbus_byte_read (const struct device *dev, uint16_t addr, uint8_t *byte)
 Perform SMBus Byte Read operation. More...
 
int smbus_byte_data_write (const struct device *dev, uint16_t addr, uint8_t cmd, uint8_t byte)
 Perform SMBus Byte Data Write operation. More...
 
int smbus_byte_data_read (const struct device *dev, uint16_t addr, uint8_t cmd, uint8_t *byte)
 Perform SMBus Byte Data Read operation. More...
 
int smbus_word_data_write (const struct device *dev, uint16_t addr, uint8_t cmd, uint16_t word)
 Perform SMBus Word Data Write operation. More...
 
int smbus_word_data_read (const struct device *dev, uint16_t addr, uint8_t cmd, uint16_t *word)
 Perform SMBus Word Data Read operation. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...