Shubhraprakash Das | eb6df1d | 2012-05-01 00:55:35 -0600 | [diff] [blame^] | 1 | /* Copyright (c) 2012, Code Aurora Forum. All rights reserved. |
| 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 __KGSL_IOMMU_H |
| 14 | #define __KGSL_IOMMU_H |
| 15 | |
| 16 | #include <mach/iommu.h> |
| 17 | |
| 18 | /* |
| 19 | * Max number of iommu units that the gpu core can have |
| 20 | * On APQ8064, KGSL can control a maximum of 2 IOMMU units. |
| 21 | */ |
| 22 | #define KGSL_IOMMU_MAX_UNITS 2 |
| 23 | |
| 24 | /* Max number of iommu contexts per IOMMU unit */ |
| 25 | #define KGSL_IOMMU_MAX_DEVS_PER_UNIT 2 |
| 26 | |
| 27 | /* |
| 28 | * struct kgsl_iommu_device - Structure holding data about iommu contexts |
| 29 | * @dev: Device pointer to iommu context |
| 30 | * @attached: Indicates whether this iommu context is presently attached to |
| 31 | * a pagetable/domain or not |
| 32 | * @pt_lsb: The LSB of IOMMU_TTBR0 register which is the pagetable |
| 33 | * register |
| 34 | * @ctx_id: This iommu units context id. It can be either 0 or 1 |
| 35 | * @clk_enabled: If set indicates that iommu clocks of this iommu context |
| 36 | * are on, else the clocks are off |
| 37 | */ |
| 38 | struct kgsl_iommu_device { |
| 39 | struct device *dev; |
| 40 | bool attached; |
| 41 | unsigned int pt_lsb; |
| 42 | enum kgsl_iommu_context_id ctx_id; |
| 43 | bool clk_enabled; |
| 44 | }; |
| 45 | |
| 46 | /* |
| 47 | * struct kgsl_iommu_unit - Structure holding data about iommu units. An IOMMU |
| 48 | * units is basically a separte IOMMU h/w block with it's own IOMMU contexts |
| 49 | * @dev: Pointer to array of struct kgsl_iommu_device which has information |
| 50 | * about the IOMMU contexts under this IOMMU unit |
| 51 | * @dev_count: Number of IOMMU contexts that are valid in the previous feild |
| 52 | * @reg_map: Memory descriptor which holds the mapped address of this IOMMU |
| 53 | * units register range |
| 54 | */ |
| 55 | struct kgsl_iommu_unit { |
| 56 | struct kgsl_iommu_device dev[KGSL_IOMMU_MAX_DEVS_PER_UNIT]; |
| 57 | unsigned int dev_count; |
| 58 | struct kgsl_memdesc reg_map; |
| 59 | }; |
| 60 | |
| 61 | /* |
| 62 | * struct kgsl_iommu - Structure holding iommu data for kgsl driver |
| 63 | * @dev: Array of kgsl_iommu_device which contain information about |
| 64 | * iommu contexts owned by graphics cores |
| 65 | * @unit_count: Number of IOMMU units that are available for this |
| 66 | * instance of the IOMMU driver |
| 67 | * @iommu_last_cmd_ts: The timestamp of last command submitted that |
| 68 | * aceeses iommu registers |
| 69 | * @device: Pointer to kgsl device |
| 70 | * @asids: A bit structure indicating which id's are presently used |
| 71 | * @asid: Contains the initial value of IOMMU_CONTEXTIDR when a domain |
| 72 | * is first attached |
| 73 | */ |
| 74 | struct kgsl_iommu { |
| 75 | struct kgsl_iommu_unit iommu_units[KGSL_IOMMU_MAX_UNITS]; |
| 76 | unsigned int unit_count; |
| 77 | unsigned int iommu_last_cmd_ts; |
| 78 | struct kgsl_device *device; |
| 79 | unsigned long *asids; |
| 80 | unsigned int asid; |
| 81 | unsigned int active_ctx; |
| 82 | }; |
| 83 | |
| 84 | #endif |