Expose power up/down reason and memory info
Root cause:N/A
How to fix:N/A
Feature:ARFP3-91: Expose power up and power down reason
ARFP3-77: Expose main memory hardware revision
RiskArea: power on,memory
Change-Id: I62242576e233d5c92025a97f46246b924b19bba8
diff --git a/arch/arm64/include/asm/processor.h b/arch/arm64/include/asm/processor.h
index e9ba70a..6c48116 100644
--- a/arch/arm64/include/asm/processor.h
+++ b/arch/arm64/include/asm/processor.h
@@ -81,7 +81,12 @@
#define ARCH_LOW_ADDRESS_LIMIT (arm64_dma_phys_limit - 1)
extern unsigned int boot_reason;
+/*[TracyChui] Expose power up/down reason and memory info 20200615 start */
+extern unsigned int qpnp_pon_reason_extern;
+extern unsigned int qpnp_poff_reason_extern;
extern unsigned int cold_boot;
+extern char ddr_vendor[32];
+/*[TracyChui] Expose power up/down reason and memory info 20200615 end */
struct debug_info {
/* Have we suspended stepping by a debugger? */
diff --git a/drivers/input/misc/qpnp-power-on.c b/drivers/input/misc/qpnp-power-on.c
index 65379ed..02b3c15 100644
--- a/drivers/input/misc/qpnp-power-on.c
+++ b/drivers/input/misc/qpnp-power-on.c
@@ -313,6 +313,10 @@
[39] = "Triggered from S3_RESET_KPDPWR_ANDOR_RESIN (power key and/or reset line)",
};
+/*[TracyChui] Expose power up/down reason and memory info 20200615 start */
+unsigned int qpnp_pon_reason_extern=0;
+unsigned int qpnp_poff_reason_extern=0;
+/*[TracyChui] Expose power up/down reason and memory info 20200615 end */
static int
qpnp_pon_masked_write(struct qpnp_pon *pon, u16 addr, u8 mask, u8 val)
{
@@ -2287,8 +2291,17 @@
goto err_out;
}
+/*[TracyChui] Expose power up/down reason and memory info 20200615 start */
+#if 1
+ if (sys_reset) {
+ boot_reason = ffs(pon_sts);
+ qpnp_pon_reason_extern = ffs(pon_sts);
+ }
+#else
if (sys_reset)
boot_reason = ffs(pon_sts);
+#endif
+/*[TracyChui] Expose power up/down reason and memory info 20200615 end */
index = ffs(pon_sts) - 1;
cold_boot = !qpnp_pon_is_warm_reset();
@@ -2322,6 +2335,11 @@
}
poff_sts = buf[0] | (buf[1] << 8);
}
+/*[TracyChui] Expose power up/down reason and memory info 20200615 start */
+ if (sys_reset) {
+ qpnp_poff_reason_extern = ffs(poff_sts);
+ }
+/*[TracyChui] Expose power up/down reason and memory info 20200615 end */
index = ffs(poff_sts) - 1 + reason_index_offset;
if (index >= ARRAY_SIZE(qpnp_poff_reason) || index < 0) {
dev_info(&pon->pdev->dev,
diff --git a/drivers/soc/qcom/socinfo.c b/drivers/soc/qcom/socinfo.c
index 7dee607..661544c 100644
--- a/drivers/soc/qcom/socinfo.c
+++ b/drivers/soc/qcom/socinfo.c
@@ -2007,6 +2007,67 @@
}
}
+/*[TracyChui] Expose power up/down reason and memory info 20200615 start */
+char ddr_vendor[32] = "";
+//BOOT.BF.3.3.2\boot_images\core\api\boot\ddr_common.h
+typedef enum
+{
+ RESERVED_0, /**< Reserved for future use. */
+ SAMSUNG, /**< Samsung. */
+ QIMONDA, /**< Qimonda. */
+ ELPIDA, /**< Elpida Memory, Inc. */
+ ETRON, /**< Etron Technology, Inc. */
+ NANYA, /**< Nanya Technology Corporation. */
+ HYNIX, /**< Hynix Semiconductor Inc. */
+ MOSEL, /**< Mosel Vitelic Corporation. */
+ WINBOND, /**< Winbond Electronics Corp. */
+ ESMT, /**< Elite Semiconductor Memory Technology Inc. */
+ RESERVED_1, /**< Reserved for future use. */
+ SPANSION, /**< Spansion Inc. */
+ SST, /**< Silicon Storage Technology, Inc. */
+ ZMOS, /**< ZMOS Technology, Inc. */
+ INTEL, /**< Intel Corporation. */
+ NUMONYX = 254, /**< Numonyx, acquired by Micron Technology, Inc. */
+ MICRON = 255, /**< Micron Technology, Inc. */
+ DDR_MANUFACTURES_MAX = 0x7FFFFFFF /**< Forces the enumerator to 32 bits. */
+} DDR_MANUFACTURES;
+
+//uint32_t smem_get_ddr_manufacturer_id()
+void smem_get_ddr_manufacturer_id(unsigned char *buf)
+{
+ unsigned int *manufacturer_id;
+ unsigned int manufacturer_id_len = sizeof(manufacturer_id);
+
+ manufacturer_id = smem_get_entry(SMEM_ID_VENDOR2, &manufacturer_id_len, 0,
+ SMEM_ANY_HOST_FLAG);
+ if (manufacturer_id == NULL)
+ {
+ pr_err("[B]%s(%d): Failed to read SMEM_ID_VENDOR2\n", __func__, __LINE__);
+ }
+
+ switch(*manufacturer_id)
+ {
+ case SAMSUNG:
+ snprintf((char *)buf, 64, "SAMSUNG");
+ break;
+ case ELPIDA:
+ snprintf((char *)buf, 64, "ELPIDA");
+ break;
+ case HYNIX:
+ snprintf((char *)buf, 64, "HYNIX");
+ break;
+ case MICRON:
+ snprintf((char *)buf, 64, "MICRON");
+ break;
+ default:
+ snprintf((char *)buf, 64, "OTHERS");
+ break;
+ }
+
+ pr_err("[B]%s(%d): manufacturer_id=%d, %s\n", __func__, __LINE__, *manufacturer_id, buf);
+}
+/*[TracyChui] Expose power up/down reason and memory info 20200615 end */
+
int __init socinfo_init(void)
{
static bool socinfo_init_done;
@@ -2036,6 +2097,12 @@
arch_read_hardware_id = msm_read_hardware_id;
socinfo_init_done = true;
+/*[TracyChui] Expose power up/down reason and memory info 20200615 start */
+ memset(ddr_vendor, 0, sizeof(ddr_vendor));
+ smem_get_ddr_manufacturer_id((unsigned char *) ddr_vendor);
+ pr_err("[B]%s(%d): ddr_vendor=%s\n", __func__, __LINE__, ddr_vendor);
+/*[TracyChui] Expose power up/down reason and memory info 20200615 end */
+
return 0;
}
subsys_initcall(socinfo_init);
diff --git a/kernel/sysctl.c b/kernel/sysctl.c
index f3a22c9..81e0209 100644
--- a/kernel/sysctl.c
+++ b/kernel/sysctl.c
@@ -66,6 +66,9 @@
#include <linux/kexec.h>
#include <linux/bpf.h>
#include <linux/mount.h>
+/*[TracyChui] Expose power up/down reason and memory info 20200615 start */
+#include <soc/qcom/smem.h>
+/*[TracyChui] Expose power up/down reason and memory info 20200615 end */
#include <asm/uaccess.h>
#include <asm/processor.h>
@@ -230,6 +233,10 @@
static struct ctl_table fs_table[];
static struct ctl_table debug_table[];
static struct ctl_table dev_table[];
+/*[TracyChui] Expose power up/down reason and memory info 20200615 start */
+static struct ctl_table qpnp_power_on_table[];
+static struct ctl_table ddr_table[];
+/*[TracyChui] Expose power up/down reason and memory info 20200615 end */
extern struct ctl_table random_table[];
#ifdef CONFIG_EPOLL
extern struct ctl_table epoll_table[];
@@ -267,6 +274,13 @@
.mode = 0555,
.child = dev_table,
},
+/*[TracyChui] Expose power up/down reason and memory info 20200615 start */
+ {
+ .procname = "qpnp-power-on",
+ .mode = 0555,
+ .child = qpnp_power_on_table,
+ },
+/*[TracyChui] Expose power up/down reason and memory info 20200615 end */
{ }
};
@@ -2089,8 +2103,42 @@
};
static struct ctl_table dev_table[] = {
+ {
+ .procname = "ddr",
+ .mode = 0555,
+ .child = ddr_table,
+ },
{ }
};
+/*[TracyChui] Expose power up/down reason and memory info 20200615 start */
+static struct ctl_table qpnp_power_on_table[] = {
+ {
+ .procname = "pon_reason",
+ .data = &qpnp_pon_reason_extern,
+ .maxlen = sizeof(int),
+ .mode = 0444,
+ .proc_handler = proc_dointvec,
+ },
+ {
+ .procname = "poff_reason",
+ .data = &qpnp_poff_reason_extern,
+ .maxlen = sizeof(int),
+ .mode = 0444,
+ .proc_handler = proc_dointvec,
+ },
+ { }
+};
+static struct ctl_table ddr_table[] = {
+ {
+ .procname = "vendor",
+ .data = &ddr_vendor,
+ .maxlen = 32,
+ .mode = 0444,
+ .proc_handler = proc_dostring,
+ },
+ { }
+};
+/*[TracyChui] Expose power up/down reason and memory info 20200615 end */
int __init sysctl_init(void)
{