Merge "lk/openssl: Enable x_sig compilation."
diff --git a/app/aboot/rules.mk b/app/aboot/rules.mk
index a26937b..5342d7a 100644
--- a/app/aboot/rules.mk
+++ b/app/aboot/rules.mk
@@ -2,6 +2,8 @@
INCLUDES += -I$(LK_TOP_DIR)/platform/msm_shared/include
+DEFINES += ASSERT_ON_TAMPER=1
+
OBJS += \
$(LOCAL_DIR)/aboot.o \
$(LOCAL_DIR)/fastboot.o \
diff --git a/dev/gcdb/display/gcdb_display.c b/dev/gcdb/display/gcdb_display.c
index f41277f..d1695f2 100755
--- a/dev/gcdb/display/gcdb_display.c
+++ b/dev/gcdb/display/gcdb_display.c
@@ -90,12 +90,13 @@
return ret;
}
-static int mdss_dsi_panel_power(uint8_t enable)
+static int mdss_dsi_panel_power(uint8_t enable,
+ struct msm_panel_info *pinfo)
{
int ret = NO_ERROR;
if (enable) {
- ret = target_ldo_ctrl(enable);
+ ret = target_ldo_ctrl(enable, pinfo);
if (ret) {
dprintf(CRITICAL, "LDO control enable failed\n");
return ret;
@@ -118,7 +119,7 @@
return ret;
}
- ret = target_ldo_ctrl(enable);
+ ret = target_ldo_ctrl(enable, pinfo);
if (ret) {
dprintf(CRITICAL, "ldo control disable failed\n");
return ret;
@@ -297,12 +298,13 @@
return target_edp_panel_disable();
}
-static int mdss_edp_panel_power(uint8_t enable)
+static int mdss_edp_panel_power(uint8_t enable,
+ struct msm_panel_info *pinfo)
{
int ret = NO_ERROR;
if (enable) {
- ret = target_ldo_ctrl(enable);
+ ret = target_ldo_ctrl(enable, pinfo);
if (ret) {
dprintf(CRITICAL, "LDO control enable failed\n");
return ret;
@@ -322,7 +324,7 @@
return ret;
}
- ret = target_ldo_ctrl(enable);
+ ret = target_ldo_ctrl(enable, pinfo);
if (ret) {
dprintf(CRITICAL, "%s: ldo control disable failed\n", __func__);
return ret;
diff --git a/dev/gcdb/display/gcdb_display.h b/dev/gcdb/display/gcdb_display.h
index 23c2811..3b112e3 100755
--- a/dev/gcdb/display/gcdb_display.h
+++ b/dev/gcdb/display/gcdb_display.h
@@ -54,7 +54,7 @@
int target_panel_clock(uint8_t enable, struct msm_panel_info *pinfo);
int target_panel_reset(uint8_t enable, struct panel_reset_sequence *resetseq,
struct msm_panel_info *pinfo);
-int target_ldo_ctrl(uint8_t enable);
+int target_ldo_ctrl(uint8_t enable, struct msm_panel_info *pinfo);
int gcdb_display_init(const char *panel_name, uint32_t rev, void *base);
bool gcdb_display_cmdline_arg(char *panel_name, char *pbuf, uint16_t buf_size);
diff --git a/dev/pmic/pm8x41/include/pm8x41.h b/dev/pmic/pm8x41/include/pm8x41.h
index 472e69f..8681feb 100644
--- a/dev/pmic/pm8x41/include/pm8x41.h
+++ b/dev/pmic/pm8x41/include/pm8x41.h
@@ -171,6 +171,12 @@
MPP_ENABLE,
};
+enum mvs_en_ctl
+{
+ MVS_DISABLE,
+ MVS_ENABLE,
+};
+
enum mpp_mode
{
MPP_DIGITAL_INPUT,
@@ -190,9 +196,15 @@
enum mpp_mode_en_source_select mode;
};
+struct pm8x41_mvs
+{
+ uint32_t base;
+};
+
#define PM8x41_MMP2_BASE 0xA100
#define PM8x41_MMP3_BASE 0xA200
#define PM8x41_MMP4_BASE 0xA300
+#define PM8x41_MVS1_BASE 0x18400
void pm8x41_lpg_write(uint8_t chan, uint8_t off, uint8_t val);
int pm8x41_gpio_get(uint8_t gpio, uint8_t *status);
@@ -212,6 +224,7 @@
uint32_t pm8x41_get_pwrkey_is_pressed();
void pm8x41_config_output_mpp(struct pm8x41_mpp *mpp);
void pm8x41_enable_mpp(struct pm8x41_mpp *mpp, enum mpp_en_ctl enable);
+void pm8x41_enable_mvs(struct pm8x41_mvs *mvs, enum mvs_en_ctl enable);
uint8_t pm8x41_get_is_cold_boot();
void pm8x41_diff_clock_ctrl(uint8_t enable);
void pm8x41_clear_pmic_watchdog(void);
diff --git a/dev/pmic/pm8x41/include/pm8x41_hw.h b/dev/pmic/pm8x41/include/pm8x41_hw.h
index 9d05219..db4473c 100644
--- a/dev/pmic/pm8x41/include/pm8x41_hw.h
+++ b/dev/pmic/pm8x41/include/pm8x41_hw.h
@@ -99,6 +99,10 @@
#define MPP_MODE_CTL_MODE_SHIFT 4
#define MPP_EN_CTL_ENABLE_SHIFT 7
+/* MVS registers */
+#define MVS_EN_CTL 0x46
+#define MVS_EN_CTL_ENABLE_SHIFT 7
+
void pm8x41_reg_write(uint32_t addr, uint8_t val);
uint8_t pm8x41_reg_read(uint32_t addr);
diff --git a/dev/pmic/pm8x41/pm8x41.c b/dev/pmic/pm8x41/pm8x41.c
index 3b9783d..2471d0a 100644
--- a/dev/pmic/pm8x41/pm8x41.c
+++ b/dev/pmic/pm8x41/pm8x41.c
@@ -397,6 +397,13 @@
return REG_READ(PON_POFF_REASON2);
}
+void pm8x41_enable_mvs(struct pm8x41_mvs *mvs, enum mvs_en_ctl enable)
+{
+ ASSERT(mvs);
+
+ REG_WRITE(mvs->base + MVS_EN_CTL, enable << MVS_EN_CTL_ENABLE_SHIFT);
+}
+
void pm8x41_enable_mpp(struct pm8x41_mpp *mpp, enum mpp_en_ctl enable)
{
ASSERT(mpp);
diff --git a/lib/heap/heap.c b/lib/heap/heap.c
index 3393081..a4835f9 100644
--- a/lib/heap/heap.c
+++ b/lib/heap/heap.c
@@ -1,7 +1,6 @@
/*
* Copyright (c) 2008-2009 Travis Geiselbrecht
* Copyright (c) 2009 Corey Tabaka
- * Copyright (c) 2009,2014 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
diff --git a/lib/libfdt/fdt.c b/lib/libfdt/fdt.c
index e56833a..3267a1c 100644
--- a/lib/libfdt/fdt.c
+++ b/lib/libfdt/fdt.c
@@ -71,6 +71,18 @@
return -FDT_ERR_BADMAGIC;
}
+ if (fdt_off_dt_struct(fdt) > (UINT_MAX - fdt_size_dt_struct(fdt)))
+ return FDT_ERR_BADOFFSET;
+
+ if (fdt_off_dt_strings(fdt) > (UINT_MAX - fdt_size_dt_strings(fdt)))
+ return FDT_ERR_BADOFFSET;
+
+ if ((fdt_off_dt_struct(fdt) + fdt_size_dt_struct(fdt)) > fdt_totalsize(fdt))
+ return FDT_ERR_BADOFFSET;
+
+ if ((fdt_off_dt_strings(fdt) + fdt_size_dt_strings(fdt)) > fdt_totalsize(fdt))
+ return FDT_ERR_BADOFFSET;
+
return 0;
}
diff --git a/lib/libfdt/fdt_rw.c b/lib/libfdt/fdt_rw.c
index a3f8fad..269073c 100644
--- a/lib/libfdt/fdt_rw.c
+++ b/lib/libfdt/fdt_rw.c
@@ -432,7 +432,7 @@
static void _fdt_packblocks(const char *old, char *new,
int mem_rsv_size, int struct_size)
{
- int mem_rsv_off, struct_off, strings_off;
+ uint32_t mem_rsv_off, struct_off, strings_off;
mem_rsv_off = FDT_ALIGN(sizeof(struct fdt_header), 8);
struct_off = mem_rsv_off + mem_rsv_size;
@@ -453,20 +453,31 @@
int fdt_open_into(const void *fdt, void *buf, int bufsize)
{
- int err;
- int mem_rsv_size, struct_size;
- int newsize;
+ int err = -1;
+ uint32_t mem_rsv_size;
+ int struct_size;
+ uint32_t newsize;
const char *fdtstart = fdt;
- const char *fdtend = fdtstart + fdt_totalsize(fdt);
+ const char *fdtend = NULL;
char *tmp;
+ if (fdtstart + fdt_totalsize(fdt) < fdtstart) {
+ return err;
+ }
+ fdtend = fdtstart + fdt_totalsize(fdt);
FDT_CHECK_HEADER(fdt);
+ if ((fdt_num_mem_rsv(fdt)+1) > (UINT_MAX / sizeof(struct fdt_reserve_entry))) {
+ return err;
+ }
+
mem_rsv_size = (fdt_num_mem_rsv(fdt)+1)
* sizeof(struct fdt_reserve_entry);
if (fdt_version(fdt) >= 17) {
struct_size = fdt_size_dt_struct(fdt);
+ if (struct_size < 0)
+ return struct_size;
} else {
struct_size = 0;
while (fdt_next_tag(fdt, struct_size, &struct_size) != FDT_END)
@@ -485,16 +496,22 @@
fdt_set_totalsize(buf, bufsize);
return 0;
}
+ if (((uint64_t)FDT_ALIGN(sizeof(struct fdt_header), 8) + (uint64_t)mem_rsv_size \
+ + (uint64_t)struct_size + (uint64_t)fdt_size_dt_strings(fdt)) > UINT_MAX) {
+ return (err = -1);
+ }
/* Need to reorder */
newsize = FDT_ALIGN(sizeof(struct fdt_header), 8) + mem_rsv_size
+ struct_size + fdt_size_dt_strings(fdt);
-
if (bufsize < newsize)
return -FDT_ERR_NOSPACE;
/* First attempt to build converted tree at beginning of buffer */
tmp = buf;
+ if (((tmp + newsize) < tmp) || ((buf + bufsize) < buf)) {
+ return (err = -1);
+ }
/* But if that overlaps with the old tree... */
if (((tmp + newsize) > fdtstart) && (tmp < fdtend)) {
/* Try right after the old tree instead */
diff --git a/platform/apq8084/acpuclock.c b/platform/apq8084/acpuclock.c
index 7f903fb..78c7b64 100644
--- a/platform/apq8084/acpuclock.c
+++ b/platform/apq8084/acpuclock.c
@@ -556,6 +556,39 @@
}
}
+void hdmi_clk_enable(void)
+{
+ int ret;
+
+ /* Configure hdmi ahb clock */
+ ret = clk_get_set_enable("hdmi_ahb_clk", 0, 1);
+ if(ret) {
+ dprintf(CRITICAL, "failed to set hdmi_ahb_clk ret = %d\n", ret);
+ ASSERT(0);
+ }
+
+ /* Configure hdmi core clock */
+ ret = clk_get_set_enable("hdmi_core_clk", 19200000, 1);
+ if(ret) {
+ dprintf(CRITICAL, "failed to set hdmi_core_clk ret = %d\n", ret);
+ ASSERT(0);
+ }
+
+ /* Configure hdmi pixel clock */
+ ret = clk_get_set_enable("hdmi_extp_clk", 148500000, 1);
+ if(ret) {
+ dprintf(CRITICAL, "failed to set hdmi_extp_clk ret = %d\n", ret);
+ ASSERT(0);
+ }
+}
+
+void hdmi_clk_disable(void)
+{
+ clk_disable(clk_get("hdmi_extp_clk"));
+ clk_disable(clk_get("hdmi_core_clk"));
+ clk_disable(clk_get("hdmi_ahb_clk"));
+}
+
void edp_clk_enable(void)
{
int ret;
diff --git a/platform/apq8084/apq8084-clock.c b/platform/apq8084/apq8084-clock.c
index 08d6d2a..f01aa7e 100644
--- a/platform/apq8084/apq8084-clock.c
+++ b/platform/apq8084/apq8084-clock.c
@@ -1,4 +1,4 @@
-/* Copyright (c) 2013, The Linux Foundation. All rights reserved.
+/* Copyright (c) 2013-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
@@ -47,6 +47,7 @@
#define gpll0_mm_source_val 5
#define edppll_270_mm_source_val 4
#define edppll_350_mm_source_val 4
+#define hdmipll_mm_source_val 3
struct clk_freq_tbl rcg_dummy_freq = F_END;
@@ -690,6 +691,69 @@
},
};
+static struct branch_clk mdss_hdmi_ahb_clk = {
+ .cbcr_reg = MDSS_HDMI_AHB_CBCR,
+ .has_sibling = 1,
+ .c = {
+ .dbg_name = "mdss_hdmi_ahb_clk",
+ .ops = &clk_ops_branch,
+ },
+};
+
+static struct clk_freq_tbl ftbl_mdss_hdmi_clk[] = {
+ F_MM( 19200000, cxo, 1, 0, 0),
+ F_END
+};
+
+static struct rcg_clk hdmi_clk_src = {
+ .cmd_reg = HDMI_CMD_RCGR,
+ .cfg_reg = HDMI_CFG_RCGR,
+ .set_rate = clock_lib2_rcg_set_rate_hid,
+ .freq_tbl = ftbl_mdss_hdmi_clk,
+ .current_freq = &rcg_dummy_freq,
+ .c = {
+ .dbg_name = "hdmi_clk_src",
+ .ops = &clk_ops_rcg,
+ },
+};
+
+static struct branch_clk mdss_hdmi_clk = {
+ .cbcr_reg = MDSS_HDMI_CBCR,
+ .has_sibling = 0,
+ .parent = &hdmi_clk_src.c,
+ .c = {
+ .dbg_name = "mdss_hdmi_clk",
+ .ops = &clk_ops_branch,
+ },
+};
+
+static struct clk_freq_tbl ftbl_mdss_extpclk_clk[] = {
+ F_MDSS(148500000, hdmipll, 1, 0, 0),
+ F_END
+};
+
+static struct rcg_clk extpclk_clk_src = {
+ .cmd_reg = EXTPCLK_CMD_RCGR,
+ .cfg_reg = EXTPCLK_CFG_RCGR,
+ .set_rate = clock_lib2_rcg_set_rate_hid,
+ .freq_tbl = ftbl_mdss_extpclk_clk,
+ .current_freq = &rcg_dummy_freq,
+ .c = {
+ .dbg_name = "extpclk_clk_src",
+ .ops = &clk_ops_rcg,
+ },
+};
+
+static struct branch_clk mdss_extpclk_clk = {
+ .cbcr_reg = MDSS_EXTPCLK_CBCR,
+ .has_sibling = 0,
+ .parent = &extpclk_clk_src.c,
+ .c = {
+ .dbg_name = "mdss_extpclk_clk",
+ .ops = &clk_ops_branch,
+ },
+};
+
static struct clk_freq_tbl ftbl_mdss_edpaux_clk[] = {
F_MM(19200000, cxo, 1, 0, 0),
F_END
@@ -838,6 +902,10 @@
CLK_LOOKUP("edp_pixel_clk", mdss_edppixel_clk.c),
CLK_LOOKUP("edp_link_clk", mdss_edplink_clk.c),
CLK_LOOKUP("edp_aux_clk", mdss_edpaux_clk.c),
+
+ CLK_LOOKUP("hdmi_ahb_clk", mdss_hdmi_ahb_clk.c),
+ CLK_LOOKUP("hdmi_core_clk", mdss_hdmi_clk.c),
+ CLK_LOOKUP("hdmi_extp_clk", mdss_extpclk_clk.c),
};
void platform_clock_init(void)
diff --git a/platform/apq8084/include/platform/clock.h b/platform/apq8084/include/platform/clock.h
index 7f4ebfd..a3bb284 100644
--- a/platform/apq8084/include/platform/clock.h
+++ b/platform/apq8084/include/platform/clock.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2013, The Linux Foundation. All rights reserved.
+/* Copyright (c) 2013-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
@@ -50,6 +50,13 @@
#define MDP_CBCR REG_MM(0x231C)
#define MDP_LUT_CBCR REG_MM(0x2320)
#define MDP_AHB_CBCR REG_MM(0x2308)
+#define MDSS_HDMI_AHB_CBCR REG_MM(0x230C)
+#define MDSS_HDMI_CBCR REG_MM(0x2338)
+#define MDSS_EXTPCLK_CBCR REG_MM(0x2324)
+#define EXTPCLK_CMD_RCGR REG_MM(0x2060)
+#define EXTPCLK_CFG_RCGR REG_MM(0x2064)
+#define HDMI_CMD_RCGR REG_MM(0x2100)
+#define HDMI_CFG_RCGR REG_MM(0x2104)
#define MDP_AXI_CMD_RCGR REG_MM(0x5040)
#define MDP_AXI_CFG_RCGR REG_MM(0x5044)
diff --git a/platform/apq8084/include/platform/iomap.h b/platform/apq8084/include/platform/iomap.h
index 241285f..6d02af3 100644
--- a/platform/apq8084/include/platform/iomap.h
+++ b/platform/apq8084/include/platform/iomap.h
@@ -271,4 +271,26 @@
#define VIDEO_MODE_CTRL 0x010
#define HS_TIMER_CTRL 0x0BC
+/* HDMI reg addresses */
+#define HDMI_BASE 0xFD922100
+#define REG_HDMI(off) (HDMI_BASE + (off))
+
+#define HDMI_USEC_REFTIMER REG_HDMI(0x208)
+#define HDMI_CTRL REG_HDMI(0x000)
+#define HDMI_HPD_INT_STATUS REG_HDMI(0x250)
+#define HDMI_HPD_INT_CTRL REG_HDMI(0x254)
+#define HDMI_HPD_CTRL REG_HDMI(0x258)
+#define HDMI_PHY_CTRL REG_HDMI(0x2D4)
+#define HDMI_TOTAL REG_HDMI(0x2C0)
+#define HDMI_ACTIVE_H REG_HDMI(0x2B4)
+#define HDMI_ACTIVE_V REG_HDMI(0x2B8)
+#define HDMI_V_TOTAL_F2 REG_HDMI(0x2C4)
+#define HDMI_ACTIVE_V_F2 REG_HDMI(0x2BC)
+#define HDMI_FRAME_CTRL REG_HDMI(0x2C8)
+
+#define HDMI_AVI_INFO0 REG_HDMI(0x06C)
+#define HDMI_AVI_INFO1 REG_HDMI(0x070)
+#define HDMI_AVI_INFO2 REG_HDMI(0x074)
+#define HDMI_AVI_INFO3 REG_HDMI(0x078)
+#define HDMI_INFOFRAME_CTRL0 REG_HDMI(0x02C)
#endif
diff --git a/platform/ferrum/platform.c b/platform/ferrum/platform.c
index 1895fe6..3765be4 100644
--- a/platform/ferrum/platform.c
+++ b/platform/ferrum/platform.c
@@ -37,6 +37,7 @@
void platform_early_init(void)
{
+ board_init();
qgic_init();
qtimer_init();
}
diff --git a/platform/msm8916/platform.c b/platform/msm8916/platform.c
index cd428e8..4deaa1b 100644
--- a/platform/msm8916/platform.c
+++ b/platform/msm8916/platform.c
@@ -190,6 +190,7 @@
case MSM8236:
case MSM8636:
case MSM8936:
+ case MSM8239:
ret = 1;
break;
default:
diff --git a/platform/msm8916/rules.mk b/platform/msm8916/rules.mk
index b0a2070..1b737e7 100644
--- a/platform/msm8916/rules.mk
+++ b/platform/msm8916/rules.mk
@@ -13,6 +13,8 @@
DEFINES += WITH_CPU_EARLY_INIT=0 WITH_CPU_WARM_BOOT=0 \
MMC_SLOT=$(MMC_SLOT) SSD_ENABLE
+DEFINES += TZ_SAVE_KERNEL_HASH
+
INCLUDES += -I$(LOCAL_DIR)/include -I$(LK_TOP_DIR)/platform/msm_shared/include
DEVS += fbcon
diff --git a/platform/msm8994/acpuclock.c b/platform/msm8994/acpuclock.c
index cd990f2..ba316fa 100644
--- a/platform/msm8994/acpuclock.c
+++ b/platform/msm8994/acpuclock.c
@@ -142,6 +142,10 @@
{
ret = clk_get_set_enable(clk_name, 192000000, 1);
}
+ else if(freq == MMC_CLK_200MHZ)
+ {
+ ret = clk_get_set_enable(clk_name, 200000000, 1);
+ }
else if(freq == MMC_CLK_400MHZ)
{
ret = clk_get_set_enable(clk_name, 384000000, 1);
diff --git a/platform/msm8994/include/platform/iomap.h b/platform/msm8994/include/platform/iomap.h
index aade4bd..6788981 100644
--- a/platform/msm8994/include/platform/iomap.h
+++ b/platform/msm8994/include/platform/iomap.h
@@ -162,6 +162,17 @@
#define SDCC1_N (CLK_CTL_BASE + 0x4DC) /* n */
#define SDCC1_D (CLK_CTL_BASE + 0x4E0) /* d */
+/* SDCC2 */
+#define SDCC2_BCR (CLK_CTL_BASE + 0x500) /* block reset */
+#define SDCC2_APPS_CBCR (CLK_CTL_BASE + 0x504) /* branch control */
+#define SDCC2_AHB_CBCR (CLK_CTL_BASE + 0x508)
+#define SDCC2_INACTIVITY_TIMER_CBCR (CLK_CTL_BASE + 0x50C)
+#define SDCC2_CMD_RCGR (CLK_CTL_BASE + 0x510) /* cmd */
+#define SDCC2_CFG_RCGR (CLK_CTL_BASE + 0x514) /* cfg */
+#define SDCC2_M (CLK_CTL_BASE + 0x518) /* m */
+#define SDCC2_N (CLK_CTL_BASE + 0x51C) /* n */
+#define SDCC2_D (CLK_CTL_BASE + 0x520) /* d */
+
/* SDCC3 */
#define SDCC3_BCR (CLK_CTL_BASE + 0x540) /* block reset */
#define SDCC3_APPS_CBCR (CLK_CTL_BASE + 0x544) /* branch control */
@@ -195,6 +206,7 @@
/* DRV strength for sdcc */
#define SDC1_HDRV_PULL_CTL (TLMM_BASE_ADDR + 0x00002044)
+#define SDC2_HDRV_PULL_CTL (TLMM_BASE_ADDR + 0x00002048)
/* SDHCI */
#define SDCC_MCI_HC_MODE (0x00000078)
@@ -217,6 +229,7 @@
/* MDSS */
#define MSM_MMSS_CLK_CTL_BASE 0xFD8C0000
+#define MMSS_MISC_AHB_CBCR (MSM_MMSS_CLK_CTL_BASE + 0x502C)
#define MIPI_DSI_BASE (0xFD998000)
#define MIPI_DSI0_BASE (MIPI_DSI_BASE)
#define MIPI_DSI1_BASE (0xFD9A0000)
diff --git a/platform/msm8994/msm8994-clock.c b/platform/msm8994/msm8994-clock.c
index 033a88d..a28291a 100644
--- a/platform/msm8994/msm8994-clock.c
+++ b/platform/msm8994/msm8994-clock.c
@@ -283,7 +283,7 @@
};
/* SDCC Clocks */
-static struct clk_freq_tbl ftbl_gcc_sdcc1_4_apps_clk[] =
+static struct clk_freq_tbl ftbl_gcc_sdcc1_apps_clk[] =
{
F( 144000, cxo, 16, 3, 25),
F( 400000, cxo, 12, 1, 4),
@@ -296,6 +296,18 @@
F_END
};
+static struct clk_freq_tbl ftbl_gcc_sdcc2_4_apps_clk[] =
+{
+ F( 144000, cxo, 16, 3, 25),
+ F( 400000, cxo, 12, 1, 4),
+ F( 20000000, gpll0, 15, 1, 2),
+ F( 25000000, gpll0, 12, 1, 2),
+ F( 50000000, gpll0, 12, 0, 0),
+ F(100000000, gpll0, 6, 0, 0),
+ F(200000000, gpll0, 3, 0, 0),
+ F_END
+};
+
static struct rcg_clk sdcc1_apps_clk_src =
{
.cmd_reg = (uint32_t *) SDCC1_CMD_RCGR,
@@ -305,7 +317,7 @@
.d_reg = (uint32_t *) SDCC1_D,
.set_rate = clock_lib2_rcg_set_rate_mnd,
- .freq_tbl = ftbl_gcc_sdcc1_4_apps_clk,
+ .freq_tbl = ftbl_gcc_sdcc1_apps_clk,
.current_freq = &rcg_dummy_freq,
.c = {
@@ -336,6 +348,46 @@
},
};
+static struct rcg_clk sdcc2_apps_clk_src =
+{
+ .cmd_reg = (uint32_t *) SDCC2_CMD_RCGR,
+ .cfg_reg = (uint32_t *) SDCC2_CFG_RCGR,
+ .m_reg = (uint32_t *) SDCC2_M,
+ .n_reg = (uint32_t *) SDCC2_N,
+ .d_reg = (uint32_t *) SDCC2_D,
+
+ .set_rate = clock_lib2_rcg_set_rate_mnd,
+ .freq_tbl = ftbl_gcc_sdcc2_4_apps_clk,
+ .current_freq = &rcg_dummy_freq,
+
+ .c = {
+ .dbg_name = "sdc2_clk",
+ .ops = &clk_ops_rcg_mnd,
+ },
+};
+
+static struct branch_clk gcc_sdcc2_apps_clk =
+{
+ .cbcr_reg = (uint32_t *) SDCC2_APPS_CBCR,
+ .parent = &sdcc2_apps_clk_src.c,
+
+ .c = {
+ .dbg_name = "gcc_sdcc2_apps_clk",
+ .ops = &clk_ops_branch,
+ },
+};
+
+static struct branch_clk gcc_sdcc2_ahb_clk =
+{
+ .cbcr_reg = (uint32_t *) SDCC2_AHB_CBCR,
+ .has_sibling = 1,
+
+ .c = {
+ .dbg_name = "gcc_sdcc2_ahb_clk",
+ .ops = &clk_ops_branch,
+ },
+};
+
static struct branch_clk gcc_sys_noc_usb30_axi_clk = {
.cbcr_reg = (uint32_t *) SYS_NOC_USB3_AXI_CBCR,
.has_sibling = 1,
@@ -756,12 +808,25 @@
},
};
+static struct branch_clk mmss_misc_ahb_clk = {
+ .cbcr_reg = MMSS_MISC_AHB_CBCR,
+ .has_sibling = 1,
+
+ .c = {
+ .dbg_name = "mmss_misc_ahb_clk",
+ .ops = &clk_ops_branch,
+ },
+};
+
/* Clock lookup table */
static struct clk_lookup msm_8994_clocks[] =
{
CLK_LOOKUP("sdc1_iface_clk", gcc_sdcc1_ahb_clk.c),
CLK_LOOKUP("sdc1_core_clk", gcc_sdcc1_apps_clk.c),
+ CLK_LOOKUP("sdc2_iface_clk", gcc_sdcc2_ahb_clk.c),
+ CLK_LOOKUP("sdc2_core_clk", gcc_sdcc2_apps_clk.c),
+
CLK_LOOKUP("uart2_iface_clk", gcc_blsp1_ahb_clk.c),
CLK_LOOKUP("uart2_core_clk", gcc_blsp1_uart2_apps_clk.c),
@@ -791,6 +856,7 @@
CLK_LOOKUP("mdss_mdp_clk_src", mdss_mdp_clk_src.c),
CLK_LOOKUP("mdss_mdp_clk", mdss_mdp_clk.c),
CLK_LOOKUP("mdss_mdp_lut_clk", mdss_mdp_lut_clk.c),
+ CLK_LOOKUP("mmss_misc_ahb_clk", mmss_misc_ahb_clk.c),
CLK_LOOKUP("edp_pixel_clk", mdss_edppixel_clk.c),
CLK_LOOKUP("edp_link_clk", mdss_edplink_clk.c),
diff --git a/platform/msm8994/platform.c b/platform/msm8994/platform.c
index 8c90dc5..f494f3f 100644
--- a/platform/msm8994/platform.c
+++ b/platform/msm8994/platform.c
@@ -66,6 +66,7 @@
platform_clock_init();
qgic_init();
qtimer_init();
+ scm_init();
}
void platform_init(void)
diff --git a/platform/msm8994/rules.mk b/platform/msm8994/rules.mk
index a9fd66f..641e3cd 100644
--- a/platform/msm8994/rules.mk
+++ b/platform/msm8994/rules.mk
@@ -13,6 +13,8 @@
DEFINES += WITH_CPU_EARLY_INIT=0 WITH_CPU_WARM_BOOT=0 \
MMC_SLOT=$(MMC_SLOT)
+DEFINES += TZ_SAVE_KERNEL_HASH
+
INCLUDES += -I$(LOCAL_DIR)/include -I$(LK_TOP_DIR)/platform/msm_shared/include
DEVS += fbcon
diff --git a/platform/msm_shared/board.c b/platform/msm_shared/board.c
index 5c7dee8..fdc8553 100644
--- a/platform/msm_shared/board.c
+++ b/platform/msm_shared/board.c
@@ -50,6 +50,7 @@
unsigned int board_info_len = 0;
unsigned ret = 0;
unsigned format = 0;
+ unsigned pmic_type = 0;
uint8_t i;
uint16_t format_major = 0;
uint16_t format_minor = 0;
@@ -131,6 +132,17 @@
for (i = 0; i < SMEM_V8_SMEM_MAX_PMIC_DEVICES; i++) {
board.pmic_info[i].pmic_type = board_info_v8.pmic_info[i].pmic_type;
board.pmic_info[i].pmic_version = board_info_v8.pmic_info[i].pmic_version;
+
+ /*
+ * fill in pimc_board_info with pmic type and pmic version information
+ * bit no |31 24 | 23 16 | 15 8 |7 0|
+ * pimc_board_info = |Unused | Major version | Minor version|PMIC_MODEL|
+ *
+ */
+ pmic_type = board_info_v8.pmic_info[i].pmic_type == PMIC_IS_INVALID? 0 : board_info_v8.pmic_info[i].pmic_type;
+
+ board.pmic_info[i].pmic_target = (((board_info_v8.pmic_info[i].pmic_version >> 16) & 0xff) << 16) |
+ ((board_info_v8.pmic_info[i].pmic_version & 0xff) << 8) | (pmic_type & 0xff);
}
if (format_minor == 0x9)
@@ -195,12 +207,21 @@
for (i = 0; i < num_ent && i < SMEM_MAX_PMIC_DEVICES; i++) {
info->pmic_type = board.pmic_info[i].pmic_type;
info->pmic_version = board.pmic_info[i].pmic_version;
+ info->pmic_target = board.pmic_info[i].pmic_target;
info++;
}
return (i--);
}
+uint32_t board_pmic_target(uint8_t num_ent)
+{
+ if (num_ent < SMEM_MAX_PMIC_DEVICES) {
+ return board.pmic_info[num_ent].pmic_target;
+ }
+ return 0;
+}
+
uint32_t board_soc_version()
{
return board.platform_version;
diff --git a/platform/msm_shared/dev_tree.c b/platform/msm_shared/dev_tree.c
index 774c8b6..bd24628 100644
--- a/platform/msm_shared/dev_tree.c
+++ b/platform/msm_shared/dev_tree.c
@@ -35,6 +35,8 @@
#include <string.h>
#include <platform.h>
#include <board.h>
+#include <list.h>
+#include <kernel/thread.h>
struct dt_entry_v1
{
@@ -46,8 +48,9 @@
};
static struct dt_mem_node_info mem_node;
-
-static int platform_dt_match(struct dt_entry *cur_dt_entry, struct board_dt_entry *board_dt_data, uint32_t subtype_mask);
+static int platform_dt_absolute_match(struct dt_entry *cur_dt_entry, struct dt_entry_node *dt_list);
+static struct dt_entry *platform_dt_match_best(struct dt_entry_node *dt_list);
+static int update_dtb_entry_node(struct dt_entry_node *dt_list, uint32_t dtb_info);
extern int target_is_emmc_boot(void);
extern uint32_t target_dev_tree_mem(void *fdt, uint32_t memory_node_offset);
/* TODO: This function needs to be moved to target layer to check violations
@@ -58,30 +61,66 @@
/* Returns soc version if platform id and hardware id matches
otherwise return 0xFFFFFFFF */
#define INVALID_SOC_REV_ID 0XFFFFFFFF
-static uint32_t dev_tree_compatible(void *dtb)
+
+/* Add function to allocate dt entry list, used for recording
+* the entry which conform to platform_dt_absolute_match()
+*/
+static struct dt_entry_node *dt_entry_list_init(void)
+{
+ struct dt_entry_node *dt_node_member = NULL;
+
+ dt_node_member = (struct dt_entry_node *)
+ malloc(sizeof(struct dt_entry_node));
+
+ ASSERT(dt_node_member);
+
+ list_clear_node(&dt_node_member->node);
+ dt_node_member->dt_entry_m = (struct dt_entry *)
+ malloc(sizeof(struct dt_entry));
+ ASSERT(dt_node_member->dt_entry_m);
+
+ memset(dt_node_member->dt_entry_m ,0 ,sizeof(struct dt_entry));
+ return dt_node_member;
+}
+
+static void insert_dt_entry_in_queue(struct dt_entry_node *dt_list, struct dt_entry_node *dt_node_member)
+{
+ list_add_tail(&dt_list->node, &dt_node_member->node);
+}
+
+static void dt_entry_list_delete(struct dt_entry_node *dt_node_member)
+{
+ if (list_in_list(&dt_node_member->node)) {
+ list_delete(&dt_node_member->node);
+ free(dt_node_member->dt_entry_m);
+ free(dt_node_member);
+ }
+}
+
+static int dev_tree_compatible(void *dtb, uint32_t dtb_size, struct dt_entry_node *dtb_list)
{
int root_offset;
const void *prop = NULL;
const char *plat_prop = NULL;
const char *board_prop = NULL;
+ const char *pmic_prop = NULL;
char *model = NULL;
- struct dt_entry cur_dt_entry;
- struct dt_entry *dt_entry_v2 = NULL;
+ struct dt_entry *cur_dt_entry;
+ struct dt_entry *dt_entry_array = NULL;
struct board_id *board_data = NULL;
struct plat_id *platform_data = NULL;
+ struct pmic_id *pmic_data = NULL;
int len;
int len_board_id;
int len_plat_id;
int min_plat_id_len = 0;
- uint32_t target_variant_id;
+ int len_pmic_id;
uint32_t dtb_ver;
uint32_t num_entries = 0;
- uint32_t i, j, k;
- uint32_t found = 0;
+ uint32_t i, j, k, n;
uint32_t msm_data_count;
uint32_t board_data_count;
- uint32_t soc_rev;
- struct board_dt_entry board_dt_data;
+ uint32_t pmic_data_count;
root_offset = fdt_path_offset(dtb, "/");
if (root_offset < 0)
@@ -95,12 +134,21 @@
} else {
dprintf(INFO, "model does not exist in device tree\n");
}
-
- /* Find the board-id prop from DTB , if board-id is present then
- * the DTB is version 2 */
+ /* Find the pmic-id prop from DTB , if pmic-id is present then
+ * the DTB is version 3, otherwise find the board-id prop from DTB ,
+ * if board-id is present then the DTB is version 2 */
+ pmic_prop = (const char *)fdt_getprop(dtb, root_offset, "qcom,pmic-id", &len_pmic_id);
board_prop = (const char *)fdt_getprop(dtb, root_offset, "qcom,board-id", &len_board_id);
- if (board_prop && len_board_id > 0)
- {
+ if (pmic_prop && (len_pmic_id > 0) && board_prop && (len_board_id > 0)) {
+ if ((len_pmic_id % PMIC_ID_SIZE) || (len_board_id % BOARD_ID_SIZE))
+ {
+ dprintf(CRITICAL, "qcom,pmic-id(%d) or qcom,board-id(%d) in device tree is not a multiple of (%d %d)\n",
+ len_pmic_id, len_board_id, PMIC_ID_SIZE, BOARD_ID_SIZE);
+ return false;
+ }
+ dtb_ver = DEV_TREE_VERSION_V3;
+ min_plat_id_len = PLAT_ID_SIZE;
+ } else if (board_prop && len_board_id > 0) {
if (len_board_id % BOARD_ID_SIZE)
{
dprintf(CRITICAL, "qcom,board-id in device tree is (%d) not a multiple of (%d)\n",
@@ -109,9 +157,7 @@
}
dtb_ver = DEV_TREE_VERSION_V2;
min_plat_id_len = PLAT_ID_SIZE;
- }
- else
- {
+ } else {
dtb_ver = DEV_TREE_VERSION_V1;
min_plat_id_len = DT_ENTRY_V1_SIZE;
}
@@ -133,197 +179,226 @@
* y: variant_id
* z: SOC rev
*/
- if (dtb_ver == DEV_TREE_VERSION_V1)
- {
- while (len_plat_id)
- {
- cur_dt_entry.platform_id = fdt32_to_cpu(((const struct dt_entry_v1 *)plat_prop)->platform_id);
- cur_dt_entry.variant_id = fdt32_to_cpu(((const struct dt_entry_v1 *)plat_prop)->variant_id);
- cur_dt_entry.soc_rev = fdt32_to_cpu(((const struct dt_entry_v1 *)plat_prop)->soc_rev);
- cur_dt_entry.board_hw_subtype = board_hardware_subtype();
+ if (dtb_ver == DEV_TREE_VERSION_V1) {
+ cur_dt_entry = (struct dt_entry *)
+ malloc(sizeof(struct dt_entry));
- board_dt_data.target_variant_id = board_hardware_id();
- board_dt_data.platform_variant_id = board_platform_id();
+ if (!cur_dt_entry) {
+ dprintf(CRITICAL, "Out of memory\n");
+ return false;
+ }
+ memset(cur_dt_entry, 0, sizeof(struct dt_entry));
+
+ while (len_plat_id) {
+ cur_dt_entry->platform_id = fdt32_to_cpu(((const struct dt_entry_v1 *)plat_prop)->platform_id);
+ cur_dt_entry->variant_id = fdt32_to_cpu(((const struct dt_entry_v1 *)plat_prop)->variant_id);
+ cur_dt_entry->soc_rev = fdt32_to_cpu(((const struct dt_entry_v1 *)plat_prop)->soc_rev);
+ cur_dt_entry->board_hw_subtype =
+ fdt32_to_cpu(((const struct dt_entry_v1 *)plat_prop)->variant_id) >> 0x18;
+ cur_dt_entry->pmic_rev[0] = board_pmic_target(0);
+ cur_dt_entry->pmic_rev[1] = board_pmic_target(1);
+ cur_dt_entry->pmic_rev[2] = board_pmic_target(2);
+ cur_dt_entry->pmic_rev[3] = board_pmic_target(3);
+ cur_dt_entry->offset = (uint32_t)dtb;
+ cur_dt_entry->size = dtb_size;
dprintf(SPEW, "Found an appended flattened device tree (%s - %u %u 0x%x)\n",
- model ? model : "unknown",
- cur_dt_entry.platform_id, cur_dt_entry.variant_id, cur_dt_entry.soc_rev);
+ *model ? model : "unknown",
+ cur_dt_entry->platform_id, cur_dt_entry->variant_id, cur_dt_entry->soc_rev);
- if (platform_dt_match(&cur_dt_entry, &board_dt_data, 0) == 1)
- {
+ if (platform_dt_absolute_match(cur_dt_entry, dtb_list)) {
+ dprintf(SPEW, "Device tree exact match the board: <%u %u 0x%x> != <%u %u 0x%x>\n",
+ cur_dt_entry->platform_id,
+ cur_dt_entry->variant_id,
+ cur_dt_entry->soc_rev,
+ board_platform_id(),
+ board_hardware_id(),
+ board_soc_version());
+
+ } else {
dprintf(SPEW, "Device tree's msm_id doesn't match the board: <%u %u 0x%x> != <%u %u 0x%x>\n",
- cur_dt_entry.platform_id,
- cur_dt_entry.variant_id,
- cur_dt_entry.soc_rev,
- board_platform_id(),
- board_hardware_id(),
- board_soc_version());
+ cur_dt_entry->platform_id,
+ cur_dt_entry->variant_id,
+ cur_dt_entry->soc_rev,
+ board_platform_id(),
+ board_hardware_id(),
+ board_soc_version());
plat_prop += DT_ENTRY_V1_SIZE;
len_plat_id -= DT_ENTRY_V1_SIZE;
continue;
}
- else
- {
- found = 1;
- break;
- }
}
+ free(cur_dt_entry);
+
}
/*
- * If DTB Version is '2' then we have split DTB with board & msm data
- * populated saperately in board-id & msm-id prop respectively.
+ * If DTB Version is '3' then we have split DTB with board & msm data & pmic
+ * populated saperately in board-id & msm-id & pmic-id prop respectively.
* Extract the data & prepare a look up table
*/
- else if (dtb_ver == DEV_TREE_VERSION_V2)
- {
+ else if (dtb_ver == DEV_TREE_VERSION_V2 || dtb_ver == DEV_TREE_VERSION_V3) {
board_data_count = (len_board_id / BOARD_ID_SIZE);
msm_data_count = (len_plat_id / PLAT_ID_SIZE);
+ /* If dtb version is v2.0, the pmic_data_count will be <= 0 */
+ pmic_data_count = (len_pmic_id / PMIC_ID_SIZE);
- /* If we are using dtb v2.0, then we have split board & msm data in the DTB */
+ /* If we are using dtb v3.0, then we have split board, msm & pmic data in the DTB
+ * If we are using dtb v2.0, then we have split board & msmdata in the DTB
+ */
board_data = (struct board_id *) malloc(sizeof(struct board_id) * (len_board_id / BOARD_ID_SIZE));
ASSERT(board_data);
platform_data = (struct plat_id *) malloc(sizeof(struct plat_id) * (len_plat_id / PLAT_ID_SIZE));
ASSERT(platform_data);
+ if (dtb_ver == DEV_TREE_VERSION_V3) {
+ pmic_data = (struct pmic_id *) malloc(sizeof(struct pmic_id) * (len_pmic_id / PMIC_ID_SIZE));
+ ASSERT(pmic_data);
+ }
i = 0;
/* Extract board data from DTB */
- for(i = 0 ; i < board_data_count; i++)
- {
+ for(i = 0 ; i < board_data_count; i++) {
board_data[i].variant_id = fdt32_to_cpu(((struct board_id *)board_prop)->variant_id);
board_data[i].platform_subtype = fdt32_to_cpu(((struct board_id *)board_prop)->platform_subtype);
+ /* For V2/V3 version of DTBs we have platform version field as part
+ * of variant ID, in such case the subtype will be mentioned as 0x0
+ * As the qcom, board-id = <0xSSPMPmPH, 0x0>
+ * SS -- Subtype
+ * PM -- Platform major version
+ * Pm -- Platform minor version
+ * PH -- Platform hardware CDP/MTP
+ * In such case to make it compatible with LK algorithm move the subtype
+ * from variant_id to subtype field
+ */
+ if (board_data[i].platform_subtype == 0)
+ board_data[i].platform_subtype =
+ fdt32_to_cpu(((struct board_id *)board_prop)->variant_id) >> 0x18;
+
len_board_id -= sizeof(struct board_id);
board_prop += sizeof(struct board_id);
}
/* Extract platform data from DTB */
- for(i = 0 ; i < msm_data_count; i++)
- {
+ for(i = 0 ; i < msm_data_count; i++) {
platform_data[i].platform_id = fdt32_to_cpu(((struct plat_id *)plat_prop)->platform_id);
platform_data[i].soc_rev = fdt32_to_cpu(((struct plat_id *)plat_prop)->soc_rev);
len_plat_id -= sizeof(struct plat_id);
plat_prop += sizeof(struct plat_id);
}
- /* We need to merge board & platform data into dt entry structure */
- num_entries = msm_data_count * board_data_count;
+ if (dtb_ver == DEV_TREE_VERSION_V3 && pmic_prop) {
+ /* Extract pmic data from DTB */
+ for(i = 0 ; i < pmic_data_count; i++) {
+ pmic_data[i].pmic_version[0]= fdt32_to_cpu(((struct pmic_id *)pmic_prop)->pmic_version[0]);
+ pmic_data[i].pmic_version[1]= fdt32_to_cpu(((struct pmic_id *)pmic_prop)->pmic_version[1]);
+ pmic_data[i].pmic_version[2]= fdt32_to_cpu(((struct pmic_id *)pmic_prop)->pmic_version[2]);
+ pmic_data[i].pmic_version[3]= fdt32_to_cpu(((struct pmic_id *)pmic_prop)->pmic_version[3]);
+ len_pmic_id -= sizeof(struct pmic_id);
+ pmic_prop += sizeof(struct pmic_id);
+ }
- if (((uint64_t)msm_data_count * (uint64_t)board_data_count) == msm_data_count * board_data_count) {
- dt_entry_v2 = (struct dt_entry*) malloc(sizeof(struct dt_entry) * num_entries);
- ASSERT(dt_entry_v2);
+ /* We need to merge board & platform data into dt entry structure */
+ num_entries = msm_data_count * board_data_count * pmic_data_count;
+ } else {
+ /* We need to merge board & platform data into dt entry structure */
+ num_entries = msm_data_count * board_data_count;
+ }
- /* If we have '<X>; <Y>; <Z>' as platform data & '<A>; <B>; <C>' as board data.
- * Then dt entry should look like
- * <X ,A >;<X, B>;<X, C>;
- * <Y ,A >;<Y, B>;<Y, C>;
- * <Z ,A >;<Z, B>;<Z, C>;
- */
- i = 0;
- k = 0;
- for (i = 0; i < msm_data_count; i++)
- {
- for (j = 0; j < board_data_count; j++)
- {
- dt_entry_v2[k].platform_id = platform_data[i].platform_id;
- dt_entry_v2[k].soc_rev = platform_data[i].soc_rev;
- dt_entry_v2[k].variant_id = board_data[j].variant_id;
- dt_entry_v2[k].board_hw_subtype = board_data[j].platform_subtype;
+ if ((((uint64_t)msm_data_count * (uint64_t)board_data_count * (uint64_t)pmic_data_count) !=
+ msm_data_count * board_data_count * pmic_data_count) ||
+ (((uint64_t)msm_data_count * (uint64_t)board_data_count) != msm_data_count * board_data_count)) {
+
+ free(board_data);
+ free(platform_data);
+ if (pmic_data)
+ free(pmic_data);
+ if (model)
+ free(model);
+ return false;
+ }
+
+ dt_entry_array = (struct dt_entry*) malloc(sizeof(struct dt_entry) * num_entries);
+ ASSERT(dt_entry_array);
+
+ /* If we have '<X>; <Y>; <Z>' as platform data & '<A>; <B>; <C>' as board data.
+ * Then dt entry should look like
+ * <X ,A >;<X, B>;<X, C>;
+ * <Y ,A >;<Y, B>;<Y, C>;
+ * <Z ,A >;<Z, B>;<Z, C>;
+ */
+ i = 0;
+ k = 0;
+ n = 0;
+ for (i = 0; i < msm_data_count; i++) {
+ for (j = 0; j < board_data_count; j++) {
+ if (dtb_ver == DEV_TREE_VERSION_V3 && pmic_prop) {
+ for (n = 0; n < pmic_data_count; n++) {
+ dt_entry_array[k].platform_id = platform_data[i].platform_id;
+ dt_entry_array[k].soc_rev = platform_data[i].soc_rev;
+ dt_entry_array[k].variant_id = board_data[j].variant_id;
+ dt_entry_array[k].board_hw_subtype = board_data[j].platform_subtype;
+ dt_entry_array[k].pmic_rev[0]= pmic_data[n].pmic_version[0];
+ dt_entry_array[k].pmic_rev[1]= pmic_data[n].pmic_version[1];
+ dt_entry_array[k].pmic_rev[2]= pmic_data[n].pmic_version[2];
+ dt_entry_array[k].pmic_rev[3]= pmic_data[n].pmic_version[3];
+ dt_entry_array[k].offset = (uint32_t)dtb;
+ dt_entry_array[k].size = dtb_size;
+ k++;
+ }
+
+ } else {
+ dt_entry_array[k].platform_id = platform_data[i].platform_id;
+ dt_entry_array[k].soc_rev = platform_data[i].soc_rev;
+ dt_entry_array[k].variant_id = board_data[j].variant_id;
+ dt_entry_array[k].board_hw_subtype = board_data[j].platform_subtype;
+ dt_entry_array[k].pmic_rev[0]= board_pmic_target(0);
+ dt_entry_array[k].pmic_rev[1]= board_pmic_target(1);
+ dt_entry_array[k].pmic_rev[2]= board_pmic_target(2);
+ dt_entry_array[k].pmic_rev[3]= board_pmic_target(3);
+ dt_entry_array[k].offset = (uint32_t)dtb;
+ dt_entry_array[k].size = dtb_size;
k++;
}
}
+ }
- /* Now find the matching entry in the merged list */
- if (board_hardware_id() == HW_PLATFORM_QRD)
- {
- board_dt_data.target_variant_id = board_target_id();
- board_dt_data.platform_variant_id = board_platform_id();
- }
- else
- {
- board_dt_data.target_variant_id = board_hardware_id() | ((board_hardware_subtype() & 0xff) << 24);
- board_dt_data.platform_variant_id = board_platform_id();
- }
+ for (i=0 ;i < num_entries; i++) {
+ dprintf(SPEW, "Found an appended flattened device tree (%s - %u %u %u 0x%x)\n",
+ *model ? model : "unknown",
+ dt_entry_array[i].platform_id, dt_entry_array[i].variant_id, dt_entry_array[i].board_hw_subtype, dt_entry_array[i].soc_rev);
- for (i=0 ;i < num_entries; i++)
- {
- dprintf(SPEW, "Found an appended flattened device tree (%s - %u %u %u 0x%x)\n",
- *model ? model : "unknown",
- dt_entry_v2[i].platform_id, dt_entry_v2[i].variant_id, dt_entry_v2[i].board_hw_subtype, dt_entry_v2[i].soc_rev);
+ if (platform_dt_absolute_match(&(dt_entry_array[i]), dtb_list)) {
+ dprintf(SPEW, "Device tree exact match the board: <%u %u %u 0x%x> == <%u %u %u 0x%x>\n",
+ dt_entry_array[i].platform_id,
+ dt_entry_array[i].variant_id,
+ dt_entry_array[i].soc_rev,
+ dt_entry_array[i].board_hw_subtype,
+ board_platform_id(),
+ board_hardware_id(),
+ board_hardware_subtype(),
+ board_soc_version());
- if (platform_dt_match(&dt_entry_v2[i], &board_dt_data, 0xff) == 1)
- {
- dprintf(SPEW, "Device tree's msm_id doesn't match the board: <%u %u %u 0x%x> != <%u %u %u 0x%x>\n",
- dt_entry_v2[i].platform_id,
- dt_entry_v2[i].variant_id,
- dt_entry_v2[i].soc_rev,
- dt_entry_v2[i].board_hw_subtype,
- board_platform_id(),
- board_hardware_id(),
- board_hardware_subtype(),
- board_soc_version());
- continue;
- }
- else
- {
- /* If found a match, return the cur_dt_entry */
- found = 1;
- cur_dt_entry = dt_entry_v2[i];
- break;
- }
+ } else {
+ dprintf(SPEW, "Device tree's msm_id doesn't match the board: <%u %u %u 0x%x> != <%u %u %u 0x%x>\n",
+ dt_entry_array[i].platform_id,
+ dt_entry_array[i].variant_id,
+ dt_entry_array[i].soc_rev,
+ dt_entry_array[i].board_hw_subtype,
+ board_platform_id(),
+ board_hardware_id(),
+ board_hardware_subtype(),
+ board_soc_version());
}
}
- else
- dprintf(CRITICAL, "Device tree got corrupted\n");
+
+ free(board_data);
+ free(platform_data);
+ if (pmic_data)
+ free(pmic_data);
+ free(dt_entry_array);
}
-
- if (dtb_ver == DEV_TREE_VERSION_V1)
- {
- if (!found)
- soc_rev = INVALID_SOC_REV_ID;
- else
- {
- soc_rev = cur_dt_entry.soc_rev;
-
- dprintf(INFO, "Device tree's msm_id matches the board: <%u %u %u 0x%x> == <%u %u %u 0x%x>\n",
- cur_dt_entry.platform_id,
- cur_dt_entry.variant_id,
- cur_dt_entry.board_hw_subtype,
- cur_dt_entry.soc_rev,
- board_platform_id(),
- board_hardware_id(),
- board_hardware_subtype(),
- board_soc_version());
- }
- return soc_rev;
- }
- else if (dtb_ver == DEV_TREE_VERSION_V2)
- {
- if (!found)
- {
- soc_rev = INVALID_SOC_REV_ID;
- goto end;
- }
- else
- soc_rev = cur_dt_entry.soc_rev;
-
- dprintf(INFO, "Device tree's msm_id matches the board: <%u %u %u 0x%x> == <%u %u %u 0x%x>\n",
- cur_dt_entry.platform_id,
- cur_dt_entry.variant_id,
- cur_dt_entry.board_hw_subtype,
- cur_dt_entry.soc_rev,
- board_platform_id(),
- board_hardware_id(),
- board_hardware_subtype(),
- board_soc_version());
- }
-
-end:
- free(board_data);
- free(platform_data);
- free(dt_entry_v2);
- if(model) {
+ if (model)
free(model);
- }
- return soc_rev;
+ return true;
}
/*
@@ -341,10 +416,25 @@
{
void *kernel_end = kernel + kernel_size;
uint32_t app_dtb_offset = 0;
- void *dtb;
+ void *dtb = NULL;
void *bestmatch_tag = NULL;
+ struct dt_entry *best_match_dt_entry = NULL;
uint32_t bestmatch_tag_size;
- uint32_t bestmatch_soc_rev_id = INVALID_SOC_REV_ID;
+ struct dt_entry_node *dt_entry_queue = NULL;
+ struct dt_entry_node *dt_node_tmp1 = NULL;
+ struct dt_entry_node *dt_node_tmp2 = NULL;
+
+
+ /* Initialize the dtb entry node*/
+ dt_entry_queue = (struct dt_entry_node *)
+ malloc(sizeof(struct dt_entry_node));
+
+ if (!dt_entry_queue) {
+ dprintf(CRITICAL, "Out of memory\n");
+ return NULL;
+ }
+ list_initialize(&dt_entry_queue->node);
+
memcpy((void*) &app_dtb_offset, (void*) (kernel + DTB_OFFSET), sizeof(uint32_t));
@@ -353,7 +443,6 @@
}
dtb = kernel + app_dtb_offset;
while (((uintptr_t)dtb + sizeof(struct fdt_header)) < (uintptr_t)kernel_end) {
- uint32_t dtb_soc_rev_id;
struct fdt_header dtb_hdr;
uint32_t dtb_size;
@@ -371,34 +460,36 @@
return NULL;
}
- /* now that we know we have a valid DTB, we need to copy
- * it somewhere aligned, like tags */
- memcpy(tags, dtb, dtb_size);
-
- dtb_soc_rev_id = dev_tree_compatible(tags);
- if (dtb_soc_rev_id == board_soc_version()) {
- /* clear out the old DTB magic so kernel doesn't find it */
- *((uint32_t *)(kernel + app_dtb_offset)) = 0;
- return tags;
- } else if ((dtb_soc_rev_id != INVALID_SOC_REV_ID) &&
- (dtb_soc_rev_id < board_soc_version())) {
- /* if current bestmatch is less than new dtb_soc_rev_id then update
- bestmatch_tag */
- if((bestmatch_soc_rev_id == INVALID_SOC_REV_ID) ||
- (bestmatch_soc_rev_id < dtb_soc_rev_id)) {
- bestmatch_tag = dtb;
- bestmatch_tag_size = dtb_size;
- bestmatch_soc_rev_id = dtb_soc_rev_id;
- }
- }
+ dev_tree_compatible(dtb, dtb_size, dt_entry_queue);
/* goto the next device tree if any */
dtb += dtb_size;
}
+ best_match_dt_entry = platform_dt_match_best(dt_entry_queue);
+ if (best_match_dt_entry){
+ bestmatch_tag = (void *)best_match_dt_entry->offset;
+ bestmatch_tag_size = best_match_dt_entry->size;
+ dprintf(INFO, "Best match DTB tags %u/%08x/0x%08x/%x/%x/%x/%x/%x/%x/%x\n",
+ best_match_dt_entry->platform_id, best_match_dt_entry->variant_id,
+ best_match_dt_entry->board_hw_subtype, best_match_dt_entry->soc_rev,
+ best_match_dt_entry->pmic_rev[0], best_match_dt_entry->pmic_rev[1],
+ best_match_dt_entry->pmic_rev[2], best_match_dt_entry->pmic_rev[3],
+ best_match_dt_entry->offset, best_match_dt_entry->size);
+ dprintf(INFO, "Using pmic info 0x%0x/0x%x/0x%x/0x%0x for device 0x%0x/0x%x/0x%x/0x%0x\n",
+ best_match_dt_entry->pmic_rev[0], best_match_dt_entry->pmic_rev[1],
+ best_match_dt_entry->pmic_rev[2], best_match_dt_entry->pmic_rev[3],
+ board_pmic_target(0), board_pmic_target(1),
+ board_pmic_target(2), board_pmic_target(3));
+ }
+ /* free queue's memory */
+ list_for_every_entry(&dt_entry_queue->node, dt_node_tmp1, dt_node, node) {
+ dt_node_tmp2 = dt_node_tmp1->node.prev;
+ dt_entry_list_delete(dt_node_tmp1);
+ dt_node_tmp1 = dt_node_tmp2;
+ }
+
if(bestmatch_tag) {
- dprintf(INFO,"DTB found with bestmatch soc rev id 0x%x.Board soc rev id 0x%x\n",
- bestmatch_soc_rev_id, board_soc_version());
memcpy(tags, bestmatch_tag, bestmatch_tag_size);
/* clear out the old DTB magic so kernel doesn't find it */
*((uint32_t *)(kernel + app_dtb_offset)) = 0;
@@ -425,6 +516,8 @@
if (table->version == DEV_TREE_VERSION_V1) {
dt_entry_size = sizeof(struct dt_entry_v1);
} else if (table->version == DEV_TREE_VERSION_V2) {
+ dt_entry_size = sizeof(struct dt_entry_v2);
+ } else if (table->version == DEV_TREE_VERSION_V3) {
dt_entry_size = sizeof(struct dt_entry);
} else {
dprintf(CRITICAL, "ERROR: Unsupported version (%d) in DT table \n",
@@ -445,64 +538,350 @@
return 0;
}
-static int platform_dt_match(struct dt_entry *cur_dt_entry, struct board_dt_entry *board_dt_data, uint32_t subtype_mask)
+static int platform_dt_absolute_match(struct dt_entry *cur_dt_entry, struct dt_entry_node *dt_list)
{
- /*
- * 1. Check if cur_dt_entry has platform_hw_version major & minor present?
- * 2. If present, calculate cur_dt_target_id for the current platform as:
- * 3. bit no |31 24 | 23 16| 15 8 |7 0|
- * 4. |subtype| major | minor |hw_platform|
- */
- uint32_t cur_dt_target_id ;
uint32_t cur_dt_hlos_subtype;
+ uint32_t cur_dt_hw_platform;
+ uint32_t cur_dt_hw_subtype;
+ uint32_t cur_dt_msm_id;
+ dt_node *dt_node_tmp = NULL;
- /*
- * if variant_id has platform_hw_ver has major = 0xff and minor = 0xff,
- * ignore the major & minor versions from the DTB entry
- */
- if ((cur_dt_entry->variant_id & 0xffff00) == 0xffff00)
- cur_dt_target_id = (cur_dt_entry->variant_id & 0xff0000ff) | (board_dt_data->target_variant_id & 0xffff00);
- /*
- * We have a valid platform_hw_version major & minor numbers in the board-id, so
- * use the board-id from the DTB.
- * Note: For some QRD platforms the format used is qcom, board-id = <0xMVmVPT 0xPS>
- * where: MV: platform major ver, mV: platform minor ver, PT: platform type
- * PS: platform subtype, so we need to put PS @ bit 24-31 to be backward compatible.
- */
- else
- cur_dt_target_id = cur_dt_entry->variant_id | ((cur_dt_entry->board_hw_subtype & subtype_mask & 0xff) << 24);
+ /* Platform-id
+ * bit no |31 24|23 16|15 0|
+ * |reserved|foundry-id|msm-id|
+ */
+ cur_dt_msm_id = (cur_dt_entry->platform_id & 0x0000ffff);
+ cur_dt_hw_platform = (cur_dt_entry->variant_id & 0x000000ff);
+ cur_dt_hw_subtype = (cur_dt_entry->board_hw_subtype);
+
+
/* Determine the bits 23:8 to check the DT with the DDR Size */
cur_dt_hlos_subtype = (cur_dt_entry->board_hw_subtype & 0xffff00);
- /* 1. must match the platform_id, platform_hw_id, platform_version
- * 2. soc rev number equal then return 0
- * 3. dt soc rev number less than cdt return -1
- * 4. otherwise return 1
+ /* 1. must match the msm_id, platform_hw_id, platform_subtype and DDR size
+ * soc, board major/minor, pmic major/minor must less than board info
+ * 2. find the matched DTB then return 1
+ * 3. otherwise return 0
*/
+ if((cur_dt_msm_id == (board_platform_id() & 0x0000ffff)) &&
+ (cur_dt_hw_platform == board_hardware_id()) &&
+ (cur_dt_hw_subtype == board_hardware_subtype()) &&
+ (cur_dt_hlos_subtype == target_get_hlos_subtype()) &&
+ (cur_dt_entry->soc_rev <= board_soc_version()) &&
+ ((cur_dt_entry->variant_id & 0x00ffff00) <= (board_target_id() & 0x00ffff00)) &&
+ ((cur_dt_entry->pmic_rev[0] & 0x00ffff00) <= (board_pmic_target(0) & 0x00ffff00)) &&
+ ((cur_dt_entry->pmic_rev[1] & 0x00ffff00) <= (board_pmic_target(1) & 0x00ffff00)) &&
+ ((cur_dt_entry->pmic_rev[2] & 0x00ffff00) <= (board_pmic_target(2) & 0x00ffff00)) &&
+ ((cur_dt_entry->pmic_rev[3] & 0x00ffff00) <= (board_pmic_target(3) & 0x00ffff00))) {
- if((cur_dt_entry->platform_id == board_dt_data->platform_variant_id) &&
- (cur_dt_target_id == board_dt_data->target_variant_id) &&
- (cur_dt_hlos_subtype == target_get_hlos_subtype())) {
- if(cur_dt_entry->soc_rev == board_soc_version()) {
+ dt_node_tmp = dt_entry_list_init();
+ memcpy((char*)dt_node_tmp->dt_entry_m,(char*)cur_dt_entry, sizeof(struct dt_entry));
+
+ dprintf(SPEW, "Add DTB entry %u/%08x/0x%08x/%x/%x/%x/%x/%x/%x/%x\n",
+ dt_node_tmp->dt_entry_m->platform_id, dt_node_tmp->dt_entry_m->variant_id,
+ dt_node_tmp->dt_entry_m->board_hw_subtype, dt_node_tmp->dt_entry_m->soc_rev,
+ dt_node_tmp->dt_entry_m->pmic_rev[0], dt_node_tmp->dt_entry_m->pmic_rev[1],
+ dt_node_tmp->dt_entry_m->pmic_rev[2], dt_node_tmp->dt_entry_m->pmic_rev[3],
+ dt_node_tmp->dt_entry_m->offset, dt_node_tmp->dt_entry_m->size);
+
+ insert_dt_entry_in_queue(dt_list, dt_node_tmp);
+ return 1;
+ }
+ return 0;
+}
+
+static int platform_dt_absolute_compat_match(struct dt_entry_node *dt_list, uint32_t dtb_info) {
+ struct dt_entry_node *dt_node_tmp1 = NULL;
+ struct dt_entry_node *dt_node_tmp2 = NULL;
+ uint32_t current_info = 0;
+ uint32_t board_info = 0;
+ uint32_t best_info = 0;
+ uint32_t current_pmic_model[4] = {0, 0, 0, 0};
+ uint32_t board_pmic_model[4] = {0, 0, 0, 0};
+ uint32_t best_pmic_model[4] = {0, 0, 0, 0};
+ uint32_t delete_current_dt = 0;
+ uint32_t i;
+
+ /* start to select the exact entry
+ * default to exact match 0, if find current DTB entry info is the same as board info,
+ * then exact match board info.
+ */
+ list_for_every_entry(&dt_list->node, dt_node_tmp1, dt_node, node) {
+ if (!dt_node_tmp1){
+ dprintf(SPEW, "Current node is the end\n");
+ break;
+ }
+ switch(dtb_info) {
+ case DTB_FOUNDRY:
+ current_info = ((dt_node_tmp1->dt_entry_m->platform_id) & 0x00ff0000);
+ board_info = board_foundry_id();
+ break;
+ case DTB_PMIC_MODEL:
+ for (i = 0; i < 4; i++) {
+ current_pmic_model[i] = (dt_node_tmp1->dt_entry_m->pmic_rev[i] & 0xff);
+ board_pmic_model[i] = (board_pmic_target(i) & 0xff);
+ }
+ break;
+ default:
+ dprintf(CRITICAL, "ERROR: Unsupported version (%d) in dt node check \n",
+ dtb_info);
return 0;
- } else if(cur_dt_entry->soc_rev < board_soc_version()) {
- return -1;
+ }
+
+ if (dtb_info == DTB_PMIC_MODEL) {
+ if ((current_pmic_model[0] == board_pmic_model[0]) &&
+ (current_pmic_model[1] == board_pmic_model[1]) &&
+ (current_pmic_model[2] == board_pmic_model[2]) &&
+ (current_pmic_model[3] == board_pmic_model[3])) {
+
+ for (i = 0; i < 4; i++) {
+ best_pmic_model[i] = current_pmic_model[i];
+ }
+ break;
+ }
+ } else {
+ if (current_info == board_info) {
+ best_info = current_info;
+ break;
+ }
+ }
+ }
+
+ list_for_every_entry(&dt_list->node, dt_node_tmp1, dt_node, node) {
+ if (!dt_node_tmp1){
+ dprintf(SPEW, "Current node is the end\n");
+ break;
+ }
+ switch(dtb_info) {
+ case DTB_FOUNDRY:
+ current_info = ((dt_node_tmp1->dt_entry_m->platform_id) & 0x00ff0000);
+ break;
+ case DTB_PMIC_MODEL:
+ for (i = 0; i < 4; i++) {
+ current_pmic_model[i] = (dt_node_tmp1->dt_entry_m->pmic_rev[i] & 0xff);
+ }
+ break;
+ default:
+ dprintf(CRITICAL, "ERROR: Unsupported version (%d) in dt node check \n",
+ dtb_info);
+ return 0;
+ }
+
+ if (dtb_info == DTB_PMIC_MODEL) {
+ if ((current_pmic_model[0] != best_pmic_model[0]) ||
+ (current_pmic_model[1] != best_pmic_model[1]) ||
+ (current_pmic_model[2] != best_pmic_model[2]) ||
+ (current_pmic_model[3] != best_pmic_model[3])) {
+
+ delete_current_dt = 1;
+ }
+ } else {
+ if (current_info != best_info) {
+ delete_current_dt = 1;
+ }
+ }
+
+ if (delete_current_dt) {
+ dprintf(SPEW, "Delete don't fit DTB entry %u/%08x/0x%08x/%x/%x/%x/%x/%x/%x/%x\n",
+ dt_node_tmp1->dt_entry_m->platform_id, dt_node_tmp1->dt_entry_m->variant_id,
+ dt_node_tmp1->dt_entry_m->board_hw_subtype, dt_node_tmp1->dt_entry_m->soc_rev,
+ dt_node_tmp1->dt_entry_m->pmic_rev[0], dt_node_tmp1->dt_entry_m->pmic_rev[1],
+ dt_node_tmp1->dt_entry_m->pmic_rev[2], dt_node_tmp1->dt_entry_m->pmic_rev[3],
+ dt_node_tmp1->dt_entry_m->offset, dt_node_tmp1->dt_entry_m->size);
+
+ dt_node_tmp2 = dt_node_tmp1->node.prev;
+ dt_entry_list_delete(dt_node_tmp1);
+ dt_node_tmp1 = dt_node_tmp2;
+ delete_current_dt = 0;
}
}
return 1;
}
-static int __dev_tree_get_entry_info(struct dt_table *table, struct dt_entry *dt_entry_info,
- struct board_dt_entry *board_dt_data, uint32_t subtype_mask)
+static int update_dtb_entry_node(struct dt_entry_node *dt_list, uint32_t dtb_info) {
+ struct dt_entry_node *dt_node_tmp1 = NULL;
+ struct dt_entry_node *dt_node_tmp2 = NULL;
+ uint32_t current_info = 0;
+ uint32_t board_info = 0;
+ uint32_t best_info = 0;
+
+ /* start to select the best entry*/
+ list_for_every_entry(&dt_list->node, dt_node_tmp1, dt_node, node) {
+ if (!dt_node_tmp1){
+ dprintf(SPEW, "Current node is the end\n");
+ break;
+ }
+ switch(dtb_info) {
+ case DTB_SOC:
+ current_info = dt_node_tmp1->dt_entry_m->soc_rev;
+ board_info = board_soc_version();
+ break;
+ case DTB_MAJOR_MINOR:
+ current_info = ((dt_node_tmp1->dt_entry_m->variant_id) & 0x00ffff00);
+ board_info = (board_target_id() & 0x00ffff00);
+ break;
+ case DTB_PMIC0:
+ current_info = ((dt_node_tmp1->dt_entry_m->pmic_rev[0]) & 0x00ffff00);
+ board_info = (board_pmic_target(0) & 0x00ffff00);
+ break;
+ case DTB_PMIC1:
+ current_info = ((dt_node_tmp1->dt_entry_m->pmic_rev[1]) & 0x00ffff00);
+ board_info = (board_pmic_target(1) & 0x00ffff00);
+ break;
+ case DTB_PMIC2:
+ current_info = ((dt_node_tmp1->dt_entry_m->pmic_rev[2]) & 0x00ffff00);
+ board_info = (board_pmic_target(2) & 0x00ffff00);
+ break;
+ case DTB_PMIC3:
+ current_info = ((dt_node_tmp1->dt_entry_m->pmic_rev[3]) & 0x00ffff00);
+ board_info = (board_pmic_target(3) & 0x00ffff00);
+ break;
+ default:
+ dprintf(CRITICAL, "ERROR: Unsupported version (%d) in dt node check \n",
+ dtb_info);
+ return 0;
+ }
+
+ if (current_info == board_info) {
+ best_info = current_info;
+ break;
+ }
+ if ((current_info < board_info) && (current_info > best_info)) {
+ best_info = current_info;
+ }
+ if (current_info < best_info) {
+ dprintf(SPEW, "Delete don't fit DTB entry %u/%08x/0x%08x/%x/%x/%x/%x/%x/%x/%x\n",
+ dt_node_tmp1->dt_entry_m->platform_id, dt_node_tmp1->dt_entry_m->variant_id,
+ dt_node_tmp1->dt_entry_m->board_hw_subtype, dt_node_tmp1->dt_entry_m->soc_rev,
+ dt_node_tmp1->dt_entry_m->pmic_rev[0], dt_node_tmp1->dt_entry_m->pmic_rev[1],
+ dt_node_tmp1->dt_entry_m->pmic_rev[2], dt_node_tmp1->dt_entry_m->pmic_rev[3],
+ dt_node_tmp1->dt_entry_m->offset, dt_node_tmp1->dt_entry_m->size);
+
+ dt_node_tmp2 = dt_node_tmp1->node.prev;
+ dt_entry_list_delete(dt_node_tmp1);
+ dt_node_tmp1 = dt_node_tmp2;
+ }
+ }
+
+ list_for_every_entry(&dt_list->node, dt_node_tmp1, dt_node, node) {
+ if (!dt_node_tmp1){
+ dprintf(SPEW, "Current node is the end\n");
+ break;
+ }
+ switch(dtb_info) {
+ case DTB_SOC:
+ current_info = dt_node_tmp1->dt_entry_m->soc_rev;
+ break;
+ case DTB_MAJOR_MINOR:
+ current_info = ((dt_node_tmp1->dt_entry_m->variant_id) & 0x00ffff00);
+ break;
+ case DTB_PMIC0:
+ current_info = ((dt_node_tmp1->dt_entry_m->pmic_rev[0]) & 0x00ffff00);
+ break;
+ case DTB_PMIC1:
+ current_info = ((dt_node_tmp1->dt_entry_m->pmic_rev[1]) & 0x00ffff00);
+ break;
+ case DTB_PMIC2:
+ current_info = ((dt_node_tmp1->dt_entry_m->pmic_rev[2]) & 0x00ffff00);
+ break;
+ case DTB_PMIC3:
+ current_info = ((dt_node_tmp1->dt_entry_m->pmic_rev[3]) & 0x00ffff00);
+ break;
+ default:
+ dprintf(CRITICAL, "ERROR: Unsupported version (%d) in dt node check \n",
+ dtb_info);
+ return 0;
+ }
+
+ if (current_info != best_info) {
+ dprintf(SPEW, "Delete don't fit DTB entry %u/%08x/0x%08x/%x/%x/%x/%x/%x/%x/%x\n",
+ dt_node_tmp1->dt_entry_m->platform_id, dt_node_tmp1->dt_entry_m->variant_id,
+ dt_node_tmp1->dt_entry_m->board_hw_subtype, dt_node_tmp1->dt_entry_m->soc_rev,
+ dt_node_tmp1->dt_entry_m->pmic_rev[0], dt_node_tmp1->dt_entry_m->pmic_rev[1],
+ dt_node_tmp1->dt_entry_m->pmic_rev[2], dt_node_tmp1->dt_entry_m->pmic_rev[3],
+ dt_node_tmp1->dt_entry_m->offset, dt_node_tmp1->dt_entry_m->size);
+
+ dt_node_tmp2 = dt_node_tmp1->node.prev;
+ dt_entry_list_delete(dt_node_tmp1);
+ dt_node_tmp1 = dt_node_tmp2;
+ }
+ }
+ return 1;
+}
+
+static struct dt_entry *platform_dt_match_best(struct dt_entry_node *dt_list)
+{
+ struct dt_entry_node *dt_node_tmp1 = NULL;
+
+ /* check Foundry id
+ * the foundry id must exact match board founddry id, this is compatibility check,
+ * if couldn't find the exact match from DTB, will exact match 0x0.
+ */
+ if (!platform_dt_absolute_compat_match(dt_list, DTB_FOUNDRY))
+ return NULL;
+
+ /* check PMIC model
+ * the PMIC model must exact match board PMIC model, this is compatibility check,
+ * if couldn't find the exact match from DTB, will exact match 0x0.
+ */
+ if (!platform_dt_absolute_compat_match(dt_list, DTB_PMIC_MODEL))
+ return NULL;
+
+ /* check soc version
+ * the suitable soc version must less than or equal to board soc version
+ */
+ if (!update_dtb_entry_node(dt_list, DTB_SOC))
+ return NULL;
+
+ /*check major and minor version
+ * the suitable major&minor version must less than or equal to board major&minor version
+ */
+ if (!update_dtb_entry_node(dt_list, DTB_MAJOR_MINOR))
+ return NULL;
+
+ /*check pmic info
+ * the suitable pmic major&minor info must less than or equal to board pmic major&minor version
+ */
+ if (!update_dtb_entry_node(dt_list, DTB_PMIC0))
+ return NULL;
+ if (!update_dtb_entry_node(dt_list, DTB_PMIC1))
+ return NULL;
+ if (!update_dtb_entry_node(dt_list, DTB_PMIC2))
+ return NULL;
+ if (!update_dtb_entry_node(dt_list, DTB_PMIC3))
+ return NULL;
+
+ list_for_every_entry(&dt_list->node, dt_node_tmp1, dt_node, node) {
+ if (!dt_node_tmp1) {
+ dprintf(CRITICAL, "ERROR: Couldn't find the suitable DTB!\n");
+ return NULL;
+ }
+ if (dt_node_tmp1->dt_entry_m)
+ return dt_node_tmp1->dt_entry_m;
+ }
+
+ return NULL;
+}
+
+/* Function to obtain the index information for the correct device tree
+ * based on the platform data.
+ * If a matching device tree is found, the information is returned in the
+ * "dt_entry_info" out parameter and a function value of 0 is returned, otherwise
+ * a non-zero function value is returned.
+ */
+int dev_tree_get_entry_info(struct dt_table *table, struct dt_entry *dt_entry_info)
{
uint32_t i;
- unsigned char *table_ptr;
+ unsigned char *table_ptr = NULL;
struct dt_entry dt_entry_buf_1;
- struct dt_entry dt_entry_buf_2;
- struct dt_entry *cur_dt_entry;
- struct dt_entry *best_match_dt_entry;
- struct dt_entry_v1 *dt_entry_v1;
+ struct dt_entry *cur_dt_entry = NULL;
+ struct dt_entry *best_match_dt_entry = NULL;
+ struct dt_entry_v1 *dt_entry_v1 = NULL;
+ struct dt_entry_v2 *dt_entry_v2 = NULL;
+ struct dt_entry_node *dt_entry_queue = NULL;
+ struct dt_entry_node *dt_node_tmp1 = NULL;
+ struct dt_entry_node *dt_node_tmp2 = NULL;
uint32_t found = 0;
if (!dt_entry_info) {
@@ -514,7 +893,16 @@
table_ptr = (unsigned char *)table + DEV_TREE_HEADER_SIZE;
cur_dt_entry = &dt_entry_buf_1;
best_match_dt_entry = NULL;
+ dt_entry_queue = (struct dt_entry_node *)
+ malloc(sizeof(struct dt_entry_node));
+ if (!dt_entry_queue) {
+ dprintf(CRITICAL, "Out of memory\n");
+ return -1;
+ }
+
+ list_initialize(&dt_entry_queue->node);
+ dprintf(INFO, "DTB Total entry: %d, DTB version: %d\n", table->num_entries, table->version);
for(i = 0; found == 0 && i < table->num_entries; i++)
{
memset(cur_dt_entry, 0, sizeof(struct dt_entry));
@@ -524,48 +912,74 @@
cur_dt_entry->platform_id = dt_entry_v1->platform_id;
cur_dt_entry->variant_id = dt_entry_v1->variant_id;
cur_dt_entry->soc_rev = dt_entry_v1->soc_rev;
- cur_dt_entry->board_hw_subtype = board_hardware_subtype();
+ cur_dt_entry->board_hw_subtype = (dt_entry_v1->variant_id >> 0x18);
+ cur_dt_entry->pmic_rev[0] = board_pmic_target(0);
+ cur_dt_entry->pmic_rev[1] = board_pmic_target(1);
+ cur_dt_entry->pmic_rev[2] = board_pmic_target(2);
+ cur_dt_entry->pmic_rev[3] = board_pmic_target(3);
cur_dt_entry->offset = dt_entry_v1->offset;
cur_dt_entry->size = dt_entry_v1->size;
table_ptr += sizeof(struct dt_entry_v1);
break;
case DEV_TREE_VERSION_V2:
+ dt_entry_v2 = (struct dt_entry_v2*)table_ptr;
+ cur_dt_entry->platform_id = dt_entry_v2->platform_id;
+ cur_dt_entry->variant_id = dt_entry_v2->variant_id;
+ cur_dt_entry->soc_rev = dt_entry_v2->soc_rev;
+ /* For V2 version of DTBs we have platform version field as part
+ * of variant ID, in such case the subtype will be mentioned as 0x0
+ * As the qcom, board-id = <0xSSPMPmPH, 0x0>
+ * SS -- Subtype
+ * PM -- Platform major version
+ * Pm -- Platform minor version
+ * PH -- Platform hardware CDP/MTP
+ * In such case to make it compatible with LK algorithm move the subtype
+ * from variant_id to subtype field
+ */
+ if (dt_entry_v2->board_hw_subtype == 0)
+ cur_dt_entry->board_hw_subtype = (cur_dt_entry->variant_id >> 0x18);
+ else
+ cur_dt_entry->board_hw_subtype = dt_entry_v2->board_hw_subtype;
+ cur_dt_entry->pmic_rev[0] = board_pmic_target(0);
+ cur_dt_entry->pmic_rev[1] = board_pmic_target(1);
+ cur_dt_entry->pmic_rev[2] = board_pmic_target(2);
+ cur_dt_entry->pmic_rev[3] = board_pmic_target(3);
+ cur_dt_entry->offset = dt_entry_v2->offset;
+ cur_dt_entry->size = dt_entry_v2->size;
+ table_ptr += sizeof(struct dt_entry_v2);
+ break;
+ case DEV_TREE_VERSION_V3:
memcpy(cur_dt_entry, (struct dt_entry *)table_ptr,
sizeof(struct dt_entry));
+ /* For V3 version of DTBs we have platform version field as part
+ * of variant ID, in such case the subtype will be mentioned as 0x0
+ * As the qcom, board-id = <0xSSPMPmPH, 0x0>
+ * SS -- Subtype
+ * PM -- Platform major version
+ * Pm -- Platform minor version
+ * PH -- Platform hardware CDP/MTP
+ * In such case to make it compatible with LK algorithm move the subtype
+ * from variant_id to subtype field
+ */
+ if (cur_dt_entry->board_hw_subtype == 0)
+ cur_dt_entry->board_hw_subtype = (cur_dt_entry->variant_id >> 0x18);
+
table_ptr += sizeof(struct dt_entry);
break;
default:
dprintf(CRITICAL, "ERROR: Unsupported version (%d) in DT table \n",
table->version);
+ free(dt_entry_queue);
return -1;
}
- /* DTBs are stored in the ascending order of soc revision.
- * For eg: Rev0..Rev1..Rev2 & so on.
- * we pickup the DTB with highest soc rev number which is less
- * than or equal to actual hardware
- */
- switch(platform_dt_match(cur_dt_entry, board_dt_data, subtype_mask)) {
- case 0:
- best_match_dt_entry = cur_dt_entry;
- found = 1;
- break;
- case -1:
- if (!best_match_dt_entry) {
- /* copy structure */
- best_match_dt_entry = cur_dt_entry;
- cur_dt_entry = &dt_entry_buf_2;
- } else {
- /* Swap dt_entry buffers */
- struct dt_entry *temp = cur_dt_entry;
- cur_dt_entry = best_match_dt_entry;
- best_match_dt_entry = temp;
- }
- default:
- break;
- }
- }
+ /* DTBs must match the platform_id, platform_hw_id, platform_subtype and DDR size.
+ * The satisfactory DTBs are stored in dt_entry_queue
+ */
+ platform_dt_absolute_match(cur_dt_entry, dt_entry_queue);
+ }
+ best_match_dt_entry = platform_dt_match_best(dt_entry_queue);
if (best_match_dt_entry) {
*dt_entry_info = *best_match_dt_entry;
found = 1;
@@ -575,71 +989,37 @@
dprintf(INFO, "Using DTB entry 0x%08x/%08x/0x%08x/%u for device 0x%08x/%08x/0x%08x/%u\n",
dt_entry_info->platform_id, dt_entry_info->soc_rev,
dt_entry_info->variant_id, dt_entry_info->board_hw_subtype,
- board_dt_data->platform_variant_id, board_soc_version(),
- board_dt_data->target_variant_id, board_hardware_subtype());
+ board_platform_id(), board_soc_version(),
+ board_target_id(), board_hardware_subtype());
+ if (dt_entry_info->pmic_rev[0] == 0 && dt_entry_info->pmic_rev[0] == 0 &&
+ dt_entry_info->pmic_rev[0] == 0 && dt_entry_info->pmic_rev[0] == 0) {
+ dprintf(SPEW, "No maintain pmic info in DTB, device pmic info is 0x%0x/0x%x/0x%x/0x%0x\n",
+ board_pmic_target(0), board_pmic_target(1),
+ board_pmic_target(2), board_pmic_target(3));
+ } else {
+ dprintf(INFO, "Using pmic info 0x%0x/0x%x/0x%x/0x%0x for device 0x%0x/0x%x/0x%x/0x%0x\n",
+ dt_entry_info->pmic_rev[0], dt_entry_info->pmic_rev[1],
+ dt_entry_info->pmic_rev[2], dt_entry_info->pmic_rev[3],
+ board_pmic_target(0), board_pmic_target(1),
+ board_pmic_target(2), board_pmic_target(3));
+ }
return 0;
}
- dprintf(CRITICAL, "INFO: Unable to find suitable device tree for device (0x%08x/0x%08x/0x%08x/%u)\n",
- board_dt_data->platform_variant_id, board_soc_version(),
- board_dt_data->target_variant_id, board_hardware_subtype());
+ dprintf(CRITICAL, "ERROR: Unable to find suitable device tree for device (%u/0x%08x/0x%08x/%u)\n",
+ board_platform_id(), board_soc_version(),
+ board_target_id(), board_hardware_subtype());
+
+ list_for_every_entry(&dt_entry_queue->node, dt_node_tmp1, dt_node, node) {
+ /* free node memory */
+ dt_node_tmp2 = dt_node_tmp1->node.prev;
+ dt_entry_list_delete(dt_node_tmp1);
+ dt_node_tmp1 = dt_node_tmp2;
+ }
+ free(dt_entry_queue);
return -1;
}
-/* Function to obtain the index information for the correct device tree
- * based on the platform data.
- * If a matching device tree is found, the information is returned in the
- * "dt_entry_info" out parameter and a function value of 0 is returned, otherwise
- * a non-zero function value is returned.
- */
-int dev_tree_get_entry_info(struct dt_table *table, struct dt_entry *dt_entry_info)
-{
- struct board_dt_entry board_dt_data;
-
- /* 1. Look for new board-id (platform version + hw + subtype) & new msm-id (soc ver + soc id + foundry-id) */
- board_dt_data.target_variant_id = board_target_id();
- /* Platform-id
- * bit no |31 24|23 16|15 0|
- * |reserved|foundry-id|msm-id|
- */
- board_dt_data.platform_variant_id = board_platform_id() | (board_foundry_id() << 16);
- if (__dev_tree_get_entry_info(table, dt_entry_info, &board_dt_data, 0xff) == 0) {
- return 0;
- }
-
- /* 2. Look for new board-id & old msm-id (no foundry-id) */
- board_dt_data.target_variant_id = board_target_id();
- board_dt_data.platform_variant_id = board_platform_id();
- if (__dev_tree_get_entry_info(table, dt_entry_info, &board_dt_data, 0xff) == 0) {
- return 0;
- }
-
- /*
- * for compatible with version 1 and version 2 dtbtool
- * will compare the subtype inside the variant id
- */
-
- /* 3. Look for old board-id (no platform version) & new msm-id (with foundry-id) */
- board_dt_data.target_variant_id = board_hardware_id() | ((board_hardware_subtype() & 0xff) << 24);
- board_dt_data.platform_variant_id = board_platform_id() | (board_foundry_id() << 16);
- if (__dev_tree_get_entry_info(table, dt_entry_info, &board_dt_data, 0xff) == 0) {
- return 0;
- }
- /* 4. Look for old board-id (no platform versions) & old msm-id(no foundry-id) */
- board_dt_data.target_variant_id = board_hardware_id() | ((board_hardware_subtype() & 0xff) << 24);
- board_dt_data.platform_variant_id = board_platform_id();
- if (__dev_tree_get_entry_info(table, dt_entry_info, &board_dt_data, 0xff) == 0) {
- return 0;
- }
-
- /*
- * add compatible with old device selection method which don't compare subtype
- */
- board_dt_data.target_variant_id = board_hardware_id();
- board_dt_data.platform_variant_id = board_platform_id();
- return __dev_tree_get_entry_info(table, dt_entry_info, &board_dt_data, 0);
-}
-
/* Function to add the first RAM partition info to the device tree.
* Note: The function replaces the reg property in the "/memory" node
* with the addr and size provided.
diff --git a/platform/msm_shared/display.c b/platform/msm_shared/display.c
index c73b06f..849b294 100644
--- a/platform/msm_shared/display.c
+++ b/platform/msm_shared/display.c
@@ -33,23 +33,6 @@
#include <mipi_dsi.h>
#include <boot_stats.h>
-#ifndef DISPLAY_TYPE_HDMI
-static int hdmi_dtv_init(void)
-{
- return 0;
-}
-
-static int hdmi_dtv_on(void)
-{
- return 0;
-}
-
-static int hdmi_msm_turn_on(void)
-{
- return 0;
-}
-#endif
-
static struct msm_fb_panel_data *panel;
extern int lvds_on(struct msm_fb_panel_data *pdata);
@@ -132,7 +115,7 @@
break;
case HDMI_PANEL:
dprintf(INFO, "Config HDMI PANEL.\n");
- ret = hdmi_dtv_init();
+ ret = mdss_hdmi_config(pinfo, &(panel->fb));
if (ret)
goto msm_display_config_out;
break;
@@ -211,11 +194,11 @@
break;
case HDMI_PANEL:
dprintf(INFO, "Turn on HDMI PANEL.\n");
- ret = hdmi_dtv_on();
+ ret = mdss_hdmi_init();
if (ret)
goto msm_display_on_out;
- ret = hdmi_msm_turn_on();
+ ret = mdss_hdmi_on();
if (ret)
goto msm_display_on_out;
break;
@@ -248,7 +231,7 @@
/* Turn on panel */
if (pdata->power_func)
- ret = pdata->power_func(1);
+ ret = pdata->power_func(1, &(panel->panel_info));
if (ret)
goto msm_display_init_out;
@@ -390,7 +373,7 @@
/* Disable panel */
if (panel->power_func)
- ret = panel->power_func(0);
+ ret = panel->power_func(0, pinfo);
msm_display_off_out:
return ret;
diff --git a/platform/msm_shared/gpio.c b/platform/msm_shared/gpio.c
index 137f00a..eb569dd 100644
--- a/platform/msm_shared/gpio.c
+++ b/platform/msm_shared/gpio.c
@@ -1,4 +1,4 @@
-/* Copyright (c) 2013, The Linux Foundation. All rights reserved.
+/* Copyright (c) 2013-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
@@ -36,13 +36,20 @@
{
uint32_t reg_val;
- reg_val = readl(SDC1_HDRV_PULL_CTL);
+ /* To support backward compatibility for this API
+ * If the reg is not passed then use SDC1 TLMM as
+ * the default value.
+ */
+ if (!cfg->reg)
+ cfg->reg = SDC1_HDRV_PULL_CTL;
+
+ reg_val = readl(cfg->reg);
reg_val &= ~(cfg->mask << cfg->off);
reg_val |= (cfg->val << cfg->off);
- writel(reg_val, SDC1_HDRV_PULL_CTL);
+ writel(reg_val, cfg->reg);
}
void tlmm_set_hdrive_ctrl(struct tlmm_cfgs *hdrv_cfgs, uint8_t sz)
diff --git a/platform/msm_shared/hdmi.c b/platform/msm_shared/hdmi.c
deleted file mode 100644
index 422a506..0000000
--- a/platform/msm_shared/hdmi.c
+++ /dev/null
@@ -1,454 +0,0 @@
-/* Copyright (c) 2010-2013, 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 "AS IS" AND ANY EXPRESS OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
- * 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 <hdmi.h>
-#include <msm_panel.h>
-#include <platform/timer.h>
-#include <platform/clock.h>
-#include <platform/iomap.h>
-
-#define MDP4_OVERLAYPROC1_BASE 0x18000
-#define MDP4_RGB_BASE 0x40000
-#define MDP4_RGB_OFF 0x10000
-
-struct hdmi_disp_mode_timing_type hdmi_timing_default = {
- .height = 1080,
- .hsync_porch_fp = 88,
- .hsync_width = 44,
- .hsync_porch_bp = 148,
- .width = 1920,
- .vsync_porch_fp = 4,
- .vsync_width = 5,
- .vsync_porch_bp = 36,
- .bpp = 24,
-};
-
-static uint8_t hdmi_msm_avi_iframe_lut[][16] = {
-/* 480p60 480i60 576p50 576i50 720p60 720p50 1080p60 1080i60 1080p50
- 1080i50 1080p24 1080p30 1080p25 640x480p 480p60_16_9 576p50_4_3 */
- {0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10,
- 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10}, /*00*/
- {0x18, 0x18, 0x28, 0x28, 0x28, 0x28, 0x28, 0x28, 0x28,
- 0x28, 0x28, 0x28, 0x28, 0x18, 0x28, 0x18}, /*01*/
- {0x00, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04,
- 0x04, 0x04, 0x04, 0x04, 0x88, 0x00, 0x04}, /*02*/
- {0x02, 0x06, 0x11, 0x15, 0x04, 0x13, 0x10, 0x05, 0x1F,
- 0x14, 0x20, 0x22, 0x21, 0x01, 0x03, 0x11}, /*03*/
- {0x00, 0x01, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*04*/
- {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*05*/
- {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*06*/
- {0xE1, 0xE1, 0x41, 0x41, 0xD1, 0xd1, 0x39, 0x39, 0x39,
- 0x39, 0x39, 0x39, 0x39, 0xe1, 0xE1, 0x41}, /*07*/
- {0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x04, 0x04, 0x04,
- 0x04, 0x04, 0x04, 0x04, 0x01, 0x01, 0x02}, /*08*/
- {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*09*/
- {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*10*/
- {0xD1, 0xD1, 0xD1, 0xD1, 0x01, 0x01, 0x81, 0x81, 0x81,
- 0x81, 0x81, 0x81, 0x81, 0x81, 0xD1, 0xD1}, /*11*/
- {0x02, 0x02, 0x02, 0x02, 0x05, 0x05, 0x07, 0x07, 0x07,
- 0x07, 0x07, 0x07, 0x07, 0x02, 0x02, 0x02} /*12*/
-};
-
-void hdmi_msm_set_mode(int on)
-{
- uint32_t val = 0;
- if (on) {
- val |= 0x00000003;
- writel(val, HDMI_CTRL);
- } else {
- val &= ~0x00000002;
- writel(val, HDMI_CTRL);
- }
-}
-
-struct hdmi_disp_mode_timing_type *hdmi_common_init_panel_info()
-{
- return &hdmi_timing_default;
-}
-
-void hdmi_set_fb_addr(void *addr)
-{
- hdmi_timing_default.base = addr;
-}
-
-void hdmi_msm_panel_init(struct msm_panel_info *pinfo)
-{
- if (!pinfo)
- return;
-
- pinfo->xres = hdmi_timing_default.width;
- pinfo->yres = hdmi_timing_default.height;
- pinfo->bpp = hdmi_timing_default.bpp;
- pinfo->type = HDMI_PANEL;
-
- pinfo->hdmi.h_back_porch = hdmi_timing_default.hsync_porch_bp;
- pinfo->hdmi.h_front_porch = hdmi_timing_default.hsync_porch_fp;
- pinfo->hdmi.h_pulse_width = hdmi_timing_default.hsync_width;
- pinfo->hdmi.v_back_porch = hdmi_timing_default.vsync_porch_bp;
- pinfo->hdmi.v_front_porch = hdmi_timing_default.vsync_porch_fp;
- pinfo->hdmi.v_pulse_width = hdmi_timing_default.vsync_width;
-}
-
-void hdmi_frame_ctrl_reg()
-{
- uint32_t hdmi_frame_ctrl;
-
- hdmi_frame_ctrl = ((0 << 31) & 0x80000000);
- hdmi_frame_ctrl |= ((0 << 29) & 0x20000000);
- hdmi_frame_ctrl |= ((0 << 28) & 0x10000000);
- writel(hdmi_frame_ctrl, HDMI_FRAME_CTRL);
-}
-
-void hdmi_video_setup()
-{
- uint32_t hsync_total = 0;
- uint32_t vsync_total = 0;
- uint32_t hsync_start = 0;
- uint32_t hsync_end = 0;
- uint32_t vsync_start = 0;
- uint32_t vsync_end = 0;
- uint32_t hvsync_total = 0;
- uint32_t hsync_active = 0;
- uint32_t vsync_active = 0;
- uint32_t hdmi_frame_ctrl = 0;
- uint32_t val;
- struct hdmi_disp_mode_timing_type *hdmi_timing =
- hdmi_common_init_panel_info();
-
- hsync_total = hdmi_timing->width + hdmi_timing->hsync_porch_fp
- + hdmi_timing->hsync_porch_bp + hdmi_timing->hsync_width - 1;
- vsync_total = hdmi_timing->height + hdmi_timing->vsync_porch_fp
- + hdmi_timing->vsync_porch_bp + hdmi_timing->vsync_width - 1;
-
- hvsync_total = (vsync_total << 16) & 0x0FFF0000;
- hvsync_total |= (hsync_total << 0) & 0x00000FFF;
- writel(hvsync_total, HDMI_TOTAL);
-
- hsync_start = hdmi_timing->hsync_porch_bp + hdmi_timing->hsync_width;
- hsync_end = (hsync_total + 1) - hdmi_timing->hsync_porch_fp;
- hsync_active = (hsync_end << 16) & 0x0FFF0000;
- hsync_active |= (hsync_start << 0) & 0x00000FFF;
- writel(hsync_active, HDMI_ACTIVE_HSYNC);
-
- vsync_start =
- hdmi_timing->vsync_porch_bp + hdmi_timing->vsync_width - 1;
- vsync_end = vsync_total - hdmi_timing->vsync_porch_fp;
- vsync_active = (vsync_end << 16) & 0x0FFF0000;
- vsync_active |= (vsync_start << 0) & 0x00000FFF;
- writel(vsync_active, HDMI_ACTIVE_VSYNC);
-
- writel(0, HDMI_VSYNC_TOTAL_F2);
- writel(0, HDMI_VSYNC_ACTIVE_F2);
- hdmi_frame_ctrl_reg();
-}
-
-void hdmi_msm_avi_info_frame(void)
-{
- /* two header + length + 13 data */
- uint8_t aviInfoFrame[16];
- uint8_t checksum;
- uint32_t sum;
- uint32_t regVal;
- uint8_t i;
- uint8_t mode = 6; //HDMI_VFRMT_1920x1080p60_16_9
-
- /* InfoFrame Type = 82 */
- aviInfoFrame[0] = 0x82;
- /* Version = 2 */
- aviInfoFrame[1] = 2;
- /* Length of AVI InfoFrame = 13 */
- aviInfoFrame[2] = 13;
-
- /* Data Byte 01: 0 Y1 Y0 A0 B1 B0 S1 S0 */
- aviInfoFrame[3] = hdmi_msm_avi_iframe_lut[0][mode];
-
- /* Setting underscan bit */
- aviInfoFrame[3] |= 0x02;
-
- /* Data Byte 02: C1 C0 M1 M0 R3 R2 R1 R0 */
- aviInfoFrame[4] = hdmi_msm_avi_iframe_lut[1][mode];
- /* Data Byte 03: ITC EC2 EC1 EC0 Q1 Q0 SC1 SC0 */
- aviInfoFrame[5] = hdmi_msm_avi_iframe_lut[2][mode];
- /* Data Byte 04: 0 VIC6 VIC5 VIC4 VIC3 VIC2 VIC1 VIC0 */
- aviInfoFrame[6] = hdmi_msm_avi_iframe_lut[3][mode];
- /* Data Byte 05: 0 0 0 0 PR3 PR2 PR1 PR0 */
- aviInfoFrame[7] = hdmi_msm_avi_iframe_lut[4][mode];
- /* Data Byte 06: LSB Line No of End of Top Bar */
- aviInfoFrame[8] = hdmi_msm_avi_iframe_lut[5][mode];
- /* Data Byte 07: MSB Line No of End of Top Bar */
- aviInfoFrame[9] = hdmi_msm_avi_iframe_lut[6][mode];
- /* Data Byte 08: LSB Line No of Start of Bottom Bar */
- aviInfoFrame[10] = hdmi_msm_avi_iframe_lut[7][mode];
- /* Data Byte 09: MSB Line No of Start of Bottom Bar */
- aviInfoFrame[11] = hdmi_msm_avi_iframe_lut[8][mode];
- /* Data Byte 10: LSB Pixel Number of End of Left Bar */
- aviInfoFrame[12] = hdmi_msm_avi_iframe_lut[9][mode];
- /* Data Byte 11: MSB Pixel Number of End of Left Bar */
- aviInfoFrame[13] = hdmi_msm_avi_iframe_lut[10][mode];
- /* Data Byte 12: LSB Pixel Number of Start of Right Bar */
- aviInfoFrame[14] = hdmi_msm_avi_iframe_lut[11][mode];
- /* Data Byte 13: MSB Pixel Number of Start of Right Bar */
- aviInfoFrame[15] = hdmi_msm_avi_iframe_lut[12][mode];
-
- sum = 0;
- for (i = 0; i < 16; i++)
- sum += aviInfoFrame[i];
- sum &= 0xFF;
- sum = 256 - sum;
- checksum = (uint8_t) sum;
-
- regVal = aviInfoFrame[5];
- regVal = regVal << 8 | aviInfoFrame[4];
- regVal = regVal << 8 | aviInfoFrame[3];
- regVal = regVal << 8 | checksum;
- writel(regVal, MSM_HDMI_BASE + 0x006C);
-
- regVal = aviInfoFrame[9];
- regVal = regVal << 8 | aviInfoFrame[8];
- regVal = regVal << 8 | aviInfoFrame[7];
- regVal = regVal << 8 | aviInfoFrame[6];
- writel(regVal, MSM_HDMI_BASE + 0x0070);
-
- regVal = aviInfoFrame[13];
- regVal = regVal << 8 | aviInfoFrame[12];
- regVal = regVal << 8 | aviInfoFrame[11];
- regVal = regVal << 8 | aviInfoFrame[10];
- writel(regVal, MSM_HDMI_BASE + 0x0074);
-
- regVal = aviInfoFrame[1];
- regVal = regVal << 16 | aviInfoFrame[15];
- regVal = regVal << 8 | aviInfoFrame[14];
- writel(regVal, MSM_HDMI_BASE + 0x0078);
-
- /* INFOFRAME_CTRL0[0x002C] */
- /* 0x3 for AVI InfFrame enable (every frame) */
- writel(readl(0x002C) | 0x00000003L, MSM_HDMI_BASE + 0x002C);
-}
-
-void hdmi_app_clk_init(int on)
-{
- uint32_t val = 0;
- if (on) {
- /* Enable hdmi apps clock */
- val = readl(MISC_CC2_REG);
- val = BIT(11);
- writel(val, MISC_CC2_REG);
- udelay(10);
-
- /* Enable hdmi master clock */
- val = readl(MMSS_AHB_EN_REG);
- val |= BIT(14);
- writel(val, MMSS_AHB_EN_REG);
- udelay(10);
-
- /* Enable hdmi slave clock */
- val = readl(MMSS_AHB_EN_REG);
- val |= BIT(4);
- writel(val, MMSS_AHB_EN_REG);
- udelay(10);
- } else {
- // Disable clocks
- val = readl(MISC_CC2_REG);
- val &= ~(BIT(11));
- writel(val, MISC_CC2_REG);
- udelay(10);
- val = readl(MMSS_AHB_EN_REG);
- val &= ~(BIT(14));
- writel(val, MMSS_AHB_EN_REG);
- udelay(10);
- val = readl(MMSS_AHB_EN_REG);
- val &= ~(BIT(4));
- writel(val, MMSS_AHB_EN_REG);
- udelay(10);
- }
-}
-
-int hdmi_msm_turn_on(void)
-{
- uint32_t hotplug_control;
-
- hdmi_msm_set_mode(0);
-
- hdmi_msm_reset_core(); // Reset the core
- hdmi_msm_init_phy();
-
- // Enable USEC REF timer
- writel(0x0001001B, HDMI_USEC_REFTIMER);
-
- // Write 1 to HDMI_CTRL to enable HDMI
- hdmi_msm_set_mode(1);
-
- // Video setup for HDMI
- hdmi_video_setup();
-
- // AVI info setup
- hdmi_msm_avi_info_frame();
-
- return 0;
-}
-
-int hdmi_dtv_init()
-{
- uint32_t hsync_period;
- uint32_t hsync_ctrl;
- uint32_t hsync_start_x;
- uint32_t hsync_end_x;
- uint32_t display_hctl;
- uint32_t vsync_period;
- uint32_t display_v_start;
- uint32_t display_v_end;
- uint32_t hsync_polarity;
- uint32_t vsync_polarity;
- uint32_t data_en_polarity;
- uint32_t ctrl_polarity;
- uint32_t dtv_border_clr = 0;
- uint32_t dtv_underflow_clr = 0;
- uint32_t active_v_start = 0;
- uint32_t active_v_end = 0;
- uint32_t dtv_hsync_skew = 0;
- uint32_t intf, stage, snum, mask, data;
- unsigned char *rgb_base;
- unsigned char *overlay_base;
- uint32_t val;
-
- struct hdmi_disp_mode_timing_type *timing =
- hdmi_common_init_panel_info();
-
- // MDP E config
- writel((unsigned)timing->base, MDP_BASE + 0xb0008); //FB Address
- writel(((timing->height << 16) | timing->width), MDP_BASE + 0xb0004);
- writel((timing->width * timing->bpp / 8), MDP_BASE + 0xb000c);
- writel(0, MDP_BASE + 0xb0010);
-
- writel(DMA_PACK_PATTERN_RGB | DMA_DSTC0G_8BITS | DMA_DSTC1B_8BITS |
- DMA_DSTC2R_8BITS, MDP_BASE + 0xb0000);
- writel(0xff0000, MDP_BASE + 0xb0070);
- writel(0xff0000, MDP_BASE + 0xb0074);
- writel(0xff0000, MDP_BASE + 0xb0078);
-
- // overlay rgb setup RGB2
- rgb_base = MDP_BASE + MDP4_RGB_BASE;
- rgb_base += (MDP4_RGB_OFF * 1);
- writel(((timing->height << 16) | timing->width), rgb_base + 0x0000);
- writel(0x0, rgb_base + 0x0004);
- writel(((timing->height << 16) | timing->width), rgb_base + 0x0008);
- writel(0x0, rgb_base + 0x000c);
- writel(timing->base, rgb_base + 0x0010); //FB address
- writel((timing->width * timing->bpp / 8), rgb_base + 0x0040);
- writel(0x2443F, rgb_base + 0x0050); //format
- writel(0x20001, rgb_base + 0x0054); //pattern
- writel(0x0, rgb_base + 0x0058);
- writel(0x20000000, rgb_base + 0x005c); //phaseX
- writel(0x20000000, rgb_base + 0x0060); // phaseY
-
- // mdp4 mixer setup MDP4_MIXER1
- data = readl(MDP_BASE + 0x10100);
- stage = 9;
- snum = 12;
- mask = 0x0f;
- mask <<= snum;
- stage <<= snum;
- data &= ~mask;
- data |= stage;
- writel(data, MDP_BASE + 0x10100); // Overlay CFG conf
- data = readl(MDP_BASE + 0x10100);
-
- // Overlay cfg
- overlay_base = MDP_BASE + MDP4_OVERLAYPROC1_BASE;
-
- writel(0x0, MDP_BASE + 0x0038); //EXternal interface select
-
- data = ((timing->height << 16) | timing->width);
- writel(data, overlay_base + 0x0008);
- writel(timing->base, overlay_base + 0x000c);
- writel((timing->width * timing->bpp / 8), overlay_base + 0x0010);
- writel(0x10, overlay_base + 0x104);
- writel(0x10, overlay_base + 0x124);
- writel(0x10, overlay_base + 0x144);
- writel(0x01, overlay_base + 0x0004); /* directout */
-
- hsync_period =
- timing->hsync_width + timing->hsync_porch_bp + timing->width +
- timing->hsync_porch_fp;
- hsync_ctrl = (hsync_period << 16) | timing->hsync_width;
- hsync_start_x = timing->hsync_width + timing->hsync_porch_bp;
- hsync_end_x = hsync_period - timing->hsync_porch_fp - 1;
- display_hctl = (hsync_end_x << 16) | hsync_start_x;
-
- vsync_period =
- (timing->vsync_width + timing->vsync_porch_bp + timing->height +
- timing->vsync_porch_fp) * hsync_period;
- display_v_start =
- (timing->vsync_width + timing->vsync_porch_bp) * hsync_period;
- display_v_end =
- vsync_period - (timing->vsync_porch_bp * hsync_period) - 1;
-
- dtv_underflow_clr |= 0x80000000;
- hsync_polarity = 0;
- vsync_polarity = 0;
- data_en_polarity = 0;
- ctrl_polarity =
- (data_en_polarity << 2) | (vsync_polarity << 1) | (hsync_polarity);
-
- writel(hsync_ctrl, MDP_BASE + DTV_BASE + 0x4);
- writel(vsync_period, MDP_BASE + DTV_BASE + 0x8);
- writel(timing->vsync_width * hsync_period,
- MDP_BASE + DTV_BASE + 0xc);
- writel(display_hctl, MDP_BASE + DTV_BASE + 0x18);
- writel(display_v_start, MDP_BASE + DTV_BASE + 0x1c);
- writel(0x25a197, MDP_BASE + DTV_BASE + 0x20);
- writel(dtv_border_clr, MDP_BASE + DTV_BASE + 0x40);
- writel(0x8fffffff, MDP_BASE + DTV_BASE + 0x44);
- writel(dtv_hsync_skew, MDP_BASE + DTV_BASE + 0x48);
- writel(ctrl_polarity, MDP_BASE + DTV_BASE + 0x50);
- writel(0x0, MDP_BASE + DTV_BASE + 0x2c);
- writel(active_v_start, MDP_BASE + DTV_BASE + 0x30);
- writel(active_v_end, MDP_BASE + DTV_BASE + 0x38);
-
- /* Enable DTV block */
- writel(0x01, MDP_BASE + DTV_BASE);
-
- /* Flush mixer/pipes configurations */
- val = BIT(1);
- val |= BIT(5);
- writel(val, MDP_BASE + 0x18000);
-
- return 0;
-}
-
-void hdmi_display_shutdown()
-{
- writel(0x0, MDP_BASE + DTV_BASE);
- writel(0x8, MDP_BASE + 0x0038);
- writel(0x0, MDP_BASE + 0x10100);
-}
diff --git a/platform/msm_shared/hdmi_pll_28nm.c b/platform/msm_shared/hdmi_pll_28nm.c
new file mode 100644
index 0000000..02b69bb
--- /dev/null
+++ b/platform/msm_shared/hdmi_pll_28nm.c
@@ -0,0 +1,260 @@
+/* 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 <reg.h>
+#include <smem.h>
+#include <bits.h>
+#include <msm_panel.h>
+#include <platform/timer.h>
+#include <platform/iomap.h>
+
+#define HDMI_PHY_BASE 0xFD922500
+#define HDMI_PLL_BASE 0xFD922700
+
+/* hdmi phy registers */
+#define HDMI_PHY_ANA_CFG0 (0x0000)
+#define HDMI_PHY_ANA_CFG1 (0x0004)
+#define HDMI_PHY_ANA_CFG2 (0x0008)
+#define HDMI_PHY_ANA_CFG3 (0x000C)
+#define HDMI_PHY_PD_CTRL0 (0x0010)
+#define HDMI_PHY_PD_CTRL1 (0x0014)
+#define HDMI_PHY_GLB_CFG (0x0018)
+#define HDMI_PHY_DCC_CFG0 (0x001C)
+#define HDMI_PHY_DCC_CFG1 (0x0020)
+#define HDMI_PHY_TXCAL_CFG0 (0x0024)
+#define HDMI_PHY_TXCAL_CFG1 (0x0028)
+#define HDMI_PHY_TXCAL_CFG2 (0x002C)
+#define HDMI_PHY_TXCAL_CFG3 (0x0030)
+#define HDMI_PHY_BIST_CFG0 (0x0034)
+#define HDMI_PHY_BIST_CFG1 (0x0038)
+#define HDMI_PHY_BIST_PATN0 (0x003C)
+#define HDMI_PHY_BIST_PATN1 (0x0040)
+#define HDMI_PHY_BIST_PATN2 (0x0044)
+#define HDMI_PHY_BIST_PATN3 (0x0048)
+#define HDMI_PHY_STATUS (0x005C)
+
+/* hdmi phy unified pll registers */
+#define HDMI_UNI_PLL_REFCLK_CFG (0x0000)
+#define HDMI_UNI_PLL_POSTDIV1_CFG (0x0004)
+#define HDMI_UNI_PLL_CHFPUMP_CFG (0x0008)
+#define HDMI_UNI_PLL_VCOLPF_CFG (0x000C)
+#define HDMI_UNI_PLL_VREG_CFG (0x0010)
+#define HDMI_UNI_PLL_PWRGEN_CFG (0x0014)
+#define HDMI_UNI_PLL_GLB_CFG (0x0020)
+#define HDMI_UNI_PLL_POSTDIV2_CFG (0x0024)
+#define HDMI_UNI_PLL_POSTDIV3_CFG (0x0028)
+#define HDMI_UNI_PLL_LPFR_CFG (0x002C)
+#define HDMI_UNI_PLL_LPFC1_CFG (0x0030)
+#define HDMI_UNI_PLL_LPFC2_CFG (0x0034)
+#define HDMI_UNI_PLL_SDM_CFG0 (0x0038)
+#define HDMI_UNI_PLL_SDM_CFG1 (0x003C)
+#define HDMI_UNI_PLL_SDM_CFG2 (0x0040)
+#define HDMI_UNI_PLL_SDM_CFG3 (0x0044)
+#define HDMI_UNI_PLL_SDM_CFG4 (0x0048)
+#define HDMI_UNI_PLL_SSC_CFG0 (0x004C)
+#define HDMI_UNI_PLL_SSC_CFG1 (0x0050)
+#define HDMI_UNI_PLL_SSC_CFG2 (0x0054)
+#define HDMI_UNI_PLL_SSC_CFG3 (0x0058)
+#define HDMI_UNI_PLL_LKDET_CFG0 (0x005C)
+#define HDMI_UNI_PLL_LKDET_CFG1 (0x0060)
+#define HDMI_UNI_PLL_LKDET_CFG2 (0x0064)
+#define HDMI_UNI_PLL_CAL_CFG0 (0x006C)
+#define HDMI_UNI_PLL_CAL_CFG1 (0x0070)
+#define HDMI_UNI_PLL_CAL_CFG2 (0x0074)
+#define HDMI_UNI_PLL_CAL_CFG3 (0x0078)
+#define HDMI_UNI_PLL_CAL_CFG4 (0x007C)
+#define HDMI_UNI_PLL_CAL_CFG5 (0x0080)
+#define HDMI_UNI_PLL_CAL_CFG6 (0x0084)
+#define HDMI_UNI_PLL_CAL_CFG7 (0x0088)
+#define HDMI_UNI_PLL_CAL_CFG8 (0x008C)
+#define HDMI_UNI_PLL_CAL_CFG9 (0x0090)
+#define HDMI_UNI_PLL_CAL_CFG10 (0x0094)
+#define HDMI_UNI_PLL_CAL_CFG11 (0x0098)
+#define HDMI_UNI_PLL_STATUS (0x00C0)
+
+#define SW_RESET BIT(2)
+#define SW_RESET_PLL BIT(0)
+
+void hdmi_phy_reset(void)
+{
+ uint32_t phy_reset_polarity = 0x0;
+ uint32_t pll_reset_polarity = 0x0;
+ uint32_t val;
+
+ val = readl(HDMI_PHY_CTRL);
+
+ phy_reset_polarity = val >> 3 & 0x1;
+ pll_reset_polarity = val >> 1 & 0x1;
+
+ if (phy_reset_polarity == 0)
+ writel(val | SW_RESET, HDMI_PHY_CTRL);
+ else
+ writel(val & (~SW_RESET), HDMI_PHY_CTRL);
+
+ if (pll_reset_polarity == 0)
+ writel(val | SW_RESET_PLL, HDMI_PHY_CTRL);
+ else
+ writel(val & (~SW_RESET_PLL), HDMI_PHY_CTRL);
+
+ if (phy_reset_polarity == 0)
+ writel(val & (~SW_RESET), HDMI_PHY_CTRL);
+ else
+ writel(val | SW_RESET, HDMI_PHY_CTRL);
+
+ if (pll_reset_polarity == 0)
+ writel(val & (~SW_RESET_PLL), HDMI_PHY_CTRL);
+ else
+ writel(val | SW_RESET_PLL, HDMI_PHY_CTRL);
+}
+
+void hdmi_phy_init(void)
+{
+ writel(0x1B, HDMI_PHY_BASE + HDMI_PHY_ANA_CFG0);
+ writel(0xF2, HDMI_PHY_BASE + HDMI_PHY_ANA_CFG1);
+ writel(0x0, HDMI_PHY_BASE + HDMI_PHY_BIST_CFG0);
+ writel(0x0, HDMI_PHY_BASE + HDMI_PHY_BIST_PATN0);
+ writel(0x0, HDMI_PHY_BASE + HDMI_PHY_BIST_PATN1);
+ writel(0x0, HDMI_PHY_BASE + HDMI_PHY_BIST_PATN2);
+ writel(0x0, HDMI_PHY_BASE + HDMI_PHY_BIST_PATN3);
+
+ writel(0x20, HDMI_PHY_BASE + HDMI_PHY_PD_CTRL1);
+}
+
+void hdmi_phy_powerdown(void)
+{
+ writel(0x7F, HDMI_PHY_BASE + HDMI_PHY_PD_CTRL0);
+}
+
+static uint32_t hdmi_poll_status(uint32_t addr)
+{
+ uint32_t count;
+
+ for (count = 20; count > 0; count--) {
+ if (readl(addr) & 0x1) {
+ return NO_ERROR;
+ }
+ udelay(100);
+ }
+ return ERR_TIMED_OUT;
+}
+
+void hdmi_vco_disable(void)
+{
+ writel(0x0, HDMI_PLL_BASE + HDMI_UNI_PLL_GLB_CFG);
+ udelay(5);
+ writel(0x0, HDMI_PHY_BASE + HDMI_PHY_GLB_CFG);
+}
+
+int hdmi_vco_enable(void)
+{
+ /* Global Enable */
+ writel(0x81, HDMI_PHY_BASE + HDMI_PHY_GLB_CFG);
+ /* Power up power gen */
+ writel(0x00, HDMI_PHY_BASE + HDMI_PHY_PD_CTRL0);
+ udelay(350);
+
+ /* PLL Power-Up */
+ writel(0x01, HDMI_PLL_BASE + HDMI_UNI_PLL_GLB_CFG);
+ udelay(5);
+
+ /* Power up PLL LDO */
+ writel(0x03, HDMI_PLL_BASE + HDMI_UNI_PLL_GLB_CFG);
+ udelay(350);
+
+ /* PLL Power-Up */
+ writel(0x0F, HDMI_PLL_BASE + HDMI_UNI_PLL_GLB_CFG);
+ udelay(350);
+
+ /* poll for PLL ready status */
+ if (hdmi_poll_status(HDMI_PLL_BASE + HDMI_UNI_PLL_STATUS)) {
+ dprintf(CRITICAL, "%s: hdmi phy pll failed to Lock\n",
+ __func__);
+ hdmi_vco_disable();
+ return ERROR;
+ }
+
+ udelay(350);
+ /* poll for PHY ready status */
+ if (hdmi_poll_status(HDMI_PHY_BASE + HDMI_PHY_STATUS)) {
+ dprintf(CRITICAL, "%s: hdmi phy failed to Lock\n",
+ __func__);
+ hdmi_vco_disable();
+ return ERROR;
+ }
+
+ return NO_ERROR;
+}
+
+uint32_t hdmi_pll_config(void)
+{
+ writel(0x81, HDMI_PHY_BASE + HDMI_PHY_GLB_CFG);
+ writel(0x01, HDMI_PLL_BASE + HDMI_UNI_PLL_GLB_CFG);
+ writel(0x01, HDMI_PLL_BASE + HDMI_UNI_PLL_REFCLK_CFG);
+ writel(0x19, HDMI_PLL_BASE + HDMI_UNI_PLL_VCOLPF_CFG);
+ writel(0x0E, HDMI_PLL_BASE + HDMI_UNI_PLL_LPFR_CFG);
+ writel(0x20, HDMI_PLL_BASE + HDMI_UNI_PLL_LPFC1_CFG);
+ writel(0x0D, HDMI_PLL_BASE + HDMI_UNI_PLL_LPFC2_CFG);
+ writel(0x00, HDMI_PLL_BASE + HDMI_UNI_PLL_SDM_CFG0);
+ writel(0x52, HDMI_PLL_BASE + HDMI_UNI_PLL_SDM_CFG1);
+ writel(0x00, HDMI_PLL_BASE + HDMI_UNI_PLL_SDM_CFG2);
+ writel(0x56, HDMI_PLL_BASE + HDMI_UNI_PLL_SDM_CFG3);
+ writel(0x00, HDMI_PLL_BASE + HDMI_UNI_PLL_SDM_CFG4);
+ writel(0x10, HDMI_PLL_BASE + HDMI_UNI_PLL_LKDET_CFG0);
+ writel(0x1A, HDMI_PLL_BASE + HDMI_UNI_PLL_LKDET_CFG1);
+ writel(0x05, HDMI_PLL_BASE + HDMI_UNI_PLL_LKDET_CFG2);
+ writel(0x01, HDMI_PLL_BASE + HDMI_UNI_PLL_POSTDIV1_CFG);
+ writel(0x00, HDMI_PLL_BASE + HDMI_UNI_PLL_POSTDIV2_CFG);
+ writel(0x00, HDMI_PLL_BASE + HDMI_UNI_PLL_POSTDIV3_CFG);
+ writel(0x01, HDMI_PLL_BASE + HDMI_UNI_PLL_CAL_CFG2);
+ writel(0x60, HDMI_PLL_BASE + HDMI_UNI_PLL_CAL_CFG8);
+ writel(0x00, HDMI_PLL_BASE + HDMI_UNI_PLL_CAL_CFG9);
+ writel(0xE6, HDMI_PLL_BASE + HDMI_UNI_PLL_CAL_CFG10);
+ writel(0x02, HDMI_PLL_BASE + HDMI_UNI_PLL_CAL_CFG11);
+ writel(0x1F, HDMI_PHY_BASE + HDMI_PHY_PD_CTRL0);
+ udelay(50);
+
+ writel(0x0F, HDMI_PLL_BASE + HDMI_UNI_PLL_GLB_CFG);
+ writel(0x00, HDMI_PHY_BASE + HDMI_PHY_PD_CTRL1);
+ writel(0x10, HDMI_PHY_BASE + HDMI_PHY_ANA_CFG2);
+ writel(0xDB, HDMI_PHY_BASE + HDMI_PHY_ANA_CFG0);
+ writel(0x43, HDMI_PHY_BASE + HDMI_PHY_ANA_CFG1);
+ writel(0x02, HDMI_PHY_BASE + HDMI_PHY_ANA_CFG2);
+ writel(0x00, HDMI_PHY_BASE + HDMI_PHY_ANA_CFG3);
+ writel(0x04, HDMI_PLL_BASE + HDMI_UNI_PLL_VREG_CFG);
+ writel(0xD0, HDMI_PHY_BASE + HDMI_PHY_DCC_CFG0);
+ writel(0x1A, HDMI_PHY_BASE + HDMI_PHY_DCC_CFG1);
+ writel(0x00, HDMI_PHY_BASE + HDMI_PHY_TXCAL_CFG0);
+ writel(0x00, HDMI_PHY_BASE + HDMI_PHY_TXCAL_CFG1);
+ writel(0x02, HDMI_PHY_BASE + HDMI_PHY_TXCAL_CFG2);
+ writel(0x05, HDMI_PHY_BASE + HDMI_PHY_TXCAL_CFG3);
+ udelay(200);
+}
+
diff --git a/platform/msm_shared/include/board.h b/platform/msm_shared/include/board.h
index 9efde4d..d7e82d5 100644
--- a/platform/msm_shared/include/board.h
+++ b/platform/msm_shared/include/board.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2012-2013, The Linux Foundation. All rights reserved.
+/* Copyright (c) 2012-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
@@ -39,6 +39,7 @@
struct board_pmic_data {
uint32_t pmic_type;
uint32_t pmic_version;
+ uint32_t pmic_target;
};
struct board_data {
@@ -65,6 +66,7 @@
uint32_t board_hardware_subtype(void);
uint32_t board_get_ddr_subtype(void);
uint32_t board_hlos_subtype(void);
+uint32_t board_pmic_target(uint8_t num_ent);
/* DDR Subtype Macros
* Determine the DDR Size on the device and define
diff --git a/platform/msm_shared/include/dev_tree.h b/platform/msm_shared/include/dev_tree.h
index ef41046..a6534c0 100644
--- a/platform/msm_shared/include/dev_tree.h
+++ b/platform/msm_shared/include/dev_tree.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2012-2013, The Linux Foundation. All rights reserved.
+/* Copyright (c) 2012-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
@@ -27,6 +27,7 @@
*/
#include <debug.h>
+#include <list.h>
#ifndef __DEVICE_TREE__
#define __DEVICE_TREE__
@@ -36,6 +37,8 @@
#define DEV_TREE_MAGIC_LEN 4
#define DEV_TREE_VERSION_V1 1
#define DEV_TREE_VERSION_V2 2
+#define DEV_TREE_VERSION_V3 3
+
#define DEV_TREE_HEADER_SIZE 12
#define DTB_MAGIC 0xedfe0dd0
@@ -54,6 +57,18 @@
#define DT_ENTRY_V1_SIZE 0xC
#define PLAT_ID_SIZE 0x8
#define BOARD_ID_SIZE 0x8
+#define PMIC_ID_SIZE 0x8
+
+
+struct dt_entry_v2
+{
+ uint32_t platform_id;
+ uint32_t variant_id;
+ uint32_t board_hw_subtype;
+ uint32_t soc_rev;
+ uint32_t offset;
+ uint32_t size;
+};
struct dt_entry
{
@@ -61,6 +76,7 @@
uint32_t variant_id;
uint32_t board_hw_subtype;
uint32_t soc_rev;
+ uint32_t pmic_rev[4];
uint32_t offset;
uint32_t size;
};
@@ -84,6 +100,11 @@
uint32_t platform_subtype;
};
+struct pmic_id
+{
+ uint32_t pmic_version[4];
+};
+
struct dt_mem_node_info
{
uint32_t offset;
@@ -92,17 +113,28 @@
uint32_t size_cell_size;
};
+enum dt_entry_info
+{
+ DTB_FOUNDRY = 0,
+ DTB_SOC,
+ DTB_MAJOR_MINOR,
+ DTB_PMIC0,
+ DTB_PMIC1,
+ DTB_PMIC2,
+ DTB_PMIC3,
+ DTB_PMIC_MODEL,
+};
+
enum dt_err_codes
{
DT_OP_SUCCESS,
DT_OP_FAILURE = -1,
};
-struct board_dt_entry
-{
- uint32_t target_variant_id;
- uint32_t platform_variant_id;
-};
+typedef struct dt_entry_node {
+ struct list_node node;
+ struct dt_entry * dt_entry_m;
+}dt_node;
int dev_tree_validate(struct dt_table *table, unsigned int page_size, uint32_t *dt_hdr_size);
int dev_tree_get_entry_info(struct dt_table *table, struct dt_entry *dt_entry_info);
diff --git a/platform/msm_shared/include/gpio.h b/platform/msm_shared/include/gpio.h
index 56b9c82..3606641 100644
--- a/platform/msm_shared/include/gpio.h
+++ b/platform/msm_shared/include/gpio.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2013, The Linux Foundation. All rights reserved.
+/* Copyright (c) 2013-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
@@ -66,6 +66,7 @@
uint32_t off; /* Bit offeset in the register */
uint8_t val; /* Current value */
uint8_t mask; /* Mask for the clk/dat/cmd control */
+ uint32_t reg; /* TLMM ping register */
};
/* APIs: exposed for other drivers */
diff --git a/platform/msm_shared/include/hdmi.h b/platform/msm_shared/include/hdmi.h
deleted file mode 100644
index 0b4fd5b..0000000
--- a/platform/msm_shared/include/hdmi.h
+++ /dev/null
@@ -1,84 +0,0 @@
-/* Copyright (c) 2010-2013, 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 "AS IS" AND ANY EXPRESS OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
- * 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.
- *
- */
-
-#ifndef __PLATFORM_MSM_SHARED_HDMI_H
-#define __PLATFORM_MSM_SHARED_HDMI_H
-
-#include <reg.h>
-#include <debug.h>
-#include <bits.h>
-#include <dev/fbcon.h>
-#include <target/display.h>
-
-#define MDP_GET_PACK_PATTERN(a,x,y,z,bit) (((a)<<(bit*3))|((x)<<(bit*2))|((y)<<bit)|(z))
-#define DMA_PACK_ALIGN_LSB 0
-#define DMA_PACK_PATTERN_RGB \
- (MDP_GET_PACK_PATTERN(0,CLR_R,CLR_G,CLR_B,2)<<8)
-#define CLR_G 0x0
-#define CLR_B 0x1
-#define CLR_R 0x2
-#define DMA_DSTC0G_8BITS (BIT(1)|BIT(0))
-#define DMA_DSTC1B_8BITS (BIT(3)|BIT(2))
-#define DMA_DSTC2R_8BITS (BIT(5)|BIT(4))
-#define BM(m, l) (((((uint32_t)-1) << (31-m)) >> (31-m+l)) << l)
-#define BVAL(m, l, val) (((val) << l) & BM(m, l))
-#define CC(m, n) (BVAL((m+1), m, 0x2) * !!(n))
-#define NS_MM(n_msb, n_lsb, n, m, d_msb, d_lsb, d, s_msb, s_lsb, s) \
- (BVAL(n_msb, n_lsb, ~(n-m)) | BVAL(d_msb, d_lsb, (d-1)) \
- | BVAL(s_msb, s_lsb, s))
-
-extern int pm8901_mpp_enable();
-extern int pm8901_vs_enable();
-extern int pm8058_ldo_set_voltage();
-extern int pm8058_vreg_enable();
-void gpio_tlmm_config(uint32_t gpio, uint8_t func,
- uint8_t dir, uint8_t pull,
- uint8_t drvstr, uint32_t enable);
-
-int hdmi_dtv_on(void);
-void hdmi_msm_set_mode(int on);
-void hdmi_msm_init_phy(void);
-void hdmi_display_shutdown(void);
-void hdmi_msm_reset_core(void);
-void hdmi_set_fb_addr(void *addr);
-
-struct hdmi_disp_mode_timing_type {
- uint32_t height;
- uint32_t hsync_porch_fp;
- uint32_t hsync_width;
- uint32_t hsync_porch_bp;
- uint32_t width;
- uint32_t vsync_porch_fp;
- uint32_t vsync_width;
- uint32_t vsync_porch_bp;
- uint32_t refresh_rate;
- uint32_t bpp;
- void *base;
-};
-#endif /* __PLATFORM_MSM_SHARED_HDMI_H */
diff --git a/platform/msm_shared/include/mdp5.h b/platform/msm_shared/include/mdp5.h
index ac389ee..8ade9c8 100644
--- a/platform/msm_shared/include/mdp5.h
+++ b/platform/msm_shared/include/mdp5.h
@@ -97,6 +97,7 @@
#define MDP_INTF_0_TIMING_ENGINE_EN REG_MDP(0x12500)
#define MDP_INTF_1_TIMING_ENGINE_EN REG_MDP(0x12700)
+#define MDP_INTF_3_TIMING_ENGINE_EN REG_MDP(0x12B00)
#define MDP_CTL_0_BASE REG_MDP(0x600)
#define MDP_CTL_1_BASE REG_MDP(0x700)
@@ -117,6 +118,7 @@
#define MDP_INTF_0_BASE REG_MDP(0x12500)
#define MDP_INTF_1_BASE REG_MDP(0x12700)
#define MDP_INTF_2_BASE REG_MDP(0x12900)
+#define MDP_INTF_3_BASE REG_MDP(0x12B00)
#define MDP_HSYNC_CTL 0x08
#define MDP_VSYNC_PERIOD_F0 0x0C
diff --git a/platform/msm_shared/include/msm_panel.h b/platform/msm_shared/include/msm_panel.h
index 8b7af72..6befefd 100755
--- a/platform/msm_shared/include/msm_panel.h
+++ b/platform/msm_shared/include/msm_panel.h
@@ -199,6 +199,7 @@
/* Select pipe type for handoff */
uint32_t pipe_type;
char lowpowerstop;
+ char lcd_reg_en;
struct lcd_panel_info lcd;
struct lcdc_panel_info lcdc;
@@ -224,7 +225,7 @@
int rotate;
/* function entry chain */
- int (*power_func) (int enable);
+ int (*power_func) (int enable, struct msm_panel_info *);
int (*clk_func) (int enable);
int (*bl_func) (int enable);
int (*pll_clk_func) (int enable, struct msm_panel_info *);
diff --git a/platform/msm_shared/include/scm.h b/platform/msm_shared/include/scm.h
index 1268db9..de046a4 100644
--- a/platform/msm_shared/include/scm.h
+++ b/platform/msm_shared/include/scm.h
@@ -29,6 +29,34 @@
#ifndef __SCM_H__
#define __SCM_H__
+/* ARM SCM format support related flags */
+#define SIP_SVC_CALLS 0x02000000
+#define MAKE_SIP_SCM_CMD(svc_id, cmd_id) ((((svc_id << 8) | (cmd_id)) & 0xFFFF) | SIP_SVC_CALLS)
+#define MAKE_SCM_VAR_ARGS(num_args, t0, t1, t2, t3, t4, t5, t6, t7, t8, t9, ...) (\
+ (((t0) & 0xff) << 4) | \
+ (((t1) & 0xff) << 6) | \
+ (((t2) & 0xff) << 8) | \
+ (((t3) & 0xff) << 10) | \
+ (((t4) & 0xff) << 12) | \
+ (((t5) & 0xff) << 14) | \
+ (((t6) & 0xff) << 16) | \
+ (((t7) & 0xff) << 18) | \
+ (((t8) & 0xff) << 20) | \
+ (((t9) & 0xff) << 22) | \
+ (num_args & 0xffff))
+#define MAKE_SCM_ARGS(...) MAKE_SCM_VAR_ARGS(__VA_ARGS__, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)
+#define SCM_ATOMIC_BIT BIT(31)
+#define SCM_MAX_ARG_LEN 5
+#define SCM_INDIR_MAX_LEN 10
+
+enum
+{
+ SMC_PARAM_TYPE_VALUE = 0,
+ SMC_PARAM_TYPE_BUFFER_READ,
+ SMC_PARAM_TYPE_BUFFER_READWRITE,
+ SMC_PARAM_TYPE_BUFFER_VALIDATION,
+} scm_arg_type;
+
/* 8 Byte SSD magic number (LE) */
#define DECRYPT_MAGIC_0 0x73737A74
#define DECRYPT_MAGIC_1 0x676D6964
@@ -126,12 +154,62 @@
uint32_t out_buf_size;
}__packed;
+/* SCM support as per ARM spec */
+/*
+ * Structure to define the argument for scm call
+ * x0: is the command ID
+ * x1: Number of argument & type of arguments
+ * : Type can be any of
+ * : SMC_PARAM_TYPE_VALUE 0
+ * : SMC_PARAM_TYPE_BUFFER_READ 1
+ * : SMC_PARAM_TYPE_BUFFER_READWRITE 2
+ * : SMC_PARAM_TYPE_BUFFER_VALIDATION 3
+ * @Note: Number of argument count starts from X2.
+ * x2-x4: Arguments
+ * X5[10]: if the number of argument is more, an indirect
+ * : list can be passed here.
+ */
+typedef struct {
+ uint32_t x0;/* command ID details as per ARMv8 spec :
+ 0:7 command, 8:15 service id
+ 0x02000000: SIP calls
+ 30: SMC32 or SMC64
+ 31: Standard or fast calls*/
+ uint32_t x1; /* # of args and attributes for buffers
+ * 0-3: arg #
+ * 4-5: type of arg1
+ * 6-7: type of arg2
+ * :
+ * :
+ * 20-21: type of arg8
+ * 22-23: type of arg9
+ */
+ uint32_t x2; /* Param1 */
+ uint32_t x3; /* Param2 */
+ uint32_t x4; /* Param3 */
+ uint32_t x5[10]; /* Indirect parameter list */
+ uint32_t atomic; /* To indicate if its standard or fast call */
+} scmcall_arg;
+
+/* Return value for the SCM call:
+ * SCM call returns values in register if its less than
+ * 12 bytes, anything greater need to be input buffer + input len
+ * arguments
+ */
+typedef struct
+{
+ uint32_t x1;
+ uint32_t x2;
+ uint32_t x3;
+} scmcall_ret;
+
/* Service IDs */
#define SCM_SVC_BOOT 0x01
#define TZBSP_SVC_INFO 0x06
#define SCM_SVC_SSD 0x07
#define SVC_MEMORY_PROTECTION 0x0C
#define TZ_SVC_CRYPTO 0x0A
+#define SCM_SVC_INFO 0x06
/*Service specific command IDs */
#define ERR_FATAL_ENABLE 0x0
@@ -151,6 +229,7 @@
#define TZ_INFO_GET_FEATURE_ID 0x03
#define PRNG_CMD_ID 0x01
+#define IS_CALL_AVAIL_CMD 0x01
/* Download Mode specific arguments to be passed to TZ */
#define SCM_EDLOAD_MODE 0x02
@@ -235,6 +314,11 @@
/* API to configure XPU violations as fatal */
int scm_xpu_err_fatal_init();
+/* APIs to support ARM scm standard
+ * Takes arguments : x0-x5 and returns result
+ * in x0-x3*/
+uint32_t scm_call2(scmcall_arg *arg, scmcall_ret *ret);
+
/**
* struct scm_command - one SCM command buffer
* @len: total available memory for command and response
@@ -278,4 +362,8 @@
uint32_t buf_offset;
uint32_t is_complete;
};
+/* Perform any scm init needed before making scm calls
+ * Used for checking if armv8 SCM support present
+ */
+void scm_init();
#endif
diff --git a/platform/msm_shared/mdp3.c b/platform/msm_shared/mdp3.c
index 2cde8ea..b53b3d8 100644
--- a/platform/msm_shared/mdp3.c
+++ b/platform/msm_shared/mdp3.c
@@ -211,3 +211,18 @@
{
return NO_ERROR;
}
+
+int mdss_hdmi_config(struct msm_panel_info *pinfo, struct fbcon_config *fb)
+{
+ return NO_ERROR;
+}
+
+int mdss_hdmi_on(void)
+{
+ return NO_ERROR;
+}
+
+int mdss_hdmi_off(void)
+{
+ return NO_ERROR;
+}
diff --git a/platform/msm_shared/mdp4.c b/platform/msm_shared/mdp4.c
index 7b7c0cf..705819e 100644
--- a/platform/msm_shared/mdp4.c
+++ b/platform/msm_shared/mdp4.c
@@ -423,3 +423,18 @@
{
return NO_ERROR;
}
+
+int mdss_hdmi_config(struct msm_panel_info *pinfo, struct fbcon_config *fb)
+{
+ return NO_ERROR;
+}
+
+int mdss_hdmi_on(void)
+{
+ return NO_ERROR;
+}
+
+int mdss_hdmi_off(void)
+{
+ return NO_ERROR;
+}
diff --git a/platform/msm_shared/mdp5.c b/platform/msm_shared/mdp5.c
index 6e8fea4..801f7b6 100644
--- a/platform/msm_shared/mdp5.c
+++ b/platform/msm_shared/mdp5.c
@@ -602,6 +602,41 @@
return 0;
}
+int mdss_hdmi_config(struct msm_panel_info *pinfo, struct fbcon_config *fb)
+{
+ int ret = NO_ERROR;
+ struct lcdc_panel_info *lcdc = NULL;
+ uint32_t left_pipe, right_pipe;
+
+ mdss_intf_tg_setup(pinfo, MDP_INTF_3_BASE);
+ mdp_select_pipe_type(pinfo, &left_pipe, &right_pipe);
+
+ mdp_clk_gating_ctrl();
+ mdss_vbif_setup();
+
+ mdss_smp_setup(pinfo, left_pipe, right_pipe);
+
+ mdss_qos_remapper_setup();
+
+ mdss_source_pipe_config(fb, pinfo, left_pipe);
+ if (pinfo->lcdc.dual_pipe)
+ mdss_source_pipe_config(fb, pinfo, right_pipe);
+
+ mdss_layer_mixer_setup(fb, pinfo);
+
+ if (pinfo->lcdc.dual_pipe)
+ writel(0x181F40, MDP_CTL_0_BASE + CTL_TOP);
+ else
+ writel(0x40, MDP_CTL_0_BASE + CTL_TOP);
+
+ writel(BIT(24) | BIT(25), MDP_DISP_INTF_SEL);
+ writel(0x1111, MDP_VIDEO_INTF_UNDERFLOW_CTL);
+ writel(0x01, MDP_UPPER_NEW_ROI_PRIOR_RO_START);
+ writel(0x01, MDP_LOWER_NEW_ROI_PRIOR_TO_START);
+
+ return 0;
+}
+
int mdp_dsi_cmd_config(struct msm_panel_info *pinfo,
struct fbcon_config *fb)
{
@@ -730,6 +765,18 @@
return NO_ERROR;
}
+int mdss_hdmi_on(struct msm_panel_info *pinfo)
+{
+ uint32_t ctl0_reg_val, ctl1_reg_val;
+
+ mdss_mdp_set_flush(pinfo, &ctl0_reg_val, &ctl1_reg_val);
+ writel(ctl0_reg_val, MDP_CTL_0_BASE + CTL_FLUSH);
+
+ writel(0x01, MDP_INTF_3_TIMING_ENGINE_EN + mdss_mdp_intf_offset());
+
+ return NO_ERROR;
+}
+
int mdp_edp_off(void)
{
if (!target_cont_splash_screen()) {
diff --git a/platform/msm_shared/mdss_hdmi.c b/platform/msm_shared/mdss_hdmi.c
new file mode 100644
index 0000000..c6a5bab
--- /dev/null
+++ b/platform/msm_shared/mdss_hdmi.c
@@ -0,0 +1,315 @@
+/* Copyright (c) 2010-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 "AS IS" AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
+ * 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 <err.h>
+#include <debug.h>
+#include <reg.h>
+#include <msm_panel.h>
+#include <platform/timer.h>
+#include <platform/clock.h>
+#include <platform/iomap.h>
+
+static struct msm_fb_panel_data panel;
+
+/* AVI INFOFRAME DATA */
+#define NUM_MODES_AVI 20
+#define AVI_MAX_DATA_BYTES 13
+
+enum {
+ DATA_BYTE_1,
+ DATA_BYTE_2,
+ DATA_BYTE_3,
+ DATA_BYTE_4,
+ DATA_BYTE_5,
+ DATA_BYTE_6,
+ DATA_BYTE_7,
+ DATA_BYTE_8,
+ DATA_BYTE_9,
+ DATA_BYTE_10,
+ DATA_BYTE_11,
+ DATA_BYTE_12,
+ DATA_BYTE_13,
+};
+
+#define IFRAME_PACKET_OFFSET 0x80
+/*
+ * InfoFrame Type Code:
+ * 0x0 - Reserved
+ * 0x1 - Vendor Specific
+ * 0x2 - Auxiliary Video Information
+ * 0x3 - Source Product Description
+ * 0x4 - AUDIO
+ * 0x5 - MPEG Source
+ * 0x6 - NTSC VBI
+ * 0x7 - 0xFF - Reserved
+ */
+#define AVI_IFRAME_TYPE 0x2
+#define AVI_IFRAME_VERSION 0x2
+#define LEFT_SHIFT_BYTE(x) ((x) << 8)
+#define LEFT_SHIFT_WORD(x) ((x) << 16)
+#define LEFT_SHIFT_24BITS(x) ((x) << 24)
+
+struct mdss_hdmi_timing_info {
+ uint32_t video_format;
+ uint32_t active_h;
+ uint32_t front_porch_h;
+ uint32_t pulse_width_h;
+ uint32_t back_porch_h;
+ uint32_t active_low_h;
+ uint32_t active_v;
+ uint32_t front_porch_v;
+ uint32_t pulse_width_v;
+ uint32_t back_porch_v;
+ uint32_t active_low_v;
+ /* Must divide by 1000 to get the actual frequency in MHZ */
+ uint32_t pixel_freq;
+ /* Must divide by 1000 to get the actual frequency in HZ */
+ uint32_t refresh_rate;
+ uint32_t interlaced;
+ uint32_t supported;
+};
+
+#define HDMI_VFRMT_1280x720p60_16_9 4
+#define HDMI_RESOLUTION_DATA HDMI_VFRMT_1280x720p60_16_9##_TIMING
+
+#define HDMI_VFRMT_1280x720p60_16_9_TIMING \
+ {HDMI_VFRMT_1280x720p60_16_9, 1280, 110, 40, 220, false, \
+ 720, 5, 5, 20, false, 74250, 60000, false, true}
+
+uint32_t mdss_hdmi_avi_info_db[] = {
+ 0x10, 0x28, 0x00, 0x04, 0x00, 0x00, 0x00,
+ 0xD1, 0x02, 0x00, 0x00, 0x01, 0x05};
+
+static int mdss_hdmi_panel_clock(uint8_t enable, struct msm_panel_info *pinfo)
+{
+ return target_hdmi_panel_clock(enable, pinfo);
+}
+
+static int mdss_hdmi_enable_power(uint8_t enable)
+{
+ int ret = NO_ERROR;
+
+ ret = target_ldo_ctrl(enable);
+ if (ret) {
+ dprintf(CRITICAL, "LDO control enable failed\n");
+ return ret;
+ }
+
+ ret = target_hdmi_regulator_ctrl(enable);
+ if (ret) {
+ dprintf(CRITICAL, "hdmi regulator control enable failed\n");
+ return ret;
+ }
+
+ dprintf(SPEW, "HDMI Panel power %s done\n", enable ? "on" : "off");
+
+ return ret;
+}
+
+static void mdss_hdmi_set_mode(bool on)
+{
+ uint32_t val = 0;
+
+ if (on) {
+ val = 0x3;
+ writel(val, HDMI_CTRL);
+ } else {
+ writel(val, HDMI_CTRL);
+ }
+}
+
+static void mdss_hdmi_panel_init(struct msm_panel_info *pinfo)
+{
+ struct mdss_hdmi_timing_info tinfo = HDMI_RESOLUTION_DATA;
+
+ if (!pinfo)
+ return;
+
+ pinfo->xres = tinfo.active_h;
+ pinfo->yres = tinfo.active_v;
+ pinfo->bpp = 24;
+ pinfo->type = HDMI_PANEL;
+
+ pinfo->lcdc.h_back_porch = tinfo.back_porch_h;
+ pinfo->lcdc.h_front_porch = tinfo.front_porch_h;
+ pinfo->lcdc.h_pulse_width = tinfo.pulse_width_h;
+ pinfo->lcdc.v_back_porch = tinfo.back_porch_v;
+ pinfo->lcdc.v_front_porch = tinfo.front_porch_v;
+ pinfo->lcdc.v_pulse_width = tinfo.pulse_width_v;
+
+ pinfo->lcdc.hsync_skew = 0;
+ pinfo->lcdc.xres_pad = 0;
+ pinfo->lcdc.yres_pad = 0;
+ pinfo->lcdc.dual_pipe = 0;
+}
+
+void mdss_hdmi_display_init(uint32_t rev, void *base)
+{
+ mdss_hdmi_panel_init(&(panel.panel_info));
+
+ panel.clk_func = mdss_hdmi_panel_clock;
+ panel.power_func = mdss_hdmi_enable_power;
+
+ 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_RGB888;
+
+ panel.fb.base = base;
+ panel.mdp_rev = rev;
+
+ msm_display_init(&panel);
+}
+
+static int mdss_hdmi_video_setup(void)
+{
+ uint32_t total_v = 0;
+ uint32_t total_h = 0;
+ uint32_t start_h = 0;
+ uint32_t end_h = 0;
+ uint32_t start_v = 0;
+ uint32_t end_v = 0;
+
+ struct mdss_hdmi_timing_info tinfo = HDMI_RESOLUTION_DATA;
+
+ total_h = tinfo.active_h + tinfo.front_porch_h +
+ tinfo.back_porch_h + tinfo.pulse_width_h - 1;
+ total_v = tinfo.active_v + tinfo.front_porch_v +
+ tinfo.back_porch_v + tinfo.pulse_width_v - 1;
+ if (((total_v << 16) & 0xE0000000) || (total_h & 0xFFFFE000)) {
+ dprintf(CRITICAL,
+ "%s: total v=%d or h=%d is larger than supported\n",
+ __func__, total_v, total_h);
+ return ERROR;
+ }
+ writel((total_v << 16) | (total_h << 0), HDMI_TOTAL);
+
+ start_h = tinfo.back_porch_h + tinfo.pulse_width_h;
+ end_h = (total_h + 1) - tinfo.front_porch_h;
+ if (((end_h << 16) & 0xE0000000) || (start_h & 0xFFFFE000)) {
+ dprintf(CRITICAL,
+ "%s: end_h=%d or start_h=%d is larger than supported\n",
+ __func__, end_h, start_h);
+ return ERROR;
+ }
+ writel((end_h << 16) | (start_h << 0), HDMI_ACTIVE_H);
+
+ start_v = tinfo.back_porch_v + tinfo.pulse_width_v - 1;
+ end_v = total_v - tinfo.front_porch_v;
+ if (((end_v << 16) & 0xE0000000) || (start_v & 0xFFFFE000)) {
+ dprintf(CRITICAL,
+ "%s: end_v=%d or start_v=%d is larger than supported\n",
+ __func__, end_v, start_v);
+ return ERROR;
+ }
+ writel((end_v << 16) | (start_v << 0), HDMI_ACTIVE_V);
+
+ if (tinfo.interlaced) {
+ writel((total_v + 1) << 0, HDMI_V_TOTAL_F2);
+ writel(((end_v + 1) << 16) | ((start_v + 1) << 0),
+ HDMI_ACTIVE_V_F2);
+ } else {
+ writel(0, HDMI_V_TOTAL_F2);
+ writel(0, HDMI_ACTIVE_V_F2);
+ }
+
+ writel(((tinfo.interlaced << 31) & 0x80000000) |
+ ((tinfo.active_low_h << 29) & 0x20000000) |
+ ((tinfo.active_low_v << 28) & 0x10000000), HDMI_FRAME_CTRL);
+
+ return 0;
+}
+
+void mdss_hdmi_avi_info_frame(void)
+{
+ uint32_t sum;
+ uint32_t reg_val;
+ uint8_t checksum;
+ uint32_t i;
+
+ sum = IFRAME_PACKET_OFFSET + AVI_IFRAME_TYPE +
+ AVI_IFRAME_VERSION + AVI_MAX_DATA_BYTES;
+
+ for (i = 0; i < AVI_MAX_DATA_BYTES; i++)
+ sum += mdss_hdmi_avi_info_db[i];
+
+ sum &= 0xFF;
+ sum = 256 - sum;
+ checksum = (uint8_t) sum;
+
+ reg_val = checksum |
+ LEFT_SHIFT_BYTE(mdss_hdmi_avi_info_db[DATA_BYTE_1]) |
+ LEFT_SHIFT_WORD(mdss_hdmi_avi_info_db[DATA_BYTE_2]) |
+ LEFT_SHIFT_24BITS(mdss_hdmi_avi_info_db[DATA_BYTE_3]);
+ writel(reg_val, HDMI_AVI_INFO0);
+
+ reg_val = mdss_hdmi_avi_info_db[DATA_BYTE_4] |
+ LEFT_SHIFT_BYTE(mdss_hdmi_avi_info_db[DATA_BYTE_5]) |
+ LEFT_SHIFT_WORD(mdss_hdmi_avi_info_db[DATA_BYTE_6]) |
+ LEFT_SHIFT_24BITS(mdss_hdmi_avi_info_db[DATA_BYTE_7]);
+ writel(reg_val, HDMI_AVI_INFO1);
+
+ reg_val = mdss_hdmi_avi_info_db[DATA_BYTE_8] |
+ LEFT_SHIFT_BYTE(mdss_hdmi_avi_info_db[DATA_BYTE_9]) |
+ LEFT_SHIFT_WORD(mdss_hdmi_avi_info_db[DATA_BYTE_10]) |
+ LEFT_SHIFT_24BITS(mdss_hdmi_avi_info_db[DATA_BYTE_11]);
+ writel(reg_val, HDMI_AVI_INFO2);
+
+ reg_val = mdss_hdmi_avi_info_db[DATA_BYTE_12] |
+ LEFT_SHIFT_BYTE(mdss_hdmi_avi_info_db[DATA_BYTE_13]) |
+ LEFT_SHIFT_24BITS(AVI_IFRAME_VERSION);
+ writel(reg_val, HDMI_AVI_INFO3);
+
+ /* AVI InfFrame enable (every frame) */
+ writel(readl(HDMI_INFOFRAME_CTRL0) | BIT(1) | BIT(0),
+ HDMI_INFOFRAME_CTRL0);
+}
+
+int mdss_hdmi_init(void)
+{
+ uint32_t hotplug_control;
+
+ mdss_hdmi_set_mode(false);
+
+ hdmi_phy_init();
+
+ // Enable USEC REF timer
+ writel(0x0001001B, HDMI_USEC_REFTIMER);
+
+ // Video setup for HDMI
+ mdss_hdmi_video_setup();
+
+ // AVI info setup
+ mdss_hdmi_avi_info_frame();
+
+ // Write 1 to HDMI_CTRL to enable HDMI
+ mdss_hdmi_set_mode(true);
+
+ return 0;
+}
diff --git a/platform/msm_shared/mipi_dsi_autopll_20nm.c b/platform/msm_shared/mipi_dsi_autopll_20nm.c
index 754eb18..0f7052a 100644
--- a/platform/msm_shared/mipi_dsi_autopll_20nm.c
+++ b/platform/msm_shared/mipi_dsi_autopll_20nm.c
@@ -227,6 +227,15 @@
pll_20nm_phy_loop_bw_config(pll_base);
}
+static void mdss_dsi_pll_20nm_disable(uint32_t pll_base)
+{
+ dprintf(SPEW, "Disabling DSI PHY PLL \n");
+ writel(0x042, pll_base + MMSS_DSI_PHY_PLL_PLL_VCOTAIL_EN);
+ writel(0x002, pll_base + MMSS_DSI_PHY_PLL_BIAS_EN_CLKBUFLR_EN);
+ writel(0x002, pll_base + MMSS_DSI_PHY_PLL_RESETSM_CNTRL3);
+ dmb();
+}
+
int32_t mdss_dsi_auto_pll_20nm_config(uint32_t pll_base, uint32_t ctl_base,
struct mdss_dsi_pll_config *pd)
{
@@ -235,6 +244,15 @@
mdss_dsi_phy_sw_reset(ctl_base);
pll_20nm_phy_config(pll_base);
+ /*
+ * For 20nm PHY, DSI PLL 1 drains some current in its reset state.
+ * Need to turn off the DSI1 PLL explicitly.
+ */
+ if (ctl_base == MIPI_DSI0_BASE) {
+ dprintf(SPEW, "Calling disable function for PHY PLL 1 \n");
+ mdss_dsi_pll_20nm_disable(DSI1_PLL_BASE);
+ }
+
/* set up divider */
data = readl(pll_base + MMSS_DSI_PHY_PLL_POST_DIVIDER_CONTROL);
data |= 0x080; /* bit 7 */
diff --git a/platform/msm_shared/mmc_sdhci.c b/platform/msm_shared/mmc_sdhci.c
index 982af7a..a31cf87 100644
--- a/platform/msm_shared/mmc_sdhci.c
+++ b/platform/msm_shared/mmc_sdhci.c
@@ -1335,7 +1335,7 @@
cmd.cmd_index = ACMD13_SEND_SD_STATUS;
cmd.argument = 0x0;
cmd.cmd_type = SDHCI_CMD_TYPE_NORMAL;
- cmd.resp_type = SDHCI_CMD_RESP_R2;
+ cmd.resp_type = SDHCI_CMD_RESP_R1;
cmd.trans_mode = SDHCI_MMC_READ;
cmd.data_present = 0x1;
cmd.data.data_ptr = raw_sd_status;
diff --git a/platform/msm_shared/rpm-smd.c b/platform/msm_shared/rpm-smd.c
index 17b7ff5..6144fba 100644
--- a/platform/msm_shared/rpm-smd.c
+++ b/platform/msm_shared/rpm-smd.c
@@ -103,9 +103,6 @@
ret = smd_write(&ch, smd_data, len_to_smd, SMD_APPS_RPM);
- /* TODO: Use events */
- mdelay(1);
-
/* Read the response */
ack_msg_len = rpm_recv_data(&rlen);
diff --git a/platform/msm_shared/rules.mk b/platform/msm_shared/rules.mk
index f5f6dce..bf6d42e 100755
--- a/platform/msm_shared/rules.mk
+++ b/platform/msm_shared/rules.mk
@@ -224,6 +224,8 @@
$(LOCAL_DIR)/mipi_dsi.o \
$(LOCAL_DIR)/mipi_dsi_phy.o \
$(LOCAL_DIR)/mipi_dsi_autopll.o \
+ $(LOCAL_DIR)/mdss_hdmi.o \
+ $(LOCAL_DIR)/hdmi_pll_28nm.o \
$(LOCAL_DIR)/spmi.o \
$(LOCAL_DIR)/bam.o \
$(LOCAL_DIR)/qpic_nand.o \
diff --git a/platform/msm_shared/scm.c b/platform/msm_shared/scm.c
index b2ebfa3..48f62be 100644
--- a/platform/msm_shared/scm.c
+++ b/platform/msm_shared/scm.c
@@ -50,6 +50,33 @@
SCM_MASK_IRQS | \
((n) & 0xf))
+/* SCM interface as per ARM spec present? */
+bool scm_arm_support;
+
+static void scm_arm_support_available(uint32_t svc_id, uint32_t cmd_id)
+{
+ uint32_t ret;
+ scmcall_arg scm_arg = {0};
+ scmcall_arg scm_ret = {0};
+ /* Make a call to check if SCM call available using new interface,
+ * if this returns 0 then scm implementation as per arm spec
+ * otherwise use the old interface for scm calls
+ */
+ scm_arg.x0 = MAKE_SIP_SCM_CMD(SCM_SVC_INFO, IS_CALL_AVAIL_CMD);
+ scm_arg.x1 = MAKE_SCM_ARGS(0x1);
+ scm_arg.x2 = MAKE_SIP_SCM_CMD(svc_id, cmd_id);
+
+ ret = scm_call2(&scm_arg, &scm_ret);
+
+ if (!ret)
+ scm_arm_support = true;
+}
+
+
+void scm_init()
+{
+ scm_arm_support_available(SCM_SVC_INFO, IS_CALL_AVAIL_CMD);
+}
/**
* alloc_scm_command() - Allocate an SCM command
@@ -255,17 +282,30 @@
secure_cfg.id = id;
secure_cfg.spare = 0;
+ scmcall_arg scm_arg = {0};
- ret = scm_call(SVC_MEMORY_PROTECTION, IOMMU_SECURE_CFG, &secure_cfg, sizeof(secure_cfg),
- NULL, 0);
+ if(!scm_arm_support)
+ {
+ ret = scm_call(SVC_MEMORY_PROTECTION, IOMMU_SECURE_CFG, &secure_cfg, sizeof(secure_cfg),
+ NULL, 0);
+ }
+ else
+ {
+ scm_arg.x0 = MAKE_SIP_SCM_CMD(SVC_MEMORY_PROTECTION, IOMMU_SECURE_CFG);
+ scm_arg.x1 = MAKE_SCM_ARGS(0x2);
+ scm_arg.x2 = id;
+ scm_arg.x3 = 0x0; /* Spare unused */
- if (ret) {
+ ret = scm_call2(&scm_arg, NULL);
+ }
+
+ if (ret)
+ {
dprintf(CRITICAL, "Secure Config failed\n");
ret = 1;
}
return ret;
-
}
/* SCM Encrypt Command */
@@ -274,6 +314,12 @@
int ret;
img_req cmd;
+ if (scm_arm_support)
+ {
+ dprintf(INFO, "%s:SCM call is not supported\n",__func__);
+ return -1;
+ }
+
cmd.img_ptr = (uint32*) img_ptr;
cmd.img_len_ptr = img_len_ptr;
@@ -302,6 +348,12 @@
int ret;
img_req cmd;
+ if (scm_arm_support)
+ {
+ dprintf(INFO, "%s:SCM call is not supported\n",__func__);
+ return -1;
+ }
+
cmd.img_ptr = (uint32*) img_ptr;
cmd.img_len_ptr = img_len_ptr;
@@ -332,6 +384,12 @@
ssd_parse_md_rsp parse_rsp;
int prev_len = 0;
+ if (scm_arm_support)
+ {
+ dprintf(INFO, "%s:SCM call is not supported\n",__func__);
+ return -1;
+ }
+
/* Populate meta-data ptr. Here md_len is the meta-data length.
* The Code below follows a growing length approach. First send
* min(img_len_ptr,SSD_HEADER_MIN_SIZE) say 128 bytes for example.
@@ -397,6 +455,12 @@
ssd_decrypt_img_frag_req decrypt_req;
ssd_decrypt_img_frag_rsp decrypt_rsp;
+ if (scm_arm_support)
+ {
+ dprintf(INFO, "%s:SCM call is not supported\n",__func__);
+ return -1;
+ }
+
ret = ssd_image_is_encrypted(img_ptr,img_len_ptr,&ctx_id);
switch(ret)
{
@@ -461,15 +525,30 @@
feature_version_req feature_req;
feature_version_rsp feature_rsp;
int ret = 0;
+ scmcall_arg scm_arg = {0};
+ scmcall_ret scm_ret = {0};
feature_req.feature_id = TZBSP_FVER_SSD;
- ret = scm_call(TZBSP_SVC_INFO,
- TZ_INFO_GET_FEATURE_ID,
- &feature_req,
- sizeof(feature_req),
- &feature_rsp,
- sizeof(feature_rsp));
+ if (!scm_arm_support)
+ {
+ ret = scm_call(TZBSP_SVC_INFO,
+ TZ_INFO_GET_FEATURE_ID,
+ &feature_req,
+ sizeof(feature_req),
+ &feature_rsp,
+ sizeof(feature_rsp));
+ }
+ else
+ {
+ scm_arg.x0 = MAKE_SIP_SCM_CMD(TZBSP_SVC_INFO, TZ_INFO_GET_FEATURE_ID);
+ scm_arg.x1 = MAKE_SCM_ARGS(0x1);
+ scm_arg.x2 = feature_req.feature_id;
+
+ ret = scm_call2(&scm_arg, &scm_ret);
+ feature_rsp.version = scm_ret.x1;
+ }
+
if(!ret)
*major = TZBSP_GET_FEATURE_VERSION(feature_rsp.version);
@@ -482,6 +561,12 @@
ssd_protect_keystore_req protect_req;
ssd_protect_keystore_rsp protect_rsp;
+ if (scm_arm_support)
+ {
+ dprintf(INFO, "%s:SCM call is not supported\n",__func__);
+ return -1;
+ }
+
protect_req.keystore_ptr = img_ptr;
protect_req.keystore_len = img_len;
@@ -522,6 +607,12 @@
cmd_buf = (void *)&fuse_id;
cmd_len = sizeof(fuse_id);
+ if (scm_arm_support)
+ {
+ dprintf(INFO, "%s:SCM call is not supported\n",__func__);
+ return;
+ }
+
/*no response */
resp_buf = NULL;
resp_len = 0;
@@ -543,6 +634,13 @@
uint8_t resp_buf;
uint32_t fuse_id = HLOS_IMG_TAMPER_FUSE;
+
+ if (scm_arm_support)
+ {
+ dprintf(INFO, "%s:SCM call is not supported\n",__func__);
+ return;
+ }
+
cmd_buf = (void *)&fuse_id;
cmd_len = sizeof(fuse_id);
@@ -577,6 +675,7 @@
void *resp_buf = NULL;
size_t resp_len = 0;
struct qseecom_save_partition_hash_req req;
+ scmcall_arg scm_arg = {0};
/*no response */
resp_buf = NULL;
@@ -585,12 +684,26 @@
req.partition_id = 0; /* kernel */
memcpy(req.digest, digest, sizeof(req.digest));
- svc_id = SCM_SVC_ES;
- cmd_id = SCM_SAVE_PARTITION_HASH_ID;
- cmd_buf = (void *)&req;
- cmd_len = sizeof(req);
+ if (!scm_arm_support)
+ {
+ svc_id = SCM_SVC_ES;
+ cmd_id = SCM_SAVE_PARTITION_HASH_ID;
+ cmd_buf = (void *)&req;
+ cmd_len = sizeof(req);
- scm_call(svc_id, cmd_id, cmd_buf, cmd_len, resp_buf, resp_len);
+ scm_call(svc_id, cmd_id, cmd_buf, cmd_len, resp_buf, resp_len);
+ }
+ else
+ {
+ scm_arg.x0 = MAKE_SIP_SCM_CMD(SCM_SVC_ES, SCM_SAVE_PARTITION_HASH_ID);
+ scm_arg.x1 = MAKE_SCM_ARGS(0x3, 0, SMC_PARAM_TYPE_BUFFER_READWRITE);
+ scm_arg.x2 = req.partition_id;
+ scm_arg.x3 = (uint8_t *)&req.digest;
+ scm_arg.x4 = sizeof(req.digest);
+
+ if (scm_call2(&scm_arg, NULL))
+ dprintf(CRITICAL, "Failed to Save kernel hash\n");
+ }
}
/*
@@ -612,6 +725,12 @@
uint32_t chn_id;
}__PACKED switch_ce_chn_buf;
+ if (scm_arm_support)
+ {
+ dprintf(INFO, "%s:SCM call is not supported\n",__func__);
+ return 0;
+ }
+
switch_ce_chn_buf.resource = TZ_RESOURCE_CE_AP;
switch_ce_chn_buf.chn_id = channel;
cmd_buf = (void *)&switch_ce_chn_buf;
@@ -631,6 +750,12 @@
{
int ret = 0;
+ if (scm_arm_support)
+ {
+ dprintf(INFO, "%s:SCM call is not supported\n",__func__);
+ return -1;
+ }
+
ret = scm_call_atomic(SCM_SVC_PWR, SCM_IO_DISABLE_PMIC_ARBITER, 0);
return ret;
@@ -656,17 +781,31 @@
void *cmd_buf;
size_t cmd_len;
static el1_system_param param;
+ scmcall_arg scm_arg = {0};
param.el1_x0 = dtb_offset;
param.el1_elr = kernel_entry;
- /* Command Buffer */
- cmd_buf = (void *)¶m;
- cmd_len = sizeof(el1_system_param);
-
/* Response Buffer = Null as no response expected */
dprintf(INFO, "Jumping to kernel via monitor\n");
- scm_call(svc_id, cmd_id, cmd_buf, cmd_len, NULL, 0);
+
+ if (!scm_arm_support)
+ {
+ /* Command Buffer */
+ cmd_buf = (void *)¶m;
+ cmd_len = sizeof(el1_system_param);
+
+ scm_call(svc_id, cmd_id, cmd_buf, cmd_len, NULL, 0);
+ }
+ else
+ {
+ scm_arg.x0 = MAKE_SIP_SCM_CMD(SCM_SVC_MILESTONE_32_64_ID, SCM_SVC_MILESTONE_CMD_ID);
+ scm_arg.x1 = MAKE_SCM_ARGS(0x2, SMC_PARAM_TYPE_BUFFER_READ);
+ scm_arg.x2 = (void *)¶m;
+ scm_arg.x3 = sizeof(el1_system_param);
+
+ scm_call2(&scm_arg, NULL);
+ }
/* Assert if execution ever reaches here */
dprintf(CRITICAL, "Failed to jump to kernel\n");
@@ -678,19 +817,36 @@
{
int ret;
struct tz_prng_data data;
+ scmcall_arg scm_arg = {0};
- data.out_buf = (uint8_t*) rbuf;
- data.out_buf_size = r_len;
+ if (!scm_arm_support)
+ {
+ data.out_buf = (uint8_t*) rbuf;
+ data.out_buf_size = r_len;
- /*
- * random buffer must be flushed/invalidated before and after TZ call.
- */
- arch_clean_invalidate_cache_range((addr_t) rbuf, r_len);
+ /*
+ * random buffer must be flushed/invalidated before and after TZ call.
+ */
+ arch_clean_invalidate_cache_range((addr_t) rbuf, r_len);
- ret = scm_call(TZ_SVC_CRYPTO, PRNG_CMD_ID, &data, sizeof(data), NULL, 0);
+ ret = scm_call(TZ_SVC_CRYPTO, PRNG_CMD_ID, &data, sizeof(data), NULL, 0);
- /* Invalidate the updated random buffer */
- arch_clean_invalidate_cache_range((addr_t) rbuf, r_len);
+ /* Invalidate the updated random buffer */
+ arch_clean_invalidate_cache_range((addr_t) rbuf, r_len);
+ }
+ else
+ {
+ scm_arg.x0 = MAKE_SIP_SCM_CMD(TZ_SVC_CRYPTO, PRNG_CMD_ID);
+ scm_arg.x1 = MAKE_SCM_ARGS(0x2,SMC_PARAM_TYPE_BUFFER_READWRITE);
+ scm_arg.x2 = (uint8_t *) rbuf;
+ scm_arg.x3 = r_len;
+
+ ret = scm_call2(&scm_arg, NULL);
+ if (!ret)
+ arch_clean_invalidate_cache_range((addr_t) rbuf, r_len);
+ else
+ dprintf(CRITICAL, "Secure canary SCM failed: %x\n", ret);
+ }
return ret;
}
@@ -714,12 +870,26 @@
uint32_t ret = 0;
uint32_t response = 0;
tz_xpu_prot_cmd cmd;
+ scmcall_arg scm_arg = {0};
+ scmcall_ret scm_ret = {0};
- cmd.config = ERR_FATAL_ENABLE;
- cmd.spare = 0;
+ if (!scm_arm_support)
+ {
+ cmd.config = ERR_FATAL_ENABLE;
+ cmd.spare = 0;
- ret = scm_call(SVC_MEMORY_PROTECTION, XPU_ERR_FATAL, &cmd, sizeof(cmd), &response,
- sizeof(response));
+ ret = scm_call(SVC_MEMORY_PROTECTION, XPU_ERR_FATAL, &cmd, sizeof(cmd), &response,
+ sizeof(response));
+ }
+ else
+ {
+ scm_arg.x0 = MAKE_SIP_SCM_CMD(SVC_MEMORY_PROTECTION, XPU_ERR_FATAL);
+ scm_arg.x1 = MAKE_SCM_ARGS(0x2);
+ scm_arg.x2 = ERR_FATAL_ENABLE;
+ scm_arg.x3 = 0x0;
+ ret = scm_call2(&scm_arg, &scm_ret);
+ response = scm_ret.x1;
+ }
if (ret)
dprintf(CRITICAL, "Failed to set XPU violations as fatal errors: %u\n", response);
@@ -728,3 +898,74 @@
return ret;
}
+
+static uint32_t scm_call_a32(uint32_t x0, uint32_t x1, uint32_t x2, uint32_t x3, uint32_t x4, uint32_t x5, scmcall_ret *ret)
+{
+ register uint32_t r0 __asm__("r0") = x0;
+ register uint32_t r1 __asm__("r1") = x1;
+ register uint32_t r2 __asm__("r2") = x2;
+ register uint32_t r3 __asm__("r3") = x3;
+ register uint32_t r4 __asm__("r4") = x4;
+ register uint32_t r5 __asm__("r5") = x5;
+
+ __asm__ volatile(
+ __asmeq("%0", "r0")
+ __asmeq("%1", "r1")
+ __asmeq("%2", "r2")
+ __asmeq("%3", "r3")
+ __asmeq("%4", "r0")
+ __asmeq("%5", "r1")
+ __asmeq("%6", "r2")
+ __asmeq("%7", "r3")
+ __asmeq("%8", "r4")
+ __asmeq("%9", "r5")
+ "smc #0 @ switch to secure world\n"
+ : "=r" (r0), "=r" (r1), "=r" (r2), "=r" (r3)
+ : "r" (r0), "r" (r1), "r" (r2), "r" (r3), "r" (r4), "r" (r5));
+
+ if (ret)
+ {
+ ret->x1 = r1;
+ ret->x2 = r2;
+ ret->x3 = r3;
+ }
+
+ return r0;
+}
+
+uint32_t scm_call2(scmcall_arg *arg, scmcall_ret *ret)
+{
+ uint32_t *indir_arg = NULL;
+ uint32_t x5;
+ int i;
+ uint32_t rc;
+
+ arg->x0 = arg->atomic ? (arg->x0 | SCM_ATOMIC_BIT) : arg->x0;
+ x5 = arg->x5[0];
+
+ if ((arg->x1 & 0xF) > SCM_MAX_ARG_LEN)
+ {
+ indir_arg = memalign(CACHE_LINE, (SCM_INDIR_MAX_LEN * sizeof(uint32_t)));
+ ASSERT(indir_arg);
+
+ for (i = 0 ; i < SCM_INDIR_MAX_LEN; i++)
+ {
+ indir_arg[i] = arg->x5[i];
+ }
+ arch_clean_invalidate_cache_range((addr_t) indir_arg, ROUNDUP((SCM_INDIR_MAX_LEN * sizeof(uint32_t)), CACHE_LINE));
+ x5 = (addr_t) indir_arg;
+ }
+
+ rc = scm_call_a32(arg->x0, arg->x1, arg->x2, arg->x3, arg->x4, x5, ret);
+
+ if (rc)
+ {
+ dprintf(CRITICAL, "SCM call: 0x%x failed with :%x\n", arg->x0, rc);
+ return rc;
+ }
+
+ if (indir_arg)
+ free(indir_arg);
+
+ return 0;
+}
diff --git a/platform/msm_shared/sdhci.c b/platform/msm_shared/sdhci.c
index e9f4e0d..8f6a86e 100644
--- a/platform/msm_shared/sdhci.c
+++ b/platform/msm_shared/sdhci.c
@@ -438,10 +438,11 @@
do {
int_status = REG_READ16(host, SDHCI_NRML_INT_STS_REG);
- int_status &= SDHCI_INT_STS_CMD_COMPLETE;
- if (int_status == SDHCI_INT_STS_CMD_COMPLETE)
+ if (int_status & SDHCI_INT_STS_CMD_COMPLETE)
break;
+ else if (int_status & SDHCI_ERR_INT_STAT_MASK && !host->tuning_in_progress)
+ goto err;
/*
* If Tuning is in progress ignore cmd crc, cmd timeout & cmd end bit errors
@@ -497,13 +498,14 @@
if (cmd->data_present || cmd->resp_type == SDHCI_CMD_RESP_R1B) {
do {
int_status = REG_READ16(host, SDHCI_NRML_INT_STS_REG);
- int_status &= SDHCI_INT_STS_TRANS_COMPLETE;
if (int_status & SDHCI_INT_STS_TRANS_COMPLETE)
{
trans_complete = 1;
break;
}
+ else if (int_status & SDHCI_ERR_INT_STAT_MASK && !host->tuning_in_progress)
+ goto err;
/*
* If we are in tuning then we need to wait until Data timeout , Data end
diff --git a/platform/msm_shared/smd.c b/platform/msm_shared/smd.c
index 6377e7e..dfb5b62 100644
--- a/platform/msm_shared/smd.c
+++ b/platform/msm_shared/smd.c
@@ -167,8 +167,20 @@
return -1;
}
- /* Clear the data_written flag */
- ch->port_info->ch1.data_written = 0;
+ /* Wait until the data updated in the smd buffer is equal to smd packet header*/
+ while ((ch->port_info->ch1.write_index - ch->port_info->ch1.read_index) < sizeof(smd_pkt_hdr))
+ {
+ /* Get the update info from memory */
+ arch_invalidate_cache_range((addr_t) ch->port_info, size);
+
+ if ((ch->port_info->ch1.read_index + sizeof(smd_pkt_hdr)) >= ch->fifo_size)
+ {
+ dprintf(CRITICAL, "At %d:%s:RX channel read index [%u] is greater than RX fifo size[%u]\n",
+ __LINE__,__func__, ch->port_info->ch1.read_index, ch->fifo_size);
+ return -1;
+ }
+ }
+
arch_invalidate_cache_range((addr_t)(ch->recv_buf + ch->port_info->ch1.read_index), sizeof(smd_hdr));
@@ -177,6 +189,21 @@
*len = smd_hdr.pkt_size;
+ /* Wait on the data being updated in SMEM before returing the response */
+ while ((ch->port_info->ch1.write_index - ch->port_info->ch1.read_index) < smd_hdr.pkt_size)
+ {
+ /* Get the update info from memory */
+ arch_invalidate_cache_range((addr_t) ch->port_info, size);
+
+ if ((ch->port_info->ch1.read_index + sizeof(smd_hdr) + smd_hdr.pkt_size) >= ch->fifo_size)
+ {
+ dprintf(CRITICAL, "At %d:%s:RX channel read index [%u] is greater than RX fifo size[%u]\n",
+ __LINE__,__func__, ch->port_info->ch1.read_index, ch->fifo_size);
+ return -1;
+ }
+ }
+
+ /* We are good to return the response now */
return (uint8_t*)(ch->recv_buf + ch->port_info->ch1.read_index + sizeof(smd_hdr));
}
@@ -184,10 +211,12 @@
{
ch->port_info->ch1.read_index += sizeof(smd_pkt_hdr) + len;
+ /* Clear the data_written flag */
+ ch->port_info->ch1.data_written = 0;
+
/* Set the data_read flag */
- ch->port_info->ch1.data_read = 1;
+ ch->port_info->ch0.data_read = 1;
ch->port_info->ch0.mask_recv_intr = 1;
- ch->port_info->ch0.state_updated = 1;
dsb();
@@ -244,7 +273,6 @@
ch->port_info->ch0.data_written = 1;
ch->port_info->ch0.mask_recv_intr = 0;
- ch->port_info->ch0.state_updated = 1;
dsb();
diff --git a/platform/msm_shared/smem.h b/platform/msm_shared/smem.h
index 14925f5..04d82a8 100644
--- a/platform/msm_shared/smem.h
+++ b/platform/msm_shared/smem.h
@@ -370,11 +370,19 @@
MSM8216 = 248,
MSM8116 = 249,
MSM8616 = 250,
+ MSM8992 = 251,
+ APQ8092 = 252,
APQ8094 = 253,
FSM9008 = 254,
FSM9010 = 255,
FSM9016 = 256,
FSM9055 = 257,
+ MSM8209 = 258,
+ MSM8208 = 259,
+ MDM9209 = 260,
+ MDM9309 = 261,
+ MDM9609 = 262,
+ MSM8239 = 263,
};
enum platform {
diff --git a/project/msm8226.mk b/project/msm8226.mk
index a165ec1..0476594 100644
--- a/project/msm8226.mk
+++ b/project/msm8226.mk
@@ -6,7 +6,12 @@
MODULES += app/aboot
+ifeq ($(TARGET_BUILD_VARIANT),user)
+DEBUG := 0
+else
DEBUG := 1
+endif
+
EMMC_BOOT := 1
ENABLE_SDHCI_SUPPORT := 1
diff --git a/target/apq8084/include/target/display.h b/target/apq8084/include/target/display.h
index 8d6eb87..38baf50 100644
--- a/target/apq8084/include/target/display.h
+++ b/target/apq8084/include/target/display.h
@@ -106,6 +106,7 @@
#define DISPLAY_CMDLINE_PREFIX " mdss_mdp.panel="
#define MIPI_FB_ADDR 0x03200000
+#define HDMI_FB_ADDR 0x03200000
#define MIPI_HSYNC_PULSE_WIDTH 12
#define MIPI_HSYNC_BACK_PORCH_DCLK 32
diff --git a/target/apq8084/target_display.c b/target/apq8084/target_display.c
index 1dd3a66..a67e97f 100755
--- a/target/apq8084/target_display.c
+++ b/target/apq8084/target_display.c
@@ -233,7 +233,7 @@
return NO_ERROR;
}
-int target_ldo_ctrl(uint8_t enable)
+int target_ldo_ctrl(uint8_t enable, struct msm_panel_info *pinfo)
{
uint32_t ldocounter = 0;
uint32_t pm8x41_ldo_base = 0x13F00;
@@ -289,6 +289,77 @@
return NO_ERROR;
}
+int target_hdmi_panel_clock(uint8_t enable, struct msm_panel_info *pinfo)
+{
+ uint32_t ret;
+
+ dprintf(SPEW, "%s: target_panel_clock\n", __func__);
+
+ if (enable) {
+ mdp_gdsc_ctrl(enable);
+ mmss_bus_clock_enable();
+ mdp_clock_enable();
+ ret = restore_secure_cfg(SECURE_DEVICE_MDSS);
+ if (ret) {
+ dprintf(CRITICAL,
+ "%s: Failed to restore MDP security configs",
+ __func__);
+ mdp_clock_disable();
+ mmss_bus_clock_disable();
+ mdp_gdsc_ctrl(0);
+ return ret;
+ }
+
+ hdmi_phy_reset();
+ hdmi_pll_config();
+ hdmi_vco_enable();
+ hdmi_clk_enable();
+ } else if(!target_cont_splash_screen()) {
+ /* Disable clocks if continuous splash off */
+ hdmi_clk_disable();
+ hdmi_vco_disable();
+ mdp_clock_disable();
+ mmss_bus_clock_disable();
+ mdp_gdsc_ctrl(enable);
+ }
+
+ return NO_ERROR;
+}
+
+static void target_hdmi_mvs_enable(bool enable)
+{
+ struct pm8x41_mvs mvs;
+ mvs.base = PM8x41_MVS1_BASE;
+
+ if (enable)
+ pm8x41_enable_mvs(&mvs, MVS_ENABLE);
+ else
+ pm8x41_enable_mvs(&mvs, MVS_DISABLE);
+}
+
+static void target_hdmi_vreg_enable(bool enable)
+{
+ struct pm8x41_mpp mpp;
+ mpp.base = PM8x41_MMP3_BASE;
+
+ if (enable) {
+ mpp.mode = MPP_HIGH;
+ mpp.vin = MPP_VIN2;
+ pm8x41_config_output_mpp(&mpp);
+ pm8x41_enable_mpp(&mpp, MPP_ENABLE);
+ } else {
+ pm8x41_enable_mpp(&mpp, MPP_DISABLE);
+ }
+}
+
+int target_hdmi_regulator_ctrl(bool enable)
+{
+ target_hdmi_mvs_enable(enable);
+ target_hdmi_vreg_enable(enable);
+
+ return 0;
+}
+
void target_edp_panel_init(struct msm_panel_info *pinfo)
{
edp_panel_init(pinfo);
@@ -371,7 +442,7 @@
if (!strcmp(panel_name, HDMI_PANEL_NAME)) {
if (buf_size < (prefix_string_len + LK_OVERRIDE_PANEL_LEN +
- HDMI_CONTROLLER_STRING)) {
+ strlen(HDMI_CONTROLLER_STRING))) {
dprintf(CRITICAL, "command line argument is greater than buffer size\n");
return false;
}
@@ -402,6 +473,7 @@
return;
} else if (!strcmp(panel_name, HDMI_PANEL_NAME)) {
dprintf(INFO, "%s: HDMI is primary\n", __func__);
+ mdss_hdmi_display_init(MDP_REV_50, HDMI_FB_ADDR);
return;
}
diff --git a/target/ferrum/init.c b/target/ferrum/init.c
index 5e87b2e..604e0ba 100644
--- a/target/ferrum/init.c
+++ b/target/ferrum/init.c
@@ -170,3 +170,36 @@
{
}
+/* Detect the target type */
+void target_detect(struct board_data *board)
+{
+ /*
+ * already fill the board->target on board.c
+ */
+}
+
+void target_baseband_detect(struct board_data *board)
+{
+ uint32_t platform;
+
+ platform = board->platform;
+ switch(platform)
+ {
+ case MSM8909:
+ case MSM8209:
+ case MSM8208:
+ board->baseband = BASEBAND_MSM;
+ break;
+
+ case MDM9209:
+ case MDM9309:
+ case MDM9609:
+ board->baseband = BASEBAND_MDM;
+ break;
+
+ default:
+ dprintf(CRITICAL, "Platform type: %u is not supported\n", platform);
+ ASSERT(0);
+ };
+}
+
diff --git a/target/msm8226/target_display.c b/target/msm8226/target_display.c
index 355d8c9..5265f7d 100755
--- a/target/msm8226/target_display.c
+++ b/target/msm8226/target_display.c
@@ -356,7 +356,7 @@
return ret;
}
-int target_ldo_ctrl(uint8_t enable)
+int target_ldo_ctrl(uint8_t enable, struct msm_panel_info *pinfo)
{
uint32_t ret = NO_ERROR;
uint32_t ldocounter = 0;
diff --git a/target/msm8610/target_display.c b/target/msm8610/target_display.c
index 66dbbdd..0db3e9e 100755
--- a/target/msm8610/target_display.c
+++ b/target/msm8610/target_display.c
@@ -135,7 +135,7 @@
return 0;
}
-int target_ldo_ctrl(uint8_t enable)
+int target_ldo_ctrl(uint8_t enable, struct msm_panel_info *pinfo)
{
uint32_t ldocounter = 0;
uint32_t pm8x41_ldo_base = 0x13F00;
diff --git a/target/msm8916/init.c b/target/msm8916/init.c
index 2385d24..bcac813 100644
--- a/target/msm8916/init.c
+++ b/target/msm8916/init.c
@@ -341,6 +341,7 @@
case MSM8236:
case MSM8636:
case MSM8936:
+ case MSM8239:
board->baseband = BASEBAND_MSM;
break;
case APQ8016:
diff --git a/target/msm8916/target_display.c b/target/msm8916/target_display.c
index ba16ac1..644b750 100755
--- a/target/msm8916/target_display.c
+++ b/target/msm8916/target_display.c
@@ -352,7 +352,7 @@
return ret;
}
-int target_ldo_ctrl(uint8_t enable)
+int target_ldo_ctrl(uint8_t enable, struct msm_panel_info *pinfo)
{
/*
* The PMIC regulators needed for display are enabled in SBL.
diff --git a/target/msm8974/target_display.c b/target/msm8974/target_display.c
index 1c236b6..fab0122 100755
--- a/target/msm8974/target_display.c
+++ b/target/msm8974/target_display.c
@@ -279,7 +279,7 @@
return NO_ERROR;
}
-int target_ldo_ctrl(uint8_t enable)
+int target_ldo_ctrl(uint8_t enable, struct msm_panel_info *pinfo)
{
uint32_t ldocounter = 0;
uint32_t pm8x41_ldo_base = 0x13F00;
diff --git a/target/msm8994/include/target/display.h b/target/msm8994/include/target/display.h
index 70e5d76..8449ee0 100644
--- a/target/msm8994/include/target/display.h
+++ b/target/msm8994/include/target/display.h
@@ -41,7 +41,7 @@
"msmgpio", 78, 3, 1, 0, 1
};
-static struct gpio_pin enable_gpio = { /* lcd_reg_en */
+static struct gpio_pin lcd_reg_en = { /* boost regulator */
"pm8994_gpios", 14, 3, 1, 0, 1
};
diff --git a/target/msm8994/init.c b/target/msm8994/init.c
index 4a3a5c2..103853c 100644
--- a/target/msm8994/init.c
+++ b/target/msm8994/init.c
@@ -74,7 +74,7 @@
#define BOOT_DEVICE_MASK(val) ((val & 0x3E) >>1)
#define PMIC_WLED_SLAVE_ID 3
-static void set_sdc_power_ctrl(void);
+static void set_sdc_power_ctrl(uint8_t slot);
static uint32_t mmc_pwrctl_base[] =
{ MSM_SDC1_BASE, MSM_SDC2_BASE };
@@ -178,27 +178,34 @@
{
}
-static void set_sdc_power_ctrl()
+static void set_sdc_power_ctrl(uint8_t slot)
{
+ uint32_t reg = 0;
+
+ if (slot == 0x1)
+ reg = SDC1_HDRV_PULL_CTL;
+ else if (slot == 0x2)
+ reg = SDC2_HDRV_PULL_CTL;
+
/* Drive strength configs for sdc pins */
struct tlmm_cfgs sdc1_hdrv_cfg[] =
{
- { SDC1_CLK_HDRV_CTL_OFF, TLMM_CUR_VAL_16MA, TLMM_HDRV_MASK },
- { SDC1_CMD_HDRV_CTL_OFF, TLMM_CUR_VAL_10MA, TLMM_HDRV_MASK },
- { SDC1_DATA_HDRV_CTL_OFF, TLMM_CUR_VAL_10MA, TLMM_HDRV_MASK },
+ { SDC1_CLK_HDRV_CTL_OFF, TLMM_CUR_VAL_16MA, TLMM_HDRV_MASK, reg },
+ { SDC1_CMD_HDRV_CTL_OFF, TLMM_CUR_VAL_10MA, TLMM_HDRV_MASK, reg },
+ { SDC1_DATA_HDRV_CTL_OFF, TLMM_CUR_VAL_10MA, TLMM_HDRV_MASK, reg },
};
/* Pull configs for sdc pins */
struct tlmm_cfgs sdc1_pull_cfg[] =
{
- { SDC1_CLK_PULL_CTL_OFF, TLMM_NO_PULL, TLMM_PULL_MASK },
- { SDC1_CMD_PULL_CTL_OFF, TLMM_PULL_UP, TLMM_PULL_MASK },
- { SDC1_DATA_PULL_CTL_OFF, TLMM_PULL_UP, TLMM_PULL_MASK },
+ { SDC1_CLK_PULL_CTL_OFF, TLMM_NO_PULL, TLMM_PULL_MASK, reg },
+ { SDC1_CMD_PULL_CTL_OFF, TLMM_PULL_UP, TLMM_PULL_MASK, reg },
+ { SDC1_DATA_PULL_CTL_OFF, TLMM_PULL_UP, TLMM_PULL_MASK, reg },
};
struct tlmm_cfgs sdc1_rclk_cfg[] =
{
- { SDC1_RCLK_PULL_CTL_OFF, TLMM_PULL_DOWN, TLMM_PULL_MASK },
+ { SDC1_RCLK_PULL_CTL_OFF, TLMM_PULL_DOWN, TLMM_PULL_MASK, reg },
};
/* Set the drive strength & pull control values */
@@ -211,9 +218,6 @@
{
struct mmc_config_data config = {0};
- /* Set drive strength & pull ctrl values */
- set_sdc_power_ctrl();
-
config.bus_width = DATA_BUS_WIDTH_8BIT;
config.max_clk_rate = MMC_CLK_192MHZ;
@@ -224,6 +228,9 @@
config.pwr_irq = mmc_sdc_pwrctl_irq[config.slot - 1];
config.hs400_support = 1;
+ /* Set drive strength & pull ctrl values */
+ set_sdc_power_ctrl(config.slot);
+
if (!(dev = mmc_init(&config)))
{
/* Try slot 2 */
@@ -233,6 +240,9 @@
config.pwrctl_base = mmc_pwrctl_base[config.slot - 1];
config.pwr_irq = mmc_sdc_pwrctl_irq[config.slot - 1];
+ /* Set drive strength & pull ctrl values */
+ set_sdc_power_ctrl(config.slot);
+
if (!(dev = mmc_init(&config)))
{
dprintf(CRITICAL, "mmc init failed!");
@@ -323,9 +333,11 @@
switch(platform) {
case MSM8994:
+ case MSM8992:
board->baseband = BASEBAND_MSM;
break;
case APQ8094:
+ case APQ8092:
board->baseband = BASEBAND_APQ;
break;
default:
diff --git a/target/msm8994/oem_panel.c b/target/msm8994/oem_panel.c
index 15049a8..f0d7ba5 100644
--- a/target/msm8994/oem_panel.c
+++ b/target/msm8994/oem_panel.c
@@ -103,6 +103,7 @@
switch (panel_id) {
case SHARP_WQXGA_DUALDSI_VIDEO_PANEL:
pan_type = PANEL_TYPE_DSI;
+ pinfo->lcd_reg_en = 0;
panelstruct->paneldata = &sharp_wqxga_dualdsi_video_panel_data;
panelstruct->paneldata->panel_operating_mode = 11;
panelstruct->paneldata->panel_with_enable_gpio = 0;
@@ -126,6 +127,7 @@
break;
case JDI_QHD_DUALDSI_VIDEO_PANEL:
pan_type = PANEL_TYPE_DSI;
+ pinfo->lcd_reg_en = 1;
panelstruct->paneldata = &jdi_qhd_dualdsi_video_panel_data;
panelstruct->panelres = &jdi_qhd_dualdsi_video_panel_res;
panelstruct->color = &jdi_qhd_dualdsi_video_color;
@@ -151,6 +153,7 @@
break;
case JDI_QHD_DUALDSI_CMD_PANEL:
pan_type = PANEL_TYPE_DSI;
+ pinfo->lcd_reg_en = 1;
panelstruct->paneldata = &jdi_qhd_dualdsi_cmd_panel_data;
panelstruct->panelres = &jdi_qhd_dualdsi_cmd_panel_res;
panelstruct->color = &jdi_qhd_dualdsi_cmd_color;
diff --git a/target/msm8994/target_display.c b/target/msm8994/target_display.c
index 57dfe20..43612bc 100644
--- a/target/msm8994/target_display.c
+++ b/target/msm8994/target_display.c
@@ -124,7 +124,7 @@
return NO_ERROR;
}
-void lcd_reg_en(void)
+void lcd_reg_enable(void)
{
struct pm8x41_gpio gpio = {
.direction = PM_GPIO_DIR_OUT,
@@ -134,8 +134,13 @@
.out_strength = PM_GPIO_OUT_DRIVE_MED,
};
- pm8x41_gpio_config(14, &gpio);
- pm8x41_gpio_set(14, 1);
+ pm8x41_gpio_config(lcd_reg_en.pin_id, &gpio);
+ pm8x41_gpio_set(lcd_reg_en.pin_id, 1);
+}
+
+void lcd_reg_disable(void)
+{
+ pm8x41_gpio_set(lcd_reg_en.pin_id, 0);
}
int target_backlight_ctrl(struct backlight *bl, uint8_t enable)
@@ -250,14 +255,20 @@
return NO_ERROR;
}
-int target_ldo_ctrl(uint8_t enable)
+int target_ldo_ctrl(uint8_t enable, struct msm_panel_info *pinfo)
{
if (enable) {
regulator_enable(); /* L2, L12, L14, and L28 */
mdelay(10);
qpnp_ibb_enable(true); /* +5V and -5V */
mdelay(50);
+
+ if (pinfo->lcd_reg_en)
+ lcd_reg_enable();
} else {
+ if (pinfo->lcd_reg_en)
+ lcd_reg_disable();
+
regulator_disable();
}
diff --git a/target/target_display.c b/target/target_display.c
index bac8a52..a4e15e2 100644
--- a/target/target_display.c
+++ b/target/target_display.c
@@ -1,4 +1,4 @@
-/* Copyright (c) 2012-2013, The Linux Foundation. All rights reserved.
+/* Copyright (c) 2012-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
@@ -62,6 +62,10 @@
{
return 0;
}
+__WEAK int target_ldo_ctrl(uint8_t enable, struct msm_panel_info *pinfo)
+{
+ return 0;
+}
__WEAK void target_edp_panel_init(struct msm_panel_info *pinfo)
{
@@ -87,3 +91,17 @@
{
return 0;
}
+
+__WEAK int target_hdmi_panel_clock(uint8_t enable, struct msm_panel_info *pinfo)
+{
+ return 0;
+}
+
+__WEAK int target_hdmi_regulator_ctrl(bool enable)
+{
+ return 0;
+}
+__WEAK int mdss_hdmi_init(void)
+{
+ return 0;
+}