* [U-Boot] [PATCH v2 0/2] video: Add support for Hitachi tx18d42vm LVDS LCD
@ 2015-01-20 14:08 Hans de Goede
2015-01-20 14:08 ` [U-Boot] [PATCH v2 1/2] video: Add support for Hitachi tx18d42vm LVDS LCD panels Hans de Goede
2015-01-20 14:08 ` [U-Boot] [PATCH v2 2/2] sunxi: " Hans de Goede
0 siblings, 2 replies; 6+ messages in thread
From: Hans de Goede @ 2015-01-20 14:08 UTC (permalink / raw)
To: u-boot
Hi Anatolij,
Here is v2 of my Hitachi tx18d42vm LVDS LCD support patches. You already
acked v1, but v1 was sunxi specific and following the example of the ssd2828
patches I've decided to respin the patch to make the hitachi tx18d42vm bits
generic so that they can be used by non sunxi boards too.
Can you please review this version ? If you're ok with it I'll queue it up
for merging un u-boot-sunxi/next .
Thanks & Regards,
Hans
^ permalink raw reply [flat|nested] 6+ messages in thread
* [U-Boot] [PATCH v2 1/2] video: Add support for Hitachi tx18d42vm LVDS LCD panels
2015-01-20 14:08 [U-Boot] [PATCH v2 0/2] video: Add support for Hitachi tx18d42vm LVDS LCD Hans de Goede
@ 2015-01-20 14:08 ` Hans de Goede
2015-01-22 17:36 ` Anatolij Gustschin
2015-01-20 14:08 ` [U-Boot] [PATCH v2 2/2] sunxi: " Hans de Goede
1 sibling, 1 reply; 6+ messages in thread
From: Hans de Goede @ 2015-01-20 14:08 UTC (permalink / raw)
To: u-boot
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>
---
drivers/video/Kconfig | 15 +++++--
drivers/video/Makefile | 1 +
drivers/video/hitachi_tx18d42vm_lcd.c | 81 +++++++++++++++++++++++++++++++++++
drivers/video/hitachi_tx18d42vm_lcd.h | 9 ++++
4 files changed, 103 insertions(+), 3 deletions(-)
create mode 100644 drivers/video/hitachi_tx18d42vm_lcd.c
create mode 100644 drivers/video/hitachi_tx18d42vm_lcd.h
diff --git a/drivers/video/Kconfig b/drivers/video/Kconfig
index d9d4afc..ccbd7e2 100644
--- a/drivers/video/Kconfig
+++ b/drivers/video/Kconfig
@@ -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
diff --git a/drivers/video/Makefile b/drivers/video/Makefile
index 3629868..c3fcf45 100644
--- a/drivers/video/Makefile
+++ b/drivers/video/Makefile
@@ -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
index 0000000..1ce4a8c
--- /dev/null
+++ b/drivers/video/hitachi_tx18d42vm_lcd.c
@@ -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
index 0000000..1b72800
--- /dev/null
+++ b/drivers/video/hitachi_tx18d42vm_lcd.h
@@ -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);
--
2.1.0
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [U-Boot] [PATCH v2 2/2] sunxi: video: Add support for Hitachi tx18d42vm LVDS LCD panels
2015-01-20 14:08 [U-Boot] [PATCH v2 0/2] video: Add support for Hitachi tx18d42vm LVDS LCD Hans de Goede
2015-01-20 14:08 ` [U-Boot] [PATCH v2 1/2] video: Add support for Hitachi tx18d42vm LVDS LCD panels Hans de Goede
@ 2015-01-20 14:08 ` Hans de Goede
2015-01-22 17:37 ` Anatolij Gustschin
1 sibling, 1 reply; 6+ messages in thread
From: Hans de Goede @ 2015-01-20 14:08 UTC (permalink / raw)
To: u-boot
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>
---
board/sunxi/Kconfig | 7 +++++++
drivers/video/sunxi_display.c | 12 ++++++++++++
2 files changed, 19 insertions(+)
diff --git a/board/sunxi/Kconfig b/board/sunxi/Kconfig
index 76d190b..97f900b 100644
--- a/board/sunxi/Kconfig
+++ b/board/sunxi/Kconfig
@@ -359,6 +359,13 @@ config VIDEO_LCD_PANEL_MIPI_4_LANE_513_MBPS_VIA_SSD2828
---help---
7.85" 768x1024 LCD panels, such as LG LP079X01 or AUO B079XAN01.0
+config VIDEO_LCD_PANEL_HITACHI_TX18D42VM
+ bool "Hitachi tx18d42vm LCD panel"
+ select VIDEO_LCD_HITACHI_TX18D42VM
+ select VIDEO_LCD_IF_LVDS
+ ---help---
+ 7.85" 1024x768 Hitachi tx18d42vm LCD panel support
+
endchoice
diff --git a/drivers/video/sunxi_display.c b/drivers/video/sunxi_display.c
index a6e3778..5a77a70 100644
--- a/drivers/video/sunxi_display.c
+++ b/drivers/video/sunxi_display.c
@@ -20,6 +20,7 @@
#include <fdt_support.h>
#include <video_fb.h>
#include "videomodes.h"
+#include "hitachi_tx18d42vm_lcd.h"
#include "ssd2828.h"
DECLARE_GLOBAL_DATA_PTR;
@@ -976,6 +977,14 @@ static int sunxi_ssd2828_init(const struct ctfb_res_modes *mode)
}
#endif /* CONFIG_VIDEO_LCD_SSD2828 */
+#ifdef CONFIG_VIDEO_LCD_HITACHI_TX18D42VM
+static void sunxi_hitachi_tx18d42vm_init(void)
+{
+ mdelay(50); /* Wait for lcd controller power on */
+ hitachi_tx18d42vm_init();
+}
+#endif
+
static void sunxi_engines_init(void)
{
sunxi_composer_init();
@@ -1004,6 +1013,9 @@ static void sunxi_mode_set(const struct ctfb_res_modes *mode,
break;
case sunxi_monitor_lcd:
sunxi_lcdc_panel_enable();
+#ifdef CONFIG_VIDEO_LCD_HITACHI_TX18D42VM
+ sunxi_hitachi_tx18d42vm_init();
+#endif
sunxi_composer_mode_set(mode, address);
sunxi_lcdc_tcon0_mode_set(mode);
sunxi_composer_enable();
--
2.1.0
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [U-Boot] [PATCH v2 1/2] video: Add support for Hitachi tx18d42vm LVDS LCD panels
2015-01-20 14:08 ` [U-Boot] [PATCH v2 1/2] video: Add support for Hitachi tx18d42vm LVDS LCD panels Hans de Goede
@ 2015-01-22 17:36 ` Anatolij Gustschin
0 siblings, 0 replies; 6+ messages in thread
From: Anatolij Gustschin @ 2015-01-22 17:36 UTC (permalink / raw)
To: u-boot
On Tue, 20 Jan 2015 15:08:01 +0100
Hans de Goede <hdegoede@redhat.com> wrote:
> 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>
^ permalink raw reply [flat|nested] 6+ messages in thread
* [U-Boot] [PATCH v2 2/2] sunxi: video: Add support for Hitachi tx18d42vm LVDS LCD panels
2015-01-20 14:08 ` [U-Boot] [PATCH v2 2/2] sunxi: " Hans de Goede
@ 2015-01-22 17:37 ` Anatolij Gustschin
2015-01-22 19:43 ` Hans de Goede
0 siblings, 1 reply; 6+ messages in thread
From: Anatolij Gustschin @ 2015-01-22 17:37 UTC (permalink / raw)
To: u-boot
On Tue, 20 Jan 2015 15:08:02 +0100
Hans de Goede <hdegoede@redhat.com> wrote:
...
> @@ -976,6 +977,14 @@ static int sunxi_ssd2828_init(const struct ctfb_res_modes *mode)
> }
> #endif /* CONFIG_VIDEO_LCD_SSD2828 */
>
> +#ifdef CONFIG_VIDEO_LCD_HITACHI_TX18D42VM
> +static void sunxi_hitachi_tx18d42vm_init(void)
> +{
> + mdelay(50); /* Wait for lcd controller power on */
> + hitachi_tx18d42vm_init();
> +}
> +#endif
Could you please test if
#if IS_ENABLED(CONFIG_VIDEO_LCD_HITACHI_TX18D42VM)
#endif
works here around sunxi_hitachi_tx18d42vm_init() definition ?
Now with Kconfig it should. I'd prefer this variant instead
of #ifdef.
...
> @@ -1004,6 +1013,9 @@ static void sunxi_mode_set(const struct ctfb_res_modes *mode,
> break;
> case sunxi_monitor_lcd:
> sunxi_lcdc_panel_enable();
> +#ifdef CONFIG_VIDEO_LCD_HITACHI_TX18D42VM
> + sunxi_hitachi_tx18d42vm_init();
> +#endif
And here, please try to use
if (IS_ENABLED(CONFIG_VIDEO_LCD_HITACHI_TX18D42VM))
sunxi_hitachi_tx18d42vm_init();
Thanks,
Anatolij
^ permalink raw reply [flat|nested] 6+ messages in thread
* [U-Boot] [PATCH v2 2/2] sunxi: video: Add support for Hitachi tx18d42vm LVDS LCD panels
2015-01-22 17:37 ` Anatolij Gustschin
@ 2015-01-22 19:43 ` Hans de Goede
0 siblings, 0 replies; 6+ messages in thread
From: Hans de Goede @ 2015-01-22 19:43 UTC (permalink / raw)
To: u-boot
Hi,
On 22-01-15 18:37, Anatolij Gustschin wrote:
> On Tue, 20 Jan 2015 15:08:02 +0100
> Hans de Goede <hdegoede@redhat.com> wrote:
> ...
>> @@ -976,6 +977,14 @@ static int sunxi_ssd2828_init(const struct ctfb_res_modes *mode)
>> }
>> #endif /* CONFIG_VIDEO_LCD_SSD2828 */
>>
>> +#ifdef CONFIG_VIDEO_LCD_HITACHI_TX18D42VM
>> +static void sunxi_hitachi_tx18d42vm_init(void)
>> +{
>> + mdelay(50); /* Wait for lcd controller power on */
>> + hitachi_tx18d42vm_init();
>> +}
>> +#endif
>
> Could you please test if
>
> #if IS_ENABLED(CONFIG_VIDEO_LCD_HITACHI_TX18D42VM)
>
> #endif
>
> works here around sunxi_hitachi_tx18d42vm_init() definition ?
>
> Now with Kconfig it should. I'd prefer this variant instead
> of #ifdef.
That won't work because then there will be no prototype declared for
sunxi_hitachi_tx18d42vm_init().
>
> ...
>> @@ -1004,6 +1013,9 @@ static void sunxi_mode_set(const struct ctfb_res_modes *mode,
>> break;
>> case sunxi_monitor_lcd:
>> sunxi_lcdc_panel_enable();
>> +#ifdef CONFIG_VIDEO_LCD_HITACHI_TX18D42VM
>> + sunxi_hitachi_tx18d42vm_init();
>> +#endif
>
> And here, please try to use
>
> if (IS_ENABLED(CONFIG_VIDEO_LCD_HITACHI_TX18D42VM))
> sunxi_hitachi_tx18d42vm_init();
So I've changed this into:
+ if (IS_ENABLED(CONFIG_VIDEO_LCD_HITACHI_TX18D42VM)) {
+ mdelay(50); /* Wait for lcd controller power on */
+ hitachi_tx18d42vm_init();
+ }
instead and completely dropped the sunxi wrapper around hitachi_tx18d42vm_init()
this way the initialization flow is more clear too as an added bonus.
I'll give this version a test spin and then send a v3.
Thanks & Regards,
Hans
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2015-01-22 19:43 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-01-20 14:08 [U-Boot] [PATCH v2 0/2] video: Add support for Hitachi tx18d42vm LVDS LCD Hans de Goede
2015-01-20 14:08 ` [U-Boot] [PATCH v2 1/2] video: Add support for Hitachi tx18d42vm LVDS LCD panels Hans de Goede
2015-01-22 17:36 ` Anatolij Gustschin
2015-01-20 14:08 ` [U-Boot] [PATCH v2 2/2] sunxi: " Hans de Goede
2015-01-22 17:37 ` Anatolij Gustschin
2015-01-22 19:43 ` Hans de Goede
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox