#include <stdint.h>
#include <stdbool.h>
#include <stdlib.h>
#include <errno.h>
#include "no_os_units.h"
#include "no_os_util.h"
#include "no_os_delay.h"
#include "no_os_alloc.h"
#include "no_os_i2c.h"
#include "no_os_gpio.h"
#include "no_os_crc8.h"
#include "lt3074.h"
Macros | |
#define | LT3074_LIN11_MANTISSA_MAX 1023000L |
#define | LT3074_LIN11_MANTISSA_MIN 511000L |
#define | LT3074_LIN11_EXPONENT_MAX 15 |
#define | LT3074_LIN11_EXPONENT_MIN -15 |
#define | LT3074_LIN11_MANTISSA_MSK NO_OS_GENMASK(10,0) |
#define | LT3074_LIN11_EXPONENT_MSK NO_OS_GENMASK(15,11) |
#define | LT3074_LIN11_EXPONENT(x) |
#define | LT3074_LIN11_MANTISSA(x) |
#define | LT3074_LIN16_EXPONENT -13 |
Functions | |
NO_OS_DECLARE_CRC8_TABLE (lt3074_crc_table) | |
int | lt3074_init (struct lt3074_dev **device, struct lt3074_init_param *init_param) |
Initialize the device structure. | |
int | lt3074_remove (struct lt3074_dev *dev) |
Free or remove device instance. | |
int | lt3074_send_byte (struct lt3074_dev *dev, uint32_t cmd) |
Send a PMBus command to the device. | |
int | lt3074_read_byte (struct lt3074_dev *dev, uint32_t cmd, uint8_t *data) |
Perform a raw PMBus read byte operation. | |
int | lt3074_write_byte (struct lt3074_dev *dev, uint32_t cmd, uint8_t value) |
Perform a raw PMBus write byte operation. | |
int | lt3074_read_word (struct lt3074_dev *dev, uint32_t cmd, uint16_t *word) |
Perform a raw PMBus read word operation. | |
int | lt3074_write_word (struct lt3074_dev *dev, uint32_t cmd, uint16_t word) |
Perform a raw PMBus write word operation. | |
int | lt3074_read_word_data (struct lt3074_dev *dev, uint32_t cmd, int *data) |
Perform a PMBus read word operation and converts to actual value. | |
int | lt3074_write_word_data (struct lt3074_dev *dev, uint32_t cmd, int data) |
Converts value to register data and do PMBus write word operation. | |
int | lt3074_read_block_data (struct lt3074_dev *dev, uint32_t cmd, uint8_t *data, size_t nbytes) |
Perform a PMBus read block operation. | |
int | lt3074_reg_read (struct lt3074_dev *dev, uint32_t reg, uint32_t *data) |
Generic register read wrapper. | |
int | lt3074_reg_write (struct lt3074_dev *dev, uint32_t reg, uint32_t val) |
Generic register write wrapper. | |
int | lt3074_read_value (struct lt3074_dev *dev, enum lt3074_value_type value_type, int *value) |
Read a value. | |
int | lt3074_read_status (struct lt3074_dev *dev, enum lt3074_status_type status_type, struct lt3074_status *status) |
Read statuses. | |
int | lt3074_vout_margin (struct lt3074_dev *dev, enum lt3074_margin margin_high, enum lt3074_margin margin_low) |
Set output voltage margin. | |
int | lt3074_set_limit (struct lt3074_dev *dev, enum lt3074_limit_type limit, int limit_val) |
Sets the limit value for a specific fault/warning limits. | |
int | lt3074_set_operation (struct lt3074_dev *dev, enum lt3074_operation_type operation) |
Set operation. | |
int | lt3074_clear_faults (struct lt3074_dev *dev) |
Clear status registers. | |
int | lt3074_set_enable_pin (struct lt3074_dev *dev, bool state) |
Enable/Disable the device using the EN pin. | |
int | lt3074_software_reset (struct lt3074_dev *dev) |
Perform a device software reset. | |
#define LT3074_LIN11_EXPONENT | ( | x | ) |
#define LT3074_LIN11_EXPONENT_MAX 15 |
#define LT3074_LIN11_EXPONENT_MIN -15 |
#define LT3074_LIN11_EXPONENT_MSK NO_OS_GENMASK(15,11) |
#define LT3074_LIN11_MANTISSA | ( | x | ) |
#define LT3074_LIN11_MANTISSA_MAX 1023000L |
#define LT3074_LIN11_MANTISSA_MIN 511000L |
#define LT3074_LIN11_MANTISSA_MSK NO_OS_GENMASK(10,0) |
#define LT3074_LIN16_EXPONENT -13 |
int lt3074_clear_faults | ( | struct lt3074_dev * | dev | ) |
Clear status registers.
dev | - Device structure |
int lt3074_init | ( | struct lt3074_dev ** | device, |
struct lt3074_init_param * | init_param ) |
Initialize the device structure.
device | - Device structure |
init_param | - Initialization parameters |
int lt3074_read_block_data | ( | struct lt3074_dev * | dev, |
uint32_t | cmd, | ||
uint8_t * | data, | ||
size_t | nbytes ) |
Perform a PMBus read block operation.
dev | - Device structure |
cmd | - PMBus command |
data | - Address of the read block |
nbytes | - Size of the block in bytes |
int lt3074_read_byte | ( | struct lt3074_dev * | dev, |
uint32_t | cmd, | ||
uint8_t * | data ) |
Perform a raw PMBus read byte operation.
dev | - Device structure |
cmd | - PMBus command |
data | - Address of the byte read |
int lt3074_read_status | ( | struct lt3074_dev * | dev, |
enum lt3074_status_type | status_type, | ||
struct lt3074_status * | status ) |
Read statuses.
dev | - Device structure |
status_type | - Status type. Example values: LT3074_STATUS_BYTE_TYPE LT3074_STATUS_VOUT_TYPE LT3074_STATUS_IOUT_TYPE LT3074_STATUS_INPUT_TYPE LT3074_STATUS_CML_TYPE |
status | - Address of the status structure |
int lt3074_read_value | ( | struct lt3074_dev * | dev, |
enum lt3074_value_type | value_type, | ||
int * | value ) |
Read a value.
dev | - Device structure |
value_type | - Value type. Example values: LT3074_VIN LT3074_VOUT LT3074_IOUT LT3074_TEMP LT3074_VBIAS |
value | - Address of the read value |
int lt3074_read_word | ( | struct lt3074_dev * | dev, |
uint32_t | cmd, | ||
uint16_t * | word ) |
Perform a raw PMBus read word operation.
dev | - Device structure |
cmd | - PMBus command |
word | - Address of the read word |
int lt3074_read_word_data | ( | struct lt3074_dev * | dev, |
uint32_t | cmd, | ||
int * | data ) |
Perform a PMBus read word operation and converts to actual value.
dev | - Device structure |
cmd | - PMBus command |
data | - Address of data read |
int lt3074_reg_read | ( | struct lt3074_dev * | dev, |
uint32_t | reg, | ||
uint32_t * | data ) |
Generic register read wrapper.
dev | - Device structure |
reg | - PMBus regiser |
data | - Address of the read data |
int lt3074_reg_write | ( | struct lt3074_dev * | dev, |
uint32_t | reg, | ||
uint32_t | val ) |
Generic register write wrapper.
dev | - Device structure |
reg | - PMBus register |
val | - Value to write |
int lt3074_remove | ( | struct lt3074_dev * | dev | ) |
Free or remove device instance.
dev | - The device structure |
int lt3074_send_byte | ( | struct lt3074_dev * | dev, |
uint32_t | cmd ) |
Send a PMBus command to the device.
dev | - Device structure |
cmd | - PMBus command |
int lt3074_set_enable_pin | ( | struct lt3074_dev * | dev, |
bool | state ) |
Enable/Disable the device using the EN pin.
dev | - Device structure |
state | - Enable/Disable state. 0 for disable, 1 for enable. |
int lt3074_set_limit | ( | struct lt3074_dev * | dev, |
enum lt3074_limit_type | limit, | ||
int | limit_val ) |
Sets the limit value for a specific fault/warning limits.
dev | - Device structure |
limit | - The type of limit to set. |
limit_val | - The value to set for the specified limit type. |
int lt3074_set_operation | ( | struct lt3074_dev * | dev, |
enum lt3074_operation_type | operation ) |
Set operation.
dev | - Device structure |
operation | - Operation. Accepted values are: LT3074_OPERATION_OFF LT3074_OPERATION_ON LT3074_OPERATION_MARGIN_HIGH LT3074_OPERATION_MARGIN_LOW |
int lt3074_software_reset | ( | struct lt3074_dev * | dev | ) |
Perform a device software reset.
dev | - Device structure |
int lt3074_vout_margin | ( | struct lt3074_dev * | dev, |
enum lt3074_margin | margin_high, | ||
enum lt3074_margin | margin_low ) |
Set output voltage margin.
dev | - Device structure |
margin_high | - Upper margin |
margin_low | - Lower margin |
int lt3074_write_byte | ( | struct lt3074_dev * | dev, |
uint32_t | cmd, | ||
uint8_t | value ) |
Perform a raw PMBus write byte operation.
dev | - Device structure |
cmd | - PMBus command |
value | - Byte to be written |
int lt3074_write_word | ( | struct lt3074_dev * | dev, |
uint32_t | cmd, | ||
uint16_t | word ) |
Perform a raw PMBus write word operation.
dev | - Device structure |
cmd | - PMBus command |
word | - Word to write |
int lt3074_write_word_data | ( | struct lt3074_dev * | dev, |
uint32_t | cmd, | ||
int | data ) |
Converts value to register data and do PMBus write word operation.
dev | - Device structure |
cmd | - PMBus command |
data | - Value to write |
NO_OS_DECLARE_CRC8_TABLE | ( | lt3074_crc_table | ) |