From patchwork Fri Sep 23 18:41:40 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robert Jarzmik X-Patchwork-Id: 9348585 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id DA34960B16 for ; Fri, 23 Sep 2016 18:42:17 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CA8EF2A206 for ; Fri, 23 Sep 2016 18:42:17 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BF9462AD53; Fri, 23 Sep 2016 18:42:17 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,FREEMAIL_FROM, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 63BE52AD52 for ; Fri, 23 Sep 2016 18:42:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1161080AbcIWSmF (ORCPT ); Fri, 23 Sep 2016 14:42:05 -0400 Received: from smtp05.smtpout.orange.fr ([80.12.242.127]:52765 "EHLO smtp.smtpout.orange.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S966538AbcIWSlu (ORCPT ); Fri, 23 Sep 2016 14:41:50 -0400 Received: from belgarion.home ([109.220.51.14]) by mwinf5d81 with ME id n6hm1t00V0JP8pp036hovz; Fri, 23 Sep 2016 20:41:48 +0200 X-ME-Helo: belgarion.home X-ME-Date: Fri, 23 Sep 2016 20:41:48 +0200 X-ME-IP: 109.220.51.14 From: Robert Jarzmik To: Mauro Carvalho Chehab , Hans Verkuil Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, Robert Jarzmik Subject: [PATCH 2/2] media: mt9m111: add regulator support Date: Fri, 23 Sep 2016 20:41:40 +0200 Message-Id: <1474656100-7415-2-git-send-email-robert.jarzmik@free.fr> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1474656100-7415-1-git-send-email-robert.jarzmik@free.fr> References: <1474656100-7415-1-git-send-email-robert.jarzmik@free.fr> Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP In the soc_camera removal, the board specific power callback was dropped. This at least will remove the power optimization from ezx and em-x270 pxa based boards. As to recreate the same level of functionality, make the mt9m111 have a regulator providing it its power, so that board designers can plug in a gpio based or ldo regulator, mimicking their former soc_camera power hook. Fixes: 5c10113cc668 ("media: mt9m111: make a standalone v4l2 subdevice") Signed-off-by: Robert Jarzmik --- drivers/media/i2c/mt9m111.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/drivers/media/i2c/mt9m111.c b/drivers/media/i2c/mt9m111.c index 72e71b762827..bb8ed4927e44 100644 --- a/drivers/media/i2c/mt9m111.c +++ b/drivers/media/i2c/mt9m111.c @@ -13,6 +13,7 @@ #include #include #include +#include #include #include @@ -215,6 +216,7 @@ struct mt9m111 { int power_count; const struct mt9m111_datafmt *fmt; int lastpage; /* PageMap cache value */ + struct regulator *regulator; }; /* Find a data format by a pixel code */ @@ -788,6 +790,9 @@ static int mt9m111_power_on(struct mt9m111 *mt9m111) if (ret < 0) return ret; + if (mt9m111->regulator) + regulator_enable(mt9m111->regulator); + ret = mt9m111_resume(mt9m111); if (ret < 0) { dev_err(&client->dev, "Failed to resume the sensor: %d\n", ret); @@ -800,6 +805,8 @@ static int mt9m111_power_on(struct mt9m111 *mt9m111) static void mt9m111_power_off(struct mt9m111 *mt9m111) { mt9m111_suspend(mt9m111); + if (mt9m111->regulator) + regulator_disable(mt9m111->regulator); v4l2_clk_disable(mt9m111->clk); } @@ -943,6 +950,13 @@ static int mt9m111_probe(struct i2c_client *client, if (!mt9m111) return -ENOMEM; + mt9m111->regulator = devm_regulator_get(&client->dev, "vdd"); + if (IS_ERR(mt9m111->regulator)) { + dev_err(&client->dev, "regulator not found: %d\n", + PTR_ERR(mt9m111->regulator)); + return PTR_ERR(mt9m111->regulator); + } + mt9m111->clk = v4l2_clk_get(&client->dev, "mclk"); if (IS_ERR(mt9m111->clk)) return -EPROBE_DEFER;