diff mbox

[U-Boot,3/3] ot1200: patch dts with EDID data

Message ID 1410786366-26494-3-git-send-email-christian.gmeiner@gmail.com
State Deferred
Delegated to: Anatolij Gustschin
Headers show

Commit Message

Christian Gmeiner Sept. 15, 2014, 1:06 p.m. UTC
We support one base print with different panel sizes. In order
to keep it simple we use one devicetree for the linux kernel.
The timing values for each panel is stored on an i2c EEPROM.
This EDID gets transformed to fb_videomode and later stored
in the dtb.

Signed-off-by: Christian Gmeiner <christian.gmeiner@gmail.com>
---
 board/bachmann/ot1200/ot1200.c | 58 ++++++++++++++++++++++++++++++++++++++++++
 include/configs/ot1200.h       |  8 ++++++
 2 files changed, 66 insertions(+)
diff mbox

Patch

diff --git a/board/bachmann/ot1200/ot1200.c b/board/bachmann/ot1200/ot1200.c
index 1c04f45..dfb4be7 100644
--- a/board/bachmann/ot1200/ot1200.c
+++ b/board/bachmann/ot1200/ot1200.c
@@ -24,6 +24,9 @@ 
 #include <pca953x.h>
 #include <asm/gpio.h>
 #include <phy.h>
+#include <edid.h>
+#include <linux/fb.h>
+#include <fdt_support.h>
 
 DECLARE_GLOBAL_DATA_PTR;
 
@@ -145,6 +148,20 @@  int board_mmc_init(bd_t *bis)
 
 #define PC MUX_PAD_CTRL(I2C_PAD_CTRL)
 
+/* I2C2 - EDID */
+static struct i2c_pads_info i2c_pad_info1 = {
+	.scl = {
+		.i2c_mode = MX6_PAD_EIM_EB2__I2C2_SCL | PC,
+		.gpio_mode = MX6_PAD_EIM_EB2__GPIO2_IO30 | PC,
+		.gp = IMX_GPIO_NR(2, 30)
+	},
+	.sda = {
+		.i2c_mode = MX6_PAD_EIM_D16__I2C2_SDA | PC,
+		.gpio_mode = MX6_PAD_EIM_D16__GPIO3_IO16 | PC,
+		.gp = IMX_GPIO_NR(3, 16)
+	}
+};
+
 /* I2C3 - IO expander  */
 static struct i2c_pads_info i2c_pad_info2 = {
 	.scl = {
@@ -216,6 +233,46 @@  int board_eth_init(bd_t *bis)
 	return 0;
 }
 
+#if defined(CONFIG_OF_LIBFDT) && defined(CONFIG_OF_BOARD_SETUP)
+void ft_board_setup(void *blob, bd_t *bd)
+{
+	struct edid1_info edid;
+	struct fb_videomode mode;
+	int ret;
+
+	i2c_set_bus_num(1);
+	ret = i2c_read(CONFIG_EDID_ADDR, 0, 1, (uchar *)&edid, sizeof(edid));
+	if (ret != 0) {
+		puts("Error reading EDID content.\n");
+		return;
+	}
+
+	if (edid_check_info(&edid)) {
+		puts("Content isn't valid EDID.\n");
+		return;
+	}
+
+	edid_to_fb_videomode(&edid, &mode);
+
+	/* clean-up all the mess */
+	int noff = fdt_find_display_timings(blob, "fsl,imx6q-ldb", "lvds-channel");
+	fdt_del_node(blob, noff);
+
+	/* start from scratch */
+	noff = fdt_node_offset_by_compatible(blob, -1, "fsl,imx6q-ldb");
+	noff = fdt_subnode_offset(blob, noff, "lvds-channel");
+
+	fdt_add_subnode(blob, noff, "display-timings");
+	noff = fdt_subnode_offset(blob, noff, "display-timings");
+	fdt_add_subnode(blob, noff, "timing0");
+
+	/* fill with useful values */
+	fdt_update_display_timings(blob, "fsl,imx6q-ldb", "lvds-channel", &mode);
+
+	return;
+}
+#endif /* defined(CONFIG_OF_LIBFDT) && defined(CONFIG_OF_BOARD_SETUP) */
+
 int board_init(void)
 {
 	struct mxc_ccm_reg *mxc_ccm = (struct mxc_ccm_reg *)CCM_BASE_ADDR;
@@ -225,6 +282,7 @@  int board_init(void)
 
 	backlight_lcd_off();
 
+	setup_i2c(1, CONFIG_SYS_I2C_SPEED, 0x7f, &i2c_pad_info1);
 	setup_i2c(2, CONFIG_SYS_I2C_SPEED, 0x7f, &i2c_pad_info2);
 
 	leds_on();
diff --git a/include/configs/ot1200.h b/include/configs/ot1200.h
index fa21874..263b6a6 100644
--- a/include/configs/ot1200.h
+++ b/include/configs/ot1200.h
@@ -57,6 +57,14 @@ 
 #define CONFIG_CMD_PCA953X
 #define CONFIG_CMD_PCA953X_INFO
 
+/* EDID eeprom */
+#define CONFIG_EDID_ADDR		0x52
+
+/* OF Configs */
+#define CONFIG_I2C_EDID
+#define CONFIG_OF_LIBFDT
+#define CONFIG_OF_BOARD_SETUP
+
 /* I2C Configs */
 #define CONFIG_CMD_I2C
 #define CONFIG_SYS_I2C