summaryrefslogtreecommitdiff
path: root/baseboard/dedede/variant_ec_npcx796fc.c
diff options
context:
space:
mode:
authorAseda Aboagye <aaboagye@google.com>2020-01-29 23:31:37 -0800
committerCommit Bot <commit-bot@chromium.org>2020-02-05 08:28:44 +0000
commit5b9636c37e42afecca1d2577722ccc8e1a6cfd21 (patch)
tree4ee3fd9db938ab32ee7d2c1f79088b427f8ffd54 /baseboard/dedede/variant_ec_npcx796fc.c
parent5d4a91818b08cee77fef812ea5acf9d31e110f27 (diff)
downloadchrome-ec-5b9636c37e42afecca1d2577722ccc8e1a6cfd21.tar.gz
dedede: Change PP3300_A PGOOD update method
We cannot read the ADCs in interrupt context, therefore we are changing the method in which we determine the PP3300_A_PGOOD status. This commit adds a ADC threshold interrupt for the PP3300_A PGOOD signal which updates a variable in SRAM. This way, the chipset task can simply use that variable for the PGOOD status instead of performing an ADC conversion in interrupt context. BUG=b:148169171 BRANCH=None TEST=Build and flash waddledoo, verify that PP3300_A PGOOD is updated correctly. TEST=Verify that DUT does not panic while power sequencing Change-Id: Ia88e0d1d95ea97c41dc4094997c0633ca1027cac Signed-off-by: Aseda Aboagye <aaboagye@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2030205 Tested-by: Aseda Aboagye <aaboagye@chromium.org> Commit-Queue: Aseda Aboagye <aaboagye@chromium.org> Reviewed-by: Diana Z <dzigterman@chromium.org>
Diffstat (limited to 'baseboard/dedede/variant_ec_npcx796fc.c')
-rw-r--r--baseboard/dedede/variant_ec_npcx796fc.c65
1 files changed, 65 insertions, 0 deletions
diff --git a/baseboard/dedede/variant_ec_npcx796fc.c b/baseboard/dedede/variant_ec_npcx796fc.c
index d981b2e786..4ef55cf682 100644
--- a/baseboard/dedede/variant_ec_npcx796fc.c
+++ b/baseboard/dedede/variant_ec_npcx796fc.c
@@ -6,13 +6,18 @@
/* Common code for VARIANT_DEDEDE_NPCX796FC configuration */
#include "adc_chip.h"
+#include "atomic.h"
#include "common.h"
#include "compile_time_macros.h"
+#include "console.h"
#include "gpio.h"
+#include "hooks.h"
#include "i2c.h"
+#include "power.h"
#include "pwm.h"
#include "pwm_chip.h"
#include "registers.h"
+#include "task.h"
/* ADC channels */
const struct adc_t adc_channels[] = {
@@ -31,6 +36,66 @@ const struct adc_t adc_channels[] = {
};
BUILD_ASSERT(ARRAY_SIZE(adc_channels) == ADC_CH_COUNT);
+void pp3300_a_pgood_high(void)
+{
+ atomic_or(&pp3300_a_pgood, 1);
+
+ /* Disable this interrupt while it's asserted. */
+ npcx_adc_thresh_int_enable(NPCX_ADC_THRESH1, 0);
+ /* Enable the voltage low interrupt. */
+ npcx_adc_thresh_int_enable(NPCX_ADC_THRESH2, 1);
+
+ /*
+ * Call power_signal_interrupt() with a dummy GPIO in order for the
+ * chipset task to pick up the change in power sequencing signals.
+ */
+ power_signal_interrupt(GPIO_PG_EC_DSW_PWROK);
+}
+
+void pp3300_a_pgood_low(void)
+{
+ atomic_clear(&pp3300_a_pgood, 1);
+
+ /* Disable this interrupt while it's asserted. */
+ npcx_adc_thresh_int_enable(NPCX_ADC_THRESH2, 0);
+ /* Enable the voltage high interrupt. */
+ npcx_adc_thresh_int_enable(NPCX_ADC_THRESH1, 1);
+
+ /*
+ * Call power_signal_interrupt() with a dummy GPIO in order for the
+ * chipset task to pick up the change in power sequencing signals.
+ */
+ power_signal_interrupt(GPIO_PG_EC_DSW_PWROK);
+}
+
+const struct npcx_adc_thresh_t adc_pp3300_a_pgood_high = {
+ .adc_ch = ADC_VSNS_PP3300_A,
+ .adc_thresh_cb = pp3300_a_pgood_high,
+ .thresh_assert = 2700,
+ .thresh_deassert = -1,
+};
+
+const struct npcx_adc_thresh_t adc_pp3300_a_pgood_low = {
+ .adc_ch = ADC_VSNS_PP3300_A,
+ .adc_thresh_cb = pp3300_a_pgood_low,
+ .lower_or_higher = 1,
+ .thresh_assert = 600,
+ .thresh_deassert = -1,
+};
+
+static void set_up_adc_irqs(void)
+{
+ /* Set interrupt thresholds for the ADC. */
+ npcx_adc_register_thresh_irq(NPCX_ADC_THRESH1,
+ &adc_pp3300_a_pgood_high);
+ npcx_adc_register_thresh_irq(NPCX_ADC_THRESH2, &adc_pp3300_a_pgood_low);
+ npcx_set_adc_repetitive(adc_channels[ADC_VSNS_PP3300_A].input_ch, 1);
+ npcx_adc_thresh_int_enable(NPCX_ADC_THRESH1, 1);
+ npcx_adc_thresh_int_enable(NPCX_ADC_THRESH2, 1);
+}
+DECLARE_HOOK(HOOK_INIT, set_up_adc_irqs, HOOK_PRIO_INIT_ADC+1);
+
+
/* I2C Ports */
const struct i2c_port_t i2c_ports[] = {
{