@@ -369,6 +369,10 @@ config VIDEO_LCD_PANEL_LVDS
bool "Generic lvds interface LCD panel"
select VIDEO_LCD_IF_LVDS
+config VIDEO_LCD_PANEL_HITACHI_TX18D42VM
+ bool "Hitachi tx18d42vm LCD panel"
+ select VIDEO_LCD_IF_LVDS
+
endchoice
@@ -39,7 +39,7 @@ obj-$(CONFIG_VIDEO_SANDBOX_SDL) += sandbox_sdl.o
obj-$(CONFIG_VIDEO_SED13806) += sed13806.o
obj-$(CONFIG_VIDEO_SM501) += sm501.o
obj-$(CONFIG_VIDEO_SMI_LYNXEM) += smiLynxEM.o videomodes.o
-obj-$(CONFIG_VIDEO_SUNXI) += sunxi_display.o videomodes.o
+obj-$(CONFIG_VIDEO_SUNXI) += sunxi_display.o sunxi_lcd_panel.o videomodes.o
obj-$(CONFIG_VIDEO_TEGRA) += tegra.o
obj-$(CONFIG_VIDEO_VCXK) += bus_vcxk.o
obj-$(CONFIG_VIDEO_X86) += x86_fb.o
@@ -19,6 +19,7 @@
#include <fdtdec.h>
#include <fdt_support.h>
#include <video_fb.h>
+#include "sunxi_lcd_panel.h"
#include "videomodes.h"
DECLARE_GLOBAL_DATA_PTR;
@@ -487,6 +488,10 @@ static void sunxi_lcdc_panel_enable(void)
gpio_request(pin, "lcd_power");
gpio_direction_output(pin, 1);
}
+
+#ifdef CONFIG_VIDEO_LCD_PANEL_HITACHI_TX18D42VM
+ sunxi_lcd_panel_hitachi_tx18d42vm_init();
+#endif
}
static void sunxi_lcdc_backlight_enable(void)
new file mode 100644
@@ -0,0 +1,68 @@
+/*
+ * LCD panel driver for Allwinner SoCs.
+ *
+ * (C) Copyright 2015 Hans de Goede <hdegoede@redhat.com>
+ *
+ * SPDX-License-Identifier: GPL-2.0+
+ */
+
+#include <common.h>
+
+#include <asm/arch/gpio.h>
+#include <asm/gpio.h>
+#include <asm/io.h>
+
+#ifdef CONFIG_VIDEO_LCD_PANEL_HITACHI_TX18D42VM
+
+#define SPI_CS SUNXI_GPA(0)
+#define SPI_CLK SUNXI_GPA(1)
+#define SPI_MOSI SUNXI_GPA(2)
+
+/*
+ * Very simple write only SPI support, this does not use the generic SPI infra
+ * because that assumes R/W SPI, requiring a MISO pin. Also the necessary glue
+ * code alone would be larger then this minimal version.
+ */
+
+static void sunxi_lcd_panel_spi_write(unsigned int data, int bits)
+{
+ int i, offset;
+
+ gpio_direction_output(SPI_CS, 0);
+ for (i = 0; i < bits; i++) {
+ gpio_direction_output(SPI_CLK, 0);
+ offset = (bits - 1) - i;
+ gpio_direction_output(SPI_MOSI, (data >> offset) & 1);
+ udelay(2);
+ gpio_direction_output(SPI_CLK, 1);
+ udelay(2);
+ }
+ gpio_direction_output(SPI_CS, 1);
+ udelay(2);
+}
+
+void sunxi_lcd_panel_hitachi_tx18d42vm_init(void)
+{
+ const u16 init_data[] = {
+ 0x0029, /* reset */
+ 0x0025, /* standby */
+ 0x0840, /* enable normally black */
+ 0x0430, /* enable FRC/dither */
+ 0x385f, /* enter test mode(1) */
+ 0x3ca4, /* enter test mode(2) */
+ 0x3409, /* enable SDRRS, enlarge OE width */
+ 0x4041, /* adopt 2 line / 1 dot */
+ };
+ int i;
+
+ mdelay(50); /* Wait for lcd controller power on */
+
+ for (i = 0; i < ARRAY_SIZE(init_data); i++)
+ sunxi_lcd_panel_spi_write(init_data[i], 16);
+
+ mdelay(50); /* All the tx18d42vm drivers have a delay here ? */
+
+ sunxi_lcd_panel_spi_write(0x00ad, 16); /* display on */
+}
+
+#endif
new file mode 100644
@@ -0,0 +1,9 @@
+/*
+ * LCD panel driver for Allwinner SoCs.
+ *
+ * (C) Copyright 2015 Hans de Goede <hdegoede@redhat.com>
+ *
+ * SPDX-License-Identifier: GPL-2.0+
+ */
+
+void sunxi_lcd_panel_hitachi_tx18d42vm_init(void);
Hitachi tx18d42vm LCD panels have an onboard controller which needs some initialization via spi for the panel to become functional as a regular LVDS panel. Signed-off-by: Hans de Goede <hdegoede@redhat.com> --- board/sunxi/Kconfig | 4 +++ drivers/video/Makefile | 2 +- drivers/video/sunxi_display.c | 5 +++ drivers/video/sunxi_lcd_panel.c | 68 +++++++++++++++++++++++++++++++++++++++++ drivers/video/sunxi_lcd_panel.h | 9 ++++++ 5 files changed, 87 insertions(+), 1 deletion(-) create mode 100644 drivers/video/sunxi_lcd_panel.c create mode 100644 drivers/video/sunxi_lcd_panel.h