aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorScott Ling <sl@opensource.wolfsonmicro.com>2012-11-23 07:37:35 -0500
committerMark Brown <broonie@opensource.wolfsonmicro.com>2012-11-23 07:44:15 -0500
commit68e1969ea705dafcee721f02c4fbc34466917f83 (patch)
treec4c2ad361c93edada702254f7ec7fd4d8913aeec
parent631fcab2eafc38a1415165ceaa217494c3f70ba5 (diff)
ASoC: wm0010: Add checking for .dfw info record version.
The info record at the start of the dsp firmware file has been expanded to incorporate additional version information. We need to check the version to make sure we understand the layout of the information in the record. The srec2image tool is currently used to create this record during creation of the .dfw file. Signed-off-by: Scott Ling <sl@opensource.wolfsonmicro.com> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
-rw-r--r--sound/soc/codecs/wm0010.c25
1 files changed, 24 insertions, 1 deletions
diff --git a/sound/soc/codecs/wm0010.c b/sound/soc/codecs/wm0010.c
index 8ebb8da88f73..3c3a7b16bb8b 100644
--- a/sound/soc/codecs/wm0010.c
+++ b/sound/soc/codecs/wm0010.c
@@ -31,6 +31,9 @@
31 31
32#define DEVICE_ID_WM0010 10 32#define DEVICE_ID_WM0010 10
33 33
34/* We only support v1 of the .dfw INFO record */
35#define INFO_VERSION 1
36
34enum dfw_cmd { 37enum dfw_cmd {
35 DFW_CMD_FUSE = 0x01, 38 DFW_CMD_FUSE = 0x01,
36 DFW_CMD_CODE_HDR, 39 DFW_CMD_CODE_HDR,
@@ -46,6 +49,13 @@ struct dfw_binrec {
46 uint8_t data[0]; 49 uint8_t data[0];
47} __packed; 50} __packed;
48 51
52struct dfw_inforec {
53 u8 info_version;
54 u8 tool_major_version;
55 u8 tool_minor_version;
56 u8 dsp_target;
57};
58
49struct dfw_pllrec { 59struct dfw_pllrec {
50 u8 command; 60 u8 command;
51 u32 length:24; 61 u32 length:24;
@@ -342,6 +352,7 @@ static int wm0010_firmware_load(char *name, struct snd_soc_codec *codec)
342 struct completion done; 352 struct completion done;
343 const struct firmware *fw; 353 const struct firmware *fw;
344 const struct dfw_binrec *rec; 354 const struct dfw_binrec *rec;
355 const struct dfw_inforec *inforec;
345 u64 *img; 356 u64 *img;
346 u8 *out, dsp; 357 u8 *out, dsp;
347 u32 len, offset; 358 u32 len, offset;
@@ -356,8 +367,9 @@ static int wm0010_firmware_load(char *name, struct snd_soc_codec *codec)
356 } 367 }
357 368
358 rec = (const struct dfw_binrec *)fw->data; 369 rec = (const struct dfw_binrec *)fw->data;
370 inforec = (const struct dfw_inforec *)rec->data;
359 offset = 0; 371 offset = 0;
360 dsp = rec->data[0]; 372 dsp = inforec->dsp_target;
361 wm0010->boot_failed = false; 373 wm0010->boot_failed = false;
362 BUG_ON(!list_empty(&xfer_list)); 374 BUG_ON(!list_empty(&xfer_list));
363 init_completion(&done); 375 init_completion(&done);
@@ -369,6 +381,17 @@ static int wm0010_firmware_load(char *name, struct snd_soc_codec *codec)
369 goto abort; 381 goto abort;
370 } 382 }
371 383
384 if (inforec->info_version != INFO_VERSION) {
385 dev_err(codec->dev,
386 "Unsupported version (%02d) of INFO record\r\n",
387 inforec->info_version);
388 ret = -EINVAL;
389 goto abort;
390 }
391
392 dev_dbg(codec->dev, "Version v%02d INFO record found\r\n",
393 inforec->info_version);
394
372 /* Check it's a DSP file */ 395 /* Check it's a DSP file */
373 if (dsp != DEVICE_ID_WM0010) { 396 if (dsp != DEVICE_ID_WM0010) {
374 dev_err(codec->dev, "Not a WM0010 firmware file.\r\n"); 397 dev_err(codec->dev, "Not a WM0010 firmware file.\r\n");