From patchwork Sun Jan 4 20:05:39 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans de Goede X-Patchwork-Id: 425190 X-Patchwork-Delegate: ijc@hellion.org.uk Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from theia.denx.de (theia.denx.de [85.214.87.163]) by ozlabs.org (Postfix) with ESMTP id AB539140082 for ; Mon, 5 Jan 2015 07:06:10 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 4949E4B742; Sun, 4 Jan 2015 21:06:08 +0100 (CET) Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id nbuFMNcNvx5a; Sun, 4 Jan 2015 21:06:07 +0100 (CET) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 6E5754B737; Sun, 4 Jan 2015 21:06:07 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id D73504B73E for ; Sun, 4 Jan 2015 21:06:01 +0100 (CET) Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id JtGJXjlzN5YB for ; Sun, 4 Jan 2015 21:06:01 +0100 (CET) X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 NOT_IN_BL_NJABL=-1.5 (only DNSBL check requested) Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by theia.denx.de (Postfix) with ESMTPS id 5B72D4B734 for ; Sun, 4 Jan 2015 21:05:58 +0100 (CET) Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id t04K5jpp028644 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Sun, 4 Jan 2015 15:05:45 -0500 Received: from shalem.localdomain.com (vpn1-4-122.ams2.redhat.com [10.36.4.122]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t04K5f1h024722; Sun, 4 Jan 2015 15:05:44 -0500 From: Hans de Goede To: Ian Campbell Date: Sun, 4 Jan 2015 21:05:39 +0100 Message-Id: <1420401940-15136-2-git-send-email-hdegoede@redhat.com> In-Reply-To: <1420401940-15136-1-git-send-email-hdegoede@redhat.com> References: <1420401940-15136-1-git-send-email-hdegoede@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 Cc: u-boot@lists.denx.de Subject: [U-Boot] [PATCH 2/3] sunxi: video: Add support for Hitachi tx18d42vm LCD panels X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.13 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: u-boot-bounces@lists.denx.de Errors-To: u-boot-bounces@lists.denx.de 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 --- board/sunxi/Kconfig | 3 ++ drivers/video/Makefile | 2 +- drivers/video/sunxi_display.c | 9 ++++++ drivers/video/sunxi_lcd_panel.c | 68 +++++++++++++++++++++++++++++++++++++++++ drivers/video/sunxi_lcd_panel.h | 9 ++++++ 5 files changed, 90 insertions(+), 1 deletion(-) create mode 100644 drivers/video/sunxi_lcd_panel.c create mode 100644 drivers/video/sunxi_lcd_panel.h diff --git a/board/sunxi/Kconfig b/board/sunxi/Kconfig index fdb18a4..e9f62b9 100644 --- a/board/sunxi/Kconfig +++ b/board/sunxi/Kconfig @@ -357,6 +357,9 @@ config VIDEO_LCD_PANEL_PARALLEL config VIDEO_LCD_PANEL_LVDS bool "Generic lvds interface LCD panel" +config VIDEO_LCD_PANEL_HITACHI_TX18D42VM + bool "Hitachi tx18d42vm LCD panel" + endchoice config USB_KEYBOARD diff --git a/drivers/video/Makefile b/drivers/video/Makefile index 42b1eaa..d4fe1aa 100644 --- a/drivers/video/Makefile +++ b/drivers/video/Makefile @@ -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 diff --git a/drivers/video/sunxi_display.c b/drivers/video/sunxi_display.c index 4b63b01..f087c2c 100644 --- a/drivers/video/sunxi_display.c +++ b/drivers/video/sunxi_display.c @@ -19,8 +19,13 @@ #include #include #include +#include "sunxi_lcd_panel.h" #include "videomodes.h" +#ifdef CONFIG_VIDEO_LCD_PANEL_HITACHI_TX18D42VM +#define CONFIG_VIDEO_LCD_PANEL_LVDS +#endif + DECLARE_GLOBAL_DATA_PTR; enum sunxi_monitor { @@ -486,6 +491,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) diff --git a/drivers/video/sunxi_lcd_panel.c b/drivers/video/sunxi_lcd_panel.c new file mode 100644 index 0000000..9ebaff2 --- /dev/null +++ b/drivers/video/sunxi_lcd_panel.c @@ -0,0 +1,68 @@ +/* + * LCD panel driver for Allwinner SoCs. + * + * (C) Copyright 2015 Hans de Goede + * + * SPDX-License-Identifier: GPL-2.0+ + */ + +#include + +#include +#include +#include + +#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 diff --git a/drivers/video/sunxi_lcd_panel.h b/drivers/video/sunxi_lcd_panel.h new file mode 100644 index 0000000..1fb9f1e --- /dev/null +++ b/drivers/video/sunxi_lcd_panel.h @@ -0,0 +1,9 @@ +/* + * LCD panel driver for Allwinner SoCs. + * + * (C) Copyright 2015 Hans de Goede + * + * SPDX-License-Identifier: GPL-2.0+ + */ + +void sunxi_lcd_panel_hitachi_tx18d42vm_init(void);