From patchwork Mon Feb 10 21:54:42 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 3623891 Return-Path: X-Original-To: patchwork-linux-arm@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 0AF97BF418 for ; Mon, 10 Feb 2014 22:01:05 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 4162A201DE for ; Mon, 10 Feb 2014 22:01:04 +0000 (UTC) Received: from casper.infradead.org (casper.infradead.org [85.118.1.10]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 4DFDC201CD for ; Mon, 10 Feb 2014 22:01:03 +0000 (UTC) Received: from merlin.infradead.org ([2001:4978:20e::2]) by casper.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1WCyt8-0000As-U6; Mon, 10 Feb 2014 21:59:39 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1WCyoF-00085Y-05; Mon, 10 Feb 2014 21:54:35 +0000 Received: from perceval.ideasonboard.com ([95.142.166.194]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1WCyoC-00082v-3Z for linux-arm-kernel@lists.infradead.org; Mon, 10 Feb 2014 21:54:32 +0000 Received: from avalon.ideasonboard.com (214.131-246-81.adsl-dyn.isp.belgacom.be [81.246.131.214]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id F2D16363CE; Mon, 10 Feb 2014 22:52:46 +0100 (CET) From: Laurent Pinchart To: linux-media@vger.kernel.org Subject: [PATCH 3/5] mt9t001: Add clock support Date: Mon, 10 Feb 2014 22:54:42 +0100 Message-Id: <1392069284-18024-4-git-send-email-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 1.8.3.2 In-Reply-To: <1392069284-18024-1-git-send-email-laurent.pinchart@ideasonboard.com> References: <1392069284-18024-1-git-send-email-laurent.pinchart@ideasonboard.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20140210_165432_272519_5DEAD6DF X-CRM114-Status: GOOD ( 12.72 ) X-Spam-Score: -2.5 (--) Cc: linux-omap@vger.kernel.org, linux-arm-kernel@lists.infradead.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.8 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable 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 The sensor needs a master clock, handle it explictly in the driver. Signed-off-by: Laurent Pinchart --- drivers/media/i2c/mt9t001.c | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/drivers/media/i2c/mt9t001.c b/drivers/media/i2c/mt9t001.c index 9a0bb06..422e068 100644 --- a/drivers/media/i2c/mt9t001.c +++ b/drivers/media/i2c/mt9t001.c @@ -12,6 +12,7 @@ * published by the Free Software Foundation. */ +#include #include #include #include @@ -118,6 +119,7 @@ struct mt9t001 { struct v4l2_subdev subdev; struct media_pad pad; + struct clk *clk; struct regulator_bulk_data regulators[2]; struct mutex power_lock; /* lock to protect power_count */ @@ -189,9 +191,21 @@ static int mt9t001_reset(struct mt9t001 *mt9t001) static int mt9t001_power_on(struct mt9t001 *mt9t001) { + int ret; + /* Bring up the supplies */ - return regulator_bulk_enable(ARRAY_SIZE(mt9t001->regulators), - mt9t001->regulators); + ret = regulator_bulk_enable(ARRAY_SIZE(mt9t001->regulators), + mt9t001->regulators); + if (ret < 0) + return ret; + + /* Enable clock */ + ret = clk_prepare_enable(mt9t001->clk); + if (ret < 0) + regulator_bulk_disable(ARRAY_SIZE(mt9t001->regulators), + mt9t001->regulators); + + return ret; } static void mt9t001_power_off(struct mt9t001 *mt9t001) @@ -199,6 +213,9 @@ static void mt9t001_power_off(struct mt9t001 *mt9t001) regulator_bulk_disable(ARRAY_SIZE(mt9t001->regulators), mt9t001->regulators); + clk_disable_unprepare(mt9t001->clk); +} + static int __mt9t001_set_power(struct mt9t001 *mt9t001, bool on) { struct i2c_client *client = v4l2_get_subdevdata(&mt9t001->subdev); @@ -854,6 +871,12 @@ static int mt9t001_probe(struct i2c_client *client, return ret; } + mt9t001->clk = devm_clk_get(&client->dev, NULL); + if (IS_ERR(mt9t001->clk)) { + dev_err(&client->dev, "Unable to get clock\n"); + return PTR_ERR(mt9t001->clk); + } + v4l2_ctrl_handler_init(&mt9t001->ctrls, ARRAY_SIZE(mt9t001_ctrls) + ARRAY_SIZE(mt9t001_gains) + 4);