Lines Matching refs:dsp
241 struct wm_adsp *dsp; member
253 static void wm_adsp_debugfs_save_wmfwname(struct wm_adsp *dsp, const char *s) in wm_adsp_debugfs_save_wmfwname() argument
257 mutex_lock(&dsp->debugfs_lock); in wm_adsp_debugfs_save_wmfwname()
258 kfree(dsp->wmfw_file_name); in wm_adsp_debugfs_save_wmfwname()
259 dsp->wmfw_file_name = tmp; in wm_adsp_debugfs_save_wmfwname()
260 mutex_unlock(&dsp->debugfs_lock); in wm_adsp_debugfs_save_wmfwname()
263 static void wm_adsp_debugfs_save_binname(struct wm_adsp *dsp, const char *s) in wm_adsp_debugfs_save_binname() argument
267 mutex_lock(&dsp->debugfs_lock); in wm_adsp_debugfs_save_binname()
268 kfree(dsp->bin_file_name); in wm_adsp_debugfs_save_binname()
269 dsp->bin_file_name = tmp; in wm_adsp_debugfs_save_binname()
270 mutex_unlock(&dsp->debugfs_lock); in wm_adsp_debugfs_save_binname()
273 static void wm_adsp_debugfs_clear(struct wm_adsp *dsp) in wm_adsp_debugfs_clear() argument
275 mutex_lock(&dsp->debugfs_lock); in wm_adsp_debugfs_clear()
276 kfree(dsp->wmfw_file_name); in wm_adsp_debugfs_clear()
277 kfree(dsp->bin_file_name); in wm_adsp_debugfs_clear()
278 dsp->wmfw_file_name = NULL; in wm_adsp_debugfs_clear()
279 dsp->bin_file_name = NULL; in wm_adsp_debugfs_clear()
280 mutex_unlock(&dsp->debugfs_lock); in wm_adsp_debugfs_clear()
287 struct wm_adsp *dsp = file->private_data; in wm_adsp_debugfs_wmfw_read() local
290 mutex_lock(&dsp->debugfs_lock); in wm_adsp_debugfs_wmfw_read()
292 if (!dsp->wmfw_file_name || !dsp->running) in wm_adsp_debugfs_wmfw_read()
296 dsp->wmfw_file_name, in wm_adsp_debugfs_wmfw_read()
297 strlen(dsp->wmfw_file_name)); in wm_adsp_debugfs_wmfw_read()
299 mutex_unlock(&dsp->debugfs_lock); in wm_adsp_debugfs_wmfw_read()
307 struct wm_adsp *dsp = file->private_data; in wm_adsp_debugfs_bin_read() local
310 mutex_lock(&dsp->debugfs_lock); in wm_adsp_debugfs_bin_read()
312 if (!dsp->bin_file_name || !dsp->running) in wm_adsp_debugfs_bin_read()
316 dsp->bin_file_name, in wm_adsp_debugfs_bin_read()
317 strlen(dsp->bin_file_name)); in wm_adsp_debugfs_bin_read()
319 mutex_unlock(&dsp->debugfs_lock); in wm_adsp_debugfs_bin_read()
343 static void wm_adsp2_init_debugfs(struct wm_adsp *dsp, in wm_adsp2_init_debugfs() argument
351 adsp_err(dsp, "No codec debugfs root\n"); in wm_adsp2_init_debugfs()
359 snprintf(root_name, PAGE_SIZE, "dsp%d", dsp->num); in wm_adsp2_init_debugfs()
366 if (!debugfs_create_bool("running", S_IRUGO, root, &dsp->running)) in wm_adsp2_init_debugfs()
369 if (!debugfs_create_x32("fw_id", S_IRUGO, root, &dsp->fw_id)) in wm_adsp2_init_debugfs()
373 &dsp->fw_id_version)) in wm_adsp2_init_debugfs()
378 S_IRUGO, root, dsp, in wm_adsp2_init_debugfs()
383 dsp->debugfs_root = root; in wm_adsp2_init_debugfs()
388 adsp_err(dsp, "Failed to create debugfs\n"); in wm_adsp2_init_debugfs()
391 static void wm_adsp2_cleanup_debugfs(struct wm_adsp *dsp) in wm_adsp2_cleanup_debugfs() argument
393 wm_adsp_debugfs_clear(dsp); in wm_adsp2_cleanup_debugfs()
394 debugfs_remove_recursive(dsp->debugfs_root); in wm_adsp2_cleanup_debugfs()
397 static inline void wm_adsp2_init_debugfs(struct wm_adsp *dsp, in wm_adsp2_init_debugfs() argument
402 static inline void wm_adsp2_cleanup_debugfs(struct wm_adsp *dsp) in wm_adsp2_cleanup_debugfs() argument
406 static inline void wm_adsp_debugfs_save_wmfwname(struct wm_adsp *dsp, in wm_adsp_debugfs_save_wmfwname() argument
411 static inline void wm_adsp_debugfs_save_binname(struct wm_adsp *dsp, in wm_adsp_debugfs_save_binname() argument
416 static inline void wm_adsp_debugfs_clear(struct wm_adsp *dsp) in wm_adsp_debugfs_clear() argument
426 struct wm_adsp *dsp = snd_soc_codec_get_drvdata(codec); in wm_adsp_fw_get() local
428 ucontrol->value.integer.value[0] = dsp[e->shift_l].fw; in wm_adsp_fw_get()
438 struct wm_adsp *dsp = snd_soc_codec_get_drvdata(codec); in wm_adsp_fw_put() local
440 if (ucontrol->value.integer.value[0] == dsp[e->shift_l].fw) in wm_adsp_fw_put()
446 if (dsp[e->shift_l].running) in wm_adsp_fw_put()
449 dsp[e->shift_l].fw = ucontrol->value.integer.value[0]; in wm_adsp_fw_put()
473 static struct wm_adsp_region const *wm_adsp_find_region(struct wm_adsp *dsp, in wm_adsp_find_region() argument
478 for (i = 0; i < dsp->num_mems; i++) in wm_adsp_find_region()
479 if (dsp->mem[i].type == type) in wm_adsp_find_region()
480 return &dsp->mem[i]; in wm_adsp_find_region()
507 static void wm_adsp2_show_fw_status(struct wm_adsp *dsp) in wm_adsp2_show_fw_status() argument
512 ret = regmap_raw_read(dsp->regmap, dsp->base + ADSP2_SCRATCH0, in wm_adsp2_show_fw_status()
515 adsp_err(dsp, "Failed to read SCRATCH regs: %d\n", ret); in wm_adsp2_show_fw_status()
519 adsp_dbg(dsp, "FW SCRATCH 0:0x%x 1:0x%x 2:0x%x 3:0x%x\n", in wm_adsp2_show_fw_status()
541 struct wm_adsp *dsp = ctl->dsp; in wm_coeff_write_control() local
546 mem = wm_adsp_find_region(dsp, alg_region->type); in wm_coeff_write_control()
548 adsp_err(dsp, "No base for region %x\n", in wm_coeff_write_control()
560 ret = regmap_raw_write(dsp->regmap, reg, scratch, in wm_coeff_write_control()
563 adsp_err(dsp, "Failed to write %zu bytes to %x: %d\n", in wm_coeff_write_control()
568 adsp_dbg(dsp, "Wrote %zu bytes to %x\n", ctl->len, reg); in wm_coeff_write_control()
595 struct wm_adsp *dsp = ctl->dsp; in wm_coeff_read_control() local
600 mem = wm_adsp_find_region(dsp, alg_region->type); in wm_coeff_read_control()
602 adsp_err(dsp, "No base for region %x\n", in wm_coeff_read_control()
614 ret = regmap_raw_read(dsp->regmap, reg, scratch, ctl->len); in wm_coeff_read_control()
616 adsp_err(dsp, "Failed to read %zu bytes from %x: %d\n", in wm_coeff_read_control()
621 adsp_dbg(dsp, "Read %zu bytes from %x\n", ctl->len, reg); in wm_coeff_read_control()
648 struct wm_adsp *dsp; member
653 static int wmfw_add_ctl(struct wm_adsp *dsp, struct wm_coeff_ctl *ctl) in wmfw_add_ctl() argument
681 ret = snd_soc_add_card_controls(dsp->card, in wmfw_add_ctl()
688 ctl->kcontrol = snd_soc_card_get_kcontrol(dsp->card, in wmfw_add_ctl()
698 static int wm_coeff_init_control_caches(struct wm_adsp *dsp) in wm_coeff_init_control_caches() argument
703 list_for_each_entry(ctl, &dsp->ctl_list, list) { in wm_coeff_init_control_caches()
719 static int wm_coeff_sync_controls(struct wm_adsp *dsp) in wm_coeff_sync_controls() argument
724 list_for_each_entry(ctl, &dsp->ctl_list, list) { in wm_coeff_sync_controls()
745 wmfw_add_ctl(ctl_work->dsp, ctl_work->ctl); in wm_adsp_ctl_work()
749 static int wm_adsp_create_control(struct wm_adsp *dsp, in wm_adsp_create_control() argument
781 adsp_err(dsp, "Unknown region type: %d\n", alg_region->type); in wm_adsp_create_control()
785 switch (dsp->fw_ver) { in wm_adsp_create_control()
789 dsp->num, region_name, alg_region->alg); in wm_adsp_create_control()
793 "DSP%d%c %.12s %x", dsp->num, *region_name, in wm_adsp_create_control()
794 wm_adsp_fw_text[dsp->fw], alg_region->alg); in wm_adsp_create_control()
811 list_for_each_entry(ctl, &dsp->ctl_list, in wm_adsp_create_control()
823 ctl->fw_name = wm_adsp_fw_text[dsp->fw]; in wm_adsp_create_control()
834 ctl->dsp = dsp; in wm_adsp_create_control()
839 adsp_warn(dsp, "Truncating control %s from %d\n", in wm_adsp_create_control()
850 list_add(&ctl->list, &dsp->ctl_list); in wm_adsp_create_control()
858 ctl_work->dsp = dsp; in wm_adsp_create_control()
935 static inline void wm_coeff_parse_alg(struct wm_adsp *dsp, const u8 **data, in wm_coeff_parse_alg() argument
940 switch (dsp->fw_ver) { in wm_coeff_parse_alg()
960 adsp_dbg(dsp, "Algorithm ID: %#x\n", blk->id); in wm_coeff_parse_alg()
961 adsp_dbg(dsp, "Algorithm name: %.*s\n", blk->name_len, blk->name); in wm_coeff_parse_alg()
962 adsp_dbg(dsp, "# of coefficient descriptors: %#x\n", blk->ncoeff); in wm_coeff_parse_alg()
965 static inline void wm_coeff_parse_coeff(struct wm_adsp *dsp, const u8 **data, in wm_coeff_parse_coeff() argument
972 switch (dsp->fw_ver) { in wm_coeff_parse_coeff()
1003 adsp_dbg(dsp, "\tCoefficient type: %#x\n", blk->mem_type); in wm_coeff_parse_coeff()
1004 adsp_dbg(dsp, "\tCoefficient offset: %#x\n", blk->offset); in wm_coeff_parse_coeff()
1005 adsp_dbg(dsp, "\tCoefficient name: %.*s\n", blk->name_len, blk->name); in wm_coeff_parse_coeff()
1006 adsp_dbg(dsp, "\tCoefficient flags: %#x\n", blk->flags); in wm_coeff_parse_coeff()
1007 adsp_dbg(dsp, "\tALSA control type: %#x\n", blk->ctl_type); in wm_coeff_parse_coeff()
1008 adsp_dbg(dsp, "\tALSA control len: %#x\n", blk->len); in wm_coeff_parse_coeff()
1011 static int wm_adsp_parse_coeff(struct wm_adsp *dsp, in wm_adsp_parse_coeff() argument
1020 wm_coeff_parse_alg(dsp, &data, &alg_blk); in wm_adsp_parse_coeff()
1022 wm_coeff_parse_coeff(dsp, &data, &coeff_blk); in wm_adsp_parse_coeff()
1028 adsp_err(dsp, "Unknown control type: %d\n", in wm_adsp_parse_coeff()
1036 ret = wm_adsp_create_control(dsp, &alg_region, in wm_adsp_parse_coeff()
1043 adsp_err(dsp, "Failed to create control: %.*s, %d\n", in wm_adsp_parse_coeff()
1050 static int wm_adsp_load(struct wm_adsp *dsp) in wm_adsp_load() argument
1054 struct regmap *regmap = dsp->regmap; in wm_adsp_load()
1073 snprintf(file, PAGE_SIZE, "%s-dsp%d-%s.wmfw", dsp->part, dsp->num, in wm_adsp_load()
1074 wm_adsp_fw[dsp->fw].file); in wm_adsp_load()
1077 ret = request_firmware(&firmware, file, dsp->dev); in wm_adsp_load()
1079 adsp_err(dsp, "Failed to request '%s'\n", file); in wm_adsp_load()
1086 adsp_err(dsp, "%s: file too short, %zu bytes\n", in wm_adsp_load()
1094 adsp_err(dsp, "%s: invalid magic\n", file); in wm_adsp_load()
1100 adsp_warn(dsp, "%s: Depreciated file format %d\n", in wm_adsp_load()
1107 adsp_err(dsp, "%s: unknown file format %d\n", in wm_adsp_load()
1112 adsp_info(dsp, "Firmware version: %d\n", header->ver); in wm_adsp_load()
1113 dsp->fw_ver = header->ver; in wm_adsp_load()
1115 if (header->core != dsp->type) { in wm_adsp_load()
1116 adsp_err(dsp, "%s: invalid core %d != %d\n", in wm_adsp_load()
1117 file, header->core, dsp->type); in wm_adsp_load()
1121 switch (dsp->type) { in wm_adsp_load()
1128 adsp_dbg(dsp, "%s: %d DM, %d PM, %d ZM\n", in wm_adsp_load()
1140 adsp_dbg(dsp, "%s: %d XM, %d YM %d PM, %d ZM\n", in wm_adsp_load()
1154 adsp_err(dsp, "%s: unexpected header length %d\n", in wm_adsp_load()
1159 adsp_dbg(dsp, "%s: timestamp %llu\n", file, in wm_adsp_load()
1170 mem = wm_adsp_find_region(dsp, type); in wm_adsp_load()
1180 ret = wm_adsp_parse_coeff(dsp, region); in wm_adsp_load()
1214 adsp_warn(dsp, in wm_adsp_load()
1220 adsp_dbg(dsp, "%s.%d: %d bytes at %d in %s\n", file, in wm_adsp_load()
1226 adsp_info(dsp, "%s: %s\n", file, text); in wm_adsp_load()
1235 adsp_err(dsp, "Out of memory\n"); in wm_adsp_load()
1243 adsp_err(dsp, in wm_adsp_load()
1258 adsp_err(dsp, "Failed to complete async write: %d\n", ret); in wm_adsp_load()
1263 adsp_warn(dsp, "%s.%d: %zu bytes at end of file\n", in wm_adsp_load()
1266 wm_adsp_debugfs_save_wmfwname(dsp, file); in wm_adsp_load()
1278 static void wm_adsp_ctl_fixup_base(struct wm_adsp *dsp, in wm_adsp_ctl_fixup_base() argument
1283 list_for_each_entry(ctl, &dsp->ctl_list, list) { in wm_adsp_ctl_fixup_base()
1284 if (ctl->fw_name == wm_adsp_fw_text[dsp->fw] && in wm_adsp_ctl_fixup_base()
1292 static void *wm_adsp_read_algs(struct wm_adsp *dsp, size_t n_algs, in wm_adsp_read_algs() argument
1300 adsp_err(dsp, "No algorithms\n"); in wm_adsp_read_algs()
1305 adsp_err(dsp, "Algorithm count %zx excessive\n", n_algs); in wm_adsp_read_algs()
1310 ret = regmap_raw_read(dsp->regmap, pos + len, &val, sizeof(val)); in wm_adsp_read_algs()
1312 adsp_err(dsp, "Failed to read algorithm list end: %d\n", in wm_adsp_read_algs()
1318 adsp_warn(dsp, "Algorithm list end %x 0x%x != 0xbeadead\n", in wm_adsp_read_algs()
1325 ret = regmap_raw_read(dsp->regmap, pos, alg, len * 2); in wm_adsp_read_algs()
1327 adsp_err(dsp, "Failed to read algorithm list: %d\n", in wm_adsp_read_algs()
1336 static struct wm_adsp_alg_region *wm_adsp_create_region(struct wm_adsp *dsp, in wm_adsp_create_region() argument
1350 list_add_tail(&alg_region->list, &dsp->alg_regions); in wm_adsp_create_region()
1352 if (dsp->fw_ver > 0) in wm_adsp_create_region()
1353 wm_adsp_ctl_fixup_base(dsp, alg_region); in wm_adsp_create_region()
1358 static int wm_adsp1_setup_algs(struct wm_adsp *dsp) in wm_adsp1_setup_algs() argument
1368 mem = wm_adsp_find_region(dsp, WMFW_ADSP1_DM); in wm_adsp1_setup_algs()
1372 ret = regmap_raw_read(dsp->regmap, mem->base, &adsp1_id, in wm_adsp1_setup_algs()
1375 adsp_err(dsp, "Failed to read algorithm info: %d\n", in wm_adsp1_setup_algs()
1381 dsp->fw_id = be32_to_cpu(adsp1_id.fw.id); in wm_adsp1_setup_algs()
1382 adsp_info(dsp, "Firmware: %x v%d.%d.%d, %zu algorithms\n", in wm_adsp1_setup_algs()
1383 dsp->fw_id, in wm_adsp1_setup_algs()
1389 alg_region = wm_adsp_create_region(dsp, WMFW_ADSP1_ZM, in wm_adsp1_setup_algs()
1394 alg_region = wm_adsp_create_region(dsp, WMFW_ADSP1_DM, in wm_adsp1_setup_algs()
1402 adsp1_alg = wm_adsp_read_algs(dsp, n_algs, mem->base + pos, len); in wm_adsp1_setup_algs()
1407 adsp_info(dsp, "%d: ID %x v%d.%d.%d DM@%x ZM@%x\n", in wm_adsp1_setup_algs()
1415 alg_region = wm_adsp_create_region(dsp, WMFW_ADSP1_DM, in wm_adsp1_setup_algs()
1422 if (dsp->fw_ver == 0) { in wm_adsp1_setup_algs()
1427 wm_adsp_create_control(dsp, alg_region, 0, in wm_adsp1_setup_algs()
1430 adsp_warn(dsp, "Missing length info for region DM with ID %x\n", in wm_adsp1_setup_algs()
1435 alg_region = wm_adsp_create_region(dsp, WMFW_ADSP1_ZM, in wm_adsp1_setup_algs()
1442 if (dsp->fw_ver == 0) { in wm_adsp1_setup_algs()
1447 wm_adsp_create_control(dsp, alg_region, 0, in wm_adsp1_setup_algs()
1450 adsp_warn(dsp, "Missing length info for region ZM with ID %x\n", in wm_adsp1_setup_algs()
1461 static int wm_adsp2_setup_algs(struct wm_adsp *dsp) in wm_adsp2_setup_algs() argument
1471 mem = wm_adsp_find_region(dsp, WMFW_ADSP2_XM); in wm_adsp2_setup_algs()
1475 ret = regmap_raw_read(dsp->regmap, mem->base, &adsp2_id, in wm_adsp2_setup_algs()
1478 adsp_err(dsp, "Failed to read algorithm info: %d\n", in wm_adsp2_setup_algs()
1484 dsp->fw_id = be32_to_cpu(adsp2_id.fw.id); in wm_adsp2_setup_algs()
1485 dsp->fw_id_version = be32_to_cpu(adsp2_id.fw.ver); in wm_adsp2_setup_algs()
1486 adsp_info(dsp, "Firmware: %x v%d.%d.%d, %zu algorithms\n", in wm_adsp2_setup_algs()
1487 dsp->fw_id, in wm_adsp2_setup_algs()
1488 (dsp->fw_id_version & 0xff0000) >> 16, in wm_adsp2_setup_algs()
1489 (dsp->fw_id_version & 0xff00) >> 8, in wm_adsp2_setup_algs()
1490 dsp->fw_id_version & 0xff, in wm_adsp2_setup_algs()
1493 alg_region = wm_adsp_create_region(dsp, WMFW_ADSP2_XM, in wm_adsp2_setup_algs()
1498 alg_region = wm_adsp_create_region(dsp, WMFW_ADSP2_YM, in wm_adsp2_setup_algs()
1503 alg_region = wm_adsp_create_region(dsp, WMFW_ADSP2_ZM, in wm_adsp2_setup_algs()
1511 adsp2_alg = wm_adsp_read_algs(dsp, n_algs, mem->base + pos, len); in wm_adsp2_setup_algs()
1516 adsp_info(dsp, in wm_adsp2_setup_algs()
1526 alg_region = wm_adsp_create_region(dsp, WMFW_ADSP2_XM, in wm_adsp2_setup_algs()
1533 if (dsp->fw_ver == 0) { in wm_adsp2_setup_algs()
1538 wm_adsp_create_control(dsp, alg_region, 0, in wm_adsp2_setup_algs()
1541 adsp_warn(dsp, "Missing length info for region XM with ID %x\n", in wm_adsp2_setup_algs()
1546 alg_region = wm_adsp_create_region(dsp, WMFW_ADSP2_YM, in wm_adsp2_setup_algs()
1553 if (dsp->fw_ver == 0) { in wm_adsp2_setup_algs()
1558 wm_adsp_create_control(dsp, alg_region, 0, in wm_adsp2_setup_algs()
1561 adsp_warn(dsp, "Missing length info for region YM with ID %x\n", in wm_adsp2_setup_algs()
1566 alg_region = wm_adsp_create_region(dsp, WMFW_ADSP2_ZM, in wm_adsp2_setup_algs()
1573 if (dsp->fw_ver == 0) { in wm_adsp2_setup_algs()
1578 wm_adsp_create_control(dsp, alg_region, 0, in wm_adsp2_setup_algs()
1581 adsp_warn(dsp, "Missing length info for region ZM with ID %x\n", in wm_adsp2_setup_algs()
1592 static int wm_adsp_load_coeff(struct wm_adsp *dsp) in wm_adsp_load_coeff() argument
1595 struct regmap *regmap = dsp->regmap; in wm_adsp_load_coeff()
1610 snprintf(file, PAGE_SIZE, "%s-dsp%d-%s.bin", dsp->part, dsp->num, in wm_adsp_load_coeff()
1611 wm_adsp_fw[dsp->fw].file); in wm_adsp_load_coeff()
1614 ret = request_firmware(&firmware, file, dsp->dev); in wm_adsp_load_coeff()
1616 adsp_warn(dsp, "Failed to request '%s'\n", file); in wm_adsp_load_coeff()
1623 adsp_err(dsp, "%s: file too short, %zu bytes\n", in wm_adsp_load_coeff()
1630 adsp_err(dsp, "%s: invalid magic\n", file); in wm_adsp_load_coeff()
1638 adsp_err(dsp, "%s: Unsupported coefficient file format %d\n", in wm_adsp_load_coeff()
1644 adsp_dbg(dsp, "%s: v%d.%d.%d\n", file, in wm_adsp_load_coeff()
1659 adsp_dbg(dsp, "%s.%d: %x v%d.%d.%d\n", in wm_adsp_load_coeff()
1664 adsp_dbg(dsp, "%s.%d: %d bytes at 0x%x in %x\n", in wm_adsp_load_coeff()
1678 if (le32_to_cpu(blk->id) == dsp->fw_id && in wm_adsp_load_coeff()
1681 mem = wm_adsp_find_region(dsp, type); in wm_adsp_load_coeff()
1683 adsp_err(dsp, "No ZM\n"); in wm_adsp_load_coeff()
1698 adsp_dbg(dsp, "%s.%d: %d bytes in %x for %x\n", in wm_adsp_load_coeff()
1702 mem = wm_adsp_find_region(dsp, type); in wm_adsp_load_coeff()
1704 adsp_err(dsp, "No base for region %x\n", type); in wm_adsp_load_coeff()
1710 &dsp->alg_regions, list) { in wm_adsp_load_coeff()
1722 adsp_err(dsp, "No %x for algorithm %x\n", in wm_adsp_load_coeff()
1727 adsp_err(dsp, "%s.%d: Unknown region type %x at %d\n", in wm_adsp_load_coeff()
1737 adsp_err(dsp, "Out of memory\n"); in wm_adsp_load_coeff()
1742 adsp_dbg(dsp, "%s.%d: Writing %d bytes at %x\n", in wm_adsp_load_coeff()
1748 adsp_err(dsp, in wm_adsp_load_coeff()
1760 adsp_err(dsp, "Failed to complete async write: %d\n", ret); in wm_adsp_load_coeff()
1763 adsp_warn(dsp, "%s.%d: %zu bytes at end of file\n", in wm_adsp_load_coeff()
1766 wm_adsp_debugfs_save_binname(dsp, file); in wm_adsp_load_coeff()
1777 int wm_adsp1_init(struct wm_adsp *dsp) in wm_adsp1_init() argument
1779 INIT_LIST_HEAD(&dsp->alg_regions); in wm_adsp1_init()
1782 mutex_init(&dsp->debugfs_lock); in wm_adsp1_init()
1794 struct wm_adsp *dsp = &dsps[w->shift]; in wm_adsp1_event() local
1800 dsp->card = codec->component.card; in wm_adsp1_event()
1804 regmap_update_bits(dsp->regmap, dsp->base + ADSP1_CONTROL_30, in wm_adsp1_event()
1811 if(dsp->sysclk_reg) { in wm_adsp1_event()
1812 ret = regmap_read(dsp->regmap, dsp->sysclk_reg, &val); in wm_adsp1_event()
1814 adsp_err(dsp, "Failed to read SYSCLK state: %d\n", in wm_adsp1_event()
1819 val = (val & dsp->sysclk_mask) in wm_adsp1_event()
1820 >> dsp->sysclk_shift; in wm_adsp1_event()
1822 ret = regmap_update_bits(dsp->regmap, in wm_adsp1_event()
1823 dsp->base + ADSP1_CONTROL_31, in wm_adsp1_event()
1826 adsp_err(dsp, "Failed to set clock rate: %d\n", in wm_adsp1_event()
1832 ret = wm_adsp_load(dsp); in wm_adsp1_event()
1836 ret = wm_adsp1_setup_algs(dsp); in wm_adsp1_event()
1840 ret = wm_adsp_load_coeff(dsp); in wm_adsp1_event()
1845 ret = wm_coeff_init_control_caches(dsp); in wm_adsp1_event()
1850 ret = wm_coeff_sync_controls(dsp); in wm_adsp1_event()
1855 regmap_update_bits(dsp->regmap, dsp->base + ADSP1_CONTROL_30, in wm_adsp1_event()
1862 regmap_update_bits(dsp->regmap, dsp->base + ADSP1_CONTROL_30, in wm_adsp1_event()
1865 regmap_update_bits(dsp->regmap, dsp->base + ADSP1_CONTROL_19, in wm_adsp1_event()
1868 regmap_update_bits(dsp->regmap, dsp->base + ADSP1_CONTROL_30, in wm_adsp1_event()
1871 list_for_each_entry(ctl, &dsp->ctl_list, list) in wm_adsp1_event()
1874 while (!list_empty(&dsp->alg_regions)) { in wm_adsp1_event()
1875 alg_region = list_first_entry(&dsp->alg_regions, in wm_adsp1_event()
1890 regmap_update_bits(dsp->regmap, dsp->base + ADSP1_CONTROL_30, in wm_adsp1_event()
1896 static int wm_adsp2_ena(struct wm_adsp *dsp) in wm_adsp2_ena() argument
1901 ret = regmap_update_bits_async(dsp->regmap, dsp->base + ADSP2_CONTROL, in wm_adsp2_ena()
1908 ret = regmap_read(dsp->regmap, dsp->base + ADSP2_STATUS1, in wm_adsp2_ena()
1920 adsp_err(dsp, "Failed to start DSP RAM\n"); in wm_adsp2_ena()
1924 adsp_dbg(dsp, "RAM ready after %d polls\n", count); in wm_adsp2_ena()
1931 struct wm_adsp *dsp = container_of(work, in wm_adsp2_boot_work() local
1941 ret = regmap_read(dsp->regmap, ARIZONA_SYSTEM_CLOCK_1, &val); in wm_adsp2_boot_work()
1943 adsp_err(dsp, "Failed to read SYSCLK state: %d\n", ret); in wm_adsp2_boot_work()
1949 ret = regmap_update_bits_async(dsp->regmap, in wm_adsp2_boot_work()
1950 dsp->base + ADSP2_CLOCKING, in wm_adsp2_boot_work()
1953 adsp_err(dsp, "Failed to set clock rate: %d\n", ret); in wm_adsp2_boot_work()
1957 ret = wm_adsp2_ena(dsp); in wm_adsp2_boot_work()
1961 ret = wm_adsp_load(dsp); in wm_adsp2_boot_work()
1965 ret = wm_adsp2_setup_algs(dsp); in wm_adsp2_boot_work()
1969 ret = wm_adsp_load_coeff(dsp); in wm_adsp2_boot_work()
1974 ret = wm_coeff_init_control_caches(dsp); in wm_adsp2_boot_work()
1979 ret = wm_coeff_sync_controls(dsp); in wm_adsp2_boot_work()
1983 dsp->running = true; in wm_adsp2_boot_work()
1988 regmap_update_bits(dsp->regmap, dsp->base + ADSP2_CONTROL, in wm_adsp2_boot_work()
1997 struct wm_adsp *dsp = &dsps[w->shift]; in wm_adsp2_early_event() local
1999 dsp->card = codec->component.card; in wm_adsp2_early_event()
2003 queue_work(system_unbound_wq, &dsp->boot_work); in wm_adsp2_early_event()
2018 struct wm_adsp *dsp = &dsps[w->shift]; in wm_adsp2_event() local
2025 flush_work(&dsp->boot_work); in wm_adsp2_event()
2027 if (!dsp->running) in wm_adsp2_event()
2030 ret = regmap_update_bits(dsp->regmap, in wm_adsp2_event()
2031 dsp->base + ADSP2_CONTROL, in wm_adsp2_event()
2040 wm_adsp2_show_fw_status(dsp); in wm_adsp2_event()
2042 wm_adsp_debugfs_clear(dsp); in wm_adsp2_event()
2044 dsp->fw_id = 0; in wm_adsp2_event()
2045 dsp->fw_id_version = 0; in wm_adsp2_event()
2046 dsp->running = false; in wm_adsp2_event()
2048 regmap_update_bits(dsp->regmap, dsp->base + ADSP2_CONTROL, in wm_adsp2_event()
2053 regmap_write(dsp->regmap, dsp->base + ADSP2_WDMA_CONFIG_1, 0); in wm_adsp2_event()
2054 regmap_write(dsp->regmap, dsp->base + ADSP2_WDMA_CONFIG_2, 0); in wm_adsp2_event()
2055 regmap_write(dsp->regmap, dsp->base + ADSP2_RDMA_CONFIG_1, 0); in wm_adsp2_event()
2057 list_for_each_entry(ctl, &dsp->ctl_list, list) in wm_adsp2_event()
2060 while (!list_empty(&dsp->alg_regions)) { in wm_adsp2_event()
2061 alg_region = list_first_entry(&dsp->alg_regions, in wm_adsp2_event()
2068 adsp_dbg(dsp, "Shutdown complete\n"); in wm_adsp2_event()
2077 regmap_update_bits(dsp->regmap, dsp->base + ADSP2_CONTROL, in wm_adsp2_event()
2083 int wm_adsp2_codec_probe(struct wm_adsp *dsp, struct snd_soc_codec *codec) in wm_adsp2_codec_probe() argument
2085 wm_adsp2_init_debugfs(dsp, codec); in wm_adsp2_codec_probe()
2088 &wm_adsp_fw_controls[dsp->num - 1], in wm_adsp2_codec_probe()
2093 int wm_adsp2_codec_remove(struct wm_adsp *dsp, struct snd_soc_codec *codec) in wm_adsp2_codec_remove() argument
2095 wm_adsp2_cleanup_debugfs(dsp); in wm_adsp2_codec_remove()
2101 int wm_adsp2_init(struct wm_adsp *dsp) in wm_adsp2_init() argument
2109 ret = regmap_update_bits(dsp->regmap, dsp->base + ADSP2_CONTROL, in wm_adsp2_init()
2112 adsp_err(dsp, "Failed to clear memory retention: %d\n", ret); in wm_adsp2_init()
2116 INIT_LIST_HEAD(&dsp->alg_regions); in wm_adsp2_init()
2117 INIT_LIST_HEAD(&dsp->ctl_list); in wm_adsp2_init()
2118 INIT_WORK(&dsp->boot_work, wm_adsp2_boot_work); in wm_adsp2_init()
2121 mutex_init(&dsp->debugfs_lock); in wm_adsp2_init()