devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH RFC 0/3] Make "ti,tilcdc,slave" DT binding more sensible
@ 2015-01-13 17:12 Jyri Sarha
  2015-01-13 17:12 ` [PATCH RFC 1/3] drm: encoder_slave: Add drm_i2c_encoder_attach() Jyri Sarha
                   ` (3 more replies)
  0 siblings, 4 replies; 6+ messages in thread
From: Jyri Sarha @ 2015-01-13 17:12 UTC (permalink / raw)
  To: dri-devel, airlied, linux-omap, devicetree, bcousson, tony
  Cc: tomi.valkeinen, detheridge, Jyri Sarha

These patches are needed for Beaglebone-back HDMI audio. There is no
direct dependency between these patches and the other (dts and ASoC)
changes needed for the HDMI audio so these changes can be merged
independently. I also feel that these changes make sense even without
the HDMI audio.

Best regards,
Jyri

Jyri Sarha (3):
  drm: encoder_slave: Add drm_i2c_encoder_attach()
  drm/tilcdc: slave: Add support for "i2c-slave" DT-parameter
  ARM: dts: am335x-boneblack: Use new binding in ti,tilcdc,slave node

 .../devicetree/bindings/drm/tilcdc/slave.txt       |    4 +-
 arch/arm/boot/dts/am335x-boneblack.dts             |    9 +++-
 drivers/gpu/drm/drm_encoder_slave.c                |   51 ++++++++++++++++++++
 drivers/gpu/drm/tilcdc/tilcdc_slave.c              |   50 +++++++++++--------
 include/drm/drm_encoder_slave.h                    |    3 ++
 5 files changed, 95 insertions(+), 22 deletions(-)

-- 
1.7.9.5


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

* [PATCH RFC 1/3] drm: encoder_slave: Add drm_i2c_encoder_attach()
  2015-01-13 17:12 [PATCH RFC 0/3] Make "ti,tilcdc,slave" DT binding more sensible Jyri Sarha
@ 2015-01-13 17:12 ` Jyri Sarha
  2015-01-13 17:12 ` [PATCH RFC 2/3] drm/tilcdc: slave: Add support for "i2c-slave" DT-parameter Jyri Sarha
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 6+ messages in thread
From: Jyri Sarha @ 2015-01-13 17:12 UTC (permalink / raw)
  To: dri-devel, airlied, linux-omap, devicetree, bcousson, tony
  Cc: tomi.valkeinen, detheridge, Jyri Sarha

Add drm_i2c_encoder_attach() for attaching an already probed i2c
encoder. This is needed for instance if the encoder is probed from
device tree.

Signed-off-by: Jyri Sarha <jsarha@ti.com>
---
 drivers/gpu/drm/drm_encoder_slave.c |   51 +++++++++++++++++++++++++++++++++++
 include/drm/drm_encoder_slave.h     |    3 +++
 2 files changed, 54 insertions(+)

diff --git a/drivers/gpu/drm/drm_encoder_slave.c b/drivers/gpu/drm/drm_encoder_slave.c
index d18b88b..ed627f7 100644
--- a/drivers/gpu/drm/drm_encoder_slave.c
+++ b/drivers/gpu/drm/drm_encoder_slave.c
@@ -120,6 +120,57 @@ void drm_i2c_encoder_destroy(struct drm_encoder *drm_encoder)
 }
 EXPORT_SYMBOL(drm_i2c_encoder_destroy);
 
+/**
+ * drm_i2c_encoder_attach - Attach an I2C slave encoder
+ * @dev:	DRM device.
+ * @encoder:	Encoder to be attached to the I2C device. You aren't
+ *		required to have called drm_encoder_init() before.
+ * @client:	I2C encoder to be attached.
+ *
+ * Attach the I2C device specified to the specified &drm_encoder_slave.
+ * The @slave_funcs field will be initialized with the hooks provided by
+ * the slave driver.
+ *
+ * Returns 0 on success or a negative errno on failure, in particular,
+ * -ENODEV is returned when no matching driver is found.
+ */
+int drm_i2c_encoder_attach(struct drm_device *dev,
+			   struct drm_encoder_slave *encoder,
+			   struct i2c_client *client)
+{
+	struct drm_i2c_encoder_driver *encoder_drv;
+	struct module *module = NULL;
+	int err = 0;
+
+	if (!client->dev.driver) {
+		err = -ENODEV;
+		goto fail;
+	}
+
+	module = client->dev.driver->owner;
+	if (!try_module_get(module)) {
+		err = -ENODEV;
+		goto fail;
+	}
+
+	encoder->bus_priv = client;
+
+	encoder_drv =
+		to_drm_i2c_encoder_driver(to_i2c_driver(client->dev.driver));
+
+	err = encoder_drv->encoder_init(client, dev, encoder);
+	if (err)
+		goto fail_put;
+
+	return 0;
+
+fail_put:
+	module_put(module);
+fail:
+	return err;
+}
+EXPORT_SYMBOL(drm_i2c_encoder_attach);
+
 /*
  * Wrapper fxns which can be plugged in to drm_encoder_helper_funcs:
  */
diff --git a/include/drm/drm_encoder_slave.h b/include/drm/drm_encoder_slave.h
index 8b9cc36..4f7f8d5 100644
--- a/include/drm/drm_encoder_slave.h
+++ b/include/drm/drm_encoder_slave.h
@@ -106,6 +106,9 @@ int drm_i2c_encoder_init(struct drm_device *dev,
 			 struct i2c_adapter *adap,
 			 const struct i2c_board_info *info);
 
+int drm_i2c_encoder_attach(struct drm_device *dev,
+			   struct drm_encoder_slave *encoder,
+			   struct i2c_client *client);
 
 /**
  * struct drm_i2c_encoder_driver
-- 
1.7.9.5


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

* [PATCH RFC 2/3] drm/tilcdc: slave: Add support for "i2c-slave" DT-parameter
  2015-01-13 17:12 [PATCH RFC 0/3] Make "ti,tilcdc,slave" DT binding more sensible Jyri Sarha
  2015-01-13 17:12 ` [PATCH RFC 1/3] drm: encoder_slave: Add drm_i2c_encoder_attach() Jyri Sarha
@ 2015-01-13 17:12 ` Jyri Sarha
       [not found] ` <cover.1421167634.git.jsarha-l0cyMroinI0@public.gmane.org>
  2015-01-14  6:57 ` [PATCH RFC 0/3] Make "ti,tilcdc,slave" DT binding more sensible Jean-Francois Moine
  3 siblings, 0 replies; 6+ messages in thread
From: Jyri Sarha @ 2015-01-13 17:12 UTC (permalink / raw)
  To: dri-devel, airlied, linux-omap, devicetree, bcousson, tony
  Cc: tomi.valkeinen, detheridge, Jyri Sarha

It is more convenient to refer to the i2c slave encoder directly with
phandle than to refer to the i2c bus and to create the device "manually".

Signed-off-by: Jyri Sarha <jsarha@ti.com>
---
 .../devicetree/bindings/drm/tilcdc/slave.txt       |    4 +-
 drivers/gpu/drm/tilcdc/tilcdc_slave.c              |   50 ++++++++++++--------
 2 files changed, 33 insertions(+), 21 deletions(-)

diff --git a/Documentation/devicetree/bindings/drm/tilcdc/slave.txt b/Documentation/devicetree/bindings/drm/tilcdc/slave.txt
index 3d2c524..930550f 100644
--- a/Documentation/devicetree/bindings/drm/tilcdc/slave.txt
+++ b/Documentation/devicetree/bindings/drm/tilcdc/slave.txt
@@ -2,6 +2,8 @@ Device-Tree bindings for tilcdc DRM encoder slave output driver
 
 Required properties:
  - compatible: value should be "ti,tilcdc,slave".
+ - i2c-slave: phandle for the encoder slave device
+ or
  - i2c: the phandle for the i2c device the encoder slave is connected to
 
 Recommended properties:
@@ -12,7 +14,7 @@ Example:
 
 	hdmi {
 		compatible = "ti,tilcdc,slave";
-		i2c = <&i2c0>;
+		i2c-slave = <&tda19988>;
 		pinctrl-names = "default";
 		pinctrl-0 = <&nxp_hdmi_bonelt_pins>;
 	};
diff --git a/drivers/gpu/drm/tilcdc/tilcdc_slave.c b/drivers/gpu/drm/tilcdc/tilcdc_slave.c
index 3775fd4..a1e2f86 100644
--- a/drivers/gpu/drm/tilcdc/tilcdc_slave.c
+++ b/drivers/gpu/drm/tilcdc/tilcdc_slave.c
@@ -25,6 +25,7 @@
 struct slave_module {
 	struct tilcdc_module base;
 	struct i2c_adapter *i2c;
+	struct i2c_client *slave;
 };
 #define to_slave_module(x) container_of(x, struct slave_module, base)
 
@@ -140,7 +141,12 @@ static struct drm_encoder *slave_encoder_create(struct drm_device *dev,
 
 	drm_encoder_helper_add(encoder, &slave_encoder_helper_funcs);
 
-	ret = drm_i2c_encoder_init(dev, to_encoder_slave(encoder), mod->i2c, &info);
+	if (mod->slave)
+		ret = drm_i2c_encoder_attach(dev, to_encoder_slave(encoder),
+					     mod->slave);
+	else
+		ret = drm_i2c_encoder_init(dev, to_encoder_slave(encoder),
+					   mod->i2c, &info);
 	if (ret)
 		goto fail;
 
@@ -309,12 +315,12 @@ static struct of_device_id slave_of_match[];
 static int slave_probe(struct platform_device *pdev)
 {
 	struct device_node *node = pdev->dev.of_node;
-	struct device_node *i2c_node;
+	struct device_node *slave_node;
 	struct slave_module *slave_mod;
 	struct tilcdc_module *mod;
 	struct pinctrl *pinctrl;
-	uint32_t i2c_phandle;
-	struct i2c_adapter *slavei2c;
+	struct i2c_adapter *slavei2c = NULL;
+	struct i2c_client *slave = NULL;
 	int ret = -EINVAL;
 
 	/* bail out early if no DT data: */
@@ -323,26 +329,29 @@ static int slave_probe(struct platform_device *pdev)
 		return -ENXIO;
 	}
 
-	/* Bail out early if i2c not specified */
-	if (of_property_read_u32(node, "i2c", &i2c_phandle)) {
-		dev_err(&pdev->dev, "could not get i2c bus phandle\n");
-		return ret;
-	}
-
-	i2c_node = of_find_node_by_phandle(i2c_phandle);
-	if (!i2c_node) {
-		dev_err(&pdev->dev, "could not get i2c bus node\n");
-		return ret;
+	slave_node = of_parse_phandle(node, "i2c-slave", 0);
+	if (slave_node) {
+		slave = of_find_i2c_device_by_node(slave_node);
+		of_node_put(slave_node);
+	} else {
+		struct device_node *i2c_node = of_parse_phandle(node, "i2c", 0);
+
+		if (!i2c_node) {
+			dev_err(&pdev->dev,
+				"phandle for i2c-slave or i2c not found\n");
+			return -ENODEV;
+		}
+		slavei2c = of_find_i2c_adapter_by_node(i2c_node);
+		of_node_put(i2c_node);
 	}
 
-	/* but defer the probe if it can't be initialized it might come later */
-	slavei2c = of_find_i2c_adapter_by_node(i2c_node);
-	of_node_put(i2c_node);
-
-	if (!slavei2c) {
+	/* defer the probe if either slave device or the i2c bus
+	   was not found, they might come later */
+	if (!slavei2c && !slave) {
 		ret = -EPROBE_DEFER;
 		tilcdc_slave_probedefer(true);
-		dev_err(&pdev->dev, "could not get i2c\n");
+		dev_info(&pdev->dev,
+			 "could not get i2c-slave or i2c, probe defered\n");
 		return ret;
 	}
 
@@ -358,6 +367,7 @@ static int slave_probe(struct platform_device *pdev)
 	mod->preferred_bpp = slave_info.bpp;
 
 	slave_mod->i2c = slavei2c;
+	slave_mod->slave = slave;
 
 	tilcdc_module_init(mod, "slave", &slave_module_ops);
 
-- 
1.7.9.5


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

* [PATCH RFC 3/3] ARM: dts: am335x-boneblack: Use new binding in ti,tilcdc,slave node
       [not found] ` <cover.1421167634.git.jsarha-l0cyMroinI0@public.gmane.org>
@ 2015-01-13 17:12   ` Jyri Sarha
  0 siblings, 0 replies; 6+ messages in thread
From: Jyri Sarha @ 2015-01-13 17:12 UTC (permalink / raw)
  To: dri-devel-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW, airlied-cv59FeDIM0c,
	linux-omap-u79uwXL29TY76Z2rM5mHXA,
	devicetree-u79uwXL29TY76Z2rM5mHXA,
	bcousson-rdvid1DuHRBWk0Htik3J/w, tony-4v6yS6AI5VpBDgjK7y7TUQ
  Cc: tomi.valkeinen-l0cyMroinI0, detheridge-l0cyMroinI0, Jyri Sarha

Add node for NXP TDA19988 encoder and refer to it in the hdmi node
instead of referring to the i2c bus where the encoder is connected to.

Signed-off-by: Jyri Sarha <jsarha-l0cyMroinI0@public.gmane.org>
---
 arch/arm/boot/dts/am335x-boneblack.dts |    9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/arch/arm/boot/dts/am335x-boneblack.dts b/arch/arm/boot/dts/am335x-boneblack.dts
index 5c42d25..c0c8e4b 100644
--- a/arch/arm/boot/dts/am335x-boneblack.dts
+++ b/arch/arm/boot/dts/am335x-boneblack.dts
@@ -70,10 +70,17 @@
 	status = "okay";
 };
 
+&i2c0 {
+	tda19988: tda19988@70 {
+		compatible = "nxp,tda998x";
+		reg = <0x70>;
+	};
+};
+
 / {
 	hdmi {
 		compatible = "ti,tilcdc,slave";
-		i2c = <&i2c0>;
+		i2c-slave = <&tda19988>;
 		pinctrl-names = "default", "off";
 		pinctrl-0 = <&nxp_hdmi_bonelt_pins>;
 		pinctrl-1 = <&nxp_hdmi_bonelt_off_pins>;
-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* Re: [PATCH RFC 0/3] Make "ti,tilcdc,slave" DT binding more sensible
  2015-01-13 17:12 [PATCH RFC 0/3] Make "ti,tilcdc,slave" DT binding more sensible Jyri Sarha
                   ` (2 preceding siblings ...)
       [not found] ` <cover.1421167634.git.jsarha-l0cyMroinI0@public.gmane.org>
@ 2015-01-14  6:57 ` Jean-Francois Moine
  2015-01-14  9:56   ` Jyri Sarha
  3 siblings, 1 reply; 6+ messages in thread
From: Jean-Francois Moine @ 2015-01-14  6:57 UTC (permalink / raw)
  To: Jyri Sarha
  Cc: devicetree, dri-devel, detheridge, tony, tomi.valkeinen, bcousson,
	linux-omap

On Tue, 13 Jan 2015 19:12:25 +0200
Jyri Sarha <jsarha@ti.com> wrote:

> These patches are needed for Beaglebone-back HDMI audio. There is no
> direct dependency between these patches and the other (dts and ASoC)
> changes needed for the HDMI audio so these changes can be merged
> independently. I also feel that these changes make sense even without
> the HDMI audio.
> 
> Best regards,
> Jyri
> 
> Jyri Sarha (3):
>   drm: encoder_slave: Add drm_i2c_encoder_attach()
>   drm/tilcdc: slave: Add support for "i2c-slave" DT-parameter
>   ARM: dts: am335x-boneblack: Use new binding in ti,tilcdc,slave node
> 
>  .../devicetree/bindings/drm/tilcdc/slave.txt       |    4 +-
>  arch/arm/boot/dts/am335x-boneblack.dts             |    9 +++-
>  drivers/gpu/drm/drm_encoder_slave.c                |   51 ++++++++++++++++++++
>  drivers/gpu/drm/tilcdc/tilcdc_slave.c              |   50 +++++++++++--------
>  include/drm/drm_encoder_slave.h                    |    3 ++
>  5 files changed, 95 insertions(+), 22 deletions(-)

Instead of adding code to have the slave encoder working, it would be
simpler to change the way tilcdc uses the tda998x.
I already proposed such a patch:

http://lists.freedesktop.org/archives/dri-devel/2014-March/056065.html

and the changes in the tda998x driver have been done by Russell:

commit: a8f4d4d63739e4bca459ff40636f1d9e4b7ef5e6
	drm/i2c: tda998x: allow re-use of tda998x support code
and
commit: c707c3619ca81f499a5ce032021405e989a96ff0
	drm/i2c: tda998x: add component support

-- 
Ken ar c'hentañ	|	      ** Breizh ha Linux atav! **
Jef		|		http://moinejf.free.fr/
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dri-devel

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

* Re: [PATCH RFC 0/3] Make "ti,tilcdc,slave" DT binding more sensible
  2015-01-14  6:57 ` [PATCH RFC 0/3] Make "ti,tilcdc,slave" DT binding more sensible Jean-Francois Moine
@ 2015-01-14  9:56   ` Jyri Sarha
  0 siblings, 0 replies; 6+ messages in thread
From: Jyri Sarha @ 2015-01-14  9:56 UTC (permalink / raw)
  To: Jean-Francois Moine
  Cc: dri-devel, airlied, linux-omap, devicetree, bcousson, tony,
	detheridge, tomi.valkeinen

On 01/14/2015 08:57 AM, Jean-Francois Moine wrote:
> On Tue, 13 Jan 2015 19:12:25 +0200
> Jyri Sarha <jsarha@ti.com> wrote:
>
>> These patches are needed for Beaglebone-back HDMI audio. There is no
>> direct dependency between these patches and the other (dts and ASoC)
>> changes needed for the HDMI audio so these changes can be merged
>> independently. I also feel that these changes make sense even without
>> the HDMI audio.
>>
>> Best regards,
>> Jyri
>>
>> Jyri Sarha (3):
>>    drm: encoder_slave: Add drm_i2c_encoder_attach()
>>    drm/tilcdc: slave: Add support for "i2c-slave" DT-parameter
>>    ARM: dts: am335x-boneblack: Use new binding in ti,tilcdc,slave node
>>
>>   .../devicetree/bindings/drm/tilcdc/slave.txt       |    4 +-
>>   arch/arm/boot/dts/am335x-boneblack.dts             |    9 +++-
>>   drivers/gpu/drm/drm_encoder_slave.c                |   51 ++++++++++++++++++++
>>   drivers/gpu/drm/tilcdc/tilcdc_slave.c              |   50 +++++++++++--------
>>   include/drm/drm_encoder_slave.h                    |    3 ++
>>   5 files changed, 95 insertions(+), 22 deletions(-)
>
> Instead of adding code to have the slave encoder working, it would be
> simpler to change the way tilcdc uses the tda998x.
> I already proposed such a patch:
>
> http://lists.freedesktop.org/archives/dri-devel/2014-March/056065.html
>
> and the changes in the tda998x driver have been done by Russell:
>
> commit: a8f4d4d63739e4bca459ff40636f1d9e4b7ef5e6
> 	drm/i2c: tda998x: allow re-use of tda998x support code
> and
> commit: c707c3619ca81f499a5ce032021405e989a96ff0
> 	drm/i2c: tda998x: add component support
>

Interesting. Would you still have the original branch somewhere? Manual 
applying the patches from the web-page is time consuming.

Best regards,
Jyri

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

end of thread, other threads:[~2015-01-14  9:56 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-01-13 17:12 [PATCH RFC 0/3] Make "ti,tilcdc,slave" DT binding more sensible Jyri Sarha
2015-01-13 17:12 ` [PATCH RFC 1/3] drm: encoder_slave: Add drm_i2c_encoder_attach() Jyri Sarha
2015-01-13 17:12 ` [PATCH RFC 2/3] drm/tilcdc: slave: Add support for "i2c-slave" DT-parameter Jyri Sarha
     [not found] ` <cover.1421167634.git.jsarha-l0cyMroinI0@public.gmane.org>
2015-01-13 17:12   ` [PATCH RFC 3/3] ARM: dts: am335x-boneblack: Use new binding in ti,tilcdc,slave node Jyri Sarha
2015-01-14  6:57 ` [PATCH RFC 0/3] Make "ti,tilcdc,slave" DT binding more sensible Jean-Francois Moine
2015-01-14  9:56   ` Jyri Sarha

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).