Merge "platform: msm_shared: Add support for kaslr"
diff --git a/include/stdlib.h b/include/stdlib.h
index 4a90831..de63213 100644
--- a/include/stdlib.h
+++ b/include/stdlib.h
@@ -50,7 +50,7 @@
#define ROUNDDOWN(a, b) ((a) & ~((b)-1))
/* Macro returns UINT_MAX in case of overflow */
-#define ROUND_TO_PAGE(x,y) (ROUNDUP((x),(y)+1) < (x))?UINT_MAX:ROUNDUP((x),(y)+1)
+#define ROUND_TO_PAGE(x,y) ((ROUNDUP((x),((y)+1)) < (x))?UINT_MAX:ROUNDUP((x),((y)+1)))
/* allocate a buffer on the stack aligned and padded to the cpu's cache line size */
#define STACKBUF_DMA_ALIGN(var, size) \
diff --git a/include/target.h b/include/target.h
index 2963b2d..772c424 100644
--- a/include/target.h
+++ b/include/target.h
@@ -1,7 +1,7 @@
/*
* Copyright (c) 2008 Travis Geiselbrecht
*
- * Copyright (c) 2013-2016, The Linux Foundation. All rights reserved.
+ * Copyright (c) 2013-2017, The Linux Foundation. All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files
@@ -98,6 +98,7 @@
int target_cont_splash_screen(void);
bool target_build_variant_user();
void pmic_reset_configure(uint8_t reset_type);
+bool is_display_disabled(void);
struct qmp_reg *target_get_qmp_settings();
int target_get_qmp_regsize();
diff --git a/platform/msm8909/include/platform/iomap.h b/platform/msm8909/include/platform/iomap.h
index 9b59657..b179a40 100644
--- a/platform/msm8909/include/platform/iomap.h
+++ b/platform/msm8909/include/platform/iomap.h
@@ -293,6 +293,9 @@
#define BOOT_CONFIG_OFFSET 0x0000602C
#define BOOT_CONFIG_REG (SEC_CTRL_CORE_BASE + BOOT_CONFIG_OFFSET)
+/* For Reading efuse entries to check whether mdp needs to be disabled or not */
+#define EFUSE_OFFSET 0x00000044
+
#define SECURITY_CONTROL_CORE_FEATURE_CONFIG0 0x0005E004
/* EBI2 */
#define TLMM_EBI2_EMMC_GPIO_CFG (TLMM_BASE_ADDR + 0x00111000)
diff --git a/platform/msm_shared/display_menu.c b/platform/msm_shared/display_menu.c
index 4942567..391e5ff 100644
--- a/platform/msm_shared/display_menu.c
+++ b/platform/msm_shared/display_menu.c
@@ -130,6 +130,8 @@
void wait_for_users_action()
{
+ if (is_display_disabled())
+ return;
/* Waiting for exit menu keys detection if there is no any usr action
* otherwise it will do the action base on the keys detection thread
*/
@@ -141,6 +143,9 @@
struct select_msg_info *select_msg;
select_msg = &msg_info;
+ if (is_display_disabled())
+ return;
+
mutex_acquire(&select_msg->msg_lock);
select_msg->info.is_exit = true;
mutex_release(&select_msg->msg_lock);
@@ -476,6 +481,9 @@
struct select_msg_info *unlock_menu_msg_info;
unlock_menu_msg_info = &msg_info;
+ if (is_display_disabled())
+ return;
+
set_message_factor();
msg_lock_init();
@@ -497,6 +505,9 @@
struct select_msg_info *fastboot_menu_msg_info;
fastboot_menu_msg_info = &msg_info;
+ if (is_display_disabled())
+ return;
+
set_message_factor();
msg_lock_init();
@@ -524,6 +535,9 @@
struct select_msg_info *bootverify_menu_msg_info;
bootverify_menu_msg_info = &msg_info;
+ if (is_display_disabled())
+ return;
+
set_message_factor();
msg_lock_init();
diff --git a/platform/msm_shared/include/mdp3.h b/platform/msm_shared/include/mdp3.h
index 183800a..aede553 100644
--- a/platform/msm_shared/include/mdp3.h
+++ b/platform/msm_shared/include/mdp3.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2011, 2014, The Linux Foundation. All rights reserved.
+/* Copyright (c) 2011, 2014, 2017, 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
@@ -29,11 +29,36 @@
#include <dev/fbcon.h>
#include <msm_panel.h>
+#include <platform/iomap.h>
+#include <smem.h>
//TODO: Make a global PASS / FAIL define
#define PASS 0
#define FAIL 1
+#define EFUSE_ENTRY(addr,off,s, m, sh,id) \
+{\
+ .start_address =addr,\
+ .offset = off, \
+ .size = s,\
+ .mask = m,\
+ .shift = sh,\
+ .board_id = id \
+}
+
+struct mdp_efuse_data {
+ uint32_t start_address;
+ uint32_t offset;
+ uint32_t size;
+ uint32_t mask;
+ uint32_t shift;
+ uint32_t board_id;
+};
+
+static struct mdp_efuse_data efuse_data[]= {
+ EFUSE_ENTRY(SEC_CTRL_CORE_BASE, EFUSE_OFFSET, 4, 0x20000000, 0x1D, APQ8009),
+};
+
int mdp_setup_dma_p_video_mode(unsigned short disp_width,
unsigned short disp_height,
unsigned short img_width,
@@ -58,3 +83,5 @@
int mdp_edp_config(struct msm_panel_info *pinfo, struct fbcon_config *fb);
int mdp_edp_on(struct msm_panel_info *pinfo);
int mdp_edp_off(void);
+bool display_efuse_check(void);
+void efuse_display_enable(char *pbuf, uint16_t buf_size);
diff --git a/target/init.c b/target/init.c
index 7a66623..fed33cc 100644
--- a/target/init.c
+++ b/target/init.c
@@ -397,6 +397,10 @@
return PMIC_IS_UNKNOWN;
}
+__WEAK bool is_display_disabled()
+{
+ return false;
+}
/* Check battery if it's exist */
bool target_battery_is_present()
{
diff --git a/target/msm8909/target_display.c b/target/msm8909/target_display.c
old mode 100755
new mode 100644
index cbb921c..0edfa89
--- a/target/msm8909/target_display.c
+++ b/target/msm8909/target_display.c
@@ -60,6 +60,7 @@
static struct gpio_pin bob_gpio = {
"pm8941_gpios", 12, 2, 1, 0, 1
};
+static bool display_efuse = false;
static void mdss_dsi_uniphy_pll_sw_reset_8909(uint32_t pll_base)
{
@@ -396,6 +397,38 @@
}
}
+bool is_display_disabled(void)
+{
+ return display_efuse;
+}
+
+bool display_efuse_check(void)
+{
+ int i;
+ uint32_t efuse = 0;
+ uint32_t board_id = board_platform_id();
+
+ for (i = 0; i < ARRAY_SIZE(efuse_data);i++)
+ if (board_id == efuse_data[i].board_id) {
+ efuse = readl((efuse_data[i].start_address + efuse_data[i].offset));
+ display_efuse = (efuse & (efuse_data[i].mask)) >> (efuse_data[i].shift);
+ }
+
+ dprintf(INFO,"Efuse register: display disable flag = %d\n",display_efuse);
+ return display_efuse;
+}
+
+void efuse_display_enable(char *pbuf, uint16_t buf_size)
+{
+ char *default_str;
+ int prefix_display_len = strlen(pbuf);
+ if (display_efuse)
+ default_str = ";display_disabled:1";
+ pbuf += prefix_display_len;
+ buf_size -= prefix_display_len;
+ strlcpy(pbuf, default_str, buf_size);
+}
+
bool target_display_panel_node(char *pbuf, uint16_t buf_size)
{
int ret = true;
@@ -403,6 +436,14 @@
if (!target_splash_disable())
ret = gcdb_display_cmdline_arg(pbuf, buf_size);
+ if (display_efuse_check()){
+ if (target_splash_disable()){
+ strlcpy(pbuf, DISPLAY_CMDLINE_PREFIX, buf_size);
+ efuse_display_enable(pbuf, buf_size);
+ } else
+ efuse_display_enable(pbuf, buf_size);
+ }
+
return ret;
}
@@ -412,6 +453,9 @@
uint32_t ret = 0;
struct oem_panel_data oem;
+ if (display_efuse_check())
+ return;
+
set_panel_cmd_string(panel_name);
oem = mdss_dsi_get_oem_data();