Blame view

drivers/iommu/omap-iopgtable.h 2.78 KB
a9dcad5e3   Hiroshi DOYU   omap iommu: tlb a...
1
2
3
  /*
   * omap iommu: pagetable definitions
   *
97ec7d585   Hiroshi DOYU   omap iommu: clean...
4
   * Copyright (C) 2008-2010 Nokia Corporation
a9dcad5e3   Hiroshi DOYU   omap iommu: tlb a...
5
6
7
8
9
10
11
   *
   * Written by Hiroshi DOYU <Hiroshi.DOYU@nokia.com>
   *
   * This program is free software; you can redistribute it and/or modify
   * it under the terms of the GNU General Public License version 2 as
   * published by the Free Software Foundation.
   */
ad8e29a08   Suman Anna   iommu/omap: Prote...
12
13
  #ifndef _OMAP_IOPGTABLE_H
  #define _OMAP_IOPGTABLE_H
5ff98fa68   Suman Anna   iommu/omap: Use B...
14
  #include <linux/bitops.h>
97ec7d585   Hiroshi DOYU   omap iommu: clean...
15
16
17
  /*
   * "L2 table" address mask and size definitions.
   */
a9dcad5e3   Hiroshi DOYU   omap iommu: tlb a...
18
  #define IOPGD_SHIFT		20
5ff98fa68   Suman Anna   iommu/omap: Use B...
19
  #define IOPGD_SIZE		BIT(IOPGD_SHIFT)
a9dcad5e3   Hiroshi DOYU   omap iommu: tlb a...
20
  #define IOPGD_MASK		(~(IOPGD_SIZE - 1))
a9dcad5e3   Hiroshi DOYU   omap iommu: tlb a...
21

97ec7d585   Hiroshi DOYU   omap iommu: clean...
22
23
24
25
  /*
   * "section" address mask and size definitions.
   */
  #define IOSECTION_SHIFT		20
5ff98fa68   Suman Anna   iommu/omap: Use B...
26
  #define IOSECTION_SIZE		BIT(IOSECTION_SHIFT)
97ec7d585   Hiroshi DOYU   omap iommu: clean...
27
28
29
30
31
32
  #define IOSECTION_MASK		(~(IOSECTION_SIZE - 1))
  
  /*
   * "supersection" address mask and size definitions.
   */
  #define IOSUPER_SHIFT		24
5ff98fa68   Suman Anna   iommu/omap: Use B...
33
  #define IOSUPER_SIZE		BIT(IOSUPER_SHIFT)
a9dcad5e3   Hiroshi DOYU   omap iommu: tlb a...
34
  #define IOSUPER_MASK		(~(IOSUPER_SIZE - 1))
97ec7d585   Hiroshi DOYU   omap iommu: clean...
35
36
37
38
39
40
  #define PTRS_PER_IOPGD		(1UL << (32 - IOPGD_SHIFT))
  #define IOPGD_TABLE_SIZE	(PTRS_PER_IOPGD * sizeof(u32))
  
  /*
   * "small page" address mask and size definitions.
   */
a9dcad5e3   Hiroshi DOYU   omap iommu: tlb a...
41
  #define IOPTE_SHIFT		12
5ff98fa68   Suman Anna   iommu/omap: Use B...
42
  #define IOPTE_SIZE		BIT(IOPTE_SHIFT)
a9dcad5e3   Hiroshi DOYU   omap iommu: tlb a...
43
  #define IOPTE_MASK		(~(IOPTE_SIZE - 1))
a9dcad5e3   Hiroshi DOYU   omap iommu: tlb a...
44

97ec7d585   Hiroshi DOYU   omap iommu: clean...
45
46
47
48
  /*
   * "large page" address mask and size definitions.
   */
  #define IOLARGE_SHIFT		16
5ff98fa68   Suman Anna   iommu/omap: Use B...
49
  #define IOLARGE_SIZE		BIT(IOLARGE_SHIFT)
a9dcad5e3   Hiroshi DOYU   omap iommu: tlb a...
50
  #define IOLARGE_MASK		(~(IOLARGE_SIZE - 1))
97ec7d585   Hiroshi DOYU   omap iommu: clean...
51
52
53
54
  #define PTRS_PER_IOPTE		(1UL << (IOPGD_SHIFT - IOPTE_SHIFT))
  #define IOPTE_TABLE_SIZE	(PTRS_PER_IOPTE * sizeof(u32))
  
  #define IOPAGE_MASK		IOPTE_MASK
f626b52d4   Ohad Ben-Cohen   omap: iommu: migr...
55
56
57
58
59
60
61
62
63
64
65
66
  /**
   * omap_iommu_translate() - va to pa translation
   * @d:		omap iommu descriptor
   * @va:		virtual address
   * @mask:	omap iommu descriptor mask
   *
   * va to pa translation
   */
  static inline phys_addr_t omap_iommu_translate(u32 d, u32 va, u32 mask)
  {
  	return (d & mask) | (va & (~mask));
  }
97ec7d585   Hiroshi DOYU   omap iommu: clean...
67
68
69
  /*
   * some descriptor attributes.
   */
5ff98fa68   Suman Anna   iommu/omap: Use B...
70
71
72
  #define IOPGD_TABLE		(1)
  #define IOPGD_SECTION		(2)
  #define IOPGD_SUPER		(BIT(18) | IOPGD_SECTION)
a9dcad5e3   Hiroshi DOYU   omap iommu: tlb a...
73

a1a54456d   Hiroshi DOYU   omap iommu: Intro...
74
  #define iopgd_is_table(x)	(((x) & 3) == IOPGD_TABLE)
f626b52d4   Ohad Ben-Cohen   omap: iommu: migr...
75
76
  #define iopgd_is_section(x)	(((x) & (1 << 18 | 3)) == IOPGD_SECTION)
  #define iopgd_is_super(x)	(((x) & (1 << 18 | 3)) == IOPGD_SUPER)
a1a54456d   Hiroshi DOYU   omap iommu: Intro...
77

5ff98fa68   Suman Anna   iommu/omap: Use B...
78
79
  #define IOPTE_SMALL		(2)
  #define IOPTE_LARGE		(1)
a9dcad5e3   Hiroshi DOYU   omap iommu: tlb a...
80

f626b52d4   Ohad Ben-Cohen   omap: iommu: migr...
81
82
  #define iopte_is_small(x)	(((x) & 2) == IOPTE_SMALL)
  #define iopte_is_large(x)	(((x) & 3) == IOPTE_LARGE)
97ec7d585   Hiroshi DOYU   omap iommu: clean...
83
  /* to find an entry in a page-table-directory */
a9dcad5e3   Hiroshi DOYU   omap iommu: tlb a...
84
85
  #define iopgd_index(da)		(((da) >> IOPGD_SHIFT) & (PTRS_PER_IOPGD - 1))
  #define iopgd_offset(obj, da)	((obj)->iopgd + iopgd_index(da))
124933599   Hiroshi DOYU   omap iommu: Renam...
86
87
  #define iopgd_page_paddr(iopgd)	(*iopgd & ~((1 << 10) - 1))
  #define iopgd_page_vaddr(iopgd)	((u32 *)phys_to_virt(iopgd_page_paddr(iopgd)))
a9dcad5e3   Hiroshi DOYU   omap iommu: tlb a...
88

97ec7d585   Hiroshi DOYU   omap iommu: clean...
89
  /* to find an entry in the second-level page table. */
a9dcad5e3   Hiroshi DOYU   omap iommu: tlb a...
90
  #define iopte_index(da)		(((da) >> IOPTE_SHIFT) & (PTRS_PER_IOPTE - 1))
124933599   Hiroshi DOYU   omap iommu: Renam...
91
  #define iopte_offset(iopgd, da)	(iopgd_page_vaddr(iopgd) + iopte_index(da))
ad8e29a08   Suman Anna   iommu/omap: Prote...
92
93
  
  #endif /* _OMAP_IOPGTABLE_H */