Blame view

drivers/iommu/msm_iommu.h 2.66 KB
08dbd0f8e   Thomas Gleixner   treewide: Replace...
1
  /* SPDX-License-Identifier: GPL-2.0-only */
41f3f5138   Stepan Moskovchenko   msm: iommu: Clock...
2
  /* Copyright (c) 2010-2011, Code Aurora Forum. All rights reserved.
0720d1f05   Stepan Moskovchenko   msm: Add MSM IOMM...
3
4
5
6
7
8
   */
  
  #ifndef MSM_IOMMU_H
  #define MSM_IOMMU_H
  
  #include <linux/interrupt.h>
42df43b36   Joerg Roedel   iommu/msm: Make u...
9
  #include <linux/iommu.h>
41f3f5138   Stepan Moskovchenko   msm: iommu: Clock...
10
  #include <linux/clk.h>
0720d1f05   Stepan Moskovchenko   msm: Add MSM IOMM...
11

08bd68397   Stepan Moskovchenko   msm: iommu: Defin...
12
13
14
15
16
17
18
19
20
21
22
23
  /* Sharability attributes of MSM IOMMU mappings */
  #define MSM_IOMMU_ATTR_NON_SH		0x0
  #define MSM_IOMMU_ATTR_SH		0x4
  
  /* Cacheability attributes of MSM IOMMU mappings */
  #define MSM_IOMMU_ATTR_NONCACHED	0x0
  #define MSM_IOMMU_ATTR_CACHED_WB_WA	0x1
  #define MSM_IOMMU_ATTR_CACHED_WB_NWA	0x2
  #define MSM_IOMMU_ATTR_CACHED_WT	0x3
  
  /* Mask for the cache policy attribute */
  #define MSM_IOMMU_CP_MASK		0x03
0720d1f05   Stepan Moskovchenko   msm: Add MSM IOMM...
24
25
26
27
28
29
  /* Maximum number of Machine IDs that we are allowing to be mapped to the same
   * context bank. The number of MIDs mapped to the same CB does not affect
   * performance, but there is a practical limit on how many distinct MIDs may
   * be present. These mappings are typically determined at design time and are
   * not expected to change at run time.
   */
23513c3b3   Stepan Moskovchenko   msm: iommu: Incre...
30
  #define MAX_NUM_MIDS	32
0720d1f05   Stepan Moskovchenko   msm: Add MSM IOMM...
31

109bd48ea   Sricharan R   iommu/msm: Add DT...
32
33
  /* Maximum number of context banks that can be present in IOMMU */
  #define IOMMU_MAX_CBS	128
0720d1f05   Stepan Moskovchenko   msm: Add MSM IOMM...
34
35
  /**
   * struct msm_iommu_dev - a single IOMMU hardware instance
a43d8c101   Stepan Moskovchenko   msm: iommu: Remov...
36
   * ncb		Number of context banks present on this IOMMU HW instance
109bd48ea   Sricharan R   iommu/msm: Add DT...
37
38
39
40
41
42
43
44
   * dev:		IOMMU device
   * irq:		Interrupt number
   * clk:		The bus clock for this IOMMU hardware instance
   * pclk:	The clock for the IOMMU bus interconnect
   * dev_node:	list head in qcom_iommu_device_list
   * dom_node:	list head for domain
   * ctx_list:	list of 'struct msm_iommu_ctx_dev'
   * context_map: Bitmap to track allocated context banks
0720d1f05   Stepan Moskovchenko   msm: Add MSM IOMM...
45
46
   */
  struct msm_iommu_dev {
109bd48ea   Sricharan R   iommu/msm: Add DT...
47
  	void __iomem *base;
a43d8c101   Stepan Moskovchenko   msm: iommu: Remov...
48
  	int ncb;
109bd48ea   Sricharan R   iommu/msm: Add DT...
49
50
51
52
53
54
55
56
  	struct device *dev;
  	int irq;
  	struct clk *clk;
  	struct clk *pclk;
  	struct list_head dev_node;
  	struct list_head dom_node;
  	struct list_head ctx_list;
  	DECLARE_BITMAP(context_map, IOMMU_MAX_CBS);
42df43b36   Joerg Roedel   iommu/msm: Make u...
57
58
  
  	struct iommu_device iommu;
0720d1f05   Stepan Moskovchenko   msm: Add MSM IOMM...
59
60
61
62
  };
  
  /**
   * struct msm_iommu_ctx_dev - an IOMMU context bank instance
109bd48ea   Sricharan R   iommu/msm: Add DT...
63
   * of_node	node ptr of client device
0720d1f05   Stepan Moskovchenko   msm: Add MSM IOMM...
64
65
66
67
68
   * num		Index of this context bank within the hardware
   * mids		List of Machine IDs that are to be mapped into this context
   *		bank, terminated by -1. The MID is a set of signals on the
   *		AXI bus that identifies the function associated with a specific
   *		memory request. (See ARM spec).
109bd48ea   Sricharan R   iommu/msm: Add DT...
69
70
   * num_mids	Total number of mids
   * node		list head in ctx_list
0720d1f05   Stepan Moskovchenko   msm: Add MSM IOMM...
71
72
   */
  struct msm_iommu_ctx_dev {
109bd48ea   Sricharan R   iommu/msm: Add DT...
73
  	struct device_node *of_node;
0720d1f05   Stepan Moskovchenko   msm: Add MSM IOMM...
74
75
  	int num;
  	int mids[MAX_NUM_MIDS];
109bd48ea   Sricharan R   iommu/msm: Add DT...
76
77
  	int num_mids;
  	struct list_head list;
0720d1f05   Stepan Moskovchenko   msm: Add MSM IOMM...
78
  };
0720d1f05   Stepan Moskovchenko   msm: Add MSM IOMM...
79
80
81
82
83
84
85
86
  /*
   * Interrupt handler for the IOMMU context fault interrupt. Hooking the
   * interrupt is not supported in the API yet, but this will print an error
   * message and dump useful IOMMU registers.
   */
  irqreturn_t msm_iommu_fault_handler(int irq, void *dev_id);
  
  #endif