Enabling LCD in u-boot Kernel 4.7.2


Recommended Posts

 Hi,

 

since Igor told me to enable LCD in u-boot I was searching for a solution. In the menuconfig of Kernel 3.4 ... 3.14 I saw Device Drivers > Graphics Support > Enable driver model support for LCD/video ...

Now in menuconfig of armbian with Kernel 4.7.2 I can't see this option. I see attach screenshot. Has anyone an idea how to enable LCD? 

I'm using LeMaker 5" LCD with CP - Touch. My board is Banana Pi with Allwinner a20.

 

post-1861-0-77910900-1472137447_thumb.png

Link to post
Share on other sites
Want Armbian t-shirt or a cup?

Ok, I downloaded the armbian source with all build tools from 

 

https://github.com/igorpecovnik/lib

 

as described at

 

http://docs.armbian.com/Developer-Guide_Build-Preparation/

 

I changed the file /sources/u-boot/v2016.07/configs/Bananapi_defconfig. Here I added:

CONFIG_VIDEO_LCD_MODE="x:800,y:480,depth:24,pclk_khz:30000,le:40,ri:40,up:29,lo:13,hs:48,vs:3,sync:3,vmode:0"
CONFIG_VIDEO_LCD_POWER="PH12"
CONFIG_VIDEO_LCD_BL_EN="PH8"
CONFIG_VIDEO_LCD_BL_PWM="PB2"
Left the rest of file as it was. 
 
 
I also changed /sources/u-boot-v2016.07/arch/arm/dts/sun7i-a20-bananapi.dts
At the end of &pio node, I added:
    edt_ft5x06_pins: edt_ft5x06_pins@0 {
            allwinner,pins = "PH7", "PH9";
            allwinner,function = "gpio_out";
            allwinner,drive = <SUN4I_PINCTRL_40_MA>;
            allwinner,pull = <SUN4I_PINCTRL_NO_PULL>;
    }; 

And for touchdriver:

&i2c3 {
        status = "okay";
        pinctrl-names = "default";
        pinctrl-0 = <&i2c3_pins_a>;
        edt: edt-ft5x06@38 {
                        compatible = "edt,edt-ft5x06";
                        reg = <0x38>;
                        interrupt-parent = <&pio>;
                        interrupts = <7 9 IRQ_TYPE_EDGE_FALLING>;
                        wake-gpios = <7 7 GPIO_ACTIVE_LOW>;
                        pinctrl-names = "default";
                        pinctrl-0 = <&edt_ft5x06_pins>;
                        touchscreen-size-x = <1024>;
                        touchscreen-size-y = <600>;
                        touchscreen-inverted-x;
                        touchscreen-swapped-x-y;
        };
};

After &i2c2.

 

PWM.

&pwm {
pinctrl-names = "default";
pinctrl-0 = <&pwm0_pins_a>, <&pwm1_pins_a>;
status = "okay";
};

for backlight PWM after the &pio node.

In /sources/u-boot-v2016.07/arch/arm/dts/sun7i-a20.dtsi I activated simpleframebuffer "framebuffer@1":

framebuffer@1 {
compatible = "allwinner,simple-framebuffer",
    "simple-framebuffer";
allwinner,pipeline = "de_be0-lcd0";
clocks = <&ahb_gates 36>, <&ahb_gates 44>,
<&de_be0_clk>, <&tcon0_ch0_clk>,
<&dram_gates 26>;
status = "enabled";
};

Built the armbian, made an image, wrote it to SD and let it run. Still HDMI is on, LCD stays dark.

 

Any Ideas?

Link to post
Share on other sites

At http://docs.armbian.com/Developer-Guide_Build-Options/I saw, that there are two variables EXTERNAL and EXTERNAL_NEW.

EXTERNAL compiles some extra applications like sunxi display control. EXTERNAL_NEW does compiles extra applications in to chroot.

 

I now set both to "yes" in compile.sh.

But still got no picture on my lcd.

Those things has nothing to do with your problem.

 

http://forum.armbian.com/index.php/topic/1905-enabling-lcd-in-u-boot-kernel-472/#entry14676

You are on the right track here but obviously something is missing.

Link to post
Share on other sites

The same thought as me. Must be missing something.

Isn't it necessary to map the pins for the Display like in FEX as shown below? 

Is there a syntax for DT to do this?

[lcd0_para]
.
.
.
.
lcd_bl_en = port:PH08<1><0><default><1>
lcd_power_used = 1
lcd_power = port:PH12<1><0><default><1>
lcd_pwm_used = 1
lcd_pwm = port:PB02<2><0><default><default>
lcdd0 = port:PD00<2><0><3><default>
lcdd1 = port:PD01<2><0><3><default>
lcdd2 = port:PD02<2><0><3><default>
lcdd3 = port:PD03<2><0><3><default>
lcdd4 = port:PD04<2><0><3><default>
lcdd5 = port:PD05<2><0><3><default>
lcdd6 = port:PD06<2><0><3><default>
lcdd7 = port:PD07<2><0><3><default>
lcdd8 = port:PD08<2><0><3><default>
lcdd9 = port:PD09<2><0><3><default>
lcdd10 = port:PD10<2><0><3><default>
lcdd11 = port:PD11<2><0><3><default>
lcdd12 = port:PD12<2><0><3><default>
lcdd13 = port:PD13<2><0><3><default>
lcdd14 = port:PD14<2><0><3><default>
lcdd15 = port:PD15<2><0><3><default>
lcdd16 = port:PD16<2><0><3><default>
lcdd17 = port:PD17<2><0><3><default>
lcdd18 = port:PD18<2><0><3><default>
lcdd19 = port:PD19<2><0><3><default>
lcdd20 = port:PD20<2><0><3><default>
lcdd21 = port:PD21<2><0><3><default>
lcdd22 = port:PD22<2><0><3><default>
lcdd23 = port:PD23<2><0><3><default>
lcdclk = port:PD24<2><0><3><default>
lcdde = port:PD25<2><0><3><default>
lcdhsync = port:PD26<2><0><3><default>
lcdvsync = port:PD27<2><0><3><default>

I saw a file at /sources/u-boot/v2016.07/drivers/video called sunxi_display.c. There are some specific defines like SSD2828. 

ifdef CONFIG_VIDEO_LCD_SSD2828
static int sunxi_ssd2828_init(const struct ctfb_res_modes *mode)
{
	struct ssd2828_config cfg = {
		.csx_pin = name_to_gpio(CONFIG_VIDEO_LCD_SPI_CS),
		.sck_pin = name_to_gpio(CONFIG_VIDEO_LCD_SPI_SCLK),
		.sdi_pin = name_to_gpio(CONFIG_VIDEO_LCD_SPI_MOSI),
		.sdo_pin = name_to_gpio(CONFIG_VIDEO_LCD_SPI_MISO),
		.reset_pin = name_to_gpio(CONFIG_VIDEO_LCD_SSD2828_RESET),
		.ssd2828_tx_clk_khz  = CONFIG_VIDEO_LCD_SSD2828_TX_CLK * 1000,
		.ssd2828_color_depth = 24,
#ifdef CONFIG_VIDEO_LCD_PANEL_MIPI_4_LANE_513_MBPS_VIA_SSD2828
		.mipi_dsi_number_of_data_lanes           = 4,
		.mipi_dsi_bitrate_per_data_lane_mbps     = 513,
		.mipi_dsi_delay_after_exit_sleep_mode_ms = 100,
		.mipi_dsi_delay_after_set_display_on_ms  = 200
#else
#error MIPI LCD panel needs configuration parameters
#endif
	};

I'm hoping not have to change a driver to make my display work.

Link to post
Share on other sites

I'm getting deeper and deeper into the topic. But it still doesn't work.

At http://wiki.lemaker.org/LeMaker_Guitar:LCD I saw an exampel of activiating LCD on the LeMakers Guitar:

I changed a few things and added this to my dtsi files.

lcd0: lcd0@01c0c000 {  /* org: lcd0: lcd0@b02a0000 {
                          0x01c0c000 from a20 allwinner manual*/
		pinctrl-names = "default";
		pinctrl-0 = <&lvds_state_default>;
		lcd_power_gpios = <&gpio 7 12 0> /*PH12"  /*<&gpio 36 0>;*/    /*GPIOB4*/
		//lcd_reset_gpios = <&gpio 49 0>; /*GPIOB17*/
		port_type = "lvds";
		data_width = <0>;		/* 0:24bit ,1:18bit */
		videomode-0 = <&lcd_mode0>;
		vsync_inversion = <0>;
		hsync_inversion = <0>;
 
		dclk_inversion = <0>;
		lde_inversion = <0>;
		lvds_ctl = <0x000a9523>;	/* last two bit: 3:8bit ,1:6bit */
		lvds_alg_ctl0 = <0xc141a030>;
		lightness = <128>;
		saturation = <7>;
		contrast = <5>;
 
		lcd_mode0:mode@800x600p60 {/*1280x800p60 {*/
				refresh = <60>;
				xres = <800>; /*1280*/
				yres = <480>; /*480*/   
				pixclock = <14090>;
				left_margin = <80>;
				right_margin = <60>;
				upper_margin = <8>;
				lower_margin = <7>;
				hsync_len = <20>;
				vsync_len = <8>;
				vmode = <0>;
		};
	};
 
        //Set LCD as a master device
        framebuffer {
                compatible = "actions,framebuffer";
                def_display = "lcd";          
        };
        //Set HDMI display as a master device
 /*     framebuffer {
                compatible = "actions,framebuffer";
                def_display = "hdmi";
                xres = <1280>;
                yres = <720>;
                bpp = <4>;               
        };
 */

First build throws an error because &lvds_state_default was unknown. So I seachrched arround and did find the original file https://github.com/LeMaker/linux-actions/blob/linux-3.10.y/arch/arm/boot/dts/lemaker_guitar_bbb.dts

I added lvds_state_default to my dtsi files. But build now throws a new error. I think it could be because of the "actions" and the names "mfp1_6_5" and so on. For a20 I saw at compatible and such things "allwinner,arm-cortex-a7" and so on.

 		lvds_state_default: lvds_default {
       			lvds_mux {
               			actions,groups = "mfp1_6_5", "mfp2_28_27";
                		actions,function = "lvds";
       			};
       			lcd_mux {
            			actions,groups = "mfp1_22_21";
            			actions,function = "lcd0";
     			};
  		};	
		rgb_state_default: rgb_default {
			rgb_mux {
				actions,groups = "mfp0_25_23","mfp1_16_14", "mfp1_22_21", "mfp1_13_12", "mfp1_11_10", "mfp1_6_5", "mfp2_30_29", "mfp2_28_27";
				actions,function = "lcd0";
			};
		};

Any hints how to name it correct?

Is there any documentation, where I can find the correct names?

Link to post
Share on other sites

Ok got some news:

 

Added following to sun7i-a20.dtsi

		framebuffer0: framebuffer@1d385000 {
			compatible = "simple-framebuffer";
			reg = <0x1d385000 (800 * 480 * 2)>;
			width = <800>;
			height = <4800>;
			stride = <(800 * 2)>;
			format = "r5g6b5";
			clocks = <&ahb_gates 36>, <&ahb_gates 43>, <&ahb_gates 44>;
			lcd-supply = <&reg_dc1sw>;
			display = <&lcdc0>;
		};
		stdout-path = "display0";

Changed the last lines in sun7i-a20.dtsi because of compiling errors to:

	 //Set LCD as a master device
	framebuffer {
			compatible = "allwinner,framebuffer";
			def_display = "lcd";          
	};
	
	/*lvds_state_default: lvds_default {
		lvds_mux {
				allwinner,groups = "mfp1_6_5", "mfp2_28_27";
				allwinner,function = "lvds";
		};
		lcd_mux {
				allwinner,groups = "mfp1_22_21";
				allwinner,function = "lcd0";
		};*/
		
		rgb_state_default: rgb_default {
			rgb_mux {
				allwinner,pins = "PD0", "PD1", "PD2", "PD3", "PD4", 
								"PD5", "PD6", "PD7", "PD8", "PD9", 
								"PD10", "PD11", "PD12", "PD13", 
								"PD14", "PD15", "PD16", "PD17", 
								"PD18", "PD19", "PD20", "PD21", 
								"PD22", "PD23", "PD24", "PD25", 
								"PD26", "PD26", "PD27", "PD27"; 								
				allwinner,function = "lcd0";
			};
		};		

And also changed the pinctrl value in sun7i-a20.dtsi for lcd0 and added a compatible line:

lcd0: lcd0@01c0c000 {
			compatible = "allwinner,sun4i-a10-lcdc";
			pinctrl-names = "default";
			pinctrl-0 = <&rgb_state_default>;

I thought "actions" could not be the correct label, because all other functions in device tree of a20 are called allwinner,...

Also find out that the groups does not exist for a20. Didn't find groups witch match. Maybe anybody knows where I can find out or add this groups. Must be a header file. So I changed "groups" to "pins" and added all pins from a20's port D witch represents the lcd0.

 

But what should I say ... display is still dark. I got sneaking suspicion, that still isn't activate in u-boot. I'm not sure, if the additions to my Bananapi_defconfig from http://forum.armbian.com/index.php/topic/1905-enabling-lcd-in-u-boot-kernel-472/?p=14676 arereally compiled into the u-boot. I'm thinking that hdmi has to stay black, if my configs are correct. Am I right?

Is there a way to check the config, of u-boot at runtime?

Link to post
Share on other sites

Okay Guys,

 

I've got a little success. My display is on now. I think the worst thing I could do, was to let HDMI plugged in and HDMI monitor switched on. Only by luck, I saw, that my display is working when HDMI monitor is switched of.

Now, I will search for the correct solution and post it here soon.

 

Yours Martin

Link to post
Share on other sites

So, now I can tell you how to enable LCD in u-boot and DT.

 

First getting the source of armbian from https://github.com/igorpecovnik/lib

Open the file sources/u-boot/v2016.09/configs/Bananapi_defconfig and add:

CONFIG_VIDEO_LCD_MODE="x:800,y:480,depth:24,pclk_khz:30000,le:40,ri:40,up:29,lo:13,hs:48,vs:3,sync:3,vmode:0"
CONFIG_VIDEO_LCD_POWER="PH12"
CONFIG_VIDEO_LCD_BL_EN="PH8"
CONFIG_VIDEO_LCD_BL_PWM="PB2"

Now LCD is enabled in u-boot. But it will not switch on backlight, because backlight uses pwm and pwm is disabled per default in DT. So you also have to add:

&pwm {
      pinctrl-names = "default";
      pinctrl-0 = <&pwm0_pins_a>, <&pwm1_pins_a>;
      status = "okay";
};

Ready!

But be aware, LCD only turns on if there is no HDMI Monitor plugged in!!

 

Ok, hopping some one else of you can use this stuff.

Link to post
Share on other sites

Hi,

 

I'm trying to do the same with Banana Pi + 7" LCD module. But my display stays dark.

 

  1. installed the toolchain
  2. changed the additional line for the 7" display to:

     

    CONFIG_VIDEO_LCD_MODE="x:1024,y:600,depth:24,pclk_khz:30000,le:40,ri:40,up:29,lo:13,hs:50,vs:10,sync:3,vmode:0"
    CONFIG_VIDEO_LCD_POWER="PH12"
    CONFIG_VIDEO_LCD_BL_EN="PH8"
    CONFIG_VIDEO_LCD_BL_PWM="PB2"

     

  3. added pwm group to .dts file like Martin did
  4. made no changes to compile.sh
  5. ./compile.sh with latest stable Jessie kernel + Desktop Environment

With a plugged in HDMI Monitor my BPi start correctly to Desktop. With unplugged HMDI unfortunately my 7" LCD stays dark

 

What have I done wrong? :-)

Link to post
Share on other sites

Hi Smuggler,

 

I think your on the right way. Your Display needs PWM to drive backlight, as you see in this line: CONFIG_VIDEO_LCD_BL_PWM="PB2". For default pwm is not enabled in device tree. So you also have to turn on the pwm backlight. Look at this thread: https://forum.armbian.com/index.php/topic/1817-using-pwm-without-rebuilding-kernel/#entry14015

 

Hope it will help you.

Yours,

Martin

Link to post
Share on other sites

I have done this. And added

&pwm {
    pinctrl-names = "default";
    pinctrl-0 = <&pwm0_pins_a>, <&pwm1_pins_a>;
    status = "okay";
};

 to my .../arch/arm/dts/sun7i-a20-bananpi.dts file

 

but it seems that the changed .dts file is not recompiled at all because after build image an recompile .dtb to .dts

i only can find

 

pwm@01c20e00 {
                        compatible = "allwinner,sun7i-a20-pwm";
                        reg = <0x1c20e00 0xc>;
                        clocks = <0xc>;
                        #pwm-cells = <0x3>;
                        status = "disabled";
                };

Link to post
Share on other sites

Ok, I got the same problem. This happens because compile.sh by default forces the checkout of all sources and also by default cleans the builds you did bevor. So every time you compile, your changes will be overwritten.

I suggest to set CREATE_PATCHES=yes in compile.sh.

Now you will be asked in the build process to change some files. Build process is hold, till you press enter. While it's waiting, copy your changed *.dts to the two folders in source. I rember, there must be two folder: /sources/linux-vanilla/master/arch/arm/boot/dts/ and /sources/u-boot/v2016.11/arch/arm/dts/. After pressing enter, the build process automatically detects your changes and creates a patch. So you only have to do this once.

 

You can read about build options and process here: https://docs.armbian.com/Developer-Guide_Build-Options/

 

 

Yours,

Martin

Link to post
Share on other sites

Hi there. I'm trying the same with bananapi_pro right now.

 

So, toolchain isn't working for me since I'm running Gentoo. But anyway.

 

I downloaded the armbian Jessie desktop image and put it on my SD. It boots and shows content on HDMI.

 

Then I've downloaded u-boot and changed sun7i-a20-bananapro.dts .

# make Bananapro_defconfig && make clean all

 

I updated u-boot via:

# dd if=u-boot-sunxi-with-spl.bin of=/dev/sdb bs=1024 seek=8

So that probably seemed to work since u-boots tells me the correct build date on startup.

 

For the kernel, I've downloaded  https://github.com/megous/linuxand copied the config from /boot .

I also added the pwm stuff in the coresponding dts.

 

So, copied modules to /lib , kernel and dts to /boot and also made the links in /boot .

 

The kernel starts fine but still a dark display while not having the HDMI connected. On reset the display seems to flash for a short time but I've no idea if this hasn't be the case before.

 

Do you have anything in /sysfs or dmesg which relates to PWM or backlight?

 

Regards,

Alex

Link to post
Share on other sites

Hi erazor,

 

thats great to read! Just wanna give you an answer, that it propably would be about the pwm isn't working. My display also is flashing for a short moment, but stays black when pwm isn't in the dtb.

 

I think thats also good information for all others who try to use Banana Pi and Pro with LCD.

 

Yours,

Martin

Link to post
Share on other sites
Guest HeinrichG

Hi Heinrich,

 

I think it should work this way. As far as I know, you do not need to change dts.

 

Did you try it?

If you get any problems, let us know.

 

Yours,

Martin

Link to post
Share on other sites
Guest HeinrichG

I remeber I had a similar problem, but do not remeber excatly where... I try to catch my memories ...

Are you sure, that there is no error at boot up?

It's possible that system uses the pins for something. You can test this by trying to export the gpio manually. If you can export and set value of gpios, system doesn't use them. When you get an error, you have to search for the useage.

Link to post
Share on other sites
Guest HeinrichG

You can't declare GPIOs in DT for exporting to sysfs. There are different device types like "gpio-leds", "gpio-backlight", "regulator-fixed", etc. that can be used to drive GPIO pins high or low for the external devices, but you'll have to check which of these drivers provide sysfs interface for controlling the state.

Link to post
Share on other sites
Guest HeinrichG

Hello guys,

 

I have tried the following HowTo to get my 7 inch LCD working, but I can't find the file "sources/u-boot/v2016.09/configs/Bananapi_defconfig".

 

Can anybody help me please?

 

On 22.9.2016 at 9:00 AM, MartinKeppler said:

So, now I can tell you how to enable LCD in u-boot and DT.

 

First getting the source of armbian from https://github.com/igorpecovnik/lib

Open the file sources/u-boot/v2016.09/configs/Bananapi_defconfig and add:


CONFIG_VIDEO_LCD_MODE="x:800,y:480,depth:24,pclk_khz:30000,le:40,ri:40,up:29,lo:13,hs:48,vs:3,sync:3,vmode:0"
CONFIG_VIDEO_LCD_POWER="PH12"
CONFIG_VIDEO_LCD_BL_EN="PH8"
CONFIG_VIDEO_LCD_BL_PWM="PB2"

Now LCD is enabled in u-boot. But it will not switch on backlight, because backlight uses pwm and pwm is disabled per default in DT. So you also have to add:


&pwm {
      pinctrl-names = "default";
      pinctrl-0 = <&pwm0_pins_a>, <&pwm1_pins_a>;
      status = "okay";
};

Ready!

But be aware, LCD only turns on if there is no HDMI Monitor plugged in!!

 

Ok, hopping some one else of you can use this stuff.

 

Thanks.

 

Steffen

Link to post
Share on other sites
Guest
This topic is now closed to further replies.