summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjeffrey <jeffrey_lin@pegatron.corp-partner.google.com>2022-12-14 12:09:58 +0800
committerChromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com>2022-12-15 04:01:56 +0000
commitf4fdcfe04999eaf6fe738a41587414ada530e47d (patch)
tree95694dc9ce597e80e7e41fd960d11e803cd8e256
parent3a71dfa983df103a7435c0f1ff0108beb1d99e77 (diff)
downloadchrome-ec-f4fdcfe04999eaf6fe738a41587414ada530e47d.tar.gz
xivur: remove sub board setting
Depend on design, sub-board only have Type-C 1. remove sub-board gpio aliases 2. add gpio_usb_c1_int_odl interrupt pin 3. add gpio_en_usb_a1_vbus netname 4. add fan fw config 5. modify fan condition BUG=b:256042758 TEST=zmake build xivur --clobber make sure sub board c1 can use. BRANCH=nissa Change-Id: I79d35c8504a943e3bef51954389839b93f9fcbbf Signed-off-by: jeffrey <jeffrey_lin@pegatron.corp-partner.google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4105061 Reviewed-by: Andrew McRae <amcrae@google.com> Code-Coverage: Andrew McRae <amcrae@google.com>
-rw-r--r--zephyr/program/nissa/CMakeLists.txt1
-rw-r--r--zephyr/program/nissa/xivur/cbi.dtsi35
-rw-r--r--zephyr/program/nissa/xivur/generated.dtsi6
-rw-r--r--zephyr/program/nissa/xivur/overlay.dtsi62
-rw-r--r--zephyr/program/nissa/xivur/project.conf2
-rw-r--r--zephyr/program/nissa/xivur/project.overlay3
-rw-r--r--zephyr/program/nissa/xivur/src/board.c33
-rw-r--r--zephyr/program/nissa/xivur/src/fan.c11
-rw-r--r--zephyr/program/nissa/xivur/src/usbc.c5
9 files changed, 88 insertions, 70 deletions
diff --git a/zephyr/program/nissa/CMakeLists.txt b/zephyr/program/nissa/CMakeLists.txt
index 8e3d267c18..070a8efb81 100644
--- a/zephyr/program/nissa/CMakeLists.txt
+++ b/zephyr/program/nissa/CMakeLists.txt
@@ -91,6 +91,7 @@ if(DEFINED CONFIG_BOARD_XIVUR)
project(xivur)
zephyr_library_sources(
"xivur/src/led.c"
+ "xivur/src/board.c"
"xivur/src/keyboard.c"
)
zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_FAN "xivur/src/fan.c")
diff --git a/zephyr/program/nissa/xivur/cbi.dtsi b/zephyr/program/nissa/xivur/cbi.dtsi
new file mode 100644
index 0000000000..d1834285b6
--- /dev/null
+++ b/zephyr/program/nissa/xivur/cbi.dtsi
@@ -0,0 +1,35 @@
+/* Copyright 2022 The ChromiumOS Authors
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+/ {
+ nissa-fw-config {
+ compatible = "cros-ec,cbi-fw-config";
+
+ /*
+ * FW_CONFIG field to enable fan or not.
+ */
+ fan {
+ enum-name = "FW_FAN";
+ start = <1>;
+ size = <1>;
+
+ no-fan {
+ compatible = "cros-ec,cbi-fw-config-value";
+ enum-name = "FW_FAN_NOT_PRESENT";
+ value = <1>;
+ };
+ fan-present {
+ compatible = "cros-ec,cbi-fw-config-value";
+ enum-name = "FW_FAN_PRESENT";
+ value = <0>;
+ /*
+ * Set as default so that unprovisioned
+ * configs will run the fan regardless.
+ */
+ default;
+ };
+ };
+ };
+};
diff --git a/zephyr/program/nissa/xivur/generated.dtsi b/zephyr/program/nissa/xivur/generated.dtsi
index ecbc1eaed2..1174d72f10 100644
--- a/zephyr/program/nissa/xivur/generated.dtsi
+++ b/zephyr/program/nissa/xivur/generated.dtsi
@@ -121,6 +121,9 @@
gpio_en_usb_a0_vbus: en_usb_a0_vbus {
gpios = <&gpio9 1 GPIO_OUTPUT>;
};
+ gpio_en_usb_a1_vbus: en_usb_a1_vbus {
+ gpios = <&gpiod 4 GPIO_OUTPUT>;
+ };
gpio_gsc_ec_pwr_btn_odl: gsc_ec_pwr_btn_odl {
gpios = <&gpio0 0 GPIO_INPUT_PULL_UP>;
enum-name = "GPIO_POWER_BUTTON_L";
@@ -173,6 +176,9 @@
gpio_usb_c0_int_odl: usb_c0_int_odl {
gpios = <&gpio0 1 GPIO_INPUT_PULL_UP>;
};
+ gpio_usb_c1_int_odl: usb_c1_int_odl {
+ gpios = <&gpio0 2 GPIO_INPUT_PULL_UP>;
+ };
gpio_vccin_aux_vid0: vccin_aux_vid0 {
gpios = <&gpio9 2 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>;
};
diff --git a/zephyr/program/nissa/xivur/overlay.dtsi b/zephyr/program/nissa/xivur/overlay.dtsi
index 29cf96ad3f..24177be1f9 100644
--- a/zephyr/program/nissa/xivur/overlay.dtsi
+++ b/zephyr/program/nissa/xivur/overlay.dtsi
@@ -56,37 +56,13 @@
handler = "usb_interrupt";
};
int_usb_c1: usb_c1 {
- irq-pin = <&gpio_sb_1>;
+ irq-pin = <&gpio_usb_c1_int_odl>;
flags = <GPIO_INT_EDGE_FALLING>;
handler = "usb_interrupt";
};
};
named-gpios {
- gpio_sb_1: sb-1 {
- gpios = <&gpio0 2 GPIO_PULL_UP>;
- no-auto-init;
- };
-
- gpio_sb_2: sb-2 {
- gpios = <&gpiod 4 GPIO_OUTPUT>;
- no-auto-init;
- };
-
- /*
- * Set I2C pins for type C sub-board to be low voltage (I2C5_1).
- * We do this for all boards, since the pins are 3.3V tolerant,
- * and the only 2 types of sub-boards used on nivviks both have
- * type-C ports on them.
- */
- gpio_sb_3: sb-3 {
- gpios = <&gpiof 4 (GPIO_OPEN_DRAIN | GPIO_VOLTAGE_1P8)>;
- no-auto-init;
- };
- gpio_sb_4: sb-4 {
- gpios = <&gpiof 5 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>;
- no-auto-init;
- };
gpio_fan_enable: fan-enable {
gpios = <&gpio6 3 GPIO_OUTPUT>;
no-auto-init;
@@ -99,31 +75,6 @@
};
};
- /*
- * Aliases used for sub-board GPIOs.
- */
- aliases {
- /*
- * Input GPIO when used with type-C port 1
- * Output when used with HDMI sub-board
- */
- gpio-usb-c1-int-odl = &gpio_sb_1;
- gpio-en-rails-odl = &gpio_sb_1;
- /*
- * Sub-board with type A USB, enable.
- */
- gpio-en-usb-a1-vbus = &gpio_sb_2;
- /*
- * HPD pins for HDMI sub-board.
- */
- gpio-hdmi-en-odl = &gpio_sb_3;
- gpio-hpd-odl = &gpio_sb_4;
- /*
- * Enable S5 rails for LTE sub-board
- */
- gpio-en-sub-s5-rails = &gpio_sb_2;
- };
-
temp_memory: memory {
compatible = "cros-ec,temp-sensor-thermistor";
thermistor = <&thermistor_3V3_51K1_47K_4050B>;
@@ -173,16 +124,7 @@
usba {
compatible = "cros-ec,usba-port-enable-pins";
- /*
- * sb_2 is only configured as GPIO when USB-A1 is present,
- * but it's still safe to control when disabled.
- *
- * ILIM_SEL pins are referred to by legacy enum name,
- * GPIO_USB*_ILIM_SEL. The one for port A1 is unused on
- * sub-boards that don't have USB-A so is safe to control
- * regardless of system configuration.
- */
- enable-pins = <&gpio_en_usb_a0_vbus &gpio_sb_2>;
+ enable-pins = <&gpio_en_usb_a0_vbus &gpio_en_usb_a1_vbus>;
status = "okay";
};
diff --git a/zephyr/program/nissa/xivur/project.conf b/zephyr/program/nissa/xivur/project.conf
index 566878ef94..e884b15a15 100644
--- a/zephyr/program/nissa/xivur/project.conf
+++ b/zephyr/program/nissa/xivur/project.conf
@@ -4,6 +4,8 @@
CONFIG_BOARD_XIVUR=y
CONFIG_PLATFORM_EC_OCPC=y
+CONFIG_PLATFORM_EC_FAN=y
+CONFIG_NISSA_SUB_BOARD=n
# Battery Configuration
CONFIG_PLATFORM_EC_SMBUS_PEC=y
diff --git a/zephyr/program/nissa/xivur/project.overlay b/zephyr/program/nissa/xivur/project.overlay
index 20ce52e4f3..ba6f6205bf 100644
--- a/zephyr/program/nissa/xivur/project.overlay
+++ b/zephyr/program/nissa/xivur/project.overlay
@@ -3,8 +3,7 @@
* found in the LICENSE file.
*/
-#include "../cbi.dtsi"
-
+#include "cbi.dtsi"
#include "generated.dtsi"
#include "keyboard.dtsi"
#include "overlay.dtsi"
diff --git a/zephyr/program/nissa/xivur/src/board.c b/zephyr/program/nissa/xivur/src/board.c
new file mode 100644
index 0000000000..7fe60c8f84
--- /dev/null
+++ b/zephyr/program/nissa/xivur/src/board.c
@@ -0,0 +1,33 @@
+/* Copyright 2022 The ChromiumOS Authors
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include "gpio/gpio_int.h"
+#include "hooks.h"
+#include "task.h"
+
+#include <zephyr/drivers/gpio.h>
+#include <zephyr/drivers/pinctrl.h>
+#include <zephyr/init.h>
+#include <zephyr/kernel.h>
+#include <zephyr/sys/printk.h>
+
+LOG_MODULE_DECLARE(nissa, CONFIG_NISSA_LOG_LEVEL);
+
+__override uint8_t board_get_usb_pd_port_count(void)
+{
+ return 2;
+}
+/*
+ * Enable interrupts
+ */
+static void board_init(void)
+{
+ /*
+ * 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));
+}
+DECLARE_HOOK(HOOK_INIT, board_init, HOOK_PRIO_DEFAULT);
diff --git a/zephyr/program/nissa/xivur/src/fan.c b/zephyr/program/nissa/xivur/src/fan.c
index 72d2405986..3223a28919 100644
--- a/zephyr/program/nissa/xivur/src/fan.c
+++ b/zephyr/program/nissa/xivur/src/fan.c
@@ -14,9 +14,6 @@
LOG_MODULE_DECLARE(nissa, CONFIG_NISSA_LOG_LEVEL);
-/*
- * Nirwen fan support
- */
static void fan_init(void)
{
int ret;
@@ -29,11 +26,15 @@ static void fan_init(void)
LOG_ERR("Error retrieving CBI FW_CONFIG field %d", FW_FAN);
return;
}
- if (val != FW_FAN_PRESENT) {
+ if (val == FW_FAN_NOT_PRESENT) {
/* Disable the fan */
+ LOG_INF("Fan not present");
fan_set_count(0);
- } else {
+ gpio_pin_configure_dt(GPIO_DT_FROM_NODELABEL(gpio_fan_enable),
+ GPIO_OUTPUT_LOW);
+ } else if (val == FW_FAN_PRESENT) {
/* Configure the fan enable GPIO */
+ LOG_INF("Fan present");
gpio_pin_configure_dt(GPIO_DT_FROM_NODELABEL(gpio_fan_enable),
GPIO_OUTPUT);
}
diff --git a/zephyr/program/nissa/xivur/src/usbc.c b/zephyr/program/nissa/xivur/src/usbc.c
index 7700121805..74d8be74aa 100644
--- a/zephyr/program/nissa/xivur/src/usbc.c
+++ b/zephyr/program/nissa/xivur/src/usbc.c
@@ -137,8 +137,7 @@ uint16_t tcpc_get_alert_status(void)
}
}
- if (board_get_usb_pd_port_count() == 2 &&
- !gpio_pin_get_dt(GPIO_DT_FROM_ALIAS(gpio_usb_c1_int_odl))) {
+ if (!gpio_pin_get_dt(GPIO_DT_FROM_NODELABEL(gpio_usb_c1_int_odl))) {
if (!tcpc_read16(1, TCPC_REG_ALERT, &regval)) {
/* TCPCI spec Rev 1.0 says to ignore bits 14:12. */
if (!(tcpc_config[1].flags & TCPC_FLAGS_TCPCI_REV2_0))
@@ -247,7 +246,7 @@ static void poll_c0_int(void)
static void poll_c1_int(void)
{
- poll_usb_gpio(1, GPIO_DT_FROM_ALIAS(gpio_usb_c1_int_odl),
+ poll_usb_gpio(1, GPIO_DT_FROM_NODELABEL(gpio_usb_c1_int_odl),
&poll_c1_int_data);
}