Skip to content

Commit 4ce2336

Browse files
committed
mchp/lfw: make sure we keep the EC on for long operations
Over the past six months with this patch set, I've observed one troubling behavior: the power button would not always work when the machine was powered completely off (EC off) and I clicked the power button. It turns out that the power buttons control VCI_IN[01] and that the VBAT-powered control interface is configured to drive GPIO250 as VCI_OUT based on the status of those inputs. Now, GPIO250 is also known as EC_ON on hx20/30: it controls whether 3VL_EC is on. The MEC1521 manual recommends the following example of using VCI_OUT on a "mobile platform" (abbreviated): 1. A coin cell battery is installed, powering VBAT 2. The power button on VCI_IN0# is pushed causing VCI_OUT to be asserted, powering the VTR rail 3. The EC reconfigured VCI so that firmware controls the VCI_OUT pin. Now, the EC is doing this over in vci_task (hx20/hx30), which is long after LFW has started and jumped to main firmware. The problem is, restoring access to RO and RW images via properly configuring the SPI flash pins' alt mode causes us to try to read from flash on startup. Reading from flash is slightly slower, so we extend the period of time between step 2 and 3 where 3VL_EC is only driven by VCI_IN0#. When the user releases the power button during that window, 3CL_EC is cut and the EC shuts down. This patch fixes the issue by asserting firmware control of VCI_OUT as early as is safe in lfw.
1 parent c187ce1 commit 4ce2336

File tree

3 files changed

+14
-0
lines changed

3 files changed

+14
-0
lines changed

board/hx20/lfw/gpio.inc

+2
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
*/
1616
GPIO(QMSPI_CS0, PIN(055), GPIO_ODR_HIGH)
1717

18+
/* We need to take control of this away from VCI */
19+
GPIO(EC_ON, PIN(0250), GPIO_OUT_HIGH) /* keep +3VL_EC to power on */
1820

1921
/* Alternate functions GPIO definition */
2022

board/hx30/lfw/gpio.inc

+2
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
*/
1616
GPIO(QMSPI_CS0, PIN(055), GPIO_ODR_HIGH)
1717

18+
/* We need to take control of this away from VCI */
19+
GPIO(EC_ON, PIN(0250), GPIO_OUT_HIGH) /* keep +3VL_EC to power on */
1820

1921
/* Alternate functions GPIO definition */
2022

chip/mchp/lfw/ec_lfw.c

+10
Original file line numberDiff line numberDiff line change
@@ -422,6 +422,16 @@ void lfw_main(void)
422422
uart_init();
423423
system_init();
424424

425+
/*
426+
* We need to switch control of VCI_OUT (aliased as EC_ON) away from
427+
* VCI_INx to keep the machine powered even after the user releases the
428+
* power button. This ensures that we can stay on long enough to read
429+
* from SPI flash.
430+
*/
431+
gpio_reset(GPIO_EC_ON);
432+
MCHP_VCI_REGISTER |= MCHP_VCI_REGISTER_FW_CNTRL;
433+
MCHP_VCI_REGISTER |= MCHP_VCI_REGISTER_FW_EXT;
434+
425435
spi_enable(CONFIG_SPI_FLASH_PORT, 1);
426436

427437
uart_puts("littlefw ");

0 commit comments

Comments
 (0)