qcom_geni_fw_initialise() runs once, at EVT_LAST_STAGE_INIT, and reads
GENI SE firmware from a dedicated storage partition into memory for
its children to pick up during their own probe(). If that partition
does not exist yet at that point (e.g. first boot, before fastboot has
flashed it), it finds nothing to load and does not retry later. A
later SPI-NOR probe cannot recover from that on its own, since the
SPI driver's probe() only re-reads firmware already cached by
qcom_geni_fw_initialise(); it does not re-read storage itself.

Override the fastboot_oem_spi_nor_reinit() hook to re-run
qcom_geni_fw_initialise(), so that "fastboot oem spi-nor-init" can
pick up firmware that has been flashed since boot before probing
the SPI-NOR device.

Signed-off-by: Vandhiadevan Karunamoorthy 
<[email protected]>
---
 drivers/misc/qcom_geni.c | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/drivers/misc/qcom_geni.c b/drivers/misc/qcom_geni.c
index a62ae6a2478..d14d74e4216 100644
--- a/drivers/misc/qcom_geni.c
+++ b/drivers/misc/qcom_geni.c
@@ -13,6 +13,7 @@
 #include <dm/device-internal.h>
 #include <dm/lists.h>
 #include <elf.h>
+#include <fastboot.h>
 #include <linux/bitops.h>
 #include <linux/delay.h>
 #include <linux/io.h>
@@ -565,6 +566,20 @@ static int qcom_geni_fw_initialise(void)
 
 EVENT_SPY_SIMPLE(EVT_LAST_STAGE_INIT, qcom_geni_fw_initialise);
 
+/*
+ * qcom_geni_fw_initialise() only runs once, at EVT_LAST_STAGE_INIT. If the
+ * firmware partition does not exist yet at that point (e.g. first boot,
+ * before fastboot has flashed it), it silently finds nothing to load. A
+ * later SPI-NOR probe cannot recover from that on its own, since its
+ * probe() only re-reads firmware already cached by qcom_geni_fw_initialise();
+ * it does not re-read storage. Re-running it here lets the SPI-NOR device
+ * pick up firmware that has since been flashed.
+ */
+int fastboot_oem_spi_nor_reinit(void)
+{
+       return qcom_geni_fw_initialise();
+}
+
 static const struct udevice_id geni_ids[] = {
        { .compatible = "qcom,geni-se-qup" },
        {}

-- 
2.34.1

Reply via email to