Dingoo A320 ⇒ OpenDingux

移植ILI9340驅動程式


雖然Dingux和OpenDingux系統很相似,不過驅動程式部份還是有一些微小差異,因此,修改的部份會跟Dingux不一樣,如下說明:

$ vim drivers/video/jz4740_slcd_panels.c
--- jz4740_slcd_panels_old.c
+++ jz4740_slcd_panels_new.c
@@ -24,7 +24,7 @@
 #include "jz4740_slcd.h"
 
 static char *default_slcd_panel;
-#ifdef CONFIG_JZ_SLCD_ILI9338
+#ifdef config_jz_slcd_ili9338
 static unsigned int default_slcd_rgb[3] = { 100, 100, 100, };
 #endif
 
@@ -517,6 +517,161 @@
 
 #endif
 
+#ifdef CONFIG_JZ_SLCD_ILI9340
+
+#define ILI9340_GPIO_CS_N   JZ_GPIO_PORTB(17)  /* Chip select */
+#define ILI9340_GPIO_RESET_N   JZ_GPIO_PORTB(18)  /* LCD reset */
+
+static void ili9340_enable(struct jzfb *jzfb)
+{
+  /* RESET pulse */
+  gpio_set_value(ILI9340_GPIO_RESET_N, 0);
+  mdelay(10);
+  gpio_set_value(ILI9340_GPIO_RESET_N, 1);
+  mdelay(50);
+
+  /* Enable chip select */
+  gpio_set_value(ILI9340_GPIO_CS_N, 0);
+
+  /* Black magic */
+  send_panel_command(jzfb, 0x11);
+  mdelay(100);
+
+  send_panel_command(jzfb, 0xCB);
+  send_panel_data(jzfb, 0x01);
+
+  send_panel_command(jzfb, 0xC0);
+  send_panel_data(jzfb, 0x27);
+  send_panel_data(jzfb, 0x09);
+  send_panel_command(jzfb, 0xC1);
+  send_panel_data(jzfb, 0x10);
+  send_panel_command(jzfb, 0xC5);
+  send_panel_data(jzfb, 0x31);
+  send_panel_data(jzfb, 0x3c);
+  
+  send_panel_command(jzfb, 0x36);
+  send_panel_data(jzfb, 0x0c);
+
+  send_panel_command(jzfb, 0x3a);
+  send_panel_data(jzfb, 0x05);
+
+  send_panel_command(jzfb, 0xb1);
+  send_panel_data(jzfb, 0x00);
+  send_panel_data(jzfb, 0x18);
+
+  send_panel_command(jzfb, 0xb6);
+  send_panel_data(jzfb, 0x0a);
+  send_panel_data(jzfb, 0x02);
+
+  send_panel_command(jzfb, 0xc7);
+  send_panel_data(jzfb, 0xcf);
+
+  send_panel_command(jzfb, 0xe8);
+  send_panel_data(jzfb, 0x89);
+  send_panel_data(jzfb, 0x11);
+  send_panel_data(jzfb, 0x78);
+
+  send_panel_command(jzfb, 0xf2);
+  send_panel_data(jzfb, 0x00);
+
+  send_panel_command(jzfb,0xE0);
+  send_panel_data(jzfb, 0x0f);
+  send_panel_data(jzfb, 0x3f);
+  send_panel_data(jzfb, 0x3f);
+  send_panel_data(jzfb, 0x02);
+  send_panel_data(jzfb, 0x04);
+  send_panel_data(jzfb, 0x05);
+  send_panel_data(jzfb, 0x49);
+  send_panel_data(jzfb, 0x75);
+  send_panel_data(jzfb, 0x20);
+  send_panel_data(jzfb, 0x08);
+  send_panel_data(jzfb, 0x14);
+  send_panel_data(jzfb, 0x0c);
+  send_panel_data(jzfb, 0x15);
+  send_panel_data(jzfb, 0x0E);
+  send_panel_data(jzfb, 0x00);
+
+  send_panel_command(jzfb, 0XE1);
+  send_panel_data(jzfb, 0x00);
+  send_panel_data(jzfb, 0x00);
+  send_panel_data(jzfb, 0x00);
+  send_panel_data(jzfb, 0x0c);
+  send_panel_data(jzfb, 0x1a);
+  send_panel_data(jzfb, 0x0d);
+  send_panel_data(jzfb, 0x3a);
+  send_panel_data(jzfb, 0x8a);
+  send_panel_data(jzfb, 0x40);
+  send_panel_data(jzfb, 0x08);
+  send_panel_data(jzfb, 0x11);
+  send_panel_data(jzfb, 0x0f);
+  send_panel_data(jzfb, 0x3f);
+  send_panel_data(jzfb, 0x3f);
+  send_panel_data(jzfb, 0x0F);
+
+  send_panel_command(jzfb, 0x2a);
+  send_panel_data(jzfb, 0x00);
+  send_panel_data(jzfb, 0x00);
+  send_panel_data(jzfb, 0x01);
+  send_panel_data(jzfb, 0x3f);
+
+  send_panel_command(jzfb, 0x2b);
+  send_panel_data(jzfb, 0x00);
+  send_panel_data(jzfb, 0x00);
+  send_panel_data(jzfb, 0x00);
+  send_panel_data(jzfb, 0xef);
+
+  send_panel_command(jzfb, 0x36);
+  send_panel_data(jzfb, 0xe8);
+
+  send_panel_command(jzfb, 0x3A);
+  send_panel_data(jzfb, 0x05);
+
+  send_panel_command(jzfb, 0x29);
+
+  send_panel_command(jzfb, 0x2c);
+}
+
+/* TODO(IGP): make sure LCD power consumption is low in these conditions */
+static void ili9340_disable(struct jzfb *jzfb)
+{
+  /* Keep chip select disabled */
+  gpio_set_value(ILI9340_GPIO_CS_N, 1);
+  /* Keep RESET active */
+  gpio_set_value(ILI9340_GPIO_RESET_N, 0);
+}
+
+static int ili9340_init(struct jzfb *jzfb)
+{
+  struct device *dev = &jzfb->pdev->dev;
+  int ret;
+
+  ret = gpio_request(ILI9340_GPIO_CS_N, dev_name(dev));
+  if (ret)
+    goto err_cs;
+  gpio_direction_output(ILI9340_GPIO_CS_N, 1);
+
+  ret = gpio_request(ILI9340_GPIO_RESET_N, dev_name(dev));
+  if (ret)
+    goto err_reset;
+  gpio_direction_output(ILI9340_GPIO_RESET_N, 0);
+
+err_reset:
+  gpio_free(ILI9340_GPIO_CS_N);
+err_cs:
+  dev_err(dev, "Could not reserve GPIO pins for ILI9340 panel driver\n");
+  return ret;
+}
+
+static void ili9340_exit(struct jzfb *jzfb)
+{
+  struct device *dev = &jzfb->pdev->dev;
+
+  gpio_free(ILI9340_GPIO_CS_N);
+  gpio_free(ILI9340_GPIO_RESET_N);
+}
+
+#endif
+
 static const struct jz_slcd_panel jz_slcd_panels[] = {
 #ifdef CONFIG_JZ_SLCD_ILI9325
   {
@@ -537,6 +692,13 @@
     ili9338_init, ili9338_exit,
     ili9338_enable, ili9338_disable,
     "ili9338",
+  },
+#endif
+#ifdef CONFIG_JZ_SLCD_ILI9340
+  {
+    ili9340_init, ili9340_exit,
+    ili9340_enable, ili9340_disable,
+    "ili9340",
   },
 #endif
 };

$ vim drivers/video/Kconfig
--- Kconfig_oled
+++ Kconfig_new
@@ -2411,6 +2411,10 @@
   bool "ILI9338 Smart LCD panel"
   depends on FB_JZ4740_SLCD
 
+config JZ_SLCD_ILI9340
+  bool "ILI9340 Smart LCD panel"
+  depends on FB_JZ4740_SLCD
+
 config FB_MXS
   tristate "MXS LCD framebuffer support"
   depends on FB && ARCH_MXS

$ make menuconfig

Device Drivers ⇒ Graphics support ⇒ Support for frame buffer devices

$ make


返回上一頁