summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJett Rink <jettrink@chromium.org>2019-09-17 16:02:58 -0600
committerJett Rink <jettrink@chromium.org>2019-09-30 22:10:31 +0000
commit3daa7fb8a4caec652dbe1ee02d505d7fffcab85a (patch)
tree41f7590d94bf76e8929f645ccf3084bc310a7f46
parent0f541c42d1b10e787a839c1cb5cc6019e6975bd2 (diff)
downloadchrome-ec-3daa7fb8a4caec652dbe1ee02d505d7fffcab85a.tar.gz
cleanup: fix byte access and ifdefs for BBRAM_PD2
Ensure that PD2 is accessed as a single byte instead of 4 bytes and remove unnecessary ifdef guards in all chip implementations. BRANCH=none BUG=none TEST=builds Change-Id: I319d8d6a8456662235ab4d8dcda6bda7e8ed7c15 Signed-off-by: Jett Rink <jettrink@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1809938 Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
-rw-r--r--chip/it83xx/system.c2
-rw-r--r--chip/mchp/system.c5
-rw-r--r--chip/mec1322/system.c5
-rw-r--r--chip/npcx/system.c9
-rw-r--r--chip/stm32/system.c3
-rw-r--r--common/usb_pd_protocol.c3
6 files changed, 10 insertions, 17 deletions
diff --git a/chip/it83xx/system.c b/chip/it83xx/system.c
index 667b8130cd..144d75c35c 100644
--- a/chip/it83xx/system.c
+++ b/chip/it83xx/system.c
@@ -287,14 +287,12 @@ static int bram_idx_lookup(enum system_bbram_idx idx)
idx <= SYSTEM_BBRAM_IDX_VBNVBLOCK15)
return BRAM_IDX_NVCONTEXT +
idx - SYSTEM_BBRAM_IDX_VBNVBLOCK0;
-#ifdef CONFIG_USB_PD_DUAL_ROLE
if (idx == SYSTEM_BBRAM_IDX_PD0)
return BRAM_IDX_PD0;
if (idx == SYSTEM_BBRAM_IDX_PD1)
return BRAM_IDX_PD1;
if (idx == SYSTEM_BBRAM_IDX_PD2)
return BRAM_IDX_PD2;
-#endif
return -1;
}
diff --git a/chip/mchp/system.c b/chip/mchp/system.c
index b481f2ba26..c19db25759 100644
--- a/chip/mchp/system.c
+++ b/chip/mchp/system.c
@@ -34,6 +34,7 @@ enum hibdata_index {
HIBDATA_INDEX_SAVED_RESET_FLAGS, /* Saved reset flags */
HIBDATA_INDEX_PD0, /* USB-PD0 saved port state */
HIBDATA_INDEX_PD1, /* USB-PD1 saved port state */
+ HIBDATA_INDEX_PD2, /* USB-PD2 saved port state */
};
static void check_reset_cause(void)
@@ -291,12 +292,12 @@ const char *system_get_chip_revision(void)
static int bbram_idx_lookup(enum system_bbram_idx idx)
{
switch (idx) {
-#ifdef CONFIG_USB_PD_DUAL_ROLE
case SYSTEM_BBRAM_IDX_PD0:
return HIBDATA_INDEX_PD0;
case SYSTEM_BBRAM_IDX_PD1:
return HIBDATA_INDEX_PD1;
-#endif
+ case SYSTEM_BBRAM_IDX_PD2:
+ return HIBDATA_INDEX_PD2;
default:
return 1;
}
diff --git a/chip/mec1322/system.c b/chip/mec1322/system.c
index e50d97bc6d..4938f07b75 100644
--- a/chip/mec1322/system.c
+++ b/chip/mec1322/system.c
@@ -26,6 +26,7 @@ enum hibdata_index {
HIBDATA_INDEX_SAVED_RESET_FLAGS, /* Saved reset flags */
HIBDATA_INDEX_PD0, /* USB-PD0 saved port state */
HIBDATA_INDEX_PD1, /* USB-PD1 saved port state */
+ HIBDATA_INDEX_PD2, /* USB-PD2 saved port state */
};
static void check_reset_cause(void)
@@ -177,12 +178,12 @@ const char *system_get_chip_revision(void)
static int bbram_idx_lookup(enum system_bbram_idx idx)
{
switch (idx) {
-#ifdef CONFIG_USB_PD_DUAL_ROLE
case SYSTEM_BBRAM_IDX_PD0:
return HIBDATA_INDEX_PD0;
case SYSTEM_BBRAM_IDX_PD1:
return HIBDATA_INDEX_PD1;
-#endif
+ case SYSTEM_BBRAM_IDX_PD2:
+ return HIBDATA_INDEX_PD2;
default:
return -1;
}
diff --git a/chip/npcx/system.c b/chip/npcx/system.c
index ff18334533..7eb95b8d34 100644
--- a/chip/npcx/system.c
+++ b/chip/npcx/system.c
@@ -79,10 +79,9 @@ static int bbram_is_byte_access(enum bbram_data_index index)
{
return (index >= BBRM_DATA_INDEX_VBNVCNTXT &&
index < BBRM_DATA_INDEX_RAMLOG)
-#ifdef CONFIG_USB_PD_DUAL_ROLE
|| index == BBRM_DATA_INDEX_PD0
|| index == BBRM_DATA_INDEX_PD1
-#endif
+ || index == BBRM_DATA_INDEX_PD2
|| index == BBRM_DATA_INDEX_PANIC_FLAGS
;
}
@@ -183,20 +182,14 @@ static int bbram_idx_lookup(enum system_bbram_idx idx)
idx <= SYSTEM_BBRAM_IDX_VBNVBLOCK15)
return BBRM_DATA_INDEX_VBNVCNTXT +
idx - SYSTEM_BBRAM_IDX_VBNVBLOCK0;
-#ifdef CONFIG_USB_PD_DUAL_ROLE
if (idx == SYSTEM_BBRAM_IDX_PD0)
return BBRM_DATA_INDEX_PD0;
if (idx == SYSTEM_BBRAM_IDX_PD1)
return BBRM_DATA_INDEX_PD1;
-#if CONFIG_USB_PD_PORT_COUNT >= 3
if (idx == SYSTEM_BBRAM_IDX_PD2)
return BBRM_DATA_INDEX_PD2;
-#endif /* CONFIG_USB_PD_PORT_COUNT >= 3 */
-#endif /* defined(CONFIG_USB_PD_DUAL_ROLE) */
-#ifdef CONFIG_VBOOT_EFS
if (idx == SYSTEM_BBRAM_IDX_TRY_SLOT)
return BBRM_DATA_INDEX_TRY_SLOT;
-#endif
return -1;
}
diff --git a/chip/stm32/system.c b/chip/stm32/system.c
index 7cc0881dc2..27e2f8fc79 100644
--- a/chip/stm32/system.c
+++ b/chip/stm32/system.c
@@ -71,6 +71,7 @@ enum bkpdata_index {
#ifdef CONFIG_USB_PD_DUAL_ROLE
BKPDATA_INDEX_PD0, /* USB-PD saved port0 state */
BKPDATA_INDEX_PD1, /* USB-PD saved port1 state */
+ BKPDATA_INDEX_PD2, /* USB-PD saved port2 state */
#endif
BKPDATA_COUNT
};
@@ -527,6 +528,8 @@ static int bkpdata_index_lookup(enum system_bbram_idx idx, int *msb)
return BKPDATA_INDEX_PD0;
if (idx == SYSTEM_BBRAM_IDX_PD1)
return BKPDATA_INDEX_PD1;
+ if (idx == SYSTEM_BBRAM_IDX_PD2)
+ return BKPDATA_INDEX_PD2;
#endif
return -1;
}
diff --git a/common/usb_pd_protocol.c b/common/usb_pd_protocol.c
index 7c791ba4a6..30e1fc3652 100644
--- a/common/usb_pd_protocol.c
+++ b/common/usb_pd_protocol.c
@@ -596,13 +596,10 @@ static int get_bbram_idx(int port)
switch (port) {
case 2:
return SYSTEM_BBRAM_IDX_PD2;
-
case 1:
return SYSTEM_BBRAM_IDX_PD1;
-
case 0:
return SYSTEM_BBRAM_IDX_PD0;
-
default:
return -1;
}