Lines Matching refs: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", \
437 struct wm_adsp *dsp; member
454 struct wm_adsp *dsp; member
488 static int wm_adsp_buffer_init(struct wm_adsp *dsp);
489 static int wm_adsp_buffer_free(struct wm_adsp *dsp);
604 struct wm_adsp *dsp; member
641 static void wm_adsp_debugfs_save_wmfwname(struct wm_adsp *dsp, const char *s) in wm_adsp_debugfs_save_wmfwname() argument
645 kfree(dsp->wmfw_file_name); in wm_adsp_debugfs_save_wmfwname()
646 dsp->wmfw_file_name = tmp; in wm_adsp_debugfs_save_wmfwname()
649 static void wm_adsp_debugfs_save_binname(struct wm_adsp *dsp, const char *s) in wm_adsp_debugfs_save_binname() argument
653 kfree(dsp->bin_file_name); in wm_adsp_debugfs_save_binname()
654 dsp->bin_file_name = tmp; in wm_adsp_debugfs_save_binname()
657 static void wm_adsp_debugfs_clear(struct wm_adsp *dsp) in wm_adsp_debugfs_clear() argument
659 kfree(dsp->wmfw_file_name); in wm_adsp_debugfs_clear()
660 kfree(dsp->bin_file_name); in wm_adsp_debugfs_clear()
661 dsp->wmfw_file_name = NULL; in wm_adsp_debugfs_clear()
662 dsp->bin_file_name = NULL; in wm_adsp_debugfs_clear()
669 struct wm_adsp *dsp = file->private_data; in wm_adsp_debugfs_wmfw_read() local
672 mutex_lock(&dsp->pwr_lock); in wm_adsp_debugfs_wmfw_read()
674 if (!dsp->wmfw_file_name || !dsp->booted) in wm_adsp_debugfs_wmfw_read()
678 dsp->wmfw_file_name, in wm_adsp_debugfs_wmfw_read()
679 strlen(dsp->wmfw_file_name)); in wm_adsp_debugfs_wmfw_read()
681 mutex_unlock(&dsp->pwr_lock); in wm_adsp_debugfs_wmfw_read()
689 struct wm_adsp *dsp = file->private_data; in wm_adsp_debugfs_bin_read() local
692 mutex_lock(&dsp->pwr_lock); in wm_adsp_debugfs_bin_read()
694 if (!dsp->bin_file_name || !dsp->booted) in wm_adsp_debugfs_bin_read()
698 dsp->bin_file_name, in wm_adsp_debugfs_bin_read()
699 strlen(dsp->bin_file_name)); in wm_adsp_debugfs_bin_read()
701 mutex_unlock(&dsp->pwr_lock); in wm_adsp_debugfs_bin_read()
725 static void wm_adsp2_init_debugfs(struct wm_adsp *dsp, in wm_adsp2_init_debugfs() argument
731 root = debugfs_create_dir(dsp->name, component->debugfs_root); in wm_adsp2_init_debugfs()
733 debugfs_create_bool("booted", 0444, root, &dsp->booted); in wm_adsp2_init_debugfs()
734 debugfs_create_bool("running", 0444, root, &dsp->running); in wm_adsp2_init_debugfs()
735 debugfs_create_x32("fw_id", 0444, root, &dsp->fw_id); in wm_adsp2_init_debugfs()
736 debugfs_create_x32("fw_version", 0444, root, &dsp->fw_id_version); in wm_adsp2_init_debugfs()
740 dsp, &wm_adsp_debugfs_fops[i].fops); in wm_adsp2_init_debugfs()
742 dsp->debugfs_root = root; in wm_adsp2_init_debugfs()
745 static void wm_adsp2_cleanup_debugfs(struct wm_adsp *dsp) in wm_adsp2_cleanup_debugfs() argument
747 wm_adsp_debugfs_clear(dsp); in wm_adsp2_cleanup_debugfs()
748 debugfs_remove_recursive(dsp->debugfs_root); in wm_adsp2_cleanup_debugfs()
751 static inline void wm_adsp2_init_debugfs(struct wm_adsp *dsp, in wm_adsp2_init_debugfs() argument
756 static inline void wm_adsp2_cleanup_debugfs(struct wm_adsp *dsp) in wm_adsp2_cleanup_debugfs() argument
760 static inline void wm_adsp_debugfs_save_wmfwname(struct wm_adsp *dsp, in wm_adsp_debugfs_save_wmfwname() argument
765 static inline void wm_adsp_debugfs_save_binname(struct wm_adsp *dsp, in wm_adsp_debugfs_save_binname() argument
770 static inline void wm_adsp_debugfs_clear(struct wm_adsp *dsp) in wm_adsp_debugfs_clear() argument
780 struct wm_adsp *dsp = snd_soc_component_get_drvdata(component); in wm_adsp_fw_get() local
782 ucontrol->value.enumerated.item[0] = dsp[e->shift_l].fw; in wm_adsp_fw_get()
793 struct wm_adsp *dsp = snd_soc_component_get_drvdata(component); in wm_adsp_fw_put() local
796 if (ucontrol->value.enumerated.item[0] == dsp[e->shift_l].fw) in wm_adsp_fw_put()
802 mutex_lock(&dsp[e->shift_l].pwr_lock); in wm_adsp_fw_put()
804 if (dsp[e->shift_l].booted || !list_empty(&dsp[e->shift_l].compr_list)) in wm_adsp_fw_put()
807 dsp[e->shift_l].fw = ucontrol->value.enumerated.item[0]; in wm_adsp_fw_put()
809 mutex_unlock(&dsp[e->shift_l].pwr_lock); in wm_adsp_fw_put()
826 static struct wm_adsp_region const *wm_adsp_find_region(struct wm_adsp *dsp, in wm_adsp_find_region() argument
831 for (i = 0; i < dsp->num_mems; i++) in wm_adsp_find_region()
832 if (dsp->mem[i].type == type) in wm_adsp_find_region()
833 return &dsp->mem[i]; in wm_adsp_find_region()
873 static void wm_adsp_read_fw_status(struct wm_adsp *dsp, in wm_adsp_read_fw_status() argument
880 ret = regmap_read(dsp->regmap, dsp->base + offs[i], &offs[i]); in wm_adsp_read_fw_status()
882 adsp_err(dsp, "Failed to read SCRATCH%u: %d\n", i, ret); in wm_adsp_read_fw_status()
888 static void wm_adsp2_show_fw_status(struct wm_adsp *dsp) in wm_adsp2_show_fw_status() argument
894 wm_adsp_read_fw_status(dsp, ARRAY_SIZE(offs), offs); in wm_adsp2_show_fw_status()
896 adsp_dbg(dsp, "FW SCRATCH 0:0x%x 1:0x%x 2:0x%x 3:0x%x\n", in wm_adsp2_show_fw_status()
900 static void wm_adsp2v2_show_fw_status(struct wm_adsp *dsp) in wm_adsp2v2_show_fw_status() argument
904 wm_adsp_read_fw_status(dsp, ARRAY_SIZE(offs), offs); in wm_adsp2v2_show_fw_status()
906 adsp_dbg(dsp, "FW SCRATCH 0:0x%x 1:0x%x 2:0x%x 3:0x%x\n", in wm_adsp2v2_show_fw_status()
911 static void wm_halo_show_fw_status(struct wm_adsp *dsp) in wm_halo_show_fw_status() argument
917 wm_adsp_read_fw_status(dsp, ARRAY_SIZE(offs), offs); in wm_halo_show_fw_status()
919 adsp_dbg(dsp, "FW SCRATCH 0:0x%x 1:0x%x 2:0x%x 3:0x%x\n", in wm_halo_show_fw_status()
931 struct wm_adsp *dsp = ctl->dsp; in wm_coeff_base_reg() local
934 mem = wm_adsp_find_region(dsp, alg_region->type); in wm_coeff_base_reg()
936 adsp_err(dsp, "No base for region %x\n", in wm_coeff_base_reg()
941 *reg = dsp->ops->region_to_reg(mem, ctl->alg_region.base + ctl->offset); in wm_coeff_base_reg()
973 struct wm_adsp *dsp = ctl->dsp; in wm_coeff_write_acked_control() local
982 adsp_dbg(dsp, "Sending 0x%x to acked control alg 0x%x %s:0x%x\n", in wm_coeff_write_acked_control()
986 ret = regmap_raw_write(dsp->regmap, reg, &val, sizeof(val)); in wm_coeff_write_acked_control()
988 adsp_err(dsp, "Failed to write %x: %d\n", reg, ret); in wm_coeff_write_acked_control()
1010 ret = regmap_raw_read(dsp->regmap, reg, &val, sizeof(val)); in wm_coeff_write_acked_control()
1012 adsp_err(dsp, "Failed to read %x: %d\n", reg, ret); in wm_coeff_write_acked_control()
1017 adsp_dbg(dsp, "Acked control ACKED at poll %u\n", i); in wm_coeff_write_acked_control()
1022 adsp_warn(dsp, "Acked control @0x%x alg:0x%x %s:0x%x timed out\n", in wm_coeff_write_acked_control()
1033 struct wm_adsp *dsp = ctl->dsp; in wm_coeff_write_control() local
1046 ret = regmap_raw_write(dsp->regmap, reg, scratch, in wm_coeff_write_control()
1049 adsp_err(dsp, "Failed to write %zu bytes to %x: %d\n", in wm_coeff_write_control()
1054 adsp_dbg(dsp, "Wrote %zu bytes to %x\n", len, reg); in wm_coeff_write_control()
1070 mutex_lock(&ctl->dsp->pwr_lock); in wm_coeff_put()
1078 if (ctl->enabled && ctl->dsp->running) in wm_coeff_put()
1081 mutex_unlock(&ctl->dsp->pwr_lock); in wm_coeff_put()
1094 mutex_lock(&ctl->dsp->pwr_lock); in wm_coeff_tlv_put()
1100 if (ctl->enabled && ctl->dsp->running) in wm_coeff_tlv_put()
1106 mutex_unlock(&ctl->dsp->pwr_lock); in wm_coeff_tlv_put()
1123 mutex_lock(&ctl->dsp->pwr_lock); in wm_coeff_put_acked()
1125 if (ctl->enabled && ctl->dsp->running) in wm_coeff_put_acked()
1130 mutex_unlock(&ctl->dsp->pwr_lock); in wm_coeff_put_acked()
1138 struct wm_adsp *dsp = ctl->dsp; in wm_coeff_read_control() local
1151 ret = regmap_raw_read(dsp->regmap, reg, scratch, len); in wm_coeff_read_control()
1153 adsp_err(dsp, "Failed to read %zu bytes from %x: %d\n", in wm_coeff_read_control()
1158 adsp_dbg(dsp, "Read %zu bytes from %x\n", len, reg); in wm_coeff_read_control()
1175 mutex_lock(&ctl->dsp->pwr_lock); in wm_coeff_get()
1178 if (ctl->enabled && ctl->dsp->running) in wm_coeff_get()
1183 if (!ctl->flags && ctl->enabled && ctl->dsp->running) in wm_coeff_get()
1189 mutex_unlock(&ctl->dsp->pwr_lock); in wm_coeff_get()
1202 mutex_lock(&ctl->dsp->pwr_lock); in wm_coeff_tlv_get()
1205 if (ctl->enabled && ctl->dsp->running) in wm_coeff_tlv_get()
1210 if (!ctl->flags && ctl->enabled && ctl->dsp->running) in wm_coeff_tlv_get()
1217 mutex_unlock(&ctl->dsp->pwr_lock); in wm_coeff_tlv_get()
1238 struct wm_adsp *dsp; member
1274 static int wmfw_add_ctl(struct wm_adsp *dsp, struct wm_coeff_ctl *ctl) in wmfw_add_ctl() argument
1310 ret = snd_soc_add_component_controls(dsp->component, kcontrol, 1); in wmfw_add_ctl()
1323 static int wm_coeff_init_control_caches(struct wm_adsp *dsp) in wm_coeff_init_control_caches() argument
1328 list_for_each_entry(ctl, &dsp->ctl_list, list) { in wm_coeff_init_control_caches()
1349 static int wm_coeff_sync_controls(struct wm_adsp *dsp) in wm_coeff_sync_controls() argument
1354 list_for_each_entry(ctl, &dsp->ctl_list, list) { in wm_coeff_sync_controls()
1367 static void wm_adsp_signal_event_controls(struct wm_adsp *dsp, in wm_adsp_signal_event_controls() argument
1373 list_for_each_entry(ctl, &dsp->ctl_list, list) { in wm_adsp_signal_event_controls()
1382 adsp_warn(dsp, in wm_adsp_signal_event_controls()
1394 wmfw_add_ctl(ctl_work->dsp, ctl_work->ctl); in wm_adsp_ctl_work()
1405 static int wm_adsp_create_control(struct wm_adsp *dsp, in wm_adsp_create_control() argument
1419 adsp_err(dsp, "Unknown region type: %d\n", alg_region->type); in wm_adsp_create_control()
1423 switch (dsp->fw_ver) { in wm_adsp_create_control()
1427 dsp->name, region_name, alg_region->alg); in wm_adsp_create_control()
1432 "%s%c %.12s %x", dsp->name, *region_name, in wm_adsp_create_control()
1433 wm_adsp_fw_text[dsp->fw], alg_region->alg); in wm_adsp_create_control()
1437 "%s %.12s %x", dsp->name, in wm_adsp_create_control()
1438 wm_adsp_fw_text[dsp->fw], alg_region->alg); in wm_adsp_create_control()
1446 if (dsp->component->name_prefix) in wm_adsp_create_control()
1447 avail -= strlen(dsp->component->name_prefix) + 1; in wm_adsp_create_control()
1457 list_for_each_entry(ctl, &dsp->ctl_list, list) { in wm_adsp_create_control()
1468 ctl->fw_name = wm_adsp_fw_text[dsp->fw]; in wm_adsp_create_control()
1479 ctl->dsp = dsp; in wm_adsp_create_control()
1491 list_add(&ctl->list, &dsp->ctl_list); in wm_adsp_create_control()
1502 ctl_work->dsp = dsp; in wm_adsp_create_control()
1579 static inline void wm_coeff_parse_alg(struct wm_adsp *dsp, const u8 **data, in wm_coeff_parse_alg() argument
1584 switch (dsp->fw_ver) { in wm_coeff_parse_alg()
1604 adsp_dbg(dsp, "Algorithm ID: %#x\n", blk->id); in wm_coeff_parse_alg()
1605 adsp_dbg(dsp, "Algorithm name: %.*s\n", blk->name_len, blk->name); in wm_coeff_parse_alg()
1606 adsp_dbg(dsp, "# of coefficient descriptors: %#x\n", blk->ncoeff); in wm_coeff_parse_alg()
1609 static inline void wm_coeff_parse_coeff(struct wm_adsp *dsp, const u8 **data, in wm_coeff_parse_coeff() argument
1616 switch (dsp->fw_ver) { in wm_coeff_parse_coeff()
1647 adsp_dbg(dsp, "\tCoefficient type: %#x\n", blk->mem_type); in wm_coeff_parse_coeff()
1648 adsp_dbg(dsp, "\tCoefficient offset: %#x\n", blk->offset); in wm_coeff_parse_coeff()
1649 adsp_dbg(dsp, "\tCoefficient name: %.*s\n", blk->name_len, blk->name); in wm_coeff_parse_coeff()
1650 adsp_dbg(dsp, "\tCoefficient flags: %#x\n", blk->flags); in wm_coeff_parse_coeff()
1651 adsp_dbg(dsp, "\tALSA control type: %#x\n", blk->ctl_type); in wm_coeff_parse_coeff()
1652 adsp_dbg(dsp, "\tALSA control len: %#x\n", blk->len); in wm_coeff_parse_coeff()
1655 static int wm_adsp_check_coeff_flags(struct wm_adsp *dsp, in wm_adsp_check_coeff_flags() argument
1662 adsp_err(dsp, "Illegal flags 0x%x for control type 0x%x\n", in wm_adsp_check_coeff_flags()
1670 static int wm_adsp_parse_coeff(struct wm_adsp *dsp, in wm_adsp_parse_coeff() argument
1679 wm_coeff_parse_alg(dsp, &data, &alg_blk); in wm_adsp_parse_coeff()
1681 wm_coeff_parse_coeff(dsp, &data, &coeff_blk); in wm_adsp_parse_coeff()
1690 ret = wm_adsp_check_coeff_flags(dsp, &coeff_blk, in wm_adsp_parse_coeff()
1699 ret = wm_adsp_check_coeff_flags(dsp, &coeff_blk, in wm_adsp_parse_coeff()
1709 ret = wm_adsp_check_coeff_flags(dsp, &coeff_blk, in wm_adsp_parse_coeff()
1718 adsp_err(dsp, "Unknown control type: %d\n", in wm_adsp_parse_coeff()
1726 ret = wm_adsp_create_control(dsp, &alg_region, in wm_adsp_parse_coeff()
1734 adsp_err(dsp, "Failed to create control: %.*s, %d\n", in wm_adsp_parse_coeff()
1741 static unsigned int wm_adsp1_parse_sizes(struct wm_adsp *dsp, in wm_adsp1_parse_sizes() argument
1750 adsp_dbg(dsp, "%s: %d DM, %d PM, %d ZM\n", file, in wm_adsp1_parse_sizes()
1757 static unsigned int wm_adsp2_parse_sizes(struct wm_adsp *dsp, in wm_adsp2_parse_sizes() argument
1766 adsp_dbg(dsp, "%s: %d XM, %d YM %d PM, %d ZM\n", file, in wm_adsp2_parse_sizes()
1773 static bool wm_adsp_validate_version(struct wm_adsp *dsp, unsigned int version) in wm_adsp_validate_version() argument
1777 adsp_warn(dsp, "Deprecated file format %d\n", version); in wm_adsp_validate_version()
1787 static bool wm_halo_validate_version(struct wm_adsp *dsp, unsigned int version) in wm_halo_validate_version() argument
1797 static int wm_adsp_load(struct wm_adsp *dsp) in wm_adsp_load() argument
1801 struct regmap *regmap = dsp->regmap; in wm_adsp_load()
1819 snprintf(file, PAGE_SIZE, "%s-%s-%s.wmfw", dsp->part, dsp->fwf_name, in wm_adsp_load()
1820 wm_adsp_fw[dsp->fw].file); in wm_adsp_load()
1823 ret = request_firmware(&firmware, file, dsp->dev); in wm_adsp_load()
1825 adsp_err(dsp, "Failed to request '%s'\n", file); in wm_adsp_load()
1832 adsp_err(dsp, "%s: file too short, %zu bytes\n", in wm_adsp_load()
1840 adsp_err(dsp, "%s: invalid magic\n", file); in wm_adsp_load()
1844 if (!dsp->ops->validate_version(dsp, header->ver)) { in wm_adsp_load()
1845 adsp_err(dsp, "%s: unknown file format %d\n", in wm_adsp_load()
1850 adsp_info(dsp, "Firmware version: %d\n", header->ver); in wm_adsp_load()
1851 dsp->fw_ver = header->ver; in wm_adsp_load()
1853 if (header->core != dsp->type) { in wm_adsp_load()
1854 adsp_err(dsp, "%s: invalid core %d != %d\n", in wm_adsp_load()
1855 file, header->core, dsp->type); in wm_adsp_load()
1860 pos = dsp->ops->parse_sizes(dsp, file, pos, firmware); in wm_adsp_load()
1866 adsp_err(dsp, "%s: unexpected header length %d\n", in wm_adsp_load()
1871 adsp_dbg(dsp, "%s: timestamp %llu\n", file, in wm_adsp_load()
1891 ret = wm_adsp_parse_coeff(dsp, region); in wm_adsp_load()
1912 mem = wm_adsp_find_region(dsp, type); in wm_adsp_load()
1914 adsp_err(dsp, "No region of type: %x\n", type); in wm_adsp_load()
1919 reg = dsp->ops->region_to_reg(mem, offset); in wm_adsp_load()
1922 adsp_warn(dsp, in wm_adsp_load()
1928 adsp_dbg(dsp, "%s.%d: %d bytes at %d in %s\n", file, in wm_adsp_load()
1934 adsp_err(dsp, in wm_adsp_load()
1944 adsp_info(dsp, "%s: %s\n", file, text); in wm_adsp_load()
1954 adsp_err(dsp, "Out of memory\n"); in wm_adsp_load()
1962 adsp_err(dsp, in wm_adsp_load()
1977 adsp_err(dsp, "Failed to complete async write: %d\n", ret); in wm_adsp_load()
1982 adsp_warn(dsp, "%s.%d: %zu bytes at end of file\n", in wm_adsp_load()
1985 wm_adsp_debugfs_save_wmfwname(dsp, file); in wm_adsp_load()
1998 static void wm_adsp_ctl_fixup_base(struct wm_adsp *dsp, in wm_adsp_ctl_fixup_base() argument
2003 list_for_each_entry(ctl, &dsp->ctl_list, list) { in wm_adsp_ctl_fixup_base()
2004 if (ctl->fw_name == wm_adsp_fw_text[dsp->fw] && in wm_adsp_ctl_fixup_base()
2012 static void *wm_adsp_read_algs(struct wm_adsp *dsp, size_t n_algs, in wm_adsp_read_algs() argument
2022 adsp_err(dsp, "No algorithms\n"); in wm_adsp_read_algs()
2027 adsp_err(dsp, "Algorithm count %zx excessive\n", n_algs); in wm_adsp_read_algs()
2032 reg = dsp->ops->region_to_reg(mem, pos + len); in wm_adsp_read_algs()
2034 ret = regmap_raw_read(dsp->regmap, reg, &val, sizeof(val)); in wm_adsp_read_algs()
2036 adsp_err(dsp, "Failed to read algorithm list end: %d\n", in wm_adsp_read_algs()
2042 adsp_warn(dsp, "Algorithm list end %x 0x%x != 0xbedead\n", in wm_adsp_read_algs()
2052 reg = dsp->ops->region_to_reg(mem, pos); in wm_adsp_read_algs()
2054 ret = regmap_raw_read(dsp->regmap, reg, alg, len); in wm_adsp_read_algs()
2056 adsp_err(dsp, "Failed to read algorithm list: %d\n", ret); in wm_adsp_read_algs()
2065 wm_adsp_find_alg_region(struct wm_adsp *dsp, int type, unsigned int id) in wm_adsp_find_alg_region() argument
2069 list_for_each_entry(alg_region, &dsp->alg_regions, list) { in wm_adsp_find_alg_region()
2077 static struct wm_adsp_alg_region *wm_adsp_create_region(struct wm_adsp *dsp, in wm_adsp_create_region() argument
2091 list_add_tail(&alg_region->list, &dsp->alg_regions); in wm_adsp_create_region()
2093 if (dsp->fw_ver > 0) in wm_adsp_create_region()
2094 wm_adsp_ctl_fixup_base(dsp, alg_region); in wm_adsp_create_region()
2099 static void wm_adsp_free_alg_regions(struct wm_adsp *dsp) in wm_adsp_free_alg_regions() argument
2103 while (!list_empty(&dsp->alg_regions)) { in wm_adsp_free_alg_regions()
2104 alg_region = list_first_entry(&dsp->alg_regions, in wm_adsp_free_alg_regions()
2112 static void wmfw_parse_id_header(struct wm_adsp *dsp, in wmfw_parse_id_header() argument
2115 dsp->fw_id = be32_to_cpu(fw->id); in wmfw_parse_id_header()
2116 dsp->fw_id_version = be32_to_cpu(fw->ver); in wmfw_parse_id_header()
2118 adsp_info(dsp, "Firmware: %x v%d.%d.%d, %d algorithms\n", in wmfw_parse_id_header()
2119 dsp->fw_id, (dsp->fw_id_version & 0xff0000) >> 16, in wmfw_parse_id_header()
2120 (dsp->fw_id_version & 0xff00) >> 8, dsp->fw_id_version & 0xff, in wmfw_parse_id_header()
2124 static void wmfw_v3_parse_id_header(struct wm_adsp *dsp, in wmfw_v3_parse_id_header() argument
2127 dsp->fw_id = be32_to_cpu(fw->id); in wmfw_v3_parse_id_header()
2128 dsp->fw_id_version = be32_to_cpu(fw->ver); in wmfw_v3_parse_id_header()
2129 dsp->fw_vendor_id = be32_to_cpu(fw->vendor_id); in wmfw_v3_parse_id_header()
2131 adsp_info(dsp, "Firmware: %x vendor: 0x%x v%d.%d.%d, %d algorithms\n", in wmfw_v3_parse_id_header()
2132 dsp->fw_id, dsp->fw_vendor_id, in wmfw_v3_parse_id_header()
2133 (dsp->fw_id_version & 0xff0000) >> 16, in wmfw_v3_parse_id_header()
2134 (dsp->fw_id_version & 0xff00) >> 8, dsp->fw_id_version & 0xff, in wmfw_v3_parse_id_header()
2138 static int wm_adsp_create_regions(struct wm_adsp *dsp, __be32 id, int nregions, in wm_adsp_create_regions() argument
2145 alg_region = wm_adsp_create_region(dsp, type[i], id, base[i]); in wm_adsp_create_regions()
2153 static int wm_adsp1_setup_algs(struct wm_adsp *dsp) in wm_adsp1_setup_algs() argument
2163 mem = wm_adsp_find_region(dsp, WMFW_ADSP1_DM); in wm_adsp1_setup_algs()
2167 ret = regmap_raw_read(dsp->regmap, mem->base, &adsp1_id, in wm_adsp1_setup_algs()
2170 adsp_err(dsp, "Failed to read algorithm info: %d\n", in wm_adsp1_setup_algs()
2177 wmfw_parse_id_header(dsp, &adsp1_id.fw, n_algs); in wm_adsp1_setup_algs()
2179 alg_region = wm_adsp_create_region(dsp, WMFW_ADSP1_ZM, in wm_adsp1_setup_algs()
2184 alg_region = wm_adsp_create_region(dsp, WMFW_ADSP1_DM, in wm_adsp1_setup_algs()
2193 adsp1_alg = wm_adsp_read_algs(dsp, n_algs, mem, pos, len); in wm_adsp1_setup_algs()
2198 adsp_info(dsp, "%d: ID %x v%d.%d.%d DM@%x ZM@%x\n", in wm_adsp1_setup_algs()
2206 alg_region = wm_adsp_create_region(dsp, WMFW_ADSP1_DM, in wm_adsp1_setup_algs()
2213 if (dsp->fw_ver == 0) { in wm_adsp1_setup_algs()
2218 wm_adsp_create_control(dsp, alg_region, 0, in wm_adsp1_setup_algs()
2222 adsp_warn(dsp, "Missing length info for region DM with ID %x\n", in wm_adsp1_setup_algs()
2227 alg_region = wm_adsp_create_region(dsp, WMFW_ADSP1_ZM, in wm_adsp1_setup_algs()
2234 if (dsp->fw_ver == 0) { in wm_adsp1_setup_algs()
2239 wm_adsp_create_control(dsp, alg_region, 0, in wm_adsp1_setup_algs()
2243 adsp_warn(dsp, "Missing length info for region ZM with ID %x\n", in wm_adsp1_setup_algs()
2254 static int wm_adsp2_setup_algs(struct wm_adsp *dsp) in wm_adsp2_setup_algs() argument
2264 mem = wm_adsp_find_region(dsp, WMFW_ADSP2_XM); in wm_adsp2_setup_algs()
2268 ret = regmap_raw_read(dsp->regmap, mem->base, &adsp2_id, in wm_adsp2_setup_algs()
2271 adsp_err(dsp, "Failed to read algorithm info: %d\n", in wm_adsp2_setup_algs()
2278 wmfw_parse_id_header(dsp, &adsp2_id.fw, n_algs); in wm_adsp2_setup_algs()
2280 alg_region = wm_adsp_create_region(dsp, WMFW_ADSP2_XM, in wm_adsp2_setup_algs()
2285 alg_region = wm_adsp_create_region(dsp, WMFW_ADSP2_YM, in wm_adsp2_setup_algs()
2290 alg_region = wm_adsp_create_region(dsp, WMFW_ADSP2_ZM, in wm_adsp2_setup_algs()
2299 adsp2_alg = wm_adsp_read_algs(dsp, n_algs, mem, pos, len); in wm_adsp2_setup_algs()
2304 adsp_info(dsp, in wm_adsp2_setup_algs()
2314 alg_region = wm_adsp_create_region(dsp, WMFW_ADSP2_XM, in wm_adsp2_setup_algs()
2321 if (dsp->fw_ver == 0) { in wm_adsp2_setup_algs()
2326 wm_adsp_create_control(dsp, alg_region, 0, in wm_adsp2_setup_algs()
2330 adsp_warn(dsp, "Missing length info for region XM with ID %x\n", in wm_adsp2_setup_algs()
2335 alg_region = wm_adsp_create_region(dsp, WMFW_ADSP2_YM, in wm_adsp2_setup_algs()
2342 if (dsp->fw_ver == 0) { in wm_adsp2_setup_algs()
2347 wm_adsp_create_control(dsp, alg_region, 0, in wm_adsp2_setup_algs()
2351 adsp_warn(dsp, "Missing length info for region YM with ID %x\n", in wm_adsp2_setup_algs()
2356 alg_region = wm_adsp_create_region(dsp, WMFW_ADSP2_ZM, in wm_adsp2_setup_algs()
2363 if (dsp->fw_ver == 0) { in wm_adsp2_setup_algs()
2368 wm_adsp_create_control(dsp, alg_region, 0, in wm_adsp2_setup_algs()
2372 adsp_warn(dsp, "Missing length info for region ZM with ID %x\n", in wm_adsp2_setup_algs()
2383 static int wm_halo_create_regions(struct wm_adsp *dsp, __be32 id, in wm_halo_create_regions() argument
2392 return wm_adsp_create_regions(dsp, id, ARRAY_SIZE(types), types, bases); in wm_halo_create_regions()
2395 static int wm_halo_setup_algs(struct wm_adsp *dsp) in wm_halo_setup_algs() argument
2404 mem = wm_adsp_find_region(dsp, WMFW_ADSP2_XM); in wm_halo_setup_algs()
2408 ret = regmap_raw_read(dsp->regmap, mem->base, &halo_id, in wm_halo_setup_algs()
2411 adsp_err(dsp, "Failed to read algorithm info: %d\n", in wm_halo_setup_algs()
2418 wmfw_v3_parse_id_header(dsp, &halo_id.fw, n_algs); in wm_halo_setup_algs()
2420 ret = wm_halo_create_regions(dsp, halo_id.fw.id, in wm_halo_setup_algs()
2429 halo_alg = wm_adsp_read_algs(dsp, n_algs, mem, pos, len); in wm_halo_setup_algs()
2434 adsp_info(dsp, in wm_halo_setup_algs()
2443 ret = wm_halo_create_regions(dsp, halo_alg[i].alg.id, in wm_halo_setup_algs()
2455 static int wm_adsp_load_coeff(struct wm_adsp *dsp) in wm_adsp_load_coeff() argument
2458 struct regmap *regmap = dsp->regmap; in wm_adsp_load_coeff()
2473 snprintf(file, PAGE_SIZE, "%s-%s-%s.bin", dsp->part, dsp->fwf_name, in wm_adsp_load_coeff()
2474 wm_adsp_fw[dsp->fw].file); in wm_adsp_load_coeff()
2477 ret = request_firmware(&firmware, file, dsp->dev); in wm_adsp_load_coeff()
2479 adsp_warn(dsp, "Failed to request '%s'\n", file); in wm_adsp_load_coeff()
2486 adsp_err(dsp, "%s: file too short, %zu bytes\n", in wm_adsp_load_coeff()
2493 adsp_err(dsp, "%s: invalid magic\n", file); in wm_adsp_load_coeff()
2501 adsp_err(dsp, "%s: Unsupported coefficient file format %d\n", in wm_adsp_load_coeff()
2507 adsp_dbg(dsp, "%s: v%d.%d.%d\n", file, in wm_adsp_load_coeff()
2522 adsp_dbg(dsp, "%s.%d: %x v%d.%d.%d\n", in wm_adsp_load_coeff()
2527 adsp_dbg(dsp, "%s.%d: %d bytes at 0x%x in %x\n", in wm_adsp_load_coeff()
2541 if (le32_to_cpu(blk->id) == dsp->fw_id && in wm_adsp_load_coeff()
2544 mem = wm_adsp_find_region(dsp, type); in wm_adsp_load_coeff()
2546 adsp_err(dsp, "No ZM\n"); in wm_adsp_load_coeff()
2549 reg = dsp->ops->region_to_reg(mem, 0); in wm_adsp_load_coeff()
2564 adsp_dbg(dsp, "%s.%d: %d bytes in %x for %x\n", in wm_adsp_load_coeff()
2568 mem = wm_adsp_find_region(dsp, type); in wm_adsp_load_coeff()
2570 adsp_err(dsp, "No base for region %x\n", type); in wm_adsp_load_coeff()
2574 alg_region = wm_adsp_find_alg_region(dsp, type, in wm_adsp_load_coeff()
2578 reg = dsp->ops->region_to_reg(mem, reg); in wm_adsp_load_coeff()
2581 adsp_err(dsp, "No %x for algorithm %x\n", in wm_adsp_load_coeff()
2587 adsp_err(dsp, "%s.%d: Unknown region type %x at %d\n", in wm_adsp_load_coeff()
2595 adsp_err(dsp, in wm_adsp_load_coeff()
2608 adsp_err(dsp, "Out of memory\n"); in wm_adsp_load_coeff()
2613 adsp_dbg(dsp, "%s.%d: Writing %d bytes at %x\n", in wm_adsp_load_coeff()
2619 adsp_err(dsp, in wm_adsp_load_coeff()
2631 adsp_err(dsp, "Failed to complete async write: %d\n", ret); in wm_adsp_load_coeff()
2634 adsp_warn(dsp, "%s.%d: %zu bytes at end of file\n", in wm_adsp_load_coeff()
2637 wm_adsp_debugfs_save_binname(dsp, file); in wm_adsp_load_coeff()
2648 static int wm_adsp_create_name(struct wm_adsp *dsp) in wm_adsp_create_name() argument
2652 if (!dsp->name) { in wm_adsp_create_name()
2653 dsp->name = devm_kasprintf(dsp->dev, GFP_KERNEL, "DSP%d", in wm_adsp_create_name()
2654 dsp->num); in wm_adsp_create_name()
2655 if (!dsp->name) in wm_adsp_create_name()
2659 if (!dsp->fwf_name) { in wm_adsp_create_name()
2660 p = devm_kstrdup(dsp->dev, dsp->name, GFP_KERNEL); in wm_adsp_create_name()
2664 dsp->fwf_name = p; in wm_adsp_create_name()
2672 static int wm_adsp_common_init(struct wm_adsp *dsp) in wm_adsp_common_init() argument
2676 ret = wm_adsp_create_name(dsp); in wm_adsp_common_init()
2680 INIT_LIST_HEAD(&dsp->alg_regions); in wm_adsp_common_init()
2681 INIT_LIST_HEAD(&dsp->ctl_list); in wm_adsp_common_init()
2682 INIT_LIST_HEAD(&dsp->compr_list); in wm_adsp_common_init()
2683 INIT_LIST_HEAD(&dsp->buffer_list); in wm_adsp_common_init()
2685 mutex_init(&dsp->pwr_lock); in wm_adsp_common_init()
2690 int wm_adsp1_init(struct wm_adsp *dsp) in wm_adsp1_init() argument
2692 dsp->ops = &wm_adsp1_ops; in wm_adsp1_init()
2694 return wm_adsp_common_init(dsp); in wm_adsp1_init()
2704 struct wm_adsp *dsp = &dsps[w->shift]; in wm_adsp1_event() local
2709 dsp->component = component; in wm_adsp1_event()
2711 mutex_lock(&dsp->pwr_lock); in wm_adsp1_event()
2715 regmap_update_bits(dsp->regmap, dsp->base + ADSP1_CONTROL_30, in wm_adsp1_event()
2722 if (dsp->sysclk_reg) { in wm_adsp1_event()
2723 ret = regmap_read(dsp->regmap, dsp->sysclk_reg, &val); in wm_adsp1_event()
2725 adsp_err(dsp, "Failed to read SYSCLK state: %d\n", in wm_adsp1_event()
2730 val = (val & dsp->sysclk_mask) >> dsp->sysclk_shift; in wm_adsp1_event()
2732 ret = regmap_update_bits(dsp->regmap, in wm_adsp1_event()
2733 dsp->base + ADSP1_CONTROL_31, in wm_adsp1_event()
2736 adsp_err(dsp, "Failed to set clock rate: %d\n", in wm_adsp1_event()
2742 ret = wm_adsp_load(dsp); in wm_adsp1_event()
2746 ret = wm_adsp1_setup_algs(dsp); in wm_adsp1_event()
2750 ret = wm_adsp_load_coeff(dsp); in wm_adsp1_event()
2755 ret = wm_coeff_init_control_caches(dsp); in wm_adsp1_event()
2760 ret = wm_coeff_sync_controls(dsp); in wm_adsp1_event()
2764 dsp->booted = true; in wm_adsp1_event()
2767 regmap_update_bits(dsp->regmap, dsp->base + ADSP1_CONTROL_30, in wm_adsp1_event()
2771 dsp->running = true; in wm_adsp1_event()
2775 dsp->running = false; in wm_adsp1_event()
2776 dsp->booted = false; in wm_adsp1_event()
2779 regmap_update_bits(dsp->regmap, dsp->base + ADSP1_CONTROL_30, in wm_adsp1_event()
2782 regmap_update_bits(dsp->regmap, dsp->base + ADSP1_CONTROL_19, in wm_adsp1_event()
2785 regmap_update_bits(dsp->regmap, dsp->base + ADSP1_CONTROL_30, in wm_adsp1_event()
2788 list_for_each_entry(ctl, &dsp->ctl_list, list) in wm_adsp1_event()
2792 wm_adsp_free_alg_regions(dsp); in wm_adsp1_event()
2799 mutex_unlock(&dsp->pwr_lock); in wm_adsp1_event()
2804 regmap_update_bits(dsp->regmap, dsp->base + ADSP1_CONTROL_30, in wm_adsp1_event()
2807 mutex_unlock(&dsp->pwr_lock); in wm_adsp1_event()
2813 static int wm_adsp2v2_enable_core(struct wm_adsp *dsp) in wm_adsp2v2_enable_core() argument
2820 ret = regmap_read(dsp->regmap, dsp->base + ADSP2_STATUS1, &val); in wm_adsp2v2_enable_core()
2831 adsp_err(dsp, "Failed to start DSP RAM\n"); in wm_adsp2v2_enable_core()
2835 adsp_dbg(dsp, "RAM ready after %d polls\n", count); in wm_adsp2v2_enable_core()
2840 static int wm_adsp2_enable_core(struct wm_adsp *dsp) in wm_adsp2_enable_core() argument
2844 ret = regmap_update_bits_async(dsp->regmap, dsp->base + ADSP2_CONTROL, in wm_adsp2_enable_core()
2849 return wm_adsp2v2_enable_core(dsp); in wm_adsp2_enable_core()
2852 static int wm_adsp2_lock(struct wm_adsp *dsp, unsigned int lock_regions) in wm_adsp2_lock() argument
2854 struct regmap *regmap = dsp->regmap; in wm_adsp2_lock()
2861 lock_reg = dsp->base + ADSP2_LOCK_REGION_1_LOCK_REGION_0; in wm_adsp2_lock()
2882 static int wm_adsp2_enable_memory(struct wm_adsp *dsp) in wm_adsp2_enable_memory() argument
2884 return regmap_update_bits(dsp->regmap, dsp->base + ADSP2_CONTROL, in wm_adsp2_enable_memory()
2888 static void wm_adsp2_disable_memory(struct wm_adsp *dsp) in wm_adsp2_disable_memory() argument
2890 regmap_update_bits(dsp->regmap, dsp->base + ADSP2_CONTROL, in wm_adsp2_disable_memory()
2894 static void wm_adsp2_disable_core(struct wm_adsp *dsp) in wm_adsp2_disable_core() argument
2896 regmap_write(dsp->regmap, dsp->base + ADSP2_RDMA_CONFIG_1, 0); in wm_adsp2_disable_core()
2897 regmap_write(dsp->regmap, dsp->base + ADSP2_WDMA_CONFIG_1, 0); in wm_adsp2_disable_core()
2898 regmap_write(dsp->regmap, dsp->base + ADSP2_WDMA_CONFIG_2, 0); in wm_adsp2_disable_core()
2900 regmap_update_bits(dsp->regmap, dsp->base + ADSP2_CONTROL, in wm_adsp2_disable_core()
2904 static void wm_adsp2v2_disable_core(struct wm_adsp *dsp) in wm_adsp2v2_disable_core() argument
2906 regmap_write(dsp->regmap, dsp->base + ADSP2_RDMA_CONFIG_1, 0); in wm_adsp2v2_disable_core()
2907 regmap_write(dsp->regmap, dsp->base + ADSP2_WDMA_CONFIG_1, 0); in wm_adsp2v2_disable_core()
2908 regmap_write(dsp->regmap, dsp->base + ADSP2V2_WDMA_CONFIG_2, 0); in wm_adsp2v2_disable_core()
2913 struct wm_adsp *dsp = container_of(work, in wm_adsp_boot_work() local
2918 mutex_lock(&dsp->pwr_lock); in wm_adsp_boot_work()
2920 if (dsp->ops->enable_memory) { in wm_adsp_boot_work()
2921 ret = dsp->ops->enable_memory(dsp); in wm_adsp_boot_work()
2926 if (dsp->ops->enable_core) { in wm_adsp_boot_work()
2927 ret = dsp->ops->enable_core(dsp); in wm_adsp_boot_work()
2932 ret = wm_adsp_load(dsp); in wm_adsp_boot_work()
2936 ret = dsp->ops->setup_algs(dsp); in wm_adsp_boot_work()
2940 ret = wm_adsp_load_coeff(dsp); in wm_adsp_boot_work()
2945 ret = wm_coeff_init_control_caches(dsp); in wm_adsp_boot_work()
2949 if (dsp->ops->disable_core) in wm_adsp_boot_work()
2950 dsp->ops->disable_core(dsp); in wm_adsp_boot_work()
2952 dsp->booted = true; in wm_adsp_boot_work()
2954 mutex_unlock(&dsp->pwr_lock); in wm_adsp_boot_work()
2959 if (dsp->ops->disable_core) in wm_adsp_boot_work()
2960 dsp->ops->disable_core(dsp); in wm_adsp_boot_work()
2962 if (dsp->ops->disable_memory) in wm_adsp_boot_work()
2963 dsp->ops->disable_memory(dsp); in wm_adsp_boot_work()
2965 mutex_unlock(&dsp->pwr_lock); in wm_adsp_boot_work()
2968 static int wm_halo_configure_mpu(struct wm_adsp *dsp, unsigned int lock_regions) in wm_halo_configure_mpu() argument
2971 { dsp->base + HALO_MPU_LOCK_CONFIG, 0x5555 }, in wm_halo_configure_mpu()
2972 { dsp->base + HALO_MPU_LOCK_CONFIG, 0xAAAA }, in wm_halo_configure_mpu()
2973 { dsp->base + HALO_MPU_XMEM_ACCESS_0, 0xFFFFFFFF }, in wm_halo_configure_mpu()
2974 { dsp->base + HALO_MPU_YMEM_ACCESS_0, 0xFFFFFFFF }, in wm_halo_configure_mpu()
2975 { dsp->base + HALO_MPU_WINDOW_ACCESS_0, lock_regions }, in wm_halo_configure_mpu()
2976 { dsp->base + HALO_MPU_XREG_ACCESS_0, lock_regions }, in wm_halo_configure_mpu()
2977 { dsp->base + HALO_MPU_YREG_ACCESS_0, lock_regions }, in wm_halo_configure_mpu()
2978 { dsp->base + HALO_MPU_XMEM_ACCESS_1, 0xFFFFFFFF }, in wm_halo_configure_mpu()
2979 { dsp->base + HALO_MPU_YMEM_ACCESS_1, 0xFFFFFFFF }, in wm_halo_configure_mpu()
2980 { dsp->base + HALO_MPU_WINDOW_ACCESS_1, lock_regions }, in wm_halo_configure_mpu()
2981 { dsp->base + HALO_MPU_XREG_ACCESS_1, lock_regions }, in wm_halo_configure_mpu()
2982 { dsp->base + HALO_MPU_YREG_ACCESS_1, lock_regions }, in wm_halo_configure_mpu()
2983 { dsp->base + HALO_MPU_XMEM_ACCESS_2, 0xFFFFFFFF }, in wm_halo_configure_mpu()
2984 { dsp->base + HALO_MPU_YMEM_ACCESS_2, 0xFFFFFFFF }, in wm_halo_configure_mpu()
2985 { dsp->base + HALO_MPU_WINDOW_ACCESS_2, lock_regions }, in wm_halo_configure_mpu()
2986 { dsp->base + HALO_MPU_XREG_ACCESS_2, lock_regions }, in wm_halo_configure_mpu()
2987 { dsp->base + HALO_MPU_YREG_ACCESS_2, lock_regions }, in wm_halo_configure_mpu()
2988 { dsp->base + HALO_MPU_XMEM_ACCESS_3, 0xFFFFFFFF }, in wm_halo_configure_mpu()
2989 { dsp->base + HALO_MPU_YMEM_ACCESS_3, 0xFFFFFFFF }, in wm_halo_configure_mpu()
2990 { dsp->base + HALO_MPU_WINDOW_ACCESS_3, lock_regions }, in wm_halo_configure_mpu()
2991 { dsp->base + HALO_MPU_XREG_ACCESS_3, lock_regions }, in wm_halo_configure_mpu()
2992 { dsp->base + HALO_MPU_YREG_ACCESS_3, lock_regions }, in wm_halo_configure_mpu()
2993 { dsp->base + HALO_MPU_LOCK_CONFIG, 0 }, in wm_halo_configure_mpu()
2996 return regmap_multi_reg_write(dsp->regmap, config, ARRAY_SIZE(config)); in wm_halo_configure_mpu()
3003 struct wm_adsp *dsp = &dsps[w->shift]; in wm_adsp2_set_dspclk() local
3006 ret = regmap_update_bits(dsp->regmap, dsp->base + ADSP2_CLOCKING, in wm_adsp2_set_dspclk()
3010 adsp_err(dsp, "Failed to set clock rate: %d\n", ret); in wm_adsp2_set_dspclk()
3023 struct wm_adsp *dsp = &dsps[mc->shift - 1]; in wm_adsp2_preloader_get() local
3025 ucontrol->value.integer.value[0] = dsp->preloaded; in wm_adsp2_preloader_get()
3039 struct wm_adsp *dsp = &dsps[mc->shift - 1]; in wm_adsp2_preloader_put() local
3042 snprintf(preload, ARRAY_SIZE(preload), "%s Preload", dsp->name); in wm_adsp2_preloader_put()
3044 dsp->preloaded = ucontrol->value.integer.value[0]; in wm_adsp2_preloader_put()
3053 flush_work(&dsp->boot_work); in wm_adsp2_preloader_put()
3059 static void wm_adsp_stop_watchdog(struct wm_adsp *dsp) in wm_adsp_stop_watchdog() argument
3061 regmap_update_bits(dsp->regmap, dsp->base + ADSP2_WATCHDOG, in wm_adsp_stop_watchdog()
3065 static void wm_halo_stop_watchdog(struct wm_adsp *dsp) in wm_halo_stop_watchdog() argument
3067 regmap_update_bits(dsp->regmap, dsp->base + HALO_WDT_CONTROL, in wm_halo_stop_watchdog()
3076 struct wm_adsp *dsp = &dsps[w->shift]; in wm_adsp_early_event() local
3081 queue_work(system_unbound_wq, &dsp->boot_work); in wm_adsp_early_event()
3084 mutex_lock(&dsp->pwr_lock); in wm_adsp_early_event()
3086 wm_adsp_debugfs_clear(dsp); in wm_adsp_early_event()
3088 dsp->fw_id = 0; in wm_adsp_early_event()
3089 dsp->fw_id_version = 0; in wm_adsp_early_event()
3091 dsp->booted = false; in wm_adsp_early_event()
3093 if (dsp->ops->disable_memory) in wm_adsp_early_event()
3094 dsp->ops->disable_memory(dsp); in wm_adsp_early_event()
3096 list_for_each_entry(ctl, &dsp->ctl_list, list) in wm_adsp_early_event()
3099 wm_adsp_free_alg_regions(dsp); in wm_adsp_early_event()
3101 mutex_unlock(&dsp->pwr_lock); in wm_adsp_early_event()
3103 adsp_dbg(dsp, "Shutdown complete\n"); in wm_adsp_early_event()
3113 static int wm_adsp2_start_core(struct wm_adsp *dsp) in wm_adsp2_start_core() argument
3115 return regmap_update_bits(dsp->regmap, dsp->base + ADSP2_CONTROL, in wm_adsp2_start_core()
3120 static void wm_adsp2_stop_core(struct wm_adsp *dsp) in wm_adsp2_stop_core() argument
3122 regmap_update_bits(dsp->regmap, dsp->base + ADSP2_CONTROL, in wm_adsp2_stop_core()
3131 struct wm_adsp *dsp = &dsps[w->shift]; in wm_adsp_event() local
3136 flush_work(&dsp->boot_work); in wm_adsp_event()
3138 mutex_lock(&dsp->pwr_lock); in wm_adsp_event()
3140 if (!dsp->booted) { in wm_adsp_event()
3145 if (dsp->ops->enable_core) { in wm_adsp_event()
3146 ret = dsp->ops->enable_core(dsp); in wm_adsp_event()
3152 ret = wm_coeff_sync_controls(dsp); in wm_adsp_event()
3156 if (dsp->ops->lock_memory) { in wm_adsp_event()
3157 ret = dsp->ops->lock_memory(dsp, dsp->lock_regions); in wm_adsp_event()
3159 adsp_err(dsp, "Error configuring MPU: %d\n", in wm_adsp_event()
3165 if (dsp->ops->start_core) { in wm_adsp_event()
3166 ret = dsp->ops->start_core(dsp); in wm_adsp_event()
3171 if (wm_adsp_fw[dsp->fw].num_caps != 0) { in wm_adsp_event()
3172 ret = wm_adsp_buffer_init(dsp); in wm_adsp_event()
3177 dsp->running = true; in wm_adsp_event()
3179 mutex_unlock(&dsp->pwr_lock); in wm_adsp_event()
3184 wm_adsp_signal_event_controls(dsp, WM_ADSP_FW_EVENT_SHUTDOWN); in wm_adsp_event()
3186 if (dsp->ops->stop_watchdog) in wm_adsp_event()
3187 dsp->ops->stop_watchdog(dsp); in wm_adsp_event()
3190 if (dsp->ops->show_fw_status) in wm_adsp_event()
3191 dsp->ops->show_fw_status(dsp); in wm_adsp_event()
3193 mutex_lock(&dsp->pwr_lock); in wm_adsp_event()
3195 dsp->running = false; in wm_adsp_event()
3197 if (dsp->ops->stop_core) in wm_adsp_event()
3198 dsp->ops->stop_core(dsp); in wm_adsp_event()
3199 if (dsp->ops->disable_core) in wm_adsp_event()
3200 dsp->ops->disable_core(dsp); in wm_adsp_event()
3202 if (wm_adsp_fw[dsp->fw].num_caps != 0) in wm_adsp_event()
3203 wm_adsp_buffer_free(dsp); in wm_adsp_event()
3205 dsp->fatal_error = false; in wm_adsp_event()
3207 mutex_unlock(&dsp->pwr_lock); in wm_adsp_event()
3209 adsp_dbg(dsp, "Execution stopped\n"); in wm_adsp_event()
3218 if (dsp->ops->stop_core) in wm_adsp_event()
3219 dsp->ops->stop_core(dsp); in wm_adsp_event()
3220 if (dsp->ops->disable_core) in wm_adsp_event()
3221 dsp->ops->disable_core(dsp); in wm_adsp_event()
3222 mutex_unlock(&dsp->pwr_lock); in wm_adsp_event()
3227 static int wm_halo_start_core(struct wm_adsp *dsp) in wm_halo_start_core() argument
3229 return regmap_update_bits(dsp->regmap, in wm_halo_start_core()
3230 dsp->base + HALO_CCM_CORE_CONTROL, in wm_halo_start_core()
3234 static void wm_halo_stop_core(struct wm_adsp *dsp) in wm_halo_stop_core() argument
3236 regmap_update_bits(dsp->regmap, dsp->base + HALO_CCM_CORE_CONTROL, in wm_halo_stop_core()
3240 regmap_update_bits(dsp->regmap, dsp->base + HALO_CORE_SOFT_RESET, in wm_halo_stop_core()
3244 int wm_adsp2_component_probe(struct wm_adsp *dsp, struct snd_soc_component *component) in wm_adsp2_component_probe() argument
3248 snprintf(preload, ARRAY_SIZE(preload), "%s Preload", dsp->name); in wm_adsp2_component_probe()
3251 wm_adsp2_init_debugfs(dsp, component); in wm_adsp2_component_probe()
3253 dsp->component = component; in wm_adsp2_component_probe()
3259 int wm_adsp2_component_remove(struct wm_adsp *dsp, struct snd_soc_component *component) in wm_adsp2_component_remove() argument
3261 wm_adsp2_cleanup_debugfs(dsp); in wm_adsp2_component_remove()
3267 int wm_adsp2_init(struct wm_adsp *dsp) in wm_adsp2_init() argument
3271 ret = wm_adsp_common_init(dsp); in wm_adsp2_init()
3275 switch (dsp->rev) { in wm_adsp2_init()
3281 ret = regmap_update_bits(dsp->regmap, dsp->base + ADSP2_CONTROL, in wm_adsp2_init()
3284 adsp_err(dsp, in wm_adsp2_init()
3289 dsp->ops = &wm_adsp2_ops[0]; in wm_adsp2_init()
3292 dsp->ops = &wm_adsp2_ops[1]; in wm_adsp2_init()
3295 dsp->ops = &wm_adsp2_ops[2]; in wm_adsp2_init()
3299 INIT_WORK(&dsp->boot_work, wm_adsp_boot_work); in wm_adsp2_init()
3305 int wm_halo_init(struct wm_adsp *dsp) in wm_halo_init() argument
3309 ret = wm_adsp_common_init(dsp); in wm_halo_init()
3313 dsp->ops = &wm_halo_ops; in wm_halo_init()
3315 INIT_WORK(&dsp->boot_work, wm_adsp_boot_work); in wm_halo_init()
3321 void wm_adsp2_remove(struct wm_adsp *dsp) in wm_adsp2_remove() argument
3325 while (!list_empty(&dsp->ctl_list)) { in wm_adsp2_remove()
3326 ctl = list_first_entry(&dsp->ctl_list, struct wm_coeff_ctl, in wm_adsp2_remove()
3343 if (compr->dsp->fatal_error) in wm_adsp_compr_attach()
3346 list_for_each_entry(tmp, &compr->dsp->buffer_list, list) { in wm_adsp_compr_attach()
3377 int wm_adsp_compr_open(struct wm_adsp *dsp, struct snd_compr_stream *stream) in wm_adsp_compr_open() argument
3383 mutex_lock(&dsp->pwr_lock); in wm_adsp_compr_open()
3385 if (wm_adsp_fw[dsp->fw].num_caps == 0) { in wm_adsp_compr_open()
3386 adsp_err(dsp, "%s: Firmware does not support compressed API\n", in wm_adsp_compr_open()
3392 if (wm_adsp_fw[dsp->fw].compr_direction != stream->direction) { in wm_adsp_compr_open()
3393 adsp_err(dsp, "%s: Firmware does not support stream direction\n", in wm_adsp_compr_open()
3399 list_for_each_entry(tmp, &dsp->compr_list, list) { in wm_adsp_compr_open()
3401 adsp_err(dsp, "%s: Only a single stream supported per dai\n", in wm_adsp_compr_open()
3414 compr->dsp = dsp; in wm_adsp_compr_open()
3418 list_add_tail(&compr->list, &dsp->compr_list); in wm_adsp_compr_open()
3423 mutex_unlock(&dsp->pwr_lock); in wm_adsp_compr_open()
3432 struct wm_adsp *dsp = compr->dsp; in wm_adsp_compr_free() local
3434 mutex_lock(&dsp->pwr_lock); in wm_adsp_compr_free()
3442 mutex_unlock(&dsp->pwr_lock); in wm_adsp_compr_free()
3452 struct wm_adsp *dsp = compr->dsp; in wm_adsp_compr_check_params() local
3469 for (i = 0; i < wm_adsp_fw[dsp->fw].num_caps; i++) { in wm_adsp_compr_check_params()
3470 caps = &wm_adsp_fw[dsp->fw].caps[i]; in wm_adsp_compr_check_params()
3534 int fw = compr->dsp->fw; in wm_adsp_compr_get_caps()
3554 static int wm_adsp_read_data_block(struct wm_adsp *dsp, int mem_type, in wm_adsp_read_data_block() argument
3558 struct wm_adsp_region const *mem = wm_adsp_find_region(dsp, mem_type); in wm_adsp_read_data_block()
3565 reg = dsp->ops->region_to_reg(mem, mem_addr); in wm_adsp_read_data_block()
3567 ret = regmap_raw_read(dsp->regmap, reg, data, in wm_adsp_read_data_block()
3578 static inline int wm_adsp_read_data_word(struct wm_adsp *dsp, int mem_type, in wm_adsp_read_data_word() argument
3581 return wm_adsp_read_data_block(dsp, mem_type, mem_addr, 1, data); in wm_adsp_read_data_word()
3584 static int wm_adsp_write_data_word(struct wm_adsp *dsp, int mem_type, in wm_adsp_write_data_word() argument
3587 struct wm_adsp_region const *mem = wm_adsp_find_region(dsp, mem_type); in wm_adsp_write_data_word()
3593 reg = dsp->ops->region_to_reg(mem, mem_addr); in wm_adsp_write_data_word()
3597 return regmap_raw_write(dsp->regmap, reg, &data, sizeof(data)); in wm_adsp_write_data_word()
3603 return wm_adsp_read_data_word(buf->dsp, buf->host_buf_mem_type, in wm_adsp_buffer_read()
3610 return wm_adsp_write_data_word(buf->dsp, buf->host_buf_mem_type, in wm_adsp_buffer_write()
3631 const struct wm_adsp_fw_caps *caps = wm_adsp_fw[buf->dsp->fw].caps; in wm_adsp_buffer_populate()
3675 static struct wm_adsp_compr_buf *wm_adsp_buffer_alloc(struct wm_adsp *dsp) in wm_adsp_buffer_alloc() argument
3683 buf->dsp = dsp; in wm_adsp_buffer_alloc()
3687 list_add_tail(&buf->list, &dsp->buffer_list); in wm_adsp_buffer_alloc()
3692 static int wm_adsp_buffer_parse_legacy(struct wm_adsp *dsp) in wm_adsp_buffer_parse_legacy() argument
3699 alg_region = wm_adsp_find_alg_region(dsp, WMFW_ADSP2_XM, dsp->fw_id); in wm_adsp_buffer_parse_legacy()
3701 adsp_err(dsp, "No algorithm region found\n"); in wm_adsp_buffer_parse_legacy()
3705 buf = wm_adsp_buffer_alloc(dsp); in wm_adsp_buffer_parse_legacy()
3709 xmalg = dsp->ops->sys_config_size / sizeof(__be32); in wm_adsp_buffer_parse_legacy()
3712 ret = wm_adsp_read_data_word(dsp, WMFW_ADSP2_XM, addr, &magic); in wm_adsp_buffer_parse_legacy()
3721 ret = wm_adsp_read_data_word(dsp, WMFW_ADSP2_XM, addr, in wm_adsp_buffer_parse_legacy()
3758 ret = regmap_raw_read(ctl->dsp->regmap, reg, &val, sizeof(val)); in wm_adsp_buffer_parse_coeff()
3769 adsp_err(ctl->dsp, "Failed to acquire host buffer\n"); in wm_adsp_buffer_parse_coeff()
3773 buf = wm_adsp_buffer_alloc(ctl->dsp); in wm_adsp_buffer_parse_coeff()
3793 ret = regmap_raw_read(ctl->dsp->regmap, reg, &coeff_v1, in wm_adsp_buffer_parse_coeff()
3803 adsp_err(ctl->dsp, in wm_adsp_buffer_parse_coeff()
3816 buf->name = kasprintf(GFP_KERNEL, "%s-dsp-%s", ctl->dsp->part, in wm_adsp_buffer_parse_coeff()
3825 static int wm_adsp_buffer_init(struct wm_adsp *dsp) in wm_adsp_buffer_init() argument
3830 list_for_each_entry(ctl, &dsp->ctl_list, list) { in wm_adsp_buffer_init()
3839 adsp_err(dsp, "Failed to parse coeff: %d\n", ret); in wm_adsp_buffer_init()
3847 if (list_empty(&dsp->buffer_list)) { in wm_adsp_buffer_init()
3849 ret = wm_adsp_buffer_parse_legacy(dsp); in wm_adsp_buffer_init()
3851 adsp_err(dsp, "Failed to parse legacy: %d\n", ret); in wm_adsp_buffer_init()
3859 wm_adsp_buffer_free(dsp); in wm_adsp_buffer_init()
3863 static int wm_adsp_buffer_free(struct wm_adsp *dsp) in wm_adsp_buffer_free() argument
3867 list_for_each_entry_safe(buf, tmp, &dsp->buffer_list, list) { in wm_adsp_buffer_free()
3899 struct wm_adsp *dsp = compr->dsp; in wm_adsp_compr_trigger() local
3904 mutex_lock(&dsp->pwr_lock); in wm_adsp_compr_trigger()
3940 mutex_unlock(&dsp->pwr_lock); in wm_adsp_compr_trigger()
3948 int last_region = wm_adsp_fw[buf->dsp->fw].caps->num_regions - 1; in wm_adsp_buffer_size()
3996 int wm_adsp_compr_handle_irq(struct wm_adsp *dsp) in wm_adsp_compr_handle_irq() argument
4002 mutex_lock(&dsp->pwr_lock); in wm_adsp_compr_handle_irq()
4004 if (list_empty(&dsp->buffer_list)) { in wm_adsp_compr_handle_irq()
4009 adsp_dbg(dsp, "Handling buffer IRQ\n"); in wm_adsp_compr_handle_irq()
4011 list_for_each_entry(buf, &dsp->buffer_list, list) { in wm_adsp_compr_handle_irq()
4031 if (wm_adsp_fw[dsp->fw].voice_trigger && buf->irq_count == 2) in wm_adsp_compr_handle_irq()
4040 mutex_unlock(&dsp->pwr_lock); in wm_adsp_compr_handle_irq()
4063 struct wm_adsp *dsp = compr->dsp; in wm_adsp_compr_pointer() local
4069 mutex_lock(&dsp->pwr_lock); in wm_adsp_compr_pointer()
4073 if (dsp->fatal_error || !buf || buf->error) { in wm_adsp_compr_pointer()
4113 mutex_unlock(&dsp->pwr_lock); in wm_adsp_compr_pointer()
4127 for (i = 0; i < wm_adsp_fw[buf->dsp->fw].caps->num_regions; ++i) in wm_adsp_buffer_capture_block()
4131 if (i == wm_adsp_fw[buf->dsp->fw].caps->num_regions) in wm_adsp_buffer_capture_block()
4151 ret = wm_adsp_read_data_block(buf->dsp, mem_type, adsp_addr, in wm_adsp_buffer_capture_block()
4177 struct wm_adsp *dsp = compr->dsp; in wm_adsp_compr_read() local
4183 if (dsp->fatal_error || !compr->buf || compr->buf->error) { in wm_adsp_compr_read()
4221 struct wm_adsp *dsp = compr->dsp; in wm_adsp_compr_copy() local
4224 mutex_lock(&dsp->pwr_lock); in wm_adsp_compr_copy()
4231 mutex_unlock(&dsp->pwr_lock); in wm_adsp_compr_copy()
4237 static void wm_adsp_fatal_error(struct wm_adsp *dsp) in wm_adsp_fatal_error() argument
4241 dsp->fatal_error = true; in wm_adsp_fatal_error()
4243 list_for_each_entry(compr, &dsp->compr_list, list) { in wm_adsp_fatal_error()
4251 struct wm_adsp *dsp = (struct wm_adsp *)data; in wm_adsp2_bus_error() local
4253 struct regmap *regmap = dsp->regmap; in wm_adsp2_bus_error()
4256 mutex_lock(&dsp->pwr_lock); in wm_adsp2_bus_error()
4258 ret = regmap_read(regmap, dsp->base + ADSP2_LOCK_REGION_CTRL, &val); in wm_adsp2_bus_error()
4260 adsp_err(dsp, in wm_adsp2_bus_error()
4266 adsp_err(dsp, "watchdog timeout error\n"); in wm_adsp2_bus_error()
4267 dsp->ops->stop_watchdog(dsp); in wm_adsp2_bus_error()
4268 wm_adsp_fatal_error(dsp); in wm_adsp2_bus_error()
4273 adsp_err(dsp, "bus error: slave error\n"); in wm_adsp2_bus_error()
4275 adsp_err(dsp, "bus error: region lock error\n"); in wm_adsp2_bus_error()
4277 ret = regmap_read(regmap, dsp->base + ADSP2_BUS_ERR_ADDR, &val); in wm_adsp2_bus_error()
4279 adsp_err(dsp, in wm_adsp2_bus_error()
4285 adsp_err(dsp, "bus error address = 0x%x\n", in wm_adsp2_bus_error()
4289 dsp->base + ADSP2_PMEM_ERR_ADDR_XMEM_ERR_ADDR, in wm_adsp2_bus_error()
4292 adsp_err(dsp, in wm_adsp2_bus_error()
4298 adsp_err(dsp, "xmem error address = 0x%x\n", in wm_adsp2_bus_error()
4300 adsp_err(dsp, "pmem error address = 0x%x\n", in wm_adsp2_bus_error()
4305 regmap_update_bits(regmap, dsp->base + ADSP2_LOCK_REGION_CTRL, in wm_adsp2_bus_error()
4309 mutex_unlock(&dsp->pwr_lock); in wm_adsp2_bus_error()
4317 struct wm_adsp *dsp = (struct wm_adsp *)data; in wm_halo_bus_error() local
4318 struct regmap *regmap = dsp->regmap; in wm_halo_bus_error()
4321 { dsp->base + HALO_MPU_XM_VIO_STATUS, 0x0 }, in wm_halo_bus_error()
4322 { dsp->base + HALO_MPU_YM_VIO_STATUS, 0x0 }, in wm_halo_bus_error()
4323 { dsp->base + HALO_MPU_PM_VIO_STATUS, 0x0 }, in wm_halo_bus_error()
4327 mutex_lock(&dsp->pwr_lock); in wm_halo_bus_error()
4329 ret = regmap_read(regmap, dsp->base_sysinfo + HALO_AHBM_WINDOW_DEBUG_1, in wm_halo_bus_error()
4332 adsp_warn(dsp, "Failed to read AHB DEBUG_1: %d\n", ret); in wm_halo_bus_error()
4336 adsp_warn(dsp, "AHB: STATUS: 0x%x ADDR: 0x%x\n", in wm_halo_bus_error()
4341 ret = regmap_read(regmap, dsp->base_sysinfo + HALO_AHBM_WINDOW_DEBUG_0, in wm_halo_bus_error()
4344 adsp_warn(dsp, "Failed to read AHB DEBUG_0: %d\n", ret); in wm_halo_bus_error()
4348 adsp_warn(dsp, "AHB: SYS_ADDR: 0x%x\n", *fault); in wm_halo_bus_error()
4350 ret = regmap_bulk_read(regmap, dsp->base + HALO_MPU_XM_VIO_ADDR, in wm_halo_bus_error()
4353 adsp_warn(dsp, "Failed to read MPU fault info: %d\n", ret); in wm_halo_bus_error()
4357 adsp_warn(dsp, "XM: STATUS:0x%x ADDR:0x%x\n", fault[1], fault[0]); in wm_halo_bus_error()
4358 adsp_warn(dsp, "YM: STATUS:0x%x ADDR:0x%x\n", fault[3], fault[2]); in wm_halo_bus_error()
4359 adsp_warn(dsp, "PM: STATUS:0x%x ADDR:0x%x\n", fault[5], fault[4]); in wm_halo_bus_error()
4361 ret = regmap_multi_reg_write(dsp->regmap, clear, ARRAY_SIZE(clear)); in wm_halo_bus_error()
4363 adsp_warn(dsp, "Failed to clear MPU status: %d\n", ret); in wm_halo_bus_error()
4366 mutex_unlock(&dsp->pwr_lock); in wm_halo_bus_error()
4374 struct wm_adsp *dsp = data; in wm_halo_wdt_expire() local
4376 mutex_lock(&dsp->pwr_lock); in wm_halo_wdt_expire()
4378 adsp_warn(dsp, "WDT Expiry Fault\n"); in wm_halo_wdt_expire()
4379 dsp->ops->stop_watchdog(dsp); in wm_halo_wdt_expire()
4380 wm_adsp_fatal_error(dsp); in wm_halo_wdt_expire()
4382 mutex_unlock(&dsp->pwr_lock); in wm_halo_wdt_expire()