Skip to content

Commit 91741bc

Browse files
author
Josh Tsai
committed
Use one offset to record the BIOS setup menu
Signed-off-by: Josh Tsai <josh_tsai@compal.corp-partner.google.com>
1 parent a031b02 commit 91741bc

File tree

4 files changed

+28
-30
lines changed

4 files changed

+28
-30
lines changed

board/hx30/board.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -433,9 +433,9 @@ bool ac_poweron_check(void)
433433
{
434434
uint8_t memcap;
435435

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

438-
return memcap ? true : false;
438+
return (memcap & BIOS_SETUP_AC_BOOT) ? true : false;
439439
}
440440

441441
int poweron_reason_acin(void)
@@ -670,16 +670,16 @@ void charger_psys_enable(uint8_t enable)
670670
static void board_init(void)
671671
{
672672
uint8_t memcap;
673-
uint8_t standalone;
674673

675-
board_spi_read_byte(SPI_AC_BOOT_OFFSET, &memcap);
676-
board_spi_read_byte(SPI_STANDALONE_OFFSET, &standalone);
674+
board_spi_read_byte(SPI_BIOS_SETUP, &memcap);
677675

678-
if (memcap && !ac_boot_status())
679-
*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);
680681

681682
check_chassis_open(1);
682-
set_standalone_mode((int)standalone);
683683

684684
gpio_enable_interrupt(GPIO_SOC_ENBKL);
685685
gpio_enable_interrupt(GPIO_ON_OFF_BTN_L);

board/hx30/board.h

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

342344
/*
343345
* Enable extra SPI flash and generic SPI

board/hx30/diagnostics.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ int standalone_mode;
3737

3838
void set_standalone_mode(int enable)
3939
{
40+
CPRINTS("set standalone = %d", enable);
4041
standalone_mode = enable;
4142
}
4243

board/hx30/host_command_customization.c

Lines changed: 15 additions & 20 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

@@ -344,21 +351,9 @@ DECLARE_HOST_COMMAND(EC_CMD_THERMAL_QEVENT, thermal_qevent, EC_VER_MASK(0));
344351
static enum ec_status standalone_mode(struct host_cmd_handler_args *args)
345352
{
346353
const struct ec_params_standalone_mode *p = args->params;
347-
static int curr;
348354

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-
*/
355+
set_standalone_mode((int)p->enable);
356+
return EC_RES_SUCCESS;
357357

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;
363358
}
364359
DECLARE_HOST_COMMAND(EC_CMD_STANDALONE_MODE, standalone_mode, EC_VER_MASK(0));

0 commit comments

Comments
 (0)