All of lore.kernel.org
 help / color / mirror / Atom feed
* rcar-vin & soc-camera device tree updates
@ 2014-07-05 22:26 ` Ben Dooks
  0 siblings, 0 replies; 34+ messages in thread
From: Ben Dooks @ 2014-07-05 22:26 UTC (permalink / raw)
  To: linux-media, linux-sh; +Cc: magnus.damm, horms, g.liakhovetski, linux-kernel

This is a new patch, with most of the issues from the previous
reviews now fixed. If there is anything that I have missed then
please let me know.

The only issues remaining is what to do about multiple subdevices
and/or multiple ports on drivers. I have yet to do either of erroring
out or supporting them. Feedback on this issue is welcome.


^ permalink raw reply	[flat|nested] 34+ messages in thread

* rcar-vin & soc-camera device tree updates
@ 2014-07-05 22:26 ` Ben Dooks
  0 siblings, 0 replies; 34+ messages in thread
From: Ben Dooks @ 2014-07-05 22:26 UTC (permalink / raw)
  To: linux-media, linux-sh; +Cc: magnus.damm, horms, g.liakhovetski, linux-kernel

This is a new patch, with most of the issues from the previous
reviews now fixed. If there is anything that I have missed then
please let me know.

The only issues remaining is what to do about multiple subdevices
and/or multiple ports on drivers. I have yet to do either of erroring
out or supporting them. Feedback on this issue is welcome.


^ permalink raw reply	[flat|nested] 34+ messages in thread

* [PATCH 1/6] adv7180: Remove duplicate unregister call
  2014-07-05 22:26 ` Ben Dooks
@ 2014-07-05 22:26   ` Ben Dooks
  -1 siblings, 0 replies; 34+ messages in thread
From: Ben Dooks @ 2014-07-05 22:26 UTC (permalink / raw)
  To: linux-media, linux-sh
  Cc: magnus.damm, horms, g.liakhovetski, linux-kernel, Ian Molton, Ben Dooks

From: Ian Molton <ian.molton@codethink.co.uk>

This driver moved over to v4l2_async_unregister_subdev()
but still retained a call to v4l2_unregister_subdev(). Remove.

Signed-off-by: Ian Molton <ian.molton@codethink.co.uk>
Signed-off-by: Ben Dooks <ben.dooks@codethink.co.uk>
---
 drivers/media/i2c/adv7180.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/media/i2c/adv7180.c b/drivers/media/i2c/adv7180.c
index ac1cdbe..821178d 100644
--- a/drivers/media/i2c/adv7180.c
+++ b/drivers/media/i2c/adv7180.c
@@ -663,7 +663,6 @@ static int adv7180_remove(struct i2c_client *client)
 	if (state->irq > 0)
 		free_irq(client->irq, state);
 
-	v4l2_device_unregister_subdev(sd);
 	adv7180_exit_controls(state);
 	mutex_destroy(&state->mutex);
 	return 0;
-- 
2.0.0


^ permalink raw reply related	[flat|nested] 34+ messages in thread

* [PATCH 1/6] adv7180: Remove duplicate unregister call
@ 2014-07-05 22:26   ` Ben Dooks
  0 siblings, 0 replies; 34+ messages in thread
From: Ben Dooks @ 2014-07-05 22:26 UTC (permalink / raw)
  To: linux-media, linux-sh
  Cc: magnus.damm, horms, g.liakhovetski, linux-kernel, Ian Molton, Ben Dooks

From: Ian Molton <ian.molton@codethink.co.uk>

This driver moved over to v4l2_async_unregister_subdev()
but still retained a call to v4l2_unregister_subdev(). Remove.

Signed-off-by: Ian Molton <ian.molton@codethink.co.uk>
Signed-off-by: Ben Dooks <ben.dooks@codethink.co.uk>
---
 drivers/media/i2c/adv7180.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/media/i2c/adv7180.c b/drivers/media/i2c/adv7180.c
index ac1cdbe..821178d 100644
--- a/drivers/media/i2c/adv7180.c
+++ b/drivers/media/i2c/adv7180.c
@@ -663,7 +663,6 @@ static int adv7180_remove(struct i2c_client *client)
 	if (state->irq > 0)
 		free_irq(client->irq, state);
 
-	v4l2_device_unregister_subdev(sd);
 	adv7180_exit_controls(state);
 	mutex_destroy(&state->mutex);
 	return 0;
-- 
2.0.0


^ permalink raw reply related	[flat|nested] 34+ messages in thread

* [PATCH 2/6] rcar_vin: copy flags from pdata
  2014-07-05 22:26 ` Ben Dooks
@ 2014-07-05 22:26   ` Ben Dooks
  -1 siblings, 0 replies; 34+ messages in thread
From: Ben Dooks @ 2014-07-05 22:26 UTC (permalink / raw)
  To: linux-media, linux-sh
  Cc: magnus.damm, horms, g.liakhovetski, linux-kernel, Ben Dooks

The platform data is a single word, so simply copy
it into the device's private data structure than
keeping a copy of the pointer.

This will make changing to device-tree binding
easier as it is one allocation instead of two.

Signed-off-by: Ben Dooks <ben.dooks@codethink.co.uk>
---
 drivers/media/platform/soc_camera/rcar_vin.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/media/platform/soc_camera/rcar_vin.c b/drivers/media/platform/soc_camera/rcar_vin.c
index e594230..7c4299d 100644
--- a/drivers/media/platform/soc_camera/rcar_vin.c
+++ b/drivers/media/platform/soc_camera/rcar_vin.c
@@ -126,13 +126,13 @@ struct rcar_vin_priv {
 	int				sequence;
 	/* State of the VIN module in capturing mode */
 	enum rcar_vin_state		state;
-	struct rcar_vin_platform_data	*pdata;
 	struct soc_camera_host		ici;
 	struct list_head		capture;
 #define MAX_BUFFER_NUM			3
 	struct vb2_buffer		*queue_buf[MAX_BUFFER_NUM];
 	struct vb2_alloc_ctx		*alloc_ctx;
 	enum v4l2_field			field;
+	unsigned int			pdata_flags;
 	unsigned int			vb_count;
 	unsigned int			nr_hw_slots;
 	bool				request_to_stop;
@@ -275,12 +275,12 @@ static int rcar_vin_setup(struct rcar_vin_priv *priv)
 		break;
 	case V4L2_MBUS_FMT_YUYV8_2X8:
 		/* BT.656 8bit YCbCr422 or BT.601 8bit YCbCr422 */
-		vnmc |= priv->pdata->flags & RCAR_VIN_BT656 ?
+		vnmc |= priv->pdata_flags & RCAR_VIN_BT656 ?
 			VNMC_INF_YUV8_BT656 : VNMC_INF_YUV8_BT601;
 		break;
 	case V4L2_MBUS_FMT_YUYV10_2X10:
 		/* BT.656 10bit YCbCr422 or BT.601 10bit YCbCr422 */
-		vnmc |= priv->pdata->flags & RCAR_VIN_BT656 ?
+		vnmc |= priv->pdata_flags & RCAR_VIN_BT656 ?
 			VNMC_INF_YUV10_BT656 : VNMC_INF_YUV10_BT601;
 		break;
 	default:
@@ -797,7 +797,7 @@ static int rcar_vin_set_bus_param(struct soc_camera_device *icd)
 	/* Make choises, based on platform preferences */
 	if ((common_flags & V4L2_MBUS_HSYNC_ACTIVE_HIGH) &&
 	    (common_flags & V4L2_MBUS_HSYNC_ACTIVE_LOW)) {
-		if (priv->pdata->flags & RCAR_VIN_HSYNC_ACTIVE_LOW)
+		if (priv->pdata_flags & RCAR_VIN_HSYNC_ACTIVE_LOW)
 			common_flags &= ~V4L2_MBUS_HSYNC_ACTIVE_HIGH;
 		else
 			common_flags &= ~V4L2_MBUS_HSYNC_ACTIVE_LOW;
@@ -805,7 +805,7 @@ static int rcar_vin_set_bus_param(struct soc_camera_device *icd)
 
 	if ((common_flags & V4L2_MBUS_VSYNC_ACTIVE_HIGH) &&
 	    (common_flags & V4L2_MBUS_VSYNC_ACTIVE_LOW)) {
-		if (priv->pdata->flags & RCAR_VIN_VSYNC_ACTIVE_LOW)
+		if (priv->pdata_flags & RCAR_VIN_VSYNC_ACTIVE_LOW)
 			common_flags &= ~V4L2_MBUS_VSYNC_ACTIVE_HIGH;
 		else
 			common_flags &= ~V4L2_MBUS_VSYNC_ACTIVE_LOW;
@@ -1445,7 +1445,7 @@ static int rcar_vin_probe(struct platform_device *pdev)
 	priv->ici.drv_name = dev_name(&pdev->dev);
 	priv->ici.ops = &rcar_vin_host_ops;
 
-	priv->pdata = pdata;
+	priv->pdata_flags = pdata->flags;
 	priv->chip = pdev->id_entry->driver_data;
 	spin_lock_init(&priv->lock);
 	INIT_LIST_HEAD(&priv->capture);
-- 
2.0.0


^ permalink raw reply related	[flat|nested] 34+ messages in thread

* [PATCH 2/6] rcar_vin: copy flags from pdata
@ 2014-07-05 22:26   ` Ben Dooks
  0 siblings, 0 replies; 34+ messages in thread
From: Ben Dooks @ 2014-07-05 22:26 UTC (permalink / raw)
  To: linux-media, linux-sh
  Cc: magnus.damm, horms, g.liakhovetski, linux-kernel, Ben Dooks

The platform data is a single word, so simply copy
it into the device's private data structure than
keeping a copy of the pointer.

This will make changing to device-tree binding
easier as it is one allocation instead of two.

Signed-off-by: Ben Dooks <ben.dooks@codethink.co.uk>
---
 drivers/media/platform/soc_camera/rcar_vin.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/media/platform/soc_camera/rcar_vin.c b/drivers/media/platform/soc_camera/rcar_vin.c
index e594230..7c4299d 100644
--- a/drivers/media/platform/soc_camera/rcar_vin.c
+++ b/drivers/media/platform/soc_camera/rcar_vin.c
@@ -126,13 +126,13 @@ struct rcar_vin_priv {
 	int				sequence;
 	/* State of the VIN module in capturing mode */
 	enum rcar_vin_state		state;
-	struct rcar_vin_platform_data	*pdata;
 	struct soc_camera_host		ici;
 	struct list_head		capture;
 #define MAX_BUFFER_NUM			3
 	struct vb2_buffer		*queue_buf[MAX_BUFFER_NUM];
 	struct vb2_alloc_ctx		*alloc_ctx;
 	enum v4l2_field			field;
+	unsigned int			pdata_flags;
 	unsigned int			vb_count;
 	unsigned int			nr_hw_slots;
 	bool				request_to_stop;
@@ -275,12 +275,12 @@ static int rcar_vin_setup(struct rcar_vin_priv *priv)
 		break;
 	case V4L2_MBUS_FMT_YUYV8_2X8:
 		/* BT.656 8bit YCbCr422 or BT.601 8bit YCbCr422 */
-		vnmc |= priv->pdata->flags & RCAR_VIN_BT656 ?
+		vnmc |= priv->pdata_flags & RCAR_VIN_BT656 ?
 			VNMC_INF_YUV8_BT656 : VNMC_INF_YUV8_BT601;
 		break;
 	case V4L2_MBUS_FMT_YUYV10_2X10:
 		/* BT.656 10bit YCbCr422 or BT.601 10bit YCbCr422 */
-		vnmc |= priv->pdata->flags & RCAR_VIN_BT656 ?
+		vnmc |= priv->pdata_flags & RCAR_VIN_BT656 ?
 			VNMC_INF_YUV10_BT656 : VNMC_INF_YUV10_BT601;
 		break;
 	default:
@@ -797,7 +797,7 @@ static int rcar_vin_set_bus_param(struct soc_camera_device *icd)
 	/* Make choises, based on platform preferences */
 	if ((common_flags & V4L2_MBUS_HSYNC_ACTIVE_HIGH) &&
 	    (common_flags & V4L2_MBUS_HSYNC_ACTIVE_LOW)) {
-		if (priv->pdata->flags & RCAR_VIN_HSYNC_ACTIVE_LOW)
+		if (priv->pdata_flags & RCAR_VIN_HSYNC_ACTIVE_LOW)
 			common_flags &= ~V4L2_MBUS_HSYNC_ACTIVE_HIGH;
 		else
 			common_flags &= ~V4L2_MBUS_HSYNC_ACTIVE_LOW;
@@ -805,7 +805,7 @@ static int rcar_vin_set_bus_param(struct soc_camera_device *icd)
 
 	if ((common_flags & V4L2_MBUS_VSYNC_ACTIVE_HIGH) &&
 	    (common_flags & V4L2_MBUS_VSYNC_ACTIVE_LOW)) {
-		if (priv->pdata->flags & RCAR_VIN_VSYNC_ACTIVE_LOW)
+		if (priv->pdata_flags & RCAR_VIN_VSYNC_ACTIVE_LOW)
 			common_flags &= ~V4L2_MBUS_VSYNC_ACTIVE_HIGH;
 		else
 			common_flags &= ~V4L2_MBUS_VSYNC_ACTIVE_LOW;
@@ -1445,7 +1445,7 @@ static int rcar_vin_probe(struct platform_device *pdev)
 	priv->ici.drv_name = dev_name(&pdev->dev);
 	priv->ici.ops = &rcar_vin_host_ops;
 
-	priv->pdata = pdata;
+	priv->pdata_flags = pdata->flags;
 	priv->chip = pdev->id_entry->driver_data;
 	spin_lock_init(&priv->lock);
 	INIT_LIST_HEAD(&priv->capture);
-- 
2.0.0


^ permalink raw reply related	[flat|nested] 34+ messages in thread

* [PATCH 3/6] rcar_vin: add devicetree support
  2014-07-05 22:26 ` Ben Dooks
@ 2014-07-05 22:26   ` Ben Dooks
  -1 siblings, 0 replies; 34+ messages in thread
From: Ben Dooks @ 2014-07-05 22:26 UTC (permalink / raw)
  To: linux-media, linux-sh
  Cc: magnus.damm, horms, g.liakhovetski, linux-kernel, Ben Dooks

Add support for devicetree probe for the rcar-vin
driver.

Signed-off-by: Ben Dooks <ben.dooks@codethink.co.uk>
---
 .../devicetree/bindings/media/rcar_vin.txt         | 86 ++++++++++++++++++++++
 drivers/media/platform/soc_camera/rcar_vin.c       | 72 ++++++++++++++++--
 2 files changed, 151 insertions(+), 7 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/media/rcar_vin.txt

diff --git a/Documentation/devicetree/bindings/media/rcar_vin.txt b/Documentation/devicetree/bindings/media/rcar_vin.txt
new file mode 100644
index 0000000..10fefa9
--- /dev/null
+++ b/Documentation/devicetree/bindings/media/rcar_vin.txt
@@ -0,0 +1,86 @@
+Renesas RCar Video Input driver (rcar_vin)
+------------------------------------------
+
+The rcar_vin device provides video input capabilities for the Renesas R-Car
+family of devices. The current blocks are always slaves and suppot one input
+channel which can be either RGB, YUYV or BT656.
+
+ - compatible: Must be one of the following
+   - "renesas,vin-r8a7791" for the R8A7791 device
+   - "renesas,vin-r8a7790" for the R8A7790 device
+   - "renesas,vin-r8a7779" for the R8A7779 device
+   - "renesas,vin-r8a7778" for the R8A7778 device
+ - reg: the register base and size for the device registers
+ - interrupts: the interrupt for the device
+ - clocks: Reference to the parent clock
+
+Additionally, an alias named vinX will need to be created to specify
+which video input device this is.
+
+The per-board settings:
+ - port sub-node describing a single endpoint connected to the vin
+   as described in video-interfaces.txt[1]. Only the first one will
+   be considered as each vin interface has one input port.
+
+   These settings are used to work out video input format and widths
+   into the system.
+
+
+Device node example
+-------------------
+
+	aliases {
+	       vin0 = &vin0;
+	};
+
+        vin0: vin@0xe6ef0000 {
+                compatible = "renesas,vin-r8a7790";
+                clocks = <&mstp8_clks R8A7790_CLK_VIN0>;
+                reg = <0 0xe6ef0000 0 0x1000>;
+                interrupts = <0 188 IRQ_TYPE_LEVEL_HIGH>;
+                status = "disabled";
+        };
+
+Board setup example (vin1 composite video input)
+------------------------------------------------
+
+&i2c2   {
+        status = "ok";
+        pinctrl-0 = <&i2c2_pins>;
+        pinctrl-names = "default";
+
+        adv7180@020 {
+                compatible = "adi,adv7180";
+                reg = <0x20>;
+                remote = <&vin1>;
+
+                port {
+                        adv7180: endpoint {
+                                bus-width = <8>;
+                                remote-endpoint = <&vin1ep0>;
+                        };
+                };
+        };
+};
+
+/* composite video input */
+&vin1 {
+        pinctrl-0 = <&vin1_pins>;
+        pinctrl-names = "default";
+
+        status = "ok";
+
+        port {
+                #address-cells = <1>;
+                #size-cells = <0>;
+
+                vin1ep0: endpoint {
+                        remote-endpoint = <&adv7180>;
+                        bus-width = <8>;
+                };
+        };
+};
+
+
+
+[1] video-interfaces.txt common video media interface
diff --git a/drivers/media/platform/soc_camera/rcar_vin.c b/drivers/media/platform/soc_camera/rcar_vin.c
index 7c4299d..eb196ef 100644
--- a/drivers/media/platform/soc_camera/rcar_vin.c
+++ b/drivers/media/platform/soc_camera/rcar_vin.c
@@ -24,6 +24,8 @@
 #include <linux/pm_runtime.h>
 #include <linux/slab.h>
 #include <linux/videodev2.h>
+#include <linux/of.h>
+#include <linux/of_device.h>
 
 #include <media/soc_camera.h>
 #include <media/soc_mediabus.h>
@@ -32,6 +34,7 @@
 #include <media/v4l2-device.h>
 #include <media/v4l2-mediabus.h>
 #include <media/v4l2-subdev.h>
+#include <media/v4l2-of.h>
 #include <media/videobuf2-dma-contig.h>
 
 #include "soc_scale_crop.h"
@@ -1390,6 +1393,17 @@ static struct soc_camera_host_ops rcar_vin_host_ops = {
 	.init_videobuf2	= rcar_vin_init_videobuf2,
 };
 
+#ifdef CONFIG_OF
+static struct of_device_id rcar_vin_of_table[] = {
+	{ .compatible = "renesas,vin-r8a7791", .data = (void *)RCAR_GEN2 },
+	{ .compatible = "renesas,vin-r8a7790", .data = (void *)RCAR_GEN2 },
+	{ .compatible = "renesas,vin-r8a7779", .data = (void *)RCAR_H1 },
+	{ .compatible = "renesas,vin-r8a7778", .data = (void *)RCAR_M1 },
+	{ },
+};
+MODULE_DEVICE_TABLE(of, rcar_vin_of_table);
+#endif
+
 static struct platform_device_id rcar_vin_id_table[] = {
 	{ "r8a7791-vin",  RCAR_GEN2 },
 	{ "r8a7790-vin",  RCAR_GEN2 },
@@ -1402,15 +1416,52 @@ MODULE_DEVICE_TABLE(platform, rcar_vin_id_table);
 
 static int rcar_vin_probe(struct platform_device *pdev)
 {
+	const struct of_device_id *match = NULL;
 	struct rcar_vin_priv *priv;
 	struct resource *mem;
 	struct rcar_vin_platform_data *pdata;
+	unsigned int pdata_flags;
 	int irq, ret;
 
-	pdata = pdev->dev.platform_data;
-	if (!pdata || !pdata->flags) {
-		dev_err(&pdev->dev, "platform data not set\n");
-		return -EINVAL;
+	if (pdev->dev.of_node) {
+		struct v4l2_of_endpoint ep;
+		struct device_node *np;
+
+		match = of_match_device(of_match_ptr(rcar_vin_of_table),
+					&pdev->dev);
+
+		np = of_graph_get_next_endpoint(pdev->dev.of_node, NULL);
+		if (!np) {
+			dev_err(&pdev->dev, "could not find endpoint\n");
+			return -EINVAL;
+		}
+
+		ret = v4l2_of_parse_endpoint(np, &ep);
+		if (ret) {
+			dev_err(&pdev->dev, "could not parse endpoint\n");
+			return ret;
+		}
+
+		if (ep.bus_type = V4L2_MBUS_BT656)
+			pdata_flags = RCAR_VIN_BT656;
+		else {
+			pdata_flags = 0;
+			if (ep.bus.parallel.flags & V4L2_MBUS_HSYNC_ACTIVE_LOW)
+				pdata_flags |= RCAR_VIN_HSYNC_ACTIVE_LOW;
+			if (ep.bus.parallel.flags & V4L2_MBUS_VSYNC_ACTIVE_LOW)
+				pdata_flags |= RCAR_VIN_VSYNC_ACTIVE_LOW;
+		}
+
+		of_node_put(np);
+
+		dev_dbg(&pdev->dev, "pdata_flags = %08x\n", pdata_flags);
+	} else {
+		pdata = pdev->dev.platform_data;
+		if (!pdata || !pdata->flags) {
+			dev_err(&pdev->dev, "platform data not set\n");
+			return -EINVAL;
+		}
+		pdata_flags = pdata->flags;
 	}
 
 	mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
@@ -1441,12 +1492,18 @@ static int rcar_vin_probe(struct platform_device *pdev)
 
 	priv->ici.priv = priv;
 	priv->ici.v4l2_dev.dev = &pdev->dev;
-	priv->ici.nr = pdev->id;
 	priv->ici.drv_name = dev_name(&pdev->dev);
 	priv->ici.ops = &rcar_vin_host_ops;
 
-	priv->pdata_flags = pdata->flags;
-	priv->chip = pdev->id_entry->driver_data;
+	priv->pdata_flags = pdata_flags;
+	if (!match) {
+		priv->ici.nr = pdev->id;
+		priv->chip = pdev->id_entry->driver_data;
+	} else {
+		priv->ici.nr = of_alias_get_id(pdev->dev.of_node, "vin");
+		priv->chip = (enum chip_id)match->data;
+	};
+
 	spin_lock_init(&priv->lock);
 	INIT_LIST_HEAD(&priv->capture);
 
@@ -1487,6 +1544,7 @@ static struct platform_driver rcar_vin_driver = {
 	.driver		= {
 		.name		= DRV_NAME,
 		.owner		= THIS_MODULE,
+		.of_match_table	= of_match_ptr(rcar_vin_of_table),
 	},
 	.id_table	= rcar_vin_id_table,
 };
-- 
2.0.0


^ permalink raw reply related	[flat|nested] 34+ messages in thread

* [PATCH 3/6] rcar_vin: add devicetree support
@ 2014-07-05 22:26   ` Ben Dooks
  0 siblings, 0 replies; 34+ messages in thread
From: Ben Dooks @ 2014-07-05 22:26 UTC (permalink / raw)
  To: linux-media, linux-sh
  Cc: magnus.damm, horms, g.liakhovetski, linux-kernel, Ben Dooks

Add support for devicetree probe for the rcar-vin
driver.

Signed-off-by: Ben Dooks <ben.dooks@codethink.co.uk>
---
 .../devicetree/bindings/media/rcar_vin.txt         | 86 ++++++++++++++++++++++
 drivers/media/platform/soc_camera/rcar_vin.c       | 72 ++++++++++++++++--
 2 files changed, 151 insertions(+), 7 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/media/rcar_vin.txt

diff --git a/Documentation/devicetree/bindings/media/rcar_vin.txt b/Documentation/devicetree/bindings/media/rcar_vin.txt
new file mode 100644
index 0000000..10fefa9
--- /dev/null
+++ b/Documentation/devicetree/bindings/media/rcar_vin.txt
@@ -0,0 +1,86 @@
+Renesas RCar Video Input driver (rcar_vin)
+------------------------------------------
+
+The rcar_vin device provides video input capabilities for the Renesas R-Car
+family of devices. The current blocks are always slaves and suppot one input
+channel which can be either RGB, YUYV or BT656.
+
+ - compatible: Must be one of the following
+   - "renesas,vin-r8a7791" for the R8A7791 device
+   - "renesas,vin-r8a7790" for the R8A7790 device
+   - "renesas,vin-r8a7779" for the R8A7779 device
+   - "renesas,vin-r8a7778" for the R8A7778 device
+ - reg: the register base and size for the device registers
+ - interrupts: the interrupt for the device
+ - clocks: Reference to the parent clock
+
+Additionally, an alias named vinX will need to be created to specify
+which video input device this is.
+
+The per-board settings:
+ - port sub-node describing a single endpoint connected to the vin
+   as described in video-interfaces.txt[1]. Only the first one will
+   be considered as each vin interface has one input port.
+
+   These settings are used to work out video input format and widths
+   into the system.
+
+
+Device node example
+-------------------
+
+	aliases {
+	       vin0 = &vin0;
+	};
+
+        vin0: vin@0xe6ef0000 {
+                compatible = "renesas,vin-r8a7790";
+                clocks = <&mstp8_clks R8A7790_CLK_VIN0>;
+                reg = <0 0xe6ef0000 0 0x1000>;
+                interrupts = <0 188 IRQ_TYPE_LEVEL_HIGH>;
+                status = "disabled";
+        };
+
+Board setup example (vin1 composite video input)
+------------------------------------------------
+
+&i2c2   {
+        status = "ok";
+        pinctrl-0 = <&i2c2_pins>;
+        pinctrl-names = "default";
+
+        adv7180@020 {
+                compatible = "adi,adv7180";
+                reg = <0x20>;
+                remote = <&vin1>;
+
+                port {
+                        adv7180: endpoint {
+                                bus-width = <8>;
+                                remote-endpoint = <&vin1ep0>;
+                        };
+                };
+        };
+};
+
+/* composite video input */
+&vin1 {
+        pinctrl-0 = <&vin1_pins>;
+        pinctrl-names = "default";
+
+        status = "ok";
+
+        port {
+                #address-cells = <1>;
+                #size-cells = <0>;
+
+                vin1ep0: endpoint {
+                        remote-endpoint = <&adv7180>;
+                        bus-width = <8>;
+                };
+        };
+};
+
+
+
+[1] video-interfaces.txt common video media interface
diff --git a/drivers/media/platform/soc_camera/rcar_vin.c b/drivers/media/platform/soc_camera/rcar_vin.c
index 7c4299d..eb196ef 100644
--- a/drivers/media/platform/soc_camera/rcar_vin.c
+++ b/drivers/media/platform/soc_camera/rcar_vin.c
@@ -24,6 +24,8 @@
 #include <linux/pm_runtime.h>
 #include <linux/slab.h>
 #include <linux/videodev2.h>
+#include <linux/of.h>
+#include <linux/of_device.h>
 
 #include <media/soc_camera.h>
 #include <media/soc_mediabus.h>
@@ -32,6 +34,7 @@
 #include <media/v4l2-device.h>
 #include <media/v4l2-mediabus.h>
 #include <media/v4l2-subdev.h>
+#include <media/v4l2-of.h>
 #include <media/videobuf2-dma-contig.h>
 
 #include "soc_scale_crop.h"
@@ -1390,6 +1393,17 @@ static struct soc_camera_host_ops rcar_vin_host_ops = {
 	.init_videobuf2	= rcar_vin_init_videobuf2,
 };
 
+#ifdef CONFIG_OF
+static struct of_device_id rcar_vin_of_table[] = {
+	{ .compatible = "renesas,vin-r8a7791", .data = (void *)RCAR_GEN2 },
+	{ .compatible = "renesas,vin-r8a7790", .data = (void *)RCAR_GEN2 },
+	{ .compatible = "renesas,vin-r8a7779", .data = (void *)RCAR_H1 },
+	{ .compatible = "renesas,vin-r8a7778", .data = (void *)RCAR_M1 },
+	{ },
+};
+MODULE_DEVICE_TABLE(of, rcar_vin_of_table);
+#endif
+
 static struct platform_device_id rcar_vin_id_table[] = {
 	{ "r8a7791-vin",  RCAR_GEN2 },
 	{ "r8a7790-vin",  RCAR_GEN2 },
@@ -1402,15 +1416,52 @@ MODULE_DEVICE_TABLE(platform, rcar_vin_id_table);
 
 static int rcar_vin_probe(struct platform_device *pdev)
 {
+	const struct of_device_id *match = NULL;
 	struct rcar_vin_priv *priv;
 	struct resource *mem;
 	struct rcar_vin_platform_data *pdata;
+	unsigned int pdata_flags;
 	int irq, ret;
 
-	pdata = pdev->dev.platform_data;
-	if (!pdata || !pdata->flags) {
-		dev_err(&pdev->dev, "platform data not set\n");
-		return -EINVAL;
+	if (pdev->dev.of_node) {
+		struct v4l2_of_endpoint ep;
+		struct device_node *np;
+
+		match = of_match_device(of_match_ptr(rcar_vin_of_table),
+					&pdev->dev);
+
+		np = of_graph_get_next_endpoint(pdev->dev.of_node, NULL);
+		if (!np) {
+			dev_err(&pdev->dev, "could not find endpoint\n");
+			return -EINVAL;
+		}
+
+		ret = v4l2_of_parse_endpoint(np, &ep);
+		if (ret) {
+			dev_err(&pdev->dev, "could not parse endpoint\n");
+			return ret;
+		}
+
+		if (ep.bus_type == V4L2_MBUS_BT656)
+			pdata_flags = RCAR_VIN_BT656;
+		else {
+			pdata_flags = 0;
+			if (ep.bus.parallel.flags & V4L2_MBUS_HSYNC_ACTIVE_LOW)
+				pdata_flags |= RCAR_VIN_HSYNC_ACTIVE_LOW;
+			if (ep.bus.parallel.flags & V4L2_MBUS_VSYNC_ACTIVE_LOW)
+				pdata_flags |= RCAR_VIN_VSYNC_ACTIVE_LOW;
+		}
+
+		of_node_put(np);
+
+		dev_dbg(&pdev->dev, "pdata_flags = %08x\n", pdata_flags);
+	} else {
+		pdata = pdev->dev.platform_data;
+		if (!pdata || !pdata->flags) {
+			dev_err(&pdev->dev, "platform data not set\n");
+			return -EINVAL;
+		}
+		pdata_flags = pdata->flags;
 	}
 
 	mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
@@ -1441,12 +1492,18 @@ static int rcar_vin_probe(struct platform_device *pdev)
 
 	priv->ici.priv = priv;
 	priv->ici.v4l2_dev.dev = &pdev->dev;
-	priv->ici.nr = pdev->id;
 	priv->ici.drv_name = dev_name(&pdev->dev);
 	priv->ici.ops = &rcar_vin_host_ops;
 
-	priv->pdata_flags = pdata->flags;
-	priv->chip = pdev->id_entry->driver_data;
+	priv->pdata_flags = pdata_flags;
+	if (!match) {
+		priv->ici.nr = pdev->id;
+		priv->chip = pdev->id_entry->driver_data;
+	} else {
+		priv->ici.nr = of_alias_get_id(pdev->dev.of_node, "vin");
+		priv->chip = (enum chip_id)match->data;
+	};
+
 	spin_lock_init(&priv->lock);
 	INIT_LIST_HEAD(&priv->capture);
 
@@ -1487,6 +1544,7 @@ static struct platform_driver rcar_vin_driver = {
 	.driver		= {
 		.name		= DRV_NAME,
 		.owner		= THIS_MODULE,
+		.of_match_table	= of_match_ptr(rcar_vin_of_table),
 	},
 	.id_table	= rcar_vin_id_table,
 };
-- 
2.0.0


^ permalink raw reply related	[flat|nested] 34+ messages in thread

* [PATCH 4/6] [V3] soc_camera: add support for dt binding soc_camera drivers
  2014-07-05 22:26 ` Ben Dooks
@ 2014-07-05 22:26   ` Ben Dooks
  -1 siblings, 0 replies; 34+ messages in thread
From: Ben Dooks @ 2014-07-05 22:26 UTC (permalink / raw)
  To: linux-media, linux-sh
  Cc: magnus.damm, horms, g.liakhovetski, linux-kernel, Ben Dooks

Add initial support for OF based soc-camera devices that may be used
by any of the soc-camera drivers. The driver itself will need converting
to use OF.

These changes allow the soc-camera driver to do the connecting of any
async capable v4l2 device to the soc-camera driver. This has currently
been tested on the Renesas Lager board.

It currently only supports one input device per driver as this seems
to be the standard connection for these devices.

Signed-off-by: Ben Dooks <ben.dooks@codethink.co.uk>
---

Fixes since v1:
	- Fix i2c mclk name compatible with other drivers
	- Ensure of_node is put after use
Fixes since v2:
	- Updated freeing of dyn-pdev as requested
	- Coding style fixes
	- Allocate initial resources in one go
---
 drivers/media/platform/soc_camera/soc_camera.c | 123 ++++++++++++++++++++++++-
 1 file changed, 122 insertions(+), 1 deletion(-)

diff --git a/drivers/media/platform/soc_camera/soc_camera.c b/drivers/media/platform/soc_camera/soc_camera.c
index 7fec8cd..e25fc8e 100644
--- a/drivers/media/platform/soc_camera/soc_camera.c
+++ b/drivers/media/platform/soc_camera/soc_camera.c
@@ -36,6 +36,7 @@
 #include <media/v4l2-common.h>
 #include <media/v4l2-ioctl.h>
 #include <media/v4l2-dev.h>
+#include <media/v4l2-of.h>
 #include <media/videobuf-core.h>
 #include <media/videobuf2-core.h>
 
@@ -1581,6 +1582,124 @@ static void scan_async_host(struct soc_camera_host *ici)
 #define scan_async_host(ici)		do {} while (0)
 #endif
 
+#ifdef CONFIG_OF
+
+struct soc_of_info {
+	struct soc_camera_async_subdev	sasd;
+	struct v4l2_async_subdev	*subdevs[2];
+};
+
+static int soc_of_bind(struct soc_camera_host *ici,
+		       struct device_node *ep,
+		       struct device_node *remote)
+{
+	struct soc_camera_device *icd;
+	struct soc_camera_desc sdesc = {.host_desc.bus_id = ici->nr,};
+	struct soc_camera_async_client *sasc;
+	struct soc_of_info *info;
+	struct i2c_client *client;
+	char clk_name[V4L2_SUBDEV_NAME_SIZE];
+	int ret;
+
+	/* allocate a new subdev and add match info to it */
+	info = devm_kzalloc(ici->v4l2_dev.dev, sizeof(struct soc_of_info),
+			    GFP_KERNEL);
+	if (!info)
+		return -ENOMEM;
+
+	info->sasd.asd.match.of.node = remote;
+	info->sasd.asd.match_type = V4L2_ASYNC_MATCH_OF;
+	info->subdevs[0] = &info->sasd.asd;
+
+	/* Or shall this be managed by the soc-camera device? */
+	sasc = devm_kzalloc(ici->v4l2_dev.dev, sizeof(*sasc), GFP_KERNEL);
+	if (!sasc)
+		return -ENOMEM;
+
+	/* HACK: just need a != NULL */
+	sdesc.host_desc.board_info = ERR_PTR(-ENODATA);
+
+	ret = soc_camera_dyn_pdev(&sdesc, sasc);
+	if (ret < 0)
+		goto eallocpdev;
+
+	sasc->sensor = &info->sasd.asd;
+
+	icd = soc_camera_add_pdev(sasc);
+	if (!icd) {
+		ret = -ENOMEM;
+		goto eaddpdev;
+	}
+
+	sasc->notifier.subdevs = info->subdevs;
+	sasc->notifier.num_subdevs = 1;
+	sasc->notifier.bound = soc_camera_async_bound;
+	sasc->notifier.unbind = soc_camera_async_unbind;
+	sasc->notifier.complete = soc_camera_async_complete;
+
+	icd->sasc = sasc;
+	icd->parent = ici->v4l2_dev.dev;
+
+	client = of_find_i2c_device_by_node(remote);
+
+	if (client)
+		snprintf(clk_name, sizeof(clk_name), "%d-%04x",
+			 client->adapter->nr, client->addr);
+	else
+		snprintf(clk_name, sizeof(clk_name), "of-%s",
+			 of_node_full_name(remote));
+
+	icd->clk = v4l2_clk_register(&soc_camera_clk_ops, clk_name, "mclk", icd);
+	if (IS_ERR(icd->clk)) {
+		ret = PTR_ERR(icd->clk);
+		goto eclkreg;
+	}
+
+	ret = v4l2_async_notifier_register(&ici->v4l2_dev, &sasc->notifier);
+	if (!ret)
+		return 0;
+eclkreg:
+	icd->clk = NULL;
+	platform_device_del(sasc->pdev);
+eaddpdev:
+	platform_device_put(sasc->pdev);
+eallocpdev:
+	devm_kfree(ici->v4l2_dev.dev, sasc);
+	dev_err(ici->v4l2_dev.dev, "group probe failed: %d\n", ret);
+
+	return ret;
+}
+
+static void scan_of_host(struct soc_camera_host *ici)
+{
+	struct device_node *np = ici->v4l2_dev.dev->of_node;
+	struct device_node *epn = NULL;
+	struct device_node *ren;
+
+	while (true) {
+		epn = of_graph_get_next_endpoint(np, epn);
+		if (!epn)
+			break;
+
+		ren = of_graph_get_remote_port(epn);
+		if (!ren) {
+			pr_info("%s: no remote for %s\n",
+				__func__,  of_node_full_name(epn));
+			continue;
+		}
+
+		/* so we now have a remote node to connect */
+		soc_of_bind(ici, epn, ren->parent);
+
+		of_node_put(epn);
+		of_node_put(ren);
+	}
+}
+
+#else
+static inline void scan_of_host(struct soc_camera_host *ici) { }
+#endif
+
 /* Called during host-driver probe */
 static int soc_camera_probe(struct soc_camera_host *ici,
 			    struct soc_camera_device *icd)
@@ -1832,7 +1951,9 @@ int soc_camera_host_register(struct soc_camera_host *ici)
 	mutex_init(&ici->host_lock);
 	mutex_init(&ici->clk_lock);
 
-	if (ici->asd_sizes)
+	if (ici->v4l2_dev.dev->of_node)
+		scan_of_host(ici);
+	else if (ici->asd_sizes)
 		/*
 		 * No OF, host with a list of subdevices. Don't try to mix
 		 * modes by initialising some groups statically and some
-- 
2.0.0


^ permalink raw reply related	[flat|nested] 34+ messages in thread

* [PATCH 4/6] [V3] soc_camera: add support for dt binding soc_camera drivers
@ 2014-07-05 22:26   ` Ben Dooks
  0 siblings, 0 replies; 34+ messages in thread
From: Ben Dooks @ 2014-07-05 22:26 UTC (permalink / raw)
  To: linux-media, linux-sh
  Cc: magnus.damm, horms, g.liakhovetski, linux-kernel, Ben Dooks

Add initial support for OF based soc-camera devices that may be used
by any of the soc-camera drivers. The driver itself will need converting
to use OF.

These changes allow the soc-camera driver to do the connecting of any
async capable v4l2 device to the soc-camera driver. This has currently
been tested on the Renesas Lager board.

It currently only supports one input device per driver as this seems
to be the standard connection for these devices.

Signed-off-by: Ben Dooks <ben.dooks@codethink.co.uk>
---

Fixes since v1:
	- Fix i2c mclk name compatible with other drivers
	- Ensure of_node is put after use
Fixes since v2:
	- Updated freeing of dyn-pdev as requested
	- Coding style fixes
	- Allocate initial resources in one go
---
 drivers/media/platform/soc_camera/soc_camera.c | 123 ++++++++++++++++++++++++-
 1 file changed, 122 insertions(+), 1 deletion(-)

diff --git a/drivers/media/platform/soc_camera/soc_camera.c b/drivers/media/platform/soc_camera/soc_camera.c
index 7fec8cd..e25fc8e 100644
--- a/drivers/media/platform/soc_camera/soc_camera.c
+++ b/drivers/media/platform/soc_camera/soc_camera.c
@@ -36,6 +36,7 @@
 #include <media/v4l2-common.h>
 #include <media/v4l2-ioctl.h>
 #include <media/v4l2-dev.h>
+#include <media/v4l2-of.h>
 #include <media/videobuf-core.h>
 #include <media/videobuf2-core.h>
 
@@ -1581,6 +1582,124 @@ static void scan_async_host(struct soc_camera_host *ici)
 #define scan_async_host(ici)		do {} while (0)
 #endif
 
+#ifdef CONFIG_OF
+
+struct soc_of_info {
+	struct soc_camera_async_subdev	sasd;
+	struct v4l2_async_subdev	*subdevs[2];
+};
+
+static int soc_of_bind(struct soc_camera_host *ici,
+		       struct device_node *ep,
+		       struct device_node *remote)
+{
+	struct soc_camera_device *icd;
+	struct soc_camera_desc sdesc = {.host_desc.bus_id = ici->nr,};
+	struct soc_camera_async_client *sasc;
+	struct soc_of_info *info;
+	struct i2c_client *client;
+	char clk_name[V4L2_SUBDEV_NAME_SIZE];
+	int ret;
+
+	/* allocate a new subdev and add match info to it */
+	info = devm_kzalloc(ici->v4l2_dev.dev, sizeof(struct soc_of_info),
+			    GFP_KERNEL);
+	if (!info)
+		return -ENOMEM;
+
+	info->sasd.asd.match.of.node = remote;
+	info->sasd.asd.match_type = V4L2_ASYNC_MATCH_OF;
+	info->subdevs[0] = &info->sasd.asd;
+
+	/* Or shall this be managed by the soc-camera device? */
+	sasc = devm_kzalloc(ici->v4l2_dev.dev, sizeof(*sasc), GFP_KERNEL);
+	if (!sasc)
+		return -ENOMEM;
+
+	/* HACK: just need a != NULL */
+	sdesc.host_desc.board_info = ERR_PTR(-ENODATA);
+
+	ret = soc_camera_dyn_pdev(&sdesc, sasc);
+	if (ret < 0)
+		goto eallocpdev;
+
+	sasc->sensor = &info->sasd.asd;
+
+	icd = soc_camera_add_pdev(sasc);
+	if (!icd) {
+		ret = -ENOMEM;
+		goto eaddpdev;
+	}
+
+	sasc->notifier.subdevs = info->subdevs;
+	sasc->notifier.num_subdevs = 1;
+	sasc->notifier.bound = soc_camera_async_bound;
+	sasc->notifier.unbind = soc_camera_async_unbind;
+	sasc->notifier.complete = soc_camera_async_complete;
+
+	icd->sasc = sasc;
+	icd->parent = ici->v4l2_dev.dev;
+
+	client = of_find_i2c_device_by_node(remote);
+
+	if (client)
+		snprintf(clk_name, sizeof(clk_name), "%d-%04x",
+			 client->adapter->nr, client->addr);
+	else
+		snprintf(clk_name, sizeof(clk_name), "of-%s",
+			 of_node_full_name(remote));
+
+	icd->clk = v4l2_clk_register(&soc_camera_clk_ops, clk_name, "mclk", icd);
+	if (IS_ERR(icd->clk)) {
+		ret = PTR_ERR(icd->clk);
+		goto eclkreg;
+	}
+
+	ret = v4l2_async_notifier_register(&ici->v4l2_dev, &sasc->notifier);
+	if (!ret)
+		return 0;
+eclkreg:
+	icd->clk = NULL;
+	platform_device_del(sasc->pdev);
+eaddpdev:
+	platform_device_put(sasc->pdev);
+eallocpdev:
+	devm_kfree(ici->v4l2_dev.dev, sasc);
+	dev_err(ici->v4l2_dev.dev, "group probe failed: %d\n", ret);
+
+	return ret;
+}
+
+static void scan_of_host(struct soc_camera_host *ici)
+{
+	struct device_node *np = ici->v4l2_dev.dev->of_node;
+	struct device_node *epn = NULL;
+	struct device_node *ren;
+
+	while (true) {
+		epn = of_graph_get_next_endpoint(np, epn);
+		if (!epn)
+			break;
+
+		ren = of_graph_get_remote_port(epn);
+		if (!ren) {
+			pr_info("%s: no remote for %s\n",
+				__func__,  of_node_full_name(epn));
+			continue;
+		}
+
+		/* so we now have a remote node to connect */
+		soc_of_bind(ici, epn, ren->parent);
+
+		of_node_put(epn);
+		of_node_put(ren);
+	}
+}
+
+#else
+static inline void scan_of_host(struct soc_camera_host *ici) { }
+#endif
+
 /* Called during host-driver probe */
 static int soc_camera_probe(struct soc_camera_host *ici,
 			    struct soc_camera_device *icd)
@@ -1832,7 +1951,9 @@ int soc_camera_host_register(struct soc_camera_host *ici)
 	mutex_init(&ici->host_lock);
 	mutex_init(&ici->clk_lock);
 
-	if (ici->asd_sizes)
+	if (ici->v4l2_dev.dev->of_node)
+		scan_of_host(ici);
+	else if (ici->asd_sizes)
 		/*
 		 * No OF, host with a list of subdevices. Don't try to mix
 		 * modes by initialising some groups statically and some
-- 
2.0.0


^ permalink raw reply related	[flat|nested] 34+ messages in thread

* [PATCH 5/6] r8a7790.dtsi: add vin[0-3] nodes
  2014-07-05 22:26 ` Ben Dooks
@ 2014-07-05 22:26   ` Ben Dooks
  -1 siblings, 0 replies; 34+ messages in thread
From: Ben Dooks @ 2014-07-05 22:26 UTC (permalink / raw)
  To: linux-media, linux-sh
  Cc: magnus.damm, horms, g.liakhovetski, linux-kernel, Ben Dooks

Add nodes for the four video input channels on the R8A7790.

Signed-off-by: Ben Dooks <ben.dooks@codethink.co.uk>
---
 arch/arm/boot/dts/r8a7790.dtsi | 36 ++++++++++++++++++++++++++++++++++++
 1 file changed, 36 insertions(+)

diff --git a/arch/arm/boot/dts/r8a7790.dtsi b/arch/arm/boot/dts/r8a7790.dtsi
index 7ff2960..a6f083d 100644
--- a/arch/arm/boot/dts/r8a7790.dtsi
+++ b/arch/arm/boot/dts/r8a7790.dtsi
@@ -33,6 +33,10 @@
 		spi2 = &msiof1;
 		spi3 = &msiof2;
 		spi4 = &msiof3;
+		vin0 = &vin0;
+		vin1 = &vin1;
+		vin2 = &vin2;
+		vin3 = &vin3;
 	};
 
 	cpus {
@@ -462,6 +466,38 @@
 		status = "disabled";
 	};
 
+	vin0: vin@e6ef0000 {
+		compatible = "renesas,vin-r8a7790";
+		clocks = <&mstp8_clks R8A7790_CLK_VIN0>;
+		reg = <0 0xe6ef0000 0 0x1000>;
+		interrupts = <0 188 IRQ_TYPE_LEVEL_HIGH>;
+		status = "disabled";
+	};
+
+	vin1: vin@e6ef1000 {
+		compatible = "renesas,vin-r8a7790";
+		clocks = <&mstp8_clks R8A7790_CLK_VIN1>;
+		reg = <0 0xe6ef1000 0 0x1000>;
+		interrupts = <0 189 IRQ_TYPE_LEVEL_HIGH>;
+		status = "disabled";
+	};
+
+	vin2: vin@e6ef2000 {
+		compatible = "renesas,vin-r8a7790";
+		clocks = <&mstp8_clks R8A7790_CLK_VIN2>;
+		reg = <0 0xe6ef2000 0 0x1000>;
+		interrupts = <0 190 IRQ_TYPE_LEVEL_HIGH>;
+		status = "disabled";
+	};
+
+	vin3: vin@e6ef3000 {
+		compatible = "renesas,vin-r8a7790";
+		clocks = <&mstp8_clks R8A7790_CLK_VIN3>;
+		reg = <0 0xe6ef3000 0 0x1000>;
+		interrupts = <0 191 IRQ_TYPE_LEVEL_HIGH>;
+		status = "disabled";
+	};
+
 	clocks {
 		#address-cells = <2>;
 		#size-cells = <2>;
-- 
2.0.0


^ permalink raw reply related	[flat|nested] 34+ messages in thread

* [PATCH 5/6] r8a7790.dtsi: add vin[0-3] nodes
@ 2014-07-05 22:26   ` Ben Dooks
  0 siblings, 0 replies; 34+ messages in thread
From: Ben Dooks @ 2014-07-05 22:26 UTC (permalink / raw)
  To: linux-media, linux-sh
  Cc: magnus.damm, horms, g.liakhovetski, linux-kernel, Ben Dooks

Add nodes for the four video input channels on the R8A7790.

Signed-off-by: Ben Dooks <ben.dooks@codethink.co.uk>
---
 arch/arm/boot/dts/r8a7790.dtsi | 36 ++++++++++++++++++++++++++++++++++++
 1 file changed, 36 insertions(+)

diff --git a/arch/arm/boot/dts/r8a7790.dtsi b/arch/arm/boot/dts/r8a7790.dtsi
index 7ff2960..a6f083d 100644
--- a/arch/arm/boot/dts/r8a7790.dtsi
+++ b/arch/arm/boot/dts/r8a7790.dtsi
@@ -33,6 +33,10 @@
 		spi2 = &msiof1;
 		spi3 = &msiof2;
 		spi4 = &msiof3;
+		vin0 = &vin0;
+		vin1 = &vin1;
+		vin2 = &vin2;
+		vin3 = &vin3;
 	};
 
 	cpus {
@@ -462,6 +466,38 @@
 		status = "disabled";
 	};
 
+	vin0: vin@e6ef0000 {
+		compatible = "renesas,vin-r8a7790";
+		clocks = <&mstp8_clks R8A7790_CLK_VIN0>;
+		reg = <0 0xe6ef0000 0 0x1000>;
+		interrupts = <0 188 IRQ_TYPE_LEVEL_HIGH>;
+		status = "disabled";
+	};
+
+	vin1: vin@e6ef1000 {
+		compatible = "renesas,vin-r8a7790";
+		clocks = <&mstp8_clks R8A7790_CLK_VIN1>;
+		reg = <0 0xe6ef1000 0 0x1000>;
+		interrupts = <0 189 IRQ_TYPE_LEVEL_HIGH>;
+		status = "disabled";
+	};
+
+	vin2: vin@e6ef2000 {
+		compatible = "renesas,vin-r8a7790";
+		clocks = <&mstp8_clks R8A7790_CLK_VIN2>;
+		reg = <0 0xe6ef2000 0 0x1000>;
+		interrupts = <0 190 IRQ_TYPE_LEVEL_HIGH>;
+		status = "disabled";
+	};
+
+	vin3: vin@e6ef3000 {
+		compatible = "renesas,vin-r8a7790";
+		clocks = <&mstp8_clks R8A7790_CLK_VIN3>;
+		reg = <0 0xe6ef3000 0 0x1000>;
+		interrupts = <0 191 IRQ_TYPE_LEVEL_HIGH>;
+		status = "disabled";
+	};
+
 	clocks {
 		#address-cells = <2>;
 		#size-cells = <2>;
-- 
2.0.0


^ permalink raw reply related	[flat|nested] 34+ messages in thread

* [PATCH 6/6] [PATCH v2] ARM: lager: add vin1 node
  2014-07-05 22:26 ` Ben Dooks
@ 2014-07-05 22:26   ` Ben Dooks
  -1 siblings, 0 replies; 34+ messages in thread
From: Ben Dooks @ 2014-07-05 22:26 UTC (permalink / raw)
  To: linux-media, linux-sh
  Cc: magnus.damm, horms, g.liakhovetski, linux-kernel, Ben Dooks

Add device-tree for vin1 (composite video in) on the
lager board.

Signed-off-by: Ben Dooks <ben.dooks@codethink.co.uk>
---

Fixes since v1:
	- Whitespace fixes as suggested by Sergei
---
 arch/arm/boot/dts/r8a7790-lager.dts | 36 ++++++++++++++++++++++++++++++++++++
 1 file changed, 36 insertions(+)

diff --git a/arch/arm/boot/dts/r8a7790-lager.dts b/arch/arm/boot/dts/r8a7790-lager.dts
index 4805c9f..e00543b 100644
--- a/arch/arm/boot/dts/r8a7790-lager.dts
+++ b/arch/arm/boot/dts/r8a7790-lager.dts
@@ -214,6 +214,11 @@
 		renesas,groups = "i2c2";
 		renesas,function = "i2c2";
 	};
+
+	vin1_pins: vin {
+		renesas,groups = "vin1_data8", "vin1_clk";
+		renesas,function = "vin1";
+	};
 };
 
 &ether {
@@ -342,8 +347,39 @@
 	status = "ok";
 	pinctrl-0 = <&i2c2_pins>;
 	pinctrl-names = "default";
+
+	composite-in@20 {
+		compatible = "adi,adv7180";
+		reg = <0x20>;
+		remote = <&vin1>;
+
+		port {
+			adv7180: endpoint {
+				bus-width = <8>;
+				remote-endpoint = <&vin1ep0>;
+			};
+		};
+	};
 };
 
 &i2c3	{
 	status = "ok";
 };
+
+/* composite video input */
+&vin1 {
+	pinctrl-0 = <&vin1_pins>;
+	pinctrl-names = "default";
+
+	status = "ok";
+
+	port {
+		#address-cells = <1>;
+		#size-cells = <0>;
+
+		vin1ep0: endpoint {
+			remote-endpoint = <&adv7180>;
+			bus-width = <8>;
+		};
+	};
+};
-- 
2.0.0


^ permalink raw reply related	[flat|nested] 34+ messages in thread

* [PATCH 6/6] [PATCH v2] ARM: lager: add vin1 node
@ 2014-07-05 22:26   ` Ben Dooks
  0 siblings, 0 replies; 34+ messages in thread
From: Ben Dooks @ 2014-07-05 22:26 UTC (permalink / raw)
  To: linux-media, linux-sh
  Cc: magnus.damm, horms, g.liakhovetski, linux-kernel, Ben Dooks

Add device-tree for vin1 (composite video in) on the
lager board.

Signed-off-by: Ben Dooks <ben.dooks@codethink.co.uk>
---

Fixes since v1:
	- Whitespace fixes as suggested by Sergei
---
 arch/arm/boot/dts/r8a7790-lager.dts | 36 ++++++++++++++++++++++++++++++++++++
 1 file changed, 36 insertions(+)

diff --git a/arch/arm/boot/dts/r8a7790-lager.dts b/arch/arm/boot/dts/r8a7790-lager.dts
index 4805c9f..e00543b 100644
--- a/arch/arm/boot/dts/r8a7790-lager.dts
+++ b/arch/arm/boot/dts/r8a7790-lager.dts
@@ -214,6 +214,11 @@
 		renesas,groups = "i2c2";
 		renesas,function = "i2c2";
 	};
+
+	vin1_pins: vin {
+		renesas,groups = "vin1_data8", "vin1_clk";
+		renesas,function = "vin1";
+	};
 };
 
 &ether {
@@ -342,8 +347,39 @@
 	status = "ok";
 	pinctrl-0 = <&i2c2_pins>;
 	pinctrl-names = "default";
+
+	composite-in@20 {
+		compatible = "adi,adv7180";
+		reg = <0x20>;
+		remote = <&vin1>;
+
+		port {
+			adv7180: endpoint {
+				bus-width = <8>;
+				remote-endpoint = <&vin1ep0>;
+			};
+		};
+	};
 };
 
 &i2c3	{
 	status = "ok";
 };
+
+/* composite video input */
+&vin1 {
+	pinctrl-0 = <&vin1_pins>;
+	pinctrl-names = "default";
+
+	status = "ok";
+
+	port {
+		#address-cells = <1>;
+		#size-cells = <0>;
+
+		vin1ep0: endpoint {
+			remote-endpoint = <&adv7180>;
+			bus-width = <8>;
+		};
+	};
+};
-- 
2.0.0


^ permalink raw reply related	[flat|nested] 34+ messages in thread

* Re: [PATCH 1/6] adv7180: Remove duplicate unregister call
  2014-07-05 22:26   ` Ben Dooks
@ 2014-07-17  7:37     ` Hans Verkuil
  -1 siblings, 0 replies; 34+ messages in thread
From: Hans Verkuil @ 2014-07-17  7:37 UTC (permalink / raw)
  To: Ben Dooks, linux-media, linux-sh
  Cc: magnus.damm, horms, g.liakhovetski, linux-kernel, Ian Molton

On 07/06/2014 12:26 AM, Ben Dooks wrote:
> From: Ian Molton <ian.molton@codethink.co.uk>
> 
> This driver moved over to v4l2_async_unregister_subdev()
> but still retained a call to v4l2_unregister_subdev(). Remove.
> 
> Signed-off-by: Ian Molton <ian.molton@codethink.co.uk>
> Signed-off-by: Ben Dooks <ben.dooks@codethink.co.uk>

Acked-by: Hans Verkuil <hans.verkuil@cisco.com>

Thanks,

	Hans

> ---
>  drivers/media/i2c/adv7180.c | 1 -
>  1 file changed, 1 deletion(-)
> 
> diff --git a/drivers/media/i2c/adv7180.c b/drivers/media/i2c/adv7180.c
> index ac1cdbe..821178d 100644
> --- a/drivers/media/i2c/adv7180.c
> +++ b/drivers/media/i2c/adv7180.c
> @@ -663,7 +663,6 @@ static int adv7180_remove(struct i2c_client *client)
>  	if (state->irq > 0)
>  		free_irq(client->irq, state);
>  
> -	v4l2_device_unregister_subdev(sd);
>  	adv7180_exit_controls(state);
>  	mutex_destroy(&state->mutex);
>  	return 0;
> 


^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: [PATCH 1/6] adv7180: Remove duplicate unregister call
@ 2014-07-17  7:37     ` Hans Verkuil
  0 siblings, 0 replies; 34+ messages in thread
From: Hans Verkuil @ 2014-07-17  7:37 UTC (permalink / raw)
  To: Ben Dooks, linux-media, linux-sh
  Cc: magnus.damm, horms, g.liakhovetski, linux-kernel, Ian Molton

On 07/06/2014 12:26 AM, Ben Dooks wrote:
> From: Ian Molton <ian.molton@codethink.co.uk>
> 
> This driver moved over to v4l2_async_unregister_subdev()
> but still retained a call to v4l2_unregister_subdev(). Remove.
> 
> Signed-off-by: Ian Molton <ian.molton@codethink.co.uk>
> Signed-off-by: Ben Dooks <ben.dooks@codethink.co.uk>

Acked-by: Hans Verkuil <hans.verkuil@cisco.com>

Thanks,

	Hans

> ---
>  drivers/media/i2c/adv7180.c | 1 -
>  1 file changed, 1 deletion(-)
> 
> diff --git a/drivers/media/i2c/adv7180.c b/drivers/media/i2c/adv7180.c
> index ac1cdbe..821178d 100644
> --- a/drivers/media/i2c/adv7180.c
> +++ b/drivers/media/i2c/adv7180.c
> @@ -663,7 +663,6 @@ static int adv7180_remove(struct i2c_client *client)
>  	if (state->irq > 0)
>  		free_irq(client->irq, state);
>  
> -	v4l2_device_unregister_subdev(sd);
>  	adv7180_exit_controls(state);
>  	mutex_destroy(&state->mutex);
>  	return 0;
> 


^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: [PATCH 5/6] r8a7790.dtsi: add vin[0-3] nodes
  2014-07-05 22:26   ` Ben Dooks
@ 2014-07-23  8:09     ` Guennadi Liakhovetski
  -1 siblings, 0 replies; 34+ messages in thread
From: Guennadi Liakhovetski @ 2014-07-23  8:09 UTC (permalink / raw)
  To: Ben Dooks; +Cc: linux-media, linux-sh, magnus.damm, horms, linux-kernel

Hi Ben,

Who is going to take this patch? Simon? It can go in independently from 
the V4L part, right? We just have to be sure, that bindings don't have to 
change, and this is likely to be the case. Doesn't it have to be Cc'ed to 
DT maintainers and the list?

Thanks
Guennadi

On Sat, 5 Jul 2014, Ben Dooks wrote:

> Add nodes for the four video input channels on the R8A7790.
> 
> Signed-off-by: Ben Dooks <ben.dooks@codethink.co.uk>
> ---
>  arch/arm/boot/dts/r8a7790.dtsi | 36 ++++++++++++++++++++++++++++++++++++
>  1 file changed, 36 insertions(+)
> 
> diff --git a/arch/arm/boot/dts/r8a7790.dtsi b/arch/arm/boot/dts/r8a7790.dtsi
> index 7ff2960..a6f083d 100644
> --- a/arch/arm/boot/dts/r8a7790.dtsi
> +++ b/arch/arm/boot/dts/r8a7790.dtsi
> @@ -33,6 +33,10 @@
>  		spi2 = &msiof1;
>  		spi3 = &msiof2;
>  		spi4 = &msiof3;
> +		vin0 = &vin0;
> +		vin1 = &vin1;
> +		vin2 = &vin2;
> +		vin3 = &vin3;
>  	};
>  
>  	cpus {
> @@ -462,6 +466,38 @@
>  		status = "disabled";
>  	};
>  
> +	vin0: vin@e6ef0000 {
> +		compatible = "renesas,vin-r8a7790";
> +		clocks = <&mstp8_clks R8A7790_CLK_VIN0>;
> +		reg = <0 0xe6ef0000 0 0x1000>;
> +		interrupts = <0 188 IRQ_TYPE_LEVEL_HIGH>;
> +		status = "disabled";
> +	};
> +
> +	vin1: vin@e6ef1000 {
> +		compatible = "renesas,vin-r8a7790";
> +		clocks = <&mstp8_clks R8A7790_CLK_VIN1>;
> +		reg = <0 0xe6ef1000 0 0x1000>;
> +		interrupts = <0 189 IRQ_TYPE_LEVEL_HIGH>;
> +		status = "disabled";
> +	};
> +
> +	vin2: vin@e6ef2000 {
> +		compatible = "renesas,vin-r8a7790";
> +		clocks = <&mstp8_clks R8A7790_CLK_VIN2>;
> +		reg = <0 0xe6ef2000 0 0x1000>;
> +		interrupts = <0 190 IRQ_TYPE_LEVEL_HIGH>;
> +		status = "disabled";
> +	};
> +
> +	vin3: vin@e6ef3000 {
> +		compatible = "renesas,vin-r8a7790";
> +		clocks = <&mstp8_clks R8A7790_CLK_VIN3>;
> +		reg = <0 0xe6ef3000 0 0x1000>;
> +		interrupts = <0 191 IRQ_TYPE_LEVEL_HIGH>;
> +		status = "disabled";
> +	};
> +
>  	clocks {
>  		#address-cells = <2>;
>  		#size-cells = <2>;
> -- 
> 2.0.0
> 

^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: [PATCH 5/6] r8a7790.dtsi: add vin[0-3] nodes
@ 2014-07-23  8:09     ` Guennadi Liakhovetski
  0 siblings, 0 replies; 34+ messages in thread
From: Guennadi Liakhovetski @ 2014-07-23  8:09 UTC (permalink / raw)
  To: Ben Dooks; +Cc: linux-media, linux-sh, magnus.damm, horms, linux-kernel

Hi Ben,

Who is going to take this patch? Simon? It can go in independently from 
the V4L part, right? We just have to be sure, that bindings don't have to 
change, and this is likely to be the case. Doesn't it have to be Cc'ed to 
DT maintainers and the list?

Thanks
Guennadi

On Sat, 5 Jul 2014, Ben Dooks wrote:

> Add nodes for the four video input channels on the R8A7790.
> 
> Signed-off-by: Ben Dooks <ben.dooks@codethink.co.uk>
> ---
>  arch/arm/boot/dts/r8a7790.dtsi | 36 ++++++++++++++++++++++++++++++++++++
>  1 file changed, 36 insertions(+)
> 
> diff --git a/arch/arm/boot/dts/r8a7790.dtsi b/arch/arm/boot/dts/r8a7790.dtsi
> index 7ff2960..a6f083d 100644
> --- a/arch/arm/boot/dts/r8a7790.dtsi
> +++ b/arch/arm/boot/dts/r8a7790.dtsi
> @@ -33,6 +33,10 @@
>  		spi2 = &msiof1;
>  		spi3 = &msiof2;
>  		spi4 = &msiof3;
> +		vin0 = &vin0;
> +		vin1 = &vin1;
> +		vin2 = &vin2;
> +		vin3 = &vin3;
>  	};
>  
>  	cpus {
> @@ -462,6 +466,38 @@
>  		status = "disabled";
>  	};
>  
> +	vin0: vin@e6ef0000 {
> +		compatible = "renesas,vin-r8a7790";
> +		clocks = <&mstp8_clks R8A7790_CLK_VIN0>;
> +		reg = <0 0xe6ef0000 0 0x1000>;
> +		interrupts = <0 188 IRQ_TYPE_LEVEL_HIGH>;
> +		status = "disabled";
> +	};
> +
> +	vin1: vin@e6ef1000 {
> +		compatible = "renesas,vin-r8a7790";
> +		clocks = <&mstp8_clks R8A7790_CLK_VIN1>;
> +		reg = <0 0xe6ef1000 0 0x1000>;
> +		interrupts = <0 189 IRQ_TYPE_LEVEL_HIGH>;
> +		status = "disabled";
> +	};
> +
> +	vin2: vin@e6ef2000 {
> +		compatible = "renesas,vin-r8a7790";
> +		clocks = <&mstp8_clks R8A7790_CLK_VIN2>;
> +		reg = <0 0xe6ef2000 0 0x1000>;
> +		interrupts = <0 190 IRQ_TYPE_LEVEL_HIGH>;
> +		status = "disabled";
> +	};
> +
> +	vin3: vin@e6ef3000 {
> +		compatible = "renesas,vin-r8a7790";
> +		clocks = <&mstp8_clks R8A7790_CLK_VIN3>;
> +		reg = <0 0xe6ef3000 0 0x1000>;
> +		interrupts = <0 191 IRQ_TYPE_LEVEL_HIGH>;
> +		status = "disabled";
> +	};
> +
>  	clocks {
>  		#address-cells = <2>;
>  		#size-cells = <2>;
> -- 
> 2.0.0
> 

^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: [PATCH 6/6] [PATCH v2] ARM: lager: add vin1 node
  2014-07-05 22:26   ` Ben Dooks
@ 2014-07-23  8:11     ` Guennadi Liakhovetski
  -1 siblings, 0 replies; 34+ messages in thread
From: Guennadi Liakhovetski @ 2014-07-23  8:11 UTC (permalink / raw)
  To: Ben Dooks; +Cc: linux-media, linux-sh, magnus.damm, horms, linux-kernel

Same for this one - who takes it and is CC sufficient?

Thanks
Guennadi

On Sat, 5 Jul 2014, Ben Dooks wrote:

> Add device-tree for vin1 (composite video in) on the
> lager board.
> 
> Signed-off-by: Ben Dooks <ben.dooks@codethink.co.uk>
> ---
> 
> Fixes since v1:
> 	- Whitespace fixes as suggested by Sergei
> ---
>  arch/arm/boot/dts/r8a7790-lager.dts | 36 ++++++++++++++++++++++++++++++++++++
>  1 file changed, 36 insertions(+)
> 
> diff --git a/arch/arm/boot/dts/r8a7790-lager.dts b/arch/arm/boot/dts/r8a7790-lager.dts
> index 4805c9f..e00543b 100644
> --- a/arch/arm/boot/dts/r8a7790-lager.dts
> +++ b/arch/arm/boot/dts/r8a7790-lager.dts
> @@ -214,6 +214,11 @@
>  		renesas,groups = "i2c2";
>  		renesas,function = "i2c2";
>  	};
> +
> +	vin1_pins: vin {
> +		renesas,groups = "vin1_data8", "vin1_clk";
> +		renesas,function = "vin1";
> +	};
>  };
>  
>  &ether {
> @@ -342,8 +347,39 @@
>  	status = "ok";
>  	pinctrl-0 = <&i2c2_pins>;
>  	pinctrl-names = "default";
> +
> +	composite-in@20 {
> +		compatible = "adi,adv7180";
> +		reg = <0x20>;
> +		remote = <&vin1>;
> +
> +		port {
> +			adv7180: endpoint {
> +				bus-width = <8>;
> +				remote-endpoint = <&vin1ep0>;
> +			};
> +		};
> +	};
>  };
>  
>  &i2c3	{
>  	status = "ok";
>  };
> +
> +/* composite video input */
> +&vin1 {
> +	pinctrl-0 = <&vin1_pins>;
> +	pinctrl-names = "default";
> +
> +	status = "ok";
> +
> +	port {
> +		#address-cells = <1>;
> +		#size-cells = <0>;
> +
> +		vin1ep0: endpoint {
> +			remote-endpoint = <&adv7180>;
> +			bus-width = <8>;
> +		};
> +	};
> +};
> -- 
> 2.0.0
> 

^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: [PATCH 6/6] [PATCH v2] ARM: lager: add vin1 node
@ 2014-07-23  8:11     ` Guennadi Liakhovetski
  0 siblings, 0 replies; 34+ messages in thread
From: Guennadi Liakhovetski @ 2014-07-23  8:11 UTC (permalink / raw)
  To: Ben Dooks; +Cc: linux-media, linux-sh, magnus.damm, horms, linux-kernel

Same for this one - who takes it and is CC sufficient?

Thanks
Guennadi

On Sat, 5 Jul 2014, Ben Dooks wrote:

> Add device-tree for vin1 (composite video in) on the
> lager board.
> 
> Signed-off-by: Ben Dooks <ben.dooks@codethink.co.uk>
> ---
> 
> Fixes since v1:
> 	- Whitespace fixes as suggested by Sergei
> ---
>  arch/arm/boot/dts/r8a7790-lager.dts | 36 ++++++++++++++++++++++++++++++++++++
>  1 file changed, 36 insertions(+)
> 
> diff --git a/arch/arm/boot/dts/r8a7790-lager.dts b/arch/arm/boot/dts/r8a7790-lager.dts
> index 4805c9f..e00543b 100644
> --- a/arch/arm/boot/dts/r8a7790-lager.dts
> +++ b/arch/arm/boot/dts/r8a7790-lager.dts
> @@ -214,6 +214,11 @@
>  		renesas,groups = "i2c2";
>  		renesas,function = "i2c2";
>  	};
> +
> +	vin1_pins: vin {
> +		renesas,groups = "vin1_data8", "vin1_clk";
> +		renesas,function = "vin1";
> +	};
>  };
>  
>  &ether {
> @@ -342,8 +347,39 @@
>  	status = "ok";
>  	pinctrl-0 = <&i2c2_pins>;
>  	pinctrl-names = "default";
> +
> +	composite-in@20 {
> +		compatible = "adi,adv7180";
> +		reg = <0x20>;
> +		remote = <&vin1>;
> +
> +		port {
> +			adv7180: endpoint {
> +				bus-width = <8>;
> +				remote-endpoint = <&vin1ep0>;
> +			};
> +		};
> +	};
>  };
>  
>  &i2c3	{
>  	status = "ok";
>  };
> +
> +/* composite video input */
> +&vin1 {
> +	pinctrl-0 = <&vin1_pins>;
> +	pinctrl-names = "default";
> +
> +	status = "ok";
> +
> +	port {
> +		#address-cells = <1>;
> +		#size-cells = <0>;
> +
> +		vin1ep0: endpoint {
> +			remote-endpoint = <&adv7180>;
> +			bus-width = <8>;
> +		};
> +	};
> +};
> -- 
> 2.0.0
> 

^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: [PATCH 5/6] r8a7790.dtsi: add vin[0-3] nodes
  2014-07-23  8:09     ` Guennadi Liakhovetski
@ 2014-07-23  8:40       ` Simon Horman
  -1 siblings, 0 replies; 34+ messages in thread
From: Simon Horman @ 2014-07-23  8:40 UTC (permalink / raw)
  To: Guennadi Liakhovetski
  Cc: Ben Dooks, linux-media, linux-sh, magnus.damm, linux-kernel

On Wed, Jul 23, 2014 at 10:09:46AM +0200, Guennadi Liakhovetski wrote:
> Hi Ben,
> 
> Who is going to take this patch? Simon? It can go in independently from 
> the V4L part, right? We just have to be sure, that bindings don't have to 
> change, and this is likely to be the case. Doesn't it have to be Cc'ed to 
> DT maintainers and the list?

Hi Guennadi,

my expectation is that I will take this and patch once the bindings have
been accepted by the subsystem maintainer.

For the board DT change my expectation is as above plus that
someone has independently tested that the device is initialised
and usable (for some definition of usable).

With regards to CCing DT maintainers, I believe that they like to be CCed
on driver changes that add or update bindings. I'm unsure if they also like
to be CCed on DT file changes. Its not something I've blocked on in the
past with regards to DT file changes.

> Thanks
> Guennadi
> 
> On Sat, 5 Jul 2014, Ben Dooks wrote:
> 
> > Add nodes for the four video input channels on the R8A7790.
> > 
> > Signed-off-by: Ben Dooks <ben.dooks@codethink.co.uk>
> > ---
> >  arch/arm/boot/dts/r8a7790.dtsi | 36 ++++++++++++++++++++++++++++++++++++
> >  1 file changed, 36 insertions(+)
> > 
> > diff --git a/arch/arm/boot/dts/r8a7790.dtsi b/arch/arm/boot/dts/r8a7790.dtsi
> > index 7ff2960..a6f083d 100644
> > --- a/arch/arm/boot/dts/r8a7790.dtsi
> > +++ b/arch/arm/boot/dts/r8a7790.dtsi
> > @@ -33,6 +33,10 @@
> >  		spi2 = &msiof1;
> >  		spi3 = &msiof2;
> >  		spi4 = &msiof3;
> > +		vin0 = &vin0;
> > +		vin1 = &vin1;
> > +		vin2 = &vin2;
> > +		vin3 = &vin3;
> >  	};
> >  
> >  	cpus {
> > @@ -462,6 +466,38 @@
> >  		status = "disabled";
> >  	};
> >  
> > +	vin0: vin@e6ef0000 {
> > +		compatible = "renesas,vin-r8a7790";
> > +		clocks = <&mstp8_clks R8A7790_CLK_VIN0>;
> > +		reg = <0 0xe6ef0000 0 0x1000>;
> > +		interrupts = <0 188 IRQ_TYPE_LEVEL_HIGH>;
> > +		status = "disabled";
> > +	};
> > +
> > +	vin1: vin@e6ef1000 {
> > +		compatible = "renesas,vin-r8a7790";
> > +		clocks = <&mstp8_clks R8A7790_CLK_VIN1>;
> > +		reg = <0 0xe6ef1000 0 0x1000>;
> > +		interrupts = <0 189 IRQ_TYPE_LEVEL_HIGH>;
> > +		status = "disabled";
> > +	};
> > +
> > +	vin2: vin@e6ef2000 {
> > +		compatible = "renesas,vin-r8a7790";
> > +		clocks = <&mstp8_clks R8A7790_CLK_VIN2>;
> > +		reg = <0 0xe6ef2000 0 0x1000>;
> > +		interrupts = <0 190 IRQ_TYPE_LEVEL_HIGH>;
> > +		status = "disabled";
> > +	};
> > +
> > +	vin3: vin@e6ef3000 {
> > +		compatible = "renesas,vin-r8a7790";
> > +		clocks = <&mstp8_clks R8A7790_CLK_VIN3>;
> > +		reg = <0 0xe6ef3000 0 0x1000>;
> > +		interrupts = <0 191 IRQ_TYPE_LEVEL_HIGH>;
> > +		status = "disabled";
> > +	};
> > +
> >  	clocks {
> >  		#address-cells = <2>;
> >  		#size-cells = <2>;
> > -- 
> > 2.0.0
> > 
> 

^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: [PATCH 5/6] r8a7790.dtsi: add vin[0-3] nodes
@ 2014-07-23  8:40       ` Simon Horman
  0 siblings, 0 replies; 34+ messages in thread
From: Simon Horman @ 2014-07-23  8:40 UTC (permalink / raw)
  To: Guennadi Liakhovetski
  Cc: Ben Dooks, linux-media, linux-sh, magnus.damm, linux-kernel

On Wed, Jul 23, 2014 at 10:09:46AM +0200, Guennadi Liakhovetski wrote:
> Hi Ben,
> 
> Who is going to take this patch? Simon? It can go in independently from 
> the V4L part, right? We just have to be sure, that bindings don't have to 
> change, and this is likely to be the case. Doesn't it have to be Cc'ed to 
> DT maintainers and the list?

Hi Guennadi,

my expectation is that I will take this and patch once the bindings have
been accepted by the subsystem maintainer.

For the board DT change my expectation is as above plus that
someone has independently tested that the device is initialised
and usable (for some definition of usable).

With regards to CCing DT maintainers, I believe that they like to be CCed
on driver changes that add or update bindings. I'm unsure if they also like
to be CCed on DT file changes. Its not something I've blocked on in the
past with regards to DT file changes.

> Thanks
> Guennadi
> 
> On Sat, 5 Jul 2014, Ben Dooks wrote:
> 
> > Add nodes for the four video input channels on the R8A7790.
> > 
> > Signed-off-by: Ben Dooks <ben.dooks@codethink.co.uk>
> > ---
> >  arch/arm/boot/dts/r8a7790.dtsi | 36 ++++++++++++++++++++++++++++++++++++
> >  1 file changed, 36 insertions(+)
> > 
> > diff --git a/arch/arm/boot/dts/r8a7790.dtsi b/arch/arm/boot/dts/r8a7790.dtsi
> > index 7ff2960..a6f083d 100644
> > --- a/arch/arm/boot/dts/r8a7790.dtsi
> > +++ b/arch/arm/boot/dts/r8a7790.dtsi
> > @@ -33,6 +33,10 @@
> >  		spi2 = &msiof1;
> >  		spi3 = &msiof2;
> >  		spi4 = &msiof3;
> > +		vin0 = &vin0;
> > +		vin1 = &vin1;
> > +		vin2 = &vin2;
> > +		vin3 = &vin3;
> >  	};
> >  
> >  	cpus {
> > @@ -462,6 +466,38 @@
> >  		status = "disabled";
> >  	};
> >  
> > +	vin0: vin@e6ef0000 {
> > +		compatible = "renesas,vin-r8a7790";
> > +		clocks = <&mstp8_clks R8A7790_CLK_VIN0>;
> > +		reg = <0 0xe6ef0000 0 0x1000>;
> > +		interrupts = <0 188 IRQ_TYPE_LEVEL_HIGH>;
> > +		status = "disabled";
> > +	};
> > +
> > +	vin1: vin@e6ef1000 {
> > +		compatible = "renesas,vin-r8a7790";
> > +		clocks = <&mstp8_clks R8A7790_CLK_VIN1>;
> > +		reg = <0 0xe6ef1000 0 0x1000>;
> > +		interrupts = <0 189 IRQ_TYPE_LEVEL_HIGH>;
> > +		status = "disabled";
> > +	};
> > +
> > +	vin2: vin@e6ef2000 {
> > +		compatible = "renesas,vin-r8a7790";
> > +		clocks = <&mstp8_clks R8A7790_CLK_VIN2>;
> > +		reg = <0 0xe6ef2000 0 0x1000>;
> > +		interrupts = <0 190 IRQ_TYPE_LEVEL_HIGH>;
> > +		status = "disabled";
> > +	};
> > +
> > +	vin3: vin@e6ef3000 {
> > +		compatible = "renesas,vin-r8a7790";
> > +		clocks = <&mstp8_clks R8A7790_CLK_VIN3>;
> > +		reg = <0 0xe6ef3000 0 0x1000>;
> > +		interrupts = <0 191 IRQ_TYPE_LEVEL_HIGH>;
> > +		status = "disabled";
> > +	};
> > +
> >  	clocks {
> >  		#address-cells = <2>;
> >  		#size-cells = <2>;
> > -- 
> > 2.0.0
> > 
> 

^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: [PATCH 3/6] rcar_vin: add devicetree support
  2014-07-05 22:26   ` Ben Dooks
@ 2014-07-23 10:20     ` Guennadi Liakhovetski
  -1 siblings, 0 replies; 34+ messages in thread
From: Guennadi Liakhovetski @ 2014-07-23 10:20 UTC (permalink / raw)
  To: Ben Dooks; +Cc: linux-media, linux-sh, magnus.damm, horms, linux-kernel

Hi Ben,

I'd love to push this for 3.17, but we have to at least show this to DT 
maintainers... Personally, I have one remark:

On Sat, 5 Jul 2014, Ben Dooks wrote:

> Add support for devicetree probe for the rcar-vin
> driver.
> 
> Signed-off-by: Ben Dooks <ben.dooks@codethink.co.uk>
> ---
>  .../devicetree/bindings/media/rcar_vin.txt         | 86 ++++++++++++++++++++++
>  drivers/media/platform/soc_camera/rcar_vin.c       | 72 ++++++++++++++++--
>  2 files changed, 151 insertions(+), 7 deletions(-)
>  create mode 100644 Documentation/devicetree/bindings/media/rcar_vin.txt
> 
> diff --git a/Documentation/devicetree/bindings/media/rcar_vin.txt b/Documentation/devicetree/bindings/media/rcar_vin.txt
> new file mode 100644
> index 0000000..10fefa9
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/media/rcar_vin.txt
> @@ -0,0 +1,86 @@
> +Renesas RCar Video Input driver (rcar_vin)
> +------------------------------------------
> +
> +The rcar_vin device provides video input capabilities for the Renesas R-Car
> +family of devices. The current blocks are always slaves and suppot one input
> +channel which can be either RGB, YUYV or BT656.
> +
> + - compatible: Must be one of the following
> +   - "renesas,vin-r8a7791" for the R8A7791 device
> +   - "renesas,vin-r8a7790" for the R8A7790 device
> +   - "renesas,vin-r8a7779" for the R8A7779 device
> +   - "renesas,vin-r8a7778" for the R8A7778 device
> + - reg: the register base and size for the device registers
> + - interrupts: the interrupt for the device
> + - clocks: Reference to the parent clock
> +
> +Additionally, an alias named vinX will need to be created to specify
> +which video input device this is.
> +
> +The per-board settings:
> + - port sub-node describing a single endpoint connected to the vin
> +   as described in video-interfaces.txt[1]. Only the first one will
> +   be considered as each vin interface has one input port.
> +
> +   These settings are used to work out video input format and widths
> +   into the system.
> +
> +
> +Device node example
> +-------------------
> +
> +	aliases {
> +	       vin0 = &vin0;
> +	};
> +
> +        vin0: vin@0xe6ef0000 {
> +                compatible = "renesas,vin-r8a7790";
> +                clocks = <&mstp8_clks R8A7790_CLK_VIN0>;
> +                reg = <0 0xe6ef0000 0 0x1000>;
> +                interrupts = <0 188 IRQ_TYPE_LEVEL_HIGH>;
> +                status = "disabled";
> +        };
> +
> +Board setup example (vin1 composite video input)
> +------------------------------------------------
> +
> +&i2c2   {
> +        status = "ok";
> +        pinctrl-0 = <&i2c2_pins>;
> +        pinctrl-names = "default";
> +
> +        adv7180@020 {

The above should be

> +        adv7180@20 {

no "0" in the I2C address. 020 looks like an octal number, which it isn't. 
I'll fix this and try to resubmit today with extended Cc.

Thanks
Guennadi

> +                compatible = "adi,adv7180";
> +                reg = <0x20>;
> +                remote = <&vin1>;
> +
> +                port {
> +                        adv7180: endpoint {
> +                                bus-width = <8>;
> +                                remote-endpoint = <&vin1ep0>;
> +                        };
> +                };
> +        };
> +};
> +
> +/* composite video input */
> +&vin1 {
> +        pinctrl-0 = <&vin1_pins>;
> +        pinctrl-names = "default";
> +
> +        status = "ok";
> +
> +        port {
> +                #address-cells = <1>;
> +                #size-cells = <0>;
> +
> +                vin1ep0: endpoint {
> +                        remote-endpoint = <&adv7180>;
> +                        bus-width = <8>;
> +                };
> +        };
> +};
> +
> +
> +
> +[1] video-interfaces.txt common video media interface
> diff --git a/drivers/media/platform/soc_camera/rcar_vin.c b/drivers/media/platform/soc_camera/rcar_vin.c
> index 7c4299d..eb196ef 100644
> --- a/drivers/media/platform/soc_camera/rcar_vin.c
> +++ b/drivers/media/platform/soc_camera/rcar_vin.c
> @@ -24,6 +24,8 @@
>  #include <linux/pm_runtime.h>
>  #include <linux/slab.h>
>  #include <linux/videodev2.h>
> +#include <linux/of.h>
> +#include <linux/of_device.h>
>  
>  #include <media/soc_camera.h>
>  #include <media/soc_mediabus.h>
> @@ -32,6 +34,7 @@
>  #include <media/v4l2-device.h>
>  #include <media/v4l2-mediabus.h>
>  #include <media/v4l2-subdev.h>
> +#include <media/v4l2-of.h>
>  #include <media/videobuf2-dma-contig.h>
>  
>  #include "soc_scale_crop.h"
> @@ -1390,6 +1393,17 @@ static struct soc_camera_host_ops rcar_vin_host_ops = {
>  	.init_videobuf2	= rcar_vin_init_videobuf2,
>  };
>  
> +#ifdef CONFIG_OF
> +static struct of_device_id rcar_vin_of_table[] = {
> +	{ .compatible = "renesas,vin-r8a7791", .data = (void *)RCAR_GEN2 },
> +	{ .compatible = "renesas,vin-r8a7790", .data = (void *)RCAR_GEN2 },
> +	{ .compatible = "renesas,vin-r8a7779", .data = (void *)RCAR_H1 },
> +	{ .compatible = "renesas,vin-r8a7778", .data = (void *)RCAR_M1 },
> +	{ },
> +};
> +MODULE_DEVICE_TABLE(of, rcar_vin_of_table);
> +#endif
> +
>  static struct platform_device_id rcar_vin_id_table[] = {
>  	{ "r8a7791-vin",  RCAR_GEN2 },
>  	{ "r8a7790-vin",  RCAR_GEN2 },
> @@ -1402,15 +1416,52 @@ MODULE_DEVICE_TABLE(platform, rcar_vin_id_table);
>  
>  static int rcar_vin_probe(struct platform_device *pdev)
>  {
> +	const struct of_device_id *match = NULL;
>  	struct rcar_vin_priv *priv;
>  	struct resource *mem;
>  	struct rcar_vin_platform_data *pdata;
> +	unsigned int pdata_flags;
>  	int irq, ret;
>  
> -	pdata = pdev->dev.platform_data;
> -	if (!pdata || !pdata->flags) {
> -		dev_err(&pdev->dev, "platform data not set\n");
> -		return -EINVAL;
> +	if (pdev->dev.of_node) {
> +		struct v4l2_of_endpoint ep;
> +		struct device_node *np;
> +
> +		match = of_match_device(of_match_ptr(rcar_vin_of_table),
> +					&pdev->dev);
> +
> +		np = of_graph_get_next_endpoint(pdev->dev.of_node, NULL);
> +		if (!np) {
> +			dev_err(&pdev->dev, "could not find endpoint\n");
> +			return -EINVAL;
> +		}
> +
> +		ret = v4l2_of_parse_endpoint(np, &ep);
> +		if (ret) {
> +			dev_err(&pdev->dev, "could not parse endpoint\n");
> +			return ret;
> +		}
> +
> +		if (ep.bus_type = V4L2_MBUS_BT656)
> +			pdata_flags = RCAR_VIN_BT656;
> +		else {
> +			pdata_flags = 0;
> +			if (ep.bus.parallel.flags & V4L2_MBUS_HSYNC_ACTIVE_LOW)
> +				pdata_flags |= RCAR_VIN_HSYNC_ACTIVE_LOW;
> +			if (ep.bus.parallel.flags & V4L2_MBUS_VSYNC_ACTIVE_LOW)
> +				pdata_flags |= RCAR_VIN_VSYNC_ACTIVE_LOW;
> +		}
> +
> +		of_node_put(np);
> +
> +		dev_dbg(&pdev->dev, "pdata_flags = %08x\n", pdata_flags);
> +	} else {
> +		pdata = pdev->dev.platform_data;
> +		if (!pdata || !pdata->flags) {
> +			dev_err(&pdev->dev, "platform data not set\n");
> +			return -EINVAL;
> +		}
> +		pdata_flags = pdata->flags;
>  	}
>  
>  	mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> @@ -1441,12 +1492,18 @@ static int rcar_vin_probe(struct platform_device *pdev)
>  
>  	priv->ici.priv = priv;
>  	priv->ici.v4l2_dev.dev = &pdev->dev;
> -	priv->ici.nr = pdev->id;
>  	priv->ici.drv_name = dev_name(&pdev->dev);
>  	priv->ici.ops = &rcar_vin_host_ops;
>  
> -	priv->pdata_flags = pdata->flags;
> -	priv->chip = pdev->id_entry->driver_data;
> +	priv->pdata_flags = pdata_flags;
> +	if (!match) {
> +		priv->ici.nr = pdev->id;
> +		priv->chip = pdev->id_entry->driver_data;
> +	} else {
> +		priv->ici.nr = of_alias_get_id(pdev->dev.of_node, "vin");
> +		priv->chip = (enum chip_id)match->data;
> +	};
> +
>  	spin_lock_init(&priv->lock);
>  	INIT_LIST_HEAD(&priv->capture);
>  
> @@ -1487,6 +1544,7 @@ static struct platform_driver rcar_vin_driver = {
>  	.driver		= {
>  		.name		= DRV_NAME,
>  		.owner		= THIS_MODULE,
> +		.of_match_table	= of_match_ptr(rcar_vin_of_table),
>  	},
>  	.id_table	= rcar_vin_id_table,
>  };
> -- 
> 2.0.0
> 

^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: [PATCH 3/6] rcar_vin: add devicetree support
@ 2014-07-23 10:20     ` Guennadi Liakhovetski
  0 siblings, 0 replies; 34+ messages in thread
From: Guennadi Liakhovetski @ 2014-07-23 10:20 UTC (permalink / raw)
  To: Ben Dooks; +Cc: linux-media, linux-sh, magnus.damm, horms, linux-kernel

Hi Ben,

I'd love to push this for 3.17, but we have to at least show this to DT 
maintainers... Personally, I have one remark:

On Sat, 5 Jul 2014, Ben Dooks wrote:

> Add support for devicetree probe for the rcar-vin
> driver.
> 
> Signed-off-by: Ben Dooks <ben.dooks@codethink.co.uk>
> ---
>  .../devicetree/bindings/media/rcar_vin.txt         | 86 ++++++++++++++++++++++
>  drivers/media/platform/soc_camera/rcar_vin.c       | 72 ++++++++++++++++--
>  2 files changed, 151 insertions(+), 7 deletions(-)
>  create mode 100644 Documentation/devicetree/bindings/media/rcar_vin.txt
> 
> diff --git a/Documentation/devicetree/bindings/media/rcar_vin.txt b/Documentation/devicetree/bindings/media/rcar_vin.txt
> new file mode 100644
> index 0000000..10fefa9
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/media/rcar_vin.txt
> @@ -0,0 +1,86 @@
> +Renesas RCar Video Input driver (rcar_vin)
> +------------------------------------------
> +
> +The rcar_vin device provides video input capabilities for the Renesas R-Car
> +family of devices. The current blocks are always slaves and suppot one input
> +channel which can be either RGB, YUYV or BT656.
> +
> + - compatible: Must be one of the following
> +   - "renesas,vin-r8a7791" for the R8A7791 device
> +   - "renesas,vin-r8a7790" for the R8A7790 device
> +   - "renesas,vin-r8a7779" for the R8A7779 device
> +   - "renesas,vin-r8a7778" for the R8A7778 device
> + - reg: the register base and size for the device registers
> + - interrupts: the interrupt for the device
> + - clocks: Reference to the parent clock
> +
> +Additionally, an alias named vinX will need to be created to specify
> +which video input device this is.
> +
> +The per-board settings:
> + - port sub-node describing a single endpoint connected to the vin
> +   as described in video-interfaces.txt[1]. Only the first one will
> +   be considered as each vin interface has one input port.
> +
> +   These settings are used to work out video input format and widths
> +   into the system.
> +
> +
> +Device node example
> +-------------------
> +
> +	aliases {
> +	       vin0 = &vin0;
> +	};
> +
> +        vin0: vin@0xe6ef0000 {
> +                compatible = "renesas,vin-r8a7790";
> +                clocks = <&mstp8_clks R8A7790_CLK_VIN0>;
> +                reg = <0 0xe6ef0000 0 0x1000>;
> +                interrupts = <0 188 IRQ_TYPE_LEVEL_HIGH>;
> +                status = "disabled";
> +        };
> +
> +Board setup example (vin1 composite video input)
> +------------------------------------------------
> +
> +&i2c2   {
> +        status = "ok";
> +        pinctrl-0 = <&i2c2_pins>;
> +        pinctrl-names = "default";
> +
> +        adv7180@020 {

The above should be

> +        adv7180@20 {

no "0" in the I2C address. 020 looks like an octal number, which it isn't. 
I'll fix this and try to resubmit today with extended Cc.

Thanks
Guennadi

> +                compatible = "adi,adv7180";
> +                reg = <0x20>;
> +                remote = <&vin1>;
> +
> +                port {
> +                        adv7180: endpoint {
> +                                bus-width = <8>;
> +                                remote-endpoint = <&vin1ep0>;
> +                        };
> +                };
> +        };
> +};
> +
> +/* composite video input */
> +&vin1 {
> +        pinctrl-0 = <&vin1_pins>;
> +        pinctrl-names = "default";
> +
> +        status = "ok";
> +
> +        port {
> +                #address-cells = <1>;
> +                #size-cells = <0>;
> +
> +                vin1ep0: endpoint {
> +                        remote-endpoint = <&adv7180>;
> +                        bus-width = <8>;
> +                };
> +        };
> +};
> +
> +
> +
> +[1] video-interfaces.txt common video media interface
> diff --git a/drivers/media/platform/soc_camera/rcar_vin.c b/drivers/media/platform/soc_camera/rcar_vin.c
> index 7c4299d..eb196ef 100644
> --- a/drivers/media/platform/soc_camera/rcar_vin.c
> +++ b/drivers/media/platform/soc_camera/rcar_vin.c
> @@ -24,6 +24,8 @@
>  #include <linux/pm_runtime.h>
>  #include <linux/slab.h>
>  #include <linux/videodev2.h>
> +#include <linux/of.h>
> +#include <linux/of_device.h>
>  
>  #include <media/soc_camera.h>
>  #include <media/soc_mediabus.h>
> @@ -32,6 +34,7 @@
>  #include <media/v4l2-device.h>
>  #include <media/v4l2-mediabus.h>
>  #include <media/v4l2-subdev.h>
> +#include <media/v4l2-of.h>
>  #include <media/videobuf2-dma-contig.h>
>  
>  #include "soc_scale_crop.h"
> @@ -1390,6 +1393,17 @@ static struct soc_camera_host_ops rcar_vin_host_ops = {
>  	.init_videobuf2	= rcar_vin_init_videobuf2,
>  };
>  
> +#ifdef CONFIG_OF
> +static struct of_device_id rcar_vin_of_table[] = {
> +	{ .compatible = "renesas,vin-r8a7791", .data = (void *)RCAR_GEN2 },
> +	{ .compatible = "renesas,vin-r8a7790", .data = (void *)RCAR_GEN2 },
> +	{ .compatible = "renesas,vin-r8a7779", .data = (void *)RCAR_H1 },
> +	{ .compatible = "renesas,vin-r8a7778", .data = (void *)RCAR_M1 },
> +	{ },
> +};
> +MODULE_DEVICE_TABLE(of, rcar_vin_of_table);
> +#endif
> +
>  static struct platform_device_id rcar_vin_id_table[] = {
>  	{ "r8a7791-vin",  RCAR_GEN2 },
>  	{ "r8a7790-vin",  RCAR_GEN2 },
> @@ -1402,15 +1416,52 @@ MODULE_DEVICE_TABLE(platform, rcar_vin_id_table);
>  
>  static int rcar_vin_probe(struct platform_device *pdev)
>  {
> +	const struct of_device_id *match = NULL;
>  	struct rcar_vin_priv *priv;
>  	struct resource *mem;
>  	struct rcar_vin_platform_data *pdata;
> +	unsigned int pdata_flags;
>  	int irq, ret;
>  
> -	pdata = pdev->dev.platform_data;
> -	if (!pdata || !pdata->flags) {
> -		dev_err(&pdev->dev, "platform data not set\n");
> -		return -EINVAL;
> +	if (pdev->dev.of_node) {
> +		struct v4l2_of_endpoint ep;
> +		struct device_node *np;
> +
> +		match = of_match_device(of_match_ptr(rcar_vin_of_table),
> +					&pdev->dev);
> +
> +		np = of_graph_get_next_endpoint(pdev->dev.of_node, NULL);
> +		if (!np) {
> +			dev_err(&pdev->dev, "could not find endpoint\n");
> +			return -EINVAL;
> +		}
> +
> +		ret = v4l2_of_parse_endpoint(np, &ep);
> +		if (ret) {
> +			dev_err(&pdev->dev, "could not parse endpoint\n");
> +			return ret;
> +		}
> +
> +		if (ep.bus_type == V4L2_MBUS_BT656)
> +			pdata_flags = RCAR_VIN_BT656;
> +		else {
> +			pdata_flags = 0;
> +			if (ep.bus.parallel.flags & V4L2_MBUS_HSYNC_ACTIVE_LOW)
> +				pdata_flags |= RCAR_VIN_HSYNC_ACTIVE_LOW;
> +			if (ep.bus.parallel.flags & V4L2_MBUS_VSYNC_ACTIVE_LOW)
> +				pdata_flags |= RCAR_VIN_VSYNC_ACTIVE_LOW;
> +		}
> +
> +		of_node_put(np);
> +
> +		dev_dbg(&pdev->dev, "pdata_flags = %08x\n", pdata_flags);
> +	} else {
> +		pdata = pdev->dev.platform_data;
> +		if (!pdata || !pdata->flags) {
> +			dev_err(&pdev->dev, "platform data not set\n");
> +			return -EINVAL;
> +		}
> +		pdata_flags = pdata->flags;
>  	}
>  
>  	mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> @@ -1441,12 +1492,18 @@ static int rcar_vin_probe(struct platform_device *pdev)
>  
>  	priv->ici.priv = priv;
>  	priv->ici.v4l2_dev.dev = &pdev->dev;
> -	priv->ici.nr = pdev->id;
>  	priv->ici.drv_name = dev_name(&pdev->dev);
>  	priv->ici.ops = &rcar_vin_host_ops;
>  
> -	priv->pdata_flags = pdata->flags;
> -	priv->chip = pdev->id_entry->driver_data;
> +	priv->pdata_flags = pdata_flags;
> +	if (!match) {
> +		priv->ici.nr = pdev->id;
> +		priv->chip = pdev->id_entry->driver_data;
> +	} else {
> +		priv->ici.nr = of_alias_get_id(pdev->dev.of_node, "vin");
> +		priv->chip = (enum chip_id)match->data;
> +	};
> +
>  	spin_lock_init(&priv->lock);
>  	INIT_LIST_HEAD(&priv->capture);
>  
> @@ -1487,6 +1544,7 @@ static struct platform_driver rcar_vin_driver = {
>  	.driver		= {
>  		.name		= DRV_NAME,
>  		.owner		= THIS_MODULE,
> +		.of_match_table	= of_match_ptr(rcar_vin_of_table),
>  	},
>  	.id_table	= rcar_vin_id_table,
>  };
> -- 
> 2.0.0
> 

^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: [PATCH 4/6] [V3] soc_camera: add support for dt binding soc_camera drivers
  2014-07-05 22:26   ` Ben Dooks
@ 2014-07-23 18:00     ` Guennadi Liakhovetski
  -1 siblings, 0 replies; 34+ messages in thread
From: Guennadi Liakhovetski @ 2014-07-23 18:00 UTC (permalink / raw)
  To: Ben Dooks; +Cc: linux-media, linux-sh, magnus.damm, horms, linux-kernel

Hi Ben,

Thanks for a patch update. According to my calculations, this is a v5, not 
a v3. And please follow the subject line convention like

[PATCH V5 4/6] subject text follows

and use the same version in all patches of a series - this simplifies 
their handling. You can use something like

--subject-prefix="PATCH V6"

for your git format-patch to automate this.

On Sat, 5 Jul 2014, Ben Dooks wrote:

> Add initial support for OF based soc-camera devices that may be used
> by any of the soc-camera drivers. The driver itself will need converting
> to use OF.
> 
> These changes allow the soc-camera driver to do the connecting of any
> async capable v4l2 device to the soc-camera driver. This has currently
> been tested on the Renesas Lager board.
> 
> It currently only supports one input device per driver as this seems
> to be the standard connection for these devices.
> 
> Signed-off-by: Ben Dooks <ben.dooks@codethink.co.uk>
> ---
> 
> Fixes since v1:
> 	- Fix i2c mclk name compatible with other drivers
> 	- Ensure of_node is put after use
> Fixes since v2:
> 	- Updated freeing of dyn-pdev as requested
> 	- Coding style fixes
> 	- Allocate initial resources in one go
> ---
>  drivers/media/platform/soc_camera/soc_camera.c | 123 ++++++++++++++++++++++++-
>  1 file changed, 122 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/media/platform/soc_camera/soc_camera.c b/drivers/media/platform/soc_camera/soc_camera.c
> index 7fec8cd..e25fc8e 100644
> --- a/drivers/media/platform/soc_camera/soc_camera.c
> +++ b/drivers/media/platform/soc_camera/soc_camera.c
> @@ -36,6 +36,7 @@
>  #include <media/v4l2-common.h>
>  #include <media/v4l2-ioctl.h>
>  #include <media/v4l2-dev.h>
> +#include <media/v4l2-of.h>
>  #include <media/videobuf-core.h>
>  #include <media/videobuf2-core.h>
>  
> @@ -1581,6 +1582,124 @@ static void scan_async_host(struct soc_camera_host *ici)
>  #define scan_async_host(ici)		do {} while (0)
>  #endif
>  
> +#ifdef CONFIG_OF
> +
> +struct soc_of_info {
> +	struct soc_camera_async_subdev	sasd;
> +	struct v4l2_async_subdev	*subdevs[2];
> +};

Yes, this is a right direction, however, why do you use an array of 2 
subdev pointers? You only seem to be using one of them?

> +
> +static int soc_of_bind(struct soc_camera_host *ici,
> +		       struct device_node *ep,
> +		       struct device_node *remote)
> +{
> +	struct soc_camera_device *icd;
> +	struct soc_camera_desc sdesc = {.host_desc.bus_id = ici->nr,};
> +	struct soc_camera_async_client *sasc;
> +	struct soc_of_info *info;
> +	struct i2c_client *client;
> +	char clk_name[V4L2_SUBDEV_NAME_SIZE];
> +	int ret;
> +
> +	/* allocate a new subdev and add match info to it */
> +	info = devm_kzalloc(ici->v4l2_dev.dev, sizeof(struct soc_of_info),
> +			    GFP_KERNEL);
> +	if (!info)
> +		return -ENOMEM;
> +
> +	info->sasd.asd.match.of.node = remote;
> +	info->sasd.asd.match_type = V4L2_ASYNC_MATCH_OF;
> +	info->subdevs[0] = &info->sasd.asd;
> +
> +	/* Or shall this be managed by the soc-camera device? */
> +	sasc = devm_kzalloc(ici->v4l2_dev.dev, sizeof(*sasc), GFP_KERNEL);

Why not also add struct soc_camera_async_client to struct soc_of_info?

Thanks
Guennadi

> +	if (!sasc)
> +		return -ENOMEM;
> +
> +	/* HACK: just need a != NULL */
> +	sdesc.host_desc.board_info = ERR_PTR(-ENODATA);
> +
> +	ret = soc_camera_dyn_pdev(&sdesc, sasc);
> +	if (ret < 0)
> +		goto eallocpdev;
> +
> +	sasc->sensor = &info->sasd.asd;
> +
> +	icd = soc_camera_add_pdev(sasc);
> +	if (!icd) {
> +		ret = -ENOMEM;
> +		goto eaddpdev;
> +	}
> +
> +	sasc->notifier.subdevs = info->subdevs;
> +	sasc->notifier.num_subdevs = 1;
> +	sasc->notifier.bound = soc_camera_async_bound;
> +	sasc->notifier.unbind = soc_camera_async_unbind;
> +	sasc->notifier.complete = soc_camera_async_complete;
> +
> +	icd->sasc = sasc;
> +	icd->parent = ici->v4l2_dev.dev;
> +
> +	client = of_find_i2c_device_by_node(remote);
> +
> +	if (client)
> +		snprintf(clk_name, sizeof(clk_name), "%d-%04x",
> +			 client->adapter->nr, client->addr);
> +	else
> +		snprintf(clk_name, sizeof(clk_name), "of-%s",
> +			 of_node_full_name(remote));
> +
> +	icd->clk = v4l2_clk_register(&soc_camera_clk_ops, clk_name, "mclk", icd);
> +	if (IS_ERR(icd->clk)) {
> +		ret = PTR_ERR(icd->clk);
> +		goto eclkreg;
> +	}
> +
> +	ret = v4l2_async_notifier_register(&ici->v4l2_dev, &sasc->notifier);
> +	if (!ret)
> +		return 0;
> +eclkreg:
> +	icd->clk = NULL;
> +	platform_device_del(sasc->pdev);
> +eaddpdev:
> +	platform_device_put(sasc->pdev);
> +eallocpdev:
> +	devm_kfree(ici->v4l2_dev.dev, sasc);
> +	dev_err(ici->v4l2_dev.dev, "group probe failed: %d\n", ret);
> +
> +	return ret;
> +}
> +
> +static void scan_of_host(struct soc_camera_host *ici)
> +{
> +	struct device_node *np = ici->v4l2_dev.dev->of_node;
> +	struct device_node *epn = NULL;
> +	struct device_node *ren;
> +
> +	while (true) {
> +		epn = of_graph_get_next_endpoint(np, epn);
> +		if (!epn)
> +			break;
> +
> +		ren = of_graph_get_remote_port(epn);
> +		if (!ren) {
> +			pr_info("%s: no remote for %s\n",
> +				__func__,  of_node_full_name(epn));
> +			continue;
> +		}
> +
> +		/* so we now have a remote node to connect */
> +		soc_of_bind(ici, epn, ren->parent);
> +
> +		of_node_put(epn);
> +		of_node_put(ren);
> +	}
> +}
> +
> +#else
> +static inline void scan_of_host(struct soc_camera_host *ici) { }
> +#endif
> +
>  /* Called during host-driver probe */
>  static int soc_camera_probe(struct soc_camera_host *ici,
>  			    struct soc_camera_device *icd)
> @@ -1832,7 +1951,9 @@ int soc_camera_host_register(struct soc_camera_host *ici)
>  	mutex_init(&ici->host_lock);
>  	mutex_init(&ici->clk_lock);
>  
> -	if (ici->asd_sizes)
> +	if (ici->v4l2_dev.dev->of_node)
> +		scan_of_host(ici);
> +	else if (ici->asd_sizes)
>  		/*
>  		 * No OF, host with a list of subdevices. Don't try to mix
>  		 * modes by initialising some groups statically and some
> -- 
> 2.0.0
> 

^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: [PATCH 4/6] [V3] soc_camera: add support for dt binding soc_camera drivers
@ 2014-07-23 18:00     ` Guennadi Liakhovetski
  0 siblings, 0 replies; 34+ messages in thread
From: Guennadi Liakhovetski @ 2014-07-23 18:00 UTC (permalink / raw)
  To: Ben Dooks; +Cc: linux-media, linux-sh, magnus.damm, horms, linux-kernel

Hi Ben,

Thanks for a patch update. According to my calculations, this is a v5, not 
a v3. And please follow the subject line convention like

[PATCH V5 4/6] subject text follows

and use the same version in all patches of a series - this simplifies 
their handling. You can use something like

--subject-prefix="PATCH V6"

for your git format-patch to automate this.

On Sat, 5 Jul 2014, Ben Dooks wrote:

> Add initial support for OF based soc-camera devices that may be used
> by any of the soc-camera drivers. The driver itself will need converting
> to use OF.
> 
> These changes allow the soc-camera driver to do the connecting of any
> async capable v4l2 device to the soc-camera driver. This has currently
> been tested on the Renesas Lager board.
> 
> It currently only supports one input device per driver as this seems
> to be the standard connection for these devices.
> 
> Signed-off-by: Ben Dooks <ben.dooks@codethink.co.uk>
> ---
> 
> Fixes since v1:
> 	- Fix i2c mclk name compatible with other drivers
> 	- Ensure of_node is put after use
> Fixes since v2:
> 	- Updated freeing of dyn-pdev as requested
> 	- Coding style fixes
> 	- Allocate initial resources in one go
> ---
>  drivers/media/platform/soc_camera/soc_camera.c | 123 ++++++++++++++++++++++++-
>  1 file changed, 122 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/media/platform/soc_camera/soc_camera.c b/drivers/media/platform/soc_camera/soc_camera.c
> index 7fec8cd..e25fc8e 100644
> --- a/drivers/media/platform/soc_camera/soc_camera.c
> +++ b/drivers/media/platform/soc_camera/soc_camera.c
> @@ -36,6 +36,7 @@
>  #include <media/v4l2-common.h>
>  #include <media/v4l2-ioctl.h>
>  #include <media/v4l2-dev.h>
> +#include <media/v4l2-of.h>
>  #include <media/videobuf-core.h>
>  #include <media/videobuf2-core.h>
>  
> @@ -1581,6 +1582,124 @@ static void scan_async_host(struct soc_camera_host *ici)
>  #define scan_async_host(ici)		do {} while (0)
>  #endif
>  
> +#ifdef CONFIG_OF
> +
> +struct soc_of_info {
> +	struct soc_camera_async_subdev	sasd;
> +	struct v4l2_async_subdev	*subdevs[2];
> +};

Yes, this is a right direction, however, why do you use an array of 2 
subdev pointers? You only seem to be using one of them?

> +
> +static int soc_of_bind(struct soc_camera_host *ici,
> +		       struct device_node *ep,
> +		       struct device_node *remote)
> +{
> +	struct soc_camera_device *icd;
> +	struct soc_camera_desc sdesc = {.host_desc.bus_id = ici->nr,};
> +	struct soc_camera_async_client *sasc;
> +	struct soc_of_info *info;
> +	struct i2c_client *client;
> +	char clk_name[V4L2_SUBDEV_NAME_SIZE];
> +	int ret;
> +
> +	/* allocate a new subdev and add match info to it */
> +	info = devm_kzalloc(ici->v4l2_dev.dev, sizeof(struct soc_of_info),
> +			    GFP_KERNEL);
> +	if (!info)
> +		return -ENOMEM;
> +
> +	info->sasd.asd.match.of.node = remote;
> +	info->sasd.asd.match_type = V4L2_ASYNC_MATCH_OF;
> +	info->subdevs[0] = &info->sasd.asd;
> +
> +	/* Or shall this be managed by the soc-camera device? */
> +	sasc = devm_kzalloc(ici->v4l2_dev.dev, sizeof(*sasc), GFP_KERNEL);

Why not also add struct soc_camera_async_client to struct soc_of_info?

Thanks
Guennadi

> +	if (!sasc)
> +		return -ENOMEM;
> +
> +	/* HACK: just need a != NULL */
> +	sdesc.host_desc.board_info = ERR_PTR(-ENODATA);
> +
> +	ret = soc_camera_dyn_pdev(&sdesc, sasc);
> +	if (ret < 0)
> +		goto eallocpdev;
> +
> +	sasc->sensor = &info->sasd.asd;
> +
> +	icd = soc_camera_add_pdev(sasc);
> +	if (!icd) {
> +		ret = -ENOMEM;
> +		goto eaddpdev;
> +	}
> +
> +	sasc->notifier.subdevs = info->subdevs;
> +	sasc->notifier.num_subdevs = 1;
> +	sasc->notifier.bound = soc_camera_async_bound;
> +	sasc->notifier.unbind = soc_camera_async_unbind;
> +	sasc->notifier.complete = soc_camera_async_complete;
> +
> +	icd->sasc = sasc;
> +	icd->parent = ici->v4l2_dev.dev;
> +
> +	client = of_find_i2c_device_by_node(remote);
> +
> +	if (client)
> +		snprintf(clk_name, sizeof(clk_name), "%d-%04x",
> +			 client->adapter->nr, client->addr);
> +	else
> +		snprintf(clk_name, sizeof(clk_name), "of-%s",
> +			 of_node_full_name(remote));
> +
> +	icd->clk = v4l2_clk_register(&soc_camera_clk_ops, clk_name, "mclk", icd);
> +	if (IS_ERR(icd->clk)) {
> +		ret = PTR_ERR(icd->clk);
> +		goto eclkreg;
> +	}
> +
> +	ret = v4l2_async_notifier_register(&ici->v4l2_dev, &sasc->notifier);
> +	if (!ret)
> +		return 0;
> +eclkreg:
> +	icd->clk = NULL;
> +	platform_device_del(sasc->pdev);
> +eaddpdev:
> +	platform_device_put(sasc->pdev);
> +eallocpdev:
> +	devm_kfree(ici->v4l2_dev.dev, sasc);
> +	dev_err(ici->v4l2_dev.dev, "group probe failed: %d\n", ret);
> +
> +	return ret;
> +}
> +
> +static void scan_of_host(struct soc_camera_host *ici)
> +{
> +	struct device_node *np = ici->v4l2_dev.dev->of_node;
> +	struct device_node *epn = NULL;
> +	struct device_node *ren;
> +
> +	while (true) {
> +		epn = of_graph_get_next_endpoint(np, epn);
> +		if (!epn)
> +			break;
> +
> +		ren = of_graph_get_remote_port(epn);
> +		if (!ren) {
> +			pr_info("%s: no remote for %s\n",
> +				__func__,  of_node_full_name(epn));
> +			continue;
> +		}
> +
> +		/* so we now have a remote node to connect */
> +		soc_of_bind(ici, epn, ren->parent);
> +
> +		of_node_put(epn);
> +		of_node_put(ren);
> +	}
> +}
> +
> +#else
> +static inline void scan_of_host(struct soc_camera_host *ici) { }
> +#endif
> +
>  /* Called during host-driver probe */
>  static int soc_camera_probe(struct soc_camera_host *ici,
>  			    struct soc_camera_device *icd)
> @@ -1832,7 +1951,9 @@ int soc_camera_host_register(struct soc_camera_host *ici)
>  	mutex_init(&ici->host_lock);
>  	mutex_init(&ici->clk_lock);
>  
> -	if (ici->asd_sizes)
> +	if (ici->v4l2_dev.dev->of_node)
> +		scan_of_host(ici);
> +	else if (ici->asd_sizes)
>  		/*
>  		 * No OF, host with a list of subdevices. Don't try to mix
>  		 * modes by initialising some groups statically and some
> -- 
> 2.0.0
> 

^ permalink raw reply	[flat|nested] 34+ messages in thread

* [PATCH v6 4/6] soc_camera: add support for dt binding soc_camera drivers
  2014-07-23 18:00     ` Guennadi Liakhovetski
@ 2014-07-23 18:01       ` Guennadi Liakhovetski
  -1 siblings, 0 replies; 34+ messages in thread
From: Guennadi Liakhovetski @ 2014-07-23 18:01 UTC (permalink / raw)
  To: Ben Dooks; +Cc: linux-media, linux-sh, magnus.damm, horms, linux-kernel

Add initial support for OF based soc-camera devices that may be used
by any of the soc-camera drivers. The driver itself will need converting
to use OF.

These changes allow the soc-camera driver to do the connecting of any
async capable v4l2 device to the soc-camera driver. This has currently
been tested on the Renesas Lager board.

It currently only supports one input device per driver as this seems
to be the standard connection for these devices.

Signed-off-by: Ben Dooks <ben.dooks@codethink.co.uk>
[g.liakhovetski@gmx.de add check for multiple subdevices]
Signed-off-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de>
---

Hi Ben,

How about this version? Could you review and test?

Thanks
Guennadi

 drivers/media/platform/soc_camera/soc_camera.c | 129 ++++++++++++++++++++++++-
 1 file changed, 128 insertions(+), 1 deletion(-)

diff --git a/drivers/media/platform/soc_camera/soc_camera.c b/drivers/media/platform/soc_camera/soc_camera.c
index dc626b9..f4308fe 100644
--- a/drivers/media/platform/soc_camera/soc_camera.c
+++ b/drivers/media/platform/soc_camera/soc_camera.c
@@ -36,6 +36,7 @@
 #include <media/v4l2-common.h>
 #include <media/v4l2-ioctl.h>
 #include <media/v4l2-dev.h>
+#include <media/v4l2-of.h>
 #include <media/videobuf-core.h>
 #include <media/videobuf2-core.h>
 
@@ -1585,6 +1586,130 @@ static void scan_async_host(struct soc_camera_host *ici)
 #define scan_async_host(ici)		do {} while (0)
 #endif
 
+#ifdef CONFIG_OF
+
+struct soc_of_info {
+	struct soc_camera_async_subdev	sasd;
+	struct soc_camera_async_client	sasc;
+	struct v4l2_async_subdev	*subdev;
+};
+
+static int soc_of_bind(struct soc_camera_host *ici,
+		       struct device_node *ep,
+		       struct device_node *remote)
+{
+	struct soc_camera_device *icd;
+	struct soc_camera_desc sdesc = {.host_desc.bus_id = ici->nr,};
+	struct soc_camera_async_client *sasc;
+	struct soc_of_info *info;
+	struct i2c_client *client;
+	char clk_name[V4L2_SUBDEV_NAME_SIZE];
+	int ret;
+
+	/* allocate a new subdev and add match info to it */
+	info = devm_kzalloc(ici->v4l2_dev.dev, sizeof(struct soc_of_info),
+			    GFP_KERNEL);
+	if (!info)
+		return -ENOMEM;
+
+	info->sasd.asd.match.of.node = remote;
+	info->sasd.asd.match_type = V4L2_ASYNC_MATCH_OF;
+	info->subdev = &info->sasd.asd;
+
+	/* Or shall this be managed by the soc-camera device? */
+	sasc = &info->sasc;
+
+	/* HACK: just need a != NULL */
+	sdesc.host_desc.board_info = ERR_PTR(-ENODATA);
+
+	ret = soc_camera_dyn_pdev(&sdesc, sasc);
+	if (ret < 0)
+		goto eallocpdev;
+
+	sasc->sensor = &info->sasd.asd;
+
+	icd = soc_camera_add_pdev(sasc);
+	if (!icd) {
+		ret = -ENOMEM;
+		goto eaddpdev;
+	}
+
+	sasc->notifier.subdevs = &info->subdev;
+	sasc->notifier.num_subdevs = 1;
+	sasc->notifier.bound = soc_camera_async_bound;
+	sasc->notifier.unbind = soc_camera_async_unbind;
+	sasc->notifier.complete = soc_camera_async_complete;
+
+	icd->sasc = sasc;
+	icd->parent = ici->v4l2_dev.dev;
+
+	client = of_find_i2c_device_by_node(remote);
+
+	if (client)
+		snprintf(clk_name, sizeof(clk_name), "%d-%04x",
+			 client->adapter->nr, client->addr);
+	else
+		snprintf(clk_name, sizeof(clk_name), "of-%s",
+			 of_node_full_name(remote));
+
+	icd->clk = v4l2_clk_register(&soc_camera_clk_ops, clk_name, "mclk", icd);
+	if (IS_ERR(icd->clk)) {
+		ret = PTR_ERR(icd->clk);
+		goto eclkreg;
+	}
+
+	ret = v4l2_async_notifier_register(&ici->v4l2_dev, &sasc->notifier);
+	if (!ret)
+		return 0;
+eclkreg:
+	icd->clk = NULL;
+	platform_device_del(sasc->pdev);
+eaddpdev:
+	platform_device_put(sasc->pdev);
+eallocpdev:
+	devm_kfree(ici->v4l2_dev.dev, sasc);
+	dev_err(ici->v4l2_dev.dev, "group probe failed: %d\n", ret);
+
+	return ret;
+}
+
+static void scan_of_host(struct soc_camera_host *ici)
+{
+	struct device *dev = ici->v4l2_dev.dev;
+	struct device_node *np = dev->of_node;
+	struct device_node *epn = NULL, *ren;
+	unsigned int i;
+
+	for (i = 0; ; i++) {
+		epn = of_graph_get_next_endpoint(np, epn);
+		if (!epn)
+			break;
+
+		ren = of_graph_get_remote_port(epn);
+		if (!ren) {
+			dev_notice(dev, "no remote for %s\n",
+				   of_node_full_name(epn));
+			continue;
+		}
+
+		/* so we now have a remote node to connect */
+		if (!i)
+			soc_of_bind(ici, epn, ren->parent);
+
+		of_node_put(epn);
+		of_node_put(ren);
+
+		if (i) {
+			dev_err(dev, "multiple subdevices aren't supported yet!\n");
+			break;
+		}
+	}
+}
+
+#else
+static inline void scan_of_host(struct soc_camera_host *ici) { }
+#endif
+
 /* Called during host-driver probe */
 static int soc_camera_probe(struct soc_camera_host *ici,
 			    struct soc_camera_device *icd)
@@ -1836,7 +1961,9 @@ int soc_camera_host_register(struct soc_camera_host *ici)
 	mutex_init(&ici->host_lock);
 	mutex_init(&ici->clk_lock);
 
-	if (ici->asd_sizes)
+	if (ici->v4l2_dev.dev->of_node)
+		scan_of_host(ici);
+	else if (ici->asd_sizes)
 		/*
 		 * No OF, host with a list of subdevices. Don't try to mix
 		 * modes by initialising some groups statically and some
-- 
1.9.3


^ permalink raw reply related	[flat|nested] 34+ messages in thread

* [PATCH v6 4/6] soc_camera: add support for dt binding soc_camera drivers
@ 2014-07-23 18:01       ` Guennadi Liakhovetski
  0 siblings, 0 replies; 34+ messages in thread
From: Guennadi Liakhovetski @ 2014-07-23 18:01 UTC (permalink / raw)
  To: Ben Dooks; +Cc: linux-media, linux-sh, magnus.damm, horms, linux-kernel

Add initial support for OF based soc-camera devices that may be used
by any of the soc-camera drivers. The driver itself will need converting
to use OF.

These changes allow the soc-camera driver to do the connecting of any
async capable v4l2 device to the soc-camera driver. This has currently
been tested on the Renesas Lager board.

It currently only supports one input device per driver as this seems
to be the standard connection for these devices.

Signed-off-by: Ben Dooks <ben.dooks@codethink.co.uk>
[g.liakhovetski@gmx.de add check for multiple subdevices]
Signed-off-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de>
---

Hi Ben,

How about this version? Could you review and test?

Thanks
Guennadi

 drivers/media/platform/soc_camera/soc_camera.c | 129 ++++++++++++++++++++++++-
 1 file changed, 128 insertions(+), 1 deletion(-)

diff --git a/drivers/media/platform/soc_camera/soc_camera.c b/drivers/media/platform/soc_camera/soc_camera.c
index dc626b9..f4308fe 100644
--- a/drivers/media/platform/soc_camera/soc_camera.c
+++ b/drivers/media/platform/soc_camera/soc_camera.c
@@ -36,6 +36,7 @@
 #include <media/v4l2-common.h>
 #include <media/v4l2-ioctl.h>
 #include <media/v4l2-dev.h>
+#include <media/v4l2-of.h>
 #include <media/videobuf-core.h>
 #include <media/videobuf2-core.h>
 
@@ -1585,6 +1586,130 @@ static void scan_async_host(struct soc_camera_host *ici)
 #define scan_async_host(ici)		do {} while (0)
 #endif
 
+#ifdef CONFIG_OF
+
+struct soc_of_info {
+	struct soc_camera_async_subdev	sasd;
+	struct soc_camera_async_client	sasc;
+	struct v4l2_async_subdev	*subdev;
+};
+
+static int soc_of_bind(struct soc_camera_host *ici,
+		       struct device_node *ep,
+		       struct device_node *remote)
+{
+	struct soc_camera_device *icd;
+	struct soc_camera_desc sdesc = {.host_desc.bus_id = ici->nr,};
+	struct soc_camera_async_client *sasc;
+	struct soc_of_info *info;
+	struct i2c_client *client;
+	char clk_name[V4L2_SUBDEV_NAME_SIZE];
+	int ret;
+
+	/* allocate a new subdev and add match info to it */
+	info = devm_kzalloc(ici->v4l2_dev.dev, sizeof(struct soc_of_info),
+			    GFP_KERNEL);
+	if (!info)
+		return -ENOMEM;
+
+	info->sasd.asd.match.of.node = remote;
+	info->sasd.asd.match_type = V4L2_ASYNC_MATCH_OF;
+	info->subdev = &info->sasd.asd;
+
+	/* Or shall this be managed by the soc-camera device? */
+	sasc = &info->sasc;
+
+	/* HACK: just need a != NULL */
+	sdesc.host_desc.board_info = ERR_PTR(-ENODATA);
+
+	ret = soc_camera_dyn_pdev(&sdesc, sasc);
+	if (ret < 0)
+		goto eallocpdev;
+
+	sasc->sensor = &info->sasd.asd;
+
+	icd = soc_camera_add_pdev(sasc);
+	if (!icd) {
+		ret = -ENOMEM;
+		goto eaddpdev;
+	}
+
+	sasc->notifier.subdevs = &info->subdev;
+	sasc->notifier.num_subdevs = 1;
+	sasc->notifier.bound = soc_camera_async_bound;
+	sasc->notifier.unbind = soc_camera_async_unbind;
+	sasc->notifier.complete = soc_camera_async_complete;
+
+	icd->sasc = sasc;
+	icd->parent = ici->v4l2_dev.dev;
+
+	client = of_find_i2c_device_by_node(remote);
+
+	if (client)
+		snprintf(clk_name, sizeof(clk_name), "%d-%04x",
+			 client->adapter->nr, client->addr);
+	else
+		snprintf(clk_name, sizeof(clk_name), "of-%s",
+			 of_node_full_name(remote));
+
+	icd->clk = v4l2_clk_register(&soc_camera_clk_ops, clk_name, "mclk", icd);
+	if (IS_ERR(icd->clk)) {
+		ret = PTR_ERR(icd->clk);
+		goto eclkreg;
+	}
+
+	ret = v4l2_async_notifier_register(&ici->v4l2_dev, &sasc->notifier);
+	if (!ret)
+		return 0;
+eclkreg:
+	icd->clk = NULL;
+	platform_device_del(sasc->pdev);
+eaddpdev:
+	platform_device_put(sasc->pdev);
+eallocpdev:
+	devm_kfree(ici->v4l2_dev.dev, sasc);
+	dev_err(ici->v4l2_dev.dev, "group probe failed: %d\n", ret);
+
+	return ret;
+}
+
+static void scan_of_host(struct soc_camera_host *ici)
+{
+	struct device *dev = ici->v4l2_dev.dev;
+	struct device_node *np = dev->of_node;
+	struct device_node *epn = NULL, *ren;
+	unsigned int i;
+
+	for (i = 0; ; i++) {
+		epn = of_graph_get_next_endpoint(np, epn);
+		if (!epn)
+			break;
+
+		ren = of_graph_get_remote_port(epn);
+		if (!ren) {
+			dev_notice(dev, "no remote for %s\n",
+				   of_node_full_name(epn));
+			continue;
+		}
+
+		/* so we now have a remote node to connect */
+		if (!i)
+			soc_of_bind(ici, epn, ren->parent);
+
+		of_node_put(epn);
+		of_node_put(ren);
+
+		if (i) {
+			dev_err(dev, "multiple subdevices aren't supported yet!\n");
+			break;
+		}
+	}
+}
+
+#else
+static inline void scan_of_host(struct soc_camera_host *ici) { }
+#endif
+
 /* Called during host-driver probe */
 static int soc_camera_probe(struct soc_camera_host *ici,
 			    struct soc_camera_device *icd)
@@ -1836,7 +1961,9 @@ int soc_camera_host_register(struct soc_camera_host *ici)
 	mutex_init(&ici->host_lock);
 	mutex_init(&ici->clk_lock);
 
-	if (ici->asd_sizes)
+	if (ici->v4l2_dev.dev->of_node)
+		scan_of_host(ici);
+	else if (ici->asd_sizes)
 		/*
 		 * No OF, host with a list of subdevices. Don't try to mix
 		 * modes by initialising some groups statically and some
-- 
1.9.3


^ permalink raw reply related	[flat|nested] 34+ messages in thread

* [PATCH v6 3/6] rcar_vin: add devicetree support
  2014-07-23 10:20     ` Guennadi Liakhovetski
@ 2014-07-23 18:23       ` Guennadi Liakhovetski
  -1 siblings, 0 replies; 34+ messages in thread
From: Guennadi Liakhovetski @ 2014-07-23 18:23 UTC (permalink / raw)
  To: Ben Dooks; +Cc: linux-media, linux-sh, magnus.damm, horms, linux-kernel

Add support for devicetree probe for the rcar-vin
driver.

Signed-off-by: Ben Dooks <ben.dooks@codethink.co.uk>
[g.liakhovetski@gmx.de fix a typo, sort headers alphabetically]
Signed-off-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de>
---

Ben, is this version ok?

 .../devicetree/bindings/media/rcar_vin.txt         | 86 ++++++++++++++++++++++
 drivers/media/platform/soc_camera/rcar_vin.c       | 72 ++++++++++++++++--
 2 files changed, 151 insertions(+), 7 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/media/rcar_vin.txt

diff --git a/Documentation/devicetree/bindings/media/rcar_vin.txt b/Documentation/devicetree/bindings/media/rcar_vin.txt
new file mode 100644
index 0000000..ba61782
--- /dev/null
+++ b/Documentation/devicetree/bindings/media/rcar_vin.txt
@@ -0,0 +1,86 @@
+Renesas RCar Video Input driver (rcar_vin)
+------------------------------------------
+
+The rcar_vin device provides video input capabilities for the Renesas R-Car
+family of devices. The current blocks are always slaves and suppot one input
+channel which can be either RGB, YUYV or BT656.
+
+ - compatible: Must be one of the following
+   - "renesas,vin-r8a7791" for the R8A7791 device
+   - "renesas,vin-r8a7790" for the R8A7790 device
+   - "renesas,vin-r8a7779" for the R8A7779 device
+   - "renesas,vin-r8a7778" for the R8A7778 device
+ - reg: the register base and size for the device registers
+ - interrupts: the interrupt for the device
+ - clocks: Reference to the parent clock
+
+Additionally, an alias named vinX will need to be created to specify
+which video input device this is.
+
+The per-board settings:
+ - port sub-node describing a single endpoint connected to the vin
+   as described in video-interfaces.txt[1]. Only the first one will
+   be considered as each vin interface has one input port.
+
+   These settings are used to work out video input format and widths
+   into the system.
+
+
+Device node example
+-------------------
+
+	aliases {
+	       vin0 = &vin0;
+	};
+
+        vin0: vin@0xe6ef0000 {
+                compatible = "renesas,vin-r8a7790";
+                clocks = <&mstp8_clks R8A7790_CLK_VIN0>;
+                reg = <0 0xe6ef0000 0 0x1000>;
+                interrupts = <0 188 IRQ_TYPE_LEVEL_HIGH>;
+                status = "disabled";
+        };
+
+Board setup example (vin1 composite video input)
+------------------------------------------------
+
+&i2c2   {
+        status = "ok";
+        pinctrl-0 = <&i2c2_pins>;
+        pinctrl-names = "default";
+
+        adv7180@20 {
+                compatible = "adi,adv7180";
+                reg = <0x20>;
+                remote = <&vin1>;
+
+                port {
+                        adv7180: endpoint {
+                                bus-width = <8>;
+                                remote-endpoint = <&vin1ep0>;
+                        };
+                };
+        };
+};
+
+/* composite video input */
+&vin1 {
+        pinctrl-0 = <&vin1_pins>;
+        pinctrl-names = "default";
+
+        status = "ok";
+
+        port {
+                #address-cells = <1>;
+                #size-cells = <0>;
+
+                vin1ep0: endpoint {
+                        remote-endpoint = <&adv7180>;
+                        bus-width = <8>;
+                };
+        };
+};
+
+
+
+[1] video-interfaces.txt common video media interface
diff --git a/drivers/media/platform/soc_camera/rcar_vin.c b/drivers/media/platform/soc_camera/rcar_vin.c
index 7c4299d..85d579f 100644
--- a/drivers/media/platform/soc_camera/rcar_vin.c
+++ b/drivers/media/platform/soc_camera/rcar_vin.c
@@ -19,6 +19,8 @@
 #include <linux/io.h>
 #include <linux/kernel.h>
 #include <linux/module.h>
+#include <linux/of.h>
+#include <linux/of_device.h>
 #include <linux/platform_data/camera-rcar.h>
 #include <linux/platform_device.h>
 #include <linux/pm_runtime.h>
@@ -31,6 +33,7 @@
 #include <media/v4l2-dev.h>
 #include <media/v4l2-device.h>
 #include <media/v4l2-mediabus.h>
+#include <media/v4l2-of.h>
 #include <media/v4l2-subdev.h>
 #include <media/videobuf2-dma-contig.h>
 
@@ -1390,6 +1393,17 @@ static struct soc_camera_host_ops rcar_vin_host_ops = {
 	.init_videobuf2	= rcar_vin_init_videobuf2,
 };
 
+#ifdef CONFIG_OF
+static struct of_device_id rcar_vin_of_table[] = {
+	{ .compatible = "renesas,vin-r8a7791", .data = (void *)RCAR_GEN2 },
+	{ .compatible = "renesas,vin-r8a7790", .data = (void *)RCAR_GEN2 },
+	{ .compatible = "renesas,vin-r8a7779", .data = (void *)RCAR_H1 },
+	{ .compatible = "renesas,vin-r8a7778", .data = (void *)RCAR_M1 },
+	{ },
+};
+MODULE_DEVICE_TABLE(of, rcar_vin_of_table);
+#endif
+
 static struct platform_device_id rcar_vin_id_table[] = {
 	{ "r8a7791-vin",  RCAR_GEN2 },
 	{ "r8a7790-vin",  RCAR_GEN2 },
@@ -1402,15 +1416,52 @@ MODULE_DEVICE_TABLE(platform, rcar_vin_id_table);
 
 static int rcar_vin_probe(struct platform_device *pdev)
 {
+	const struct of_device_id *match = NULL;
 	struct rcar_vin_priv *priv;
 	struct resource *mem;
 	struct rcar_vin_platform_data *pdata;
+	unsigned int pdata_flags;
 	int irq, ret;
 
-	pdata = pdev->dev.platform_data;
-	if (!pdata || !pdata->flags) {
-		dev_err(&pdev->dev, "platform data not set\n");
-		return -EINVAL;
+	if (pdev->dev.of_node) {
+		struct v4l2_of_endpoint ep;
+		struct device_node *np;
+
+		match = of_match_device(of_match_ptr(rcar_vin_of_table),
+					&pdev->dev);
+
+		np = of_graph_get_next_endpoint(pdev->dev.of_node, NULL);
+		if (!np) {
+			dev_err(&pdev->dev, "could not find endpoint\n");
+			return -EINVAL;
+		}
+
+		ret = v4l2_of_parse_endpoint(np, &ep);
+		if (ret) {
+			dev_err(&pdev->dev, "could not parse endpoint\n");
+			return ret;
+		}
+
+		if (ep.bus_type = V4L2_MBUS_BT656)
+			pdata_flags = RCAR_VIN_BT656;
+		else {
+			pdata_flags = 0;
+			if (ep.bus.parallel.flags & V4L2_MBUS_HSYNC_ACTIVE_LOW)
+				pdata_flags |= RCAR_VIN_HSYNC_ACTIVE_LOW;
+			if (ep.bus.parallel.flags & V4L2_MBUS_VSYNC_ACTIVE_LOW)
+				pdata_flags |= RCAR_VIN_VSYNC_ACTIVE_LOW;
+		}
+
+		of_node_put(np);
+
+		dev_dbg(&pdev->dev, "pdata_flags = %08x\n", pdata_flags);
+	} else {
+		pdata = pdev->dev.platform_data;
+		if (!pdata || !pdata->flags) {
+			dev_err(&pdev->dev, "platform data not set\n");
+			return -EINVAL;
+		}
+		pdata_flags = pdata->flags;
 	}
 
 	mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
@@ -1441,12 +1492,18 @@ static int rcar_vin_probe(struct platform_device *pdev)
 
 	priv->ici.priv = priv;
 	priv->ici.v4l2_dev.dev = &pdev->dev;
-	priv->ici.nr = pdev->id;
 	priv->ici.drv_name = dev_name(&pdev->dev);
 	priv->ici.ops = &rcar_vin_host_ops;
 
-	priv->pdata_flags = pdata->flags;
-	priv->chip = pdev->id_entry->driver_data;
+	priv->pdata_flags = pdata_flags;
+	if (!match) {
+		priv->ici.nr = pdev->id;
+		priv->chip = pdev->id_entry->driver_data;
+	} else {
+		priv->ici.nr = of_alias_get_id(pdev->dev.of_node, "vin");
+		priv->chip = (enum chip_id)match->data;
+	};
+
 	spin_lock_init(&priv->lock);
 	INIT_LIST_HEAD(&priv->capture);
 
@@ -1487,6 +1544,7 @@ static struct platform_driver rcar_vin_driver = {
 	.driver		= {
 		.name		= DRV_NAME,
 		.owner		= THIS_MODULE,
+		.of_match_table	= of_match_ptr(rcar_vin_of_table),
 	},
 	.id_table	= rcar_vin_id_table,
 };
-- 
1.9.3


^ permalink raw reply related	[flat|nested] 34+ messages in thread

* [PATCH v6 3/6] rcar_vin: add devicetree support
@ 2014-07-23 18:23       ` Guennadi Liakhovetski
  0 siblings, 0 replies; 34+ messages in thread
From: Guennadi Liakhovetski @ 2014-07-23 18:23 UTC (permalink / raw)
  To: Ben Dooks; +Cc: linux-media, linux-sh, magnus.damm, horms, linux-kernel

Add support for devicetree probe for the rcar-vin
driver.

Signed-off-by: Ben Dooks <ben.dooks@codethink.co.uk>
[g.liakhovetski@gmx.de fix a typo, sort headers alphabetically]
Signed-off-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de>
---

Ben, is this version ok?

 .../devicetree/bindings/media/rcar_vin.txt         | 86 ++++++++++++++++++++++
 drivers/media/platform/soc_camera/rcar_vin.c       | 72 ++++++++++++++++--
 2 files changed, 151 insertions(+), 7 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/media/rcar_vin.txt

diff --git a/Documentation/devicetree/bindings/media/rcar_vin.txt b/Documentation/devicetree/bindings/media/rcar_vin.txt
new file mode 100644
index 0000000..ba61782
--- /dev/null
+++ b/Documentation/devicetree/bindings/media/rcar_vin.txt
@@ -0,0 +1,86 @@
+Renesas RCar Video Input driver (rcar_vin)
+------------------------------------------
+
+The rcar_vin device provides video input capabilities for the Renesas R-Car
+family of devices. The current blocks are always slaves and suppot one input
+channel which can be either RGB, YUYV or BT656.
+
+ - compatible: Must be one of the following
+   - "renesas,vin-r8a7791" for the R8A7791 device
+   - "renesas,vin-r8a7790" for the R8A7790 device
+   - "renesas,vin-r8a7779" for the R8A7779 device
+   - "renesas,vin-r8a7778" for the R8A7778 device
+ - reg: the register base and size for the device registers
+ - interrupts: the interrupt for the device
+ - clocks: Reference to the parent clock
+
+Additionally, an alias named vinX will need to be created to specify
+which video input device this is.
+
+The per-board settings:
+ - port sub-node describing a single endpoint connected to the vin
+   as described in video-interfaces.txt[1]. Only the first one will
+   be considered as each vin interface has one input port.
+
+   These settings are used to work out video input format and widths
+   into the system.
+
+
+Device node example
+-------------------
+
+	aliases {
+	       vin0 = &vin0;
+	};
+
+        vin0: vin@0xe6ef0000 {
+                compatible = "renesas,vin-r8a7790";
+                clocks = <&mstp8_clks R8A7790_CLK_VIN0>;
+                reg = <0 0xe6ef0000 0 0x1000>;
+                interrupts = <0 188 IRQ_TYPE_LEVEL_HIGH>;
+                status = "disabled";
+        };
+
+Board setup example (vin1 composite video input)
+------------------------------------------------
+
+&i2c2   {
+        status = "ok";
+        pinctrl-0 = <&i2c2_pins>;
+        pinctrl-names = "default";
+
+        adv7180@20 {
+                compatible = "adi,adv7180";
+                reg = <0x20>;
+                remote = <&vin1>;
+
+                port {
+                        adv7180: endpoint {
+                                bus-width = <8>;
+                                remote-endpoint = <&vin1ep0>;
+                        };
+                };
+        };
+};
+
+/* composite video input */
+&vin1 {
+        pinctrl-0 = <&vin1_pins>;
+        pinctrl-names = "default";
+
+        status = "ok";
+
+        port {
+                #address-cells = <1>;
+                #size-cells = <0>;
+
+                vin1ep0: endpoint {
+                        remote-endpoint = <&adv7180>;
+                        bus-width = <8>;
+                };
+        };
+};
+
+
+
+[1] video-interfaces.txt common video media interface
diff --git a/drivers/media/platform/soc_camera/rcar_vin.c b/drivers/media/platform/soc_camera/rcar_vin.c
index 7c4299d..85d579f 100644
--- a/drivers/media/platform/soc_camera/rcar_vin.c
+++ b/drivers/media/platform/soc_camera/rcar_vin.c
@@ -19,6 +19,8 @@
 #include <linux/io.h>
 #include <linux/kernel.h>
 #include <linux/module.h>
+#include <linux/of.h>
+#include <linux/of_device.h>
 #include <linux/platform_data/camera-rcar.h>
 #include <linux/platform_device.h>
 #include <linux/pm_runtime.h>
@@ -31,6 +33,7 @@
 #include <media/v4l2-dev.h>
 #include <media/v4l2-device.h>
 #include <media/v4l2-mediabus.h>
+#include <media/v4l2-of.h>
 #include <media/v4l2-subdev.h>
 #include <media/videobuf2-dma-contig.h>
 
@@ -1390,6 +1393,17 @@ static struct soc_camera_host_ops rcar_vin_host_ops = {
 	.init_videobuf2	= rcar_vin_init_videobuf2,
 };
 
+#ifdef CONFIG_OF
+static struct of_device_id rcar_vin_of_table[] = {
+	{ .compatible = "renesas,vin-r8a7791", .data = (void *)RCAR_GEN2 },
+	{ .compatible = "renesas,vin-r8a7790", .data = (void *)RCAR_GEN2 },
+	{ .compatible = "renesas,vin-r8a7779", .data = (void *)RCAR_H1 },
+	{ .compatible = "renesas,vin-r8a7778", .data = (void *)RCAR_M1 },
+	{ },
+};
+MODULE_DEVICE_TABLE(of, rcar_vin_of_table);
+#endif
+
 static struct platform_device_id rcar_vin_id_table[] = {
 	{ "r8a7791-vin",  RCAR_GEN2 },
 	{ "r8a7790-vin",  RCAR_GEN2 },
@@ -1402,15 +1416,52 @@ MODULE_DEVICE_TABLE(platform, rcar_vin_id_table);
 
 static int rcar_vin_probe(struct platform_device *pdev)
 {
+	const struct of_device_id *match = NULL;
 	struct rcar_vin_priv *priv;
 	struct resource *mem;
 	struct rcar_vin_platform_data *pdata;
+	unsigned int pdata_flags;
 	int irq, ret;
 
-	pdata = pdev->dev.platform_data;
-	if (!pdata || !pdata->flags) {
-		dev_err(&pdev->dev, "platform data not set\n");
-		return -EINVAL;
+	if (pdev->dev.of_node) {
+		struct v4l2_of_endpoint ep;
+		struct device_node *np;
+
+		match = of_match_device(of_match_ptr(rcar_vin_of_table),
+					&pdev->dev);
+
+		np = of_graph_get_next_endpoint(pdev->dev.of_node, NULL);
+		if (!np) {
+			dev_err(&pdev->dev, "could not find endpoint\n");
+			return -EINVAL;
+		}
+
+		ret = v4l2_of_parse_endpoint(np, &ep);
+		if (ret) {
+			dev_err(&pdev->dev, "could not parse endpoint\n");
+			return ret;
+		}
+
+		if (ep.bus_type == V4L2_MBUS_BT656)
+			pdata_flags = RCAR_VIN_BT656;
+		else {
+			pdata_flags = 0;
+			if (ep.bus.parallel.flags & V4L2_MBUS_HSYNC_ACTIVE_LOW)
+				pdata_flags |= RCAR_VIN_HSYNC_ACTIVE_LOW;
+			if (ep.bus.parallel.flags & V4L2_MBUS_VSYNC_ACTIVE_LOW)
+				pdata_flags |= RCAR_VIN_VSYNC_ACTIVE_LOW;
+		}
+
+		of_node_put(np);
+
+		dev_dbg(&pdev->dev, "pdata_flags = %08x\n", pdata_flags);
+	} else {
+		pdata = pdev->dev.platform_data;
+		if (!pdata || !pdata->flags) {
+			dev_err(&pdev->dev, "platform data not set\n");
+			return -EINVAL;
+		}
+		pdata_flags = pdata->flags;
 	}
 
 	mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
@@ -1441,12 +1492,18 @@ static int rcar_vin_probe(struct platform_device *pdev)
 
 	priv->ici.priv = priv;
 	priv->ici.v4l2_dev.dev = &pdev->dev;
-	priv->ici.nr = pdev->id;
 	priv->ici.drv_name = dev_name(&pdev->dev);
 	priv->ici.ops = &rcar_vin_host_ops;
 
-	priv->pdata_flags = pdata->flags;
-	priv->chip = pdev->id_entry->driver_data;
+	priv->pdata_flags = pdata_flags;
+	if (!match) {
+		priv->ici.nr = pdev->id;
+		priv->chip = pdev->id_entry->driver_data;
+	} else {
+		priv->ici.nr = of_alias_get_id(pdev->dev.of_node, "vin");
+		priv->chip = (enum chip_id)match->data;
+	};
+
 	spin_lock_init(&priv->lock);
 	INIT_LIST_HEAD(&priv->capture);
 
@@ -1487,6 +1544,7 @@ static struct platform_driver rcar_vin_driver = {
 	.driver		= {
 		.name		= DRV_NAME,
 		.owner		= THIS_MODULE,
+		.of_match_table	= of_match_ptr(rcar_vin_of_table),
 	},
 	.id_table	= rcar_vin_id_table,
 };
-- 
1.9.3


^ permalink raw reply related	[flat|nested] 34+ messages in thread

* Re: [PATCH v6 4/6] soc_camera: add support for dt binding soc_camera drivers
  2014-07-23 18:01       ` Guennadi Liakhovetski
@ 2014-07-25  3:23         ` Josh Wu
  -1 siblings, 0 replies; 34+ messages in thread
From: Josh Wu @ 2014-07-25  3:23 UTC (permalink / raw)
  To: Guennadi Liakhovetski, Ben Dooks
  Cc: linux-media, linux-sh, magnus.damm, horms, linux-kernel

Hi, Guennadi

On 7/24/2014 2:01 AM, Guennadi Liakhovetski wrote:
> Add initial support for OF based soc-camera devices that may be used
> by any of the soc-camera drivers. The driver itself will need converting
> to use OF.
>
> These changes allow the soc-camera driver to do the connecting of any
> async capable v4l2 device to the soc-camera driver. This has currently
> been tested on the Renesas Lager board.
>
> It currently only supports one input device per driver as this seems
> to be the standard connection for these devices.
>
> Signed-off-by: Ben Dooks <ben.dooks@codethink.co.uk>
> [g.liakhovetski@gmx.de add check for multiple subdevices]
> Signed-off-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de>
I tested in sama5d3xek board with Atmel-isi dt and ov2640 dt. It works fine.
Tested-by: Josh Wu <josh.wu@atmel.com>

Best Regards,
Josh Wu
> ---
>
> Hi Ben,
>
> How about this version? Could you review and test?
>
> Thanks
> Guennadi
>
>   drivers/media/platform/soc_camera/soc_camera.c | 129 ++++++++++++++++++++++++-
>   1 file changed, 128 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/media/platform/soc_camera/soc_camera.c b/drivers/media/platform/soc_camera/soc_camera.c
> index dc626b9..f4308fe 100644
> --- a/drivers/media/platform/soc_camera/soc_camera.c
> +++ b/drivers/media/platform/soc_camera/soc_camera.c
> @@ -36,6 +36,7 @@
>   #include <media/v4l2-common.h>
>   #include <media/v4l2-ioctl.h>
>   #include <media/v4l2-dev.h>
> +#include <media/v4l2-of.h>
>   #include <media/videobuf-core.h>
>   #include <media/videobuf2-core.h>
>   
> @@ -1585,6 +1586,130 @@ static void scan_async_host(struct soc_camera_host *ici)
>   #define scan_async_host(ici)		do {} while (0)
>   #endif
>   
> +#ifdef CONFIG_OF
> +
> +struct soc_of_info {
> +	struct soc_camera_async_subdev	sasd;
> +	struct soc_camera_async_client	sasc;
> +	struct v4l2_async_subdev	*subdev;
> +};
> +
> +static int soc_of_bind(struct soc_camera_host *ici,
> +		       struct device_node *ep,
> +		       struct device_node *remote)
> +{
> +	struct soc_camera_device *icd;
> +	struct soc_camera_desc sdesc = {.host_desc.bus_id = ici->nr,};
> +	struct soc_camera_async_client *sasc;
> +	struct soc_of_info *info;
> +	struct i2c_client *client;
> +	char clk_name[V4L2_SUBDEV_NAME_SIZE];
> +	int ret;
> +
> +	/* allocate a new subdev and add match info to it */
> +	info = devm_kzalloc(ici->v4l2_dev.dev, sizeof(struct soc_of_info),
> +			    GFP_KERNEL);
> +	if (!info)
> +		return -ENOMEM;
> +
> +	info->sasd.asd.match.of.node = remote;
> +	info->sasd.asd.match_type = V4L2_ASYNC_MATCH_OF;
> +	info->subdev = &info->sasd.asd;
> +
> +	/* Or shall this be managed by the soc-camera device? */
> +	sasc = &info->sasc;
> +
> +	/* HACK: just need a != NULL */
> +	sdesc.host_desc.board_info = ERR_PTR(-ENODATA);
> +
> +	ret = soc_camera_dyn_pdev(&sdesc, sasc);
> +	if (ret < 0)
> +		goto eallocpdev;
> +
> +	sasc->sensor = &info->sasd.asd;
> +
> +	icd = soc_camera_add_pdev(sasc);
> +	if (!icd) {
> +		ret = -ENOMEM;
> +		goto eaddpdev;
> +	}
> +
> +	sasc->notifier.subdevs = &info->subdev;
> +	sasc->notifier.num_subdevs = 1;
> +	sasc->notifier.bound = soc_camera_async_bound;
> +	sasc->notifier.unbind = soc_camera_async_unbind;
> +	sasc->notifier.complete = soc_camera_async_complete;
> +
> +	icd->sasc = sasc;
> +	icd->parent = ici->v4l2_dev.dev;
> +
> +	client = of_find_i2c_device_by_node(remote);
> +
> +	if (client)
> +		snprintf(clk_name, sizeof(clk_name), "%d-%04x",
> +			 client->adapter->nr, client->addr);
> +	else
> +		snprintf(clk_name, sizeof(clk_name), "of-%s",
> +			 of_node_full_name(remote));
> +
> +	icd->clk = v4l2_clk_register(&soc_camera_clk_ops, clk_name, "mclk", icd);
> +	if (IS_ERR(icd->clk)) {
> +		ret = PTR_ERR(icd->clk);
> +		goto eclkreg;
> +	}
> +
> +	ret = v4l2_async_notifier_register(&ici->v4l2_dev, &sasc->notifier);
> +	if (!ret)
> +		return 0;
> +eclkreg:
> +	icd->clk = NULL;
> +	platform_device_del(sasc->pdev);
> +eaddpdev:
> +	platform_device_put(sasc->pdev);
> +eallocpdev:
> +	devm_kfree(ici->v4l2_dev.dev, sasc);
> +	dev_err(ici->v4l2_dev.dev, "group probe failed: %d\n", ret);
> +
> +	return ret;
> +}
> +
> +static void scan_of_host(struct soc_camera_host *ici)
> +{
> +	struct device *dev = ici->v4l2_dev.dev;
> +	struct device_node *np = dev->of_node;
> +	struct device_node *epn = NULL, *ren;
> +	unsigned int i;
> +
> +	for (i = 0; ; i++) {
> +		epn = of_graph_get_next_endpoint(np, epn);
> +		if (!epn)
> +			break;
> +
> +		ren = of_graph_get_remote_port(epn);
> +		if (!ren) {
> +			dev_notice(dev, "no remote for %s\n",
> +				   of_node_full_name(epn));
> +			continue;
> +		}
> +
> +		/* so we now have a remote node to connect */
> +		if (!i)
> +			soc_of_bind(ici, epn, ren->parent);
> +
> +		of_node_put(epn);
> +		of_node_put(ren);
> +
> +		if (i) {
> +			dev_err(dev, "multiple subdevices aren't supported yet!\n");
> +			break;
> +		}
> +	}
> +}
> +
> +#else
> +static inline void scan_of_host(struct soc_camera_host *ici) { }
> +#endif
> +
>   /* Called during host-driver probe */
>   static int soc_camera_probe(struct soc_camera_host *ici,
>   			    struct soc_camera_device *icd)
> @@ -1836,7 +1961,9 @@ int soc_camera_host_register(struct soc_camera_host *ici)
>   	mutex_init(&ici->host_lock);
>   	mutex_init(&ici->clk_lock);
>   
> -	if (ici->asd_sizes)
> +	if (ici->v4l2_dev.dev->of_node)
> +		scan_of_host(ici);
> +	else if (ici->asd_sizes)
>   		/*
>   		 * No OF, host with a list of subdevices. Don't try to mix
>   		 * modes by initialising some groups statically and some


^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: [PATCH v6 4/6] soc_camera: add support for dt binding soc_camera drivers
@ 2014-07-25  3:23         ` Josh Wu
  0 siblings, 0 replies; 34+ messages in thread
From: Josh Wu @ 2014-07-25  3:23 UTC (permalink / raw)
  To: Guennadi Liakhovetski, Ben Dooks
  Cc: linux-media, linux-sh, magnus.damm, horms, linux-kernel

Hi, Guennadi

On 7/24/2014 2:01 AM, Guennadi Liakhovetski wrote:
> Add initial support for OF based soc-camera devices that may be used
> by any of the soc-camera drivers. The driver itself will need converting
> to use OF.
>
> These changes allow the soc-camera driver to do the connecting of any
> async capable v4l2 device to the soc-camera driver. This has currently
> been tested on the Renesas Lager board.
>
> It currently only supports one input device per driver as this seems
> to be the standard connection for these devices.
>
> Signed-off-by: Ben Dooks <ben.dooks@codethink.co.uk>
> [g.liakhovetski@gmx.de add check for multiple subdevices]
> Signed-off-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de>
I tested in sama5d3xek board with Atmel-isi dt and ov2640 dt. It works fine.
Tested-by: Josh Wu <josh.wu@atmel.com>

Best Regards,
Josh Wu
> ---
>
> Hi Ben,
>
> How about this version? Could you review and test?
>
> Thanks
> Guennadi
>
>   drivers/media/platform/soc_camera/soc_camera.c | 129 ++++++++++++++++++++++++-
>   1 file changed, 128 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/media/platform/soc_camera/soc_camera.c b/drivers/media/platform/soc_camera/soc_camera.c
> index dc626b9..f4308fe 100644
> --- a/drivers/media/platform/soc_camera/soc_camera.c
> +++ b/drivers/media/platform/soc_camera/soc_camera.c
> @@ -36,6 +36,7 @@
>   #include <media/v4l2-common.h>
>   #include <media/v4l2-ioctl.h>
>   #include <media/v4l2-dev.h>
> +#include <media/v4l2-of.h>
>   #include <media/videobuf-core.h>
>   #include <media/videobuf2-core.h>
>   
> @@ -1585,6 +1586,130 @@ static void scan_async_host(struct soc_camera_host *ici)
>   #define scan_async_host(ici)		do {} while (0)
>   #endif
>   
> +#ifdef CONFIG_OF
> +
> +struct soc_of_info {
> +	struct soc_camera_async_subdev	sasd;
> +	struct soc_camera_async_client	sasc;
> +	struct v4l2_async_subdev	*subdev;
> +};
> +
> +static int soc_of_bind(struct soc_camera_host *ici,
> +		       struct device_node *ep,
> +		       struct device_node *remote)
> +{
> +	struct soc_camera_device *icd;
> +	struct soc_camera_desc sdesc = {.host_desc.bus_id = ici->nr,};
> +	struct soc_camera_async_client *sasc;
> +	struct soc_of_info *info;
> +	struct i2c_client *client;
> +	char clk_name[V4L2_SUBDEV_NAME_SIZE];
> +	int ret;
> +
> +	/* allocate a new subdev and add match info to it */
> +	info = devm_kzalloc(ici->v4l2_dev.dev, sizeof(struct soc_of_info),
> +			    GFP_KERNEL);
> +	if (!info)
> +		return -ENOMEM;
> +
> +	info->sasd.asd.match.of.node = remote;
> +	info->sasd.asd.match_type = V4L2_ASYNC_MATCH_OF;
> +	info->subdev = &info->sasd.asd;
> +
> +	/* Or shall this be managed by the soc-camera device? */
> +	sasc = &info->sasc;
> +
> +	/* HACK: just need a != NULL */
> +	sdesc.host_desc.board_info = ERR_PTR(-ENODATA);
> +
> +	ret = soc_camera_dyn_pdev(&sdesc, sasc);
> +	if (ret < 0)
> +		goto eallocpdev;
> +
> +	sasc->sensor = &info->sasd.asd;
> +
> +	icd = soc_camera_add_pdev(sasc);
> +	if (!icd) {
> +		ret = -ENOMEM;
> +		goto eaddpdev;
> +	}
> +
> +	sasc->notifier.subdevs = &info->subdev;
> +	sasc->notifier.num_subdevs = 1;
> +	sasc->notifier.bound = soc_camera_async_bound;
> +	sasc->notifier.unbind = soc_camera_async_unbind;
> +	sasc->notifier.complete = soc_camera_async_complete;
> +
> +	icd->sasc = sasc;
> +	icd->parent = ici->v4l2_dev.dev;
> +
> +	client = of_find_i2c_device_by_node(remote);
> +
> +	if (client)
> +		snprintf(clk_name, sizeof(clk_name), "%d-%04x",
> +			 client->adapter->nr, client->addr);
> +	else
> +		snprintf(clk_name, sizeof(clk_name), "of-%s",
> +			 of_node_full_name(remote));
> +
> +	icd->clk = v4l2_clk_register(&soc_camera_clk_ops, clk_name, "mclk", icd);
> +	if (IS_ERR(icd->clk)) {
> +		ret = PTR_ERR(icd->clk);
> +		goto eclkreg;
> +	}
> +
> +	ret = v4l2_async_notifier_register(&ici->v4l2_dev, &sasc->notifier);
> +	if (!ret)
> +		return 0;
> +eclkreg:
> +	icd->clk = NULL;
> +	platform_device_del(sasc->pdev);
> +eaddpdev:
> +	platform_device_put(sasc->pdev);
> +eallocpdev:
> +	devm_kfree(ici->v4l2_dev.dev, sasc);
> +	dev_err(ici->v4l2_dev.dev, "group probe failed: %d\n", ret);
> +
> +	return ret;
> +}
> +
> +static void scan_of_host(struct soc_camera_host *ici)
> +{
> +	struct device *dev = ici->v4l2_dev.dev;
> +	struct device_node *np = dev->of_node;
> +	struct device_node *epn = NULL, *ren;
> +	unsigned int i;
> +
> +	for (i = 0; ; i++) {
> +		epn = of_graph_get_next_endpoint(np, epn);
> +		if (!epn)
> +			break;
> +
> +		ren = of_graph_get_remote_port(epn);
> +		if (!ren) {
> +			dev_notice(dev, "no remote for %s\n",
> +				   of_node_full_name(epn));
> +			continue;
> +		}
> +
> +		/* so we now have a remote node to connect */
> +		if (!i)
> +			soc_of_bind(ici, epn, ren->parent);
> +
> +		of_node_put(epn);
> +		of_node_put(ren);
> +
> +		if (i) {
> +			dev_err(dev, "multiple subdevices aren't supported yet!\n");
> +			break;
> +		}
> +	}
> +}
> +
> +#else
> +static inline void scan_of_host(struct soc_camera_host *ici) { }
> +#endif
> +
>   /* Called during host-driver probe */
>   static int soc_camera_probe(struct soc_camera_host *ici,
>   			    struct soc_camera_device *icd)
> @@ -1836,7 +1961,9 @@ int soc_camera_host_register(struct soc_camera_host *ici)
>   	mutex_init(&ici->host_lock);
>   	mutex_init(&ici->clk_lock);
>   
> -	if (ici->asd_sizes)
> +	if (ici->v4l2_dev.dev->of_node)
> +		scan_of_host(ici);
> +	else if (ici->asd_sizes)
>   		/*
>   		 * No OF, host with a list of subdevices. Don't try to mix
>   		 * modes by initialising some groups statically and some


^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: [PATCH v6 3/6] rcar_vin: add devicetree support
  2014-07-23 18:23       ` Guennadi Liakhovetski
@ 2014-07-25  7:30         ` Ben Dooks
  -1 siblings, 0 replies; 34+ messages in thread
From: Ben Dooks @ 2014-07-25  7:30 UTC (permalink / raw)
  To: Guennadi Liakhovetski
  Cc: linux-media, linux-sh, magnus.damm, horms, linux-kernel

On 23/07/14 19:23, Guennadi Liakhovetski wrote:
> Add support for devicetree probe for the rcar-vin
> driver.
> 
> Signed-off-by: Ben Dooks <ben.dooks@codethink.co.uk>
> [g.liakhovetski@gmx.de fix a typo, sort headers alphabetically]
> Signed-off-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de>
> ---
> 
> Ben, is this version ok?

From looking at it, it seems ok.

I have been off work ill for the last couple of days, so have only
just seen these. I will try and get these reviewed/tests as soon
as possible.

Is there a git branch I could merge with our devel tree?

-- 
Ben Dooks				http://www.codethink.co.uk/
Senior Engineer				Codethink - Providing Genius

^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: [PATCH v6 3/6] rcar_vin: add devicetree support
@ 2014-07-25  7:30         ` Ben Dooks
  0 siblings, 0 replies; 34+ messages in thread
From: Ben Dooks @ 2014-07-25  7:30 UTC (permalink / raw)
  To: Guennadi Liakhovetski
  Cc: linux-media, linux-sh, magnus.damm, horms, linux-kernel

On 23/07/14 19:23, Guennadi Liakhovetski wrote:
> Add support for devicetree probe for the rcar-vin
> driver.
> 
> Signed-off-by: Ben Dooks <ben.dooks@codethink.co.uk>
> [g.liakhovetski@gmx.de fix a typo, sort headers alphabetically]
> Signed-off-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de>
> ---
> 
> Ben, is this version ok?

>From looking at it, it seems ok.

I have been off work ill for the last couple of days, so have only
just seen these. I will try and get these reviewed/tests as soon
as possible.

Is there a git branch I could merge with our devel tree?

-- 
Ben Dooks				http://www.codethink.co.uk/
Senior Engineer				Codethink - Providing Genius

^ permalink raw reply	[flat|nested] 34+ messages in thread

end of thread, other threads:[~2014-07-25  7:30 UTC | newest]

Thread overview: 34+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-07-05 22:26 rcar-vin & soc-camera device tree updates Ben Dooks
2014-07-05 22:26 ` Ben Dooks
2014-07-05 22:26 ` [PATCH 1/6] adv7180: Remove duplicate unregister call Ben Dooks
2014-07-05 22:26   ` Ben Dooks
2014-07-17  7:37   ` Hans Verkuil
2014-07-17  7:37     ` Hans Verkuil
2014-07-05 22:26 ` [PATCH 2/6] rcar_vin: copy flags from pdata Ben Dooks
2014-07-05 22:26   ` Ben Dooks
2014-07-05 22:26 ` [PATCH 3/6] rcar_vin: add devicetree support Ben Dooks
2014-07-05 22:26   ` Ben Dooks
2014-07-23 10:20   ` Guennadi Liakhovetski
2014-07-23 10:20     ` Guennadi Liakhovetski
2014-07-23 18:23     ` [PATCH v6 " Guennadi Liakhovetski
2014-07-23 18:23       ` Guennadi Liakhovetski
2014-07-25  7:30       ` Ben Dooks
2014-07-25  7:30         ` Ben Dooks
2014-07-05 22:26 ` [PATCH 4/6] [V3] soc_camera: add support for dt binding soc_camera drivers Ben Dooks
2014-07-05 22:26   ` Ben Dooks
2014-07-23 18:00   ` Guennadi Liakhovetski
2014-07-23 18:00     ` Guennadi Liakhovetski
2014-07-23 18:01     ` [PATCH v6 4/6] " Guennadi Liakhovetski
2014-07-23 18:01       ` Guennadi Liakhovetski
2014-07-25  3:23       ` Josh Wu
2014-07-25  3:23         ` Josh Wu
2014-07-05 22:26 ` [PATCH 5/6] r8a7790.dtsi: add vin[0-3] nodes Ben Dooks
2014-07-05 22:26   ` Ben Dooks
2014-07-23  8:09   ` Guennadi Liakhovetski
2014-07-23  8:09     ` Guennadi Liakhovetski
2014-07-23  8:40     ` Simon Horman
2014-07-23  8:40       ` Simon Horman
2014-07-05 22:26 ` [PATCH 6/6] [PATCH v2] ARM: lager: add vin1 node Ben Dooks
2014-07-05 22:26   ` Ben Dooks
2014-07-23  8:11   ` Guennadi Liakhovetski
2014-07-23  8:11     ` Guennadi Liakhovetski

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.