Ofcourse, with only a LCD connected to a Linux-system, you can't display anything yet, you need a software driver for that. I decided to go all the way and write a framebuffer device driver for the Linux-kernel: with a framebuffer driver, you can use the LCD for the Linux-console, run X on it, as well as run programs that can write directly to the framebuffer device.

Normally, a framebuffer implies that the processor has direct access to the video memory, so for example the X-server can write directly to that. Here, there's a weird SPI-driver in the way... Luckily, the kernel has a solution for that: you can allocate a random bit of RAM and tell the Linux-kernel that will be the framebuffer memory. You can then request the help of the deferred I/O framework, which will inform you when that bit of memory is written to, and at which memory page. You can then use that to sync the in-RAM framebuffer memory to your real display device.

After some searching, I actually found two drivers that already supported the SSD1289 driver chip in my LCD. Beside not supporting the weird SPI interface I concocted, they both had their quirks: one didn't make use of the deferred I/O features of the Linux-kernel but just continuously blasted the current framebuffer contents to the LCD, pinning the CPU at 100%; the other one didn't implement all the kernel interfaces, making a console on the LCD impossible. I combined the two, plus I added some of my own code to be able to control the LCD through the shift registers.

If you want to hack the LCD to your own embedded device: I've packaged the driver in a patch for the Linux-kernel; apply that to the kernel of your favorite SPI-enabled embedded device and you should get the option in your kernel configuration file to enable the driver.

Only enabling the driver isn't enough, however: you'll also need to let the driver know it has to use a SPI port: You can do that by editting the machine setup source file for your specific board. It's usually as simple as finding the modalias line of the SPI configuration and changing it to 'SSD1289'. For example:

static struct spi_board_info carambola_spi_info[] = {
	{ /* Display, on native SPI-bus (id=0) */
		.modalias	= "spi-ssd1289",
		.irq            = -1,
		.max_speed_hz   = 52428800,
		.bus_num	= 0,
		.chip_select	= 0,

If you want the complete example, check my patch patch for the Carambola-board that does this. I've also implemented a secondary SPI port plus platform description for the touchscreen on my LCD; you can copy that if you want the touchscreen to work.

« Prev 3 Next »

© 2006-2016 Sprite_tm - Contact