diff --git a/drivers/potentiometer/ad514x/ad5141.c b/drivers/potentiometer/ad514x/ad5141.c index c7d8872954f..5816a17bf17 100644 --- a/drivers/potentiometer/ad514x/ad5141.c +++ b/drivers/potentiometer/ad514x/ad5141.c @@ -606,6 +606,41 @@ int ad5141_dpot_chn_read(struct dpot_dev *desc, return 0; } +/** + * @brief Enter/Exit the top scale or bottom scale . + * @param desc - digipot descriptor. + * @param chn - digipot channel. + * @param is_top_scale - boolean flag to indicate top scale or bottom scale. + * @param enable - Enter or exit the TS. + * @return 0 in case of success, negative error code otherwise. + */ +int ad5141_dpot_top_bottom_scale_enable(struct dpot_dev *desc, + enum dpot_chn_type chn, + bool is_top_scale, + uint8_t enable) +{ + int ret; + struct dpot_command cmd; + + if (!desc) + return -EINVAL; + + ret = ad5141_validate_chn(desc->extra, chn); + if (ret) + return ret; + + /* Enter/Exit the top scale or bottom scale (command #12 or command #13) */ + cmd.control = EXTRACT_CMD_BITS(AD51XX_CMD_TOP_SCALE_EXIT); + cmd.address = ad5141_dpot_cmd_addr[chn]; + cmd.data = enable; + if (is_top_scale == true) + cmd.data |= EXTRACT_DATA_BITS(AD51XX_CMD_TOP_SCALE_EXIT); + + cmd.is_readback = false; + + return ad5141_dpot_send_cmd(desc, &cmd); +} + /** * @brief Write to the digital potentiometer channel. * @param desc - digipot descriptor. @@ -923,6 +958,7 @@ const struct dpot_ops ad5141_dpot_ops = { .dpot_copy_nvm_to_rdac = &ad5141_dpot_copy_nvm_to_rdac, .dpot_rdac_linear_update = &ad5141_dpot_rdac_linear_update, .dpot_rdac_6db_update = &ad5141_dpot_rdac_6db_update, -// .dpot_send_cmd = &ad5141_dpot_send_cmd, + .dpot_send_cmd = &ad5141_dpot_send_cmd, .dpot_remove = &ad5141_dpot_remove, + .dpot_enable_top_bottom_scale = &ad5141_dpot_top_bottom_scale_enable }; diff --git a/drivers/potentiometer/ad514x/ad5142.c b/drivers/potentiometer/ad514x/ad5142.c index 5d5a02d77b1..59a8b40e83f 100644 --- a/drivers/potentiometer/ad514x/ad5142.c +++ b/drivers/potentiometer/ad514x/ad5142.c @@ -559,6 +559,41 @@ int ad5142_dpot_chn_read(struct dpot_dev *desc, return 0; } +/** + * @brief Enter/Exit the top scale or bottom scale . + * @param desc - digipot descriptor. + * @param chn - digipot channel. + * @param is_top_scale - boolean flag to indicate top scale or bottom scale. + * @param enable - Enter or exit the TS. + * @return 0 in case of success, negative error code otherwise. + */ +int ad5142_dpot_top_bottom_scale_enable(struct dpot_dev *desc, + enum dpot_chn_type chn, + bool is_top_scale, + uint8_t enable) +{ + int ret; + struct dpot_command cmd; + + if (!desc) + return -EINVAL; + + ret = ad5142_validate_chn(desc->extra, chn); + if (ret) + return ret; + + /* Enter/Exit the top scale or bottom scale (command #12 or command #13) */ + cmd.control = EXTRACT_CMD_BITS(AD51XX_CMD_TOP_SCALE_EXIT); + cmd.address = ad5142_dpot_cmd_addr[chn]; + cmd.data = enable; + if (is_top_scale == true) + cmd.data |= EXTRACT_DATA_BITS(AD51XX_CMD_TOP_SCALE_EXIT); + + cmd.is_readback = false; + + return ad5142_dpot_send_cmd(desc, &cmd); +} + /** * @brief Write to the digital potentiometer channel. * @param desc - digipot descriptor. @@ -875,6 +910,7 @@ const struct dpot_ops ad5142_dpot_ops = { .dpot_copy_nvm_to_rdac = &ad5142_dpot_copy_nvm_to_rdac, .dpot_rdac_linear_update = &ad5142_dpot_rdac_linear_update, .dpot_rdac_6db_update = &ad5142_dpot_rdac_6db_update, - //.dpot_send_cmd = &ad5142_dpot_send_cmd, + .dpot_send_cmd = &ad5142_dpot_send_cmd, .dpot_remove = &ad5142_dpot_remove, + .dpot_enable_top_bottom_scale = &ad5142_dpot_top_bottom_scale_enable }; diff --git a/drivers/potentiometer/ad514x/ad5143.c b/drivers/potentiometer/ad514x/ad5143.c index 2d8609cd8bc..78cf489734b 100644 --- a/drivers/potentiometer/ad514x/ad5143.c +++ b/drivers/potentiometer/ad514x/ad5143.c @@ -423,6 +423,41 @@ int ad5143_dpot_chn_read(struct dpot_dev *desc, return 0; } +/** + * @brief Enter/Exit the top scale or bottom scale . + * @param desc - digipot descriptor. + * @param chn - digipot channel. + * @param is_top_scale - boolean flag to indicate top scale or bottom scale. + * @param enable - Enter or exit the TS. + * @return 0 in case of success, negative error code otherwise. + */ +int ad5143_dpot_top_bottom_scale_enable(struct dpot_dev *desc, + enum dpot_chn_type chn, + bool is_top_scale, + uint8_t enable) +{ + int ret; + struct dpot_command cmd; + + if (!desc) + return -EINVAL; + + ret = ad5143_validate_chn(desc->extra, chn); + if (ret) + return ret; + + /* Enter/Exit the top scale or bottom scale (command #12 or command #13) */ + cmd.control = EXTRACT_CMD_BITS(AD51XX_CMD_TOP_SCALE_EXIT); + cmd.address = ad5143_dpot_cmd_addr[chn]; + cmd.data = enable; + if (is_top_scale == true) + cmd.data |= EXTRACT_DATA_BITS(AD51XX_CMD_TOP_SCALE_EXIT); + + cmd.is_readback = false; + + return ad5143_dpot_send_cmd(desc, &cmd); +} + /** * @brief Write to the digital potentiometer channel. * @param desc - digipot descriptor. @@ -726,4 +761,5 @@ const struct dpot_ops ad5143_dpot_ops = { .dpot_rdac_6db_update = &ad5143_dpot_rdac_6db_update, .dpot_send_cmd = &ad5143_dpot_send_cmd, .dpot_remove = &ad5143_dpot_remove, + .dpot_enable_top_bottom_scale = &ad5143_dpot_top_bottom_scale_enable }; diff --git a/drivers/potentiometer/ad514x/ad5144.c b/drivers/potentiometer/ad514x/ad5144.c index b466474c503..f66ee5734a7 100644 --- a/drivers/potentiometer/ad514x/ad5144.c +++ b/drivers/potentiometer/ad514x/ad5144.c @@ -615,18 +615,19 @@ int ad5144_dpot_chn_read(struct dpot_dev *desc, return 0; } + /** - * @brief Enter/Exit the top scale or Bottom scale . + * @brief Enter/Exit the top scale or Bottom scale . * @param desc - digipot descriptor. * @param chn - digipot channel. - * @param IsTopScale - boolean flag to indicat top scale or bottom scale. - * @param nEnable - Enter or exit the TS. + * @param is_top_scale - boolean flag to indicate top scale or bottom scale. + * @param enable - Enter or exit the TS. * @return 0 in case of success, negative error code otherwise. */ int ad5144_dpot_top_bottom_scale_enable(struct dpot_dev *desc, enum dpot_chn_type chn, - bool IsTopScale, - uint8_t nEnable) + bool is_top_scale, + uint8_t enable) { int ret; struct dpot_command cmd; @@ -638,21 +639,16 @@ int ad5144_dpot_top_bottom_scale_enable(struct dpot_dev *desc, if (ret) return ret; - /* Write contents of serial register data to RDAC (command #1) */ - cmd.control = 0x9; + /* Enter/Exit the top scale or Bottom scale (command #12 or command #13) */ + cmd.control = EXTRACT_CMD_BITS(AD51XX_CMD_TOP_SCALE_EXIT); cmd.address = ad5144_dpot_cmd_addr[chn]; - cmd.data = nEnable; - if (IsTopScale == true) { - cmd.data |= 0x80; - } + cmd.data = enable; + if (is_top_scale == true) + cmd.data |= EXTRACT_DATA_BITS(AD51XX_CMD_TOP_SCALE_EXIT); cmd.is_readback = false; - ret = ad5144_dpot_send_cmd(desc, &cmd); - if (ret) - return ret; - - return 0; + return ad5144_dpot_send_cmd(desc, &cmd); } /** @@ -972,7 +968,7 @@ const struct dpot_ops ad5144_dpot_ops = { .dpot_copy_nvm_to_rdac = &ad5144_dpot_copy_nvm_to_rdac, .dpot_rdac_linear_update = &ad5144_dpot_rdac_linear_update, .dpot_rdac_6db_update = &ad5144_dpot_rdac_6db_update, - //.dpot_send_cmd = &ad5144_dpot_send_cmd, + .dpot_send_cmd = &ad5144_dpot_send_cmd, .dpot_remove = &ad5144_dpot_remove, .dpot_enable_top_bottom_scale = &ad5144_dpot_top_bottom_scale_enable };