summaryrefslogtreecommitdiff
path: root/board/hatch
diff options
context:
space:
mode:
authorScott Collyer <scollyer@google.com>2019-03-11 18:00:57 -0700
committerchrome-bot <chrome-bot@chromium.org>2019-03-13 21:05:01 -0700
commita784e311d8ea6dd55d7a51ee4e82d323c027d9bd (patch)
tree581dc0e87338b40f01309e1069ededbcd9c9f900 /board/hatch
parent7f93dd558b1ab16d0595ff701584daa8b4f8f4e2 (diff)
downloadchrome-ec-a784e311d8ea6dd55d7a51ee4e82d323c027d9bd.tar.gz
hatch: Make EN_PP5000_A gpio signal runtime configurable
The EC pin used for EN_PP5000_A has changed. This CL adds code to configure and select the correct gpio signal based on board version. BUG=b:123553959 BRANCH=none TEST=Tested on P0 board and verified that AP boots up which means that EN_PP5000_A is being selected properly. Change-Id: I0a1d5a55cf87b0ef8ed044e6e72caec37483692f Signed-off-by: Scott Collyer <scollyer@google.com> Reviewed-on: https://chromium-review.googlesource.com/1515950 Commit-Ready: Scott Collyer <scollyer@chromium.org> Tested-by: Scott Collyer <scollyer@chromium.org> Reviewed-by: Furquan Shaikh <furquan@chromium.org>
Diffstat (limited to 'board/hatch')
-rw-r--r--board/hatch/board.c37
-rw-r--r--board/hatch/board.h4
-rw-r--r--board/hatch/gpio.inc3
3 files changed, 43 insertions, 1 deletions
diff --git a/board/hatch/board.c b/board/hatch/board.c
index c4178f4169..7ec5136801 100644
--- a/board/hatch/board.c
+++ b/board/hatch/board.c
@@ -9,6 +9,7 @@
#include "adc_chip.h"
#include "button.h"
#include "common.h"
+#include "cros_board_info.h"
#include "driver/accel_bma2x2.h"
#include "driver/accelgyro_bmi160.h"
#include "driver/als_opt3001.h"
@@ -331,12 +332,48 @@ static void setup_fans(void)
thermal_params[TEMP_SENSOR_2] = thermal_a;
}
+/* Sets the gpio flags correct taking into account warm resets */
+static void reset_gpio_flags(enum gpio_signal signal, int flags)
+{
+ /*
+ * If the system was already on, we cannot set the value otherwise we
+ * may change the value from the previous image which could cause a
+ * brownout.
+ */
+ if (system_is_reboot_warm() || system_jumped_to_this_image())
+ flags &= ~(GPIO_LOW | GPIO_HIGH);
+
+ gpio_set_flags(signal, flags);
+}
+
+/* Runtime GPIO defaults */
+enum gpio_signal gpio_en_pp5000_a = GPIO_EN_PP5000_A_V1;
+
+static void board_gpio_set_pp5000(void)
+{
+ uint32_t board_id = 0;
+
+ /* Errors will count as board_id 0 */
+ cbi_get_board_version(&board_id);
+
+ if (board_id == 0) {
+ reset_gpio_flags(GPIO_EN_PP5000_A_V0, GPIO_OUT_LOW);
+ /* Change runtime default for V0 */
+ gpio_en_pp5000_a = GPIO_EN_PP5000_A_V0;
+ } else if (board_id >= 1) {
+ reset_gpio_flags(GPIO_EN_PP5000_A_V1, GPIO_OUT_LOW);
+ }
+
+}
+
static void board_init(void)
{
/* Initialize Fans */
setup_fans();
/* Enable gpio interrupt for base accelgyro sensor */
gpio_enable_interrupt(GPIO_BASE_SIXAXIS_INT_L);
+ /* Select correct gpio signal for PP5000_A control */
+ board_gpio_set_pp5000();
}
DECLARE_HOOK(HOOK_INIT, board_init, HOOK_PRIO_DEFAULT);
diff --git a/board/hatch/board.h b/board/hatch/board.h
index 7ee08f8d1e..94bb0c7894 100644
--- a/board/hatch/board.h
+++ b/board/hatch/board.h
@@ -89,6 +89,10 @@
#include "gpio_signal.h"
#include "registers.h"
+/* GPIO signals updated base on board version. */
+#define GPIO_EN_PP5000_A gpio_en_pp5000_a
+extern enum gpio_signal gpio_en_pp5000_a;
+
enum adc_channel {
ADC_TEMP_SENSOR_1, /* ADC0 */
ADC_TEMP_SENSOR_2, /* ADC1 */
diff --git a/board/hatch/gpio.inc b/board/hatch/gpio.inc
index f7a15e04ef..a07c3bc495 100644
--- a/board/hatch/gpio.inc
+++ b/board/hatch/gpio.inc
@@ -46,7 +46,8 @@ GPIO(PCH_WAKE_L, PIN(7, 4), GPIO_ODR_HIGH) /* EC_PCH_WAKE_O
GPIO(PCH_PWRBTN_L, PIN(C, 1), GPIO_ODR_HIGH) /* EC_PCH_PWR_BTN_ODL */
/* Power Sequencing Signals */
-GPIO(EN_PP5000_A, PIN(7, 3), GPIO_OUT_LOW)
+GPIO(EN_PP5000_A_V1, PIN(A, 4), GPIO_DEFAULT)
+GPIO(EN_PP5000_A_V0, PIN(7, 3), GPIO_DEFAULT)
GPIO(EN_A_RAILS, PIN(A, 3), GPIO_OUT_LOW)
GPIO(EC_PCH_RSMRST_L, PIN(A, 6), GPIO_OUT_LOW)
GPIO(EC_PROCHOT_ODL, PIN(6, 3), GPIO_ODR_HIGH)