blob: 52e70ecbcbd0cd7a5d138579b083b70d8868603a [file] [log] [blame]
Olav Hauganab77b1b2012-02-28 09:19:22 -08001/* Copyright (c) 2011-2012, Code Aurora Forum. All rights reserved.
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002 *
3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License version 2 and
5 * only version 2 as published by the Free Software Foundation.
6 *
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
11 */
12
13#ifndef _ARCH_IOMMU_DOMAINS_H
14#define _ARCH_IOMMU_DOMAINS_H
15
Laura Abbott0577d7b2012-04-17 11:14:30 -070016#include <linux/memory_alloc.h>
17
Laura Abbott9f4a8e62011-08-29 19:08:07 -070018enum {
Olav Hauganab77b1b2012-02-28 09:19:22 -080019 VIDEO_DOMAIN,
Olav Haugan2d191032012-02-28 09:46:31 -080020 CAMERA_DOMAIN,
21 DISPLAY_DOMAIN,
22 ROTATOR_DOMAIN,
Laura Abbott9f4a8e62011-08-29 19:08:07 -070023 MAX_DOMAINS
24};
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070025
Laura Abbott9f4a8e62011-08-29 19:08:07 -070026enum {
27 VIDEO_FIRMWARE_POOL,
Olav Hauganee365362012-02-16 09:31:37 -080028 VIDEO_MAIN_POOL,
Olav Hauganee365362012-02-16 09:31:37 -080029 GEN_POOL,
Laura Abbott9f4a8e62011-08-29 19:08:07 -070030};
31
Laura Abbott0577d7b2012-04-17 11:14:30 -070032struct msm_iommu_domain_name {
33 char *name;
34 int domain;
35};
36
37struct msm_iommu_domain {
38 /* iommu domain to map in */
39 struct iommu_domain *domain;
40 /* total number of allocations from this domain */
41 atomic_t allocation_cnt;
42 /* number of iova pools */
43 int npools;
44 /*
45 * array of gen_pools for allocating iovas.
46 * behavior is undefined if these overlap
47 */
48 struct mem_pool *iova_pools;
49};
50
51struct iommu_domains_pdata {
52 struct msm_iommu_domain *domains;
53 int ndomains;
54 struct msm_iommu_domain_name *domain_names;
55 int nnames;
56 unsigned int domain_alloc_flags;
57};
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070058
59#if defined(CONFIG_MSM_IOMMU)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070060
Laura Abbott9f4a8e62011-08-29 19:08:07 -070061extern struct iommu_domain *msm_get_iommu_domain(int domain_num);
62
63extern unsigned long msm_allocate_iova_address(unsigned int iommu_domain,
64 unsigned int partition_no,
65 unsigned long size,
66 unsigned long align);
67
68extern void msm_free_iova_address(unsigned long iova,
69 unsigned int iommu_domain,
70 unsigned int partition_no,
71 unsigned long size);
72
Laura Abbott9f4a8e62011-08-29 19:08:07 -070073extern int msm_use_iommu(void);
Laura Abbotte956cce2011-10-25 13:33:20 -070074
75extern int msm_iommu_map_extra(struct iommu_domain *domain,
76 unsigned long start_iova,
77 unsigned long size,
78 int cached);
79
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070080#else
81static inline struct iommu_domain
Laura Abbott9f4a8e62011-08-29 19:08:07 -070082 *msm_get_iommu_domain(int subsys_id) { return NULL; }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070083
Laura Abbott9f4a8e62011-08-29 19:08:07 -070084
85
86static inline unsigned long msm_allocate_iova_address(unsigned int iommu_domain,
87 unsigned int partition_no,
88 unsigned long size,
89 unsigned long align) { return 0; }
90
91static inline void msm_free_iova_address(unsigned long iova,
92 unsigned int iommu_domain,
93 unsigned int partition_no,
94 unsigned long size) { return; }
95
Laura Abbott9f4a8e62011-08-29 19:08:07 -070096static inline int msm_use_iommu(void)
97{
98 return 0;
99}
Laura Abbotte956cce2011-10-25 13:33:20 -0700100
101static inline int msm_iommu_map_extra(struct iommu_domain *domain,
102 unsigned long start_iova,
103 unsigned long size,
104 int cached)
105{
106 return -ENODEV;
107}
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700108#endif
109
110#endif