Skip to contentSkip to conversation

Sil9022 DPI to HDMI Encoder

RFC PATCH In review Sathya Prakash M R 4 participants 8 messages Mar 18, 2014

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

cover Sil9022 DPI to HDMI Encoder

This patch series adds the Silicon Image Sil9022 driver.

Sil9022 is HDMI Transmitter compliant to HDMI 1.2a and DVI 1.0.
It supports 1080p and UXGA. It has single slave I2C from Host,
passing through to master I2C interface for DDC Connection.
It provides Transmitter Programming Interface (TPI) for simplified API programming. Product brief:
http://www.semiconductorstore.com/pdf/newsite/siliconimage/SiI9022a_pb.pdf

Current driver is tested on AM43x SOC.

This series is on top of series posted to add DSS support on AM43x [2]
[2] https://patchwork.kernel.org/patch/3822691/

This is initial driver supporting limited features.

TODO ->
Audio Support
Detailed Hot Plug event handling and also routing the hot plug event to host processor

These features will be added in future.

Sathya Prakash M R (2):
OMAPDSS: Add Sil9022 DPI-HDMI Encoder Driver
ARM: DTS: AM43x: Add sii9022 dt information

 arch/arm/boot/dts/am437x-gp-evm.dts                |   58 +-
 arch/arm/boot/dts/am43x-epos-evm.dts               |   59 +-
 drivers/video/omap2/displays-new/Kconfig           |    8 +
 drivers/video/omap2/displays-new/Makefile          |    1 +
 drivers/video/omap2/displays-new/encoder-sil9022.c |  748 ++++++++++++++++++++
 drivers/video/omap2/displays-new/encoder-sil9022.h |  105 +++
 6 files changed, 973 insertions(+), 6 deletions(-)
 create mode 100644 drivers/video/omap2/displays-new/encoder-sil9022.c
 create mode 100644 drivers/video/omap2/displays-new/encoder-sil9022.h
Signature · 1 line
1.7.9.5
#1 lore raw

PATCH 1/2 OMAPDSS: Add Sil9022 DPI-HDMI Encoder Driver

Sil9022 DPI to HDMI Encoder driver is part of
AM43xx SOC. Adding the basic Sil9022 driver
HPD and Audio support is not present yet.

---
 drivers/video/omap2/displays-new/Kconfig           |    8 +
 drivers/video/omap2/displays-new/Makefile          |    1 +
 drivers/video/omap2/displays-new/encoder-sil9022.c |  748 ++++++++++++++++++++
 drivers/video/omap2/displays-new/encoder-sil9022.h |  105 +++
 4 files changed, 862 insertions(+)
 create mode 100644 drivers/video/omap2/displays-new/encoder-sil9022.c
 create mode 100644 drivers/video/omap2/displays-new/encoder-sil9022.h
drivers/video/omap2/displays-new/Kconfig +8 -0
index e6cfc38..9243dd7 100644
@@ -12,6 +12,14 @@ config DISPLAY_ENCODER_TPD12S015
 	  Driver for TPD12S015, which offers HDMI ESD protection and level
 	  shifting.
 
+config DISPLAY_ENCODER_SIL9022
+        tristate "Sil9022 DPI to HDMI Encoder"
+	depends on I2C
+	help
+	  Driver for Silicon Image Sil9022 DPI to HDMI encoder and
+	  a brief about Sil9022 can be found here:
+	  http://www.semiconductorstore.com/pdf/newsite/siliconimage/SiI9022a_pb.pdf
+
 config DISPLAY_CONNECTOR_DVI
         tristate "DVI Connector"
 	depends on I2C
drivers/video/omap2/displays-new/Makefile +1 -0
index 0323a8a..f3c8997 100644
@@ -1,5 +1,6 @@
 obj-$(CONFIG_DISPLAY_ENCODER_TFP410) += encoder-tfp410.o
 obj-$(CONFIG_DISPLAY_ENCODER_TPD12S015) += encoder-tpd12s015.o
+obj-$(CONFIG_DISPLAY_ENCODER_SIL9022) += encoder-sil9022.o
 obj-$(CONFIG_DISPLAY_CONNECTOR_DVI) += connector-dvi.o
 obj-$(CONFIG_DISPLAY_CONNECTOR_HDMI) += connector-hdmi.o
 obj-$(CONFIG_DISPLAY_CONNECTOR_ANALOG_TV) += connector-analog-tv.o
drivers/video/omap2/displays-new/encoder-sil9022.c new file +748 -0

748 lines not on this page · raw message

drivers/video/omap2/displays-new/encoder-sil9022.h new file +105 -0

105 lines not on this page · raw message

Signature · 1 line
1.7.9.5
#3 lore raw

PATCH 2/2 ARM: DTS: AM43x: Add sii9022 dt information

In reply to Sathya Prakash M R

AM43x-epos and AM437x-gp device use external sii9022 DPI to HDMI encoder.
Sii9022 use i2c for communication.
Sii9022 dt entries are added to corresponding dts.

---
 arch/arm/boot/dts/am437x-gp-evm.dts  |   58 +++++++++++++++++++++++++++++++--
 arch/arm/boot/dts/am43x-epos-evm.dts |   59 ++++++++++++++++++++++++++++++++--
 2 files changed, 111 insertions(+), 6 deletions(-)
arch/arm/boot/dts/am437x-gp-evm.dts +55 -3
index a178e8d..c4225b1 100644
@@ -51,6 +51,41 @@
 			remote-endpoint = <&dpi_out>;
 		};
 	};
+
+	sii9022: encoder@0 {
+		compatible = "sii,sii9022";
+		reset-gpio = <&gpio5 8 GPIO_ACTIVE_LOW>;/* 'SelLCDorHDMI' Gpio, LOW to select HDMI */
+
+		ports {
+			#address-cells = <1>;
+			#size-cells = <0>;
+
+			port@0 {
+				reg = <0>;
+
+				sii9022_in: endpoint@0 {
+					remote-endpoint = <&dpi_out>;
+				};
+			};
+
+			port@1 {
+				reg = <1>;
+
+				sii9022_out: endpoint@0 {
+					remote-endpoint = <&hdmi_connector_in>;
+				};
+			};
+		};
+	};
+
+	hdmi0: connector@0 {
+		compatible = "hdmi-connector";
+		label = "hdmi";
+
+		hdmi_connector_in: endpoint {
+			remote-endpoint = <&sil9022_out>;
+		};
+	};
 };
 
 &am43xx_pinmux {
@@ -119,6 +154,9 @@
         status = "okay";
         pinctrl-names = "default";
         pinctrl-0 = <&i2c1_pins>;
+	&sii9022 {
+		reg = <0x3b>;
+	}
 };
 
 &epwmss0 {
@@ -141,8 +179,22 @@
 	pinctrl-names = "default";
 	pinctrl-0 = <&dss_pinctrl>;
 
-	dpi_out: endpoint@0 {
-		remote-endpoint = <&lcd_in>;
-		data-lines = <24>;
+	ports {
+		#address-cells = <1>;
+		#size-cells = <0>;
+
+		port@0 {
+			reg = <0>;
+			dpi_out: endpoint@0 {
+				remote-endpoint = <&lcd_in>;
+				data-lines = <24>;
+			};
+
+			dpi_out:endpoint@1 {
+				remote-endpoint = <&sii9022_in>;
+				data-lines = <24>;
+
+			};
+		};
 	};
 };
arch/arm/boot/dts/am43x-epos-evm.dts +56 -3

82 lines not on this page · raw message

Signature · 1 line
1.7.9.5
#4 lore raw

Re: [PATCH 2/2] ARM: DTS: AM43x: Add sii9022 dt information

Quoted 16 lines · Sathya Prakash M R

AM43x-epos and AM437x-gp device use external sii9022 DPI to HDMI encoder.
Sii9022 use i2c for communication.
Sii9022 dt entries are added to corresponding dts.

---
 arch/arm/boot/dts/am437x-gp-evm.dts  |   58 +++++++++++++++++++++++++++++++--
 arch/arm/boot/dts/am43x-epos-evm.dts |   59 ++++++++++++++++++++++++++++++++--
 2 files changed, 111 insertions(+), 6 deletions(-)
arch/arm/boot/dts/am437x-gp-evm.dts +0 -0
index a178e8d..c4225b1 100644

arch/arm/boot/dts/am437x-gp-evm.dts line 56

Quoted 6 lines
arch/arm/boot/dts/am437x-gp-evm.dts +3 -0
@@ -51,6 +51,41 @@
 			remote-endpoint = <&dpi_out>;
 		};
 	};
+
+	sii9022: encoder@0 {
+		compatible = "sii,sii9022";

See Documentation/devicetree/bindings/vendor-prefixes.txt

The vendor prefix is "sil".

Quoted 36 lines
arch/arm/boot/dts/am437x-gp-evm.dts +32 -0
+		reset-gpio = <&gpio5 8 GPIO_ACTIVE_LOW>;/* 'SelLCDorHDMI' Gpio, LOW to select HDMI */
+
+		ports {
+			#address-cells = <1>;
+			#size-cells = <0>;
+
+			port@0 {
+				reg = <0>;
+
+				sii9022_in: endpoint@0 {
+					remote-endpoint = <&dpi_out>;
+				};
+			};
+
+			port@1 {
+				reg = <1>;
+
+				sii9022_out: endpoint@0 {
+					remote-endpoint = <&hdmi_connector_in>;
+				};
+			};
+		};
+	};
+
+	hdmi0: connector@0 {
+		compatible = "hdmi-connector";
+		label = "hdmi";
+
+		hdmi_connector_in: endpoint {
+			remote-endpoint = <&sil9022_out>;
+		};
+	};
 };
 
 &am43xx_pinmux {

arch/arm/boot/dts/am437x-gp-evm.dts line 159

Quoted 6 lines
arch/arm/boot/dts/am437x-gp-evm.dts +3 -0
@@ -119,6 +154,9 @@
         status = "okay";
         pinctrl-names = "default";
         pinctrl-0 = <&i2c1_pins>;
+	&sii9022 {
+		reg = <0x3b>;
+	}

This looks very very odd... The whole sii9022 node should be here.

Quoted 16 lines
arch/arm/boot/dts/am437x-gp-evm.dts +6 -3
 };
 
 &epwmss0 {
@@ -141,8 +179,22 @@
 	pinctrl-names = "default";
 	pinctrl-0 = <&dss_pinctrl>;
 
-	dpi_out: endpoint@0 {
-		remote-endpoint = <&lcd_in>;
-		data-lines = <24>;
+	ports {
+		#address-cells = <1>;
+		#size-cells = <0>;
+
+		port@0 {
+			reg = <0>;

arch/arm/boot/dts/am437x-gp-evm.dts line 197

Quoted 10 lines
arch/arm/boot/dts/am437x-gp-evm.dts +10 -0
+			dpi_out: endpoint@0 {
+				remote-endpoint = <&lcd_in>;
+				data-lines = <24>;
+			};
+
+			dpi_out:endpoint@1 {
+				remote-endpoint = <&sii9022_in>;
+				data-lines = <24>;
+
+			};

You add the same label, "dpi_out" to both endpoints. Does this even compile?

As there's just one port, you can leave out the 'ports' node.

Tomi

#7 lore raw
In reply to Sathya Prakash M R
Quoted 26 lines · Sathya Prakash M R

This patch series adds the Silicon Image Sil9022 driver.

Sil9022 is HDMI Transmitter compliant to HDMI 1.2a and DVI 1.0.
It supports 1080p and UXGA. It has single slave I2C from Host,
passing through to master I2C interface for DDC Connection.
It provides Transmitter Programming Interface (TPI) for simplified API programming. Product brief:
http://www.semiconductorstore.com/pdf/newsite/siliconimage/SiI9022a_pb.pdf

Current driver is tested on AM43x SOC.

This series is on top of series posted to add DSS support on AM43x [2]
[2] https://patchwork.kernel.org/patch/3822691/

This is initial driver supporting limited features.

TODO ->
Audio Support
Detailed Hot Plug event handling and also routing the hot plug event to host processor

These features will be added in future.

Sathya Prakash M R (2):
OMAPDSS: Add Sil9022 DPI-HDMI Encoder Driver
ARM: DTS: AM43x: Add sii9022 dt information

Quoted 9 lines
 arch/arm/boot/dts/am437x-gp-evm.dts                |   58 +-
 arch/arm/boot/dts/am43x-epos-evm.dts               |   59 +-
 drivers/video/omap2/displays-new/Kconfig           |    8 +
 drivers/video/omap2/displays-new/Makefile          |    1 +
 drivers/video/omap2/displays-new/encoder-sil9022.c |  748 ++++++++++++++++++++
 drivers/video/omap2/displays-new/encoder-sil9022.h |  105 +++
 6 files changed, 973 insertions(+), 6 deletions(-)
 create mode 100644 drivers/video/omap2/displays-new/encoder-sil9022.c
 create mode 100644 drivers/video/omap2/displays-new/encoder-sil9022.h

Is there already a binding document?

If not, please add one.

Cheers,
Mark.

#5 lore raw

Re: [PATCH 2/2] ARM: DTS: AM43x: Add sii9022 dt information

In reply to Tomi Valkeinen
Quoted 25 lines · Tomi Valkeinen
Quoted 16 lines · Sathya Prakash M R

AM43x-epos and AM437x-gp device use external sii9022 DPI to HDMI encoder.
Sii9022 use i2c for communication.
Sii9022 dt entries are added to corresponding dts.

---
  arch/arm/boot/dts/am437x-gp-evm.dts  |   58 +++++++++++++++++++++++++++++++--
  arch/arm/boot/dts/am43x-epos-evm.dts |   59 ++++++++++++++++++++++++++++++++--
  2 files changed, 111 insertions(+), 6 deletions(-)
arch/arm/boot/dts/am437x-gp-evm.dts +0 -0
index a178e8d..c4225b1 100644

arch/arm/boot/dts/am437x-gp-evm.dts line 56

Quoted 6 lines
arch/arm/boot/dts/am437x-gp-evm.dts +3 -0
@@ -51,6 +51,41 @@
  			remote-endpoint = <&dpi_out>;
  		};
  	};
+
+	sii9022: encoder@0 {
+		compatible = "sii,sii9022";

See Documentation/devicetree/bindings/vendor-prefixes.txt

Quoted 1 line

The vendor prefix is "sil".

My bad. that was typo.

Quoted 35 lines
Quoted 35 lines
arch/arm/boot/dts/am437x-gp-evm.dts +32 -0
+		reset-gpio = <&gpio5 8 GPIO_ACTIVE_LOW>;/* 'SelLCDorHDMI' Gpio, LOW to select HDMI */
+
+		ports {
+			#address-cells = <1>;
+			#size-cells = <0>;
+
+			port@0 {
+				reg = <0>;
+
+				sii9022_in: endpoint@0 {
+					remote-endpoint = <&dpi_out>;
+				};
+			};
+
+			port@1 {
+				reg = <1>;
+
+				sii9022_out: endpoint@0 {
+					remote-endpoint = <&hdmi_connector_in>;
+				};
+			};
+		};
+	};
+
+	hdmi0: connector@0 {
+		compatible = "hdmi-connector";
+		label = "hdmi";
+
+		hdmi_connector_in: endpoint {
+			remote-endpoint = <&sil9022_out>;
+		};
+	};
  };
 
Quoted 9 lines

arch/arm/boot/dts/am437x-gp-evm.dts line 159

Quoted 8 lines
arch/arm/boot/dts/am437x-gp-evm.dts +3 -0
  &am43xx_pinmux {
@@ -119,6 +154,9 @@
          status = "okay";
          pinctrl-names = "default";
          pinctrl-0 = <&i2c1_pins>;
+	&sii9022 {
+		reg = <0x3b>;
+	}

This looks very very odd... The whole sii9022 node should be here.

ok. i was also bit confused with this placement.

Quoted 29 lines
Quoted 17 lines
arch/arm/boot/dts/am437x-gp-evm.dts +6 -3
  };
 
  &epwmss0 {
@@ -141,8 +179,22 @@
  	pinctrl-names = "default";
  	pinctrl-0 = <&dss_pinctrl>;
 
-	dpi_out: endpoint@0 {
-		remote-endpoint = <&lcd_in>;
-		data-lines = <24>;
+	ports {
+		#address-cells = <1>;
+		#size-cells = <0>;
+
+		port@0 {
+			reg = <0>;

arch/arm/boot/dts/am437x-gp-evm.dts line 197

Quoted 10 lines
arch/arm/boot/dts/am437x-gp-evm.dts +10 -0
+			dpi_out: endpoint@0 {
+				remote-endpoint = <&lcd_in>;
+				data-lines = <24>;
+			};
+
+			dpi_out:endpoint@1 {
+				remote-endpoint = <&sii9022_in>;
+				data-lines = <24>;
+
+			};

You add the same label, "dpi_out" to both endpoints. Does this even compile?

Quoted 1 line

As there's just one port, you can leave out the 'ports' node.

Will check. the ports was added as per documentation in video-interfaces.txt Can you suggest how to add the 2 dpi_out endpoints?
Thanks

Quoted 3 lines

Tomi

Sathya

#6 lore raw

Re: [PATCH 2/2] ARM: DTS: AM43x: Add sii9022 dt information

Quoted 6 lines · Sathya Prakash
Quoted 4 lines

You add the same label, "dpi_out" to both endpoints. Does this even compile?

As there's just one port, you can leave out the 'ports' node.

Will check. the ports was added as per documentation in video-interfaces.txt

It mentions that the 'ports' is optional.

Quoted 1 line

Can you suggest how to add the 2 dpi_out endpoints?

Didn't try, but:

port {
	#address-cells = <1>;
	#size-cells = <0>;

	dpi_lcd_out: endpoint@0 {
		reg = <0>;
		remote-endpoint = <&lcd_in>;
		data-lines = <24>;
	};

	dpi_sii_out: endpoint@1 {
		reg = <1>;
		remote-endpoint = <&sii9022_in>;
		data-lines = <24>;
	};
};

However, we still need to handle the GPIO which is used to select the LCD or HDMI. So, maybe the above works, but we should try the encoder-gpio-switch to handle the GPIO, which we discussed about earlier.

Tomi

#2 lore raw

Re: [PATCH 1/2] OMAPDSS: Add Sil9022 DPI-HDMI Encoder Driver

In reply to Sathya Prakash M R

Hi Sathya,

Quoted 2 lines · Sathya Prakash M R

Sil9022 DPI to HDMI Encoder driver is part of
AM43xx SOC. Adding the basic Sil9022 driver

Umm it's not part of AM43xx SoC...

Quoted 17 lines

HPD and Audio support is not present yet.

---
 drivers/video/omap2/displays-new/Kconfig           |    8 +
 drivers/video/omap2/displays-new/Makefile          |    1 +
 drivers/video/omap2/displays-new/encoder-sil9022.c |  748 ++++++++++++++++++++
 drivers/video/omap2/displays-new/encoder-sil9022.h |  105 +++
 4 files changed, 862 insertions(+)
 create mode 100644 drivers/video/omap2/displays-new/encoder-sil9022.c
 create mode 100644 drivers/video/omap2/displays-new/encoder-sil9022.h
drivers/video/omap2/displays-new/Kconfig +0 -0
index e6cfc38..9243dd7 100644

drivers/video/omap2/displays-new/Kconfig config DISPLAY_ENCODER_TPD12S015 · line 16

Quoted 5 lines
drivers/video/omap2/displays-new/Kconfig +2 -0
@@ -12,6 +12,14 @@ config DISPLAY_ENCODER_TPD12S015
 	  Driver for TPD12S015, which offers HDMI ESD protection and level
 	  shifting.
 
+config DISPLAY_ENCODER_SIL9022
+        tristate "Sil9022 DPI to HDMI Encoder"

Use a tab there.

Quoted 26 lines
drivers/video/omap2/displays-new/Kconfig +6 -0
+	depends on I2C
+	help
+	  Driver for Silicon Image Sil9022 DPI to HDMI encoder and
+	  a brief about Sil9022 can be found here:
+	  http://www.semiconductorstore.com/pdf/newsite/siliconimage/SiI9022a_pb.pdf
+
 config DISPLAY_CONNECTOR_DVI
         tristate "DVI Connector"
 	depends on I2C
drivers/video/omap2/displays-new/Makefile +1 -0
index 0323a8a..f3c8997 100644
@@ -1,5 +1,6 @@
 obj-$(CONFIG_DISPLAY_ENCODER_TFP410) += encoder-tfp410.o
 obj-$(CONFIG_DISPLAY_ENCODER_TPD12S015) += encoder-tpd12s015.o
+obj-$(CONFIG_DISPLAY_ENCODER_SIL9022) += encoder-sil9022.o
 obj-$(CONFIG_DISPLAY_CONNECTOR_DVI) += connector-dvi.o
 obj-$(CONFIG_DISPLAY_CONNECTOR_HDMI) += connector-hdmi.o
 obj-$(CONFIG_DISPLAY_CONNECTOR_ANALOG_TV) += connector-analog-tv.o
drivers/video/omap2/displays-new/encoder-sil9022.c new file +0 -0
new file mode 100644
index 0000000..411867b

drivers/video/omap2/displays-new/encoder-sil9022.c line 2

Quoted 2 lines
drivers/video/omap2/displays-new/encoder-sil9022.c new file +2 -0
@@ -0,0 +1,748 @@
+/*
+ * Silicon image Sil9022 DPI-to-HDMI encoder driver

The chip is SiI9022, not Sil, according to the specs from Silicon Image. I'm not sure what would be the best naming all around, but at least in the comments and Kconfig help texts it would be best to use the correct names to help finding the chip with google.

Quoted 20 lines
drivers/video/omap2/displays-new/encoder-sil9022.c new file +20 -0
+ *
+ * Copyright (C) 2013 Texas Instruments
+ * Author: Sathya Prakash M R <[email protected]>
+ *
+ * This file is licensed under the terms of the GNU General Public License
+ * version 2. This program is licensed "as is" without any warranty of any
+ * kind, whether express or implied.
+ *
+ */
+
+#include <linux/module.h>
+#include <linux/kernel.h>
+#include <linux/errno.h>
+#include <linux/string.h>
+#include <linux/types.h>
+#include <linux/slab.h>
+#include <linux/io.h>
+#include <linux/init.h>
+#include <linux/interrupt.h>
+#include <linux/i2c.h>

drivers/video/omap2/displays-new/encoder-sil9022.c line 32

Quoted 10 lines
drivers/video/omap2/displays-new/encoder-sil9022.c new file +10 -0
+#include <linux/device.h>
+#include <linux/delay.h>
+#include <linux/gpio.h>
+#include <linux/platform_device.h>
+#include <linux/regmap.h>
+#include <linux/of_gpio.h>
+
+#include <video/omapdss.h>
+#include <video/omap-panel-data.h>
+#include "encoder-sil9022.h"

You should quickly go though the includes, and remove unneeded ones. There are no platform devices here, nor is video/omap-panel-data.h needed.

Quoted 4 lines
drivers/video/omap2/displays-new/encoder-sil9022.c new file +4 -0
+struct panel_drv_data {
+	struct omap_dss_device dssdev;
+	struct omap_dss_device *in;
+	struct i2c_client *i2c_client;

drivers/video/omap2/displays-new/encoder-sil9022.c line 47

Quoted 10 lines
drivers/video/omap2/displays-new/encoder-sil9022.c new file +10 -0
+	int reset_gpio;
+	int data_lines;
+	struct regmap *regmap;
+	struct omap_video_timings timings;
+};
+
+static struct regmap_config sil9022_regmap_config = {
+	.reg_bits = 8,
+	.val_bits = 8,
+};

Can this be const?

Quoted 38 lines
drivers/video/omap2/displays-new/encoder-sil9022.c new file +38 -0
+
+
+#define to_panel_data(x) container_of(x, struct panel_drv_data, dssdev)
+
+static int sil9022_ddc_read(struct i2c_client *client,
+		unsigned char *buf, u16 count, u8 offset)
+{
+	int r, retries;
+
+	for (retries = 3; retries > 0; retries--) {
+		struct i2c_msg msgs[] = {
+			{
+				.addr   = 0x50,
+				.flags  = 0,
+				.len    = 1,
+				.buf    = &offset,
+			}, {
+				.addr   = 0x50,
+				.flags  = I2C_M_RD,
+				.len    = count,
+				.buf    = buf,
+			}
+		};
+
+		r = i2c_transfer(client->adapter, msgs, 2);
+		if (r == 2)
+			return 0;
+
+		if (r != -EAGAIN)
+			break;
+	}
+
+	return r < 0 ? r : -EIO;
+}
+
+static int sil9022_hw_enable(struct omap_dss_device *dssdev)
+{
+	int		r = 0;

drivers/video/omap2/displays-new/encoder-sil9022.c line 95

Quoted 10 lines
drivers/video/omap2/displays-new/encoder-sil9022.c new file +10 -0
+	u8		vals[8];
+	unsigned int val;
+	u16		xres;
+	u16		yres;
+	u16		pclk;
+
+	struct panel_drv_data *ddata = to_panel_data(dssdev);
+	struct omap_video_timings *hdmi_timings = &ddata->timings;
+	struct i2c_client *sil9022_client = ddata->i2c_client;
+	struct regmap *map = ddata->regmap;

Use a consistent style. If you align variable names like you do for xres, yes, etc., use it for everything. I think personally it's cleaner to not align them.

drivers/video/omap2/displays-new/encoder-sil9022.c line 101

Quoted 6 lines
drivers/video/omap2/displays-new/encoder-sil9022.c new file +6 -0
+
+	xres = hdmi_timings->x_res;
+	yres = hdmi_timings->y_res;
+	pclk = hdmi_timings->pixel_clock;
+
+	dev_info(dssdev->dev,

In the minimum change the dev_info()s to dev_dbg(). Even better, have a bit thought and see if they are needed at all or were they only useful for early device bring-up.

drivers/video/omap2/displays-new/encoder-sil9022.c line 113

Quoted 12 lines
drivers/video/omap2/displays-new/encoder-sil9022.c new file +12 -0
+			 "sii9022_ENABLE -> Timings\n"
+			 "pixel_clk			= %d\n"
+			 "horizontal res		= %d\n"
+			 "vertical res			= %d\n",
+			 pclk, xres, yres);
+
+	/*  Fill the TPI Video Mode Data structure */
+	vals[0] = (pclk & 0xFF);                  /* Pixel clock */
+	vals[1] = ((pclk & 0xFF00) >> 8);
+	vals[2] = VERTICAL_FREQ;                    /* Vertical freq */
+	/* register programming information on how vertical freq is to be
+	programmed to Sil9022 not clear. Hence setting to 60 for now */

Use the comment formatting according to kernel's coding style.

Quoted 66 lines
drivers/video/omap2/displays-new/encoder-sil9022.c new file +66 -0
+	vals[3] = 0x00;
+	vals[4] = (xres & 0xFF);         /* Horizontal pixels*/
+	vals[5] = ((xres & 0xFF00) >> 8);
+	vals[6] = (yres & 0xFF);           /* Vertical pixels */
+	vals[7] = ((yres & 0xFF00) >> 8);
+
+	/*  Write out the TPI Video Mode Data */
+	r = regmap_raw_write(map, HDMI_TPI_VIDEO_DATA_BASE_REG, vals, 8);
+
+	if (r < 0) {
+		dev_err(dssdev->dev,
+			"ERROR: writing TPI video mode data\n");
+		return r;
+	}
+
+	/* Write out the TPI Input bus and pixel repetition Data:
+	(24 bit wide bus, falling edge, no pixel replication, 1:1 CLK ratio) */
+	r = regmap_write(map,
+			HDMI_TPI_PIXEL_REPETITION_REG,
+			TPI_AVI_PIXEL_REP_BUS_24BIT |
+			TPI_AVI_PIXEL_REP_FALLING_EDGE |
+			TPI_AVI_PIXEL_REP_NONE |
+			TPI_CLK_RATIO_1X);
+
+	if (r < 0) {
+		dev_err(dssdev->dev,
+			"ERROR: writing TPI pixel repetition data\n");
+		return r;
+	}
+
+	 /*  Write out the TPI AVI Input Format */
+	r = regmap_write(map,
+			HDMI_TPI_AVI_IN_FORMAT_REG,
+			TPI_AVI_INPUT_BITMODE_8BIT |
+			TPI_AVI_INPUT_RANGE_AUTO |
+			TPI_AVI_INPUT_COLORSPACE_RGB);
+
+	if (r < 0) {
+		dev_err(dssdev->dev,
+			"ERROR: writing TPI AVI Input format\n");
+		return r;
+	}
+
+	/*  Write out the TPI AVI Output Format */
+	r = regmap_write(map,
+			HDMI_TPI_AVI_OUT_FORMAT_REG,
+			TPI_AVI_OUTPUT_CONV_BT709 |
+			TPI_AVI_OUTPUT_RANGE_AUTO |
+			TPI_AVI_OUTPUT_COLORSPACE_RGBHDMI);
+
+	if (r < 0) {
+		dev_err(dssdev->dev,
+			"ERROR: writing TPI AVI output format\n");
+		return r;
+	}
+
+	/* Write out the TPI System Control Data to power down */
+	r = regmap_write(map,
+			HDMI_SYS_CTRL_DATA_REG,
+			TPI_SYS_CTRL_POWER_DOWN);
+
+	if (r < 0) {
+		dev_err(dssdev->dev,
+			"ERROR: writing TPI power down control data\n");
+		return r;
+	}

drivers/video/omap2/displays-new/encoder-sil9022.c line 189

Quoted 10 lines
drivers/video/omap2/displays-new/encoder-sil9022.c new file +10 -0
+
+	/* Move from ENABLED -> FULLY ENABLED Power State  */
+	r = regmap_write(map,
+			HDMI_TPI_POWER_STATE_CTRL_REG,
+			TPI_AVI_POWER_STATE_D0);
+
+	if (r < 0) {
+		dev_err(&sil9022_client->dev,
+			"<%s> ERROR: Setting device power state to D0\n",
+			__func__);

No need to print __func__. dyndbg will allow the user to either print or not print the function name.

You could store &sil9022_client->dev to variable 'dev', reducing the code quite a bit. And if you change the texts a bit, maybe many of them even fit into one line (say, "ERROR: Setting device power state to D0" -> "Failed to set power state to D0").

Quoted 82 lines
drivers/video/omap2/displays-new/encoder-sil9022.c new file +82 -0
+		return r;
+	}
+
+	/* Write out the TPI System Control Data to power up and
+	 * select output mode
+	 */
+
+	r = regmap_write(map,
+			HDMI_SYS_CTRL_DATA_REG,
+			TPI_SYS_CTRL_POWER_ACTIVE |
+			TPI_SYS_CTRL_OUTPUT_MODE_HDMI);
+
+	if (r < 0) {
+		dev_err(&sil9022_client->dev,
+			"<%s> ERROR: Writing system control data\n", __func__);
+		return r;
+	}
+
+	/*  Read back TPI System Control Data to latch settings */
+	r = regmap_read(map, HDMI_SYS_CTRL_DATA_REG, &val);
+
+	if (r < 0) {
+		dev_err(&sil9022_client->dev,
+			"<%s> ERROR: Reading back system control data\n",
+			__func__);
+		return r;
+	}
+
+	/* HDCP */
+	r = regmap_write(map,
+				HDMI_TPI_HDCP_CONTROLDATA_REG,
+				HDCP_DISABLE);
+
+	if (r < 0) {
+		dev_err(&sil9022_client->dev,
+			"<%s> ERROR: Writing HDCP information",
+			__func__);
+		return r;
+	}
+
+	dev_info(&sil9022_client->dev,
+		"<%s> hdmi over sil9022 is now enabled\n", __func__);
+	return 0;
+
+}
+
+static int sil9022_hw_disable(struct omap_dss_device *dssdev)
+{
+	unsigned int val = 0;
+	int r = 0;
+	struct panel_drv_data *ddata = to_panel_data(dssdev);
+	struct regmap *map = ddata->regmap;
+
+	/*  Write out the TPI System Control Data to power down  */
+	r = regmap_write(map,
+			HDMI_SYS_CTRL_DATA_REG,
+			TPI_SYS_CTRL_POWER_DOWN);
+
+	if (r < 0) {
+		dev_err(dssdev->dev,
+			"ERROR: writing control data - power down\n");
+		return r;
+	}
+
+	/*  Move from FULLY ENABLED -> ENABLED Power state */
+	r = regmap_write(map,
+			HDMI_TPI_POWER_STATE_CTRL_REG,
+			TPI_AVI_POWER_STATE_D2);
+
+	if (r < 0) {
+		dev_err(dssdev->dev,
+			"ERROR: Setting device power state to D2\n");
+		return r;
+	}
+
+	/*  Read back TPI System Control Data to latch settings */
+	r = regmap_read(map, HDMI_SYS_CTRL_DATA_REG, &val);
+	if (r < 0) {
+		dev_err(dssdev->dev,
+			"ERROR:  Reading System control data "
+			"- latch settings\n");
+		return r;

drivers/video/omap2/displays-new/encoder-sil9022.c line 281

Quoted 10 lines
drivers/video/omap2/displays-new/encoder-sil9022.c new file +10 -0
+	}
+
+	dev_info(dssdev->dev, "hdmi disabled\n");
+	return 0;
+
+}
+
+static int sil9022_probe_chip_version(struct omap_dss_device *dssdev)
+{
+	int r = 0;

Here, and also elsewhere in this driver, assigning initial 0 to the return value is not needed.

Quoted 70 lines
drivers/video/omap2/displays-new/encoder-sil9022.c new file +70 -0
+	unsigned int ver;
+	struct panel_drv_data *ddata = to_panel_data(dssdev);
+	struct regmap *map = ddata->regmap;
+
+	/* probe for sil9022 chip version*/
+	r = regmap_write(map, SIL9022_REG_TPI_RQB, 0x00);
+	if (r < 0) {
+		dev_err(dssdev->dev,
+			"ERROR: Writing HDMI configuration to "
+			"reg - SI9022_REG_TPI_RQB\n");
+		return r;
+	}
+
+	r = regmap_read(map, SIL9022_REG_CHIPID0, &ver);
+	if (r < 0) {
+		dev_err(dssdev->dev,
+			"ERROR: Reading HDMI version Id\n");
+	} else if (ver != SIL9022_CHIPID_902x) {
+		dev_err(dssdev->dev,
+			"Not a valid verId: 0x%x\n", ver);
+	} else {
+		dev_info(dssdev->dev,
+			 "sil9022 HDMI Chip version = %x\n", ver);
+	}
+	return r;
+}
+
+/* Hdmi ops */
+
+static int sil9022_connect(struct omap_dss_device *dssdev,
+		struct omap_dss_device *dst)
+{
+	struct panel_drv_data *ddata = to_panel_data(dssdev);
+	struct omap_dss_device *in = ddata->in;
+	struct regmap *map = ddata->regmap;
+	int r = 0;
+
+	if (omapdss_device_is_connected(dssdev))
+		return -EBUSY;
+
+	r = in->ops.dpi->connect(in, dssdev);
+	if (r)
+		return r;
+
+	dst->src = dssdev;
+	dssdev->dst = dst;
+
+	/* Move from LOW -> ENABLED Power state */
+	r = regmap_write(map, HDMI_TPI_POWER_STATE_CTRL_REG,
+			TPI_AVI_POWER_STATE_D2);
+	if (r < 0) {
+		dev_err(dssdev->dev, "ERROR: Setting device power state to D2\n");
+		goto err_pwr;
+	}
+
+	return 0;
+err_pwr:
+		dst->src = NULL;
+		dssdev->dst = NULL;
+		in->ops.dpi->disconnect(in, dssdev);
+		return r;
+
+}
+
+static void sil9022_disconnect(struct omap_dss_device *dssdev,
+		struct omap_dss_device *dst)
+{
+	struct panel_drv_data *ddata = to_panel_data(dssdev);
+	struct omap_dss_device *in = ddata->in;
+

drivers/video/omap2/displays-new/encoder-sil9022.c line 361

Quoted 10 lines
drivers/video/omap2/displays-new/encoder-sil9022.c new file +10 -0
+	WARN_ON(!omapdss_device_is_connected(dssdev));
+	if (!omapdss_device_is_connected(dssdev))
+		return;
+
+	WARN_ON(dst != dssdev->dst);
+	if (dst != dssdev->dst)
+		return;
+
+	/* we don't control the RESET pin, so we can't wake up from D3 */
+	/* Hence we dont move to D3 state when disconnect is done */

So, this hacky reset handling, which wasn't switching reset but a GPIO to switch HDMI/LCD, was ok for testing purposes, but we need to clean this up before this can be merged to mainline.

The driver should be made to handle the reset gpio properly. However, having the reset gpio should be optional for cases where the reset pin is not controllable (like it is on the current AM4 boards). So the driver should get the reset gpio from th DT, but if it's missing, then act as it can't be controlled.

Quoted 32 lines
drivers/video/omap2/displays-new/encoder-sil9022.c new file +32 -0
+
+	dst->src = NULL;
+	dssdev->dst = NULL;
+	in->ops.dpi->disconnect(in, &ddata->dssdev);
+}
+
+static int sil9022_enable(struct omap_dss_device *dssdev)
+{
+	struct panel_drv_data *ddata = to_panel_data(dssdev);
+	struct omap_dss_device *in = ddata->in;
+	int r;
+
+	if (!omapdss_device_is_connected(dssdev))
+		return -ENODEV;
+
+	if (omapdss_device_is_enabled(dssdev))
+		return 0;
+
+	in->ops.dpi->set_timings(in, &ddata->timings);
+	in->ops.dpi->set_data_lines(in, ddata->data_lines);
+
+	r = in->ops.dpi->enable(in);
+	if (r)
+		return r;
+
+	if (gpio_is_valid(ddata->reset_gpio))
+		gpio_set_value_cansleep(ddata->reset_gpio, 0);
+
+	r = sil9022_hw_enable(dssdev);
+	if (r)
+		goto err_hw_en;
+

drivers/video/omap2/displays-new/encoder-sil9022.c line 403

Quoted 10 lines
drivers/video/omap2/displays-new/encoder-sil9022.c new file +10 -0
+	dssdev->state = OMAP_DSS_DISPLAY_ACTIVE;
+
+	return 0;
+
+err_hw_en:
+		if (gpio_is_valid(ddata->reset_gpio))
+			gpio_set_value_cansleep(ddata->reset_gpio, 1);
+
+		in->ops.dpi->disable(in);
+		return r;

Indentation is wrong here.

Quoted 20 lines
drivers/video/omap2/displays-new/encoder-sil9022.c new file +20 -0
+}
+
+static void sil9022_disable(struct omap_dss_device *dssdev)
+{
+	struct panel_drv_data *ddata = to_panel_data(dssdev);
+	struct omap_dss_device *in = ddata->in;
+
+	if (!omapdss_device_is_enabled(dssdev))
+		return;
+
+	sil9022_hw_disable(dssdev);
+
+	if (gpio_is_valid(ddata->reset_gpio))
+		gpio_set_value_cansleep(ddata->reset_gpio, 1);
+
+	in->ops.dpi->disable(in);
+
+	dssdev->state = OMAP_DSS_DISPLAY_DISABLED;
+}
+

drivers/video/omap2/displays-new/encoder-sil9022.c line 433

Quoted 10 lines
drivers/video/omap2/displays-new/encoder-sil9022.c new file +10 -0
+static void sil9022_set_timings(struct omap_dss_device *dssdev,
+		struct omap_video_timings *timings)
+{
+	struct panel_drv_data *ddata = to_panel_data(dssdev);
+	struct omap_dss_device *in = ddata->in;
+	struct omap_video_timings *sil9022_timings = timings;
+
+       /* update DPI specific timing info */
+	sil9022_timings->data_pclk_edge  = OMAPDSS_DRIVE_SIG_RISING_EDGE;
+	sil9022_timings->de_level		  = OMAPDSS_SIG_ACTIVE_HIGH;

Extra spaces/tabs.

Quoted 14 lines
drivers/video/omap2/displays-new/encoder-sil9022.c new file +14 -0
+	sil9022_timings->sync_pclk_edge = OMAPDSS_DRIVE_SIG_OPPOSITE_EDGES;
+	ddata->timings = *sil9022_timings;
+	dssdev->panel.timings = *sil9022_timings;
+
+	in->ops.dpi->set_timings(in, sil9022_timings);
+}
+
+static void sil9022_get_timings(struct omap_dss_device *dssdev,
+		struct omap_video_timings *timings)
+{
+	struct panel_drv_data *ddata = to_panel_data(dssdev);
+	*timings = ddata->timings;
+}
+

drivers/video/omap2/displays-new/encoder-sil9022.c line 457

Quoted 10 lines
drivers/video/omap2/displays-new/encoder-sil9022.c new file +10 -0
+static int sil9022_check_timings(struct omap_dss_device *dssdev,
+		struct omap_video_timings *timings)
+{
+	struct panel_drv_data *ddata = to_panel_data(dssdev);
+	struct omap_dss_device *in = ddata->in;
+	struct omap_video_timings *sil9022_timings = timings;
+
+	/* update DPI specific timing info */
+	sil9022_timings->data_pclk_edge  = OMAPDSS_DRIVE_SIG_RISING_EDGE;
+	sil9022_timings->de_level		  = OMAPDSS_SIG_ACTIVE_HIGH;

And here.

Quoted 138 lines
drivers/video/omap2/displays-new/encoder-sil9022.c new file +138 -0
+	sil9022_timings->sync_pclk_edge = OMAPDSS_DRIVE_SIG_OPPOSITE_EDGES;
+
+	return in->ops.dpi->check_timings(in, sil9022_timings);
+}
+
+static int sil9022_read_edid(struct omap_dss_device *dssdev,
+	       u8 *edid, int len)
+{
+
+	int r =  0;
+	unsigned int val = 0;
+	int retries = 0;
+	struct panel_drv_data *ddata = to_panel_data(dssdev);
+	struct i2c_client *client = ddata->i2c_client;
+	struct regmap *map = ddata->regmap;
+
+	len = (len < HDMI_EDID_MAX_LENGTH) ? len : HDMI_EDID_MAX_LENGTH;
+
+	/* Request DDC bus access to read EDID info */
+
+	/* Disable TMDS clock */
+
+	r = regmap_write(map, HDMI_SYS_CTRL_DATA_REG, 0x11);
+	if (r < 0) {
+		dev_err(&client->dev,
+			"ERROR: Failed to disable TMDS clock\n");
+		return r;
+	}
+
+	val = 0;
+
+	/* Read TPI system control register*/
+	r = regmap_read(map, HDMI_SYS_CTRL_DATA_REG, &val);
+	if (r < 0) {
+		dev_err(&client->dev,
+			"ERROR: Reading DDC BUS REQUEST\n");
+		return r;
+	}
+
+	/* The host writes 0x1A[2]=1 to request the
+	 * DDC(Display Data Channel) bus
+	 */
+	r = regmap_write(map, HDMI_SYS_CTRL_DATA_REG,
+				val | TPI_SYS_CTRL_DDC_BUS_REQUEST);
+	if (r < 0) {
+		dev_err(&client->dev,
+			"ERROR: Writing DDC BUS REQUEST\n");
+		return r;
+	}
+
+	/*  Poll for bus DDC Bus control to be granted */
+	val = 0;
+
+	/* Through trial and error, to get DDC BUS we need around 3 tries */
+	/* Hence keeping it rounded at 5 tries - a max of 4 retries allowed */
+	do {
+		r = regmap_read(map, HDMI_SYS_CTRL_DATA_REG, &val);
+		if (retries++ > 5) {
+			dev_err(&client->dev, "ERROR: Acquiring DDC Bus\n");
+			return r;
+		}
+	} while ((val & TPI_SYS_CTRL_DDC_BUS_GRANTED) == 0);
+
+	/*  Close the switch to the DDC */
+	r = regmap_write(map, HDMI_SYS_CTRL_DATA_REG,
+		val | TPI_SYS_CTRL_DDC_BUS_REQUEST |
+		TPI_SYS_CTRL_DDC_BUS_GRANTED);
+
+	if (r < 0) {
+		dev_err(&client->dev,
+			"<%s> ERROR: Close switch to DDC BUS REQUEST\n",
+			__func__);
+		return r;
+	}
+
+	r = sil9022_ddc_read(client, edid, len, 0);
+	if (r < 0) {
+		dev_err(&client->dev, "ERROR: Reading EDID\n");
+		return r;
+	}
+
+	/* Release DDC bus access */
+	val &= ~(TPI_SYS_CTRL_DDC_BUS_REQUEST | TPI_SYS_CTRL_DDC_BUS_GRANTED);
+
+	/*Through trial and error, seen that releasing BUS needed 3 tries */
+	/* Hence keeping it rounded at 5 tries - a max of 4 retries allowed */
+	retries = 0;
+	do {
+		r = regmap_write(map, HDMI_SYS_CTRL_DATA_REG, val);
+		if (r >= 0)
+			break;
+		retries++;
+	} while (retries < 5);
+	if (r < 0) {
+		dev_err(&client->dev, "ERROR: Releasing DDC Bus Access\n");
+		return r;
+		}
+	return 0;
+}
+
+static bool sil9022_detect(struct omap_dss_device *dssdev)
+{
+	/* Hot plug detection is not implemented */
+	/* Hence we assume monitor connected */
+	/* This will be fixed once HPD / polling is implemented */
+	return true;
+}
+
+static bool sil9022_audio_supported(struct omap_dss_device *dssdev)
+{
+	/* Audio configuration not present, hence returning false */
+	return false;
+}
+
+static const struct omapdss_hdmi_ops sil9022_hdmi_ops = {
+	.connect			= sil9022_connect,
+	.disconnect		= sil9022_disconnect,
+
+	.enable			= sil9022_enable,
+	.disable			= sil9022_disable,
+
+	.check_timings	= sil9022_check_timings,
+	.set_timings		= sil9022_set_timings,
+	.get_timings		= sil9022_get_timings,
+
+	.read_edid		= sil9022_read_edid,
+	.detect			= sil9022_detect,
+
+	.audio_supported	= sil9022_audio_supported,
+	/* Yet to implement audio ops */
+	/* For now audio_supported ops to return false */
+};
+
+
+static int sil9022_probe_of(struct i2c_client *client)
+{
+	struct panel_drv_data *ddata = dev_get_drvdata(&client->dev);
+	struct device_node *node = client->dev.of_node;

drivers/video/omap2/displays-new/encoder-sil9022.c line 605

Quoted 10 lines
drivers/video/omap2/displays-new/encoder-sil9022.c new file +10 -0
+	struct device_node *src_node;
+	struct omap_dss_device *dssdev, *in;
+
+	int r, reset_gpio, datalines;
+
+	src_node = of_parse_phandle(node, "video-source", 0);
+	if (!src_node) {
+		dev_err(&client->dev, "failed to parse video source\n");
+		return -ENODEV;
+	}

There is no "video-source" property any more, and the endpoint handling is missing, so I think it's clear you have not tested this driver with the bindings you have in the patch 2/2.

Quoted 8 lines
drivers/video/omap2/displays-new/encoder-sil9022.c new file +8 -0
+
+	in = omap_dss_find_output_by_node(src_node);
+	if (in == NULL) {
+		dev_err(&client->dev, "failed to find video source\n");
+		return -EPROBE_DEFER;
+	}
+	ddata->in = in;
+

drivers/video/omap2/displays-new/encoder-sil9022.c line 623

Quoted 10 lines
drivers/video/omap2/displays-new/encoder-sil9022.c new file +10 -0
+	reset_gpio = of_get_named_gpio(node, "reset-gpio", 0);
+
+	if (gpio_is_valid(reset_gpio) || reset_gpio == -ENOENT) {
+		ddata->reset_gpio = reset_gpio;
+	} else {
+		dev_err(&client->dev, "failed to parse lcdorhdmi gpio\n");
+		return reset_gpio;
+	}
+
+	r = of_property_read_u32(node, "data-lines", &datalines);

This driver doesn't use datalines information for anything, so this is not needed.

Tomi