TT-System-Firmware APIs 19.10.99
Tenstorrent Firmware
Loading...
Searching...
No Matches
smbus_target.c File Reference
#include <zephyr/sys/util.h>
#include <zephyr/kernel.h>
#include <errno.h>
#include <zephyr/drivers/i2c.h>
#include <zephyr/sys/crc.h>
#include <tenstorrent/smbus_target.h>
#include <zephyr/logging/log.h>
Include dependency graph for smbus_target.c:

Data Structures

struct  smbus_target_data
struct  smbus_target_config

Macros

#define DT_DRV_COMPAT   zephyr_smbus_target
#define LOG_LEVEL   CONFIG_I2C_LOG_LEVEL
#define SMBUS_TARGET_INIT(inst)

Enumerations

enum  SmbusState {
  kSmbusStateIdle ,
  kSmbusStateCmd ,
  kSmbusStateRcvData ,
  kSmbusStateRcvPec ,
  kSmbusStateSendData ,
  kSmbusStateSendPec ,
  kSmbusStateWaitIdle
}

Functions

 LOG_MODULE_REGISTER (i2c_target)
static const struct SmbusCmdDefget_cmd_def (struct smbus_target_data *smbus_data, uint8_t cmd)
static uint8_t pec_crc_8 (uint8_t crc, uint8_t data)
static int32_t smbus_target_register (const struct device *dev)
static int32_t smbus_target_unregister (const struct device *dev)
static int smbus_write_handler (struct i2c_target_config *config, uint8_t val)
static int32_t smbus_read_handler (struct i2c_target_config *config, uint8_t *val)
static int32_t smbus_stop_handler (struct i2c_target_config *config)
static int32_t smbus_write_requested (struct i2c_target_config *config)
static int32_t smbus_target_init (const struct device *dev)
int32_t smbus_target_register_cmd (const struct device *dev, uint8_t cmd_id, const struct SmbusCmdDef *smbus_cmd)
 Register the given command to the SMBUS target implementation.

Variables

static const struct i2c_target_driver_api api_funcs
const struct i2c_target_callbacks smbus_target_cb_impl

Macro Definition Documentation

◆ DT_DRV_COMPAT

#define DT_DRV_COMPAT   zephyr_smbus_target

◆ LOG_LEVEL

#define LOG_LEVEL   CONFIG_I2C_LOG_LEVEL

◆ SMBUS_TARGET_INIT

#define SMBUS_TARGET_INIT ( inst)
Value:
static struct smbus_target_data smbus_target_##inst##_dev_data = {0}; \
static const struct smbus_target_config smbus_target_##inst##_cfg = { \
.bus = I2C_DT_SPEC_INST_GET(inst), \
}; \
\
DEVICE_DT_INST_DEFINE(inst, &smbus_target_init, NULL, &smbus_target_##inst##_dev_data, \
&smbus_target_##inst##_cfg, POST_KERNEL, \
CONFIG_I2C_TARGET_INIT_PRIORITY, &api_funcs);
#define NULL
Definition avs.c:45
static int32_t smbus_target_init(const struct device *dev)
Definition smbus_target.c:340
static const struct i2c_target_driver_api api_funcs
Definition smbus_target.c:327
#define I2C_DT_SPEC_INST_GET(inst)
Definition smbus_target.c:43
Definition smbus_target.c:30

Enumeration Type Documentation

◆ SmbusState

enum SmbusState
Enumerator
kSmbusStateIdle 
kSmbusStateCmd 
kSmbusStateRcvData 
kSmbusStateRcvPec 
kSmbusStateSendData 
kSmbusStateSendPec 
kSmbusStateWaitIdle 

Function Documentation

◆ get_cmd_def()

const struct SmbusCmdDef * get_cmd_def ( struct smbus_target_data * smbus_data,
uint8_t cmd )
static

◆ LOG_MODULE_REGISTER()

LOG_MODULE_REGISTER ( i2c_target )

◆ pec_crc_8()

uint8_t pec_crc_8 ( uint8_t crc,
uint8_t data )
inlinestatic

◆ smbus_read_handler()

int32_t smbus_read_handler ( struct i2c_target_config * config,
uint8_t * val )
static

◆ smbus_stop_handler()

int32_t smbus_stop_handler ( struct i2c_target_config * config)
static

◆ smbus_target_init()

int32_t smbus_target_init ( const struct device * dev)
static

◆ smbus_target_register()

int32_t smbus_target_register ( const struct device * dev)
static

◆ smbus_target_register_cmd()

int32_t smbus_target_register_cmd ( const struct device * dev,
uint8_t cmd_id,
const struct SmbusCmdDef * smbus_cmd )

Register the given command to the SMBUS target implementation.

Parameters
devThe device to register the command for.
cmd_idThe command ID to register the handler for.
smbus_cmdPointer to the smbus command to register. The memory must have persistent storage for the duration of the time the target remains registered to the I2C.

◆ smbus_target_unregister()

int32_t smbus_target_unregister ( const struct device * dev)
static

◆ smbus_write_handler()

int smbus_write_handler ( struct i2c_target_config * config,
uint8_t val )
static

◆ smbus_write_requested()

int32_t smbus_write_requested ( struct i2c_target_config * config)
static

Variable Documentation

◆ api_funcs

const struct i2c_target_driver_api api_funcs
static
Initial value:
= {
.driver_register = smbus_target_register,
.driver_unregister = smbus_target_unregister,
}
static int32_t smbus_target_unregister(const struct device *dev)
Definition smbus_target.c:65
static int32_t smbus_target_register(const struct device *dev)
Definition smbus_target.c:57

◆ smbus_target_cb_impl

const struct i2c_target_callbacks smbus_target_cb_impl
Initial value:
= {
.write_requested = &smbus_write_requested,
.write_received = &smbus_write_handler,
.read_requested = &smbus_read_handler,
.read_processed = &smbus_read_handler,
}
static int smbus_write_handler(struct i2c_target_config *config, uint8_t val)
Definition smbus_target.c:73
static int32_t smbus_read_handler(struct i2c_target_config *config, uint8_t *val)
Definition smbus_target.c:184
static int32_t smbus_write_requested(struct i2c_target_config *config)
Definition smbus_target.c:321
static int32_t smbus_stop_handler(struct i2c_target_config *config)
Definition smbus_target.c:297