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()
1604 static inline void wm_coeff_parse_alg(struct wm_adsp *dsp, const u8 **data, in wm_coeff_parse_alg() argument
1609 switch (dsp->fw_ver) { in wm_coeff_parse_alg()
1629 adsp_dbg(dsp, "Algorithm ID: %#x\n", blk->id); in wm_coeff_parse_alg()
1630 adsp_dbg(dsp, "Algorithm name: %.*s\n", blk->name_len, blk->name); in wm_coeff_parse_alg()
1631 adsp_dbg(dsp, "# of coefficient descriptors: %#x\n", blk->ncoeff); in wm_coeff_parse_alg()
1634 static inline void wm_coeff_parse_coeff(struct wm_adsp *dsp, const u8 **data, in wm_coeff_parse_coeff() argument
1641 switch (dsp->fw_ver) { in wm_coeff_parse_coeff()
1672 adsp_dbg(dsp, "\tCoefficient type: %#x\n", blk->mem_type); in wm_coeff_parse_coeff()
1673 adsp_dbg(dsp, "\tCoefficient offset: %#x\n", blk->offset); in wm_coeff_parse_coeff()
1674 adsp_dbg(dsp, "\tCoefficient name: %.*s\n", blk->name_len, blk->name); in wm_coeff_parse_coeff()
1675 adsp_dbg(dsp, "\tCoefficient flags: %#x\n", blk->flags); in wm_coeff_parse_coeff()
1676 adsp_dbg(dsp, "\tALSA control type: %#x\n", blk->ctl_type); in wm_coeff_parse_coeff()
1677 adsp_dbg(dsp, "\tALSA control len: %#x\n", blk->len); in wm_coeff_parse_coeff()
1680 static int wm_adsp_check_coeff_flags(struct wm_adsp *dsp, in wm_adsp_check_coeff_flags() argument
1687 adsp_err(dsp, "Illegal flags 0x%x for control type 0x%x\n", in wm_adsp_check_coeff_flags()
1695 static int wm_adsp_parse_coeff(struct wm_adsp *dsp, in wm_adsp_parse_coeff() argument
1704 wm_coeff_parse_alg(dsp, &data, &alg_blk); in wm_adsp_parse_coeff()
1706 wm_coeff_parse_coeff(dsp, &data, &coeff_blk); in wm_adsp_parse_coeff()
1715 ret = wm_adsp_check_coeff_flags(dsp, &coeff_blk, in wm_adsp_parse_coeff()
1724 ret = wm_adsp_check_coeff_flags(dsp, &coeff_blk, in wm_adsp_parse_coeff()
1734 ret = wm_adsp_check_coeff_flags(dsp, &coeff_blk, in wm_adsp_parse_coeff()
1743 adsp_err(dsp, "Unknown control type: %d\n", in wm_adsp_parse_coeff()
1751 ret = wm_adsp_create_control(dsp, &alg_region, in wm_adsp_parse_coeff()
1759 adsp_err(dsp, "Failed to create control: %.*s, %d\n", in wm_adsp_parse_coeff()
1766 static unsigned int wm_adsp1_parse_sizes(struct wm_adsp *dsp, in wm_adsp1_parse_sizes() argument
1775 adsp_dbg(dsp, "%s: %d DM, %d PM, %d ZM\n", file, in wm_adsp1_parse_sizes()
1782 static unsigned int wm_adsp2_parse_sizes(struct wm_adsp *dsp, in wm_adsp2_parse_sizes() argument
1791 adsp_dbg(dsp, "%s: %d XM, %d YM %d PM, %d ZM\n", file, in wm_adsp2_parse_sizes()
1798 static bool wm_adsp_validate_version(struct wm_adsp *dsp, unsigned int version) in wm_adsp_validate_version() argument
1802 adsp_warn(dsp, "Deprecated file format %d\n", version); in wm_adsp_validate_version()
1812 static bool wm_halo_validate_version(struct wm_adsp *dsp, unsigned int version) in wm_halo_validate_version() argument
1822 static int wm_adsp_load(struct wm_adsp *dsp) in wm_adsp_load() argument
1826 struct regmap *regmap = dsp->regmap; in wm_adsp_load()
1844 snprintf(file, PAGE_SIZE, "%s-%s-%s.wmfw", dsp->part, dsp->fwf_name, in wm_adsp_load()
1845 wm_adsp_fw[dsp->fw].file); in wm_adsp_load()
1848 ret = request_firmware(&firmware, file, dsp->dev); in wm_adsp_load()
1850 adsp_err(dsp, "Failed to request '%s'\n", file); in wm_adsp_load()
1857 adsp_err(dsp, "%s: file too short, %zu bytes\n", in wm_adsp_load()
1865 adsp_err(dsp, "%s: invalid magic\n", file); in wm_adsp_load()
1869 if (!dsp->ops->validate_version(dsp, header->ver)) { in wm_adsp_load()
1870 adsp_err(dsp, "%s: unknown file format %d\n", in wm_adsp_load()
1875 adsp_info(dsp, "Firmware version: %d\n", header->ver); in wm_adsp_load()
1876 dsp->fw_ver = header->ver; in wm_adsp_load()
1878 if (header->core != dsp->type) { in wm_adsp_load()
1879 adsp_err(dsp, "%s: invalid core %d != %d\n", in wm_adsp_load()
1880 file, header->core, dsp->type); in wm_adsp_load()
1885 pos = dsp->ops->parse_sizes(dsp, file, pos, firmware); in wm_adsp_load()
1891 adsp_err(dsp, "%s: unexpected header length %d\n", in wm_adsp_load()
1896 adsp_dbg(dsp, "%s: timestamp %llu\n", file, in wm_adsp_load()
1916 ret = wm_adsp_parse_coeff(dsp, region); in wm_adsp_load()
1937 mem = wm_adsp_find_region(dsp, type); in wm_adsp_load()
1939 adsp_err(dsp, "No region of type: %x\n", type); in wm_adsp_load()
1945 reg = dsp->ops->region_to_reg(mem, offset); in wm_adsp_load()
1948 adsp_warn(dsp, in wm_adsp_load()
1954 adsp_dbg(dsp, "%s.%d: %d bytes at %d in %s\n", file, in wm_adsp_load()
1960 adsp_err(dsp, in wm_adsp_load()
1970 adsp_info(dsp, "%s: %s\n", file, text); in wm_adsp_load()
1980 adsp_err(dsp, "Out of memory\n"); in wm_adsp_load()
1988 adsp_err(dsp, in wm_adsp_load()
2003 adsp_err(dsp, "Failed to complete async write: %d\n", ret); in wm_adsp_load()
2008 adsp_warn(dsp, "%s.%d: %zu bytes at end of file\n", in wm_adsp_load()
2011 wm_adsp_debugfs_save_wmfwname(dsp, file); in wm_adsp_load()
2028 static struct wm_coeff_ctl *wm_adsp_get_ctl(struct wm_adsp *dsp, in wm_adsp_get_ctl() argument
2034 list_for_each_entry(pos, &dsp->ctl_list, list) { in wm_adsp_get_ctl()
2048 int wm_adsp_write_ctl(struct wm_adsp *dsp, const char *name, int type, in wm_adsp_write_ctl() argument
2056 ctl = wm_adsp_get_ctl(dsp, name, type, alg); in wm_adsp_write_ctl()
2070 if (dsp->component->name_prefix) in wm_adsp_write_ctl()
2072 dsp->component->name_prefix, ctl->name); in wm_adsp_write_ctl()
2077 kcontrol = snd_soc_card_get_kcontrol(dsp->component->card, ctl_name); in wm_adsp_write_ctl()
2079 adsp_err(dsp, "Can't find kcontrol %s\n", ctl_name); in wm_adsp_write_ctl()
2083 snd_ctl_notify(dsp->component->card->snd_card, in wm_adsp_write_ctl()
2090 int wm_adsp_read_ctl(struct wm_adsp *dsp, const char *name, int type, in wm_adsp_read_ctl() argument
2095 ctl = wm_adsp_get_ctl(dsp, name, type, alg); in wm_adsp_read_ctl()
2106 static void wm_adsp_ctl_fixup_base(struct wm_adsp *dsp, in wm_adsp_ctl_fixup_base() argument
2111 list_for_each_entry(ctl, &dsp->ctl_list, list) { in wm_adsp_ctl_fixup_base()
2112 if (ctl->fw_name == wm_adsp_fw_text[dsp->fw] && in wm_adsp_ctl_fixup_base()
2120 static void *wm_adsp_read_algs(struct wm_adsp *dsp, size_t n_algs, in wm_adsp_read_algs() argument
2130 adsp_err(dsp, "No algorithms\n"); in wm_adsp_read_algs()
2135 adsp_err(dsp, "Algorithm count %zx excessive\n", n_algs); in wm_adsp_read_algs()
2140 reg = dsp->ops->region_to_reg(mem, pos + len); in wm_adsp_read_algs()
2142 ret = regmap_raw_read(dsp->regmap, reg, &val, sizeof(val)); in wm_adsp_read_algs()
2144 adsp_err(dsp, "Failed to read algorithm list end: %d\n", in wm_adsp_read_algs()
2150 adsp_warn(dsp, "Algorithm list end %x 0x%x != 0xbedead\n", in wm_adsp_read_algs()
2153 /* Convert length from DSP words to bytes */ in wm_adsp_read_algs()
2160 reg = dsp->ops->region_to_reg(mem, pos); in wm_adsp_read_algs()
2162 ret = regmap_raw_read(dsp->regmap, reg, alg, len); in wm_adsp_read_algs()
2164 adsp_err(dsp, "Failed to read algorithm list: %d\n", ret); in wm_adsp_read_algs()
2173 wm_adsp_find_alg_region(struct wm_adsp *dsp, int type, unsigned int id) in wm_adsp_find_alg_region() argument
2177 list_for_each_entry(alg_region, &dsp->alg_regions, list) { in wm_adsp_find_alg_region()
2185 static struct wm_adsp_alg_region *wm_adsp_create_region(struct wm_adsp *dsp, in wm_adsp_create_region() argument
2199 list_add_tail(&alg_region->list, &dsp->alg_regions); in wm_adsp_create_region()
2201 if (dsp->fw_ver > 0) in wm_adsp_create_region()
2202 wm_adsp_ctl_fixup_base(dsp, alg_region); in wm_adsp_create_region()
2207 static void wm_adsp_free_alg_regions(struct wm_adsp *dsp) in wm_adsp_free_alg_regions() argument
2211 while (!list_empty(&dsp->alg_regions)) { in wm_adsp_free_alg_regions()
2212 alg_region = list_first_entry(&dsp->alg_regions, in wm_adsp_free_alg_regions()
2220 static void wmfw_parse_id_header(struct wm_adsp *dsp, in wmfw_parse_id_header() argument
2223 dsp->fw_id = be32_to_cpu(fw->id); in wmfw_parse_id_header()
2224 dsp->fw_id_version = be32_to_cpu(fw->ver); in wmfw_parse_id_header()
2226 adsp_info(dsp, "Firmware: %x v%d.%d.%d, %d algorithms\n", in wmfw_parse_id_header()
2227 dsp->fw_id, (dsp->fw_id_version & 0xff0000) >> 16, in wmfw_parse_id_header()
2228 (dsp->fw_id_version & 0xff00) >> 8, dsp->fw_id_version & 0xff, in wmfw_parse_id_header()
2232 static void wmfw_v3_parse_id_header(struct wm_adsp *dsp, in wmfw_v3_parse_id_header() argument
2235 dsp->fw_id = be32_to_cpu(fw->id); in wmfw_v3_parse_id_header()
2236 dsp->fw_id_version = be32_to_cpu(fw->ver); in wmfw_v3_parse_id_header()
2237 dsp->fw_vendor_id = be32_to_cpu(fw->vendor_id); in wmfw_v3_parse_id_header()
2239 adsp_info(dsp, "Firmware: %x vendor: 0x%x v%d.%d.%d, %d algorithms\n", in wmfw_v3_parse_id_header()
2240 dsp->fw_id, dsp->fw_vendor_id, in wmfw_v3_parse_id_header()
2241 (dsp->fw_id_version & 0xff0000) >> 16, in wmfw_v3_parse_id_header()
2242 (dsp->fw_id_version & 0xff00) >> 8, dsp->fw_id_version & 0xff, in wmfw_v3_parse_id_header()
2246 static int wm_adsp_create_regions(struct wm_adsp *dsp, __be32 id, int nregions, in wm_adsp_create_regions() argument
2253 alg_region = wm_adsp_create_region(dsp, type[i], id, base[i]); in wm_adsp_create_regions()
2261 static int wm_adsp1_setup_algs(struct wm_adsp *dsp) in wm_adsp1_setup_algs() argument
2271 mem = wm_adsp_find_region(dsp, WMFW_ADSP1_DM); in wm_adsp1_setup_algs()
2275 ret = regmap_raw_read(dsp->regmap, mem->base, &adsp1_id, in wm_adsp1_setup_algs()
2278 adsp_err(dsp, "Failed to read algorithm info: %d\n", in wm_adsp1_setup_algs()
2285 wmfw_parse_id_header(dsp, &adsp1_id.fw, n_algs); in wm_adsp1_setup_algs()
2287 alg_region = wm_adsp_create_region(dsp, WMFW_ADSP1_ZM, in wm_adsp1_setup_algs()
2292 alg_region = wm_adsp_create_region(dsp, WMFW_ADSP1_DM, in wm_adsp1_setup_algs()
2297 /* Calculate offset and length in DSP words */ in wm_adsp1_setup_algs()
2301 adsp1_alg = wm_adsp_read_algs(dsp, n_algs, mem, pos, len); in wm_adsp1_setup_algs()
2306 adsp_info(dsp, "%d: ID %x v%d.%d.%d DM@%x ZM@%x\n", in wm_adsp1_setup_algs()
2314 alg_region = wm_adsp_create_region(dsp, WMFW_ADSP1_DM, in wm_adsp1_setup_algs()
2321 if (dsp->fw_ver == 0) { in wm_adsp1_setup_algs()
2326 wm_adsp_create_control(dsp, alg_region, 0, in wm_adsp1_setup_algs()
2330 adsp_warn(dsp, "Missing length info for region DM with ID %x\n", in wm_adsp1_setup_algs()
2335 alg_region = wm_adsp_create_region(dsp, WMFW_ADSP1_ZM, in wm_adsp1_setup_algs()
2342 if (dsp->fw_ver == 0) { in wm_adsp1_setup_algs()
2347 wm_adsp_create_control(dsp, alg_region, 0, in wm_adsp1_setup_algs()
2351 adsp_warn(dsp, "Missing length info for region ZM with ID %x\n", in wm_adsp1_setup_algs()
2362 static int wm_adsp2_setup_algs(struct wm_adsp *dsp) in wm_adsp2_setup_algs() argument
2372 mem = wm_adsp_find_region(dsp, WMFW_ADSP2_XM); in wm_adsp2_setup_algs()
2376 ret = regmap_raw_read(dsp->regmap, mem->base, &adsp2_id, in wm_adsp2_setup_algs()
2379 adsp_err(dsp, "Failed to read algorithm info: %d\n", in wm_adsp2_setup_algs()
2386 wmfw_parse_id_header(dsp, &adsp2_id.fw, n_algs); in wm_adsp2_setup_algs()
2388 alg_region = wm_adsp_create_region(dsp, WMFW_ADSP2_XM, in wm_adsp2_setup_algs()
2393 alg_region = wm_adsp_create_region(dsp, WMFW_ADSP2_YM, in wm_adsp2_setup_algs()
2398 alg_region = wm_adsp_create_region(dsp, WMFW_ADSP2_ZM, in wm_adsp2_setup_algs()
2403 /* Calculate offset and length in DSP words */ in wm_adsp2_setup_algs()
2407 adsp2_alg = wm_adsp_read_algs(dsp, n_algs, mem, pos, len); in wm_adsp2_setup_algs()
2412 adsp_info(dsp, in wm_adsp2_setup_algs()
2422 alg_region = wm_adsp_create_region(dsp, WMFW_ADSP2_XM, in wm_adsp2_setup_algs()
2429 if (dsp->fw_ver == 0) { in wm_adsp2_setup_algs()
2434 wm_adsp_create_control(dsp, alg_region, 0, in wm_adsp2_setup_algs()
2438 adsp_warn(dsp, "Missing length info for region XM with ID %x\n", in wm_adsp2_setup_algs()
2443 alg_region = wm_adsp_create_region(dsp, WMFW_ADSP2_YM, in wm_adsp2_setup_algs()
2450 if (dsp->fw_ver == 0) { in wm_adsp2_setup_algs()
2455 wm_adsp_create_control(dsp, alg_region, 0, in wm_adsp2_setup_algs()
2459 adsp_warn(dsp, "Missing length info for region YM with ID %x\n", in wm_adsp2_setup_algs()
2464 alg_region = wm_adsp_create_region(dsp, WMFW_ADSP2_ZM, in wm_adsp2_setup_algs()
2471 if (dsp->fw_ver == 0) { in wm_adsp2_setup_algs()
2476 wm_adsp_create_control(dsp, alg_region, 0, in wm_adsp2_setup_algs()
2480 adsp_warn(dsp, "Missing length info for region ZM with ID %x\n", in wm_adsp2_setup_algs()
2491 static int wm_halo_create_regions(struct wm_adsp *dsp, __be32 id, in wm_halo_create_regions() argument
2500 return wm_adsp_create_regions(dsp, id, ARRAY_SIZE(types), types, bases); in wm_halo_create_regions()
2503 static int wm_halo_setup_algs(struct wm_adsp *dsp) in wm_halo_setup_algs() argument
2512 mem = wm_adsp_find_region(dsp, WMFW_ADSP2_XM); in wm_halo_setup_algs()
2516 ret = regmap_raw_read(dsp->regmap, mem->base, &halo_id, in wm_halo_setup_algs()
2519 adsp_err(dsp, "Failed to read algorithm info: %d\n", in wm_halo_setup_algs()
2526 wmfw_v3_parse_id_header(dsp, &halo_id.fw, n_algs); in wm_halo_setup_algs()
2528 ret = wm_halo_create_regions(dsp, halo_id.fw.id, in wm_halo_setup_algs()
2533 /* Calculate offset and length in DSP words */ in wm_halo_setup_algs()
2537 halo_alg = wm_adsp_read_algs(dsp, n_algs, mem, pos, len); in wm_halo_setup_algs()
2542 adsp_info(dsp, in wm_halo_setup_algs()
2551 ret = wm_halo_create_regions(dsp, halo_alg[i].alg.id, in wm_halo_setup_algs()
2563 static int wm_adsp_load_coeff(struct wm_adsp *dsp) in wm_adsp_load_coeff() argument
2566 struct regmap *regmap = dsp->regmap; in wm_adsp_load_coeff()
2581 snprintf(file, PAGE_SIZE, "%s-%s-%s.bin", dsp->part, dsp->fwf_name, in wm_adsp_load_coeff()
2582 wm_adsp_fw[dsp->fw].file); in wm_adsp_load_coeff()
2585 ret = request_firmware(&firmware, file, dsp->dev); in wm_adsp_load_coeff()
2587 adsp_warn(dsp, "Failed to request '%s'\n", file); in wm_adsp_load_coeff()
2594 adsp_err(dsp, "%s: file too short, %zu bytes\n", in wm_adsp_load_coeff()
2601 adsp_err(dsp, "%s: invalid magic\n", file); in wm_adsp_load_coeff()
2609 adsp_err(dsp, "%s: Unsupported coefficient file format %d\n", in wm_adsp_load_coeff()
2615 adsp_dbg(dsp, "%s: v%d.%d.%d\n", file, in wm_adsp_load_coeff()
2630 adsp_dbg(dsp, "%s.%d: %x v%d.%d.%d\n", in wm_adsp_load_coeff()
2635 adsp_dbg(dsp, "%s.%d: %d bytes at 0x%x in %x\n", in wm_adsp_load_coeff()
2650 if (le32_to_cpu(blk->id) == dsp->fw_id && in wm_adsp_load_coeff()
2653 mem = wm_adsp_find_region(dsp, type); in wm_adsp_load_coeff()
2655 adsp_err(dsp, "No ZM\n"); in wm_adsp_load_coeff()
2658 reg = dsp->ops->region_to_reg(mem, 0); in wm_adsp_load_coeff()
2673 adsp_dbg(dsp, "%s.%d: %d bytes in %x for %x\n", in wm_adsp_load_coeff()
2677 mem = wm_adsp_find_region(dsp, type); in wm_adsp_load_coeff()
2679 adsp_err(dsp, "No base for region %x\n", type); in wm_adsp_load_coeff()
2683 alg_region = wm_adsp_find_alg_region(dsp, type, in wm_adsp_load_coeff()
2687 reg = dsp->ops->region_to_reg(mem, reg); in wm_adsp_load_coeff()
2690 adsp_err(dsp, "No %x for algorithm %x\n", in wm_adsp_load_coeff()
2696 adsp_err(dsp, "%s.%d: Unknown region type %x at %d\n", in wm_adsp_load_coeff()
2704 adsp_err(dsp, in wm_adsp_load_coeff()
2717 adsp_err(dsp, "Out of memory\n"); in wm_adsp_load_coeff()
2722 adsp_dbg(dsp, "%s.%d: Writing %d bytes at %x\n", in wm_adsp_load_coeff()
2728 adsp_err(dsp, in wm_adsp_load_coeff()
2740 adsp_err(dsp, "Failed to complete async write: %d\n", ret); in wm_adsp_load_coeff()
2743 adsp_warn(dsp, "%s.%d: %zu bytes at end of file\n", in wm_adsp_load_coeff()
2746 wm_adsp_debugfs_save_binname(dsp, file); in wm_adsp_load_coeff()
2757 static int wm_adsp_create_name(struct wm_adsp *dsp) in wm_adsp_create_name() argument
2761 if (!dsp->name) { in wm_adsp_create_name()
2762 dsp->name = devm_kasprintf(dsp->dev, GFP_KERNEL, "DSP%d", in wm_adsp_create_name()
2763 dsp->num); in wm_adsp_create_name()
2764 if (!dsp->name) in wm_adsp_create_name()
2768 if (!dsp->fwf_name) { in wm_adsp_create_name()
2769 p = devm_kstrdup(dsp->dev, dsp->name, GFP_KERNEL); in wm_adsp_create_name()
2773 dsp->fwf_name = p; in wm_adsp_create_name()
2781 static int wm_adsp_common_init(struct wm_adsp *dsp) in wm_adsp_common_init() argument
2785 ret = wm_adsp_create_name(dsp); in wm_adsp_common_init()
2789 INIT_LIST_HEAD(&dsp->alg_regions); in wm_adsp_common_init()
2790 INIT_LIST_HEAD(&dsp->ctl_list); in wm_adsp_common_init()
2791 INIT_LIST_HEAD(&dsp->compr_list); in wm_adsp_common_init()
2792 INIT_LIST_HEAD(&dsp->buffer_list); in wm_adsp_common_init()
2794 mutex_init(&dsp->pwr_lock); in wm_adsp_common_init()
2799 int wm_adsp1_init(struct wm_adsp *dsp) in wm_adsp1_init() argument
2801 dsp->ops = &wm_adsp1_ops; in wm_adsp1_init()
2803 return wm_adsp_common_init(dsp); in wm_adsp1_init()
2813 struct wm_adsp *dsp = &dsps[w->shift]; in wm_adsp1_event() local
2818 dsp->component = component; in wm_adsp1_event()
2820 mutex_lock(&dsp->pwr_lock); in wm_adsp1_event()
2824 regmap_update_bits(dsp->regmap, dsp->base + ADSP1_CONTROL_30, in wm_adsp1_event()
2828 * For simplicity set the DSP clock rate to be the in wm_adsp1_event()
2831 if (dsp->sysclk_reg) { in wm_adsp1_event()
2832 ret = regmap_read(dsp->regmap, dsp->sysclk_reg, &val); in wm_adsp1_event()
2834 adsp_err(dsp, "Failed to read SYSCLK state: %d\n", in wm_adsp1_event()
2839 val = (val & dsp->sysclk_mask) >> dsp->sysclk_shift; in wm_adsp1_event()
2841 ret = regmap_update_bits(dsp->regmap, in wm_adsp1_event()
2842 dsp->base + ADSP1_CONTROL_31, in wm_adsp1_event()
2845 adsp_err(dsp, "Failed to set clock rate: %d\n", in wm_adsp1_event()
2851 ret = wm_adsp_load(dsp); in wm_adsp1_event()
2855 ret = wm_adsp1_setup_algs(dsp); in wm_adsp1_event()
2859 ret = wm_adsp_load_coeff(dsp); in wm_adsp1_event()
2864 ret = wm_coeff_init_control_caches(dsp); in wm_adsp1_event()
2869 ret = wm_coeff_sync_controls(dsp); in wm_adsp1_event()
2873 dsp->booted = true; in wm_adsp1_event()
2876 regmap_update_bits(dsp->regmap, dsp->base + ADSP1_CONTROL_30, in wm_adsp1_event()
2880 dsp->running = true; in wm_adsp1_event()
2884 dsp->running = false; in wm_adsp1_event()
2885 dsp->booted = false; in wm_adsp1_event()
2888 regmap_update_bits(dsp->regmap, dsp->base + ADSP1_CONTROL_30, in wm_adsp1_event()
2891 regmap_update_bits(dsp->regmap, dsp->base + ADSP1_CONTROL_19, in wm_adsp1_event()
2894 regmap_update_bits(dsp->regmap, dsp->base + ADSP1_CONTROL_30, in wm_adsp1_event()
2897 list_for_each_entry(ctl, &dsp->ctl_list, list) in wm_adsp1_event()
2901 wm_adsp_free_alg_regions(dsp); in wm_adsp1_event()
2908 mutex_unlock(&dsp->pwr_lock); in wm_adsp1_event()
2913 regmap_update_bits(dsp->regmap, dsp->base + ADSP1_CONTROL_30, in wm_adsp1_event()
2916 mutex_unlock(&dsp->pwr_lock); in wm_adsp1_event()
2922 static int wm_adsp2v2_enable_core(struct wm_adsp *dsp) in wm_adsp2v2_enable_core() argument
2929 ret = regmap_read(dsp->regmap, dsp->base + ADSP2_STATUS1, &val); in wm_adsp2v2_enable_core()
2940 adsp_err(dsp, "Failed to start DSP RAM\n"); in wm_adsp2v2_enable_core()
2944 adsp_dbg(dsp, "RAM ready after %d polls\n", count); in wm_adsp2v2_enable_core()
2949 static int wm_adsp2_enable_core(struct wm_adsp *dsp) in wm_adsp2_enable_core() argument
2953 ret = regmap_update_bits_async(dsp->regmap, dsp->base + ADSP2_CONTROL, in wm_adsp2_enable_core()
2958 return wm_adsp2v2_enable_core(dsp); in wm_adsp2_enable_core()
2961 static int wm_adsp2_lock(struct wm_adsp *dsp, unsigned int lock_regions) in wm_adsp2_lock() argument
2963 struct regmap *regmap = dsp->regmap; in wm_adsp2_lock()
2970 lock_reg = dsp->base + ADSP2_LOCK_REGION_1_LOCK_REGION_0; in wm_adsp2_lock()
2991 static int wm_adsp2_enable_memory(struct wm_adsp *dsp) in wm_adsp2_enable_memory() argument
2993 return regmap_update_bits(dsp->regmap, dsp->base + ADSP2_CONTROL, in wm_adsp2_enable_memory()
2997 static void wm_adsp2_disable_memory(struct wm_adsp *dsp) in wm_adsp2_disable_memory() argument
2999 regmap_update_bits(dsp->regmap, dsp->base + ADSP2_CONTROL, in wm_adsp2_disable_memory()
3003 static void wm_adsp2_disable_core(struct wm_adsp *dsp) in wm_adsp2_disable_core() argument
3005 regmap_write(dsp->regmap, dsp->base + ADSP2_RDMA_CONFIG_1, 0); in wm_adsp2_disable_core()
3006 regmap_write(dsp->regmap, dsp->base + ADSP2_WDMA_CONFIG_1, 0); in wm_adsp2_disable_core()
3007 regmap_write(dsp->regmap, dsp->base + ADSP2_WDMA_CONFIG_2, 0); in wm_adsp2_disable_core()
3009 regmap_update_bits(dsp->regmap, dsp->base + ADSP2_CONTROL, in wm_adsp2_disable_core()
3013 static void wm_adsp2v2_disable_core(struct wm_adsp *dsp) in wm_adsp2v2_disable_core() argument
3015 regmap_write(dsp->regmap, dsp->base + ADSP2_RDMA_CONFIG_1, 0); in wm_adsp2v2_disable_core()
3016 regmap_write(dsp->regmap, dsp->base + ADSP2_WDMA_CONFIG_1, 0); in wm_adsp2v2_disable_core()
3017 regmap_write(dsp->regmap, dsp->base + ADSP2V2_WDMA_CONFIG_2, 0); in wm_adsp2v2_disable_core()
3022 struct wm_adsp *dsp = container_of(work, in wm_adsp_boot_work() local
3027 mutex_lock(&dsp->pwr_lock); in wm_adsp_boot_work()
3029 if (dsp->ops->enable_memory) { in wm_adsp_boot_work()
3030 ret = dsp->ops->enable_memory(dsp); in wm_adsp_boot_work()
3035 if (dsp->ops->enable_core) { in wm_adsp_boot_work()
3036 ret = dsp->ops->enable_core(dsp); in wm_adsp_boot_work()
3041 ret = wm_adsp_load(dsp); in wm_adsp_boot_work()
3045 ret = dsp->ops->setup_algs(dsp); in wm_adsp_boot_work()
3049 ret = wm_adsp_load_coeff(dsp); in wm_adsp_boot_work()
3054 ret = wm_coeff_init_control_caches(dsp); in wm_adsp_boot_work()
3058 if (dsp->ops->disable_core) in wm_adsp_boot_work()
3059 dsp->ops->disable_core(dsp); in wm_adsp_boot_work()
3061 dsp->booted = true; in wm_adsp_boot_work()
3063 mutex_unlock(&dsp->pwr_lock); in wm_adsp_boot_work()
3068 if (dsp->ops->disable_core) in wm_adsp_boot_work()
3069 dsp->ops->disable_core(dsp); in wm_adsp_boot_work()
3071 if (dsp->ops->disable_memory) in wm_adsp_boot_work()
3072 dsp->ops->disable_memory(dsp); in wm_adsp_boot_work()
3074 mutex_unlock(&dsp->pwr_lock); in wm_adsp_boot_work()
3077 static int wm_halo_configure_mpu(struct wm_adsp *dsp, unsigned int lock_regions) in wm_halo_configure_mpu() argument
3080 { dsp->base + HALO_MPU_LOCK_CONFIG, 0x5555 }, in wm_halo_configure_mpu()
3081 { dsp->base + HALO_MPU_LOCK_CONFIG, 0xAAAA }, in wm_halo_configure_mpu()
3082 { dsp->base + HALO_MPU_XMEM_ACCESS_0, 0xFFFFFFFF }, in wm_halo_configure_mpu()
3083 { dsp->base + HALO_MPU_YMEM_ACCESS_0, 0xFFFFFFFF }, in wm_halo_configure_mpu()
3084 { dsp->base + HALO_MPU_WINDOW_ACCESS_0, lock_regions }, in wm_halo_configure_mpu()
3085 { dsp->base + HALO_MPU_XREG_ACCESS_0, lock_regions }, in wm_halo_configure_mpu()
3086 { dsp->base + HALO_MPU_YREG_ACCESS_0, lock_regions }, in wm_halo_configure_mpu()
3087 { dsp->base + HALO_MPU_XMEM_ACCESS_1, 0xFFFFFFFF }, in wm_halo_configure_mpu()
3088 { dsp->base + HALO_MPU_YMEM_ACCESS_1, 0xFFFFFFFF }, in wm_halo_configure_mpu()
3089 { dsp->base + HALO_MPU_WINDOW_ACCESS_1, lock_regions }, in wm_halo_configure_mpu()
3090 { dsp->base + HALO_MPU_XREG_ACCESS_1, lock_regions }, in wm_halo_configure_mpu()
3091 { dsp->base + HALO_MPU_YREG_ACCESS_1, lock_regions }, in wm_halo_configure_mpu()
3092 { dsp->base + HALO_MPU_XMEM_ACCESS_2, 0xFFFFFFFF }, in wm_halo_configure_mpu()
3093 { dsp->base + HALO_MPU_YMEM_ACCESS_2, 0xFFFFFFFF }, in wm_halo_configure_mpu()
3094 { dsp->base + HALO_MPU_WINDOW_ACCESS_2, lock_regions }, in wm_halo_configure_mpu()
3095 { dsp->base + HALO_MPU_XREG_ACCESS_2, lock_regions }, in wm_halo_configure_mpu()
3096 { dsp->base + HALO_MPU_YREG_ACCESS_2, lock_regions }, in wm_halo_configure_mpu()
3097 { dsp->base + HALO_MPU_XMEM_ACCESS_3, 0xFFFFFFFF }, in wm_halo_configure_mpu()
3098 { dsp->base + HALO_MPU_YMEM_ACCESS_3, 0xFFFFFFFF }, in wm_halo_configure_mpu()
3099 { dsp->base + HALO_MPU_WINDOW_ACCESS_3, lock_regions }, in wm_halo_configure_mpu()
3100 { dsp->base + HALO_MPU_XREG_ACCESS_3, lock_regions }, in wm_halo_configure_mpu()
3101 { dsp->base + HALO_MPU_YREG_ACCESS_3, lock_regions }, in wm_halo_configure_mpu()
3102 { dsp->base + HALO_MPU_LOCK_CONFIG, 0 }, in wm_halo_configure_mpu()
3105 return regmap_multi_reg_write(dsp->regmap, config, ARRAY_SIZE(config)); in wm_halo_configure_mpu()
3112 struct wm_adsp *dsp = &dsps[w->shift]; in wm_adsp2_set_dspclk() local
3115 ret = regmap_update_bits(dsp->regmap, dsp->base + ADSP2_CLOCKING, in wm_adsp2_set_dspclk()
3119 adsp_err(dsp, "Failed to set clock rate: %d\n", ret); in wm_adsp2_set_dspclk()
3132 struct wm_adsp *dsp = &dsps[mc->shift - 1]; in wm_adsp2_preloader_get() local
3134 ucontrol->value.integer.value[0] = dsp->preloaded; in wm_adsp2_preloader_get()
3148 struct wm_adsp *dsp = &dsps[mc->shift - 1]; in wm_adsp2_preloader_put() local
3151 snprintf(preload, ARRAY_SIZE(preload), "%s Preload", dsp->name); in wm_adsp2_preloader_put()
3153 dsp->preloaded = ucontrol->value.integer.value[0]; in wm_adsp2_preloader_put()
3162 flush_work(&dsp->boot_work); in wm_adsp2_preloader_put()
3168 static void wm_adsp_stop_watchdog(struct wm_adsp *dsp) in wm_adsp_stop_watchdog() argument
3170 regmap_update_bits(dsp->regmap, dsp->base + ADSP2_WATCHDOG, in wm_adsp_stop_watchdog()
3174 static void wm_halo_stop_watchdog(struct wm_adsp *dsp) in wm_halo_stop_watchdog() argument
3176 regmap_update_bits(dsp->regmap, dsp->base + HALO_WDT_CONTROL, in wm_halo_stop_watchdog()
3185 struct wm_adsp *dsp = &dsps[w->shift]; in wm_adsp_early_event() local
3190 queue_work(system_unbound_wq, &dsp->boot_work); in wm_adsp_early_event()
3193 mutex_lock(&dsp->pwr_lock); in wm_adsp_early_event()
3195 wm_adsp_debugfs_clear(dsp); in wm_adsp_early_event()
3197 dsp->fw_id = 0; in wm_adsp_early_event()
3198 dsp->fw_id_version = 0; in wm_adsp_early_event()
3200 dsp->booted = false; in wm_adsp_early_event()
3202 if (dsp->ops->disable_memory) in wm_adsp_early_event()
3203 dsp->ops->disable_memory(dsp); in wm_adsp_early_event()
3205 list_for_each_entry(ctl, &dsp->ctl_list, list) in wm_adsp_early_event()
3208 wm_adsp_free_alg_regions(dsp); in wm_adsp_early_event()
3210 mutex_unlock(&dsp->pwr_lock); in wm_adsp_early_event()
3212 adsp_dbg(dsp, "Shutdown complete\n"); in wm_adsp_early_event()
3222 static int wm_adsp2_start_core(struct wm_adsp *dsp) in wm_adsp2_start_core() argument
3224 return regmap_update_bits(dsp->regmap, dsp->base + ADSP2_CONTROL, in wm_adsp2_start_core()
3229 static void wm_adsp2_stop_core(struct wm_adsp *dsp) in wm_adsp2_stop_core() argument
3231 regmap_update_bits(dsp->regmap, dsp->base + ADSP2_CONTROL, in wm_adsp2_stop_core()
3240 struct wm_adsp *dsp = &dsps[w->shift]; in wm_adsp_event() local
3245 flush_work(&dsp->boot_work); in wm_adsp_event()
3247 mutex_lock(&dsp->pwr_lock); in wm_adsp_event()
3249 if (!dsp->booted) { in wm_adsp_event()
3254 if (dsp->ops->enable_core) { in wm_adsp_event()
3255 ret = dsp->ops->enable_core(dsp); in wm_adsp_event()
3261 ret = wm_coeff_sync_controls(dsp); in wm_adsp_event()
3265 if (dsp->ops->lock_memory) { in wm_adsp_event()
3266 ret = dsp->ops->lock_memory(dsp, dsp->lock_regions); in wm_adsp_event()
3268 adsp_err(dsp, "Error configuring MPU: %d\n", in wm_adsp_event()
3274 if (dsp->ops->start_core) { in wm_adsp_event()
3275 ret = dsp->ops->start_core(dsp); in wm_adsp_event()
3280 if (wm_adsp_fw[dsp->fw].num_caps != 0) { in wm_adsp_event()
3281 ret = wm_adsp_buffer_init(dsp); in wm_adsp_event()
3286 dsp->running = true; in wm_adsp_event()
3288 mutex_unlock(&dsp->pwr_lock); in wm_adsp_event()
3293 wm_adsp_signal_event_controls(dsp, WM_ADSP_FW_EVENT_SHUTDOWN); in wm_adsp_event()
3295 if (dsp->ops->stop_watchdog) in wm_adsp_event()
3296 dsp->ops->stop_watchdog(dsp); in wm_adsp_event()
3299 if (dsp->ops->show_fw_status) in wm_adsp_event()
3300 dsp->ops->show_fw_status(dsp); in wm_adsp_event()
3302 mutex_lock(&dsp->pwr_lock); in wm_adsp_event()
3304 dsp->running = false; in wm_adsp_event()
3306 if (dsp->ops->stop_core) in wm_adsp_event()
3307 dsp->ops->stop_core(dsp); in wm_adsp_event()
3308 if (dsp->ops->disable_core) in wm_adsp_event()
3309 dsp->ops->disable_core(dsp); in wm_adsp_event()
3311 if (wm_adsp_fw[dsp->fw].num_caps != 0) in wm_adsp_event()
3312 wm_adsp_buffer_free(dsp); in wm_adsp_event()
3314 dsp->fatal_error = false; in wm_adsp_event()
3316 mutex_unlock(&dsp->pwr_lock); in wm_adsp_event()
3318 adsp_dbg(dsp, "Execution stopped\n"); in wm_adsp_event()
3327 if (dsp->ops->stop_core) in wm_adsp_event()
3328 dsp->ops->stop_core(dsp); in wm_adsp_event()
3329 if (dsp->ops->disable_core) in wm_adsp_event()
3330 dsp->ops->disable_core(dsp); in wm_adsp_event()
3331 mutex_unlock(&dsp->pwr_lock); in wm_adsp_event()
3336 static int wm_halo_start_core(struct wm_adsp *dsp) in wm_halo_start_core() argument
3338 return regmap_update_bits(dsp->regmap, in wm_halo_start_core()
3339 dsp->base + HALO_CCM_CORE_CONTROL, in wm_halo_start_core()
3343 static void wm_halo_stop_core(struct wm_adsp *dsp) in wm_halo_stop_core() argument
3345 regmap_update_bits(dsp->regmap, dsp->base + HALO_CCM_CORE_CONTROL, in wm_halo_stop_core()
3349 regmap_update_bits(dsp->regmap, dsp->base + HALO_CORE_SOFT_RESET, in wm_halo_stop_core()
3353 int wm_adsp2_component_probe(struct wm_adsp *dsp, struct snd_soc_component *component) in wm_adsp2_component_probe() argument
3357 snprintf(preload, ARRAY_SIZE(preload), "%s Preload", dsp->name); in wm_adsp2_component_probe()
3360 wm_adsp2_init_debugfs(dsp, component); in wm_adsp2_component_probe()
3362 dsp->component = component; in wm_adsp2_component_probe()
3368 int wm_adsp2_component_remove(struct wm_adsp *dsp, struct snd_soc_component *component) in wm_adsp2_component_remove() argument
3370 wm_adsp2_cleanup_debugfs(dsp); in wm_adsp2_component_remove()
3376 int wm_adsp2_init(struct wm_adsp *dsp) in wm_adsp2_init() argument
3380 ret = wm_adsp_common_init(dsp); in wm_adsp2_init()
3384 switch (dsp->rev) { in wm_adsp2_init()
3387 * Disable the DSP memory by default when in reset for a small in wm_adsp2_init()
3390 ret = regmap_update_bits(dsp->regmap, dsp->base + ADSP2_CONTROL, in wm_adsp2_init()
3393 adsp_err(dsp, in wm_adsp2_init()
3398 dsp->ops = &wm_adsp2_ops[0]; in wm_adsp2_init()
3401 dsp->ops = &wm_adsp2_ops[1]; in wm_adsp2_init()
3404 dsp->ops = &wm_adsp2_ops[2]; in wm_adsp2_init()
3408 INIT_WORK(&dsp->boot_work, wm_adsp_boot_work); in wm_adsp2_init()
3414 int wm_halo_init(struct wm_adsp *dsp) in wm_halo_init() argument
3418 ret = wm_adsp_common_init(dsp); in wm_halo_init()
3422 dsp->ops = &wm_halo_ops; in wm_halo_init()
3424 INIT_WORK(&dsp->boot_work, wm_adsp_boot_work); in wm_halo_init()
3430 void wm_adsp2_remove(struct wm_adsp *dsp) in wm_adsp2_remove() argument
3434 while (!list_empty(&dsp->ctl_list)) { in wm_adsp2_remove()
3435 ctl = list_first_entry(&dsp->ctl_list, struct wm_coeff_ctl, in wm_adsp2_remove()
3452 if (compr->dsp->fatal_error) in wm_adsp_compr_attach()
3455 list_for_each_entry(tmp, &compr->dsp->buffer_list, list) { in wm_adsp_compr_attach()
3486 int wm_adsp_compr_open(struct wm_adsp *dsp, struct snd_compr_stream *stream) in wm_adsp_compr_open() argument
3492 mutex_lock(&dsp->pwr_lock); in wm_adsp_compr_open()
3494 if (wm_adsp_fw[dsp->fw].num_caps == 0) { in wm_adsp_compr_open()
3495 adsp_err(dsp, "%s: Firmware does not support compressed API\n", in wm_adsp_compr_open()
3501 if (wm_adsp_fw[dsp->fw].compr_direction != stream->direction) { in wm_adsp_compr_open()
3502 adsp_err(dsp, "%s: Firmware does not support stream direction\n", in wm_adsp_compr_open()
3508 list_for_each_entry(tmp, &dsp->compr_list, list) { in wm_adsp_compr_open()
3510 adsp_err(dsp, "%s: Only a single stream supported per dai\n", in wm_adsp_compr_open()
3523 compr->dsp = dsp; in wm_adsp_compr_open()
3527 list_add_tail(&compr->list, &dsp->compr_list); in wm_adsp_compr_open()
3532 mutex_unlock(&dsp->pwr_lock); in wm_adsp_compr_open()
3542 struct wm_adsp *dsp = compr->dsp; in wm_adsp_compr_free() local
3544 mutex_lock(&dsp->pwr_lock); in wm_adsp_compr_free()
3552 mutex_unlock(&dsp->pwr_lock); in wm_adsp_compr_free()
3562 struct wm_adsp *dsp = compr->dsp; in wm_adsp_compr_check_params() local
3579 for (i = 0; i < wm_adsp_fw[dsp->fw].num_caps; i++) { in wm_adsp_compr_check_params()
3580 caps = &wm_adsp_fw[dsp->fw].caps[i]; in wm_adsp_compr_check_params()
3646 int fw = compr->dsp->fw; in wm_adsp_compr_get_caps()
3666 static int wm_adsp_read_data_block(struct wm_adsp *dsp, int mem_type, in wm_adsp_read_data_block() argument
3670 struct wm_adsp_region const *mem = wm_adsp_find_region(dsp, mem_type); in wm_adsp_read_data_block()
3677 reg = dsp->ops->region_to_reg(mem, mem_addr); in wm_adsp_read_data_block()
3679 ret = regmap_raw_read(dsp->regmap, reg, data, in wm_adsp_read_data_block()
3690 static inline int wm_adsp_read_data_word(struct wm_adsp *dsp, int mem_type, in wm_adsp_read_data_word() argument
3693 return wm_adsp_read_data_block(dsp, mem_type, mem_addr, 1, data); in wm_adsp_read_data_word()
3696 static int wm_adsp_write_data_word(struct wm_adsp *dsp, int mem_type, in wm_adsp_write_data_word() argument
3699 struct wm_adsp_region const *mem = wm_adsp_find_region(dsp, mem_type); in wm_adsp_write_data_word()
3705 reg = dsp->ops->region_to_reg(mem, mem_addr); in wm_adsp_write_data_word()
3709 return regmap_raw_write(dsp->regmap, reg, &data, sizeof(data)); in wm_adsp_write_data_word()
3715 return wm_adsp_read_data_word(buf->dsp, buf->host_buf_mem_type, in wm_adsp_buffer_read()
3722 return wm_adsp_write_data_word(buf->dsp, buf->host_buf_mem_type, in wm_adsp_buffer_write()
3732 /* Remove the padding bytes from the data read from the DSP */ in wm_adsp_remove_padding()
3743 const struct wm_adsp_fw_caps *caps = wm_adsp_fw[buf->dsp->fw].caps; in wm_adsp_buffer_populate()
3787 static struct wm_adsp_compr_buf *wm_adsp_buffer_alloc(struct wm_adsp *dsp) in wm_adsp_buffer_alloc() argument
3795 buf->dsp = dsp; in wm_adsp_buffer_alloc()
3799 list_add_tail(&buf->list, &dsp->buffer_list); in wm_adsp_buffer_alloc()
3804 static int wm_adsp_buffer_parse_legacy(struct wm_adsp *dsp) in wm_adsp_buffer_parse_legacy() argument
3811 alg_region = wm_adsp_find_alg_region(dsp, WMFW_ADSP2_XM, dsp->fw_id); in wm_adsp_buffer_parse_legacy()
3813 adsp_err(dsp, "No algorithm region found\n"); in wm_adsp_buffer_parse_legacy()
3817 buf = wm_adsp_buffer_alloc(dsp); in wm_adsp_buffer_parse_legacy()
3821 xmalg = dsp->ops->sys_config_size / sizeof(__be32); in wm_adsp_buffer_parse_legacy()
3824 ret = wm_adsp_read_data_word(dsp, WMFW_ADSP2_XM, addr, &magic); in wm_adsp_buffer_parse_legacy()
3833 ret = wm_adsp_read_data_word(dsp, WMFW_ADSP2_XM, addr, in wm_adsp_buffer_parse_legacy()
3870 ret = regmap_raw_read(ctl->dsp->regmap, reg, &val, sizeof(val)); in wm_adsp_buffer_parse_coeff()
3881 adsp_err(ctl->dsp, "Failed to acquire host buffer\n"); in wm_adsp_buffer_parse_coeff()
3885 buf = wm_adsp_buffer_alloc(ctl->dsp); in wm_adsp_buffer_parse_coeff()
3905 ret = regmap_raw_read(ctl->dsp->regmap, reg, &coeff_v1, in wm_adsp_buffer_parse_coeff()
3915 adsp_err(ctl->dsp, in wm_adsp_buffer_parse_coeff()
3928 buf->name = kasprintf(GFP_KERNEL, "%s-dsp-%s", ctl->dsp->part, in wm_adsp_buffer_parse_coeff()
3937 static int wm_adsp_buffer_init(struct wm_adsp *dsp) in wm_adsp_buffer_init() argument
3942 list_for_each_entry(ctl, &dsp->ctl_list, list) { in wm_adsp_buffer_init()
3951 adsp_err(dsp, "Failed to parse coeff: %d\n", ret); in wm_adsp_buffer_init()
3959 if (list_empty(&dsp->buffer_list)) { in wm_adsp_buffer_init()
3961 ret = wm_adsp_buffer_parse_legacy(dsp); in wm_adsp_buffer_init()
3963 adsp_err(dsp, "Failed to parse legacy: %d\n", ret); in wm_adsp_buffer_init()
3971 wm_adsp_buffer_free(dsp); in wm_adsp_buffer_init()
3975 static int wm_adsp_buffer_free(struct wm_adsp *dsp) in wm_adsp_buffer_free() argument
3979 list_for_each_entry_safe(buf, tmp, &dsp->buffer_list, list) { in wm_adsp_buffer_free()
4012 struct wm_adsp *dsp = compr->dsp; in wm_adsp_compr_trigger() local
4017 mutex_lock(&dsp->pwr_lock); in wm_adsp_compr_trigger()
4053 mutex_unlock(&dsp->pwr_lock); in wm_adsp_compr_trigger()
4061 int last_region = wm_adsp_fw[buf->dsp->fw].caps->num_regions - 1; in wm_adsp_buffer_size()
4109 int wm_adsp_compr_handle_irq(struct wm_adsp *dsp) in wm_adsp_compr_handle_irq() argument
4115 mutex_lock(&dsp->pwr_lock); in wm_adsp_compr_handle_irq()
4117 if (list_empty(&dsp->buffer_list)) { in wm_adsp_compr_handle_irq()
4122 adsp_dbg(dsp, "Handling buffer IRQ\n"); in wm_adsp_compr_handle_irq()
4124 list_for_each_entry(buf, &dsp->buffer_list, list) { in wm_adsp_compr_handle_irq()
4144 if (wm_adsp_fw[dsp->fw].voice_trigger && buf->irq_count == 2) in wm_adsp_compr_handle_irq()
4153 mutex_unlock(&dsp->pwr_lock); in wm_adsp_compr_handle_irq()
4177 struct wm_adsp *dsp = compr->dsp; in wm_adsp_compr_pointer() local
4183 mutex_lock(&dsp->pwr_lock); in wm_adsp_compr_pointer()
4187 if (dsp->fatal_error || !buf || buf->error) { in wm_adsp_compr_pointer()
4202 * DSP to inform us once a whole fragment is available. in wm_adsp_compr_pointer()
4227 mutex_unlock(&dsp->pwr_lock); in wm_adsp_compr_pointer()
4241 for (i = 0; i < wm_adsp_fw[buf->dsp->fw].caps->num_regions; ++i) in wm_adsp_buffer_capture_block()
4245 if (i == wm_adsp_fw[buf->dsp->fw].caps->num_regions) in wm_adsp_buffer_capture_block()
4264 /* Read data from DSP */ in wm_adsp_buffer_capture_block()
4265 ret = wm_adsp_read_data_block(buf->dsp, mem_type, adsp_addr, in wm_adsp_buffer_capture_block()
4291 struct wm_adsp *dsp = compr->dsp; in wm_adsp_compr_read() local
4297 if (dsp->fatal_error || !compr->buf || compr->buf->error) { in wm_adsp_compr_read()
4336 struct wm_adsp *dsp = compr->dsp; in wm_adsp_compr_copy() local
4339 mutex_lock(&dsp->pwr_lock); in wm_adsp_compr_copy()
4346 mutex_unlock(&dsp->pwr_lock); in wm_adsp_compr_copy()
4352 static void wm_adsp_fatal_error(struct wm_adsp *dsp) in wm_adsp_fatal_error() argument
4356 dsp->fatal_error = true; in wm_adsp_fatal_error()
4358 list_for_each_entry(compr, &dsp->compr_list, list) { in wm_adsp_fatal_error()
4366 struct wm_adsp *dsp = (struct wm_adsp *)data; in wm_adsp2_bus_error() local
4368 struct regmap *regmap = dsp->regmap; in wm_adsp2_bus_error()
4371 mutex_lock(&dsp->pwr_lock); in wm_adsp2_bus_error()
4373 ret = regmap_read(regmap, dsp->base + ADSP2_LOCK_REGION_CTRL, &val); in wm_adsp2_bus_error()
4375 adsp_err(dsp, in wm_adsp2_bus_error()
4381 adsp_err(dsp, "watchdog timeout error\n"); in wm_adsp2_bus_error()
4382 dsp->ops->stop_watchdog(dsp); in wm_adsp2_bus_error()
4383 wm_adsp_fatal_error(dsp); in wm_adsp2_bus_error()
4388 adsp_err(dsp, "bus error: address error\n"); in wm_adsp2_bus_error()
4390 adsp_err(dsp, "bus error: region lock error\n"); in wm_adsp2_bus_error()
4392 ret = regmap_read(regmap, dsp->base + ADSP2_BUS_ERR_ADDR, &val); in wm_adsp2_bus_error()
4394 adsp_err(dsp, in wm_adsp2_bus_error()
4400 adsp_err(dsp, "bus error address = 0x%x\n", in wm_adsp2_bus_error()
4404 dsp->base + ADSP2_PMEM_ERR_ADDR_XMEM_ERR_ADDR, in wm_adsp2_bus_error()
4407 adsp_err(dsp, in wm_adsp2_bus_error()
4413 adsp_err(dsp, "xmem error address = 0x%x\n", in wm_adsp2_bus_error()
4415 adsp_err(dsp, "pmem error address = 0x%x\n", in wm_adsp2_bus_error()
4420 regmap_update_bits(regmap, dsp->base + ADSP2_LOCK_REGION_CTRL, in wm_adsp2_bus_error()
4424 mutex_unlock(&dsp->pwr_lock); in wm_adsp2_bus_error()
4432 struct wm_adsp *dsp = (struct wm_adsp *)data; in wm_halo_bus_error() local
4433 struct regmap *regmap = dsp->regmap; in wm_halo_bus_error()
4436 { dsp->base + HALO_MPU_XM_VIO_STATUS, 0x0 }, in wm_halo_bus_error()
4437 { dsp->base + HALO_MPU_YM_VIO_STATUS, 0x0 }, in wm_halo_bus_error()
4438 { dsp->base + HALO_MPU_PM_VIO_STATUS, 0x0 }, in wm_halo_bus_error()
4442 mutex_lock(&dsp->pwr_lock); in wm_halo_bus_error()
4444 ret = regmap_read(regmap, dsp->base_sysinfo + HALO_AHBM_WINDOW_DEBUG_1, in wm_halo_bus_error()
4447 adsp_warn(dsp, "Failed to read AHB DEBUG_1: %d\n", ret); in wm_halo_bus_error()
4451 adsp_warn(dsp, "AHB: STATUS: 0x%x ADDR: 0x%x\n", in wm_halo_bus_error()
4456 ret = regmap_read(regmap, dsp->base_sysinfo + HALO_AHBM_WINDOW_DEBUG_0, in wm_halo_bus_error()
4459 adsp_warn(dsp, "Failed to read AHB DEBUG_0: %d\n", ret); in wm_halo_bus_error()
4463 adsp_warn(dsp, "AHB: SYS_ADDR: 0x%x\n", *fault); in wm_halo_bus_error()
4465 ret = regmap_bulk_read(regmap, dsp->base + HALO_MPU_XM_VIO_ADDR, in wm_halo_bus_error()
4468 adsp_warn(dsp, "Failed to read MPU fault info: %d\n", ret); in wm_halo_bus_error()
4472 adsp_warn(dsp, "XM: STATUS:0x%x ADDR:0x%x\n", fault[1], fault[0]); in wm_halo_bus_error()
4473 adsp_warn(dsp, "YM: STATUS:0x%x ADDR:0x%x\n", fault[3], fault[2]); in wm_halo_bus_error()
4474 adsp_warn(dsp, "PM: STATUS:0x%x ADDR:0x%x\n", fault[5], fault[4]); in wm_halo_bus_error()
4476 ret = regmap_multi_reg_write(dsp->regmap, clear, ARRAY_SIZE(clear)); in wm_halo_bus_error()
4478 adsp_warn(dsp, "Failed to clear MPU status: %d\n", ret); in wm_halo_bus_error()
4481 mutex_unlock(&dsp->pwr_lock); in wm_halo_bus_error()
4489 struct wm_adsp *dsp = data; in wm_halo_wdt_expire() local
4491 mutex_lock(&dsp->pwr_lock); in wm_halo_wdt_expire()
4493 adsp_warn(dsp, "WDT Expiry Fault\n"); in wm_halo_wdt_expire()
4494 dsp->ops->stop_watchdog(dsp); in wm_halo_wdt_expire()
4495 wm_adsp_fatal_error(dsp); in wm_halo_wdt_expire()
4497 mutex_unlock(&dsp->pwr_lock); in wm_halo_wdt_expire()