summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorMichał Barnaś <mb@semihalf.com>2021-08-06 14:16:34 +0200
committerCommit Bot <commit-bot@chromium.org>2021-08-18 01:33:10 +0000
commitdac94834ba1fe8a60ec6e6b0f3884782dd95a270 (patch)
tree67e734e4917024406fa7a72f222e2bab4a4771e0 /include
parent1f723e545eafada64da2ce0bd9b5b9e5d183d5aa (diff)
downloadchrome-ec-dac94834ba1fe8a60ec6e6b0f3884782dd95a270.tar.gz
zephyr: provide unified method to get sku id and board version
Previously, functions for reading board version and sku id were defined in board.c files which are not compiled in Zephyr builds. Logic from board.c files should be moved to the DeviceTree files. This commit adds support for defining board version and sku id pins and numeral system used to decode them. BRANCH=main BUG=b:194136536 TEST=Call system_get_sku_id and system_get_board_version on CrOS EC and Zephyr, values should be correct and the same on both versions Change-Id: I61b5e205cb2a2299ad86c5dff38c05a9659eb2d3 Signed-off-by: Michał Barnaś <mb@semihalf.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3048102 Reviewed-by: Wai-Hong Tam <waihong@google.com> Reviewed-by: Keith Short <keithshort@chromium.org> Commit-Queue: Wai-Hong Tam <waihong@google.com> Tested-by: Wai-Hong Tam <waihong@google.com>
Diffstat (limited to 'include')
-rw-r--r--include/util.h21
1 files changed, 20 insertions, 1 deletions
diff --git a/include/util.h b/include/util.h
index 4ed352f0d7..1b077d0f55 100644
--- a/include/util.h
+++ b/include/util.h
@@ -342,7 +342,7 @@ void wait_for_ready(volatile uint32_t *reg, uint32_t enable, uint32_t ready);
* the normal ternary system order (skipping the values that were already used
* up).
*
- * This function is useful for converting BOARd ID, which is initially used a
+ * This function is useful for converting BOARD ID, which is initially used a
* binary and later decided to switch to tri-state after some revisions have
* already been built.
*
@@ -365,6 +365,25 @@ void wait_for_ready(volatile uint32_t *reg, uint32_t enable, uint32_t ready);
*/
int binary_first_base3_from_bits(int *bits, int nbits);
+/**
+ * Convert the binary bit array to integer value.
+ *
+ * @param bits array of integers with values of 0 and 1
+ * @param nbits number of bits to decode
+ * @return integer decoded from bits
+ */
+int binary_from_bits(int *bits, int nbits);
+
+/**
+ * Convert the ternary bit array to integer value.
+ * This function is used to handle 'Z' state of gpio as value of '2'.
+ *
+ * @param bits array of integers with values of 0, 1 or 2
+ * @param nbits number of bits to decode
+ * @return integer decoded from bits
+ */
+int ternary_from_bits(int *bits, int nbits);
+
#ifdef __cplusplus
}
#endif