Lines Matching full:dsp
47 adsp_err(_obj->dsp, "%s: " fmt, _obj->name ? _obj->name : "legacy", \
50 adsp_dbg(_obj->dsp, "%s: " fmt, _obj->name ? _obj->name : "legacy", \
418 __be32 buf1_size; /* Size of buf1 area in DSP words */
420 __be32 buf1_buf2_size; /* Size of buf1+buf2 in DSP words */
422 __be32 buf_total_size; /* Size of buf1+buf2+buf3 in DSP words */
441 struct wm_adsp *dsp; member
458 struct wm_adsp *dsp; member
492 static int wm_adsp_buffer_init(struct wm_adsp *dsp);
493 static int wm_adsp_buffer_free(struct wm_adsp *dsp);
613 struct wm_adsp *dsp; member
650 static void wm_adsp_debugfs_save_wmfwname(struct wm_adsp *dsp, const char *s) in wm_adsp_debugfs_save_wmfwname() argument
654 kfree(dsp->wmfw_file_name); in wm_adsp_debugfs_save_wmfwname()
655 dsp->wmfw_file_name = tmp; in wm_adsp_debugfs_save_wmfwname()
658 static void wm_adsp_debugfs_save_binname(struct wm_adsp *dsp, const char *s) in wm_adsp_debugfs_save_binname() argument
662 kfree(dsp->bin_file_name); in wm_adsp_debugfs_save_binname()
663 dsp->bin_file_name = tmp; in wm_adsp_debugfs_save_binname()
666 static void wm_adsp_debugfs_clear(struct wm_adsp *dsp) in wm_adsp_debugfs_clear() argument
668 kfree(dsp->wmfw_file_name); in wm_adsp_debugfs_clear()
669 kfree(dsp->bin_file_name); in wm_adsp_debugfs_clear()
670 dsp->wmfw_file_name = NULL; in wm_adsp_debugfs_clear()
671 dsp->bin_file_name = NULL; in wm_adsp_debugfs_clear()
678 struct wm_adsp *dsp = file->private_data; in wm_adsp_debugfs_wmfw_read() local
681 mutex_lock(&dsp->pwr_lock); in wm_adsp_debugfs_wmfw_read()
683 if (!dsp->wmfw_file_name || !dsp->booted) in wm_adsp_debugfs_wmfw_read()
687 dsp->wmfw_file_name, in wm_adsp_debugfs_wmfw_read()
688 strlen(dsp->wmfw_file_name)); in wm_adsp_debugfs_wmfw_read()
690 mutex_unlock(&dsp->pwr_lock); in wm_adsp_debugfs_wmfw_read()
698 struct wm_adsp *dsp = file->private_data; in wm_adsp_debugfs_bin_read() local
701 mutex_lock(&dsp->pwr_lock); in wm_adsp_debugfs_bin_read()
703 if (!dsp->bin_file_name || !dsp->booted) in wm_adsp_debugfs_bin_read()
707 dsp->bin_file_name, in wm_adsp_debugfs_bin_read()
708 strlen(dsp->bin_file_name)); in wm_adsp_debugfs_bin_read()
710 mutex_unlock(&dsp->pwr_lock); in wm_adsp_debugfs_bin_read()
734 static void wm_adsp2_init_debugfs(struct wm_adsp *dsp, in wm_adsp2_init_debugfs() argument
740 root = debugfs_create_dir(dsp->name, component->debugfs_root); in wm_adsp2_init_debugfs()
742 debugfs_create_bool("booted", 0444, root, &dsp->booted); in wm_adsp2_init_debugfs()
743 debugfs_create_bool("running", 0444, root, &dsp->running); in wm_adsp2_init_debugfs()
744 debugfs_create_x32("fw_id", 0444, root, &dsp->fw_id); in wm_adsp2_init_debugfs()
745 debugfs_create_x32("fw_version", 0444, root, &dsp->fw_id_version); in wm_adsp2_init_debugfs()
749 dsp, &wm_adsp_debugfs_fops[i].fops); in wm_adsp2_init_debugfs()
751 dsp->debugfs_root = root; in wm_adsp2_init_debugfs()
754 static void wm_adsp2_cleanup_debugfs(struct wm_adsp *dsp) in wm_adsp2_cleanup_debugfs() argument
756 wm_adsp_debugfs_clear(dsp); in wm_adsp2_cleanup_debugfs()
757 debugfs_remove_recursive(dsp->debugfs_root); in wm_adsp2_cleanup_debugfs()
760 static inline void wm_adsp2_init_debugfs(struct wm_adsp *dsp, in wm_adsp2_init_debugfs() argument
765 static inline void wm_adsp2_cleanup_debugfs(struct wm_adsp *dsp) in wm_adsp2_cleanup_debugfs() argument
769 static inline void wm_adsp_debugfs_save_wmfwname(struct wm_adsp *dsp, in wm_adsp_debugfs_save_wmfwname() argument
774 static inline void wm_adsp_debugfs_save_binname(struct wm_adsp *dsp, in wm_adsp_debugfs_save_binname() argument
779 static inline void wm_adsp_debugfs_clear(struct wm_adsp *dsp) in wm_adsp_debugfs_clear() argument
789 struct wm_adsp *dsp = snd_soc_component_get_drvdata(component); in wm_adsp_fw_get() local
791 ucontrol->value.enumerated.item[0] = dsp[e->shift_l].fw; in wm_adsp_fw_get()
802 struct wm_adsp *dsp = snd_soc_component_get_drvdata(component); in wm_adsp_fw_put() local
805 if (ucontrol->value.enumerated.item[0] == dsp[e->shift_l].fw) in wm_adsp_fw_put()
811 mutex_lock(&dsp[e->shift_l].pwr_lock); in wm_adsp_fw_put()
813 if (dsp[e->shift_l].booted || !list_empty(&dsp[e->shift_l].compr_list)) in wm_adsp_fw_put()
816 dsp[e->shift_l].fw = ucontrol->value.enumerated.item[0]; in wm_adsp_fw_put()
818 mutex_unlock(&dsp[e->shift_l].pwr_lock); in wm_adsp_fw_put()
835 static struct wm_adsp_region const *wm_adsp_find_region(struct wm_adsp *dsp, in wm_adsp_find_region() argument
840 for (i = 0; i < dsp->num_mems; i++) in wm_adsp_find_region()
841 if (dsp->mem[i].type == type) in wm_adsp_find_region()
842 return &dsp->mem[i]; in wm_adsp_find_region()
882 static void wm_adsp_read_fw_status(struct wm_adsp *dsp, in wm_adsp_read_fw_status() argument
889 ret = regmap_read(dsp->regmap, dsp->base + offs[i], &offs[i]); in wm_adsp_read_fw_status()
891 adsp_err(dsp, "Failed to read SCRATCH%u: %d\n", i, ret); in wm_adsp_read_fw_status()
897 static void wm_adsp2_show_fw_status(struct wm_adsp *dsp) in wm_adsp2_show_fw_status() argument
903 wm_adsp_read_fw_status(dsp, ARRAY_SIZE(offs), offs); in wm_adsp2_show_fw_status()
905 adsp_dbg(dsp, "FW SCRATCH 0:0x%x 1:0x%x 2:0x%x 3:0x%x\n", in wm_adsp2_show_fw_status()
909 static void wm_adsp2v2_show_fw_status(struct wm_adsp *dsp) in wm_adsp2v2_show_fw_status() argument
913 wm_adsp_read_fw_status(dsp, ARRAY_SIZE(offs), offs); in wm_adsp2v2_show_fw_status()
915 adsp_dbg(dsp, "FW SCRATCH 0:0x%x 1:0x%x 2:0x%x 3:0x%x\n", in wm_adsp2v2_show_fw_status()
920 static void wm_halo_show_fw_status(struct wm_adsp *dsp) in wm_halo_show_fw_status() argument
926 wm_adsp_read_fw_status(dsp, ARRAY_SIZE(offs), offs); in wm_halo_show_fw_status()
928 adsp_dbg(dsp, "FW SCRATCH 0:0x%x 1:0x%x 2:0x%x 3:0x%x\n", in wm_halo_show_fw_status()
940 struct wm_adsp *dsp = ctl->dsp; in wm_coeff_base_reg() local
943 mem = wm_adsp_find_region(dsp, alg_region->type); in wm_coeff_base_reg()
945 adsp_err(dsp, "No base for region %x\n", in wm_coeff_base_reg()
950 *reg = dsp->ops->region_to_reg(mem, ctl->alg_region.base + ctl->offset); in wm_coeff_base_reg()
982 struct wm_adsp *dsp = ctl->dsp; in wm_coeff_write_acked_control() local
991 adsp_dbg(dsp, "Sending 0x%x to acked control alg 0x%x %s:0x%x\n", in wm_coeff_write_acked_control()
995 ret = regmap_raw_write(dsp->regmap, reg, &val, sizeof(val)); in wm_coeff_write_acked_control()
997 adsp_err(dsp, "Failed to write %x: %d\n", reg, ret); in wm_coeff_write_acked_control()
1019 ret = regmap_raw_read(dsp->regmap, reg, &val, sizeof(val)); in wm_coeff_write_acked_control()
1021 adsp_err(dsp, "Failed to read %x: %d\n", reg, ret); in wm_coeff_write_acked_control()
1026 adsp_dbg(dsp, "Acked control ACKED at poll %u\n", i); in wm_coeff_write_acked_control()
1031 adsp_warn(dsp, "Acked control @0x%x alg:0x%x %s:0x%x timed out\n", in wm_coeff_write_acked_control()
1042 struct wm_adsp *dsp = ctl->dsp; in wm_coeff_write_ctrl_raw() local
1055 ret = regmap_raw_write(dsp->regmap, reg, scratch, in wm_coeff_write_ctrl_raw()
1058 adsp_err(dsp, "Failed to write %zu bytes to %x: %d\n", in wm_coeff_write_ctrl_raw()
1063 adsp_dbg(dsp, "Wrote %zu bytes to %x\n", len, reg); in wm_coeff_write_ctrl_raw()
1081 if (ctl->enabled && ctl->dsp->running) in wm_coeff_write_ctrl()
1096 mutex_lock(&ctl->dsp->pwr_lock); in wm_coeff_put()
1098 mutex_unlock(&ctl->dsp->pwr_lock); in wm_coeff_put()
1111 mutex_lock(&ctl->dsp->pwr_lock); in wm_coeff_tlv_put()
1118 mutex_unlock(&ctl->dsp->pwr_lock); in wm_coeff_tlv_put()
1135 mutex_lock(&ctl->dsp->pwr_lock); in wm_coeff_put_acked()
1137 if (ctl->enabled && ctl->dsp->running) in wm_coeff_put_acked()
1142 mutex_unlock(&ctl->dsp->pwr_lock); in wm_coeff_put_acked()
1150 struct wm_adsp *dsp = ctl->dsp; in wm_coeff_read_ctrl_raw() local
1163 ret = regmap_raw_read(dsp->regmap, reg, scratch, len); in wm_coeff_read_ctrl_raw()
1165 adsp_err(dsp, "Failed to read %zu bytes from %x: %d\n", in wm_coeff_read_ctrl_raw()
1170 adsp_dbg(dsp, "Read %zu bytes from %x\n", len, reg); in wm_coeff_read_ctrl_raw()
1183 if (ctl->enabled && ctl->dsp->running) in wm_coeff_read_ctrl()
1188 if (!ctl->flags && ctl->enabled && ctl->dsp->running) in wm_coeff_read_ctrl()
1207 mutex_lock(&ctl->dsp->pwr_lock); in wm_coeff_get()
1209 mutex_unlock(&ctl->dsp->pwr_lock); in wm_coeff_get()
1222 mutex_lock(&ctl->dsp->pwr_lock); in wm_coeff_tlv_get()
1229 mutex_unlock(&ctl->dsp->pwr_lock); in wm_coeff_tlv_get()
1250 struct wm_adsp *dsp; member
1286 static int wmfw_add_ctl(struct wm_adsp *dsp, struct wm_coeff_ctl *ctl) in wmfw_add_ctl() argument
1322 ret = snd_soc_add_component_controls(dsp->component, kcontrol, 1); in wmfw_add_ctl()
1335 static int wm_coeff_init_control_caches(struct wm_adsp *dsp) in wm_coeff_init_control_caches() argument
1340 list_for_each_entry(ctl, &dsp->ctl_list, list) { in wm_coeff_init_control_caches()
1347 * For readable controls populate the cache from the DSP memory. in wm_coeff_init_control_caches()
1361 static int wm_coeff_sync_controls(struct wm_adsp *dsp) in wm_coeff_sync_controls() argument
1366 list_for_each_entry(ctl, &dsp->ctl_list, list) { in wm_coeff_sync_controls()
1380 static void wm_adsp_signal_event_controls(struct wm_adsp *dsp, in wm_adsp_signal_event_controls() argument
1386 list_for_each_entry(ctl, &dsp->ctl_list, list) { in wm_adsp_signal_event_controls()
1395 adsp_warn(dsp, in wm_adsp_signal_event_controls()
1407 wmfw_add_ctl(ctl_work->dsp, ctl_work->ctl); in wm_adsp_ctl_work()
1419 static int wm_adsp_create_control(struct wm_adsp *dsp, in wm_adsp_create_control() argument
1433 adsp_err(dsp, "Unknown region type: %d\n", alg_region->type); in wm_adsp_create_control()
1437 switch (dsp->fw_ver) { in wm_adsp_create_control()
1441 dsp->name, region_name, alg_region->alg); in wm_adsp_create_control()
1446 "%s%c %.12s %x", dsp->name, *region_name, in wm_adsp_create_control()
1447 wm_adsp_fw_text[dsp->fw], alg_region->alg); in wm_adsp_create_control()
1451 "%s %.12s %x", dsp->name, in wm_adsp_create_control()
1452 wm_adsp_fw_text[dsp->fw], alg_region->alg); in wm_adsp_create_control()
1460 if (dsp->component->name_prefix) in wm_adsp_create_control()
1461 avail -= strlen(dsp->component->name_prefix) + 1; in wm_adsp_create_control()
1471 list_for_each_entry(ctl, &dsp->ctl_list, list) { in wm_adsp_create_control()
1482 ctl->fw_name = wm_adsp_fw_text[dsp->fw]; in wm_adsp_create_control()
1502 ctl->dsp = dsp; in wm_adsp_create_control()
1514 list_add(&ctl->list, &dsp->ctl_list); in wm_adsp_create_control()
1525 ctl_work->dsp = dsp; in wm_adsp_create_control()
1605 static inline void wm_coeff_parse_alg(struct wm_adsp *dsp, const u8 **data, in wm_coeff_parse_alg() argument
1610 switch (dsp->fw_ver) { in wm_coeff_parse_alg()
1630 adsp_dbg(dsp, "Algorithm ID: %#x\n", blk->id); in wm_coeff_parse_alg()
1631 adsp_dbg(dsp, "Algorithm name: %.*s\n", blk->name_len, blk->name); in wm_coeff_parse_alg()
1632 adsp_dbg(dsp, "# of coefficient descriptors: %#x\n", blk->ncoeff); in wm_coeff_parse_alg()
1635 static inline void wm_coeff_parse_coeff(struct wm_adsp *dsp, const u8 **data, in wm_coeff_parse_coeff() argument
1642 switch (dsp->fw_ver) { in wm_coeff_parse_coeff()
1673 adsp_dbg(dsp, "\tCoefficient type: %#x\n", blk->mem_type); in wm_coeff_parse_coeff()
1674 adsp_dbg(dsp, "\tCoefficient offset: %#x\n", blk->offset); in wm_coeff_parse_coeff()
1675 adsp_dbg(dsp, "\tCoefficient name: %.*s\n", blk->name_len, blk->name); in wm_coeff_parse_coeff()
1676 adsp_dbg(dsp, "\tCoefficient flags: %#x\n", blk->flags); in wm_coeff_parse_coeff()
1677 adsp_dbg(dsp, "\tALSA control type: %#x\n", blk->ctl_type); in wm_coeff_parse_coeff()
1678 adsp_dbg(dsp, "\tALSA control len: %#x\n", blk->len); in wm_coeff_parse_coeff()
1681 static int wm_adsp_check_coeff_flags(struct wm_adsp *dsp, in wm_adsp_check_coeff_flags() argument
1688 adsp_err(dsp, "Illegal flags 0x%x for control type 0x%x\n", in wm_adsp_check_coeff_flags()
1696 static int wm_adsp_parse_coeff(struct wm_adsp *dsp, in wm_adsp_parse_coeff() argument
1705 wm_coeff_parse_alg(dsp, &data, &alg_blk); in wm_adsp_parse_coeff()
1707 wm_coeff_parse_coeff(dsp, &data, &coeff_blk); in wm_adsp_parse_coeff()
1716 ret = wm_adsp_check_coeff_flags(dsp, &coeff_blk, in wm_adsp_parse_coeff()
1725 ret = wm_adsp_check_coeff_flags(dsp, &coeff_blk, in wm_adsp_parse_coeff()
1735 ret = wm_adsp_check_coeff_flags(dsp, &coeff_blk, in wm_adsp_parse_coeff()
1744 adsp_err(dsp, "Unknown control type: %d\n", in wm_adsp_parse_coeff()
1752 ret = wm_adsp_create_control(dsp, &alg_region, in wm_adsp_parse_coeff()
1760 adsp_err(dsp, "Failed to create control: %.*s, %d\n", in wm_adsp_parse_coeff()
1767 static unsigned int wm_adsp1_parse_sizes(struct wm_adsp *dsp, in wm_adsp1_parse_sizes() argument
1776 adsp_dbg(dsp, "%s: %d DM, %d PM, %d ZM\n", file, in wm_adsp1_parse_sizes()
1783 static unsigned int wm_adsp2_parse_sizes(struct wm_adsp *dsp, in wm_adsp2_parse_sizes() argument
1792 adsp_dbg(dsp, "%s: %d XM, %d YM %d PM, %d ZM\n", file, in wm_adsp2_parse_sizes()
1799 static bool wm_adsp_validate_version(struct wm_adsp *dsp, unsigned int version) in wm_adsp_validate_version() argument
1803 adsp_warn(dsp, "Deprecated file format %d\n", version); in wm_adsp_validate_version()
1813 static bool wm_halo_validate_version(struct wm_adsp *dsp, unsigned int version) in wm_halo_validate_version() argument
1823 static int wm_adsp_load(struct wm_adsp *dsp) in wm_adsp_load() argument
1827 struct regmap *regmap = dsp->regmap; in wm_adsp_load()
1845 snprintf(file, PAGE_SIZE, "%s-%s-%s.wmfw", dsp->part, dsp->fwf_name, in wm_adsp_load()
1846 wm_adsp_fw[dsp->fw].file); in wm_adsp_load()
1849 ret = request_firmware(&firmware, file, dsp->dev); in wm_adsp_load()
1851 adsp_err(dsp, "Failed to request '%s'\n", file); in wm_adsp_load()
1858 adsp_err(dsp, "%s: file too short, %zu bytes\n", in wm_adsp_load()
1866 adsp_err(dsp, "%s: invalid magic\n", file); in wm_adsp_load()
1870 if (!dsp->ops->validate_version(dsp, header->ver)) { in wm_adsp_load()
1871 adsp_err(dsp, "%s: unknown file format %d\n", in wm_adsp_load()
1876 adsp_info(dsp, "Firmware version: %d\n", header->ver); in wm_adsp_load()
1877 dsp->fw_ver = header->ver; in wm_adsp_load()
1879 if (header->core != dsp->type) { in wm_adsp_load()
1880 adsp_err(dsp, "%s: invalid core %d != %d\n", in wm_adsp_load()
1881 file, header->core, dsp->type); in wm_adsp_load()
1886 pos = dsp->ops->parse_sizes(dsp, file, pos, firmware); in wm_adsp_load()
1892 adsp_err(dsp, "%s: unexpected header length %d\n", in wm_adsp_load()
1897 adsp_dbg(dsp, "%s: timestamp %llu\n", file, in wm_adsp_load()
1917 ret = wm_adsp_parse_coeff(dsp, region); in wm_adsp_load()
1938 mem = wm_adsp_find_region(dsp, type); in wm_adsp_load()
1940 adsp_err(dsp, "No region of type: %x\n", type); in wm_adsp_load()
1946 reg = dsp->ops->region_to_reg(mem, offset); in wm_adsp_load()
1949 adsp_warn(dsp, in wm_adsp_load()
1955 adsp_dbg(dsp, "%s.%d: %d bytes at %d in %s\n", file, in wm_adsp_load()
1961 adsp_err(dsp, in wm_adsp_load()
1971 adsp_info(dsp, "%s: %s\n", file, text); in wm_adsp_load()
1981 adsp_err(dsp, "Out of memory\n"); in wm_adsp_load()
1989 adsp_err(dsp, in wm_adsp_load()
2004 adsp_err(dsp, "Failed to complete async write: %d\n", ret); in wm_adsp_load()
2009 adsp_warn(dsp, "%s.%d: %zu bytes at end of file\n", in wm_adsp_load()
2012 wm_adsp_debugfs_save_wmfwname(dsp, file); in wm_adsp_load()
2029 static struct wm_coeff_ctl *wm_adsp_get_ctl(struct wm_adsp *dsp, in wm_adsp_get_ctl() argument
2034 const char *fw_txt = wm_adsp_fw_text[dsp->fw]; in wm_adsp_get_ctl()
2036 list_for_each_entry(pos, &dsp->ctl_list, list) { in wm_adsp_get_ctl()
2052 int wm_adsp_write_ctl(struct wm_adsp *dsp, const char *name, int type, in wm_adsp_write_ctl() argument
2060 ctl = wm_adsp_get_ctl(dsp, name, type, alg); in wm_adsp_write_ctl()
2074 if (dsp->component->name_prefix) in wm_adsp_write_ctl()
2076 dsp->component->name_prefix, ctl->name); in wm_adsp_write_ctl()
2081 kcontrol = snd_soc_card_get_kcontrol(dsp->component->card, ctl_name); in wm_adsp_write_ctl()
2083 adsp_err(dsp, "Can't find kcontrol %s\n", ctl_name); in wm_adsp_write_ctl()
2087 snd_ctl_notify(dsp->component->card->snd_card, in wm_adsp_write_ctl()
2094 int wm_adsp_read_ctl(struct wm_adsp *dsp, const char *name, int type, in wm_adsp_read_ctl() argument
2099 ctl = wm_adsp_get_ctl(dsp, name, type, alg); in wm_adsp_read_ctl()
2110 static void wm_adsp_ctl_fixup_base(struct wm_adsp *dsp, in wm_adsp_ctl_fixup_base() argument
2115 list_for_each_entry(ctl, &dsp->ctl_list, list) { in wm_adsp_ctl_fixup_base()
2116 if (ctl->fw_name == wm_adsp_fw_text[dsp->fw] && in wm_adsp_ctl_fixup_base()
2124 static void *wm_adsp_read_algs(struct wm_adsp *dsp, size_t n_algs, in wm_adsp_read_algs() argument
2134 adsp_err(dsp, "No algorithms\n"); in wm_adsp_read_algs()
2139 adsp_err(dsp, "Algorithm count %zx excessive\n", n_algs); in wm_adsp_read_algs()
2144 reg = dsp->ops->region_to_reg(mem, pos + len); in wm_adsp_read_algs()
2146 ret = regmap_raw_read(dsp->regmap, reg, &val, sizeof(val)); in wm_adsp_read_algs()
2148 adsp_err(dsp, "Failed to read algorithm list end: %d\n", in wm_adsp_read_algs()
2154 adsp_warn(dsp, "Algorithm list end %x 0x%x != 0xbedead\n", in wm_adsp_read_algs()
2157 /* Convert length from DSP words to bytes */ in wm_adsp_read_algs()
2164 reg = dsp->ops->region_to_reg(mem, pos); in wm_adsp_read_algs()
2166 ret = regmap_raw_read(dsp->regmap, reg, alg, len); in wm_adsp_read_algs()
2168 adsp_err(dsp, "Failed to read algorithm list: %d\n", ret); in wm_adsp_read_algs()
2177 wm_adsp_find_alg_region(struct wm_adsp *dsp, int type, unsigned int id) in wm_adsp_find_alg_region() argument
2181 list_for_each_entry(alg_region, &dsp->alg_regions, list) { in wm_adsp_find_alg_region()
2189 static struct wm_adsp_alg_region *wm_adsp_create_region(struct wm_adsp *dsp, in wm_adsp_create_region() argument
2203 list_add_tail(&alg_region->list, &dsp->alg_regions); in wm_adsp_create_region()
2205 if (dsp->fw_ver > 0) in wm_adsp_create_region()
2206 wm_adsp_ctl_fixup_base(dsp, alg_region); in wm_adsp_create_region()
2211 static void wm_adsp_free_alg_regions(struct wm_adsp *dsp) in wm_adsp_free_alg_regions() argument
2215 while (!list_empty(&dsp->alg_regions)) { in wm_adsp_free_alg_regions()
2216 alg_region = list_first_entry(&dsp->alg_regions, in wm_adsp_free_alg_regions()
2224 static void wmfw_parse_id_header(struct wm_adsp *dsp, in wmfw_parse_id_header() argument
2227 dsp->fw_id = be32_to_cpu(fw->id); in wmfw_parse_id_header()
2228 dsp->fw_id_version = be32_to_cpu(fw->ver); in wmfw_parse_id_header()
2230 adsp_info(dsp, "Firmware: %x v%d.%d.%d, %d algorithms\n", in wmfw_parse_id_header()
2231 dsp->fw_id, (dsp->fw_id_version & 0xff0000) >> 16, in wmfw_parse_id_header()
2232 (dsp->fw_id_version & 0xff00) >> 8, dsp->fw_id_version & 0xff, in wmfw_parse_id_header()
2236 static void wmfw_v3_parse_id_header(struct wm_adsp *dsp, in wmfw_v3_parse_id_header() argument
2239 dsp->fw_id = be32_to_cpu(fw->id); in wmfw_v3_parse_id_header()
2240 dsp->fw_id_version = be32_to_cpu(fw->ver); in wmfw_v3_parse_id_header()
2241 dsp->fw_vendor_id = be32_to_cpu(fw->vendor_id); in wmfw_v3_parse_id_header()
2243 adsp_info(dsp, "Firmware: %x vendor: 0x%x v%d.%d.%d, %d algorithms\n", in wmfw_v3_parse_id_header()
2244 dsp->fw_id, dsp->fw_vendor_id, in wmfw_v3_parse_id_header()
2245 (dsp->fw_id_version & 0xff0000) >> 16, in wmfw_v3_parse_id_header()
2246 (dsp->fw_id_version & 0xff00) >> 8, dsp->fw_id_version & 0xff, in wmfw_v3_parse_id_header()
2250 static int wm_adsp_create_regions(struct wm_adsp *dsp, __be32 id, int nregions, in wm_adsp_create_regions() argument
2257 alg_region = wm_adsp_create_region(dsp, type[i], id, base[i]); in wm_adsp_create_regions()
2265 static int wm_adsp1_setup_algs(struct wm_adsp *dsp) in wm_adsp1_setup_algs() argument
2275 mem = wm_adsp_find_region(dsp, WMFW_ADSP1_DM); in wm_adsp1_setup_algs()
2279 ret = regmap_raw_read(dsp->regmap, mem->base, &adsp1_id, in wm_adsp1_setup_algs()
2282 adsp_err(dsp, "Failed to read algorithm info: %d\n", in wm_adsp1_setup_algs()
2289 wmfw_parse_id_header(dsp, &adsp1_id.fw, n_algs); in wm_adsp1_setup_algs()
2291 alg_region = wm_adsp_create_region(dsp, WMFW_ADSP1_ZM, in wm_adsp1_setup_algs()
2296 alg_region = wm_adsp_create_region(dsp, WMFW_ADSP1_DM, in wm_adsp1_setup_algs()
2301 /* Calculate offset and length in DSP words */ in wm_adsp1_setup_algs()
2305 adsp1_alg = wm_adsp_read_algs(dsp, n_algs, mem, pos, len); in wm_adsp1_setup_algs()
2310 adsp_info(dsp, "%d: ID %x v%d.%d.%d DM@%x ZM@%x\n", in wm_adsp1_setup_algs()
2318 alg_region = wm_adsp_create_region(dsp, WMFW_ADSP1_DM, in wm_adsp1_setup_algs()
2325 if (dsp->fw_ver == 0) { in wm_adsp1_setup_algs()
2330 wm_adsp_create_control(dsp, alg_region, 0, in wm_adsp1_setup_algs()
2334 adsp_warn(dsp, "Missing length info for region DM with ID %x\n", in wm_adsp1_setup_algs()
2339 alg_region = wm_adsp_create_region(dsp, WMFW_ADSP1_ZM, in wm_adsp1_setup_algs()
2346 if (dsp->fw_ver == 0) { in wm_adsp1_setup_algs()
2351 wm_adsp_create_control(dsp, alg_region, 0, in wm_adsp1_setup_algs()
2355 adsp_warn(dsp, "Missing length info for region ZM with ID %x\n", in wm_adsp1_setup_algs()
2366 static int wm_adsp2_setup_algs(struct wm_adsp *dsp) in wm_adsp2_setup_algs() argument
2376 mem = wm_adsp_find_region(dsp, WMFW_ADSP2_XM); in wm_adsp2_setup_algs()
2380 ret = regmap_raw_read(dsp->regmap, mem->base, &adsp2_id, in wm_adsp2_setup_algs()
2383 adsp_err(dsp, "Failed to read algorithm info: %d\n", in wm_adsp2_setup_algs()
2390 wmfw_parse_id_header(dsp, &adsp2_id.fw, n_algs); in wm_adsp2_setup_algs()
2392 alg_region = wm_adsp_create_region(dsp, WMFW_ADSP2_XM, in wm_adsp2_setup_algs()
2397 alg_region = wm_adsp_create_region(dsp, WMFW_ADSP2_YM, in wm_adsp2_setup_algs()
2402 alg_region = wm_adsp_create_region(dsp, WMFW_ADSP2_ZM, in wm_adsp2_setup_algs()
2407 /* Calculate offset and length in DSP words */ in wm_adsp2_setup_algs()
2411 adsp2_alg = wm_adsp_read_algs(dsp, n_algs, mem, pos, len); in wm_adsp2_setup_algs()
2416 adsp_info(dsp, in wm_adsp2_setup_algs()
2426 alg_region = wm_adsp_create_region(dsp, WMFW_ADSP2_XM, in wm_adsp2_setup_algs()
2433 if (dsp->fw_ver == 0) { in wm_adsp2_setup_algs()
2438 wm_adsp_create_control(dsp, alg_region, 0, in wm_adsp2_setup_algs()
2442 adsp_warn(dsp, "Missing length info for region XM with ID %x\n", in wm_adsp2_setup_algs()
2447 alg_region = wm_adsp_create_region(dsp, WMFW_ADSP2_YM, in wm_adsp2_setup_algs()
2454 if (dsp->fw_ver == 0) { in wm_adsp2_setup_algs()
2459 wm_adsp_create_control(dsp, alg_region, 0, in wm_adsp2_setup_algs()
2463 adsp_warn(dsp, "Missing length info for region YM with ID %x\n", in wm_adsp2_setup_algs()
2468 alg_region = wm_adsp_create_region(dsp, WMFW_ADSP2_ZM, in wm_adsp2_setup_algs()
2475 if (dsp->fw_ver == 0) { in wm_adsp2_setup_algs()
2480 wm_adsp_create_control(dsp, alg_region, 0, in wm_adsp2_setup_algs()
2484 adsp_warn(dsp, "Missing length info for region ZM with ID %x\n", in wm_adsp2_setup_algs()
2495 static int wm_halo_create_regions(struct wm_adsp *dsp, __be32 id, in wm_halo_create_regions() argument
2504 return wm_adsp_create_regions(dsp, id, ARRAY_SIZE(types), types, bases); in wm_halo_create_regions()
2507 static int wm_halo_setup_algs(struct wm_adsp *dsp) in wm_halo_setup_algs() argument
2516 mem = wm_adsp_find_region(dsp, WMFW_ADSP2_XM); in wm_halo_setup_algs()
2520 ret = regmap_raw_read(dsp->regmap, mem->base, &halo_id, in wm_halo_setup_algs()
2523 adsp_err(dsp, "Failed to read algorithm info: %d\n", in wm_halo_setup_algs()
2530 wmfw_v3_parse_id_header(dsp, &halo_id.fw, n_algs); in wm_halo_setup_algs()
2532 ret = wm_halo_create_regions(dsp, halo_id.fw.id, in wm_halo_setup_algs()
2537 /* Calculate offset and length in DSP words */ in wm_halo_setup_algs()
2541 halo_alg = wm_adsp_read_algs(dsp, n_algs, mem, pos, len); in wm_halo_setup_algs()
2546 adsp_info(dsp, in wm_halo_setup_algs()
2555 ret = wm_halo_create_regions(dsp, halo_alg[i].alg.id, in wm_halo_setup_algs()
2567 static int wm_adsp_load_coeff(struct wm_adsp *dsp) in wm_adsp_load_coeff() argument
2570 struct regmap *regmap = dsp->regmap; in wm_adsp_load_coeff()
2585 snprintf(file, PAGE_SIZE, "%s-%s-%s.bin", dsp->part, dsp->fwf_name, in wm_adsp_load_coeff()
2586 wm_adsp_fw[dsp->fw].file); in wm_adsp_load_coeff()
2589 ret = request_firmware(&firmware, file, dsp->dev); in wm_adsp_load_coeff()
2591 adsp_warn(dsp, "Failed to request '%s'\n", file); in wm_adsp_load_coeff()
2598 adsp_err(dsp, "%s: file too short, %zu bytes\n", in wm_adsp_load_coeff()
2605 adsp_err(dsp, "%s: invalid magic\n", file); in wm_adsp_load_coeff()
2613 adsp_err(dsp, "%s: Unsupported coefficient file format %d\n", in wm_adsp_load_coeff()
2619 adsp_dbg(dsp, "%s: v%d.%d.%d\n", file, in wm_adsp_load_coeff()
2634 adsp_dbg(dsp, "%s.%d: %x v%d.%d.%d\n", in wm_adsp_load_coeff()
2639 adsp_dbg(dsp, "%s.%d: %d bytes at 0x%x in %x\n", in wm_adsp_load_coeff()
2654 if (le32_to_cpu(blk->id) == dsp->fw_id && in wm_adsp_load_coeff()
2657 mem = wm_adsp_find_region(dsp, type); in wm_adsp_load_coeff()
2659 adsp_err(dsp, "No ZM\n"); in wm_adsp_load_coeff()
2662 reg = dsp->ops->region_to_reg(mem, 0); in wm_adsp_load_coeff()
2677 adsp_dbg(dsp, "%s.%d: %d bytes in %x for %x\n", in wm_adsp_load_coeff()
2681 mem = wm_adsp_find_region(dsp, type); in wm_adsp_load_coeff()
2683 adsp_err(dsp, "No base for region %x\n", type); in wm_adsp_load_coeff()
2687 alg_region = wm_adsp_find_alg_region(dsp, type, in wm_adsp_load_coeff()
2691 reg = dsp->ops->region_to_reg(mem, reg); in wm_adsp_load_coeff()
2694 adsp_err(dsp, "No %x for algorithm %x\n", in wm_adsp_load_coeff()
2700 adsp_err(dsp, "%s.%d: Unknown region type %x at %d\n", in wm_adsp_load_coeff()
2708 adsp_err(dsp, in wm_adsp_load_coeff()
2721 adsp_err(dsp, "Out of memory\n"); in wm_adsp_load_coeff()
2726 adsp_dbg(dsp, "%s.%d: Writing %d bytes at %x\n", in wm_adsp_load_coeff()
2732 adsp_err(dsp, in wm_adsp_load_coeff()
2744 adsp_err(dsp, "Failed to complete async write: %d\n", ret); in wm_adsp_load_coeff()
2747 adsp_warn(dsp, "%s.%d: %zu bytes at end of file\n", in wm_adsp_load_coeff()
2750 wm_adsp_debugfs_save_binname(dsp, file); in wm_adsp_load_coeff()
2761 static int wm_adsp_create_name(struct wm_adsp *dsp) in wm_adsp_create_name() argument
2765 if (!dsp->name) { in wm_adsp_create_name()
2766 dsp->name = devm_kasprintf(dsp->dev, GFP_KERNEL, "DSP%d", in wm_adsp_create_name()
2767 dsp->num); in wm_adsp_create_name()
2768 if (!dsp->name) in wm_adsp_create_name()
2772 if (!dsp->fwf_name) { in wm_adsp_create_name()
2773 p = devm_kstrdup(dsp->dev, dsp->name, GFP_KERNEL); in wm_adsp_create_name()
2777 dsp->fwf_name = p; in wm_adsp_create_name()
2785 static int wm_adsp_common_init(struct wm_adsp *dsp) in wm_adsp_common_init() argument
2789 ret = wm_adsp_create_name(dsp); in wm_adsp_common_init()
2793 INIT_LIST_HEAD(&dsp->alg_regions); in wm_adsp_common_init()
2794 INIT_LIST_HEAD(&dsp->ctl_list); in wm_adsp_common_init()
2795 INIT_LIST_HEAD(&dsp->compr_list); in wm_adsp_common_init()
2796 INIT_LIST_HEAD(&dsp->buffer_list); in wm_adsp_common_init()
2798 mutex_init(&dsp->pwr_lock); in wm_adsp_common_init()
2803 int wm_adsp1_init(struct wm_adsp *dsp) in wm_adsp1_init() argument
2805 dsp->ops = &wm_adsp1_ops; in wm_adsp1_init()
2807 return wm_adsp_common_init(dsp); in wm_adsp1_init()
2817 struct wm_adsp *dsp = &dsps[w->shift]; in wm_adsp1_event() local
2822 dsp->component = component; in wm_adsp1_event()
2824 mutex_lock(&dsp->pwr_lock); in wm_adsp1_event()
2828 regmap_update_bits(dsp->regmap, dsp->base + ADSP1_CONTROL_30, in wm_adsp1_event()
2832 * For simplicity set the DSP clock rate to be the in wm_adsp1_event()
2835 if (dsp->sysclk_reg) { in wm_adsp1_event()
2836 ret = regmap_read(dsp->regmap, dsp->sysclk_reg, &val); in wm_adsp1_event()
2838 adsp_err(dsp, "Failed to read SYSCLK state: %d\n", in wm_adsp1_event()
2843 val = (val & dsp->sysclk_mask) >> dsp->sysclk_shift; in wm_adsp1_event()
2845 ret = regmap_update_bits(dsp->regmap, in wm_adsp1_event()
2846 dsp->base + ADSP1_CONTROL_31, in wm_adsp1_event()
2849 adsp_err(dsp, "Failed to set clock rate: %d\n", in wm_adsp1_event()
2855 ret = wm_adsp_load(dsp); in wm_adsp1_event()
2859 ret = wm_adsp1_setup_algs(dsp); in wm_adsp1_event()
2863 ret = wm_adsp_load_coeff(dsp); in wm_adsp1_event()
2868 ret = wm_coeff_init_control_caches(dsp); in wm_adsp1_event()
2873 ret = wm_coeff_sync_controls(dsp); in wm_adsp1_event()
2877 dsp->booted = true; in wm_adsp1_event()
2880 regmap_update_bits(dsp->regmap, dsp->base + ADSP1_CONTROL_30, in wm_adsp1_event()
2884 dsp->running = true; in wm_adsp1_event()
2888 dsp->running = false; in wm_adsp1_event()
2889 dsp->booted = false; in wm_adsp1_event()
2892 regmap_update_bits(dsp->regmap, dsp->base + ADSP1_CONTROL_30, in wm_adsp1_event()
2895 regmap_update_bits(dsp->regmap, dsp->base + ADSP1_CONTROL_19, in wm_adsp1_event()
2898 regmap_update_bits(dsp->regmap, dsp->base + ADSP1_CONTROL_30, in wm_adsp1_event()
2901 list_for_each_entry(ctl, &dsp->ctl_list, list) in wm_adsp1_event()
2905 wm_adsp_free_alg_regions(dsp); in wm_adsp1_event()
2912 mutex_unlock(&dsp->pwr_lock); in wm_adsp1_event()
2917 regmap_update_bits(dsp->regmap, dsp->base + ADSP1_CONTROL_30, in wm_adsp1_event()
2920 mutex_unlock(&dsp->pwr_lock); in wm_adsp1_event()
2926 static int wm_adsp2v2_enable_core(struct wm_adsp *dsp) in wm_adsp2v2_enable_core() argument
2933 ret = regmap_read(dsp->regmap, dsp->base + ADSP2_STATUS1, &val); in wm_adsp2v2_enable_core()
2944 adsp_err(dsp, "Failed to start DSP RAM\n"); in wm_adsp2v2_enable_core()
2948 adsp_dbg(dsp, "RAM ready after %d polls\n", count); in wm_adsp2v2_enable_core()
2953 static int wm_adsp2_enable_core(struct wm_adsp *dsp) in wm_adsp2_enable_core() argument
2957 ret = regmap_update_bits_async(dsp->regmap, dsp->base + ADSP2_CONTROL, in wm_adsp2_enable_core()
2962 return wm_adsp2v2_enable_core(dsp); in wm_adsp2_enable_core()
2965 static int wm_adsp2_lock(struct wm_adsp *dsp, unsigned int lock_regions) in wm_adsp2_lock() argument
2967 struct regmap *regmap = dsp->regmap; in wm_adsp2_lock()
2974 lock_reg = dsp->base + ADSP2_LOCK_REGION_1_LOCK_REGION_0; in wm_adsp2_lock()
2995 static int wm_adsp2_enable_memory(struct wm_adsp *dsp) in wm_adsp2_enable_memory() argument
2997 return regmap_update_bits(dsp->regmap, dsp->base + ADSP2_CONTROL, in wm_adsp2_enable_memory()
3001 static void wm_adsp2_disable_memory(struct wm_adsp *dsp) in wm_adsp2_disable_memory() argument
3003 regmap_update_bits(dsp->regmap, dsp->base + ADSP2_CONTROL, in wm_adsp2_disable_memory()
3007 static void wm_adsp2_disable_core(struct wm_adsp *dsp) in wm_adsp2_disable_core() argument
3009 regmap_write(dsp->regmap, dsp->base + ADSP2_RDMA_CONFIG_1, 0); in wm_adsp2_disable_core()
3010 regmap_write(dsp->regmap, dsp->base + ADSP2_WDMA_CONFIG_1, 0); in wm_adsp2_disable_core()
3011 regmap_write(dsp->regmap, dsp->base + ADSP2_WDMA_CONFIG_2, 0); in wm_adsp2_disable_core()
3013 regmap_update_bits(dsp->regmap, dsp->base + ADSP2_CONTROL, in wm_adsp2_disable_core()
3017 static void wm_adsp2v2_disable_core(struct wm_adsp *dsp) in wm_adsp2v2_disable_core() argument
3019 regmap_write(dsp->regmap, dsp->base + ADSP2_RDMA_CONFIG_1, 0); in wm_adsp2v2_disable_core()
3020 regmap_write(dsp->regmap, dsp->base + ADSP2_WDMA_CONFIG_1, 0); in wm_adsp2v2_disable_core()
3021 regmap_write(dsp->regmap, dsp->base + ADSP2V2_WDMA_CONFIG_2, 0); in wm_adsp2v2_disable_core()
3026 struct wm_adsp *dsp = container_of(work, in wm_adsp_boot_work() local
3031 mutex_lock(&dsp->pwr_lock); in wm_adsp_boot_work()
3033 if (dsp->ops->enable_memory) { in wm_adsp_boot_work()
3034 ret = dsp->ops->enable_memory(dsp); in wm_adsp_boot_work()
3039 if (dsp->ops->enable_core) { in wm_adsp_boot_work()
3040 ret = dsp->ops->enable_core(dsp); in wm_adsp_boot_work()
3045 ret = wm_adsp_load(dsp); in wm_adsp_boot_work()
3049 ret = dsp->ops->setup_algs(dsp); in wm_adsp_boot_work()
3053 ret = wm_adsp_load_coeff(dsp); in wm_adsp_boot_work()
3058 ret = wm_coeff_init_control_caches(dsp); in wm_adsp_boot_work()
3062 if (dsp->ops->disable_core) in wm_adsp_boot_work()
3063 dsp->ops->disable_core(dsp); in wm_adsp_boot_work()
3065 dsp->booted = true; in wm_adsp_boot_work()
3067 mutex_unlock(&dsp->pwr_lock); in wm_adsp_boot_work()
3072 if (dsp->ops->disable_core) in wm_adsp_boot_work()
3073 dsp->ops->disable_core(dsp); in wm_adsp_boot_work()
3075 if (dsp->ops->disable_memory) in wm_adsp_boot_work()
3076 dsp->ops->disable_memory(dsp); in wm_adsp_boot_work()
3078 mutex_unlock(&dsp->pwr_lock); in wm_adsp_boot_work()
3081 static int wm_halo_configure_mpu(struct wm_adsp *dsp, unsigned int lock_regions) in wm_halo_configure_mpu() argument
3084 { dsp->base + HALO_MPU_LOCK_CONFIG, 0x5555 }, in wm_halo_configure_mpu()
3085 { dsp->base + HALO_MPU_LOCK_CONFIG, 0xAAAA }, in wm_halo_configure_mpu()
3086 { dsp->base + HALO_MPU_XMEM_ACCESS_0, 0xFFFFFFFF }, in wm_halo_configure_mpu()
3087 { dsp->base + HALO_MPU_YMEM_ACCESS_0, 0xFFFFFFFF }, in wm_halo_configure_mpu()
3088 { dsp->base + HALO_MPU_WINDOW_ACCESS_0, lock_regions }, in wm_halo_configure_mpu()
3089 { dsp->base + HALO_MPU_XREG_ACCESS_0, lock_regions }, in wm_halo_configure_mpu()
3090 { dsp->base + HALO_MPU_YREG_ACCESS_0, lock_regions }, in wm_halo_configure_mpu()
3091 { dsp->base + HALO_MPU_XMEM_ACCESS_1, 0xFFFFFFFF }, in wm_halo_configure_mpu()
3092 { dsp->base + HALO_MPU_YMEM_ACCESS_1, 0xFFFFFFFF }, in wm_halo_configure_mpu()
3093 { dsp->base + HALO_MPU_WINDOW_ACCESS_1, lock_regions }, in wm_halo_configure_mpu()
3094 { dsp->base + HALO_MPU_XREG_ACCESS_1, lock_regions }, in wm_halo_configure_mpu()
3095 { dsp->base + HALO_MPU_YREG_ACCESS_1, lock_regions }, in wm_halo_configure_mpu()
3096 { dsp->base + HALO_MPU_XMEM_ACCESS_2, 0xFFFFFFFF }, in wm_halo_configure_mpu()
3097 { dsp->base + HALO_MPU_YMEM_ACCESS_2, 0xFFFFFFFF }, in wm_halo_configure_mpu()
3098 { dsp->base + HALO_MPU_WINDOW_ACCESS_2, lock_regions }, in wm_halo_configure_mpu()
3099 { dsp->base + HALO_MPU_XREG_ACCESS_2, lock_regions }, in wm_halo_configure_mpu()
3100 { dsp->base + HALO_MPU_YREG_ACCESS_2, lock_regions }, in wm_halo_configure_mpu()
3101 { dsp->base + HALO_MPU_XMEM_ACCESS_3, 0xFFFFFFFF }, in wm_halo_configure_mpu()
3102 { dsp->base + HALO_MPU_YMEM_ACCESS_3, 0xFFFFFFFF }, in wm_halo_configure_mpu()
3103 { dsp->base + HALO_MPU_WINDOW_ACCESS_3, lock_regions }, in wm_halo_configure_mpu()
3104 { dsp->base + HALO_MPU_XREG_ACCESS_3, lock_regions }, in wm_halo_configure_mpu()
3105 { dsp->base + HALO_MPU_YREG_ACCESS_3, lock_regions }, in wm_halo_configure_mpu()
3106 { dsp->base + HALO_MPU_LOCK_CONFIG, 0 }, in wm_halo_configure_mpu()
3109 return regmap_multi_reg_write(dsp->regmap, config, ARRAY_SIZE(config)); in wm_halo_configure_mpu()
3116 struct wm_adsp *dsp = &dsps[w->shift]; in wm_adsp2_set_dspclk() local
3119 ret = regmap_update_bits(dsp->regmap, dsp->base + ADSP2_CLOCKING, in wm_adsp2_set_dspclk()
3123 adsp_err(dsp, "Failed to set clock rate: %d\n", ret); in wm_adsp2_set_dspclk()
3136 struct wm_adsp *dsp = &dsps[mc->shift - 1]; in wm_adsp2_preloader_get() local
3138 ucontrol->value.integer.value[0] = dsp->preloaded; in wm_adsp2_preloader_get()
3152 struct wm_adsp *dsp = &dsps[mc->shift - 1]; in wm_adsp2_preloader_put() local
3155 snprintf(preload, ARRAY_SIZE(preload), "%s Preload", dsp->name); in wm_adsp2_preloader_put()
3157 dsp->preloaded = ucontrol->value.integer.value[0]; in wm_adsp2_preloader_put()
3166 flush_work(&dsp->boot_work); in wm_adsp2_preloader_put()
3172 static void wm_adsp_stop_watchdog(struct wm_adsp *dsp) in wm_adsp_stop_watchdog() argument
3174 regmap_update_bits(dsp->regmap, dsp->base + ADSP2_WATCHDOG, in wm_adsp_stop_watchdog()
3178 static void wm_halo_stop_watchdog(struct wm_adsp *dsp) in wm_halo_stop_watchdog() argument
3180 regmap_update_bits(dsp->regmap, dsp->base + HALO_WDT_CONTROL, in wm_halo_stop_watchdog()
3189 struct wm_adsp *dsp = &dsps[w->shift]; in wm_adsp_early_event() local
3194 queue_work(system_unbound_wq, &dsp->boot_work); in wm_adsp_early_event()
3197 mutex_lock(&dsp->pwr_lock); in wm_adsp_early_event()
3199 wm_adsp_debugfs_clear(dsp); in wm_adsp_early_event()
3201 dsp->fw_id = 0; in wm_adsp_early_event()
3202 dsp->fw_id_version = 0; in wm_adsp_early_event()
3204 dsp->booted = false; in wm_adsp_early_event()
3206 if (dsp->ops->disable_memory) in wm_adsp_early_event()
3207 dsp->ops->disable_memory(dsp); in wm_adsp_early_event()
3209 list_for_each_entry(ctl, &dsp->ctl_list, list) in wm_adsp_early_event()
3212 wm_adsp_free_alg_regions(dsp); in wm_adsp_early_event()
3214 mutex_unlock(&dsp->pwr_lock); in wm_adsp_early_event()
3216 adsp_dbg(dsp, "Shutdown complete\n"); in wm_adsp_early_event()
3226 static int wm_adsp2_start_core(struct wm_adsp *dsp) in wm_adsp2_start_core() argument
3228 return regmap_update_bits(dsp->regmap, dsp->base + ADSP2_CONTROL, in wm_adsp2_start_core()
3233 static void wm_adsp2_stop_core(struct wm_adsp *dsp) in wm_adsp2_stop_core() argument
3235 regmap_update_bits(dsp->regmap, dsp->base + ADSP2_CONTROL, in wm_adsp2_stop_core()
3244 struct wm_adsp *dsp = &dsps[w->shift]; in wm_adsp_event() local
3249 flush_work(&dsp->boot_work); in wm_adsp_event()
3251 mutex_lock(&dsp->pwr_lock); in wm_adsp_event()
3253 if (!dsp->booted) { in wm_adsp_event()
3258 if (dsp->ops->enable_core) { in wm_adsp_event()
3259 ret = dsp->ops->enable_core(dsp); in wm_adsp_event()
3265 ret = wm_coeff_sync_controls(dsp); in wm_adsp_event()
3269 if (dsp->ops->lock_memory) { in wm_adsp_event()
3270 ret = dsp->ops->lock_memory(dsp, dsp->lock_regions); in wm_adsp_event()
3272 adsp_err(dsp, "Error configuring MPU: %d\n", in wm_adsp_event()
3278 if (dsp->ops->start_core) { in wm_adsp_event()
3279 ret = dsp->ops->start_core(dsp); in wm_adsp_event()
3284 if (wm_adsp_fw[dsp->fw].num_caps != 0) { in wm_adsp_event()
3285 ret = wm_adsp_buffer_init(dsp); in wm_adsp_event()
3290 dsp->running = true; in wm_adsp_event()
3292 mutex_unlock(&dsp->pwr_lock); in wm_adsp_event()
3297 wm_adsp_signal_event_controls(dsp, WM_ADSP_FW_EVENT_SHUTDOWN); in wm_adsp_event()
3299 if (dsp->ops->stop_watchdog) in wm_adsp_event()
3300 dsp->ops->stop_watchdog(dsp); in wm_adsp_event()
3303 if (dsp->ops->show_fw_status) in wm_adsp_event()
3304 dsp->ops->show_fw_status(dsp); in wm_adsp_event()
3306 mutex_lock(&dsp->pwr_lock); in wm_adsp_event()
3308 dsp->running = false; in wm_adsp_event()
3310 if (dsp->ops->stop_core) in wm_adsp_event()
3311 dsp->ops->stop_core(dsp); in wm_adsp_event()
3312 if (dsp->ops->disable_core) in wm_adsp_event()
3313 dsp->ops->disable_core(dsp); in wm_adsp_event()
3315 if (wm_adsp_fw[dsp->fw].num_caps != 0) in wm_adsp_event()
3316 wm_adsp_buffer_free(dsp); in wm_adsp_event()
3318 dsp->fatal_error = false; in wm_adsp_event()
3320 mutex_unlock(&dsp->pwr_lock); in wm_adsp_event()
3322 adsp_dbg(dsp, "Execution stopped\n"); in wm_adsp_event()
3331 if (dsp->ops->stop_core) in wm_adsp_event()
3332 dsp->ops->stop_core(dsp); in wm_adsp_event()
3333 if (dsp->ops->disable_core) in wm_adsp_event()
3334 dsp->ops->disable_core(dsp); in wm_adsp_event()
3335 mutex_unlock(&dsp->pwr_lock); in wm_adsp_event()
3340 static int wm_halo_start_core(struct wm_adsp *dsp) in wm_halo_start_core() argument
3342 return regmap_update_bits(dsp->regmap, in wm_halo_start_core()
3343 dsp->base + HALO_CCM_CORE_CONTROL, in wm_halo_start_core()
3347 static void wm_halo_stop_core(struct wm_adsp *dsp) in wm_halo_stop_core() argument
3349 regmap_update_bits(dsp->regmap, dsp->base + HALO_CCM_CORE_CONTROL, in wm_halo_stop_core()
3353 regmap_update_bits(dsp->regmap, dsp->base + HALO_CORE_SOFT_RESET, in wm_halo_stop_core()
3357 int wm_adsp2_component_probe(struct wm_adsp *dsp, struct snd_soc_component *component) in wm_adsp2_component_probe() argument
3361 snprintf(preload, ARRAY_SIZE(preload), "%s Preload", dsp->name); in wm_adsp2_component_probe()
3364 wm_adsp2_init_debugfs(dsp, component); in wm_adsp2_component_probe()
3366 dsp->component = component; in wm_adsp2_component_probe()
3372 int wm_adsp2_component_remove(struct wm_adsp *dsp, struct snd_soc_component *component) in wm_adsp2_component_remove() argument
3374 wm_adsp2_cleanup_debugfs(dsp); in wm_adsp2_component_remove()
3380 int wm_adsp2_init(struct wm_adsp *dsp) in wm_adsp2_init() argument
3384 ret = wm_adsp_common_init(dsp); in wm_adsp2_init()
3388 switch (dsp->rev) { in wm_adsp2_init()
3391 * Disable the DSP memory by default when in reset for a small in wm_adsp2_init()
3394 ret = regmap_update_bits(dsp->regmap, dsp->base + ADSP2_CONTROL, in wm_adsp2_init()
3397 adsp_err(dsp, in wm_adsp2_init()
3402 dsp->ops = &wm_adsp2_ops[0]; in wm_adsp2_init()
3405 dsp->ops = &wm_adsp2_ops[1]; in wm_adsp2_init()
3408 dsp->ops = &wm_adsp2_ops[2]; in wm_adsp2_init()
3412 INIT_WORK(&dsp->boot_work, wm_adsp_boot_work); in wm_adsp2_init()
3418 int wm_halo_init(struct wm_adsp *dsp) in wm_halo_init() argument
3422 ret = wm_adsp_common_init(dsp); in wm_halo_init()
3426 dsp->ops = &wm_halo_ops; in wm_halo_init()
3428 INIT_WORK(&dsp->boot_work, wm_adsp_boot_work); in wm_halo_init()
3434 void wm_adsp2_remove(struct wm_adsp *dsp) in wm_adsp2_remove() argument
3438 while (!list_empty(&dsp->ctl_list)) { in wm_adsp2_remove()
3439 ctl = list_first_entry(&dsp->ctl_list, struct wm_coeff_ctl, in wm_adsp2_remove()
3456 if (compr->dsp->fatal_error) in wm_adsp_compr_attach()
3459 list_for_each_entry(tmp, &compr->dsp->buffer_list, list) { in wm_adsp_compr_attach()
3490 int wm_adsp_compr_open(struct wm_adsp *dsp, struct snd_compr_stream *stream) in wm_adsp_compr_open() argument
3496 mutex_lock(&dsp->pwr_lock); in wm_adsp_compr_open()
3498 if (wm_adsp_fw[dsp->fw].num_caps == 0) { in wm_adsp_compr_open()
3499 adsp_err(dsp, "%s: Firmware does not support compressed API\n", in wm_adsp_compr_open()
3505 if (wm_adsp_fw[dsp->fw].compr_direction != stream->direction) { in wm_adsp_compr_open()
3506 adsp_err(dsp, "%s: Firmware does not support stream direction\n", in wm_adsp_compr_open()
3512 list_for_each_entry(tmp, &dsp->compr_list, list) { in wm_adsp_compr_open()
3514 adsp_err(dsp, "%s: Only a single stream supported per dai\n", in wm_adsp_compr_open()
3527 compr->dsp = dsp; in wm_adsp_compr_open()
3531 list_add_tail(&compr->list, &dsp->compr_list); in wm_adsp_compr_open()
3536 mutex_unlock(&dsp->pwr_lock); in wm_adsp_compr_open()
3546 struct wm_adsp *dsp = compr->dsp; in wm_adsp_compr_free() local
3548 mutex_lock(&dsp->pwr_lock); in wm_adsp_compr_free()
3556 mutex_unlock(&dsp->pwr_lock); in wm_adsp_compr_free()
3566 struct wm_adsp *dsp = compr->dsp; in wm_adsp_compr_check_params() local
3583 for (i = 0; i < wm_adsp_fw[dsp->fw].num_caps; i++) { in wm_adsp_compr_check_params()
3584 caps = &wm_adsp_fw[dsp->fw].caps[i]; in wm_adsp_compr_check_params()
3650 int fw = compr->dsp->fw; in wm_adsp_compr_get_caps()
3670 static int wm_adsp_read_data_block(struct wm_adsp *dsp, int mem_type, in wm_adsp_read_data_block() argument
3674 struct wm_adsp_region const *mem = wm_adsp_find_region(dsp, mem_type); in wm_adsp_read_data_block()
3681 reg = dsp->ops->region_to_reg(mem, mem_addr); in wm_adsp_read_data_block()
3683 ret = regmap_raw_read(dsp->regmap, reg, data, in wm_adsp_read_data_block()
3694 static inline int wm_adsp_read_data_word(struct wm_adsp *dsp, int mem_type, in wm_adsp_read_data_word() argument
3697 return wm_adsp_read_data_block(dsp, mem_type, mem_addr, 1, data); in wm_adsp_read_data_word()
3700 static int wm_adsp_write_data_word(struct wm_adsp *dsp, int mem_type, in wm_adsp_write_data_word() argument
3703 struct wm_adsp_region const *mem = wm_adsp_find_region(dsp, mem_type); in wm_adsp_write_data_word()
3709 reg = dsp->ops->region_to_reg(mem, mem_addr); in wm_adsp_write_data_word()
3713 return regmap_raw_write(dsp->regmap, reg, &data, sizeof(data)); in wm_adsp_write_data_word()
3719 return wm_adsp_read_data_word(buf->dsp, buf->host_buf_mem_type, in wm_adsp_buffer_read()
3726 return wm_adsp_write_data_word(buf->dsp, buf->host_buf_mem_type, in wm_adsp_buffer_write()
3736 /* Remove the padding bytes from the data read from the DSP */ in wm_adsp_remove_padding()
3747 const struct wm_adsp_fw_caps *caps = wm_adsp_fw[buf->dsp->fw].caps; in wm_adsp_buffer_populate()
3795 static struct wm_adsp_compr_buf *wm_adsp_buffer_alloc(struct wm_adsp *dsp) in wm_adsp_buffer_alloc() argument
3803 buf->dsp = dsp; in wm_adsp_buffer_alloc()
3807 list_add_tail(&buf->list, &dsp->buffer_list); in wm_adsp_buffer_alloc()
3812 static int wm_adsp_buffer_parse_legacy(struct wm_adsp *dsp) in wm_adsp_buffer_parse_legacy() argument
3819 alg_region = wm_adsp_find_alg_region(dsp, WMFW_ADSP2_XM, dsp->fw_id); in wm_adsp_buffer_parse_legacy()
3821 adsp_err(dsp, "No algorithm region found\n"); in wm_adsp_buffer_parse_legacy()
3825 buf = wm_adsp_buffer_alloc(dsp); in wm_adsp_buffer_parse_legacy()
3829 xmalg = dsp->ops->sys_config_size / sizeof(__be32); in wm_adsp_buffer_parse_legacy()
3832 ret = wm_adsp_read_data_word(dsp, WMFW_ADSP2_XM, addr, &magic); in wm_adsp_buffer_parse_legacy()
3841 ret = wm_adsp_read_data_word(dsp, WMFW_ADSP2_XM, addr, in wm_adsp_buffer_parse_legacy()
3878 ret = regmap_raw_read(ctl->dsp->regmap, reg, &val, sizeof(val)); in wm_adsp_buffer_parse_coeff()
3889 adsp_err(ctl->dsp, "Failed to acquire host buffer\n"); in wm_adsp_buffer_parse_coeff()
3893 buf = wm_adsp_buffer_alloc(ctl->dsp); in wm_adsp_buffer_parse_coeff()
3913 ret = regmap_raw_read(ctl->dsp->regmap, reg, &coeff_v1, in wm_adsp_buffer_parse_coeff()
3923 adsp_err(ctl->dsp, in wm_adsp_buffer_parse_coeff()
3936 buf->name = kasprintf(GFP_KERNEL, "%s-dsp-%s", ctl->dsp->part, in wm_adsp_buffer_parse_coeff()
3945 static int wm_adsp_buffer_init(struct wm_adsp *dsp) in wm_adsp_buffer_init() argument
3950 list_for_each_entry(ctl, &dsp->ctl_list, list) { in wm_adsp_buffer_init()
3959 adsp_err(dsp, "Failed to parse coeff: %d\n", ret); in wm_adsp_buffer_init()
3967 if (list_empty(&dsp->buffer_list)) { in wm_adsp_buffer_init()
3969 ret = wm_adsp_buffer_parse_legacy(dsp); in wm_adsp_buffer_init()
3971 adsp_err(dsp, "Failed to parse legacy: %d\n", ret); in wm_adsp_buffer_init()
3979 wm_adsp_buffer_free(dsp); in wm_adsp_buffer_init()
3983 static int wm_adsp_buffer_free(struct wm_adsp *dsp) in wm_adsp_buffer_free() argument
3987 list_for_each_entry_safe(buf, tmp, &dsp->buffer_list, list) { in wm_adsp_buffer_free()
4020 struct wm_adsp *dsp = compr->dsp; in wm_adsp_compr_trigger() local
4025 mutex_lock(&dsp->pwr_lock); in wm_adsp_compr_trigger()
4061 mutex_unlock(&dsp->pwr_lock); in wm_adsp_compr_trigger()
4069 int last_region = wm_adsp_fw[buf->dsp->fw].caps->num_regions - 1; in wm_adsp_buffer_size()
4117 int wm_adsp_compr_handle_irq(struct wm_adsp *dsp) in wm_adsp_compr_handle_irq() argument
4123 mutex_lock(&dsp->pwr_lock); in wm_adsp_compr_handle_irq()
4125 if (list_empty(&dsp->buffer_list)) { in wm_adsp_compr_handle_irq()
4130 adsp_dbg(dsp, "Handling buffer IRQ\n"); in wm_adsp_compr_handle_irq()
4132 list_for_each_entry(buf, &dsp->buffer_list, list) { in wm_adsp_compr_handle_irq()
4152 if (wm_adsp_fw[dsp->fw].voice_trigger && buf->irq_count == 2) in wm_adsp_compr_handle_irq()
4161 mutex_unlock(&dsp->pwr_lock); in wm_adsp_compr_handle_irq()
4185 struct wm_adsp *dsp = compr->dsp; in wm_adsp_compr_pointer() local
4191 mutex_lock(&dsp->pwr_lock); in wm_adsp_compr_pointer()
4195 if (dsp->fatal_error || !buf || buf->error) { in wm_adsp_compr_pointer()
4210 * DSP to inform us once a whole fragment is available. in wm_adsp_compr_pointer()
4235 mutex_unlock(&dsp->pwr_lock); in wm_adsp_compr_pointer()
4249 for (i = 0; i < wm_adsp_fw[buf->dsp->fw].caps->num_regions; ++i) in wm_adsp_buffer_capture_block()
4253 if (i == wm_adsp_fw[buf->dsp->fw].caps->num_regions) in wm_adsp_buffer_capture_block()
4272 /* Read data from DSP */ in wm_adsp_buffer_capture_block()
4273 ret = wm_adsp_read_data_block(buf->dsp, mem_type, adsp_addr, in wm_adsp_buffer_capture_block()
4299 struct wm_adsp *dsp = compr->dsp; in wm_adsp_compr_read() local
4305 if (dsp->fatal_error || !compr->buf || compr->buf->error) { in wm_adsp_compr_read()
4344 struct wm_adsp *dsp = compr->dsp; in wm_adsp_compr_copy() local
4347 mutex_lock(&dsp->pwr_lock); in wm_adsp_compr_copy()
4354 mutex_unlock(&dsp->pwr_lock); in wm_adsp_compr_copy()
4360 static void wm_adsp_fatal_error(struct wm_adsp *dsp) in wm_adsp_fatal_error() argument
4364 dsp->fatal_error = true; in wm_adsp_fatal_error()
4366 list_for_each_entry(compr, &dsp->compr_list, list) { in wm_adsp_fatal_error()
4374 struct wm_adsp *dsp = (struct wm_adsp *)data; in wm_adsp2_bus_error() local
4376 struct regmap *regmap = dsp->regmap; in wm_adsp2_bus_error()
4379 mutex_lock(&dsp->pwr_lock); in wm_adsp2_bus_error()
4381 ret = regmap_read(regmap, dsp->base + ADSP2_LOCK_REGION_CTRL, &val); in wm_adsp2_bus_error()
4383 adsp_err(dsp, in wm_adsp2_bus_error()
4389 adsp_err(dsp, "watchdog timeout error\n"); in wm_adsp2_bus_error()
4390 dsp->ops->stop_watchdog(dsp); in wm_adsp2_bus_error()
4391 wm_adsp_fatal_error(dsp); in wm_adsp2_bus_error()
4396 adsp_err(dsp, "bus error: address error\n"); in wm_adsp2_bus_error()
4398 adsp_err(dsp, "bus error: region lock error\n"); in wm_adsp2_bus_error()
4400 ret = regmap_read(regmap, dsp->base + ADSP2_BUS_ERR_ADDR, &val); in wm_adsp2_bus_error()
4402 adsp_err(dsp, in wm_adsp2_bus_error()
4408 adsp_err(dsp, "bus error address = 0x%x\n", in wm_adsp2_bus_error()
4412 dsp->base + ADSP2_PMEM_ERR_ADDR_XMEM_ERR_ADDR, in wm_adsp2_bus_error()
4415 adsp_err(dsp, in wm_adsp2_bus_error()
4421 adsp_err(dsp, "xmem error address = 0x%x\n", in wm_adsp2_bus_error()
4423 adsp_err(dsp, "pmem error address = 0x%x\n", in wm_adsp2_bus_error()
4428 regmap_update_bits(regmap, dsp->base + ADSP2_LOCK_REGION_CTRL, in wm_adsp2_bus_error()
4432 mutex_unlock(&dsp->pwr_lock); in wm_adsp2_bus_error()
4440 struct wm_adsp *dsp = (struct wm_adsp *)data; in wm_halo_bus_error() local
4441 struct regmap *regmap = dsp->regmap; in wm_halo_bus_error()
4444 { dsp->base + HALO_MPU_XM_VIO_STATUS, 0x0 }, in wm_halo_bus_error()
4445 { dsp->base + HALO_MPU_YM_VIO_STATUS, 0x0 }, in wm_halo_bus_error()
4446 { dsp->base + HALO_MPU_PM_VIO_STATUS, 0x0 }, in wm_halo_bus_error()
4450 mutex_lock(&dsp->pwr_lock); in wm_halo_bus_error()
4452 ret = regmap_read(regmap, dsp->base_sysinfo + HALO_AHBM_WINDOW_DEBUG_1, in wm_halo_bus_error()
4455 adsp_warn(dsp, "Failed to read AHB DEBUG_1: %d\n", ret); in wm_halo_bus_error()
4459 adsp_warn(dsp, "AHB: STATUS: 0x%x ADDR: 0x%x\n", in wm_halo_bus_error()
4464 ret = regmap_read(regmap, dsp->base_sysinfo + HALO_AHBM_WINDOW_DEBUG_0, in wm_halo_bus_error()
4467 adsp_warn(dsp, "Failed to read AHB DEBUG_0: %d\n", ret); in wm_halo_bus_error()
4471 adsp_warn(dsp, "AHB: SYS_ADDR: 0x%x\n", *fault); in wm_halo_bus_error()
4473 ret = regmap_bulk_read(regmap, dsp->base + HALO_MPU_XM_VIO_ADDR, in wm_halo_bus_error()
4476 adsp_warn(dsp, "Failed to read MPU fault info: %d\n", ret); in wm_halo_bus_error()
4480 adsp_warn(dsp, "XM: STATUS:0x%x ADDR:0x%x\n", fault[1], fault[0]); in wm_halo_bus_error()
4481 adsp_warn(dsp, "YM: STATUS:0x%x ADDR:0x%x\n", fault[3], fault[2]); in wm_halo_bus_error()
4482 adsp_warn(dsp, "PM: STATUS:0x%x ADDR:0x%x\n", fault[5], fault[4]); in wm_halo_bus_error()
4484 ret = regmap_multi_reg_write(dsp->regmap, clear, ARRAY_SIZE(clear)); in wm_halo_bus_error()
4486 adsp_warn(dsp, "Failed to clear MPU status: %d\n", ret); in wm_halo_bus_error()
4489 mutex_unlock(&dsp->pwr_lock); in wm_halo_bus_error()
4497 struct wm_adsp *dsp = data; in wm_halo_wdt_expire() local
4499 mutex_lock(&dsp->pwr_lock); in wm_halo_wdt_expire()
4501 adsp_warn(dsp, "WDT Expiry Fault\n"); in wm_halo_wdt_expire()
4502 dsp->ops->stop_watchdog(dsp); in wm_halo_wdt_expire()
4503 wm_adsp_fatal_error(dsp); in wm_halo_wdt_expire()
4505 mutex_unlock(&dsp->pwr_lock); in wm_halo_wdt_expire()