* [PATCH RFC 03/13] OF: define of_*_cmp() macros also if CONFIG_OF isn't set
2012-12-10 19:41 [PATCH RFC 00/13] Common video input interfaces bindings and V4L2 OF helpers Sylwester Nawrocki
@ 2012-12-10 19:41 ` Sylwester Nawrocki
[not found] ` <1355168499-5847-4-git-send-email-s.nawrocki-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org>
2012-12-10 19:41 ` [PATCH RFC 04/13] OF: make a function pointer argument const Sylwester Nawrocki
` (9 subsequent siblings)
10 siblings, 1 reply; 25+ messages in thread
From: Sylwester Nawrocki @ 2012-12-10 19:41 UTC (permalink / raw)
To: g.liakhovetski, linux-media
Cc: grant.likely, rob.herring, thomas.abraham, t.figa, sw0312.kim,
kyungmin.park, devicetree-discuss, linux-kernel
From: Guennadi Liakhovetski <g.liakhovetski@gmx.de>
of_*_cmp() macros do not depend on any OF functions and can be defined also
if CONFIG_OF isn't set. Also include linux/string.h, required by those
macros.
Signed-off-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de>
---
include/linux/of.h | 15 ++++++++-------
1 file changed, 8 insertions(+), 7 deletions(-)
diff --git a/include/linux/of.h b/include/linux/of.h
index 9ba8cf1..38d4b1a 100644
--- a/include/linux/of.h
+++ b/include/linux/of.h
@@ -85,6 +85,14 @@ static inline struct device_node *of_node_get(struct device_node *node)
static inline void of_node_put(struct device_node *node) { }
#endif /* !CONFIG_OF_DYNAMIC */
+/* Default string compare functions, Allow arch asm/prom.h to override */
+#if !defined(of_compat_cmp)
+#include <linux/string.h>
+#define of_compat_cmp(s1, s2, l) strcasecmp((s1), (s2))
+#define of_prop_cmp(s1, s2) strcmp((s1), (s2))
+#define of_node_cmp(s1, s2) strcasecmp((s1), (s2))
+#endif
+
#ifdef CONFIG_OF
/* Pointer for first entry in chain of all nodes. */
@@ -143,13 +151,6 @@ static inline unsigned long of_read_ulong(const __be32 *cell, int size)
#define OF_ROOT_NODE_SIZE_CELLS_DEFAULT 1
#endif
-/* Default string compare functions, Allow arch asm/prom.h to override */
-#if !defined(of_compat_cmp)
-#define of_compat_cmp(s1, s2, l) strcasecmp((s1), (s2))
-#define of_prop_cmp(s1, s2) strcmp((s1), (s2))
-#define of_node_cmp(s1, s2) strcasecmp((s1), (s2))
-#endif
-
/* flag descriptions */
#define OF_DYNAMIC 1 /* node and properties were allocated via kmalloc */
#define OF_DETACHED 2 /* node has been detached from the device tree */
--
1.7.9.5
^ permalink raw reply related [flat|nested] 25+ messages in thread
* [PATCH RFC 04/13] OF: make a function pointer argument const
2012-12-10 19:41 [PATCH RFC 00/13] Common video input interfaces bindings and V4L2 OF helpers Sylwester Nawrocki
2012-12-10 19:41 ` [PATCH RFC 03/13] OF: define of_*_cmp() macros also if CONFIG_OF isn't set Sylwester Nawrocki
@ 2012-12-10 19:41 ` Sylwester Nawrocki
2012-12-11 8:51 ` Grant Likely
[not found] ` <1355168499-5847-1-git-send-email-s.nawrocki-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org>
` (8 subsequent siblings)
10 siblings, 1 reply; 25+ messages in thread
From: Sylwester Nawrocki @ 2012-12-10 19:41 UTC (permalink / raw)
To: g.liakhovetski, linux-media
Cc: grant.likely, rob.herring, thomas.abraham, t.figa, sw0312.kim,
kyungmin.park, devicetree-discuss, linux-kernel
From: Guennadi Liakhovetski <g.liakhovetski@gmx.de>
The "struct device_node *" argument of of_parse_phandle_*() can be const.
Signed-off-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de>
---
drivers/of/base.c | 4 ++--
include/linux/of.h | 6 +++---
2 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/drivers/of/base.c b/drivers/of/base.c
index af3b22a..c180205 100644
--- a/drivers/of/base.c
+++ b/drivers/of/base.c
@@ -894,7 +894,7 @@ EXPORT_SYMBOL_GPL(of_property_count_strings);
* of_node_put() on it when done.
*/
struct device_node *
-of_parse_phandle(struct device_node *np, const char *phandle_name, int index)
+of_parse_phandle(const struct device_node *np, const char *phandle_name, int index)
{
const __be32 *phandle;
int size;
@@ -939,7 +939,7 @@ EXPORT_SYMBOL(of_parse_phandle);
* To get a device_node of the `node2' node you may call this:
* of_parse_phandle_with_args(node3, "list", "#list-cells", 1, &args);
*/
-int of_parse_phandle_with_args(struct device_node *np, const char *list_name,
+int of_parse_phandle_with_args(const struct device_node *np, const char *list_name,
const char *cells_name, int index,
struct of_phandle_args *out_args)
{
diff --git a/include/linux/of.h b/include/linux/of.h
index 38d4b1a..2fb0dbe 100644
--- a/include/linux/of.h
+++ b/include/linux/of.h
@@ -256,10 +256,10 @@ extern int of_n_size_cells(struct device_node *np);
extern const struct of_device_id *of_match_node(
const struct of_device_id *matches, const struct device_node *node);
extern int of_modalias_node(struct device_node *node, char *modalias, int len);
-extern struct device_node *of_parse_phandle(struct device_node *np,
+extern struct device_node *of_parse_phandle(const struct device_node *np,
const char *phandle_name,
int index);
-extern int of_parse_phandle_with_args(struct device_node *np,
+extern int of_parse_phandle_with_args(const struct device_node *np,
const char *list_name, const char *cells_name, int index,
struct of_phandle_args *out_args);
@@ -412,7 +412,7 @@ static inline int of_property_match_string(struct device_node *np,
return -ENOSYS;
}
-static inline struct device_node *of_parse_phandle(struct device_node *np,
+static inline struct device_node *of_parse_phandle(const struct device_node *np,
const char *phandle_name,
int index)
{
--
1.7.9.5
^ permalink raw reply related [flat|nested] 25+ messages in thread
* Re: [PATCH RFC 04/13] OF: make a function pointer argument const
2012-12-10 19:41 ` [PATCH RFC 04/13] OF: make a function pointer argument const Sylwester Nawrocki
@ 2012-12-11 8:51 ` Grant Likely
0 siblings, 0 replies; 25+ messages in thread
From: Grant Likely @ 2012-12-11 8:51 UTC (permalink / raw)
To: Sylwester Nawrocki, g.liakhovetski, linux-media
Cc: rob.herring, thomas.abraham, t.figa, sw0312.kim, kyungmin.park,
devicetree-discuss, linux-kernel
On Mon, 10 Dec 2012 20:41:30 +0100, Sylwester Nawrocki <s.nawrocki@samsung.com> wrote:
> From: Guennadi Liakhovetski <g.liakhovetski@gmx.de>
>
> The "struct device_node *" argument of of_parse_phandle_*() can be const.
This is a good time to talk about commit text. Again, the patch looks
fine, but it helps *a lot* if you give me some details about how you
constructed the patch and tested it.
What architectures did you build? What defconfigs did you use? Did you look
at all the users, or can you say the users should all be good?
It also always helps to tell my *why* you made a change.
Otherwise you leave all the leg work up to me or another maintainer.
We've got a lot of work. Anything you can do to make that easier makes
us less grumpy. :-)
I'll try to apply the patch (I've actually already merged another one
that does of_parse_phandle, but not of_parse_phandle_with_args, so I'll
need to resolve the conflict)
g.
>
> Signed-off-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de>
> ---
> drivers/of/base.c | 4 ++--
> include/linux/of.h | 6 +++---
> 2 files changed, 5 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/of/base.c b/drivers/of/base.c
> index af3b22a..c180205 100644
> --- a/drivers/of/base.c
> +++ b/drivers/of/base.c
> @@ -894,7 +894,7 @@ EXPORT_SYMBOL_GPL(of_property_count_strings);
> * of_node_put() on it when done.
> */
> struct device_node *
> -of_parse_phandle(struct device_node *np, const char *phandle_name, int index)
> +of_parse_phandle(const struct device_node *np, const char *phandle_name, int index)
> {
> const __be32 *phandle;
> int size;
> @@ -939,7 +939,7 @@ EXPORT_SYMBOL(of_parse_phandle);
> * To get a device_node of the `node2' node you may call this:
> * of_parse_phandle_with_args(node3, "list", "#list-cells", 1, &args);
> */
> -int of_parse_phandle_with_args(struct device_node *np, const char *list_name,
> +int of_parse_phandle_with_args(const struct device_node *np, const char *list_name,
> const char *cells_name, int index,
> struct of_phandle_args *out_args)
> {
> diff --git a/include/linux/of.h b/include/linux/of.h
> index 38d4b1a..2fb0dbe 100644
> --- a/include/linux/of.h
> +++ b/include/linux/of.h
> @@ -256,10 +256,10 @@ extern int of_n_size_cells(struct device_node *np);
> extern const struct of_device_id *of_match_node(
> const struct of_device_id *matches, const struct device_node *node);
> extern int of_modalias_node(struct device_node *node, char *modalias, int len);
> -extern struct device_node *of_parse_phandle(struct device_node *np,
> +extern struct device_node *of_parse_phandle(const struct device_node *np,
> const char *phandle_name,
> int index);
> -extern int of_parse_phandle_with_args(struct device_node *np,
> +extern int of_parse_phandle_with_args(const struct device_node *np,
> const char *list_name, const char *cells_name, int index,
> struct of_phandle_args *out_args);
>
> @@ -412,7 +412,7 @@ static inline int of_property_match_string(struct device_node *np,
> return -ENOSYS;
> }
>
> -static inline struct device_node *of_parse_phandle(struct device_node *np,
> +static inline struct device_node *of_parse_phandle(const struct device_node *np,
> const char *phandle_name,
> int index)
> {
> --
> 1.7.9.5
>
--
Grant Likely, B.Sc, P.Eng.
Secret Lab Technologies, Ltd.
^ permalink raw reply [flat|nested] 25+ messages in thread
[parent not found: <1355168499-5847-1-git-send-email-s.nawrocki-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org>]
* [PATCH RFC 01/13] i2c: add dummy inline functions for when CONFIG_OF_I2C(_MODULE) isn't defined
[not found] ` <1355168499-5847-1-git-send-email-s.nawrocki-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org>
@ 2012-12-10 19:41 ` Sylwester Nawrocki
2012-12-11 8:39 ` Grant Likely
2012-12-10 19:41 ` [PATCH RFC 02/13] of: add a dummy inline function for when CONFIG_OF is not defined Sylwester Nawrocki
2012-12-10 19:41 ` [PATCH RFC 05/13] of: Add empty for_each_available_child_of_node() macro definition Sylwester Nawrocki
2 siblings, 1 reply; 25+ messages in thread
From: Sylwester Nawrocki @ 2012-12-10 19:41 UTC (permalink / raw)
To: g.liakhovetski-Mmb7MZpHnFY, linux-media-u79uwXL29TY76Z2rM5mHXA
Cc: sw0312.kim-Sze3O3UU22JBDgjK7y7TUQ,
linux-kernel-u79uwXL29TY76Z2rM5mHXA,
rob.herring-bsGFqQB8/DxBDgjK7y7TUQ,
kyungmin.park-Sze3O3UU22JBDgjK7y7TUQ,
devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ
From: Guennadi Liakhovetski <g.liakhovetski-Mmb7MZpHnFY@public.gmane.org>
If CONFIG_OF_I2C and CONFIG_OF_I2C_MODULE are undefined no declaration of
of_find_i2c_device_by_node and of_find_i2c_adapter_by_node will be
available. Add dummy inline functions to avoid compilation breakage.
Signed-off-by: Guennadi Liakhovetski <g.liakhovetski-Mmb7MZpHnFY@public.gmane.org>
---
include/linux/of_i2c.h | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/include/linux/of_i2c.h b/include/linux/of_i2c.h
index 1cb775f..cfb545c 100644
--- a/include/linux/of_i2c.h
+++ b/include/linux/of_i2c.h
@@ -29,6 +29,18 @@ static inline void of_i2c_register_devices(struct i2c_adapter *adap)
{
return;
}
+
+static inline struct i2c_client *of_find_i2c_device_by_node(struct device_node *node)
+{
+ return NULL;
+}
+
+/* must call put_device() when done with returned i2c_adapter device */
+static inline struct i2c_adapter *of_find_i2c_adapter_by_node(
+ struct device_node *node)
+{
+ return NULL;
+}
#endif /* CONFIG_OF_I2C */
#endif /* __LINUX_OF_I2C_H */
--
1.7.9.5
^ permalink raw reply related [flat|nested] 25+ messages in thread
* Re: [PATCH RFC 01/13] i2c: add dummy inline functions for when CONFIG_OF_I2C(_MODULE) isn't defined
2012-12-10 19:41 ` [PATCH RFC 01/13] i2c: add dummy inline functions for when CONFIG_OF_I2C(_MODULE) isn't defined Sylwester Nawrocki
@ 2012-12-11 8:39 ` Grant Likely
0 siblings, 0 replies; 25+ messages in thread
From: Grant Likely @ 2012-12-11 8:39 UTC (permalink / raw)
To: Sylwester Nawrocki, g.liakhovetski, linux-media
Cc: rob.herring, thomas.abraham, t.figa, sw0312.kim, kyungmin.park,
devicetree-discuss, linux-kernel
On Mon, 10 Dec 2012 20:41:27 +0100, Sylwester Nawrocki <s.nawrocki@samsung.com> wrote:
> From: Guennadi Liakhovetski <g.liakhovetski@gmx.de>
>
> If CONFIG_OF_I2C and CONFIG_OF_I2C_MODULE are undefined no declaration of
> of_find_i2c_device_by_node and of_find_i2c_adapter_by_node will be
> available. Add dummy inline functions to avoid compilation breakage.
>
> Signed-off-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de>
Applied, thanks.
g.
^ permalink raw reply [flat|nested] 25+ messages in thread
* [PATCH RFC 02/13] of: add a dummy inline function for when CONFIG_OF is not defined
[not found] ` <1355168499-5847-1-git-send-email-s.nawrocki-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org>
2012-12-10 19:41 ` [PATCH RFC 01/13] i2c: add dummy inline functions for when CONFIG_OF_I2C(_MODULE) isn't defined Sylwester Nawrocki
@ 2012-12-10 19:41 ` Sylwester Nawrocki
2012-12-11 8:42 ` Grant Likely
2012-12-10 19:41 ` [PATCH RFC 05/13] of: Add empty for_each_available_child_of_node() macro definition Sylwester Nawrocki
2 siblings, 1 reply; 25+ messages in thread
From: Sylwester Nawrocki @ 2012-12-10 19:41 UTC (permalink / raw)
To: g.liakhovetski-Mmb7MZpHnFY, linux-media-u79uwXL29TY76Z2rM5mHXA
Cc: sw0312.kim-Sze3O3UU22JBDgjK7y7TUQ,
linux-kernel-u79uwXL29TY76Z2rM5mHXA,
rob.herring-bsGFqQB8/DxBDgjK7y7TUQ,
kyungmin.park-Sze3O3UU22JBDgjK7y7TUQ,
devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ
From: Guennadi Liakhovetski <g.liakhovetski-Mmb7MZpHnFY@public.gmane.org>
If CONFIG_OF isn't defined, no declaration of of_get_parent will be found
and compilation can fail. This patch adds a dummy inline function
definition to fix the problem.
Signed-off-by: Guennadi Liakhovetski <g.liakhovetski-Mmb7MZpHnFY@public.gmane.org>
---
include/linux/of.h | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/include/linux/of.h b/include/linux/of.h
index b4e50d5..9ba8cf1 100644
--- a/include/linux/of.h
+++ b/include/linux/of.h
@@ -427,6 +427,11 @@ static inline int of_parse_phandle_with_args(struct device_node *np,
return -ENOSYS;
}
+static inline struct device_node *of_get_parent(const struct device_node *np)
+{
+ return NULL;
+}
+
static inline int of_alias_get_id(struct device_node *np, const char *stem)
{
return -ENOSYS;
--
1.7.9.5
^ permalink raw reply related [flat|nested] 25+ messages in thread
* Re: [PATCH RFC 02/13] of: add a dummy inline function for when CONFIG_OF is not defined
2012-12-10 19:41 ` [PATCH RFC 02/13] of: add a dummy inline function for when CONFIG_OF is not defined Sylwester Nawrocki
@ 2012-12-11 8:42 ` Grant Likely
0 siblings, 0 replies; 25+ messages in thread
From: Grant Likely @ 2012-12-11 8:42 UTC (permalink / raw)
To: Sylwester Nawrocki, g.liakhovetski, linux-media
Cc: rob.herring, thomas.abraham, t.figa, sw0312.kim, kyungmin.park,
devicetree-discuss, linux-kernel
On Mon, 10 Dec 2012 20:41:28 +0100, Sylwester Nawrocki <s.nawrocki@samsung.com> wrote:
> From: Guennadi Liakhovetski <g.liakhovetski@gmx.de>
>
> If CONFIG_OF isn't defined, no declaration of of_get_parent will be found
> and compilation can fail. This patch adds a dummy inline function
> definition to fix the problem.
Where is this function getting called when CONFIG_OF is not defined? I
suspect that any code calling of_get_parent() should be CONFIG_OF
specific code and configured out when CONFIG_OF=n, but let me know if
I'm missing something.
g.
^ permalink raw reply [flat|nested] 25+ messages in thread
* [PATCH RFC 05/13] of: Add empty for_each_available_child_of_node() macro definition
[not found] ` <1355168499-5847-1-git-send-email-s.nawrocki-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org>
2012-12-10 19:41 ` [PATCH RFC 01/13] i2c: add dummy inline functions for when CONFIG_OF_I2C(_MODULE) isn't defined Sylwester Nawrocki
2012-12-10 19:41 ` [PATCH RFC 02/13] of: add a dummy inline function for when CONFIG_OF is not defined Sylwester Nawrocki
@ 2012-12-10 19:41 ` Sylwester Nawrocki
[not found] ` <1355168499-5847-6-git-send-email-s.nawrocki-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org>
2 siblings, 1 reply; 25+ messages in thread
From: Sylwester Nawrocki @ 2012-12-10 19:41 UTC (permalink / raw)
To: g.liakhovetski-Mmb7MZpHnFY, linux-media-u79uwXL29TY76Z2rM5mHXA
Cc: sw0312.kim-Sze3O3UU22JBDgjK7y7TUQ,
linux-kernel-u79uwXL29TY76Z2rM5mHXA,
rob.herring-bsGFqQB8/DxBDgjK7y7TUQ,
kyungmin.park-Sze3O3UU22JBDgjK7y7TUQ, Sylwester Nawrocki,
devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ
Add this empty macro definition so users can be compiled without
excluding this macro call with preprocessor directives when CONFIG_OF
is disabled.
Signed-off-by: Sylwester Nawrocki <s.nawrocki-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org>
Signed-off-by: Kyungmin Park <kyungmin.park-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org>
---
include/linux/of.h | 3 +++
1 file changed, 3 insertions(+)
diff --git a/include/linux/of.h b/include/linux/of.h
index 2fb0dbe..7df42cc 100644
--- a/include/linux/of.h
+++ b/include/linux/of.h
@@ -332,6 +332,9 @@ static inline bool of_have_populated_dt(void)
#define for_each_child_of_node(parent, child) \
while (0)
+#define for_each_available_child_of_node(parent, child) \
+ while (0)
+
static inline struct device_node *of_get_child_by_name(
const struct device_node *node,
const char *name)
--
1.7.9.5
^ permalink raw reply related [flat|nested] 25+ messages in thread
* [PATCH RFC 06/13] of: Add empty of_find_device_by_node() function definition
2012-12-10 19:41 [PATCH RFC 00/13] Common video input interfaces bindings and V4L2 OF helpers Sylwester Nawrocki
` (2 preceding siblings ...)
[not found] ` <1355168499-5847-1-git-send-email-s.nawrocki-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org>
@ 2012-12-10 19:41 ` Sylwester Nawrocki
2012-12-11 8:59 ` Grant Likely
2012-12-10 19:41 ` [PATCH RFC 07/13] of: Add empty of_get_next_child() " Sylwester Nawrocki
` (6 subsequent siblings)
10 siblings, 1 reply; 25+ messages in thread
From: Sylwester Nawrocki @ 2012-12-10 19:41 UTC (permalink / raw)
To: g.liakhovetski, linux-media
Cc: grant.likely, rob.herring, thomas.abraham, t.figa, sw0312.kim,
kyungmin.park, devicetree-discuss, linux-kernel,
Sylwester Nawrocki
This allows users to be compiled without excluding this function
call with preprocessor directives when CONFIG_OF_DEVICE is disabled.
Signed-off-by: Sylwester Nawrocki <s.nawrocki@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
---
include/linux/of_platform.h | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/include/linux/of_platform.h b/include/linux/of_platform.h
index b47d204..d8f587f 100644
--- a/include/linux/of_platform.h
+++ b/include/linux/of_platform.h
@@ -96,6 +96,13 @@ extern int of_platform_populate(struct device_node *root,
struct device *parent);
#endif /* CONFIG_OF_ADDRESS */
+#else /* CONFIG_OF_DEVICE */
+static inline struct platform_device *of_find_device_by_node(
+ struct device_node *np)
+{
+ return NULL;
+}
+
#endif /* CONFIG_OF_DEVICE */
#if !defined(CONFIG_OF_ADDRESS)
--
1.7.9.5
^ permalink raw reply related [flat|nested] 25+ messages in thread
* Re: [PATCH RFC 06/13] of: Add empty of_find_device_by_node() function definition
2012-12-10 19:41 ` [PATCH RFC 06/13] of: Add empty of_find_device_by_node() function definition Sylwester Nawrocki
@ 2012-12-11 8:59 ` Grant Likely
0 siblings, 0 replies; 25+ messages in thread
From: Grant Likely @ 2012-12-11 8:59 UTC (permalink / raw)
To: g.liakhovetski, linux-media
Cc: rob.herring, thomas.abraham, t.figa, sw0312.kim, kyungmin.park,
devicetree-discuss, linux-kernel, Sylwester Nawrocki
On Mon, 10 Dec 2012 20:41:32 +0100, Sylwester Nawrocki <s.nawrocki@samsung.com> wrote:
> This allows users to be compiled without excluding this function
> call with preprocessor directives when CONFIG_OF_DEVICE is disabled.
>
> Signed-off-by: Sylwester Nawrocki <s.nawrocki@samsung.com>
> Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
Same question here... Okay, I'll stop replying to these now. :-) When
you repost, for each one of these please tell me why the empty version
is needed. ie. what is the non-OF code block that is simpler if it
doesn't have to worry about CONFIG_OF?
g.
> ---
> include/linux/of_platform.h | 7 +++++++
> 1 file changed, 7 insertions(+)
>
> diff --git a/include/linux/of_platform.h b/include/linux/of_platform.h
> index b47d204..d8f587f 100644
> --- a/include/linux/of_platform.h
> +++ b/include/linux/of_platform.h
> @@ -96,6 +96,13 @@ extern int of_platform_populate(struct device_node *root,
> struct device *parent);
> #endif /* CONFIG_OF_ADDRESS */
>
> +#else /* CONFIG_OF_DEVICE */
> +static inline struct platform_device *of_find_device_by_node(
> + struct device_node *np)
> +{
> + return NULL;
> +}
> +
> #endif /* CONFIG_OF_DEVICE */
>
> #if !defined(CONFIG_OF_ADDRESS)
> --
> 1.7.9.5
>
--
Grant Likely, B.Sc, P.Eng.
Secret Lab Technologies, Ltd.
^ permalink raw reply [flat|nested] 25+ messages in thread
* [PATCH RFC 07/13] of: Add empty of_get_next_child() function definition
2012-12-10 19:41 [PATCH RFC 00/13] Common video input interfaces bindings and V4L2 OF helpers Sylwester Nawrocki
` (3 preceding siblings ...)
2012-12-10 19:41 ` [PATCH RFC 06/13] of: Add empty of_find_device_by_node() function definition Sylwester Nawrocki
@ 2012-12-10 19:41 ` Sylwester Nawrocki
2012-12-10 19:41 ` [PATCH RFC 08/13] media: add V4L2 DT binding documentation Sylwester Nawrocki
` (5 subsequent siblings)
10 siblings, 0 replies; 25+ messages in thread
From: Sylwester Nawrocki @ 2012-12-10 19:41 UTC (permalink / raw)
To: g.liakhovetski, linux-media
Cc: grant.likely, rob.herring, thomas.abraham, t.figa, sw0312.kim,
kyungmin.park, devicetree-discuss, linux-kernel,
Sylwester Nawrocki
Add an empty of_get_next_child() function definition so users can
be build when CONFIG_OF is disabled and are not required to exclude
OF specific parts explicitly with #ifdefs.
Signed-off-by: Sylwester Nawrocki <s.nawrocki@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
---
include/linux/of.h | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/include/linux/of.h b/include/linux/of.h
index 7df42cc..fb92acc 100644
--- a/include/linux/of.h
+++ b/include/linux/of.h
@@ -335,6 +335,13 @@ static inline bool of_have_populated_dt(void)
#define for_each_available_child_of_node(parent, child) \
while (0)
+static inline struct device_node *of_get_next_child(
+ const struct device_node *node,
+ struct device_node *prev)
+{
+ return NULL;
+}
+
static inline struct device_node *of_get_child_by_name(
const struct device_node *node,
const char *name)
--
1.7.9.5
^ permalink raw reply related [flat|nested] 25+ messages in thread
* [PATCH RFC 08/13] media: add V4L2 DT binding documentation
2012-12-10 19:41 [PATCH RFC 00/13] Common video input interfaces bindings and V4L2 OF helpers Sylwester Nawrocki
` (4 preceding siblings ...)
2012-12-10 19:41 ` [PATCH RFC 07/13] of: Add empty of_get_next_child() " Sylwester Nawrocki
@ 2012-12-10 19:41 ` Sylwester Nawrocki
2012-12-15 21:13 ` [PATCH] [media] Add common binding documentation for video interfaces Sylwester Nawrocki
2012-12-10 19:41 ` [PATCH RFC 09/13] media: add a V4L2 OF parser Sylwester Nawrocki
` (4 subsequent siblings)
10 siblings, 1 reply; 25+ messages in thread
From: Sylwester Nawrocki @ 2012-12-10 19:41 UTC (permalink / raw)
To: g.liakhovetski, linux-media
Cc: grant.likely, rob.herring, thomas.abraham, t.figa, sw0312.kim,
kyungmin.park, devicetree-discuss, linux-kernel
From: Guennadi Liakhovetski <g.liakhovetski@gmx.de>
This patch adds a document, describing common V4L2 device tree bindings.
Co-authored-by: Sylwester Nawrocki <s.nawrocki@samsung.com>
Signed-off-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de>
---
Documentation/devicetree/bindings/media/v4l2.txt | 162 ++++++++++++++++++++++
1 file changed, 162 insertions(+)
create mode 100644 Documentation/devicetree/bindings/media/v4l2.txt
diff --git a/Documentation/devicetree/bindings/media/v4l2.txt b/Documentation/devicetree/bindings/media/v4l2.txt
new file mode 100644
index 0000000..b8b3f41
--- /dev/null
+++ b/Documentation/devicetree/bindings/media/v4l2.txt
@@ -0,0 +1,162 @@
+Video4Linux Version 2 (V4L2)
+
+General concept
+---------------
+
+Video pipelines consist of external devices, e.g. camera sensors, controlled
+over an I2C, SPI or UART bus, and SoC internal IP blocks, including video DMA
+engines and video data processors.
+
+SoC internal blocks are described by DT nodes, placed similarly to other SoC
+blocks. External devices are represented as child nodes of their respective bus
+controller nodes, e.g. I2C.
+
+Data interfaces on all video devices are described by "port" child DT nodes.
+Configuration of a port depends on other devices participating in the data
+transfer and is described by "link" DT nodes, specified as children of the
+"port" nodes:
+
+/foo {
+ port@0 {
+ link@0 { ... };
+ link@1 { ... };
+ };
+ port@1 { ... };
+};
+
+If a port can be configured to work with more than one other device on the same
+bus, a "link" child DT node must be provided for each of them. If more than one
+port is present on a device or more than one link is connected to a port, a
+common scheme, using "#address-cells," "#size-cells" and "reg" properties is
+used.
+
+Optional link properties:
+- remote: phandle to the other endpoint link DT node.
+- slave-mode: a boolean property, run the link in slave mode. Default is master
+ mode.
+- data-shift: on parallel data busses, if data-width is used to specify the
+ number of data lines, data-shift can be used to specify which data lines are
+ used, e.g. "data-width=<10>; data-shift=<2>;" means, that lines 9:2 are used.
+- hsync-active: 1 or 0 for active-high or -low HSYNC signal polarity
+ respectively.
+- vsync-active: ditto for VSYNC. Note, that if HSYNC and VSYNC polarities are
+ not specified, embedded synchronisation may be required, where supported.
+- data-active: similar to HSYNC and VSYNC specifies data line polarity.
+- field-even-active: field signal level during the even field data transmission.
+- pclk-sample: rising (1) or falling (0) edge to sample the pixel clock pin.
+- data-lanes: array of serial, e.g. MIPI CSI-2, data hardware lane numbers in
+ the ascending order, beginning with logical lane 0.
+- clock-lanes: hardware lane number, used for the clock lane.
+- clock-noncontinuous: a boolean property to allow MIPI CSI-2 non-continuous
+ clock mode.
+
+Example:
+
+ ceu0: ceu@0xfe910000 {
+ compatible = "renesas,sh-mobile-ceu";
+ reg = <0xfe910000 0xa0>;
+ interrupts = <0x880>;
+
+ mclk: master_clock {
+ compatible = "renesas,ceu-clock";
+ #clock-cells = <1>;
+ clock-frequency = <50000000>; /* max clock frequency */
+ clock-output-names = "mclk";
+ };
+
+ port {
+ #address-cells = <1>;
+ #size-cells = <0>;
+
+ ceu0_1: link@1 {
+ reg = <1>; /* local link # */
+ remote = <&ov772x_1_1>; /* remote phandle */
+ bus-width = <8>; /* used data lines */
+ data-shift = <0>; /* lines 7:0 are used */
+
+ /* If [hv]sync-active are missing, embedded bt.605 sync is used */
+ hsync-active = <1>; /* active high */
+ vsync-active = <1>; /* active high */
+ data-active = <1>; /* active high */
+ pclk-sample = <1>; /* rising */
+ };
+
+ ceu0_0: link@0 {
+ reg = <0>;
+ remote = <&csi2_2>;
+ immutable;
+ };
+ };
+ };
+
+ i2c0: i2c@0xfff20000 {
+ ...
+ ov772x_1: camera@0x21 {
+ compatible = "omnivision,ov772x";
+ reg = <0x21>;
+ vddio-supply = <®ulator1>;
+ vddcore-supply = <®ulator2>;
+
+ clock-frequency = <20000000>;
+ clocks = <&mclk 0>;
+ clock-names = "xclk";
+
+ port {
+ /* With 1 link per port no need in addresses */
+ ov772x_1_1: link {
+ bus-width = <8>;
+ remote = <&ceu0_1>;
+ hsync-active = <1>;
+ vsync-active = <0>; /* who came up with an inverter here?... */
+ data-active = <1>;
+ pclk-sample = <1>;
+ };
+ };
+ };
+
+ imx074: camera@0x1a {
+ compatible = "sony,imx074";
+ reg = <0x1a>;
+ vddio-supply = <®ulator1>;
+ vddcore-supply = <®ulator2>;
+
+ clock-frequency = <30000000>; /* shared clock with ov772x_1 */
+ clocks = <&mclk 0>;
+ clock-names = "sysclk"; /* assuming this is the name in the datasheet */
+
+ port {
+ imx074_1: link {
+ clock-lanes = <0>;
+ data-lanes = <1>, <2>;
+ remote = <&csi2_1>;
+ };
+ };
+ };
+ };
+
+ csi2: csi2@0xffc90000 {
+ compatible = "renesas,sh-mobile-csi2";
+ reg = <0xffc90000 0x1000>;
+ interrupts = <0x17a0>;
+ #address-cells = <1>;
+ #size-cells = <0>;
+
+ port@1 {
+ compatible = "renesas,csi2c"; /* one of CSI2I and CSI2C */
+ reg = <1>; /* CSI-2 PHY #1 of 2: PHY_S, PHY_M has port address 0, is unused */
+
+ csi2_1: link {
+ clock-lanes = <0>;
+ data-lanes = <2>, <1>;
+ remote = <&imx074_1>;
+ };
+ };
+ port@2 {
+ reg = <2>; /* port 2: link to the CEU */
+
+ csi2_2: link {
+ immutable;
+ remote = <&ceu0_0>;
+ };
+ };
+ };
--
1.7.9.5
^ permalink raw reply related [flat|nested] 25+ messages in thread
* [PATCH] [media] Add common binding documentation for video interfaces
2012-12-10 19:41 ` [PATCH RFC 08/13] media: add V4L2 DT binding documentation Sylwester Nawrocki
@ 2012-12-15 21:13 ` Sylwester Nawrocki
2012-12-18 17:14 ` Stephen Warren
2012-12-31 21:55 ` Rob Herring
0 siblings, 2 replies; 25+ messages in thread
From: Sylwester Nawrocki @ 2012-12-15 21:13 UTC (permalink / raw)
To: g.liakhovetski, linux-media
Cc: swarren, grant.likely, rob.herring, nicolas.thery, s.hauer,
laurent.pinchart, hverkuil, devicetree-discuss, linux-doc,
Sylwester Nawrocki
From: Guennadi Liakhovetski <g.liakhovetski@gmx.de>
This patch adds a document describing common OF bindings for video
capture, output and video processing devices. It is currently mainly
focused on video capture devices, with data interfaces defined in
standards like ITU-R BT.656 or MIPI CSI-2.
It also documents a method of describing data links between devices.
Signed-off-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de>
Signed-off-by: Sylwester Nawrocki <s.nawrocki@samsung.com>
---
Hi,
This is an updated version of patch [1]. My changes include resolving
issues pointed out during review, i.e.:
- renaming 'link' node to 'endpoint,
- renaming 'remote' phandle to 'remote-endpoint',
- file v4l2.txt renamed to video-interfaces.txt,
- removed references to V4L2,
- added short description of the example DT snippet
and additionally:
- added "Required properties' paragraph,
- updated description of 'data-lanes' property,
- renamed all erroneous occurrences of 'data-width' to 'bus-width',
- added 'bus-width' property description,
- modified description of hsync-active, vsync-active properties,
- added a little paragraph further explaining that each endpoint
node has properties determining configuration of its corresponding
device.
[1] https://patchwork.kernel.org/patch/1514381/
I'm still unsure about the first sentence, as these bindings can be
used for describing SoC internal connections between modules as well.
I was considering adding something like:
"This document describes common bindings for video capture, processing
and output devices using data buses defined in standards like ITU-R
BT.656, MIPI CSI-2,..."
before the "General concept" paragraph.
And maybe Documentation/devicetree/bindings/video/ would a better place
for this video-interfaces.txt file ?
Thanks,
Sylwester
---
.../devicetree/bindings/media/video-interfaces.txt | 198 ++++++++++++++++++++
1 files changed, 198 insertions(+), 0 deletions(-)
create mode 100644 Documentation/devicetree/bindings/media/video-interfaces.txt
diff --git a/Documentation/devicetree/bindings/media/video-interfaces.txt b/Documentation/devicetree/bindings/media/video-interfaces.txt
new file mode 100644
index 0000000..10ebbc4
--- /dev/null
+++ b/Documentation/devicetree/bindings/media/video-interfaces.txt
@@ -0,0 +1,198 @@
+Common bindings for video data receiver and transmitter interfaces
+
+General concept
+---------------
+
+Video data pipelines usually consist of external devices, e.g. camera sensors,
+controlled over an I2C, SPI or UART bus, and SoC internal IP blocks, including
+video DMA engines and video data processors.
+
+SoC internal blocks are described by DT nodes, placed similarly to other SoC
+blocks. External devices are represented as child nodes of their respective
+bus controller nodes, e.g. I2C.
+
+Data interfaces on all video devices are described by their child 'port' nodes.
+Configuration of a port depends on other devices participating in the data
+transfer and is described by 'endpoint' subnodes.
+
+dev {
+ #address-cells = <1>;
+ #size-cells = <0>;
+ port@0 {
+ endpoint@0 { ... };
+ endpoint@1 { ... };
+ };
+ port@1 { ... };
+};
+
+If a port can be configured to work with more than one other device on the same
+bus, an 'endpoint' child node must be provided for each of them. If more than
+one port is present in a device node or there is more than one endpoint at a
+port, a common scheme, using '#address-cells', '#size-cells' and 'reg' properties
+is used.
+
+Two 'endpoint' nodes are linked with each other through their 'remote-endpoint'
+phandles. An endpoint subnode of a device contains all properties needed for
+configuration of this device for data exchange with the other device. In most
+cases properties at the peer 'endpoint' nodes will be identical, however
+they might need to be different when there are any signal modifications on the
+bus between two devices, e.g. there are logic signal inverters on the lines.
+
+Required properties
+-------------------
+
+If there is more that one 'port' or more than one 'endpoint' node following
+properties are required in relevant parent node:
+
+- #address-cells : number of cells required to define port number, should be 1.
+- #size-cells : should be zero.
+
+Optional endpoint properties
+----------------------------
+
+- remote-endpoint : phandle to an 'endpoint' subnode of the other device node.
+- slave-mode : a boolean property, run the link in slave mode. Default is master
+ mode.
+- bus-width : the number of data lines, valid for parallel buses.
+- data-shift: on parallel data busses, if bus-width is used to specify the
+ number of data lines, data-shift can be used to specify which data lines are
+ used, e.g. "bus-width=<10>; data-shift=<2>;" means, that lines 9:2 are used.
+- hsync-active : active state of HSYNC signal, 0/1 for LOW/HIGH respectively.
+- vsync-active : active state of VSYNC signal, 0/1 for LOW/HIGH respectively.
+ Note, that if HSYNC and VSYNC polarities are not specified, embedded
+ synchronization may be required, where supported.
+- data-active : similar to HSYNC and VSYNC, specifies data line polarity.
+- field-even-active: field signal level during the even field data transmission.
+- pclk-sample : rising (1) or falling (0) edge to sample the pixel clock signal.
+- data-lanes : an array of physical data lane indexes. Position of an entry
+ determines logical lane number, while the value of an entry indicates physical
+ lane, e.g. for 2-lane MIPI CSI-2 bus we could have "data-lanes = <1>, <2>;",
+ assuming the clock lane is on hardware lane 0. This property is valid for
+ serial buses only (e.g. MIPI CSI-2).
+- clock-lanes : a number of physical lane used as a clock lane.
+- clock-noncontinuous : a boolean property to allow MIPI CSI-2 non-continuous
+ clock mode.
+
+Example
+-------
+
+The below example snippet describes two data pipelines. ov772x and imx074 are
+camera sensors with parallel and serial (MIPI CSI-2) video bus respectively.
+Both sensors are on I2C control bus corresponding to i2c0 controller node.
+ov772x sensor is linked directly to the ceu0 video host interface. imx074 is
+linked to ceu0 through MIPI CSI-2 receiver (csi2). ceu0 has a (single) DMA
+engine writing captured data to memory. ceu0 node has single 'port' node which
+indicates at any time only one of following data pipeline can be active:
+ov772x -> ceu0 or imx074 -> csi2 -> ceu0.
+
+ ceu0: ceu@0xfe910000 {
+ compatible = "renesas,sh-mobile-ceu";
+ reg = <0xfe910000 0xa0>;
+ interrupts = <0x880>;
+
+ mclk: master_clock {
+ compatible = "renesas,ceu-clock";
+ #clock-cells = <1>;
+ clock-frequency = <50000000>; /* Max clock frequency */
+ clock-output-names = "mclk";
+ };
+
+ port {
+ #address-cells = <1>;
+ #size-cells = <0>;
+
+ ceu0_1: endpoint@1 {
+ reg = <1>; /* Local endpoint # */
+ remote = <&ov772x_1_1>; /* Remote phandle */
+ bus-width = <8>; /* Used data lines */
+ data-shift = <0>; /* Lines 7:0 are used */
+
+ /* If hsync-active/vsync-active are missing,
+ embedded bt.605 sync is used */
+ hsync-active = <1>; /* Active high */
+ vsync-active = <1>; /* Active high */
+ data-active = <1>; /* Active high */
+ pclk-sample = <1>; /* Rising */
+ };
+
+ ceu0_0: endpoint@0 {
+ reg = <0>;
+ remote = <&csi2_2>;
+ immutable;
+ };
+ };
+ };
+
+ i2c0: i2c@0xfff20000 {
+ ...
+ ov772x_1: camera@0x21 {
+ compatible = "omnivision,ov772x";
+ reg = <0x21>;
+ vddio-supply = <®ulator1>;
+ vddcore-supply = <®ulator2>;
+
+ clock-frequency = <20000000>;
+ clocks = <&mclk 0>;
+ clock-names = "xclk";
+
+ port {
+ /* With 1 endpoint per port no need in addresses. */
+ ov772x_1_1: endpoint {
+ bus-width = <8>;
+ remote-endpoint = <&ceu0_1>;
+ hsync-active = <1>;
+ vsync-active = <0>; /* Who came up with an
+ inverter here ?... */
+ data-active = <1>;
+ pclk-sample = <1>;
+ };
+ };
+ };
+
+ imx074: camera@0x1a {
+ compatible = "sony,imx074";
+ reg = <0x1a>;
+ vddio-supply = <®ulator1>;
+ vddcore-supply = <®ulator2>;
+
+ clock-frequency = <30000000>; /* Shared clock with ov772x_1 */
+ clocks = <&mclk 0>;
+ clock-names = "sysclk"; /* Assuming this is the
+ name in the datasheet */
+ port {
+ imx074_1: endpoint {
+ clock-lanes = <0>;
+ data-lanes = <1>, <2>;
+ remote-endpoint = <&csi2_1>;
+ };
+ };
+ };
+ };
+
+ csi2: csi2@0xffc90000 {
+ compatible = "renesas,sh-mobile-csi2";
+ reg = <0xffc90000 0x1000>;
+ interrupts = <0x17a0>;
+ #address-cells = <1>;
+ #size-cells = <0>;
+
+ port@1 {
+ compatible = "renesas,csi2c"; /* One of CSI2I and CSI2C. */
+ reg = <1>; /* CSI-2 PHY #1 of 2: PHY_S,
+ PHY_M has port address 0,
+ is unused. */
+ csi2_1: endpoint {
+ clock-lanes = <0>;
+ data-lanes = <2>, <1>;
+ remote-endpoint = <&imx074_1>;
+ };
+ };
+ port@2 {
+ reg = <2>; /* port 2: link to the CEU */
+
+ csi2_2: endpoint {
+ immutable;
+ remote-endpoint = <&ceu0_0>;
+ };
+ };
+ };
--
1.7.4.1
^ permalink raw reply related [flat|nested] 25+ messages in thread
* Re: [PATCH] [media] Add common binding documentation for video interfaces
2012-12-15 21:13 ` [PATCH] [media] Add common binding documentation for video interfaces Sylwester Nawrocki
@ 2012-12-18 17:14 ` Stephen Warren
[not found] ` <50D0A475.7010800-3lzwWm7+Weoh9ZMKESR00Q@public.gmane.org>
2012-12-31 21:55 ` Rob Herring
1 sibling, 1 reply; 25+ messages in thread
From: Stephen Warren @ 2012-12-18 17:14 UTC (permalink / raw)
To: Sylwester Nawrocki
Cc: g.liakhovetski, linux-media, grant.likely, rob.herring,
nicolas.thery, s.hauer, laurent.pinchart, hverkuil,
devicetree-discuss, linux-doc, Sylwester Nawrocki
On 12/15/2012 02:13 PM, Sylwester Nawrocki wrote:
> From: Guennadi Liakhovetski <g.liakhovetski@gmx.de>
>
> This patch adds a document describing common OF bindings for video
> capture, output and video processing devices. It is currently mainly
> focused on video capture devices, with data interfaces defined in
> standards like ITU-R BT.656 or MIPI CSI-2.
> It also documents a method of describing data links between devices.
(quickly/briefly)
Reviewed-by: Stephen Warren <swarren@nvidia.com>
^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: [PATCH] [media] Add common binding documentation for video interfaces
2012-12-15 21:13 ` [PATCH] [media] Add common binding documentation for video interfaces Sylwester Nawrocki
2012-12-18 17:14 ` Stephen Warren
@ 2012-12-31 21:55 ` Rob Herring
1 sibling, 0 replies; 25+ messages in thread
From: Rob Herring @ 2012-12-31 21:55 UTC (permalink / raw)
To: Sylwester Nawrocki
Cc: g.liakhovetski, linux-media, hverkuil, s.hauer, linux-doc,
nicolas.thery, rob.herring, laurent.pinchart, Sylwester Nawrocki,
devicetree-discuss
On 12/15/2012 03:13 PM, Sylwester Nawrocki wrote:
> From: Guennadi Liakhovetski <g.liakhovetski@gmx.de>
>
> This patch adds a document describing common OF bindings for video
> capture, output and video processing devices. It is currently mainly
> focused on video capture devices, with data interfaces defined in
> standards like ITU-R BT.656 or MIPI CSI-2.
> It also documents a method of describing data links between devices.
>
> Signed-off-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de>
> Signed-off-by: Sylwester Nawrocki <s.nawrocki@samsung.com>
Looks reasonable. You can merge this with the rest of the series.
Acked-by: Rob Herring <rob.herring@calxeda.com>
> ---
> Hi,
>
> This is an updated version of patch [1]. My changes include resolving
> issues pointed out during review, i.e.:
> - renaming 'link' node to 'endpoint,
> - renaming 'remote' phandle to 'remote-endpoint',
> - file v4l2.txt renamed to video-interfaces.txt,
> - removed references to V4L2,
> - added short description of the example DT snippet
>
> and additionally:
> - added "Required properties' paragraph,
> - updated description of 'data-lanes' property,
> - renamed all erroneous occurrences of 'data-width' to 'bus-width',
> - added 'bus-width' property description,
> - modified description of hsync-active, vsync-active properties,
> - added a little paragraph further explaining that each endpoint
> node has properties determining configuration of its corresponding
> device.
>
> [1] https://patchwork.kernel.org/patch/1514381/
>
> I'm still unsure about the first sentence, as these bindings can be
> used for describing SoC internal connections between modules as well.
>
> I was considering adding something like:
>
> "This document describes common bindings for video capture, processing
> and output devices using data buses defined in standards like ITU-R
> BT.656, MIPI CSI-2,..."
>
> before the "General concept" paragraph.
>
> And maybe Documentation/devicetree/bindings/video/ would a better place
> for this video-interfaces.txt file ?
>
> Thanks,
> Sylwester
> ---
> .../devicetree/bindings/media/video-interfaces.txt | 198 ++++++++++++++++++++
> 1 files changed, 198 insertions(+), 0 deletions(-)
> create mode 100644 Documentation/devicetree/bindings/media/video-interfaces.txt
>
> diff --git a/Documentation/devicetree/bindings/media/video-interfaces.txt b/Documentation/devicetree/bindings/media/video-interfaces.txt
> new file mode 100644
> index 0000000..10ebbc4
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/media/video-interfaces.txt
> @@ -0,0 +1,198 @@
> +Common bindings for video data receiver and transmitter interfaces
> +
> +General concept
> +---------------
> +
> +Video data pipelines usually consist of external devices, e.g. camera sensors,
> +controlled over an I2C, SPI or UART bus, and SoC internal IP blocks, including
> +video DMA engines and video data processors.
> +
> +SoC internal blocks are described by DT nodes, placed similarly to other SoC
> +blocks. External devices are represented as child nodes of their respective
> +bus controller nodes, e.g. I2C.
> +
> +Data interfaces on all video devices are described by their child 'port' nodes.
> +Configuration of a port depends on other devices participating in the data
> +transfer and is described by 'endpoint' subnodes.
> +
> +dev {
> + #address-cells = <1>;
> + #size-cells = <0>;
> + port@0 {
> + endpoint@0 { ... };
> + endpoint@1 { ... };
> + };
> + port@1 { ... };
> +};
> +
> +If a port can be configured to work with more than one other device on the same
> +bus, an 'endpoint' child node must be provided for each of them. If more than
> +one port is present in a device node or there is more than one endpoint at a
> +port, a common scheme, using '#address-cells', '#size-cells' and 'reg' properties
> +is used.
> +
> +Two 'endpoint' nodes are linked with each other through their 'remote-endpoint'
> +phandles. An endpoint subnode of a device contains all properties needed for
> +configuration of this device for data exchange with the other device. In most
> +cases properties at the peer 'endpoint' nodes will be identical, however
> +they might need to be different when there are any signal modifications on the
> +bus between two devices, e.g. there are logic signal inverters on the lines.
> +
> +Required properties
> +-------------------
> +
> +If there is more that one 'port' or more than one 'endpoint' node following
> +properties are required in relevant parent node:
> +
> +- #address-cells : number of cells required to define port number, should be 1.
> +- #size-cells : should be zero.
> +
> +Optional endpoint properties
> +----------------------------
> +
> +- remote-endpoint : phandle to an 'endpoint' subnode of the other device node.
> +- slave-mode : a boolean property, run the link in slave mode. Default is master
> + mode.
> +- bus-width : the number of data lines, valid for parallel buses.
> +- data-shift: on parallel data busses, if bus-width is used to specify the
> + number of data lines, data-shift can be used to specify which data lines are
> + used, e.g. "bus-width=<10>; data-shift=<2>;" means, that lines 9:2 are used.
> +- hsync-active : active state of HSYNC signal, 0/1 for LOW/HIGH respectively.
> +- vsync-active : active state of VSYNC signal, 0/1 for LOW/HIGH respectively.
> + Note, that if HSYNC and VSYNC polarities are not specified, embedded
> + synchronization may be required, where supported.
> +- data-active : similar to HSYNC and VSYNC, specifies data line polarity.
> +- field-even-active: field signal level during the even field data transmission.
> +- pclk-sample : rising (1) or falling (0) edge to sample the pixel clock signal.
> +- data-lanes : an array of physical data lane indexes. Position of an entry
> + determines logical lane number, while the value of an entry indicates physical
> + lane, e.g. for 2-lane MIPI CSI-2 bus we could have "data-lanes = <1>, <2>;",
> + assuming the clock lane is on hardware lane 0. This property is valid for
> + serial buses only (e.g. MIPI CSI-2).
> +- clock-lanes : a number of physical lane used as a clock lane.
> +- clock-noncontinuous : a boolean property to allow MIPI CSI-2 non-continuous
> + clock mode.
> +
> +Example
> +-------
> +
> +The below example snippet describes two data pipelines. ov772x and imx074 are
> +camera sensors with parallel and serial (MIPI CSI-2) video bus respectively.
> +Both sensors are on I2C control bus corresponding to i2c0 controller node.
> +ov772x sensor is linked directly to the ceu0 video host interface. imx074 is
> +linked to ceu0 through MIPI CSI-2 receiver (csi2). ceu0 has a (single) DMA
> +engine writing captured data to memory. ceu0 node has single 'port' node which
> +indicates at any time only one of following data pipeline can be active:
> +ov772x -> ceu0 or imx074 -> csi2 -> ceu0.
> +
> + ceu0: ceu@0xfe910000 {
> + compatible = "renesas,sh-mobile-ceu";
> + reg = <0xfe910000 0xa0>;
> + interrupts = <0x880>;
> +
> + mclk: master_clock {
> + compatible = "renesas,ceu-clock";
> + #clock-cells = <1>;
> + clock-frequency = <50000000>; /* Max clock frequency */
> + clock-output-names = "mclk";
> + };
> +
> + port {
> + #address-cells = <1>;
> + #size-cells = <0>;
> +
> + ceu0_1: endpoint@1 {
> + reg = <1>; /* Local endpoint # */
> + remote = <&ov772x_1_1>; /* Remote phandle */
> + bus-width = <8>; /* Used data lines */
> + data-shift = <0>; /* Lines 7:0 are used */
> +
> + /* If hsync-active/vsync-active are missing,
> + embedded bt.605 sync is used */
> + hsync-active = <1>; /* Active high */
> + vsync-active = <1>; /* Active high */
> + data-active = <1>; /* Active high */
> + pclk-sample = <1>; /* Rising */
> + };
> +
> + ceu0_0: endpoint@0 {
> + reg = <0>;
> + remote = <&csi2_2>;
> + immutable;
> + };
> + };
> + };
> +
> + i2c0: i2c@0xfff20000 {
> + ...
> + ov772x_1: camera@0x21 {
> + compatible = "omnivision,ov772x";
> + reg = <0x21>;
> + vddio-supply = <®ulator1>;
> + vddcore-supply = <®ulator2>;
> +
> + clock-frequency = <20000000>;
> + clocks = <&mclk 0>;
> + clock-names = "xclk";
> +
> + port {
> + /* With 1 endpoint per port no need in addresses. */
> + ov772x_1_1: endpoint {
> + bus-width = <8>;
> + remote-endpoint = <&ceu0_1>;
> + hsync-active = <1>;
> + vsync-active = <0>; /* Who came up with an
> + inverter here ?... */
> + data-active = <1>;
> + pclk-sample = <1>;
> + };
> + };
> + };
> +
> + imx074: camera@0x1a {
> + compatible = "sony,imx074";
> + reg = <0x1a>;
> + vddio-supply = <®ulator1>;
> + vddcore-supply = <®ulator2>;
> +
> + clock-frequency = <30000000>; /* Shared clock with ov772x_1 */
> + clocks = <&mclk 0>;
> + clock-names = "sysclk"; /* Assuming this is the
> + name in the datasheet */
> + port {
> + imx074_1: endpoint {
> + clock-lanes = <0>;
> + data-lanes = <1>, <2>;
> + remote-endpoint = <&csi2_1>;
> + };
> + };
> + };
> + };
> +
> + csi2: csi2@0xffc90000 {
> + compatible = "renesas,sh-mobile-csi2";
> + reg = <0xffc90000 0x1000>;
> + interrupts = <0x17a0>;
> + #address-cells = <1>;
> + #size-cells = <0>;
> +
> + port@1 {
> + compatible = "renesas,csi2c"; /* One of CSI2I and CSI2C. */
> + reg = <1>; /* CSI-2 PHY #1 of 2: PHY_S,
> + PHY_M has port address 0,
> + is unused. */
> + csi2_1: endpoint {
> + clock-lanes = <0>;
> + data-lanes = <2>, <1>;
> + remote-endpoint = <&imx074_1>;
> + };
> + };
> + port@2 {
> + reg = <2>; /* port 2: link to the CEU */
> +
> + csi2_2: endpoint {
> + immutable;
> + remote-endpoint = <&ceu0_0>;
> + };
> + };
> + };
> --
> 1.7.4.1
>
> _______________________________________________
> devicetree-discuss mailing list
> devicetree-discuss@lists.ozlabs.org
> https://lists.ozlabs.org/listinfo/devicetree-discuss
>
^ permalink raw reply [flat|nested] 25+ messages in thread
* [PATCH RFC 09/13] media: add a V4L2 OF parser
2012-12-10 19:41 [PATCH RFC 00/13] Common video input interfaces bindings and V4L2 OF helpers Sylwester Nawrocki
` (5 preceding siblings ...)
2012-12-10 19:41 ` [PATCH RFC 08/13] media: add V4L2 DT binding documentation Sylwester Nawrocki
@ 2012-12-10 19:41 ` Sylwester Nawrocki
2012-12-10 19:41 ` [PATCH RFC 10/13] v4l2-of: Support variable length of data-lanes property Sylwester Nawrocki
` (3 subsequent siblings)
10 siblings, 0 replies; 25+ messages in thread
From: Sylwester Nawrocki @ 2012-12-10 19:41 UTC (permalink / raw)
To: g.liakhovetski, linux-media
Cc: grant.likely, rob.herring, thomas.abraham, t.figa, sw0312.kim,
kyungmin.park, devicetree-discuss, linux-kernel
From: Guennadi Liakhovetski <g.liakhovetski@gmx.de>
Add a V4L2 OF parser, implementing bindings, documented in
Documentation/devicetree/bindings/media/v4l2.txt.
Signed-off-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de>
---
drivers/media/v4l2-core/Makefile | 3 +
drivers/media/v4l2-core/v4l2-of.c | 190 +++++++++++++++++++++++++++++++++++++
include/media/v4l2-of.h | 62 ++++++++++++
3 files changed, 255 insertions(+)
create mode 100644 drivers/media/v4l2-core/v4l2-of.c
create mode 100644 include/media/v4l2-of.h
diff --git a/drivers/media/v4l2-core/Makefile b/drivers/media/v4l2-core/Makefile
index c2d61d4..00f64d6 100644
--- a/drivers/media/v4l2-core/Makefile
+++ b/drivers/media/v4l2-core/Makefile
@@ -9,6 +9,9 @@ videodev-objs := v4l2-dev.o v4l2-ioctl.o v4l2-device.o v4l2-fh.o \
ifeq ($(CONFIG_COMPAT),y)
videodev-objs += v4l2-compat-ioctl32.o
endif
+ifeq ($(CONFIG_OF),y)
+ videodev-objs += v4l2-of.o
+endif
obj-$(CONFIG_VIDEO_DEV) += videodev.o v4l2-int-device.o
obj-$(CONFIG_VIDEO_V4L2) += v4l2-common.o
diff --git a/drivers/media/v4l2-core/v4l2-of.c b/drivers/media/v4l2-core/v4l2-of.c
new file mode 100644
index 0000000..f45d64b
--- /dev/null
+++ b/drivers/media/v4l2-core/v4l2-of.c
@@ -0,0 +1,190 @@
+/*
+ * V4L2 OF binding parsing library
+ *
+ * Copyright (C) 2012 Renesas Electronics Corp.
+ * Author: Guennadi Liakhovetski <g.liakhovetski@gmx.de>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of version 2 of the GNU General Public License as
+ * published by the Free Software Foundation.
+ */
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/of.h>
+#include <linux/types.h>
+
+#include <media/v4l2-of.h>
+
+/*
+ * All properties are optional. If none are found, we don't set any flags. This
+ * means, the port has a static configuration and no properties have to be
+ * specified explicitly.
+ * If any properties are found, that identify the bus as parallel, and
+ * slave-mode isn't set, we set V4L2_MBUS_MASTER. Similarly, if we recognise the
+ * bus as serial CSI-2 and clock-noncontinuous isn't set, we set the
+ * V4L2_MBUS_CSI2_CONTINUOUS_CLOCK flag.
+ * The caller should hold a reference to "node."
+ */
+void v4l2_of_parse_link(const struct device_node *node,
+ struct v4l2_of_link *link)
+{
+ const struct device_node *port_node = of_get_parent(node);
+ int size;
+ unsigned int v;
+ u32 data_lanes[ARRAY_SIZE(link->mipi_csi_2.data_lanes)];
+ bool data_lanes_present;
+
+ memset(link, 0, sizeof(*link));
+
+ link->local_node = node;
+
+ /* Doesn't matter, whether the below two calls succeed */
+ of_property_read_u32(port_node, "reg", &link->port);
+ of_property_read_u32(node, "reg", &link->addr);
+
+ if (!of_property_read_u32(node, "bus-width", &v))
+ link->parallel.bus_width = v;
+
+ if (!of_property_read_u32(node, "data-shift", &v))
+ link->parallel.data_shift = v;
+
+ if (!of_property_read_u32(node, "hsync-active", &v))
+ link->mbus_flags |= v ? V4L2_MBUS_HSYNC_ACTIVE_HIGH :
+ V4L2_MBUS_HSYNC_ACTIVE_LOW;
+
+ if (!of_property_read_u32(node, "vsync-active", &v))
+ link->mbus_flags |= v ? V4L2_MBUS_VSYNC_ACTIVE_HIGH :
+ V4L2_MBUS_VSYNC_ACTIVE_LOW;
+
+ if (!of_property_read_u32(node, "data-active", &v))
+ link->mbus_flags |= v ? V4L2_MBUS_DATA_ACTIVE_HIGH :
+ V4L2_MBUS_DATA_ACTIVE_LOW;
+
+ if (!of_property_read_u32(node, "pclk-sample", &v))
+ link->mbus_flags |= v ? V4L2_MBUS_PCLK_SAMPLE_RISING :
+ V4L2_MBUS_PCLK_SAMPLE_FALLING;
+
+ if (!of_property_read_u32(node, "field-even-active", &v))
+ link->mbus_flags |= v ? V4L2_MBUS_FIELD_EVEN_HIGH :
+ V4L2_MBUS_FIELD_EVEN_LOW;
+
+ if (of_get_property(node, "slave-mode", &size))
+ link->mbus_flags |= V4L2_MBUS_SLAVE;
+
+ /* If any parallel-bus properties have been found, skip serial ones */
+ if (link->parallel.bus_width || link->parallel.data_shift ||
+ link->mbus_flags) {
+ /* Default parallel bus-master */
+ if (!(link->mbus_flags & V4L2_MBUS_SLAVE))
+ link->mbus_flags |= V4L2_MBUS_MASTER;
+ return;
+ }
+
+ if (!of_property_read_u32(node, "clock-lanes", &v))
+ link->mipi_csi_2.clock_lane = v;
+
+ if (!of_property_read_u32_array(node, "data-lanes", data_lanes,
+ ARRAY_SIZE(data_lanes))) {
+ int i;
+ for (i = 0; i < ARRAY_SIZE(data_lanes); i++)
+ link->mipi_csi_2.data_lanes[i] = data_lanes[i];
+ data_lanes_present = true;
+ } else {
+ data_lanes_present = false;
+ }
+
+ if (of_get_property(node, "clock-noncontinuous", &size))
+ link->mbus_flags |= V4L2_MBUS_CSI2_NONCONTINUOUS_CLOCK;
+
+ if ((link->mipi_csi_2.clock_lane || data_lanes_present) &&
+ !(link->mbus_flags & V4L2_MBUS_CSI2_NONCONTINUOUS_CLOCK))
+ /* Default CSI-2: continuous clock */
+ link->mbus_flags |= V4L2_MBUS_CSI2_CONTINUOUS_CLOCK;
+}
+EXPORT_SYMBOL(v4l2_of_parse_link);
+
+/*
+ * Return a refcounted next "link" DT node. Contrary to the common OF practice,
+ * we do not drop the reference to previous, users have to do it themselves,
+ * when they're done with the node.
+ */
+struct device_node *v4l2_of_get_next_link(const struct device_node *parent,
+ struct device_node *previous)
+{
+ struct device_node *child, *port;
+
+ if (!parent)
+ return NULL;
+
+ if (!previous) {
+ /*
+ * If this is the first call, we have to find a port within this
+ * node
+ */
+ for_each_child_of_node(parent, port) {
+ if (!of_node_cmp(port->name, "port"))
+ break;
+ }
+ if (port) {
+ /* Found a port, get a link */
+ child = of_get_next_child(port, NULL);
+ of_node_put(port);
+ } else {
+ child = NULL;
+ }
+ if (!child)
+ pr_err("%s(): Invalid DT: %s has no link children!\n",
+ __func__, parent->name);
+ } else {
+ port = of_get_parent(previous);
+ if (!port)
+ /* Hm, has someone given us the root node?... */
+ return NULL;
+
+ /* Avoid dropping previous refcount to 0 */
+ of_node_get(previous);
+ child = of_get_next_child(port, previous);
+ if (child) {
+ of_node_put(port);
+ return child;
+ }
+
+ /* No more links under this port, try the next one */
+ do {
+ port = of_get_next_child(parent, port);
+ if (!port)
+ return NULL;
+ } while (of_node_cmp(port->name, "port"));
+
+ /* Pick up the first link on this port */
+ child = of_get_next_child(port, NULL);
+ of_node_put(port);
+ }
+
+ return child;
+}
+EXPORT_SYMBOL(v4l2_of_get_next_link);
+
+/* Return a refcounted DT node, owning the link, referenced by "remote" */
+struct device_node *v4l2_of_get_remote(const struct device_node *node)
+{
+ struct device_node *remote, *tmp;
+
+ /* Get remote link DT node */
+ remote = of_parse_phandle(node, "remote", 0);
+ if (!remote)
+ return NULL;
+
+ /* remote port */
+ tmp = of_get_parent(remote);
+ of_node_put(remote);
+ if (!tmp)
+ return NULL;
+
+ /* remote DT node */
+ remote = of_get_parent(tmp);
+ of_node_put(tmp);
+
+ return remote;
+}
+EXPORT_SYMBOL(v4l2_of_get_remote);
diff --git a/include/media/v4l2-of.h b/include/media/v4l2-of.h
new file mode 100644
index 0000000..6fafedb
--- /dev/null
+++ b/include/media/v4l2-of.h
@@ -0,0 +1,62 @@
+/*
+ * V4L2 OF binding parsing library
+ *
+ * Copyright (C) 2012 Renesas Electronics Corp.
+ * Author: Guennadi Liakhovetski <g.liakhovetski@gmx.de>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of version 2 of the GNU General Public License as
+ * published by the Free Software Foundation.
+ */
+#ifndef _V4L2_OF_H
+#define _V4L2_OF_H
+
+#include <linux/list.h>
+#include <linux/types.h>
+
+#include <media/v4l2-mediabus.h>
+
+struct device_node;
+
+struct v4l2_of_link {
+ unsigned int port;
+ unsigned int addr;
+ struct list_head head;
+ const struct device_node *local_node;
+ const __be32 *remote;
+ unsigned int mbus_flags;
+ union {
+ struct {
+ unsigned char bus_width;
+ unsigned char data_shift;
+ } parallel;
+ struct {
+ unsigned char data_lanes[4];
+ unsigned char clock_lane;
+ } mipi_csi_2;
+ };
+};
+
+#ifdef CONFIG_OF
+void v4l2_of_parse_link(const struct device_node *node,
+ struct v4l2_of_link *link);
+struct device_node *v4l2_of_get_next_link(const struct device_node *parent,
+ struct device_node *previous);
+struct device_node *v4l2_of_get_remote(const struct device_node *node);
+#else
+static inline void v4l2_of_parse_link(const struct device_node *node,
+ struct v4l2_of_link *link)
+{
+}
+static inline struct device_node *v4l2_of_get_next_link(const struct device_node *parent,
+ struct device_node *previous)
+{
+ return NULL;
+}
+static inline struct device_node *v4l2_of_get_remote(const struct device_node *node)
+{
+ return NULL;
+}
+#endif
+
+#endif
--
1.7.9.5
^ permalink raw reply related [flat|nested] 25+ messages in thread
* [PATCH RFC 10/13] v4l2-of: Support variable length of data-lanes property
2012-12-10 19:41 [PATCH RFC 00/13] Common video input interfaces bindings and V4L2 OF helpers Sylwester Nawrocki
` (6 preceding siblings ...)
2012-12-10 19:41 ` [PATCH RFC 09/13] media: add a V4L2 OF parser Sylwester Nawrocki
@ 2012-12-10 19:41 ` Sylwester Nawrocki
2012-12-10 19:41 ` [PATCH RFC 11/13] v4l2-of: Add v4l2_of_parse_data_lanes() function Sylwester Nawrocki
` (2 subsequent siblings)
10 siblings, 0 replies; 25+ messages in thread
From: Sylwester Nawrocki @ 2012-12-10 19:41 UTC (permalink / raw)
To: g.liakhovetski, linux-media
Cc: grant.likely, rob.herring, thomas.abraham, t.figa, sw0312.kim,
kyungmin.park, devicetree-discuss, linux-kernel,
Sylwester Nawrocki
Based on code from Guennadi Liakhovetski <g.liakhovetski@gmx.de>.
Add data_lanes property which relects the number of active data lanes,
that is length of the data-lanes array. Previously we assumed the
data-lanes array had fixed length which doesn't match the binding
semantics.
Signed-off-by: Sylwester Nawrocki <s.nawrocki@samsung.com>
---
drivers/media/v4l2-core/v4l2-of.c | 15 +++++++++++----
include/media/v4l2-of.h | 1 +
2 files changed, 12 insertions(+), 4 deletions(-)
diff --git a/drivers/media/v4l2-core/v4l2-of.c b/drivers/media/v4l2-core/v4l2-of.c
index f45d64b..4e6658c 100644
--- a/drivers/media/v4l2-core/v4l2-of.c
+++ b/drivers/media/v4l2-core/v4l2-of.c
@@ -33,6 +33,7 @@ void v4l2_of_parse_link(const struct device_node *node,
unsigned int v;
u32 data_lanes[ARRAY_SIZE(link->mipi_csi_2.data_lanes)];
bool data_lanes_present;
+ struct property *prop;
memset(link, 0, sizeof(*link));
@@ -83,10 +84,16 @@ void v4l2_of_parse_link(const struct device_node *node,
if (!of_property_read_u32(node, "clock-lanes", &v))
link->mipi_csi_2.clock_lane = v;
- if (!of_property_read_u32_array(node, "data-lanes", data_lanes,
- ARRAY_SIZE(data_lanes))) {
- int i;
- for (i = 0; i < ARRAY_SIZE(data_lanes); i++)
+ prop = of_find_property(node, "data-lanes", NULL);
+ if (prop) {
+ int i = 0;
+ const __be32 *lane = NULL;
+ do {
+ lane = of_prop_next_u32(prop, lane, &data_lanes[i]);
+ } while (lane && i++ < ARRAY_SIZE(data_lanes));
+
+ link->mipi_csi_2.num_data_lanes = i;
+ while (i--)
link->mipi_csi_2.data_lanes[i] = data_lanes[i];
data_lanes_present = true;
} else {
diff --git a/include/media/v4l2-of.h b/include/media/v4l2-of.h
index 6fafedb..ccb1ebe 100644
--- a/include/media/v4l2-of.h
+++ b/include/media/v4l2-of.h
@@ -33,6 +33,7 @@ struct v4l2_of_link {
struct {
unsigned char data_lanes[4];
unsigned char clock_lane;
+ unsigned short num_data_lanes;
} mipi_csi_2;
};
};
--
1.7.9.5
^ permalink raw reply related [flat|nested] 25+ messages in thread
* [PATCH RFC 11/13] v4l2-of: Add v4l2_of_parse_data_lanes() function
2012-12-10 19:41 [PATCH RFC 00/13] Common video input interfaces bindings and V4L2 OF helpers Sylwester Nawrocki
` (7 preceding siblings ...)
2012-12-10 19:41 ` [PATCH RFC 10/13] v4l2-of: Support variable length of data-lanes property Sylwester Nawrocki
@ 2012-12-10 19:41 ` Sylwester Nawrocki
2012-12-10 19:41 ` [PATCH RFC 12/13] v4l2-of: Corrected v4l2_of_parse_link() function declaration Sylwester Nawrocki
2012-12-10 19:41 ` [PATCH RFC 13/13] v4l2-of: Replace "remote" property with "remote-endpoint" Sylwester Nawrocki
10 siblings, 0 replies; 25+ messages in thread
From: Sylwester Nawrocki @ 2012-12-10 19:41 UTC (permalink / raw)
To: g.liakhovetski, linux-media
Cc: grant.likely, rob.herring, thomas.abraham, t.figa, sw0312.kim,
kyungmin.park, devicetree-discuss, linux-kernel,
Sylwester Nawrocki
Put the data-lanes property parsing code and make a separate function
out of it, so it can be used in drivers that don't need all features
packed in v4l2_of_parse_link().
Signed-off-by: Sylwester Nawrocki <s.nawrocki@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
---
drivers/media/v4l2-core/v4l2-of.c | 48 ++++++++++++++++++++++++-------------
include/media/v4l2-of.h | 28 ++++++++++++++++------
2 files changed, 52 insertions(+), 24 deletions(-)
diff --git a/drivers/media/v4l2-core/v4l2-of.c b/drivers/media/v4l2-core/v4l2-of.c
index 4e6658c..032ee67 100644
--- a/drivers/media/v4l2-core/v4l2-of.c
+++ b/drivers/media/v4l2-core/v4l2-of.c
@@ -15,6 +15,35 @@
#include <media/v4l2-of.h>
+
+/**
+ * v4l2_of_parse_data_lanes() - parse data-lanes property
+ * @node: a node containing data-lanes property [in]
+ * @mipi_csi2: data lanes configuration [out]
+ *
+ * Return: 0 on success or negative error value otherwise.
+ */
+int v4l2_of_parse_data_lanes(const struct device_node *node,
+ struct v4l2_of_mipi_csi2 *mipi_csi2)
+{
+ struct property *prop = of_find_property(node, "data-lanes", NULL);
+ u32 data_lanes[ARRAY_SIZE(mipi_csi2->data_lanes)];
+ const __be32 *lane = NULL;
+ int i = 0;
+
+ if (!prop)
+ return -EINVAL;
+
+ do {
+ lane = of_prop_next_u32(prop, lane, &data_lanes[i]);
+ } while (lane && i++ < ARRAY_SIZE(data_lanes));
+
+ mipi_csi2->num_data_lanes = i;
+ while (i--)
+ mipi_csi2->data_lanes[i] = data_lanes[i];
+ return 0;
+}
+
/*
* All properties are optional. If none are found, we don't set any flags. This
* means, the port has a static configuration and no properties have to be
@@ -29,11 +58,9 @@ void v4l2_of_parse_link(const struct device_node *node,
struct v4l2_of_link *link)
{
const struct device_node *port_node = of_get_parent(node);
+ bool data_lanes_present = false;
int size;
unsigned int v;
- u32 data_lanes[ARRAY_SIZE(link->mipi_csi_2.data_lanes)];
- bool data_lanes_present;
- struct property *prop;
memset(link, 0, sizeof(*link));
@@ -84,21 +111,8 @@ void v4l2_of_parse_link(const struct device_node *node,
if (!of_property_read_u32(node, "clock-lanes", &v))
link->mipi_csi_2.clock_lane = v;
- prop = of_find_property(node, "data-lanes", NULL);
- if (prop) {
- int i = 0;
- const __be32 *lane = NULL;
- do {
- lane = of_prop_next_u32(prop, lane, &data_lanes[i]);
- } while (lane && i++ < ARRAY_SIZE(data_lanes));
-
- link->mipi_csi_2.num_data_lanes = i;
- while (i--)
- link->mipi_csi_2.data_lanes[i] = data_lanes[i];
+ if (!v4l2_of_parse_data_lanes(node, &link->mipi_csi_2))
data_lanes_present = true;
- } else {
- data_lanes_present = false;
- }
if (of_get_property(node, "clock-noncontinuous", &size))
link->mbus_flags |= V4L2_MBUS_CSI2_NONCONTINUOUS_CLOCK;
diff --git a/include/media/v4l2-of.h b/include/media/v4l2-of.h
index ccb1ebe..9b036e6 100644
--- a/include/media/v4l2-of.h
+++ b/include/media/v4l2-of.h
@@ -13,11 +13,18 @@
#include <linux/list.h>
#include <linux/types.h>
+#include <linux/errno.h>
#include <media/v4l2-mediabus.h>
struct device_node;
+struct v4l2_of_mipi_csi2 {
+ unsigned char data_lanes[4];
+ unsigned char clock_lane;
+ unsigned short num_data_lanes;
+};
+
struct v4l2_of_link {
unsigned int port;
unsigned int addr;
@@ -30,17 +37,15 @@ struct v4l2_of_link {
unsigned char bus_width;
unsigned char data_shift;
} parallel;
- struct {
- unsigned char data_lanes[4];
- unsigned char clock_lane;
- unsigned short num_data_lanes;
- } mipi_csi_2;
+ struct v4l2_of_mipi_csi2 mipi_csi_2;
};
};
#ifdef CONFIG_OF
void v4l2_of_parse_link(const struct device_node *node,
struct v4l2_of_link *link);
+int v4l2_of_parse_data_lanes(const struct device_node *node,
+ struct v4l2_of_mipi_csi2 *mipi_csi2);
struct device_node *v4l2_of_get_next_link(const struct device_node *parent,
struct device_node *previous);
struct device_node *v4l2_of_get_remote(const struct device_node *node);
@@ -49,15 +54,24 @@ static inline void v4l2_of_parse_link(const struct device_node *node,
struct v4l2_of_link *link)
{
}
+
+static inline int v4l2_of_parse_data_lanes(const struct device_node *node,
+ struct v4l2_of_mipi_csi2 *mipi_csi2)
+{
+ return -ENOSYS;
+}
+
static inline struct device_node *v4l2_of_get_next_link(const struct device_node *parent,
struct device_node *previous)
{
return NULL;
}
+
static inline struct device_node *v4l2_of_get_remote(const struct device_node *node)
{
return NULL;
}
-#endif
-#endif
+#endif /* CONFIG_OF */
+
+#endif /* _V4L2_OF_H */
--
1.7.9.5
^ permalink raw reply related [flat|nested] 25+ messages in thread
* [PATCH RFC 12/13] v4l2-of: Corrected v4l2_of_parse_link() function declaration
2012-12-10 19:41 [PATCH RFC 00/13] Common video input interfaces bindings and V4L2 OF helpers Sylwester Nawrocki
` (8 preceding siblings ...)
2012-12-10 19:41 ` [PATCH RFC 11/13] v4l2-of: Add v4l2_of_parse_data_lanes() function Sylwester Nawrocki
@ 2012-12-10 19:41 ` Sylwester Nawrocki
2012-12-10 19:41 ` [PATCH RFC 13/13] v4l2-of: Replace "remote" property with "remote-endpoint" Sylwester Nawrocki
10 siblings, 0 replies; 25+ messages in thread
From: Sylwester Nawrocki @ 2012-12-10 19:41 UTC (permalink / raw)
To: g.liakhovetski, linux-media
Cc: grant.likely, rob.herring, thomas.abraham, t.figa, sw0312.kim,
kyungmin.park, devicetree-discuss, linux-kernel,
Sylwester Nawrocki
v4l2_of_parse_link() return value type is int, not void.
Signed-off-by: Sylwester Nawrocki <s.nawrocki@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
---
include/media/v4l2-of.h | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/include/media/v4l2-of.h b/include/media/v4l2-of.h
index 9b036e6..686d04b 100644
--- a/include/media/v4l2-of.h
+++ b/include/media/v4l2-of.h
@@ -49,10 +49,13 @@ int v4l2_of_parse_data_lanes(const struct device_node *node,
struct device_node *v4l2_of_get_next_link(const struct device_node *parent,
struct device_node *previous);
struct device_node *v4l2_of_get_remote(const struct device_node *node);
-#else
-static inline void v4l2_of_parse_link(const struct device_node *node,
+
+#else /* CONFIG_OF */
+
+static inline int v4l2_of_parse_link(const struct device_node *node,
struct v4l2_of_link *link)
{
+ return -ENOSYS;
}
static inline int v4l2_of_parse_data_lanes(const struct device_node *node,
--
1.7.9.5
^ permalink raw reply related [flat|nested] 25+ messages in thread
* [PATCH RFC 13/13] v4l2-of: Replace "remote" property with "remote-endpoint"
2012-12-10 19:41 [PATCH RFC 00/13] Common video input interfaces bindings and V4L2 OF helpers Sylwester Nawrocki
` (9 preceding siblings ...)
2012-12-10 19:41 ` [PATCH RFC 12/13] v4l2-of: Corrected v4l2_of_parse_link() function declaration Sylwester Nawrocki
@ 2012-12-10 19:41 ` Sylwester Nawrocki
10 siblings, 0 replies; 25+ messages in thread
From: Sylwester Nawrocki @ 2012-12-10 19:41 UTC (permalink / raw)
To: g.liakhovetski, linux-media
Cc: grant.likely, rob.herring, thomas.abraham, t.figa, sw0312.kim,
kyungmin.park, devicetree-discuss, linux-kernel,
Sylwester Nawrocki
As agreed (I hope I'm not wrong) on the LMML use "remote-endpoint"
property instead of "remote". Also add kerneldoc description for
the function.
Signed-off-by: Sylwester Nawrocki <s.nawrocki@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
---
drivers/media/v4l2-core/v4l2-of.c | 12 +++++++++---
1 file changed, 9 insertions(+), 3 deletions(-)
diff --git a/drivers/media/v4l2-core/v4l2-of.c b/drivers/media/v4l2-core/v4l2-of.c
index 032ee67..10a06e4 100644
--- a/drivers/media/v4l2-core/v4l2-of.c
+++ b/drivers/media/v4l2-core/v4l2-of.c
@@ -186,13 +186,19 @@ struct device_node *v4l2_of_get_next_link(const struct device_node *parent,
}
EXPORT_SYMBOL(v4l2_of_get_next_link);
-/* Return a refcounted DT node, owning the link, referenced by "remote" */
+/**
+ * v4l2_of_get_remote() - get device node corresponding to remote enpoint
+ * @node: local endpoint node
+ *
+ * Return: Remote device node associated with remote endpoint node linked
+ * to @node. Use of_node_put() on it when done.
+ */
struct device_node *v4l2_of_get_remote(const struct device_node *node)
{
struct device_node *remote, *tmp;
- /* Get remote link DT node */
- remote = of_parse_phandle(node, "remote", 0);
+ /* Get remote endpoint DT node */
+ remote = of_parse_phandle(node, "remote-endpoint", 0);
if (!remote)
return NULL;
--
1.7.9.5
^ permalink raw reply related [flat|nested] 25+ messages in thread