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

Commit 4dc8c3c0 authored by qctecmdr's avatar qctecmdr Committed by Gerrit - the friendly Code Review server
Browse files

Merge "mhi: controller: qcom: Store serial number and oem pkhash info"

parents 44f03b80 289ec251
Loading
Loading
Loading
Loading
+53 −0
Original line number Diff line number Diff line
@@ -533,6 +533,19 @@ static int mhi_lpm_enable(struct mhi_controller *mhi_cntrl, void *priv)
	return ret;
}

void mhi_qcom_store_hwinfo(struct mhi_controller *mhi_cntrl)
{
	struct mhi_dev *mhi_dev = mhi_controller_get_devdata(mhi_cntrl);
	int i;

	mhi_dev->serial_num = readl_relaxed(mhi_cntrl->bhi +
			MHI_BHI_SERIAL_NUM_OFFS);

	for (i = 0; i < ARRAY_SIZE(mhi_dev->oem_pk_hash); i++)
		mhi_dev->oem_pk_hash[i] = readl_relaxed(mhi_cntrl->bhi +
			MHI_BHI_OEMPKHASH(i));
}

static int mhi_qcom_power_up(struct mhi_controller *mhi_cntrl)
{
	enum mhi_dev_state dev_state = mhi_get_mhi_state(mhi_cntrl);
@@ -569,6 +582,10 @@ static int mhi_qcom_power_up(struct mhi_controller *mhi_cntrl)

	ret = mhi_async_power_up(mhi_cntrl);

	/* Update modem serial Info */
	if (!ret)
		mhi_qcom_store_hwinfo(mhi_cntrl);

	/* power up create the dentry */
	if (mhi_cntrl->dentry) {
		debugfs_create_file("m0", 0444, mhi_cntrl->dentry, mhi_cntrl,
@@ -678,9 +695,45 @@ static ssize_t power_up_store(struct device *dev,
}
static DEVICE_ATTR_WO(power_up);

static ssize_t serial_info_show(struct device *dev,
				struct device_attribute *attr,
				char *buf)
{
	struct mhi_device *mhi_device = to_mhi_device(dev);
	struct mhi_controller *mhi_cntrl = mhi_device->mhi_cntrl;
	struct mhi_dev *mhi_dev = mhi_controller_get_devdata(mhi_cntrl);
	int n;

	n = scnprintf(buf, PAGE_SIZE, "Serial Number:%u\n",
		      mhi_dev->serial_num);

	return n;
}
static DEVICE_ATTR_RO(serial_info);

static ssize_t oempkhash_info_show(struct device *dev,
				struct device_attribute *attr,
				char *buf)
{
	struct mhi_device *mhi_device = to_mhi_device(dev);
	struct mhi_controller *mhi_cntrl = mhi_device->mhi_cntrl;
	struct mhi_dev *mhi_dev = mhi_controller_get_devdata(mhi_cntrl);
	int i, n = 0;

	for (i = 0; i < ARRAY_SIZE(mhi_dev->oem_pk_hash); i++)
		n += scnprintf(buf + n, PAGE_SIZE - n, "OEMPKHASH[%d]:%u\n",
		      i, mhi_dev->oem_pk_hash[i]);

	return n;
}
static DEVICE_ATTR_RO(oempkhash_info);


static struct attribute *mhi_qcom_attrs[] = {
	&dev_attr_timeout_ms.attr,
	&dev_attr_power_up.attr,
	&dev_attr_serial_info.attr,
	&dev_attr_oempkhash_info.attr,
	NULL
};

+8 −0
Original line number Diff line number Diff line
@@ -14,6 +14,10 @@
#define MHI_PCIE_VENDOR_ID (0x17cb)
#define MHI_PCIE_DEBUG_ID (0xffff)

#define MHI_BHI_SERIAL_NUM_OFFS (0x40)
#define MHI_BHI_OEMPKHASH(n) (0x64 + (0x4 * (n)))
#define MHI_BHI_OEMPKHASH_SEG (16)

/* runtime suspend timer */
#define MHI_RPM_SUSPEND_TMR_MS (250)
#define MHI_PCI_BAR_NUM (0)
@@ -49,6 +53,10 @@ struct mhi_dev {
	dma_addr_t iova_stop;
	enum mhi_suspend_mode suspend_mode;

	/* hardware info */
	u32 serial_num;
	u32 oem_pk_hash[MHI_BHI_OEMPKHASH_SEG];

	unsigned int lpm_disable_depth;
	/* lock to toggle low power modes */
	spinlock_t lpm_lock;