From e4deb46ba10f3cad5f42379a21473e6147ea99f9 Mon Sep 17 00:00:00 2001 From: Declan Snyder Date: Tue, 8 Oct 2024 16:15:53 -0500 Subject: [PATCH] dts: nxp_vref: Add current compensation prop Add DT property to enable current compensation feature of NXP VREF. Signed-off-by: Declan Snyder --- drivers/regulator/regulator_nxp_vref.c | 9 +++++++++ dts/bindings/regulator/nxp,vref.yaml | 7 +++++++ 2 files changed, 16 insertions(+) diff --git a/drivers/regulator/regulator_nxp_vref.c b/drivers/regulator/regulator_nxp_vref.c index 1e2f51e06b7..e0c8f30d46f 100644 --- a/drivers/regulator/regulator_nxp_vref.c +++ b/drivers/regulator/regulator_nxp_vref.c @@ -26,6 +26,7 @@ struct regulator_nxp_vref_config { VREF_Type *base; uint16_t buf_start_delay; uint16_t bg_start_time; + bool current_compensation_en; }; static int regulator_nxp_vref_enable(const struct device *dev) @@ -183,6 +184,8 @@ static const struct regulator_driver_api api = { static int regulator_nxp_vref_init(const struct device *dev) { + const struct regulator_nxp_vref_config *config = dev->config; + VREF_Type *const base = config->base; int ret; regulator_common_data_init(dev); @@ -192,6 +195,10 @@ static int regulator_nxp_vref_init(const struct device *dev) return ret; } + if (config->current_compensation_en) { + base->CSR |= VREF_CSR_ICOMPEN_MASK; + } + return regulator_common_init(dev, false); } @@ -205,6 +212,8 @@ static int regulator_nxp_vref_init(const struct device *dev) nxp_buffer_startup_delay_us), \ .bg_start_time = DT_INST_PROP(inst, \ nxp_bandgap_startup_time_us), \ + .current_compensation_en = DT_INST_PROP(inst, \ + nxp_current_compensation_en), \ }; \ \ DEVICE_DT_INST_DEFINE(inst, regulator_nxp_vref_init, NULL, &data_##inst,\ diff --git a/dts/bindings/regulator/nxp,vref.yaml b/dts/bindings/regulator/nxp,vref.yaml index ce678f8708c..7f07dc681b6 100644 --- a/dts/bindings/regulator/nxp,vref.yaml +++ b/dts/bindings/regulator/nxp,vref.yaml @@ -34,6 +34,13 @@ properties: Maximum bandgap startup time as specified in the appropriate device data sheet, in microseconds. + nxp,current-compensation-en: + type: boolean + description: | + Enable second-order curvature compensation. + This must be enabled to achieve the performance stated in the datasheet. + However, the reset value of the peripheral has it disabled. + "#nxp,reference-cells": type: int const: 1