no-OS
All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
ltp8800.h
Go to the documentation of this file.
1/*******************************************************************************
2 * @file ltp8800.h
3 * @brief Header file of the LTP8800 Driver
4 * @authors Cedric Justine Encarnacion (cedricjustine.encarnacion@analog.com)
5********************************************************************************
6 * Copyright 2024(c) Analog Devices, Inc.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions are met:
10 *
11 * 1. Redistributions of source code must retain the above copyright notice,
12 * this list of conditions and the following disclaimer.
13 *
14 * 2. Redistributions in binary form must reproduce the above copyright notice,
15 * this list of conditions and the following disclaimer in the documentation
16 * and/or other materials provided with the distribution.
17 *
18 * 3. Neither the name of Analog Devices, Inc. nor the names of its
19 * contributors may be used to endorse or promote products derived from this
20 * software without specific prior written permission.
21 *
22 * THIS SOFTWARE IS PROVIDED BY ANALOG DEVICES, INC. “AS IS” AND ANY EXPRESS OR
23 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
24 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
25 * EVENT SHALL ANALOG DEVICES, INC. BE LIABLE FOR ANY DIRECT, INDIRECT,
26 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
27 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
28 * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
29 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
30 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
31 * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32*******************************************************************************/
33#ifndef __LTP8800_H__
34#define __LTP8800_H__
35
36#include <stdint.h>
37#include <string.h>
38#include "no_os_util.h"
39#include "no_os_i2c.h"
40
41/* PMBus commands */
42#define LTP8800_PAGE 0x00
43#define LTP8800_OPERATION 0x01
44#define LTP8800_WRITE_PROTECT 0x10
45#define LTP8800_STORE_USER_ALL 0x15
46#define LTP8800_RESTORE_USER_ALL 0x16
47#define LTP8800_VOUT_MODE 0x20
48
49#define LTP8800_VOUT_COMMAND 0x21
50#define LTP8800_VOUT_SCALE_LOOP 0x29
51#define LTP8800_VOUT_SCALE_MONITOR 0x2A
52
53#define LTP8800_FREQUENCY_SWITCH 0x33
54#define LTP8800_VIN_ON 0x35
55#define LTP8800_VIN_OFF 0x36
56#define LTP8800_INTERLEAVE 0x37
57
58#define LTP8800_VIN_OV_FAULT_LIMIT 0x55
59#define LTP8800_VIN_UV_FAULT_LIMIT 0x59
60#define LTP8800_IIN_OC_FAULT_LIMIT 0x5B
61#define LTP8800_POUT_OP_FAULT_LIMIT 0x68
62
63#define LTP8800_STATUS_BYTE 0x78
64#define LTP8800_STATUS_WORD 0x79
65#define LTP8800_STATUS_VOUT 0x7A
66#define LTP8800_STATUS_IOUT 0x7B
67#define LTP8800_STATUS_INPUT 0x7C
68#define LTP8800_STATUS_TEMPERATURE 0x7D
69#define LTP8800_STATUS_CML 0x7E
70#define LTP8800_STATUS_OTHER 0x7F
71#define LTP8800_STATUS_MFR_SPECIFIC 0x80
72
73#define LTP8800_READ_VIN 0x88
74#define LTP8800_READ_IIN 0x89
75#define LTP8800_READ_VOUT 0x8B
76#define LTP8800_READ_IOUT 0x8C
77#define LTP8800_READ_TEMPERATURE_2 0x8E
78#define LTP8800_READ_TEMPERATURE_3 0x8F
79#define LTP8800_READ_DUTY_CYCLE 0x94
80#define LTP8800_READ_FREQUENCY 0x95
81#define LTP8800_READ_POUT 0x96
82
83#define LTP8800_REVISION 0x98
84#define LTP8800_MFR_ID 0x99
85#define LTP8800_MFR_MODEL 0x9A
86#define LTP8800_MFR_REVISION 0x9B
87#define LTP8800_MFR_SERIAL 0x9E
88#define LTP8800_IC_DEVICE_ID 0xAD
89#define LTP8800_IC_DEVICE_REV 0xAE
90
91#define LTP8800_EEPROM_PASSWORD 0xD5
92
93#define LTP8800_GO_CMD 0xFE00
94#define LTP8800_NM_DIGFILT_LF_GAIN 0xFE01
95#define LTP8800_NM_DIGFILT_ZERO 0xFE02
96#define LTP8800_NM_DIGFILT_POLE 0xFE03
97#define LTP8800_NM_DIGFILT_HF_GAIN 0xFE04
98#define LTP8800_SYNC 0xFE55
99
100/* PMBus-specific parameters */
101#define LTP8800_CRC_POLYNOMIAL 0x7
102#define LTP8800_VOUT_MODE_VAL_MSK NO_OS_GENMASK(4,0)
103
104/* LINEAR data format params */
105#define LTP8800_LIN11_MANTISSA_MAX 1023L
106#define LTP8800_LIN11_MANTISSA_MIN 511L
107#define LTP8800_LIN11_EXPONENT_MAX 15
108#define LTP8800_LIN11_EXPONENT_MIN -15
109#define LTP8800_LIN11_MANTISSA_MSK NO_OS_GENMASK(10,0)
110#define LTP8800_LIN11_EXPONENT_MSK NO_OS_GENMASK(15,11)
111#define LTP8800_LIN11_EXPONENT(x) ((int16_t)(x) >> 11)
112#define LTP8800_LIN11_MANTISSA(x) (((int16_t)((x & 0x7FF) << 5)) >> 5)
113#define LTP8800_LIN16_EXPONENT -14
114
115/* Extended commands constants */
116#define LTP8800_EXTENDED_COMMAND_PREFIX 0xFE
117#define LTP8800_EXTENDED_COMMAND_BEGIN 0xFE00
118#define LTP8800_COMMAND_LSB_MSK NO_OS_GENMASK(7, 0)
119#define LTP8800_COMMAND_MSB_MSK NO_OS_GENMASK(15, 8)
120
121/* Status types masks */
122#define LTP8800_STATUS_BYTE_TYPE_MSK 0x01
123#define LTP8800_STATUS_VOUT_TYPE_MSK 0x02
124#define LTP8800_STATUS_IOUT_TYPE_MSK 0x04
125#define LTP8800_STATUS_INPUT_TYPE_MSK 0x08
126#define LTP8800_STATUS_TEMP_TYPE_MSK 0x10
127#define LTP8800_STATUS_CML_TYPE_MSK 0x20
128#define LTP8800_STATUS_MFR_SPECIFIC_TYPE_MSK 0x40
129#define LTP8800_STATUS_WORD_TYPE_MSK 0x80
130#define LTP8800_STATUS_ALL_TYPE_MSK 0xFF
131
132/* LTP8800 configurable bits and masks */
133#define LTP8800_SYNC_ENABLE_BIT NO_OS_BIT(6)
134#define LTP8800_SYNC_LATCH_BIT NO_OS_BIT(6)
135#define LTP8800_WRITE_PROTECT_1_BIT NO_OS_BIT(7)
136#define LTP8800_WRITE_PROTECT_2_BIT NO_OS_BIT(6)
137#define LTP8800_WRITE_PROTECT_3_BIT NO_OS_BIT(5)
138#define LTP8800_INTERLEAVE_ORDER_MSK NO_OS_GENMASK(3, 0)
139
140/* LTP8800 device constants */
141#define LTP8800_IC_DEVICE_ID_VALUE {0x41, 0x55}
142#define LTP8800_MAX_INTERLEAVE_ORDER 0xF
143#define LTP8800_VOUT_COMMAND_MAX 1100
144#define LTP8800_VOUT_COMMAND_MIN 500
145#define LTP8800_VOUT_COMMAND_DEFAULT 0x3000
146#define LTP8800_EEPROM_PASSWORD_VALUE 0xFF
147#define LTP8800_EEPROM_LOCK_VALUE 0xAB
148
149/* LTP8800 device settings */
150#define LTP8800_STATE_ON 1
151#define LTP8800_STATE_OFF 0
152
164
171
183
188
200
213
215 uint16_t word;
216 uint8_t byte;
217 uint8_t vout;
218 uint8_t iout;
219 uint8_t input;
220 uint8_t temp;
221 uint8_t cml;
223};
224
225/* Initialize the device structure */
226int ltp8800_init(struct ltp8800_dev **device,
228
229/* Free or remove device instance */
230int ltp8800_remove(struct ltp8800_dev *dev);
231
232/* Send a PMBus command to the device */
233int ltp8800_send_byte(struct ltp8800_dev *dev, uint16_t cmd);
234
235/* Perform a PMBus read_byte operation */
236int ltp8800_read_byte(struct ltp8800_dev *dev, uint16_t cmd, uint8_t *data);
237
238/* Perform a PMBus write_byte operation */
239int ltp8800_write_byte(struct ltp8800_dev *dev, uint16_t cmd, uint8_t value);
240
241/* Perform a PMBus read_word operation */
242int ltp8800_read_word(struct ltp8800_dev *dev, uint16_t cmd, uint16_t *word);
243
244/* Perform a PMBus write_word operation */
245int ltp8800_write_word(struct ltp8800_dev *dev, uint16_t cmd, uint16_t word);
246
247/* Perform a PMBus read_word operation then perform conversion*/
248int ltp8800_read_word_data(struct ltp8800_dev *dev, uint16_t cmd, int *data);
249
250/* Perform conversion then perform a PMBus write_word operation */
251int ltp8800_write_word_data(struct ltp8800_dev *dev, uint16_t cmd, int data);
252
253/* Read a block of bytes */
254int ltp8800_read_block_data(struct ltp8800_dev *dev, uint16_t cmd,
255 uint8_t *data, size_t nbytes);
256
257/* Read specific value type */
258int ltp8800_read_value(struct ltp8800_dev *dev,
259 enum ltp8800_value_type value_type,
260 int *value);
261
262/* Read status */
263int ltp8800_read_status(struct ltp8800_dev *dev,
264 enum ltp8800_status_type status_type,
265 struct ltp8800_status *status);
266
267/* Set VOUT command */
268int ltp8800_vout_value(struct ltp8800_dev *dev, int vout_command);
269
270/* Set gain settings */
271int ltp8800_vout_settings(struct ltp8800_dev *dev,
272 enum ltp8800_vout_settings settings);
273
274/* Set VIN threshold when to start power conversion */
275int ltp8800_set_vin(struct ltp8800_dev *dev, int vin_on, int vin_off);
276
277/* Set fault/warning limit values */
279 enum ltp8800_limit_type limit,
280 int limit_val);
281
282/* Enable/Disable multi-device synchronization */
283int ltp8800_sync_config(struct ltp8800_dev *dev, bool enable);
284
285/* Set PolyPhase order */
286int ltp8800_interleave_order(struct ltp8800_dev *dev, uint8_t order);
287
288/* Program loop compensation */
290 uint8_t pole,
291 uint8_t zero,
292 uint8_t hf_gain,
293 uint8_t lf_gain);
294
295/* Set device state */
296int ltp8800_set_device_state(struct ltp8800_dev *dev, bool state);
297
298/* Store user settings to EEPROM */
300
301/* Restore user settings from EEPROM */
303
304#endif /* __LTP8800_H__ */
struct ad7616_init_param init_param
Definition ad7616_sdz.c:107
#define LTP8800_STATUS_TEMP_TYPE_MSK
Definition ltp8800.h:126
#define LTP8800_IIN_OC_FAULT_LIMIT
Definition ltp8800.h:60
#define LTP8800_VIN_OV_FAULT_LIMIT
Definition ltp8800.h:58
#define LTP8800_STATUS_ALL_TYPE_MSK
Definition ltp8800.h:130
ltp8800_status_type
Definition ltp8800.h:172
@ LTP8800_STATUS_IOUT_TYPE
Definition ltp8800.h:175
@ LTP8800_STATUS_WORD_TYPE
Definition ltp8800.h:180
@ LTP8800_STATUS_TEMP_TYPE
Definition ltp8800.h:177
@ LTP8800_STATUS_VOUT_TYPE
Definition ltp8800.h:174
@ LTP8800_STATUS_ALL_TYPE
Definition ltp8800.h:181
@ LTP8800_STATUS_INPUT_TYPE
Definition ltp8800.h:176
@ LTP8800_STATUS_BYTE_TYPE
Definition ltp8800.h:173
@ LTP8800_STATUS_MFR_SPECIFIC_TYPE
Definition ltp8800.h:179
@ LTP8800_STATUS_CML_TYPE
Definition ltp8800.h:178
int ltp8800_read_block_data(struct ltp8800_dev *dev, uint16_t cmd, uint8_t *data, size_t nbytes)
Perform a PMBus read block operation.
Definition ltp8800.c:651
int ltp8800_send_byte(struct ltp8800_dev *dev, uint16_t cmd)
Send a PMBus command to the device.
Definition ltp8800.c:439
int ltp8800_remove(struct ltp8800_dev *dev)
Free or remove device instance.
Definition ltp8800.c:404
ltp8800_limit_type
Definition ltp8800.h:165
@ LTP8800_POUT_OP_FAULT_LIMIT_TYPE
Definition ltp8800.h:169
@ LTP8800_VIN_UV_FAULT_LIMIT_TYPE
Definition ltp8800.h:167
@ LTP8800_IIN_OC_FAULT_LIMIT_TYPE
Definition ltp8800.h:168
@ LTP8800_VIN_OV_FAULT_LIMIT_TYPE
Definition ltp8800.h:166
#define LTP8800_VIN_UV_FAULT_LIMIT
Definition ltp8800.h:59
int ltp8800_write_word_data(struct ltp8800_dev *dev, uint16_t cmd, int data)
Converts value to register data and do PMBus write word operation.
Definition ltp8800.c:630
int ltp8800_init(struct ltp8800_dev **device, struct ltp8800_init_param *init_param)
Initialize the device structure.
Definition ltp8800.c:289
#define LTP8800_STATUS_IOUT_TYPE_MSK
Definition ltp8800.h:124
#define LTP8800_READ_IOUT
Definition ltp8800.h:76
int ltp8800_interleave_order(struct ltp8800_dev *dev, uint8_t order)
Set phase order for polyphase application.
Definition ltp8800.c:914
int ltp8800_set_device_state(struct ltp8800_dev *dev, bool state)
Set device state.
Definition ltp8800.c:978
ltp8800_vout_settings
Definition ltp8800.h:184
@ LTP8800_VOUT_SETTING_ADI_FACTORY
Definition ltp8800.h:185
@ LTP8800_VOUT_SETTING_UNITY
Definition ltp8800.h:186
int ltp8800_read_value(struct ltp8800_dev *dev, enum ltp8800_value_type value_type, int *value)
Read a value.
Definition ltp8800.c:710
#define LTP8800_STATUS_VOUT_TYPE_MSK
Definition ltp8800.h:123
int ltp8800_read_word(struct ltp8800_dev *dev, uint16_t cmd, uint16_t *word)
Perform a raw PMBus read word operation.
Definition ltp8800.c:536
#define LTP8800_STATUS_CML_TYPE_MSK
Definition ltp8800.h:127
int ltp8800_write_word(struct ltp8800_dev *dev, uint16_t cmd, uint16_t word)
Perform a raw PMBus write word operation.
Definition ltp8800.c:580
#define LTP8800_STATUS_BYTE_TYPE_MSK
Definition ltp8800.h:122
#define LTP8800_STATUS_INPUT_TYPE_MSK
Definition ltp8800.h:125
int ltp8800_loop_compensation(struct ltp8800_dev *dev, uint8_t pole, uint8_t zero, uint8_t hf_gain, uint8_t lf_gain)
Program loop compensation for regulator transient response.
Definition ltp8800.c:948
#define LTP8800_READ_VOUT
Definition ltp8800.h:75
int ltp8800_restore_user_settings(struct ltp8800_dev *dev)
Restore user settings.
Definition ltp8800.c:1015
ltp8800_value_type
Definition ltp8800.h:153
@ LTP8800_POUT
Definition ltp8800.h:162
@ LTP8800_REVERSE_DIODE_TEMP
Definition ltp8800.h:159
@ LTP8800_FREQUENCY
Definition ltp8800.h:161
@ LTP8800_DUTY_CYCLE
Definition ltp8800.h:160
@ LTP8800_FORWARD_DIODE_TEMP
Definition ltp8800.h:158
@ LTP8800_IIN
Definition ltp8800.h:155
@ LTP8800_VOUT
Definition ltp8800.h:156
@ LTP8800_VIN
Definition ltp8800.h:154
@ LTP8800_IOUT
Definition ltp8800.h:157
#define LTP8800_READ_TEMPERATURE_2
Definition ltp8800.h:77
int ltp8800_store_user_settings(struct ltp8800_dev *dev)
Store user settings to EEPROM.
Definition ltp8800.c:989
#define LTP8800_READ_FREQUENCY
Definition ltp8800.h:80
int ltp8800_read_status(struct ltp8800_dev *dev, enum ltp8800_status_type status_type, struct ltp8800_status *status)
Read statuses.
Definition ltp8800.c:730
#define LTP8800_POUT_OP_FAULT_LIMIT
Definition ltp8800.h:61
#define LTP8800_READ_VIN
Definition ltp8800.h:73
int ltp8800_sync_config(struct ltp8800_dev *dev, bool enable)
Enable or disable sync pin.
Definition ltp8800.c:887
#define LTP8800_READ_POUT
Definition ltp8800.h:81
int ltp8800_write_byte(struct ltp8800_dev *dev, uint16_t cmd, uint8_t value)
Perform a raw PMBus write byte operation.
Definition ltp8800.c:507
#define LTP8800_READ_DUTY_CYCLE
Definition ltp8800.h:79
#define LTP8800_STATUS_WORD_TYPE_MSK
Definition ltp8800.h:129
int ltp8800_set_fault_limit(struct ltp8800_dev *dev, enum ltp8800_limit_type limit, int limit_val)
Set overvalue and undervalue limits.
Definition ltp8800.c:873
#define LTP8800_READ_TEMPERATURE_3
Definition ltp8800.h:78
#define LTP8800_READ_IIN
Definition ltp8800.h:74
int ltp8800_set_vin(struct ltp8800_dev *dev, int vin_on, int vin_off)
Set input voltage window at which power conversion will proceed.
Definition ltp8800.c:846
#define LTP8800_STATUS_MFR_SPECIFIC_TYPE_MSK
Definition ltp8800.h:128
int ltp8800_vout_value(struct ltp8800_dev *dev, int vout_command)
Set output voltage command.
Definition ltp8800.c:802
int ltp8800_read_word_data(struct ltp8800_dev *dev, uint16_t cmd, int *data)
Perform a PMBus read word operation and converts to actual value.
Definition ltp8800.c:610
int ltp8800_read_byte(struct ltp8800_dev *dev, uint16_t cmd, uint8_t *data)
Perform a raw PMBus read byte operation.
Definition ltp8800.c:466
Header file of I2C Interface.
Header file of utility functions.
Definition ad9361_util.h:63
Definition ltp8800.h:189
bool crc_en
Definition ltp8800.h:197
struct no_os_gpio_desc * ctrl_desc
Definition ltp8800.h:192
struct no_os_gpio_desc * smbalert_desc
Definition ltp8800.h:191
struct no_os_i2c_desc * i2c_desc
Definition ltp8800.h:190
bool write_protect_en
Definition ltp8800.h:196
int lin16_exp
Definition ltp8800.h:195
uint8_t polyphase_order
Definition ltp8800.h:198
struct no_os_pwm_desc * ext_clk_desc
Definition ltp8800.h:193
Definition ltp8800.h:201
bool external_clk_en
Definition ltp8800.h:208
bool write_protect_en
Definition ltp8800.h:207
struct no_os_gpio_init_param * ctrl_param
Definition ltp8800.h:204
struct no_os_i2c_init_param * i2c_init
Definition ltp8800.h:202
bool crc_en
Definition ltp8800.h:210
struct no_os_gpio_init_param * smbalert_param
Definition ltp8800.h:203
bool sync_en
Definition ltp8800.h:209
struct no_os_pwm_init_param * ext_clk_param
Definition ltp8800.h:205
uint8_t polyphase_order
Definition ltp8800.h:211
Definition ltp8800.h:214
uint8_t vout
Definition ltp8800.h:217
uint8_t input
Definition ltp8800.h:219
uint8_t cml
Definition ltp8800.h:221
uint8_t mfr_specific
Definition ltp8800.h:222
uint8_t temp
Definition ltp8800.h:220
uint16_t word
Definition ltp8800.h:215
uint8_t iout
Definition ltp8800.h:218
uint8_t byte
Definition ltp8800.h:216
Structure holding the GPIO descriptor.
Definition no_os_gpio.h:84
Structure holding the parameters for GPIO initialization.
Definition no_os_gpio.h:67
Structure holding I2C address descriptor.
Definition no_os_i2c.h:89
Structure holding the parameters for I2C initialization.
Definition no_os_i2c.h:52
Structure representing an PWM generator device.
Definition no_os_pwm.h:83
Structure containing the init parameters needed by the PWM generator.
Definition no_os_pwm.h:56