summaryrefslogtreecommitdiff
path: root/zephyr/program/nissa/yavilla/src/board.c
diff options
context:
space:
mode:
authorIvan Chen <yulunchen@google.com>2023-05-17 03:32:45 +0000
committerIvan Chen <yulunchen@google.com>2023-05-17 03:32:45 +0000
commitd7c9c6beb03ee5725232b9ac3bfe4825e1e227cb (patch)
tree3a0d6776c0e76e325d1b087cd51a850cb871358e /zephyr/program/nissa/yavilla/src/board.c
parent8641442366bd7c2c133e302a57f904dfac3c896b (diff)
parentb34dc2ae9022e2fbb57ae6477891ff32954c62fd (diff)
downloadchrome-ec-d7c9c6beb03ee5725232b9ac3bfe4825e1e227cb.tar.gz
Merge remote-tracking branch cros/main into firmware-brya-14505.B-mainfirmware-brya-14505.B-main
Generated by: util/update_release_branch.py --board brya firmware-brya-14505.B-main Relevant changes: git log --oneline 8641442366..b34dc2ae90 -- board/brya board/brya util/getversion.sh BRANCH=None TEST=`make -j buildall` Force-Relevant-Builds: all Change-Id: I63149b4c1782b3ed57f2556755901c21f5f1e3e9 Signed-off-by: Ivan Chen <yulunchen@google.com>
Diffstat (limited to 'zephyr/program/nissa/yavilla/src/board.c')
-rw-r--r--zephyr/program/nissa/yavilla/src/board.c36
1 files changed, 35 insertions, 1 deletions
diff --git a/zephyr/program/nissa/yavilla/src/board.c b/zephyr/program/nissa/yavilla/src/board.c
index f89b92ebd8..feee5fa91f 100644
--- a/zephyr/program/nissa/yavilla/src/board.c
+++ b/zephyr/program/nissa/yavilla/src/board.c
@@ -3,14 +3,19 @@
* found in the LICENSE file.
*/
/* yavilla hardware configuration */
+#include "cros_cbi.h"
#include "gpio/gpio_int.h"
#include "hooks.h"
+#include "motion_sense.h"
+#include "tablet_mode.h"
#include "task.h"
+#include <zephyr/devicetree.h>
#include <zephyr/drivers/gpio.h>
#include <zephyr/drivers/pinctrl.h>
#include <zephyr/init.h>
#include <zephyr/kernel.h>
+#include <zephyr/logging/log.h>
#include <zephyr/sys/printk.h>
LOG_MODULE_DECLARE(nissa, CONFIG_NISSA_LOG_LEVEL);
__override uint8_t board_get_usb_pd_port_count(void)
@@ -22,10 +27,39 @@ __override uint8_t board_get_usb_pd_port_count(void)
*/
static void board_init(void)
{
+ int ret;
+ uint32_t val;
+
+ /*
+ * Retrieve the tablet config.
+ */
+ ret = cros_cbi_get_fw_config(FW_TABLET, &val);
+ if (ret != 0) {
+ LOG_ERR("Error retrieving CBI FW_CONFIG field %d", FW_TABLET);
+ return;
+ }
+
/*
* Enable USB-C interrupts.
*/
gpio_enable_dt_interrupt(GPIO_INT_FROM_NODELABEL(int_usb_c0));
gpio_enable_dt_interrupt(GPIO_INT_FROM_NODELABEL(int_usb_c1));
+
+ /*
+ * Disable tablet related interrupts for tablet absent DUT.
+ */
+ if (val == FW_TABLET_ABSENT) {
+ motion_sensor_count = 0;
+ gmr_tablet_switch_disable();
+ gpio_disable_dt_interrupt(GPIO_INT_FROM_NODELABEL(int_imu));
+ /* Base accel is not stuffed, don't allow line to float */
+ gpio_pin_configure_dt(GPIO_DT_FROM_NODELABEL(gpio_imu_int_l),
+ GPIO_INPUT | GPIO_PULL_DOWN);
+ /* Lid accel is not stuffed, don't allow line to float */
+ gpio_pin_configure_dt(GPIO_DT_FROM_NODELABEL(gpio_acc_int_l),
+ GPIO_INPUT | GPIO_PULL_DOWN);
+ LOG_INF("Clameshell: Disable motion sensors and gmr sensor!");
+ } else
+ LOG_INF("Convertible!!!");
}
-DECLARE_HOOK(HOOK_INIT, board_init, HOOK_PRIO_DEFAULT);
+DECLARE_HOOK(HOOK_INIT, board_init, HOOK_PRIO_POST_I2C);