Skip to content

Commit

Permalink
mchp/lfw: make sure we keep the EC on for long operations
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
DHowett committed Jan 23, 2023
1 parent c187ce1 commit 4ce2336
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 0 deletions.
2 changes: 2 additions & 0 deletions board/hx20/lfw/gpio.inc
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
*/
GPIO(QMSPI_CS0, PIN(055), GPIO_ODR_HIGH)

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

/* Alternate functions GPIO definition */

Expand Down
2 changes: 2 additions & 0 deletions board/hx30/lfw/gpio.inc
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
*/
GPIO(QMSPI_CS0, PIN(055), GPIO_ODR_HIGH)

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

/* Alternate functions GPIO definition */

Expand Down
10 changes: 10 additions & 0 deletions chip/mchp/lfw/ec_lfw.c
Original file line number Diff line number Diff line change
Expand Up @@ -422,6 +422,16 @@ void lfw_main(void)
uart_init();
system_init();

/*
* We need to switch control of VCI_OUT (aliased as EC_ON) away from
* VCI_INx to keep the machine powered even after the user releases the
* power button. This ensures that we can stay on long enough to read
* from SPI flash.
*/
gpio_reset(GPIO_EC_ON);
MCHP_VCI_REGISTER |= MCHP_VCI_REGISTER_FW_CNTRL;
MCHP_VCI_REGISTER |= MCHP_VCI_REGISTER_FW_EXT;

spi_enable(CONFIG_SPI_FLASH_PORT, 1);

uart_puts("littlefw ");
Expand Down

0 comments on commit 4ce2336

Please sign in to comment.