Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

hx30: restore RW firmware access #35

Draft
wants to merge 9 commits into
base: fwk-hx20-hx30-4410
Choose a base branch
from

Conversation

Emantor
Copy link

@Emantor Emantor commented Oct 10, 2023

Based on #16, this implements the same fixes for hx30.
Also moves the watchdog deactivation, I am not yet entirely sure this fix is required.

DHowett and others added 9 commits January 22, 2023 23:00
The alternate function table for LFW on the hx20 contained a few
incorrect values that resulted in LFW being unable to read from flash,
which disabled the use of the RW (and in some cases the RO) firmware
image.

1. SHD_IO0 is function 1 on the MEC152x, not function 2.
2. SHD_IO2 and SHD_IO3 were not included in the alternate function table.

The alternate function table from hx20/gpio.inc is correct, but it is
missing the SPI alternate for SHD_GLK/GPIO_0056.

In the future, we may want to move to model where hx20/gpio.inc includes
hx20/lfw/gpio.inc and common pin configurations are shared.
On the hx20 (and presumably hx30,) a design issue prevents us from
hibernating the EC properly. Therefore, every time we bring the machine
down we cut power instead of hibernating. That results in the next boot
being a complete reset.

There is code in lfw that checks whether the current boot is due to a
watchdog reset or a power-on reset and if it is, clears the image type
back to EC_IMAGE_UNKNOWN. Due to that design issue, the hx20 EC is
*always* in POR/VTR or WDT on startup.

By storing whether the last shutdown was graceful/intended and checking
it before resetting the image type, we can work around this issue.
This ensures that the hook in common/system.c that triggers an
"at-shutdown" reboot from RO to RW fires.

Without this, `ectool reboot_ec RW at-shutdown` doesn't work.
Over the past six months with this patch set, I've observed one
troubling behavior: the laptop would not always boot when it was powered
completely off (with the EC off as well) 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 reconfigures 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 in the prior three commits 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, 3VL_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.
Basically a copy from hx20 commit
7f78c55.
Implementation of c187ce1 for hx30.

Signed-off-by: Rouven Czerwinski <rouven@czerwinskis.de>
Implementation of 4ed2983 for hx30.

Signed-off-by: Rouven Czerwinski <rouven@czerwinskis.de>
If the lfw is stopped after the firmware was loaded, we will only ever
be ablt to boot the bootrom loaded RO FW, since we otherwise don't have
the time to load a bigger image from the SPI flash.

Signed-off-by: Rouven Czerwinski <rouven@czerwinskis.de>
@github-actions
Copy link

github-actions bot commented Oct 10, 2023

CLA Assistant Lite bot All contributors have signed the CLA ✍️ ✅

@Emantor
Copy link
Author

Emantor commented Oct 10, 2023

I have read the CLA Document and I hereby sign the CLA

@Emantor
Copy link
Author

Emantor commented Oct 10, 2023

recheck

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants