Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1 | /* Copyright (c) 2008-2011, 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 __ADRENO_H |
| 14 | #define __ADRENO_H |
| 15 | |
| 16 | #include "kgsl_device.h" |
| 17 | #include "adreno_drawctxt.h" |
| 18 | #include "adreno_ringbuffer.h" |
| 19 | |
| 20 | #define DEVICE_3D_NAME "kgsl-3d" |
| 21 | #define DEVICE_3D0_NAME "kgsl-3d0" |
| 22 | |
| 23 | #define ADRENO_DEVICE(device) \ |
| 24 | KGSL_CONTAINER_OF(device, struct adreno_device, dev) |
| 25 | |
| 26 | /* Flags to control command packet settings */ |
| 27 | #define KGSL_CMD_FLAGS_PMODE 0x00000001 |
| 28 | #define KGSL_CMD_FLAGS_NO_TS_CMP 0x00000002 |
| 29 | #define KGSL_CMD_FLAGS_NOT_KERNEL_CMD 0x00000004 |
| 30 | |
| 31 | /* Command identifiers */ |
| 32 | #define KGSL_CONTEXT_TO_MEM_IDENTIFIER 0xDEADBEEF |
| 33 | #define KGSL_CMD_IDENTIFIER 0xFEEDFACE |
| 34 | |
| 35 | #ifdef CONFIG_MSM_SCM |
| 36 | #define ADRENO_DEFAULT_PWRSCALE_POLICY (&kgsl_pwrscale_policy_tz) |
| 37 | #else |
| 38 | #define ADRENO_DEFAULT_PWRSCALE_POLICY NULL |
| 39 | #endif |
| 40 | |
Jeremy Gebben | ddf6b57 | 2011-09-09 13:39:49 -0700 | [diff] [blame] | 41 | /* |
| 42 | * constants for the size of shader instructions |
| 43 | */ |
| 44 | #define ADRENO_ISTORE_BYTES 12 |
| 45 | #define ADRENO_ISTORE_WORDS 3 |
| 46 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 47 | enum adreno_gpurev { |
| 48 | ADRENO_REV_UNKNOWN = 0, |
| 49 | ADRENO_REV_A200 = 200, |
| 50 | ADRENO_REV_A205 = 205, |
| 51 | ADRENO_REV_A220 = 220, |
| 52 | ADRENO_REV_A225 = 225, |
| 53 | }; |
| 54 | |
Jordan Crouse | a78c917 | 2011-07-11 13:14:09 -0600 | [diff] [blame] | 55 | struct adreno_gpudev; |
| 56 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 57 | struct adreno_device { |
| 58 | struct kgsl_device dev; /* Must be first field in this struct */ |
| 59 | unsigned int chip_id; |
| 60 | enum adreno_gpurev gpurev; |
| 61 | struct kgsl_memregion gmemspace; |
| 62 | struct adreno_context *drawctxt_active; |
Jordan Crouse | 505df9c | 2011-07-28 08:37:59 -0600 | [diff] [blame] | 63 | const char *pfp_fwfile; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 64 | unsigned int *pfp_fw; |
| 65 | size_t pfp_fw_size; |
Jordan Crouse | 505df9c | 2011-07-28 08:37:59 -0600 | [diff] [blame] | 66 | const char *pm4_fwfile; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 67 | unsigned int *pm4_fw; |
| 68 | size_t pm4_fw_size; |
| 69 | struct adreno_ringbuffer ringbuffer; |
| 70 | unsigned int mharb; |
Jordan Crouse | a78c917 | 2011-07-11 13:14:09 -0600 | [diff] [blame] | 71 | struct adreno_gpudev *gpudev; |
Ranjhith Kalisamy | 823c148 | 2011-09-05 20:31:07 +0530 | [diff] [blame] | 72 | unsigned int wait_timeout; |
Jeremy Gebben | ddf6b57 | 2011-09-09 13:39:49 -0700 | [diff] [blame] | 73 | unsigned int istore_size; |
| 74 | unsigned int pix_shader_start; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 75 | }; |
| 76 | |
Jordan Crouse | a78c917 | 2011-07-11 13:14:09 -0600 | [diff] [blame] | 77 | struct adreno_gpudev { |
| 78 | int (*ctxt_gpustate_shadow)(struct adreno_device *, |
| 79 | struct adreno_context *); |
| 80 | int (*ctxt_gmem_shadow)(struct adreno_device *, |
| 81 | struct adreno_context *); |
| 82 | void (*ctxt_save)(struct adreno_device *, struct adreno_context *); |
| 83 | void (*ctxt_restore)(struct adreno_device *, struct adreno_context *); |
| 84 | irqreturn_t (*irq_handler)(struct adreno_device *); |
| 85 | void (*irq_control)(struct adreno_device *, int); |
| 86 | }; |
| 87 | |
| 88 | extern struct adreno_gpudev adreno_a2xx_gpudev; |
| 89 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 90 | int adreno_idle(struct kgsl_device *device, unsigned int timeout); |
| 91 | void adreno_regread(struct kgsl_device *device, unsigned int offsetwords, |
| 92 | unsigned int *value); |
| 93 | void adreno_regwrite(struct kgsl_device *device, unsigned int offsetwords, |
| 94 | unsigned int value); |
| 95 | |
Jeremy Gebben | 16e80fa | 2011-11-30 15:56:29 -0700 | [diff] [blame^] | 96 | const struct kgsl_memdesc *adreno_find_region(struct kgsl_device *device, |
| 97 | unsigned int pt_base, |
| 98 | unsigned int gpuaddr, |
| 99 | unsigned int size); |
| 100 | |
| 101 | uint8_t *adreno_convertaddr(struct kgsl_device *device, |
| 102 | unsigned int pt_base, unsigned int gpuaddr, unsigned int size); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 103 | |
| 104 | static inline int adreno_is_a200(struct adreno_device *adreno_dev) |
| 105 | { |
| 106 | return (adreno_dev->gpurev == ADRENO_REV_A200); |
| 107 | } |
| 108 | |
| 109 | static inline int adreno_is_a205(struct adreno_device *adreno_dev) |
| 110 | { |
| 111 | return (adreno_dev->gpurev == ADRENO_REV_A200); |
| 112 | } |
| 113 | |
| 114 | static inline int adreno_is_a20x(struct adreno_device *adreno_dev) |
| 115 | { |
| 116 | return (adreno_dev->gpurev == ADRENO_REV_A200 || |
| 117 | adreno_dev->gpurev == ADRENO_REV_A205); |
| 118 | } |
| 119 | |
| 120 | static inline int adreno_is_a220(struct adreno_device *adreno_dev) |
| 121 | { |
| 122 | return (adreno_dev->gpurev == ADRENO_REV_A220); |
| 123 | } |
| 124 | |
| 125 | static inline int adreno_is_a225(struct adreno_device *adreno_dev) |
| 126 | { |
| 127 | return (adreno_dev->gpurev == ADRENO_REV_A225); |
| 128 | } |
| 129 | |
| 130 | static inline int adreno_is_a22x(struct adreno_device *adreno_dev) |
| 131 | { |
| 132 | return (adreno_dev->gpurev == ADRENO_REV_A220 || |
| 133 | adreno_dev->gpurev == ADRENO_REV_A225); |
| 134 | } |
| 135 | |
Jordan Crouse | 196c45b | 2011-07-28 08:37:57 -0600 | [diff] [blame] | 136 | static inline int adreno_is_a2xx(struct adreno_device *adreno_dev) |
| 137 | { |
| 138 | return (adreno_dev->gpurev <= ADRENO_REV_A225); |
| 139 | } |
| 140 | |
Jeremy Gebben | ddf6b57 | 2011-09-09 13:39:49 -0700 | [diff] [blame] | 141 | /** |
| 142 | * adreno_encode_istore_size - encode istore size in CP format |
| 143 | * @adreno_dev - The 3D device. |
| 144 | * |
| 145 | * Encode the istore size into the format expected that the |
| 146 | * CP_SET_SHADER_BASES and CP_ME_INIT commands: |
| 147 | * bits 31:29 - istore size as encoded by this function |
| 148 | * bits 27:16 - vertex shader start offset in instructions |
| 149 | * bits 11:0 - pixel shader start offset in instructions. |
| 150 | */ |
| 151 | static inline int adreno_encode_istore_size(struct adreno_device *adreno_dev) |
| 152 | { |
| 153 | unsigned int size; |
| 154 | /* in a225 the CP microcode multiplies the encoded |
| 155 | * value by 3 while decoding. |
| 156 | */ |
| 157 | if (adreno_is_a225(adreno_dev)) |
| 158 | size = adreno_dev->istore_size/3; |
| 159 | else |
| 160 | size = adreno_dev->istore_size; |
| 161 | |
| 162 | return (ilog2(size) - 5) << 29; |
| 163 | } |
Jordan Crouse | 196c45b | 2011-07-28 08:37:57 -0600 | [diff] [blame] | 164 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 165 | #endif /*__ADRENO_H */ |