blob: 2d6527e52acce5dc8bf9f155ee0152f7ccef8540 [file] [log] [blame]
Daniel Vettereb805622015-05-04 14:58:44 +02001/*
2 * Copyright © 2014 Intel Corporation
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
13 * Software.
14 *
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
21 * IN THE SOFTWARE.
22 *
23 */
24#include <linux/firmware.h>
25#include "i915_drv.h"
26#include "i915_reg.h"
27
Animesh Mannaaa9145c2015-05-13 22:13:29 +053028/**
29 * DOC: csr support for dmc
30 *
31 * Display Context Save and Restore (CSR) firmware support added from gen9
32 * onwards to drive newly added DMC (Display microcontroller) in display
33 * engine to save and restore the state of display engine when it enter into
34 * low-power state and comes back to normal.
35 *
36 * Firmware loading status will be one of the below states: FW_UNINITIALIZED,
37 * FW_LOADED, FW_FAILED.
38 *
39 * Once the firmware is written into the registers status will be moved from
40 * FW_UNINITIALIZED to FW_LOADED and for any erroneous condition status will
41 * be moved to FW_FAILED.
42 */
43
Rodrigo Vivibf546f82015-06-03 16:50:19 -070044#define I915_CSR_SKL "i915/skl_dmc_ver1.bin"
Animesh Manna18c237c2015-08-04 22:02:41 +053045#define I915_CSR_BXT "i915/bxt_dmc_ver1.bin"
Daniel Vettereb805622015-05-04 14:58:44 +020046
47MODULE_FIRMWARE(I915_CSR_SKL);
Animesh Manna18c237c2015-08-04 22:02:41 +053048MODULE_FIRMWARE(I915_CSR_BXT);
Daniel Vettereb805622015-05-04 14:58:44 +020049
Mika Kuoppala9c5308e2015-10-30 17:52:16 +020050#define SKL_CSR_VERSION_REQUIRED CSR_VERSION(1, 23)
51
Daniel Vettereb805622015-05-04 14:58:44 +020052#define CSR_MAX_FW_SIZE 0x2FFF
53#define CSR_DEFAULT_FW_OFFSET 0xFFFFFFFF
Daniel Vettereb805622015-05-04 14:58:44 +020054
55struct intel_css_header {
56 /* 0x09 for DMC */
57 uint32_t module_type;
58
59 /* Includes the DMC specific header in dwords */
60 uint32_t header_len;
61
62 /* always value would be 0x10000 */
63 uint32_t header_ver;
64
65 /* Not used */
66 uint32_t module_id;
67
68 /* Not used */
69 uint32_t module_vendor;
70
71 /* in YYYYMMDD format */
72 uint32_t date;
73
74 /* Size in dwords (CSS_Headerlen + PackageHeaderLen + dmc FWsLen)/4 */
75 uint32_t size;
76
77 /* Not used */
78 uint32_t key_size;
79
80 /* Not used */
81 uint32_t modulus_size;
82
83 /* Not used */
84 uint32_t exponent_size;
85
86 /* Not used */
87 uint32_t reserved1[12];
88
89 /* Major Minor */
90 uint32_t version;
91
92 /* Not used */
93 uint32_t reserved2[8];
94
95 /* Not used */
96 uint32_t kernel_header_info;
97} __packed;
98
99struct intel_fw_info {
100 uint16_t reserved1;
101
102 /* Stepping (A, B, C, ..., *). * is a wildcard */
103 char stepping;
104
105 /* Sub-stepping (0, 1, ..., *). * is a wildcard */
106 char substepping;
107
108 uint32_t offset;
109 uint32_t reserved2;
110} __packed;
111
112struct intel_package_header {
113 /* DMC container header length in dwords */
114 unsigned char header_len;
115
116 /* always value would be 0x01 */
117 unsigned char header_ver;
118
119 unsigned char reserved[10];
120
121 /* Number of valid entries in the FWInfo array below */
122 uint32_t num_entries;
123
124 struct intel_fw_info fw_info[20];
125} __packed;
126
127struct intel_dmc_header {
128 /* always value would be 0x40403E3E */
129 uint32_t signature;
130
131 /* DMC binary header length */
132 unsigned char header_len;
133
134 /* 0x01 */
135 unsigned char header_ver;
136
137 /* Reserved */
138 uint16_t dmcc_ver;
139
140 /* Major, Minor */
141 uint32_t project;
142
143 /* Firmware program size (excluding header) in dwords */
144 uint32_t fw_size;
145
146 /* Major Minor version */
147 uint32_t fw_version;
148
149 /* Number of valid MMIO cycles present. */
150 uint32_t mmio_count;
151
152 /* MMIO address */
153 uint32_t mmioaddr[8];
154
155 /* MMIO data */
156 uint32_t mmiodata[8];
157
158 /* FW filename */
159 unsigned char dfile[32];
160
161 uint32_t reserved1[2];
162} __packed;
163
164struct stepping_info {
165 char stepping;
166 char substepping;
167};
168
169static const struct stepping_info skl_stepping_info[] = {
Jani Nikula84cb00e2015-10-20 15:38:31 +0300170 {'A', '0'}, {'B', '0'}, {'C', '0'},
171 {'D', '0'}, {'E', '0'}, {'F', '0'},
172 {'G', '0'}, {'H', '0'}, {'I', '0'}
Daniel Vettereb805622015-05-04 14:58:44 +0200173};
174
Jani Nikulab9cd5bf2015-10-20 15:38:32 +0300175static const struct stepping_info bxt_stepping_info[] = {
Animesh Mannacff765f2015-08-04 22:02:43 +0530176 {'A', '0'}, {'A', '1'}, {'A', '2'},
177 {'B', '0'}, {'B', '1'}, {'B', '2'}
178};
179
Jani Nikulab1a14c62015-10-20 15:38:33 +0300180static const struct stepping_info *intel_get_stepping_info(struct drm_device *dev)
Daniel Vettereb805622015-05-04 14:58:44 +0200181{
Jani Nikulab1a14c62015-10-20 15:38:33 +0300182 const struct stepping_info *si;
183 unsigned int size;
Daniel Vettereb805622015-05-04 14:58:44 +0200184
Jani Nikulab1a14c62015-10-20 15:38:33 +0300185 if (IS_SKYLAKE(dev)) {
186 size = ARRAY_SIZE(skl_stepping_info);
187 si = skl_stepping_info;
188 } else if (IS_BROXTON(dev)) {
189 size = ARRAY_SIZE(bxt_stepping_info);
190 si = bxt_stepping_info;
191 } else {
192 return NULL;
193 }
194
195 if (INTEL_REVID(dev) < size)
196 return si + INTEL_REVID(dev);
197
198 return NULL;
Daniel Vettereb805622015-05-04 14:58:44 +0200199}
200
Animesh Mannaaa9145c2015-05-13 22:13:29 +0530201/**
Animesh Mannaaa9145c2015-05-13 22:13:29 +0530202 * intel_csr_load_program() - write the firmware from memory to register.
Daniel Vetterf4448372015-10-28 23:59:02 +0200203 * @dev_priv: i915 drm device.
Animesh Mannaaa9145c2015-05-13 22:13:29 +0530204 *
205 * CSR firmware is read from a .bin file and kept in internal memory one time.
206 * Everytime display comes back from low power state this function is called to
207 * copy the firmware from internal memory to registers.
208 */
Daniel Vetterf4448372015-10-28 23:59:02 +0200209void intel_csr_load_program(struct drm_i915_private *dev_priv)
Daniel Vettereb805622015-05-04 14:58:44 +0200210{
Animesh Mannaa7f749f2015-08-03 21:55:32 +0530211 u32 *payload = dev_priv->csr.dmc_payload;
Daniel Vettereb805622015-05-04 14:58:44 +0200212 uint32_t i, fw_size;
213
Daniel Vetterf4448372015-10-28 23:59:02 +0200214 if (!IS_GEN9(dev_priv)) {
Daniel Vettereb805622015-05-04 14:58:44 +0200215 DRM_ERROR("No CSR support available for this platform\n");
216 return;
217 }
218
Animesh Manna4b7ab5f2015-08-26 01:36:05 +0530219 /*
220 * FIXME: Firmware gets lost on S3/S4, but not when entering system
221 * standby or suspend-to-idle (which is just like forced runtime pm).
222 * Unfortunately the ACPI subsystem doesn't yet give us a way to
223 * differentiate this, hence figure it out with this hack.
224 */
Daniel Vetterbffbcd92015-10-28 23:59:01 +0200225 if ((!dev_priv->csr.dmc_payload) || I915_READ(CSR_PROGRAM(0)))
Animesh Manna4b7ab5f2015-08-26 01:36:05 +0530226 return;
227
Daniel Vettereb805622015-05-04 14:58:44 +0200228 fw_size = dev_priv->csr.dmc_fw_size;
229 for (i = 0; i < fw_size; i++)
Ville Syrjäläd2aa5ae2015-09-18 20:03:23 +0300230 I915_WRITE(CSR_PROGRAM(i), payload[i]);
Daniel Vettereb805622015-05-04 14:58:44 +0200231
232 for (i = 0; i < dev_priv->csr.mmio_count; i++) {
233 I915_WRITE(dev_priv->csr.mmioaddr[i],
Daniel Vetterf98f70d2015-10-28 23:58:59 +0200234 dev_priv->csr.mmiodata[i]);
Daniel Vettereb805622015-05-04 14:58:44 +0200235 }
Daniel Vettereb805622015-05-04 14:58:44 +0200236}
237
Daniel Vetter6a6582b2015-11-12 17:11:29 +0200238static uint32_t *parse_csr_fw(struct drm_i915_private *dev_priv,
239 const struct firmware *fw)
Daniel Vettereb805622015-05-04 14:58:44 +0200240{
Daniel Vettereb805622015-05-04 14:58:44 +0200241 struct drm_device *dev = dev_priv->dev;
242 struct intel_css_header *css_header;
243 struct intel_package_header *package_header;
244 struct intel_dmc_header *dmc_header;
245 struct intel_csr *csr = &dev_priv->csr;
Jani Nikulab1a14c62015-10-20 15:38:33 +0300246 const struct stepping_info *stepping_info = intel_get_stepping_info(dev);
247 char stepping, substepping;
Daniel Vettereb805622015-05-04 14:58:44 +0200248 uint32_t dmc_offset = CSR_DEFAULT_FW_OFFSET, readcount = 0, nbytes;
249 uint32_t i;
Animesh Mannaa7f749f2015-08-03 21:55:32 +0530250 uint32_t *dmc_payload;
Daniel Vettereb805622015-05-04 14:58:44 +0200251
Mika Kuoppala9c5308e2015-10-30 17:52:16 +0200252 if (!fw)
Daniel Vetter6a6582b2015-11-12 17:11:29 +0200253 return NULL;
Daniel Vettereb805622015-05-04 14:58:44 +0200254
Jani Nikulab1a14c62015-10-20 15:38:33 +0300255 if (!stepping_info) {
Daniel Vettereb805622015-05-04 14:58:44 +0200256 DRM_ERROR("Unknown stepping info, firmware loading failed\n");
Daniel Vetter6a6582b2015-11-12 17:11:29 +0200257 return NULL;
Daniel Vettereb805622015-05-04 14:58:44 +0200258 }
259
Jani Nikulab1a14c62015-10-20 15:38:33 +0300260 stepping = stepping_info->stepping;
261 substepping = stepping_info->substepping;
262
Daniel Vettereb805622015-05-04 14:58:44 +0200263 /* Extract CSS Header information*/
264 css_header = (struct intel_css_header *)fw->data;
265 if (sizeof(struct intel_css_header) !=
Daniel Vetterf98f70d2015-10-28 23:58:59 +0200266 (css_header->header_len * 4)) {
Daniel Vettereb805622015-05-04 14:58:44 +0200267 DRM_ERROR("Firmware has wrong CSS header length %u bytes\n",
Daniel Vetterf98f70d2015-10-28 23:58:59 +0200268 (css_header->header_len * 4));
Daniel Vetter6a6582b2015-11-12 17:11:29 +0200269 return NULL;
Daniel Vettereb805622015-05-04 14:58:44 +0200270 }
Damien Lespiaub6e7d892015-10-27 14:46:59 +0200271
272 csr->version = css_header->version;
273
Mika Kuoppala9c5308e2015-10-30 17:52:16 +0200274 if (IS_SKYLAKE(dev) && csr->version < SKL_CSR_VERSION_REQUIRED) {
275 DRM_INFO("Refusing to load old Skylake DMC firmware v%u.%u,"
276 " please upgrade to v%u.%u or later"
277 " [https://01.org/linuxgraphics/intel-linux-graphics-firmwares].\n",
278 CSR_VERSION_MAJOR(csr->version),
279 CSR_VERSION_MINOR(csr->version),
280 CSR_VERSION_MAJOR(SKL_CSR_VERSION_REQUIRED),
281 CSR_VERSION_MINOR(SKL_CSR_VERSION_REQUIRED));
Daniel Vetter6a6582b2015-11-12 17:11:29 +0200282 return NULL;
Mika Kuoppala9c5308e2015-10-30 17:52:16 +0200283 }
284
Daniel Vettereb805622015-05-04 14:58:44 +0200285 readcount += sizeof(struct intel_css_header);
286
287 /* Extract Package Header information*/
288 package_header = (struct intel_package_header *)
Daniel Vetterf98f70d2015-10-28 23:58:59 +0200289 &fw->data[readcount];
Daniel Vettereb805622015-05-04 14:58:44 +0200290 if (sizeof(struct intel_package_header) !=
Daniel Vetterf98f70d2015-10-28 23:58:59 +0200291 (package_header->header_len * 4)) {
Daniel Vettereb805622015-05-04 14:58:44 +0200292 DRM_ERROR("Firmware has wrong package header length %u bytes\n",
Daniel Vetterf98f70d2015-10-28 23:58:59 +0200293 (package_header->header_len * 4));
Daniel Vetter6a6582b2015-11-12 17:11:29 +0200294 return NULL;
Daniel Vettereb805622015-05-04 14:58:44 +0200295 }
296 readcount += sizeof(struct intel_package_header);
297
298 /* Search for dmc_offset to find firware binary. */
299 for (i = 0; i < package_header->num_entries; i++) {
300 if (package_header->fw_info[i].substepping == '*' &&
Daniel Vetterf98f70d2015-10-28 23:58:59 +0200301 stepping == package_header->fw_info[i].stepping) {
Daniel Vettereb805622015-05-04 14:58:44 +0200302 dmc_offset = package_header->fw_info[i].offset;
303 break;
304 } else if (stepping == package_header->fw_info[i].stepping &&
305 substepping == package_header->fw_info[i].substepping) {
306 dmc_offset = package_header->fw_info[i].offset;
307 break;
308 } else if (package_header->fw_info[i].stepping == '*' &&
Daniel Vetterf98f70d2015-10-28 23:58:59 +0200309 package_header->fw_info[i].substepping == '*')
Daniel Vettereb805622015-05-04 14:58:44 +0200310 dmc_offset = package_header->fw_info[i].offset;
311 }
312 if (dmc_offset == CSR_DEFAULT_FW_OFFSET) {
313 DRM_ERROR("Firmware not supported for %c stepping\n", stepping);
Daniel Vetter6a6582b2015-11-12 17:11:29 +0200314 return NULL;
Daniel Vettereb805622015-05-04 14:58:44 +0200315 }
316 readcount += dmc_offset;
317
318 /* Extract dmc_header information. */
319 dmc_header = (struct intel_dmc_header *)&fw->data[readcount];
320 if (sizeof(struct intel_dmc_header) != (dmc_header->header_len)) {
321 DRM_ERROR("Firmware has wrong dmc header length %u bytes\n",
Daniel Vetterf98f70d2015-10-28 23:58:59 +0200322 (dmc_header->header_len));
Daniel Vetter6a6582b2015-11-12 17:11:29 +0200323 return NULL;
Daniel Vettereb805622015-05-04 14:58:44 +0200324 }
325 readcount += sizeof(struct intel_dmc_header);
326
327 /* Cache the dmc header info. */
328 if (dmc_header->mmio_count > ARRAY_SIZE(csr->mmioaddr)) {
329 DRM_ERROR("Firmware has wrong mmio count %u\n",
Daniel Vetterf98f70d2015-10-28 23:58:59 +0200330 dmc_header->mmio_count);
Daniel Vetter6a6582b2015-11-12 17:11:29 +0200331 return NULL;
Daniel Vettereb805622015-05-04 14:58:44 +0200332 }
333 csr->mmio_count = dmc_header->mmio_count;
334 for (i = 0; i < dmc_header->mmio_count; i++) {
Takashi Iwai982b0b22015-09-09 16:52:09 +0200335 if (dmc_header->mmioaddr[i] < CSR_MMIO_START_RANGE ||
Daniel Vetterf98f70d2015-10-28 23:58:59 +0200336 dmc_header->mmioaddr[i] > CSR_MMIO_END_RANGE) {
Daniel Vettereb805622015-05-04 14:58:44 +0200337 DRM_ERROR(" Firmware has wrong mmio address 0x%x\n",
Daniel Vetterf98f70d2015-10-28 23:58:59 +0200338 dmc_header->mmioaddr[i]);
Daniel Vetter6a6582b2015-11-12 17:11:29 +0200339 return NULL;
Daniel Vettereb805622015-05-04 14:58:44 +0200340 }
341 csr->mmioaddr[i] = dmc_header->mmioaddr[i];
342 csr->mmiodata[i] = dmc_header->mmiodata[i];
343 }
344
345 /* fw_size is in dwords, so multiplied by 4 to convert into bytes. */
346 nbytes = dmc_header->fw_size * 4;
347 if (nbytes > CSR_MAX_FW_SIZE) {
348 DRM_ERROR("CSR firmware too big (%u) bytes\n", nbytes);
Daniel Vetter6a6582b2015-11-12 17:11:29 +0200349 return NULL;
Daniel Vettereb805622015-05-04 14:58:44 +0200350 }
351 csr->dmc_fw_size = dmc_header->fw_size;
352
Daniel Vetter6a6582b2015-11-12 17:11:29 +0200353 dmc_payload = kmalloc(nbytes, GFP_KERNEL);
354 if (!dmc_payload) {
Daniel Vettereb805622015-05-04 14:58:44 +0200355 DRM_ERROR("Memory allocation failed for dmc payload\n");
Daniel Vetter6a6582b2015-11-12 17:11:29 +0200356 return NULL;
Daniel Vettereb805622015-05-04 14:58:44 +0200357 }
358
Animesh Mannaa7f749f2015-08-03 21:55:32 +0530359 memcpy(dmc_payload, &fw->data[readcount], nbytes);
Daniel Vettereb805622015-05-04 14:58:44 +0200360
Daniel Vetter6a6582b2015-11-12 17:11:29 +0200361 return dmc_payload;
362}
363
Daniel Vetter8144ac52015-10-28 23:59:04 +0200364static void csr_load_work_fn(struct work_struct *work)
Daniel Vetter6a6582b2015-11-12 17:11:29 +0200365{
Daniel Vetter8144ac52015-10-28 23:59:04 +0200366 struct drm_i915_private *dev_priv;
367 struct intel_csr *csr;
368 const struct firmware *fw;
369 int ret;
Daniel Vetter6a6582b2015-11-12 17:11:29 +0200370
Daniel Vetter8144ac52015-10-28 23:59:04 +0200371 dev_priv = container_of(work, typeof(*dev_priv), csr.work);
372 csr = &dev_priv->csr;
373
374 ret = request_firmware(&fw, dev_priv->csr.fw_path,
375 &dev_priv->dev->pdev->dev);
Daniel Vetter6a6582b2015-11-12 17:11:29 +0200376 if (!fw)
377 goto out;
378
379 dev_priv->csr.dmc_payload = parse_csr_fw(dev_priv, fw);
380 if (!dev_priv->csr.dmc_payload)
381 goto out;
382
Daniel Vettereb805622015-05-04 14:58:44 +0200383 /* load csr program during system boot, as needed for DC states */
Daniel Vetterf4448372015-10-28 23:59:02 +0200384 intel_csr_load_program(dev_priv);
Suketu Shahdc174302015-04-17 19:46:16 +0530385
Daniel Vettereb805622015-05-04 14:58:44 +0200386out:
Daniel Vetter6a6582b2015-11-12 17:11:29 +0200387 if (dev_priv->csr.dmc_payload) {
Daniel Vetter01a69082015-10-28 23:58:56 +0200388 intel_display_power_put(dev_priv, POWER_DOMAIN_INIT);
Mika Kuoppala9c5308e2015-10-30 17:52:16 +0200389
390 DRM_INFO("Finished loading %s (v%u.%u)\n",
391 dev_priv->csr.fw_path,
392 CSR_VERSION_MAJOR(csr->version),
393 CSR_VERSION_MINOR(csr->version));
394 } else {
Daniel Vetterc729ed82015-10-28 23:59:00 +0200395 DRM_ERROR("Failed to load DMC firmware, disabling rpm\n");
Mika Kuoppala9c5308e2015-10-30 17:52:16 +0200396 }
397
Daniel Vettereb805622015-05-04 14:58:44 +0200398 release_firmware(fw);
399}
400
Animesh Mannaaa9145c2015-05-13 22:13:29 +0530401/**
402 * intel_csr_ucode_init() - initialize the firmware loading.
Daniel Vetterf4448372015-10-28 23:59:02 +0200403 * @dev_priv: i915 drm device.
Animesh Mannaaa9145c2015-05-13 22:13:29 +0530404 *
405 * This function is called at the time of loading the display driver to read
406 * firmware from a .bin file and copied into a internal memory.
407 */
Daniel Vetterf4448372015-10-28 23:59:02 +0200408void intel_csr_ucode_init(struct drm_i915_private *dev_priv)
Daniel Vettereb805622015-05-04 14:58:44 +0200409{
Daniel Vettereb805622015-05-04 14:58:44 +0200410 struct intel_csr *csr = &dev_priv->csr;
Daniel Vetter8144ac52015-10-28 23:59:04 +0200411
412 INIT_WORK(&dev_priv->csr.work, csr_load_work_fn);
Daniel Vettereb805622015-05-04 14:58:44 +0200413
Daniel Vetterf4448372015-10-28 23:59:02 +0200414 if (!HAS_CSR(dev_priv))
Daniel Vettereb805622015-05-04 14:58:44 +0200415 return;
416
Daniel Vetterf4448372015-10-28 23:59:02 +0200417 if (IS_SKYLAKE(dev_priv))
Daniel Vettereb805622015-05-04 14:58:44 +0200418 csr->fw_path = I915_CSR_SKL;
Animesh Manna18c237c2015-08-04 22:02:41 +0530419 else if (IS_BROXTON(dev_priv))
420 csr->fw_path = I915_CSR_BXT;
Daniel Vettereb805622015-05-04 14:58:44 +0200421 else {
422 DRM_ERROR("Unexpected: no known CSR firmware for platform\n");
423 return;
424 }
425
Damien Lespiauabd41dc2015-06-04 16:42:16 +0100426 DRM_DEBUG_KMS("Loading %s\n", csr->fw_path);
427
Suketu Shahdc174302015-04-17 19:46:16 +0530428 /*
429 * Obtain a runtime pm reference, until CSR is loaded,
430 * to avoid entering runtime-suspend.
431 */
Daniel Vetter01a69082015-10-28 23:58:56 +0200432 intel_display_power_get(dev_priv, POWER_DOMAIN_INIT);
Suketu Shahdc174302015-04-17 19:46:16 +0530433
Daniel Vetter8144ac52015-10-28 23:59:04 +0200434 schedule_work(&dev_priv->csr.work);
Daniel Vettereb805622015-05-04 14:58:44 +0200435}
436
Animesh Mannaaa9145c2015-05-13 22:13:29 +0530437/**
438 * intel_csr_ucode_fini() - unload the CSR firmware.
Daniel Vetterf4448372015-10-28 23:59:02 +0200439 * @dev_priv: i915 drm device.
Animesh Mannaaa9145c2015-05-13 22:13:29 +0530440 *
441 * Firmmware unloading includes freeing the internal momory and reset the
442 * firmware loading status.
443 */
Daniel Vetterf4448372015-10-28 23:59:02 +0200444void intel_csr_ucode_fini(struct drm_i915_private *dev_priv)
Daniel Vettereb805622015-05-04 14:58:44 +0200445{
Daniel Vetterf4448372015-10-28 23:59:02 +0200446 if (!HAS_CSR(dev_priv))
Daniel Vettereb805622015-05-04 14:58:44 +0200447 return;
448
Animesh Manna15e72c12015-10-28 23:59:05 +0200449 flush_work(&dev_priv->csr.work);
450
Daniel Vettereb805622015-05-04 14:58:44 +0200451 kfree(dev_priv->csr.dmc_payload);
452}