mirror of
https://github.com/Telecominfraproject/OpenCellular.git
synced 2025-12-27 18:25:05 +00:00
Fix incorrect valid and writable flash flags
The valid and writable flags the EC sends back to the AP are incorrect. They are a little bit different on differnt chips, so let's move it to flash physical layer. This is not any causing problem, but we should fix this. BUG=chrome-os-partner:32745 TEST=make buildall BRANCH=samus Change-Id: Ibcda5ae770f5ea02cde094490997a5bc447df88f Signed-off-by: Vic Yang <victoryang@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/222661 Reviewed-by: Randall Spangler <rspangler@chromium.org>
This commit is contained in:
committed by
chrome-internal-fetch
parent
847eb1ec44
commit
f8fd63f135
@@ -118,6 +118,32 @@ int flash_physical_protect_now(int all)
|
||||
return EC_SUCCESS;
|
||||
}
|
||||
|
||||
uint32_t flash_physical_get_valid_flags(void)
|
||||
{
|
||||
return EC_FLASH_PROTECT_RO_AT_BOOT |
|
||||
EC_FLASH_PROTECT_RO_NOW |
|
||||
EC_FLASH_PROTECT_ALL_NOW;
|
||||
}
|
||||
|
||||
uint32_t flash_physical_get_writable_flags(uint32_t cur_flags)
|
||||
{
|
||||
uint32_t ret = 0;
|
||||
|
||||
/* If RO protection isn't enabled, its at-boot state can be changed. */
|
||||
if (!(cur_flags & EC_FLASH_PROTECT_RO_NOW))
|
||||
ret |= EC_FLASH_PROTECT_RO_AT_BOOT;
|
||||
|
||||
/*
|
||||
* If entire flash isn't protected at this boot, it can be enabled if
|
||||
* the WP GPIO is asserted.
|
||||
*/
|
||||
if (!(cur_flags & EC_FLASH_PROTECT_ALL_NOW) &&
|
||||
(cur_flags & EC_FLASH_PROTECT_GPIO_ASSERTED))
|
||||
ret |= EC_FLASH_PROTECT_ALL_NOW;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
int flash_pre_init(void)
|
||||
{
|
||||
uint32_t prot_flags;
|
||||
|
||||
@@ -204,6 +204,32 @@ int flash_physical_protect_now(int all)
|
||||
return EC_SUCCESS;
|
||||
}
|
||||
|
||||
uint32_t flash_physical_get_valid_flags(void)
|
||||
{
|
||||
return EC_FLASH_PROTECT_RO_AT_BOOT |
|
||||
EC_FLASH_PROTECT_RO_NOW |
|
||||
EC_FLASH_PROTECT_ALL_NOW;
|
||||
}
|
||||
|
||||
uint32_t flash_physical_get_writable_flags(uint32_t cur_flags)
|
||||
{
|
||||
uint32_t ret = 0;
|
||||
|
||||
/* If RO protection isn't enabled, its at-boot state can be changed. */
|
||||
if (!(cur_flags & EC_FLASH_PROTECT_RO_NOW))
|
||||
ret |= EC_FLASH_PROTECT_RO_AT_BOOT;
|
||||
|
||||
/*
|
||||
* If entire flash isn't protected at this boot, it can be enabled if
|
||||
* the WP GPIO is asserted.
|
||||
*/
|
||||
if (!(cur_flags & EC_FLASH_PROTECT_ALL_NOW) &&
|
||||
(cur_flags & EC_FLASH_PROTECT_GPIO_ASSERTED))
|
||||
ret |= EC_FLASH_PROTECT_ALL_NOW;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
/*****************************************************************************/
|
||||
/* High-level APIs */
|
||||
|
||||
@@ -67,6 +67,32 @@ int flash_physical_protect_now(int all)
|
||||
}
|
||||
}
|
||||
|
||||
uint32_t flash_physical_get_valid_flags(void)
|
||||
{
|
||||
return EC_FLASH_PROTECT_RO_AT_BOOT |
|
||||
EC_FLASH_PROTECT_RO_NOW |
|
||||
EC_FLASH_PROTECT_ALL_NOW;
|
||||
}
|
||||
|
||||
uint32_t flash_physical_get_writable_flags(uint32_t cur_flags)
|
||||
{
|
||||
uint32_t ret = 0;
|
||||
|
||||
/* If RO protection isn't enabled, its at-boot state can be changed. */
|
||||
if (!(cur_flags & EC_FLASH_PROTECT_RO_NOW))
|
||||
ret |= EC_FLASH_PROTECT_RO_AT_BOOT;
|
||||
|
||||
/*
|
||||
* If entire flash isn't protected at this boot, it can be enabled if
|
||||
* the WP GPIO is asserted.
|
||||
*/
|
||||
if (!(cur_flags & EC_FLASH_PROTECT_ALL_NOW) &&
|
||||
(cur_flags & EC_FLASH_PROTECT_GPIO_ASSERTED))
|
||||
ret |= EC_FLASH_PROTECT_ALL_NOW;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
int flash_physical_restore_state(void)
|
||||
{
|
||||
uint32_t reset_flags = system_get_reset_flags();
|
||||
|
||||
@@ -42,3 +42,30 @@ int flash_physical_restore_state(void)
|
||||
/* Nothing to restore */
|
||||
return 0;
|
||||
}
|
||||
|
||||
uint32_t flash_physical_get_valid_flags(void)
|
||||
{
|
||||
return EC_FLASH_PROTECT_RO_AT_BOOT |
|
||||
EC_FLASH_PROTECT_ALL_AT_BOOT |
|
||||
EC_FLASH_PROTECT_RO_NOW |
|
||||
EC_FLASH_PROTECT_ALL_NOW;
|
||||
}
|
||||
|
||||
uint32_t flash_physical_get_writable_flags(uint32_t cur_flags)
|
||||
{
|
||||
uint32_t ret = 0;
|
||||
|
||||
/* If RO protection isn't enabled, its at-boot state can be changed. */
|
||||
if (!(cur_flags & EC_FLASH_PROTECT_RO_NOW))
|
||||
ret |= EC_FLASH_PROTECT_RO_AT_BOOT;
|
||||
|
||||
/*
|
||||
* RW at-boot state can be set if WP GPIO is asserted and can always
|
||||
* be cleared.
|
||||
*/
|
||||
if (cur_flags & (EC_FLASH_PROTECT_ALL_AT_BOOT |
|
||||
EC_FLASH_PROTECT_GPIO_ASSERTED))
|
||||
ret |= EC_FLASH_PROTECT_ALL_AT_BOOT;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -400,6 +400,32 @@ int flash_physical_protect_now(int all)
|
||||
}
|
||||
}
|
||||
|
||||
uint32_t flash_physical_get_valid_flags(void)
|
||||
{
|
||||
return EC_FLASH_PROTECT_RO_AT_BOOT |
|
||||
EC_FLASH_PROTECT_RO_NOW |
|
||||
EC_FLASH_PROTECT_ALL_NOW;
|
||||
}
|
||||
|
||||
uint32_t flash_physical_get_writable_flags(uint32_t cur_flags)
|
||||
{
|
||||
uint32_t ret = 0;
|
||||
|
||||
/* If RO protection isn't enabled, its at-boot state can be changed. */
|
||||
if (!(cur_flags & EC_FLASH_PROTECT_RO_NOW))
|
||||
ret |= EC_FLASH_PROTECT_RO_AT_BOOT;
|
||||
|
||||
/*
|
||||
* If entire flash isn't protected at this boot, it can be enabled if
|
||||
* the WP GPIO is asserted.
|
||||
*/
|
||||
if (!(cur_flags & EC_FLASH_PROTECT_ALL_NOW) &&
|
||||
(cur_flags & EC_FLASH_PROTECT_GPIO_ASSERTED))
|
||||
ret |= EC_FLASH_PROTECT_ALL_NOW;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
int flash_pre_init(void)
|
||||
{
|
||||
uint32_t reset_flags = system_get_reset_flags();
|
||||
|
||||
@@ -624,23 +624,9 @@ static int flash_command_protect(struct host_cmd_handler_args *args)
|
||||
r->valid_flags =
|
||||
EC_FLASH_PROTECT_GPIO_ASSERTED |
|
||||
EC_FLASH_PROTECT_ERROR_STUCK |
|
||||
EC_FLASH_PROTECT_RO_AT_BOOT |
|
||||
EC_FLASH_PROTECT_RO_NOW |
|
||||
EC_FLASH_PROTECT_ALL_NOW |
|
||||
EC_FLASH_PROTECT_ERROR_INCONSISTENT;
|
||||
r->writable_flags = 0;
|
||||
|
||||
/* If RO protection isn't enabled, its at-boot state can be changed. */
|
||||
if (!(r->flags & EC_FLASH_PROTECT_RO_NOW))
|
||||
r->writable_flags |= EC_FLASH_PROTECT_RO_AT_BOOT;
|
||||
|
||||
/*
|
||||
* If entire flash isn't protected at this boot, it can be enabled if
|
||||
* the WP GPIO is asserted.
|
||||
*/
|
||||
if (!(r->flags & EC_FLASH_PROTECT_ALL_NOW) &&
|
||||
(r->flags & EC_FLASH_PROTECT_GPIO_ASSERTED))
|
||||
r->writable_flags |= EC_FLASH_PROTECT_ALL_NOW;
|
||||
EC_FLASH_PROTECT_ERROR_INCONSISTENT |
|
||||
flash_physical_get_valid_flags();
|
||||
r->writable_flags = flash_physical_get_writable_flags(r->flags);
|
||||
|
||||
args->response_size = sizeof(*r);
|
||||
|
||||
|
||||
@@ -110,6 +110,21 @@ int flash_physical_force_reload(void);
|
||||
*/
|
||||
int flash_physical_restore_state(void);
|
||||
|
||||
/**
|
||||
* Return the valid flash protect flags.
|
||||
*
|
||||
* @return a combination of EC_FLASH_PROTECT_* flags from ec_commands.h
|
||||
*/
|
||||
uint32_t flash_physical_get_valid_flags(void);
|
||||
|
||||
/**
|
||||
* Return the writable flash protect flags.
|
||||
*
|
||||
* @param cur_flags The current flash protect flags.
|
||||
* @return a combination of EC_FLASH_PROTECT_* flags from ec_commands.h
|
||||
*/
|
||||
uint32_t flash_physical_get_writable_flags(uint32_t cur_flags);
|
||||
|
||||
/*****************************************************************************/
|
||||
/* Low-level common code for use by flash modules. */
|
||||
|
||||
|
||||
Reference in New Issue
Block a user