]> git.kernelconcepts.de Git - karo-tx-uboot.git/commitdiff
video: Add support for Hitachi tx18d42vm LVDS LCD panels
authorHans de Goede <hdegoede@redhat.com>
Tue, 20 Jan 2015 08:22:26 +0000 (09:22 +0100)
committerHans de Goede <hdegoede@redhat.com>
Thu, 22 Jan 2015 19:44:33 +0000 (20:44 +0100)
Add support for Hitachi tx18d42vm LVDS LCD panels, these panels have a
lcd controller which needs to be initialized over SPI, once that is
done they work like a regular LVDS panel.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Acked-by: Anatolij Gustschin <agust@denx.de>
drivers/video/Kconfig
drivers/video/Makefile
drivers/video/hitachi_tx18d42vm_lcd.c [new file with mode: 0644]
drivers/video/hitachi_tx18d42vm_lcd.h [new file with mode: 0644]

index d9d4afcba6abc466923589fe36d6837412bf799d..ccbd7e295dda9d259cb1b54c208fc8e4e3678268 100644 (file)
@@ -36,9 +36,18 @@ config VIDEO_LCD_SSD2828_RESET
        The reset pin of SSD2828 chip. This takes a string in the format
        understood by 'name_to_gpio' function, e.g. PH1 for pin 1 of port H.
 
+config VIDEO_LCD_HITACHI_TX18D42VM
+       bool "Hitachi tx18d42vm LVDS LCD panel support"
+       depends on VIDEO
+       default n
+       ---help---
+       Support for Hitachi tx18d42vm LVDS LCD panels, these panels have a
+       lcd controller which needs to be initialized over SPI, once that is
+       done they work like a regular LVDS panel.
+
 config VIDEO_LCD_SPI_CS
        string "SPI CS pin for LCD related config job"
-       depends on VIDEO_LCD_SSD2828
+       depends on VIDEO_LCD_SSD2828 || VIDEO_LCD_HITACHI_TX18D42VM
        default ""
        ---help---
        This is one of the SPI communication pins, involved in setting up a
@@ -48,7 +57,7 @@ config VIDEO_LCD_SPI_CS
 
 config VIDEO_LCD_SPI_SCLK
        string "SPI SCLK pin for LCD related config job"
-       depends on VIDEO_LCD_SSD2828
+       depends on VIDEO_LCD_SSD2828 || VIDEO_LCD_HITACHI_TX18D42VM
        default ""
        ---help---
        This is one of the SPI communication pins, involved in setting up a
@@ -58,7 +67,7 @@ config VIDEO_LCD_SPI_SCLK
 
 config VIDEO_LCD_SPI_MOSI
        string "SPI MOSI pin for LCD related config job"
-       depends on VIDEO_LCD_SSD2828
+       depends on VIDEO_LCD_SSD2828 || VIDEO_LCD_HITACHI_TX18D42VM
        default ""
        ---help---
        This is one of the SPI communication pins, involved in setting up a
index 36298684bf9653004f1a47d991392cd223376339..c3fcf455d268eeb5442cbe3987c11bd5b0750f01 100644 (file)
@@ -29,6 +29,7 @@ obj-$(CONFIG_VIDEO_COREBOOT) += coreboot_fb.o
 obj-$(CONFIG_VIDEO_CT69000) += ct69000.o videomodes.o
 obj-$(CONFIG_VIDEO_DA8XX) += da8xx-fb.o videomodes.o
 obj-$(CONFIG_VIDEO_IMX25LCDC) += imx25lcdc.o videomodes.o
+obj-$(CONFIG_VIDEO_LCD_HITACHI_TX18D42VM) += hitachi_tx18d42vm_lcd.o
 obj-$(CONFIG_VIDEO_LCD_SSD2828) += ssd2828.o
 obj-$(CONFIG_VIDEO_MB862xx) += mb862xx.o videomodes.o
 obj-$(CONFIG_VIDEO_MB86R0xGDC) += mb86r0xgdc.o videomodes.o
diff --git a/drivers/video/hitachi_tx18d42vm_lcd.c b/drivers/video/hitachi_tx18d42vm_lcd.c
new file mode 100644 (file)
index 0000000..1ce4a8c
--- /dev/null
@@ -0,0 +1,81 @@
+/*
+ * Hitachi tx18d42vm LVDS LCD panel driver
+ *
+ * (C) Copyright 2015 Hans de Goede <hdegoede@redhat.com>
+ *
+ * SPDX-License-Identifier:    GPL-2.0+
+ */
+
+#include <common.h>
+
+#include <asm/gpio.h>
+#include <errno.h>
+
+/*
+ * 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 lcd_panel_spi_write(int cs, int clk, int mosi,
+                               unsigned int data, int bits)
+{
+       int i, offset;
+
+       gpio_direction_output(cs, 0);
+       for (i = 0; i < bits; i++) {
+               gpio_direction_output(clk, 0);
+               offset = (bits - 1) - i;
+               gpio_direction_output(mosi, (data >> offset) & 1);
+               udelay(2);
+               gpio_direction_output(clk, 1);
+               udelay(2);
+       }
+       gpio_direction_output(cs, 1);
+       udelay(2);
+}
+
+int 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, cs, clk, mosi, ret = 0;
+
+       cs = name_to_gpio(CONFIG_VIDEO_LCD_SPI_CS);
+       clk = name_to_gpio(CONFIG_VIDEO_LCD_SPI_SCLK);
+       mosi = name_to_gpio(CONFIG_VIDEO_LCD_SPI_MOSI);
+
+       if (cs == -1 || clk == -1 || mosi == 1) {
+               printf("Error tx18d42vm spi gpio config is invalid\n");
+               return -EINVAL;
+       }
+
+       if (gpio_request(cs, "tx18d42vm-spi-cs") != 0 ||
+           gpio_request(clk, "tx18d42vm-spi-clk") != 0 ||
+           gpio_request(mosi, "tx18d42vm-spi-mosi") != 0) {
+               printf("Error cannot request tx18d42vm spi gpios\n");
+               ret = -EBUSY;
+               goto out;
+       }
+
+       for (i = 0; i < ARRAY_SIZE(init_data); i++)
+               lcd_panel_spi_write(cs, clk, mosi, init_data[i], 16);
+
+       mdelay(50); /* All the tx18d42vm drivers have a delay here ? */
+
+       lcd_panel_spi_write(cs, clk, mosi, 0x00ad, 16); /* display on */
+
+out:
+       gpio_free(mosi);
+       gpio_free(clk);
+       gpio_free(cs);
+
+       return ret;
+}
diff --git a/drivers/video/hitachi_tx18d42vm_lcd.h b/drivers/video/hitachi_tx18d42vm_lcd.h
new file mode 100644 (file)
index 0000000..1b72800
--- /dev/null
@@ -0,0 +1,9 @@
+/*
+ * Hitachi tx18d42vm LVDS LCD panel driver
+ *
+ * (C) Copyright 2015 Hans de Goede <hdegoede@redhat.com>
+ *
+ * SPDX-License-Identifier:    GPL-2.0+
+ */
+
+void hitachi_tx18d42vm_init(void);