Skip to content

Commit b5b44c7

Browse files
authored
Merge pull request #507 from FrameworkComputer/hx30.standalone
Implement standalone mode
2 parents a90650c + 91741bc commit b5b44c7

File tree

7 files changed

+74
-24
lines changed

7 files changed

+74
-24
lines changed

board/hx30/board.c

Lines changed: 9 additions & 5 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"
@@ -432,9 +433,9 @@ bool ac_poweron_check(void)
432433
{
433434
uint8_t memcap;
434435

435-
board_spi_read_byte(SPI_AC_BOOT_OFFSET, &memcap);
436+
board_spi_read_byte(SPI_BIOS_SETUP, &memcap);
436437

437-
return memcap ? true : false;
438+
return (memcap & BIOS_SETUP_AC_BOOT) ? true : false;
438439
}
439440

440441
int poweron_reason_acin(void)
@@ -670,10 +671,13 @@ static void board_init(void)
670671
{
671672
uint8_t memcap;
672673

673-
board_spi_read_byte(SPI_AC_BOOT_OFFSET, &memcap);
674+
board_spi_read_byte(SPI_BIOS_SETUP, &memcap);
674675

675-
if (memcap && !ac_boot_status())
676-
*host_get_customer_memmap(0x48) = (memcap & BIT(0));
676+
if ((memcap & BIOS_SETUP_AC_BOOT) && !ac_boot_status())
677+
*host_get_customer_memmap(0x48) = (memcap & BIOS_SETUP_AC_BOOT);
678+
679+
if (memcap & BIOS_SETUP_STANDALONE)
680+
set_standalone_mode(1);
677681

678682
check_chassis_open(1);
679683

board/hx30/board.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -336,7 +336,10 @@
336336
*/
337337
#define CONFIG_FLASH_SIZE 0x100000
338338
#define CONFIG_SPI_FLASH_W25Q80
339-
#define SPI_AC_BOOT_OFFSET 0x00
339+
#define SPI_BIOS_SETUP 0x00
340+
341+
#define BIOS_SETUP_AC_BOOT BIT(0)
342+
#define BIOS_SETUP_STANDALONE BIT(1)
340343

341344
/*
342345
* Enable extra SPI flash and generic SPI

board/hx30/diagnostics.c

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,20 @@ 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+
CPRINTS("set standalone = %d", enable);
41+
standalone_mode = enable;
42+
}
43+
44+
int get_standalone_mode(void)
45+
{
46+
return standalone_mode;
47+
}
48+
3549
void reset_diagnostics(void)
3650
{
3751
hw_diagnostics =0;
@@ -100,9 +114,8 @@ bool diagnostics_tick(void)
100114
set_hw_diagnostic(DIAGNOSTICS_NO_S0, true);
101115
}
102116

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

107120
if (hw_diagnostic_tick & 0x01) {
108121
/*off*/
@@ -163,13 +176,13 @@ static void diagnostic_check_tempsensor_deferred(void)
163176
device_id[0] = get_hardware_id(ADC_TP_BOARD_ID);
164177
device_id[1] = get_hardware_id(ADC_AUDIO_BOARD_ID);
165178

166-
if (device_id[0] <= BOARD_VERSION_1 || device_id[0] >= BOARD_VERSION_14 ||
167-
(high_adc[0] - low_adc[0]) > ADC_NC_DELTA) {
179+
if ((device_id[0] <= BOARD_VERSION_1 || device_id[0] >= BOARD_VERSION_14 ||
180+
(high_adc[0] - low_adc[0]) > ADC_NC_DELTA) && !standalone_mode) {
168181
set_hw_diagnostic(DIAGNOSTICS_TOUCHPAD, true);
169182
}
170183

171-
if (device_id[1] <= BOARD_VERSION_1 || device_id[1] >= BOARD_VERSION_14 ||
172-
(high_adc[1] - low_adc[1]) > ADC_NC_DELTA) {
184+
if ((device_id[1] <= BOARD_VERSION_1 || device_id[1] >= BOARD_VERSION_14 ||
185+
(high_adc[1] - low_adc[1]) > ADC_NC_DELTA) && !standalone_mode) {
173186
set_hw_diagnostic(DIAGNOSTICS_AUDIO_DAUGHTERBOARD, true);
174187
}
175188
CPRINTS("TP Ver %d, delta %d", device_id[0], high_adc[0] - low_adc[0]);
@@ -204,6 +217,6 @@ void set_bios_diagnostic(uint8_t code)
204217

205218
if (code == CODE_DDR_FAIL)
206219
set_hw_diagnostic(DIAGNOSTICS_NO_DDR, true);
207-
if (code == CODE_NO_EDP)
220+
if (code == CODE_NO_EDP && !standalone_mode)
208221
set_hw_diagnostic(DIAGNOSTICS_NO_EDP, true);
209-
}
222+
}

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: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -57,18 +57,25 @@ void set_non_acpi_mode(int enable)
5757
static void sci_enable(void)
5858
{
5959
uint8_t dataInSPI;
60-
int dataInEMI;
60+
int biosSetup = 0;
61+
6162

6263
if (*host_get_customer_memmap(0x00) & BIT(0)) {
6364
/* when host set EC driver ready flag, EC need to enable SCI */
6465
lpc_set_host_event_mask(LPC_HOST_EVENT_SCI, SCI_HOST_EVENT_MASK);
6566
update_soc_power_limit(true, false);
6667

6768
/* check the Flag in EEPROM and EMI, if values are different, write the value in EEPROM */
68-
board_spi_read_byte(SPI_AC_BOOT_OFFSET, &dataInSPI);
69-
dataInEMI = ac_boot_status();
70-
if ((int)dataInSPI != dataInEMI)
71-
board_spi_write_byte(SPI_AC_BOOT_OFFSET, (uint8_t)dataInEMI);
69+
board_spi_read_byte(SPI_BIOS_SETUP, &dataInSPI);
70+
71+
if (ac_boot_status())
72+
biosSetup |= BIT(0);
73+
74+
if (get_standalone_mode())
75+
biosSetup |= BIT(1);
76+
77+
if ((int)dataInSPI != biosSetup)
78+
board_spi_write_byte(SPI_BIOS_SETUP, (uint8_t)biosSetup);
7279

7380
set_non_acpi_mode(0);
7481
} else
@@ -158,7 +165,7 @@ static enum ec_status factory_mode(struct host_cmd_handler_args *args)
158165
system_set_bbram(STSTEM_BBRAM_IDX_CHASSIS_MAGIC, EC_PARAM_CHASSIS_BBRAM_MAGIC);
159166
system_set_bbram(STSTEM_BBRAM_IDX_CHASSIS_VTR_OPEN, 0);
160167
system_set_bbram(STSTEM_BBRAM_IDX_CHASSIS_WAS_OPEN, 0);
161-
board_spi_write_byte(SPI_AC_BOOT_OFFSET, 0);
168+
board_spi_write_byte(SPI_BIOS_SETUP, 0);
162169
system_set_bbram(STSTEM_BBRAM_IDX_FP_LED_LEVEL, 0);
163170
}
164171

@@ -339,3 +346,14 @@ static enum ec_status thermal_qevent(struct host_cmd_handler_args *args)
339346
return EC_ERROR_INVAL;
340347
}
341348
DECLARE_HOST_COMMAND(EC_CMD_THERMAL_QEVENT, thermal_qevent, EC_VER_MASK(0));
349+
350+
351+
static enum ec_status standalone_mode(struct host_cmd_handler_args *args)
352+
{
353+
const struct ec_params_standalone_mode *p = args->params;
354+
355+
set_standalone_mode((int)p->enable);
356+
return EC_RES_SUCCESS;
357+
358+
}
359+
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)