From 43c4356e43d544ffeac1839ed2d64f5118eea3eb Mon Sep 17 00:00:00 2001 From: ivangilmercano Date: Thu, 28 Nov 2024 15:11:34 +0800 Subject: [PATCH 1/4] Adding driver support for ADP105x - ADP1051 Signed-off-by: ivangilmercano --- drivers/power/adp1050/adp1050.c | 192 ++++++++++++++++++++++++-- drivers/power/adp1050/adp1050.h | 233 +++++++++++++++++++++++++++----- 2 files changed, 381 insertions(+), 44 deletions(-) diff --git a/drivers/power/adp1050/adp1050.c b/drivers/power/adp1050/adp1050.c index 872d3b34617..5c20a829283 100644 --- a/drivers/power/adp1050/adp1050.c +++ b/drivers/power/adp1050/adp1050.c @@ -155,6 +155,7 @@ int adp1050_read_status(struct adp1050_desc *desc, case ADP1050_STATUS_INPUT_TYPE: case ADP1050_STATUS_TEMPERATURE_TYPE: case ADP1050_STATUS_CML_TYPE: + case ADP1051_STATUS_IOUT_TYPE: ret = adp1050_read(desc, (uint16_t)status, &read_byte, 1); if (ret) return ret; @@ -364,6 +365,30 @@ int adp1050_pwm_duty_cycle(struct adp1050_desc *desc, uint16_t pulse_width, reg_redge = ADP1050_OUTB_RISING_EDGE_TIMING; reg_lsb = ADP1050_OUTB_RISING_FALLING_TIMING_LSB; + break; + case ADP1051_OUTC: + fedge_msb = no_os_field_get(ADP1050_EDGE_MSB_MASK, pulse_width + pulse_start); + redge_msb = no_os_field_get(ADP1050_EDGE_MSB_MASK, pulse_start); + lsb = no_os_field_get(ADP1050_FALLING_EDGE_LSB_MASK, + pulse_width + pulse_start) | no_os_field_get(ADP1050_RISING_EDGE_LSB_MASK, + pulse_start); + + reg_fedge = ADP1051_OUTC_FALLING_EDGE_TIMING; + reg_redge = ADP1051_OUTC_RISING_EDGE_TIMING; + reg_lsb = ADP1051_OUTC_RISING_FALLING_TIMING_LSB; + + break; + case ADP1051_OUTD: + fedge_msb = no_os_field_get(ADP1050_EDGE_MSB_MASK, pulse_width + pulse_start); + redge_msb = no_os_field_get(ADP1050_EDGE_MSB_MASK, pulse_start); + lsb = no_os_field_get(ADP1050_FALLING_EDGE_LSB_MASK, + pulse_width + pulse_start) | no_os_field_get(ADP1050_RISING_EDGE_LSB_MASK, + pulse_start); + + reg_fedge = ADP1051_OUTD_FALLING_EDGE_TIMING; + reg_redge = ADP1051_OUTD_RISING_EDGE_TIMING; + reg_lsb = ADP1051_OUTD_RISING_FALLING_TIMING_LSB; + break; case ADP1050_SR1: redge_msb = no_os_field_get(ADP1050_EDGE_MSB_MASK, pulse_width + pulse_start); @@ -421,17 +446,17 @@ int adp1050_pwm_modulation(struct adp1050_desc *desc, enum adp1050_mod mod, uint32_t mask, reg; switch (mod) { - case ADP1050_OUTA_SR1_FALLING_MOD: - mask = ADP1050_OUTA_SR1_FALLING_MOD_MASK; + case ADP1050_OUTA_OUTC_SR1_FALLING_MOD: + mask = ADP1050_OUTA_OUTC_SR1_FALLING_MOD_MASK; break; - case ADP1050_OUTA_SR1_RISING_MOD: - mask = ADP1050_OUTA_SR1_RISING_MOD_MASK; + case ADP1050_OUTA_OUTC_SR1_RISING_MOD: + mask = ADP1050_OUTA_OUTC_SR1_RISING_MOD_MASK; break; - case ADP1050_OUTB_SR2_FALLING_MOD: - mask = ADP1050_OUTB_SR2_FALLING_MOD_MASK; + case ADP1050_OUTB_OUTD_SR2_FALLING_MOD: + mask = ADP1050_OUTB_OUTD_SR2_FALLING_MOD_MASK; break; - case ADP1050_OUTB_SR2_RISING_MOD: - mask = ADP1050_OUTB_SR2_RISING_MOD_MASK; + case ADP1050_OUTB_OUTD_SR2_RISING_MOD: + mask = ADP1050_OUTB_OUTD_SR2_RISING_MOD_MASK; break; default: return -EINVAL; @@ -442,6 +467,10 @@ int adp1050_pwm_modulation(struct adp1050_desc *desc, enum adp1050_mod mod, case ADP1050_OUTB: reg = ADP1050_OUTA_OUTB_MODULATION_SETTINGS; break; + case ADP1050_OUTC: + case ADP1050_OUTD: + reg = ADP1051_OUTC_OUTD_MODULATION_SETTINGS; + break; case ADP1050_SR1: case ADP1050_SR2: reg = ADP1050_SR1_SR2_MODULATION_SETTINGS; @@ -530,6 +559,20 @@ int adp1050_set_vin(struct adp1050_desc *desc, int16_t mantissa, int8_t exp, val, 2); } +/** + * @brief Set ADP1051 vout droop for setting the rate of output voltage and current + * @param desc - ADP1050 device descriptor + * @param mantissa - Mantissa value to be transmitted, 7 bit twos complment + * @return 0 in case of success, negative error code otherwise +*/ +int adp1051_set_vout_droop(struct adp1050_desc *desc, uint16_t mantissa) +{ + if(mantissa > ADP1051_VDROOP_MAXVAL) + return -EINVAL; + + return adp1050_write(desc, ADP1051_VOUT_DROOP, mantissa, 2); +} + /** * @brief Set current limit fast fault for overcurrent protection and current * limit cycle-by-cycle reference @@ -578,6 +621,96 @@ int adp1050_set_cs1_settings(struct adp1050_desc *desc, return adp1050_write(desc, ADP1050_CS1_CBC_CURR_LIM_SETTINGS, val, 1); } +/** + * @brief Set light load and deep light load common setting + * @param desc - ADP1050 device descriptor + * @param drooping - avg speed for drooping contrl + * @param avg_speed - light load and deep light load avg speed + * @param hysteresis - light load and deep light load hysteresis + * @return 0 in case of succes, negative error code otherwise. +*/ +int adp1051_llm_dllm_comm_setting(struct adp1050_desc *desc, + enum adp1051_llm_dlm_drooping drooping, + enum adp1051_llm_dlm_avg_speed avg_speed, + enum adp1051_llm_dlm_hysteresis hysteresis) +{ + uint16_t val; + + val = no_os_field_prep(ADP1051_LLM_DLM_DROOPING_MASK, drooping) | + no_os_field_prep(ADP1051_LLM_DLM_AVG_SPEED_MASK, avg_speed) | + no_os_field_prep(ADP1051_LLM_DLM_HYST_MASK, hysteresis); + + return adp1050_write(desc, ADP1051_LLM_DLM_SET, val, 1); +} + +/** + * @brief Set light load and deep light load + * @param desc - ADP1050 device descriptor + * @param llm_debounce - cs3_oc_fault flag debounce + * @param thresh - light load and deep light load threshold + * @param light en - 1 to enable light load mode + * @return 0 in case of succes, negative error code otherwise. +*/ +int adp1051_llm_dllm_setting(struct adp1050_desc *desc, + enum adp1051_cs2_lightload_debounce llm_debounce, + enum adp1051_llm_dlm_thresh thresh, + bool light_en) +{ + int16_t val; + + if (light_en) + val = no_os_field_prep(ADP1051_LLM_DEBOUNCE_MASK, 1) | + no_os_field_prep(ADP1051_LLM_DEBOUNCE_MASK, llm_debounce) | + no_os_field_prep(ADP1051_LLM_THRESH_MASK, thresh); + + return adp1050_write(desc, ADP1051_CS2_LIGHT_THRESH, val, 1); + + if (!light_en) + val = no_os_field_prep(ADP1051_LLM_THRESH_MASK, thresh); + + return adp1050_write(desc, ADP1051_CS2_LIGHT_THRESH, val, 1); +} + +/** + * @brief Set the IOUT calibration gain for ADP1051 + * @param desc - ADP1050 device descriptor + * @param mantissa - Mantissa value to be transmitted, 11 bit twos complement. + * @param exp - Exponent value to be transmitted, 5 bit twos complement. + * added support for ADP1051 - usually used in the read_iout command + */ +int adp1051_set_iout_cal_gain(struct adp1050_desc *desc, int16_t mantissa, + int8_t exp) +{ + uint16_t val; + + if (mantissa > ADP1050_MANT_MAX || exp > ADP1050_EXP_MAX) + return -EINVAL; + + val = no_os_field_prep(ADP1050_EXP_MASK, exp) | mantissa; + + return adp1050_write(desc, ADP1051_IOUT_CAL_GAIN, val, 2); +} + +/** + * @brief Set the IOUT OC fault limit for ADP1051 + * @param desc - ADP1050 device descriptor + * @param mantissa - Mantissa value to be transmitted, 11 bit twos complement. + * @param exp - Exponent value to be transmitted, 5 bit twos complement. + * added support for ADP1051 - + */ +int adp1051_set_iout_oc_fault_limit(struct adp1050_desc *desc, int16_t mantissa, + int8_t exp) +{ + uint16_t val; + + if (mantissa > ADP1050_MANT_MAX || exp > ADP1050_EXP_MAX) + return -EINVAL; + + val = no_os_field_prep(ADP1050_EXP_MASK, exp) | mantissa; + + return adp1050_write(desc, ADP1051_IOUT_OC_FAULT_LIMIT, val, 2); +} + /** * @brief Set requested ADP1050 channel in Open Loop operation mode. * @param desc - ADP1050 device descriptor. @@ -591,7 +724,8 @@ int adp1050_set_open_loop(struct adp1050_desc *desc, uint8_t rising_edge, { int ret; - if ((chan == ADP1050_OUTA || chan == ADP1050_OUTB) + if ((chan == ADP1050_OUTA || chan == ADP1050_OUTB || chan == ADP1051_OUTC + || chan == ADP1051_OUTD) && falling_edge < rising_edge) return -EINVAL; @@ -610,6 +744,8 @@ int adp1050_set_open_loop(struct adp1050_desc *desc, uint8_t rising_edge, switch (chan) { case ADP1050_OUTA: case ADP1050_OUTB: + case ADP1051_OUTC: + case ADP1051_OUTD: ret = adp1050_pwm_duty_cycle(desc, falling_edge, falling_edge - rising_edge, chan); break; @@ -634,7 +770,8 @@ int adp1050_set_open_loop(struct adp1050_desc *desc, uint8_t rising_edge, if (ret) return ret; - if (chan == ADP1050_OUTA || chan == ADP1050_OUTB) { + if (chan == ADP1050_OUTA || chan == ADP1050_OUTB || chan == ADP1051_OUTC + || chan == ADP1051_OUTD) { ret = adp1050_write(desc, ADP1050_SOFT_START_SETTING_OL, ADP1050_OL_SS_64_CYCLES, 1); if (ret) @@ -773,8 +910,8 @@ int adp1050_set_flgi_response(struct adp1050_desc *desc, * @param hf - Normal mode high filter gain settings. * @return 0 in case of succes, negative error code otherwise */ -int adp1050_filter(struct adp1050_desc *desc, uint8_t zero, uint8_t pole, - uint8_t lf, uint8_t hf) +int adp1050_nfilter(struct adp1050_desc *desc, uint8_t zero, uint8_t pole, + uint8_t lf, uint8_t hf) { int ret; @@ -793,6 +930,35 @@ int adp1050_filter(struct adp1050_desc *desc, uint8_t zero, uint8_t pole, return adp1050_write(desc, ADP1050_NORMAL_MODE_COMP_HIGH_FREQ, hf, 1); } +/** + * @brief Adjust filter settings of the light mode compensator + * @param desc - ADP1050 device descriptor + * @param zero - light mode zero settings. + * @param pole - light mode pole settings. + * @param lf - light mode low filter gain settings. + * @param hf - light mode high filter gain settings. + * @return 0 in case of succes, negative error code otherwise +*/ +int adp1050_lfilter(struct adp1050_desc *desc, uint8_t zero, uint8_t pole, + uint8_t lf, uint8_t hf) +{ + int ret; + + ret = adp1050_write(desc, ADP1051_LIGHT_MOD_COMP_LOW_FREQ, lf, 1); + if (ret) + return ret; + + ret = adp1050_write(desc, ADP1051_LIGHT_MODE_COMP_ZERO, zero, 1); + if (ret) + return ret; + + ret = adp1050_write(desc, ADP1051_LIGHT_MODE_COMP_POLE, pole, 1); + if (ret) + return ret; + + return adp1050_write(desc, ADP1051_LIGHTL_MODE_COMP_HIGH_FREQ, hf, 1); +} + /** * @brief Trim IIN(CS1 pin)/VIN(VF pin)/VOUT(VS pin). * @param desc - ADP1050 device descriptor @@ -1184,4 +1350,4 @@ int adp1050_remove(struct adp1050_desc *desc) no_os_free(desc); return 0; -} +} \ No newline at end of file diff --git a/drivers/power/adp1050/adp1050.h b/drivers/power/adp1050/adp1050.h index d5fd9b8fac2..ec648b536aa 100644 --- a/drivers/power/adp1050/adp1050.h +++ b/drivers/power/adp1050/adp1050.h @@ -33,6 +33,10 @@ #ifndef __ADP_1050_H__ #define __ADP_1050_H__ + +/******************************************************************************/ +/***************************** Include Files **********************************/ +/******************************************************************************/ #include #include #include @@ -42,6 +46,9 @@ #include "no_os_util.h" #include "no_os_units.h" +/*****************************************************************************/ +/************************** ADP1050 Constants ********************************/ +/*****************************************************************************/ #define ADP1050_EXTENDED_COMMAND 0xFF #define ADP1050_WRITE_BYTE_MAX_VAL 0xFF @@ -83,6 +90,8 @@ #define ADP1050_EXP_MASK NO_OS_GENMASK(15, 11) #define ADP1050_MANT_MASK NO_OS_GENMASK(10, 0) +#define ADP1051_VDROOP_MAXVAL 0xFF + #define ADP1050_VOUT_EXP_MASK NO_OS_GENMASK(4, 0) #define ADP1050_VOUT_GO_COMMAND 0x06 #define ADP1050_VOUT_OFF 0x00 @@ -106,13 +115,22 @@ #define ADP1050_OUTA_OL_ENABLE NO_OS_BIT(0) #define ADP1050_OUTB_OL_ENABLE NO_OS_BIT(1) +#define ADP1051_OUTC_OL_ENABLE NO_OS_BIT(2) +#define ADP1051_OUTD_OL_ENABLE NO_OS_BIT(3) #define ADP1050_SR1_OL_ENABLE NO_OS_BIT(4) #define ADP1050_SR2_OL_ENABLE NO_OS_BIT(5) -#define ADP1050_OUTB_SR2_RISING_MOD_MASK NO_OS_GENMASK(7, 6) -#define ADP1050_OUTB_SR2_FALLING_MOD_MASK NO_OS_GENMASK(5, 4) -#define ADP1050_OUTA_SR1_RISING_MOD_MASK NO_OS_GENMASK(3, 2) -#define ADP1050_OUTA_SR1_FALLING_MOD_MASK NO_OS_GENMASK(1, 0) +#define ADP1050_OUTB_OUTD_SR2_RISING_MOD_MASK NO_OS_GENMASK(7, 6) +#define ADP1051_OUTD_SR2_RISING_MOD_MASK NO_OS_GENMASK(7, 6) + +#define ADP1050_OUTB_OUTD_SR2_FALLING_MOD_MASK NO_OS_GENMASK(5, 4) +#define ADP1051_OUTD_SR2_FALLING_MOD_MASK NO_OS_GENMASK(5 ,4) + +#define ADP1050_OUTA_OUTC_SR1_RISING_MOD_MASK NO_OS_GENMASK(3, 2) +#define ADP1051_OUTC_SR1_RISING_MOD_MASK NO_OS_GENMASK(3, 2) + +#define ADP1050_OUTA_OUTC_SR1_FALLING_MOD_MASK NO_OS_GENMASK(1, 0) +#define ADP1051_OUTC_SR1_FALLING_MOD_MASK NO_OS_GENMASK(1, 0) #define ADP1050_POSITIVE_MOD_SIGN 0x02 #define ADP1050_NEGATIVE_MOD_SIGN 0x03 @@ -127,6 +145,7 @@ #define ADP1050_FREQ_SYNC_ON 0x48 #define ADP1050_FREQ_SYNC_OFF 0x49 + #define ADP1050_MAX_PERIOD_INTEGER(x) ((1000 / (x)) * 1000) #define ADP1050_MAX_PERIOD_FLOAT(x) ((1000 / (((x) - 0xF800) / 2)) * 1000) #define ADP1050_FLOAT_FREQ_MASK NO_OS_BIT(15) @@ -158,6 +177,14 @@ #define ADP1050_VS_MAX_INIT_VAL 0xFF #define ADP1050_VS_INIT_MASK NO_OS_GENMASK(14, 0) +#define ADP1051_LLM_DLM_DROOPING_MASK NO_OS_GENMASK(7, 6) +#define ADP1051_LLM_DLM_AVG_SPEED_MASK NO_OS_GENMASK(5, 4) +#define ADP1051_LLM_DLM_HYST_MASK NO_OS_GENMASK(3, 2) + +#define ADP1051_LLM_DEBOUNCE_MASK NO_OS_GENMASK(6, 5) +#define ADP1051_LLM_THRESH_MASK NO_OS_GENMASK(3, 0) +#define ADP1051_LLM_ENABLE_MASK NO_OS_BIT(4) + /* PMBus Addresses */ #define ADP1050_PMBUS_10KOHM_ADDRESS 0x70 #define ADP1050_PMBUS_31KOHM_ADDRESS 0x71 @@ -189,6 +216,9 @@ #define ADP1050_TON_RISE_100MS 0x0064 /* PMBus COMMAND SET */ +/*****************************************************************************/ +/************************** ADP1050 Registers ********************************/ +/*****************************************************************************/ #define ADP1050_OPERATION 0x01 #define ADP1050_ON_OFF_CONFIG 0x02 #define ADP1050_CLEAR_FAULTS 0x03 @@ -205,15 +235,20 @@ #define ADP1050_VOUT_MARGIN_HIGH 0x25 #define ADP1050_VOUT_MARGIN_LOW 0x26 #define ADP1050_VOUT_TRANSITION_RATE 0x27 +#define ADP1051_VOUT_DROOP 0x28 #define ADP1050_VOUT_SCALE_LOOP 0x29 #define ADP1050_VOUT_SCALE_MONITOR 0x2A #define ADP1050_FREQUENCY_SWITCH 0x33 #define ADP1050_VIN_ON 0x35 #define ADP1050_VIN_OFF 0x36 +#define ADP1051_IOUT_CAL_GAIN 0x38 #define ADP1050_VOUT_OV_FAULT_LIMIT 0x40 #define ADP1050_VOUT_OV_FAULT_RESPONSE 0x41 #define ADP1050_VOUT_UV_FAULT_LIMIT 0x44 #define ADP1050_VOUT_UV_FAULT_RESPONSE 0x45 +#define ADP1051_IOUT_OC_FAULT_LIMIT 0x46 +#define ADP1051_IOUT_OC_FAULT_RES 0x47 +#define ADP1051_IOUT_OC_LV_FAULT_LIMIT 0x48 #define ADP1050_OT_FAULT_LIMIT 0x4F #define ADP1050_OT_FAULT_RESPONSE 0x50 #define ADP1050_POWER_GOOD_ON 0x5E @@ -224,12 +259,14 @@ #define ADP1050_STATUS_BYTE 0x78 #define ADP1050_STATUS_WORD 0x79 #define ADP1050_STATUS_VOUT 0x7A +#define ADP1051_STATUS_IOUT 0x7B #define ADP1050_STATUS_INPUT 0x7C #define ADP1050_STATUS_TEMPERATURE 0x7D #define ADP1050_STATUS_CML 0x7E #define ADP1050_READ_VIN 0x88 #define ADP1050_READ_IIN 0x89 #define ADP1050_READ_VOUT 0x8B +#define ADP1051_READ_IOUT 0x8C #define ADP1050_READ_TEMPERATURE 0x8D #define ADP1050_READ_DUTY_CYCLE 0x94 #define ADP1050_READ_FREQUENCY 0x95 @@ -297,11 +334,15 @@ /* Current Sense and Limit Setting Registers */ #define ADP1050_CS1_GAIN_TRIM 0xFE14 -#define ADP1050_CS3_OC_DEBOUNCE 0xFE19 +#define ADP1051_CS2_GAIN_TRIM 0xFE15 +#define ADP1051_CS2_DIG_OFFSET_TRIM 0xFE16 +#define ADP1051_CS2_ANA_TRIM 0xFE17 +#define ADP1051_CS2_LIGHT_THRESH 0xFE19 #define ADP1050_IIN_OC_FAST_FAULT_LIMIT 0xFE1A #define ADP1050_CS1_CBC_CURR_LIM_REF 0xFE1B +#define ADP1051_PWM_OUT_DIS_DLM 0xFE1C #define ADP1050_MATCHED_CBC_CURR_LIM_SETTINGS 0xFE1D -#define ADP1050_SR1_SR2_RESPONSE_CBC_CURR_LIM 0xFE1E +#define ADP1051_LLM_DLM_SET 0xFE1E #define ADP1050_CS1_CBC_CURR_LIM_SETTINGS 0xFE1F /* Voltage Sense and Limit Setting Registers */ @@ -328,6 +369,10 @@ #define ADP1050_PWM_180_PHASE_SHIFT_SETTINGS 0xFE3B #define ADP1050_MODULATION_LIMIT 0xFE3C #define ADP1050_FEEDFORWARD_SS_FILTER_GAIN 0xFE3D +#define ADP1051_LIGHT_MOD_COMP_LOW_FREQ 0xFE34 +#define ADP1051_LIGHT_MODE_COMP_ZERO 0xFE35 +#define ADP1051_LIGHT_MODE_COMP_POLE 0xFE36 +#define ADP1051_LIGHTL_MODE_COMP_HIGH_FREQ 0xFE37 /* PWM Outputs Timing Registers */ #define ADP1050_OUTA_RISING_EDGE_TIMING 0xFE3E @@ -345,16 +390,33 @@ #define ADP1050_OUTA_OUTB_MODULATION_SETTINGS 0xFE50 #define ADP1050_SR1_SR2_MODULATION_SETTINGS 0xFE52 #define ADP1050_PWM_OUTPUT_DISABLE 0xFE53 +#define ADP1051_OUTC_RISING_EDGE_TIMING 0xFE44 +#define ADP1051_OUTC_FALLING_EDGE_TIMING 0xFE45 +#define ADP1051_OUTC_RISING_FALLING_TIMING_LSB 0xFE46 +#define ADP1051_OUTD_RISING_EDGE_TIMING 0xFE47 +#define ADP1051_OUTD_FALLING_EDGE_TIMING 0xFE48 +#define ADP1051_OUTD_RISING_FALLING_TIMING_LSB 0xFE49 +#define ADP1051_OUTC_OUTD_MODULATION_SETTINGS 0xFE51 /* Volt-Second Balance Control Registers */ #define ADP1050_VS_BAL_CTRL_GENERAL_SETTINGS 0xFE54 #define ADP1050_VS_BAL_CTRL_OUTA_OUTB 0xFE55 #define ADP1050_VS_BAL_CTRL_SR1_SR2 0xFE57 +#define ADP1051_VS_BAL_CTRL_OUTC_OUTD 0xFE56 /* Duty Cycle Reading Setting Registers */ #define ADP1050_DUTY_CYCLE_READING_SETTINGS 0xFE58 #define ADP1050_INPUT_VOLTAGE_COMP_MULT 0xFE59 +/* Adaptive Dead Time Compensation Registers */ +#define ADP1051_ADAPTIVE_DTIME_TRESH 0xFE5A +#define ADP1051_OUTA_DTIME 0xFE5B +#define ADP1051_OUTB_DTIME 0xFE5C +#define ADP1051_OUTC_DTIME 0xFE5D +#define ADP1051_OUTD_DTIME 0xFE5E +#define ADP1051_SR1_DTIME 0xFE5F +#define ADP1051_SR2_DTIME 0xFE60 + /* Other Setting Registers */ #define ADP1050_GO_COMMANDS 0xFE61 #define ADP1050_CUSTOMIZED_REGISTERS 0xFE62 @@ -368,6 +430,9 @@ #define ADP1050_MOD_FLAG_OVP_SELECTION 0xFE6C #define ADP1050_OUTA_OUTB_ADJ_REF_SYNCH 0xFE6D #define ADP1050_SR1_SR2_ADJ_REF_SYNCH 0xFE6F +#define ADP1051_ADAPTIVE_DTIME_COMP_CONFIG 0xFE66 +#define ADP1051_OFFSET_SR1_SR2 0xFE68 +#define ADP1051_OUTC_OUTD_ADJ_REF_SYNC 0xFE6E /* Manufacturer Specific Fault Flag Registers */ #define ADP1050_FLAG_REGISTER1 0xFEA0 @@ -386,6 +451,7 @@ #define ADP1050_VF_VALUE 0xFEAC #define ADP1050_DUTY_CYCLE_VALUE 0xFEAD #define ADP1050_INPUT_POWER_VALUE 0xFEAE +#define ADP1051_OUTPUT_POWER_VALUE 0xFEAF enum adp1050_loop { ADP1050_CLOSE_LOOP, @@ -395,16 +461,18 @@ enum adp1050_loop { enum adp1050_channel { ADP1050_OUTA, ADP1050_OUTB, + ADP1051_OUTC, + ADP1051_OUTD, ADP1050_SR1, ADP1050_SR2, ADP1050_DISABLE_ALL }; enum adp1050_mod { - ADP1050_OUTA_SR1_FALLING_MOD = NO_OS_BIT(1), - ADP1050_OUTA_SR1_RISING_MOD = NO_OS_BIT(3), - ADP1050_OUTB_SR2_FALLING_MOD = NO_OS_BIT(5), - ADP1050_OUTB_SR2_RISING_MOD = NO_OS_BIT(7), + ADP1050_OUTA_OUTC_SR1_FALLING_MOD = NO_OS_BIT(1), + ADP1050_OUTA_OUTC_SR1_RISING_MOD = NO_OS_BIT(3), + ADP1050_OUTB_OUTD_SR2_FALLING_MOD = NO_OS_BIT(5), + ADP1050_OUTB_OUTD_SR2_RISING_MOD = NO_OS_BIT(7), }; enum adp1050_pass_type { @@ -421,42 +489,63 @@ enum adp1050_freq { ADP1050_71KHZ = 0x0047, ADP1050_78KHZ = 0x004E, ADP1050_87KHZ = 0x0057, + ADP1050_97_5KHZ = 0xF8C3, ADP1050_104KHZ = 0x0068, + ADP1050_111_5KHZ = 0xF8DF, ADP1050_120KHZ = 0x0078, ADP1050_130KHZ = 0x0082, ADP1050_136KHZ = 0x0088, ADP1050_142KHZ = 0x008E, ADP1050_149KHZ = 0x0095, - ADP1050_184KHZ = 0x00B8, - ADP1050_223KHZ = 0x00DF, - ADP1050_250KHZ = 0x00FA, - ADP1050_284KHZ = 0x011C, - ADP1050_329KHZ = 0x0149, - ADP1050_338KHZ = 0x0152, - ADP1050_347KHZ = 0x015B, - ADP1050_357KHZ = 0x0165, - ADP1050_379KHZ = 0x017B, - ADP1050_397KHZ = 0x018D, - ADP1050_403KHZ = 0x0193, - ADP1050_410KHZ = 0x019A, - ADP1050_97_5KHZ = 0xF8C3, - ADP1050_111_5KHZ = 0xF8DF, ADP1050_156_5KHZ = 0xF939, ADP1050_164_5KHZ = 0xF949, ADP1050_173_5KHZ = 0xF95B, + ADP1050_184KHZ = 0x00B8, ADP1050_195_5KHZ = 0xF987, ADP1050_201_5KHZ = 0xF993, ADP1050_208_5KHZ = 0xF9A1, ADP1050_215_5KHZ = 0xF9AF, + ADP1050_223KHZ = 0x00DF, ADP1050_231_5KHZ = 0xF9CF, ADP1050_240_5KHZ = 0xF9E1, + ADP1050_250KHZ = 0x00FA, ADP1050_260_5KHZ = 0xFA09, ADP1050_271_5KHZ = 0xFA1F, + ADP1050_284KHZ = 0x011C, ADP1050_297_5KHZ = 0xFA53, ADP1050_312_5KHZ = 0xFA71, ADP1050_320_5KHZ = 0xFA81, + ADP1050_329KHZ = 0x0149, + ADP1050_338KHZ = 0x0152, + ADP1050_347KHZ = 0x015B, + ADP1050_357KHZ = 0x0165, ADP1050_367_5KHZ = 0xFADF, + ADP1050_379KHZ = 0x017B, ADP1050_390_5KHZ = 0xFB0D, + ADP1050_397KHZ = 0x018D, + ADP1050_403KHZ = 0x0193, + ADP1050_410KHZ = 0x019A, + ADP1050_416_5KHZ = 0xFB41, + ADP1050_426_5KHZ = 0xFB4F, + ADP1050_431KHZ = 0x1AF, + ADP1050_438_5KHZ = 0xFB6D, + ADP1050_446_5KHZ = 0xFB7D, + ADP1050_454_5KHZ = 0xFB8D, + ADP1050_463KHZ = 0x01CF, + ADP1050_472KHZ = 0x01D8, + ADP1050_481KHZ = 0x01E1, + ADP1050_490KHZ = 0x1EA, + ADP1050_500KHZ = 0x1F4, + ADP1050_510KHZ = 0x01FE, + ADP1050_520KHZ = 0x0208, + ADP1050_531KHZ = 0x0213, + ADP1050_543KHZ = 0x021F, + ADP1050_556KHZ = 0x022C, + ADP1050_568KHZ = 0x0238, + ADP1050_581KHZ = 0x0245, + ADP1050_595KHZ = 0x0253, + ADP1050_610KHZ = 0x0262, + ADP1050_625KHZ = 0x0271, }; enum adp1050_vout_tr { @@ -522,7 +611,8 @@ enum adp1050_value_type { ADP1050_IIN = ADP1050_READ_IIN, ADP1050_TEMP = ADP1050_READ_TEMPERATURE, ADP1050_DUTY_CYCLE = ADP1050_READ_DUTY_CYCLE, - ADP1050_FREQUENCY = ADP1050_READ_FREQUENCY + ADP1050_FREQUENCY = ADP1050_READ_FREQUENCY, + ADP1051_IOUT = ADP1051_READ_IOUT, }; enum adp1050_status_type { @@ -530,13 +620,66 @@ enum adp1050_status_type { ADP1050_STATUS_INPUT_TYPE = ADP1050_STATUS_INPUT, ADP1050_STATUS_WORD_TYPE = ADP1050_STATUS_WORD, ADP1050_STATUS_TEMPERATURE_TYPE = ADP1050_STATUS_TEMPERATURE, - ADP1050_STATUS_CML_TYPE = ADP1050_STATUS_CML + ADP1050_STATUS_CML_TYPE = ADP1050_STATUS_CML, + ADP1051_STATUS_IOUT_TYPE = ADP1051_STATUS_IOUT, }; enum adp1050_trim_type { ADP1050_CS1_IIN_TRIM, ADP1050_VS_VOUT_TRIM, - ADP1050_VF_VIN_TRIM + ADP1050_VF_VIN_TRIM, +}; + +enum adp105x_id { + ID_ADP1050, + ID_ADP1051, +}; + +enum adp1051_llm_dlm_drooping { + ADP1051_82US_7B, + ADP1051_164US_8B = 0x40, + ADP1051_328US_9B = 0x80, + ADP1051_656_10B = 0xC0, +}; + +enum adp1051_llm_dlm_avg_speed { + ADP1051_41US_6B_AVG, + ADP1051_82US_7B_AVG = 0x10, + ADP1051_164US_8B_AVG = 0x20, + ADP1051_328US_9B_AVG = 0x30, +}; + +enum adp1051_llm_dlm_hysteresis { + ADP1051_3LSB, + ADP1051_8LSB = 0x04, + ADP1051_12LSB = 0x08, + ADP1051_16LSB = 0x0C, +}; + +enum adp1051_cs2_lightload_debounce { + ADP1051_0MS, + ADP1051_10MS = 0x20, + ADP1051_20MS = 0x40, + ADP1051_200MS = 0x60, +}; + +enum adp1051_llm_dlm_thresh { + ADP1051_0mv, + ADP1051_093_7mv = 0x01, + ADP1051_187_15mv = 0x02, + ADP1051_281_22mv = 0x03, + ADP1051_375_30mv = 0x04, + ADP1051_468_37mv = 0x05, + ADP1051_562_45mv = 0x06, + ADP1051_656_52mv = 0x07, + ADP1051_750_60mv = 0x08, + ADP1051_843_67mv = 0x09, + ADP1051_937_75mv = 0x0A, + ADP1051_103_82mv = 0x0B, + ADP1051_112_90mv = 0x0C, + ADP1051_121_97mv = 0x0D, + ADP1051_131_105mv = 0x0E, + ADP1051_140_112mv = 0x0F, }; /** @@ -550,6 +693,7 @@ struct adp1050_init_param { struct no_os_gpio_init_param *ctrl_param; uint8_t on_off_config; bool ext_syni; + enum adp105x_id device_id; }; /** @@ -654,10 +798,6 @@ int adp1050_set_flgi_response(struct adp1050_desc *desc, enum adp1050_flgi_fault_response fault_response, enum adp1050_flgi_after_fault after_fault); -/** Set ADP1050's filter value. */ -int adp1050_filter(struct adp1050_desc *desc, uint8_t zero, uint8_t pole, - uint8_t lf, uint8_t hf); - /** Set ADP1050's trim. */ int adp1050_trim(struct adp1050_desc *desc, enum adp1050_trim_type trim_type, uint16_t vout_command, uint16_t vout_scale, uint16_t trim_val); @@ -684,4 +824,35 @@ int adp1050_init(struct adp1050_desc **desc, /** Remove resources allocated by the init function. */ int adp1050_remove(struct adp1050_desc *desc); +/** Light Load and Deep Light Load Mode Common Setting */ +int adp1051_llm_dllm_comm_setting(struct adp1050_desc *desc, + enum adp1051_llm_dlm_drooping drooping, + enum adp1051_llm_dlm_avg_speed avg_speed, + enum adp1051_llm_dlm_hysteresis hysteresis); + +/** Light Load and Deep Light Load Mode Setting */ +int adp1051_llm_dllm_setting(struct adp1050_desc *desc, + enum adp1051_cs2_lightload_debounce llm_debounce, + enum adp1051_llm_dlm_thresh thresh, + bool light_en); + +/** Sets IOUT calibration gain */ +int adp1051_set_iout_cal_gain(struct adp1050_desc *desc, int16_t mantissa, + int8_t exp); + +/** Sets VOUT drooping */ +int adp1051_set_vout_droop(struct adp1050_desc *desc, uint16_t mantissa); + +/** Sets IOUT OC fault limit */ +int adp1051_set_iout_oc_fault_limit(struct adp1050_desc *desc, int16_t mantissa, + int8_t exp); + +/** Adjust filter settings of the light mode compensator */ +int adp1050_lfilter(struct adp1050_desc *desc, uint8_t zero, uint8_t pole, + uint8_t lf, uint8_t hf); + +/** Adjust filter settings of the normal mode compensator */ +int adp1050_nfilter(struct adp1050_desc *desc, uint8_t zero, uint8_t pole, + uint8_t lf, uint8_t hf); + #endif /** __ADP_1050_H__ */ From 568b6dda08c141fc64813fd4cfaa01d6d586183d Mon Sep 17 00:00:00 2001 From: ivangilmercano Date: Thu, 28 Nov 2024 15:32:18 +0800 Subject: [PATCH 2/4] Adding project support for ADP105x - ADP1051 Signed-off-by: ivangilmercano --- drivers/power/adp1050/adp1050.c | 2 +- projects/adp1050/Makefile | 2 +- projects/adp1050/README.rst | 4 ++-- projects/adp1050/src/common/common_data.c | 1 + projects/adp1050/src/examples/basic/basic_example.c | 11 ++++++++++- projects/adp1050/src/examples/examples_src.mk | 4 ++-- projects/adp1050/src/platform/maxim/main.c | 2 +- projects/adp1050/src/platform/maxim/parameters.h | 4 ++-- 8 files changed, 20 insertions(+), 10 deletions(-) diff --git a/drivers/power/adp1050/adp1050.c b/drivers/power/adp1050/adp1050.c index 5c20a829283..f3f8d458205 100644 --- a/drivers/power/adp1050/adp1050.c +++ b/drivers/power/adp1050/adp1050.c @@ -1350,4 +1350,4 @@ int adp1050_remove(struct adp1050_desc *desc) no_os_free(desc); return 0; -} \ No newline at end of file +} diff --git a/projects/adp1050/Makefile b/projects/adp1050/Makefile index ea22697a376..03726052cb6 100644 --- a/projects/adp1050/Makefile +++ b/projects/adp1050/Makefile @@ -6,4 +6,4 @@ include ../../tools/scripts/generic_variables.mk include src.mk -include ../../tools/scripts/generic.mk +include ../../tools/scripts/generic.mk \ No newline at end of file diff --git a/projects/adp1050/README.rst b/projects/adp1050/README.rst index dc98850bcc8..79ae8be95b0 100644 --- a/projects/adp1050/README.rst +++ b/projects/adp1050/README.rst @@ -1,5 +1,5 @@ -ADP1050 no-OS Example Project -============================= +Evaluating the ADP1050 +====================== .. contents:: :depth: 3 diff --git a/projects/adp1050/src/common/common_data.c b/projects/adp1050/src/common/common_data.c index dcd49f60e99..1425893a84c 100644 --- a/projects/adp1050/src/common/common_data.c +++ b/projects/adp1050/src/common/common_data.c @@ -64,4 +64,5 @@ struct adp1050_init_param adp1050_ip = { .flgi_param = NULL, .syni_param = NULL, .on_off_config = ADP1050_ON_OFF_DEFAULT_CFG, + .device_id = ID_ADP1051, }; diff --git a/projects/adp1050/src/examples/basic/basic_example.c b/projects/adp1050/src/examples/basic/basic_example.c index 18a938a5d64..ac638ae8df0 100644 --- a/projects/adp1050/src/examples/basic/basic_example.c +++ b/projects/adp1050/src/examples/basic/basic_example.c @@ -113,9 +113,18 @@ int basic_example_main() if (ret) goto exit; + ret = adp1051_llm_dllm_comm_setting(adp1050_desc, ADP1051_82US_7B, + ADP1051_41US_6B_AVG, ADP1051_3LSB); + if (ret) + goto exit; + + ret = adp1051_llm_dllm_setting(adp1050_desc, ADP1051_0MS, ADP1051_0mv, 1); + if (ret) + goto exit; + exit: if (ret) pr_info("Error!\n"); adp1050_remove(adp1050_desc); return ret; -} +} \ No newline at end of file diff --git a/projects/adp1050/src/examples/examples_src.mk b/projects/adp1050/src/examples/examples_src.mk index cd3bef49b0a..830a887c024 100644 --- a/projects/adp1050/src/examples/examples_src.mk +++ b/projects/adp1050/src/examples/examples_src.mk @@ -1,12 +1,12 @@ ifeq (y,$(strip $(IIO_EXAMPLE))) IIOD=y -CFLAGS += -DIIO_EXAMPLE +CFLAGS += -DIIO_EXAMPLE=1 SRCS += $(PROJECT)/src/examples/iio_example/iio_example.c INCS += $(PROJECT)/src/examples/iio_example/iio_example.h endif ifeq (y,$(strip $(BASIC_EXAMPLE))) -CFLAGS += -DBASIC_EXAMPLE +CFLAGS += -DBASIC_EXAMPLE=1 SRCS += $(PROJECT)/src/examples/basic/basic_example.c INCS += $(PROJECT)/src/examples/basic/basic_example.h endif diff --git a/projects/adp1050/src/platform/maxim/main.c b/projects/adp1050/src/platform/maxim/main.c index 98a193918df..577aef29e8b 100644 --- a/projects/adp1050/src/platform/maxim/main.c +++ b/projects/adp1050/src/platform/maxim/main.c @@ -69,4 +69,4 @@ Please enable only one example and rebuild the project. #endif return ret; -} +} \ No newline at end of file diff --git a/projects/adp1050/src/platform/maxim/parameters.h b/projects/adp1050/src/platform/maxim/parameters.h index d6c0363ffa7..3d51ffba55e 100644 --- a/projects/adp1050/src/platform/maxim/parameters.h +++ b/projects/adp1050/src/platform/maxim/parameters.h @@ -43,13 +43,13 @@ #define INTC_DEVICE_ID 0 #endif -#define UART_DEVICE_ID 0 +#define UART_DEVICE_ID 2 #define UART_BAUDRATE 57600 #define UART_OPS &max_uart_ops #define UART_EXTRA &adp1050_uart_extra #define GPIO_PG_ALT_PORT 0 -#define GPIO_PG_ALT_PIN 24 +#define GPIO_PG_ALT_PIN 9 #define GPIO_OPS &max_gpio_ops #define GPIO_EXTRA &adp1050_pg_alt_extra From 6c7f85fd5ea9a1f32d10c8853222d821d1b6ebda Mon Sep 17 00:00:00 2001 From: ivangilmercano Date: Fri, 29 Nov 2024 12:20:25 +0800 Subject: [PATCH 3/4] Add README documentation for ADP105x - ADP1051 Signed-off-by: ivangilmercano --- drivers/power/adp1050/README.rst | 10 +++++++--- projects/adp1050/Makefile | 6 +++--- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/drivers/power/adp1050/README.rst b/drivers/power/adp1050/README.rst index 2d09163e12a..30691ec6253 100644 --- a/drivers/power/adp1050/README.rst +++ b/drivers/power/adp1050/README.rst @@ -5,15 +5,16 @@ Supported Devices ----------------- `ADP1050 `_ +`ADP1051 `_ Overview -------- -The ADP1050 is an advanced digital controller with a PMBus™ interface targeting +The ADP1050 and ADP1051 is an advanced digital controller with a PMBus™ interface targeting high density, high efficiency dc-to-dc power conversion. This controller implements voltage mode control with high speed, input voltage feedforward operation for enhanced transient and noise performance. -The ADP1050 has four programmable pulse-width modulation (PWM) outputs capable +ADP1050 and ADP1051 has four programmable pulse-width modulation (PWM) outputs capable of controlling most high efficiency power supply topologies, with the added control of synchronous rectification (SR). @@ -21,6 +22,7 @@ Applications ------------ ADP1050 +ADP1051 ------- * High density, isolated dc-to-dc power supplies @@ -181,6 +183,7 @@ ADP1050 Driver Initialization Example .flgi_param = NULL, .syni_param = NULL, .on_off_config = ADP1050_ON_OFF_DEFAULT_CFG, + .device_id = ID_ADP1051, }; ret = adp1050_init(&adp1050_desc, &adp1050_ip); if (ret) @@ -207,7 +210,7 @@ and each of them has a total of 2 channel attributes: Output Channel Attributes ------------------------- -OUTA/OUTB/SR1/SR2 channels are thee output channels of the ADP1050 IIO device +OUTA/OUTB/OUTC/SR1/SR2 channels are thee output channels of the ADP1050 IIO device and each of them has a total of 7 channel attributes: * ``enable - state of the channel`` @@ -245,6 +248,7 @@ Debug Attributes * ``status_temperature - TEMPERATURE status byte value of the device`` * ``status_cml - CML status byte value of the device`` * ``status_word - Status word value of the device`` +* ``status_iout - IOUT status byte value of the device`` ADP1050 IIO Driver Initialization Example ----------------------------------------- diff --git a/projects/adp1050/Makefile b/projects/adp1050/Makefile index 03726052cb6..fcee5523391 100644 --- a/projects/adp1050/Makefile +++ b/projects/adp1050/Makefile @@ -2,8 +2,8 @@ BASIC_EXAMPLE = n IIO_EXAMPLE = y -include ../../tools/scripts/generic_variables.mk + include ../../tools/scripts/generic_variables.mk -include src.mk + include src.mk -include ../../tools/scripts/generic.mk \ No newline at end of file + include ../../tools/scripts/generic.mk \ No newline at end of file From 1d6a400e0de0f5852fb5bd4345705163b80572ae Mon Sep 17 00:00:00 2001 From: ivangilmercano Date: Fri, 29 Nov 2024 12:28:53 +0800 Subject: [PATCH 4/4] Add README project documentation for ADP105x - ADP1051 Signed-off-by: ivangilmercano --- projects/adp1050/Makefile | 6 +++--- projects/adp1050/README.rst | 9 +++++---- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/projects/adp1050/Makefile b/projects/adp1050/Makefile index fcee5523391..03726052cb6 100644 --- a/projects/adp1050/Makefile +++ b/projects/adp1050/Makefile @@ -2,8 +2,8 @@ BASIC_EXAMPLE = n IIO_EXAMPLE = y - include ../../tools/scripts/generic_variables.mk +include ../../tools/scripts/generic_variables.mk - include src.mk +include src.mk - include ../../tools/scripts/generic.mk \ No newline at end of file +include ../../tools/scripts/generic.mk \ No newline at end of file diff --git a/projects/adp1050/README.rst b/projects/adp1050/README.rst index 79ae8be95b0..54931d12782 100644 --- a/projects/adp1050/README.rst +++ b/projects/adp1050/README.rst @@ -8,11 +8,12 @@ Supported Evaluation Boards --------------------------- * `ADP1050DC1-EVALZ `_ +* `ADP1051-240-EVALZ `_ Overview -------- -The evaluation board allows the ADP1050 to be exercised without the need for +The evaluation board allows the ADP1050 and ADP1051 to be exercised without the need for external components. The board is set up to act as an isolated PSU, outputting a rated load of 12 V, 20 A from a 36 V dc to 75 V dc source. @@ -26,8 +27,8 @@ Power Supply Requirments ^^^^^^^^^^^^^^^^^^^^^^^^ For this specific project an external power supply is used to provide a 20.1V -and 12V voltages for the ADP1050DC1-EVALZ daughter board to simulate a parallel -circuit to the ADP1050 as well as a +5V Power Supply for the PMBUS/I2C +and 12V voltages for the ADP1050DC1-EVALZ and ADP1051-240-EVALZ daughter board to simulate a parallel +circuit to the ADP1050 and ADP1051 as well as a +5V Power Supply for the PMBUS/I2C interface. **Pin Description** @@ -116,7 +117,7 @@ The macros used in Common Data are defined in platform specific files found in: Basic example ^^^^^^^^^^^^^ -This is a simple example that initializes the ADP1050, unlock its CHIP, EEPROM +This is a simple example that initializes the ADP1050 and ADP1051, unlock its CHIP, EEPROM and TRIM registers, sets the device in a closed loop state, and then : sets the VOUT transition rate, VOUT scale and value of the VOUT_COMMAND and VOUT_MAX.