[U-Boot] [PATCH 1/3] sunxi: video: Add lvds support

Add support for lvds lcd panels
Signed-off-by: Hans de Goede hdegoede@redhat.com --- arch/arm/include/asm/arch-sunxi/clock_sun4i.h | 2 ++ arch/arm/include/asm/arch-sunxi/display.h | 12 ++++++++++ arch/arm/include/asm/arch-sunxi/gpio.h | 1 + board/sunxi/Kconfig | 14 ++++++++++++ drivers/video/sunxi_display.c | 33 +++++++++++++++++++++++++-- 5 files changed, 60 insertions(+), 2 deletions(-)
diff --git a/arch/arm/include/asm/arch-sunxi/clock_sun4i.h b/arch/arm/include/asm/arch-sunxi/clock_sun4i.h index 64b5c38..70b789e 100644 --- a/arch/arm/include/asm/arch-sunxi/clock_sun4i.h +++ b/arch/arm/include/asm/arch-sunxi/clock_sun4i.h @@ -284,6 +284,8 @@ struct sunxi_ccm_reg { /* Enable / disable both ch1 sclk1 and sclk2 at the same time */ #define CCM_LCD_CH1_CTRL_GATE (0x1 << 31 | 0x1 << 15)
+#define CCM_LVDS_CTRL_RST (1 << 0) + #define CCM_HDMI_CTRL_M(n) ((((n) - 1) & 0xf) << 0) #define CCM_HDMI_CTRL_PLL_MASK (3 << 24) #define CCM_HDMI_CTRL_PLL3 (0 << 24) diff --git a/arch/arm/include/asm/arch-sunxi/display.h b/arch/arm/include/asm/arch-sunxi/display.h index 44a274d..f1dfde1 100644 --- a/arch/arm/include/asm/arch-sunxi/display.h +++ b/arch/arm/include/asm/arch-sunxi/display.h @@ -88,6 +88,9 @@ struct sunxi_lcdc_reg { u8 res3[0x44]; /* 0xac */ u32 tcon1_io_polarity; /* 0xf0 */ u32 tcon1_io_tristate; /* 0xf4 */ + u8 res4[0x128]; /* 0xf8 */ + u32 lvds_ana0; /* 0x220 */ + u32 lvds_ana1; /* 0x224 */ };
struct sunxi_hdmi_reg { @@ -241,12 +244,21 @@ struct sunxi_tve_reg { #define SUNXI_LCDC_TCON0_TIMING_H_TOTAL(n) (((n) - 1) << 16) #define SUNXI_LCDC_TCON0_TIMING_V_BP(n) (((n) - 1) << 0) #define SUNXI_LCDC_TCON0_TIMING_V_TOTAL(n) (((n) * 2) << 16) +#define SUNXI_LCDC_TCON0_LVDS_INTF_BITWIDTH(n) ((n) << 26) +#define SUNXI_LCDC_TCON0_LVDS_INTF_ENABLE (1 << 31) +#define SUNXI_LCDC_TCON0_IO_POL_DCLK_PHASE0 (0 << 28) +#define SUNXI_LCDC_TCON0_IO_POL_DCLK_PHASE60 (1 << 28) +#define SUNXI_LCDC_TCON0_IO_POL_DCLK_PHASE120 (2 << 28) #define SUNXI_LCDC_TCON1_CTRL_CLK_DELAY(n) (((n) & 0x1f) << 4) #define SUNXI_LCDC_TCON1_CTRL_ENABLE (1 << 31) #define SUNXI_LCDC_TCON1_TIMING_H_BP(n) (((n) - 1) << 0) #define SUNXI_LCDC_TCON1_TIMING_H_TOTAL(n) (((n) - 1) << 16) #define SUNXI_LCDC_TCON1_TIMING_V_BP(n) (((n) - 1) << 0) #define SUNXI_LCDC_TCON1_TIMING_V_TOTAL(n) (((n) * 2) << 16) +#define SUNXI_LCDC_LVDS_ANA0 0x3f310000 +#define SUNXI_LCDC_LVDS_ANA0_UPDATE (1 << 22) +#define SUNXI_LCDC_LVDS_ANA1_INIT1 (0x1f << 26 | 0x1f << 10) +#define SUNXI_LCDC_LVDS_ANA1_INIT2 (0x1f << 16 | 0x1f << 00)
/* * HDMI register constants. diff --git a/arch/arm/include/asm/arch-sunxi/gpio.h b/arch/arm/include/asm/arch-sunxi/gpio.h index 9438f5a..71cc879 100644 --- a/arch/arm/include/asm/arch-sunxi/gpio.h +++ b/arch/arm/include/asm/arch-sunxi/gpio.h @@ -151,6 +151,7 @@ enum sunxi_gpio_number { #define SUNXI_GPC6_SDC2 3
#define SUNXI_GPD0_LCD0 2 +#define SUNXI_GPD0_LVDS0 3
#define SUNXI_GPF0_SDC0 2
diff --git a/board/sunxi/Kconfig b/board/sunxi/Kconfig index 8782394..fdb18a4 100644 --- a/board/sunxi/Kconfig +++ b/board/sunxi/Kconfig @@ -345,6 +345,20 @@ config VIDEO_LCD_BL_PWM Set the backlight pwm pin for the LCD panel. This takes a string in the format understood by sunxi_name_to_gpio, e.g. PH1 for pin 1 of port H.
+choice + prompt "LCD panel support" + depends on VIDEO + ---help--- + Select which type of LCD panel to support. + +config VIDEO_LCD_PANEL_PARALLEL + bool "Generic parallel interface LCD panel" + +config VIDEO_LCD_PANEL_LVDS + bool "Generic lvds interface LCD panel" + +endchoice + config USB_KEYBOARD boolean "Enable USB keyboard support" default y diff --git a/drivers/video/sunxi_display.c b/drivers/video/sunxi_display.c index 319e578..4b63b01 100644 --- a/drivers/video/sunxi_display.c +++ b/drivers/video/sunxi_display.c @@ -339,8 +339,12 @@ static void sunxi_lcdc_pll_set(int tcon, int dotclock, int best_double = 0;
if (tcon == 0) { +#ifdef CONFIG_VIDEO_LCD_PANEL_LVDS + min_m = max_m = 7; +#else min_m = 6; max_m = 127; +#endif } else { min_m = 1; max_m = 15; @@ -420,6 +424,9 @@ static void sunxi_lcdc_init(void)
/* Clock on */ setbits_le32(&ccm->ahb_gate1, 1 << AHB_GATE_OFFSET_LCD0); +#ifdef CONFIG_VIDEO_LCD_PANEL_LVDS + setbits_le32(&ccm->lvds_clk_cfg, CCM_LVDS_CTRL_RST); +#endif
/* Init lcdc */ writel(0, &lcdc->ctrl); /* Disable tcon */ @@ -439,6 +446,16 @@ static void sunxi_lcdc_enable(void) (struct sunxi_lcdc_reg *)SUNXI_LCD0_BASE;
setbits_le32(&lcdc->ctrl, SUNXI_LCDC_CTRL_TCON_ENABLE); +#ifdef CONFIG_VIDEO_LCD_PANEL_LVDS + setbits_le32(&lcdc->tcon0_lvds_intf, SUNXI_LCDC_TCON0_LVDS_INTF_ENABLE); + setbits_le32(&lcdc->lvds_ana0, SUNXI_LCDC_LVDS_ANA0); + setbits_le32(&lcdc->lvds_ana0, SUNXI_LCDC_LVDS_ANA0_UPDATE); + udelay(2); /* delay at least 1200 ns */ + setbits_le32(&lcdc->lvds_ana1, SUNXI_LCDC_LVDS_ANA1_INIT1); + udelay(1); /* delay at least 120 ns */ + setbits_le32(&lcdc->lvds_ana1, SUNXI_LCDC_LVDS_ANA1_INIT2); + setbits_le32(&lcdc->lvds_ana0, SUNXI_LCDC_LVDS_ANA0_UPDATE); +#endif }
static void sunxi_lcdc_panel_enable(void) @@ -507,7 +524,11 @@ static void sunxi_lcdc_tcon0_mode_set(const struct ctfb_res_modes *mode) int bp, clk_delay, clk_div, clk_double, pin, total, val;
for (pin = SUNXI_GPD(0); pin <= SUNXI_GPD(27); pin++) +#ifdef CONFIG_VIDEO_LCD_PANEL_LVDS + sunxi_gpio_set_cfgpin(pin, SUNXI_GPD0_LVDS0); +#else sunxi_gpio_set_cfgpin(pin, SUNXI_GPD0_LCD0); +#endif
sunxi_lcdc_pll_set(0, mode->pixclock_khz, &clk_div, &clk_double);
@@ -535,12 +556,16 @@ static void sunxi_lcdc_tcon0_mode_set(const struct ctfb_res_modes *mode) writel(SUNXI_LCDC_TCON0_TIMING_V_TOTAL(total) | SUNXI_LCDC_TCON0_TIMING_V_BP(bp), &lcdc->tcon0_timing_v);
+#ifdef CONFIG_VIDEO_LCD_PANEL_LVDS + val = (sunxi_display.depth == 18) ? 1 : 0; + writel(SUNXI_LCDC_TCON0_LVDS_INTF_BITWIDTH(val), &lcdc->tcon0_lvds_intf); +#else writel(SUNXI_LCDC_X(mode->hsync_len) | SUNXI_LCDC_Y(mode->vsync_len), &lcdc->tcon0_timing_sync);
- /* We only support hv-sync parallel lcd-s for now */ writel(0, &lcdc->tcon0_hv_intf); writel(0, &lcdc->tcon0_cpu_intf); +#endif
if (sunxi_display.depth == 18 || sunxi_display.depth == 17) { writel(SUNXI_LCDC_FRAME_CTRL_DITHER0, &lcdc->frame_ctrl[1]); @@ -559,7 +584,11 @@ static void sunxi_lcdc_tcon0_mode_set(const struct ctfb_res_modes *mode) &lcdc->frame_ctrl[0]); }
- val = 0; +#ifdef CONFIG_VIDEO_LCD_PANEL_LVDS + val = SUNXI_LCDC_TCON0_IO_POL_DCLK_PHASE60; +#else + val = SUNXI_LCDC_TCON0_IO_POL_DCLK_PHASE0; +#endif if (!(mode->sync & FB_SYNC_HOR_HIGH_ACT)) val |= SUNXI_LCDC_TCON_HSYNC_MASK; if (!(mode->sync & FB_SYNC_VERT_HIGH_ACT))

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 | 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 <fdtdec.h> #include <fdt_support.h> #include <video_fb.h> +#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 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 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 hdegoede@redhat.com + * + * SPDX-License-Identifier: GPL-2.0+ + */ + +void sunxi_lcd_panel_hitachi_tx18d42vm_init(void);

On Sun, 2015-01-04 at 21:05 +0100, Hans de Goede wrote:
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.
This doesn't sound terribly sunxi specific, shouldn't sunxi_lcd_panel_hitachi_tx18d42vm_init be generic but making use of some sort of arch-provided interface for actually talking SPI to the device (which may or may not use the generic SPI infra, as your code comment talked about)?
Ian.

Hi,
On 07-01-15 19:59, Ian Campbell wrote:
On Sun, 2015-01-04 at 21:05 +0100, Hans de Goede wrote:
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.
This doesn't sound terribly sunxi specific, shouldn't sunxi_lcd_panel_hitachi_tx18d42vm_init be generic but making use of some sort of arch-provided interface for actually talking SPI to the device (which may or may not use the generic SPI infra, as your code comment talked about)?
You're right it is not sunxi specific, but for now sunxi is the only user (I've checked) so this seemed simplest, with the idea that it is always much easier to make something properly generic when there is more then one user.
I guess I should have put something about this in the commit message :)
Regards,
Hans

On Wed, 2015-01-07 at 21:04 +0100, Hans de Goede wrote:
Hi,
On 07-01-15 19:59, Ian Campbell wrote:
On Sun, 2015-01-04 at 21:05 +0100, Hans de Goede wrote:
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.
This doesn't sound terribly sunxi specific, shouldn't sunxi_lcd_panel_hitachi_tx18d42vm_init be generic but making use of some sort of arch-provided interface for actually talking SPI to the device (which may or may not use the generic SPI infra, as your code comment talked about)?
You're right it is not sunxi specific, but for now sunxi is the only user (I've checked) so this seemed simplest, with the idea that it is always much easier to make something properly generic when there is more then one user.
I think we are more likely to simply end up with N versions of this code because no one notices that it already exists under some other name. If Anatolij is OK with it then I have no objections.
I guess I should have put something about this in the commit message :)
Regards,
Hans

On Sun, 2015-01-04 at 21:05 +0100, Hans de Goede wrote:
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 | 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 <fdtdec.h> #include <fdt_support.h> #include <video_fb.h> +#include "sunxi_lcd_panel.h" #include "videomodes.h"
+#ifdef CONFIG_VIDEO_LCD_PANEL_HITACHI_TX18D42VM +#define CONFIG_VIDEO_LCD_PANEL_LVDS +#endif
Your reply to 1/3 made me notice this, which I somehow missed before, I don't think this is the right way to go about this.
It seems to me that LCD_PANEL_HITACHI does not belong under the PARALLEL vs LVDS Kconfig choice, rather it should be an independent bool option which depends on PANEL_LVDS.
Ian.

Hi,
On 08-01-15 09:32, Ian Campbell wrote:
On Sun, 2015-01-04 at 21:05 +0100, Hans de Goede wrote:
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 | 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 <fdtdec.h> #include <fdt_support.h> #include <video_fb.h> +#include "sunxi_lcd_panel.h" #include "videomodes.h"
+#ifdef CONFIG_VIDEO_LCD_PANEL_HITACHI_TX18D42VM +#define CONFIG_VIDEO_LCD_PANEL_LVDS +#endif
Your reply to 1/3 made me notice this, which I somehow missed before, I don't think this is the right way to go about this.
It seems to me that LCD_PANEL_HITACHI does not belong under the PARALLEL vs LVDS Kconfig choice, rather it should be an independent bool option which depends on PANEL_LVDS.
Technically you are correct, but from a user pov it seems easier to tell the user to select which panel he has, and then the user can chose between a bunch of generic ones (generic parallel, generic lvds) and a bunch of specific panels which need some extra setup.
If you insist I can live with doing things your way though, either way let me know how you want to handle this.
Regards,
Hans

On Thu, 2015-01-08 at 09:39 +0100, Hans de Goede wrote:
Hi,
On 08-01-15 09:32, Ian Campbell wrote:
On Sun, 2015-01-04 at 21:05 +0100, Hans de Goede wrote:
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 | 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 <fdtdec.h> #include <fdt_support.h> #include <video_fb.h> +#include "sunxi_lcd_panel.h" #include "videomodes.h"
+#ifdef CONFIG_VIDEO_LCD_PANEL_HITACHI_TX18D42VM +#define CONFIG_VIDEO_LCD_PANEL_LVDS +#endif
Your reply to 1/3 made me notice this, which I somehow missed before, I don't think this is the right way to go about this.
It seems to me that LCD_PANEL_HITACHI does not belong under the PARALLEL vs LVDS Kconfig choice, rather it should be an independent bool option which depends on PANEL_LVDS.
Technically you are correct, but from a user pov it seems easier to tell the user to select which panel he has, and then the user can chose between a bunch of generic ones (generic parallel, generic lvds) and a bunch of specific panels which need some extra setup.
Hrm, true.
If you insist I can live with doing things your way though, either way let me know how you want to handle this.
Perhaps have hidden Kconfig options for the baseline LVDS vs PARALLEL support and then a choice of GENERIC //, GENERIC LVDS, HITACHI TX.., OTHER MAGIC PANEL with appropriate selects on the hidden options?
Then the generic code would use the hidden options, no need for a weird #ifdef/#define pair for each non-standard panel (which depending on how many panels are normal vs. needing magic could get unwieldy).
Ian.

The Chuwi V7 is an A10 (sun4i) based tablet with 1G of RAM, 16G of nand flash, microsd slot, 7" 1024x768 lvds ips panel, mini hdmi out, headphones out, stereo speakers, front & back camera and usb wifi.
It is clearly marked "CHUWI", "V7" and "Model: CW0825" on the back of the tablet.
Signed-off-by: Hans de Goede hdegoede@redhat.com --- board/sunxi/Kconfig | 4 ++++ board/sunxi/MAINTAINERS | 1 + board/sunxi/Makefile | 1 + board/sunxi/dram_sun4i_408_1024_iow16.c | 31 +++++++++++++++++++++++++++++++ configs/Chuwi_V7_CW0825_defconfig | 13 +++++++++++++ 5 files changed, 50 insertions(+) create mode 100644 board/sunxi/dram_sun4i_408_1024_iow16.c create mode 100644 configs/Chuwi_V7_CW0825_defconfig
diff --git a/board/sunxi/Kconfig b/board/sunxi/Kconfig index e9f62b9..bbee94f 100644 --- a/board/sunxi/Kconfig +++ b/board/sunxi/Kconfig @@ -101,6 +101,10 @@ config TARGET_BANANAPRO bool "BANANAPRO" depends on MACH_SUN7I
+config TARGET_CHUWI_V7_CW0825 + bool "CHUWI_V7_CW0825" + depends on MACH_SUN4I + config TARGET_COLOMBUS bool "COLOMBUS" depends on MACH_SUN6I diff --git a/board/sunxi/MAINTAINERS b/board/sunxi/MAINTAINERS index d926d2e..d880b63 100644 --- a/board/sunxi/MAINTAINERS +++ b/board/sunxi/MAINTAINERS @@ -5,6 +5,7 @@ F: board/sunxi/ F: include/configs/sun4i.h F: configs/A10-OLinuXino-Lime_defconfig F: configs/ba10_tv_box_defconfig +F: configs/Chuwi_V7_CW0825_defconfig F: configs/Cubieboard_defconfig F: configs/Mele_A1000_defconfig F: configs/Mele_A1000G_defconfig diff --git a/board/sunxi/Makefile b/board/sunxi/Makefile index 8ca01f6..805d8c9 100644 --- a/board/sunxi/Makefile +++ b/board/sunxi/Makefile @@ -23,6 +23,7 @@ obj-$(CONFIG_TARGET_AUXTEK_T004) += dram_a10s_olinuxino_m.o obj-$(CONFIG_TARGET_BA10_TV_BOX) += dram_sun4i_384_1024_iow8.o obj-$(CONFIG_TARGET_BANANAPI) += dram_bananapi.o obj-$(CONFIG_TARGET_BANANAPRO) += dram_bananapi.o +obj-$(CONFIG_TARGET_CHUWI_V7_CW0825) += dram_sun4i_408_1024_iow16.o obj-$(CONFIG_TARGET_CUBIEBOARD) += dram_cubieboard.o obj-$(CONFIG_TARGET_CUBIEBOARD2) += dram_cubieboard2.o obj-$(CONFIG_TARGET_CUBIETRUCK) += dram_cubietruck.o diff --git a/board/sunxi/dram_sun4i_408_1024_iow16.c b/board/sunxi/dram_sun4i_408_1024_iow16.c new file mode 100644 index 0000000..1bc9f73 --- /dev/null +++ b/board/sunxi/dram_sun4i_408_1024_iow16.c @@ -0,0 +1,31 @@ +/* this file is generated, don't edit it yourself */ + +#include <common.h> +#include <asm/arch/dram.h> + +static struct dram_para dram_para = { + .clock = 408, + .type = 3, + .rank_num = 1, + .density = 4096, + .io_width = 16, + .bus_width = 32, + .cas = 6, + .zq = 123, + .odt_en = 0, + .size = 1024, + .tpr0 = 0x30926692, + .tpr1 = 0x1090, + .tpr2 = 0x1a0c8, + .tpr3 = 0, + .tpr4 = 0, + .tpr5 = 0, + .emr1 = 0x4, + .emr2 = 0, + .emr3 = 0, +}; + +unsigned long sunxi_dram_init(void) +{ + return dramc_init(&dram_para); +} diff --git a/configs/Chuwi_V7_CW0825_defconfig b/configs/Chuwi_V7_CW0825_defconfig new file mode 100644 index 0000000..15bd9c7 --- /dev/null +++ b/configs/Chuwi_V7_CW0825_defconfig @@ -0,0 +1,13 @@ +CONFIG_SPL=y +CONFIG_SYS_EXTRA_OPTIONS="AXP209_POWER" +CONFIG_FDTFILE="sun4i-a10-chuwi-v7-cw0825.dtb" +CONFIG_VIDEO_LCD_MODE="x:1024,y:768,depth:24,pclk_khz:51000,le:19,ri:300,up:6,lo:31,hs:1,vs:1,sync:3,vmode:0" +CONFIG_VIDEO_LCD_POWER="PH8" +CONFIG_VIDEO_LCD_BL_EN="PH7" +CONFIG_VIDEO_LCD_BL_PWM="PB2" +CONFIG_VIDEO_LCD_PANEL_HITACHI_TX18D42VM=y +CONFIG_USB_KEYBOARD=n ++S:CONFIG_ARM=y ++S:CONFIG_ARCH_SUNXI=y ++S:CONFIG_MACH_SUN4I=y ++S:CONFIG_TARGET_CHUWI_V7_CW0825=y

On Sun, 2015-01-04 at 21:05 +0100, Hans de Goede wrote:
The Chuwi V7 is an A10 (sun4i) based tablet with 1G of RAM, 16G of nand flash, microsd slot, 7" 1024x768 lvds ips panel, mini hdmi out, headphones out, stereo speakers, front & back camera and usb wifi.
It is clearly marked "CHUWI", "V7" and "Model: CW0825" on the back of the tablet.
Signed-off-by: Hans de Goede hdegoede@redhat.com
Acked-by: Ian Campbell ijc@hellion.org.uk

On Sun, 2015-01-04 at 21:05 +0100, Hans de Goede wrote:
diff --git a/board/sunxi/Kconfig b/board/sunxi/Kconfig index 8782394..fdb18a4 100644 --- a/board/sunxi/Kconfig +++ b/board/sunxi/Kconfig @@ -345,6 +345,20 @@ config VIDEO_LCD_BL_PWM Set the backlight pwm pin for the LCD panel. This takes a string in the format understood by sunxi_name_to_gpio, e.g. PH1 for pin 1 of port H.
+choice
- prompt "LCD panel support"
- depends on VIDEO
- ---help---
- Select which type of LCD panel to support.
+config VIDEO_LCD_PANEL_PARALLEL
- bool "Generic parallel interface LCD panel"
I don't see any use of this choice, I suppose it is the #else case?
Are there other (third) options for LCDs? Or could this be reworded as a boolean rather than a choice? If it's to remain a choice I think it'd be better to have explicit #ifdef ..._PARALLEL rather than #else. Maybe an #else /* ..._PARALLEL */ style would be an ok compromise though.
The code itself is fine by me, not that I know **** about graphics stuff ;-)
Ian.

Hi,
On 07-01-15 19:56, Ian Campbell wrote:
On Sun, 2015-01-04 at 21:05 +0100, Hans de Goede wrote:
diff --git a/board/sunxi/Kconfig b/board/sunxi/Kconfig index 8782394..fdb18a4 100644 --- a/board/sunxi/Kconfig +++ b/board/sunxi/Kconfig @@ -345,6 +345,20 @@ config VIDEO_LCD_BL_PWM Set the backlight pwm pin for the LCD panel. This takes a string in the format understood by sunxi_name_to_gpio, e.g. PH1 for pin 1 of port H.
+choice
- prompt "LCD panel support"
- depends on VIDEO
- ---help---
- Select which type of LCD panel to support.
+config VIDEO_LCD_PANEL_PARALLEL
- bool "Generic parallel interface LCD panel"
I don't see any use of this choice, I suppose it is the #else case?
Right, it is the else case in the actual code (for now).
Are there other (third) options for LCDs?
Yes, see the second patch in this series, and Sairhei has a tablet which needs something similar (but different) to the second patch.
Or could this be reworded as a boolean rather than a choice? If it's to remain a choice I think it'd be better to have explicit #ifdef ..._PARALLEL rather than #else. Maybe an #else /* ..._PARALLEL */ style would be an ok compromise though.
I can make either change, looking at the original allwinner kernel code I guess doing the #ifdef variant makes most sense. I'll respin this when we know what to do wrt patch 2/3.
Regards,
Hans

On Wed, 2015-01-07 at 20:58 +0100, Hans de Goede wrote:
Hi,
On 07-01-15 19:56, Ian Campbell wrote:
On Sun, 2015-01-04 at 21:05 +0100, Hans de Goede wrote:
diff --git a/board/sunxi/Kconfig b/board/sunxi/Kconfig index 8782394..fdb18a4 100644 --- a/board/sunxi/Kconfig +++ b/board/sunxi/Kconfig @@ -345,6 +345,20 @@ config VIDEO_LCD_BL_PWM Set the backlight pwm pin for the LCD panel. This takes a string in the format understood by sunxi_name_to_gpio, e.g. PH1 for pin 1 of port H.
+choice
- prompt "LCD panel support"
- depends on VIDEO
- ---help---
- Select which type of LCD panel to support.
+config VIDEO_LCD_PANEL_PARALLEL
- bool "Generic parallel interface LCD panel"
I don't see any use of this choice, I suppose it is the #else case?
Right, it is the else case in the actual code (for now).
Are there other (third) options for LCDs?
Yes, see the second patch in this series,
I've replied to the second patch again because it doesn't seem right to put the specific choice of panel under the class of panel choice label.
and Sairhei has a tablet which needs something similar (but different) to the second patch.
I can't find a reference for this, but I suppose it might imply that the choice of panel should be a Kconfig choice too, just not the same one as the general class of panel Kconfig choice (IYSWIM).
Ian.
participants (2)
-
Hans de Goede
-
Ian Campbell