diff options
author | Philipp Zabel <p.zabel@pengutronix.de> | 2014-07-11 13:36:24 +0400 |
---|---|---|
committer | Mauro Carvalho Chehab <m.chehab@samsung.com> | 2014-07-22 19:02:25 +0400 |
commit | fe7554e6210090d0d8a8dff6b7f0082fdf1ddbf1 (patch) | |
tree | 3f4ddfa9018d1c75d78001e5e7f069d8c7ceaf97 /drivers/media/platform/coda.c | |
parent | 1e17273112d60ca93e1248715039f9bf1aa09733 (diff) | |
download | linux-fe7554e6210090d0d8a8dff6b7f0082fdf1ddbf1.tar.xz |
[media] coda: split firmware version check out of coda_hw_init
This adds a new function coda_check_firmware that does the firmware
version checks so that this can be done only once from coda_probe
instead of every time the runtime pm framework resumes the coda.
Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
Signed-off-by: Kamil Debski <k.debski@samsung.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
Diffstat (limited to 'drivers/media/platform/coda.c')
-rw-r--r-- | drivers/media/platform/coda.c | 42 |
1 files changed, 37 insertions, 5 deletions
diff --git a/drivers/media/platform/coda.c b/drivers/media/platform/coda.c index 131cb5f53b22..87cc22606e22 100644 --- a/drivers/media/platform/coda.c +++ b/drivers/media/platform/coda.c @@ -3195,7 +3195,6 @@ static bool coda_firmware_supported(u32 vernum) static int coda_hw_init(struct coda_dev *dev) { - u16 product, major, minor, release; u32 data; u16 *p; int i, ret; @@ -3276,17 +3275,40 @@ static int coda_hw_init(struct coda_dev *dev) coda_write(dev, data, CODA_REG_BIT_CODE_RESET); coda_write(dev, CODA_REG_RUN_ENABLE, CODA_REG_BIT_CODE_RUN); - /* Load firmware */ + clk_disable_unprepare(dev->clk_ahb); + clk_disable_unprepare(dev->clk_per); + + return 0; + +err_clk_ahb: + clk_disable_unprepare(dev->clk_per); +err_clk_per: + return ret; +} + +static int coda_check_firmware(struct coda_dev *dev) +{ + u16 product, major, minor, release; + u32 data; + int ret; + + ret = clk_prepare_enable(dev->clk_per); + if (ret) + goto err_clk_per; + + ret = clk_prepare_enable(dev->clk_ahb); + if (ret) + goto err_clk_ahb; + coda_write(dev, 0, CODA_CMD_FIRMWARE_VERNUM); coda_write(dev, CODA_REG_BIT_BUSY_FLAG, CODA_REG_BIT_BUSY); coda_write(dev, 0, CODA_REG_BIT_RUN_INDEX); coda_write(dev, 0, CODA_REG_BIT_RUN_COD_STD); coda_write(dev, CODA_COMMAND_FIRMWARE_GET, CODA_REG_BIT_RUN_COMMAND); if (coda_wait_timeout(dev)) { - clk_disable_unprepare(dev->clk_per); - clk_disable_unprepare(dev->clk_ahb); v4l2_err(&dev->v4l2_dev, "firmware get command error\n"); - return -EIO; + ret = -EIO; + goto err_run_cmd; } if (dev->devtype->product == CODA_960) { @@ -3326,6 +3348,8 @@ static int coda_hw_init(struct coda_dev *dev) return 0; +err_run_cmd: + clk_disable_unprepare(dev->clk_ahb); err_clk_ahb: clk_disable_unprepare(dev->clk_per); err_clk_per: @@ -3366,6 +3390,10 @@ static void coda_fw_callback(const struct firmware *fw, void *context) return; } + ret = coda_check_firmware(dev); + if (ret < 0) + return; + pm_runtime_put_sync(&dev->plat_dev->dev); } else { /* @@ -3377,6 +3405,10 @@ static void coda_fw_callback(const struct firmware *fw, void *context) v4l2_err(&dev->v4l2_dev, "HW initialization failed\n"); return; } + + ret = coda_check_firmware(dev); + if (ret < 0) + return; } dev->vfd.fops = &coda_fops, |