Mark Brown | 2159ad93 | 2012-10-11 11:54:02 +0900 | [diff] [blame] | 1 | /* |
| 2 | * wm_adsp.c -- Wolfson ADSP support |
| 3 | * |
| 4 | * Copyright 2012 Wolfson Microelectronics plc |
| 5 | * |
| 6 | * Author: Mark Brown <broonie@opensource.wolfsonmicro.com> |
| 7 | * |
| 8 | * This program is free software; you can redistribute it and/or modify |
| 9 | * it under the terms of the GNU General Public License version 2 as |
| 10 | * published by the Free Software Foundation. |
| 11 | */ |
| 12 | |
| 13 | #include <linux/module.h> |
| 14 | #include <linux/moduleparam.h> |
| 15 | #include <linux/init.h> |
| 16 | #include <linux/delay.h> |
| 17 | #include <linux/firmware.h> |
Mark Brown | cf17c83 | 2013-01-30 14:37:23 +0800 | [diff] [blame] | 18 | #include <linux/list.h> |
Mark Brown | 2159ad93 | 2012-10-11 11:54:02 +0900 | [diff] [blame] | 19 | #include <linux/pm.h> |
| 20 | #include <linux/pm_runtime.h> |
| 21 | #include <linux/regmap.h> |
Mark Brown | 973838a | 2012-11-28 17:20:32 +0000 | [diff] [blame] | 22 | #include <linux/regulator/consumer.h> |
Mark Brown | 2159ad93 | 2012-10-11 11:54:02 +0900 | [diff] [blame] | 23 | #include <linux/slab.h> |
Charles Keepax | cdcd7f7 | 2014-11-14 15:40:45 +0000 | [diff] [blame] | 24 | #include <linux/vmalloc.h> |
Dimitris Papastamos | 6ab2b7b | 2013-05-08 14:15:35 +0100 | [diff] [blame] | 25 | #include <linux/workqueue.h> |
Mark Brown | 2159ad93 | 2012-10-11 11:54:02 +0900 | [diff] [blame] | 26 | #include <sound/core.h> |
| 27 | #include <sound/pcm.h> |
| 28 | #include <sound/pcm_params.h> |
| 29 | #include <sound/soc.h> |
| 30 | #include <sound/jack.h> |
| 31 | #include <sound/initval.h> |
| 32 | #include <sound/tlv.h> |
| 33 | |
| 34 | #include <linux/mfd/arizona/registers.h> |
| 35 | |
Mark Brown | dc91428 | 2013-02-18 19:09:23 +0000 | [diff] [blame] | 36 | #include "arizona.h" |
Mark Brown | 2159ad93 | 2012-10-11 11:54:02 +0900 | [diff] [blame] | 37 | #include "wm_adsp.h" |
| 38 | |
| 39 | #define adsp_crit(_dsp, fmt, ...) \ |
| 40 | dev_crit(_dsp->dev, "DSP%d: " fmt, _dsp->num, ##__VA_ARGS__) |
| 41 | #define adsp_err(_dsp, fmt, ...) \ |
| 42 | dev_err(_dsp->dev, "DSP%d: " fmt, _dsp->num, ##__VA_ARGS__) |
| 43 | #define adsp_warn(_dsp, fmt, ...) \ |
| 44 | dev_warn(_dsp->dev, "DSP%d: " fmt, _dsp->num, ##__VA_ARGS__) |
| 45 | #define adsp_info(_dsp, fmt, ...) \ |
| 46 | dev_info(_dsp->dev, "DSP%d: " fmt, _dsp->num, ##__VA_ARGS__) |
| 47 | #define adsp_dbg(_dsp, fmt, ...) \ |
| 48 | dev_dbg(_dsp->dev, "DSP%d: " fmt, _dsp->num, ##__VA_ARGS__) |
| 49 | |
| 50 | #define ADSP1_CONTROL_1 0x00 |
| 51 | #define ADSP1_CONTROL_2 0x02 |
| 52 | #define ADSP1_CONTROL_3 0x03 |
| 53 | #define ADSP1_CONTROL_4 0x04 |
| 54 | #define ADSP1_CONTROL_5 0x06 |
| 55 | #define ADSP1_CONTROL_6 0x07 |
| 56 | #define ADSP1_CONTROL_7 0x08 |
| 57 | #define ADSP1_CONTROL_8 0x09 |
| 58 | #define ADSP1_CONTROL_9 0x0A |
| 59 | #define ADSP1_CONTROL_10 0x0B |
| 60 | #define ADSP1_CONTROL_11 0x0C |
| 61 | #define ADSP1_CONTROL_12 0x0D |
| 62 | #define ADSP1_CONTROL_13 0x0F |
| 63 | #define ADSP1_CONTROL_14 0x10 |
| 64 | #define ADSP1_CONTROL_15 0x11 |
| 65 | #define ADSP1_CONTROL_16 0x12 |
| 66 | #define ADSP1_CONTROL_17 0x13 |
| 67 | #define ADSP1_CONTROL_18 0x14 |
| 68 | #define ADSP1_CONTROL_19 0x16 |
| 69 | #define ADSP1_CONTROL_20 0x17 |
| 70 | #define ADSP1_CONTROL_21 0x18 |
| 71 | #define ADSP1_CONTROL_22 0x1A |
| 72 | #define ADSP1_CONTROL_23 0x1B |
| 73 | #define ADSP1_CONTROL_24 0x1C |
| 74 | #define ADSP1_CONTROL_25 0x1E |
| 75 | #define ADSP1_CONTROL_26 0x20 |
| 76 | #define ADSP1_CONTROL_27 0x21 |
| 77 | #define ADSP1_CONTROL_28 0x22 |
| 78 | #define ADSP1_CONTROL_29 0x23 |
| 79 | #define ADSP1_CONTROL_30 0x24 |
| 80 | #define ADSP1_CONTROL_31 0x26 |
| 81 | |
| 82 | /* |
| 83 | * ADSP1 Control 19 |
| 84 | */ |
| 85 | #define ADSP1_WDMA_BUFFER_LENGTH_MASK 0x00FF /* DSP1_WDMA_BUFFER_LENGTH - [7:0] */ |
| 86 | #define ADSP1_WDMA_BUFFER_LENGTH_SHIFT 0 /* DSP1_WDMA_BUFFER_LENGTH - [7:0] */ |
| 87 | #define ADSP1_WDMA_BUFFER_LENGTH_WIDTH 8 /* DSP1_WDMA_BUFFER_LENGTH - [7:0] */ |
| 88 | |
| 89 | |
| 90 | /* |
| 91 | * ADSP1 Control 30 |
| 92 | */ |
| 93 | #define ADSP1_DBG_CLK_ENA 0x0008 /* DSP1_DBG_CLK_ENA */ |
| 94 | #define ADSP1_DBG_CLK_ENA_MASK 0x0008 /* DSP1_DBG_CLK_ENA */ |
| 95 | #define ADSP1_DBG_CLK_ENA_SHIFT 3 /* DSP1_DBG_CLK_ENA */ |
| 96 | #define ADSP1_DBG_CLK_ENA_WIDTH 1 /* DSP1_DBG_CLK_ENA */ |
| 97 | #define ADSP1_SYS_ENA 0x0004 /* DSP1_SYS_ENA */ |
| 98 | #define ADSP1_SYS_ENA_MASK 0x0004 /* DSP1_SYS_ENA */ |
| 99 | #define ADSP1_SYS_ENA_SHIFT 2 /* DSP1_SYS_ENA */ |
| 100 | #define ADSP1_SYS_ENA_WIDTH 1 /* DSP1_SYS_ENA */ |
| 101 | #define ADSP1_CORE_ENA 0x0002 /* DSP1_CORE_ENA */ |
| 102 | #define ADSP1_CORE_ENA_MASK 0x0002 /* DSP1_CORE_ENA */ |
| 103 | #define ADSP1_CORE_ENA_SHIFT 1 /* DSP1_CORE_ENA */ |
| 104 | #define ADSP1_CORE_ENA_WIDTH 1 /* DSP1_CORE_ENA */ |
| 105 | #define ADSP1_START 0x0001 /* DSP1_START */ |
| 106 | #define ADSP1_START_MASK 0x0001 /* DSP1_START */ |
| 107 | #define ADSP1_START_SHIFT 0 /* DSP1_START */ |
| 108 | #define ADSP1_START_WIDTH 1 /* DSP1_START */ |
| 109 | |
Chris Rattray | 94e205b | 2013-01-18 08:43:09 +0000 | [diff] [blame] | 110 | /* |
| 111 | * ADSP1 Control 31 |
| 112 | */ |
| 113 | #define ADSP1_CLK_SEL_MASK 0x0007 /* CLK_SEL_ENA */ |
| 114 | #define ADSP1_CLK_SEL_SHIFT 0 /* CLK_SEL_ENA */ |
| 115 | #define ADSP1_CLK_SEL_WIDTH 3 /* CLK_SEL_ENA */ |
| 116 | |
Mark Brown | 2d30b57 | 2013-01-28 20:18:17 +0800 | [diff] [blame] | 117 | #define ADSP2_CONTROL 0x0 |
| 118 | #define ADSP2_CLOCKING 0x1 |
| 119 | #define ADSP2_STATUS1 0x4 |
| 120 | #define ADSP2_WDMA_CONFIG_1 0x30 |
| 121 | #define ADSP2_WDMA_CONFIG_2 0x31 |
| 122 | #define ADSP2_RDMA_CONFIG_1 0x34 |
Mark Brown | 2159ad93 | 2012-10-11 11:54:02 +0900 | [diff] [blame] | 123 | |
Richard Fitzgerald | 10337b0 | 2015-05-29 10:23:07 +0100 | [diff] [blame] | 124 | #define ADSP2_SCRATCH0 0x40 |
| 125 | #define ADSP2_SCRATCH1 0x41 |
| 126 | #define ADSP2_SCRATCH2 0x42 |
| 127 | #define ADSP2_SCRATCH3 0x43 |
| 128 | |
Mark Brown | 2159ad93 | 2012-10-11 11:54:02 +0900 | [diff] [blame] | 129 | /* |
| 130 | * ADSP2 Control |
| 131 | */ |
| 132 | |
| 133 | #define ADSP2_MEM_ENA 0x0010 /* DSP1_MEM_ENA */ |
| 134 | #define ADSP2_MEM_ENA_MASK 0x0010 /* DSP1_MEM_ENA */ |
| 135 | #define ADSP2_MEM_ENA_SHIFT 4 /* DSP1_MEM_ENA */ |
| 136 | #define ADSP2_MEM_ENA_WIDTH 1 /* DSP1_MEM_ENA */ |
| 137 | #define ADSP2_SYS_ENA 0x0004 /* DSP1_SYS_ENA */ |
| 138 | #define ADSP2_SYS_ENA_MASK 0x0004 /* DSP1_SYS_ENA */ |
| 139 | #define ADSP2_SYS_ENA_SHIFT 2 /* DSP1_SYS_ENA */ |
| 140 | #define ADSP2_SYS_ENA_WIDTH 1 /* DSP1_SYS_ENA */ |
| 141 | #define ADSP2_CORE_ENA 0x0002 /* DSP1_CORE_ENA */ |
| 142 | #define ADSP2_CORE_ENA_MASK 0x0002 /* DSP1_CORE_ENA */ |
| 143 | #define ADSP2_CORE_ENA_SHIFT 1 /* DSP1_CORE_ENA */ |
| 144 | #define ADSP2_CORE_ENA_WIDTH 1 /* DSP1_CORE_ENA */ |
| 145 | #define ADSP2_START 0x0001 /* DSP1_START */ |
| 146 | #define ADSP2_START_MASK 0x0001 /* DSP1_START */ |
| 147 | #define ADSP2_START_SHIFT 0 /* DSP1_START */ |
| 148 | #define ADSP2_START_WIDTH 1 /* DSP1_START */ |
| 149 | |
| 150 | /* |
Mark Brown | 973838a | 2012-11-28 17:20:32 +0000 | [diff] [blame] | 151 | * ADSP2 clocking |
| 152 | */ |
| 153 | #define ADSP2_CLK_SEL_MASK 0x0007 /* CLK_SEL_ENA */ |
| 154 | #define ADSP2_CLK_SEL_SHIFT 0 /* CLK_SEL_ENA */ |
| 155 | #define ADSP2_CLK_SEL_WIDTH 3 /* CLK_SEL_ENA */ |
| 156 | |
| 157 | /* |
Mark Brown | 2159ad93 | 2012-10-11 11:54:02 +0900 | [diff] [blame] | 158 | * ADSP2 Status 1 |
| 159 | */ |
| 160 | #define ADSP2_RAM_RDY 0x0001 |
| 161 | #define ADSP2_RAM_RDY_MASK 0x0001 |
| 162 | #define ADSP2_RAM_RDY_SHIFT 0 |
| 163 | #define ADSP2_RAM_RDY_WIDTH 1 |
| 164 | |
Mark Brown | cf17c83 | 2013-01-30 14:37:23 +0800 | [diff] [blame] | 165 | struct wm_adsp_buf { |
| 166 | struct list_head list; |
| 167 | void *buf; |
| 168 | }; |
| 169 | |
| 170 | static struct wm_adsp_buf *wm_adsp_buf_alloc(const void *src, size_t len, |
| 171 | struct list_head *list) |
| 172 | { |
| 173 | struct wm_adsp_buf *buf = kzalloc(sizeof(*buf), GFP_KERNEL); |
| 174 | |
| 175 | if (buf == NULL) |
| 176 | return NULL; |
| 177 | |
Charles Keepax | cdcd7f7 | 2014-11-14 15:40:45 +0000 | [diff] [blame] | 178 | buf->buf = vmalloc(len); |
Mark Brown | cf17c83 | 2013-01-30 14:37:23 +0800 | [diff] [blame] | 179 | if (!buf->buf) { |
Charles Keepax | cdcd7f7 | 2014-11-14 15:40:45 +0000 | [diff] [blame] | 180 | vfree(buf); |
Mark Brown | cf17c83 | 2013-01-30 14:37:23 +0800 | [diff] [blame] | 181 | return NULL; |
| 182 | } |
Charles Keepax | cdcd7f7 | 2014-11-14 15:40:45 +0000 | [diff] [blame] | 183 | memcpy(buf->buf, src, len); |
Mark Brown | cf17c83 | 2013-01-30 14:37:23 +0800 | [diff] [blame] | 184 | |
| 185 | if (list) |
| 186 | list_add_tail(&buf->list, list); |
| 187 | |
| 188 | return buf; |
| 189 | } |
| 190 | |
| 191 | static void wm_adsp_buf_free(struct list_head *list) |
| 192 | { |
| 193 | while (!list_empty(list)) { |
| 194 | struct wm_adsp_buf *buf = list_first_entry(list, |
| 195 | struct wm_adsp_buf, |
| 196 | list); |
| 197 | list_del(&buf->list); |
Charles Keepax | cdcd7f7 | 2014-11-14 15:40:45 +0000 | [diff] [blame] | 198 | vfree(buf->buf); |
Mark Brown | cf17c83 | 2013-01-30 14:37:23 +0800 | [diff] [blame] | 199 | kfree(buf); |
| 200 | } |
| 201 | } |
| 202 | |
Mark Brown | 36e8fe9 | 2013-01-25 17:47:48 +0800 | [diff] [blame] | 203 | #define WM_ADSP_NUM_FW 4 |
Mark Brown | 1023dbd | 2013-01-11 22:58:28 +0000 | [diff] [blame] | 204 | |
Mark Brown | dd84f92 | 2013-03-08 15:25:58 +0800 | [diff] [blame] | 205 | #define WM_ADSP_FW_MBC_VSS 0 |
| 206 | #define WM_ADSP_FW_TX 1 |
| 207 | #define WM_ADSP_FW_TX_SPK 2 |
| 208 | #define WM_ADSP_FW_RX_ANC 3 |
| 209 | |
Mark Brown | 1023dbd | 2013-01-11 22:58:28 +0000 | [diff] [blame] | 210 | static const char *wm_adsp_fw_text[WM_ADSP_NUM_FW] = { |
Mark Brown | dd84f92 | 2013-03-08 15:25:58 +0800 | [diff] [blame] | 211 | [WM_ADSP_FW_MBC_VSS] = "MBC/VSS", |
| 212 | [WM_ADSP_FW_TX] = "Tx", |
| 213 | [WM_ADSP_FW_TX_SPK] = "Tx Speaker", |
| 214 | [WM_ADSP_FW_RX_ANC] = "Rx ANC", |
Mark Brown | 1023dbd | 2013-01-11 22:58:28 +0000 | [diff] [blame] | 215 | }; |
| 216 | |
| 217 | static struct { |
| 218 | const char *file; |
| 219 | } wm_adsp_fw[WM_ADSP_NUM_FW] = { |
Mark Brown | dd84f92 | 2013-03-08 15:25:58 +0800 | [diff] [blame] | 220 | [WM_ADSP_FW_MBC_VSS] = { .file = "mbc-vss" }, |
| 221 | [WM_ADSP_FW_TX] = { .file = "tx" }, |
| 222 | [WM_ADSP_FW_TX_SPK] = { .file = "tx-spk" }, |
| 223 | [WM_ADSP_FW_RX_ANC] = { .file = "rx-anc" }, |
Mark Brown | 1023dbd | 2013-01-11 22:58:28 +0000 | [diff] [blame] | 224 | }; |
| 225 | |
Dimitris Papastamos | 6ab2b7b | 2013-05-08 14:15:35 +0100 | [diff] [blame] | 226 | struct wm_coeff_ctl_ops { |
| 227 | int (*xget)(struct snd_kcontrol *kcontrol, |
| 228 | struct snd_ctl_elem_value *ucontrol); |
| 229 | int (*xput)(struct snd_kcontrol *kcontrol, |
| 230 | struct snd_ctl_elem_value *ucontrol); |
| 231 | int (*xinfo)(struct snd_kcontrol *kcontrol, |
| 232 | struct snd_ctl_elem_info *uinfo); |
| 233 | }; |
| 234 | |
Dimitris Papastamos | 6ab2b7b | 2013-05-08 14:15:35 +0100 | [diff] [blame] | 235 | struct wm_coeff_ctl { |
| 236 | const char *name; |
Charles Keepax | 2323736 | 2015-04-13 13:28:02 +0100 | [diff] [blame] | 237 | const char *fw_name; |
Charles Keepax | 3809f00 | 2015-04-13 13:27:54 +0100 | [diff] [blame] | 238 | struct wm_adsp_alg_region alg_region; |
Dimitris Papastamos | 6ab2b7b | 2013-05-08 14:15:35 +0100 | [diff] [blame] | 239 | struct wm_coeff_ctl_ops ops; |
Charles Keepax | 3809f00 | 2015-04-13 13:27:54 +0100 | [diff] [blame] | 240 | struct wm_adsp *dsp; |
Dimitris Papastamos | 6ab2b7b | 2013-05-08 14:15:35 +0100 | [diff] [blame] | 241 | unsigned int enabled:1; |
| 242 | struct list_head list; |
| 243 | void *cache; |
Charles Keepax | 2323736 | 2015-04-13 13:28:02 +0100 | [diff] [blame] | 244 | unsigned int offset; |
Dimitris Papastamos | 6ab2b7b | 2013-05-08 14:15:35 +0100 | [diff] [blame] | 245 | size_t len; |
Dimitris Papastamos | 0c2e3f3 | 2013-05-28 12:01:50 +0100 | [diff] [blame] | 246 | unsigned int set:1; |
Dimitris Papastamos | 6ab2b7b | 2013-05-08 14:15:35 +0100 | [diff] [blame] | 247 | struct snd_kcontrol *kcontrol; |
Charles Keepax | 26c22a1 | 2015-04-20 13:52:45 +0100 | [diff] [blame] | 248 | unsigned int flags; |
Dimitris Papastamos | 6ab2b7b | 2013-05-08 14:15:35 +0100 | [diff] [blame] | 249 | }; |
| 250 | |
Mark Brown | 1023dbd | 2013-01-11 22:58:28 +0000 | [diff] [blame] | 251 | static int wm_adsp_fw_get(struct snd_kcontrol *kcontrol, |
| 252 | struct snd_ctl_elem_value *ucontrol) |
| 253 | { |
Lars-Peter Clausen | ea53bf7 | 2014-03-18 09:02:04 +0100 | [diff] [blame] | 254 | struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); |
Mark Brown | 1023dbd | 2013-01-11 22:58:28 +0000 | [diff] [blame] | 255 | struct soc_enum *e = (struct soc_enum *)kcontrol->private_value; |
Charles Keepax | 3809f00 | 2015-04-13 13:27:54 +0100 | [diff] [blame] | 256 | struct wm_adsp *dsp = snd_soc_codec_get_drvdata(codec); |
Mark Brown | 1023dbd | 2013-01-11 22:58:28 +0000 | [diff] [blame] | 257 | |
Charles Keepax | 3809f00 | 2015-04-13 13:27:54 +0100 | [diff] [blame] | 258 | ucontrol->value.integer.value[0] = dsp[e->shift_l].fw; |
Mark Brown | 1023dbd | 2013-01-11 22:58:28 +0000 | [diff] [blame] | 259 | |
| 260 | return 0; |
| 261 | } |
| 262 | |
| 263 | static int wm_adsp_fw_put(struct snd_kcontrol *kcontrol, |
| 264 | struct snd_ctl_elem_value *ucontrol) |
| 265 | { |
Lars-Peter Clausen | ea53bf7 | 2014-03-18 09:02:04 +0100 | [diff] [blame] | 266 | struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); |
Mark Brown | 1023dbd | 2013-01-11 22:58:28 +0000 | [diff] [blame] | 267 | struct soc_enum *e = (struct soc_enum *)kcontrol->private_value; |
Charles Keepax | 3809f00 | 2015-04-13 13:27:54 +0100 | [diff] [blame] | 268 | struct wm_adsp *dsp = snd_soc_codec_get_drvdata(codec); |
Mark Brown | 1023dbd | 2013-01-11 22:58:28 +0000 | [diff] [blame] | 269 | |
Charles Keepax | 3809f00 | 2015-04-13 13:27:54 +0100 | [diff] [blame] | 270 | if (ucontrol->value.integer.value[0] == dsp[e->shift_l].fw) |
Mark Brown | 1023dbd | 2013-01-11 22:58:28 +0000 | [diff] [blame] | 271 | return 0; |
| 272 | |
| 273 | if (ucontrol->value.integer.value[0] >= WM_ADSP_NUM_FW) |
| 274 | return -EINVAL; |
| 275 | |
Charles Keepax | 3809f00 | 2015-04-13 13:27:54 +0100 | [diff] [blame] | 276 | if (dsp[e->shift_l].running) |
Mark Brown | 1023dbd | 2013-01-11 22:58:28 +0000 | [diff] [blame] | 277 | return -EBUSY; |
| 278 | |
Charles Keepax | 3809f00 | 2015-04-13 13:27:54 +0100 | [diff] [blame] | 279 | dsp[e->shift_l].fw = ucontrol->value.integer.value[0]; |
Mark Brown | 1023dbd | 2013-01-11 22:58:28 +0000 | [diff] [blame] | 280 | |
| 281 | return 0; |
| 282 | } |
| 283 | |
| 284 | static const struct soc_enum wm_adsp_fw_enum[] = { |
| 285 | SOC_ENUM_SINGLE(0, 0, ARRAY_SIZE(wm_adsp_fw_text), wm_adsp_fw_text), |
| 286 | SOC_ENUM_SINGLE(0, 1, ARRAY_SIZE(wm_adsp_fw_text), wm_adsp_fw_text), |
| 287 | SOC_ENUM_SINGLE(0, 2, ARRAY_SIZE(wm_adsp_fw_text), wm_adsp_fw_text), |
| 288 | SOC_ENUM_SINGLE(0, 3, ARRAY_SIZE(wm_adsp_fw_text), wm_adsp_fw_text), |
| 289 | }; |
| 290 | |
Mark Brown | b6ed61cf | 2013-03-29 18:00:24 +0000 | [diff] [blame] | 291 | const struct snd_kcontrol_new wm_adsp1_fw_controls[] = { |
Mark Brown | 1023dbd | 2013-01-11 22:58:28 +0000 | [diff] [blame] | 292 | SOC_ENUM_EXT("DSP1 Firmware", wm_adsp_fw_enum[0], |
| 293 | wm_adsp_fw_get, wm_adsp_fw_put), |
| 294 | SOC_ENUM_EXT("DSP2 Firmware", wm_adsp_fw_enum[1], |
| 295 | wm_adsp_fw_get, wm_adsp_fw_put), |
| 296 | SOC_ENUM_EXT("DSP3 Firmware", wm_adsp_fw_enum[2], |
| 297 | wm_adsp_fw_get, wm_adsp_fw_put), |
Mark Brown | b6ed61cf | 2013-03-29 18:00:24 +0000 | [diff] [blame] | 298 | }; |
| 299 | EXPORT_SYMBOL_GPL(wm_adsp1_fw_controls); |
| 300 | |
| 301 | #if IS_ENABLED(CONFIG_SND_SOC_ARIZONA) |
| 302 | static const struct soc_enum wm_adsp2_rate_enum[] = { |
Mark Brown | dc91428 | 2013-02-18 19:09:23 +0000 | [diff] [blame] | 303 | SOC_VALUE_ENUM_SINGLE(ARIZONA_DSP1_CONTROL_1, |
| 304 | ARIZONA_DSP1_RATE_SHIFT, 0xf, |
| 305 | ARIZONA_RATE_ENUM_SIZE, |
| 306 | arizona_rate_text, arizona_rate_val), |
| 307 | SOC_VALUE_ENUM_SINGLE(ARIZONA_DSP2_CONTROL_1, |
| 308 | ARIZONA_DSP1_RATE_SHIFT, 0xf, |
| 309 | ARIZONA_RATE_ENUM_SIZE, |
| 310 | arizona_rate_text, arizona_rate_val), |
| 311 | SOC_VALUE_ENUM_SINGLE(ARIZONA_DSP3_CONTROL_1, |
| 312 | ARIZONA_DSP1_RATE_SHIFT, 0xf, |
| 313 | ARIZONA_RATE_ENUM_SIZE, |
| 314 | arizona_rate_text, arizona_rate_val), |
Charles Keepax | 5be9c5b | 2013-06-14 14:19:36 +0100 | [diff] [blame] | 315 | SOC_VALUE_ENUM_SINGLE(ARIZONA_DSP4_CONTROL_1, |
Mark Brown | dc91428 | 2013-02-18 19:09:23 +0000 | [diff] [blame] | 316 | ARIZONA_DSP1_RATE_SHIFT, 0xf, |
| 317 | ARIZONA_RATE_ENUM_SIZE, |
| 318 | arizona_rate_text, arizona_rate_val), |
| 319 | }; |
| 320 | |
Mark Brown | b6ed61cf | 2013-03-29 18:00:24 +0000 | [diff] [blame] | 321 | const struct snd_kcontrol_new wm_adsp2_fw_controls[] = { |
Mark Brown | 1023dbd | 2013-01-11 22:58:28 +0000 | [diff] [blame] | 322 | SOC_ENUM_EXT("DSP1 Firmware", wm_adsp_fw_enum[0], |
| 323 | wm_adsp_fw_get, wm_adsp_fw_put), |
Mark Brown | b6ed61cf | 2013-03-29 18:00:24 +0000 | [diff] [blame] | 324 | SOC_ENUM("DSP1 Rate", wm_adsp2_rate_enum[0]), |
Mark Brown | 1023dbd | 2013-01-11 22:58:28 +0000 | [diff] [blame] | 325 | SOC_ENUM_EXT("DSP2 Firmware", wm_adsp_fw_enum[1], |
| 326 | wm_adsp_fw_get, wm_adsp_fw_put), |
Mark Brown | b6ed61cf | 2013-03-29 18:00:24 +0000 | [diff] [blame] | 327 | SOC_ENUM("DSP2 Rate", wm_adsp2_rate_enum[1]), |
Mark Brown | 1023dbd | 2013-01-11 22:58:28 +0000 | [diff] [blame] | 328 | SOC_ENUM_EXT("DSP3 Firmware", wm_adsp_fw_enum[2], |
| 329 | wm_adsp_fw_get, wm_adsp_fw_put), |
Mark Brown | b6ed61cf | 2013-03-29 18:00:24 +0000 | [diff] [blame] | 330 | SOC_ENUM("DSP3 Rate", wm_adsp2_rate_enum[2]), |
Mark Brown | 1023dbd | 2013-01-11 22:58:28 +0000 | [diff] [blame] | 331 | SOC_ENUM_EXT("DSP4 Firmware", wm_adsp_fw_enum[3], |
| 332 | wm_adsp_fw_get, wm_adsp_fw_put), |
Mark Brown | b6ed61cf | 2013-03-29 18:00:24 +0000 | [diff] [blame] | 333 | SOC_ENUM("DSP4 Rate", wm_adsp2_rate_enum[3]), |
Mark Brown | 1023dbd | 2013-01-11 22:58:28 +0000 | [diff] [blame] | 334 | }; |
Mark Brown | b6ed61cf | 2013-03-29 18:00:24 +0000 | [diff] [blame] | 335 | EXPORT_SYMBOL_GPL(wm_adsp2_fw_controls); |
| 336 | #endif |
Mark Brown | 2159ad93 | 2012-10-11 11:54:02 +0900 | [diff] [blame] | 337 | |
| 338 | static struct wm_adsp_region const *wm_adsp_find_region(struct wm_adsp *dsp, |
| 339 | int type) |
| 340 | { |
| 341 | int i; |
| 342 | |
| 343 | for (i = 0; i < dsp->num_mems; i++) |
| 344 | if (dsp->mem[i].type == type) |
| 345 | return &dsp->mem[i]; |
| 346 | |
| 347 | return NULL; |
| 348 | } |
| 349 | |
Charles Keepax | 3809f00 | 2015-04-13 13:27:54 +0100 | [diff] [blame] | 350 | static unsigned int wm_adsp_region_to_reg(struct wm_adsp_region const *mem, |
Mark Brown | 45b9ee7 | 2013-01-08 16:02:06 +0000 | [diff] [blame] | 351 | unsigned int offset) |
| 352 | { |
Charles Keepax | 3809f00 | 2015-04-13 13:27:54 +0100 | [diff] [blame] | 353 | if (WARN_ON(!mem)) |
Takashi Iwai | 6c452bd | 2013-11-05 18:40:00 +0100 | [diff] [blame] | 354 | return offset; |
Charles Keepax | 3809f00 | 2015-04-13 13:27:54 +0100 | [diff] [blame] | 355 | switch (mem->type) { |
Mark Brown | 45b9ee7 | 2013-01-08 16:02:06 +0000 | [diff] [blame] | 356 | case WMFW_ADSP1_PM: |
Charles Keepax | 3809f00 | 2015-04-13 13:27:54 +0100 | [diff] [blame] | 357 | return mem->base + (offset * 3); |
Mark Brown | 45b9ee7 | 2013-01-08 16:02:06 +0000 | [diff] [blame] | 358 | case WMFW_ADSP1_DM: |
Charles Keepax | 3809f00 | 2015-04-13 13:27:54 +0100 | [diff] [blame] | 359 | return mem->base + (offset * 2); |
Mark Brown | 45b9ee7 | 2013-01-08 16:02:06 +0000 | [diff] [blame] | 360 | case WMFW_ADSP2_XM: |
Charles Keepax | 3809f00 | 2015-04-13 13:27:54 +0100 | [diff] [blame] | 361 | return mem->base + (offset * 2); |
Mark Brown | 45b9ee7 | 2013-01-08 16:02:06 +0000 | [diff] [blame] | 362 | case WMFW_ADSP2_YM: |
Charles Keepax | 3809f00 | 2015-04-13 13:27:54 +0100 | [diff] [blame] | 363 | return mem->base + (offset * 2); |
Mark Brown | 45b9ee7 | 2013-01-08 16:02:06 +0000 | [diff] [blame] | 364 | case WMFW_ADSP1_ZM: |
Charles Keepax | 3809f00 | 2015-04-13 13:27:54 +0100 | [diff] [blame] | 365 | return mem->base + (offset * 2); |
Mark Brown | 45b9ee7 | 2013-01-08 16:02:06 +0000 | [diff] [blame] | 366 | default: |
Takashi Iwai | 6c452bd | 2013-11-05 18:40:00 +0100 | [diff] [blame] | 367 | WARN(1, "Unknown memory region type"); |
Mark Brown | 45b9ee7 | 2013-01-08 16:02:06 +0000 | [diff] [blame] | 368 | return offset; |
| 369 | } |
| 370 | } |
| 371 | |
Richard Fitzgerald | 10337b0 | 2015-05-29 10:23:07 +0100 | [diff] [blame] | 372 | static void wm_adsp2_show_fw_status(struct wm_adsp *dsp) |
| 373 | { |
| 374 | u16 scratch[4]; |
| 375 | int ret; |
| 376 | |
| 377 | ret = regmap_raw_read(dsp->regmap, dsp->base + ADSP2_SCRATCH0, |
| 378 | scratch, sizeof(scratch)); |
| 379 | if (ret) { |
| 380 | adsp_err(dsp, "Failed to read SCRATCH regs: %d\n", ret); |
| 381 | return; |
| 382 | } |
| 383 | |
| 384 | adsp_dbg(dsp, "FW SCRATCH 0:0x%x 1:0x%x 2:0x%x 3:0x%x\n", |
| 385 | be16_to_cpu(scratch[0]), |
| 386 | be16_to_cpu(scratch[1]), |
| 387 | be16_to_cpu(scratch[2]), |
| 388 | be16_to_cpu(scratch[3])); |
| 389 | } |
| 390 | |
Dimitris Papastamos | 6ab2b7b | 2013-05-08 14:15:35 +0100 | [diff] [blame] | 391 | static int wm_coeff_info(struct snd_kcontrol *kcontrol, |
| 392 | struct snd_ctl_elem_info *uinfo) |
| 393 | { |
| 394 | struct wm_coeff_ctl *ctl = (struct wm_coeff_ctl *)kcontrol->private_value; |
| 395 | |
| 396 | uinfo->type = SNDRV_CTL_ELEM_TYPE_BYTES; |
| 397 | uinfo->count = ctl->len; |
| 398 | return 0; |
| 399 | } |
| 400 | |
Charles Keepax | c9f8dd7 | 2015-04-13 13:27:58 +0100 | [diff] [blame] | 401 | static int wm_coeff_write_control(struct wm_coeff_ctl *ctl, |
Dimitris Papastamos | 6ab2b7b | 2013-05-08 14:15:35 +0100 | [diff] [blame] | 402 | const void *buf, size_t len) |
| 403 | { |
Charles Keepax | 3809f00 | 2015-04-13 13:27:54 +0100 | [diff] [blame] | 404 | struct wm_adsp_alg_region *alg_region = &ctl->alg_region; |
Dimitris Papastamos | 6ab2b7b | 2013-05-08 14:15:35 +0100 | [diff] [blame] | 405 | const struct wm_adsp_region *mem; |
Charles Keepax | 3809f00 | 2015-04-13 13:27:54 +0100 | [diff] [blame] | 406 | struct wm_adsp *dsp = ctl->dsp; |
Dimitris Papastamos | 6ab2b7b | 2013-05-08 14:15:35 +0100 | [diff] [blame] | 407 | void *scratch; |
| 408 | int ret; |
| 409 | unsigned int reg; |
| 410 | |
Charles Keepax | 3809f00 | 2015-04-13 13:27:54 +0100 | [diff] [blame] | 411 | mem = wm_adsp_find_region(dsp, alg_region->type); |
Dimitris Papastamos | 6ab2b7b | 2013-05-08 14:15:35 +0100 | [diff] [blame] | 412 | if (!mem) { |
Charles Keepax | 3809f00 | 2015-04-13 13:27:54 +0100 | [diff] [blame] | 413 | adsp_err(dsp, "No base for region %x\n", |
| 414 | alg_region->type); |
Dimitris Papastamos | 6ab2b7b | 2013-05-08 14:15:35 +0100 | [diff] [blame] | 415 | return -EINVAL; |
| 416 | } |
| 417 | |
Charles Keepax | 2323736 | 2015-04-13 13:28:02 +0100 | [diff] [blame] | 418 | reg = ctl->alg_region.base + ctl->offset; |
Dimitris Papastamos | 6ab2b7b | 2013-05-08 14:15:35 +0100 | [diff] [blame] | 419 | reg = wm_adsp_region_to_reg(mem, reg); |
| 420 | |
| 421 | scratch = kmemdup(buf, ctl->len, GFP_KERNEL | GFP_DMA); |
| 422 | if (!scratch) |
| 423 | return -ENOMEM; |
| 424 | |
Charles Keepax | 3809f00 | 2015-04-13 13:27:54 +0100 | [diff] [blame] | 425 | ret = regmap_raw_write(dsp->regmap, reg, scratch, |
Dimitris Papastamos | 6ab2b7b | 2013-05-08 14:15:35 +0100 | [diff] [blame] | 426 | ctl->len); |
| 427 | if (ret) { |
Charles Keepax | 3809f00 | 2015-04-13 13:27:54 +0100 | [diff] [blame] | 428 | adsp_err(dsp, "Failed to write %zu bytes to %x: %d\n", |
Dimitris Papastamos | 43bc3bf | 2013-11-01 15:56:52 +0000 | [diff] [blame] | 429 | ctl->len, reg, ret); |
Dimitris Papastamos | 6ab2b7b | 2013-05-08 14:15:35 +0100 | [diff] [blame] | 430 | kfree(scratch); |
| 431 | return ret; |
| 432 | } |
Charles Keepax | 3809f00 | 2015-04-13 13:27:54 +0100 | [diff] [blame] | 433 | adsp_dbg(dsp, "Wrote %zu bytes to %x\n", ctl->len, reg); |
Dimitris Papastamos | 6ab2b7b | 2013-05-08 14:15:35 +0100 | [diff] [blame] | 434 | |
| 435 | kfree(scratch); |
| 436 | |
| 437 | return 0; |
| 438 | } |
| 439 | |
| 440 | static int wm_coeff_put(struct snd_kcontrol *kcontrol, |
| 441 | struct snd_ctl_elem_value *ucontrol) |
| 442 | { |
| 443 | struct wm_coeff_ctl *ctl = (struct wm_coeff_ctl *)kcontrol->private_value; |
| 444 | char *p = ucontrol->value.bytes.data; |
| 445 | |
| 446 | memcpy(ctl->cache, p, ctl->len); |
| 447 | |
Nikesh Oswal | 65d17a9 | 2015-02-16 15:25:48 +0000 | [diff] [blame] | 448 | ctl->set = 1; |
| 449 | if (!ctl->enabled) |
Dimitris Papastamos | 6ab2b7b | 2013-05-08 14:15:35 +0100 | [diff] [blame] | 450 | return 0; |
Dimitris Papastamos | 6ab2b7b | 2013-05-08 14:15:35 +0100 | [diff] [blame] | 451 | |
Charles Keepax | c9f8dd7 | 2015-04-13 13:27:58 +0100 | [diff] [blame] | 452 | return wm_coeff_write_control(ctl, p, ctl->len); |
Dimitris Papastamos | 6ab2b7b | 2013-05-08 14:15:35 +0100 | [diff] [blame] | 453 | } |
| 454 | |
Charles Keepax | c9f8dd7 | 2015-04-13 13:27:58 +0100 | [diff] [blame] | 455 | static int wm_coeff_read_control(struct wm_coeff_ctl *ctl, |
Dimitris Papastamos | 6ab2b7b | 2013-05-08 14:15:35 +0100 | [diff] [blame] | 456 | void *buf, size_t len) |
| 457 | { |
Charles Keepax | 3809f00 | 2015-04-13 13:27:54 +0100 | [diff] [blame] | 458 | struct wm_adsp_alg_region *alg_region = &ctl->alg_region; |
Dimitris Papastamos | 6ab2b7b | 2013-05-08 14:15:35 +0100 | [diff] [blame] | 459 | const struct wm_adsp_region *mem; |
Charles Keepax | 3809f00 | 2015-04-13 13:27:54 +0100 | [diff] [blame] | 460 | struct wm_adsp *dsp = ctl->dsp; |
Dimitris Papastamos | 6ab2b7b | 2013-05-08 14:15:35 +0100 | [diff] [blame] | 461 | void *scratch; |
| 462 | int ret; |
| 463 | unsigned int reg; |
| 464 | |
Charles Keepax | 3809f00 | 2015-04-13 13:27:54 +0100 | [diff] [blame] | 465 | mem = wm_adsp_find_region(dsp, alg_region->type); |
Dimitris Papastamos | 6ab2b7b | 2013-05-08 14:15:35 +0100 | [diff] [blame] | 466 | if (!mem) { |
Charles Keepax | 3809f00 | 2015-04-13 13:27:54 +0100 | [diff] [blame] | 467 | adsp_err(dsp, "No base for region %x\n", |
| 468 | alg_region->type); |
Dimitris Papastamos | 6ab2b7b | 2013-05-08 14:15:35 +0100 | [diff] [blame] | 469 | return -EINVAL; |
| 470 | } |
| 471 | |
Charles Keepax | 2323736 | 2015-04-13 13:28:02 +0100 | [diff] [blame] | 472 | reg = ctl->alg_region.base + ctl->offset; |
Dimitris Papastamos | 6ab2b7b | 2013-05-08 14:15:35 +0100 | [diff] [blame] | 473 | reg = wm_adsp_region_to_reg(mem, reg); |
| 474 | |
| 475 | scratch = kmalloc(ctl->len, GFP_KERNEL | GFP_DMA); |
| 476 | if (!scratch) |
| 477 | return -ENOMEM; |
| 478 | |
Charles Keepax | 3809f00 | 2015-04-13 13:27:54 +0100 | [diff] [blame] | 479 | ret = regmap_raw_read(dsp->regmap, reg, scratch, ctl->len); |
Dimitris Papastamos | 6ab2b7b | 2013-05-08 14:15:35 +0100 | [diff] [blame] | 480 | if (ret) { |
Charles Keepax | 3809f00 | 2015-04-13 13:27:54 +0100 | [diff] [blame] | 481 | adsp_err(dsp, "Failed to read %zu bytes from %x: %d\n", |
Dimitris Papastamos | 43bc3bf | 2013-11-01 15:56:52 +0000 | [diff] [blame] | 482 | ctl->len, reg, ret); |
Dimitris Papastamos | 6ab2b7b | 2013-05-08 14:15:35 +0100 | [diff] [blame] | 483 | kfree(scratch); |
| 484 | return ret; |
| 485 | } |
Charles Keepax | 3809f00 | 2015-04-13 13:27:54 +0100 | [diff] [blame] | 486 | adsp_dbg(dsp, "Read %zu bytes from %x\n", ctl->len, reg); |
Dimitris Papastamos | 6ab2b7b | 2013-05-08 14:15:35 +0100 | [diff] [blame] | 487 | |
| 488 | memcpy(buf, scratch, ctl->len); |
| 489 | kfree(scratch); |
| 490 | |
| 491 | return 0; |
| 492 | } |
| 493 | |
| 494 | static int wm_coeff_get(struct snd_kcontrol *kcontrol, |
| 495 | struct snd_ctl_elem_value *ucontrol) |
| 496 | { |
| 497 | struct wm_coeff_ctl *ctl = (struct wm_coeff_ctl *)kcontrol->private_value; |
| 498 | char *p = ucontrol->value.bytes.data; |
| 499 | |
Charles Keepax | 26c22a1 | 2015-04-20 13:52:45 +0100 | [diff] [blame] | 500 | if (ctl->flags & WMFW_CTL_FLAG_VOLATILE) { |
| 501 | if (ctl->enabled) |
| 502 | return wm_coeff_read_control(ctl, p, ctl->len); |
| 503 | else |
| 504 | return -EPERM; |
| 505 | } |
| 506 | |
Dimitris Papastamos | 6ab2b7b | 2013-05-08 14:15:35 +0100 | [diff] [blame] | 507 | memcpy(p, ctl->cache, ctl->len); |
Charles Keepax | 26c22a1 | 2015-04-20 13:52:45 +0100 | [diff] [blame] | 508 | |
Dimitris Papastamos | 6ab2b7b | 2013-05-08 14:15:35 +0100 | [diff] [blame] | 509 | return 0; |
| 510 | } |
| 511 | |
Dimitris Papastamos | 6ab2b7b | 2013-05-08 14:15:35 +0100 | [diff] [blame] | 512 | struct wmfw_ctl_work { |
Charles Keepax | 3809f00 | 2015-04-13 13:27:54 +0100 | [diff] [blame] | 513 | struct wm_adsp *dsp; |
Dimitris Papastamos | 6ab2b7b | 2013-05-08 14:15:35 +0100 | [diff] [blame] | 514 | struct wm_coeff_ctl *ctl; |
| 515 | struct work_struct work; |
| 516 | }; |
| 517 | |
Charles Keepax | 3809f00 | 2015-04-13 13:27:54 +0100 | [diff] [blame] | 518 | static int wmfw_add_ctl(struct wm_adsp *dsp, struct wm_coeff_ctl *ctl) |
Dimitris Papastamos | 6ab2b7b | 2013-05-08 14:15:35 +0100 | [diff] [blame] | 519 | { |
| 520 | struct snd_kcontrol_new *kcontrol; |
| 521 | int ret; |
| 522 | |
Dimitris Papastamos | 92bb4c3 | 2013-08-01 11:11:28 +0100 | [diff] [blame] | 523 | if (!ctl || !ctl->name) |
Dimitris Papastamos | 6ab2b7b | 2013-05-08 14:15:35 +0100 | [diff] [blame] | 524 | return -EINVAL; |
| 525 | |
| 526 | kcontrol = kzalloc(sizeof(*kcontrol), GFP_KERNEL); |
| 527 | if (!kcontrol) |
| 528 | return -ENOMEM; |
| 529 | kcontrol->iface = SNDRV_CTL_ELEM_IFACE_MIXER; |
| 530 | |
| 531 | kcontrol->name = ctl->name; |
| 532 | kcontrol->info = wm_coeff_info; |
| 533 | kcontrol->get = wm_coeff_get; |
| 534 | kcontrol->put = wm_coeff_put; |
| 535 | kcontrol->private_value = (unsigned long)ctl; |
| 536 | |
Charles Keepax | 26c22a1 | 2015-04-20 13:52:45 +0100 | [diff] [blame] | 537 | if (ctl->flags) { |
| 538 | if (ctl->flags & WMFW_CTL_FLAG_WRITEABLE) |
| 539 | kcontrol->access |= SNDRV_CTL_ELEM_ACCESS_WRITE; |
| 540 | if (ctl->flags & WMFW_CTL_FLAG_READABLE) |
| 541 | kcontrol->access |= SNDRV_CTL_ELEM_ACCESS_READ; |
| 542 | if (ctl->flags & WMFW_CTL_FLAG_VOLATILE) |
| 543 | kcontrol->access |= SNDRV_CTL_ELEM_ACCESS_VOLATILE; |
| 544 | } |
| 545 | |
Charles Keepax | 3809f00 | 2015-04-13 13:27:54 +0100 | [diff] [blame] | 546 | ret = snd_soc_add_card_controls(dsp->card, |
Dimitris Papastamos | 81ad93e | 2013-07-29 13:51:59 +0100 | [diff] [blame] | 547 | kcontrol, 1); |
Dimitris Papastamos | 6ab2b7b | 2013-05-08 14:15:35 +0100 | [diff] [blame] | 548 | if (ret < 0) |
| 549 | goto err_kcontrol; |
| 550 | |
| 551 | kfree(kcontrol); |
| 552 | |
Charles Keepax | 3809f00 | 2015-04-13 13:27:54 +0100 | [diff] [blame] | 553 | ctl->kcontrol = snd_soc_card_get_kcontrol(dsp->card, |
Dimitris Papastamos | 81ad93e | 2013-07-29 13:51:59 +0100 | [diff] [blame] | 554 | ctl->name); |
| 555 | |
Dimitris Papastamos | 6ab2b7b | 2013-05-08 14:15:35 +0100 | [diff] [blame] | 556 | return 0; |
| 557 | |
| 558 | err_kcontrol: |
| 559 | kfree(kcontrol); |
| 560 | return ret; |
| 561 | } |
| 562 | |
Charles Keepax | b21acc1 | 2015-04-13 13:28:01 +0100 | [diff] [blame] | 563 | static int wm_coeff_init_control_caches(struct wm_adsp *dsp) |
| 564 | { |
| 565 | struct wm_coeff_ctl *ctl; |
| 566 | int ret; |
| 567 | |
| 568 | list_for_each_entry(ctl, &dsp->ctl_list, list) { |
| 569 | if (!ctl->enabled || ctl->set) |
| 570 | continue; |
Charles Keepax | 26c22a1 | 2015-04-20 13:52:45 +0100 | [diff] [blame] | 571 | if (ctl->flags & WMFW_CTL_FLAG_VOLATILE) |
| 572 | continue; |
| 573 | |
Charles Keepax | b21acc1 | 2015-04-13 13:28:01 +0100 | [diff] [blame] | 574 | ret = wm_coeff_read_control(ctl, |
| 575 | ctl->cache, |
| 576 | ctl->len); |
| 577 | if (ret < 0) |
| 578 | return ret; |
| 579 | } |
| 580 | |
| 581 | return 0; |
| 582 | } |
| 583 | |
| 584 | static int wm_coeff_sync_controls(struct wm_adsp *dsp) |
| 585 | { |
| 586 | struct wm_coeff_ctl *ctl; |
| 587 | int ret; |
| 588 | |
| 589 | list_for_each_entry(ctl, &dsp->ctl_list, list) { |
| 590 | if (!ctl->enabled) |
| 591 | continue; |
Charles Keepax | 26c22a1 | 2015-04-20 13:52:45 +0100 | [diff] [blame] | 592 | if (ctl->set && !(ctl->flags & WMFW_CTL_FLAG_VOLATILE)) { |
Charles Keepax | b21acc1 | 2015-04-13 13:28:01 +0100 | [diff] [blame] | 593 | ret = wm_coeff_write_control(ctl, |
| 594 | ctl->cache, |
| 595 | ctl->len); |
| 596 | if (ret < 0) |
| 597 | return ret; |
| 598 | } |
| 599 | } |
| 600 | |
| 601 | return 0; |
| 602 | } |
| 603 | |
| 604 | static void wm_adsp_ctl_work(struct work_struct *work) |
| 605 | { |
| 606 | struct wmfw_ctl_work *ctl_work = container_of(work, |
| 607 | struct wmfw_ctl_work, |
| 608 | work); |
| 609 | |
| 610 | wmfw_add_ctl(ctl_work->dsp, ctl_work->ctl); |
| 611 | kfree(ctl_work); |
| 612 | } |
| 613 | |
| 614 | static int wm_adsp_create_control(struct wm_adsp *dsp, |
| 615 | const struct wm_adsp_alg_region *alg_region, |
Charles Keepax | 2323736 | 2015-04-13 13:28:02 +0100 | [diff] [blame] | 616 | unsigned int offset, unsigned int len, |
Charles Keepax | 26c22a1 | 2015-04-20 13:52:45 +0100 | [diff] [blame] | 617 | const char *subname, unsigned int subname_len, |
| 618 | unsigned int flags) |
Charles Keepax | b21acc1 | 2015-04-13 13:28:01 +0100 | [diff] [blame] | 619 | { |
| 620 | struct wm_coeff_ctl *ctl; |
| 621 | struct wmfw_ctl_work *ctl_work; |
| 622 | char name[SNDRV_CTL_ELEM_ID_NAME_MAXLEN]; |
| 623 | char *region_name; |
| 624 | int ret; |
| 625 | |
Charles Keepax | 26c22a1 | 2015-04-20 13:52:45 +0100 | [diff] [blame] | 626 | if (flags & WMFW_CTL_FLAG_SYS) |
| 627 | return 0; |
| 628 | |
Charles Keepax | b21acc1 | 2015-04-13 13:28:01 +0100 | [diff] [blame] | 629 | switch (alg_region->type) { |
| 630 | case WMFW_ADSP1_PM: |
| 631 | region_name = "PM"; |
| 632 | break; |
| 633 | case WMFW_ADSP1_DM: |
| 634 | region_name = "DM"; |
| 635 | break; |
| 636 | case WMFW_ADSP2_XM: |
| 637 | region_name = "XM"; |
| 638 | break; |
| 639 | case WMFW_ADSP2_YM: |
| 640 | region_name = "YM"; |
| 641 | break; |
| 642 | case WMFW_ADSP1_ZM: |
| 643 | region_name = "ZM"; |
| 644 | break; |
| 645 | default: |
Charles Keepax | 2323736 | 2015-04-13 13:28:02 +0100 | [diff] [blame] | 646 | adsp_err(dsp, "Unknown region type: %d\n", alg_region->type); |
Charles Keepax | b21acc1 | 2015-04-13 13:28:01 +0100 | [diff] [blame] | 647 | return -EINVAL; |
| 648 | } |
| 649 | |
Charles Keepax | cb5b57a | 2015-04-13 13:28:04 +0100 | [diff] [blame] | 650 | switch (dsp->fw_ver) { |
| 651 | case 0: |
| 652 | case 1: |
| 653 | snprintf(name, SNDRV_CTL_ELEM_ID_NAME_MAXLEN, "DSP%d %s %x", |
| 654 | dsp->num, region_name, alg_region->alg); |
| 655 | break; |
| 656 | default: |
| 657 | ret = snprintf(name, SNDRV_CTL_ELEM_ID_NAME_MAXLEN, |
| 658 | "DSP%d%c %.12s %x", dsp->num, *region_name, |
| 659 | wm_adsp_fw_text[dsp->fw], alg_region->alg); |
| 660 | |
| 661 | /* Truncate the subname from the start if it is too long */ |
| 662 | if (subname) { |
| 663 | int avail = SNDRV_CTL_ELEM_ID_NAME_MAXLEN - ret - 2; |
| 664 | int skip = 0; |
| 665 | |
| 666 | if (subname_len > avail) |
| 667 | skip = subname_len - avail; |
| 668 | |
| 669 | snprintf(name + ret, |
| 670 | SNDRV_CTL_ELEM_ID_NAME_MAXLEN - ret, " %.*s", |
| 671 | subname_len - skip, subname + skip); |
| 672 | } |
| 673 | break; |
| 674 | } |
Charles Keepax | b21acc1 | 2015-04-13 13:28:01 +0100 | [diff] [blame] | 675 | |
| 676 | list_for_each_entry(ctl, &dsp->ctl_list, |
| 677 | list) { |
| 678 | if (!strcmp(ctl->name, name)) { |
| 679 | if (!ctl->enabled) |
| 680 | ctl->enabled = 1; |
| 681 | return 0; |
| 682 | } |
| 683 | } |
| 684 | |
| 685 | ctl = kzalloc(sizeof(*ctl), GFP_KERNEL); |
| 686 | if (!ctl) |
| 687 | return -ENOMEM; |
Charles Keepax | 2323736 | 2015-04-13 13:28:02 +0100 | [diff] [blame] | 688 | ctl->fw_name = wm_adsp_fw_text[dsp->fw]; |
Charles Keepax | b21acc1 | 2015-04-13 13:28:01 +0100 | [diff] [blame] | 689 | ctl->alg_region = *alg_region; |
| 690 | ctl->name = kmemdup(name, strlen(name) + 1, GFP_KERNEL); |
| 691 | if (!ctl->name) { |
| 692 | ret = -ENOMEM; |
| 693 | goto err_ctl; |
| 694 | } |
| 695 | ctl->enabled = 1; |
| 696 | ctl->set = 0; |
| 697 | ctl->ops.xget = wm_coeff_get; |
| 698 | ctl->ops.xput = wm_coeff_put; |
| 699 | ctl->dsp = dsp; |
| 700 | |
Charles Keepax | 26c22a1 | 2015-04-20 13:52:45 +0100 | [diff] [blame] | 701 | ctl->flags = flags; |
Charles Keepax | 2323736 | 2015-04-13 13:28:02 +0100 | [diff] [blame] | 702 | ctl->offset = offset; |
Charles Keepax | b21acc1 | 2015-04-13 13:28:01 +0100 | [diff] [blame] | 703 | if (len > 512) { |
| 704 | adsp_warn(dsp, "Truncating control %s from %d\n", |
| 705 | ctl->name, len); |
| 706 | len = 512; |
| 707 | } |
| 708 | ctl->len = len; |
| 709 | ctl->cache = kzalloc(ctl->len, GFP_KERNEL); |
| 710 | if (!ctl->cache) { |
| 711 | ret = -ENOMEM; |
| 712 | goto err_ctl_name; |
| 713 | } |
| 714 | |
Charles Keepax | 2323736 | 2015-04-13 13:28:02 +0100 | [diff] [blame] | 715 | list_add(&ctl->list, &dsp->ctl_list); |
| 716 | |
Charles Keepax | b21acc1 | 2015-04-13 13:28:01 +0100 | [diff] [blame] | 717 | ctl_work = kzalloc(sizeof(*ctl_work), GFP_KERNEL); |
| 718 | if (!ctl_work) { |
| 719 | ret = -ENOMEM; |
| 720 | goto err_ctl_cache; |
| 721 | } |
| 722 | |
| 723 | ctl_work->dsp = dsp; |
| 724 | ctl_work->ctl = ctl; |
| 725 | INIT_WORK(&ctl_work->work, wm_adsp_ctl_work); |
| 726 | schedule_work(&ctl_work->work); |
| 727 | |
| 728 | return 0; |
| 729 | |
| 730 | err_ctl_cache: |
| 731 | kfree(ctl->cache); |
| 732 | err_ctl_name: |
| 733 | kfree(ctl->name); |
| 734 | err_ctl: |
| 735 | kfree(ctl); |
| 736 | |
| 737 | return ret; |
| 738 | } |
| 739 | |
Charles Keepax | 2323736 | 2015-04-13 13:28:02 +0100 | [diff] [blame] | 740 | struct wm_coeff_parsed_alg { |
| 741 | int id; |
| 742 | const u8 *name; |
| 743 | int name_len; |
| 744 | int ncoeff; |
| 745 | }; |
| 746 | |
| 747 | struct wm_coeff_parsed_coeff { |
| 748 | int offset; |
| 749 | int mem_type; |
| 750 | const u8 *name; |
| 751 | int name_len; |
| 752 | int ctl_type; |
| 753 | int flags; |
| 754 | int len; |
| 755 | }; |
| 756 | |
Charles Keepax | cb5b57a | 2015-04-13 13:28:04 +0100 | [diff] [blame] | 757 | static int wm_coeff_parse_string(int bytes, const u8 **pos, const u8 **str) |
| 758 | { |
| 759 | int length; |
| 760 | |
| 761 | switch (bytes) { |
| 762 | case 1: |
| 763 | length = **pos; |
| 764 | break; |
| 765 | case 2: |
Charles Keepax | 8299ee8 | 2015-04-20 13:52:44 +0100 | [diff] [blame] | 766 | length = le16_to_cpu(*((__le16 *)*pos)); |
Charles Keepax | cb5b57a | 2015-04-13 13:28:04 +0100 | [diff] [blame] | 767 | break; |
| 768 | default: |
| 769 | return 0; |
| 770 | } |
| 771 | |
| 772 | if (str) |
| 773 | *str = *pos + bytes; |
| 774 | |
| 775 | *pos += ((length + bytes) + 3) & ~0x03; |
| 776 | |
| 777 | return length; |
| 778 | } |
| 779 | |
| 780 | static int wm_coeff_parse_int(int bytes, const u8 **pos) |
| 781 | { |
| 782 | int val = 0; |
| 783 | |
| 784 | switch (bytes) { |
| 785 | case 2: |
Charles Keepax | 8299ee8 | 2015-04-20 13:52:44 +0100 | [diff] [blame] | 786 | val = le16_to_cpu(*((__le16 *)*pos)); |
Charles Keepax | cb5b57a | 2015-04-13 13:28:04 +0100 | [diff] [blame] | 787 | break; |
| 788 | case 4: |
Charles Keepax | 8299ee8 | 2015-04-20 13:52:44 +0100 | [diff] [blame] | 789 | val = le32_to_cpu(*((__le32 *)*pos)); |
Charles Keepax | cb5b57a | 2015-04-13 13:28:04 +0100 | [diff] [blame] | 790 | break; |
| 791 | default: |
| 792 | break; |
| 793 | } |
| 794 | |
| 795 | *pos += bytes; |
| 796 | |
| 797 | return val; |
| 798 | } |
| 799 | |
Charles Keepax | 2323736 | 2015-04-13 13:28:02 +0100 | [diff] [blame] | 800 | static inline void wm_coeff_parse_alg(struct wm_adsp *dsp, const u8 **data, |
| 801 | struct wm_coeff_parsed_alg *blk) |
| 802 | { |
| 803 | const struct wmfw_adsp_alg_data *raw; |
| 804 | |
Charles Keepax | cb5b57a | 2015-04-13 13:28:04 +0100 | [diff] [blame] | 805 | switch (dsp->fw_ver) { |
| 806 | case 0: |
| 807 | case 1: |
| 808 | raw = (const struct wmfw_adsp_alg_data *)*data; |
| 809 | *data = raw->data; |
Charles Keepax | 2323736 | 2015-04-13 13:28:02 +0100 | [diff] [blame] | 810 | |
Charles Keepax | cb5b57a | 2015-04-13 13:28:04 +0100 | [diff] [blame] | 811 | blk->id = le32_to_cpu(raw->id); |
| 812 | blk->name = raw->name; |
| 813 | blk->name_len = strlen(raw->name); |
| 814 | blk->ncoeff = le32_to_cpu(raw->ncoeff); |
| 815 | break; |
| 816 | default: |
| 817 | blk->id = wm_coeff_parse_int(sizeof(raw->id), data); |
| 818 | blk->name_len = wm_coeff_parse_string(sizeof(u8), data, |
| 819 | &blk->name); |
| 820 | wm_coeff_parse_string(sizeof(u16), data, NULL); |
| 821 | blk->ncoeff = wm_coeff_parse_int(sizeof(raw->ncoeff), data); |
| 822 | break; |
| 823 | } |
Charles Keepax | 2323736 | 2015-04-13 13:28:02 +0100 | [diff] [blame] | 824 | |
| 825 | adsp_dbg(dsp, "Algorithm ID: %#x\n", blk->id); |
| 826 | adsp_dbg(dsp, "Algorithm name: %.*s\n", blk->name_len, blk->name); |
| 827 | adsp_dbg(dsp, "# of coefficient descriptors: %#x\n", blk->ncoeff); |
| 828 | } |
| 829 | |
| 830 | static inline void wm_coeff_parse_coeff(struct wm_adsp *dsp, const u8 **data, |
| 831 | struct wm_coeff_parsed_coeff *blk) |
| 832 | { |
| 833 | const struct wmfw_adsp_coeff_data *raw; |
Charles Keepax | cb5b57a | 2015-04-13 13:28:04 +0100 | [diff] [blame] | 834 | const u8 *tmp; |
| 835 | int length; |
Charles Keepax | 2323736 | 2015-04-13 13:28:02 +0100 | [diff] [blame] | 836 | |
Charles Keepax | cb5b57a | 2015-04-13 13:28:04 +0100 | [diff] [blame] | 837 | switch (dsp->fw_ver) { |
| 838 | case 0: |
| 839 | case 1: |
| 840 | raw = (const struct wmfw_adsp_coeff_data *)*data; |
| 841 | *data = *data + sizeof(raw->hdr) + le32_to_cpu(raw->hdr.size); |
Charles Keepax | 2323736 | 2015-04-13 13:28:02 +0100 | [diff] [blame] | 842 | |
Charles Keepax | cb5b57a | 2015-04-13 13:28:04 +0100 | [diff] [blame] | 843 | blk->offset = le16_to_cpu(raw->hdr.offset); |
| 844 | blk->mem_type = le16_to_cpu(raw->hdr.type); |
| 845 | blk->name = raw->name; |
| 846 | blk->name_len = strlen(raw->name); |
| 847 | blk->ctl_type = le16_to_cpu(raw->ctl_type); |
| 848 | blk->flags = le16_to_cpu(raw->flags); |
| 849 | blk->len = le32_to_cpu(raw->len); |
| 850 | break; |
| 851 | default: |
| 852 | tmp = *data; |
| 853 | blk->offset = wm_coeff_parse_int(sizeof(raw->hdr.offset), &tmp); |
| 854 | blk->mem_type = wm_coeff_parse_int(sizeof(raw->hdr.type), &tmp); |
| 855 | length = wm_coeff_parse_int(sizeof(raw->hdr.size), &tmp); |
| 856 | blk->name_len = wm_coeff_parse_string(sizeof(u8), &tmp, |
| 857 | &blk->name); |
| 858 | wm_coeff_parse_string(sizeof(u8), &tmp, NULL); |
| 859 | wm_coeff_parse_string(sizeof(u16), &tmp, NULL); |
| 860 | blk->ctl_type = wm_coeff_parse_int(sizeof(raw->ctl_type), &tmp); |
| 861 | blk->flags = wm_coeff_parse_int(sizeof(raw->flags), &tmp); |
| 862 | blk->len = wm_coeff_parse_int(sizeof(raw->len), &tmp); |
| 863 | |
| 864 | *data = *data + sizeof(raw->hdr) + length; |
| 865 | break; |
| 866 | } |
Charles Keepax | 2323736 | 2015-04-13 13:28:02 +0100 | [diff] [blame] | 867 | |
| 868 | adsp_dbg(dsp, "\tCoefficient type: %#x\n", blk->mem_type); |
| 869 | adsp_dbg(dsp, "\tCoefficient offset: %#x\n", blk->offset); |
| 870 | adsp_dbg(dsp, "\tCoefficient name: %.*s\n", blk->name_len, blk->name); |
| 871 | adsp_dbg(dsp, "\tCoefficient flags: %#x\n", blk->flags); |
| 872 | adsp_dbg(dsp, "\tALSA control type: %#x\n", blk->ctl_type); |
| 873 | adsp_dbg(dsp, "\tALSA control len: %#x\n", blk->len); |
| 874 | } |
| 875 | |
| 876 | static int wm_adsp_parse_coeff(struct wm_adsp *dsp, |
| 877 | const struct wmfw_region *region) |
| 878 | { |
| 879 | struct wm_adsp_alg_region alg_region = {}; |
| 880 | struct wm_coeff_parsed_alg alg_blk; |
| 881 | struct wm_coeff_parsed_coeff coeff_blk; |
| 882 | const u8 *data = region->data; |
| 883 | int i, ret; |
| 884 | |
| 885 | wm_coeff_parse_alg(dsp, &data, &alg_blk); |
| 886 | for (i = 0; i < alg_blk.ncoeff; i++) { |
| 887 | wm_coeff_parse_coeff(dsp, &data, &coeff_blk); |
| 888 | |
| 889 | switch (coeff_blk.ctl_type) { |
| 890 | case SNDRV_CTL_ELEM_TYPE_BYTES: |
| 891 | break; |
| 892 | default: |
| 893 | adsp_err(dsp, "Unknown control type: %d\n", |
| 894 | coeff_blk.ctl_type); |
| 895 | return -EINVAL; |
| 896 | } |
| 897 | |
| 898 | alg_region.type = coeff_blk.mem_type; |
| 899 | alg_region.alg = alg_blk.id; |
| 900 | |
| 901 | ret = wm_adsp_create_control(dsp, &alg_region, |
| 902 | coeff_blk.offset, |
| 903 | coeff_blk.len, |
| 904 | coeff_blk.name, |
Charles Keepax | 26c22a1 | 2015-04-20 13:52:45 +0100 | [diff] [blame] | 905 | coeff_blk.name_len, |
| 906 | coeff_blk.flags); |
Charles Keepax | 2323736 | 2015-04-13 13:28:02 +0100 | [diff] [blame] | 907 | if (ret < 0) |
| 908 | adsp_err(dsp, "Failed to create control: %.*s, %d\n", |
| 909 | coeff_blk.name_len, coeff_blk.name, ret); |
| 910 | } |
| 911 | |
| 912 | return 0; |
| 913 | } |
| 914 | |
Mark Brown | 2159ad93 | 2012-10-11 11:54:02 +0900 | [diff] [blame] | 915 | static int wm_adsp_load(struct wm_adsp *dsp) |
| 916 | { |
Mark Brown | cf17c83 | 2013-01-30 14:37:23 +0800 | [diff] [blame] | 917 | LIST_HEAD(buf_list); |
Mark Brown | 2159ad93 | 2012-10-11 11:54:02 +0900 | [diff] [blame] | 918 | const struct firmware *firmware; |
| 919 | struct regmap *regmap = dsp->regmap; |
| 920 | unsigned int pos = 0; |
| 921 | const struct wmfw_header *header; |
| 922 | const struct wmfw_adsp1_sizes *adsp1_sizes; |
| 923 | const struct wmfw_adsp2_sizes *adsp2_sizes; |
| 924 | const struct wmfw_footer *footer; |
| 925 | const struct wmfw_region *region; |
| 926 | const struct wm_adsp_region *mem; |
| 927 | const char *region_name; |
| 928 | char *file, *text; |
Mark Brown | cf17c83 | 2013-01-30 14:37:23 +0800 | [diff] [blame] | 929 | struct wm_adsp_buf *buf; |
Mark Brown | 2159ad93 | 2012-10-11 11:54:02 +0900 | [diff] [blame] | 930 | unsigned int reg; |
| 931 | int regions = 0; |
| 932 | int ret, offset, type, sizes; |
| 933 | |
| 934 | file = kzalloc(PAGE_SIZE, GFP_KERNEL); |
| 935 | if (file == NULL) |
| 936 | return -ENOMEM; |
| 937 | |
Mark Brown | 1023dbd | 2013-01-11 22:58:28 +0000 | [diff] [blame] | 938 | snprintf(file, PAGE_SIZE, "%s-dsp%d-%s.wmfw", dsp->part, dsp->num, |
| 939 | wm_adsp_fw[dsp->fw].file); |
Mark Brown | 2159ad93 | 2012-10-11 11:54:02 +0900 | [diff] [blame] | 940 | file[PAGE_SIZE - 1] = '\0'; |
| 941 | |
| 942 | ret = request_firmware(&firmware, file, dsp->dev); |
| 943 | if (ret != 0) { |
| 944 | adsp_err(dsp, "Failed to request '%s'\n", file); |
| 945 | goto out; |
| 946 | } |
| 947 | ret = -EINVAL; |
| 948 | |
| 949 | pos = sizeof(*header) + sizeof(*adsp1_sizes) + sizeof(*footer); |
| 950 | if (pos >= firmware->size) { |
| 951 | adsp_err(dsp, "%s: file too short, %zu bytes\n", |
| 952 | file, firmware->size); |
| 953 | goto out_fw; |
| 954 | } |
| 955 | |
| 956 | header = (void*)&firmware->data[0]; |
| 957 | |
| 958 | if (memcmp(&header->magic[0], "WMFW", 4) != 0) { |
| 959 | adsp_err(dsp, "%s: invalid magic\n", file); |
| 960 | goto out_fw; |
| 961 | } |
| 962 | |
Charles Keepax | 2323736 | 2015-04-13 13:28:02 +0100 | [diff] [blame] | 963 | switch (header->ver) { |
| 964 | case 0: |
Charles Keepax | c61e59f | 2015-04-13 13:28:05 +0100 | [diff] [blame] | 965 | adsp_warn(dsp, "%s: Depreciated file format %d\n", |
| 966 | file, header->ver); |
| 967 | break; |
Charles Keepax | 2323736 | 2015-04-13 13:28:02 +0100 | [diff] [blame] | 968 | case 1: |
Charles Keepax | cb5b57a | 2015-04-13 13:28:04 +0100 | [diff] [blame] | 969 | case 2: |
Charles Keepax | 2323736 | 2015-04-13 13:28:02 +0100 | [diff] [blame] | 970 | break; |
| 971 | default: |
Mark Brown | 2159ad93 | 2012-10-11 11:54:02 +0900 | [diff] [blame] | 972 | adsp_err(dsp, "%s: unknown file format %d\n", |
| 973 | file, header->ver); |
| 974 | goto out_fw; |
| 975 | } |
Charles Keepax | 2323736 | 2015-04-13 13:28:02 +0100 | [diff] [blame] | 976 | |
Dimitris Papastamos | 3626992 | 2013-11-01 15:56:57 +0000 | [diff] [blame] | 977 | adsp_info(dsp, "Firmware version: %d\n", header->ver); |
Charles Keepax | 2323736 | 2015-04-13 13:28:02 +0100 | [diff] [blame] | 978 | dsp->fw_ver = header->ver; |
Mark Brown | 2159ad93 | 2012-10-11 11:54:02 +0900 | [diff] [blame] | 979 | |
| 980 | if (header->core != dsp->type) { |
| 981 | adsp_err(dsp, "%s: invalid core %d != %d\n", |
| 982 | file, header->core, dsp->type); |
| 983 | goto out_fw; |
| 984 | } |
| 985 | |
| 986 | switch (dsp->type) { |
| 987 | case WMFW_ADSP1: |
| 988 | pos = sizeof(*header) + sizeof(*adsp1_sizes) + sizeof(*footer); |
| 989 | adsp1_sizes = (void *)&(header[1]); |
| 990 | footer = (void *)&(adsp1_sizes[1]); |
| 991 | sizes = sizeof(*adsp1_sizes); |
| 992 | |
| 993 | adsp_dbg(dsp, "%s: %d DM, %d PM, %d ZM\n", |
| 994 | file, le32_to_cpu(adsp1_sizes->dm), |
| 995 | le32_to_cpu(adsp1_sizes->pm), |
| 996 | le32_to_cpu(adsp1_sizes->zm)); |
| 997 | break; |
| 998 | |
| 999 | case WMFW_ADSP2: |
| 1000 | pos = sizeof(*header) + sizeof(*adsp2_sizes) + sizeof(*footer); |
| 1001 | adsp2_sizes = (void *)&(header[1]); |
| 1002 | footer = (void *)&(adsp2_sizes[1]); |
| 1003 | sizes = sizeof(*adsp2_sizes); |
| 1004 | |
| 1005 | adsp_dbg(dsp, "%s: %d XM, %d YM %d PM, %d ZM\n", |
| 1006 | file, le32_to_cpu(adsp2_sizes->xm), |
| 1007 | le32_to_cpu(adsp2_sizes->ym), |
| 1008 | le32_to_cpu(adsp2_sizes->pm), |
| 1009 | le32_to_cpu(adsp2_sizes->zm)); |
| 1010 | break; |
| 1011 | |
| 1012 | default: |
Takashi Iwai | 6c452bd | 2013-11-05 18:40:00 +0100 | [diff] [blame] | 1013 | WARN(1, "Unknown DSP type"); |
Mark Brown | 2159ad93 | 2012-10-11 11:54:02 +0900 | [diff] [blame] | 1014 | goto out_fw; |
| 1015 | } |
| 1016 | |
| 1017 | if (le32_to_cpu(header->len) != sizeof(*header) + |
| 1018 | sizes + sizeof(*footer)) { |
| 1019 | adsp_err(dsp, "%s: unexpected header length %d\n", |
| 1020 | file, le32_to_cpu(header->len)); |
| 1021 | goto out_fw; |
| 1022 | } |
| 1023 | |
| 1024 | adsp_dbg(dsp, "%s: timestamp %llu\n", file, |
| 1025 | le64_to_cpu(footer->timestamp)); |
| 1026 | |
| 1027 | while (pos < firmware->size && |
| 1028 | pos - firmware->size > sizeof(*region)) { |
| 1029 | region = (void *)&(firmware->data[pos]); |
| 1030 | region_name = "Unknown"; |
| 1031 | reg = 0; |
| 1032 | text = NULL; |
| 1033 | offset = le32_to_cpu(region->offset) & 0xffffff; |
| 1034 | type = be32_to_cpu(region->type) & 0xff; |
| 1035 | mem = wm_adsp_find_region(dsp, type); |
| 1036 | |
| 1037 | switch (type) { |
| 1038 | case WMFW_NAME_TEXT: |
| 1039 | region_name = "Firmware name"; |
| 1040 | text = kzalloc(le32_to_cpu(region->len) + 1, |
| 1041 | GFP_KERNEL); |
| 1042 | break; |
Charles Keepax | 2323736 | 2015-04-13 13:28:02 +0100 | [diff] [blame] | 1043 | case WMFW_ALGORITHM_DATA: |
| 1044 | region_name = "Algorithm"; |
| 1045 | ret = wm_adsp_parse_coeff(dsp, region); |
| 1046 | if (ret != 0) |
| 1047 | goto out_fw; |
| 1048 | break; |
Mark Brown | 2159ad93 | 2012-10-11 11:54:02 +0900 | [diff] [blame] | 1049 | case WMFW_INFO_TEXT: |
| 1050 | region_name = "Information"; |
| 1051 | text = kzalloc(le32_to_cpu(region->len) + 1, |
| 1052 | GFP_KERNEL); |
| 1053 | break; |
| 1054 | case WMFW_ABSOLUTE: |
| 1055 | region_name = "Absolute"; |
| 1056 | reg = offset; |
| 1057 | break; |
| 1058 | case WMFW_ADSP1_PM: |
Mark Brown | 2159ad93 | 2012-10-11 11:54:02 +0900 | [diff] [blame] | 1059 | region_name = "PM"; |
Mark Brown | 45b9ee7 | 2013-01-08 16:02:06 +0000 | [diff] [blame] | 1060 | reg = wm_adsp_region_to_reg(mem, offset); |
Mark Brown | 2159ad93 | 2012-10-11 11:54:02 +0900 | [diff] [blame] | 1061 | break; |
| 1062 | case WMFW_ADSP1_DM: |
Mark Brown | 2159ad93 | 2012-10-11 11:54:02 +0900 | [diff] [blame] | 1063 | region_name = "DM"; |
Mark Brown | 45b9ee7 | 2013-01-08 16:02:06 +0000 | [diff] [blame] | 1064 | reg = wm_adsp_region_to_reg(mem, offset); |
Mark Brown | 2159ad93 | 2012-10-11 11:54:02 +0900 | [diff] [blame] | 1065 | break; |
| 1066 | case WMFW_ADSP2_XM: |
Mark Brown | 2159ad93 | 2012-10-11 11:54:02 +0900 | [diff] [blame] | 1067 | region_name = "XM"; |
Mark Brown | 45b9ee7 | 2013-01-08 16:02:06 +0000 | [diff] [blame] | 1068 | reg = wm_adsp_region_to_reg(mem, offset); |
Mark Brown | 2159ad93 | 2012-10-11 11:54:02 +0900 | [diff] [blame] | 1069 | break; |
| 1070 | case WMFW_ADSP2_YM: |
Mark Brown | 2159ad93 | 2012-10-11 11:54:02 +0900 | [diff] [blame] | 1071 | region_name = "YM"; |
Mark Brown | 45b9ee7 | 2013-01-08 16:02:06 +0000 | [diff] [blame] | 1072 | reg = wm_adsp_region_to_reg(mem, offset); |
Mark Brown | 2159ad93 | 2012-10-11 11:54:02 +0900 | [diff] [blame] | 1073 | break; |
| 1074 | case WMFW_ADSP1_ZM: |
Mark Brown | 2159ad93 | 2012-10-11 11:54:02 +0900 | [diff] [blame] | 1075 | region_name = "ZM"; |
Mark Brown | 45b9ee7 | 2013-01-08 16:02:06 +0000 | [diff] [blame] | 1076 | reg = wm_adsp_region_to_reg(mem, offset); |
Mark Brown | 2159ad93 | 2012-10-11 11:54:02 +0900 | [diff] [blame] | 1077 | break; |
| 1078 | default: |
| 1079 | adsp_warn(dsp, |
| 1080 | "%s.%d: Unknown region type %x at %d(%x)\n", |
| 1081 | file, regions, type, pos, pos); |
| 1082 | break; |
| 1083 | } |
| 1084 | |
| 1085 | adsp_dbg(dsp, "%s.%d: %d bytes at %d in %s\n", file, |
| 1086 | regions, le32_to_cpu(region->len), offset, |
| 1087 | region_name); |
| 1088 | |
| 1089 | if (text) { |
| 1090 | memcpy(text, region->data, le32_to_cpu(region->len)); |
| 1091 | adsp_info(dsp, "%s: %s\n", file, text); |
| 1092 | kfree(text); |
| 1093 | } |
| 1094 | |
| 1095 | if (reg) { |
Charles Keepax | cdcd7f7 | 2014-11-14 15:40:45 +0000 | [diff] [blame] | 1096 | buf = wm_adsp_buf_alloc(region->data, |
| 1097 | le32_to_cpu(region->len), |
| 1098 | &buf_list); |
| 1099 | if (!buf) { |
| 1100 | adsp_err(dsp, "Out of memory\n"); |
| 1101 | ret = -ENOMEM; |
| 1102 | goto out_fw; |
| 1103 | } |
Mark Brown | a76fefa | 2013-01-07 19:03:17 +0000 | [diff] [blame] | 1104 | |
Charles Keepax | cdcd7f7 | 2014-11-14 15:40:45 +0000 | [diff] [blame] | 1105 | ret = regmap_raw_write_async(regmap, reg, buf->buf, |
| 1106 | le32_to_cpu(region->len)); |
| 1107 | if (ret != 0) { |
| 1108 | adsp_err(dsp, |
| 1109 | "%s.%d: Failed to write %d bytes at %d in %s: %d\n", |
| 1110 | file, regions, |
| 1111 | le32_to_cpu(region->len), offset, |
| 1112 | region_name, ret); |
| 1113 | goto out_fw; |
Mark Brown | 2159ad93 | 2012-10-11 11:54:02 +0900 | [diff] [blame] | 1114 | } |
| 1115 | } |
| 1116 | |
| 1117 | pos += le32_to_cpu(region->len) + sizeof(*region); |
| 1118 | regions++; |
| 1119 | } |
Mark Brown | cf17c83 | 2013-01-30 14:37:23 +0800 | [diff] [blame] | 1120 | |
| 1121 | ret = regmap_async_complete(regmap); |
| 1122 | if (ret != 0) { |
| 1123 | adsp_err(dsp, "Failed to complete async write: %d\n", ret); |
| 1124 | goto out_fw; |
| 1125 | } |
| 1126 | |
Mark Brown | 2159ad93 | 2012-10-11 11:54:02 +0900 | [diff] [blame] | 1127 | if (pos > firmware->size) |
| 1128 | adsp_warn(dsp, "%s.%d: %zu bytes at end of file\n", |
| 1129 | file, regions, pos - firmware->size); |
| 1130 | |
| 1131 | out_fw: |
Mark Brown | cf17c83 | 2013-01-30 14:37:23 +0800 | [diff] [blame] | 1132 | regmap_async_complete(regmap); |
| 1133 | wm_adsp_buf_free(&buf_list); |
Mark Brown | 2159ad93 | 2012-10-11 11:54:02 +0900 | [diff] [blame] | 1134 | release_firmware(firmware); |
| 1135 | out: |
| 1136 | kfree(file); |
| 1137 | |
| 1138 | return ret; |
| 1139 | } |
| 1140 | |
Charles Keepax | 2323736 | 2015-04-13 13:28:02 +0100 | [diff] [blame] | 1141 | static void wm_adsp_ctl_fixup_base(struct wm_adsp *dsp, |
| 1142 | const struct wm_adsp_alg_region *alg_region) |
| 1143 | { |
| 1144 | struct wm_coeff_ctl *ctl; |
| 1145 | |
| 1146 | list_for_each_entry(ctl, &dsp->ctl_list, list) { |
| 1147 | if (ctl->fw_name == wm_adsp_fw_text[dsp->fw] && |
| 1148 | alg_region->alg == ctl->alg_region.alg && |
| 1149 | alg_region->type == ctl->alg_region.type) { |
| 1150 | ctl->alg_region.base = alg_region->base; |
| 1151 | } |
| 1152 | } |
| 1153 | } |
| 1154 | |
Charles Keepax | 3809f00 | 2015-04-13 13:27:54 +0100 | [diff] [blame] | 1155 | static void *wm_adsp_read_algs(struct wm_adsp *dsp, size_t n_algs, |
Charles Keepax | b618a185 | 2015-04-13 13:27:53 +0100 | [diff] [blame] | 1156 | unsigned int pos, unsigned int len) |
Mark Brown | db40517 | 2012-10-26 19:30:40 +0100 | [diff] [blame] | 1157 | { |
Charles Keepax | b618a185 | 2015-04-13 13:27:53 +0100 | [diff] [blame] | 1158 | void *alg; |
| 1159 | int ret; |
Mark Brown | db40517 | 2012-10-26 19:30:40 +0100 | [diff] [blame] | 1160 | __be32 val; |
Mark Brown | db40517 | 2012-10-26 19:30:40 +0100 | [diff] [blame] | 1161 | |
Charles Keepax | 3809f00 | 2015-04-13 13:27:54 +0100 | [diff] [blame] | 1162 | if (n_algs == 0) { |
Mark Brown | db40517 | 2012-10-26 19:30:40 +0100 | [diff] [blame] | 1163 | adsp_err(dsp, "No algorithms\n"); |
Charles Keepax | b618a185 | 2015-04-13 13:27:53 +0100 | [diff] [blame] | 1164 | return ERR_PTR(-EINVAL); |
Mark Brown | db40517 | 2012-10-26 19:30:40 +0100 | [diff] [blame] | 1165 | } |
| 1166 | |
Charles Keepax | 3809f00 | 2015-04-13 13:27:54 +0100 | [diff] [blame] | 1167 | if (n_algs > 1024) { |
| 1168 | adsp_err(dsp, "Algorithm count %zx excessive\n", n_algs); |
Charles Keepax | b618a185 | 2015-04-13 13:27:53 +0100 | [diff] [blame] | 1169 | return ERR_PTR(-EINVAL); |
Mark Brown | d62f4bc | 2012-12-19 14:00:30 +0000 | [diff] [blame] | 1170 | } |
| 1171 | |
Mark Brown | db40517 | 2012-10-26 19:30:40 +0100 | [diff] [blame] | 1172 | /* Read the terminator first to validate the length */ |
Charles Keepax | b618a185 | 2015-04-13 13:27:53 +0100 | [diff] [blame] | 1173 | ret = regmap_raw_read(dsp->regmap, pos + len, &val, sizeof(val)); |
Mark Brown | db40517 | 2012-10-26 19:30:40 +0100 | [diff] [blame] | 1174 | if (ret != 0) { |
| 1175 | adsp_err(dsp, "Failed to read algorithm list end: %d\n", |
| 1176 | ret); |
Charles Keepax | b618a185 | 2015-04-13 13:27:53 +0100 | [diff] [blame] | 1177 | return ERR_PTR(ret); |
Mark Brown | db40517 | 2012-10-26 19:30:40 +0100 | [diff] [blame] | 1178 | } |
| 1179 | |
| 1180 | if (be32_to_cpu(val) != 0xbedead) |
| 1181 | adsp_warn(dsp, "Algorithm list end %x 0x%x != 0xbeadead\n", |
Charles Keepax | b618a185 | 2015-04-13 13:27:53 +0100 | [diff] [blame] | 1182 | pos + len, be32_to_cpu(val)); |
Mark Brown | db40517 | 2012-10-26 19:30:40 +0100 | [diff] [blame] | 1183 | |
Charles Keepax | b618a185 | 2015-04-13 13:27:53 +0100 | [diff] [blame] | 1184 | alg = kzalloc(len * 2, GFP_KERNEL | GFP_DMA); |
Mark Brown | db40517 | 2012-10-26 19:30:40 +0100 | [diff] [blame] | 1185 | if (!alg) |
Charles Keepax | b618a185 | 2015-04-13 13:27:53 +0100 | [diff] [blame] | 1186 | return ERR_PTR(-ENOMEM); |
Mark Brown | db40517 | 2012-10-26 19:30:40 +0100 | [diff] [blame] | 1187 | |
Charles Keepax | b618a185 | 2015-04-13 13:27:53 +0100 | [diff] [blame] | 1188 | ret = regmap_raw_read(dsp->regmap, pos, alg, len * 2); |
Mark Brown | db40517 | 2012-10-26 19:30:40 +0100 | [diff] [blame] | 1189 | if (ret != 0) { |
| 1190 | adsp_err(dsp, "Failed to read algorithm list: %d\n", |
| 1191 | ret); |
Charles Keepax | b618a185 | 2015-04-13 13:27:53 +0100 | [diff] [blame] | 1192 | kfree(alg); |
| 1193 | return ERR_PTR(ret); |
Mark Brown | db40517 | 2012-10-26 19:30:40 +0100 | [diff] [blame] | 1194 | } |
| 1195 | |
Charles Keepax | b618a185 | 2015-04-13 13:27:53 +0100 | [diff] [blame] | 1196 | return alg; |
| 1197 | } |
| 1198 | |
Charles Keepax | d9d20e1 | 2015-04-13 13:27:59 +0100 | [diff] [blame] | 1199 | static struct wm_adsp_alg_region *wm_adsp_create_region(struct wm_adsp *dsp, |
| 1200 | int type, __be32 id, |
| 1201 | __be32 base) |
| 1202 | { |
| 1203 | struct wm_adsp_alg_region *alg_region; |
| 1204 | |
| 1205 | alg_region = kzalloc(sizeof(*alg_region), GFP_KERNEL); |
| 1206 | if (!alg_region) |
| 1207 | return ERR_PTR(-ENOMEM); |
| 1208 | |
| 1209 | alg_region->type = type; |
| 1210 | alg_region->alg = be32_to_cpu(id); |
| 1211 | alg_region->base = be32_to_cpu(base); |
| 1212 | |
| 1213 | list_add_tail(&alg_region->list, &dsp->alg_regions); |
| 1214 | |
Charles Keepax | 2323736 | 2015-04-13 13:28:02 +0100 | [diff] [blame] | 1215 | if (dsp->fw_ver > 0) |
| 1216 | wm_adsp_ctl_fixup_base(dsp, alg_region); |
| 1217 | |
Charles Keepax | d9d20e1 | 2015-04-13 13:27:59 +0100 | [diff] [blame] | 1218 | return alg_region; |
| 1219 | } |
| 1220 | |
Charles Keepax | b618a185 | 2015-04-13 13:27:53 +0100 | [diff] [blame] | 1221 | static int wm_adsp1_setup_algs(struct wm_adsp *dsp) |
| 1222 | { |
| 1223 | struct wmfw_adsp1_id_hdr adsp1_id; |
| 1224 | struct wmfw_adsp1_alg_hdr *adsp1_alg; |
Charles Keepax | 3809f00 | 2015-04-13 13:27:54 +0100 | [diff] [blame] | 1225 | struct wm_adsp_alg_region *alg_region; |
Charles Keepax | b618a185 | 2015-04-13 13:27:53 +0100 | [diff] [blame] | 1226 | const struct wm_adsp_region *mem; |
| 1227 | unsigned int pos, len; |
Charles Keepax | 3809f00 | 2015-04-13 13:27:54 +0100 | [diff] [blame] | 1228 | size_t n_algs; |
Charles Keepax | b618a185 | 2015-04-13 13:27:53 +0100 | [diff] [blame] | 1229 | int i, ret; |
| 1230 | |
| 1231 | mem = wm_adsp_find_region(dsp, WMFW_ADSP1_DM); |
| 1232 | if (WARN_ON(!mem)) |
| 1233 | return -EINVAL; |
| 1234 | |
| 1235 | ret = regmap_raw_read(dsp->regmap, mem->base, &adsp1_id, |
| 1236 | sizeof(adsp1_id)); |
| 1237 | if (ret != 0) { |
| 1238 | adsp_err(dsp, "Failed to read algorithm info: %d\n", |
| 1239 | ret); |
| 1240 | return ret; |
| 1241 | } |
| 1242 | |
Charles Keepax | 3809f00 | 2015-04-13 13:27:54 +0100 | [diff] [blame] | 1243 | n_algs = be32_to_cpu(adsp1_id.n_algs); |
Charles Keepax | b618a185 | 2015-04-13 13:27:53 +0100 | [diff] [blame] | 1244 | dsp->fw_id = be32_to_cpu(adsp1_id.fw.id); |
| 1245 | adsp_info(dsp, "Firmware: %x v%d.%d.%d, %zu algorithms\n", |
| 1246 | dsp->fw_id, |
| 1247 | (be32_to_cpu(adsp1_id.fw.ver) & 0xff0000) >> 16, |
| 1248 | (be32_to_cpu(adsp1_id.fw.ver) & 0xff00) >> 8, |
| 1249 | be32_to_cpu(adsp1_id.fw.ver) & 0xff, |
Charles Keepax | 3809f00 | 2015-04-13 13:27:54 +0100 | [diff] [blame] | 1250 | n_algs); |
Charles Keepax | b618a185 | 2015-04-13 13:27:53 +0100 | [diff] [blame] | 1251 | |
Charles Keepax | d9d20e1 | 2015-04-13 13:27:59 +0100 | [diff] [blame] | 1252 | alg_region = wm_adsp_create_region(dsp, WMFW_ADSP1_ZM, |
| 1253 | adsp1_id.fw.id, adsp1_id.zm); |
| 1254 | if (IS_ERR(alg_region)) |
| 1255 | return PTR_ERR(alg_region); |
Charles Keepax | b618a185 | 2015-04-13 13:27:53 +0100 | [diff] [blame] | 1256 | |
Charles Keepax | d9d20e1 | 2015-04-13 13:27:59 +0100 | [diff] [blame] | 1257 | alg_region = wm_adsp_create_region(dsp, WMFW_ADSP1_DM, |
| 1258 | adsp1_id.fw.id, adsp1_id.dm); |
| 1259 | if (IS_ERR(alg_region)) |
| 1260 | return PTR_ERR(alg_region); |
Charles Keepax | b618a185 | 2015-04-13 13:27:53 +0100 | [diff] [blame] | 1261 | |
| 1262 | pos = sizeof(adsp1_id) / 2; |
Charles Keepax | 3809f00 | 2015-04-13 13:27:54 +0100 | [diff] [blame] | 1263 | len = (sizeof(*adsp1_alg) * n_algs) / 2; |
Charles Keepax | b618a185 | 2015-04-13 13:27:53 +0100 | [diff] [blame] | 1264 | |
Charles Keepax | 3809f00 | 2015-04-13 13:27:54 +0100 | [diff] [blame] | 1265 | adsp1_alg = wm_adsp_read_algs(dsp, n_algs, mem->base + pos, len); |
Charles Keepax | b618a185 | 2015-04-13 13:27:53 +0100 | [diff] [blame] | 1266 | if (IS_ERR(adsp1_alg)) |
| 1267 | return PTR_ERR(adsp1_alg); |
Mark Brown | db40517 | 2012-10-26 19:30:40 +0100 | [diff] [blame] | 1268 | |
Charles Keepax | 3809f00 | 2015-04-13 13:27:54 +0100 | [diff] [blame] | 1269 | for (i = 0; i < n_algs; i++) { |
Charles Keepax | b618a185 | 2015-04-13 13:27:53 +0100 | [diff] [blame] | 1270 | adsp_info(dsp, "%d: ID %x v%d.%d.%d DM@%x ZM@%x\n", |
| 1271 | i, be32_to_cpu(adsp1_alg[i].alg.id), |
| 1272 | (be32_to_cpu(adsp1_alg[i].alg.ver) & 0xff0000) >> 16, |
| 1273 | (be32_to_cpu(adsp1_alg[i].alg.ver) & 0xff00) >> 8, |
| 1274 | be32_to_cpu(adsp1_alg[i].alg.ver) & 0xff, |
| 1275 | be32_to_cpu(adsp1_alg[i].dm), |
| 1276 | be32_to_cpu(adsp1_alg[i].zm)); |
Mark Brown | 471f488 | 2013-01-08 16:09:31 +0000 | [diff] [blame] | 1277 | |
Charles Keepax | d9d20e1 | 2015-04-13 13:27:59 +0100 | [diff] [blame] | 1278 | alg_region = wm_adsp_create_region(dsp, WMFW_ADSP1_DM, |
| 1279 | adsp1_alg[i].alg.id, |
| 1280 | adsp1_alg[i].dm); |
| 1281 | if (IS_ERR(alg_region)) { |
| 1282 | ret = PTR_ERR(alg_region); |
Charles Keepax | b618a185 | 2015-04-13 13:27:53 +0100 | [diff] [blame] | 1283 | goto out; |
| 1284 | } |
Charles Keepax | 2323736 | 2015-04-13 13:28:02 +0100 | [diff] [blame] | 1285 | if (dsp->fw_ver == 0) { |
| 1286 | if (i + 1 < n_algs) { |
| 1287 | len = be32_to_cpu(adsp1_alg[i + 1].dm); |
| 1288 | len -= be32_to_cpu(adsp1_alg[i].dm); |
| 1289 | len *= 4; |
| 1290 | wm_adsp_create_control(dsp, alg_region, 0, |
Charles Keepax | 26c22a1 | 2015-04-20 13:52:45 +0100 | [diff] [blame] | 1291 | len, NULL, 0, 0); |
Charles Keepax | 2323736 | 2015-04-13 13:28:02 +0100 | [diff] [blame] | 1292 | } else { |
| 1293 | adsp_warn(dsp, "Missing length info for region DM with ID %x\n", |
| 1294 | be32_to_cpu(adsp1_alg[i].alg.id)); |
| 1295 | } |
Charles Keepax | b618a185 | 2015-04-13 13:27:53 +0100 | [diff] [blame] | 1296 | } |
Mark Brown | 471f488 | 2013-01-08 16:09:31 +0000 | [diff] [blame] | 1297 | |
Charles Keepax | d9d20e1 | 2015-04-13 13:27:59 +0100 | [diff] [blame] | 1298 | alg_region = wm_adsp_create_region(dsp, WMFW_ADSP1_ZM, |
| 1299 | adsp1_alg[i].alg.id, |
| 1300 | adsp1_alg[i].zm); |
| 1301 | if (IS_ERR(alg_region)) { |
| 1302 | ret = PTR_ERR(alg_region); |
Charles Keepax | b618a185 | 2015-04-13 13:27:53 +0100 | [diff] [blame] | 1303 | goto out; |
| 1304 | } |
Charles Keepax | 2323736 | 2015-04-13 13:28:02 +0100 | [diff] [blame] | 1305 | if (dsp->fw_ver == 0) { |
| 1306 | if (i + 1 < n_algs) { |
| 1307 | len = be32_to_cpu(adsp1_alg[i + 1].zm); |
| 1308 | len -= be32_to_cpu(adsp1_alg[i].zm); |
| 1309 | len *= 4; |
| 1310 | wm_adsp_create_control(dsp, alg_region, 0, |
Charles Keepax | 26c22a1 | 2015-04-20 13:52:45 +0100 | [diff] [blame] | 1311 | len, NULL, 0, 0); |
Charles Keepax | 2323736 | 2015-04-13 13:28:02 +0100 | [diff] [blame] | 1312 | } else { |
| 1313 | adsp_warn(dsp, "Missing length info for region ZM with ID %x\n", |
| 1314 | be32_to_cpu(adsp1_alg[i].alg.id)); |
| 1315 | } |
Mark Brown | db40517 | 2012-10-26 19:30:40 +0100 | [diff] [blame] | 1316 | } |
| 1317 | } |
| 1318 | |
| 1319 | out: |
Charles Keepax | b618a185 | 2015-04-13 13:27:53 +0100 | [diff] [blame] | 1320 | kfree(adsp1_alg); |
| 1321 | return ret; |
| 1322 | } |
| 1323 | |
| 1324 | static int wm_adsp2_setup_algs(struct wm_adsp *dsp) |
| 1325 | { |
| 1326 | struct wmfw_adsp2_id_hdr adsp2_id; |
| 1327 | struct wmfw_adsp2_alg_hdr *adsp2_alg; |
Charles Keepax | 3809f00 | 2015-04-13 13:27:54 +0100 | [diff] [blame] | 1328 | struct wm_adsp_alg_region *alg_region; |
Charles Keepax | b618a185 | 2015-04-13 13:27:53 +0100 | [diff] [blame] | 1329 | const struct wm_adsp_region *mem; |
| 1330 | unsigned int pos, len; |
Charles Keepax | 3809f00 | 2015-04-13 13:27:54 +0100 | [diff] [blame] | 1331 | size_t n_algs; |
Charles Keepax | b618a185 | 2015-04-13 13:27:53 +0100 | [diff] [blame] | 1332 | int i, ret; |
| 1333 | |
| 1334 | mem = wm_adsp_find_region(dsp, WMFW_ADSP2_XM); |
| 1335 | if (WARN_ON(!mem)) |
| 1336 | return -EINVAL; |
| 1337 | |
| 1338 | ret = regmap_raw_read(dsp->regmap, mem->base, &adsp2_id, |
| 1339 | sizeof(adsp2_id)); |
| 1340 | if (ret != 0) { |
| 1341 | adsp_err(dsp, "Failed to read algorithm info: %d\n", |
| 1342 | ret); |
| 1343 | return ret; |
| 1344 | } |
| 1345 | |
Charles Keepax | 3809f00 | 2015-04-13 13:27:54 +0100 | [diff] [blame] | 1346 | n_algs = be32_to_cpu(adsp2_id.n_algs); |
Charles Keepax | b618a185 | 2015-04-13 13:27:53 +0100 | [diff] [blame] | 1347 | dsp->fw_id = be32_to_cpu(adsp2_id.fw.id); |
| 1348 | adsp_info(dsp, "Firmware: %x v%d.%d.%d, %zu algorithms\n", |
| 1349 | dsp->fw_id, |
| 1350 | (be32_to_cpu(adsp2_id.fw.ver) & 0xff0000) >> 16, |
| 1351 | (be32_to_cpu(adsp2_id.fw.ver) & 0xff00) >> 8, |
| 1352 | be32_to_cpu(adsp2_id.fw.ver) & 0xff, |
Charles Keepax | 3809f00 | 2015-04-13 13:27:54 +0100 | [diff] [blame] | 1353 | n_algs); |
Charles Keepax | b618a185 | 2015-04-13 13:27:53 +0100 | [diff] [blame] | 1354 | |
Charles Keepax | d9d20e1 | 2015-04-13 13:27:59 +0100 | [diff] [blame] | 1355 | alg_region = wm_adsp_create_region(dsp, WMFW_ADSP2_XM, |
| 1356 | adsp2_id.fw.id, adsp2_id.xm); |
| 1357 | if (IS_ERR(alg_region)) |
| 1358 | return PTR_ERR(alg_region); |
Charles Keepax | b618a185 | 2015-04-13 13:27:53 +0100 | [diff] [blame] | 1359 | |
Charles Keepax | d9d20e1 | 2015-04-13 13:27:59 +0100 | [diff] [blame] | 1360 | alg_region = wm_adsp_create_region(dsp, WMFW_ADSP2_YM, |
| 1361 | adsp2_id.fw.id, adsp2_id.ym); |
| 1362 | if (IS_ERR(alg_region)) |
| 1363 | return PTR_ERR(alg_region); |
Charles Keepax | b618a185 | 2015-04-13 13:27:53 +0100 | [diff] [blame] | 1364 | |
Charles Keepax | d9d20e1 | 2015-04-13 13:27:59 +0100 | [diff] [blame] | 1365 | alg_region = wm_adsp_create_region(dsp, WMFW_ADSP2_ZM, |
| 1366 | adsp2_id.fw.id, adsp2_id.zm); |
| 1367 | if (IS_ERR(alg_region)) |
| 1368 | return PTR_ERR(alg_region); |
Charles Keepax | b618a185 | 2015-04-13 13:27:53 +0100 | [diff] [blame] | 1369 | |
| 1370 | pos = sizeof(adsp2_id) / 2; |
Charles Keepax | 3809f00 | 2015-04-13 13:27:54 +0100 | [diff] [blame] | 1371 | len = (sizeof(*adsp2_alg) * n_algs) / 2; |
Charles Keepax | b618a185 | 2015-04-13 13:27:53 +0100 | [diff] [blame] | 1372 | |
Charles Keepax | 3809f00 | 2015-04-13 13:27:54 +0100 | [diff] [blame] | 1373 | adsp2_alg = wm_adsp_read_algs(dsp, n_algs, mem->base + pos, len); |
Charles Keepax | b618a185 | 2015-04-13 13:27:53 +0100 | [diff] [blame] | 1374 | if (IS_ERR(adsp2_alg)) |
| 1375 | return PTR_ERR(adsp2_alg); |
| 1376 | |
Charles Keepax | 3809f00 | 2015-04-13 13:27:54 +0100 | [diff] [blame] | 1377 | for (i = 0; i < n_algs; i++) { |
Charles Keepax | b618a185 | 2015-04-13 13:27:53 +0100 | [diff] [blame] | 1378 | adsp_info(dsp, |
| 1379 | "%d: ID %x v%d.%d.%d XM@%x YM@%x ZM@%x\n", |
| 1380 | i, be32_to_cpu(adsp2_alg[i].alg.id), |
| 1381 | (be32_to_cpu(adsp2_alg[i].alg.ver) & 0xff0000) >> 16, |
| 1382 | (be32_to_cpu(adsp2_alg[i].alg.ver) & 0xff00) >> 8, |
| 1383 | be32_to_cpu(adsp2_alg[i].alg.ver) & 0xff, |
| 1384 | be32_to_cpu(adsp2_alg[i].xm), |
| 1385 | be32_to_cpu(adsp2_alg[i].ym), |
| 1386 | be32_to_cpu(adsp2_alg[i].zm)); |
| 1387 | |
Charles Keepax | d9d20e1 | 2015-04-13 13:27:59 +0100 | [diff] [blame] | 1388 | alg_region = wm_adsp_create_region(dsp, WMFW_ADSP2_XM, |
| 1389 | adsp2_alg[i].alg.id, |
| 1390 | adsp2_alg[i].xm); |
| 1391 | if (IS_ERR(alg_region)) { |
| 1392 | ret = PTR_ERR(alg_region); |
Charles Keepax | b618a185 | 2015-04-13 13:27:53 +0100 | [diff] [blame] | 1393 | goto out; |
| 1394 | } |
Charles Keepax | 2323736 | 2015-04-13 13:28:02 +0100 | [diff] [blame] | 1395 | if (dsp->fw_ver == 0) { |
| 1396 | if (i + 1 < n_algs) { |
| 1397 | len = be32_to_cpu(adsp2_alg[i + 1].xm); |
| 1398 | len -= be32_to_cpu(adsp2_alg[i].xm); |
| 1399 | len *= 4; |
| 1400 | wm_adsp_create_control(dsp, alg_region, 0, |
Charles Keepax | 26c22a1 | 2015-04-20 13:52:45 +0100 | [diff] [blame] | 1401 | len, NULL, 0, 0); |
Charles Keepax | 2323736 | 2015-04-13 13:28:02 +0100 | [diff] [blame] | 1402 | } else { |
| 1403 | adsp_warn(dsp, "Missing length info for region XM with ID %x\n", |
| 1404 | be32_to_cpu(adsp2_alg[i].alg.id)); |
| 1405 | } |
Charles Keepax | b618a185 | 2015-04-13 13:27:53 +0100 | [diff] [blame] | 1406 | } |
| 1407 | |
Charles Keepax | d9d20e1 | 2015-04-13 13:27:59 +0100 | [diff] [blame] | 1408 | alg_region = wm_adsp_create_region(dsp, WMFW_ADSP2_YM, |
| 1409 | adsp2_alg[i].alg.id, |
| 1410 | adsp2_alg[i].ym); |
| 1411 | if (IS_ERR(alg_region)) { |
| 1412 | ret = PTR_ERR(alg_region); |
Charles Keepax | b618a185 | 2015-04-13 13:27:53 +0100 | [diff] [blame] | 1413 | goto out; |
| 1414 | } |
Charles Keepax | 2323736 | 2015-04-13 13:28:02 +0100 | [diff] [blame] | 1415 | if (dsp->fw_ver == 0) { |
| 1416 | if (i + 1 < n_algs) { |
| 1417 | len = be32_to_cpu(adsp2_alg[i + 1].ym); |
| 1418 | len -= be32_to_cpu(adsp2_alg[i].ym); |
| 1419 | len *= 4; |
| 1420 | wm_adsp_create_control(dsp, alg_region, 0, |
Charles Keepax | 26c22a1 | 2015-04-20 13:52:45 +0100 | [diff] [blame] | 1421 | len, NULL, 0, 0); |
Charles Keepax | 2323736 | 2015-04-13 13:28:02 +0100 | [diff] [blame] | 1422 | } else { |
| 1423 | adsp_warn(dsp, "Missing length info for region YM with ID %x\n", |
| 1424 | be32_to_cpu(adsp2_alg[i].alg.id)); |
| 1425 | } |
Charles Keepax | b618a185 | 2015-04-13 13:27:53 +0100 | [diff] [blame] | 1426 | } |
| 1427 | |
Charles Keepax | d9d20e1 | 2015-04-13 13:27:59 +0100 | [diff] [blame] | 1428 | alg_region = wm_adsp_create_region(dsp, WMFW_ADSP2_ZM, |
| 1429 | adsp2_alg[i].alg.id, |
| 1430 | adsp2_alg[i].zm); |
| 1431 | if (IS_ERR(alg_region)) { |
| 1432 | ret = PTR_ERR(alg_region); |
Charles Keepax | b618a185 | 2015-04-13 13:27:53 +0100 | [diff] [blame] | 1433 | goto out; |
| 1434 | } |
Charles Keepax | 2323736 | 2015-04-13 13:28:02 +0100 | [diff] [blame] | 1435 | if (dsp->fw_ver == 0) { |
| 1436 | if (i + 1 < n_algs) { |
| 1437 | len = be32_to_cpu(adsp2_alg[i + 1].zm); |
| 1438 | len -= be32_to_cpu(adsp2_alg[i].zm); |
| 1439 | len *= 4; |
| 1440 | wm_adsp_create_control(dsp, alg_region, 0, |
Charles Keepax | 26c22a1 | 2015-04-20 13:52:45 +0100 | [diff] [blame] | 1441 | len, NULL, 0, 0); |
Charles Keepax | 2323736 | 2015-04-13 13:28:02 +0100 | [diff] [blame] | 1442 | } else { |
| 1443 | adsp_warn(dsp, "Missing length info for region ZM with ID %x\n", |
| 1444 | be32_to_cpu(adsp2_alg[i].alg.id)); |
| 1445 | } |
Charles Keepax | b618a185 | 2015-04-13 13:27:53 +0100 | [diff] [blame] | 1446 | } |
| 1447 | } |
| 1448 | |
| 1449 | out: |
| 1450 | kfree(adsp2_alg); |
Mark Brown | db40517 | 2012-10-26 19:30:40 +0100 | [diff] [blame] | 1451 | return ret; |
| 1452 | } |
| 1453 | |
Mark Brown | 2159ad93 | 2012-10-11 11:54:02 +0900 | [diff] [blame] | 1454 | static int wm_adsp_load_coeff(struct wm_adsp *dsp) |
| 1455 | { |
Mark Brown | cf17c83 | 2013-01-30 14:37:23 +0800 | [diff] [blame] | 1456 | LIST_HEAD(buf_list); |
Mark Brown | 2159ad93 | 2012-10-11 11:54:02 +0900 | [diff] [blame] | 1457 | struct regmap *regmap = dsp->regmap; |
| 1458 | struct wmfw_coeff_hdr *hdr; |
| 1459 | struct wmfw_coeff_item *blk; |
| 1460 | const struct firmware *firmware; |
Mark Brown | 471f488 | 2013-01-08 16:09:31 +0000 | [diff] [blame] | 1461 | const struct wm_adsp_region *mem; |
| 1462 | struct wm_adsp_alg_region *alg_region; |
Mark Brown | 2159ad93 | 2012-10-11 11:54:02 +0900 | [diff] [blame] | 1463 | const char *region_name; |
| 1464 | int ret, pos, blocks, type, offset, reg; |
| 1465 | char *file; |
Mark Brown | cf17c83 | 2013-01-30 14:37:23 +0800 | [diff] [blame] | 1466 | struct wm_adsp_buf *buf; |
Mark Brown | 2159ad93 | 2012-10-11 11:54:02 +0900 | [diff] [blame] | 1467 | |
| 1468 | file = kzalloc(PAGE_SIZE, GFP_KERNEL); |
| 1469 | if (file == NULL) |
| 1470 | return -ENOMEM; |
| 1471 | |
Mark Brown | 1023dbd | 2013-01-11 22:58:28 +0000 | [diff] [blame] | 1472 | snprintf(file, PAGE_SIZE, "%s-dsp%d-%s.bin", dsp->part, dsp->num, |
| 1473 | wm_adsp_fw[dsp->fw].file); |
Mark Brown | 2159ad93 | 2012-10-11 11:54:02 +0900 | [diff] [blame] | 1474 | file[PAGE_SIZE - 1] = '\0'; |
| 1475 | |
| 1476 | ret = request_firmware(&firmware, file, dsp->dev); |
| 1477 | if (ret != 0) { |
| 1478 | adsp_warn(dsp, "Failed to request '%s'\n", file); |
| 1479 | ret = 0; |
| 1480 | goto out; |
| 1481 | } |
| 1482 | ret = -EINVAL; |
| 1483 | |
| 1484 | if (sizeof(*hdr) >= firmware->size) { |
| 1485 | adsp_err(dsp, "%s: file too short, %zu bytes\n", |
| 1486 | file, firmware->size); |
| 1487 | goto out_fw; |
| 1488 | } |
| 1489 | |
| 1490 | hdr = (void*)&firmware->data[0]; |
| 1491 | if (memcmp(hdr->magic, "WMDR", 4) != 0) { |
| 1492 | adsp_err(dsp, "%s: invalid magic\n", file); |
Charles Keepax | a4cdbec | 2013-01-21 09:02:31 +0000 | [diff] [blame] | 1493 | goto out_fw; |
Mark Brown | 2159ad93 | 2012-10-11 11:54:02 +0900 | [diff] [blame] | 1494 | } |
| 1495 | |
Mark Brown | c712326 | 2013-01-16 16:59:04 +0900 | [diff] [blame] | 1496 | switch (be32_to_cpu(hdr->rev) & 0xff) { |
| 1497 | case 1: |
| 1498 | break; |
| 1499 | default: |
| 1500 | adsp_err(dsp, "%s: Unsupported coefficient file format %d\n", |
| 1501 | file, be32_to_cpu(hdr->rev) & 0xff); |
| 1502 | ret = -EINVAL; |
| 1503 | goto out_fw; |
| 1504 | } |
| 1505 | |
Mark Brown | 2159ad93 | 2012-10-11 11:54:02 +0900 | [diff] [blame] | 1506 | adsp_dbg(dsp, "%s: v%d.%d.%d\n", file, |
| 1507 | (le32_to_cpu(hdr->ver) >> 16) & 0xff, |
| 1508 | (le32_to_cpu(hdr->ver) >> 8) & 0xff, |
| 1509 | le32_to_cpu(hdr->ver) & 0xff); |
| 1510 | |
| 1511 | pos = le32_to_cpu(hdr->len); |
| 1512 | |
| 1513 | blocks = 0; |
| 1514 | while (pos < firmware->size && |
| 1515 | pos - firmware->size > sizeof(*blk)) { |
| 1516 | blk = (void*)(&firmware->data[pos]); |
| 1517 | |
Mark Brown | c712326 | 2013-01-16 16:59:04 +0900 | [diff] [blame] | 1518 | type = le16_to_cpu(blk->type); |
| 1519 | offset = le16_to_cpu(blk->offset); |
Mark Brown | 2159ad93 | 2012-10-11 11:54:02 +0900 | [diff] [blame] | 1520 | |
| 1521 | adsp_dbg(dsp, "%s.%d: %x v%d.%d.%d\n", |
| 1522 | file, blocks, le32_to_cpu(blk->id), |
| 1523 | (le32_to_cpu(blk->ver) >> 16) & 0xff, |
| 1524 | (le32_to_cpu(blk->ver) >> 8) & 0xff, |
| 1525 | le32_to_cpu(blk->ver) & 0xff); |
| 1526 | adsp_dbg(dsp, "%s.%d: %d bytes at 0x%x in %x\n", |
| 1527 | file, blocks, le32_to_cpu(blk->len), offset, type); |
| 1528 | |
| 1529 | reg = 0; |
| 1530 | region_name = "Unknown"; |
| 1531 | switch (type) { |
Mark Brown | c712326 | 2013-01-16 16:59:04 +0900 | [diff] [blame] | 1532 | case (WMFW_NAME_TEXT << 8): |
| 1533 | case (WMFW_INFO_TEXT << 8): |
Mark Brown | 2159ad93 | 2012-10-11 11:54:02 +0900 | [diff] [blame] | 1534 | break; |
Mark Brown | c712326 | 2013-01-16 16:59:04 +0900 | [diff] [blame] | 1535 | case (WMFW_ABSOLUTE << 8): |
Mark Brown | f395a21 | 2013-03-05 22:39:54 +0800 | [diff] [blame] | 1536 | /* |
| 1537 | * Old files may use this for global |
| 1538 | * coefficients. |
| 1539 | */ |
| 1540 | if (le32_to_cpu(blk->id) == dsp->fw_id && |
| 1541 | offset == 0) { |
| 1542 | region_name = "global coefficients"; |
| 1543 | mem = wm_adsp_find_region(dsp, type); |
| 1544 | if (!mem) { |
| 1545 | adsp_err(dsp, "No ZM\n"); |
| 1546 | break; |
| 1547 | } |
| 1548 | reg = wm_adsp_region_to_reg(mem, 0); |
| 1549 | |
| 1550 | } else { |
| 1551 | region_name = "register"; |
| 1552 | reg = offset; |
| 1553 | } |
Mark Brown | 2159ad93 | 2012-10-11 11:54:02 +0900 | [diff] [blame] | 1554 | break; |
Mark Brown | 471f488 | 2013-01-08 16:09:31 +0000 | [diff] [blame] | 1555 | |
| 1556 | case WMFW_ADSP1_DM: |
| 1557 | case WMFW_ADSP1_ZM: |
| 1558 | case WMFW_ADSP2_XM: |
| 1559 | case WMFW_ADSP2_YM: |
| 1560 | adsp_dbg(dsp, "%s.%d: %d bytes in %x for %x\n", |
| 1561 | file, blocks, le32_to_cpu(blk->len), |
| 1562 | type, le32_to_cpu(blk->id)); |
| 1563 | |
| 1564 | mem = wm_adsp_find_region(dsp, type); |
| 1565 | if (!mem) { |
| 1566 | adsp_err(dsp, "No base for region %x\n", type); |
| 1567 | break; |
| 1568 | } |
| 1569 | |
| 1570 | reg = 0; |
| 1571 | list_for_each_entry(alg_region, |
| 1572 | &dsp->alg_regions, list) { |
| 1573 | if (le32_to_cpu(blk->id) == alg_region->alg && |
| 1574 | type == alg_region->type) { |
Mark Brown | 338c518 | 2013-01-24 00:35:48 +0800 | [diff] [blame] | 1575 | reg = alg_region->base; |
Mark Brown | 471f488 | 2013-01-08 16:09:31 +0000 | [diff] [blame] | 1576 | reg = wm_adsp_region_to_reg(mem, |
| 1577 | reg); |
Mark Brown | 338c518 | 2013-01-24 00:35:48 +0800 | [diff] [blame] | 1578 | reg += offset; |
Charles Keepax | d733dc0 | 2013-11-28 16:37:51 +0000 | [diff] [blame] | 1579 | break; |
Mark Brown | 471f488 | 2013-01-08 16:09:31 +0000 | [diff] [blame] | 1580 | } |
| 1581 | } |
| 1582 | |
| 1583 | if (reg == 0) |
| 1584 | adsp_err(dsp, "No %x for algorithm %x\n", |
| 1585 | type, le32_to_cpu(blk->id)); |
| 1586 | break; |
| 1587 | |
Mark Brown | 2159ad93 | 2012-10-11 11:54:02 +0900 | [diff] [blame] | 1588 | default: |
Mark Brown | 25c62f7e | 2013-01-20 19:02:19 +0900 | [diff] [blame] | 1589 | adsp_err(dsp, "%s.%d: Unknown region type %x at %d\n", |
| 1590 | file, blocks, type, pos); |
Mark Brown | 2159ad93 | 2012-10-11 11:54:02 +0900 | [diff] [blame] | 1591 | break; |
| 1592 | } |
| 1593 | |
| 1594 | if (reg) { |
Mark Brown | cf17c83 | 2013-01-30 14:37:23 +0800 | [diff] [blame] | 1595 | buf = wm_adsp_buf_alloc(blk->data, |
| 1596 | le32_to_cpu(blk->len), |
| 1597 | &buf_list); |
Mark Brown | a76fefa | 2013-01-07 19:03:17 +0000 | [diff] [blame] | 1598 | if (!buf) { |
| 1599 | adsp_err(dsp, "Out of memory\n"); |
Wei Yongjun | f4b8281 | 2013-03-12 00:23:15 +0800 | [diff] [blame] | 1600 | ret = -ENOMEM; |
| 1601 | goto out_fw; |
Mark Brown | a76fefa | 2013-01-07 19:03:17 +0000 | [diff] [blame] | 1602 | } |
| 1603 | |
Mark Brown | 20da6d5 | 2013-01-12 19:58:17 +0000 | [diff] [blame] | 1604 | adsp_dbg(dsp, "%s.%d: Writing %d bytes at %x\n", |
| 1605 | file, blocks, le32_to_cpu(blk->len), |
| 1606 | reg); |
Mark Brown | cf17c83 | 2013-01-30 14:37:23 +0800 | [diff] [blame] | 1607 | ret = regmap_raw_write_async(regmap, reg, buf->buf, |
| 1608 | le32_to_cpu(blk->len)); |
Mark Brown | 2159ad93 | 2012-10-11 11:54:02 +0900 | [diff] [blame] | 1609 | if (ret != 0) { |
| 1610 | adsp_err(dsp, |
Dimitris Papastamos | 43bc3bf | 2013-11-01 15:56:52 +0000 | [diff] [blame] | 1611 | "%s.%d: Failed to write to %x in %s: %d\n", |
| 1612 | file, blocks, reg, region_name, ret); |
Mark Brown | 2159ad93 | 2012-10-11 11:54:02 +0900 | [diff] [blame] | 1613 | } |
| 1614 | } |
| 1615 | |
Charles Keepax | be95101 | 2015-02-16 15:25:49 +0000 | [diff] [blame] | 1616 | pos += (le32_to_cpu(blk->len) + sizeof(*blk) + 3) & ~0x03; |
Mark Brown | 2159ad93 | 2012-10-11 11:54:02 +0900 | [diff] [blame] | 1617 | blocks++; |
| 1618 | } |
| 1619 | |
Mark Brown | cf17c83 | 2013-01-30 14:37:23 +0800 | [diff] [blame] | 1620 | ret = regmap_async_complete(regmap); |
| 1621 | if (ret != 0) |
| 1622 | adsp_err(dsp, "Failed to complete async write: %d\n", ret); |
| 1623 | |
Mark Brown | 2159ad93 | 2012-10-11 11:54:02 +0900 | [diff] [blame] | 1624 | if (pos > firmware->size) |
| 1625 | adsp_warn(dsp, "%s.%d: %zu bytes at end of file\n", |
| 1626 | file, blocks, pos - firmware->size); |
| 1627 | |
| 1628 | out_fw: |
Charles Keepax | 9da7a5a | 2014-11-17 10:48:21 +0000 | [diff] [blame] | 1629 | regmap_async_complete(regmap); |
Mark Brown | 2159ad93 | 2012-10-11 11:54:02 +0900 | [diff] [blame] | 1630 | release_firmware(firmware); |
Mark Brown | cf17c83 | 2013-01-30 14:37:23 +0800 | [diff] [blame] | 1631 | wm_adsp_buf_free(&buf_list); |
Mark Brown | 2159ad93 | 2012-10-11 11:54:02 +0900 | [diff] [blame] | 1632 | out: |
| 1633 | kfree(file); |
Wei Yongjun | f4b8281 | 2013-03-12 00:23:15 +0800 | [diff] [blame] | 1634 | return ret; |
Mark Brown | 2159ad93 | 2012-10-11 11:54:02 +0900 | [diff] [blame] | 1635 | } |
| 1636 | |
Charles Keepax | 3809f00 | 2015-04-13 13:27:54 +0100 | [diff] [blame] | 1637 | int wm_adsp1_init(struct wm_adsp *dsp) |
Mark Brown | 5e7a7a2 | 2013-01-16 10:03:56 +0900 | [diff] [blame] | 1638 | { |
Charles Keepax | 3809f00 | 2015-04-13 13:27:54 +0100 | [diff] [blame] | 1639 | INIT_LIST_HEAD(&dsp->alg_regions); |
Mark Brown | 5e7a7a2 | 2013-01-16 10:03:56 +0900 | [diff] [blame] | 1640 | |
| 1641 | return 0; |
| 1642 | } |
| 1643 | EXPORT_SYMBOL_GPL(wm_adsp1_init); |
| 1644 | |
Mark Brown | 2159ad93 | 2012-10-11 11:54:02 +0900 | [diff] [blame] | 1645 | int wm_adsp1_event(struct snd_soc_dapm_widget *w, |
| 1646 | struct snd_kcontrol *kcontrol, |
| 1647 | int event) |
| 1648 | { |
Lars-Peter Clausen | 7271851 | 2015-01-13 10:27:34 +0100 | [diff] [blame] | 1649 | struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); |
Mark Brown | 2159ad93 | 2012-10-11 11:54:02 +0900 | [diff] [blame] | 1650 | struct wm_adsp *dsps = snd_soc_codec_get_drvdata(codec); |
| 1651 | struct wm_adsp *dsp = &dsps[w->shift]; |
Dimitris Papastamos | b0101b4 | 2013-11-01 15:56:56 +0000 | [diff] [blame] | 1652 | struct wm_adsp_alg_region *alg_region; |
Dimitris Papastamos | 6ab2b7b | 2013-05-08 14:15:35 +0100 | [diff] [blame] | 1653 | struct wm_coeff_ctl *ctl; |
Mark Brown | 2159ad93 | 2012-10-11 11:54:02 +0900 | [diff] [blame] | 1654 | int ret; |
Chris Rattray | 94e205b | 2013-01-18 08:43:09 +0000 | [diff] [blame] | 1655 | int val; |
Mark Brown | 2159ad93 | 2012-10-11 11:54:02 +0900 | [diff] [blame] | 1656 | |
Lars-Peter Clausen | 0020010 | 2014-07-17 22:01:07 +0200 | [diff] [blame] | 1657 | dsp->card = codec->component.card; |
Dimitris Papastamos | 92bb4c3 | 2013-08-01 11:11:28 +0100 | [diff] [blame] | 1658 | |
Mark Brown | 2159ad93 | 2012-10-11 11:54:02 +0900 | [diff] [blame] | 1659 | switch (event) { |
| 1660 | case SND_SOC_DAPM_POST_PMU: |
| 1661 | regmap_update_bits(dsp->regmap, dsp->base + ADSP1_CONTROL_30, |
| 1662 | ADSP1_SYS_ENA, ADSP1_SYS_ENA); |
| 1663 | |
Chris Rattray | 94e205b | 2013-01-18 08:43:09 +0000 | [diff] [blame] | 1664 | /* |
| 1665 | * For simplicity set the DSP clock rate to be the |
| 1666 | * SYSCLK rate rather than making it configurable. |
| 1667 | */ |
| 1668 | if(dsp->sysclk_reg) { |
| 1669 | ret = regmap_read(dsp->regmap, dsp->sysclk_reg, &val); |
| 1670 | if (ret != 0) { |
| 1671 | adsp_err(dsp, "Failed to read SYSCLK state: %d\n", |
| 1672 | ret); |
| 1673 | return ret; |
| 1674 | } |
| 1675 | |
| 1676 | val = (val & dsp->sysclk_mask) |
| 1677 | >> dsp->sysclk_shift; |
| 1678 | |
| 1679 | ret = regmap_update_bits(dsp->regmap, |
| 1680 | dsp->base + ADSP1_CONTROL_31, |
| 1681 | ADSP1_CLK_SEL_MASK, val); |
| 1682 | if (ret != 0) { |
| 1683 | adsp_err(dsp, "Failed to set clock rate: %d\n", |
| 1684 | ret); |
| 1685 | return ret; |
| 1686 | } |
| 1687 | } |
| 1688 | |
Mark Brown | 2159ad93 | 2012-10-11 11:54:02 +0900 | [diff] [blame] | 1689 | ret = wm_adsp_load(dsp); |
| 1690 | if (ret != 0) |
| 1691 | goto err; |
| 1692 | |
Charles Keepax | b618a185 | 2015-04-13 13:27:53 +0100 | [diff] [blame] | 1693 | ret = wm_adsp1_setup_algs(dsp); |
Mark Brown | db40517 | 2012-10-26 19:30:40 +0100 | [diff] [blame] | 1694 | if (ret != 0) |
| 1695 | goto err; |
| 1696 | |
Mark Brown | 2159ad93 | 2012-10-11 11:54:02 +0900 | [diff] [blame] | 1697 | ret = wm_adsp_load_coeff(dsp); |
| 1698 | if (ret != 0) |
| 1699 | goto err; |
| 1700 | |
Dimitris Papastamos | 0c2e3f3 | 2013-05-28 12:01:50 +0100 | [diff] [blame] | 1701 | /* Initialize caches for enabled and unset controls */ |
Dimitris Papastamos | 81ad93e | 2013-07-29 13:51:59 +0100 | [diff] [blame] | 1702 | ret = wm_coeff_init_control_caches(dsp); |
Dimitris Papastamos | 6ab2b7b | 2013-05-08 14:15:35 +0100 | [diff] [blame] | 1703 | if (ret != 0) |
| 1704 | goto err; |
| 1705 | |
Dimitris Papastamos | 0c2e3f3 | 2013-05-28 12:01:50 +0100 | [diff] [blame] | 1706 | /* Sync set controls */ |
Dimitris Papastamos | 81ad93e | 2013-07-29 13:51:59 +0100 | [diff] [blame] | 1707 | ret = wm_coeff_sync_controls(dsp); |
Dimitris Papastamos | 6ab2b7b | 2013-05-08 14:15:35 +0100 | [diff] [blame] | 1708 | if (ret != 0) |
| 1709 | goto err; |
| 1710 | |
Mark Brown | 2159ad93 | 2012-10-11 11:54:02 +0900 | [diff] [blame] | 1711 | /* Start the core running */ |
| 1712 | regmap_update_bits(dsp->regmap, dsp->base + ADSP1_CONTROL_30, |
| 1713 | ADSP1_CORE_ENA | ADSP1_START, |
| 1714 | ADSP1_CORE_ENA | ADSP1_START); |
| 1715 | break; |
| 1716 | |
| 1717 | case SND_SOC_DAPM_PRE_PMD: |
| 1718 | /* Halt the core */ |
| 1719 | regmap_update_bits(dsp->regmap, dsp->base + ADSP1_CONTROL_30, |
| 1720 | ADSP1_CORE_ENA | ADSP1_START, 0); |
| 1721 | |
| 1722 | regmap_update_bits(dsp->regmap, dsp->base + ADSP1_CONTROL_19, |
| 1723 | ADSP1_WDMA_BUFFER_LENGTH_MASK, 0); |
| 1724 | |
| 1725 | regmap_update_bits(dsp->regmap, dsp->base + ADSP1_CONTROL_30, |
| 1726 | ADSP1_SYS_ENA, 0); |
Dimitris Papastamos | 6ab2b7b | 2013-05-08 14:15:35 +0100 | [diff] [blame] | 1727 | |
Dimitris Papastamos | 81ad93e | 2013-07-29 13:51:59 +0100 | [diff] [blame] | 1728 | list_for_each_entry(ctl, &dsp->ctl_list, list) |
Dimitris Papastamos | 6ab2b7b | 2013-05-08 14:15:35 +0100 | [diff] [blame] | 1729 | ctl->enabled = 0; |
Dimitris Papastamos | b0101b4 | 2013-11-01 15:56:56 +0000 | [diff] [blame] | 1730 | |
| 1731 | while (!list_empty(&dsp->alg_regions)) { |
| 1732 | alg_region = list_first_entry(&dsp->alg_regions, |
| 1733 | struct wm_adsp_alg_region, |
| 1734 | list); |
| 1735 | list_del(&alg_region->list); |
| 1736 | kfree(alg_region); |
| 1737 | } |
Mark Brown | 2159ad93 | 2012-10-11 11:54:02 +0900 | [diff] [blame] | 1738 | break; |
| 1739 | |
| 1740 | default: |
| 1741 | break; |
| 1742 | } |
| 1743 | |
| 1744 | return 0; |
| 1745 | |
| 1746 | err: |
| 1747 | regmap_update_bits(dsp->regmap, dsp->base + ADSP1_CONTROL_30, |
| 1748 | ADSP1_SYS_ENA, 0); |
| 1749 | return ret; |
| 1750 | } |
| 1751 | EXPORT_SYMBOL_GPL(wm_adsp1_event); |
| 1752 | |
| 1753 | static int wm_adsp2_ena(struct wm_adsp *dsp) |
| 1754 | { |
| 1755 | unsigned int val; |
| 1756 | int ret, count; |
| 1757 | |
Mark Brown | 1552c32 | 2013-11-28 18:11:38 +0000 | [diff] [blame] | 1758 | ret = regmap_update_bits_async(dsp->regmap, dsp->base + ADSP2_CONTROL, |
| 1759 | ADSP2_SYS_ENA, ADSP2_SYS_ENA); |
Mark Brown | 2159ad93 | 2012-10-11 11:54:02 +0900 | [diff] [blame] | 1760 | if (ret != 0) |
| 1761 | return ret; |
| 1762 | |
| 1763 | /* Wait for the RAM to start, should be near instantaneous */ |
Charles Keepax | 939fd1e | 2013-12-18 09:25:49 +0000 | [diff] [blame] | 1764 | for (count = 0; count < 10; ++count) { |
Mark Brown | 2159ad93 | 2012-10-11 11:54:02 +0900 | [diff] [blame] | 1765 | ret = regmap_read(dsp->regmap, dsp->base + ADSP2_STATUS1, |
| 1766 | &val); |
| 1767 | if (ret != 0) |
| 1768 | return ret; |
Charles Keepax | 939fd1e | 2013-12-18 09:25:49 +0000 | [diff] [blame] | 1769 | |
| 1770 | if (val & ADSP2_RAM_RDY) |
| 1771 | break; |
| 1772 | |
| 1773 | msleep(1); |
| 1774 | } |
Mark Brown | 2159ad93 | 2012-10-11 11:54:02 +0900 | [diff] [blame] | 1775 | |
| 1776 | if (!(val & ADSP2_RAM_RDY)) { |
| 1777 | adsp_err(dsp, "Failed to start DSP RAM\n"); |
| 1778 | return -EBUSY; |
| 1779 | } |
| 1780 | |
| 1781 | adsp_dbg(dsp, "RAM ready after %d polls\n", count); |
Mark Brown | 2159ad93 | 2012-10-11 11:54:02 +0900 | [diff] [blame] | 1782 | |
| 1783 | return 0; |
| 1784 | } |
| 1785 | |
Charles Keepax | 18b1a90 | 2014-01-09 09:06:54 +0000 | [diff] [blame] | 1786 | static void wm_adsp2_boot_work(struct work_struct *work) |
Charles Keepax | d8a64d6 | 2014-01-08 17:42:18 +0000 | [diff] [blame] | 1787 | { |
| 1788 | struct wm_adsp *dsp = container_of(work, |
| 1789 | struct wm_adsp, |
| 1790 | boot_work); |
| 1791 | int ret; |
| 1792 | unsigned int val; |
| 1793 | |
| 1794 | /* |
| 1795 | * For simplicity set the DSP clock rate to be the |
| 1796 | * SYSCLK rate rather than making it configurable. |
| 1797 | */ |
| 1798 | ret = regmap_read(dsp->regmap, ARIZONA_SYSTEM_CLOCK_1, &val); |
| 1799 | if (ret != 0) { |
| 1800 | adsp_err(dsp, "Failed to read SYSCLK state: %d\n", ret); |
| 1801 | return; |
| 1802 | } |
| 1803 | val = (val & ARIZONA_SYSCLK_FREQ_MASK) |
| 1804 | >> ARIZONA_SYSCLK_FREQ_SHIFT; |
| 1805 | |
| 1806 | ret = regmap_update_bits_async(dsp->regmap, |
| 1807 | dsp->base + ADSP2_CLOCKING, |
| 1808 | ADSP2_CLK_SEL_MASK, val); |
| 1809 | if (ret != 0) { |
| 1810 | adsp_err(dsp, "Failed to set clock rate: %d\n", ret); |
| 1811 | return; |
| 1812 | } |
| 1813 | |
Charles Keepax | d8a64d6 | 2014-01-08 17:42:18 +0000 | [diff] [blame] | 1814 | ret = wm_adsp2_ena(dsp); |
| 1815 | if (ret != 0) |
| 1816 | return; |
| 1817 | |
| 1818 | ret = wm_adsp_load(dsp); |
| 1819 | if (ret != 0) |
| 1820 | goto err; |
| 1821 | |
Charles Keepax | b618a185 | 2015-04-13 13:27:53 +0100 | [diff] [blame] | 1822 | ret = wm_adsp2_setup_algs(dsp); |
Charles Keepax | d8a64d6 | 2014-01-08 17:42:18 +0000 | [diff] [blame] | 1823 | if (ret != 0) |
| 1824 | goto err; |
| 1825 | |
| 1826 | ret = wm_adsp_load_coeff(dsp); |
| 1827 | if (ret != 0) |
| 1828 | goto err; |
| 1829 | |
| 1830 | /* Initialize caches for enabled and unset controls */ |
| 1831 | ret = wm_coeff_init_control_caches(dsp); |
| 1832 | if (ret != 0) |
| 1833 | goto err; |
| 1834 | |
| 1835 | /* Sync set controls */ |
| 1836 | ret = wm_coeff_sync_controls(dsp); |
| 1837 | if (ret != 0) |
| 1838 | goto err; |
| 1839 | |
Charles Keepax | d8a64d6 | 2014-01-08 17:42:18 +0000 | [diff] [blame] | 1840 | dsp->running = true; |
| 1841 | |
| 1842 | return; |
| 1843 | |
| 1844 | err: |
| 1845 | regmap_update_bits(dsp->regmap, dsp->base + ADSP2_CONTROL, |
| 1846 | ADSP2_SYS_ENA | ADSP2_CORE_ENA | ADSP2_START, 0); |
| 1847 | } |
| 1848 | |
Charles Keepax | 12db5ed | 2014-01-08 17:42:19 +0000 | [diff] [blame] | 1849 | int wm_adsp2_early_event(struct snd_soc_dapm_widget *w, |
| 1850 | struct snd_kcontrol *kcontrol, int event) |
| 1851 | { |
Lars-Peter Clausen | 7271851 | 2015-01-13 10:27:34 +0100 | [diff] [blame] | 1852 | struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); |
Charles Keepax | 12db5ed | 2014-01-08 17:42:19 +0000 | [diff] [blame] | 1853 | struct wm_adsp *dsps = snd_soc_codec_get_drvdata(codec); |
| 1854 | struct wm_adsp *dsp = &dsps[w->shift]; |
| 1855 | |
Lars-Peter Clausen | 0020010 | 2014-07-17 22:01:07 +0200 | [diff] [blame] | 1856 | dsp->card = codec->component.card; |
Charles Keepax | 12db5ed | 2014-01-08 17:42:19 +0000 | [diff] [blame] | 1857 | |
| 1858 | switch (event) { |
| 1859 | case SND_SOC_DAPM_PRE_PMU: |
| 1860 | queue_work(system_unbound_wq, &dsp->boot_work); |
| 1861 | break; |
| 1862 | default: |
| 1863 | break; |
Charles Keepax | cab27258 | 2014-04-17 13:42:54 +0100 | [diff] [blame] | 1864 | } |
Charles Keepax | 12db5ed | 2014-01-08 17:42:19 +0000 | [diff] [blame] | 1865 | |
| 1866 | return 0; |
| 1867 | } |
| 1868 | EXPORT_SYMBOL_GPL(wm_adsp2_early_event); |
| 1869 | |
Mark Brown | 2159ad93 | 2012-10-11 11:54:02 +0900 | [diff] [blame] | 1870 | int wm_adsp2_event(struct snd_soc_dapm_widget *w, |
| 1871 | struct snd_kcontrol *kcontrol, int event) |
| 1872 | { |
Lars-Peter Clausen | 7271851 | 2015-01-13 10:27:34 +0100 | [diff] [blame] | 1873 | struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); |
Mark Brown | 2159ad93 | 2012-10-11 11:54:02 +0900 | [diff] [blame] | 1874 | struct wm_adsp *dsps = snd_soc_codec_get_drvdata(codec); |
| 1875 | struct wm_adsp *dsp = &dsps[w->shift]; |
Mark Brown | 471f488 | 2013-01-08 16:09:31 +0000 | [diff] [blame] | 1876 | struct wm_adsp_alg_region *alg_region; |
Dimitris Papastamos | 6ab2b7b | 2013-05-08 14:15:35 +0100 | [diff] [blame] | 1877 | struct wm_coeff_ctl *ctl; |
Mark Brown | 2159ad93 | 2012-10-11 11:54:02 +0900 | [diff] [blame] | 1878 | int ret; |
| 1879 | |
| 1880 | switch (event) { |
| 1881 | case SND_SOC_DAPM_POST_PMU: |
Charles Keepax | d8a64d6 | 2014-01-08 17:42:18 +0000 | [diff] [blame] | 1882 | flush_work(&dsp->boot_work); |
Mark Brown | dd49e2c | 2012-12-02 21:50:46 +0900 | [diff] [blame] | 1883 | |
Charles Keepax | d8a64d6 | 2014-01-08 17:42:18 +0000 | [diff] [blame] | 1884 | if (!dsp->running) |
| 1885 | return -EIO; |
Mark Brown | dd49e2c | 2012-12-02 21:50:46 +0900 | [diff] [blame] | 1886 | |
Charles Keepax | d8a64d6 | 2014-01-08 17:42:18 +0000 | [diff] [blame] | 1887 | ret = regmap_update_bits(dsp->regmap, |
| 1888 | dsp->base + ADSP2_CONTROL, |
Charles Keepax | 00e4c3b | 2014-11-18 16:25:27 +0000 | [diff] [blame] | 1889 | ADSP2_CORE_ENA | ADSP2_START, |
| 1890 | ADSP2_CORE_ENA | ADSP2_START); |
Mark Brown | 2159ad93 | 2012-10-11 11:54:02 +0900 | [diff] [blame] | 1891 | if (ret != 0) |
| 1892 | goto err; |
Mark Brown | 2159ad93 | 2012-10-11 11:54:02 +0900 | [diff] [blame] | 1893 | break; |
| 1894 | |
| 1895 | case SND_SOC_DAPM_PRE_PMD: |
Richard Fitzgerald | 10337b0 | 2015-05-29 10:23:07 +0100 | [diff] [blame] | 1896 | /* Log firmware state, it can be useful for analysis */ |
| 1897 | wm_adsp2_show_fw_status(dsp); |
| 1898 | |
Mark Brown | 1023dbd | 2013-01-11 22:58:28 +0000 | [diff] [blame] | 1899 | dsp->running = false; |
| 1900 | |
Mark Brown | 2159ad93 | 2012-10-11 11:54:02 +0900 | [diff] [blame] | 1901 | regmap_update_bits(dsp->regmap, dsp->base + ADSP2_CONTROL, |
Mark Brown | a7f9be7 | 2012-11-28 19:53:59 +0000 | [diff] [blame] | 1902 | ADSP2_SYS_ENA | ADSP2_CORE_ENA | |
| 1903 | ADSP2_START, 0); |
Mark Brown | 973838a | 2012-11-28 17:20:32 +0000 | [diff] [blame] | 1904 | |
Mark Brown | 2d30b57 | 2013-01-28 20:18:17 +0800 | [diff] [blame] | 1905 | /* Make sure DMAs are quiesced */ |
| 1906 | regmap_write(dsp->regmap, dsp->base + ADSP2_WDMA_CONFIG_1, 0); |
| 1907 | regmap_write(dsp->regmap, dsp->base + ADSP2_WDMA_CONFIG_2, 0); |
| 1908 | regmap_write(dsp->regmap, dsp->base + ADSP2_RDMA_CONFIG_1, 0); |
| 1909 | |
Dimitris Papastamos | 81ad93e | 2013-07-29 13:51:59 +0100 | [diff] [blame] | 1910 | list_for_each_entry(ctl, &dsp->ctl_list, list) |
Dimitris Papastamos | 6ab2b7b | 2013-05-08 14:15:35 +0100 | [diff] [blame] | 1911 | ctl->enabled = 0; |
Dimitris Papastamos | 6ab2b7b | 2013-05-08 14:15:35 +0100 | [diff] [blame] | 1912 | |
Mark Brown | 471f488 | 2013-01-08 16:09:31 +0000 | [diff] [blame] | 1913 | while (!list_empty(&dsp->alg_regions)) { |
| 1914 | alg_region = list_first_entry(&dsp->alg_regions, |
| 1915 | struct wm_adsp_alg_region, |
| 1916 | list); |
| 1917 | list_del(&alg_region->list); |
| 1918 | kfree(alg_region); |
| 1919 | } |
Charles Keepax | ddbc5ef | 2014-01-22 10:09:11 +0000 | [diff] [blame] | 1920 | |
| 1921 | adsp_dbg(dsp, "Shutdown complete\n"); |
Mark Brown | 2159ad93 | 2012-10-11 11:54:02 +0900 | [diff] [blame] | 1922 | break; |
| 1923 | |
| 1924 | default: |
| 1925 | break; |
| 1926 | } |
| 1927 | |
| 1928 | return 0; |
| 1929 | err: |
| 1930 | regmap_update_bits(dsp->regmap, dsp->base + ADSP2_CONTROL, |
Mark Brown | a7f9be7 | 2012-11-28 19:53:59 +0000 | [diff] [blame] | 1931 | ADSP2_SYS_ENA | ADSP2_CORE_ENA | ADSP2_START, 0); |
Mark Brown | 2159ad93 | 2012-10-11 11:54:02 +0900 | [diff] [blame] | 1932 | return ret; |
| 1933 | } |
| 1934 | EXPORT_SYMBOL_GPL(wm_adsp2_event); |
Mark Brown | 973838a | 2012-11-28 17:20:32 +0000 | [diff] [blame] | 1935 | |
Richard Fitzgerald | 81ac58b | 2015-06-02 11:53:34 +0100 | [diff] [blame] | 1936 | int wm_adsp2_init(struct wm_adsp *dsp) |
Mark Brown | 973838a | 2012-11-28 17:20:32 +0000 | [diff] [blame] | 1937 | { |
| 1938 | int ret; |
| 1939 | |
Mark Brown | 10a2b66 | 2012-12-02 21:37:00 +0900 | [diff] [blame] | 1940 | /* |
| 1941 | * Disable the DSP memory by default when in reset for a small |
| 1942 | * power saving. |
| 1943 | */ |
Charles Keepax | 3809f00 | 2015-04-13 13:27:54 +0100 | [diff] [blame] | 1944 | ret = regmap_update_bits(dsp->regmap, dsp->base + ADSP2_CONTROL, |
Mark Brown | 10a2b66 | 2012-12-02 21:37:00 +0900 | [diff] [blame] | 1945 | ADSP2_MEM_ENA, 0); |
| 1946 | if (ret != 0) { |
Charles Keepax | 3809f00 | 2015-04-13 13:27:54 +0100 | [diff] [blame] | 1947 | adsp_err(dsp, "Failed to clear memory retention: %d\n", ret); |
Mark Brown | 10a2b66 | 2012-12-02 21:37:00 +0900 | [diff] [blame] | 1948 | return ret; |
| 1949 | } |
| 1950 | |
Charles Keepax | 3809f00 | 2015-04-13 13:27:54 +0100 | [diff] [blame] | 1951 | INIT_LIST_HEAD(&dsp->alg_regions); |
| 1952 | INIT_LIST_HEAD(&dsp->ctl_list); |
| 1953 | INIT_WORK(&dsp->boot_work, wm_adsp2_boot_work); |
Dimitris Papastamos | 6ab2b7b | 2013-05-08 14:15:35 +0100 | [diff] [blame] | 1954 | |
Mark Brown | 973838a | 2012-11-28 17:20:32 +0000 | [diff] [blame] | 1955 | return 0; |
| 1956 | } |
| 1957 | EXPORT_SYMBOL_GPL(wm_adsp2_init); |
Praveen Diwakar | 0a37c6ef | 2014-07-04 11:17:41 +0530 | [diff] [blame] | 1958 | |
| 1959 | MODULE_LICENSE("GPL v2"); |