* I2C add ov2640 ?
@ 2013-11-05 1:19 Chris Ruehl
[not found] ` <52784785.1040406-CR359r9tUDPXPF5Rlphj1Q@public.gmane.org>
0 siblings, 1 reply; 7+ messages in thread
From: Chris Ruehl @ 2013-11-05 1:19 UTC (permalink / raw)
To: devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Hi,
we continuing moving our board (imx27) to the devicetree implementation,
and find nothing howto deal with the ov2640 connect via i2c(0x30) and CSI
interface to the Freescale SoC.
Here is what I did:
&i2c1 {
status = "okay";
clock-frequency = <400000>;
cmos@30 {
compatible = "omni,ov2640";
reg = <0x30>;
};
};
but when I boot the kernel, ov2640 complains about missing platform data.
--
Regards
Chris
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: I2C add ov2640 ?
[not found] ` <52784785.1040406-CR359r9tUDPXPF5Rlphj1Q@public.gmane.org>
@ 2013-11-05 10:04 ` Chris Ruehl
[not found] ` <5278C2B4.802-CR359r9tUDPXPF5Rlphj1Q@public.gmane.org>
0 siblings, 1 reply; 7+ messages in thread
From: Chris Ruehl @ 2013-11-05 10:04 UTC (permalink / raw)
To: devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Hi
On Tuesday, November 05, 2013 09:19 AM, Chris Ruehl wrote:
> Hi,
>
> we continuing moving our board (imx27) to the devicetree implementation,
> and find nothing howto deal with the ov2640 connect via i2c(0x30) and
> CSI interface to the Freescale SoC.
>
> Here is what I did:
>
> &i2c1 {
> status = "okay";
> clock-frequency = <400000>;
>
> cmos@30 {
> compatible = "omni,ov2640";
> reg = <0x30>;
> };
> };
>
>
>
> but when I boot the kernel, ov2640 complains about missing platform data.
>
Seams I got it. Will try that patch tomorrow and send a proper patch-set when
done.
--- a/drivers/media/i2c/soc_camera/ov2640.c
+++ b/drivers/media/i2c/soc_camera/ov2640.c
@@ -15,6 +15,7 @@
#include <linux/init.h>
#include <linux/module.h>
+#include <linux/of.h>
#include <linux/i2c.h>
#include <linux/slab.h>
#include <linux/delay.h>
@@ -1060,6 +1061,24 @@ static struct v4l2_subdev_ops ov2640_subdev_ops = {
.video = &ov2640_subdev_video_ops,
};
+static struct soc_camera_subdev_desc *
+ov2640_get_pdata(struct i2c_client *client)
+{
+ struct soc_camera_subdev_desc *pdata;
+
+ if (!IS_ENABLED(CONFIG_OF) || !client->dev.of_node)
+ return soc_camera_i2c_to_desc(client);
+
+ pdata = devm_kzalloc(&client->dev, sizeof(*pdata), GFP_KERNEL);
+
+ if (!pdata)
+ goto done;
+
+ /* TODO anything to prepare before return */
+done:
+ return pdata;
+}
+
/*
* i2c_driver functions
*/
@@ -1067,7 +1086,7 @@ static int ov2640_probe(struct i2c_client *client,
const struct i2c_device_id *did)
{
struct ov2640_priv *priv;
- struct soc_camera_subdev_desc *ssdd = soc_camera_i2c_to_desc(client);
+ struct soc_camera_subdev_desc *ssdd = ov2640_get_pdata(client);
struct i2c_adapter *adapter = to_i2c_adapter(client->dev.parent);
int ret;
@@ -1128,6 +1147,14 @@ static int ov2640_remove(struct i2c_client *client)
return 0;
}
+#if IS_ENABLED(CONFIG_OF)
+static const struct of_device_id ov2640_of_match[] = {
+ { .compatible = "omnivision,ov2640" },
+ { /* sentinel */ }
+};
+MODULE_DEVICE_TABLE(of, ov2640_of_match);
+#endif
+
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: I2C add ov2640 ?
[not found] ` <5278C2B4.802-CR359r9tUDPXPF5Rlphj1Q@public.gmane.org>
@ 2013-11-05 10:58 ` Fabio Estevam
[not found] ` <CAOMZO5DdUyvKAJdwYLpVR2+V5HBCt-AqgDxwgkh4AHQsE+evng-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
0 siblings, 1 reply; 7+ messages in thread
From: Fabio Estevam @ 2013-11-05 10:58 UTC (permalink / raw)
To: Chris Ruehl; +Cc: devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Hi Chris,
On Tue, Nov 5, 2013 at 8:04 AM, Chris Ruehl <chris.ruehl-CR359r9tUDPXPF5Rlphj1Q@public.gmane.org> wrote:
>
> Seams I got it. Will try that patch tomorrow and send a proper patch-set
> when
> done.
Don't you need to retrieve the regulators from dt as well?
Regards,
Fabio Estevam
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: I2C add ov2640 ?
[not found] ` <CAOMZO5DdUyvKAJdwYLpVR2+V5HBCt-AqgDxwgkh4AHQsE+evng-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
@ 2013-11-07 6:28 ` Chris Ruehl
[not found] ` <527B330D.3040704-CR359r9tUDPXPF5Rlphj1Q@public.gmane.org>
0 siblings, 1 reply; 7+ messages in thread
From: Chris Ruehl @ 2013-11-07 6:28 UTC (permalink / raw)
To: Fabio Estevam; +Cc: devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Hi Fabio
On Tuesday, November 05, 2013 06:58 PM, Fabio Estevam wrote:
> Hi Chris,
>
> On Tue, Nov 5, 2013 at 8:04 AM, Chris Ruehl<chris.ruehl-CR359r9tUDPXPF5Rlphj1Q@public.gmane.org> wrote:
>
>>
>> Seams I got it. Will try that patch tomorrow and send a proper patch-set
>> when
>> done.
>
> Don't you need to retrieve the regulators from dt as well?
>
> Regards,
>
> Fabio Estevam
Still try to make the ov2640 run with DT and imx27 good thing:
I see a i2c-0 in the /sys path for the 0x30 but the driver is not loaded
I did
a) add a pw_gpios = <&gpio1 13 0> and mentioned regulator
b) add some code to fill the pdata allocate at runtime
c) find out that mclk seams missing and this is why the driver was not loaded
a)
&i2c1 {
status = "okay";
clock-frequency = <400000>;
ov2640@30 {
compatible = "omnivision,ov2640";
vcc-supply = <®_3v3>;
reg = <0x30>;
pw_gpios = <&gpio1 13 0>;
};
};
b)
--- a/drivers/media/i2c/soc_camera/ov2640.c
+++ b/drivers/media/i2c/soc_camera/ov2640.c
@@ -15,6 +15,9 @@
#include <linux/init.h>
#include <linux/module.h>
+#include <linux/of.h>
+#include <linux/of_device.h>
+#include <linux/of_gpio.h>
#include <linux/i2c.h>
#include <linux/slab.h>
#include <linux/delay.h>
@@ -983,8 +986,10 @@ static int ov2640_video_probe(struct i2c_client *client)
int ret;
ret = ov2640_s_power(&priv->subdev, 1);
- if (ret < 0)
+ if (ret < 0) {
+ dev_err(&client->dev,"PowerON failed");
return ret;
+ }
/*
* check and show product ID and manufacturer ID
@@ -1059,6 +1064,49 @@ static struct v4l2_subdev_ops ov2640_subdev_ops = {
.core = &ov2640_subdev_core_ops,
.video = &ov2640_subdev_video_ops,
};
+#ifdef CONFIG_OF
+static int camera_power_of(struct device *dev, int on)
+{
+ int pwgpio;
+ struct device_node *np = dev->of_node;
+ if (!np)
+ goto power_done;
+
+ pwgpio = of_get_named_gpio(np, "pw-gpios", 0);
+ if (gpio_is_valid(pwgpio))
+ gpio_set_value(pwgpio, on);
+
+power_done:
+ return 0;
+}
+
+static struct soc_camera_subdev_desc *
+ov2640_get_pdata(struct i2c_client *client)
+{
+ struct soc_camera_subdev_desc *pdata;
+
+ if (!client->dev.of_node)
+ return soc_camera_i2c_to_desc(client);
+
+ pdata = devm_kzalloc(&client->dev, sizeof(*pdata), GFP_KERNEL);
+
+ if (!pdata)
+ goto get_done;
+
+ /* TODO anything to prepare before return */
+ pdata->power = camera_power_of;
+ client->dev.platform_data = pdata;
+
+get_done:
+ return pdata;
+}
+#else
+static struct soc_camera_subdev_desc *
+ov2640_get_pdata(struct i2c_client *client)
+{
+ return soc_camera_i2c_to_desc(client);
+}
+#endif /* CONFIG_OF */
/*
* i2c_driver functions
@@ -1067,7 +1115,7 @@ static int ov2640_probe(struct i2c_client *client,
const struct i2c_device_id *did)
{
struct ov2640_priv *priv;
- struct soc_camera_subdev_desc *ssdd = soc_camera_i2c_to_desc(client);
+ struct soc_camera_subdev_desc *ssdd = ov2640_get_pdata(client);
struct i2c_adapter *adapter = to_i2c_adapter(client->dev.parent);
int ret;
@@ -1083,7 +1131,8 @@ static int ov2640_probe(struct i2c_client *client,
return -EIO;
}
- priv = devm_kzalloc(&client->dev, sizeof(struct ov2640_priv), GFP_KERNEL);
+ priv = devm_kzalloc(&client->dev, sizeof(struct ov2640_priv)
+ , GFP_KERNEL);
if (!priv) {
dev_err(&adapter->dev,
"Failed to allocate memory for private data!\n");
@@ -1102,6 +1151,7 @@ static int ov2640_probe(struct i2c_client *client,
priv->clk = v4l2_clk_get(&client->dev, "mclk");
if (IS_ERR(priv->clk)) {
+ dev_err(&adapter->dev, "OV2640 Not probed mclk missing\n");
ret = PTR_ERR(priv->clk);
goto eclkget;
}
@@ -1128,6 +1178,14 @@ static int ov2640_remove(struct i2c_client *client)
return 0;
}
+#if IS_ENABLED(CONFIG_OF)
+static const struct of_device_id ov2640_of_match[] = {
+ { .compatible = "omnivision,ov2640" },
+ { /* sentinel */ }
+};
+MODULE_DEVICE_TABLE(of, ov2640_of_match);
+#endif
+
c) in the patch dev_err(&adapter->dev, "OV2640 Not probed mclk missing\n");
give me the hint was wrong.
from your conversation with Sascha Hauer
http://www.spinics.net/lists/linux-i2c/msg09099.html
I see that's other ways to get a clock, thats works for
v4l2_clk_get(&client->dev, "mclk")
v4l2_clk_get(&client->dev, NULL)
as well?
Regards
Chris
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: I2C add ov2640 ?
[not found] ` <527B330D.3040704-CR359r9tUDPXPF5Rlphj1Q@public.gmane.org>
@ 2013-11-07 18:08 ` Fabio Estevam
[not found] ` <CAOMZO5Acink+VzWZmv_w1dEyp4AU3mS9fHwt82c28h+VHFDmUw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
0 siblings, 1 reply; 7+ messages in thread
From: Fabio Estevam @ 2013-11-07 18:08 UTC (permalink / raw)
To: Chris Ruehl; +Cc: devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
On Thu, Nov 7, 2013 at 4:28 AM, Chris Ruehl <chris.ruehl-CR359r9tUDPXPF5Rlphj1Q@public.gmane.org> wrote:
> c) in the patch dev_err(&adapter->dev, "OV2640 Not probed mclk missing\n");
> give me the hint was wrong.
>
> from your conversation with Sascha Hauer
> http://www.spinics.net/lists/linux-i2c/msg09099.html
>
> I see that's other ways to get a clock, thats works for
> v4l2_clk_get(&client->dev, "mclk")
> v4l2_clk_get(&client->dev, NULL)
You probably need to pass the mclk clock via device tree.
Please start a new thread about it on linux-media and add Guennadi on Cc.
Regards,
Fabio Estveam
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: I2C add ov2640 ?
[not found] ` <CAOMZO5Acink+VzWZmv_w1dEyp4AU3mS9fHwt82c28h+VHFDmUw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
@ 2013-11-08 1:12 ` Chris Ruehl
2014-03-14 14:02 ` Ramiro Oliveira
0 siblings, 1 reply; 7+ messages in thread
From: Chris Ruehl @ 2013-11-08 1:12 UTC (permalink / raw)
To: Fabio Estevam; +Cc: devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
On Friday, November 08, 2013 02:08 AM, Fabio Estevam wrote:
> On Thu, Nov 7, 2013 at 4:28 AM, Chris Ruehl<chris.ruehl-CR359r9tUDPXPF5Rlphj1Q@public.gmane.org> wrote:
>
>> c) in the patch dev_err(&adapter->dev, "OV2640 Not probed mclk missing\n");
>> give me the hint was wrong.
>>
>> from your conversation with Sascha Hauer
>> http://www.spinics.net/lists/linux-i2c/msg09099.html
>>
>> I see that's other ways to get a clock, thats works for
>> v4l2_clk_get(&client->dev, "mclk")
>> v4l2_clk_get(&client->dev, NULL)
>
> You probably need to pass the mclk clock via device tree.
>
> Please start a new thread about it on linux-media and add Guennadi on Cc.
>
> Regards,
>
> Fabio Estveam
Hi Fabio,
Thanks for the hint,, found an old thread
https://lkml.org/lkml/2013/7/30/246
where the clock is provided to a sound card via device tree. I will see if I can
make a patch and then I post it again.
Chris
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: I2C add ov2640 ?
2013-11-08 1:12 ` Chris Ruehl
@ 2014-03-14 14:02 ` Ramiro Oliveira
0 siblings, 0 replies; 7+ messages in thread
From: Ramiro Oliveira @ 2014-03-14 14:02 UTC (permalink / raw)
To: devicetree-u79uwXL29TY76Z2rM5mHXA
Chris Ruehl <chris.ruehl@...> writes:
> Hi Fabio,
>
> Thanks for the hint,, found an old thread
> https://lkml.org/lkml/2013/7/30/246
>
> where the clock is provided to a sound card via device tree. I will see if
I can
> make a patch and then I post it again.
>
> Chris
> --
> To unsubscribe from this list: send the line "unsubscribe devicetree" in
> the body of a message to majordomo@...
> More majordomo info at http://vger.kernel.org/majordomo-info.html
>
>
Hi,
Sorry for hijacking this thread, but I'm having some issues with v4l2_clk_get
which doesn't seem to support device tree.
Did you manage to find a solution to your problem?
Thanks,
Ramiro
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2014-03-14 14:02 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-11-05 1:19 I2C add ov2640 ? Chris Ruehl
[not found] ` <52784785.1040406-CR359r9tUDPXPF5Rlphj1Q@public.gmane.org>
2013-11-05 10:04 ` Chris Ruehl
[not found] ` <5278C2B4.802-CR359r9tUDPXPF5Rlphj1Q@public.gmane.org>
2013-11-05 10:58 ` Fabio Estevam
[not found] ` <CAOMZO5DdUyvKAJdwYLpVR2+V5HBCt-AqgDxwgkh4AHQsE+evng-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2013-11-07 6:28 ` Chris Ruehl
[not found] ` <527B330D.3040704-CR359r9tUDPXPF5Rlphj1Q@public.gmane.org>
2013-11-07 18:08 ` Fabio Estevam
[not found] ` <CAOMZO5Acink+VzWZmv_w1dEyp4AU3mS9fHwt82c28h+VHFDmUw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2013-11-08 1:12 ` Chris Ruehl
2014-03-14 14:02 ` Ramiro Oliveira
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).