summaryrefslogtreecommitdiff
path: root/board/ampton/board.c
diff options
context:
space:
mode:
authorDiana Z <dzigterman@chromium.org>2018-09-11 15:52:03 -0600
committerchrome-bot <chrome-bot@chromium.org>2018-09-14 12:08:45 -0700
commitca25c78f48ed3fb6b52945afa9b5d83136f07c08 (patch)
treecb28b23c55de422b23fc4633580aa351c0c10ffa /board/ampton/board.c
parent2c760cf30b95715791eb43701b3d5536558b3a8d (diff)
downloadchrome-ec-ca25c78f48ed3fb6b52945afa9b5d83136f07c08.tar.gz
Ampton: create initial EC image
This image is based on bip from current ToT and the most recent ampton schematics. Bugs have been created and put into TODO statements for the future work needed on this EC image. BRANCH=None BUG=b:111498206 TEST=builds Change-Id: Idff972b9ce5231524dd4865a87953ebcd5310c62 Signed-off-by: Diana Z <dzigterman@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1225350 Reviewed-by: Justin TerAvest <teravest@chromium.org>
Diffstat (limited to 'board/ampton/board.c')
-rw-r--r--board/ampton/board.c122
1 files changed, 122 insertions, 0 deletions
diff --git a/board/ampton/board.c b/board/ampton/board.c
new file mode 100644
index 0000000000..0552be05a6
--- /dev/null
+++ b/board/ampton/board.c
@@ -0,0 +1,122 @@
+/* Copyright 2018 The Chromium OS Authors. All rights reserved.
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+/* Ampton/Apel board-specific configuration */
+
+#include "adc.h"
+#include "adc_chip.h"
+#include "button.h"
+#include "charge_state.h"
+#include "common.h"
+#include "driver/bc12/bq24392.h"
+#include "driver/ppc/sn5s330.h"
+#include "driver/tcpm/it83xx_pd.h"
+#include "driver/tcpm/ps8xxx.h"
+#include "driver/usb_mux_it5205.h"
+#include "extpower.h"
+#include "gpio.h"
+#include "hooks.h"
+#include "i2c.h"
+#include "intc.h"
+#include "keyboard_scan.h"
+#include "lid_switch.h"
+#include "power.h"
+#include "power_button.h"
+#include "spi.h"
+#include "switch.h"
+#include "system.h"
+#include "tcpci.h"
+#include "tablet_mode.h"
+#include "temp_sensor.h"
+#include "thermistor.h"
+#include "uart.h"
+#include "usb_mux.h"
+#include "usbc_ppc.h"
+#include "util.h"
+
+static void ppc_interrupt(enum gpio_signal signal)
+{
+ if (signal == GPIO_USB_C0_PD_INT_ODL)
+ sn5s330_interrupt(0);
+ else if (signal == GPIO_USB_C1_PD_INT_ODL)
+ sn5s330_interrupt(1);
+}
+
+#include "gpio_list.h" /* Must come after other header files. */
+
+/******************************************************************************/
+/* ADC channels */
+const struct adc_t adc_channels[] = {
+ /* Vbus C0 sensing (10x voltage divider). PPVAR_USB_C0_VBUS */
+ [ADC_VBUS_C0] = {.name = "VBUS_C0",
+ .factor_mul = 10 * ADC_MAX_MVOLT,
+ .factor_div = ADC_READ_MAX + 1,
+ .shift = 0,
+ .channel = CHIP_ADC_CH13},
+ /* Vbus C1 sensing (10x voltage divider). SUB_EC_ADC */
+ [ADC_VBUS_C1] = {.name = "VBUS_C1",
+ .factor_mul = 10 * ADC_MAX_MVOLT,
+ .factor_div = ADC_READ_MAX + 1,
+ .shift = 0,
+ .channel = CHIP_ADC_CH14},
+ /* Convert to raw mV for thermistor table lookup */
+ [ADC_TEMP_SENSOR_AMB] = {.name = "TEMP_AMB",
+ .factor_mul = ADC_MAX_MVOLT,
+ .factor_div = ADC_READ_MAX + 1,
+ .shift = 0,
+ .channel = CHIP_ADC_CH3},
+ /* Convert to raw mV for thermistor table lookup */
+ [ADC_TEMP_SENSOR_CHARGER] = {.name = "TEMP_CHARGER",
+ .factor_mul = ADC_MAX_MVOLT,
+ .factor_div = ADC_READ_MAX + 1,
+ .shift = 0,
+ .channel = CHIP_ADC_CH5},
+};
+BUILD_ASSERT(ARRAY_SIZE(adc_channels) == ADC_CH_COUNT);
+
+static int read_charger_temp(int idx, int *temp_ptr)
+{
+ if (!gpio_get_level(GPIO_AC_PRESENT))
+ return EC_ERROR_NOT_POWERED;
+ return get_temp_3v3_13k7_47k_4050b(idx, temp_ptr);
+}
+
+const struct temp_sensor_t temp_sensors[] = {
+ [TEMP_SENSOR_BATTERY] = {.name = "Battery",
+ .type = TEMP_SENSOR_TYPE_BATTERY,
+ .read = charge_get_battery_temp,
+ .action_delay_sec = 1},
+ [TEMP_SENSOR_AMBIENT] = {.name = "Ambient",
+ .type = TEMP_SENSOR_TYPE_BOARD,
+ .read = get_temp_3v3_51k1_47k_4050b,
+ .idx = ADC_TEMP_SENSOR_AMB,
+ .action_delay_sec = 5},
+ [TEMP_SENSOR_CHARGER] = {.name = "Charger",
+ .type = TEMP_SENSOR_TYPE_BOARD,
+ .read = read_charger_temp,
+ .idx = ADC_TEMP_SENSOR_CHARGER,
+ .action_delay_sec = 1},
+};
+BUILD_ASSERT(ARRAY_SIZE(temp_sensors) == TEMP_SENSOR_COUNT);
+
+void board_hibernate_late(void)
+{
+ /*
+ * Set KSO/KSI pins to GPIO input function to disable keyboard scan
+ * while hibernating. This also prevent leakage current caused
+ * by internal pullup of keyboard scan module.
+ */
+ gpio_set_flags_by_mask(GPIO_KSO_H, 0xff, GPIO_INPUT);
+ gpio_set_flags_by_mask(GPIO_KSO_L, 0xff, GPIO_INPUT);
+ gpio_set_flags_by_mask(GPIO_KSI, 0xff, GPIO_INPUT);
+}
+
+/* TODO(b/115501243): Ampton/Apel: implement motion sensors in EC code */
+
+void board_overcurrent_event(int port)
+{
+ /* TODO(b/78344554): pass this signal upstream once hardware reworked */
+ cprints(CC_USBPD, "p%d: overcurrent!", port);
+}