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

Commit 65b4b9e4 authored by Siddartha Mohanadoss's avatar Siddartha Mohanadoss
Browse files

mhi_dev: mhi: Enable IPA DMA for software channels



Update MHI device driver to distinguish between using
IPA DMA and memcpy for software channels. An
optional property qcom,use-ipa-software-channel is
added to support software channels to use IPA DMA.
On targets that do not support IPA DMA driver can
continue to use memcpy for software channel transfers.
An option property qcom,mhi-config-iatu supports
enabling iATU translation. This is needed on targets
that map and translate the MHI data and control address
region used by MHI device driver to transfer data
between device and host over PCIe.

Change-Id: I8d636ccbebf60177376ed80c614200d556e0a9a1
Signed-off-by: default avatarSiddartha Mohanadoss <smohanad@codeaurora.org>
parent 44521c71
Loading
Loading
Loading
Loading
+11 −0
Original line number Diff line number Diff line
@@ -19,6 +19,17 @@ Required properties:
  - qcom,mhi-ep-msi: End point MSI number.
  - qcom,mhi-version: MHI specification version supported by the device.

Optional property:
  - qcom,use-ipa-software-channel: If property is present use IPA hardware
		accelerated path for MHI software channel data transfers
		between host and device.
  - qcom,mhi-config-iatu: If property is present map the control and data region
		between host and device using iatu.
  - qcom,mhi-local-pa-base: The physical base address on the device used by the
		MHI device driver to map the control and data region with the
		MHI driver on the host. This property is required if iatu
		property qcom,mhi-config-iatu is present.

Example:

	mhi: qcom,msm-mhi-dev {
+357 −129

File changed.

Preview size limit exceeded, changes collapsed.

+19 −7
Original line number Diff line number Diff line
/* Copyright (c) 2015, The Linux Foundation. All rights reserved.
/* Copyright (c) 2015-2016, The Linux Foundation. All rights reserved.
 *
 * 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
@@ -322,7 +322,10 @@ struct mhi_addr {
	uint64_t	host_pa;
	uintptr_t	device_pa;
	uintptr_t	device_va;
	uint32_t	size;
	size_t		size;
	dma_addr_t	phy_addr;
	void		*virt_addr;
	bool		use_ipa_dma;
};

struct mhi_interrupt_state {
@@ -479,6 +482,7 @@ struct mhi_dev {
	struct mhi_dev_ch_ctx		*cmd_ctx_cache;
	dma_addr_t			cmd_ctx_cache_dma_handle;
	struct mhi_dev_ring		*ring;
	int				mhi_irq;
	struct mhi_dev_channel		*ch;

	int				ctrl_int;
@@ -516,6 +520,7 @@ struct mhi_dev {
	atomic_t			write_active;
	atomic_t			is_suspended;
	struct mutex			mhi_write_test;
	u32				device_local_pa_base;
	u32				mhi_ep_msi_num;
	u32				mhi_version;
	void				*dma_cache;
@@ -533,6 +538,12 @@ struct mhi_dev {
	 * region from device used in mhi_write()
	 */
	dma_addr_t			write_dma_handle;

	/* Use IPA DMA for Software channel data transfer */
	bool				use_ipa;

	/* iATU is required to map control and data region */
	bool				config_iatu;
};

enum mhi_msg_level {
@@ -756,14 +767,14 @@ int mhi_transfer_host_to_device(void *device, uint64_t src_pa, uint32_t len,
				struct mhi_dev *mhi);

/**
 * mhi_dev_write_to_host() - memcpy equivalent API to transfer data
 *		from device to host.
 * mhi_dev_write_to_host() - Transfer data from device to host.
 *		Based on support available, either IPA DMA or memcpy is used.
 * @host:	Host and device address details.
 * @buf:	Data buffer that needs to be written to the host.
 * @size:	Data buffer size.
 */
void mhi_dev_write_to_host(struct mhi_addr *host, void *buf, size_t size,
				struct mhi_dev *mhi);
void mhi_dev_write_to_host(struct mhi_dev *mhi,
				struct mhi_addr *mhi_transfer);

/**
 * mhi_dev_read_from_host() - memcpy equivalent API to transfer data
@@ -772,7 +783,8 @@ void mhi_dev_write_to_host(struct mhi_addr *host, void *buf, size_t size,
 * @buf:	Data buffer that needs to be read from the host.
 * @size:	Data buffer size.
 */
void mhi_dev_read_from_host(struct mhi_addr *dst, dma_addr_t buf, size_t size);
void mhi_dev_read_from_host(struct mhi_dev *mhi,
				struct mhi_addr *mhi_transfer);

/**
 * mhi_dev_read_from_host() - memcpy equivalent API to transfer data
+35 −29

File changed.

Preview size limit exceeded, changes collapsed.

+32 −14

File changed.

Preview size limit exceeded, changes collapsed.