Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit efda3d36 authored by tracychui's avatar tracychui Committed by Rohit Sekhar
Browse files

sysctl: Expose power up/down reason and memory info

Feature:ARFP3-91: Expose power up and power down reason
        ARFP3-77: Expose main memory hardware revision

Issue: FP3-A11#230
Change-Id: I62242576e233d5c92025a97f46246b924b19bba8
parent a0c85413
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -81,7 +81,10 @@ extern phys_addr_t arm64_dma_phys_limit;
#define ARCH_LOW_ADDRESS_LIMIT	(arm64_dma_phys_limit - 1)

extern unsigned int boot_reason;
extern unsigned int qpnp_pon_reason_extern;
extern unsigned int qpnp_poff_reason_extern;
extern unsigned int cold_boot;
extern char ddr_vendor[32];

struct debug_info {
	/* Have we suspended stepping by a debugger? */
+8 −1
Original line number Diff line number Diff line
@@ -313,6 +313,8 @@ static const char * const qpnp_poff_reason[] = {
	[39] = "Triggered from S3_RESET_KPDPWR_ANDOR_RESIN (power key and/or reset line)",
};

unsigned int qpnp_pon_reason_extern = 0;
unsigned int qpnp_poff_reason_extern = 0;
static int
qpnp_pon_masked_write(struct qpnp_pon *pon, u16 addr, u8 mask, u8 val)
{
@@ -2287,8 +2289,10 @@ static int qpnp_pon_probe(struct platform_device *pdev)
		goto err_out;
	}

	if (sys_reset)
	if (sys_reset) {
		boot_reason = ffs(pon_sts);
		qpnp_pon_reason_extern = ffs(pon_sts);
	}

	index = ffs(pon_sts) - 1;
	cold_boot = !qpnp_pon_is_warm_reset();
@@ -2322,6 +2326,9 @@ static int qpnp_pon_probe(struct platform_device *pdev)
		}
		poff_sts = buf[0] | (buf[1] << 8);
	}
	if (sys_reset) {
		qpnp_poff_reason_extern = ffs(poff_sts);
	}
	index = ffs(poff_sts) - 1 + reason_index_offset;
	if (index >= ARRAY_SIZE(qpnp_poff_reason) || index < 0) {
		dev_info(&pon->pdev->dev,

drivers/soc/qcom/socinfo.c

100644 → 100755
+62 −0
Original line number Diff line number Diff line
@@ -2007,6 +2007,64 @@ static void socinfo_select_format(void)
	}
}

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;

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);
}

int __init socinfo_init(void)
{
	static bool socinfo_init_done;
@@ -2036,6 +2094,10 @@ int __init socinfo_init(void)
	arch_read_hardware_id = msm_read_hardware_id;
	socinfo_init_done = true;

	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);

	return 0;
}
subsys_initcall(socinfo_init);

kernel/sysctl.c

100644 → 100755
+40 −0
Original line number Diff line number Diff line
@@ -66,6 +66,7 @@
#include <linux/kexec.h>
#include <linux/bpf.h>
#include <linux/mount.h>
#include <soc/qcom/smem.h>

#include <asm/uaccess.h>
#include <asm/processor.h>
@@ -230,6 +231,8 @@ static struct ctl_table vm_table[];
static struct ctl_table fs_table[];
static struct ctl_table debug_table[];
static struct ctl_table dev_table[];
static struct ctl_table qpnp_power_on_table[];
static struct ctl_table ddr_table[];
extern struct ctl_table random_table[];
#ifdef CONFIG_EPOLL
extern struct ctl_table epoll_table[];
@@ -267,6 +270,11 @@ static struct ctl_table sysctl_base_table[] = {
		.mode		= 0555,
		.child		= dev_table,
	},
	{
		.procname	= "qpnp-power-on",
		.mode		= 0555,
		.child		= qpnp_power_on_table,
	},
	{ }
};

@@ -2089,6 +2097,38 @@ static struct ctl_table debug_table[] = {
};

static struct ctl_table dev_table[] = {
	{
		.procname	= "ddr",
		.mode		= 0555,
		.child		= ddr_table,
	},
	{ }
};
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,
	},
	{ }
};