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

Commit 1b235ff0 authored by Rama Krishna Phani A's avatar Rama Krishna Phani A Committed by Gerrit - the friendly Code Review server
Browse files

msm: mhi_dev: Add cv2x HW channel support in MHI driver



CV2X channels are used to transfer latency sensitive information
between host and modem using the IPA HW-accelerated path.

Change-Id: I3fd15de5115c4e861469f19623a7d81893020f4a
Signed-off-by: default avatarRama Krishna Phani A <rphani@codeaurora.org>
parent 8517bb17
Loading
Loading
Loading
Loading
+20 −6
Original line number Original line Diff line number Diff line
@@ -44,7 +44,6 @@
#define MHI_RING_PRIMARY_EVT_ID		1
#define MHI_RING_PRIMARY_EVT_ID		1
#define MHI_1K_SIZE			0x1000
#define MHI_1K_SIZE			0x1000
/* Updated Specification for event start is NER - 2 and end - NER -1 */
/* Updated Specification for event start is NER - 2 and end - NER -1 */
#define MHI_HW_ACC_EVT_RING_START	3
#define MHI_HW_ACC_EVT_RING_END		1
#define MHI_HW_ACC_EVT_RING_END		1


#define MHI_HOST_REGION_NUM             2
#define MHI_HOST_REGION_NUM             2
@@ -306,7 +305,7 @@ static void mhi_dev_get_erdb_db_cfg(struct mhi_dev *mhi,
		break;
		break;
	default:
	default:
		erdb_cfg->base = mhi->cfg.event_rings -
		erdb_cfg->base = mhi->cfg.event_rings -
					MHI_HW_ACC_EVT_RING_START;
					(mhi->cfg.hw_event_rings);
		erdb_cfg->end =  mhi->cfg.event_rings -
		erdb_cfg->end =  mhi->cfg.event_rings -
					MHI_HW_ACC_EVT_RING_END;
					MHI_HW_ACC_EVT_RING_END;
		break;
		break;
@@ -496,17 +495,32 @@ static int mhi_hwc_chcmd(struct mhi_dev *mhi, uint chid,
	case MHI_DEV_RING_EL_START:
	case MHI_DEV_RING_EL_START:
		connect_params.channel_id = chid;
		connect_params.channel_id = chid;
		connect_params.sys.skip_ep_cfg = true;
		connect_params.sys.skip_ep_cfg = true;
		if (chid == MHI_CLIENT_ADPL_IN)

		switch (chid) {
		case MHI_CLIENT_ADPL_IN:
			connect_params.sys.client = IPA_CLIENT_MHI_DPL_CONS;
			connect_params.sys.client = IPA_CLIENT_MHI_DPL_CONS;
		else if ((chid % 2) == 0x0)
			break;
		case MHI_CLIENT_IP_HW_0_OUT:
			connect_params.sys.client = IPA_CLIENT_MHI_PROD;
			connect_params.sys.client = IPA_CLIENT_MHI_PROD;
		else
			break;
		case MHI_CLIENT_IP_HW_0_IN:
			connect_params.sys.client = IPA_CLIENT_MHI_CONS;
			connect_params.sys.client = IPA_CLIENT_MHI_CONS;
			break;
		case MHI_CLIENT_IP_HW_1_OUT:
			connect_params.sys.client = IPA_CLIENT_MHI2_PROD;
			break;
		case MHI_CLIENT_IP_HW_1_IN:
			connect_params.sys.client = IPA_CLIENT_MHI2_CONS;
			break;
		default:
			pr_err("Invalid channel = 0x%X\n", chid);
			return -EINVAL;
		}


		rc = ipa_mhi_connect_pipe(&connect_params,
		rc = ipa_mhi_connect_pipe(&connect_params,
			&mhi->ipa_clnt_hndl[chid-HW_CHANNEL_BASE]);
			&mhi->ipa_clnt_hndl[chid-HW_CHANNEL_BASE]);
		if (rc)
		if (rc)
			pr_err("HW Channel%d start failed 0x%X\n",
			pr_err("HW Channel%d start failed : %d\n",
							chid, rc);
							chid, rc);
		break;
		break;
	case MHI_DEV_RING_EL_INVALID:
	case MHI_DEV_RING_EL_INVALID:
+1 −0
Original line number Original line Diff line number Diff line
@@ -263,6 +263,7 @@ struct mhi_config {
	uint32_t	mhi_reg_len;
	uint32_t	mhi_reg_len;
	uint32_t	version;
	uint32_t	version;
	uint32_t	event_rings;
	uint32_t	event_rings;
	uint32_t	hw_event_rings;
	uint32_t	channels;
	uint32_t	channels;
	uint32_t	chdb_offset;
	uint32_t	chdb_offset;
	uint32_t	erdb_offset;
	uint32_t	erdb_offset;
+3 −3
Original line number Original line Diff line number Diff line
/* Copyright (c) 2015, 2017-2018, The Linux Foundation. All rights reserved.
/* Copyright (c) 2015, 2017-2019, The Linux Foundation. All rights reserved.
 *
 *
 * This program is free software; you can redistribute it and/or modify
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 and
 * it under the terms of the GNU General Public License version 2 and
@@ -65,8 +65,8 @@
#define MHIVER_MHIVER_SHIFT				0x0
#define MHIVER_MHIVER_SHIFT				0x0


#define MHICFG						(0x0110)
#define MHICFG						(0x0110)
#define MHICFG_RESERVED_BITS31_24_MASK			0xff000000
#define MHICFG_NHWER_MASK			0xff000000
#define MHICFG_RESERVED_BITS31_24_SHIFT			0x18
#define MHICFG_NHWER_SHIFT			0x18
#define MHICFG_NER_MASK					0xff0000
#define MHICFG_NER_MASK					0xff0000
#define MHICFG_NER_SHIFT				0x10
#define MHICFG_NER_SHIFT				0x10
#define MHICFG_RESERVED_BITS15_8_MASK			0xff00
#define MHICFG_RESERVED_BITS15_8_MASK			0xff00
+6 −1
Original line number Original line Diff line number Diff line
/* Copyright (c) 2015, 2017-2018, The Linux Foundation. All rights reserved.
/* Copyright (c) 2015, 2017-2019, The Linux Foundation. All rights reserved.
 *
 *
 * This program is free software; you can redistribute it and/or modify
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 and
 * it under the terms of the GNU General Public License version 2 and
@@ -953,6 +953,11 @@ int mhi_dev_mmio_init(struct mhi_dev *dev)
	if (rc)
	if (rc)
		return rc;
		return rc;


	rc = mhi_dev_mmio_masked_read(dev, MHICFG, MHICFG_NHWER_MASK,
				MHICFG_NHWER_SHIFT, &dev->cfg.hw_event_rings);
	if (rc)
		return rc;

	rc = mhi_dev_mmio_read(dev, CHDBOFF, &dev->cfg.chdb_offset);
	rc = mhi_dev_mmio_read(dev, CHDBOFF, &dev->cfg.chdb_offset);
	if (rc)
	if (rc)
		return rc;
		return rc;
+24 −0
Original line number Original line Diff line number Diff line
@@ -38,6 +38,7 @@
#define MAX_NR_TRBS_PER_CHAN		9
#define MAX_NR_TRBS_PER_CHAN		9
#define MHI_QTI_IFACE_ID		4
#define MHI_QTI_IFACE_ID		4
#define MHI_ADPL_IFACE_ID		5
#define MHI_ADPL_IFACE_ID		5
#define MHI_CV2X_IFACE_ID		6
#define DEVICE_NAME			"mhi"
#define DEVICE_NAME			"mhi"
#define MAX_DEVICE_NAME_SIZE		80
#define MAX_DEVICE_NAME_SIZE		80


@@ -1576,6 +1577,29 @@ static long mhi_uci_client_ioctl(struct file *file, unsigned int cmd,
		uci_log(UCI_DBG_DBG, "DPL ipa_prod_idx:%d\n",
		uci_log(UCI_DBG_DBG, "DPL ipa_prod_idx:%d\n",
			epinfo.ipa_ep_pair.prod_pipe_num);
			epinfo.ipa_ep_pair.prod_pipe_num);


		rc = copy_to_user((void __user *)arg, &epinfo,
			sizeof(epinfo));
		if (rc)
			uci_log(UCI_DBG_ERROR, "copying to user space failed");
	} else if (cmd == MHI_UCI_CV2X_EP_LOOKUP) {
		uci_log(UCI_DBG_DBG, "CV2X EP_LOOKUP for client:%d\n",
						uci_handle->client_index);
		epinfo.ph_ep_info.ep_type = DATA_EP_TYPE_PCIE;
		epinfo.ph_ep_info.peripheral_iface_id = MHI_CV2X_IFACE_ID;
		epinfo.ipa_ep_pair.cons_pipe_num =
			ipa_get_ep_mapping(IPA_CLIENT_MHI2_PROD);
		epinfo.ipa_ep_pair.prod_pipe_num =
			ipa_get_ep_mapping(IPA_CLIENT_MHI2_CONS);

		uci_log(UCI_DBG_DBG, "client:%d ep_type:%d intf:%d\n",
			uci_handle->client_index,
			epinfo.ph_ep_info.ep_type,
			epinfo.ph_ep_info.peripheral_iface_id);

		uci_log(UCI_DBG_DBG, "ipa_cons2_idx:%d ipa_prod2_idx:%d\n",
			epinfo.ipa_ep_pair.cons_pipe_num,
			epinfo.ipa_ep_pair.prod_pipe_num);

		rc = copy_to_user((void __user *)arg, &epinfo,
		rc = copy_to_user((void __user *)arg, &epinfo,
			sizeof(epinfo));
			sizeof(epinfo));
		if (rc)
		if (rc)
Loading