2 * Hitachi tx18d42vm LVDS LCD panel driver
4 * (C) Copyright 2015 Hans de Goede <hdegoede@redhat.com>
6 * SPDX-License-Identifier: GPL-2.0+
15 * Very simple write only SPI support, this does not use the generic SPI infra
16 * because that assumes R/W SPI, requiring a MISO pin. Also the necessary glue
17 * code alone would be larger then this minimal version.
19 static void lcd_panel_spi_write(int cs, int clk, int mosi,
20 unsigned int data, int bits)
24 gpio_direction_output(cs, 0);
25 for (i = 0; i < bits; i++) {
26 gpio_direction_output(clk, 0);
27 offset = (bits - 1) - i;
28 gpio_direction_output(mosi, (data >> offset) & 1);
30 gpio_direction_output(clk, 1);
33 gpio_direction_output(cs, 1);
37 int hitachi_tx18d42vm_init(void)
39 const u16 init_data[] = {
42 0x0840, /* enable normally black */
43 0x0430, /* enable FRC/dither */
44 0x385f, /* enter test mode(1) */
45 0x3ca4, /* enter test mode(2) */
46 0x3409, /* enable SDRRS, enlarge OE width */
47 0x4041, /* adopt 2 line / 1 dot */
49 int i, cs, clk, mosi, ret = 0;
51 cs = name_to_gpio(CONFIG_VIDEO_LCD_SPI_CS);
52 clk = name_to_gpio(CONFIG_VIDEO_LCD_SPI_SCLK);
53 mosi = name_to_gpio(CONFIG_VIDEO_LCD_SPI_MOSI);
55 if (cs == -1 || clk == -1 || mosi == 1) {
56 printf("Error tx18d42vm spi gpio config is invalid\n");
60 if (gpio_request(cs, "tx18d42vm-spi-cs") != 0 ||
61 gpio_request(clk, "tx18d42vm-spi-clk") != 0 ||
62 gpio_request(mosi, "tx18d42vm-spi-mosi") != 0) {
63 printf("Error cannot request tx18d42vm spi gpios\n");
68 for (i = 0; i < ARRAY_SIZE(init_data); i++)
69 lcd_panel_spi_write(cs, clk, mosi, init_data[i], 16);
71 mdelay(50); /* All the tx18d42vm drivers have a delay here ? */
73 lcd_panel_spi_write(cs, clk, mosi, 0x00ad, 16); /* display on */