Zephyr API Documentation  3.6.99
A Scalable Open Source RTOS
Loading...
Searching...
No Matches
smbus.h File Reference

Public SMBus Driver APIs. More...

#include <errno.h>
#include <zephyr/sys/slist.h>
#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
 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)   SMBUS_DT_SPEC_GET(DT_DRV_INST(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, ...)    SMBUS_DEVICE_DT_DEFINE(DT_DRV_INST(inst), __VA_ARGS__)
 Like SMBUS_DEVICE_DT_DEFINE() for an instance of a DT_DRV_COMPAT compatible.
 
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)
 

Typedefs

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

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.
 
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.
 

Detailed Description

Public SMBus Driver APIs.