Olav Haugan | ab77b1b | 2012-02-28 09:19:22 -0800 | [diff] [blame] | 1 | /* Copyright (c) 2011-2012, Code Aurora Forum. All rights reserved. |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 2 | * |
| 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 Abbott | 0577d7b | 2012-04-17 11:14:30 -0700 | [diff] [blame^] | 16 | #include <linux/memory_alloc.h> |
| 17 | |
Laura Abbott | 9f4a8e6 | 2011-08-29 19:08:07 -0700 | [diff] [blame] | 18 | enum { |
Olav Haugan | ab77b1b | 2012-02-28 09:19:22 -0800 | [diff] [blame] | 19 | VIDEO_DOMAIN, |
Olav Haugan | 2d19103 | 2012-02-28 09:46:31 -0800 | [diff] [blame] | 20 | CAMERA_DOMAIN, |
| 21 | DISPLAY_DOMAIN, |
| 22 | ROTATOR_DOMAIN, |
Laura Abbott | 9f4a8e6 | 2011-08-29 19:08:07 -0700 | [diff] [blame] | 23 | MAX_DOMAINS |
| 24 | }; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 25 | |
Laura Abbott | 9f4a8e6 | 2011-08-29 19:08:07 -0700 | [diff] [blame] | 26 | enum { |
| 27 | VIDEO_FIRMWARE_POOL, |
Olav Haugan | ee36536 | 2012-02-16 09:31:37 -0800 | [diff] [blame] | 28 | VIDEO_MAIN_POOL, |
Olav Haugan | ee36536 | 2012-02-16 09:31:37 -0800 | [diff] [blame] | 29 | GEN_POOL, |
Laura Abbott | 9f4a8e6 | 2011-08-29 19:08:07 -0700 | [diff] [blame] | 30 | }; |
| 31 | |
Laura Abbott | 0577d7b | 2012-04-17 11:14:30 -0700 | [diff] [blame^] | 32 | struct msm_iommu_domain_name { |
| 33 | char *name; |
| 34 | int domain; |
| 35 | }; |
| 36 | |
| 37 | struct 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 | |
| 51 | struct 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 Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 58 | |
| 59 | #if defined(CONFIG_MSM_IOMMU) |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 60 | |
Laura Abbott | 9f4a8e6 | 2011-08-29 19:08:07 -0700 | [diff] [blame] | 61 | extern struct iommu_domain *msm_get_iommu_domain(int domain_num); |
| 62 | |
| 63 | extern unsigned long msm_allocate_iova_address(unsigned int iommu_domain, |
| 64 | unsigned int partition_no, |
| 65 | unsigned long size, |
| 66 | unsigned long align); |
| 67 | |
| 68 | extern void msm_free_iova_address(unsigned long iova, |
| 69 | unsigned int iommu_domain, |
| 70 | unsigned int partition_no, |
| 71 | unsigned long size); |
| 72 | |
Laura Abbott | 9f4a8e6 | 2011-08-29 19:08:07 -0700 | [diff] [blame] | 73 | extern int msm_use_iommu(void); |
Laura Abbott | e956cce | 2011-10-25 13:33:20 -0700 | [diff] [blame] | 74 | |
| 75 | extern int msm_iommu_map_extra(struct iommu_domain *domain, |
| 76 | unsigned long start_iova, |
| 77 | unsigned long size, |
| 78 | int cached); |
| 79 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 80 | #else |
| 81 | static inline struct iommu_domain |
Laura Abbott | 9f4a8e6 | 2011-08-29 19:08:07 -0700 | [diff] [blame] | 82 | *msm_get_iommu_domain(int subsys_id) { return NULL; } |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 83 | |
Laura Abbott | 9f4a8e6 | 2011-08-29 19:08:07 -0700 | [diff] [blame] | 84 | |
| 85 | |
| 86 | static 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 | |
| 91 | static 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 Abbott | 9f4a8e6 | 2011-08-29 19:08:07 -0700 | [diff] [blame] | 96 | static inline int msm_use_iommu(void) |
| 97 | { |
| 98 | return 0; |
| 99 | } |
Laura Abbott | e956cce | 2011-10-25 13:33:20 -0700 | [diff] [blame] | 100 | |
| 101 | static 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 Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 108 | #endif |
| 109 | |
| 110 | #endif |