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

Commit c43d2d05 authored by Linux Build Service Account's avatar Linux Build Service Account Committed by Gerrit - the friendly Code Review server
Browse files

Merge "msm: mhi: Fix issues regarding BHI img load"

parents 71362bb1 e346352b
Loading
Loading
Loading
Loading
+21 −13
Original line number Diff line number Diff line
@@ -73,6 +73,7 @@ static ssize_t bhi_write(struct file *file,
		goto bhi_copy_error;
	}
	amount_copied = count;
	wmb();
	mhi_log(MHI_MSG_INFO,
		"Copied image from user at addr: %p\n", bhi_ctxt->image_loc);
	bhi_ctxt->phy_image_loc = dma_map_single(NULL,
@@ -114,13 +115,20 @@ static ssize_t bhi_write(struct file *file,
	mhi_reg_write_field(mhi_dev_ctxt, bhi_ctxt->bhi_base,
			BHI_IMGTXDB, 0xFFFFFFFF, 0, ++pcie_word_val);

	mhi_reg_write(mhi_dev_ctxt, bhi_ctxt->bhi_base, BHI_INTVEC, 0);

	for (i = 0; i < BHI_POLL_NR_RETRIES; ++i) {
		tx_db_val = mhi_reg_read(bhi_ctxt->bhi_base, BHI_STATUS);
		if ((0x80000000 | tx_db_val) == pcie_word_val)
			break;
		else
		tx_db_val = mhi_reg_read_field(bhi_ctxt->bhi_base,
						BHI_STATUS,
						BHI_STATUS_MASK,
						BHI_STATUS_SHIFT);
		mhi_log(MHI_MSG_CRITICAL, "BHI STATUS 0x%x\n", tx_db_val);
		if (BHI_STATUS_SUCCESS != tx_db_val)
			mhi_log(MHI_MSG_CRITICAL,
				"BHI STATUS 0x%x\n", pcie_word_val);
				"Incorrect BHI status: %d retry: %d\n",
				tx_db_val, i);
		else
			break;
		usleep_range(20000, 25000);
	}
	dma_unmap_single(NULL, bhi_ctxt->phy_image_loc,
@@ -157,6 +165,14 @@ int bhi_probe(struct mhi_pcie_dev_info *mhi_pcie_device)
	    || 0 == mhi_pcie_device->core.bar0_end)
		return -EIO;

	bhi_ctxt->bhi_base = mhi_pcie_device->core.bar0_base;
	pcie_word_val = mhi_reg_read(bhi_ctxt->bhi_base, BHIOFF);
	bhi_ctxt->bhi_base += pcie_word_val;
	wmb();

	mhi_log(MHI_MSG_INFO,
		"Successfully registered char dev. bhi base is: 0x%p.\n",
		bhi_ctxt->bhi_base);
	ret_val = alloc_chrdev_region(&bhi_ctxt->bhi_dev, 0, 1, "bhi");
	if (IS_ERR_VALUE(ret_val)) {
		mhi_log(MHI_MSG_CRITICAL,
@@ -184,14 +200,6 @@ int bhi_probe(struct mhi_pcie_dev_info *mhi_pcie_device)
		r = (int)bhi_ctxt->dev;
		goto err_dev_create;
	}

	bhi_ctxt->bhi_base = mhi_pcie_device->core.bar0_base;
	pcie_word_val = mhi_reg_read(bhi_ctxt->bhi_base, BHIOFF);
	bhi_ctxt->bhi_base += pcie_word_val;

	mhi_log(MHI_MSG_INFO,
		"Successfully registered char dev. bhi base is: 0x%p.\n",
		bhi_ctxt->bhi_base);
	return 0;
err_dev_create:
	cdev_del(&bhi_ctxt->cdev);
+6 −1
Original line number Diff line number Diff line
@@ -36,6 +36,11 @@
#define BHI_MSMHWID(n)                                     (0x4C + 0x4 * (n))
#define BHI_OEMPKHASH(n)                                   (0x64 + 0x4 * (n))
#define BHI_RSVD5                                          (0xC4)
#define BHI_STATUS_MASK					   (0xC0000000)
#define BHI_STATUS_SHIFT				   (30)
#define BHI_STATUS_ERROR				   (3)
#define BHI_STATUS_SUCCESS				   (2)
#define BHI_STATUS_RESET				   (0)

#define BHI_MAJOR_VERSION 0x0
#define BHI_MINOR_VERSION 0x1
@@ -48,7 +53,7 @@
#define BHI_MAX_IMAGE_SIZE (256 * 1024)

#define BHI_POLL_SLEEP_TIME 1000
#define BHI_POLL_NR_RETRIES 1
#define BHI_POLL_NR_RETRIES 10

int bhi_probe(struct mhi_pcie_dev_info *mhi_pcie_device);