From 13c68a3e7a85119367ddbcd130518163e4dcd619 Mon Sep 17 00:00:00 2001 From: Keith Short Date: Thu, 20 Oct 2022 11:35:45 -0600 Subject: zephyr: rename projects folder to program Renme the projects folder to program for consistency with the name scheme used by the boxster configuration. BUG=b:254097139 BRANCH=none TEST=zmake compare-builds -a TEST=twister Signed-off-by: Keith Short Change-Id: Ib56a57f1e5942e6dd0460e3be81722896eed72af Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3968444 Reviewed-by: Jeremy Bettis Commit-Queue: Jeremy Bettis --- zephyr/program/nissa/pujjo/src/charger.c | 64 +++++++ zephyr/program/nissa/pujjo/src/fan.c | 43 +++++ zephyr/program/nissa/pujjo/src/form_factor.c | 66 ++++++++ zephyr/program/nissa/pujjo/src/hdmi.c | 12 ++ zephyr/program/nissa/pujjo/src/keyboard.c | 29 ++++ zephyr/program/nissa/pujjo/src/led.c | 134 +++++++++++++++ zephyr/program/nissa/pujjo/src/usbc.c | 242 +++++++++++++++++++++++++++ 7 files changed, 590 insertions(+) create mode 100644 zephyr/program/nissa/pujjo/src/charger.c create mode 100644 zephyr/program/nissa/pujjo/src/fan.c create mode 100644 zephyr/program/nissa/pujjo/src/form_factor.c create mode 100644 zephyr/program/nissa/pujjo/src/hdmi.c create mode 100644 zephyr/program/nissa/pujjo/src/keyboard.c create mode 100644 zephyr/program/nissa/pujjo/src/led.c create mode 100644 zephyr/program/nissa/pujjo/src/usbc.c (limited to 'zephyr/program/nissa/pujjo/src') diff --git a/zephyr/program/nissa/pujjo/src/charger.c b/zephyr/program/nissa/pujjo/src/charger.c new file mode 100644 index 0000000000..f1f1d57790 --- /dev/null +++ b/zephyr/program/nissa/pujjo/src/charger.c @@ -0,0 +1,64 @@ +/* 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 + +#include "battery.h" +#include "charger.h" +#include "charger/isl923x_public.h" +#include "driver/tcpm/raa489000.h" +#include "driver/charger/isl923x.h" +#include "console.h" +#include "extpower.h" +#include "usb_pd.h" +#include "nissa_common.h" +#include "hooks.h" + +LOG_MODULE_DECLARE(nissa, CONFIG_NISSA_LOG_LEVEL); + +int extpower_is_present(void) +{ + int port; + int rv; + bool acok; + + for (port = 0; port < board_get_usb_pd_port_count(); port++) { + rv = raa489000_is_acok(port, &acok); + if ((rv == EC_SUCCESS) && acok) + return 1; + } + + return 0; +} + +/* + * Pujjo does not have a GPIO indicating whether extpower is present, + * so detect using the charger(s). + */ +__override void board_check_extpower(void) +{ + static int last_extpower_present; + int extpower_present = extpower_is_present(); + + if (last_extpower_present ^ extpower_present) + extpower_handle_update(extpower_present); + + last_extpower_present = extpower_present; +} + +__override void board_hibernate(void) +{ + /* Shut down the chargers */ + raa489000_hibernate(0, true); + LOG_INF("Charger(s) hibernated"); + cflush(); +} + +static void charger_prochot_init(void) +{ + isl923x_set_ac_prochot(CHARGER_SOLO, 3500); + isl923x_set_dc_prochot(CHARGER_SOLO, 6528); +} +DECLARE_HOOK(HOOK_INIT, charger_prochot_init, HOOK_PRIO_POST_FIRST); diff --git a/zephyr/program/nissa/pujjo/src/fan.c b/zephyr/program/nissa/pujjo/src/fan.c new file mode 100644 index 0000000000..97323a7edf --- /dev/null +++ b/zephyr/program/nissa/pujjo/src/fan.c @@ -0,0 +1,43 @@ +/* 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 +#include +#include + +#include "cros_cbi.h" +#include "fan.h" +#include "gpio/gpio.h" +#include "hooks.h" + +#include "nissa_common.h" + +LOG_MODULE_DECLARE(nissa, CONFIG_NISSA_LOG_LEVEL); + +/* + * Pujjo fan support + */ +static void fan_init(void) +{ + int ret; + uint32_t val; + /* + * Retrieve the fan config. + */ + ret = cros_cbi_get_fw_config(FW_FAN, &val); + if (ret != 0) { + LOG_ERR("Error retrieving CBI FW_CONFIG field %d", FW_FAN); + return; + } + if (val != FW_FAN_PRESENT) { + /* Disable the fan */ + fan_set_count(0); + } else { + /* Configure the fan enable GPIO */ + gpio_pin_configure_dt(GPIO_DT_FROM_NODELABEL(gpio_fan_enable), + GPIO_OUTPUT); + } +} +DECLARE_HOOK(HOOK_INIT, fan_init, HOOK_PRIO_POST_FIRST); diff --git a/zephyr/program/nissa/pujjo/src/form_factor.c b/zephyr/program/nissa/pujjo/src/form_factor.c new file mode 100644 index 0000000000..6b02a258bc --- /dev/null +++ b/zephyr/program/nissa/pujjo/src/form_factor.c @@ -0,0 +1,66 @@ +/* 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 +#include + +#include "accelgyro.h" +#include "button.h" +#include "cros_board_info.h" +#include "cros_cbi.h" +#include "driver/accelgyro_bmi323.h" +#include "driver/accelgyro_lsm6dsm.h" +#include "gpio/gpio_int.h" +#include "hooks.h" +#include "motionsense_sensors.h" +#include "motion_sense.h" +#include "tablet_mode.h" + +#include "nissa_common.h" + +LOG_MODULE_DECLARE(nissa, CONFIG_NISSA_LOG_LEVEL); + +static bool use_alt_sensor; + +void motion_interrupt(enum gpio_signal signal) +{ + if (use_alt_sensor) + lsm6dsm_interrupt(signal); + else + bmi3xx_interrupt(signal); +} + +static void sensor_init(void) +{ + int ret; + uint32_t val; + /* check which base sensor is used for motion_interrupt */ + use_alt_sensor = cros_cbi_ssfc_check_match( + CBI_SSFC_VALUE_ID(DT_NODELABEL(base_sensor_1))); + + motion_sensors_check_ssfc(); + + /* Check if it's tablet or not */ + ret = cros_cbi_get_fw_config(FW_TABLET, &val); + if (ret != 0) { + LOG_ERR("Error retrieving CBI FW_CONFIG field %d", FW_TABLET); + return; + } + if (val == FW_TABLET_NOT_PRESENT) { + LOG_INF("Clamshell: disable motionsense function."); + motion_sensor_count = 0; + gmr_tablet_switch_disable(); + gpio_disable_dt_interrupt(GPIO_INT_FROM_NODELABEL(int_imu)); + gpio_pin_configure_dt(GPIO_DT_FROM_NODELABEL(gpio_imu_int_l), + GPIO_DISCONNECTED); + + LOG_INF("Clamshell: disable volume button function."); + button_disable_gpio(BUTTON_VOLUME_UP); + button_disable_gpio(BUTTON_VOLUME_DOWN); + } else { + LOG_INF("Tablet: Enable motionsense function."); + } +} +DECLARE_HOOK(HOOK_INIT, sensor_init, HOOK_PRIO_POST_I2C); diff --git a/zephyr/program/nissa/pujjo/src/hdmi.c b/zephyr/program/nissa/pujjo/src/hdmi.c new file mode 100644 index 0000000000..9461e7c53e --- /dev/null +++ b/zephyr/program/nissa/pujjo/src/hdmi.c @@ -0,0 +1,12 @@ +/* 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 "nissa_hdmi.h" + +__override void nissa_configure_hdmi_power_gpios(void) +{ + /* Pujjo needs to drive VCC enable but not core rails */ + nissa_configure_hdmi_vcc(); +} diff --git a/zephyr/program/nissa/pujjo/src/keyboard.c b/zephyr/program/nissa/pujjo/src/keyboard.c new file mode 100644 index 0000000000..1587030080 --- /dev/null +++ b/zephyr/program/nissa/pujjo/src/keyboard.c @@ -0,0 +1,29 @@ +/* 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" + +static const struct ec_response_keybd_config pujjo_kb = { + .num_top_row_keys = 10, + .action_keys = { + TK_BACK, /* T1 */ + TK_REFRESH, /* T2 */ + TK_FULLSCREEN, /* T3 */ + TK_OVERVIEW, /* T4 */ + TK_BRIGHTNESS_DOWN, /* T5 */ + TK_BRIGHTNESS_UP, /* T6 */ + TK_MICMUTE, /* 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 &pujjo_kb; +} diff --git a/zephyr/program/nissa/pujjo/src/led.c b/zephyr/program/nissa/pujjo/src/led.c new file mode 100644 index 0000000000..bd04af5a25 --- /dev/null +++ b/zephyr/program/nissa/pujjo/src/led.c @@ -0,0 +1,134 @@ +/* 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. + */ + +/* Pujjo specific PWM LED settings: there are 2 LEDs on each side of the board, + * each one can be controlled separately. The LED colors are white or amber, + * and the default behavior is tied to the charging process: both sides are + * amber while charging the battery and white when the battery is charged. + */ + +#include "common.h" +#include "led_onoff_states.h" +#include "led_common.h" +#include "gpio.h" + +#define CPRINTS(format, args...) cprints(CC_CHARGER, format, ##args) +#define CPRINTF(format, args...) cprintf(CC_CHARGER, format, ##args) + +#define LED_OFF_LVL 1 +#define LED_ON_LVL 0 + +__override const int led_charge_lvl_1 = 5; + +__override const int led_charge_lvl_2 = 97; + +__override struct led_descriptor + led_bat_state_table[LED_NUM_STATES][LED_NUM_PHASES] = { + [STATE_CHARGING_LVL_1] = { { EC_LED_COLOR_RED, + LED_INDEFINITE } }, + [STATE_CHARGING_LVL_2] = { { EC_LED_COLOR_AMBER, + LED_INDEFINITE } }, + [STATE_CHARGING_FULL_CHARGE] = { { EC_LED_COLOR_GREEN, + LED_INDEFINITE } }, + [STATE_DISCHARGE_S0] = { { LED_OFF, LED_INDEFINITE } }, + [STATE_DISCHARGE_S3] = { { LED_OFF, LED_INDEFINITE } }, + [STATE_DISCHARGE_S5] = { { LED_OFF, LED_INDEFINITE } }, + [STATE_BATTERY_ERROR] = { { EC_LED_COLOR_RED, 1 * LED_ONE_SEC }, + { LED_OFF, 1 * LED_ONE_SEC } }, + [STATE_FACTORY_TEST] = { { EC_LED_COLOR_RED, 2 * LED_ONE_SEC }, + { EC_LED_COLOR_GREEN, + 2 * LED_ONE_SEC } }, + }; + +__override const struct led_descriptor + led_pwr_state_table[PWR_LED_NUM_STATES][LED_NUM_PHASES] = { + [PWR_LED_STATE_ON] = { { EC_LED_COLOR_WHITE, LED_INDEFINITE } }, + [PWR_LED_STATE_SUSPEND_AC] = { { EC_LED_COLOR_WHITE, + 3 * LED_ONE_SEC }, + { LED_OFF, 0.5 * LED_ONE_SEC } }, + [PWR_LED_STATE_SUSPEND_NO_AC] = { { EC_LED_COLOR_WHITE, + 3 * LED_ONE_SEC }, + { LED_OFF, + 0.5 * LED_ONE_SEC } }, + [PWR_LED_STATE_OFF] = { { LED_OFF, LED_INDEFINITE } }, + }; + +const enum ec_led_id supported_led_ids[] = { EC_LED_ID_BATTERY_LED, + EC_LED_ID_POWER_LED }; + +const int supported_led_ids_count = ARRAY_SIZE(supported_led_ids); + +__override void led_set_color_power(enum ec_led_colors color) +{ + if (color == EC_LED_COLOR_WHITE) + gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(gpio_power_led), + LED_ON_LVL); + else + /* LED_OFF and unsupported colors */ + gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(gpio_power_led), + LED_OFF_LVL); +} + +__override void led_set_color_battery(enum ec_led_colors color) +{ + switch (color) { + case EC_LED_COLOR_AMBER: + gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(gpio_led_1_odl), + LED_ON_LVL); + gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(gpio_led_2_odl), + LED_ON_LVL); + break; + case EC_LED_COLOR_RED: + gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(gpio_led_1_odl), + LED_ON_LVL); + gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(gpio_led_2_odl), + LED_OFF_LVL); + break; + case EC_LED_COLOR_GREEN: + gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(gpio_led_1_odl), + LED_OFF_LVL); + gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(gpio_led_2_odl), + LED_ON_LVL); + break; + default: /* LED_OFF and other unsupported colors */ + gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(gpio_led_1_odl), + LED_OFF_LVL); + gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(gpio_led_2_odl), + LED_OFF_LVL); + break; + } +} + +void led_get_brightness_range(enum ec_led_id led_id, uint8_t *brightness_range) +{ + if (led_id == EC_LED_ID_BATTERY_LED) { + brightness_range[EC_LED_COLOR_RED] = 1; + brightness_range[EC_LED_COLOR_AMBER] = 1; + brightness_range[EC_LED_COLOR_GREEN] = 1; + } else if (led_id == EC_LED_ID_POWER_LED) { + brightness_range[EC_LED_COLOR_WHITE] = 1; + } +} + +int led_set_brightness(enum ec_led_id led_id, const uint8_t *brightness) +{ + if (led_id == EC_LED_ID_BATTERY_LED) { + if (brightness[EC_LED_COLOR_RED] != 0) + led_set_color_battery(EC_LED_COLOR_RED); + else if (brightness[EC_LED_COLOR_AMBER] != 0) + led_set_color_battery(EC_LED_COLOR_AMBER); + else if (brightness[EC_LED_COLOR_GREEN] != 0) + led_set_color_battery(EC_LED_COLOR_GREEN); + else + led_set_color_battery(LED_OFF); + } else if (led_id == EC_LED_ID_POWER_LED) { + if (brightness[EC_LED_COLOR_WHITE] != 0) + led_set_color_power(EC_LED_COLOR_WHITE); + else + led_set_color_power(LED_OFF); + } + + return EC_SUCCESS; +} diff --git a/zephyr/program/nissa/pujjo/src/usbc.c b/zephyr/program/nissa/pujjo/src/usbc.c new file mode 100644 index 0000000000..5d3d94c243 --- /dev/null +++ b/zephyr/program/nissa/pujjo/src/usbc.c @@ -0,0 +1,242 @@ +/* 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 + +#include "charge_state_v2.h" +#include "chipset.h" +#include "hooks.h" +#include "usb_mux.h" +#include "system.h" +#include "driver/charger/isl923x_public.h" +#include "driver/retimer/anx7483_public.h" +#include "driver/tcpm/tcpci.h" +#include "driver/tcpm/raa489000.h" + +#include "nissa_common.h" + +LOG_MODULE_DECLARE(nissa, CONFIG_NISSA_LOG_LEVEL); + +struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_MAX_COUNT] = { + { + .bus_type = EC_BUS_TYPE_I2C, + .i2c_info = { + .port = I2C_PORT_USB_C0_TCPC, + .addr_flags = RAA489000_TCPC0_I2C_FLAGS, + }, + .drv = &raa489000_tcpm_drv, + /* RAA489000 implements TCPCI 2.0 */ + .flags = TCPC_FLAGS_TCPCI_REV2_0 | + TCPC_FLAGS_VBUS_MONITOR, + }, +}; + +int board_is_sourcing_vbus(int port) +{ + int regval; + + tcpc_read(port, TCPC_REG_POWER_STATUS, ®val); + return !!(regval & TCPC_REG_POWER_STATUS_SOURCING_VBUS); +} + +int board_set_active_charge_port(int port) +{ + int is_real_port = (port >= 0 && port < CONFIG_USB_PD_PORT_MAX_COUNT); + int i; + int old_port; + + if (!is_real_port && port != CHARGE_PORT_NONE) + return EC_ERROR_INVAL; + + old_port = charge_manager_get_active_charge_port(); + + LOG_INF("New chg p%d", port); + + /* Disable all ports. */ + if (port == CHARGE_PORT_NONE) { + for (i = 0; i < CONFIG_USB_PD_PORT_MAX_COUNT; i++) { + tcpc_write(i, TCPC_REG_COMMAND, + TCPC_REG_COMMAND_SNK_CTRL_LOW); + raa489000_enable_asgate(i, false); + } + + return EC_SUCCESS; + } + + /* Check if port is sourcing VBUS. */ + if (board_is_sourcing_vbus(port)) { + LOG_WRN("Skip enable p%d", port); + return EC_ERROR_INVAL; + } + + /* + * Turn off the other ports' sink path FETs, before enabling the + * requested charge port. + */ + for (i = 0; i < CONFIG_USB_PD_PORT_MAX_COUNT; i++) { + if (i == port) + continue; + + if (tcpc_write(i, TCPC_REG_COMMAND, + TCPC_REG_COMMAND_SNK_CTRL_LOW)) + LOG_WRN("p%d: sink path disable failed.", i); + raa489000_enable_asgate(i, false); + } + + /* + * Stop the charger IC from switching while changing ports. Otherwise, + * we can overcurrent the adapter we're switching to. (crbug.com/926056) + */ + if (old_port != CHARGE_PORT_NONE) + charger_discharge_on_ac(1); + + /* Enable requested charge port. */ + if (raa489000_enable_asgate(port, true) || + tcpc_write(port, TCPC_REG_COMMAND, + TCPC_REG_COMMAND_SNK_CTRL_HIGH)) { + LOG_WRN("p%d: sink path enable failed.", port); + charger_discharge_on_ac(0); + return EC_ERROR_UNKNOWN; + } + + /* Allow the charger IC to begin/continue switching. */ + charger_discharge_on_ac(0); + + return EC_SUCCESS; +} + +uint16_t tcpc_get_alert_status(void) +{ + uint16_t status = 0; + int regval; + + /* + * The interrupt line is shared between the TCPC and BC1.2 detector IC. + * Therefore, go out and actually read the alert registers to report the + * alert status. + */ + if (!gpio_pin_get_dt(GPIO_DT_FROM_NODELABEL(gpio_usb_c0_int_odl))) { + if (!tcpc_read16(0, TCPC_REG_ALERT, ®val)) { + /* The TCPCI Rev 1.0 spec says to ignore bits 14:12. */ + if (!(tcpc_config[0].flags & TCPC_FLAGS_TCPCI_REV2_0)) + regval &= ~((1 << 14) | (1 << 13) | (1 << 12)); + + if (regval) + status |= PD_STATUS_TCPC_ALERT_0; + } + } + return status; +} + +void pd_power_supply_reset(int port) +{ + /* Disable VBUS */ + tcpc_write(port, TCPC_REG_COMMAND, TCPC_REG_COMMAND_SRC_CTRL_LOW); + + /* Notify host of power info change. */ + pd_send_host_event(PD_EVENT_POWER_CHANGE); +} + +__override void typec_set_source_current_limit(int port, enum tcpc_rp_value rp) +{ + if (port < 0 || port >= CONFIG_USB_PD_PORT_MAX_COUNT) + return; + + raa489000_set_output_current(port, rp); +} + +int pd_set_power_supply_ready(int port) +{ + int rv; + + if (port >= CONFIG_USB_PD_PORT_MAX_COUNT) + return EC_ERROR_INVAL; + + /* Disable charging. */ + rv = tcpc_write(port, TCPC_REG_COMMAND, TCPC_REG_COMMAND_SNK_CTRL_LOW); + if (rv) + return rv; + + /* Our policy is not to source VBUS when the AP is off. */ + if (chipset_in_state(CHIPSET_STATE_ANY_OFF)) + return EC_ERROR_NOT_POWERED; + + /* Provide Vbus. */ + rv = tcpc_write(port, TCPC_REG_COMMAND, TCPC_REG_COMMAND_SRC_CTRL_HIGH); + if (rv) + return rv; + + rv = raa489000_enable_asgate(port, true); + if (rv) + return rv; + + /* Notify host of power info change. */ + pd_send_host_event(PD_EVENT_POWER_CHANGE); + + return EC_SUCCESS; +} + +void board_reset_pd_mcu(void) +{ + /* + * TODO(b:147316511): could send a reset command to the TCPC here + * if needed. + */ +} + +/* + * Because the TCPCs and BC1.2 chips share interrupt lines, it's possible + * for an interrupt to be lost if one asserts the IRQ, the other does the same + * then the first releases it: there will only be one falling edge to trigger + * the interrupt, and the line will be held low. We handle this by running a + * deferred check after a falling edge to see whether the IRQ is still being + * asserted. If it is, we assume an interrupt may have been lost and we need + * to poll each chip for events again. + */ +#define USBC_INT_POLL_DELAY_US 5000 + +static void poll_c0_int(void); +DECLARE_DEFERRED(poll_c0_int); + +static void usbc_interrupt_trigger(int port) +{ + schedule_deferred_pd_interrupt(port); + usb_charger_task_set_event(port, USB_CHG_EVENT_BC12); +} + +static inline void poll_usb_gpio(int port, const struct gpio_dt_spec *gpio, + const struct deferred_data *ud) +{ + if (!gpio_pin_get_dt(gpio)) { + usbc_interrupt_trigger(port); + hook_call_deferred(ud, USBC_INT_POLL_DELAY_US); + } +} + +static void poll_c0_int(void) +{ + poll_usb_gpio(0, GPIO_DT_FROM_NODELABEL(gpio_usb_c0_int_odl), + &poll_c0_int_data); +} + +void usb_interrupt(enum gpio_signal signal) +{ + int port; + const struct deferred_data *ud; + + if (signal == GPIO_SIGNAL(DT_NODELABEL(gpio_usb_c0_int_odl))) { + port = 0; + ud = &poll_c0_int_data; + } + /* + * We've just been called from a falling edge, so there's definitely + * no lost IRQ right now. Cancel any pending check. + */ + hook_call_deferred(ud, -1); + /* Trigger polling of TCPC and BC1.2 in respective tasks */ + usbc_interrupt_trigger(port); + /* Check for lost interrupts in a bit */ + hook_call_deferred(ud, USBC_INT_POLL_DELAY_US); +} -- cgit v1.2.1 From 05dee9db4e4d863665925dfa374f37b9641af036 Mon Sep 17 00:00:00 2001 From: Peter Marheine Date: Fri, 4 Nov 2022 15:30:24 +1100 Subject: pujjo: enable interrupts for lid accel The BMA4xx driver now supports interrupts, so stop polling the lid accel. BUG=b:254380338 TEST=accelinfo still shows accurate lid angle on pujjo with LIS2DW12 sensor installed BRANCH=none LOW_COVERAGE_REASON=board-specific code is not tested Signed-off-by: Peter Marheine Change-Id: I29b8675736d38e1f737f9faf139ae9aa0058758c Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4005683 Reviewed-by: Andrew McRae Code-Coverage: Zoss --- zephyr/program/nissa/pujjo/src/form_factor.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'zephyr/program/nissa/pujjo/src') diff --git a/zephyr/program/nissa/pujjo/src/form_factor.c b/zephyr/program/nissa/pujjo/src/form_factor.c index 6b02a258bc..1b096e8fa4 100644 --- a/zephyr/program/nissa/pujjo/src/form_factor.c +++ b/zephyr/program/nissa/pujjo/src/form_factor.c @@ -10,6 +10,8 @@ #include "button.h" #include "cros_board_info.h" #include "cros_cbi.h" +#include "driver/accel_bma4xx.h" +#include "driver/accel_lis2dw12_public.h" #include "driver/accelgyro_bmi323.h" #include "driver/accelgyro_lsm6dsm.h" #include "gpio/gpio_int.h" @@ -23,6 +25,7 @@ LOG_MODULE_DECLARE(nissa, CONFIG_NISSA_LOG_LEVEL); static bool use_alt_sensor; +static bool use_alt_lid_accel; void motion_interrupt(enum gpio_signal signal) { @@ -32,13 +35,23 @@ void motion_interrupt(enum gpio_signal signal) bmi3xx_interrupt(signal); } +void lid_accel_interrupt(enum gpio_signal signal) +{ + if (use_alt_lid_accel) + lis2dw12_interrupt(signal); + else + bma4xx_interrupt(signal); +} + static void sensor_init(void) { int ret; uint32_t val; - /* check which base sensor is used for motion_interrupt */ + /* check which sensors are installed */ use_alt_sensor = cros_cbi_ssfc_check_match( CBI_SSFC_VALUE_ID(DT_NODELABEL(base_sensor_1))); + use_alt_lid_accel = cros_cbi_ssfc_check_match( + CBI_SSFC_VALUE_ID(DT_NODELABEL(lid_sensor_1))); motion_sensors_check_ssfc(); -- cgit v1.2.1 From 9ff48ff131b44af163190aca38673a952652f90d Mon Sep 17 00:00:00 2001 From: Jeremy Bettis Date: Fri, 18 Nov 2022 15:49:50 -0700 Subject: zephyr/program: Sort header files Sort all headers in zephyr/test with the clang-format rules used by the zephyr project. BRANCH=None BUG=b:247100970 TEST=zmake build -a TEST=./twister --clobber -v -i TEST=make -j$(nproc) buildall_only runtests TEST=zmake compare-builds Signed-off-by: Jeremy Bettis Change-Id: Ibd81df9a27fc0c934b4134106d6f09487439c245 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4039149 Commit-Queue: Jeremy Bettis Reviewed-by: Aaron Massey Tested-by: Jeremy Bettis Code-Coverage: Zoss --- zephyr/program/nissa/pujjo/src/charger.c | 12 ++++++------ zephyr/program/nissa/pujjo/src/fan.c | 9 ++++----- zephyr/program/nissa/pujjo/src/form_factor.c | 9 ++++----- zephyr/program/nissa/pujjo/src/led.c | 4 ++-- zephyr/program/nissa/pujjo/src/usbc.c | 13 ++++++------- 5 files changed, 22 insertions(+), 25 deletions(-) (limited to 'zephyr/program/nissa/pujjo/src') diff --git a/zephyr/program/nissa/pujjo/src/charger.c b/zephyr/program/nissa/pujjo/src/charger.c index f1f1d57790..8763f24793 100644 --- a/zephyr/program/nissa/pujjo/src/charger.c +++ b/zephyr/program/nissa/pujjo/src/charger.c @@ -3,18 +3,18 @@ * found in the LICENSE file. */ -#include - #include "battery.h" #include "charger.h" #include "charger/isl923x_public.h" -#include "driver/tcpm/raa489000.h" -#include "driver/charger/isl923x.h" #include "console.h" +#include "driver/charger/isl923x.h" +#include "driver/tcpm/raa489000.h" #include "extpower.h" -#include "usb_pd.h" -#include "nissa_common.h" #include "hooks.h" +#include "nissa_common.h" +#include "usb_pd.h" + +#include LOG_MODULE_DECLARE(nissa, CONFIG_NISSA_LOG_LEVEL); diff --git a/zephyr/program/nissa/pujjo/src/fan.c b/zephyr/program/nissa/pujjo/src/fan.c index 97323a7edf..8b8634a653 100644 --- a/zephyr/program/nissa/pujjo/src/fan.c +++ b/zephyr/program/nissa/pujjo/src/fan.c @@ -3,17 +3,16 @@ * found in the LICENSE file. */ -#include -#include -#include - #include "cros_cbi.h" #include "fan.h" #include "gpio/gpio.h" #include "hooks.h" - #include "nissa_common.h" +#include +#include +#include + LOG_MODULE_DECLARE(nissa, CONFIG_NISSA_LOG_LEVEL); /* diff --git a/zephyr/program/nissa/pujjo/src/form_factor.c b/zephyr/program/nissa/pujjo/src/form_factor.c index 1b096e8fa4..f160c88d78 100644 --- a/zephyr/program/nissa/pujjo/src/form_factor.c +++ b/zephyr/program/nissa/pujjo/src/form_factor.c @@ -3,9 +3,6 @@ * found in the LICENSE file. */ -#include -#include - #include "accelgyro.h" #include "button.h" #include "cros_board_info.h" @@ -16,11 +13,13 @@ #include "driver/accelgyro_lsm6dsm.h" #include "gpio/gpio_int.h" #include "hooks.h" -#include "motionsense_sensors.h" #include "motion_sense.h" +#include "motionsense_sensors.h" +#include "nissa_common.h" #include "tablet_mode.h" -#include "nissa_common.h" +#include +#include LOG_MODULE_DECLARE(nissa, CONFIG_NISSA_LOG_LEVEL); diff --git a/zephyr/program/nissa/pujjo/src/led.c b/zephyr/program/nissa/pujjo/src/led.c index bd04af5a25..4d859f2764 100644 --- a/zephyr/program/nissa/pujjo/src/led.c +++ b/zephyr/program/nissa/pujjo/src/led.c @@ -10,9 +10,9 @@ */ #include "common.h" -#include "led_onoff_states.h" -#include "led_common.h" #include "gpio.h" +#include "led_common.h" +#include "led_onoff_states.h" #define CPRINTS(format, args...) cprints(CC_CHARGER, format, ##args) #define CPRINTF(format, args...) cprintf(CC_CHARGER, format, ##args) diff --git a/zephyr/program/nissa/pujjo/src/usbc.c b/zephyr/program/nissa/pujjo/src/usbc.c index 5d3d94c243..b56e36049c 100644 --- a/zephyr/program/nissa/pujjo/src/usbc.c +++ b/zephyr/program/nissa/pujjo/src/usbc.c @@ -3,19 +3,18 @@ * found in the LICENSE file. */ -#include - #include "charge_state_v2.h" #include "chipset.h" -#include "hooks.h" -#include "usb_mux.h" -#include "system.h" #include "driver/charger/isl923x_public.h" #include "driver/retimer/anx7483_public.h" -#include "driver/tcpm/tcpci.h" #include "driver/tcpm/raa489000.h" - +#include "driver/tcpm/tcpci.h" +#include "hooks.h" #include "nissa_common.h" +#include "system.h" +#include "usb_mux.h" + +#include LOG_MODULE_DECLARE(nissa, CONFIG_NISSA_LOG_LEVEL); -- cgit v1.2.1 From 62720a799b980f7f47a476f63b99a1d5a51af833 Mon Sep 17 00:00:00 2001 From: Adam Mills Date: Fri, 25 Nov 2022 10:57:20 +1100 Subject: nissa: use device tree for USB-C config Enable support for USB-C configuration on Nissa boards through the device tree rather than in code. BUG=b:213963699 TEST=zmake build -a; Flashed Nereid and Craask devices and verified USB-C ports working. BRANCH=main LOW_COVERAGE_REASON=Nissa specific changes. Change-Id: I2d840da5db5291066f206d9bf3d28dc0bca98307 Signed-off-by: Adam Mills Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4054313 Code-Coverage: Zoss Reviewed-by: Peter Marheine --- zephyr/program/nissa/pujjo/src/usbc.c | 14 -------------- 1 file changed, 14 deletions(-) (limited to 'zephyr/program/nissa/pujjo/src') diff --git a/zephyr/program/nissa/pujjo/src/usbc.c b/zephyr/program/nissa/pujjo/src/usbc.c index b56e36049c..ac93edfd7a 100644 --- a/zephyr/program/nissa/pujjo/src/usbc.c +++ b/zephyr/program/nissa/pujjo/src/usbc.c @@ -18,20 +18,6 @@ LOG_MODULE_DECLARE(nissa, CONFIG_NISSA_LOG_LEVEL); -struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_MAX_COUNT] = { - { - .bus_type = EC_BUS_TYPE_I2C, - .i2c_info = { - .port = I2C_PORT_USB_C0_TCPC, - .addr_flags = RAA489000_TCPC0_I2C_FLAGS, - }, - .drv = &raa489000_tcpm_drv, - /* RAA489000 implements TCPCI 2.0 */ - .flags = TCPC_FLAGS_TCPCI_REV2_0 | - TCPC_FLAGS_VBUS_MONITOR, - }, -}; - int board_is_sourcing_vbus(int port) { int regval; -- cgit v1.2.1