Skip to content

Commit a031b02

Browse files
author
Josh Tsai
committed
Implement standalone mode
Signed-off-by: Josh Tsai <josh_tsai@compal.corp-partner.google.com>
1 parent 7a61a89 commit a031b02

File tree

7 files changed

+64
-12
lines changed

7 files changed

+64
-12
lines changed

board/hx30/board.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
#include "chipset.h"
2222
#include "console.h"
2323
#include "cypress5525.h"
24+
#include "diagnostics.h"
2425
#include "driver/als_cm32183.h"
2526
#include "driver/accel_kionix.h"
2627
#include "driver/accel_kx022.h"
@@ -669,13 +670,16 @@ void charger_psys_enable(uint8_t enable)
669670
static void board_init(void)
670671
{
671672
uint8_t memcap;
673+
uint8_t standalone;
672674

673675
board_spi_read_byte(SPI_AC_BOOT_OFFSET, &memcap);
676+
board_spi_read_byte(SPI_STANDALONE_OFFSET, &standalone);
674677

675678
if (memcap && !ac_boot_status())
676679
*host_get_customer_memmap(0x48) = (memcap & BIT(0));
677680

678681
check_chassis_open(1);
682+
set_standalone_mode((int)standalone);
679683

680684
gpio_enable_interrupt(GPIO_SOC_ENBKL);
681685
gpio_enable_interrupt(GPIO_ON_OFF_BTN_L);

board/hx30/board.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -337,6 +337,7 @@
337337
#define CONFIG_FLASH_SIZE 0x100000
338338
#define CONFIG_SPI_FLASH_W25Q80
339339
#define SPI_AC_BOOT_OFFSET 0x00
340+
#define SPI_STANDALONE_OFFSET 0x01
340341

341342
/*
342343
* Enable extra SPI flash and generic SPI

board/hx30/diagnostics.c

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,19 @@ uint8_t bios_complete;
3232
uint8_t fan_seen;
3333
uint8_t s0_seen;
3434
uint8_t run_diagnostics;
35+
36+
int standalone_mode;
37+
38+
void set_standalone_mode(int enable)
39+
{
40+
standalone_mode = enable;
41+
}
42+
43+
int get_standalone_mode(void)
44+
{
45+
return standalone_mode;
46+
}
47+
3548
void reset_diagnostics(void)
3649
{
3750
hw_diagnostics =0;
@@ -100,9 +113,8 @@ bool diagnostics_tick(void)
100113
set_hw_diagnostic(DIAGNOSTICS_NO_S0, true);
101114
}
102115

103-
if (charge_get_state() == PWR_STATE_ERROR){
104-
set_hw_diagnostic(DIAGNOSTICS_HW_NO_BATTERY, true);
105-
}
116+
if ((charge_get_state() == PWR_STATE_ERROR) && !standalone_mode)
117+
set_hw_diagnostic(DIAGNOSTICS_HW_NO_BATTERY, true);
106118

107119
if (hw_diagnostic_tick & 0x01) {
108120
/*off*/
@@ -163,13 +175,13 @@ static void diagnostic_check_tempsensor_deferred(void)
163175
device_id[0] = get_hardware_id(ADC_TP_BOARD_ID);
164176
device_id[1] = get_hardware_id(ADC_AUDIO_BOARD_ID);
165177

166-
if (device_id[0] <= BOARD_VERSION_1 || device_id[0] >= BOARD_VERSION_14 ||
167-
(high_adc[0] - low_adc[0]) > ADC_NC_DELTA) {
178+
if ((device_id[0] <= BOARD_VERSION_1 || device_id[0] >= BOARD_VERSION_14 ||
179+
(high_adc[0] - low_adc[0]) > ADC_NC_DELTA) && !standalone_mode) {
168180
set_hw_diagnostic(DIAGNOSTICS_TOUCHPAD, true);
169181
}
170182

171-
if (device_id[1] <= BOARD_VERSION_1 || device_id[1] >= BOARD_VERSION_14 ||
172-
(high_adc[1] - low_adc[1]) > ADC_NC_DELTA) {
183+
if ((device_id[1] <= BOARD_VERSION_1 || device_id[1] >= BOARD_VERSION_14 ||
184+
(high_adc[1] - low_adc[1]) > ADC_NC_DELTA) && !standalone_mode) {
173185
set_hw_diagnostic(DIAGNOSTICS_AUDIO_DAUGHTERBOARD, true);
174186
}
175187
CPRINTS("TP Ver %d, delta %d", device_id[0], high_adc[0] - low_adc[0]);
@@ -204,6 +216,6 @@ void set_bios_diagnostic(uint8_t code)
204216

205217
if (code == CODE_DDR_FAIL)
206218
set_hw_diagnostic(DIAGNOSTICS_NO_DDR, true);
207-
if (code == CODE_NO_EDP)
219+
if (code == CODE_NO_EDP && !standalone_mode)
208220
set_hw_diagnostic(DIAGNOSTICS_NO_EDP, true);
209-
}
221+
}

board/hx30/diagnostics.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,9 @@ enum diagnostics_device_idx {
4343
void set_hw_diagnostic(enum diagnostics_device_idx idx, bool error);
4444
void set_bios_diagnostic(uint8_t code);
4545

46+
void set_standalone_mode(int enable);
47+
int get_standalone_mode(void);
48+
4649
void reset_diagnostics(void);
4750

4851
void cancel_diagnostics(void);

board/hx30/host_command_customization.c

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -339,3 +339,26 @@ static enum ec_status thermal_qevent(struct host_cmd_handler_args *args)
339339
return EC_ERROR_INVAL;
340340
}
341341
DECLARE_HOST_COMMAND(EC_CMD_THERMAL_QEVENT, thermal_qevent, EC_VER_MASK(0));
342+
343+
344+
static enum ec_status standalone_mode(struct host_cmd_handler_args *args)
345+
{
346+
const struct ec_params_standalone_mode *p = args->params;
347+
static int curr;
348+
349+
curr = get_standalone_mode();
350+
351+
if ((int)p->enable != curr) {
352+
/*
353+
* BIOS writes the host command after board initial,
354+
* if curr mode is different with parameters from host command,
355+
* updates the SPI ROM value, also updates the current standalone mode.
356+
*/
357+
358+
board_spi_write_byte(SPI_STANDALONE_OFFSET, p->enable);
359+
set_standalone_mode((int)p->enable);
360+
return EC_RES_SUCCESS;
361+
}
362+
return EC_ERROR_INVAL;
363+
}
364+
DECLARE_HOST_COMMAND(EC_CMD_STANDALONE_MODE, standalone_mode, EC_VER_MASK(0));

board/hx30/host_command_customization.h

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,4 +216,10 @@ struct ec_params_thermal_qevent_control {
216216
uint8_t send_event;
217217
} __ec_align1;
218218

219-
#endif /* __HOST_COMMAND_CUSTOMIZATION_H */
219+
#define EC_CMD_STANDALONE_MODE 0x3E13
220+
221+
struct ec_params_standalone_mode {
222+
uint8_t enable;
223+
} __ec_align1;
224+
225+
#endif /* __HOST_COMMAND_CUSTOMIZATION_H */

board/hx30/led.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -251,8 +251,11 @@ static void led_set_battery(void)
251251
(battery_ticks & 0x2) ? EC_LED_COLOR_RED : EC_LED_COLOR_BLUE);
252252
return;
253253
}
254-
/* Blink both mainboard LEDS as a warning if the chasssis is open and power is on */
255-
if (!gpio_get_level(GPIO_CHASSIS_OPEN)) {
254+
/*
255+
* Blink both mainboard LEDS as a warning if the chasssis is open and power is on,
256+
* if EC in standalone mode, disable the blinking behavior when chassis is open.
257+
*/
258+
if (!gpio_get_level(GPIO_CHASSIS_OPEN) && !get_standalone_mode()) {
256259
set_pwm_led_color(PWM_LED0, (battery_ticks & 0x2) ? EC_LED_COLOR_RED : -1);
257260
set_pwm_led_color(PWM_LED1, (battery_ticks & 0x2) ? EC_LED_COLOR_RED : -1);
258261
return;

0 commit comments

Comments
 (0)