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

Commit 77bfb63d authored by qctecmdr Service's avatar qctecmdr Service Committed by Gerrit - the friendly Code Review server
Browse files

Merge "ARM: dts: msm: auto start Boot Log (BL) and disable its outbound channel"

parents c65f53b5 57b21993
Loading
Loading
Loading
Loading
+4 −22
Original line number Diff line number Diff line
@@ -258,17 +258,6 @@
				mhi,ee = <0x4>;
			};

			mhi_chan@24 {
				reg = <24>;
				label = "BL";
				mhi,num-elements = <64>;
				mhi,event-ring = <2>;
				mhi,chan-dir = <1>;
				mhi,data-type = <0>;
				mhi,doorbell-mode = <2>;
				mhi,ee = <0x2>;
			};

			mhi_chan@25 {
				reg = <25>;
				label = "BL";
@@ -278,6 +267,8 @@
				mhi,data-type = <0>;
				mhi,doorbell-mode = <2>;
				mhi,ee = <0x2>;
				mhi,auto-queue;
				mhi,auto-start;
			};

			mhi_chan@26 {
@@ -686,17 +677,6 @@
				mhi,ee = <0x4>;
			};

			mhi_chan@24 {
				reg = <24>;
				label = "BL";
				mhi,num-elements = <64>;
				mhi,event-ring = <2>;
				mhi,chan-dir = <1>;
				mhi,data-type = <0>;
				mhi,doorbell-mode = <2>;
				mhi,ee = <0x2>;
			};

			mhi_chan@25 {
				reg = <25>;
				label = "BL";
@@ -706,6 +686,8 @@
				mhi,data-type = <0>;
				mhi,doorbell-mode = <2>;
				mhi,ee = <0x2>;
				mhi,auto-queue;
				mhi,auto-start;
			};

			mhi_chan@26 {
+114 −0
Original line number Diff line number Diff line
@@ -11,6 +11,7 @@
 */

#include <asm/dma-iommu.h>
#include <linux/async.h>
#include <linux/debugfs.h>
#include <linux/device.h>
#include <linux/dma-direction.h>
@@ -38,6 +39,16 @@ struct arch_info {
	struct dma_iommu_mapping *mapping;
};

struct mhi_bl_info {
	struct mhi_device *mhi_device;
	async_cookie_t cookie;
	void *ipc_log;
};

/* ipc log markings */
#define DLOG "Dev->Host: "
#define HLOG "Host: "

#ifdef CONFIG_MHI_DEBUG

#define MHI_IPC_LOG_PAGES (100)
@@ -142,6 +153,107 @@ void mhi_arch_esoc_ops_power_off(void *priv, bool mdm_state)
	mhi_dev->powered_on = false;
}

static void mhi_bl_dl_cb(struct mhi_device *mhi_dev,
			 struct mhi_result *mhi_result)
{
	struct mhi_bl_info *mhi_bl_info = mhi_device_get_devdata(mhi_dev);
	char *buf = mhi_result->buf_addr;

	/* force a null at last character */
	buf[mhi_result->bytes_xferd - 1] = 0;

	ipc_log_string(mhi_bl_info->ipc_log, "%s %s", DLOG, buf);
}

static void mhi_bl_dummy_cb(struct mhi_device *mhi_dev,
			    struct mhi_result *mhi_result)
{
}

static void mhi_bl_remove(struct mhi_device *mhi_dev)
{
	struct mhi_bl_info *mhi_bl_info = mhi_device_get_devdata(mhi_dev);

	ipc_log_string(mhi_bl_info->ipc_log, HLOG "Received Remove notif.\n");

	/* wait for boot monitor to exit */
	async_synchronize_cookie(mhi_bl_info->cookie + 1);
}

static void mhi_bl_boot_monitor(void *data, async_cookie_t cookie)
{
	struct mhi_bl_info *mhi_bl_info = data;
	struct mhi_device *mhi_device = mhi_bl_info->mhi_device;
	struct mhi_controller *mhi_cntrl = mhi_device->mhi_cntrl;
	/* 15 sec timeout for booting device */
	const u32 timeout = msecs_to_jiffies(15000);

	/* wait for device to enter boot stage */
	wait_event_timeout(mhi_cntrl->state_event, mhi_cntrl->ee == MHI_EE_AMSS
			   || mhi_cntrl->ee == MHI_EE_DISABLE_TRANSITION,
			   timeout);

	if (mhi_cntrl->ee == MHI_EE_AMSS) {
		ipc_log_string(mhi_bl_info->ipc_log, HLOG
			       "Device successfully booted to mission mode\n");

		mhi_unprepare_from_transfer(mhi_device);
	} else {
		ipc_log_string(mhi_bl_info->ipc_log, HLOG
			       "Device failed to boot to mission mode, ee = %s\n",
			       TO_MHI_EXEC_STR(mhi_cntrl->ee));
	}
}

static int mhi_bl_probe(struct mhi_device *mhi_dev,
			const struct mhi_device_id *id)
{
	char node_name[32];
	struct mhi_bl_info *mhi_bl_info;

	mhi_bl_info = devm_kzalloc(&mhi_dev->dev, sizeof(*mhi_bl_info),
				   GFP_KERNEL);
	if (!mhi_bl_info)
		return -ENOMEM;

	snprintf(node_name, sizeof(node_name), "mhi_bl_%04x_%02u.%02u.%02u",
		 mhi_dev->dev_id, mhi_dev->domain, mhi_dev->bus, mhi_dev->slot);

	mhi_bl_info->ipc_log = ipc_log_context_create(MHI_IPC_LOG_PAGES,
						      node_name, 0);
	if (!mhi_bl_info->ipc_log)
		return -EINVAL;

	mhi_bl_info->mhi_device = mhi_dev;
	mhi_device_set_devdata(mhi_dev, mhi_bl_info);

	ipc_log_string(mhi_bl_info->ipc_log, HLOG
		       "Entered SBL, Session ID:0x%x\n",
		       mhi_dev->mhi_cntrl->session_id);

	/* start a thread to monitor entering mission mode */
	mhi_bl_info->cookie = async_schedule(mhi_bl_boot_monitor, mhi_bl_info);

	return 0;
}

static const struct mhi_device_id mhi_bl_match_table[] = {
	{ .chan = "BL" },
	{},
};

static struct mhi_driver mhi_bl_driver = {
	.id_table = mhi_bl_match_table,
	.remove = mhi_bl_remove,
	.probe = mhi_bl_probe,
	.ul_xfer_cb = mhi_bl_dummy_cb,
	.dl_xfer_cb = mhi_bl_dl_cb,
	.driver = {
		.name = "MHI_BL",
		.owner = THIS_MODULE,
	},
};

int mhi_arch_pcie_init(struct mhi_controller *mhi_cntrl)
{
	struct mhi_dev *mhi_dev = mhi_controller_get_devdata(mhi_cntrl);
@@ -212,6 +324,8 @@ int mhi_arch_pcie_init(struct mhi_controller *mhi_cntrl)
		/* save reference state for pcie config space */
		arch_info->ref_pcie_state = pci_store_saved_state(
							mhi_dev->pci_dev);

		mhi_driver_register(&mhi_bl_driver);
	}

	return mhi_arch_set_bus_request(mhi_cntrl, 1);
+3 −0
Original line number Diff line number Diff line
@@ -24,6 +24,9 @@
#define MHI_RPM_SUSPEND_TMR_MS (1000)
#define MHI_PCI_BAR_NUM (0)

extern const char * const mhi_ee_str[MHI_EE_MAX];
#define TO_MHI_EXEC_STR(ee) (ee >= MHI_EE_MAX ? "INVALID_EE" : mhi_ee_str[ee])

struct mhi_dev {
	struct pci_dev *pci_dev;
	u32 smmu_cfg;
+0 −1
Original line number Diff line number Diff line
@@ -653,7 +653,6 @@ static const struct mhi_device_id mhi_uci_match_table[] = {
	{ .chan = "QMI0", .driver_data = 0x1000 },
	{ .chan = "QMI1", .driver_data = 0x1000 },
	{ .chan = "TF", .driver_data = 0x1000 },
	{ .chan = "BL", .driver_data = 0x1000 },
	{ .chan = "DUN", .driver_data = 0x1000 },
	{},
};