Load firmware for the peripheral if necessary.

Signed-off-by: Casey Connolly <casey.conno...@linaro.org>
Reviewed-by: Neil Armstrong <neil.armstr...@linaro.org>
---
 drivers/i2c/geni_i2c.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/drivers/i2c/geni_i2c.c b/drivers/i2c/geni_i2c.c
index 
4eb41ba852f7790ca646c8ba38f29fdb727fa804..d29e00fdf41df1d7a95d8d9b3b98f784f5b2a3e1
 100644
--- a/drivers/i2c/geni_i2c.c
+++ b/drivers/i2c/geni_i2c.c
@@ -21,8 +21,9 @@
 #include <clk.h>
 #include <reset.h>
 #include <time.h>
 #include <soc/qcom/geni-se.h>
+#include <soc/qcom/qup-fw-load.h>
 
 #define SE_I2C_TX_TRANS_LEN            0x26c
 #define SE_I2C_RX_TRANS_LEN            0x270
 #define SE_I2C_SCL_COUNTERS            0x278
@@ -498,8 +499,15 @@ static int geni_i2c_probe(struct udevice *dev)
        proto = readl(geni->base + GENI_FW_REVISION_RO);
        proto &= FW_REV_PROTOCOL_MSK;
        proto >>= FW_REV_PROTOCOL_SHFT;
 
+       if (proto == GENI_SE_INVALID_PROTO) {
+               qcom_geni_load_firmware(geni->base, dev);
+               proto = readl(geni->base + GENI_FW_REVISION_RO);
+               proto &= FW_REV_PROTOCOL_MSK;
+               proto >>= FW_REV_PROTOCOL_SHFT;
+       }
+
        if (proto != GENI_SE_I2C) {
                dev_err(dev, "Invalid proto %d\n", proto);
                geni_i2c_disable_clocks(dev, geni);
                return -ENXIO;

-- 
2.49.0

Reply via email to