target: mdm9635: Add dummy display support

Add display support for mdm9635 target using dummy panel.
This is disabled by default, user needs turn on the settings.

Change-Id: Id5dca10784b9c22b31e8479b37f8c2eccc24adf4
diff --git a/platform/msm_shared/include/qpic_panel.h b/platform/msm_shared/include/qpic_panel.h
index af6230e..bbee022 100644
--- a/platform/msm_shared/include/qpic_panel.h
+++ b/platform/msm_shared/include/qpic_panel.h
@@ -109,10 +109,6 @@
 #define	OP_WRITE_MEMORY_CONTINUE  0x3C /* size not fixed */
 #define	OP_WRITE_MEMORY_START   0x2C /* size not fixed */
 
-/* ILI9341 commands */
-#define OP_ILI9341_INTERFACE_CONTROL	0xf6
-#define OP_ILI9341_TEARING_EFFECT_LINE_ON	0x35
-
 struct qpic_panel_io_desc {
 	int rst_gpio;
 	int cs_gpio;
@@ -126,7 +122,7 @@
 
 int mdss_qpic_panel_io_init(struct qpic_panel_io_desc *qpic_panel_io);
 uint32_t qpic_panel_get_cmd(uint32_t command, uint32_t size);
-int ili9341_on(struct qpic_panel_io_desc *qpic_panel_io);
-void ili9341_off(struct qpic_panel_io_desc *qpic_panel_io);
+int dummy_panel_on(struct qpic_panel_io_desc *qpic_panel_io);
+void dummy_panel_off(struct qpic_panel_io_desc *qpic_panel_io);
 
 #endif /* MDSS_QPIC_PANEL_H */
diff --git a/platform/msm_shared/qpic_panel.c b/platform/msm_shared/qpic_panel.c
index 71993a7..d92d7ae 100644
--- a/platform/msm_shared/qpic_panel.c
+++ b/platform/msm_shared/qpic_panel.c
@@ -127,6 +127,9 @@
 
 int mdss_qpic_panel_init(struct qpic_panel_io_desc *panel_io)
 {
+	qpic_panel_on = dummy_panel_on;
+	qpic_panel_off = dummy_panel_off;
+
 	return 0;
 }
 
diff --git a/target/mdm9635/init.c b/target/mdm9635/init.c
index 647cf95..7557d75 100644
--- a/target/mdm9635/init.c
+++ b/target/mdm9635/init.c
@@ -148,10 +148,25 @@
 	flash_set_ptable(&flash_ptable);
 	rpm_smd_init();
 }
+
+int target_cont_splash_screen()
+{
+	/*
+	 * FOR OEMs - Set cont_splash_screen to keep the splash enable after LK.
+	 * By default: the cont-splash-screen is ON
+	 */
+	return false;
+}
+
 void target_uninit()
 {
-	rpm_smd_uninit();
+#if DISPLAY_SPLASH_SCREEN
+	/* target_display_shutdown will uninitialize it in case of cont-splash */
+	if(target_cont_splash_screen())
+#endif
+		rpm_smd_uninit();
 }
+
 /* Do target specific usb initialization */
 void target_usb_init(void)
 {
diff --git a/target/mdm9635/qpic_panel_drv.c b/target/mdm9635/qpic_panel_drv.c
new file mode 100644
index 0000000..6d364ea
--- /dev/null
+++ b/target/mdm9635/qpic_panel_drv.c
@@ -0,0 +1,151 @@
+/* Copyright (c) 2014, The Linux Foundation. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *  * Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ *  * Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in
+ *    the documentation and/or other materials provided with the
+ *    distribution.
+ *  * Neither the name of The Linux Foundation nor the names of its
+ *    contributors may be used to endorse or promote products derived
+ *    from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <debug.h>
+#include <err.h>
+#include <endian.h>
+#include <platform/gpio.h>
+#include <platform/clock.h>
+#include <regulator.h>
+#include <rpm-smd.h>
+#include <platform/timer.h>
+
+#include "qpic.h"
+#include "qpic_panel.h"
+
+#define GPIOMUX_FUNC_1 1
+#define GPIOMUX_FUNC_GPIO 0
+
+#define RST_GPIO_ID 23
+#define CS_GPIO_ID 21
+#define AD8_GPIO_ID 20
+#define TE_GPIO_ID 22
+#define BL_GPIO_ID 84
+
+#define MEM_ACCESS_MODE 0x48
+#define MEM_ACCESS_FORMAT 0x66
+
+static uint32_t ldo6[][11] = {
+	{
+		LDOA_RES_TYPE, 6,
+		KEY_SOFTWARE_ENABLE, 4, GENERIC_DISABLE,
+		KEY_LDO_SOFTWARE_MODE, 4, SW_MODE_LDO_IPEAK,
+		KEY_MICRO_VOLT, 4, 0,
+	},
+	{
+		LDOA_RES_TYPE, 6,
+		KEY_SOFTWARE_ENABLE, 4, GENERIC_ENABLE,
+		KEY_LDO_SOFTWARE_MODE, 4, SW_MODE_LDO_IPEAK,
+		KEY_MICRO_VOLT, 4, 1800000,
+	},
+};
+
+static uint32_t ldo12[][11] = {
+	{
+		LDOA_RES_TYPE, 12,
+		KEY_SOFTWARE_ENABLE, 4, GENERIC_DISABLE,
+		KEY_LDO_SOFTWARE_MODE, 4, SW_MODE_LDO_IPEAK,
+		KEY_MICRO_VOLT, 4, 0,
+	},
+	{
+		LDOA_RES_TYPE, 12,
+		KEY_SOFTWARE_ENABLE, 4, GENERIC_ENABLE,
+		KEY_LDO_SOFTWARE_MODE, 4, SW_MODE_LDO_IPEAK,
+		KEY_MICRO_VOLT, 4, 2700000,
+	},
+};
+
+static void panel_io_off(struct qpic_panel_io_desc *qpic_panel_io)
+{
+	/* Turning off all gpios */
+	gpio_tlmm_config(RST_GPIO_ID, GPIOMUX_FUNC_1, GPIO_INPUT, GPIO_NO_PULL,
+				GPIO_10MA, GPIO_DISABLE);
+	gpio_tlmm_config(CS_GPIO_ID, GPIOMUX_FUNC_1, GPIO_INPUT, GPIO_NO_PULL,
+				GPIO_10MA, GPIO_DISABLE);
+	gpio_tlmm_config(AD8_GPIO_ID, GPIOMUX_FUNC_1, GPIO_INPUT, GPIO_NO_PULL,
+				GPIO_10MA, GPIO_DISABLE);
+	gpio_tlmm_config(TE_GPIO_ID, GPIOMUX_FUNC_1, GPIO_INPUT, GPIO_NO_PULL,
+				GPIO_10MA, GPIO_DISABLE);
+	gpio_tlmm_config(BL_GPIO_ID, GPIOMUX_FUNC_GPIO, GPIO_INPUT, GPIO_NO_PULL,
+				GPIO_10MA, GPIO_ENABLE);
+	gpio_set(BL_GPIO_ID, 0x0);
+
+	/* Disabling vdd & avdd voltage */
+	rpm_send_data(&ldo6[GENERIC_DISABLE][0], 36, RPM_REQUEST_TYPE);
+	rpm_send_data(&ldo12[GENERIC_DISABLE][0], 36, RPM_REQUEST_TYPE);
+
+	/* uninitializing smd */
+	rpm_smd_uninit();
+
+	return;
+}
+
+void dummy_panel_off(struct qpic_panel_io_desc *qpic_panel_io)
+{
+	panel_io_off(qpic_panel_io);
+}
+
+static int panel_io_on(struct qpic_panel_io_desc *qpic_panel_io)
+{
+	int rc = 0;
+
+	/* Setting vdd & avdd voltage */
+	rpm_send_data(&ldo6[GENERIC_ENABLE][0], 36, RPM_REQUEST_TYPE);
+	rpm_send_data(&ldo12[GENERIC_ENABLE][0], 36, RPM_REQUEST_TYPE);
+
+	/* Turning on all gpios */
+	gpio_tlmm_config(RST_GPIO_ID, GPIOMUX_FUNC_1, GPIO_INPUT,GPIO_NO_PULL,
+			GPIO_10MA, GPIO_ENABLE);
+	gpio_tlmm_config(CS_GPIO_ID, GPIOMUX_FUNC_1, GPIO_INPUT,GPIO_NO_PULL,
+			GPIO_10MA, GPIO_ENABLE);
+	gpio_tlmm_config(AD8_GPIO_ID, GPIOMUX_FUNC_1, GPIO_INPUT,GPIO_NO_PULL,
+			GPIO_10MA, GPIO_ENABLE);
+	gpio_tlmm_config(TE_GPIO_ID, GPIOMUX_FUNC_1, GPIO_INPUT,GPIO_NO_PULL,
+			GPIO_10MA, GPIO_ENABLE);
+	gpio_tlmm_config(BL_GPIO_ID, GPIOMUX_FUNC_GPIO, GPIO_INPUT, GPIO_NO_PULL,
+			GPIO_10MA, GPIO_DISABLE);
+	gpio_set(BL_GPIO_ID, 0x2);
+
+	mdelay(20);
+	return rc;
+}
+
+int dummy_panel_on(struct qpic_panel_io_desc *qpic_panel_io)
+{
+	uint8_t param[4];
+	int ret;
+
+	ret = panel_io_on(qpic_panel_io);
+	if (ret)
+		return ret;
+	/* add panel init code here */
+	qpic_send_pkt(OP_SOFT_RESET, NULL, 0);
+	param[0] = qpic_read_data(OP_GET_PIXEL_FORMAT, 1);
+	return 0;
+}
diff --git a/target/mdm9635/rules.mk b/target/mdm9635/rules.mk
index 62fb3e2..0c84c38 100644
--- a/target/mdm9635/rules.mk
+++ b/target/mdm9635/rules.mk
@@ -12,14 +12,17 @@
 SCRATCH_REGION2                     := 0x01300000
 SCRATCH_REGION2_SIZE                := 0x06B00000 # 107MB
 
+DEFINES += DISPLAY_SPLASH_SCREEN=0
 DEFINES += NO_KEYPAD_DRIVER=1
 DEFINES += PERIPH_BLK_BLSP=1
 
+DEVS += fbcon
 MODULES += \
 	dev/keys \
-	lib/ptable \
 	dev/pmic/pm8x41 \
-	lib/libfdt
+	lib/ptable \
+	lib/libfdt \
+	dev/fbcon
 
 DEFINES += \
 	MEMBASE=$(MEMBASE) \
@@ -33,4 +36,6 @@
 OBJS += \
 	$(LOCAL_DIR)/init.o \
 	$(LOCAL_DIR)/meminfo.o \
+	$(LOCAL_DIR)/target_display.o \
+	$(LOCAL_DIR)/qpic_panel_drv.o \
 	$(LOCAL_DIR)/keypad.o
diff --git a/target/mdm9635/target_display.c b/target/mdm9635/target_display.c
new file mode 100644
index 0000000..de54ea3
--- /dev/null
+++ b/target/mdm9635/target_display.c
@@ -0,0 +1,72 @@
+/* Copyright (c) 2014, The Linux Foundation. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *  * Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ *  * Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in
+ *    the documentation and/or other materials provided with the
+ *    distribution.
+ *  * Neither the name of The Linux Foundation nor the names of its
+ *    contributors may be used to endorse or promote products derived
+ *    from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <debug.h>
+#include <err.h>
+#include <msm_panel.h>
+#include "splash.h"
+
+/* PANEL INFO */
+#define QVGA_PANEL_XRES 240
+#define QVGA_PANEL_YRES 320
+#define BPP_16 16
+
+/* FB Base Address */
+#define QPIC_FB_ADDR  0x06D00000
+
+static struct msm_fb_panel_data panel;
+
+void target_display_init(const char *panel_name)
+{
+	uint32_t ret = 0;
+	dprintf(SPEW, "%s: Panel name = %s\n", __func__, panel_name);
+
+	/* Setting panel info */
+	panel.panel_info.xres = QVGA_PANEL_XRES;
+	panel.panel_info.yres = QVGA_PANEL_YRES;
+	panel.panel_info.bpp = BPP_16;
+	panel.panel_info.type = QPIC_PANEL;
+
+	/* Setting FB info */
+	panel.fb.width =  panel.panel_info.xres;
+	panel.fb.height =  panel.panel_info.yres;
+	panel.fb.stride =  panel.panel_info.xres;
+	panel.fb.bpp =  panel.panel_info.bpp;
+	panel.fb.format = FB_FORMAT_RGB565;
+	panel.fb.base = QPIC_FB_ADDR;
+
+	ret = msm_display_init(&panel);
+	if (ret)
+		dprintf(CRITICAL, "%s: ERROR: Display init failed\n", __func__);
+}
+
+void target_display_shutdown(void)
+{
+	msm_display_off();
+}