Commit 1a4c450e authored by Mark Brown's avatar Mark Brown

Merge series "ASoC: Intel: Catpt - Lynx and Wildcat point" from Cezary...

Merge series "ASoC: Intel: Catpt - Lynx and Wildcat point" from Cezary Rojewski <cezary.rojewski@intel.com>:

Implement support for Lynxpoint and Wildcat Point AudioDSP. Catpt
solution deprecates existing sound/soc/intel/haswell which is removed in
the following series.

Due to high range of errors and desynchronization from recommendations
set by Windows solution, re-write came as a lower-cost solution compared
to refactoring /haswell/ with several series of patches.

Series is dependent on linux-spi change:
spi: pxa2xx: Add SSC2 and SSPSP2 SSP registers
https://www.spinics.net/lists/linux-spi/msg23885.html
which has been already merged and is now part of linux-spi tree.

Bulk of series content is device driver core code - everything up to
patch 7/14 - with fs entries and trace macros introduced right after.
While each core patch is shaped in such a way that no unavailable
members are ever called, until patch 14/14 is applied, no code
compilation can occur as no Makefile is present. Once said patch is
added, Makefile and Kconfig are implemented and driver module compiles
as expected.

Special thanks go to Marcin Barlik and Piotr Papierkowski for sharing
their LPT/WPT AudioDSP architecture expertise as well as helping
backtrack its historical background.
My thanks go to Amadeusz Slawinski for reviews and improvements proposed
on and off the internal list. Most of internal diff below is his
contribution.
Krzysztof Hejmowski helped me setup my own Xtensa environment and
recompile LPT/WPT FW binary sources what sped up the development greatly.

This would not have been possible without help from these champions,
especially considering how quickly the catpt was written: 2 weeks
features, 3 weeks optimizations. Thank you.

Userspace-exposed members are compatible with what is exposed by
deprecated solution as well as FW binary being re-used thus no harm is
done. The only visible differences are: the newly added 'Loopback Mute'
kcontrol and volume support extending to quad from stereo.

On top of fixing erros and design flows, catpt also adds module reload,
dynamic SRAM memory allocation during PCM runtime and exposes missing
userspace API: 'Loopback Mute' kcontrol, quad volume controls and sysfs
fw-version entries. Event tracing is provided to ease solution
debugging.

Following are not included in this update and are scheduled as later
addition:
- fw logging
- module (library) support

Note: LPT power up/down sequences might get aligned with WPT once enough
testing is done as capabilities are shared for both DSPs.
Note #2: Both LPT and WPT power up/down sequences may get optimized in
future updates as thanks to help from the Windows team, most of nuances
behind why/what/when in regard to hw registers have been backtracked and
reviewed again.

Link to developer's deep dive message:
https://www.spinics.net/lists/alsa-devel/msg113563.html

Changes in v10:
- reverted DUAL_MONO case relocation from v9
- indented all constants of enum catpt_module_id to the same column
- new newline appended for return path of catpt_dsp_do_send_msg()

Changes in v9:
https://www.spinics.net/lists/alsa-devel/msg116305.html
- fixed newlines in sysfs as requested by Andy, left tags as no other
  changes done
- removed volume_map and replaced by simple formulas for volume kcontrol
  calculations
- removed redundant parentheses in catpt_get_channel_map() and
  relocated DUAL_MONO case
- runtime suspend no longer called during module unload
- removed redundant size checks for catpt_dsp_send_tx() and
  catpt_dsp_copy_rx()

Changes in v8:
https://www.spinics.net/lists/alsa-devel/msg116168.html
- updated catpt_arrange_page_table() with GENMASK and U32_MAX usage
- made use of PFN_DOWN() replacing explicit right shitfs by PAGE_SIZE
- made fw hash dumping in catpt_coredump() more readable and removed
  hardcodes
- catpt_coredump() dumps fw hash now only if said segment has been found
  within fw_info
- shortened _MSECS suffixes to _MS
- IPC structs no longer contain enum members
- simplified definition of catpt_set_dspvol()

Changes in v7:
https://www.spinics.net/lists/alsa-devel/msg116019.html
- fixed licence header for fs.c
- renamed fs.c to sysfs.c to better match its purpose
- added documentation within Documentation/ABI/testing for entries
  exposed by catpt
- bin_attribute fw_build replaced by attribute fw_info:
  fw_info contains full FW information and after successful handshake,
  it's always available (stored in driver data) so no need to invoke
  GET_FW_VERSION IPC again, just dump the stored information
- rather than manually creating and removing sysfs files, now makes use
  of dev_groups member of struct device_driver
- patch: 10/14 'ASoC: Intel: Select catpt and deprecate haswell' has
  been moved to the back of the list: enable catpt after machine boards
  have been prepared for it first
- improved readability of several goto labels

Changes in v6:
https://www.spinics.net/lists/alsa-devel/msg115765.html
- reordered and reorganized code for patches 1/13 - 8/13 of v5, so each
  patches makes use of no member or function which is unavailable to it.
  Series size increased from 13 to 14 patches: addition of base members
  e.g.: registers has been split from addition of device.c file which
  describes acpi device behavior

Changes in v5:
https://www.spinics.net/lists/alsa-devel/msg115621.html
Basically everything below is result of Andy's review. Thank you Andy
for taking time into this detailed review

- catpt now makes use of common linux/pxa2xx_ssp.h header file, removing
  redundant SSP register declarations in the process. As stated in the
  opening, this is dependent upon linux-spi change:
  spi: pxa2xx: Add SSC2 and SSPSP2 SSP registers

- updated Kconfig by removing DMADEVICES and adding COMPILE_TEST
  as optional depends-on
- updated all register macros definitions to be more safe against common
  arithmetics when specifying macro's parameters
- removed CONFIG_PM and CONFIG_PM_SLEEP usage in favor of __maybe_unused
- all 'if (ret < 0)' converted to simple 'if (ret)' whenever possible
- fixed erroneous check for platform_device_register_data within
  catpt_register_board()
- _SLAVE/_MASTER replaced with more inclusive _CONSUMER/_PROVIDER for
  enum catpt_ssp_mode
- catpt_acpi_probe() is now making use of high-level wrappers for
  ioremapping and resource assignment, reducing function's code size
- due to improved catpt_acpi_probe() behavior, catpt_acpi_remove() needs
  not to cast dma_free_coherent() any longer
- DMA source and destrination maxburst now of value 16, see:
https://www.spinics.net/lists/alsa-devel/msg114394.html

- simplified catpt_dsp_update_lpclock() as list_for_each_entry() is
  empty-safe by default
- dropped '_SSP_' from all names of all CATPT_SSP_SSXXX_DEFAULT macros
- catpt_updatel_pci now makes use of linux/pci.h and uapi/linux/pci.h
  constants such as: PCI_PM_CTRL_STATE_MASK and PCI_D3hot

Changes in v4:
https://www.spinics.net/lists/alsa-devel/msg113762.html
- fixed compilation with i386 kconfig (conflicting names)
- streamlined naming for SHIM and PCI registers to match SSP ones
  (SHIM_REG -> SHIM)
- catpt_component_probe removed and kcontrols again initializzed
  statically via snd_kcontrol_new array: this is to remove
  kctl->id.device shenanigans
- renamed catpt_set_ctlvol to catpt_set_dspvol - function name wasn't
  matching its purpose

Changes in v3:
- fixed IRAM mask usage in lpt_dsp_power_up (dsp.c)
- updated dbg message formatting in catpt_restore_fwimage as suggested
  by Andy
- fixed alignment for struct catpt_ssp_device_format
- catpt_set_ctlvol now verifies all-equal scenario based on all
  channels rather than just first two as requested by Amadeo
- fixed SPDX for registers.h

Changes in v2:
https://www.spinics.net/lists/alsa-devel/msg113660.html
- fixed SPDX formatting for all header files as well as pcm.c
- fixed size provided to memcpy() in fw_build_read() as reported by Mark
- renamed struct catpt_pdata to struct catpt_spec (cosmetic)
- fixed erroneous path in catpt_load_block: region is properly released
- trace.h events for updating registers have been removed and usages
  replaced by dev_dbg (SRAMPGE/ LPCS)

- as requested by Andy, struct resource has replaced struct catpt_mbank
  and struct catpt_mregion. This change cascaded into:

  - catpt_mbank_size and catpt_mregion_size replaced by resource_size
  - catpt_mregion_intersects replaced by resource_overlaps
  - all catpt_mbank_ and catpt_mregion_ handlers found in loader.c
    (_request, _reserve, _release, _extract, _split, _join) have been
    removed
  - __request_region and __release_region have been enlisted in their
    place
  - catpt_mregion_intersecting renamed to catpt_resource_overlapping
  - catpt_request_region helper has been provided to deal with -size
    based requests
      o haven't found direct replacements in resource.c/ ioport.h for
      both functions

  - catpt_mbank_create and catpt_mbank_remove renamed to catpt_sram_init
    and catpt_sram_free respectively
  - catpt_sram_init now returns void instead of int and has been
    converted to simple initialized. This change ultimately cascaded
    into:
      o both SRAM banks initialization being moved to catpt_dev_init
        from catpt_acpi_probe (device.c)
      o catpt_dev::spec is now initialized first, with catpt_dev_init
        following it soon after
      o catpt_acpi_probe erroneous path has been simplified as SRAM
        banks no longer need to be freed

  - catpt_sram_free now frees all resources via child -> sibling
    enumeration rather than region_list iteration
  - catpt_dsp_update_srampge and catpt_dsp_set_srampge now accept new
    argument: unsigned long mask. Caused by removal of catpt_mbank -
    mask is taken directly from catpt_dev::spec::d/iram_mask
  - trace.h events for catpt_mbank and catpt_mregion have been removed

Diff against last drop on internal list:
https://www.spinics.net/lists/alsa-devel/msg113549.html
- replaced spinlock with mutex for mregion allocation and release to
  address sleeping in atomic context warnings
- fixed coredump fw_hash dumping
- kcontrol values are now always stored regardless of stream of interest
  is running or not
- kcontrol values are now applied after stream is prepared instead of
  ignoring what has been set by user initially
- catpt_pdata instances have been renamed from hsw_ and bdw_ to lpt_ and
  wpt_ respectively
- reordered Makefile .o(s) (cosmetic)

Cezary Rojewski (14):
  ASoC: Intel: Add catpt base members
  ASoC: Intel: catpt: Implement IPC protocol
  ASoC: Intel: catpt: Add IPC message handlers
  ASoC: Intel: catpt: Define DSP operations
  ASoC: Intel: catpt: Firmware loading and context restore
  ASoC: Intel: catpt: PCM operations
  ASoC: Intel: catpt: Device driver lifecycle
  ASoC: Intel: catpt: Event tracing
  ASoC: Intel: catpt: Simple sysfs attributes
  ASoC: Intel: haswell: Remove haswell-solution specific code
  ASoC: Intel: broadwell: Remove haswell-solution specific code
  ASoC: Intel: bdw-5650: Remove haswell-solution specific code
  ASoC: Intel: bdw-5677: Remove haswell-solution specific code
  ASoC: Intel: Select catpt and deprecate haswell

 .../ABI/testing/sysfs-bus-pci-devices-catpt   |   16 +
 sound/soc/intel/Kconfig                       |   24 +-
 sound/soc/intel/Makefile                      |    2 +-
 sound/soc/intel/boards/Kconfig                |    8 +-
 sound/soc/intel/boards/bdw-rt5650.c           |   36 -
 sound/soc/intel/boards/bdw-rt5677.c           |   33 -
 sound/soc/intel/boards/broadwell.c            |   33 -
 sound/soc/intel/boards/haswell.c              |   28 +-
 sound/soc/intel/catpt/Makefile                |    6 +
 sound/soc/intel/catpt/core.h                  |  188 +++
 sound/soc/intel/catpt/device.c                |  352 +++++
 sound/soc/intel/catpt/dsp.c                   |  578 ++++++++
 sound/soc/intel/catpt/ipc.c                   |  298 +++++
 sound/soc/intel/catpt/loader.c                |  671 ++++++++++
 sound/soc/intel/catpt/messages.c              |  313 +++++
 sound/soc/intel/catpt/messages.h              |  401 ++++++
 sound/soc/intel/catpt/pcm.c                   | 1175 +++++++++++++++++
 sound/soc/intel/catpt/registers.h             |  178 +++
 sound/soc/intel/catpt/sysfs.c                 |   55 +
 sound/soc/intel/catpt/trace.h                 |   83 ++
 20 files changed, 4335 insertions(+), 143 deletions(-)
 create mode 100644 Documentation/ABI/testing/sysfs-bus-pci-devices-catpt
 create mode 100644 sound/soc/intel/catpt/Makefile
 create mode 100644 sound/soc/intel/catpt/core.h
 create mode 100644 sound/soc/intel/catpt/device.c
 create mode 100644 sound/soc/intel/catpt/dsp.c
 create mode 100644 sound/soc/intel/catpt/ipc.c
 create mode 100644 sound/soc/intel/catpt/loader.c
 create mode 100644 sound/soc/intel/catpt/messages.c
 create mode 100644 sound/soc/intel/catpt/messages.h
 create mode 100644 sound/soc/intel/catpt/pcm.c
 create mode 100644 sound/soc/intel/catpt/registers.h
 create mode 100644 sound/soc/intel/catpt/sysfs.c
 create mode 100644 sound/soc/intel/catpt/trace.h

--
2.17.1
parents 2bc8831b 6cbfa11d
What: /sys/devices/pci0000:00/<dev>/fw_version
Date: September 2020
Contact: Cezary Rojewski <cezary.rojewski@intel.com>
Description:
Version of AudioDSP firmware ASoC catpt driver is
communicating with.
Format: %d.%d.%d.%d, type:major:minor:build.
What: /sys/devices/pci0000:00/<dev>/fw_info
Date: September 2020
Contact: Cezary Rojewski <cezary.rojewski@intel.com>
Description:
Detailed AudioDSP firmware build information including
build hash and log-providers hash. This information is
obtained during initial handshake with firmware.
Format: %s.
...@@ -47,21 +47,21 @@ config SND_SOC_INTEL_SST_FIRMWARE ...@@ -47,21 +47,21 @@ config SND_SOC_INTEL_SST_FIRMWARE
# Haswell/Broadwell/Baytrail legacy and will be set # Haswell/Broadwell/Baytrail legacy and will be set
# when these platforms are enabled # when these platforms are enabled
config SND_SOC_INTEL_HASWELL config SND_SOC_INTEL_CATPT
tristate "Haswell/Broadwell Platforms" tristate "Haswell and Broadwell"
depends on ACPI || COMPILE_TEST
depends on SND_DMA_SGBUF depends on SND_DMA_SGBUF
depends on DMADEVICES && ACPI select DW_DMAC_CORE
select SND_SOC_INTEL_SST
select SND_SOC_INTEL_SST_ACPI
select SND_SOC_INTEL_SST_FIRMWARE
select SND_SOC_ACPI_INTEL_MATCH select SND_SOC_ACPI_INTEL_MATCH
help help
If you have a Intel Haswell or Broadwell platform connected to Enable support for Intel(R) Haswell and Broadwell platforms
an I2S codec, then enable this option by saying Y or m. This is with I2S codec present. This is a recommended option.
typically used for Chromebooks. This is a recommended option. Say Y or m if you have such device.
This option is mutually exclusive with the SOF support on If unsure, say N.
Broadwell. If you want to enable SOF on Broadwell, you need to
deselect this option first. config SND_SOC_INTEL_HASWELL
tristate
select SND_SOC_INTEL_CATPT
config SND_SOC_INTEL_BAYTRAIL config SND_SOC_INTEL_BAYTRAIL
tristate "Baytrail (legacy) Platforms" tristate "Baytrail (legacy) Platforms"
......
...@@ -3,9 +3,9 @@ ...@@ -3,9 +3,9 @@
obj-$(CONFIG_SND_SOC) += common/ obj-$(CONFIG_SND_SOC) += common/
# Platform Support # Platform Support
obj-$(CONFIG_SND_SOC_INTEL_HASWELL) += haswell/
obj-$(CONFIG_SND_SOC_INTEL_BAYTRAIL) += baytrail/ obj-$(CONFIG_SND_SOC_INTEL_BAYTRAIL) += baytrail/
obj-$(CONFIG_SND_SST_ATOM_HIFI2_PLATFORM) += atom/ obj-$(CONFIG_SND_SST_ATOM_HIFI2_PLATFORM) += atom/
obj-$(CONFIG_SND_SOC_INTEL_CATPT) += catpt/
obj-$(CONFIG_SND_SOC_INTEL_SKYLAKE) += skylake/ obj-$(CONFIG_SND_SOC_INTEL_SKYLAKE) += skylake/
obj-$(CONFIG_SND_SOC_INTEL_KEEMBAY) += keembay/ obj-$(CONFIG_SND_SOC_INTEL_KEEMBAY) += keembay/
......
...@@ -26,7 +26,7 @@ config SND_SOC_INTEL_USER_FRIENDLY_LONG_NAMES ...@@ -26,7 +26,7 @@ config SND_SOC_INTEL_USER_FRIENDLY_LONG_NAMES
interface. interface.
If unsure select N. If unsure select N.
if SND_SOC_INTEL_HASWELL if SND_SOC_INTEL_CATPT
config SND_SOC_INTEL_HASWELL_MACH config SND_SOC_INTEL_HASWELL_MACH
tristate "Haswell Lynxpoint" tristate "Haswell Lynxpoint"
...@@ -40,9 +40,9 @@ config SND_SOC_INTEL_HASWELL_MACH ...@@ -40,9 +40,9 @@ config SND_SOC_INTEL_HASWELL_MACH
Say Y or m if you have such a device. Say Y or m if you have such a device.
If unsure select "N". If unsure select "N".
endif ## SND_SOC_INTEL_HASWELL endif ## SND_SOC_INTEL_CATPT
if SND_SOC_INTEL_HASWELL || SND_SOC_SOF_BROADWELL if SND_SOC_INTEL_CATPT || SND_SOC_SOF_BROADWELL
config SND_SOC_INTEL_BDW_RT5650_MACH config SND_SOC_INTEL_BDW_RT5650_MACH
tristate "Broadwell with RT5650 codec" tristate "Broadwell with RT5650 codec"
...@@ -83,7 +83,7 @@ config SND_SOC_INTEL_BROADWELL_MACH ...@@ -83,7 +83,7 @@ config SND_SOC_INTEL_BROADWELL_MACH
Ultrabook platforms. Ultrabook platforms.
Say Y or m if you have such a device. This is a recommended option. Say Y or m if you have such a device. This is a recommended option.
If unsure select "N". If unsure select "N".
endif ## SND_SOC_INTEL_HASWELL || SND_SOC_SOF_BROADWELL endif ## SND_SOC_INTEL_CATPT || SND_SOC_SOF_BROADWELL
if SND_SOC_INTEL_BAYTRAIL if SND_SOC_INTEL_BAYTRAIL
......
...@@ -16,9 +16,6 @@ ...@@ -16,9 +16,6 @@
#include <sound/soc.h> #include <sound/soc.h>
#include <sound/soc-acpi.h> #include <sound/soc-acpi.h>
#include "../common/sst-dsp.h"
#include "../haswell/sst-haswell-ipc.h"
#include "../../codecs/rt5645.h" #include "../../codecs/rt5645.h"
struct bdw_rt5650_priv { struct bdw_rt5650_priv {
...@@ -138,30 +135,6 @@ static struct snd_soc_ops bdw_rt5650_ops = { ...@@ -138,30 +135,6 @@ static struct snd_soc_ops bdw_rt5650_ops = {
.hw_params = bdw_rt5650_hw_params, .hw_params = bdw_rt5650_hw_params,
}; };
#if !IS_ENABLED(CONFIG_SND_SOC_SOF_BROADWELL)
static int bdw_rt5650_rtd_init(struct snd_soc_pcm_runtime *rtd)
{
struct snd_soc_component *component =
snd_soc_rtdcom_lookup(rtd, DRV_NAME);
struct sst_pdata *pdata = dev_get_platdata(component->dev);
struct sst_hsw *broadwell = pdata->dsp;
int ret;
/* Set ADSP SSP port settings
* clock_divider = 4 means BCLK = MCLK/5 = 24MHz/5 = 4.8MHz
*/
ret = sst_hsw_device_set_config(broadwell, SST_HSW_DEVICE_SSP_0,
SST_HSW_DEVICE_MCLK_FREQ_24_MHZ,
SST_HSW_DEVICE_TDM_CLOCK_MASTER, 4);
if (ret < 0) {
dev_err(rtd->dev, "error: failed to set device config\n");
return ret;
}
return 0;
}
#endif
static const unsigned int channels[] = { static const unsigned int channels[] = {
2, 4, 2, 4,
}; };
...@@ -251,10 +224,8 @@ SND_SOC_DAILINK_DEF(platform, ...@@ -251,10 +224,8 @@ SND_SOC_DAILINK_DEF(platform,
SND_SOC_DAILINK_DEF(be, SND_SOC_DAILINK_DEF(be,
DAILINK_COMP_ARRAY(COMP_CODEC("i2c-10EC5650:00", "rt5645-aif1"))); DAILINK_COMP_ARRAY(COMP_CODEC("i2c-10EC5650:00", "rt5645-aif1")));
#if IS_ENABLED(CONFIG_SND_SOC_SOF_BROADWELL)
SND_SOC_DAILINK_DEF(ssp0_port, SND_SOC_DAILINK_DEF(ssp0_port,
DAILINK_COMP_ARRAY(COMP_CPU("ssp0-port"))); DAILINK_COMP_ARRAY(COMP_CPU("ssp0-port")));
#endif
static struct snd_soc_dai_link bdw_rt5650_dais[] = { static struct snd_soc_dai_link bdw_rt5650_dais[] = {
/* Front End DAI links */ /* Front End DAI links */
...@@ -263,9 +234,6 @@ static struct snd_soc_dai_link bdw_rt5650_dais[] = { ...@@ -263,9 +234,6 @@ static struct snd_soc_dai_link bdw_rt5650_dais[] = {
.stream_name = "System Playback", .stream_name = "System Playback",
.dynamic = 1, .dynamic = 1,
.ops = &bdw_rt5650_fe_ops, .ops = &bdw_rt5650_fe_ops,
#if !IS_ENABLED(CONFIG_SND_SOC_SOF_BROADWELL)
.init = bdw_rt5650_rtd_init,
#endif
.trigger = { .trigger = {
SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST,
SND_SOC_DPCM_TRIGGER_POST SND_SOC_DPCM_TRIGGER_POST
...@@ -289,11 +257,7 @@ static struct snd_soc_dai_link bdw_rt5650_dais[] = { ...@@ -289,11 +257,7 @@ static struct snd_soc_dai_link bdw_rt5650_dais[] = {
.dpcm_playback = 1, .dpcm_playback = 1,
.dpcm_capture = 1, .dpcm_capture = 1,
.init = bdw_rt5650_init, .init = bdw_rt5650_init,
#if !IS_ENABLED(CONFIG_SND_SOC_SOF_BROADWELL)
SND_SOC_DAILINK_REG(dummy, be, dummy),
#else
SND_SOC_DAILINK_REG(ssp0_port, be, platform), SND_SOC_DAILINK_REG(ssp0_port, be, platform),
#endif
}, },
}; };
......
...@@ -17,9 +17,6 @@ ...@@ -17,9 +17,6 @@
#include <sound/jack.h> #include <sound/jack.h>
#include <sound/soc-acpi.h> #include <sound/soc-acpi.h>
#include "../common/sst-dsp.h"
#include "../haswell/sst-haswell-ipc.h"
#include "../../codecs/rt5677.h" #include "../../codecs/rt5677.h"
struct bdw_rt5677_priv { struct bdw_rt5677_priv {
...@@ -201,27 +198,6 @@ static const struct snd_soc_ops bdw_rt5677_dsp_ops = { ...@@ -201,27 +198,6 @@ static const struct snd_soc_ops bdw_rt5677_dsp_ops = {
.hw_params = bdw_rt5677_dsp_hw_params, .hw_params = bdw_rt5677_dsp_hw_params,
}; };
#if !IS_ENABLED(CONFIG_SND_SOC_SOF_BROADWELL)
static int bdw_rt5677_rtd_init(struct snd_soc_pcm_runtime *rtd)
{
struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, DRV_NAME);
struct sst_pdata *pdata = dev_get_platdata(component->dev);
struct sst_hsw *broadwell = pdata->dsp;
int ret;
/* Set ADSP SSP port settings */
ret = sst_hsw_device_set_config(broadwell, SST_HSW_DEVICE_SSP_0,
SST_HSW_DEVICE_MCLK_FREQ_24_MHZ,
SST_HSW_DEVICE_CLOCK_MASTER, 9);
if (ret < 0) {
dev_err(rtd->dev, "error: failed to set device config\n");
return ret;
}
return 0;
}
#endif
static const unsigned int channels[] = { static const unsigned int channels[] = {
2, 2,
}; };
...@@ -333,10 +309,8 @@ SND_SOC_DAILINK_DEF(platform, ...@@ -333,10 +309,8 @@ SND_SOC_DAILINK_DEF(platform,
SND_SOC_DAILINK_DEF(be, SND_SOC_DAILINK_DEF(be,
DAILINK_COMP_ARRAY(COMP_CODEC("i2c-RT5677CE:00", "rt5677-aif1"))); DAILINK_COMP_ARRAY(COMP_CODEC("i2c-RT5677CE:00", "rt5677-aif1")));
#if IS_ENABLED(CONFIG_SND_SOC_SOF_BROADWELL)
SND_SOC_DAILINK_DEF(ssp0_port, SND_SOC_DAILINK_DEF(ssp0_port,
DAILINK_COMP_ARRAY(COMP_CPU("ssp0-port"))); DAILINK_COMP_ARRAY(COMP_CPU("ssp0-port")));
#endif
/* Wake on voice interface */ /* Wake on voice interface */
SND_SOC_DAILINK_DEFS(dsp, SND_SOC_DAILINK_DEFS(dsp,
...@@ -350,9 +324,6 @@ static struct snd_soc_dai_link bdw_rt5677_dais[] = { ...@@ -350,9 +324,6 @@ static struct snd_soc_dai_link bdw_rt5677_dais[] = {
.name = "System PCM", .name = "System PCM",
.stream_name = "System Playback/Capture", .stream_name = "System Playback/Capture",
.dynamic = 1, .dynamic = 1,
#if !IS_ENABLED(CONFIG_SND_SOC_SOF_BROADWELL)
.init = bdw_rt5677_rtd_init,
#endif
.trigger = { .trigger = {
SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST,
SND_SOC_DPCM_TRIGGER_POST SND_SOC_DPCM_TRIGGER_POST
...@@ -387,11 +358,7 @@ static struct snd_soc_dai_link bdw_rt5677_dais[] = { ...@@ -387,11 +358,7 @@ static struct snd_soc_dai_link bdw_rt5677_dais[] = {
.dpcm_capture = 1, .dpcm_capture = 1,
.init = bdw_rt5677_init, .init = bdw_rt5677_init,
.exit = bdw_rt5677_exit, .exit = bdw_rt5677_exit,
#if !IS_ENABLED(CONFIG_SND_SOC_SOF_BROADWELL)
SND_SOC_DAILINK_REG(dummy, be, dummy),
#else
SND_SOC_DAILINK_REG(ssp0_port, be, platform), SND_SOC_DAILINK_REG(ssp0_port, be, platform),
#endif
}, },
}; };
......
...@@ -14,9 +14,6 @@ ...@@ -14,9 +14,6 @@
#include <sound/pcm_params.h> #include <sound/pcm_params.h>
#include <sound/soc-acpi.h> #include <sound/soc-acpi.h>
#include "../common/sst-dsp.h"
#include "../haswell/sst-haswell-ipc.h"
#include "../../codecs/rt286.h" #include "../../codecs/rt286.h"
static struct snd_soc_jack broadwell_headset; static struct snd_soc_jack broadwell_headset;
...@@ -122,27 +119,6 @@ static const struct snd_soc_ops broadwell_rt286_ops = { ...@@ -122,27 +119,6 @@ static const struct snd_soc_ops broadwell_rt286_ops = {
.hw_params = broadwell_rt286_hw_params, .hw_params = broadwell_rt286_hw_params,
}; };
#if !IS_ENABLED(CONFIG_SND_SOC_SOF_BROADWELL)
static int broadwell_rtd_init(struct snd_soc_pcm_runtime *rtd)
{
struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, DRV_NAME);
struct sst_pdata *pdata = dev_get_platdata(component->dev);
struct sst_hsw *broadwell = pdata->dsp;
int ret;
/* Set ADSP SSP port settings */
ret = sst_hsw_device_set_config(broadwell, SST_HSW_DEVICE_SSP_0,
SST_HSW_DEVICE_MCLK_FREQ_24_MHZ,
SST_HSW_DEVICE_CLOCK_MASTER, 9);
if (ret < 0) {
dev_err(rtd->dev, "error: failed to set device config\n");
return ret;
}
return 0;
}
#endif
static const unsigned int channels[] = { static const unsigned int channels[] = {
2, 2,
}; };
...@@ -189,10 +165,8 @@ SND_SOC_DAILINK_DEF(platform, ...@@ -189,10 +165,8 @@ SND_SOC_DAILINK_DEF(platform,
SND_SOC_DAILINK_DEF(codec, SND_SOC_DAILINK_DEF(codec,
DAILINK_COMP_ARRAY(COMP_CODEC("i2c-INT343A:00", "rt286-aif1"))); DAILINK_COMP_ARRAY(COMP_CODEC("i2c-INT343A:00", "rt286-aif1")));
#if IS_ENABLED(CONFIG_SND_SOC_SOF_BROADWELL)
SND_SOC_DAILINK_DEF(ssp0_port, SND_SOC_DAILINK_DEF(ssp0_port,
DAILINK_COMP_ARRAY(COMP_CPU("ssp0-port"))); DAILINK_COMP_ARRAY(COMP_CPU("ssp0-port")));
#endif
/* broadwell digital audio interface glue - connects codec <--> CPU */ /* broadwell digital audio interface glue - connects codec <--> CPU */
static struct snd_soc_dai_link broadwell_rt286_dais[] = { static struct snd_soc_dai_link broadwell_rt286_dais[] = {
...@@ -201,9 +175,6 @@ static struct snd_soc_dai_link broadwell_rt286_dais[] = { ...@@ -201,9 +175,6 @@ static struct snd_soc_dai_link broadwell_rt286_dais[] = {
.name = "System PCM", .name = "System PCM",
.stream_name = "System Playback/Capture", .stream_name = "System Playback/Capture",
.dynamic = 1, .dynamic = 1,
#if !IS_ENABLED(CONFIG_SND_SOC_SOF_BROADWELL)
.init = broadwell_rtd_init,
#endif
.trigger = {SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST}, .trigger = {SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST},
.ops = &broadwell_fe_ops, .ops = &broadwell_fe_ops,
.dpcm_playback = 1, .dpcm_playback = 1,
...@@ -248,11 +219,7 @@ static struct snd_soc_dai_link broadwell_rt286_dais[] = { ...@@ -248,11 +219,7 @@ static struct snd_soc_dai_link broadwell_rt286_dais[] = {
.ops = &broadwell_rt286_ops, .ops = &broadwell_rt286_ops,
.dpcm_playback = 1, .dpcm_playback = 1,
.dpcm_capture = 1, .dpcm_capture = 1,
#if !IS_ENABLED(CONFIG_SND_SOC_SOF_BROADWELL)
SND_SOC_DAILINK_REG(dummy, codec, dummy),
#else
SND_SOC_DAILINK_REG(ssp0_port, codec, platform), SND_SOC_DAILINK_REG(ssp0_port, codec, platform),
#endif
}, },
}; };
......
...@@ -13,9 +13,6 @@ ...@@ -13,9 +13,6 @@
#include <sound/soc-acpi.h> #include <sound/soc-acpi.h>
#include <sound/pcm_params.h> #include <sound/pcm_params.h>
#include "../common/sst-dsp.h"
#include "../haswell/sst-haswell-ipc.h"
#include "../../codecs/rt5640.h" #include "../../codecs/rt5640.h"
/* Haswell ULT platforms have a Headphone and Mic jack */ /* Haswell ULT platforms have a Headphone and Mic jack */
...@@ -77,25 +74,6 @@ static const struct snd_soc_ops haswell_rt5640_ops = { ...@@ -77,25 +74,6 @@ static const struct snd_soc_ops haswell_rt5640_ops = {
.hw_params = haswell_rt5640_hw_params, .hw_params = haswell_rt5640_hw_params,
}; };
static int haswell_rtd_init(struct snd_soc_pcm_runtime *rtd)
{
struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, DRV_NAME);
struct sst_pdata *pdata = dev_get_platdata(component->dev);
struct sst_hsw *haswell = pdata->dsp;
int ret;
/* Set ADSP SSP port settings */
ret = sst_hsw_device_set_config(haswell, SST_HSW_DEVICE_SSP_0,
SST_HSW_DEVICE_MCLK_FREQ_24_MHZ,
SST_HSW_DEVICE_CLOCK_MASTER, 9);
if (ret < 0) {
dev_err(rtd->dev, "failed to set device config\n");
return ret;
}
return 0;
}
SND_SOC_DAILINK_DEF(dummy, SND_SOC_DAILINK_DEF(dummy,
DAILINK_COMP_ARRAY(COMP_DUMMY())); DAILINK_COMP_ARRAY(COMP_DUMMY()));
...@@ -117,13 +95,15 @@ SND_SOC_DAILINK_DEF(codec, ...@@ -117,13 +95,15 @@ SND_SOC_DAILINK_DEF(codec,
SND_SOC_DAILINK_DEF(platform, SND_SOC_DAILINK_DEF(platform,
DAILINK_COMP_ARRAY(COMP_PLATFORM("haswell-pcm-audio"))); DAILINK_COMP_ARRAY(COMP_PLATFORM("haswell-pcm-audio")));
SND_SOC_DAILINK_DEF(ssp0_port,
DAILINK_COMP_ARRAY(COMP_CPU("ssp0-port")));
static struct snd_soc_dai_link haswell_rt5640_dais[] = { static struct snd_soc_dai_link haswell_rt5640_dais[] = {
/* Front End DAI links */ /* Front End DAI links */
{ {
.name = "System", .name = "System",
.stream_name = "System Playback/Capture", .stream_name = "System Playback/Capture",
.dynamic = 1, .dynamic = 1,
.init = haswell_rtd_init,
.trigger = {SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST}, .trigger = {SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST},
.dpcm_playback = 1, .dpcm_playback = 1,
.dpcm_capture = 1, .dpcm_capture = 1,
...@@ -167,7 +147,7 @@ static struct snd_soc_dai_link haswell_rt5640_dais[] = { ...@@ -167,7 +147,7 @@ static struct snd_soc_dai_link haswell_rt5640_dais[] = {
.ops = &haswell_rt5640_ops, .ops = &haswell_rt5640_ops,
.dpcm_playback = 1, .dpcm_playback = 1,
.dpcm_capture = 1, .dpcm_capture = 1,
SND_SOC_DAILINK_REG(dummy, codec, dummy), SND_SOC_DAILINK_REG(ssp0_port, codec, platform),
}, },
}; };
......
snd-soc-catpt-objs := device.o dsp.o loader.o ipc.o messages.o pcm.o sysfs.o
# tell define_trace.h where to find the trace header
CFLAGS_device.o := -I$(src)
obj-$(CONFIG_SND_SOC_INTEL_CATPT) += snd-soc-catpt.o
/* SPDX-License-Identifier: GPL-2.0-only */
/*
* Copyright(c) 2020 Intel Corporation. All rights reserved.
*
* Author: Cezary Rojewski <cezary.rojewski@intel.com>
*/
#ifndef __SND_SOC_INTEL_CATPT_CORE_H
#define __SND_SOC_INTEL_CATPT_CORE_H
#include <linux/dma/dw.h>
#include <linux/irqreturn.h>
#include "messages.h"
#include "registers.h"
struct catpt_dev;
extern const struct attribute_group *catpt_attr_groups[];
void catpt_sram_init(struct resource *sram, u32 start, u32 size);
void catpt_sram_free(struct resource *sram);
struct resource *
catpt_request_region(struct resource *root, resource_size_t size);
static inline bool catpt_resource_overlapping(struct resource *r1,
struct resource *r2,
struct resource *ret)
{
if (!resource_overlaps(r1, r2))
return false;
ret->start = max(r1->start, r2->start);
ret->end = min(r1->end, r2->end);
return true;
}
struct catpt_ipc_msg {
union {
u32 header;
union catpt_global_msg rsp;
};
void *data;
size_t size;
};
struct catpt_ipc {
struct device *dev;
struct catpt_ipc_msg rx;
struct catpt_fw_ready config;
u32 default_timeout;
bool ready;
spinlock_t lock;
struct mutex mutex;
struct completion done_completion;
struct completion busy_completion;
};
void catpt_ipc_init(struct catpt_ipc *ipc, struct device *dev);
struct catpt_module_type {
bool loaded;
u32 entry_point;
u32 persistent_size;
u32 scratch_size;
/* DRAM, initial module state */
u32 state_offset;
u32 state_size;
struct list_head node;
};
struct catpt_spec {
struct snd_soc_acpi_mach *machines;
u8 core_id;
u32 host_dram_offset;
u32 host_iram_offset;
u32 host_shim_offset;
u32 host_dma_offset[CATPT_DMA_COUNT];
u32 host_ssp_offset[CATPT_SSP_COUNT];
u32 dram_mask;
u32 iram_mask;
void (*pll_shutdown)(struct catpt_dev *cdev, bool enable);
int (*power_up)(struct catpt_dev *cdev);
int (*power_down)(struct catpt_dev *cdev);
};
struct catpt_dev {
struct device *dev;
struct dw_dma_chip *dmac;
struct catpt_ipc ipc;
void __iomem *pci_ba;
void __iomem *lpe_ba;
u32 lpe_base;
int irq;
const struct catpt_spec *spec;
struct completion fw_ready;
struct resource dram;
struct resource iram;
struct resource *scratch;
struct catpt_mixer_stream_info mixer;
struct catpt_module_type modules[CATPT_MODULE_COUNT];
struct catpt_ssp_device_format devfmt[CATPT_SSP_COUNT];
struct list_head stream_list;
spinlock_t list_lock;
struct mutex clk_mutex;
struct catpt_dx_context dx_ctx;
void *dxbuf_vaddr;
dma_addr_t dxbuf_paddr;
};
int catpt_dmac_probe(struct catpt_dev *cdev);
void catpt_dmac_remove(struct catpt_dev *cdev);
struct dma_chan *catpt_dma_request_config_chan(struct catpt_dev *cdev);
int catpt_dma_memcpy_todsp(struct catpt_dev *cdev, struct dma_chan *chan,
dma_addr_t dst_addr, dma_addr_t src_addr,
size_t size);
int catpt_dma_memcpy_fromdsp(struct catpt_dev *cdev, struct dma_chan *chan,
dma_addr_t dst_addr, dma_addr_t src_addr,
size_t size);
void lpt_dsp_pll_shutdown(struct catpt_dev *cdev, bool enable);
void wpt_dsp_pll_shutdown(struct catpt_dev *cdev, bool enable);
int lpt_dsp_power_up(struct catpt_dev *cdev);
int lpt_dsp_power_down(struct catpt_dev *cdev);
int wpt_dsp_power_up(struct catpt_dev *cdev);
int wpt_dsp_power_down(struct catpt_dev *cdev);
int catpt_dsp_stall(struct catpt_dev *cdev, bool stall);
void catpt_dsp_update_srampge(struct catpt_dev *cdev, struct resource *sram,
unsigned long mask);
int catpt_dsp_update_lpclock(struct catpt_dev *cdev);
irqreturn_t catpt_dsp_irq_handler(int irq, void *dev_id);
irqreturn_t catpt_dsp_irq_thread(int irq, void *dev_id);
/*
* IPC handlers may return positive values which denote successful
* HOST <-> DSP communication yet failure to process specific request.
* Use below macro to convert returned non-zero values appropriately
*/
#define CATPT_IPC_ERROR(err) (((err) < 0) ? (err) : -EREMOTEIO)
int catpt_dsp_send_msg_timeout(struct catpt_dev *cdev,
struct catpt_ipc_msg request,
struct catpt_ipc_msg *reply, int timeout);
int catpt_dsp_send_msg(struct catpt_dev *cdev, struct catpt_ipc_msg request,
struct catpt_ipc_msg *reply);
int catpt_first_boot_firmware(struct catpt_dev *cdev);
int catpt_boot_firmware(struct catpt_dev *cdev, bool restore);
int catpt_store_streams_context(struct catpt_dev *cdev, struct dma_chan *chan);
int catpt_store_module_states(struct catpt_dev *cdev, struct dma_chan *chan);
int catpt_store_memdumps(struct catpt_dev *cdev, struct dma_chan *chan);
int catpt_coredump(struct catpt_dev *cdev);
#include <sound/memalloc.h>
#include <uapi/sound/asound.h>
struct snd_pcm_substream;
struct catpt_stream_template;
struct catpt_stream_runtime {
struct snd_pcm_substream *substream;
struct catpt_stream_template *template;
struct catpt_stream_info info;
struct resource *persistent;
struct snd_dma_buffer pgtbl;
bool allocated;
bool prepared;
struct list_head node;
};
int catpt_register_plat_component(struct catpt_dev *cdev);
void catpt_stream_update_position(struct catpt_dev *cdev,
struct catpt_stream_runtime *stream,
struct catpt_notify_position *pos);
struct catpt_stream_runtime *
catpt_stream_find(struct catpt_dev *cdev, u8 stream_hw_id);
int catpt_arm_stream_templates(struct catpt_dev *cdev);
#endif
// SPDX-License-Identifier: GPL-2.0-only
//
// Copyright(c) 2020 Intel Corporation. All rights reserved.
//
// Author: Cezary Rojewski <cezary.rojewski@intel.com>
//
// Special thanks to:
// Marcin Barlik <marcin.barlik@intel.com>
// Piotr Papierkowski <piotr.papierkowski@intel.com>
//
// for sharing LPT-LP and WTP-LP AudioDSP architecture expertise and
// helping backtrack its historical background
//
#include <linux/acpi.h>
#include <linux/dma-mapping.h>
#include <linux/interrupt.h>
#include <linux/module.h>
#include <linux/pci.h>
#include <linux/platform_device.h>
#include <linux/pm_runtime.h>
#include <sound/soc.h>
#include <sound/soc-acpi.h>
#include <sound/soc-acpi-intel-match.h>
#include "core.h"
#include "registers.h"
#define CREATE_TRACE_POINTS
#include "trace.h"
static int __maybe_unused catpt_suspend(struct device *dev)
{
struct catpt_dev *cdev = dev_get_drvdata(dev);
struct dma_chan *chan;
int ret;
chan = catpt_dma_request_config_chan(cdev);
if (IS_ERR(chan))
return PTR_ERR(chan);
memset(&cdev->dx_ctx, 0, sizeof(cdev->dx_ctx));
ret = catpt_ipc_enter_dxstate(cdev, CATPT_DX_STATE_D3, &cdev->dx_ctx);
if (ret) {
ret = CATPT_IPC_ERROR(ret);
goto release_dma_chan;
}
ret = catpt_dsp_stall(cdev, true);
if (ret)
goto release_dma_chan;
ret = catpt_store_memdumps(cdev, chan);
if (ret) {
dev_err(cdev->dev, "store memdumps failed: %d\n", ret);
goto release_dma_chan;
}
ret = catpt_store_module_states(cdev, chan);
if (ret) {
dev_err(cdev->dev, "store module states failed: %d\n", ret);
goto release_dma_chan;
}
ret = catpt_store_streams_context(cdev, chan);
if (ret)
dev_err(cdev->dev, "store streams ctx failed: %d\n", ret);
release_dma_chan:
dma_release_channel(chan);
if (ret)
return ret;
return cdev->spec->power_down(cdev);
}
static int __maybe_unused catpt_resume(struct device *dev)
{
struct catpt_dev *cdev = dev_get_drvdata(dev);
int ret, i;
ret = cdev->spec->power_up(cdev);
if (ret)
return ret;
if (!module_is_live(dev->driver->owner)) {
dev_info(dev, "module unloading, skipping fw boot\n");
return 0;
}
ret = catpt_boot_firmware(cdev, true);
if (ret) {
dev_err(cdev->dev, "boot firmware failed: %d\n", ret);
return ret;
}
/* reconfigure SSP devices after Dx transition */
for (i = 0; i < CATPT_SSP_COUNT; i++) {
if (cdev->devfmt[i].iface == UINT_MAX)
continue;
ret = catpt_ipc_set_device_format(cdev, &cdev->devfmt[i]);
if (ret)
return CATPT_IPC_ERROR(ret);
}
return 0;
}
static int __maybe_unused catpt_runtime_suspend(struct device *dev)
{
if (!module_is_live(dev->driver->owner)) {
dev_info(dev, "module unloading, skipping suspend\n");
return 0;
}
return catpt_suspend(dev);
}
static int __maybe_unused catpt_runtime_resume(struct device *dev)
{
return catpt_resume(dev);
}
static const struct dev_pm_ops catpt_dev_pm = {
SET_SYSTEM_SLEEP_PM_OPS(catpt_suspend, catpt_resume)
SET_RUNTIME_PM_OPS(catpt_runtime_suspend, catpt_runtime_resume, NULL)
};
/* machine board owned by CATPT is removed with this hook */
static void board_pdev_unregister(void *data)
{
platform_device_unregister(data);
}
static int catpt_register_board(struct catpt_dev *cdev)
{
const struct catpt_spec *spec = cdev->spec;
struct snd_soc_acpi_mach *mach;
struct platform_device *board;
mach = snd_soc_acpi_find_machine(spec->machines);
if (!mach) {
dev_info(cdev->dev, "no machines present\n");
return 0;
}
mach->mach_params.platform = "catpt-platform";
board = platform_device_register_data(NULL, mach->drv_name,
PLATFORM_DEVID_NONE,
(const void *)mach, sizeof(*mach));
if (IS_ERR(board)) {
dev_err(cdev->dev, "board register failed\n");
return PTR_ERR(board);
}
return devm_add_action_or_reset(cdev->dev, board_pdev_unregister,
board);
}
static int catpt_probe_components(struct catpt_dev *cdev)
{
int ret;
ret = cdev->spec->power_up(cdev);
if (ret)
return ret;
ret = catpt_dmac_probe(cdev);
if (ret) {
dev_err(cdev->dev, "DMAC probe failed: %d\n", ret);
goto err_dmac_probe;
}
ret = catpt_first_boot_firmware(cdev);
if (ret) {
dev_err(cdev->dev, "first fw boot failed: %d\n", ret);
goto err_boot_fw;
}
ret = catpt_register_plat_component(cdev);
if (ret) {
dev_err(cdev->dev, "register plat comp failed: %d\n", ret);
goto err_boot_fw;
}
ret = catpt_register_board(cdev);
if (ret) {
dev_err(cdev->dev, "register board failed: %d\n", ret);
goto err_reg_board;
}
/* reflect actual ADSP state in pm_runtime */
pm_runtime_set_active(cdev->dev);
pm_runtime_set_autosuspend_delay(cdev->dev, 2000);
pm_runtime_use_autosuspend(cdev->dev);
pm_runtime_mark_last_busy(cdev->dev);
pm_runtime_enable(cdev->dev);
return 0;
err_reg_board:
snd_soc_unregister_component(cdev->dev);
err_boot_fw:
catpt_dmac_remove(cdev);
err_dmac_probe:
cdev->spec->power_down(cdev);
return ret;
}
static void catpt_dev_init(struct catpt_dev *cdev, struct device *dev,
const struct catpt_spec *spec)
{
cdev->dev = dev;
cdev->spec = spec;
init_completion(&cdev->fw_ready);
INIT_LIST_HEAD(&cdev->stream_list);
spin_lock_init(&cdev->list_lock);
mutex_init(&cdev->clk_mutex);
/*
* Mark both device formats as uninitialized. Once corresponding
* cpu_dai's pcm is created, proper values are assigned.
*/
cdev->devfmt[CATPT_SSP_IFACE_0].iface = UINT_MAX;
cdev->devfmt[CATPT_SSP_IFACE_1].iface = UINT_MAX;
catpt_ipc_init(&cdev->ipc, dev);
catpt_sram_init(&cdev->dram, spec->host_dram_offset,
catpt_dram_size(cdev));
catpt_sram_init(&cdev->iram, spec->host_iram_offset,
catpt_iram_size(cdev));
}
static int catpt_acpi_probe(struct platform_device *pdev)
{
const struct catpt_spec *spec;
struct catpt_dev *cdev;
struct device *dev = &pdev->dev;
struct resource *res;
int ret;
spec = device_get_match_data(dev);
if (!spec)
return -ENODEV;
cdev = devm_kzalloc(dev, sizeof(*cdev), GFP_KERNEL);
if (!cdev)
return -ENOMEM;
catpt_dev_init(cdev, dev, spec);
/* map DSP bar address */
cdev->lpe_ba = devm_platform_get_and_ioremap_resource(pdev, 0, &res);
if (IS_ERR(cdev->lpe_ba))
return PTR_ERR(cdev->lpe_ba);
cdev->lpe_base = res->start;
/* map PCI bar address */
cdev->pci_ba = devm_platform_ioremap_resource(pdev, 1);
if (IS_ERR(cdev->pci_ba))
return PTR_ERR(cdev->pci_ba);
/* alloc buffer for storing DRAM context during dx transitions */
cdev->dxbuf_vaddr = dmam_alloc_coherent(dev, catpt_dram_size(cdev),
&cdev->dxbuf_paddr, GFP_KERNEL);
if (!cdev->dxbuf_vaddr)
return -ENOMEM;
ret = platform_get_irq(pdev, 0);
if (ret < 0)
return ret;
cdev->irq = ret;
platform_set_drvdata(pdev, cdev);
ret = devm_request_threaded_irq(dev, cdev->irq, catpt_dsp_irq_handler,
catpt_dsp_irq_thread,
IRQF_SHARED, "AudioDSP", cdev);
if (ret)
return ret;
return catpt_probe_components(cdev);
}
static int catpt_acpi_remove(struct platform_device *pdev)
{
struct catpt_dev *cdev = platform_get_drvdata(pdev);
pm_runtime_disable(cdev->dev);
snd_soc_unregister_component(cdev->dev);
catpt_dmac_remove(cdev);
cdev->spec->power_down(cdev);
catpt_sram_free(&cdev->iram);
catpt_sram_free(&cdev->dram);
return 0;
}
static struct catpt_spec lpt_desc = {
.machines = snd_soc_acpi_intel_haswell_machines,
.core_id = 0x01,
.host_dram_offset = 0x000000,
.host_iram_offset = 0x080000,
.host_shim_offset = 0x0E7000,
.host_dma_offset = { 0x0F0000, 0x0F8000 },
.host_ssp_offset = { 0x0E8000, 0x0E9000 },
.dram_mask = LPT_VDRTCTL0_DSRAMPGE_MASK,
.iram_mask = LPT_VDRTCTL0_ISRAMPGE_MASK,
.pll_shutdown = lpt_dsp_pll_shutdown,
.power_up = lpt_dsp_power_up,
.power_down = lpt_dsp_power_down,
};
static struct catpt_spec wpt_desc = {
.machines = snd_soc_acpi_intel_broadwell_machines,
.core_id = 0x02,
.host_dram_offset = 0x000000,
.host_iram_offset = 0x0A0000,
.host_shim_offset = 0x0FB000,
.host_dma_offset = { 0x0FE000, 0x0FF000 },
.host_ssp_offset = { 0x0FC000, 0x0FD000 },
.dram_mask = WPT_VDRTCTL0_DSRAMPGE_MASK,
.iram_mask = WPT_VDRTCTL0_ISRAMPGE_MASK,
.pll_shutdown = wpt_dsp_pll_shutdown,
.power_up = wpt_dsp_power_up,
.power_down = wpt_dsp_power_down,
};
static const struct acpi_device_id catpt_ids[] = {
{ "INT33C8", (unsigned long)&lpt_desc },
{ "INT3438", (unsigned long)&wpt_desc },
{ }
};
MODULE_DEVICE_TABLE(acpi, catpt_ids);
static struct platform_driver catpt_acpi_driver = {
.probe = catpt_acpi_probe,
.remove = catpt_acpi_remove,
.driver = {
.name = "intel_catpt",
.acpi_match_table = catpt_ids,
.pm = &catpt_dev_pm,
.dev_groups = catpt_attr_groups,
},
};
module_platform_driver(catpt_acpi_driver);
MODULE_AUTHOR("Cezary Rojewski <cezary.rojewski@intel.com>");
MODULE_DESCRIPTION("Intel LPT/WPT AudioDSP driver");
MODULE_LICENSE("GPL v2");
This diff is collapsed.
// SPDX-License-Identifier: GPL-2.0-only
//
// Copyright(c) 2020 Intel Corporation. All rights reserved.
//
// Author: Cezary Rojewski <cezary.rojewski@intel.com>
//
#include <linux/irqreturn.h>
#include "core.h"
#include "messages.h"
#include "registers.h"
#include "trace.h"
#define CATPT_IPC_TIMEOUT_MS 300
void catpt_ipc_init(struct catpt_ipc *ipc, struct device *dev)
{
ipc->dev = dev;
ipc->ready = false;
ipc->default_timeout = CATPT_IPC_TIMEOUT_MS;
init_completion(&ipc->done_completion);
init_completion(&ipc->busy_completion);
spin_lock_init(&ipc->lock);
mutex_init(&ipc->mutex);
}
static int catpt_ipc_arm(struct catpt_ipc *ipc, struct catpt_fw_ready *config)
{
/*
* Both tx and rx are put into and received from outbox. Inbox is
* only used for notifications where payload size is known upfront,
* thus no separate buffer is allocated for it.
*/
ipc->rx.data = devm_kzalloc(ipc->dev, config->outbox_size, GFP_KERNEL);
if (!ipc->rx.data)
return -ENOMEM;
memcpy(&ipc->config, config, sizeof(*config));
ipc->ready = true;
return 0;
}
static void catpt_ipc_msg_init(struct catpt_ipc *ipc,
struct catpt_ipc_msg *reply)
{
lockdep_assert_held(&ipc->lock);
ipc->rx.header = 0;
ipc->rx.size = reply ? reply->size : 0;
reinit_completion(&ipc->done_completion);
reinit_completion(&ipc->busy_completion);
}
static void catpt_dsp_send_tx(struct catpt_dev *cdev,
const struct catpt_ipc_msg *tx)
{
u32 header = tx->header | CATPT_IPCC_BUSY;
trace_catpt_ipc_request(header);
trace_catpt_ipc_payload(tx->data, tx->size);
memcpy_toio(catpt_outbox_addr(cdev), tx->data, tx->size);
catpt_writel_shim(cdev, IPCC, header);
}
static int catpt_wait_msg_completion(struct catpt_dev *cdev, int timeout)
{
struct catpt_ipc *ipc = &cdev->ipc;
int ret;
ret = wait_for_completion_timeout(&ipc->done_completion,
msecs_to_jiffies(timeout));
if (!ret)
return -ETIMEDOUT;
if (ipc->rx.rsp.status != CATPT_REPLY_PENDING)
return 0;
/* wait for delayed reply */
ret = wait_for_completion_timeout(&ipc->busy_completion,
msecs_to_jiffies(timeout));
return ret ? 0 : -ETIMEDOUT;
}
static int catpt_dsp_do_send_msg(struct catpt_dev *cdev,
struct catpt_ipc_msg request,
struct catpt_ipc_msg *reply, int timeout)
{
struct catpt_ipc *ipc = &cdev->ipc;
unsigned long flags;
int ret;
if (!ipc->ready)
return -EPERM;
if (request.size > ipc->config.outbox_size ||
(reply && reply->size > ipc->config.outbox_size))
return -EINVAL;
spin_lock_irqsave(&ipc->lock, flags);
catpt_ipc_msg_init(ipc, reply);
catpt_dsp_send_tx(cdev, &request);
spin_unlock_irqrestore(&ipc->lock, flags);
ret = catpt_wait_msg_completion(cdev, timeout);
if (ret) {
dev_crit(cdev->dev, "communication severed: %d, rebooting dsp..\n",
ret);
ipc->ready = false;
/* TODO: attempt recovery */
return ret;
}
ret = ipc->rx.rsp.status;
if (reply) {
reply->header = ipc->rx.header;
if (!ret && reply->data)
memcpy(reply->data, ipc->rx.data, reply->size);
}
return ret;
}
int catpt_dsp_send_msg_timeout(struct catpt_dev *cdev,
struct catpt_ipc_msg request,
struct catpt_ipc_msg *reply, int timeout)
{
struct catpt_ipc *ipc = &cdev->ipc;
int ret;
mutex_lock(&ipc->mutex);
ret = catpt_dsp_do_send_msg(cdev, request, reply, timeout);
mutex_unlock(&ipc->mutex);
return ret;
}
int catpt_dsp_send_msg(struct catpt_dev *cdev, struct catpt_ipc_msg request,
struct catpt_ipc_msg *reply)
{
return catpt_dsp_send_msg_timeout(cdev, request, reply,
cdev->ipc.default_timeout);
}
static void
catpt_dsp_notify_stream(struct catpt_dev *cdev, union catpt_notify_msg msg)
{
struct catpt_stream_runtime *stream;
struct catpt_notify_position pos;
struct catpt_notify_glitch glitch;
stream = catpt_stream_find(cdev, msg.stream_hw_id);
if (!stream) {
dev_warn(cdev->dev, "notify %d for non-existent stream %d\n",
msg.notify_reason, msg.stream_hw_id);
return;
}
switch (msg.notify_reason) {
case CATPT_NOTIFY_POSITION_CHANGED:
memcpy_fromio(&pos, catpt_inbox_addr(cdev), sizeof(pos));
trace_catpt_ipc_payload((u8 *)&pos, sizeof(pos));
catpt_stream_update_position(cdev, stream, &pos);
break;
case CATPT_NOTIFY_GLITCH_OCCURRED:
memcpy_fromio(&glitch, catpt_inbox_addr(cdev), sizeof(glitch));
trace_catpt_ipc_payload((u8 *)&glitch, sizeof(glitch));
dev_warn(cdev->dev, "glitch %d at pos: 0x%08llx, wp: 0x%08x\n",
glitch.type, glitch.presentation_pos,
glitch.write_pos);
break;
default:
dev_warn(cdev->dev, "unknown notification: %d received\n",
msg.notify_reason);
break;
}
}
static void catpt_dsp_copy_rx(struct catpt_dev *cdev, u32 header)
{
struct catpt_ipc *ipc = &cdev->ipc;
ipc->rx.header = header;
if (ipc->rx.rsp.status != CATPT_REPLY_SUCCESS)
return;
memcpy_fromio(ipc->rx.data, catpt_outbox_addr(cdev), ipc->rx.size);
trace_catpt_ipc_payload(ipc->rx.data, ipc->rx.size);
}
static void catpt_dsp_process_response(struct catpt_dev *cdev, u32 header)
{
union catpt_notify_msg msg = CATPT_MSG(header);
struct catpt_ipc *ipc = &cdev->ipc;
if (msg.fw_ready) {
struct catpt_fw_ready config;
/* to fit 32b header original address is shifted right by 3 */
u32 off = msg.mailbox_address << 3;
memcpy_fromio(&config, cdev->lpe_ba + off, sizeof(config));
trace_catpt_ipc_payload((u8 *)&config, sizeof(config));
catpt_ipc_arm(ipc, &config);
complete(&cdev->fw_ready);
return;
}
switch (msg.global_msg_type) {
case CATPT_GLB_REQUEST_CORE_DUMP:
dev_err(cdev->dev, "ADSP device coredump received\n");
ipc->ready = false;
catpt_coredump(cdev);
/* TODO: attempt recovery */
break;
case CATPT_GLB_STREAM_MESSAGE:
switch (msg.stream_msg_type) {
case CATPT_STRM_NOTIFICATION:
catpt_dsp_notify_stream(cdev, msg);
break;
default:
catpt_dsp_copy_rx(cdev, header);
/* signal completion of delayed reply */
complete(&ipc->busy_completion);
break;
}
break;
default:
dev_warn(cdev->dev, "unknown response: %d received\n",
msg.global_msg_type);
break;
}
}
irqreturn_t catpt_dsp_irq_thread(int irq, void *dev_id)
{
struct catpt_dev *cdev = dev_id;
u32 ipcd;
ipcd = catpt_readl_shim(cdev, IPCD);
trace_catpt_ipc_notify(ipcd);
/* ensure there is delayed reply or notification to process */
if (!(ipcd & CATPT_IPCD_BUSY))
return IRQ_NONE;
catpt_dsp_process_response(cdev, ipcd);
/* tell DSP processing is completed */
catpt_updatel_shim(cdev, IPCD, CATPT_IPCD_BUSY | CATPT_IPCD_DONE,
CATPT_IPCD_DONE);
/* unmask dsp BUSY interrupt */
catpt_updatel_shim(cdev, IMC, CATPT_IMC_IPCDB, 0);
return IRQ_HANDLED;
}
irqreturn_t catpt_dsp_irq_handler(int irq, void *dev_id)
{
struct catpt_dev *cdev = dev_id;
irqreturn_t ret = IRQ_NONE;
u32 isc, ipcc;
isc = catpt_readl_shim(cdev, ISC);
trace_catpt_irq(isc);
/* immediate reply */
if (isc & CATPT_ISC_IPCCD) {
/* mask host DONE interrupt */
catpt_updatel_shim(cdev, IMC, CATPT_IMC_IPCCD, CATPT_IMC_IPCCD);
ipcc = catpt_readl_shim(cdev, IPCC);
trace_catpt_ipc_reply(ipcc);
catpt_dsp_copy_rx(cdev, ipcc);
complete(&cdev->ipc.done_completion);
/* tell DSP processing is completed */
catpt_updatel_shim(cdev, IPCC, CATPT_IPCC_DONE, 0);
/* unmask host DONE interrupt */
catpt_updatel_shim(cdev, IMC, CATPT_IMC_IPCCD, 0);
ret = IRQ_HANDLED;
}
/* delayed reply or notification */
if (isc & CATPT_ISC_IPCDB) {
/* mask dsp BUSY interrupt */
catpt_updatel_shim(cdev, IMC, CATPT_IMC_IPCDB, CATPT_IMC_IPCDB);
ret = IRQ_WAKE_THREAD;
}
return ret;
}
This diff is collapsed.
// SPDX-License-Identifier: GPL-2.0-only
//
// Copyright(c) 2020 Intel Corporation. All rights reserved.
//
// Author: Cezary Rojewski <cezary.rojewski@intel.com>
//
#include <linux/slab.h>
#include "core.h"
#include "messages.h"
#include "registers.h"
int catpt_ipc_get_fw_version(struct catpt_dev *cdev,
struct catpt_fw_version *version)
{
union catpt_global_msg msg = CATPT_GLOBAL_MSG(GET_FW_VERSION);
struct catpt_ipc_msg request = {{0}}, reply;
int ret;
request.header = msg.val;
reply.size = sizeof(*version);
reply.data = version;
ret = catpt_dsp_send_msg(cdev, request, &reply);
if (ret)
dev_err(cdev->dev, "get fw version failed: %d\n", ret);
return ret;
}
struct catpt_alloc_stream_input {
enum catpt_path_id path_id:8;
enum catpt_stream_type stream_type:8;
enum catpt_format_id format_id:8;
u8 reserved;
struct catpt_audio_format input_format;
struct catpt_ring_info ring_info;
u8 num_entries;
/* flex array with entries here */
struct catpt_memory_info persistent_mem;
struct catpt_memory_info scratch_mem;
u32 num_notifications; /* obsolete */
} __packed;
int catpt_ipc_alloc_stream(struct catpt_dev *cdev,
enum catpt_path_id path_id,
enum catpt_stream_type type,
struct catpt_audio_format *afmt,
struct catpt_ring_info *rinfo,
u8 num_modules,
struct catpt_module_entry *modules,
struct resource *persistent,
struct resource *scratch,
struct catpt_stream_info *sinfo)
{
union catpt_global_msg msg = CATPT_GLOBAL_MSG(ALLOCATE_STREAM);
struct catpt_alloc_stream_input input;
struct catpt_ipc_msg request, reply;
size_t size, arrsz;
u8 *payload;
off_t off;
int ret;
off = offsetof(struct catpt_alloc_stream_input, persistent_mem);
arrsz = sizeof(*modules) * num_modules;
size = sizeof(input) + arrsz;
payload = kzalloc(size, GFP_KERNEL);
if (!payload)
return -ENOMEM;
memset(&input, 0, sizeof(input));
input.path_id = path_id;
input.stream_type = type;
input.format_id = CATPT_FORMAT_PCM;
input.input_format = *afmt;
input.ring_info = *rinfo;
input.num_entries = num_modules;
input.persistent_mem.offset = catpt_to_dsp_offset(persistent->start);
input.persistent_mem.size = resource_size(persistent);
if (scratch) {
input.scratch_mem.offset = catpt_to_dsp_offset(scratch->start);
input.scratch_mem.size = resource_size(scratch);
}
/* re-arrange the input: account for flex array 'entries' */
memcpy(payload, &input, sizeof(input));
memmove(payload + off + arrsz, payload + off, sizeof(input) - off);
memcpy(payload + off, modules, arrsz);
request.header = msg.val;
request.size = size;
request.data = payload;
reply.size = sizeof(*sinfo);
reply.data = sinfo;
ret = catpt_dsp_send_msg(cdev, request, &reply);
if (ret)
dev_err(cdev->dev, "alloc stream type %d failed: %d\n",
type, ret);
kfree(payload);
return ret;
}
int catpt_ipc_free_stream(struct catpt_dev *cdev, u8 stream_hw_id)
{
union catpt_global_msg msg = CATPT_GLOBAL_MSG(FREE_STREAM);
struct catpt_ipc_msg request;
int ret;
request.header = msg.val;
request.size = sizeof(stream_hw_id);
request.data = &stream_hw_id;
ret = catpt_dsp_send_msg(cdev, request, NULL);
if (ret)
dev_err(cdev->dev, "free stream %d failed: %d\n",
stream_hw_id, ret);
return ret;
}
int catpt_ipc_set_device_format(struct catpt_dev *cdev,
struct catpt_ssp_device_format *devfmt)
{
union catpt_global_msg msg = CATPT_GLOBAL_MSG(SET_DEVICE_FORMATS);
struct catpt_ipc_msg request;
int ret;
request.header = msg.val;
request.size = sizeof(*devfmt);
request.data = devfmt;
ret = catpt_dsp_send_msg(cdev, request, NULL);
if (ret)
dev_err(cdev->dev, "set device format failed: %d\n", ret);
return ret;
}
int catpt_ipc_enter_dxstate(struct catpt_dev *cdev, enum catpt_dx_state state,
struct catpt_dx_context *context)
{
union catpt_global_msg msg = CATPT_GLOBAL_MSG(ENTER_DX_STATE);
struct catpt_ipc_msg request, reply;
int ret;
request.header = msg.val;
request.size = sizeof(state);
request.data = &state;
reply.size = sizeof(*context);
reply.data = context;
ret = catpt_dsp_send_msg(cdev, request, &reply);
if (ret)
dev_err(cdev->dev, "enter dx state failed: %d\n", ret);
return ret;
}
int catpt_ipc_get_mixer_stream_info(struct catpt_dev *cdev,
struct catpt_mixer_stream_info *info)
{
union catpt_global_msg msg = CATPT_GLOBAL_MSG(GET_MIXER_STREAM_INFO);
struct catpt_ipc_msg request = {{0}}, reply;
int ret;
request.header = msg.val;
reply.size = sizeof(*info);
reply.data = info;
ret = catpt_dsp_send_msg(cdev, request, &reply);
if (ret)
dev_err(cdev->dev, "get mixer info failed: %d\n", ret);
return ret;
}
int catpt_ipc_reset_stream(struct catpt_dev *cdev, u8 stream_hw_id)
{
union catpt_stream_msg msg = CATPT_STREAM_MSG(RESET_STREAM);
struct catpt_ipc_msg request = {{0}};
int ret;
msg.stream_hw_id = stream_hw_id;
request.header = msg.val;
ret = catpt_dsp_send_msg(cdev, request, NULL);
if (ret)
dev_err(cdev->dev, "reset stream %d failed: %d\n",
stream_hw_id, ret);
return ret;
}
int catpt_ipc_pause_stream(struct catpt_dev *cdev, u8 stream_hw_id)
{
union catpt_stream_msg msg = CATPT_STREAM_MSG(PAUSE_STREAM);
struct catpt_ipc_msg request = {{0}};
int ret;
msg.stream_hw_id = stream_hw_id;
request.header = msg.val;
ret = catpt_dsp_send_msg(cdev, request, NULL);
if (ret)
dev_err(cdev->dev, "pause stream %d failed: %d\n",
stream_hw_id, ret);
return ret;
}
int catpt_ipc_resume_stream(struct catpt_dev *cdev, u8 stream_hw_id)
{
union catpt_stream_msg msg = CATPT_STREAM_MSG(RESUME_STREAM);
struct catpt_ipc_msg request = {{0}};
int ret;
msg.stream_hw_id = stream_hw_id;
request.header = msg.val;
ret = catpt_dsp_send_msg(cdev, request, NULL);
if (ret)
dev_err(cdev->dev, "resume stream %d failed: %d\n",
stream_hw_id, ret);
return ret;
}
struct catpt_set_volume_input {
u32 channel;
u32 target_volume;
u64 curve_duration;
u32 curve_type;
} __packed;
int catpt_ipc_set_volume(struct catpt_dev *cdev, u8 stream_hw_id,
u32 channel, u32 volume,
u32 curve_duration,
enum catpt_audio_curve_type curve_type)
{
union catpt_stream_msg msg = CATPT_STAGE_MSG(SET_VOLUME);
struct catpt_ipc_msg request;
struct catpt_set_volume_input input;
int ret;
msg.stream_hw_id = stream_hw_id;
input.channel = channel;
input.target_volume = volume;
input.curve_duration = curve_duration;
input.curve_type = curve_type;
request.header = msg.val;
request.size = sizeof(input);
request.data = &input;
ret = catpt_dsp_send_msg(cdev, request, NULL);
if (ret)
dev_err(cdev->dev, "set stream %d volume failed: %d\n",
stream_hw_id, ret);
return ret;
}
struct catpt_set_write_pos_input {
u32 new_write_pos;
bool end_of_buffer;
bool low_latency;
} __packed;
int catpt_ipc_set_write_pos(struct catpt_dev *cdev, u8 stream_hw_id,
u32 pos, bool eob, bool ll)
{
union catpt_stream_msg msg = CATPT_STAGE_MSG(SET_WRITE_POSITION);
struct catpt_ipc_msg request;
struct catpt_set_write_pos_input input;
int ret;
msg.stream_hw_id = stream_hw_id;
input.new_write_pos = pos;
input.end_of_buffer = eob;
input.low_latency = ll;
request.header = msg.val;
request.size = sizeof(input);
request.data = &input;
ret = catpt_dsp_send_msg(cdev, request, NULL);
if (ret)
dev_err(cdev->dev, "set stream %d write pos failed: %d\n",
stream_hw_id, ret);
return ret;
}
int catpt_ipc_mute_loopback(struct catpt_dev *cdev, u8 stream_hw_id, bool mute)
{
union catpt_stream_msg msg = CATPT_STAGE_MSG(MUTE_LOOPBACK);
struct catpt_ipc_msg request;
int ret;
msg.stream_hw_id = stream_hw_id;
request.header = msg.val;
request.size = sizeof(mute);
request.data = &mute;
ret = catpt_dsp_send_msg(cdev, request, NULL);
if (ret)
dev_err(cdev->dev, "mute loopback failed: %d\n", ret);
return ret;
}
/* SPDX-License-Identifier: GPL-2.0-only */
/*
* Copyright(c) 2020 Intel Corporation. All rights reserved.
*
* Author: Cezary Rojewski <cezary.rojewski@intel.com>
*/
#ifndef __SND_SOC_INTEL_CATPT_MSG_H
#define __SND_SOC_INTEL_CATPT_MSG_H
struct catpt_dev;
/* IPC messages base types */
enum catpt_reply_status {
CATPT_REPLY_SUCCESS = 0,
CATPT_REPLY_ERROR_INVALID_PARAM = 1,
CATPT_REPLY_UNKNOWN_MESSAGE_TYPE = 2,
CATPT_REPLY_OUT_OF_RESOURCES = 3,
CATPT_REPLY_BUSY = 4,
CATPT_REPLY_PENDING = 5,
CATPT_REPLY_FAILURE = 6,
CATPT_REPLY_INVALID_REQUEST = 7,
CATPT_REPLY_UNINITIALIZED = 8,
CATPT_REPLY_NOT_FOUND = 9,
CATPT_REPLY_SOURCE_NOT_STARTED = 10,
};
/* GLOBAL messages */
enum catpt_global_msg_type {
CATPT_GLB_GET_FW_VERSION = 0,
CATPT_GLB_ALLOCATE_STREAM = 3,
CATPT_GLB_FREE_STREAM = 4,
CATPT_GLB_STREAM_MESSAGE = 6,
CATPT_GLB_REQUEST_CORE_DUMP = 7,
CATPT_GLB_SET_DEVICE_FORMATS = 10,
CATPT_GLB_ENTER_DX_STATE = 12,
CATPT_GLB_GET_MIXER_STREAM_INFO = 13,
};
union catpt_global_msg {
u32 val;
struct {
u32 status:5;
u32 context:19; /* stream or module specific */
u32 global_msg_type:5;
u32 fw_ready:1;
u32 done:1;
u32 busy:1;
};
} __packed;
#define CATPT_MSG(hdr) { .val = hdr }
#define CATPT_GLOBAL_MSG(msg_type) \
{ .global_msg_type = CATPT_GLB_##msg_type }
#define BUILD_HASH_SIZE 40
struct catpt_fw_version {
u8 build;
u8 minor;
u8 major;
u8 type;
u8 build_hash[BUILD_HASH_SIZE];
u32 log_providers_hash;
} __packed;
int catpt_ipc_get_fw_version(struct catpt_dev *cdev,
struct catpt_fw_version *version);
enum catpt_pin_id {
CATPT_PIN_ID_SYSTEM = 0,
CATPT_PIN_ID_REFERENCE = 1,
CATPT_PIN_ID_CAPTURE1 = 2,
CATPT_PIN_ID_CAPTURE2 = 3,
CATPT_PIN_ID_OFFLOAD1 = 4,
CATPT_PIN_ID_OFFLOAD2 = 5,
CATPT_PIN_ID_MIXER = 7,
CATPT_PIN_ID_BLUETOOTH_CAPTURE = 8,
CATPT_PIN_ID_BLUETOOTH_RENDER = 9,
};
enum catpt_path_id {
CATPT_PATH_SSP0_OUT = 0,
CATPT_PATH_SSP0_IN = 1,
CATPT_PATH_SSP1_OUT = 2,
CATPT_PATH_SSP1_IN = 3,
/* duplicated audio in capture path */
CATPT_PATH_SSP0_IN_DUP = 4,
};
enum catpt_stream_type {
CATPT_STRM_TYPE_RENDER = 0, /* offload */
CATPT_STRM_TYPE_SYSTEM = 1,
CATPT_STRM_TYPE_CAPTURE = 2,
CATPT_STRM_TYPE_LOOPBACK = 3,
CATPT_STRM_TYPE_BLUETOOTH_RENDER = 4,
CATPT_STRM_TYPE_BLUETOOTH_CAPTURE = 5,
};
enum catpt_format_id {
CATPT_FORMAT_PCM = 0,
CATPT_FORMAT_MP3 = 1,
CATPT_FORMAT_AAC = 2,
CATPT_FORMAT_WMA = 3,
};
enum catpt_channel_index {
CATPT_CHANNEL_LEFT = 0x0,
CATPT_CHANNEL_CENTER = 0x1,
CATPT_CHANNEL_RIGHT = 0x2,
CATPT_CHANNEL_LEFT_SURROUND = 0x3,
CATPT_CHANNEL_CENTER_SURROUND = 0x3,
CATPT_CHANNEL_RIGHT_SURROUND = 0x4,
CATPT_CHANNEL_LFE = 0x7,
CATPT_CHANNEL_INVALID = 0xF,
};
enum catpt_channel_config {
CATPT_CHANNEL_CONFIG_MONO = 0, /* One channel only */
CATPT_CHANNEL_CONFIG_STEREO = 1, /* L & R */
CATPT_CHANNEL_CONFIG_2_POINT_1 = 2, /* L, R & LFE; PCM only */
CATPT_CHANNEL_CONFIG_3_POINT_0 = 3, /* L, C & R; MP3 & AAC only */
CATPT_CHANNEL_CONFIG_3_POINT_1 = 4, /* L, C, R & LFE; PCM only */
CATPT_CHANNEL_CONFIG_QUATRO = 5, /* L, R, Ls & Rs; PCM only */
CATPT_CHANNEL_CONFIG_4_POINT_0 = 6, /* L, C, R & Cs; MP3 & AAC only */
CATPT_CHANNEL_CONFIG_5_POINT_0 = 7, /* L, C, R, Ls & Rs */
CATPT_CHANNEL_CONFIG_5_POINT_1 = 8, /* L, C, R, Ls, Rs & LFE */
CATPT_CHANNEL_CONFIG_DUAL_MONO = 9, /* One channel replicated in two */
CATPT_CHANNEL_CONFIG_INVALID = 10,
};
enum catpt_interleaving_style {
CATPT_INTERLEAVING_PER_CHANNEL = 0,
CATPT_INTERLEAVING_PER_SAMPLE = 1,
};
struct catpt_audio_format {
u32 sample_rate;
u32 bit_depth;
u32 channel_map;
u32 channel_config;
u32 interleaving;
u8 num_channels;
u8 valid_bit_depth;
u8 reserved[2];
} __packed;
struct catpt_ring_info {
u32 page_table_addr;
u32 num_pages;
u32 size;
u32 offset;
u32 ring_first_page_pfn;
} __packed;
#define CATPT_MODULE_COUNT (CATPT_MODID_LAST + 1)
enum catpt_module_id {
CATPT_MODID_BASE_FW = 0x0,
CATPT_MODID_MP3 = 0x1,
CATPT_MODID_AAC_5_1 = 0x2,
CATPT_MODID_AAC_2_0 = 0x3,
CATPT_MODID_SRC = 0x4,
CATPT_MODID_WAVES = 0x5,
CATPT_MODID_DOLBY = 0x6,
CATPT_MODID_BOOST = 0x7,
CATPT_MODID_LPAL = 0x8,
CATPT_MODID_DTS = 0x9,
CATPT_MODID_PCM_CAPTURE = 0xA,
CATPT_MODID_PCM_SYSTEM = 0xB,
CATPT_MODID_PCM_REFERENCE = 0xC,
CATPT_MODID_PCM = 0xD, /* offload */
CATPT_MODID_BLUETOOTH_RENDER = 0xE,
CATPT_MODID_BLUETOOTH_CAPTURE = 0xF,
CATPT_MODID_LAST = CATPT_MODID_BLUETOOTH_CAPTURE,
};
struct catpt_module_entry {
u32 module_id;
u32 entry_point;
} __packed;
struct catpt_module_map {
u8 num_entries;
struct catpt_module_entry entries[];
} __packed;
struct catpt_memory_info {
u32 offset;
u32 size;
} __packed;
#define CATPT_CHANNELS_MAX 4
#define CATPT_ALL_CHANNELS_MASK UINT_MAX
struct catpt_stream_info {
u32 stream_hw_id;
u32 reserved;
u32 read_pos_regaddr;
u32 pres_pos_regaddr;
u32 peak_meter_regaddr[CATPT_CHANNELS_MAX];
u32 volume_regaddr[CATPT_CHANNELS_MAX];
} __packed;
int catpt_ipc_alloc_stream(struct catpt_dev *cdev,
enum catpt_path_id path_id,
enum catpt_stream_type type,
struct catpt_audio_format *afmt,
struct catpt_ring_info *rinfo,
u8 num_modules,
struct catpt_module_entry *modules,
struct resource *persistent,
struct resource *scratch,
struct catpt_stream_info *sinfo);
int catpt_ipc_free_stream(struct catpt_dev *cdev, u8 stream_hw_id);
enum catpt_ssp_iface {
CATPT_SSP_IFACE_0 = 0,
CATPT_SSP_IFACE_1 = 1,
CATPT_SSP_IFACE_LAST = CATPT_SSP_IFACE_1,
};
#define CATPT_SSP_COUNT (CATPT_SSP_IFACE_LAST + 1)
enum catpt_mclk_frequency {
CATPT_MCLK_OFF = 0,
CATPT_MCLK_FREQ_6_MHZ = 1,
CATPT_MCLK_FREQ_21_MHZ = 2,
CATPT_MCLK_FREQ_24_MHZ = 3,
};
enum catpt_ssp_mode {
CATPT_SSP_MODE_I2S_CONSUMER = 0,
CATPT_SSP_MODE_I2S_PROVIDER = 1,
CATPT_SSP_MODE_TDM_PROVIDER = 2,
};
struct catpt_ssp_device_format {
u32 iface;
u32 mclk;
u32 mode;
u16 clock_divider;
u8 channels;
} __packed;
int catpt_ipc_set_device_format(struct catpt_dev *cdev,
struct catpt_ssp_device_format *devfmt);
enum catpt_dx_state {
CATPT_DX_STATE_D3 = 3,
};
enum catpt_dx_type {
CATPT_DX_TYPE_FW_IMAGE = 0,
CATPT_DX_TYPE_MEMORY_DUMP = 1,
};
struct catpt_save_meminfo {
u32 offset;
u32 size;
u32 source;
} __packed;
#define SAVE_MEMINFO_MAX 14
struct catpt_dx_context {
u32 num_meminfo;
struct catpt_save_meminfo meminfo[SAVE_MEMINFO_MAX];
} __packed;
int catpt_ipc_enter_dxstate(struct catpt_dev *cdev, enum catpt_dx_state state,
struct catpt_dx_context *context);
struct catpt_mixer_stream_info {
u32 mixer_hw_id;
u32 peak_meter_regaddr[CATPT_CHANNELS_MAX];
u32 volume_regaddr[CATPT_CHANNELS_MAX];
} __packed;
int catpt_ipc_get_mixer_stream_info(struct catpt_dev *cdev,
struct catpt_mixer_stream_info *info);
/* STREAM messages */
enum catpt_stream_msg_type {
CATPT_STRM_RESET_STREAM = 0,
CATPT_STRM_PAUSE_STREAM = 1,
CATPT_STRM_RESUME_STREAM = 2,
CATPT_STRM_STAGE_MESSAGE = 3,
CATPT_STRM_NOTIFICATION = 4,
};
enum catpt_stage_action {
CATPT_STG_SET_VOLUME = 1,
CATPT_STG_SET_WRITE_POSITION = 2,
CATPT_STG_MUTE_LOOPBACK = 3,
};
union catpt_stream_msg {
u32 val;
struct {
u32 status:5;
u32 reserved:7;
u32 stage_action:4;
u32 stream_hw_id:4;
u32 stream_msg_type:4;
u32 global_msg_type:5;
u32 fw_ready:1;
u32 done:1;
u32 busy:1;
};
} __packed;
#define CATPT_STREAM_MSG(msg_type) \
{ \
.stream_msg_type = CATPT_STRM_##msg_type, \
.global_msg_type = CATPT_GLB_STREAM_MESSAGE }
#define CATPT_STAGE_MSG(msg_type) \
{ \
.stage_action = CATPT_STG_##msg_type, \
.stream_msg_type = CATPT_STRM_STAGE_MESSAGE, \
.global_msg_type = CATPT_GLB_STREAM_MESSAGE }
int catpt_ipc_reset_stream(struct catpt_dev *cdev, u8 stream_hw_id);
int catpt_ipc_pause_stream(struct catpt_dev *cdev, u8 stream_hw_id);
int catpt_ipc_resume_stream(struct catpt_dev *cdev, u8 stream_hw_id);
/* STREAM messages - STAGE subtype */
enum catpt_audio_curve_type {
CATPT_AUDIO_CURVE_NONE = 0,
CATPT_AUDIO_CURVE_WINDOWS_FADE = 1,
};
int catpt_ipc_set_volume(struct catpt_dev *cdev, u8 stream_hw_id,
u32 channel, u32 volume,
u32 curve_duration,
enum catpt_audio_curve_type curve_type);
int catpt_ipc_set_write_pos(struct catpt_dev *cdev, u8 stream_hw_id,
u32 pos, bool eob, bool ll);
int catpt_ipc_mute_loopback(struct catpt_dev *cdev, u8 stream_hw_id, bool mute);
/* NOTIFICATION messages */
enum catpt_notify_reason {
CATPT_NOTIFY_POSITION_CHANGED = 0,
CATPT_NOTIFY_GLITCH_OCCURRED = 1,
};
union catpt_notify_msg {
u32 val;
struct {
u32 mailbox_address:29;
u32 fw_ready:1;
u32 done:1;
u32 busy:1;
};
struct {
u32 status:5;
u32 reserved:7;
u32 notify_reason:4;
u32 stream_hw_id:4;
u32 stream_msg_type:4;
u32 global_msg_type:5;
u32 hdr:3; /* fw_ready, done, busy */
};
} __packed;
#define FW_INFO_SIZE_MAX 100
struct catpt_fw_ready {
u32 inbox_offset;
u32 outbox_offset;
u32 inbox_size;
u32 outbox_size;
u32 fw_info_size;
char fw_info[FW_INFO_SIZE_MAX];
} __packed;
struct catpt_notify_position {
u32 stream_position;
u32 fw_cycle_count;
} __packed;
enum catpt_glitch_type {
CATPT_GLITCH_UNDERRUN = 1,
CATPT_GLITCH_DECODER_ERROR = 2,
CATPT_GLITCH_DOUBLED_WRITE_POS = 3,
};
struct catpt_notify_glitch {
u32 type;
u64 presentation_pos;
u32 write_pos;
} __packed;
#endif
This diff is collapsed.
/* SPDX-License-Identifier: GPL-2.0-only */
/*
* Copyright(c) 2020 Intel Corporation. All rights reserved.
*
* Author: Cezary Rojewski <cezary.rojewski@intel.com>
*/
#ifndef __SND_SOC_INTEL_CATPT_REGS_H
#define __SND_SOC_INTEL_CATPT_REGS_H
#include <linux/bitops.h>
#include <linux/iopoll.h>
#include <uapi/linux/pci_regs.h>
#define CATPT_SHIM_REGS_SIZE 4096
#define CATPT_DMA_REGS_SIZE 1024
#define CATPT_DMA_COUNT 2
#define CATPT_SSP_REGS_SIZE 512
/* DSP Shim registers */
#define CATPT_SHIM_CS1 0x00
#define CATPT_SHIM_ISC 0x18
#define CATPT_SHIM_ISD 0x20
#define CATPT_SHIM_IMC 0x28
#define CATPT_SHIM_IMD 0x30
#define CATPT_SHIM_IPCC 0x38
#define CATPT_SHIM_IPCD 0x40
#define CATPT_SHIM_CLKCTL 0x78
#define CATPT_SHIM_CS2 0x80
#define CATPT_SHIM_LTRC 0xE0
#define CATPT_SHIM_HMDC 0xE8
#define CATPT_CS_LPCS BIT(31)
#define CATPT_CS_SFCR(ssp) BIT(27 + (ssp))
#define CATPT_CS_S1IOCS BIT(23)
#define CATPT_CS_S0IOCS BIT(21)
#define CATPT_CS_PCE BIT(15)
#define CATPT_CS_SDPM(ssp) BIT(11 + (ssp))
#define CATPT_CS_STALL BIT(10)
#define CATPT_CS_DCS GENMASK(6, 4)
/* b100 DSP core & audio fabric high clock */
#define CATPT_CS_DCS_HIGH (0x4 << 4)
#define CATPT_CS_SBCS(ssp) BIT(2 + (ssp))
#define CATPT_CS_RST BIT(1)
#define CATPT_ISC_IPCDB BIT(1)
#define CATPT_ISC_IPCCD BIT(0)
#define CATPT_ISD_DCPWM BIT(31)
#define CATPT_ISD_IPCCB BIT(1)
#define CATPT_ISD_IPCDD BIT(0)
#define CATPT_IMC_IPCDB BIT(1)
#define CATPT_IMC_IPCCD BIT(0)
#define CATPT_IMD_IPCCB BIT(1)
#define CATPT_IMD_IPCDD BIT(0)
#define CATPT_IPCC_BUSY BIT(31)
#define CATPT_IPCC_DONE BIT(30)
#define CATPT_IPCD_BUSY BIT(31)
#define CATPT_IPCD_DONE BIT(30)
#define CATPT_CLKCTL_CFCIP BIT(31)
#define CATPT_CLKCTL_SMOS GENMASK(25, 24)
#define CATPT_HMDC_HDDA(e, ch) BIT(8 * (e) + (ch))
/* defaults to reset SHIM registers to after each power cycle */
#define CATPT_CS_DEFAULT 0x8480040E
#define CATPT_ISC_DEFAULT 0x0
#define CATPT_ISD_DEFAULT 0x0
#define CATPT_IMC_DEFAULT 0x7FFF0003
#define CATPT_IMD_DEFAULT 0x7FFF0003
#define CATPT_IPCC_DEFAULT 0x0
#define CATPT_IPCD_DEFAULT 0x0
#define CATPT_CLKCTL_DEFAULT 0x7FF
#define CATPT_CS2_DEFAULT 0x0
#define CATPT_LTRC_DEFAULT 0x0
#define CATPT_HMDC_DEFAULT 0x0
/* PCI Configuration registers */
#define CATPT_PCI_PMCAPID 0x80
#define CATPT_PCI_PMCS (CATPT_PCI_PMCAPID + PCI_PM_CTRL)
#define CATPT_PCI_VDRTCTL0 0xA0
#define CATPT_PCI_VDRTCTL2 0xA8
#define CATPT_VDRTCTL2_DTCGE BIT(10)
#define CATPT_VDRTCTL2_DCLCGE BIT(1)
#define CATPT_VDRTCTL2_CGEALL 0xF7F
/* LPT PCI Configuration bits */
#define LPT_VDRTCTL0_DSRAMPGE(b) BIT(16 + (b))
#define LPT_VDRTCTL0_DSRAMPGE_MASK GENMASK(31, 16)
#define LPT_VDRTCTL0_ISRAMPGE(b) BIT(6 + (b))
#define LPT_VDRTCTL0_ISRAMPGE_MASK GENMASK(15, 6)
#define LPT_VDRTCTL0_D3SRAMPGD BIT(2)
#define LPT_VDRTCTL0_D3PGD BIT(1)
#define LPT_VDRTCTL0_APLLSE BIT(0)
/* WPT PCI Configuration bits */
#define WPT_VDRTCTL0_DSRAMPGE(b) BIT(12 + (b))
#define WPT_VDRTCTL0_DSRAMPGE_MASK GENMASK(31, 12)
#define WPT_VDRTCTL0_ISRAMPGE(b) BIT(2 + (b))
#define WPT_VDRTCTL0_ISRAMPGE_MASK GENMASK(11, 2)
#define WPT_VDRTCTL0_D3SRAMPGD BIT(1)
#define WPT_VDRTCTL0_D3PGD BIT(0)
#define WPT_VDRTCTL2_APLLSE BIT(31)
/* defaults to reset SSP registers to after each power cycle */
#define CATPT_SSC0_DEFAULT 0x0
#define CATPT_SSC1_DEFAULT 0x0
#define CATPT_SSS_DEFAULT 0xF004
#define CATPT_SSIT_DEFAULT 0x0
#define CATPT_SSD_DEFAULT 0xC43893A3
#define CATPT_SSTO_DEFAULT 0x0
#define CATPT_SSPSP_DEFAULT 0x0
#define CATPT_SSTSA_DEFAULT 0x0
#define CATPT_SSRSA_DEFAULT 0x0
#define CATPT_SSTSS_DEFAULT 0x0
#define CATPT_SSCR2_DEFAULT 0x0
#define CATPT_SSPSP2_DEFAULT 0x0
/* Physically the same block, access address differs between host and dsp */
#define CATPT_DSP_DRAM_OFFSET 0x400000
#define catpt_to_host_offset(offset) ((offset) & ~(CATPT_DSP_DRAM_OFFSET))
#define catpt_to_dsp_offset(offset) ((offset) | CATPT_DSP_DRAM_OFFSET)
#define CATPT_MEMBLOCK_SIZE 0x8000
#define catpt_num_dram(cdev) (hweight_long((cdev)->spec->dram_mask))
#define catpt_num_iram(cdev) (hweight_long((cdev)->spec->iram_mask))
#define catpt_dram_size(cdev) (catpt_num_dram(cdev) * CATPT_MEMBLOCK_SIZE)
#define catpt_iram_size(cdev) (catpt_num_iram(cdev) * CATPT_MEMBLOCK_SIZE)
/* registry I/O helpers */
#define catpt_shim_addr(cdev) \
((cdev)->lpe_ba + (cdev)->spec->host_shim_offset)
#define catpt_dma_addr(cdev, dma) \
((cdev)->lpe_ba + (cdev)->spec->host_dma_offset[dma])
#define catpt_ssp_addr(cdev, ssp) \
((cdev)->lpe_ba + (cdev)->spec->host_ssp_offset[ssp])
#define catpt_inbox_addr(cdev) \
((cdev)->lpe_ba + (cdev)->ipc.config.inbox_offset)
#define catpt_outbox_addr(cdev) \
((cdev)->lpe_ba + (cdev)->ipc.config.outbox_offset)
#define catpt_writel_ssp(cdev, ssp, reg, val) \
writel(val, catpt_ssp_addr(cdev, ssp) + (reg))
#define catpt_readl_shim(cdev, reg) \
readl(catpt_shim_addr(cdev) + CATPT_SHIM_##reg)
#define catpt_writel_shim(cdev, reg, val) \
writel(val, catpt_shim_addr(cdev) + CATPT_SHIM_##reg)
#define catpt_updatel_shim(cdev, reg, mask, val) \
catpt_writel_shim(cdev, reg, \
(catpt_readl_shim(cdev, reg) & ~(mask)) | (val))
#define catpt_readl_poll_shim(cdev, reg, val, cond, delay_us, timeout_us) \
readl_poll_timeout(catpt_shim_addr(cdev) + CATPT_SHIM_##reg, \
val, cond, delay_us, timeout_us)
#define catpt_readl_pci(cdev, reg) \
readl(cdev->pci_ba + CATPT_PCI_##reg)
#define catpt_writel_pci(cdev, reg, val) \
writel(val, cdev->pci_ba + CATPT_PCI_##reg)
#define catpt_updatel_pci(cdev, reg, mask, val) \
catpt_writel_pci(cdev, reg, \
(catpt_readl_pci(cdev, reg) & ~(mask)) | (val))
#define catpt_readl_poll_pci(cdev, reg, val, cond, delay_us, timeout_us) \
readl_poll_timeout((cdev)->pci_ba + CATPT_PCI_##reg, \
val, cond, delay_us, timeout_us)
#endif
// SPDX-License-Identifier: GPL-2.0-only
//
// Copyright(c) 2020 Intel Corporation. All rights reserved.
//
// Author: Cezary Rojewski <cezary.rojewski@intel.com>
//
#include <linux/pm_runtime.h>
#include "core.h"
static ssize_t fw_version_show(struct device *dev,
struct device_attribute *attr, char *buf)
{
struct catpt_dev *cdev = dev_get_drvdata(dev);
struct catpt_fw_version version;
int ret;
pm_runtime_get_sync(cdev->dev);
ret = catpt_ipc_get_fw_version(cdev, &version);
pm_runtime_mark_last_busy(cdev->dev);
pm_runtime_put_autosuspend(cdev->dev);
if (ret)
return CATPT_IPC_ERROR(ret);
return sprintf(buf, "%d.%d.%d.%d\n", version.type, version.major,
version.minor, version.build);
}
static DEVICE_ATTR_RO(fw_version);
static ssize_t fw_info_show(struct device *dev,
struct device_attribute *attr, char *buf)
{
struct catpt_dev *cdev = dev_get_drvdata(dev);
return sprintf(buf, "%s\n", cdev->ipc.config.fw_info);
}
static DEVICE_ATTR_RO(fw_info);
static struct attribute *catpt_attrs[] = {
&dev_attr_fw_version.attr,
&dev_attr_fw_info.attr,
NULL
};
static const struct attribute_group catpt_attr_group = {
.attrs = catpt_attrs,
};
const struct attribute_group *catpt_attr_groups[] = {
&catpt_attr_group,
NULL
};
/* SPDX-License-Identifier: GPL-2.0-only */
/*
* Copyright(c) 2020 Intel Corporation. All rights reserved.
*
* Author: Cezary Rojewski <cezary.rojewski@intel.com>
*/
#undef TRACE_SYSTEM
#define TRACE_SYSTEM intel_catpt
#if !defined(__SND_SOC_INTEL_CATPT_TRACE_H) || defined(TRACE_HEADER_MULTI_READ)
#define __SND_SOC_INTEL_CATPT_TRACE_H
#include <linux/types.h>
#include <linux/tracepoint.h>
DECLARE_EVENT_CLASS(catpt_ipc_msg,
TP_PROTO(u32 header),
TP_ARGS(header),
TP_STRUCT__entry(
__field(u32, header)
),
TP_fast_assign(
__entry->header = header;
),
TP_printk("0x%08x", __entry->header)
);
DEFINE_EVENT(catpt_ipc_msg, catpt_irq,
TP_PROTO(u32 header),
TP_ARGS(header)
);
DEFINE_EVENT(catpt_ipc_msg, catpt_ipc_request,
TP_PROTO(u32 header),
TP_ARGS(header)
);
DEFINE_EVENT(catpt_ipc_msg, catpt_ipc_reply,
TP_PROTO(u32 header),
TP_ARGS(header)
);
DEFINE_EVENT(catpt_ipc_msg, catpt_ipc_notify,
TP_PROTO(u32 header),
TP_ARGS(header)
);
TRACE_EVENT_CONDITION(catpt_ipc_payload,
TP_PROTO(const u8 *data, size_t size),
TP_ARGS(data, size),
TP_CONDITION(data && size),
TP_STRUCT__entry(
__dynamic_array(u8, buf, size)
),
TP_fast_assign(
memcpy(__get_dynamic_array(buf), data, size);
),
TP_printk("%u byte(s)%s",
__get_dynamic_array_len(buf),
__print_hex_dump("", DUMP_PREFIX_NONE, 16, 4,
__get_dynamic_array(buf),
__get_dynamic_array_len(buf), false))
);
#endif /* __SND_SOC_INTEL_CATPT_TRACE_H */
/* This part must be outside protection */
#undef TRACE_INCLUDE_PATH
#define TRACE_INCLUDE_PATH .
#define TRACE_INCLUDE_FILE trace
#include <trace/define_trace.h>
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment