iMX233-OLinuXino-MAXI + TFT lcd (LCDIF - DOT-CLK interface)

Started by Dataedge, March 03, 2013, 02:00:49 PM

Previous topic - Next topic

Dataedge

Hi everybody,

several months ago, I saw on olimex blog that someone succeeded to get iMX233-OLinuXino-MAXI working with a TFT LCD rgb interface (called DOT-CLK interface in iMX233 reference manual): http://olimex.wordpress.com/2012/12/17/imx233-olinuxino-with-lcd-4-3-and-touchscreen/. Unfortunately no news / details on this project to this day, so I decided in my spare time to examine the matter.

I wrote this guide to help anyone else who wants to achieve the same goal.

- Part I -

Let's start to describe my system:
If you need some hints about install Archlinux on your SD, you'll probably wanna read those wonderful tutorials:
http://www.jann.cc/2013/02/04/a_new_image_for_the_imx233_olinuxino.html
That one for building the kernel from sources (skip bootlets and go straight to Uboot solution)
http://www.jann.cc/2012/08/23/building_a_kernel_3_x_for_the_olinuxino_from_sources.html
Last one about Uboot on Olinuxino
http://www.jann.cc/2013/02/07/u_boot_for_the_imx233_olinuxino.html
* Huge thanks to Christian Jann and his very good blog ! *

Now you can get (for example) linux-next integration testing tree with git command :
git clone git://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git next-20130301
By the way, linux-next have LRADC and HW watchdog support (via i.MX23 STMP3xxx integrated real-time clock)

I've uploaded all the modified files to get LCD working with olinuxino in :
https://docs.google.com/folder/d/0ByblbZniEE5gcEVpaVgtY2hTOUk/edit?usp=sharing

HardwareConnections document:
As you can see besides lcd-data + control signals (DOTCLK,VSYNC,HSYNC,LCDENA) all managed by iMX23 LCDIF, there are 3V3 and GND power lines, and some miscellaneous outputs from iMX233 (3 of them).

  • One general digital output pin to blink a led on LCD7 cape board
  • One digital output to enable the TPS65105PWP (LCD7 cape TFT power supply)
  • One PWM output to drive LCD backlight via TPS61080DRC
LCD7 cape board have a separate 5V power connector,so the main power supply is not from Olinuxino (only 3V3 as stated above). Since my system has a LM75 temperature sensor and a TSL2561 light sensor (both I2C devices), I had to disable AUART on UEXT and switch I2C SDA/SCL into AUART pins. Original SDA/SCL are needed by LCDIF controller of iMX233. Disabled SPI on UEXT too.

  • AUART -> disabled, SPI (SSP2) -> disabled
  • AUART1_TXD became I2C_SCL and AUART1_RXD became I2C_SDA
  • I2C_SCL used as LCD_EN and I2C_SDA used as LCD_HSYNC
  • SSP2_MISO used as LCD_D08 and UEXT_CS used as LCD_D11
Further details about iMX233 and integrated LCD interface :
http://cache.freescale.com/files/dsp/doc/ref_manual/IMX23RM.pdf?fpsp=1

LCD7 cape schematic :
https://github.com/CircuitCo/BeagleBone-LCD7-RevA3/blob/master/BeagleBone-LCD7-RevA3-schematic.pdf?raw=true

Dataedge

- Part II -

imx23.dtsi (arch/arm/boot/dts/imx23.dtsi):
First device tree file with already included : 0001-MXS-imx23-olinuxino-Add-i2c-support.patch
Note: changed to reflect Nicolas Lefalher I2C driver patch (line 470)
compatible = "fsl,imx23-i2c";
My chunk for LCDIF 16bit pin declaration (from line 283)
lcdif_16bit_pins_a: lcdif-16bit@0 {
reg = <0>;
fsl,pinmux-ids = <
0x1000 /* MX23_PAD_LCD_D00__LCD_D0 */
0x1010 /* MX23_PAD_LCD_D01__LCD_D1 */
0x1020 /* MX23_PAD_LCD_D02__LCD_D2 */
0x1030 /* MX23_PAD_LCD_D03__LCD_D3 */
0x1040 /* MX23_PAD_LCD_D04__LCD_D4 */
0x1050 /* MX23_PAD_LCD_D05__LCD_D5 */
0x1060 /* MX23_PAD_LCD_D06__LCD_D6 */
0x1070 /* MX23_PAD_LCD_D07__LCD_D7 */
0x0001 /* MX23_PAD_GPMI_D00__LCD_D8 */
0x0011 /* MX23_PAD_GPMI_D01__LCD_D9 */
0x0021 /* MX23_PAD_GPMI_D02__LCD_D10 */
0x0031 /* MX23_PAD_GPMI_D03__LCD_D11 */
0x0041 /* MX23_PAD_GPMI_D04__LCD_D12 */
0x0051 /* MX23_PAD_GPMI_D05__LCD_D13 */
0x0061 /* MX23_PAD_GPMI_D06__LCD_D14 */
0x0071 /* MX23_PAD_GPMI_D07__LCD_D15 */
0x1160 /* MX23_PAD_LCD_DOTCK__LCD_DOTCK */
0x1170 /* MX23_PAD_LCD_ENABLE__LCD_ENABLE */
0x1180 /* MX23_PAD_LCD_HSYNC__LCD_HSYNC */
0x1190 /* MX23_PAD_LCD_VSYNC__LCD_VSYNC */
>;
fsl,drive-strength = <0>;
fsl,voltage = <1>;
fsl,pull-up = <0>;
};


imx23-olinuxino.dts (arch/arm/boot/dts/imx23-olinuxino.dts):
Second device tree file with already included : 0001-MXS-imx23-olinuxino-Add-i2c-support.patch
The digital output pin declaration, TPS65105PWP - TFT power supply enable (line 43)
0x0193 /* MX23_PAD_GPMI_RDN__GPIO_0_25 */
The digital output pin declaration to blink a led on LCD7 cape board (from line 60)

led_pin_gpio0_23: led_gpio0_23@0 {
reg = <0>;
fsl,pinmux-ids = <
0x0173 /* MX23_PAD_GPMI_WPN__GPIO_0_23 */
>;
fsl,drive-strength = <0>;
fsl,voltage = <1>;
fsl,pull-up = <0>;
};

LCDIF interface enabled with lcdif_16bit_pins_a declaration and panel enable (TPS65105PWP enable) (from line 71)

lcdif@80030000 {
pinctrl-names = "default";
pinctrl-0 = <&lcdif_16bit_pins_a>;
panel-enable-gpios = <&gpio0 25 0>;
status = "okay";
};

SPI (SSP2) disabled (from line 77 to line 86)
LRADC enabled (from line 91)

lradc@80050000 {
status = "okay";
};

I2C bus with alternative pinout (AUART1_TXD->I2C_SCL,AUART1_RXD->I2C_SDA) and various devices (from line 95)

i2c0: i2c@80058000 {
pinctrl-names = "default";
pinctrl-0 = <&i2c0_pins_a>;
status = "okay";

tsl2561: tsl2561@29 {
compatible = "taos,tsl2561";
reg = <0x29>;
};

lm75: lm75@48 {
compatible = "national,lm75";
reg = <0x48>;
};
};

PWM and output pin (LCD backlight) enabled (from line 111)

pwm: pwm@80064000 {
pinctrl-names = "default";
pinctrl-0 = <&pwm2_pins_a>;
status = "okay";
};

AUART -> disabled (from line 122 to line 128)
Enabled led blinking on LCD7 cape board  (from line 159)

...
pinctrl-0 = <&led_pin_gpio2_1 &led_pin_gpio0_23>;
...
cape {
label = "lcd";
gpios = <&gpio0 23 0>;
linux,default-trigger = "timer";
};
...

Backlight pwm management (from line 174)

backlight {
compatible = "pwm-backlight";
pwms = <&pwm 2 5000000>;
brightness-levels = <0 4 8 16 32 64 128 255>;
default-brightness-level = <6>;
};


Dataedge

- Part III -

dotconfig file to rename in .config:
My kernel configuration file, no module support, monolithic, no wifi, no fancy drivers enabled, use as example and modify for your application.

pwm-mxs.c file (drivers/pwm/pwm-mxs.c):
PWM driver for backlight management, modified only to show "mxs-pwm 80064000.pwm: initialized" in kernel boot log

mxsfb.h and mxsfb.c (include/linux/mxsfb.h and drivers/video/mxsfb.c):
iMX23/28 LCDIF controller driver with framebuffer support, with this patch already included : https://patchwork.kernel.org/patch/1783671/

i2c-mxs.c (/drivers/i2c/busses/i2c-mxs.c)
iMX23/28 I2C driver with a nice patch (already included) from Nicolas Lefalher :
https://www.olimex.com/forum/index.php?topic=283.15
https://www.dropbox.com/s/5t5ewcvtsuh4oba/next20130218_i2c-mxs.c.patch

mach-mxs.c (/arch/arm/mach-mxs/mach-mxs.c):
This patch is already included (same as mxsfb.h and mxsfb.c) : https://patchwork.kernel.org/patch/1783671/
Architecture initialization file, on Olinuxino mainly setup the LCD interface for framebuffer driver
Display Model declaration for ThreeFive TFC-S9700RTWV35TR-01 used in BeagleBone LCD7 cape (from line 31)

static struct fb_videomode imx23olinuxino_video_modes[] = {
{
.name = "TFC-S9700RTWV35TR-01",
.refresh = 60,
.xres = 800,
.yres = 480,
.pixclock = 33333, /* picosecond (30.00 MHz) */
.left_margin = 88,
.right_margin = 40,
.upper_margin = 32,
.lower_margin = 13,
.hsync_len = 48,
.vsync_len = 3,
.sync = FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT |
FB_SYNC_DATA_ENABLE_HIGH_ACT |
FB_SYNC_DOTCLK_FALLING_ACT,
},
};

Olinuxino LCD initialization function (from line 275)

static void __init imx23_olinuxino_init(void)
{
mxsfb_pdata.mode_list = imx23olinuxino_video_modes;
mxsfb_pdata.mode_count = ARRAY_SIZE(imx23olinuxino_video_modes);
mxsfb_pdata.default_bpp = 16;
mxsfb_pdata.ld_intf_width = STMLCDIF_16BIT;
}

Board name detect to call Olinuxino LCD initialization function (line 461/462)
Reference : imx23-olinuxino.dts line 19 -> "olimex,imx23-olinuxino"

else if (of_machine_is_compatible("olimex,imx23-olinuxino"))
imx23_olinuxino_init();


I hope I didn't forget anything :)
Have fun !

Luca Bassanello,
Dataedge

Niii

Nice howto Luca !
Can you post a picture of your LCD ?

It's too bad, you must disable AUART for move I2C mxs  :-\.
Why you're not using gpio i2c for save AUART ?

Dataedge

Update : picture of olinuxino + BBone LCD7 cape


Nicolas, about gpio-i2c you make a good point here, I'll definitely look into it!
Right now, I'm diving into DirectFB library http://directfb.org/ :)

jasonjf

Hi Dataedge,
Thank you very much for your guide. I had some questions though.
First would this work with the iMX233 Olinuxino Micro?

Next, Do you know any low cost 3.5 inch touchscreens that would work? The example you gave used a 7 inch touch screen- i really need a 3.5 screen. Also your example used the Beaglebone LCD 7 cape- would the 3.5 one work with most of the same code? Also im sorry I dont know much about the technical details but is there a way to make it work with JUST an LCD screen? Whats with the board that's attached to the LCD?

I'd very much appreciate any help you could give me.
Thanks!
Jason

Dataedge

Hey jasonjf,

from what I see you can connect without problems a TFT-LCD to iMX233 Olinuxino Micro.
My guide should work with any TFT-LCD 16bit and 18bit RGB interface.
For 18bit version, a small change must be made in imx23.dtsi to add lcd_d16 and lcd_d17 . Then you must change mach-mxs.c Olinuxino LCD initialization like that :

...
mxsfb_pdata.default_bpp = 18;
mxsfb_pdata.ld_intf_width = STMLCDIF_18BIT;
...


I'm not really aware of LCD market, you can check Distrelec / Digikey or Mouser for those devices.
A final note, you can't connect just the LCD screen, because sometimes data and control signals needs a level shifter/converter from 3V3 to 5V, and above all it needs more different voltages ! (more than just 5V or 3.3V).

 

olimex

so imx233 can drive 800x480 pixels as well (yet another datasheet mistake where is written max 640x480 pixels :) )


Dataedge

Update:

  • Re-enabled AUART on UEXT connector
  • Switched from hardware I2C to software I2C-GPIO

    • SSP2_SCK became soft SCL (I2C-GPIO)
    • SSP2_MOSI became soft SDA (I2C-GPIO)
Check "AUART_Gpio-I2C_Version" directory, always in :
https://docs.google.com/folder/d/0ByblbZniEE5gcEVpaVgtY2hTOUk/edit?usp=sharing

imx23-olinuxino.dts (arch/arm/boot/dts/imx23-olinuxino.dts):
New software I2C-GPIO pins initialization (lines 44/45):

...
0x0183 /* MX23_PAD_GPMI_WRN__GPIO_0_24 */
0x0143 /* MX23_PAD_GPMI_RDY1__GPIO_0_20 */
...

Hardware I2C disabled (from line 96 to line 112)
Instanciate a I2C-GPIO driver (from line 158):

i2c@0 {
compatible = "i2c-gpio";
gpios = <
&gpio0 20 0 /* sda */
&gpio0 24 0 /* scl */
>;
i2c-gpio,sda-open-drain;
i2c-gpio,scl-open-drain;
i2c-gpio,delay-us = <2>; /* ~100 kHz */
#address-cells = <1>;
#size-cells = <0>;

tsl2561: tsl2561@29 {
compatible = "taos,tsl2561";
reg = <0x29>;
};

lm75: lm75@48 {
compatible = "national,lm75";
reg = <0x48>;
};
};


dotconfig file to rename in .config:
disabled MXS hardware I2C driver and enabled Device Drivers->I2C support->I2C Hardware Bus support->GPIO-based bitbanging I2C

Luca

tavish

Hi,
I was using the earlier mxsfb and lcdif interfaces with an LCD(ILI9325 based) which was
running in 8 bit system mode, with kernel 2.6.35. Do you know how I can get it to work with
3.x, since there is no lcdif.h/c and device.c(dtb replaced this?)?

Dataedge

Hey,

as far as I know, the mxsfb in 3.X only support Dotclock interface, here a little chunk of driver :

/**
* @file
* @brief LCDIF driver for i.MX23 and i.MX28
*
* The LCDIF support four modes of operation
* - MPU interface (to drive smart displays) -> not supported yet
* - VSYNC interface (like MPU interface plus Vsync) -> not supported yet
* - Dotclock interface (to drive LC displays with RGB data and sync signals)
* - DVI (to drive ITU-R BT656)  -> not supported yet
*
* This driver depends on a correct setup of the pins used for this purpose
* (platform specific).
*
* For the developer: Don't forget to set the data bus width to the display
* in the imx_fb_videomode structure. You will else end up with ugly colours.
* If you fight against jitter you can vary the clock delay. This is a feature
* of the i.MX28 and you can vary it between 2 ns ... 8 ns in 2 ns steps. Give
* the required value in the imx_fb_videomode structure.
*/


And you are right, device tree replaced lcdif.c/h...

P.S. A small side note : from linux next-20130322 onward, all display configuration was moved from mach-mxs.c to device tree, so my tutorial works with a linux next-xxxxxxxx before 20130322. I hope to update this howto soon..

Reference : https://patchwork.kernel.org/patch/2267811/

letaft

Hi,

I have an LQ035NC211 TFT LCD, the datasheet www.dzsc.com/uploadfile/company/686441/2011219155057970.pdf describes an 8 bit interface using HSYNC, VSYNC, DOTCLK and DEN and also a Serial RGB interface.

Can I interface it with an olinuxino-maxi? If so, can you help me with the right connections and what mode should I use or an starting point?

Thank you