All of lore.kernel.org
 help / color / mirror / Atom feed
* [RFC PATCH 1/2] fsl-mc: Added header file to provide fsl-mc bus iommu group creation
@ 2016-06-29 17:14 ` Nipun Gupta
  0 siblings, 0 replies; 16+ messages in thread
From: Nipun Gupta @ 2016-06-29 17:14 UTC (permalink / raw)
  To: will.deacon-5wv7dgnIgG8, robin.murphy-5wv7dgnIgG8,
	stuart.yoder-3arQi8VN3Tc,
	iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA,
	linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r
  Cc: Bharat Bhushan

Added a header file fsl_mc_smmu.h to provide basic support of creating
an IOMMU group for a fsl-mc type device and also provide helper macro
to get the stream ID of fsl-mc tyoe device.

Signed-off-by: Nipun Gupta <nipun.gupta-3arQi8VN3Tc@public.gmane.org>
Signed-off-by: Bharat Bhushan <bharat.bhushan-3arQi8VN3Tc@public.gmane.org>
---
 drivers/staging/fsl-mc/include/fsl_mc_smmu.h | 45 ++++++++++++++++++++++++++++
 1 file changed, 45 insertions(+)
 create mode 100644 drivers/staging/fsl-mc/include/fsl_mc_smmu.h

diff --git a/drivers/staging/fsl-mc/include/fsl_mc_smmu.h b/drivers/staging/fsl-mc/include/fsl_mc_smmu.h
new file mode 100644
index 0000000..9dff5ba
--- /dev/null
+++ b/drivers/staging/fsl-mc/include/fsl_mc_smmu.h
@@ -0,0 +1,45 @@
+/*
+ * Copyright (C) 2016 Freescale Semiconductor, Inc.
+ * Author: Nipun Gupta <nipun.gupta-KZfg59tc24xl57MIdRCFDg@public.gmane.org>
+ *
+ * This file is licensed under the terms of the GNU General Public
+ * License version 2. This program is licensed "as is" without any
+ * warranty of any kind, whether express or implied.
+ */
+
+#ifndef _FSL_MC_SMMU_H_
+#define _FSL_MC_SMMU_H_
+
+#include <../drivers/staging/fsl-mc/include/mc.h>
+
+/* Macro to get the MC device ICID (Stream ID) */
+#define fslmc_dev_streamid(_dev) (to_fsl_mc_device(_dev)->icid)
+
+/* Macro to get the container device of a MC device */
+#define fslmc_cont_dev(_dev) ((to_fsl_mc_device(dev)->flags & \
+	FSL_MC_IS_DPRC) ? (_dev) : (_dev->parent))
+
+/* Macro to check if a device is a container device */
+#define is_cont_dev(_dev) (to_fsl_mc_device(_dev)->flags & FSL_MC_IS_DPRC)
+
+static struct iommu_group *fslmc_device_group(struct device *dev)
+{
+	struct device *cont_dev = fslmc_cont_dev(dev);
+	struct iommu_group *group;
+
+	/* Container device is responsible for creating the iommu group */
+	if (is_cont_dev(dev)) {
+		group = iommu_group_alloc();
+
+		if (IS_ERR(group))
+			return NULL;
+	} else {
+		get_device(cont_dev);
+		group = iommu_group_get(cont_dev);
+		put_device(cont_dev);
+	}
+
+	return group;
+}
+
+#endif /* _FSL_MC_SMMU_H_ */
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2016-07-01 15:11 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-06-29 17:14 [RFC PATCH 1/2] fsl-mc: Added header file to provide fsl-mc bus iommu group creation Nipun Gupta
2016-06-29 17:14 ` Nipun Gupta
     [not found] ` <1467220448-16764-1-git-send-email-nipun.gupta-3arQi8VN3Tc@public.gmane.org>
2016-06-29 17:14   ` [RFC PATCH 2/2] iommu/arm-smmu: Add support for the fsl-mc bus Nipun Gupta
2016-06-29 17:14     ` Nipun Gupta
     [not found]     ` <1467220448-16764-2-git-send-email-nipun.gupta-3arQi8VN3Tc@public.gmane.org>
2016-06-30 11:23       ` Robin Murphy
2016-06-30 11:23         ` Robin Murphy
     [not found]         ` <5775011C.60402-5wv7dgnIgG8@public.gmane.org>
2016-06-30 12:11           ` Nipun Gupta
2016-06-30 12:11             ` Nipun Gupta
2016-06-30 10:55   ` [RFC PATCH 1/2] fsl-mc: Added header file to provide fsl-mc bus iommu group creation Robin Murphy
2016-06-30 10:55     ` Robin Murphy
     [not found]     ` <5774FABE.5070707-5wv7dgnIgG8@public.gmane.org>
2016-06-30 11:43       ` Nipun Gupta
2016-06-30 11:43         ` Nipun Gupta
     [not found]         ` <HE1PR0401MB1866C1468D3B4733B437C79BE6240-B0v07Ae2tarOWAm+xAH2pY3W/0Ik+aLCnBOFsp37pqbUKgpGm//BTAC/G2K4zDHf@public.gmane.org>
2016-06-30 14:14           ` Robin Murphy
2016-06-30 14:14             ` Robin Murphy
     [not found]             ` <57752939.9010504-5wv7dgnIgG8@public.gmane.org>
2016-07-01 15:11               ` Nipun Gupta
2016-07-01 15:11                 ` Nipun Gupta

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.