Reload firmware before power on if failed in probe
authorTracy Yi <tracy-yi@ti.com>
Wed, 5 Sep 2018 09:32:08 +0000 (17:32 +0800)
committerTracy Yi <tracy-yi@ti.com>
Wed, 5 Sep 2018 09:32:08 +0000 (17:32 +0800)
Signed-off-by: Tracy Yi <tracy-yi@ti.com>
tas2557-core.c

index eabb9676c9f99cefc37097296dd3a96a1f3a2543..4b947094ed9e506e065c3a3fb04b130c1f5e05c1 100755 (executable)
@@ -461,6 +461,7 @@ int tas2557_enable(struct tas2557_priv *pTAS2557, bool bEnable)
 {
        int nResult = 0;
        unsigned int nValue;
+       const char *pFWName;
        struct TProgram *pProgram;
 
        dev_dbg(pTAS2557->dev, "Enable: %d\n", bEnable);
@@ -468,8 +469,25 @@ int tas2557_enable(struct tas2557_priv *pTAS2557, bool bEnable)
        if ((pTAS2557->mpFirmware->mnPrograms == 0)
                || (pTAS2557->mpFirmware->mnConfigurations == 0)) {
                dev_err(pTAS2557->dev, "%s, firmware not loaded\n", __func__);
-               goto end;
+               /*Load firmware*/
+               if (pTAS2557->mnPGID == TAS2557_PG_VERSION_2P1) {
+                       dev_info(pTAS2557->dev, "PG2.1 Silicon found\n");
+                       pFWName = TAS2557_FW_NAME;
+               } else if (pTAS2557->mnPGID == TAS2557_PG_VERSION_1P0) {
+                       dev_info(pTAS2557->dev, "PG1.0 Silicon found\n");
+                       pFWName = TAS2557_PG1P0_FW_NAME;
+               } else {
+                       nResult = -ENOTSUPP;
+                       dev_info(pTAS2557->dev, "unsupport Silicon 0x%x\n", pTAS2557->mnPGID);
+                       goto end;
+               }
+               nResult = request_firmware_nowait(THIS_MODULE, 1, pFWName,
+                       pTAS2557->dev, GFP_KERNEL, pTAS2557, tas2557_fw_ready);
+               if(nResult < 0)
+                       goto end;
+               dev_err(pTAS2557->dev, "%s, firmware is loaded\n", __func__);
        }
+
        /* check safe guard*/
        nResult = pTAS2557->read(pTAS2557, TAS2557_SAFE_GUARD_REG, &nValue);
        if (nResult < 0)