| Jeremy Gebben | b7bc955 | 2012-01-09 13:32:49 -0700 | [diff] [blame] | 1 | /* Copyright (c) 2002,2007-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 |  */ | 
| Steve Muckle | f132c6c | 2012-06-06 18:30:57 -0700 | [diff] [blame] | 13 | #include <linux/module.h> | 
| Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 14 | #include <linux/uaccess.h> | 
| Steve Muckle | f132c6c | 2012-06-06 18:30:57 -0700 | [diff] [blame] | 15 | #include <linux/sched.h> | 
| Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 16 |  | 
 | 17 | #include "kgsl.h" | 
 | 18 | #include "kgsl_cffdump.h" | 
 | 19 | #include "kgsl_sharedmem.h" | 
 | 20 |  | 
 | 21 | #include "z180.h" | 
 | 22 | #include "z180_reg.h" | 
| Norman Gee | d7402ff | 2011-10-28 08:51:11 -0600 | [diff] [blame] | 23 | #include "z180_trace.h" | 
| Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 24 |  | 
 | 25 | #define DRIVER_VERSION_MAJOR   3 | 
 | 26 | #define DRIVER_VERSION_MINOR   1 | 
 | 27 |  | 
 | 28 | #define Z180_DEVICE(device) \ | 
 | 29 | 		KGSL_CONTAINER_OF(device, struct z180_device, dev) | 
 | 30 |  | 
 | 31 | #define GSL_VGC_INT_MASK \ | 
 | 32 | 	 (REG_VGC_IRQSTATUS__MH_MASK | \ | 
 | 33 | 	  REG_VGC_IRQSTATUS__G2D_MASK | \ | 
 | 34 | 	  REG_VGC_IRQSTATUS__FIFO_MASK) | 
 | 35 |  | 
 | 36 | #define VGV3_NEXTCMD_JUMP        0x01 | 
 | 37 |  | 
 | 38 | #define VGV3_NEXTCMD_NEXTCMD_FSHIFT 12 | 
 | 39 | #define VGV3_NEXTCMD_NEXTCMD_FMASK 0x7 | 
 | 40 |  | 
 | 41 | #define VGV3_CONTROL_MARKADD_FSHIFT 0 | 
 | 42 | #define VGV3_CONTROL_MARKADD_FMASK 0xfff | 
 | 43 |  | 
 | 44 | #define Z180_PACKET_SIZE 15 | 
 | 45 | #define Z180_MARKER_SIZE 10 | 
 | 46 | #define Z180_CALL_CMD     0x1000 | 
 | 47 | #define Z180_MARKER_CMD   0x8000 | 
 | 48 | #define Z180_STREAM_END_CMD 0x9000 | 
 | 49 | #define Z180_STREAM_PACKET 0x7C000176 | 
 | 50 | #define Z180_STREAM_PACKET_CALL 0x7C000275 | 
 | 51 | #define Z180_PACKET_COUNT 8 | 
 | 52 | #define Z180_RB_SIZE (Z180_PACKET_SIZE*Z180_PACKET_COUNT \ | 
 | 53 | 			  *sizeof(uint32_t)) | 
 | 54 |  | 
 | 55 | #define NUMTEXUNITS             4 | 
 | 56 | #define TEXUNITREGCOUNT         25 | 
 | 57 | #define VG_REGCOUNT             0x39 | 
 | 58 |  | 
 | 59 | #define PACKETSIZE_BEGIN        3 | 
 | 60 | #define PACKETSIZE_G2DCOLOR     2 | 
 | 61 | #define PACKETSIZE_TEXUNIT      (TEXUNITREGCOUNT * 2) | 
 | 62 | #define PACKETSIZE_REG          (VG_REGCOUNT * 2) | 
 | 63 | #define PACKETSIZE_STATE        (PACKETSIZE_TEXUNIT * NUMTEXUNITS + \ | 
 | 64 | 				 PACKETSIZE_REG + PACKETSIZE_BEGIN + \ | 
 | 65 | 				 PACKETSIZE_G2DCOLOR) | 
 | 66 | #define PACKETSIZE_STATESTREAM  (ALIGN((PACKETSIZE_STATE * \ | 
 | 67 | 				 sizeof(unsigned int)), 32) / \ | 
 | 68 | 				 sizeof(unsigned int)) | 
 | 69 |  | 
 | 70 | #define Z180_INVALID_CONTEXT UINT_MAX | 
 | 71 |  | 
 | 72 | /* z180 MH arbiter config*/ | 
 | 73 | #define Z180_CFG_MHARB \ | 
 | 74 | 	(0x10 \ | 
 | 75 | 		| (0 << MH_ARBITER_CONFIG__SAME_PAGE_GRANULARITY__SHIFT) \ | 
 | 76 | 		| (1 << MH_ARBITER_CONFIG__L1_ARB_ENABLE__SHIFT) \ | 
 | 77 | 		| (1 << MH_ARBITER_CONFIG__L1_ARB_HOLD_ENABLE__SHIFT) \ | 
 | 78 | 		| (0 << MH_ARBITER_CONFIG__L2_ARB_CONTROL__SHIFT) \ | 
 | 79 | 		| (1 << MH_ARBITER_CONFIG__PAGE_SIZE__SHIFT) \ | 
 | 80 | 		| (1 << MH_ARBITER_CONFIG__TC_REORDER_ENABLE__SHIFT) \ | 
 | 81 | 		| (1 << MH_ARBITER_CONFIG__TC_ARB_HOLD_ENABLE__SHIFT) \ | 
 | 82 | 		| (0 << MH_ARBITER_CONFIG__IN_FLIGHT_LIMIT_ENABLE__SHIFT) \ | 
 | 83 | 		| (0x8 << MH_ARBITER_CONFIG__IN_FLIGHT_LIMIT__SHIFT) \ | 
 | 84 | 		| (1 << MH_ARBITER_CONFIG__CP_CLNT_ENABLE__SHIFT) \ | 
 | 85 | 		| (1 << MH_ARBITER_CONFIG__VGT_CLNT_ENABLE__SHIFT) \ | 
 | 86 | 		| (1 << MH_ARBITER_CONFIG__TC_CLNT_ENABLE__SHIFT) \ | 
 | 87 | 		| (1 << MH_ARBITER_CONFIG__RB_CLNT_ENABLE__SHIFT) \ | 
 | 88 | 		| (1 << MH_ARBITER_CONFIG__PA_CLNT_ENABLE__SHIFT)) | 
 | 89 |  | 
 | 90 | #define Z180_TIMESTAMP_EPSILON 20000 | 
 | 91 | #define Z180_IDLE_COUNT_MAX 1000000 | 
 | 92 |  | 
 | 93 | enum z180_cmdwindow_type { | 
 | 94 | 	Z180_CMDWINDOW_2D = 0x00000000, | 
 | 95 | 	Z180_CMDWINDOW_MMU = 0x00000002, | 
 | 96 | }; | 
 | 97 |  | 
 | 98 | #define Z180_CMDWINDOW_TARGET_MASK		0x000000FF | 
 | 99 | #define Z180_CMDWINDOW_ADDR_MASK		0x00FFFF00 | 
 | 100 | #define Z180_CMDWINDOW_TARGET_SHIFT		0 | 
 | 101 | #define Z180_CMDWINDOW_ADDR_SHIFT		8 | 
 | 102 |  | 
 | 103 | static int z180_start(struct kgsl_device *device, unsigned int init_ram); | 
 | 104 | static int z180_stop(struct kgsl_device *device); | 
 | 105 | static int z180_wait(struct kgsl_device *device, | 
| Carter Cooper | 7e7f02e | 2012-02-15 09:36:31 -0700 | [diff] [blame] | 106 | 				struct kgsl_context *context, | 
| Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 107 | 				unsigned int timestamp, | 
 | 108 | 				unsigned int msecs); | 
 | 109 | static void z180_regread(struct kgsl_device *device, | 
 | 110 | 				unsigned int offsetwords, | 
 | 111 | 				unsigned int *value); | 
 | 112 | static void z180_regwrite(struct kgsl_device *device, | 
 | 113 | 				unsigned int offsetwords, | 
 | 114 | 				unsigned int value); | 
 | 115 | static void z180_cmdwindow_write(struct kgsl_device *device, | 
 | 116 | 				unsigned int addr, | 
 | 117 | 				unsigned int data); | 
 | 118 |  | 
 | 119 | #define Z180_MMU_CONFIG					     \ | 
 | 120 | 	(0x01							     \ | 
 | 121 | 	| (MMU_CONFIG << MH_MMU_CONFIG__RB_W_CLNT_BEHAVIOR__SHIFT)   \ | 
 | 122 | 	| (MMU_CONFIG << MH_MMU_CONFIG__CP_W_CLNT_BEHAVIOR__SHIFT)   \ | 
 | 123 | 	| (MMU_CONFIG << MH_MMU_CONFIG__CP_R0_CLNT_BEHAVIOR__SHIFT)  \ | 
 | 124 | 	| (MMU_CONFIG << MH_MMU_CONFIG__CP_R1_CLNT_BEHAVIOR__SHIFT)  \ | 
 | 125 | 	| (MMU_CONFIG << MH_MMU_CONFIG__CP_R2_CLNT_BEHAVIOR__SHIFT)  \ | 
 | 126 | 	| (MMU_CONFIG << MH_MMU_CONFIG__CP_R3_CLNT_BEHAVIOR__SHIFT)  \ | 
 | 127 | 	| (MMU_CONFIG << MH_MMU_CONFIG__CP_R4_CLNT_BEHAVIOR__SHIFT)  \ | 
 | 128 | 	| (MMU_CONFIG << MH_MMU_CONFIG__VGT_R0_CLNT_BEHAVIOR__SHIFT) \ | 
 | 129 | 	| (MMU_CONFIG << MH_MMU_CONFIG__VGT_R1_CLNT_BEHAVIOR__SHIFT) \ | 
 | 130 | 	| (MMU_CONFIG << MH_MMU_CONFIG__TC_R_CLNT_BEHAVIOR__SHIFT)   \ | 
 | 131 | 	| (MMU_CONFIG << MH_MMU_CONFIG__PA_W_CLNT_BEHAVIOR__SHIFT)) | 
 | 132 |  | 
 | 133 | static const struct kgsl_functable z180_functable; | 
 | 134 |  | 
 | 135 | static struct z180_device device_2d0 = { | 
 | 136 | 	.dev = { | 
| Jeremy Gebben | 84d75d0 | 2012-03-01 14:47:45 -0700 | [diff] [blame] | 137 | 		KGSL_DEVICE_COMMON_INIT(device_2d0.dev), | 
| Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 138 | 		.name = DEVICE_2D0_NAME, | 
 | 139 | 		.id = KGSL_DEVICE_2D0, | 
| Jeremy Gebben | 4e8aada | 2011-07-12 10:07:47 -0600 | [diff] [blame] | 140 | 		.mh = { | 
 | 141 | 			.mharb = Z180_CFG_MHARB, | 
 | 142 | 			.mh_intf_cfg1 = 0x00032f07, | 
 | 143 | 			.mh_intf_cfg2 = 0x004b274f, | 
| Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 144 | 			/* turn off memory protection unit by setting | 
 | 145 | 			   acceptable physical address range to include | 
 | 146 | 			   all pages. */ | 
 | 147 | 			.mpu_base = 0x00000000, | 
 | 148 | 			.mpu_range =  0xFFFFF000, | 
 | 149 | 		}, | 
| Jeremy Gebben | 4e8aada | 2011-07-12 10:07:47 -0600 | [diff] [blame] | 150 | 		.mmu = { | 
 | 151 | 			.config = Z180_MMU_CONFIG, | 
 | 152 | 		}, | 
| Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 153 | 		.pwrctrl = { | 
| Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 154 | 			.irq_name = KGSL_2D0_IRQ, | 
 | 155 | 		}, | 
| Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 156 | 		.iomemname = KGSL_2D0_REG_MEMORY, | 
 | 157 | 		.ftbl = &z180_functable, | 
| Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 158 | 	}, | 
| Jeremy Gebben | 84d75d0 | 2012-03-01 14:47:45 -0700 | [diff] [blame] | 159 | 	.cmdwin_lock = __SPIN_LOCK_INITIALIZER(device_2d1.cmdwin_lock), | 
| Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 160 | }; | 
 | 161 |  | 
 | 162 | static struct z180_device device_2d1 = { | 
 | 163 | 	.dev = { | 
| Jeremy Gebben | 84d75d0 | 2012-03-01 14:47:45 -0700 | [diff] [blame] | 164 | 		KGSL_DEVICE_COMMON_INIT(device_2d1.dev), | 
| Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 165 | 		.name = DEVICE_2D1_NAME, | 
 | 166 | 		.id = KGSL_DEVICE_2D1, | 
| Jeremy Gebben | 4e8aada | 2011-07-12 10:07:47 -0600 | [diff] [blame] | 167 | 		.mh = { | 
 | 168 | 			.mharb = Z180_CFG_MHARB, | 
 | 169 | 			.mh_intf_cfg1 = 0x00032f07, | 
 | 170 | 			.mh_intf_cfg2 = 0x004b274f, | 
| Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 171 | 			/* turn off memory protection unit by setting | 
 | 172 | 			   acceptable physical address range to include | 
 | 173 | 			   all pages. */ | 
 | 174 | 			.mpu_base = 0x00000000, | 
 | 175 | 			.mpu_range =  0xFFFFF000, | 
 | 176 | 		}, | 
| Jeremy Gebben | 4e8aada | 2011-07-12 10:07:47 -0600 | [diff] [blame] | 177 | 		.mmu = { | 
 | 178 | 			.config = Z180_MMU_CONFIG, | 
 | 179 | 		}, | 
| Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 180 | 		.pwrctrl = { | 
| Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 181 | 			.irq_name = KGSL_2D1_IRQ, | 
 | 182 | 		}, | 
| Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 183 | 		.iomemname = KGSL_2D1_REG_MEMORY, | 
 | 184 | 		.ftbl = &z180_functable, | 
| Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 185 | 	}, | 
| Jeremy Gebben | 84d75d0 | 2012-03-01 14:47:45 -0700 | [diff] [blame] | 186 | 	.cmdwin_lock = __SPIN_LOCK_INITIALIZER(device_2d1.cmdwin_lock), | 
| Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 187 | }; | 
 | 188 |  | 
| Jordan Crouse | b368e9b | 2012-04-27 14:01:59 -0600 | [diff] [blame] | 189 | static irqreturn_t z180_irq_handler(struct kgsl_device *device) | 
| Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 190 | { | 
 | 191 | 	irqreturn_t result = IRQ_NONE; | 
 | 192 | 	unsigned int status; | 
| Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 193 | 	struct z180_device *z180_dev = Z180_DEVICE(device); | 
 | 194 |  | 
 | 195 | 	z180_regread(device, ADDR_VGC_IRQSTATUS >> 2, &status); | 
 | 196 |  | 
| Norman Gee | d7402ff | 2011-10-28 08:51:11 -0600 | [diff] [blame] | 197 | 	trace_kgsl_z180_irq_status(device, status); | 
 | 198 |  | 
| Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 199 | 	if (status & GSL_VGC_INT_MASK) { | 
 | 200 | 		z180_regwrite(device, | 
 | 201 | 			ADDR_VGC_IRQSTATUS >> 2, status & GSL_VGC_INT_MASK); | 
 | 202 |  | 
 | 203 | 		result = IRQ_HANDLED; | 
 | 204 |  | 
 | 205 | 		if (status & REG_VGC_IRQSTATUS__FIFO_MASK) | 
 | 206 | 			KGSL_DRV_ERR(device, "z180 fifo interrupt\n"); | 
 | 207 | 		if (status & REG_VGC_IRQSTATUS__MH_MASK) | 
 | 208 | 			kgsl_mh_intrcallback(device); | 
 | 209 | 		if (status & REG_VGC_IRQSTATUS__G2D_MASK) { | 
 | 210 | 			int count; | 
 | 211 |  | 
 | 212 | 			z180_regread(device, | 
 | 213 | 					 ADDR_VGC_IRQ_ACTIVE_CNT >> 2, | 
 | 214 | 					 &count); | 
 | 215 |  | 
 | 216 | 			count >>= 8; | 
 | 217 | 			count &= 255; | 
 | 218 | 			z180_dev->timestamp += count; | 
 | 219 |  | 
| Jordan Crouse | 1bf80aa | 2011-10-12 16:57:47 -0600 | [diff] [blame] | 220 | 			queue_work(device->work_queue, &device->ts_expired_ws); | 
| Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 221 | 			wake_up_interruptible(&device->wait_queue); | 
 | 222 |  | 
 | 223 | 			atomic_notifier_call_chain( | 
 | 224 | 				&(device->ts_notifier_list), | 
 | 225 | 				device->id, NULL); | 
 | 226 | 		} | 
 | 227 | 	} | 
 | 228 |  | 
 | 229 | 	if ((device->pwrctrl.nap_allowed == true) && | 
 | 230 | 		(device->requested_state == KGSL_STATE_NONE)) { | 
| Jeremy Gebben | 388c297 | 2011-12-16 09:05:07 -0700 | [diff] [blame] | 231 | 		kgsl_pwrctrl_request_state(device, KGSL_STATE_NAP); | 
| Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 232 | 		queue_work(device->work_queue, &device->idle_check_ws); | 
 | 233 | 	} | 
| Tarun Karra | 6875576 | 2012-01-12 16:07:09 -0800 | [diff] [blame] | 234 | 	mod_timer_pending(&device->idle_timer, | 
| Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 235 | 			jiffies + device->pwrctrl.interval_timeout); | 
 | 236 |  | 
 | 237 | 	return result; | 
 | 238 | } | 
 | 239 |  | 
| Jordan Crouse | 9f73921 | 2011-07-28 08:37:57 -0600 | [diff] [blame] | 240 | static void z180_cleanup_pt(struct kgsl_device *device, | 
| Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 241 | 			       struct kgsl_pagetable *pagetable) | 
 | 242 | { | 
 | 243 | 	struct z180_device *z180_dev = Z180_DEVICE(device); | 
 | 244 |  | 
| Shubhraprakash Das | 767fdda | 2011-08-15 15:49:45 -0600 | [diff] [blame] | 245 | 	kgsl_mmu_unmap(pagetable, &device->mmu.setstate_memory); | 
| Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 246 |  | 
 | 247 | 	kgsl_mmu_unmap(pagetable, &device->memstore); | 
 | 248 |  | 
 | 249 | 	kgsl_mmu_unmap(pagetable, &z180_dev->ringbuffer.cmdbufdesc); | 
| Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 250 | } | 
 | 251 |  | 
 | 252 | static int z180_setup_pt(struct kgsl_device *device, | 
 | 253 | 			     struct kgsl_pagetable *pagetable) | 
 | 254 | { | 
 | 255 | 	int result = 0; | 
 | 256 | 	struct z180_device *z180_dev = Z180_DEVICE(device); | 
 | 257 |  | 
| Shubhraprakash Das | 767fdda | 2011-08-15 15:49:45 -0600 | [diff] [blame] | 258 | 	result = kgsl_mmu_map_global(pagetable, &device->mmu.setstate_memory, | 
| Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 259 | 				     GSL_PT_PAGE_RV | GSL_PT_PAGE_WV); | 
 | 260 |  | 
 | 261 | 	if (result) | 
 | 262 | 		goto error; | 
 | 263 |  | 
 | 264 | 	result = kgsl_mmu_map_global(pagetable, &device->memstore, | 
 | 265 | 				     GSL_PT_PAGE_RV | GSL_PT_PAGE_WV); | 
 | 266 | 	if (result) | 
 | 267 | 		goto error_unmap_dummy; | 
 | 268 |  | 
 | 269 | 	result = kgsl_mmu_map_global(pagetable, | 
 | 270 | 				     &z180_dev->ringbuffer.cmdbufdesc, | 
 | 271 | 				     GSL_PT_PAGE_RV); | 
 | 272 | 	if (result) | 
 | 273 | 		goto error_unmap_memstore; | 
 | 274 | 	return result; | 
 | 275 |  | 
 | 276 | error_unmap_dummy: | 
| Shubhraprakash Das | 767fdda | 2011-08-15 15:49:45 -0600 | [diff] [blame] | 277 | 	kgsl_mmu_unmap(pagetable, &device->mmu.setstate_memory); | 
| Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 278 |  | 
 | 279 | error_unmap_memstore: | 
 | 280 | 	kgsl_mmu_unmap(pagetable, &device->memstore); | 
 | 281 |  | 
 | 282 | error: | 
 | 283 | 	return result; | 
 | 284 | } | 
 | 285 |  | 
| Jeremy Gebben | 8b253bf | 2012-04-23 16:02:47 -0600 | [diff] [blame] | 286 | static inline unsigned int rb_offset(unsigned int timestamp) | 
| Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 287 | { | 
| Jeremy Gebben | 8b253bf | 2012-04-23 16:02:47 -0600 | [diff] [blame] | 288 | 	return (timestamp % Z180_PACKET_COUNT) | 
 | 289 | 		*sizeof(unsigned int)*(Z180_PACKET_SIZE); | 
| Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 290 | } | 
 | 291 |  | 
| Jeremy Gebben | 8b253bf | 2012-04-23 16:02:47 -0600 | [diff] [blame] | 292 | static inline unsigned int rb_gpuaddr(struct z180_device *z180_dev, | 
 | 293 | 					unsigned int timestamp) | 
 | 294 | { | 
 | 295 | 	return z180_dev->ringbuffer.cmdbufdesc.gpuaddr + rb_offset(timestamp); | 
 | 296 | } | 
 | 297 |  | 
 | 298 | static void addmarker(struct z180_ringbuffer *rb, unsigned int timestamp) | 
| Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 299 | { | 
 | 300 | 	char *ptr = (char *)(rb->cmdbufdesc.hostptr); | 
| Jeremy Gebben | 8b253bf | 2012-04-23 16:02:47 -0600 | [diff] [blame] | 301 | 	unsigned int *p = (unsigned int *)(ptr + rb_offset(timestamp)); | 
| Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 302 |  | 
 | 303 | 	*p++ = Z180_STREAM_PACKET; | 
 | 304 | 	*p++ = (Z180_MARKER_CMD | 5); | 
 | 305 | 	*p++ = ADDR_VGV3_LAST << 24; | 
 | 306 | 	*p++ = ADDR_VGV3_LAST << 24; | 
 | 307 | 	*p++ = ADDR_VGV3_LAST << 24; | 
 | 308 | 	*p++ = Z180_STREAM_PACKET; | 
 | 309 | 	*p++ = 5; | 
 | 310 | 	*p++ = ADDR_VGV3_LAST << 24; | 
 | 311 | 	*p++ = ADDR_VGV3_LAST << 24; | 
 | 312 | 	*p++ = ADDR_VGV3_LAST << 24; | 
 | 313 | } | 
 | 314 |  | 
| Jeremy Gebben | 8b253bf | 2012-04-23 16:02:47 -0600 | [diff] [blame] | 315 | static void addcmd(struct z180_ringbuffer *rb, unsigned int timestamp, | 
| Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 316 | 			unsigned int cmd, unsigned int nextcnt) | 
 | 317 | { | 
 | 318 | 	char * ptr = (char *)(rb->cmdbufdesc.hostptr); | 
| Jeremy Gebben | 8b253bf | 2012-04-23 16:02:47 -0600 | [diff] [blame] | 319 | 	unsigned int *p = (unsigned int *)(ptr + (rb_offset(timestamp) | 
| Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 320 | 			   + (Z180_MARKER_SIZE * sizeof(unsigned int)))); | 
 | 321 |  | 
 | 322 | 	*p++ = Z180_STREAM_PACKET_CALL; | 
 | 323 | 	*p++ = cmd; | 
 | 324 | 	*p++ = Z180_CALL_CMD | nextcnt; | 
 | 325 | 	*p++ = ADDR_VGV3_LAST << 24; | 
 | 326 | 	*p++ = ADDR_VGV3_LAST << 24; | 
 | 327 | } | 
 | 328 |  | 
| Shubhraprakash Das | 8cbd232 | 2012-03-04 14:41:39 -0700 | [diff] [blame] | 329 | static void z180_cmdstream_start(struct kgsl_device *device, int init_ram) | 
| Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 330 | { | 
 | 331 | 	struct z180_device *z180_dev = Z180_DEVICE(device); | 
 | 332 | 	unsigned int cmd = VGV3_NEXTCMD_JUMP << VGV3_NEXTCMD_NEXTCMD_FSHIFT; | 
 | 333 |  | 
| Shubhraprakash Das | 8cbd232 | 2012-03-04 14:41:39 -0700 | [diff] [blame] | 334 | 	if (init_ram) { | 
 | 335 | 		z180_dev->timestamp = 0; | 
 | 336 | 		z180_dev->current_timestamp = 0; | 
 | 337 | 	} | 
| Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 338 |  | 
 | 339 | 	addmarker(&z180_dev->ringbuffer, 0); | 
 | 340 |  | 
 | 341 | 	z180_cmdwindow_write(device, ADDR_VGV3_MODE, 4); | 
 | 342 |  | 
 | 343 | 	z180_cmdwindow_write(device, ADDR_VGV3_NEXTADDR, | 
| Jeremy Gebben | 8b253bf | 2012-04-23 16:02:47 -0600 | [diff] [blame] | 344 | 			     rb_gpuaddr(z180_dev, z180_dev->current_timestamp)); | 
| Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 345 |  | 
 | 346 | 	z180_cmdwindow_write(device, ADDR_VGV3_NEXTCMD, cmd | 5); | 
 | 347 |  | 
 | 348 | 	z180_cmdwindow_write(device, ADDR_VGV3_WRITEADDR, | 
 | 349 | 			device->memstore.gpuaddr); | 
 | 350 |  | 
 | 351 | 	cmd = (int)(((1) & VGV3_CONTROL_MARKADD_FMASK) | 
 | 352 | 			<< VGV3_CONTROL_MARKADD_FSHIFT); | 
 | 353 |  | 
 | 354 | 	z180_cmdwindow_write(device, ADDR_VGV3_CONTROL, cmd); | 
 | 355 |  | 
 | 356 | 	z180_cmdwindow_write(device, ADDR_VGV3_CONTROL, 0); | 
 | 357 | } | 
 | 358 |  | 
 | 359 | static int room_in_rb(struct z180_device *device) | 
 | 360 | { | 
 | 361 | 	int ts_diff; | 
 | 362 |  | 
 | 363 | 	ts_diff = device->current_timestamp - device->timestamp; | 
 | 364 |  | 
 | 365 | 	return ts_diff < Z180_PACKET_COUNT; | 
 | 366 | } | 
 | 367 |  | 
 | 368 | static int z180_idle(struct kgsl_device *device, unsigned int timeout) | 
 | 369 | { | 
 | 370 | 	int status = 0; | 
 | 371 | 	struct z180_device *z180_dev = Z180_DEVICE(device); | 
 | 372 |  | 
| Jordan Crouse | e6239dd | 2011-11-17 13:39:21 -0700 | [diff] [blame] | 373 | 	if (timestamp_cmp(z180_dev->current_timestamp, | 
 | 374 | 		z180_dev->timestamp) > 0) | 
| Carter Cooper | 7e7f02e | 2012-02-15 09:36:31 -0700 | [diff] [blame] | 375 | 		status = z180_wait(device, NULL, | 
 | 376 | 				z180_dev->current_timestamp, timeout); | 
| Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 377 |  | 
 | 378 | 	if (status) | 
 | 379 | 		KGSL_DRV_ERR(device, "z180_waittimestamp() timed out\n"); | 
 | 380 |  | 
 | 381 | 	return status; | 
 | 382 | } | 
 | 383 |  | 
| Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 384 | int | 
 | 385 | z180_cmdstream_issueibcmds(struct kgsl_device_private *dev_priv, | 
 | 386 | 			struct kgsl_context *context, | 
 | 387 | 			struct kgsl_ibdesc *ibdesc, | 
 | 388 | 			unsigned int numibs, | 
 | 389 | 			uint32_t *timestamp, | 
 | 390 | 			unsigned int ctrl) | 
 | 391 | { | 
| Tarun Karra | 9b92ccd | 2011-08-19 10:59:57 -0700 | [diff] [blame] | 392 | 	long result = 0; | 
| Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 393 | 	unsigned int ofs        = PACKETSIZE_STATESTREAM * sizeof(unsigned int); | 
 | 394 | 	unsigned int cnt        = 5; | 
| Jeremy Gebben | 8b253bf | 2012-04-23 16:02:47 -0600 | [diff] [blame] | 395 | 	unsigned int old_timestamp = 0; | 
| Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 396 | 	unsigned int nextcnt    = Z180_STREAM_END_CMD | 5; | 
| Jeremy Gebben | d27b09f | 2012-04-06 16:09:13 -0600 | [diff] [blame] | 397 | 	struct kgsl_mem_entry *entry = NULL; | 
| Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 398 | 	unsigned int cmd; | 
 | 399 | 	struct kgsl_device *device = dev_priv->device; | 
 | 400 | 	struct kgsl_pagetable *pagetable = dev_priv->process_priv->pagetable; | 
 | 401 | 	struct z180_device *z180_dev = Z180_DEVICE(device); | 
 | 402 | 	unsigned int sizedwords; | 
 | 403 |  | 
 | 404 | 	if (device->state & KGSL_STATE_HUNG) { | 
| Carter Cooper | b90880d | 2011-10-26 14:38:02 -0600 | [diff] [blame] | 405 | 		result = -EINVAL; | 
| Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 406 | 		goto error; | 
 | 407 | 	} | 
 | 408 | 	if (numibs != 1) { | 
 | 409 | 		KGSL_DRV_ERR(device, "Invalid number of ibs: %d\n", numibs); | 
 | 410 | 		result = -EINVAL; | 
 | 411 | 		goto error; | 
 | 412 | 	} | 
 | 413 | 	cmd = ibdesc[0].gpuaddr; | 
 | 414 | 	sizedwords = ibdesc[0].sizedwords; | 
| Jeremy Gebben | d27b09f | 2012-04-06 16:09:13 -0600 | [diff] [blame] | 415 | 	/* | 
 | 416 | 	 * Get a kernel mapping to the IB for monkey patching. | 
 | 417 | 	 * See the end of this function. | 
 | 418 | 	 */ | 
 | 419 | 	entry = kgsl_sharedmem_find_region(dev_priv->process_priv, cmd, | 
 | 420 | 		sizedwords); | 
 | 421 | 	if (entry == NULL) { | 
 | 422 | 		KGSL_DRV_ERR(device, "Bad ibdesc: gpuaddr 0x%x size %d\n", | 
 | 423 | 			     cmd, sizedwords); | 
 | 424 | 		result = -EINVAL; | 
 | 425 | 		goto error; | 
 | 426 | 	} | 
 | 427 | 	/* | 
 | 428 | 	 * This will only map memory if it exists, otherwise it will reuse the | 
 | 429 | 	 * mapping. And the 2d userspace reuses IBs so we likely won't create | 
 | 430 | 	 * too many mappings. | 
 | 431 | 	 */ | 
 | 432 | 	if (kgsl_gpuaddr_to_vaddr(&entry->memdesc, cmd) == NULL) { | 
 | 433 | 		KGSL_DRV_ERR(device, | 
 | 434 | 			     "Cannot make kernel mapping for gpuaddr 0x%x\n", | 
 | 435 | 			     cmd); | 
 | 436 | 		result = -EINVAL; | 
 | 437 | 		goto error; | 
 | 438 | 	} | 
| Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 439 |  | 
 | 440 | 	KGSL_CMD_INFO(device, "ctxt %d ibaddr 0x%08x sizedwords %d\n", | 
 | 441 | 		context->id, cmd, sizedwords); | 
 | 442 | 	/* context switch */ | 
 | 443 | 	if ((context->id != (int)z180_dev->ringbuffer.prevctx) || | 
 | 444 | 	    (ctrl & KGSL_CONTEXT_CTX_SWITCH)) { | 
 | 445 | 		KGSL_CMD_INFO(device, "context switch %d -> %d\n", | 
 | 446 | 			context->id, z180_dev->ringbuffer.prevctx); | 
| Shubhraprakash Das | b2abc45 | 2012-06-08 16:33:03 -0600 | [diff] [blame] | 447 | 		kgsl_mmu_setstate(&device->mmu, pagetable, | 
 | 448 | 				KGSL_MEMSTORE_GLOBAL); | 
| Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 449 | 		cnt = PACKETSIZE_STATESTREAM; | 
 | 450 | 		ofs = 0; | 
 | 451 | 	} | 
| Shubhraprakash Das | 1c52826 | 2012-04-26 17:38:13 -0600 | [diff] [blame] | 452 | 	kgsl_setstate(&device->mmu, | 
| Shubhraprakash Das | b2abc45 | 2012-06-08 16:33:03 -0600 | [diff] [blame] | 453 | 			KGSL_MEMSTORE_GLOBAL, | 
| Shubhraprakash Das | 1c52826 | 2012-04-26 17:38:13 -0600 | [diff] [blame] | 454 | 			kgsl_mmu_pt_get_flags(device->mmu.hwpagetable, | 
 | 455 | 			device->id)); | 
| Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 456 |  | 
 | 457 | 	result = wait_event_interruptible_timeout(device->wait_queue, | 
 | 458 | 				  room_in_rb(z180_dev), | 
 | 459 | 				  msecs_to_jiffies(KGSL_TIMEOUT_DEFAULT)); | 
 | 460 | 	if (result < 0) { | 
 | 461 | 		KGSL_CMD_ERR(device, "wait_event_interruptible_timeout " | 
| Tarun Karra | 9b92ccd | 2011-08-19 10:59:57 -0700 | [diff] [blame] | 462 | 			"failed: %ld\n", result); | 
| Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 463 | 		goto error; | 
 | 464 | 	} | 
 | 465 | 	result = 0; | 
 | 466 |  | 
| Jeremy Gebben | 8b253bf | 2012-04-23 16:02:47 -0600 | [diff] [blame] | 467 | 	old_timestamp = z180_dev->current_timestamp; | 
| Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 468 | 	z180_dev->current_timestamp++; | 
| Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 469 | 	*timestamp = z180_dev->current_timestamp; | 
 | 470 |  | 
 | 471 | 	z180_dev->ringbuffer.prevctx = context->id; | 
 | 472 |  | 
| Jeremy Gebben | 8b253bf | 2012-04-23 16:02:47 -0600 | [diff] [blame] | 473 | 	addcmd(&z180_dev->ringbuffer, old_timestamp, cmd + ofs, cnt); | 
| Lucille Sylvester | 808eca2 | 2011-11-03 10:26:29 -0700 | [diff] [blame] | 474 | 	kgsl_pwrscale_busy(device); | 
| Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 475 |  | 
 | 476 | 	/* Make sure the next ringbuffer entry has a marker */ | 
| Jeremy Gebben | 8b253bf | 2012-04-23 16:02:47 -0600 | [diff] [blame] | 477 | 	addmarker(&z180_dev->ringbuffer, z180_dev->current_timestamp); | 
| Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 478 |  | 
| Jeremy Gebben | d27b09f | 2012-04-06 16:09:13 -0600 | [diff] [blame] | 479 | 	/* monkey patch the IB so that it jumps back to the ringbuffer */ | 
 | 480 | 	kgsl_sharedmem_writel(&entry->memdesc, | 
| Jeremy Gebben | 8b253bf | 2012-04-23 16:02:47 -0600 | [diff] [blame] | 481 | 		      ((sizedwords + 1) * sizeof(unsigned int)), | 
 | 482 | 		      rb_gpuaddr(z180_dev, z180_dev->current_timestamp)); | 
| Jeremy Gebben | d27b09f | 2012-04-06 16:09:13 -0600 | [diff] [blame] | 483 | 	kgsl_sharedmem_writel(&entry->memdesc, | 
 | 484 | 			      ((sizedwords + 2) * sizeof(unsigned int)), | 
 | 485 | 			      nextcnt); | 
| Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 486 |  | 
 | 487 | 	/* sync memory before activating the hardware for the new command*/ | 
 | 488 | 	mb(); | 
 | 489 |  | 
 | 490 | 	cmd = (int)(((2) & VGV3_CONTROL_MARKADD_FMASK) | 
 | 491 | 		<< VGV3_CONTROL_MARKADD_FSHIFT); | 
 | 492 |  | 
 | 493 | 	z180_cmdwindow_write(device, ADDR_VGV3_CONTROL, cmd); | 
 | 494 | 	z180_cmdwindow_write(device, ADDR_VGV3_CONTROL, 0); | 
 | 495 | error: | 
| Tarun Karra | 9b92ccd | 2011-08-19 10:59:57 -0700 | [diff] [blame] | 496 | 	return (int)result; | 
| Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 497 | } | 
 | 498 |  | 
 | 499 | static int z180_ringbuffer_init(struct kgsl_device *device) | 
 | 500 | { | 
 | 501 | 	struct z180_device *z180_dev = Z180_DEVICE(device); | 
 | 502 | 	memset(&z180_dev->ringbuffer, 0, sizeof(struct z180_ringbuffer)); | 
 | 503 | 	z180_dev->ringbuffer.prevctx = Z180_INVALID_CONTEXT; | 
 | 504 | 	return kgsl_allocate_contiguous(&z180_dev->ringbuffer.cmdbufdesc, | 
 | 505 | 		Z180_RB_SIZE); | 
 | 506 | } | 
 | 507 |  | 
 | 508 | static void z180_ringbuffer_close(struct kgsl_device *device) | 
 | 509 | { | 
 | 510 | 	struct z180_device *z180_dev = Z180_DEVICE(device); | 
 | 511 | 	kgsl_sharedmem_free(&z180_dev->ringbuffer.cmdbufdesc); | 
 | 512 | 	memset(&z180_dev->ringbuffer, 0, sizeof(struct z180_ringbuffer)); | 
 | 513 | } | 
 | 514 |  | 
 | 515 | static int __devinit z180_probe(struct platform_device *pdev) | 
 | 516 | { | 
 | 517 | 	int status = -EINVAL; | 
 | 518 | 	struct kgsl_device *device = NULL; | 
 | 519 | 	struct z180_device *z180_dev; | 
 | 520 |  | 
 | 521 | 	device = (struct kgsl_device *)pdev->id_entry->driver_data; | 
 | 522 | 	device->parentdev = &pdev->dev; | 
 | 523 |  | 
 | 524 | 	z180_dev = Z180_DEVICE(device); | 
| Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 525 |  | 
 | 526 | 	status = z180_ringbuffer_init(device); | 
 | 527 | 	if (status != 0) | 
 | 528 | 		goto error; | 
 | 529 |  | 
| Jordan Crouse | b368e9b | 2012-04-27 14:01:59 -0600 | [diff] [blame] | 530 | 	status = kgsl_device_platform_probe(device); | 
| Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 531 | 	if (status) | 
 | 532 | 		goto error_close_ringbuffer; | 
 | 533 |  | 
| Lucille Sylvester | 591ea03 | 2011-07-21 16:08:37 -0600 | [diff] [blame] | 534 | 	kgsl_pwrscale_init(device); | 
| Lucille Sylvester | 808eca2 | 2011-11-03 10:26:29 -0700 | [diff] [blame] | 535 | 	kgsl_pwrscale_attach_policy(device, Z180_DEFAULT_PWRSCALE_POLICY); | 
| Lucille Sylvester | 591ea03 | 2011-07-21 16:08:37 -0600 | [diff] [blame] | 536 |  | 
| Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 537 | 	return status; | 
 | 538 |  | 
 | 539 | error_close_ringbuffer: | 
 | 540 | 	z180_ringbuffer_close(device); | 
 | 541 | error: | 
 | 542 | 	device->parentdev = NULL; | 
 | 543 | 	return status; | 
 | 544 | } | 
 | 545 |  | 
 | 546 | static int __devexit z180_remove(struct platform_device *pdev) | 
 | 547 | { | 
 | 548 | 	struct kgsl_device *device = NULL; | 
 | 549 |  | 
 | 550 | 	device = (struct kgsl_device *)pdev->id_entry->driver_data; | 
 | 551 |  | 
| Lucille Sylvester | 591ea03 | 2011-07-21 16:08:37 -0600 | [diff] [blame] | 552 | 	kgsl_pwrscale_close(device); | 
| Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 553 | 	kgsl_device_platform_remove(device); | 
 | 554 |  | 
 | 555 | 	z180_ringbuffer_close(device); | 
 | 556 |  | 
 | 557 | 	return 0; | 
 | 558 | } | 
 | 559 |  | 
 | 560 | static int z180_start(struct kgsl_device *device, unsigned int init_ram) | 
 | 561 | { | 
 | 562 | 	int status = 0; | 
 | 563 |  | 
| Jeremy Gebben | 388c297 | 2011-12-16 09:05:07 -0700 | [diff] [blame] | 564 | 	kgsl_pwrctrl_set_state(device, KGSL_STATE_INIT); | 
| Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 565 |  | 
 | 566 | 	kgsl_pwrctrl_enable(device); | 
 | 567 |  | 
| Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 568 | 	/* Set interrupts to 0 to ensure a good state */ | 
 | 569 | 	z180_regwrite(device, (ADDR_VGC_IRQENABLE >> 2), 0x0); | 
 | 570 |  | 
| Jeremy Gebben | 4e8aada | 2011-07-12 10:07:47 -0600 | [diff] [blame] | 571 | 	kgsl_mh_start(device); | 
 | 572 |  | 
| Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 573 | 	status = kgsl_mmu_start(device); | 
 | 574 | 	if (status) | 
 | 575 | 		goto error_clk_off; | 
 | 576 |  | 
| Shubhraprakash Das | 8cbd232 | 2012-03-04 14:41:39 -0700 | [diff] [blame] | 577 | 	z180_cmdstream_start(device, init_ram); | 
| Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 578 |  | 
 | 579 | 	mod_timer(&device->idle_timer, jiffies + FIRST_TIMEOUT); | 
| Jeremy Gebben | b46f415 | 2011-10-14 14:27:00 -0600 | [diff] [blame] | 580 | 	kgsl_pwrctrl_irq(device, KGSL_PWRFLAGS_ON); | 
| Jeremy Gebben | b7bc955 | 2012-01-09 13:32:49 -0700 | [diff] [blame] | 581 | 	device->ftbl->irqctrl(device, 1); | 
| Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 582 | 	return 0; | 
 | 583 |  | 
 | 584 | error_clk_off: | 
 | 585 | 	z180_regwrite(device, (ADDR_VGC_IRQENABLE >> 2), 0); | 
 | 586 | 	kgsl_pwrctrl_disable(device); | 
 | 587 | 	return status; | 
 | 588 | } | 
 | 589 |  | 
 | 590 | static int z180_stop(struct kgsl_device *device) | 
 | 591 | { | 
| Jeremy Gebben | b7bc955 | 2012-01-09 13:32:49 -0700 | [diff] [blame] | 592 | 	device->ftbl->irqctrl(device, 0); | 
| Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 593 | 	z180_idle(device, KGSL_TIMEOUT_DEFAULT); | 
 | 594 |  | 
| Suman Tatiraju | 4a32c65 | 2012-02-17 11:59:05 -0800 | [diff] [blame] | 595 | 	del_timer_sync(&device->idle_timer); | 
 | 596 |  | 
| Shubhraprakash Das | 7944795 | 2012-04-26 18:12:23 -0600 | [diff] [blame] | 597 | 	kgsl_mmu_stop(&device->mmu); | 
| Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 598 |  | 
 | 599 | 	/* Disable the clocks before the power rail. */ | 
 | 600 | 	kgsl_pwrctrl_irq(device, KGSL_PWRFLAGS_OFF); | 
 | 601 |  | 
 | 602 | 	kgsl_pwrctrl_disable(device); | 
 | 603 |  | 
 | 604 | 	return 0; | 
 | 605 | } | 
 | 606 |  | 
 | 607 | static int z180_getproperty(struct kgsl_device *device, | 
 | 608 | 				enum kgsl_property_type type, | 
 | 609 | 				void *value, | 
 | 610 | 				unsigned int sizebytes) | 
 | 611 | { | 
 | 612 | 	int status = -EINVAL; | 
 | 613 |  | 
 | 614 | 	switch (type) { | 
 | 615 | 	case KGSL_PROP_DEVICE_INFO: | 
 | 616 | 	{ | 
 | 617 | 		struct kgsl_devinfo devinfo; | 
 | 618 |  | 
 | 619 | 		if (sizebytes != sizeof(devinfo)) { | 
 | 620 | 			status = -EINVAL; | 
 | 621 | 			break; | 
 | 622 | 		} | 
 | 623 |  | 
 | 624 | 		memset(&devinfo, 0, sizeof(devinfo)); | 
 | 625 | 		devinfo.device_id = device->id+1; | 
 | 626 | 		devinfo.chip_id = 0; | 
 | 627 | 		devinfo.mmu_enabled = kgsl_mmu_enabled(); | 
 | 628 |  | 
 | 629 | 		if (copy_to_user(value, &devinfo, sizeof(devinfo)) != | 
 | 630 | 				0) { | 
 | 631 | 			status = -EFAULT; | 
 | 632 | 			break; | 
 | 633 | 		} | 
 | 634 | 		status = 0; | 
 | 635 | 	} | 
 | 636 | 	break; | 
 | 637 | 	case KGSL_PROP_MMU_ENABLE: | 
 | 638 | 		{ | 
| Shubhraprakash Das | 767fdda | 2011-08-15 15:49:45 -0600 | [diff] [blame] | 639 | 			int mmu_prop = kgsl_mmu_enabled(); | 
| Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 640 | 			if (sizebytes != sizeof(int)) { | 
 | 641 | 				status = -EINVAL; | 
 | 642 | 				break; | 
 | 643 | 			} | 
| Shubhraprakash Das | 767fdda | 2011-08-15 15:49:45 -0600 | [diff] [blame] | 644 | 			if (copy_to_user(value, &mmu_prop, sizeof(mmu_prop))) { | 
| Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 645 | 				status = -EFAULT; | 
 | 646 | 				break; | 
 | 647 | 			} | 
 | 648 | 			status = 0; | 
 | 649 | 		} | 
 | 650 | 		break; | 
 | 651 |  | 
 | 652 | 	default: | 
 | 653 | 		KGSL_DRV_ERR(device, "invalid property: %d\n", type); | 
 | 654 | 		status = -EINVAL; | 
 | 655 | 	} | 
 | 656 | 	return status; | 
 | 657 | } | 
 | 658 |  | 
 | 659 | static unsigned int z180_isidle(struct kgsl_device *device) | 
 | 660 | { | 
| Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 661 | 	struct z180_device *z180_dev = Z180_DEVICE(device); | 
 | 662 |  | 
| Jordan Crouse | e6239dd | 2011-11-17 13:39:21 -0700 | [diff] [blame] | 663 | 	return (timestamp_cmp(z180_dev->timestamp, | 
 | 664 | 		z180_dev->current_timestamp) == 0) ? true : false; | 
| Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 665 | } | 
 | 666 |  | 
 | 667 | static int z180_suspend_context(struct kgsl_device *device) | 
 | 668 | { | 
 | 669 | 	struct z180_device *z180_dev = Z180_DEVICE(device); | 
 | 670 |  | 
 | 671 | 	z180_dev->ringbuffer.prevctx = Z180_INVALID_CONTEXT; | 
 | 672 |  | 
 | 673 | 	return 0; | 
 | 674 | } | 
 | 675 |  | 
 | 676 | /* Not all Z180 registers are directly accessible. | 
 | 677 |  * The _z180_(read|write)_simple functions below handle the ones that are. | 
 | 678 |  */ | 
 | 679 | static void _z180_regread_simple(struct kgsl_device *device, | 
 | 680 | 				unsigned int offsetwords, | 
 | 681 | 				unsigned int *value) | 
 | 682 | { | 
 | 683 | 	unsigned int *reg; | 
 | 684 |  | 
| Jordan Crouse | 7501d45 | 2012-04-19 08:58:44 -0600 | [diff] [blame] | 685 | 	BUG_ON(offsetwords * sizeof(uint32_t) >= device->reg_len); | 
| Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 686 |  | 
| Jordan Crouse | 7501d45 | 2012-04-19 08:58:44 -0600 | [diff] [blame] | 687 | 	reg = (unsigned int *)(device->reg_virt + (offsetwords << 2)); | 
| Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 688 |  | 
 | 689 | 	/*ensure this read finishes before the next one. | 
 | 690 | 	 * i.e. act like normal readl() */ | 
 | 691 | 	*value = __raw_readl(reg); | 
 | 692 | 	rmb(); | 
 | 693 |  | 
 | 694 | } | 
 | 695 |  | 
 | 696 | static void _z180_regwrite_simple(struct kgsl_device *device, | 
 | 697 | 				 unsigned int offsetwords, | 
 | 698 | 				 unsigned int value) | 
 | 699 | { | 
 | 700 | 	unsigned int *reg; | 
 | 701 |  | 
| Jordan Crouse | 7501d45 | 2012-04-19 08:58:44 -0600 | [diff] [blame] | 702 | 	BUG_ON(offsetwords*sizeof(uint32_t) >= device->reg_len); | 
| Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 703 |  | 
| Jordan Crouse | 7501d45 | 2012-04-19 08:58:44 -0600 | [diff] [blame] | 704 | 	reg = (unsigned int *)(device->reg_virt + (offsetwords << 2)); | 
| Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 705 | 	kgsl_cffdump_regwrite(device->id, offsetwords << 2, value); | 
 | 706 | 	/*ensure previous writes post before this one, | 
 | 707 | 	 * i.e. act like normal writel() */ | 
 | 708 | 	wmb(); | 
 | 709 | 	__raw_writel(value, reg); | 
 | 710 | } | 
 | 711 |  | 
 | 712 |  | 
 | 713 | /* The MH registers must be accessed through via a 2 step write, (read|write) | 
 | 714 |  * process. These registers may be accessed from interrupt context during | 
 | 715 |  * the handling of MH or MMU error interrupts. Therefore a spin lock is used | 
 | 716 |  * to ensure that the 2 step sequence is not interrupted. | 
 | 717 |  */ | 
 | 718 | static void _z180_regread_mmu(struct kgsl_device *device, | 
 | 719 | 			     unsigned int offsetwords, | 
 | 720 | 			     unsigned int *value) | 
 | 721 | { | 
 | 722 | 	struct z180_device *z180_dev = Z180_DEVICE(device); | 
 | 723 | 	unsigned long flags; | 
 | 724 |  | 
 | 725 | 	spin_lock_irqsave(&z180_dev->cmdwin_lock, flags); | 
 | 726 | 	_z180_regwrite_simple(device, (ADDR_VGC_MH_READ_ADDR >> 2), | 
 | 727 | 				offsetwords); | 
 | 728 | 	_z180_regread_simple(device, (ADDR_VGC_MH_DATA_ADDR >> 2), value); | 
 | 729 | 	spin_unlock_irqrestore(&z180_dev->cmdwin_lock, flags); | 
 | 730 | } | 
 | 731 |  | 
 | 732 |  | 
 | 733 | static void _z180_regwrite_mmu(struct kgsl_device *device, | 
 | 734 | 			      unsigned int offsetwords, | 
 | 735 | 			      unsigned int value) | 
 | 736 | { | 
 | 737 | 	struct z180_device *z180_dev = Z180_DEVICE(device); | 
 | 738 | 	unsigned int cmdwinaddr; | 
 | 739 | 	unsigned long flags; | 
 | 740 |  | 
 | 741 | 	cmdwinaddr = ((Z180_CMDWINDOW_MMU << Z180_CMDWINDOW_TARGET_SHIFT) & | 
 | 742 | 			Z180_CMDWINDOW_TARGET_MASK); | 
 | 743 | 	cmdwinaddr |= ((offsetwords << Z180_CMDWINDOW_ADDR_SHIFT) & | 
 | 744 | 			Z180_CMDWINDOW_ADDR_MASK); | 
 | 745 |  | 
 | 746 | 	spin_lock_irqsave(&z180_dev->cmdwin_lock, flags); | 
 | 747 | 	_z180_regwrite_simple(device, ADDR_VGC_MMUCOMMANDSTREAM >> 2, | 
 | 748 | 			     cmdwinaddr); | 
 | 749 | 	_z180_regwrite_simple(device, ADDR_VGC_MMUCOMMANDSTREAM >> 2, value); | 
 | 750 | 	spin_unlock_irqrestore(&z180_dev->cmdwin_lock, flags); | 
 | 751 | } | 
 | 752 |  | 
 | 753 | /* the rest of the code doesn't want to think about if it is writing mmu | 
 | 754 |  * registers or normal registers so handle it here | 
 | 755 |  */ | 
 | 756 | static void z180_regread(struct kgsl_device *device, | 
 | 757 | 			unsigned int offsetwords, | 
 | 758 | 			unsigned int *value) | 
 | 759 | { | 
 | 760 | 	if (!in_interrupt()) | 
 | 761 | 		kgsl_pre_hwaccess(device); | 
 | 762 |  | 
| Jeremy Gebben | 4e8aada | 2011-07-12 10:07:47 -0600 | [diff] [blame] | 763 | 	if ((offsetwords >= MH_ARBITER_CONFIG && | 
 | 764 | 	     offsetwords <= MH_AXI_HALT_CONTROL) || | 
| Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 765 | 	    (offsetwords >= MH_MMU_CONFIG && | 
 | 766 | 	     offsetwords <= MH_MMU_MPU_END)) { | 
 | 767 | 		_z180_regread_mmu(device, offsetwords, value); | 
 | 768 | 	} else { | 
 | 769 | 		_z180_regread_simple(device, offsetwords, value); | 
 | 770 | 	} | 
 | 771 | } | 
 | 772 |  | 
 | 773 | static void z180_regwrite(struct kgsl_device *device, | 
 | 774 | 				unsigned int offsetwords, | 
 | 775 | 				unsigned int value) | 
 | 776 | { | 
 | 777 | 	if (!in_interrupt()) | 
 | 778 | 		kgsl_pre_hwaccess(device); | 
 | 779 |  | 
| Jeremy Gebben | 4e8aada | 2011-07-12 10:07:47 -0600 | [diff] [blame] | 780 | 	if ((offsetwords >= MH_ARBITER_CONFIG && | 
 | 781 | 	     offsetwords <= MH_CLNT_INTF_CTRL_CONFIG2) || | 
| Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 782 | 	    (offsetwords >= MH_MMU_CONFIG && | 
 | 783 | 	     offsetwords <= MH_MMU_MPU_END)) { | 
 | 784 | 		_z180_regwrite_mmu(device, offsetwords, value); | 
 | 785 | 	} else { | 
 | 786 | 		_z180_regwrite_simple(device, offsetwords, value); | 
 | 787 | 	} | 
 | 788 | } | 
 | 789 |  | 
 | 790 | static void z180_cmdwindow_write(struct kgsl_device *device, | 
 | 791 | 		unsigned int addr, unsigned int data) | 
 | 792 | { | 
 | 793 | 	unsigned int cmdwinaddr; | 
 | 794 |  | 
 | 795 | 	cmdwinaddr = ((Z180_CMDWINDOW_2D << Z180_CMDWINDOW_TARGET_SHIFT) & | 
 | 796 | 			Z180_CMDWINDOW_TARGET_MASK); | 
 | 797 | 	cmdwinaddr |= ((addr << Z180_CMDWINDOW_ADDR_SHIFT) & | 
 | 798 | 			Z180_CMDWINDOW_ADDR_MASK); | 
 | 799 |  | 
 | 800 | 	z180_regwrite(device, ADDR_VGC_COMMANDSTREAM >> 2, cmdwinaddr); | 
 | 801 | 	z180_regwrite(device, ADDR_VGC_COMMANDSTREAM >> 2, data); | 
 | 802 | } | 
 | 803 |  | 
 | 804 | static unsigned int z180_readtimestamp(struct kgsl_device *device, | 
| Carter Cooper | 7e7f02e | 2012-02-15 09:36:31 -0700 | [diff] [blame] | 805 | 		struct kgsl_context *context, enum kgsl_timestamp_type type) | 
| Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 806 | { | 
 | 807 | 	struct z180_device *z180_dev = Z180_DEVICE(device); | 
| Carter Cooper | 7e7f02e | 2012-02-15 09:36:31 -0700 | [diff] [blame] | 808 | 	(void)context; | 
| Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 809 | 	/* get current EOP timestamp */ | 
 | 810 | 	return z180_dev->timestamp; | 
 | 811 | } | 
 | 812 |  | 
 | 813 | static int z180_waittimestamp(struct kgsl_device *device, | 
| Carter Cooper | 7e7f02e | 2012-02-15 09:36:31 -0700 | [diff] [blame] | 814 | 				struct kgsl_context *context, | 
| Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 815 | 				unsigned int timestamp, | 
 | 816 | 				unsigned int msecs) | 
 | 817 | { | 
 | 818 | 	int status = -EINVAL; | 
| Ranjhith Kalisamy | 823c148 | 2011-09-05 20:31:07 +0530 | [diff] [blame] | 819 |  | 
 | 820 | 	/* Don't wait forever, set a max (10 sec) value for now */ | 
 | 821 | 	if (msecs == -1) | 
 | 822 | 		msecs = 10 * MSEC_PER_SEC; | 
 | 823 |  | 
| Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 824 | 	mutex_unlock(&device->mutex); | 
| Carter Cooper | 7e7f02e | 2012-02-15 09:36:31 -0700 | [diff] [blame] | 825 | 	status = z180_wait(device, context, timestamp, msecs); | 
| Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 826 | 	mutex_lock(&device->mutex); | 
 | 827 |  | 
 | 828 | 	return status; | 
 | 829 | } | 
 | 830 |  | 
 | 831 | static int z180_wait(struct kgsl_device *device, | 
| Carter Cooper | 7e7f02e | 2012-02-15 09:36:31 -0700 | [diff] [blame] | 832 | 				struct kgsl_context *context, | 
| Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 833 | 				unsigned int timestamp, | 
 | 834 | 				unsigned int msecs) | 
 | 835 | { | 
 | 836 | 	int status = -EINVAL; | 
 | 837 | 	long timeout = 0; | 
 | 838 |  | 
 | 839 | 	timeout = wait_io_event_interruptible_timeout( | 
 | 840 | 			device->wait_queue, | 
| Carter Cooper | 7e7f02e | 2012-02-15 09:36:31 -0700 | [diff] [blame] | 841 | 			kgsl_check_timestamp(device, context, timestamp), | 
| Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 842 | 			msecs_to_jiffies(msecs)); | 
 | 843 |  | 
 | 844 | 	if (timeout > 0) | 
 | 845 | 		status = 0; | 
 | 846 | 	else if (timeout == 0) { | 
 | 847 | 		status = -ETIMEDOUT; | 
| Jeremy Gebben | 388c297 | 2011-12-16 09:05:07 -0700 | [diff] [blame] | 848 | 		kgsl_pwrctrl_set_state(device, KGSL_STATE_HUNG); | 
| Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 849 | 	} else | 
 | 850 | 		status = timeout; | 
 | 851 |  | 
 | 852 | 	return status; | 
 | 853 | } | 
 | 854 |  | 
 | 855 | static void | 
 | 856 | z180_drawctxt_destroy(struct kgsl_device *device, | 
 | 857 | 			  struct kgsl_context *context) | 
 | 858 | { | 
 | 859 | 	struct z180_device *z180_dev = Z180_DEVICE(device); | 
 | 860 |  | 
 | 861 | 	z180_idle(device, KGSL_TIMEOUT_DEFAULT); | 
 | 862 |  | 
 | 863 | 	if (z180_dev->ringbuffer.prevctx == context->id) { | 
 | 864 | 		z180_dev->ringbuffer.prevctx = Z180_INVALID_CONTEXT; | 
 | 865 | 		device->mmu.hwpagetable = device->mmu.defaultpagetable; | 
| Shubhraprakash Das | b2abc45 | 2012-06-08 16:33:03 -0600 | [diff] [blame] | 866 | 		kgsl_setstate(&device->mmu, KGSL_MEMSTORE_GLOBAL, | 
 | 867 | 				KGSL_MMUFLAGS_PTUPDATE); | 
| Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 868 | 	} | 
 | 869 | } | 
 | 870 |  | 
 | 871 | static void z180_power_stats(struct kgsl_device *device, | 
 | 872 | 			    struct kgsl_power_stats *stats) | 
 | 873 | { | 
| Lucille Sylvester | 591ea03 | 2011-07-21 16:08:37 -0600 | [diff] [blame] | 874 | 	struct kgsl_pwrctrl *pwr = &device->pwrctrl; | 
| Lucille Sylvester | 808eca2 | 2011-11-03 10:26:29 -0700 | [diff] [blame] | 875 | 	s64 tmp = ktime_to_us(ktime_get()); | 
| Lucille Sylvester | 591ea03 | 2011-07-21 16:08:37 -0600 | [diff] [blame] | 876 |  | 
 | 877 | 	if (pwr->time == 0) { | 
| Lucille Sylvester | 808eca2 | 2011-11-03 10:26:29 -0700 | [diff] [blame] | 878 | 		pwr->time = tmp; | 
| Lucille Sylvester | 591ea03 | 2011-07-21 16:08:37 -0600 | [diff] [blame] | 879 | 		stats->total_time = 0; | 
 | 880 | 		stats->busy_time = 0; | 
 | 881 | 	} else { | 
| Lucille Sylvester | 591ea03 | 2011-07-21 16:08:37 -0600 | [diff] [blame] | 882 | 		stats->total_time = tmp - pwr->time; | 
| Lucille Sylvester | 591ea03 | 2011-07-21 16:08:37 -0600 | [diff] [blame] | 883 | 		pwr->time = tmp; | 
| Lucille Sylvester | 808eca2 | 2011-11-03 10:26:29 -0700 | [diff] [blame] | 884 | 		stats->busy_time = tmp - device->on_time; | 
 | 885 | 		device->on_time = tmp; | 
| Lucille Sylvester | 591ea03 | 2011-07-21 16:08:37 -0600 | [diff] [blame] | 886 | 	} | 
| Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 887 | } | 
 | 888 |  | 
 | 889 | static void z180_irqctrl(struct kgsl_device *device, int state) | 
 | 890 | { | 
 | 891 | 	/* Control interrupts for Z180 and the Z180 MMU */ | 
 | 892 |  | 
 | 893 | 	if (state) { | 
 | 894 | 		z180_regwrite(device, (ADDR_VGC_IRQENABLE >> 2), 3); | 
 | 895 | 		z180_regwrite(device, MH_INTERRUPT_MASK, KGSL_MMU_INT_MASK); | 
 | 896 | 	} else { | 
 | 897 | 		z180_regwrite(device, (ADDR_VGC_IRQENABLE >> 2), 0); | 
 | 898 | 		z180_regwrite(device, MH_INTERRUPT_MASK, 0); | 
 | 899 | 	} | 
 | 900 | } | 
 | 901 |  | 
| Jordan Crouse | d653588 | 2012-06-20 08:22:16 -0600 | [diff] [blame] | 902 | static unsigned int z180_gpuid(struct kgsl_device *device, unsigned int *chipid) | 
| Jordan Crouse | a0758f2 | 2011-12-07 11:19:22 -0700 | [diff] [blame] | 903 | { | 
| Jordan Crouse | d653588 | 2012-06-20 08:22:16 -0600 | [diff] [blame] | 904 | 	if (chipid != NULL) | 
 | 905 | 		*chipid = 0; | 
 | 906 |  | 
| Jordan Crouse | a0758f2 | 2011-12-07 11:19:22 -0700 | [diff] [blame] | 907 | 	/* Standard KGSL gpuid format: | 
 | 908 | 	 * top word is 0x0002 for 2D or 0x0003 for 3D | 
 | 909 | 	 * Bottom word is core specific identifer | 
 | 910 | 	 */ | 
 | 911 |  | 
 | 912 | 	return (0x0002 << 16) | 180; | 
 | 913 | } | 
 | 914 |  | 
| Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 915 | static const struct kgsl_functable z180_functable = { | 
 | 916 | 	/* Mandatory functions */ | 
 | 917 | 	.regread = z180_regread, | 
 | 918 | 	.regwrite = z180_regwrite, | 
 | 919 | 	.idle = z180_idle, | 
 | 920 | 	.isidle = z180_isidle, | 
 | 921 | 	.suspend_context = z180_suspend_context, | 
 | 922 | 	.start = z180_start, | 
 | 923 | 	.stop = z180_stop, | 
 | 924 | 	.getproperty = z180_getproperty, | 
 | 925 | 	.waittimestamp = z180_waittimestamp, | 
 | 926 | 	.readtimestamp = z180_readtimestamp, | 
 | 927 | 	.issueibcmds = z180_cmdstream_issueibcmds, | 
 | 928 | 	.setup_pt = z180_setup_pt, | 
 | 929 | 	.cleanup_pt = z180_cleanup_pt, | 
 | 930 | 	.power_stats = z180_power_stats, | 
 | 931 | 	.irqctrl = z180_irqctrl, | 
| Jordan Crouse | a0758f2 | 2011-12-07 11:19:22 -0700 | [diff] [blame] | 932 | 	.gpuid = z180_gpuid, | 
| Jordan Crouse | b368e9b | 2012-04-27 14:01:59 -0600 | [diff] [blame] | 933 | 	.irq_handler = z180_irq_handler, | 
| Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 934 | 	/* Optional functions */ | 
| Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 935 | 	.drawctxt_create = NULL, | 
 | 936 | 	.drawctxt_destroy = z180_drawctxt_destroy, | 
 | 937 | 	.ioctl = NULL, | 
 | 938 | }; | 
 | 939 |  | 
 | 940 | static struct platform_device_id z180_id_table[] = { | 
 | 941 | 	{ DEVICE_2D0_NAME, (kernel_ulong_t)&device_2d0.dev, }, | 
 | 942 | 	{ DEVICE_2D1_NAME, (kernel_ulong_t)&device_2d1.dev, }, | 
 | 943 | 	{ }, | 
 | 944 | }; | 
 | 945 | MODULE_DEVICE_TABLE(platform, z180_id_table); | 
 | 946 |  | 
 | 947 | static struct platform_driver z180_platform_driver = { | 
 | 948 | 	.probe = z180_probe, | 
 | 949 | 	.remove = __devexit_p(z180_remove), | 
 | 950 | 	.suspend = kgsl_suspend_driver, | 
 | 951 | 	.resume = kgsl_resume_driver, | 
 | 952 | 	.id_table = z180_id_table, | 
 | 953 | 	.driver = { | 
 | 954 | 		.owner = THIS_MODULE, | 
 | 955 | 		.name = DEVICE_2D_NAME, | 
 | 956 | 		.pm = &kgsl_pm_ops, | 
 | 957 | 	} | 
 | 958 | }; | 
 | 959 |  | 
 | 960 | static int __init kgsl_2d_init(void) | 
 | 961 | { | 
 | 962 | 	return platform_driver_register(&z180_platform_driver); | 
 | 963 | } | 
 | 964 |  | 
 | 965 | static void __exit kgsl_2d_exit(void) | 
 | 966 | { | 
 | 967 | 	platform_driver_unregister(&z180_platform_driver); | 
 | 968 | } | 
 | 969 |  | 
 | 970 | module_init(kgsl_2d_init); | 
 | 971 | module_exit(kgsl_2d_exit); | 
 | 972 |  | 
 | 973 | MODULE_DESCRIPTION("2D Graphics driver"); | 
 | 974 | MODULE_VERSION("1.2"); | 
 | 975 | MODULE_LICENSE("GPL v2"); | 
 | 976 | MODULE_ALIAS("platform:kgsl_2d"); |