From: Hugues Fruchet <hugues.fruchet@st.com>
To: Sylwester Nawrocki <sylvester.nawrocki@gmail.com>,
" H. Nikolaus Schaller" <hns@goldelico.com>,
Guennadi Liakhovetski <g.liakhovetski@gmx.de>,
Rob Herring <robh+dt@kernel.org>,
Mark Rutland <mark.rutland@arm.com>,
Maxime Coquelin <mcoquelin.stm32@gmail.com>,
Alexandre Torgue <alexandre.torgue@st.com>,
Mauro Carvalho Chehab <mchehab@kernel.org>,
Hans Verkuil <hverkuil@xs4all.nl>
Cc: <devicetree@vger.kernel.org>,
<linux-arm-kernel@lists.infradead.org>,
<linux-kernel@vger.kernel.org>, <linux-media@vger.kernel.org>,
Benjamin Gaignard <benjamin.gaignard@linaro.org>,
Yannick Fertre <yannick.fertre@st.com>,
Hugues Fruchet <hugues.fruchet@st.com>
Subject: [PATCH v2 7/7] [media] ov9650: add analog power supply and clock gating
Date: Mon, 3 Jul 2017 11:16:08 +0200 [thread overview]
Message-ID: <1499073368-31905-8-git-send-email-hugues.fruchet@st.com> (raw)
In-Reply-To: <1499073368-31905-1-git-send-email-hugues.fruchet@st.com>
Add optional analog power supply and clock gating.
Signed-off-by: H. Nikolaus Schaller <hns@goldelico.com>
Signed-off-by: Hugues Fruchet <hugues.fruchet@st.com>
---
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 <linux/module.h>
#include <linux/of_gpio.h>
#include <linux/ratelimit.h>
+#include <linux/regulator/consumer.h>
#include <linux/slab.h>
#include <linux/string.h>
#include <linux/videodev2.h>
@@ -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");
--
1.9.1
next prev parent reply other threads:[~2017-07-03 9:18 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-07-03 9:16 [PATCH v2 0/7] [PATCH v2 0/7] Add support of OV9655 camera Hugues Fruchet
2017-07-03 9:16 ` [PATCH v2 1/7] DT bindings: add bindings for ov965x camera module Hugues Fruchet
2017-07-05 14:03 ` Rob Herring
2017-07-05 14:48 ` Hugues FRUCHET
2017-07-03 9:16 ` [PATCH v2 2/7] [media] ov9650: switch i2c device id to lower case Hugues Fruchet
2017-07-12 19:18 ` Sylwester Nawrocki
2017-07-03 9:16 ` [PATCH v2 3/7] [media] ov9650: add device tree support Hugues Fruchet
2017-07-08 23:06 ` Sakari Ailus
2017-07-18 10:26 ` Hugues FRUCHET
2017-07-12 19:33 ` Sylwester Nawrocki
2017-07-03 9:16 ` [PATCH v2 4/7] [media] ov9650: use write_array() for resolution sequences Hugues Fruchet
2017-07-08 23:08 ` Sakari Ailus
2017-07-03 9:16 ` [PATCH v2 5/7] [media] ov9650: add multiple variant support Hugues Fruchet
2017-07-03 9:16 ` [PATCH v2 6/7] [media] ov9650: add support of OV9655 variant Hugues Fruchet
2017-07-03 9:16 ` Hugues Fruchet [this message]
2017-07-06 7:51 ` [PATCH v2 0/7] [PATCH v2 0/7] Add support of OV9655 camera Hugues FRUCHET
2017-07-09 16:18 ` Sylwester Nawrocki
2017-07-12 20:01 ` Sylwester Nawrocki
2017-07-18 11:59 ` Hans Verkuil
2017-07-18 12:17 ` H. Nikolaus Schaller
2017-07-18 12:53 ` Hugues FRUCHET
2017-07-18 19:52 ` Sakari Ailus
2017-07-20 8:37 ` H. Nikolaus Schaller
2017-07-20 9:17 ` Hugues FRUCHET
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1499073368-31905-8-git-send-email-hugues.fruchet@st.com \
--to=hugues.fruchet@st.com \
--cc=alexandre.torgue@st.com \
--cc=benjamin.gaignard@linaro.org \
--cc=devicetree@vger.kernel.org \
--cc=g.liakhovetski@gmx.de \
--cc=hns@goldelico.com \
--cc=hverkuil@xs4all.nl \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=mark.rutland@arm.com \
--cc=mchehab@kernel.org \
--cc=mcoquelin.stm32@gmail.com \
--cc=robh+dt@kernel.org \
--cc=sylvester.nawrocki@gmail.com \
--cc=yannick.fertre@st.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®