From patchwork Mon Jul 3 09:16:08 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hugues FRUCHET X-Patchwork-Id: 9822315 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 B41C360246 for ; Mon, 3 Jul 2017 09:17:39 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id ECF5F201A4 for ; Mon, 3 Jul 2017 09:17:35 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E1188251F4; Mon, 3 Jul 2017 09:17:35 +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=-1.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 8A1D92811A for ; Mon, 3 Jul 2017 09:17:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=M6lO9VoDOSOLXkEmj9nCDhL2FkEsdViXaUCGof9v7ow=; b=pv3Fvrp7QxGpJv ZucQJ4CF43DQc+JdrSf7lCKrFiRGs4qZKAkCJ9FhfsqWc4UbZ8iXGv6qVhy27fWkbUYcMZEt57mkk 2X/ajfxwKm7lKp9+deIkBnXqBOWYM7VjZQQaDmTeIBok9ilRE2GhCUgdmka4aCJkNb0FdXF8N8OWp 8JKZToN1FXzN7ThPleZMcTTx8ifGYlguAuDTLD1PekASnI7UraqoKiDj5FaM3cmoCaHtDxlgzCaQ6 es2v4P+ATYpjkjb7MOWe3E6z3+ceE4LnkKPEijQntXqkCpV1NGBZJs/9v9inrd8bjx3JzVKMiMOKx FsGrTQBvcxsiP3BC1ndA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1dRxU5-0007cs-7l; Mon, 03 Jul 2017 09:17:33 +0000 Received: from mx08-00178001.pphosted.com ([91.207.212.93] helo=mx07-00178001.pphosted.com) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1dRxTX-0006Wp-6T for linux-arm-kernel@lists.infradead.org; Mon, 03 Jul 2017 09:17:01 +0000 Received: from pps.filterd (m0046661.ppops.net [127.0.0.1]) by mx08-.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id v63913mE015212; Mon, 3 Jul 2017 11:16:32 +0200 Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx08-.pphosted.com with ESMTP id 2be2mbtm6v-1 (version=TLSv1 cipher=ECDHE-RSA-AES256-SHA bits=256 verify=NOT); Mon, 03 Jul 2017 11:16:31 +0200 Received: from zeta.dmz-eu.st.com (zeta.dmz-eu.st.com [164.129.230.9]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id A86063D; Mon, 3 Jul 2017 09:16:30 +0000 (GMT) Received: from Webmail-eu.st.com (Safex1hubcas23.st.com [10.75.90.46]) by zeta.dmz-eu.st.com (STMicroelectronics) with ESMTP id C19A713AA; Mon, 3 Jul 2017 09:16:29 +0000 (GMT) Received: from localhost (10.201.23.73) by webmail-ga.st.com (10.75.90.48) with Microsoft SMTP Server (TLS) id 14.3.339.0; Mon, 3 Jul 2017 11:16:29 +0200 From: Hugues Fruchet To: Sylwester Nawrocki , " H. Nikolaus Schaller" , Guennadi Liakhovetski , Rob Herring , Mark Rutland , Maxime Coquelin , Alexandre Torgue , Mauro Carvalho Chehab , Hans Verkuil Subject: [PATCH v2 7/7] [media] ov9650: add analog power supply and clock gating Date: Mon, 3 Jul 2017 11:16:08 +0200 Message-ID: <1499073368-31905-8-git-send-email-hugues.fruchet@st.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1499073368-31905-1-git-send-email-hugues.fruchet@st.com> References: <1499073368-31905-1-git-send-email-hugues.fruchet@st.com> MIME-Version: 1.0 X-Originating-IP: [10.201.23.73] X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-07-03_04:, , signatures=0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170703_021659_569488_D916B215 X-CRM114-Status: GOOD ( 12.62 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Yannick Fertre , Benjamin Gaignard , Hugues Fruchet , linux-arm-kernel@lists.infradead.org, linux-media@vger.kernel.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Add optional analog power supply and clock gating. Signed-off-by: H. Nikolaus Schaller Signed-off-by: Hugues Fruchet --- drivers/media/i2c/ov9650.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/drivers/media/i2c/ov9650.c b/drivers/media/i2c/ov9650.c index 9ff0782..56b1eb3 100644 --- a/drivers/media/i2c/ov9650.c +++ b/drivers/media/i2c/ov9650.c @@ -29,6 +29,7 @@ #include #include #include +#include #include #include #include @@ -374,6 +375,7 @@ struct ov965x { /* External master clock frequency */ unsigned long mclk_frequency; struct clk *clk; + struct regulator *avdd; /* Protects the struct fields below */ struct mutex lock; @@ -943,13 +945,31 @@ static void ov965x_gpio_set(struct gpio_desc *gpio, int val) static void __ov965x_set_power(struct ov965x *ov965x, int on) { + int ret; + if (on) { + /* Bring up the power supply */ + ret = regulator_enable(ov965x->avdd); + if (ret) + dev_warn(&ov965x->client->dev, + "Failed to enable analog power (%d)\n", ret); + msleep(25); + /* Enable clock */ + ret = clk_prepare_enable(ov965x->clk); + if (ret) + dev_warn(&ov965x->client->dev, + "Failed to enable clock (%d)\n", ret); + msleep(25); + ov965x_gpio_set(ov965x->gpios[GPIO_PWDN], 0); ov965x_gpio_set(ov965x->gpios[GPIO_RST], 0); msleep(25); } else { ov965x_gpio_set(ov965x->gpios[GPIO_RST], 1); ov965x_gpio_set(ov965x->gpios[GPIO_PWDN], 1); + + clk_disable_unprepare(ov965x->clk); + regulator_disable(ov965x->avdd); } ov965x->streaming = 0; @@ -1969,6 +1989,12 @@ static int ov965x_probe(struct i2c_client *client, devm_gpiod_get_optional(&client->dev, "pwdn", GPIOD_OUT_HIGH); + ov965x->avdd = devm_regulator_get(&client->dev, "avdd"); + if (IS_ERR(ov965x->avdd)) { + dev_err(&client->dev, "Could not get analog regulator\n"); + return PTR_ERR(ov965x->avdd); + } + ov965x->clk = devm_clk_get(&client->dev, NULL); if (IS_ERR(ov965x->clk)) { dev_err(&client->dev, "Could not get clock\n");