From: Sakari Ailus <sakari.ailus@linux.intel.com>
To: linux-media@vger.kernel.org
Subject: [PATCH 3/4] smiapp: Get clock rate if it's not available through DT
Date: Mon, 13 Feb 2017 18:16:25 +0200 [thread overview]
Message-ID: <1487002586-1480-4-git-send-email-sakari.ailus@linux.intel.com> (raw)
In-Reply-To: <1487002586-1480-1-git-send-email-sakari.ailus@linux.intel.com>
Obtain the clock rate from the clock framework if it's not available
through DT. The assumption is that the parent device (camera module)
defines the rate as clock control is a part of the power on and power off
sequences --- which are camera module specific.
Also use the clock rate from DT if no clock is provided.
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
---
drivers/media/i2c/smiapp/smiapp-core.c | 50 ++++++++++++++++++++++------------
1 file changed, 32 insertions(+), 18 deletions(-)
diff --git a/drivers/media/i2c/smiapp/smiapp-core.c b/drivers/media/i2c/smiapp/smiapp-core.c
index 64ee215..caf376c 100644
--- a/drivers/media/i2c/smiapp/smiapp-core.c
+++ b/drivers/media/i2c/smiapp/smiapp-core.c
@@ -2822,10 +2822,8 @@ static struct smiapp_hwconfig *smiapp_get_hwconfig(struct device *dev)
rval = of_property_read_u32(dev->of_node, "clock-frequency",
&hwcfg->ext_clk);
- if (rval) {
- dev_warn(dev, "can't get clock-frequency\n");
- goto out_err;
- }
+ if (rval)
+ dev_info(dev, "can't get clock-frequency\n");
dev_dbg(dev, "nvm %d, clk %d, csi %d\n", hwcfg->nvm_size,
hwcfg->ext_clk, hwcfg->csi_signalling_mode);
@@ -2861,7 +2859,6 @@ static int smiapp_probe(struct i2c_client *client,
{
struct smiapp_sensor *sensor;
struct smiapp_hwconfig *hwcfg = smiapp_get_hwconfig(&client->dev);
- unsigned long rate;
unsigned int i;
int rval;
@@ -2892,20 +2889,37 @@ static int smiapp_probe(struct i2c_client *client,
return -EPROBE_DEFER;
}
- rval = clk_set_rate(sensor->ext_clk, sensor->hwcfg->ext_clk);
- if (rval < 0) {
- dev_err(&client->dev,
- "unable to set clock freq to %u\n",
- sensor->hwcfg->ext_clk);
- return rval;
- }
+ if (sensor->ext_clk) {
+ if (sensor->hwcfg->ext_clk) {
+ unsigned long rate;
- rate = clk_get_rate(sensor->ext_clk);
- if (rate != sensor->hwcfg->ext_clk) {
- dev_err(&client->dev,
- "can't set clock freq, asked for %u but got %lu\n",
- sensor->hwcfg->ext_clk, rate);
- return rval;
+ rval = clk_set_rate(sensor->ext_clk,
+ sensor->hwcfg->ext_clk);
+ if (rval < 0) {
+ dev_err(&client->dev,
+ "unable to set clock freq to %u\n",
+ sensor->hwcfg->ext_clk);
+ return rval;
+ }
+
+ rate = clk_get_rate(sensor->ext_clk);
+ if (rate != sensor->hwcfg->ext_clk) {
+ dev_err(&client->dev,
+ "can't set clock freq, asked for %lu but got %lu\n",
+ sensor->hwcfg->ext_clk, rate);
+ return rval;
+ }
+ } else {
+ sensor->hwcfg->ext_clk = clk_get_rate(sensor->ext_clk);
+ dev_dbg(&client->dev, "obtained clock freq %u\n",
+ sensor->hwcfg->ext_clk);
+ }
+ } else if (sensor->hwcfg->ext_clk) {
+ dev_dbg(&client->dev, "assuming clock freq %u\n",
+ sensor->hwcfg->ext_clk);
+ } else {
+ dev_err(&client->dev, "unable to obtain clock freq\n");
+ return -EINVAL;
}
sensor->xshutdown = devm_gpiod_get_optional(&client->dev, "xshutdown",
--
2.1.4
next prev parent reply other threads:[~2017-02-13 16:16 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-02-13 16:16 [PATCH 0/4] smiapp cleanups, clock control changes Sakari Ailus
2017-02-13 16:16 ` [PATCH 1/4] smiapp: Remove smiapp.h header under include Sakari Ailus
2017-02-13 16:16 ` [PATCH 2/4] smiapp: Verify clock frequency after setting it, prevent changing it Sakari Ailus
2017-02-13 16:16 ` Sakari Ailus [this message]
2017-02-13 18:27 ` [PATCH 3/4] smiapp: Get clock rate if it's not available through DT kbuild test robot
2017-02-14 7:37 ` [PATCH v1.1 " Sakari Ailus
2017-02-15 23:05 ` [PATCH " kbuild test robot
2017-02-13 16:16 ` [PATCH 4/4] smiapp: Make clock control optional Sakari Ailus
-- strict thread matches above, loose matches on Subject: below --
2017-08-29 12:41 [PATCH 0/4] Better support for ACPI in smiapp Sakari Ailus
2017-08-29 12:41 ` [PATCH 3/4] smiapp: Get clock rate if it's not available through DT Sakari Ailus
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=1487002586-1480-4-git-send-email-sakari.ailus@linux.intel.com \
--to=sakari.ailus@linux.intel.com \
--cc=linux-media@vger.kernel.org \
/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