summaryrefslogtreecommitdiff
path: root/zephyr/projects/skyrim/src/frostflow
diff options
context:
space:
mode:
Diffstat (limited to 'zephyr/projects/skyrim/src/frostflow')
-rw-r--r--zephyr/projects/skyrim/src/frostflow/keyboard.c74
-rw-r--r--zephyr/projects/skyrim/src/frostflow/keyboard_customization.c85
-rw-r--r--zephyr/projects/skyrim/src/frostflow/ppc_config.c46
-rw-r--r--zephyr/projects/skyrim/src/frostflow/usb_mux_config.c123
4 files changed, 328 insertions, 0 deletions
diff --git a/zephyr/projects/skyrim/src/frostflow/keyboard.c b/zephyr/projects/skyrim/src/frostflow/keyboard.c
new file mode 100644
index 0000000000..2905f17941
--- /dev/null
+++ b/zephyr/projects/skyrim/src/frostflow/keyboard.c
@@ -0,0 +1,74 @@
+/* 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 "ec_commands.h"
+#include "keyboard_scan.h"
+#include "timer.h"
+
+/* Keyboard scan setting */
+__override struct keyboard_scan_config keyscan_config = {
+ /* Increase from 50 us, because KSO_02 passes through the H1. */
+ .output_settle_us = 80,
+ /* Other values should be the same as the default configuration. */
+ .debounce_down_us = 9 * MSEC,
+ .debounce_up_us = 30 * MSEC,
+ .scan_period_us = 3 * MSEC,
+ .min_post_scan_delay_us = 1000,
+ .poll_timeout_us = 100 * MSEC,
+ .actual_key_mask = {
+ 0x1c, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0x86, 0xff, 0xff, 0x55, 0xff, 0xff, 0xff, 0xff, /* full set */
+ },
+};
+
+static const struct ec_response_keybd_config frostflow_kb = {
+ .num_top_row_keys = 10,
+ .action_keys = {
+ TK_BACK, /* T1 */
+ TK_REFRESH, /* T2 */
+ TK_FULLSCREEN, /* T3 */
+ TK_OVERVIEW, /* T4 */
+ TK_SNAPSHOT, /* T5 */
+ TK_BRIGHTNESS_DOWN, /* T6 */
+ TK_BRIGHTNESS_UP, /* T7 */
+ TK_VOL_MUTE, /* T8 */
+ TK_VOL_DOWN, /* T9 */
+ TK_VOL_UP, /* T10 */
+ },
+ .capabilities = KEYBD_CAP_SCRNLOCK_KEY,
+};
+
+__override const struct ec_response_keybd_config *
+board_vivaldi_keybd_config(void)
+{
+ return &frostflow_kb;
+}
+
+/*
+ * Row Column info for Top row keys T1 - T15.
+ * on frostflow_kb keyboard Row Column is customization
+ * need define row col to mapping matrix layout.
+ */
+__override const struct key {
+ uint8_t row;
+ uint8_t col;
+} vivaldi_keys[] = {
+ { .row = 4, .col = 2 }, /* T1 */
+ { .row = 3, .col = 2 }, /* T2 */
+ { .row = 2, .col = 2 }, /* T3 */
+ { .row = 1, .col = 2 }, /* T4 */
+ { .row = 4, .col = 4 }, /* T5 */
+ { .row = 3, .col = 4 }, /* T6 */
+ { .row = 2, .col = 4 }, /* T7 */
+ { .row = 2, .col = 9 }, /* T8 */
+ { .row = 1, .col = 9 }, /* T9 */
+ { .row = 1, .col = 4 }, /* T10 */
+ { .row = 0, .col = 4 }, /* T11 */
+ { .row = 1, .col = 5 }, /* T12 */
+ { .row = 3, .col = 5 }, /* T13 */
+ { .row = 2, .col = 1 }, /* T14 */
+ { .row = 0, .col = 1 }, /* T15 */
+};
+BUILD_ASSERT(ARRAY_SIZE(vivaldi_keys) == MAX_TOP_ROW_KEYS);
diff --git a/zephyr/projects/skyrim/src/frostflow/keyboard_customization.c b/zephyr/projects/skyrim/src/frostflow/keyboard_customization.c
new file mode 100644
index 0000000000..d176323d80
--- /dev/null
+++ b/zephyr/projects/skyrim/src/frostflow/keyboard_customization.c
@@ -0,0 +1,85 @@
+/* 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 <zephyr/drivers/gpio.h>
+
+#include "common.h"
+#include "gpio.h"
+#include "keyboard_customization.h"
+#include "keyboard_protocol.h"
+#include "keyboard_raw.h"
+
+static uint16_t scancode_set2[KEYBOARD_COLS_MAX][KEYBOARD_ROWS] = {
+ { 0x0000, 0x0000, 0x0014, 0xe01f, 0xe014, 0x0000, 0x0000, 0x0000 },
+ { 0x001f, 0x0076, 0x0017, 0x000e, 0x001c, 0x003a, 0x000d, 0x0016 },
+ { 0x006c, 0xe024, 0xe01d, 0xe020, 0xe038, 0xe071, 0x0026, 0x002a },
+ { 0x0032, 0x0034, 0x002c, 0x002e, 0x002b, 0x0029, 0x0025, 0x002d },
+ { 0x0078, 0xe032, 0xe035, 0xe02c, 0xe02d, 0x0041, 0x001e, 0x001d },
+ { 0x0051, 0x0007, 0x005b, 0x000f, 0x0042, 0x0022, 0x003e, 0x0043 },
+ { 0x0031, 0x0033, 0x0035, 0x0036, 0x003b, 0x001b, 0x003d, 0x003c },
+ { 0x0000, 0x0012, 0x0061, 0x0000, 0x0000, 0x0000, 0x0000, 0x0059 },
+ { 0x0055, 0x0052, 0x0054, 0x004e, 0x004c, 0x0024, 0x0044, 0x004d },
+ { 0x0045, 0xe021, 0xe023, 0x002f, 0x004b, 0x0049, 0x0046, 0x001a },
+ { 0xe011, 0x0000, 0x006a, 0x0000, 0x005d, 0x0000, 0x0011, 0x0000 },
+ { 0xe07a, 0x005d, 0xe075, 0x006b, 0x005a, 0xe072, 0x004a, 0x0066 },
+ { 0xe06b, 0xe074, 0xe069, 0x0067, 0xe06c, 0x0064, 0x0015, 0xe07d },
+ { 0x0073, 0x007c, 0x007b, 0x0074, 0x0071, 0xe04a, 0x0070, 0x0021 },
+ { 0x0023, 0xe05a, 0x0075, 0x0079, 0x007a, 0x0072, 0x007d, 0x0069 },
+};
+
+uint16_t get_scancode_set2(uint8_t row, uint8_t col)
+{
+ if (col < KEYBOARD_COLS_MAX && row < KEYBOARD_ROWS)
+ return scancode_set2[col][row];
+ return 0;
+}
+
+void set_scancode_set2(uint8_t row, uint8_t col, uint16_t val)
+{
+ if (col < KEYBOARD_COLS_MAX && row < KEYBOARD_ROWS)
+ scancode_set2[col][row] = val;
+}
+
+#ifdef CONFIG_KEYBOARD_DEBUG
+static char keycap_label[KEYBOARD_COLS_MAX][KEYBOARD_ROWS] = {
+ { 'c', KLLI_UNKNO, KLLI_UNKNO, KLLI_UNKNO, KLLI_UNKNO, KLLI_UNKNO,
+ KLLI_UNKNO, KLLI_UNKNO },
+ { KLLI_UNKNO, KLLI_UNKNO, KLLI_UNKNO, KLLI_UNKNO, KLLI_UNKNO,
+ KLLI_UNKNO, KLLI_UNKNO, KLLI_UNKNO },
+ { 'q', KLLI_UNKNO, KLLI_UNKNO, KLLI_TAB, '`', '1', KLLI_UNKNO, 'a' },
+ { KLLI_R_ALT, KLLI_L_ALT, KLLI_UNKNO, KLLI_UNKNO, KLLI_UNKNO,
+ KLLI_UNKNO, KLLI_UNKNO, KLLI_UNKNO },
+ { KLLI_UNKNO, KLLI_SPACE, 'e', KLLI_F4, KLLI_SEARC, '3', KLLI_F3,
+ KLLI_UNKNO },
+ { 'x', 'z', KLLI_F2, KLLI_F1, 's', '2', 'w', KLLI_ESC },
+ { 'v', 'b', 'g', 't', '5', '4', 'r', 'f' },
+ { 'm', 'n', 'h', 'y', '6', '7', 'u', 'j' },
+ { '.', KLLI_DOWN, '\\', 'o', KLLI_F10, '9', KLLI_UNKNO, 'l' },
+ { KLLI_R_SHT, KLLI_L_SHT, KLLI_UNKNO, KLLI_UNKNO, KLLI_UNKNO,
+ KLLI_UNKNO, KLLI_UNKNO, KLLI_UNKNO },
+ { ',', KLLI_UNKNO, KLLI_F7, KLLI_F6, KLLI_F5, '8', 'i', 'k' },
+ { KLLI_UNKNO, KLLI_UNKNO, KLLI_UNKNO, KLLI_F9, KLLI_UNKNO, KLLI_UNKNO,
+ KLLI_LEFT, KLLI_UNKNO },
+ { KLLI_R_CTR, KLLI_L_CTR, KLLI_UNKNO, KLLI_UNKNO, KLLI_UNKNO,
+ KLLI_UNKNO, KLLI_UNKNO, KLLI_UNKNO },
+ { '/', KLLI_UP, '-', KLLI_UNKNO, '0', 'p', '[', ';' },
+ { '\'', KLLI_ENTER, KLLI_UNKNO, KLLI_UNKNO, '=', KLLI_B_SPC, ']', 'd' },
+ { KLLI_UNKNO, KLLI_F8, KLLI_RIGHT, KLLI_UNKNO, KLLI_UNKNO, KLLI_UNKNO,
+ KLLI_UNKNO, KLLI_UNKNO },
+};
+
+char get_keycap_label(uint8_t row, uint8_t col)
+{
+ if (col < KEYBOARD_COLS_MAX && row < KEYBOARD_ROWS)
+ return keycap_label[col][row];
+ return KLLI_UNKNO;
+}
+
+void set_keycap_label(uint8_t row, uint8_t col, char val)
+{
+ if (col < KEYBOARD_COLS_MAX && row < KEYBOARD_ROWS)
+ keycap_label[col][row] = val;
+}
+#endif
diff --git a/zephyr/projects/skyrim/src/frostflow/ppc_config.c b/zephyr/projects/skyrim/src/frostflow/ppc_config.c
new file mode 100644
index 0000000000..6072a788eb
--- /dev/null
+++ b/zephyr/projects/skyrim/src/frostflow/ppc_config.c
@@ -0,0 +1,46 @@
+/* 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.
+ */
+
+/* Frostflow board-specific PPC code */
+
+#include <zephyr/drivers/gpio.h>
+
+#include "driver/ppc/nx20p348x.h"
+#include "driver/ppc/aoz1380_public.h"
+#include "usbc_ppc.h"
+
+#define CPRINTSUSB(format, args...) cprints(CC_USBCHARGE, format, ##args)
+#define CPRINTFUSB(format, args...) cprintf(CC_USBCHARGE, format, ##args)
+
+/*
+ * In the AOZ1380 PPC, there are no programmable features. We use
+ * the attached NCT3807 to control a GPIO to indicate 1A5 or 3A0
+ * current limits.
+ */
+int board_aoz1380_set_vbus_source_current_limit(int port, enum tcpc_rp_value rp)
+{
+ int rv = EC_SUCCESS;
+
+ rv = gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(ioex_usb_c0_ilim_3a_en),
+ (rp == TYPEC_RP_3A0) ? 1 : 0);
+
+ return rv;
+}
+
+void ppc_interrupt(enum gpio_signal signal)
+{
+ switch (signal) {
+ case GPIO_USB_C0_PPC_INT_ODL:
+ aoz1380_interrupt(0);
+ break;
+
+ case GPIO_USB_C1_PPC_INT_ODL:
+ nx20p348x_interrupt(1);
+ break;
+
+ default:
+ break;
+ }
+}
diff --git a/zephyr/projects/skyrim/src/frostflow/usb_mux_config.c b/zephyr/projects/skyrim/src/frostflow/usb_mux_config.c
new file mode 100644
index 0000000000..e641e0d649
--- /dev/null
+++ b/zephyr/projects/skyrim/src/frostflow/usb_mux_config.c
@@ -0,0 +1,123 @@
+/* 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.
+ */
+
+/* Frostflow board-specific USB-C mux configuration */
+
+#include <zephyr/drivers/gpio.h>
+
+#include "console.h"
+#include "cros_board_info.h"
+#include "cros_cbi.h"
+#include "driver/retimer/anx7483_public.h"
+#include "hooks.h"
+#include "ioexpander.h"
+#include "usb_mux.h"
+#include "usbc/usb_muxes.h"
+
+#define CPRINTSUSB(format, args...) cprints(CC_USBCHARGE, format, ##args)
+#define CPRINTFUSB(format, args...) cprintf(CC_USBCHARGE, format, ##args)
+
+/*
+ * USB C0 (general) and C1 (just ANX DB) use IOEX pins to
+ * indicate flipped polarity to a protection switch.
+ */
+static int ioex_set_flip(int port, mux_state_t mux_state)
+{
+ if (port == 0) {
+ if (mux_state & USB_PD_MUX_POLARITY_INVERTED)
+ gpio_pin_set_dt(
+ GPIO_DT_FROM_NODELABEL(ioex_usb_c0_sbu_flip),
+ 1);
+ else
+ gpio_pin_set_dt(
+ GPIO_DT_FROM_NODELABEL(ioex_usb_c0_sbu_flip),
+ 0);
+ } else {
+ if (mux_state & USB_PD_MUX_POLARITY_INVERTED)
+ gpio_pin_set_dt(
+ GPIO_DT_FROM_NODELABEL(ioex_usb_c1_sbu_flip),
+ 1);
+ else
+ gpio_pin_set_dt(
+ GPIO_DT_FROM_NODELABEL(ioex_usb_c1_sbu_flip),
+ 0);
+ }
+
+ return EC_SUCCESS;
+}
+
+int board_anx7483_c0_mux_set(const struct usb_mux *me, mux_state_t mux_state)
+{
+ /* Set the SBU polarity mux */
+ RETURN_ERROR(ioex_set_flip(me->usb_port, mux_state));
+
+ return anx7483_set_default_tuning(me, mux_state);
+}
+
+int board_anx7483_c1_mux_set(const struct usb_mux *me, mux_state_t mux_state)
+{
+ bool flipped = mux_state & USB_PD_MUX_POLARITY_INVERTED;
+
+ /* Set the SBU polarity mux */
+ RETURN_ERROR(ioex_set_flip(me->usb_port, mux_state));
+
+ /* Remove flipped from the state for easier compraisons */
+ mux_state = mux_state & ~USB_PD_MUX_POLARITY_INVERTED;
+
+ RETURN_ERROR(anx7483_set_default_tuning(me, mux_state));
+
+ if (mux_state == USB_PD_MUX_USB_ENABLED) {
+ RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_URX1,
+ ANX7483_EQ_SETTING_12_5DB));
+ RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_URX2,
+ ANX7483_EQ_SETTING_12_5DB));
+ RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_DRX1,
+ ANX7483_EQ_SETTING_12_5DB));
+ RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_DRX2,
+ ANX7483_EQ_SETTING_12_5DB));
+ } else if (mux_state == USB_PD_MUX_DP_ENABLED) {
+ RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_URX1,
+ ANX7483_EQ_SETTING_12_5DB));
+ RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_URX2,
+ ANX7483_EQ_SETTING_12_5DB));
+ RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_UTX1,
+ ANX7483_EQ_SETTING_12_5DB));
+ RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_UTX2,
+ ANX7483_EQ_SETTING_12_5DB));
+ } else if (mux_state == USB_PD_MUX_DOCK && !flipped) {
+ RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_URX1,
+ ANX7483_EQ_SETTING_12_5DB));
+ RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_URX2,
+ ANX7483_EQ_SETTING_12_5DB));
+ RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_DRX1,
+ ANX7483_EQ_SETTING_12_5DB));
+ RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_UTX2,
+ ANX7483_EQ_SETTING_12_5DB));
+ } else if (mux_state == USB_PD_MUX_DOCK && flipped) {
+ RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_URX1,
+ ANX7483_EQ_SETTING_12_5DB));
+ RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_URX2,
+ ANX7483_EQ_SETTING_12_5DB));
+ RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_UTX1,
+ ANX7483_EQ_SETTING_12_5DB));
+ RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_DRX2,
+ ANX7483_EQ_SETTING_12_5DB));
+ }
+
+ return EC_SUCCESS;
+}
+
+int board_c1_ps8818_mux_set(const struct usb_mux *me, mux_state_t mux_state)
+{
+ CPRINTSUSB("C1: PS8818 mux using default tuning");
+
+ /* Once a DP connection is established, we need to set IN_HPD */
+ if (mux_state & USB_PD_MUX_DP_ENABLED)
+ ioex_set_level(IOEX_USB_C1_HPD_IN_DB, 1);
+ else
+ ioex_set_level(IOEX_USB_C1_HPD_IN_DB, 0);
+
+ return 0;
+}