• Home
  • Raw
  • Download

Lines Matching full:dsp

337 	struct wm_adsp *dsp;  member
350 struct wm_adsp *dsp; member
377 static int wm_adsp_buffer_init(struct wm_adsp *dsp);
378 static int wm_adsp_buffer_free(struct wm_adsp *dsp);
493 struct wm_adsp *dsp; member
524 static void wm_adsp_debugfs_save_wmfwname(struct wm_adsp *dsp, const char *s) in wm_adsp_debugfs_save_wmfwname() argument
528 kfree(dsp->wmfw_file_name); in wm_adsp_debugfs_save_wmfwname()
529 dsp->wmfw_file_name = tmp; in wm_adsp_debugfs_save_wmfwname()
532 static void wm_adsp_debugfs_save_binname(struct wm_adsp *dsp, const char *s) in wm_adsp_debugfs_save_binname() argument
536 kfree(dsp->bin_file_name); in wm_adsp_debugfs_save_binname()
537 dsp->bin_file_name = tmp; in wm_adsp_debugfs_save_binname()
540 static void wm_adsp_debugfs_clear(struct wm_adsp *dsp) in wm_adsp_debugfs_clear() argument
542 kfree(dsp->wmfw_file_name); in wm_adsp_debugfs_clear()
543 kfree(dsp->bin_file_name); in wm_adsp_debugfs_clear()
544 dsp->wmfw_file_name = NULL; in wm_adsp_debugfs_clear()
545 dsp->bin_file_name = NULL; in wm_adsp_debugfs_clear()
552 struct wm_adsp *dsp = file->private_data; in wm_adsp_debugfs_wmfw_read() local
555 mutex_lock(&dsp->pwr_lock); in wm_adsp_debugfs_wmfw_read()
557 if (!dsp->wmfw_file_name || !dsp->booted) in wm_adsp_debugfs_wmfw_read()
561 dsp->wmfw_file_name, in wm_adsp_debugfs_wmfw_read()
562 strlen(dsp->wmfw_file_name)); in wm_adsp_debugfs_wmfw_read()
564 mutex_unlock(&dsp->pwr_lock); in wm_adsp_debugfs_wmfw_read()
572 struct wm_adsp *dsp = file->private_data; in wm_adsp_debugfs_bin_read() local
575 mutex_lock(&dsp->pwr_lock); in wm_adsp_debugfs_bin_read()
577 if (!dsp->bin_file_name || !dsp->booted) in wm_adsp_debugfs_bin_read()
581 dsp->bin_file_name, in wm_adsp_debugfs_bin_read()
582 strlen(dsp->bin_file_name)); in wm_adsp_debugfs_bin_read()
584 mutex_unlock(&dsp->pwr_lock); in wm_adsp_debugfs_bin_read()
608 static void wm_adsp2_init_debugfs(struct wm_adsp *dsp, in wm_adsp2_init_debugfs() argument
615 adsp_err(dsp, "No codec debugfs root\n"); in wm_adsp2_init_debugfs()
619 root = debugfs_create_dir(dsp->name, component->debugfs_root); in wm_adsp2_init_debugfs()
624 if (!debugfs_create_bool("booted", 0444, root, &dsp->booted)) in wm_adsp2_init_debugfs()
627 if (!debugfs_create_bool("running", 0444, root, &dsp->running)) in wm_adsp2_init_debugfs()
630 if (!debugfs_create_x32("fw_id", 0444, root, &dsp->fw_id)) in wm_adsp2_init_debugfs()
633 if (!debugfs_create_x32("fw_version", 0444, root, &dsp->fw_id_version)) in wm_adsp2_init_debugfs()
638 0444, root, dsp, in wm_adsp2_init_debugfs()
643 dsp->debugfs_root = root; in wm_adsp2_init_debugfs()
648 adsp_err(dsp, "Failed to create debugfs\n"); in wm_adsp2_init_debugfs()
651 static void wm_adsp2_cleanup_debugfs(struct wm_adsp *dsp) in wm_adsp2_cleanup_debugfs() argument
653 wm_adsp_debugfs_clear(dsp); in wm_adsp2_cleanup_debugfs()
654 debugfs_remove_recursive(dsp->debugfs_root); in wm_adsp2_cleanup_debugfs()
657 static inline void wm_adsp2_init_debugfs(struct wm_adsp *dsp, in wm_adsp2_init_debugfs() argument
662 static inline void wm_adsp2_cleanup_debugfs(struct wm_adsp *dsp) in wm_adsp2_cleanup_debugfs() argument
666 static inline void wm_adsp_debugfs_save_wmfwname(struct wm_adsp *dsp, in wm_adsp_debugfs_save_wmfwname() argument
671 static inline void wm_adsp_debugfs_save_binname(struct wm_adsp *dsp, in wm_adsp_debugfs_save_binname() argument
676 static inline void wm_adsp_debugfs_clear(struct wm_adsp *dsp) in wm_adsp_debugfs_clear() argument
686 struct wm_adsp *dsp = snd_soc_component_get_drvdata(component); in wm_adsp_fw_get() local
688 ucontrol->value.enumerated.item[0] = dsp[e->shift_l].fw; in wm_adsp_fw_get()
699 struct wm_adsp *dsp = snd_soc_component_get_drvdata(component); in wm_adsp_fw_put() local
702 if (ucontrol->value.enumerated.item[0] == dsp[e->shift_l].fw) in wm_adsp_fw_put()
708 mutex_lock(&dsp[e->shift_l].pwr_lock); in wm_adsp_fw_put()
710 if (dsp[e->shift_l].booted || dsp[e->shift_l].compr) in wm_adsp_fw_put()
713 dsp[e->shift_l].fw = ucontrol->value.enumerated.item[0]; in wm_adsp_fw_put()
715 mutex_unlock(&dsp[e->shift_l].pwr_lock); in wm_adsp_fw_put()
732 static struct wm_adsp_region const *wm_adsp_find_region(struct wm_adsp *dsp, in wm_adsp_find_region() argument
737 for (i = 0; i < dsp->num_mems; i++) in wm_adsp_find_region()
738 if (dsp->mem[i].type == type) in wm_adsp_find_region()
739 return &dsp->mem[i]; in wm_adsp_find_region()
766 static void wm_adsp2_show_fw_status(struct wm_adsp *dsp) in wm_adsp2_show_fw_status() argument
769 unsigned int addr = dsp->base + ADSP2_SCRATCH0; in wm_adsp2_show_fw_status()
774 ret = regmap_read(dsp->regmap, addr + i, &scratch[i]); in wm_adsp2_show_fw_status()
776 adsp_err(dsp, "Failed to read SCRATCH%u: %d\n", i, ret); in wm_adsp2_show_fw_status()
781 adsp_dbg(dsp, "FW SCRATCH 0:0x%x 1:0x%x 2:0x%x 3:0x%x\n", in wm_adsp2_show_fw_status()
785 static void wm_adsp2v2_show_fw_status(struct wm_adsp *dsp) in wm_adsp2v2_show_fw_status() argument
790 ret = regmap_read(dsp->regmap, dsp->base + ADSP2V2_SCRATCH0_1, in wm_adsp2v2_show_fw_status()
793 adsp_err(dsp, "Failed to read SCRATCH0_1: %d\n", ret); in wm_adsp2v2_show_fw_status()
797 ret = regmap_read(dsp->regmap, dsp->base + ADSP2V2_SCRATCH2_3, in wm_adsp2v2_show_fw_status()
800 adsp_err(dsp, "Failed to read SCRATCH2_3: %d\n", ret); in wm_adsp2v2_show_fw_status()
804 adsp_dbg(dsp, "FW SCRATCH 0:0x%x 1:0x%x 2:0x%x 3:0x%x\n", in wm_adsp2v2_show_fw_status()
819 struct wm_adsp *dsp = ctl->dsp; in wm_coeff_base_reg() local
822 mem = wm_adsp_find_region(dsp, alg_region->type); in wm_coeff_base_reg()
824 adsp_err(dsp, "No base for region %x\n", in wm_coeff_base_reg()
861 struct wm_adsp *dsp = ctl->dsp; in wm_coeff_write_acked_control() local
870 adsp_dbg(dsp, "Sending 0x%x to acked control alg 0x%x %s:0x%x\n", in wm_coeff_write_acked_control()
874 ret = regmap_raw_write(dsp->regmap, reg, &val, sizeof(val)); in wm_coeff_write_acked_control()
876 adsp_err(dsp, "Failed to write %x: %d\n", reg, ret); in wm_coeff_write_acked_control()
898 ret = regmap_raw_read(dsp->regmap, reg, &val, sizeof(val)); in wm_coeff_write_acked_control()
900 adsp_err(dsp, "Failed to read %x: %d\n", reg, ret); in wm_coeff_write_acked_control()
905 adsp_dbg(dsp, "Acked control ACKED at poll %u\n", i); in wm_coeff_write_acked_control()
910 adsp_warn(dsp, "Acked control @0x%x alg:0x%x %s:0x%x timed out\n", in wm_coeff_write_acked_control()
921 struct wm_adsp *dsp = ctl->dsp; in wm_coeff_write_control() local
934 ret = regmap_raw_write(dsp->regmap, reg, scratch, in wm_coeff_write_control()
937 adsp_err(dsp, "Failed to write %zu bytes to %x: %d\n", in wm_coeff_write_control()
942 adsp_dbg(dsp, "Wrote %zu bytes to %x\n", len, reg); in wm_coeff_write_control()
958 mutex_lock(&ctl->dsp->pwr_lock); in wm_coeff_put()
966 if (ctl->enabled && ctl->dsp->running) in wm_coeff_put()
969 mutex_unlock(&ctl->dsp->pwr_lock); in wm_coeff_put()
982 mutex_lock(&ctl->dsp->pwr_lock); in wm_coeff_tlv_put()
988 if (ctl->enabled && ctl->dsp->running) in wm_coeff_tlv_put()
994 mutex_unlock(&ctl->dsp->pwr_lock); in wm_coeff_tlv_put()
1011 mutex_lock(&ctl->dsp->pwr_lock); in wm_coeff_put_acked()
1013 if (ctl->enabled && ctl->dsp->running) in wm_coeff_put_acked()
1018 mutex_unlock(&ctl->dsp->pwr_lock); in wm_coeff_put_acked()
1026 struct wm_adsp *dsp = ctl->dsp; in wm_coeff_read_control() local
1039 ret = regmap_raw_read(dsp->regmap, reg, scratch, len); in wm_coeff_read_control()
1041 adsp_err(dsp, "Failed to read %zu bytes from %x: %d\n", in wm_coeff_read_control()
1046 adsp_dbg(dsp, "Read %zu bytes from %x\n", len, reg); in wm_coeff_read_control()
1063 mutex_lock(&ctl->dsp->pwr_lock); in wm_coeff_get()
1066 if (ctl->enabled && ctl->dsp->running) in wm_coeff_get()
1071 if (!ctl->flags && ctl->enabled && ctl->dsp->running) in wm_coeff_get()
1077 mutex_unlock(&ctl->dsp->pwr_lock); in wm_coeff_get()
1090 mutex_lock(&ctl->dsp->pwr_lock); in wm_coeff_tlv_get()
1093 if (ctl->enabled && ctl->dsp->running) in wm_coeff_tlv_get()
1098 if (!ctl->flags && ctl->enabled && ctl->dsp->running) in wm_coeff_tlv_get()
1105 mutex_unlock(&ctl->dsp->pwr_lock); in wm_coeff_tlv_get()
1126 struct wm_adsp *dsp; member
1162 static int wmfw_add_ctl(struct wm_adsp *dsp, struct wm_coeff_ctl *ctl) in wmfw_add_ctl() argument
1198 ret = snd_soc_add_component_controls(dsp->component, kcontrol, 1); in wmfw_add_ctl()
1211 static int wm_coeff_init_control_caches(struct wm_adsp *dsp) in wm_coeff_init_control_caches() argument
1216 list_for_each_entry(ctl, &dsp->ctl_list, list) { in wm_coeff_init_control_caches()
1223 * For readable controls populate the cache from the DSP memory. in wm_coeff_init_control_caches()
1237 static int wm_coeff_sync_controls(struct wm_adsp *dsp) in wm_coeff_sync_controls() argument
1242 list_for_each_entry(ctl, &dsp->ctl_list, list) { in wm_coeff_sync_controls()
1255 static void wm_adsp_signal_event_controls(struct wm_adsp *dsp, in wm_adsp_signal_event_controls() argument
1261 list_for_each_entry(ctl, &dsp->ctl_list, list) { in wm_adsp_signal_event_controls()
1270 adsp_warn(dsp, in wm_adsp_signal_event_controls()
1282 wmfw_add_ctl(ctl_work->dsp, ctl_work->ctl); in wm_adsp_ctl_work()
1293 static int wm_adsp_create_control(struct wm_adsp *dsp, in wm_adsp_create_control() argument
1307 adsp_err(dsp, "Unknown region type: %d\n", alg_region->type); in wm_adsp_create_control()
1311 switch (dsp->fw_ver) { in wm_adsp_create_control()
1315 dsp->name, region_name, alg_region->alg); in wm_adsp_create_control()
1319 "%s%c %.12s %x", dsp->name, *region_name, in wm_adsp_create_control()
1320 wm_adsp_fw_text[dsp->fw], alg_region->alg); in wm_adsp_create_control()
1327 if (dsp->component->name_prefix) in wm_adsp_create_control()
1328 avail -= strlen(dsp->component->name_prefix) + 1; in wm_adsp_create_control()
1340 list_for_each_entry(ctl, &dsp->ctl_list, list) { in wm_adsp_create_control()
1351 ctl->fw_name = wm_adsp_fw_text[dsp->fw]; in wm_adsp_create_control()
1362 ctl->dsp = dsp; in wm_adsp_create_control()
1374 list_add(&ctl->list, &dsp->ctl_list); in wm_adsp_create_control()
1385 ctl_work->dsp = dsp; in wm_adsp_create_control()
1462 static inline void wm_coeff_parse_alg(struct wm_adsp *dsp, const u8 **data, in wm_coeff_parse_alg() argument
1467 switch (dsp->fw_ver) { in wm_coeff_parse_alg()
1487 adsp_dbg(dsp, "Algorithm ID: %#x\n", blk->id); in wm_coeff_parse_alg()
1488 adsp_dbg(dsp, "Algorithm name: %.*s\n", blk->name_len, blk->name); in wm_coeff_parse_alg()
1489 adsp_dbg(dsp, "# of coefficient descriptors: %#x\n", blk->ncoeff); in wm_coeff_parse_alg()
1492 static inline void wm_coeff_parse_coeff(struct wm_adsp *dsp, const u8 **data, in wm_coeff_parse_coeff() argument
1499 switch (dsp->fw_ver) { in wm_coeff_parse_coeff()
1530 adsp_dbg(dsp, "\tCoefficient type: %#x\n", blk->mem_type); in wm_coeff_parse_coeff()
1531 adsp_dbg(dsp, "\tCoefficient offset: %#x\n", blk->offset); in wm_coeff_parse_coeff()
1532 adsp_dbg(dsp, "\tCoefficient name: %.*s\n", blk->name_len, blk->name); in wm_coeff_parse_coeff()
1533 adsp_dbg(dsp, "\tCoefficient flags: %#x\n", blk->flags); in wm_coeff_parse_coeff()
1534 adsp_dbg(dsp, "\tALSA control type: %#x\n", blk->ctl_type); in wm_coeff_parse_coeff()
1535 adsp_dbg(dsp, "\tALSA control len: %#x\n", blk->len); in wm_coeff_parse_coeff()
1538 static int wm_adsp_check_coeff_flags(struct wm_adsp *dsp, in wm_adsp_check_coeff_flags() argument
1545 adsp_err(dsp, "Illegal flags 0x%x for control type 0x%x\n", in wm_adsp_check_coeff_flags()
1553 static int wm_adsp_parse_coeff(struct wm_adsp *dsp, in wm_adsp_parse_coeff() argument
1562 wm_coeff_parse_alg(dsp, &data, &alg_blk); in wm_adsp_parse_coeff()
1564 wm_coeff_parse_coeff(dsp, &data, &coeff_blk); in wm_adsp_parse_coeff()
1573 ret = wm_adsp_check_coeff_flags(dsp, &coeff_blk, in wm_adsp_parse_coeff()
1582 ret = wm_adsp_check_coeff_flags(dsp, &coeff_blk, in wm_adsp_parse_coeff()
1592 ret = wm_adsp_check_coeff_flags(dsp, &coeff_blk, in wm_adsp_parse_coeff()
1601 adsp_err(dsp, "Unknown control type: %d\n", in wm_adsp_parse_coeff()
1609 ret = wm_adsp_create_control(dsp, &alg_region, in wm_adsp_parse_coeff()
1617 adsp_err(dsp, "Failed to create control: %.*s, %d\n", in wm_adsp_parse_coeff()
1624 static int wm_adsp_load(struct wm_adsp *dsp) in wm_adsp_load() argument
1628 struct regmap *regmap = dsp->regmap; in wm_adsp_load()
1647 snprintf(file, PAGE_SIZE, "%s-%s-%s.wmfw", dsp->part, dsp->fwf_name, in wm_adsp_load()
1648 wm_adsp_fw[dsp->fw].file); in wm_adsp_load()
1651 ret = request_firmware(&firmware, file, dsp->dev); in wm_adsp_load()
1653 adsp_err(dsp, "Failed to request '%s'\n", file); in wm_adsp_load()
1660 adsp_err(dsp, "%s: file too short, %zu bytes\n", in wm_adsp_load()
1668 adsp_err(dsp, "%s: invalid magic\n", file); in wm_adsp_load()
1674 adsp_warn(dsp, "%s: Depreciated file format %d\n", in wm_adsp_load()
1681 adsp_err(dsp, "%s: unknown file format %d\n", in wm_adsp_load()
1686 adsp_info(dsp, "Firmware version: %d\n", header->ver); in wm_adsp_load()
1687 dsp->fw_ver = header->ver; in wm_adsp_load()
1689 if (header->core != dsp->type) { in wm_adsp_load()
1690 adsp_err(dsp, "%s: invalid core %d != %d\n", in wm_adsp_load()
1691 file, header->core, dsp->type); in wm_adsp_load()
1695 switch (dsp->type) { in wm_adsp_load()
1702 adsp_dbg(dsp, "%s: %d DM, %d PM, %d ZM\n", in wm_adsp_load()
1714 adsp_dbg(dsp, "%s: %d XM, %d YM %d PM, %d ZM\n", in wm_adsp_load()
1722 WARN(1, "Unknown DSP type"); in wm_adsp_load()
1728 adsp_err(dsp, "%s: unexpected header length %d\n", in wm_adsp_load()
1733 adsp_dbg(dsp, "%s: timestamp %llu\n", file, in wm_adsp_load()
1744 mem = wm_adsp_find_region(dsp, type); in wm_adsp_load()
1754 ret = wm_adsp_parse_coeff(dsp, region); in wm_adsp_load()
1776 adsp_warn(dsp, in wm_adsp_load()
1782 adsp_dbg(dsp, "%s.%d: %d bytes at %d in %s\n", file, in wm_adsp_load()
1788 adsp_err(dsp, in wm_adsp_load()
1798 adsp_info(dsp, "%s: %s\n", file, text); in wm_adsp_load()
1808 adsp_err(dsp, "Out of memory\n"); in wm_adsp_load()
1816 adsp_err(dsp, in wm_adsp_load()
1831 adsp_err(dsp, "Failed to complete async write: %d\n", ret); in wm_adsp_load()
1836 adsp_warn(dsp, "%s.%d: %zu bytes at end of file\n", in wm_adsp_load()
1839 wm_adsp_debugfs_save_wmfwname(dsp, file); in wm_adsp_load()
1852 static void wm_adsp_ctl_fixup_base(struct wm_adsp *dsp, in wm_adsp_ctl_fixup_base() argument
1857 list_for_each_entry(ctl, &dsp->ctl_list, list) { in wm_adsp_ctl_fixup_base()
1858 if (ctl->fw_name == wm_adsp_fw_text[dsp->fw] && in wm_adsp_ctl_fixup_base()
1866 static void *wm_adsp_read_algs(struct wm_adsp *dsp, size_t n_algs, in wm_adsp_read_algs() argument
1876 adsp_err(dsp, "No algorithms\n"); in wm_adsp_read_algs()
1881 adsp_err(dsp, "Algorithm count %zx excessive\n", n_algs); in wm_adsp_read_algs()
1888 ret = regmap_raw_read(dsp->regmap, reg, &val, sizeof(val)); in wm_adsp_read_algs()
1890 adsp_err(dsp, "Failed to read algorithm list end: %d\n", in wm_adsp_read_algs()
1896 adsp_warn(dsp, "Algorithm list end %x 0x%x != 0xbedead\n", in wm_adsp_read_algs()
1899 /* Convert length from DSP words to bytes */ in wm_adsp_read_algs()
1908 ret = regmap_raw_read(dsp->regmap, reg, alg, len); in wm_adsp_read_algs()
1910 adsp_err(dsp, "Failed to read algorithm list: %d\n", ret); in wm_adsp_read_algs()
1919 wm_adsp_find_alg_region(struct wm_adsp *dsp, int type, unsigned int id) in wm_adsp_find_alg_region() argument
1923 list_for_each_entry(alg_region, &dsp->alg_regions, list) { in wm_adsp_find_alg_region()
1931 static struct wm_adsp_alg_region *wm_adsp_create_region(struct wm_adsp *dsp, in wm_adsp_create_region() argument
1945 list_add_tail(&alg_region->list, &dsp->alg_regions); in wm_adsp_create_region()
1947 if (dsp->fw_ver > 0) in wm_adsp_create_region()
1948 wm_adsp_ctl_fixup_base(dsp, alg_region); in wm_adsp_create_region()
1953 static void wm_adsp_free_alg_regions(struct wm_adsp *dsp) in wm_adsp_free_alg_regions() argument
1957 while (!list_empty(&dsp->alg_regions)) { in wm_adsp_free_alg_regions()
1958 alg_region = list_first_entry(&dsp->alg_regions, in wm_adsp_free_alg_regions()
1966 static int wm_adsp1_setup_algs(struct wm_adsp *dsp) in wm_adsp1_setup_algs() argument
1976 mem = wm_adsp_find_region(dsp, WMFW_ADSP1_DM); in wm_adsp1_setup_algs()
1980 ret = regmap_raw_read(dsp->regmap, mem->base, &adsp1_id, in wm_adsp1_setup_algs()
1983 adsp_err(dsp, "Failed to read algorithm info: %d\n", in wm_adsp1_setup_algs()
1989 dsp->fw_id = be32_to_cpu(adsp1_id.fw.id); in wm_adsp1_setup_algs()
1990 adsp_info(dsp, "Firmware: %x v%d.%d.%d, %zu algorithms\n", in wm_adsp1_setup_algs()
1991 dsp->fw_id, in wm_adsp1_setup_algs()
1997 alg_region = wm_adsp_create_region(dsp, WMFW_ADSP1_ZM, in wm_adsp1_setup_algs()
2002 alg_region = wm_adsp_create_region(dsp, WMFW_ADSP1_DM, in wm_adsp1_setup_algs()
2007 /* Calculate offset and length in DSP words */ in wm_adsp1_setup_algs()
2011 adsp1_alg = wm_adsp_read_algs(dsp, n_algs, mem, pos, len); in wm_adsp1_setup_algs()
2016 adsp_info(dsp, "%d: ID %x v%d.%d.%d DM@%x ZM@%x\n", in wm_adsp1_setup_algs()
2024 alg_region = wm_adsp_create_region(dsp, WMFW_ADSP1_DM, in wm_adsp1_setup_algs()
2031 if (dsp->fw_ver == 0) { in wm_adsp1_setup_algs()
2036 wm_adsp_create_control(dsp, alg_region, 0, in wm_adsp1_setup_algs()
2040 adsp_warn(dsp, "Missing length info for region DM with ID %x\n", in wm_adsp1_setup_algs()
2045 alg_region = wm_adsp_create_region(dsp, WMFW_ADSP1_ZM, in wm_adsp1_setup_algs()
2052 if (dsp->fw_ver == 0) { in wm_adsp1_setup_algs()
2057 wm_adsp_create_control(dsp, alg_region, 0, in wm_adsp1_setup_algs()
2061 adsp_warn(dsp, "Missing length info for region ZM with ID %x\n", in wm_adsp1_setup_algs()
2072 static int wm_adsp2_setup_algs(struct wm_adsp *dsp) in wm_adsp2_setup_algs() argument
2082 mem = wm_adsp_find_region(dsp, WMFW_ADSP2_XM); in wm_adsp2_setup_algs()
2086 ret = regmap_raw_read(dsp->regmap, mem->base, &adsp2_id, in wm_adsp2_setup_algs()
2089 adsp_err(dsp, "Failed to read algorithm info: %d\n", in wm_adsp2_setup_algs()
2095 dsp->fw_id = be32_to_cpu(adsp2_id.fw.id); in wm_adsp2_setup_algs()
2096 dsp->fw_id_version = be32_to_cpu(adsp2_id.fw.ver); in wm_adsp2_setup_algs()
2097 adsp_info(dsp, "Firmware: %x v%d.%d.%d, %zu algorithms\n", in wm_adsp2_setup_algs()
2098 dsp->fw_id, in wm_adsp2_setup_algs()
2099 (dsp->fw_id_version & 0xff0000) >> 16, in wm_adsp2_setup_algs()
2100 (dsp->fw_id_version & 0xff00) >> 8, in wm_adsp2_setup_algs()
2101 dsp->fw_id_version & 0xff, in wm_adsp2_setup_algs()
2104 alg_region = wm_adsp_create_region(dsp, WMFW_ADSP2_XM, in wm_adsp2_setup_algs()
2109 alg_region = wm_adsp_create_region(dsp, WMFW_ADSP2_YM, in wm_adsp2_setup_algs()
2114 alg_region = wm_adsp_create_region(dsp, WMFW_ADSP2_ZM, in wm_adsp2_setup_algs()
2119 /* Calculate offset and length in DSP words */ in wm_adsp2_setup_algs()
2123 adsp2_alg = wm_adsp_read_algs(dsp, n_algs, mem, pos, len); in wm_adsp2_setup_algs()
2128 adsp_info(dsp, in wm_adsp2_setup_algs()
2138 alg_region = wm_adsp_create_region(dsp, WMFW_ADSP2_XM, in wm_adsp2_setup_algs()
2145 if (dsp->fw_ver == 0) { in wm_adsp2_setup_algs()
2150 wm_adsp_create_control(dsp, alg_region, 0, in wm_adsp2_setup_algs()
2154 adsp_warn(dsp, "Missing length info for region XM with ID %x\n", in wm_adsp2_setup_algs()
2159 alg_region = wm_adsp_create_region(dsp, WMFW_ADSP2_YM, in wm_adsp2_setup_algs()
2166 if (dsp->fw_ver == 0) { in wm_adsp2_setup_algs()
2171 wm_adsp_create_control(dsp, alg_region, 0, in wm_adsp2_setup_algs()
2175 adsp_warn(dsp, "Missing length info for region YM with ID %x\n", in wm_adsp2_setup_algs()
2180 alg_region = wm_adsp_create_region(dsp, WMFW_ADSP2_ZM, in wm_adsp2_setup_algs()
2187 if (dsp->fw_ver == 0) { in wm_adsp2_setup_algs()
2192 wm_adsp_create_control(dsp, alg_region, 0, in wm_adsp2_setup_algs()
2196 adsp_warn(dsp, "Missing length info for region ZM with ID %x\n", in wm_adsp2_setup_algs()
2207 static int wm_adsp_load_coeff(struct wm_adsp *dsp) in wm_adsp_load_coeff() argument
2210 struct regmap *regmap = dsp->regmap; in wm_adsp_load_coeff()
2225 snprintf(file, PAGE_SIZE, "%s-%s-%s.bin", dsp->part, dsp->fwf_name, in wm_adsp_load_coeff()
2226 wm_adsp_fw[dsp->fw].file); in wm_adsp_load_coeff()
2229 ret = request_firmware(&firmware, file, dsp->dev); in wm_adsp_load_coeff()
2231 adsp_warn(dsp, "Failed to request '%s'\n", file); in wm_adsp_load_coeff()
2238 adsp_err(dsp, "%s: file too short, %zu bytes\n", in wm_adsp_load_coeff()
2245 adsp_err(dsp, "%s: invalid magic\n", file); in wm_adsp_load_coeff()
2253 adsp_err(dsp, "%s: Unsupported coefficient file format %d\n", in wm_adsp_load_coeff()
2259 adsp_dbg(dsp, "%s: v%d.%d.%d\n", file, in wm_adsp_load_coeff()
2274 adsp_dbg(dsp, "%s.%d: %x v%d.%d.%d\n", in wm_adsp_load_coeff()
2279 adsp_dbg(dsp, "%s.%d: %d bytes at 0x%x in %x\n", in wm_adsp_load_coeff()
2293 if (le32_to_cpu(blk->id) == dsp->fw_id && in wm_adsp_load_coeff()
2296 mem = wm_adsp_find_region(dsp, type); in wm_adsp_load_coeff()
2298 adsp_err(dsp, "No ZM\n"); in wm_adsp_load_coeff()
2313 adsp_dbg(dsp, "%s.%d: %d bytes in %x for %x\n", in wm_adsp_load_coeff()
2317 mem = wm_adsp_find_region(dsp, type); in wm_adsp_load_coeff()
2319 adsp_err(dsp, "No base for region %x\n", type); in wm_adsp_load_coeff()
2323 alg_region = wm_adsp_find_alg_region(dsp, type, in wm_adsp_load_coeff()
2330 adsp_err(dsp, "No %x for algorithm %x\n", in wm_adsp_load_coeff()
2336 adsp_err(dsp, "%s.%d: Unknown region type %x at %d\n", in wm_adsp_load_coeff()
2344 adsp_err(dsp, in wm_adsp_load_coeff()
2357 adsp_err(dsp, "Out of memory\n"); in wm_adsp_load_coeff()
2362 adsp_dbg(dsp, "%s.%d: Writing %d bytes at %x\n", in wm_adsp_load_coeff()
2368 adsp_err(dsp, in wm_adsp_load_coeff()
2380 adsp_err(dsp, "Failed to complete async write: %d\n", ret); in wm_adsp_load_coeff()
2383 adsp_warn(dsp, "%s.%d: %zu bytes at end of file\n", in wm_adsp_load_coeff()
2386 wm_adsp_debugfs_save_binname(dsp, file); in wm_adsp_load_coeff()
2397 static int wm_adsp_create_name(struct wm_adsp *dsp) in wm_adsp_create_name() argument
2401 if (!dsp->name) { in wm_adsp_create_name()
2402 dsp->name = devm_kasprintf(dsp->dev, GFP_KERNEL, "DSP%d", in wm_adsp_create_name()
2403 dsp->num); in wm_adsp_create_name()
2404 if (!dsp->name) in wm_adsp_create_name()
2408 if (!dsp->fwf_name) { in wm_adsp_create_name()
2409 p = devm_kstrdup(dsp->dev, dsp->name, GFP_KERNEL); in wm_adsp_create_name()
2413 dsp->fwf_name = p; in wm_adsp_create_name()
2421 int wm_adsp1_init(struct wm_adsp *dsp) in wm_adsp1_init() argument
2425 ret = wm_adsp_create_name(dsp); in wm_adsp1_init()
2429 INIT_LIST_HEAD(&dsp->alg_regions); in wm_adsp1_init()
2431 mutex_init(&dsp->pwr_lock); in wm_adsp1_init()
2443 struct wm_adsp *dsp = &dsps[w->shift]; in wm_adsp1_event() local
2448 dsp->component = component; in wm_adsp1_event()
2450 mutex_lock(&dsp->pwr_lock); in wm_adsp1_event()
2454 regmap_update_bits(dsp->regmap, dsp->base + ADSP1_CONTROL_30, in wm_adsp1_event()
2458 * For simplicity set the DSP clock rate to be the in wm_adsp1_event()
2461 if (dsp->sysclk_reg) { in wm_adsp1_event()
2462 ret = regmap_read(dsp->regmap, dsp->sysclk_reg, &val); in wm_adsp1_event()
2464 adsp_err(dsp, "Failed to read SYSCLK state: %d\n", in wm_adsp1_event()
2469 val = (val & dsp->sysclk_mask) >> dsp->sysclk_shift; in wm_adsp1_event()
2471 ret = regmap_update_bits(dsp->regmap, in wm_adsp1_event()
2472 dsp->base + ADSP1_CONTROL_31, in wm_adsp1_event()
2475 adsp_err(dsp, "Failed to set clock rate: %d\n", in wm_adsp1_event()
2481 ret = wm_adsp_load(dsp); in wm_adsp1_event()
2485 ret = wm_adsp1_setup_algs(dsp); in wm_adsp1_event()
2489 ret = wm_adsp_load_coeff(dsp); in wm_adsp1_event()
2494 ret = wm_coeff_init_control_caches(dsp); in wm_adsp1_event()
2499 ret = wm_coeff_sync_controls(dsp); in wm_adsp1_event()
2503 dsp->booted = true; in wm_adsp1_event()
2506 regmap_update_bits(dsp->regmap, dsp->base + ADSP1_CONTROL_30, in wm_adsp1_event()
2510 dsp->running = true; in wm_adsp1_event()
2514 dsp->running = false; in wm_adsp1_event()
2515 dsp->booted = false; in wm_adsp1_event()
2518 regmap_update_bits(dsp->regmap, dsp->base + ADSP1_CONTROL_30, in wm_adsp1_event()
2521 regmap_update_bits(dsp->regmap, dsp->base + ADSP1_CONTROL_19, in wm_adsp1_event()
2524 regmap_update_bits(dsp->regmap, dsp->base + ADSP1_CONTROL_30, in wm_adsp1_event()
2527 list_for_each_entry(ctl, &dsp->ctl_list, list) in wm_adsp1_event()
2531 wm_adsp_free_alg_regions(dsp); in wm_adsp1_event()
2538 mutex_unlock(&dsp->pwr_lock); in wm_adsp1_event()
2543 regmap_update_bits(dsp->regmap, dsp->base + ADSP1_CONTROL_30, in wm_adsp1_event()
2546 mutex_unlock(&dsp->pwr_lock); in wm_adsp1_event()
2552 static int wm_adsp2_ena(struct wm_adsp *dsp) in wm_adsp2_ena() argument
2557 switch (dsp->rev) { in wm_adsp2_ena()
2559 ret = regmap_update_bits_async(dsp->regmap, in wm_adsp2_ena()
2560 dsp->base + ADSP2_CONTROL, in wm_adsp2_ena()
2571 ret = regmap_read(dsp->regmap, dsp->base + ADSP2_STATUS1, &val); in wm_adsp2_ena()
2582 adsp_err(dsp, "Failed to start DSP RAM\n"); in wm_adsp2_ena()
2586 adsp_dbg(dsp, "RAM ready after %d polls\n", count); in wm_adsp2_ena()
2593 struct wm_adsp *dsp = container_of(work, in wm_adsp2_boot_work() local
2598 mutex_lock(&dsp->pwr_lock); in wm_adsp2_boot_work()
2600 ret = regmap_update_bits(dsp->regmap, dsp->base + ADSP2_CONTROL, in wm_adsp2_boot_work()
2605 ret = wm_adsp2_ena(dsp); in wm_adsp2_boot_work()
2609 ret = wm_adsp_load(dsp); in wm_adsp2_boot_work()
2613 ret = wm_adsp2_setup_algs(dsp); in wm_adsp2_boot_work()
2617 ret = wm_adsp_load_coeff(dsp); in wm_adsp2_boot_work()
2622 ret = wm_coeff_init_control_caches(dsp); in wm_adsp2_boot_work()
2626 switch (dsp->rev) { in wm_adsp2_boot_work()
2628 /* Turn DSP back off until we are ready to run */ in wm_adsp2_boot_work()
2629 ret = regmap_update_bits(dsp->regmap, dsp->base + ADSP2_CONTROL, in wm_adsp2_boot_work()
2638 dsp->booted = true; in wm_adsp2_boot_work()
2640 mutex_unlock(&dsp->pwr_lock); in wm_adsp2_boot_work()
2645 regmap_update_bits(dsp->regmap, dsp->base + ADSP2_CONTROL, in wm_adsp2_boot_work()
2648 regmap_update_bits(dsp->regmap, dsp->base + ADSP2_CONTROL, in wm_adsp2_boot_work()
2651 mutex_unlock(&dsp->pwr_lock); in wm_adsp2_boot_work()
2654 static void wm_adsp2_set_dspclk(struct wm_adsp *dsp, unsigned int freq) in wm_adsp2_set_dspclk() argument
2658 switch (dsp->rev) { in wm_adsp2_set_dspclk()
2660 ret = regmap_update_bits_async(dsp->regmap, in wm_adsp2_set_dspclk()
2661 dsp->base + ADSP2_CLOCKING, in wm_adsp2_set_dspclk()
2665 adsp_err(dsp, "Failed to set clock rate: %d\n", ret); in wm_adsp2_set_dspclk()
2682 struct wm_adsp *dsp = &dsps[mc->shift - 1]; in wm_adsp2_preloader_get() local
2684 ucontrol->value.integer.value[0] = dsp->preloaded; in wm_adsp2_preloader_get()
2698 struct wm_adsp *dsp = &dsps[mc->shift - 1]; in wm_adsp2_preloader_put() local
2701 snprintf(preload, ARRAY_SIZE(preload), "%s Preload", dsp->name); in wm_adsp2_preloader_put()
2703 dsp->preloaded = ucontrol->value.integer.value[0]; in wm_adsp2_preloader_put()
2712 flush_work(&dsp->boot_work); in wm_adsp2_preloader_put()
2718 static void wm_adsp_stop_watchdog(struct wm_adsp *dsp) in wm_adsp_stop_watchdog() argument
2720 switch (dsp->rev) { in wm_adsp_stop_watchdog()
2725 regmap_update_bits(dsp->regmap, dsp->base + ADSP2_WATCHDOG, in wm_adsp_stop_watchdog()
2736 struct wm_adsp *dsp = &dsps[w->shift]; in wm_adsp2_early_event() local
2741 wm_adsp2_set_dspclk(dsp, freq); in wm_adsp2_early_event()
2742 queue_work(system_unbound_wq, &dsp->boot_work); in wm_adsp2_early_event()
2745 mutex_lock(&dsp->pwr_lock); in wm_adsp2_early_event()
2747 wm_adsp_debugfs_clear(dsp); in wm_adsp2_early_event()
2749 dsp->fw_id = 0; in wm_adsp2_early_event()
2750 dsp->fw_id_version = 0; in wm_adsp2_early_event()
2752 dsp->booted = false; in wm_adsp2_early_event()
2754 regmap_update_bits(dsp->regmap, dsp->base + ADSP2_CONTROL, in wm_adsp2_early_event()
2757 list_for_each_entry(ctl, &dsp->ctl_list, list) in wm_adsp2_early_event()
2760 wm_adsp_free_alg_regions(dsp); in wm_adsp2_early_event()
2762 mutex_unlock(&dsp->pwr_lock); in wm_adsp2_early_event()
2764 adsp_dbg(dsp, "Shutdown complete\n"); in wm_adsp2_early_event()
2779 struct wm_adsp *dsp = &dsps[w->shift]; in wm_adsp2_event() local
2784 flush_work(&dsp->boot_work); in wm_adsp2_event()
2786 mutex_lock(&dsp->pwr_lock); in wm_adsp2_event()
2788 if (!dsp->booted) { in wm_adsp2_event()
2793 ret = wm_adsp2_ena(dsp); in wm_adsp2_event()
2798 ret = wm_coeff_sync_controls(dsp); in wm_adsp2_event()
2802 wm_adsp2_lock(dsp, dsp->lock_regions); in wm_adsp2_event()
2804 ret = regmap_update_bits(dsp->regmap, in wm_adsp2_event()
2805 dsp->base + ADSP2_CONTROL, in wm_adsp2_event()
2811 if (wm_adsp_fw[dsp->fw].num_caps != 0) { in wm_adsp2_event()
2812 ret = wm_adsp_buffer_init(dsp); in wm_adsp2_event()
2817 dsp->running = true; in wm_adsp2_event()
2819 mutex_unlock(&dsp->pwr_lock); in wm_adsp2_event()
2825 wm_adsp_signal_event_controls(dsp, WM_ADSP_FW_EVENT_SHUTDOWN); in wm_adsp2_event()
2827 wm_adsp_stop_watchdog(dsp); in wm_adsp2_event()
2830 switch (dsp->rev) { in wm_adsp2_event()
2832 wm_adsp2_show_fw_status(dsp); in wm_adsp2_event()
2835 wm_adsp2v2_show_fw_status(dsp); in wm_adsp2_event()
2839 mutex_lock(&dsp->pwr_lock); in wm_adsp2_event()
2841 dsp->running = false; in wm_adsp2_event()
2843 regmap_update_bits(dsp->regmap, in wm_adsp2_event()
2844 dsp->base + ADSP2_CONTROL, in wm_adsp2_event()
2848 switch (dsp->rev) { in wm_adsp2_event()
2850 regmap_write(dsp->regmap, in wm_adsp2_event()
2851 dsp->base + ADSP2_RDMA_CONFIG_1, 0); in wm_adsp2_event()
2852 regmap_write(dsp->regmap, in wm_adsp2_event()
2853 dsp->base + ADSP2_WDMA_CONFIG_1, 0); in wm_adsp2_event()
2854 regmap_write(dsp->regmap, in wm_adsp2_event()
2855 dsp->base + ADSP2_WDMA_CONFIG_2, 0); in wm_adsp2_event()
2857 regmap_update_bits(dsp->regmap, in wm_adsp2_event()
2858 dsp->base + ADSP2_CONTROL, in wm_adsp2_event()
2862 regmap_write(dsp->regmap, in wm_adsp2_event()
2863 dsp->base + ADSP2_RDMA_CONFIG_1, 0); in wm_adsp2_event()
2864 regmap_write(dsp->regmap, in wm_adsp2_event()
2865 dsp->base + ADSP2_WDMA_CONFIG_1, 0); in wm_adsp2_event()
2866 regmap_write(dsp->regmap, in wm_adsp2_event()
2867 dsp->base + ADSP2V2_WDMA_CONFIG_2, 0); in wm_adsp2_event()
2871 if (wm_adsp_fw[dsp->fw].num_caps != 0) in wm_adsp2_event()
2872 wm_adsp_buffer_free(dsp); in wm_adsp2_event()
2874 mutex_unlock(&dsp->pwr_lock); in wm_adsp2_event()
2876 adsp_dbg(dsp, "Execution stopped\n"); in wm_adsp2_event()
2885 regmap_update_bits(dsp->regmap, dsp->base + ADSP2_CONTROL, in wm_adsp2_event()
2887 mutex_unlock(&dsp->pwr_lock); in wm_adsp2_event()
2892 int wm_adsp2_component_probe(struct wm_adsp *dsp, struct snd_soc_component *component) in wm_adsp2_component_probe() argument
2896 snprintf(preload, ARRAY_SIZE(preload), "%s Preload", dsp->name); in wm_adsp2_component_probe()
2899 wm_adsp2_init_debugfs(dsp, component); in wm_adsp2_component_probe()
2901 dsp->component = component; in wm_adsp2_component_probe()
2907 int wm_adsp2_component_remove(struct wm_adsp *dsp, struct snd_soc_component *component) in wm_adsp2_component_remove() argument
2909 wm_adsp2_cleanup_debugfs(dsp); in wm_adsp2_component_remove()
2915 int wm_adsp2_init(struct wm_adsp *dsp) in wm_adsp2_init() argument
2919 ret = wm_adsp_create_name(dsp); in wm_adsp2_init()
2923 switch (dsp->rev) { in wm_adsp2_init()
2926 * Disable the DSP memory by default when in reset for a small in wm_adsp2_init()
2929 ret = regmap_update_bits(dsp->regmap, dsp->base + ADSP2_CONTROL, in wm_adsp2_init()
2932 adsp_err(dsp, in wm_adsp2_init()
2941 INIT_LIST_HEAD(&dsp->alg_regions); in wm_adsp2_init()
2942 INIT_LIST_HEAD(&dsp->ctl_list); in wm_adsp2_init()
2943 INIT_WORK(&dsp->boot_work, wm_adsp2_boot_work); in wm_adsp2_init()
2945 mutex_init(&dsp->pwr_lock); in wm_adsp2_init()
2951 void wm_adsp2_remove(struct wm_adsp *dsp) in wm_adsp2_remove() argument
2955 while (!list_empty(&dsp->ctl_list)) { in wm_adsp2_remove()
2956 ctl = list_first_entry(&dsp->ctl_list, struct wm_coeff_ctl, in wm_adsp2_remove()
2972 * Note this will be more complex once each DSP can support multiple in wm_adsp_compr_attach()
2975 if (!compr->dsp->buffer) in wm_adsp_compr_attach()
2978 compr->buf = compr->dsp->buffer; in wm_adsp_compr_attach()
2999 int wm_adsp_compr_open(struct wm_adsp *dsp, struct snd_compr_stream *stream) in wm_adsp_compr_open() argument
3004 mutex_lock(&dsp->pwr_lock); in wm_adsp_compr_open()
3006 if (wm_adsp_fw[dsp->fw].num_caps == 0) { in wm_adsp_compr_open()
3007 adsp_err(dsp, "Firmware does not support compressed API\n"); in wm_adsp_compr_open()
3012 if (wm_adsp_fw[dsp->fw].compr_direction != stream->direction) { in wm_adsp_compr_open()
3013 adsp_err(dsp, "Firmware does not support stream direction\n"); in wm_adsp_compr_open()
3018 if (dsp->compr) { in wm_adsp_compr_open()
3020 adsp_err(dsp, "Only a single stream supported per DSP\n"); in wm_adsp_compr_open()
3031 compr->dsp = dsp; in wm_adsp_compr_open()
3034 dsp->compr = compr; in wm_adsp_compr_open()
3039 mutex_unlock(&dsp->pwr_lock); in wm_adsp_compr_open()
3048 struct wm_adsp *dsp = compr->dsp; in wm_adsp_compr_free() local
3050 mutex_lock(&dsp->pwr_lock); in wm_adsp_compr_free()
3053 dsp->compr = NULL; in wm_adsp_compr_free()
3058 mutex_unlock(&dsp->pwr_lock); in wm_adsp_compr_free()
3068 struct wm_adsp *dsp = compr->dsp; in wm_adsp_compr_check_params() local
3078 adsp_err(dsp, "Invalid buffer fragsize=%d fragments=%d\n", in wm_adsp_compr_check_params()
3085 for (i = 0; i < wm_adsp_fw[dsp->fw].num_caps; i++) { in wm_adsp_compr_check_params()
3086 caps = &wm_adsp_fw[dsp->fw].caps[i]; in wm_adsp_compr_check_params()
3108 adsp_err(dsp, "Invalid params id=%u ch=%u,%u rate=%u fmt=%u\n", in wm_adsp_compr_check_params()
3132 adsp_dbg(compr->dsp, "fragment_size=%d fragments=%d\n", in wm_adsp_compr_set_params()
3150 int fw = compr->dsp->fw; in wm_adsp_compr_get_caps()
3170 static int wm_adsp_read_data_block(struct wm_adsp *dsp, int mem_type, in wm_adsp_read_data_block() argument
3174 struct wm_adsp_region const *mem = wm_adsp_find_region(dsp, mem_type); in wm_adsp_read_data_block()
3183 ret = regmap_raw_read(dsp->regmap, reg, data, in wm_adsp_read_data_block()
3194 static inline int wm_adsp_read_data_word(struct wm_adsp *dsp, int mem_type, in wm_adsp_read_data_word() argument
3197 return wm_adsp_read_data_block(dsp, mem_type, mem_addr, 1, data); in wm_adsp_read_data_word()
3200 static int wm_adsp_write_data_word(struct wm_adsp *dsp, int mem_type, in wm_adsp_write_data_word() argument
3203 struct wm_adsp_region const *mem = wm_adsp_find_region(dsp, mem_type); in wm_adsp_write_data_word()
3213 return regmap_raw_write(dsp->regmap, reg, &data, sizeof(data)); in wm_adsp_write_data_word()
3219 return wm_adsp_read_data_word(buf->dsp, WMFW_ADSP2_XM, in wm_adsp_buffer_read()
3226 return wm_adsp_write_data_word(buf->dsp, WMFW_ADSP2_XM, in wm_adsp_buffer_write()
3233 struct wm_adsp *dsp = buf->dsp; in wm_adsp_legacy_host_buf_addr() local
3237 alg_region = wm_adsp_find_alg_region(dsp, WMFW_ADSP2_XM, dsp->fw_id); in wm_adsp_legacy_host_buf_addr()
3241 ret = wm_adsp_read_data_word(dsp, WMFW_ADSP2_XM, addr, &magic); in wm_adsp_legacy_host_buf_addr()
3250 ret = wm_adsp_read_data_word(dsp, WMFW_ADSP2_XM, addr, in wm_adsp_legacy_host_buf_addr()
3264 adsp_dbg(dsp, "host_buf_ptr=%x\n", buf->host_buf_ptr); in wm_adsp_legacy_host_buf_addr()
3272 struct wm_adsp *dsp = buf->dsp; in wm_adsp_find_host_buffer_ctrl() local
3275 list_for_each_entry(ctl, &dsp->ctl_list, list) { in wm_adsp_find_host_buffer_ctrl()
3290 struct wm_adsp *dsp = buf->dsp; in wm_adsp_buffer_locate() local
3305 ret = regmap_raw_read(dsp->regmap, reg, &val, sizeof(val)); in wm_adsp_buffer_locate()
3319 adsp_dbg(dsp, "host_buf_ptr=%x\n", buf->host_buf_ptr); in wm_adsp_buffer_locate()
3326 const struct wm_adsp_fw_caps *caps = wm_adsp_fw[buf->dsp->fw].caps; in wm_adsp_buffer_populate()
3349 adsp_dbg(buf->dsp, in wm_adsp_buffer_populate()
3365 static int wm_adsp_buffer_init(struct wm_adsp *dsp) in wm_adsp_buffer_init() argument
3374 buf->dsp = dsp; in wm_adsp_buffer_init()
3380 adsp_err(dsp, "Failed to acquire host buffer: %d\n", ret); in wm_adsp_buffer_init()
3384 buf->regions = kcalloc(wm_adsp_fw[dsp->fw].caps->num_regions, in wm_adsp_buffer_init()
3393 adsp_err(dsp, "Failed to populate host buffer: %d\n", ret); in wm_adsp_buffer_init()
3397 dsp->buffer = buf; in wm_adsp_buffer_init()
3408 static int wm_adsp_buffer_free(struct wm_adsp *dsp) in wm_adsp_buffer_free() argument
3410 if (dsp->buffer) { in wm_adsp_buffer_free()
3411 wm_adsp_compr_detach(dsp->buffer->compr); in wm_adsp_buffer_free()
3413 kfree(dsp->buffer->regions); in wm_adsp_buffer_free()
3414 kfree(dsp->buffer); in wm_adsp_buffer_free()
3416 dsp->buffer = NULL; in wm_adsp_buffer_free()
3425 struct wm_adsp *dsp = compr->dsp; in wm_adsp_compr_trigger() local
3428 adsp_dbg(dsp, "Trigger: %d\n", cmd); in wm_adsp_compr_trigger()
3430 mutex_lock(&dsp->pwr_lock); in wm_adsp_compr_trigger()
3437 adsp_err(dsp, "Failed to link buffer and stream: %d\n", in wm_adsp_compr_trigger()
3448 adsp_err(dsp, "Failed to set high water mark: %d\n", in wm_adsp_compr_trigger()
3462 mutex_unlock(&dsp->pwr_lock); in wm_adsp_compr_trigger()
3470 int last_region = wm_adsp_fw[buf->dsp->fw].caps->num_regions - 1; in wm_adsp_buffer_size()
3492 adsp_dbg(buf->dsp, "Avail check on unstarted stream\n"); in wm_adsp_buffer_update_avail()
3510 adsp_dbg(buf->dsp, "readindex=0x%x, writeindex=0x%x, avail=%d\n", in wm_adsp_buffer_update_avail()
3524 adsp_err(buf->dsp, "Failed to check buffer error: %d\n", ret); in wm_adsp_buffer_get_error()
3528 adsp_err(buf->dsp, "Buffer error occurred: %d\n", buf->error); in wm_adsp_buffer_get_error()
3535 int wm_adsp_compr_handle_irq(struct wm_adsp *dsp) in wm_adsp_compr_handle_irq() argument
3541 mutex_lock(&dsp->pwr_lock); in wm_adsp_compr_handle_irq()
3543 buf = dsp->buffer; in wm_adsp_compr_handle_irq()
3544 compr = dsp->compr; in wm_adsp_compr_handle_irq()
3551 adsp_dbg(dsp, "Handling buffer IRQ\n"); in wm_adsp_compr_handle_irq()
3560 adsp_err(dsp, "Failed to get irq_count: %d\n", ret); in wm_adsp_compr_handle_irq()
3566 adsp_err(dsp, "Error reading avail: %d\n", ret); in wm_adsp_compr_handle_irq()
3570 if (wm_adsp_fw[dsp->fw].voice_trigger && buf->irq_count == 2) in wm_adsp_compr_handle_irq()
3578 mutex_unlock(&dsp->pwr_lock); in wm_adsp_compr_handle_irq()
3589 adsp_dbg(buf->dsp, "Enable IRQ(0x%x) for next fragment\n", in wm_adsp_buffer_reenable_irq()
3602 struct wm_adsp *dsp = compr->dsp; in wm_adsp_compr_pointer() local
3606 adsp_dbg(dsp, "Pointer request\n"); in wm_adsp_compr_pointer()
3608 mutex_lock(&dsp->pwr_lock); in wm_adsp_compr_pointer()
3621 adsp_err(dsp, "Error reading avail: %d\n", ret); in wm_adsp_compr_pointer()
3627 * DSP to inform us once a whole fragment is available. in wm_adsp_compr_pointer()
3640 adsp_err(dsp, in wm_adsp_compr_pointer()
3653 mutex_unlock(&dsp->pwr_lock); in wm_adsp_compr_pointer()
3669 for (i = 0; i < wm_adsp_fw[buf->dsp->fw].caps->num_regions; ++i) in wm_adsp_buffer_capture_block()
3673 if (i == wm_adsp_fw[buf->dsp->fw].caps->num_regions) in wm_adsp_buffer_capture_block()
3692 /* Read data from DSP */ in wm_adsp_buffer_capture_block()
3693 ret = wm_adsp_read_data_block(buf->dsp, mem_type, adsp_addr, in wm_adsp_buffer_capture_block()
3698 /* Remove the padding bytes from the data read from the DSP */ in wm_adsp_buffer_capture_block()
3725 struct wm_adsp *dsp = compr->dsp; in wm_adsp_compr_read() local
3729 adsp_dbg(dsp, "Requested read of %zu bytes\n", count); in wm_adsp_compr_read()
3741 adsp_err(dsp, "Failed to capture block: %d\n", nwords); in wm_adsp_compr_read()
3747 adsp_dbg(dsp, "Read %d bytes\n", nbytes); in wm_adsp_compr_read()
3750 adsp_err(dsp, "Failed to copy data to user: %d, %d\n", in wm_adsp_compr_read()
3768 struct wm_adsp *dsp = compr->dsp; in wm_adsp_compr_copy() local
3771 mutex_lock(&dsp->pwr_lock); in wm_adsp_compr_copy()
3778 mutex_unlock(&dsp->pwr_lock); in wm_adsp_compr_copy()
3784 int wm_adsp2_lock(struct wm_adsp *dsp, unsigned int lock_regions) in wm_adsp2_lock() argument
3786 struct regmap *regmap = dsp->regmap; in wm_adsp2_lock()
3793 lock_reg = dsp->base + ADSP2_LOCK_REGION_1_LOCK_REGION_0; in wm_adsp2_lock()
3815 irqreturn_t wm_adsp2_bus_error(struct wm_adsp *dsp) in wm_adsp2_bus_error() argument
3818 struct regmap *regmap = dsp->regmap; in wm_adsp2_bus_error()
3821 mutex_lock(&dsp->pwr_lock); in wm_adsp2_bus_error()
3823 ret = regmap_read(regmap, dsp->base + ADSP2_LOCK_REGION_CTRL, &val); in wm_adsp2_bus_error()
3825 adsp_err(dsp, in wm_adsp2_bus_error()
3831 adsp_err(dsp, "watchdog timeout error\n"); in wm_adsp2_bus_error()
3832 wm_adsp_stop_watchdog(dsp); in wm_adsp2_bus_error()
3837 adsp_err(dsp, "bus error: slave error\n"); in wm_adsp2_bus_error()
3839 adsp_err(dsp, "bus error: region lock error\n"); in wm_adsp2_bus_error()
3841 ret = regmap_read(regmap, dsp->base + ADSP2_BUS_ERR_ADDR, &val); in wm_adsp2_bus_error()
3843 adsp_err(dsp, in wm_adsp2_bus_error()
3849 adsp_err(dsp, "bus error address = 0x%x\n", in wm_adsp2_bus_error()
3853 dsp->base + ADSP2_PMEM_ERR_ADDR_XMEM_ERR_ADDR, in wm_adsp2_bus_error()
3856 adsp_err(dsp, in wm_adsp2_bus_error()
3862 adsp_err(dsp, "xmem error address = 0x%x\n", in wm_adsp2_bus_error()
3864 adsp_err(dsp, "pmem error address = 0x%x\n", in wm_adsp2_bus_error()
3869 regmap_update_bits(regmap, dsp->base + ADSP2_LOCK_REGION_CTRL, in wm_adsp2_bus_error()
3873 mutex_unlock(&dsp->pwr_lock); in wm_adsp2_bus_error()