summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--zephyr/Kconfig1
-rw-r--r--zephyr/Kconfig.init_priority17
-rw-r--r--zephyr/shim/src/flash.c6
-rw-r--r--zephyr/shim/src/gpio.c5
4 files changed, 27 insertions, 2 deletions
diff --git a/zephyr/Kconfig b/zephyr/Kconfig
index f0fb5c4115..b0937203ab 100644
--- a/zephyr/Kconfig
+++ b/zephyr/Kconfig
@@ -41,6 +41,7 @@ rsource "Kconfig.debug_assert"
rsource "Kconfig.espi"
rsource "Kconfig.flash"
rsource "Kconfig.header"
+rsource "Kconfig.init_priority"
rsource "Kconfig.keyboard"
rsource "Kconfig.led"
rsource "Kconfig.panic"
diff --git a/zephyr/Kconfig.init_priority b/zephyr/Kconfig.init_priority
new file mode 100644
index 0000000000..b8b3ab7195
--- /dev/null
+++ b/zephyr/Kconfig.init_priority
@@ -0,0 +1,17 @@
+# Copyright 2021 The Chromium OS Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+config PLATFORM_EC_FLASH_INIT_PRIORITY
+ int "Init priority of the flash module"
+ default 52
+ help
+ The initialization priority of the flash module. This should always be
+ greater than PLATFORM_EC_GPIO_INIT_PRIORITY.
+
+config PLATFORM_EC_GPIO_INIT_PRIORITY
+ int "Init priority of the GPIO module"
+ default 51
+ help
+ The initialization priority of the GPIO module. This should always happen
+ after the gpio drivers are initialized.
diff --git a/zephyr/shim/src/flash.c b/zephyr/shim/src/flash.c
index baac38af92..064067a2bc 100644
--- a/zephyr/shim/src/flash.c
+++ b/zephyr/shim/src/flash.c
@@ -418,4 +418,8 @@ uint32_t flash_physical_get_writable_flags(uint32_t cur_flags)
* The priority flash_dev_init should be lower than GPIO initialization because
* it calls gpio_get_level function.
*/
-SYS_INIT(flash_dev_init, PRE_KERNEL_1, 51);
+#if CONFIG_PLATFORM_EC_FLASH_INIT_PRIORITY <= \
+ CONFIG_PLATFORM_EC_GPIO_INIT_PRIORITY
+#error "Flash must be initialized after GPIOs"
+#endif
+SYS_INIT(flash_dev_init, POST_KERNEL, CONFIG_PLATFORM_EC_FLASH_INIT_PRIORITY);
diff --git a/zephyr/shim/src/gpio.c b/zephyr/shim/src/gpio.c
index fc9a77c1bf..020cb54d31 100644
--- a/zephyr/shim/src/gpio.c
+++ b/zephyr/shim/src/gpio.c
@@ -258,7 +258,10 @@ static int init_gpios(const struct device *unused)
return 0;
}
-SYS_INIT(init_gpios, PRE_KERNEL_1, 50);
+#if CONFIG_PLATFORM_EC_GPIO_INIT_PRIORITY <= CONFIG_KERNEL_INIT_PRIORITY_DEFAULT
+#error "GPIOs must initialize after the kernel default initialization"
+#endif
+SYS_INIT(init_gpios, POST_KERNEL, CONFIG_PLATFORM_EC_GPIO_INIT_PRIORITY);
int gpio_enable_interrupt(enum gpio_signal signal)
{