From patchwork Fri Jun 13 16:08:39 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Philipp Zabel X-Patchwork-Id: 4350691 Return-Path: X-Original-To: patchwork-linux-media@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 9B3C6BEEAA for ; Fri, 13 Jun 2014 16:10:18 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id A80A220268 for ; Fri, 13 Jun 2014 16:10:17 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id BB17120265 for ; Fri, 13 Jun 2014 16:10:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753421AbaFMQJK (ORCPT ); Fri, 13 Jun 2014 12:09:10 -0400 Received: from metis.ext.pengutronix.de ([92.198.50.35]:44451 "EHLO metis.ext.pengutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753402AbaFMQJI (ORCPT ); Fri, 13 Jun 2014 12:09:08 -0400 Received: from client-120-static.hi.pengutronix.de ([10.1.0.120] helo=paszta.pengutronix.de.) by metis.ext.pengutronix.de with esmtp (Exim 4.72) (envelope-from ) id 1WvU2G-0006dC-9E; Fri, 13 Jun 2014 18:09:00 +0200 From: Philipp Zabel To: linux-media@vger.kernel.org Cc: Mauro Carvalho Chehab , Kamil Debski , Fabio Estevam , kernel@pengutronix.de, Philipp Zabel Subject: [PATCH 13/30] [media] coda: split firmware version check out of coda_hw_init Date: Fri, 13 Jun 2014 18:08:39 +0200 Message-Id: <1402675736-15379-14-git-send-email-p.zabel@pengutronix.de> X-Mailer: git-send-email 2.0.0.rc2 In-Reply-To: <1402675736-15379-1-git-send-email-p.zabel@pengutronix.de> References: <1402675736-15379-1-git-send-email-p.zabel@pengutronix.de> X-SA-Exim-Connect-IP: 10.1.0.120 X-SA-Exim-Mail-From: p.zabel@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-media@vger.kernel.org Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Spam-Status: No, score=-7.5 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 --- drivers/media/platform/coda.c | 42 +++++++++++++++++++++++++++++++++++++----- 1 file changed, 37 insertions(+), 5 deletions(-) diff --git a/drivers/media/platform/coda.c b/drivers/media/platform/coda.c index f39f693..b2e8e0e 100644 --- a/drivers/media/platform/coda.c +++ b/drivers/media/platform/coda.c @@ -3247,7 +3247,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; @@ -3328,17 +3327,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) { @@ -3378,6 +3400,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: @@ -3418,6 +3442,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 { /* @@ -3429,6 +3457,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,