ASoC: amd: ps: add SoundWire support
Subsystems (3)
Vijendar Mukunda
maintainerv3 cover ASoC: amd: ps: add SoundWire support
This patch series add support for
- Platform device creation for SoundWire Manager instances and PDM controller.
- SoundWire DMA driver.
- Interrupt handling for SoundWire manager related interrupts, SoundWire DMA interrupts and ACP error interrupts.
- ACP PCI driver PM ops modification with respect to SoundWire Power modes.
Changes since v1:
- update "soundwire" as "SoundWire" in code.
- add comments for platform device mask and platform device count
- remove unused variables in acp pci driver private data structure
- refactor dma enable register structures in SoundWire DMA driver
- add TODO comments in IRQ handler
- update IRQ mask values using bit macros
- Fix build error reported in Makefile
- rename "sdw_dma_stream_instance" structure name as "acp_sdw_dma_stream"
changes since v2:
- add comments in irq handler.
- remove workqueue for SoundWire DMA interrupts and use thread implementation for DMA interrupt handling.
- add error checks in sdw_amd_scan_controller()
- remove passing "acp_lock" as platform resource for SoundWire DMA driver and PDM driver.
- retrieve "acp_lock" reference from parent driver directly and use the reference in SoundWire DMA driver.
- add handling for acp pci driver probe even when no ACP PDM or SoundWire manager platform devices created.
- Fix indentation for acp_sdw_dma_count structure variables.
- Use macro instead of hard coded values for FIFO offset and PTE offset.
- Change pm_runtime enable sequence in SoundWire DMA driver probe function.
- Refactor system level resume callback in SoundWire DMA driver.
Vijendar Mukunda (9):
ASoC: amd: ps: create platform devices based on acp config
ASoC: amd: ps: handle SoundWire interrupts in acp pci driver
ASoC: amd: ps: add SoundWire dma driver
ASoC: amd: ps: add SoundWire dma driver dma ops
ASoC: amd: ps: add support for SoundWire DMA interrupts
ASoC: amd: ps: add pm ops support for SoundWire dma driver
ASoC: amd: ps: enable SoundWire dma driver build
ASoC: amd: update comments in Kconfig file
ASoC: amd: ps: Add SoundWire specific checks in pci driver in pm ops.
sound/soc/amd/Kconfig | 3 +- sound/soc/amd/ps/Makefile | 2 + sound/soc/amd/ps/acp63.h | 180 ++++++++++- sound/soc/amd/ps/pci-ps.c | 400 +++++++++++++++++++++-- sound/soc/amd/ps/ps-sdw-dma.c | 579 ++++++++++++++++++++++++++++++++++ 5 files changed, 1138 insertions(+), 26 deletions(-) create mode 100644 sound/soc/amd/ps/ps-sdw-dma.c
Signature · 1 line
2.34.1
Vijendar Mukunda
maintainerPATCH v3 1/9 ASoC: amd: ps: create platform devices based on acp config
Based on ACP pin configuration and scanning child devices under ACP pci device ACPI scope, platform device mask(pdev_mask) and platform device count(pdev_count) will be calculated.
Using pdev_mask and pdev_count values, ACP PCI driver will create platform devices for Pink Sardine platform.
--- sound/soc/amd/ps/acp63.h | 81 +++++++++++- sound/soc/amd/ps/pci-ps.c | 252 ++++++++++++++++++++++++++++++++++++-- 2 files changed, 318 insertions(+), 15 deletions(-)
sound/soc/amd/ps/acp63.h +77 -4
@@ -10,7 +10,7 @@#define ACP_DEVICE_ID 0x15E2#define ACP63_REG_START 0x1240000#define ACP63_REG_END 0x1250200 -#define ACP63_DEVS 3 +#define ACP63_DEVS 5#define ACP_SOFT_RESET_SOFTRESET_AUDDONE_MASK 0x00010001#define ACP_PGFSM_CNTL_POWER_ON_MASK 1
@@ -53,11 +53,38 @@/* time in ms for runtime suspend delay */ #define ACP_SUSPEND_DELAY_MS 2000 -#define ACP63_DMIC_ADDR 2 -#define ACP63_PDM_MODE_DEVS 3 -#define ACP63_PDM_DEV_MASK 1#define ACP_DMIC_DEV 2 +/* ACP63_PDM_MODE_DEVS corresponds to platform devices count for ACP PDM configuration */ +#define ACP63_PDM_MODE_DEVS 3 + +/* +* ACP63_SDW0_MODE_DEVS corresponds to platform devices count for +* SW0 SoundWire manager instance configuration +*/ +#define ACP63_SDW0_MODE_DEVS 2 + +/* +* ACP63_SDW0_SDW1_MODE_DEVS corresponds to platform devices count for SW0 + SW1 SoundWire manager +* instances configuration +*/ +#define ACP63_SDW0_SDW1_MODE_DEVS 3 + +/* +* ACP63_SDW0_PDM_MODE_DEVS corresponds to platform devices count for SW0 manager +* instance + ACP PDM controller configuration +*/ +#define ACP63_SDW0_PDM_MODE_DEVS 4 + +/* +* ACP63_SDW0_SDW1_PDM_MODE_DEVS corresponds to platform devices count for +* SW0 + SW1 SoundWire manager instances + ACP PDM controller configuration +*/ +#define ACP63_SDW0_SDW1_PDM_MODE_DEVS 5 +#define ACP63_DMIC_ADDR 2 +#define ACP63_SDW_ADDR 5 +#define AMD_SDW_MAX_MANAGERS 2 +/* time in ms for acp timeout */ #define ACP_TIMEOUT 500
@@ -80,6 +107,28 @@ enum acp_config { ACP_CONFIG_15, }; +/** +* acp_pdev_mask corresponds to platform device mask based on audio endpoint combinations. +* acp_pdev_mask will be calculated based on ACPI Scan under ACP PCI device and +* ACP PIN Configuration. +* Based acp_pdev_mask, platform devices will be created. +* Below are possible platform device combinations. +* 1) ACP PDM Controller, dmic-codec, machine driver platform device node +* 2) ACP PDM Controller , dmic-codec, SW0 SoundWire manager instance, platform device for +* SoundWire DMA driver +* 3) SW0, SW1 SoundWire manager instances, platform device for SoundWire DMA driver +* 4) ACP PDM Controller, dmic-codec, SDW0, SDW1 manager instances, platform device for +* SoundWire DMA driver +* ACP63_PDM_DEV_MASK corresponds to platform device mask for ACP PDM controller. +* ACP63_SDW_DEV_MASK corresponds to platform device mask for SDW manager instances. +* ACP63_SDW_PDM_DEV_MASK corresponds to platform device mask for ACP PDM + SDW manager combination +*/ +enum acp_pdev_mask { +ACP63_PDM_DEV_MASK =1 , +ACP63_SDW_DEV_MASK , +ACP63_SDW_PDM_DEV_MASK , +}; +struct pdm_stream_instance {u16 num_pages;u16 channels;
@@ -95,14 +144,38 @@ struct pdm_dev_data {struct snd_pcm_substream *capture_stream; }; +/** +* struct acp63_dev_data - acp pci driver context +* @acp63_base: acp mmio base +* @res: resource +* @pdev: array of child platform device node structures +* @acp_lock: used to protect acp common registers +* @sdw_fw_node: SoundWire controller fw node handle +* @pdev_mask: platform device mask +* @pdev_count: platform devices count +* @pdm_dev_index: pdm platform device index +* @sdw_manager_count: SoundWire manager instance count +* @sdw0_dev_index: SoundWire Manager-0 platform device index +* @sdw1_dev_index: SoundWire Manager-1 platform device index +* @sdw_dma_dev_index: SoundWire DMA controller platform device index +* @acp_reset: flag set to true when bus reset is applied across all +* the active SoundWire manager instances +*/ +struct acp63_dev_data {void __iomem *acp63_base;struct resource *res;struct platform_device *pdev[ACP63_DEVS ];struct mutex acp_lock;/* protect shared registers */ +struct fwnode_handle *sdw_fw_node;u16 pdev_mask;u16 pdev_count;u16 pdm_dev_index; +u8 sdw_manager_count; +u16 sdw0_dev_index; +u16 sdw1_dev_index; +u16 sdw_dma_dev_index; +bool acp_reset; };int snd_amd_acp_find_config (struct pci_dev *pci);
sound/soc/amd/ps/pci-ps.c +241 -11
316 lines not on this page · raw message
Signature · 1 line
2.34.1
Re: [PATCH V3 1/9] ASoC: amd: ps: create platform devices based on acp config
Quoted 14 lines
sound/soc/amd/ps/acp63.h +11
-0+/** +* acp_pdev_mask corresponds to platform device mask based on audio endpoint combinations. +* acp_pdev_mask will be calculated based on ACPI Scan under ACP PCI device and +* ACP PIN Configuration. +* Based acp_pdev_mask, platform devices will be created. +* Below are possible platform device combinations. +* 1) ACP PDM Controller, dmic-codec, machine driver platform device node +* 2) ACP PDM Controller , dmic-codec, SW0 SoundWire manager instance, platform device for +* SoundWire DMA driver +* 3) SW0, SW1 SoundWire manager instances, platform device for SoundWire DMA driver +* 4) ACP PDM Controller, dmic-codec, SDW0, SDW1 manager instances, platform device for
sound/soc/amd/ps/acp63.h enum acp_config { · line 130
Quoted 10 lines
sound/soc/amd/ps/acp63.h +10
-0+* SoundWire DMA driver +* ACP63_PDM_DEV_MASK corresponds to platform device mask for ACP PDM controller. +* ACP63_SDW_DEV_MASK corresponds to platform device mask for SDW manager instances. +* ACP63_SDW_PDM_DEV_MASK corresponds to platform device mask for ACP PDM + SDW manager combination +*/ +enum acp_pdev_mask { +ACP63_PDM_DEV_MASK =1 , +ACP63_SDW_DEV_MASK , +ACP63_SDW_PDM_DEV_MASK , +};
This does not look like a mask, the definitions prevent bit-wise operations from happening.
Either use BIT(0), BIT(1), BIT(2) or GENMASK(1, 0), or demote this to a regular enum (e.g. pdev_config or something)
Quoted 75 lines
sound/soc/amd/ps/acp63.h +25
-0+struct pdm_stream_instance {u16 num_pages;u16 channels;@@ -95,14 +144,38 @@ struct pdm_dev_data {struct snd_pcm_substream *capture_stream; }; +/** +* struct acp63_dev_data - acp pci driver context +* @acp63_base: acp mmio base +* @res: resource +* @pdev: array of child platform device node structures +* @acp_lock: used to protect acp common registers +* @sdw_fw_node: SoundWire controller fw node handle +* @pdev_mask: platform device mask +* @pdev_count: platform devices count +* @pdm_dev_index: pdm platform device index +* @sdw_manager_count: SoundWire manager instance count +* @sdw0_dev_index: SoundWire Manager-0 platform device index +* @sdw1_dev_index: SoundWire Manager-1 platform device index +* @sdw_dma_dev_index: SoundWire DMA controller platform device index +* @acp_reset: flag set to true when bus reset is applied across all +* the active SoundWire manager instances +*/ +struct acp63_dev_data {void __iomem *acp63_base;struct resource *res;struct platform_device *pdev[ACP63_DEVS ];struct mutex acp_lock;/* protect shared registers */ +struct fwnode_handle *sdw_fw_node;u16 pdev_mask;u16 pdev_count;u16 pdm_dev_index; +u8 sdw_manager_count; +u16 sdw0_dev_index; +u16 sdw1_dev_index; +u16 sdw_dma_dev_index; +bool acp_reset; };int snd_amd_acp_find_config (struct pci_dev *pci);sound/soc/amd/ps/pci-ps.c +8
-2@@ -6,6 +6,7 @@*/ #include <linux/pci.h> +#include <linux/bitops.h> #include <linux/module.h> #include <linux/io.h> #include <linux/delay.h> @@ -15,6 +16,7 @@#include <sound/pcm_params.h> #include <linux/pm_runtime.h> #include <linux/iopoll.h> +#include <linux/soundwire/sdw_amd.h> #include "acp63.h" @@ -119,37 +121,162 @@ static irqreturn_t acp63_irq_handler(int irq, void *dev_id)return IRQ_NONE ; } -static void get_acp63_device_config (u32 config,struct pci_dev *pci, -struct acp63_dev_data *acp_data) +static int sdw_amd_scan_controller (struct device *dev) +{ +struct acp63_dev_data *acp_data; +struct fwnode_handle *link; +char name[32 ]; +u32 sdw_manager_bitmap;
sound/soc/amd/ps/pci-ps.c static irqreturn_t acp63_irq_handler(int irq, void *dev_id) · line 139
Quoted 10 lines
sound/soc/amd/ps/pci-ps.c +10
-0+u8 count =0 ; +u32 acp_sdw_power_mode =0 ; +int index; +int ret; + + acp_data =dev_get_drvdata (dev); + acp_data->acp_reset = true; +/* Found controller, find links supported */ + ret =fwnode_property_read_u32_array ((acp_data->sdw_fw_node),"mipi-sdw-manager-list" , + &sdw_manager_bitmap,1 );
IIRC this is only defined in the DisCo 2.0 spec, previous editions had a 'mipi-master-count'. A comment would not hurt to point to the minimal DisCo spec version.
Quoted 46 lines
sound/soc/amd/ps/pci-ps.c +44
-0+ +if (ret) { +dev_err (dev,"Failed to read mipi-sdw-manager-list: %d\n" , ret); +return -EINVAL ; + } + count =hweight32 (sdw_manager_bitmap); +/* Check count is within bounds */ +if (count >AMD_SDW_MAX_MANAGERS ) { +dev_err (dev,"Manager count %d exceeds max %d\n" , count,AMD_SDW_MAX_MANAGERS ); +return -EINVAL ; + } + +if (!count) { +dev_dbg (dev,"No SoundWire Managers detected\n" ); +return -EINVAL ; + } +dev_dbg (dev,"ACPI reports %d SoundWire Manager devices\n" , count); + acp_data->sdw_manager_count = count; +for (index =0 ; index < count; index++) { +snprintf (name,sizeof (name),"mipi-sdw-link-%d-subproperties" , index); + link =fwnode_get_named_child_node (acp_data->sdw_fw_node, name); +if (!link) { +dev_err (dev,"Manager node %s not found\n" , name); +return -EIO ; + } + + ret =fwnode_property_read_u32 (link,"amd-sdw-power-mode" , &acp_sdw_power_mode); +if (ret) +return ret; +/* +* when SoundWire configuration is selected from acp pin config, +* based on manager instances count, acp init/de-init sequence should be +* executed as part of PM ops only when Bus reset is applied for the active +* SoundWire manager instances. +*/ +if (acp_sdw_power_mode !=AMD_SDW_POWER_OFF_MODE ) { + acp_data->acp_reset = false; +return 0 ; + } + } +return 0 ; +} + +static int get_acp63_device_config (u32 config,struct pci_dev *pci,struct acp63_dev_data *acp_data) {struct acpi_device *dmic_dev;
sound/soc/amd/ps/pci-ps.c static irqreturn_t acp63_irq_handler(int irq, void *dev_id) · line 195
Quoted 10 lines
sound/soc/amd/ps/pci-ps.c +4
-0+struct acpi_device *sdw_dev;const union acpi_object *obj;bool is_dmic_dev = false; +bool is_sdw_dev = false; +int ret; dmic_dev =acpi_find_child_device (ACPI_COMPANION (&pci->dev),ACP63_DMIC_ADDR ,0 ); if (dmic_dev) { + /* is_dmic_dev flag will be set when ACP PDM controller device exists */ if (!acpi_dev_get_property(dmic_dev, "acp-audio-device-type",
usually properties start with the 'mipi-' or 'vendor-' prefix. Is there a missing 'amd-' here or is 'acp-' unique enough?
Mukunda,Vijendar
maintainerRe: [PATCH V3 1/9] ASoC: amd: ps: create platform devices based on acp config
Quoted 26 lines · Pierre-Louis Bossart
Quoted 13 lines
sound/soc/amd/ps/acp63.h +11
-0+/** +* acp_pdev_mask corresponds to platform device mask based on audio endpoint combinations. +* acp_pdev_mask will be calculated based on ACPI Scan under ACP PCI device and +* ACP PIN Configuration. +* Based acp_pdev_mask, platform devices will be created. +* Below are possible platform device combinations. +* 1) ACP PDM Controller, dmic-codec, machine driver platform device node +* 2) ACP PDM Controller , dmic-codec, SW0 SoundWire manager instance, platform device for +* SoundWire DMA driver +* 3) SW0, SW1 SoundWire manager instances, platform device for SoundWire DMA driver +* 4) ACP PDM Controller, dmic-codec, SDW0, SDW1 manager instances, platform device for sound/soc/amd/ps/acp63.h enum acp_config { · line 130
Quoted 10 lines
sound/soc/amd/ps/acp63.h +10
-0+* SoundWire DMA driver +* ACP63_PDM_DEV_MASK corresponds to platform device mask for ACP PDM controller. +* ACP63_SDW_DEV_MASK corresponds to platform device mask for SDW manager instances. +* ACP63_SDW_PDM_DEV_MASK corresponds to platform device mask for ACP PDM + SDW manager combination +*/ +enum acp_pdev_mask { +ACP63_PDM_DEV_MASK =1 , +ACP63_SDW_DEV_MASK , +ACP63_SDW_PDM_DEV_MASK , +};This does not look like a mask, the definitions prevent bit-wise operations from happening.
Quoted 2 lines
Either use BIT(0), BIT(1), BIT(2) or
GENMASK(1, 0), or demote this to a regular enum (e.g.pdev_configor something)
ACP63_PDM_DEV_MASK - Will be set only PDM config is selected. ACP63_SDW_DEV_MASK - will be set only when SDW config is selected. ACP63_SDW_PDM_DEV_MASK - will be set only when ACP PDM + SDW config is selected.
We have already added comments for above masks definitions in code.
Our intention is to use it as a mask.
We don't think it breaks anything.
Currently, we have only one extra check for SDW case, in suspend/resume scenario. Based on SoundWire power mode, ACP PCI driver should invoke acp_deinit/acp_init() calls in suspend/resume callbacks.
For this, we have added check for pdev_mask. If pdev_mask is set to ACP63_SDW_DEV_MASK
(2) or ACP63_SDW_PDM_DEV_MASK(3), in this case only by checking SoundWire power mode invoke acp_deinit/acp_init() sequence. This is already in place.
There won't be any extra checks will be added in the future. As per our understanding, it's good to go.
Quoted 80 lines
Quoted 80 lines
sound/soc/amd/ps/acp63.h +25
-0+struct pdm_stream_instance {u16 num_pages;u16 channels;@@ -95,14 +144,38 @@ struct pdm_dev_data {struct snd_pcm_substream *capture_stream; }; +/** +* struct acp63_dev_data - acp pci driver context +* @acp63_base: acp mmio base +* @res: resource +* @pdev: array of child platform device node structures +* @acp_lock: used to protect acp common registers +* @sdw_fw_node: SoundWire controller fw node handle +* @pdev_mask: platform device mask +* @pdev_count: platform devices count +* @pdm_dev_index: pdm platform device index +* @sdw_manager_count: SoundWire manager instance count +* @sdw0_dev_index: SoundWire Manager-0 platform device index +* @sdw1_dev_index: SoundWire Manager-1 platform device index +* @sdw_dma_dev_index: SoundWire DMA controller platform device index +* @acp_reset: flag set to true when bus reset is applied across all +* the active SoundWire manager instances +*/ +struct acp63_dev_data {void __iomem *acp63_base;struct resource *res;struct platform_device *pdev[ACP63_DEVS ];struct mutex acp_lock;/* protect shared registers */ +struct fwnode_handle *sdw_fw_node;u16 pdev_mask;u16 pdev_count;u16 pdm_dev_index; +u8 sdw_manager_count; +u16 sdw0_dev_index; +u16 sdw1_dev_index; +u16 sdw_dma_dev_index; +bool acp_reset; };int snd_amd_acp_find_config (struct pci_dev *pci);sound/soc/amd/ps/pci-ps.c +13
-2@@ -6,6 +6,7 @@*/ #include <linux/pci.h> +#include <linux/bitops.h> #include <linux/module.h> #include <linux/io.h> #include <linux/delay.h> @@ -15,6 +16,7 @@#include <sound/pcm_params.h> #include <linux/pm_runtime.h> #include <linux/iopoll.h> +#include <linux/soundwire/sdw_amd.h> #include "acp63.h" @@ -119,37 +121,162 @@ static irqreturn_t acp63_irq_handler(int irq, void *dev_id)return IRQ_NONE ; } -static void get_acp63_device_config (u32 config,struct pci_dev *pci, -struct acp63_dev_data *acp_data) +static int sdw_amd_scan_controller (struct device *dev) +{ +struct acp63_dev_data *acp_data; +struct fwnode_handle *link; +char name[32 ]; +u32 sdw_manager_bitmap; +u8 count =0 ; +u32 acp_sdw_power_mode =0 ; +int index; +int ret; +
Quoted 8 lines
sound/soc/amd/ps/pci-ps.c static irqreturn_t acp63_irq_handler(int irq, void *dev_id) · line 139
Quoted 5 lines
sound/soc/amd/ps/pci-ps.c +5
-0+ acp_data =dev_get_drvdata (dev); + acp_data->acp_reset = true; +/* Found controller, find links supported */ + ret =fwnode_property_read_u32_array ((acp_data->sdw_fw_node),"mipi-sdw-manager-list" , + &sdw_manager_bitmap,1 );IIRC this is only defined in the DisCo 2.0 spec, previous editions had a 'mipi-master-count'. A comment would not hurt to point to the minimal DisCo spec version.
We will add comment.
Quoted 52 lines
Quoted 52 lines
sound/soc/amd/ps/pci-ps.c +47
-0+ +if (ret) { +dev_err (dev,"Failed to read mipi-sdw-manager-list: %d\n" , ret); +return -EINVAL ; + } + count =hweight32 (sdw_manager_bitmap); +/* Check count is within bounds */ +if (count >AMD_SDW_MAX_MANAGERS ) { +dev_err (dev,"Manager count %d exceeds max %d\n" , count,AMD_SDW_MAX_MANAGERS ); +return -EINVAL ; + } + +if (!count) { +dev_dbg (dev,"No SoundWire Managers detected\n" ); +return -EINVAL ; + } +dev_dbg (dev,"ACPI reports %d SoundWire Manager devices\n" , count); + acp_data->sdw_manager_count = count; +for (index =0 ; index < count; index++) { +snprintf (name,sizeof (name),"mipi-sdw-link-%d-subproperties" , index); + link =fwnode_get_named_child_node (acp_data->sdw_fw_node, name); +if (!link) { +dev_err (dev,"Manager node %s not found\n" , name); +return -EIO ; + } + + ret =fwnode_property_read_u32 (link,"amd-sdw-power-mode" , &acp_sdw_power_mode); +if (ret) +return ret; +/* +* when SoundWire configuration is selected from acp pin config, +* based on manager instances count, acp init/de-init sequence should be +* executed as part of PM ops only when Bus reset is applied for the active +* SoundWire manager instances. +*/ +if (acp_sdw_power_mode !=AMD_SDW_POWER_OFF_MODE ) { + acp_data->acp_reset = false; +return 0 ; + } + } +return 0 ; +} + +static int get_acp63_device_config (u32 config,struct pci_dev *pci,struct acp63_dev_data *acp_data) {struct acpi_device *dmic_dev; +struct acpi_device *sdw_dev;const union acpi_object *obj;bool is_dmic_dev = false; +bool is_sdw_dev = false; +int ret;
Quoted 6 lines
sound/soc/amd/ps/pci-ps.c static irqreturn_t acp63_irq_handler(int irq, void *dev_id) · line 195
Quoted 4 lines
sound/soc/amd/ps/pci-ps.c +1
-0dmic_dev =acpi_find_child_device (ACPI_COMPANION (&pci->dev),ACP63_DMIC_ADDR ,0 ); if (dmic_dev) { + /* is_dmic_dev flag will be set when ACP PDM controller device exists */ if (!acpi_dev_get_property(dmic_dev, "acp-audio-device-type",usually properties start with the 'mipi-' or 'vendor-' prefix. Is there a missing 'amd-' here or is 'acp-' unique enough?
It's not SoundWire related MIPI/Vendor property.
Our BIOS changes are freeze. We can't modify this one as of this moment. We will consider it for next platform.
Re: [PATCH V3 1/9] ASoC: amd: ps: create platform devices based on acp config
Quoted 42 lines · Mukunda,Vijendar
Quoted 25 lines · Pierre-Louis Bossart
Quoted 12 lines
sound/soc/amd/ps/acp63.h +11
-0+/** +* acp_pdev_mask corresponds to platform device mask based on audio endpoint combinations. +* acp_pdev_mask will be calculated based on ACPI Scan under ACP PCI device and +* ACP PIN Configuration. +* Based acp_pdev_mask, platform devices will be created. +* Below are possible platform device combinations. +* 1) ACP PDM Controller, dmic-codec, machine driver platform device node +* 2) ACP PDM Controller , dmic-codec, SW0 SoundWire manager instance, platform device for +* SoundWire DMA driver +* 3) SW0, SW1 SoundWire manager instances, platform device for SoundWire DMA driver +* 4) ACP PDM Controller, dmic-codec, SDW0, SDW1 manager instances, platform device for sound/soc/amd/ps/acp63.h enum acp_config { · line 130
Quoted 10 lines
sound/soc/amd/ps/acp63.h +10
-0+* SoundWire DMA driver +* ACP63_PDM_DEV_MASK corresponds to platform device mask for ACP PDM controller. +* ACP63_SDW_DEV_MASK corresponds to platform device mask for SDW manager instances. +* ACP63_SDW_PDM_DEV_MASK corresponds to platform device mask for ACP PDM + SDW manager combination +*/ +enum acp_pdev_mask { +ACP63_PDM_DEV_MASK =1 , +ACP63_SDW_DEV_MASK , +ACP63_SDW_PDM_DEV_MASK , +};This does not look like a mask, the definitions prevent bit-wise operations from happening.
Quoted 2 lines
Either use BIT(0), BIT(1), BIT(2) or
GENMASK(1, 0), or demote this to a regular enum (e.g.pdev_configor something)
ACP63_PDM_DEV_MASK- Will be set only PDM config is selected.ACP63_SDW_DEV_MASK- will be set only when SDW config is selected.ACP63_SDW_PDM_DEV_MASK- will be set only when ACP PDM + SDW config is selected.We have already added comments for above masks definitions in code.
Our intention is to use it as a mask.
We don't think it breaks anything.
Currently, we have only one extra check for SDW case, in suspend/resume scenario. Based on SoundWire power mode, ACP PCI driver should invoke acp_deinit/acp_init() calls in suspend/resume callbacks.
For this, we have added check forpdev_mask. Ifpdev_maskis set toACP63_SDW_DEV_MASK
(2) orACP63_SDW_PDM_DEV_MASK(3), in this case only by checking SoundWire power mode invoke acp_deinit/acp_init() sequence. This is already in place.
Quoted 3 lines
There won't be any extra checks will be added in the future. As per our understanding, it's good to go.
I think the problem is in use of the word "mask" in this context. That usually means that you can do a bitwise operation on it. Really it's behaving more like an "enum" does.
In patch 9 you have the following code:
+ if (adata->pdev_mask & ACP63_SDW_DEV_MASK) {
That's checking if bits 0 and 1 are both set.
But if in the future a new set of hypothetical device types was introduced that mapped out to values "4" and "5" then you might end up with matches in the code that don't make sense.
So it makes more sense to do one of these solutions:
1) rename this adev->pdev_mask to be adev->pdev_config and then in patch 9 to use something like this:
if (adev->pdev_config == ACP63_SDW_DEV_CONFIG)
2) re-assign it so each config gets a single bit and keep the patch 9 behavior. PDM is BIT(0), SDW is BIT(1) PDM + SDW is BIT(2) etc.
Either way that will ensure that you never have an unexpected match. Unexpected matches can be more likely as the code base grows and it's used for more platforms and configs.
Quoted 149 lines
Quoted 82 lines
Quoted 82 lines
sound/soc/amd/ps/acp63.h +25
-0+struct pdm_stream_instance {u16 num_pages;u16 channels;@@ -95,14 +144,38 @@ struct pdm_dev_data {struct snd_pcm_substream *capture_stream; }; +/** +* struct acp63_dev_data - acp pci driver context +* @acp63_base: acp mmio base +* @res: resource +* @pdev: array of child platform device node structures +* @acp_lock: used to protect acp common registers +* @sdw_fw_node: SoundWire controller fw node handle +* @pdev_mask: platform device mask +* @pdev_count: platform devices count +* @pdm_dev_index: pdm platform device index +* @sdw_manager_count: SoundWire manager instance count +* @sdw0_dev_index: SoundWire Manager-0 platform device index +* @sdw1_dev_index: SoundWire Manager-1 platform device index +* @sdw_dma_dev_index: SoundWire DMA controller platform device index +* @acp_reset: flag set to true when bus reset is applied across all +* the active SoundWire manager instances +*/ +struct acp63_dev_data {void __iomem *acp63_base;struct resource *res;struct platform_device *pdev[ACP63_DEVS ];struct mutex acp_lock;/* protect shared registers */ +struct fwnode_handle *sdw_fw_node;u16 pdev_mask;u16 pdev_count;u16 pdm_dev_index; +u8 sdw_manager_count; +u16 sdw0_dev_index; +u16 sdw1_dev_index; +u16 sdw_dma_dev_index; +bool acp_reset; };int snd_amd_acp_find_config (struct pci_dev *pci);sound/soc/amd/ps/pci-ps.c +13
-2@@ -6,6 +6,7 @@*/ #include <linux/pci.h> +#include <linux/bitops.h> #include <linux/module.h> #include <linux/io.h> #include <linux/delay.h> @@ -15,6 +16,7 @@#include <sound/pcm_params.h> #include <linux/pm_runtime.h> #include <linux/iopoll.h> +#include <linux/soundwire/sdw_amd.h> #include "acp63.h" @@ -119,37 +121,162 @@ static irqreturn_t acp63_irq_handler(int irq, void *dev_id)return IRQ_NONE ; } -static void get_acp63_device_config (u32 config,struct pci_dev *pci, -struct acp63_dev_data *acp_data) +static int sdw_amd_scan_controller (struct device *dev) +{ +struct acp63_dev_data *acp_data; +struct fwnode_handle *link; +char name[32 ]; +u32 sdw_manager_bitmap; +u8 count =0 ; +u32 acp_sdw_power_mode =0 ; +int index; +int ret; +Quoted 8 lines
sound/soc/amd/ps/pci-ps.c static irqreturn_t acp63_irq_handler(int irq, void *dev_id) · line 139
Quoted 5 lines
sound/soc/amd/ps/pci-ps.c +5
-0+ acp_data =dev_get_drvdata (dev); + acp_data->acp_reset = true; +/* Found controller, find links supported */ + ret =fwnode_property_read_u32_array ((acp_data->sdw_fw_node),"mipi-sdw-manager-list" , + &sdw_manager_bitmap,1 );IIRC this is only defined in the DisCo 2.0 spec, previous editions had a 'mipi-master-count'. A comment would not hurt to point to the minimal DisCo spec version.
We will add comment.
Quoted 52 lines
Quoted 52 lines
sound/soc/amd/ps/pci-ps.c +47
-0+ +if (ret) { +dev_err (dev,"Failed to read mipi-sdw-manager-list: %d\n" , ret); +return -EINVAL ; + } + count =hweight32 (sdw_manager_bitmap); +/* Check count is within bounds */ +if (count >AMD_SDW_MAX_MANAGERS ) { +dev_err (dev,"Manager count %d exceeds max %d\n" , count,AMD_SDW_MAX_MANAGERS ); +return -EINVAL ; + } + +if (!count) { +dev_dbg (dev,"No SoundWire Managers detected\n" ); +return -EINVAL ; + } +dev_dbg (dev,"ACPI reports %d SoundWire Manager devices\n" , count); + acp_data->sdw_manager_count = count; +for (index =0 ; index < count; index++) { +snprintf (name,sizeof (name),"mipi-sdw-link-%d-subproperties" , index); + link =fwnode_get_named_child_node (acp_data->sdw_fw_node, name); +if (!link) { +dev_err (dev,"Manager node %s not found\n" , name); +return -EIO ; + } + + ret =fwnode_property_read_u32 (link,"amd-sdw-power-mode" , &acp_sdw_power_mode); +if (ret) +return ret; +/* +* when SoundWire configuration is selected from acp pin config, +* based on manager instances count, acp init/de-init sequence should be +* executed as part of PM ops only when Bus reset is applied for the active +* SoundWire manager instances. +*/ +if (acp_sdw_power_mode !=AMD_SDW_POWER_OFF_MODE ) { + acp_data->acp_reset = false; +return 0 ; + } + } +return 0 ; +} + +static int get_acp63_device_config (u32 config,struct pci_dev *pci,struct acp63_dev_data *acp_data) {struct acpi_device *dmic_dev; +struct acpi_device *sdw_dev;const union acpi_object *obj;bool is_dmic_dev = false; +bool is_sdw_dev = false; +int ret;Quoted 6 lines
sound/soc/amd/ps/pci-ps.c static irqreturn_t acp63_irq_handler(int irq, void *dev_id) · line 195
Quoted 4 lines
sound/soc/amd/ps/pci-ps.c +1
-0dmic_dev =acpi_find_child_device (ACPI_COMPANION (&pci->dev),ACP63_DMIC_ADDR ,0 ); if (dmic_dev) { + /* is_dmic_dev flag will be set when ACP PDM controller device exists */ if (!acpi_dev_get_property(dmic_dev, "acp-audio-device-type",usually properties start with the 'mipi-' or 'vendor-' prefix. Is there a missing 'amd-' here or is 'acp-' unique enough?
Quoted 3 lines
It's not SoundWire related MIPI/Vendor property.
Our BIOS changes are freeze. We can't modify this one as of this moment. We will consider it for next platform.
Besides impact to BIOS it also has impact to drivers in other operating systems as well. So changing a property name is not something that can be taken lightly.
I'd also point out the use of the ACPI property is localized to an AMD specific driver not generic code.
Mukunda,Vijendar
maintainerRe: [PATCH V3 1/9] ASoC: amd: ps: create platform devices based on acp config
Quoted 66 lines · Mario
Quoted 42 lines · Mukunda,Vijendar
Quoted 25 lines · Pierre-Louis Bossart
Quoted 12 lines
sound/soc/amd/ps/acp63.h +11
-0+/** +* acp_pdev_mask corresponds to platform device mask based on audio endpoint combinations. +* acp_pdev_mask will be calculated based on ACPI Scan under ACP PCI device and +* ACP PIN Configuration. +* Based acp_pdev_mask, platform devices will be created. +* Below are possible platform device combinations. +* 1) ACP PDM Controller, dmic-codec, machine driver platform device node +* 2) ACP PDM Controller , dmic-codec, SW0 SoundWire manager instance, platform device for +* SoundWire DMA driver +* 3) SW0, SW1 SoundWire manager instances, platform device for SoundWire DMA driver +* 4) ACP PDM Controller, dmic-codec, SDW0, SDW1 manager instances, platform device for sound/soc/amd/ps/acp63.h enum acp_config { · line 130
Quoted 10 lines
sound/soc/amd/ps/acp63.h +10
-0+* SoundWire DMA driver +* ACP63_PDM_DEV_MASK corresponds to platform device mask for ACP PDM controller. +* ACP63_SDW_DEV_MASK corresponds to platform device mask for SDW manager instances. +* ACP63_SDW_PDM_DEV_MASK corresponds to platform device mask for ACP PDM + SDW manager combination +*/ +enum acp_pdev_mask { + ACP63_PDM_DEV_MASK = 1, + ACP63_SDW_DEV_MASK, + ACP63_SDW_PDM_DEV_MASK, +};This does not look like a mask, the definitions prevent bit-wise operations from happening.
Quoted 2 lines
Either use BIT(0), BIT(1), BIT(2) or
GENMASK(1, 0), or demote this to a regular enum (e.g.pdev_configor something)
ACP63_PDM_DEV_MASK- Will be set only PDM config is selected.ACP63_SDW_DEV_MASK- will be set only when SDW config is selected.ACP63_SDW_PDM_DEV_MASK- will be set only when ACP PDM + SDW config is selected.We have already added comments for above masks definitions in code.
Our intention is to use it as a mask.
We don't think it breaks anything.
Currently, we have only one extra check for SDW case, in suspend/resume scenario. Based on SoundWire power mode, ACP PCI driver should invoke acp_deinit/acp_init() calls in suspend/resume callbacks.
For this, we have added check forpdev_mask. Ifpdev_maskis set toACP63_SDW_DEV_MASK
(2) orACP63_SDW_PDM_DEV_MASK(3), in this case only by checking SoundWire power mode invoke acp_deinit/acp_init() sequence. This is already in place.Quoted 3 lines
There won't be any extra checks will be added in the future. As per our understanding, it's good to go.
I think the problem is in use of the word "mask" in this context. That usually means that you can do a bitwise operation on it. Really it's behaving more like an "enum" does.
In patch 9 you have the following code:
+ if (
adata->pdev_mask&ACP63_SDW_DEV_MASK) {That's checking if bits 0 and 1 are both set.
But if in the future a new set of hypothetical device types was introduced that mapped out to values "4" and "5" then you might end up with matches in the code that don't make sense.
So it makes more sense to do one of these solutions:
1) rename this
adev->pdev_maskto beadev->pdev_configand then in patch 9 to use something like this:
Quoted 8 lines
if (
adev->pdev_config==ACP63_SDW_DEV_CONFIG)2) re-assign it so each config gets a single bit and keep the patch 9 behavior. PDM is BIT(0), SDW is BIT(1) PDM + SDW is BIT(2) etc.
Either way that will ensure that you never have an unexpected match. Unexpected matches can be more likely as the code base grows and it's used for more platforms and configs.
I think Mask word is created confusion here.
These changes are specific to PS platform only.
To avoid further confusion, we will rename the pdev_mask as pdev_config. "if (adata->pdev_mask & ACP63_SDW_DEV_MASK)" condition check can be refactored.
will fix it and post V4 patch set.
Quoted 143 lines
Quoted 143 lines
Quoted 77 lines
Quoted 77 lines
+
structpdm_stream_instance{
u16num_pages;
u16 channels;sound/soc/amd/ps/acp63.h +0
-0@@ -95,14 +144,38 @@ struct pdm_dev_data { struct snd_pcm_substream *capture_stream; };+/**
+ * structacp63_dev_data- acp pci driver context
+ * @acp63_base: acp mmio base
+ * @res: resource
+ * @pdev: array of child platform device node structures
+ * @acp_lock: used to protect acp common registers
+ * @sdw_fw_node: SoundWire controller fw node handle
+ * @pdev_mask: platform device mask
+ * @pdev_count: platform devices count
+ * @pdm_dev_index: pdm platform device index
+ * @sdw_manager_count: SoundWire manager instance count
+ * @sdw0_dev_index: SoundWire Manager-0 platform device index
+ * @sdw1_dev_index: SoundWire Manager-1 platform device index
+ * @sdw_dma_dev_index: SoundWire DMA controller platform device index
+ * @acp_reset: flag set to true when bus reset is applied across all
+ * the active SoundWire manager instances
+ */
+
structacp63_dev_data{
void__iomem*acp63_base;
struct resource *res;
structplatform_device*pdev[ACP63_DEVS];
struct mutexacp_lock; /* protect shared registers */ + structfwnode_handle*sdw_fw_node;
u16pdev_mask;
u16pdev_count;
u16pdm_dev_index;
+ u8sdw_manager_count;
+ u16sdw0_dev_index;
+ u16sdw1_dev_index;
+ u16sdw_dma_dev_index;
+ boolacp_reset;
};
intsnd_amd_acp_find_config(struct pci_dev *pci);sound/soc/amd/ps/pci-ps.c +2
-0@@ -6,6 +6,7 @@*/ #include <linux/pci.h> +#include <linux/bitops.h> #include <linux/module.h> #include <linux/io.h> #include <linux/delay.h>@@ -15,6 +16,7 @@ #include <sound/pcm_params.h> #include <linux/pm_runtime.h> #include <linux/iopoll.h> +#include <linux/soundwire/sdw_amd.h> #include "acp63.h" @@ -119,37 +121,162 @@ static irqreturn_t acp63_irq_handler(int irq, void *dev_id) return IRQ_NONE;}
-static void get_acp63_device_config(u32 config, structpci_dev*pci, - structacp63_dev_data*acp_data)sound/soc/amd/ps/pci-ps.c +11
-0+static int sdw_amd_scan_controller (struct device *dev) +{ + struct acp63_dev_data *acp_data; + struct fwnode_handle *link; + char name[32]; + u32 sdw_manager_bitmap; + u8 count = 0; + u32 acp_sdw_power_mode = 0; + int index; + int ret; +Quoted 8 lines
Quoted 5 lines
+
acp_data=dev_get_drvdata(dev);
+acp_data->acp_reset= true;
+ /* Found controller, find links supported */
+ ret = fwnode_property_read_u32_array((acp_data->sdw_fw_node), "mipi-sdw-manager-list", +&sdw_manager_bitmap, 1);IIRC this is only defined in the DisCo 2.0 spec, previous editions had a 'mipi-master-count'. A comment would not hurt to point to the minimal DisCo spec version.
We will add comment.
Quoted 57 lines
Quoted 47 lines
sound/soc/amd/ps/pci-ps.c +44
-0+ + if (ret) { + dev_err(dev, "Failed to read mipi-sdw-manager-list: %d\n", ret); + return -EINVAL; + } + count = hweight32(sdw_manager_bitmap); + /* Check count is within bounds */ + if (count > AMD_SDW_MAX_MANAGERS) { + dev_err(dev, "Manager count %d exceeds max %d\n", count, AMD_SDW_MAX_MANAGERS); + return -EINVAL; + } + + if (!count) { + dev_dbg(dev, "No SoundWire Managers detected\n"); + return -EINVAL; + } + dev_dbg(dev, "ACPI reports %d SoundWire Manager devices\n", count); + acp_data->sdw_manager_count = count; + for (index = 0; index < count; index++) { + snprintf(name, sizeof(name), "mipi-sdw-link-%d-subproperties", index); + link = fwnode_get_named_child_node(acp_data->sdw_fw_node, name); + if (!link) { + dev_err(dev, "Manager node %s not found\n", name); + return -EIO; + } + + ret = fwnode_property_read_u32(link, "amd-sdw-power-mode", &acp_sdw_power_mode); + if (ret) + return ret; + /* + * when SoundWire configuration is selected from acp pin config, + * based on manager instances count, acp init/de-init sequence should be + * executed as part of PM ops only when Bus reset is applied for the active + * SoundWire manager instances. + */ + if (acp_sdw_power_mode != AMD_SDW_POWER_OFF_MODE) { + acp_data->acp_reset = false; + return 0; + } + } + return 0; +} + +static int get_acp63_device_config (u32 config,struct pci_dev *pci,struct acp63_dev_data *acp_data){
structacpi_device*dmic_dev;
+ structacpi_device*sdw_dev;Quoted 8 lines
const union
acpi_object*obj;
boolis_dmic_dev= false;
+ boolis_sdw_dev= false;
+ int ret;
dmic_dev=acpi_find_child_device(ACPI_COMPANION(&pci->dev), ACP63_DMIC_ADDR, 0); if (dmic_dev) {
+ /*is_dmic_devflag will be set when ACP PDM controller device exists */ if (!acpi_dev_get_property(dmic_dev, "acp-audio-device-type",usually properties start with the 'mipi-' or 'vendor-' prefix. Is there a missing 'amd-' here or is 'acp-' unique enough?
Quoted 8 lines
Quoted 3 lines
It's not SoundWire related MIPI/Vendor property.
Our BIOS changes are freeze. We can't modify this one as of this moment. We will consider it for next platform.Besides impact to BIOS it also has impact to drivers in other operating systems as well. So changing a property name is not something that can be taken lightly.
Agreed.
Quoted 3 lines
I'd also point out the use of the ACPI property is localized to an AMD specific driver not generic code.
Vijendar Mukunda
maintainerPATCH v3 2/9 ASoC: amd: ps: handle SoundWire interrupts in acp pci driver
In reply to Vijendar MukundaHandle SoundWire manager related interrupts in ACP PCI driver interrupt handler and schedule SoundWire manager work queue for further processing.
--- sound/soc/amd/ps/acp63.h | 4 ++++ sound/soc/amd/ps/pci-ps.c | 48 +++++++++++++++++++++++++++++++++++---- 2 files changed, 47 insertions(+), 5 deletions(-)
sound/soc/amd/ps/acp63.h +4 -0
@@ -88,6 +88,10 @@/* time in ms for acp timeout */ #define ACP_TIMEOUT 500 +#define ACP_SDW0_STAT BIT(21) +#define ACP_SDW1_STAT BIT(2) +#define ACP_ERROR_IRQ BIT(29) +enum acp_config {ACP_CONFIG_0 =0 ,ACP_CONFIG_1 ,
sound/soc/amd/ps/pci-ps.c +43 -5
72 lines not on this page · raw message
Signature · 1 line
2.34.1
Re: [PATCH V3 2/9] ASoC: amd: ps: handle SoundWire interrupts in acp pci driver
Quoted 16 lines
static void
acp63_disable_interrupts(void __iomem *acp_base)sound/soc/amd/ps/pci-ps.c +4
-1@@ -102,23 +103,60 @@ static irqreturn_t acp63_irq_handler(int irq, void *dev_id) {struct acp63_dev_data *adata;struct pdm_dev_data *ps_pdm_data; -u32 val; +struct amd_sdw_manager *amd_manager; +u32 ext_intr_stat, ext_intr_stat1; +u16 irq_flag =0 ;u16 pdev_index; adata = dev_id;if (!adata)return IRQ_NONE ; +/* ACP interrupts will be cleared by reading particular bit and writing
sound/soc/amd/ps/pci-ps.c static irqreturn_t acp63_irq_handler(int irq, void *dev_id) · line 124
Quoted 10 lines
sound/soc/amd/ps/pci-ps.c +10
-0+* same value to the status register. writing zero's doesn't have any +* effect. +* Bit by bit checking of IRQ field is implemented. +*/ + ext_intr_stat =readl (adata->acp63_base +ACP_EXTERNAL_INTR_STAT ); +if (ext_intr_stat &ACP_SDW0_STAT ) { +writel (ACP_SDW0_STAT , adata->acp63_base +ACP_EXTERNAL_INTR_STAT ); + pdev_index = adata->sdw0_dev_index; + amd_manager =dev_get_drvdata (&adata->pdev[pdev_index]->dev); +if (amd_manager)
can this test be false?
sound/soc/amd/ps/pci-ps.c static irqreturn_t acp63_irq_handler(int irq, void *dev_id) · line 134
Quoted 12 lines
sound/soc/amd/ps/pci-ps.c +9
-2+schedule_work (&amd_manager->amd_sdw_irq_thread); + irq_flag =1 ; + } - val =readl (adata->acp63_base +ACP_EXTERNAL_INTR_STAT ); -if (val &BIT (PDM_DMA_STAT )) { + ext_intr_stat1 =readl (adata->acp63_base +ACP_EXTERNAL_INTR_STAT1 ); +if (ext_intr_stat1 &ACP_SDW1_STAT ) { +writel (ACP_SDW1_STAT , adata->acp63_base +ACP_EXTERNAL_INTR_STAT1 ); + pdev_index = adata->sdw1_dev_index; + amd_manager =dev_get_drvdata (&adata->pdev[pdev_index]->dev); +if (amd_manager)
can this be false?
Quoted 30 lines
sound/soc/amd/ps/pci-ps.c +19
-2+schedule_work (&amd_manager->amd_sdw_irq_thread); + irq_flag =1 ; + } + +if (ext_intr_stat &ACP_ERROR_IRQ ) { +writel (ACP_ERROR_IRQ , adata->acp63_base +ACP_EXTERNAL_INTR_STAT ); +/* TODO: Report SoundWire Manager instance errors */ +writel (0 , adata->acp63_base +ACP_SW0_I2S_ERROR_REASON ); +writel (0 , adata->acp63_base +ACP_SW1_I2S_ERROR_REASON ); +writel (0 , adata->acp63_base +ACP_ERROR_STATUS ); + irq_flag =1 ; + } + +if (ext_intr_stat &BIT (PDM_DMA_STAT )) { pdev_index = adata->pdm_dev_index; ps_pdm_data =dev_get_drvdata (&adata->pdev[pdev_index]->dev);writel (BIT (PDM_DMA_STAT ), adata->acp63_base +ACP_EXTERNAL_INTR_STAT );if (ps_pdm_data->capture_stream)snd_pcm_period_elapsed (ps_pdm_data->capture_stream); -return IRQ_HANDLED ; + irq_flag =1 ; } -return IRQ_NONE ; +if (irq_flag) +return IRQ_HANDLED ; +else +return IRQ_NONE ; }static int sdw_amd_scan_controller (struct device *dev)
Mukunda,Vijendar
maintainerRe: [PATCH V3 2/9] ASoC: amd: ps: handle SoundWire interrupts in acp pci driver
Quoted 11 lines · Pierre-Louis Bossart
Quoted 11 lines
static void
acp63_disable_interrupts(void __iomem *acp_base)sound/soc/amd/ps/pci-ps.c +3
-1@@ -102,23 +103,60 @@ static irqreturn_t acp63_irq_handler(int irq, void *dev_id) {struct acp63_dev_data *adata;struct pdm_dev_data *ps_pdm_data; -u32 val; +struct amd_sdw_manager *amd_manager; +u32 ext_intr_stat, ext_intr_stat1; +u16 irq_flag =0 ;u16 pdev_index;
Quoted 15 lines
Quoted 4 lines
sound/soc/amd/ps/pci-ps.c +1
-0adata = dev_id;if (!adata)return IRQ_NONE ; +/* ACP interrupts will be cleared by reading particular bit and writing sound/soc/amd/ps/pci-ps.c static irqreturn_t acp63_irq_handler(int irq, void *dev_id) · line 124
Quoted 10 lines
sound/soc/amd/ps/pci-ps.c +10
-0+* same value to the status register. writing zero's doesn't have any +* effect. +* Bit by bit checking of IRQ field is implemented. +*/ + ext_intr_stat =readl (adata->acp63_base +ACP_EXTERNAL_INTR_STAT ); +if (ext_intr_stat &ACP_SDW0_STAT ) { +writel (ACP_SDW0_STAT , adata->acp63_base +ACP_EXTERNAL_INTR_STAT ); + pdev_index = adata->sdw0_dev_index; + amd_manager =dev_get_drvdata (&adata->pdev[pdev_index]->dev); +if (amd_manager)can this test be false?
No, this test won't be false.
It's only extra NULL check before scheduling work queue.
Quoted 5 lines
Quoted 5 lines
sound/soc/amd/ps/pci-ps.c +3
-0+schedule_work (&amd_manager->amd_sdw_irq_thread); + irq_flag =1 ; + }
Quoted 9 lines
sound/soc/amd/ps/pci-ps.c static irqreturn_t acp63_irq_handler(int irq, void *dev_id) · line 134
Quoted 8 lines
sound/soc/amd/ps/pci-ps.c +6
-2- val =readl (adata->acp63_base +ACP_EXTERNAL_INTR_STAT ); -if (val &BIT (PDM_DMA_STAT )) { + ext_intr_stat1 =readl (adata->acp63_base +ACP_EXTERNAL_INTR_STAT1 ); +if (ext_intr_stat1 &ACP_SDW1_STAT ) { +writel (ACP_SDW1_STAT , adata->acp63_base +ACP_EXTERNAL_INTR_STAT1 ); + pdev_index = adata->sdw1_dev_index; + amd_manager =dev_get_drvdata (&adata->pdev[pdev_index]->dev); +if (amd_manager)can this be false?
No, this test won't be false.
It's only extra NULL check before scheduling work queue.
Quoted 31 lines
Quoted 31 lines
sound/soc/amd/ps/pci-ps.c +19
-2+schedule_work (&amd_manager->amd_sdw_irq_thread); + irq_flag =1 ; + } + +if (ext_intr_stat &ACP_ERROR_IRQ ) { +writel (ACP_ERROR_IRQ , adata->acp63_base +ACP_EXTERNAL_INTR_STAT ); +/* TODO: Report SoundWire Manager instance errors */ +writel (0 , adata->acp63_base +ACP_SW0_I2S_ERROR_REASON ); +writel (0 , adata->acp63_base +ACP_SW1_I2S_ERROR_REASON ); +writel (0 , adata->acp63_base +ACP_ERROR_STATUS ); + irq_flag =1 ; + } + +if (ext_intr_stat &BIT (PDM_DMA_STAT )) { pdev_index = adata->pdm_dev_index; ps_pdm_data =dev_get_drvdata (&adata->pdev[pdev_index]->dev);writel (BIT (PDM_DMA_STAT ), adata->acp63_base +ACP_EXTERNAL_INTR_STAT );if (ps_pdm_data->capture_stream)snd_pcm_period_elapsed (ps_pdm_data->capture_stream); -return IRQ_HANDLED ; + irq_flag =1 ; } -return IRQ_NONE ; +if (irq_flag) +return IRQ_HANDLED ; +else +return IRQ_NONE ; }static int sdw_amd_scan_controller (struct device *dev)
Vijendar Mukunda
maintainerPATCH v3 3/9 ASoC: amd: ps: add SoundWire dma driver
In reply to Vijendar MukundaSoundWire DMA platform driver binds to the platform device created by ACP PCI device. SoundWire DMA driver registers ALSA DMA component with ASoC framework.
--- sound/soc/amd/ps/acp63.h | 5 +++ sound/soc/amd/ps/ps-sdw-dma.c | 70 +++++++++++++++++++++++++++++++++++ 2 files changed, 75 insertions(+) create mode 100644 sound/soc/amd/ps/ps-sdw-dma.c
sound/soc/amd/ps/acp63.h +5 -0
@@ -148,6 +148,11 @@ struct pdm_dev_data {struct snd_pcm_substream *capture_stream; }; +struct sdw_dma_dev_data { +void __iomem *acp_base; +struct mutex *acp_lock;/* used to protect acp common register access */ +}; +/** * struct acp63_dev_data - acp pci driver context * @acp63_base: acp mmio base
sound/soc/amd/ps/ps-sdw-dma.c new file +70 -0
70 lines not on this page · raw message
Signature · 1 line
2.34.1
Vijendar Mukunda
maintainerPATCH v3 4/9 ASoC: amd: ps: add SoundWire dma driver dma ops
In reply to Vijendar MukundaAdd SoundWire DMA driver dma ops for Pink Sardine platform.
--- sound/soc/amd/ps/acp63.h | 72 ++++++ sound/soc/amd/ps/ps-sdw-dma.c | 415 ++++++++++++++++++++++++++++++++++ 2 files changed, 487 insertions(+)
sound/soc/amd/ps/acp63.h +72 -0
@@ -91,6 +91,48 @@#define ACP_SDW0_STAT BIT(21)#define ACP_SDW1_STAT BIT(2)#define ACP_ERROR_IRQ BIT(29) +#define ACP_AUDIO0_TX_THRESHOLD 0x1c +#define ACP_AUDIO1_TX_THRESHOLD 0x1a +#define ACP_AUDIO2_TX_THRESHOLD 0x18 +#define ACP_AUDIO0_RX_THRESHOLD 0x1b +#define ACP_AUDIO1_RX_THRESHOLD 0x19 +#define ACP_AUDIO2_RX_THRESHOLD 0x17 +#define ACP_P1_AUDIO1_TX_THRESHOLD BIT(6) +#define ACP_P1_AUDIO1_RX_THRESHOLD BIT(5) +#define ACP_SDW_DMA_IRQ_MASK 0x1F800000 +#define ACP_P1_SDW_DMA_IRQ_MASK 0x60 +#define ACP63_SDW0_DMA_MAX_STREAMS 6 +#define ACP63_SDW1_DMA_MAX_STREAMS 2 +#define ACP_P1_AUDIO_TX_THRESHOLD 6 +#define SDW0_DMA_TX_IRQ_MASK (i) (ACP_AUDIO0_TX_THRESHOLD - (2 * (i))) +#define SDW0_DMA_RX_IRQ_MASK (i) (ACP_AUDIO0_RX_THRESHOLD - (2 * (i))) +#define SDW1_DMA_IRQ_MASK (i) (ACP_P1_AUDIO_TX_THRESHOLD - (i)) + +#define ACP_DELAY_US 5 +#define ACP_SDW_RING_BUFF_ADDR_OFFSET (128 * 1024) +#define SDW0_MEM_WINDOW_START 0x4800000 +#define ACP_SDW_SRAM_PTE_OFFSET 0x03800400 +#define SDW0_PTE_OFFSET 0x400 +#define SDW_FIFO_SIZE 0x100 +#define SDW_DMA_SIZE 0x40 +#define ACP_SDW0_FIFO_OFFSET 0x100 +#define ACP_SDW_PTE_OFFSET 0x100 +#define SDW_FIFO_OFFSET 0x100 +#define SDW_PTE_OFFSET (i) (SDW0_PTE_OFFSET + ((i) * 0x600)) +#define ACP_SDW_FIFO_OFFSET (i) (ACP_SDW0_FIFO_OFFSET + ((i) * 0x500)) +#define SDW_MEM_WINDOW_START (i) (SDW0_MEM_WINDOW_START + ((i) * 0xC0000)) + +#define SDW_PLAYBACK_MIN_NUM_PERIODS 2 +#define SDW_PLAYBACK_MAX_NUM_PERIODS 8 +#define SDW_PLAYBACK_MAX_PERIOD_SIZE 8192 +#define SDW_PLAYBACK_MIN_PERIOD_SIZE 1024 +#define SDW_CAPTURE_MIN_NUM_PERIODS 2 +#define SDW_CAPTURE_MAX_NUM_PERIODS 8 +#define SDW_CAPTURE_MAX_PERIOD_SIZE 8192 +#define SDW_CAPTURE_MIN_PERIOD_SIZE 1024 + +#define SDW_MAX_BUFFER (SDW_PLAYBACK_MAX_PERIOD_SIZE * SDW_PLAYBACK_MAX_NUM_PERIODS) +#define SDW_MIN_BUFFER SDW_MAX_BUFFERenum acp_config {ACP_CONFIG_0 =0 ,
@@ -151,6 +193,36 @@ struct pdm_dev_data {struct sdw_dma_dev_data {void __iomem *acp_base;struct mutex *acp_lock;/* used to protect acp common register access */ +struct snd_pcm_substream *sdw0_dma_stream[ACP63_SDW0_DMA_MAX_STREAMS ]; +struct snd_pcm_substream *sdw1_dma_stream[ACP63_SDW1_DMA_MAX_STREAMS ]; +}; + +struct acp_sdw_dma_stream { +u16 num_pages; +u16 channels; +u32 stream_id; +u32 instance; +dma_addr_t dma_addr; +u64 bytescount; +}; + +union acp_sdw_dma_count { +struct { +u32 low; +u32 high; + } bcount; +u64 bytescount; +}; + +struct sdw_dma_ring_buf_reg { +u32 reg_dma_size; +u32 reg_fifo_addr; +u32 reg_fifo_size; +u32 reg_ring_buf_size; +u32 reg_ring_buf_addr; +u32 water_mark_size_reg; +u32 pos_low_reg; +u32 pos_high_reg; };/**
sound/soc/amd/ps/ps-sdw-dma.c +415 -0
427 lines not on this page · raw message
Signature · 1 line
2.34.1
Re: [PATCH V3 4/9] ASoC: amd: ps: add SoundWire dma driver dma ops
Quoted 43 lines
sound/soc/amd/ps/ps-sdw-dma.c +42
-0+static int acp63_sdw_dma_start (struct snd_pcm_substream *substream,void __iomem *acp_base) +{ +struct acp_sdw_dma_stream *stream; +u32 stream_id; +u32 sdw_dma_en_reg; +u32 sdw_dma_en_stat_reg; +u32 sdw_dma_stat; + + stream = substream->runtime->private_data; + stream_id = stream->stream_id; +switch (stream->instance) { +case ACP_SDW0 : + sdw_dma_en_reg = sdw0_dma_enable_reg[stream_id]; +break ; +case ACP_SDW1 : + sdw_dma_en_reg = sdw1_dma_enable_reg[stream_id]; +break ; +default : +return -EINVAL ; + } +writel (0x01 , acp_base + sdw_dma_en_reg); + sdw_dma_en_stat_reg = sdw_dma_en_reg +4 ; +return readl_poll_timeout (acp_base + sdw_dma_en_stat_reg, sdw_dma_stat, + (sdw_dma_stat &BIT (0 )),ACP_DELAY_US ,ACP_COUNTER ); +} + +static int acp63_sdw_dma_stop (struct snd_pcm_substream *substream,void __iomem *acp_base) +{ +struct acp_sdw_dma_stream *stream; +u32 stream_id; +u32 sdw_dma_en_reg; +u32 sdw_dma_en_stat_reg; +u32 sdw_dma_stat; + + stream = substream->runtime->private_data; + stream_id = stream->stream_id; +switch (stream->instance) { +case ACP_SDW0 : + sdw_dma_en_reg = sdw0_dma_enable_reg[stream_id]; +break ; +case ACP_SDW1 : + sdw_dma_en_reg = sdw1_dma_enable_reg[stream_id];
sound/soc/amd/ps/ps-sdw-dma.c line 399
Quoted 10 lines
sound/soc/amd/ps/ps-sdw-dma.c +10
-0+break ; +default : +return -EINVAL ; + } + +writel (0 , acp_base + sdw_dma_en_reg); + sdw_dma_en_stat_reg = sdw_dma_en_reg +4 ; +return readl_poll_timeout (acp_base + sdw_dma_en_stat_reg, sdw_dma_stat, !sdw_dma_stat, +ACP_DELAY_US ,ACP_COUNTER ); +}
these start/stop routines look mostly the same, except for the value to be written in the register. Maybe they can be factored with a common helper, e.g. acp63_sdw_dma_enable(true/false).
Quoted 27 lines
sound/soc/amd/ps/ps-sdw-dma.c +27
-0+ +static int acp63_sdw_dma_trigger (struct snd_soc_component *comp, +struct snd_pcm_substream *substream, +int cmd) +{ +struct sdw_dma_dev_data *sdw_data; +int ret; + + sdw_data =dev_get_drvdata (comp->dev); +switch (cmd) { +case SNDRV_PCM_TRIGGER_START : +case SNDRV_PCM_TRIGGER_PAUSE_RELEASE : +case SNDRV_PCM_TRIGGER_RESUME : + ret =acp63_sdw_dma_start (substream, sdw_data->acp_base); +break ; +case SNDRV_PCM_TRIGGER_PAUSE_PUSH : +case SNDRV_PCM_TRIGGER_SUSPEND : +case SNDRV_PCM_TRIGGER_STOP : + ret =acp63_sdw_dma_stop (substream, sdw_data->acp_base); +break ; +default : + ret = -EINVAL ; + } +if (ret) +dev_err (comp->dev,"trigger %d failed: %d" , cmd, ret); +return ret; +}
Mukunda,Vijendar
maintainerRe: [PATCH V3 4/9] ASoC: amd: ps: add SoundWire dma driver dma ops
Quoted 47 lines · Pierre-Louis Bossart
Quoted 47 lines
sound/soc/amd/ps/ps-sdw-dma.c +47
-0+static int acp63_sdw_dma_start (struct snd_pcm_substream *substream,void __iomem *acp_base) +{ +struct acp_sdw_dma_stream *stream; +u32 stream_id; +u32 sdw_dma_en_reg; +u32 sdw_dma_en_stat_reg; +u32 sdw_dma_stat; + + stream = substream->runtime->private_data; + stream_id = stream->stream_id; +switch (stream->instance) { +case ACP_SDW0 : + sdw_dma_en_reg = sdw0_dma_enable_reg[stream_id]; +break ; +case ACP_SDW1 : + sdw_dma_en_reg = sdw1_dma_enable_reg[stream_id]; +break ; +default : +return -EINVAL ; + } +writel (0x01 , acp_base + sdw_dma_en_reg); + sdw_dma_en_stat_reg = sdw_dma_en_reg +4 ; +return readl_poll_timeout (acp_base + sdw_dma_en_stat_reg, sdw_dma_stat, + (sdw_dma_stat &BIT (0 )),ACP_DELAY_US ,ACP_COUNTER ); +} + +static int acp63_sdw_dma_stop (struct snd_pcm_substream *substream,void __iomem *acp_base) +{ +struct acp_sdw_dma_stream *stream; +u32 stream_id; +u32 sdw_dma_en_reg; +u32 sdw_dma_en_stat_reg; +u32 sdw_dma_stat; + + stream = substream->runtime->private_data; + stream_id = stream->stream_id; +switch (stream->instance) { +case ACP_SDW0 : + sdw_dma_en_reg = sdw0_dma_enable_reg[stream_id]; +break ; +case ACP_SDW1 : + sdw_dma_en_reg = sdw1_dma_enable_reg[stream_id]; +break ; +default : +return -EINVAL ; + } +
Quoted 8 lines
sound/soc/amd/ps/ps-sdw-dma.c line 399
Quoted 5 lines
sound/soc/amd/ps/ps-sdw-dma.c +5
-0+writel (0 , acp_base + sdw_dma_en_reg); + sdw_dma_en_stat_reg = sdw_dma_en_reg +4 ; +return readl_poll_timeout (acp_base + sdw_dma_en_stat_reg, sdw_dma_stat, !sdw_dma_stat, +ACP_DELAY_US ,ACP_COUNTER ); +}these start/stop routines look mostly the same, except for the value to be written in the register. Maybe they can be factored with a common helper, e.g.
acp63_sdw_dma_enable(true/false).
Yes, it can be refactored. Will fix it.
Quoted 27 lines
Quoted 27 lines
sound/soc/amd/ps/ps-sdw-dma.c +27
-0+ +static int acp63_sdw_dma_trigger (struct snd_soc_component *comp, +struct snd_pcm_substream *substream, +int cmd) +{ +struct sdw_dma_dev_data *sdw_data; +int ret; + + sdw_data =dev_get_drvdata (comp->dev); +switch (cmd) { +case SNDRV_PCM_TRIGGER_START : +case SNDRV_PCM_TRIGGER_PAUSE_RELEASE : +case SNDRV_PCM_TRIGGER_RESUME : + ret =acp63_sdw_dma_start (substream, sdw_data->acp_base); +break ; +case SNDRV_PCM_TRIGGER_PAUSE_PUSH : +case SNDRV_PCM_TRIGGER_SUSPEND : +case SNDRV_PCM_TRIGGER_STOP : + ret =acp63_sdw_dma_stop (substream, sdw_data->acp_base); +break ; +default : + ret = -EINVAL ; + } +if (ret) +dev_err (comp->dev,"trigger %d failed: %d" , cmd, ret); +return ret; +}
Vijendar Mukunda
maintainerPATCH v3 5/9 ASoC: amd: ps: add support for SoundWire DMA interrupts
In reply to Vijendar MukundaMove to request_threaded_irq and use thread for handling SoundWire DMA interrupts.
Whenever audio data equal to the SoundWire FIFO watermark level are produced/consumed, interrupt is generated. Acknowledge the interrupt and wake up the irq thread.
--- sound/soc/amd/ps/acp63.h | 18 +++++++++ sound/soc/amd/ps/pci-ps.c | 84 ++++++++++++++++++++++++++++++++++++++- 2 files changed, 100 insertions(+), 2 deletions(-)
sound/soc/amd/ps/acp63.h +18 -0
@@ -175,6 +175,20 @@ enum acp_pdev_mask { ACP63_SDW_PDM_DEV_MASK, }; +enum amd_sdw0_channel { +ACP_SDW0_AUDIO0_TX =0 , +ACP_SDW0_AUDIO1_TX , +ACP_SDW0_AUDIO2_TX , +ACP_SDW0_AUDIO0_RX , +ACP_SDW0_AUDIO1_RX , +ACP_SDW0_AUDIO2_RX , +}; + +enum amd_sdw1_channel { +ACP_SDW1_AUDIO1_TX , +ACP_SDW1_AUDIO1_RX , +}; +struct pdm_stream_instance {u16 num_pages;u16 channels;
@@ -239,6 +253,8 @@ struct sdw_dma_ring_buf_reg {* @sdw0_dev_index: SoundWire Manager-0 platform device index * @sdw1_dev_index: SoundWire Manager-1 platform device index * @sdw_dma_dev_index: SoundWire DMA controller platform device index +* @sdw0-dma_intr_stat: DMA interrupt status array for SoundWire manager-SW0 instance +* @sdw_dma_intr_stat: DMA interrupt status array for SoundWire manager-SW1 instance * @acp_reset: flag set to true when bus reset is applied across all * the active SoundWire manager instances */
@@ -256,6 +272,8 @@ struct acp63_dev_data {u16 sdw0_dev_index;u16 sdw1_dev_index;u16 sdw_dma_dev_index; +u16 sdw0_dma_intr_stat[ACP63_SDW0_DMA_MAX_STREAMS ]; +u16 sdw1_dma_intr_stat[ACP63_SDW1_DMA_MAX_STREAMS ];bool acp_reset; };
sound/soc/amd/ps/pci-ps.c +82 -2
110 lines not on this page · raw message
Signature · 1 line
2.34.1
Re: [PATCH V3 5/9] ASoC: amd: ps: add support for SoundWire DMA interrupts
sound/soc/amd/ps/acp63.h enum acp_pdev_mask { · line 189
Quoted 13 lines
sound/soc/amd/ps/acp63.h +12
-0+enum amd_sdw0_channel { +ACP_SDW0_AUDIO0_TX =0 , +ACP_SDW0_AUDIO1_TX , +ACP_SDW0_AUDIO2_TX , +ACP_SDW0_AUDIO0_RX , +ACP_SDW0_AUDIO1_RX , +ACP_SDW0_AUDIO2_RX , +}; + +enum amd_sdw1_channel { +ACP_SDW1_AUDIO1_TX , +ACP_SDW1_AUDIO1_RX ,
any specify reason why SDW0 starts with AUDIO0 and SDW1 with AUDIO1?
Quoted 34 lines
sound/soc/amd/ps/acp63.h +6
-0+}; +struct pdm_stream_instance {u16 num_pages;u16 channels;@@ -239,6 +253,8 @@ struct sdw_dma_ring_buf_reg {* @sdw0_dev_index: SoundWire Manager-0 platform device index * @sdw1_dev_index: SoundWire Manager-1 platform device index * @sdw_dma_dev_index: SoundWire DMA controller platform device index +* @sdw0-dma_intr_stat: DMA interrupt status array for SoundWire manager-SW0 instance +* @sdw_dma_intr_stat: DMA interrupt status array for SoundWire manager-SW1 instance * @acp_reset: flag set to true when bus reset is applied across all * the active SoundWire manager instances */ @@ -256,6 +272,8 @@ struct acp63_dev_data {u16 sdw0_dev_index;u16 sdw1_dev_index;u16 sdw_dma_dev_index; +u16 sdw0_dma_intr_stat[ACP63_SDW0_DMA_MAX_STREAMS ]; +u16 sdw1_dma_intr_stat[ACP63_SDW1_DMA_MAX_STREAMS ];bool acp_reset; };sound/soc/amd/ps/pci-ps.c +3
-0@@ -99,14 +99,44 @@ static int acp63_deinit(void __iomem *acp_base, struct device *dev)return 0 ; } +static irqreturn_t acp63_irq_thread (int irq,void *context) +{ +struct sdw_dma_dev_data *sdw_dma_data;
sound/soc/amd/ps/pci-ps.c static int acp63_deinit(void __iomem *acp_base, struct device *dev) · line 114
Quoted 10 lines
sound/soc/amd/ps/pci-ps.c +10
-0+struct acp63_dev_data *adata = context; +u32 stream_index; +u16 pdev_index; + + pdev_index = adata->sdw_dma_dev_index; + sdw_dma_data =dev_get_drvdata (&adata->pdev[pdev_index]->dev); + +for (stream_index =0 ; stream_index <ACP63_SDW0_DMA_MAX_STREAMS ; stream_index++) { +if (adata->sdw0_dma_intr_stat[stream_index]) { +if (sdw_dma_data->sdw0_dma_stream[stream_index])
can this test be false?
sound/soc/amd/ps/pci-ps.c static int acp63_deinit(void __iomem *acp_base, struct device *dev) · line 121
Quoted 7 lines
sound/soc/amd/ps/pci-ps.c +7
-0+snd_pcm_period_elapsed (sdw_dma_data->sdw0_dma_stream[stream_index]); + adata->sdw0_dma_intr_stat[stream_index] =0 ; + } + } +for (stream_index =0 ; stream_index <ACP63_SDW1_DMA_MAX_STREAMS ; stream_index++) { +if (adata->sdw1_dma_intr_stat[stream_index]) { +if (sdw_dma_data->sdw1_dma_stream[stream_index])
can this test be false?
Quoted 55 lines
sound/soc/amd/ps/pci-ps.c +40
-0+snd_pcm_period_elapsed (sdw_dma_data->sdw1_dma_stream[stream_index]); + adata->sdw1_dma_intr_stat[stream_index] =0 ; + } + } +return IRQ_HANDLED ; +} +static irqreturn_t acp63_irq_handler (int irq,void *dev_id) {struct acp63_dev_data *adata;struct pdm_dev_data *ps_pdm_data;struct amd_sdw_manager *amd_manager;u32 ext_intr_stat, ext_intr_stat1; +u32 stream_id =0 ;u16 irq_flag =0 ; +u16 sdw_dma_irq_flag =0 ;u16 pdev_index; +u16 index; adata = dev_id;if (!adata)@@ -153,6 +183,56 @@ static irqreturn_t acp63_irq_handler(int irq, void *dev_id)snd_pcm_period_elapsed (ps_pdm_data->capture_stream); irq_flag =1 ; } +if (ext_intr_stat &ACP_SDW_DMA_IRQ_MASK ) { +for (index =ACP_AUDIO2_RX_THRESHOLD ; index <=ACP_AUDIO0_TX_THRESHOLD ; index++) { +if (ext_intr_stat &BIT (index)) { +writel (BIT (index), adata->acp63_base +ACP_EXTERNAL_INTR_STAT ); +switch (index) { +case ACP_AUDIO0_TX_THRESHOLD : + stream_id =ACP_SDW0_AUDIO0_TX ; +break ; +case ACP_AUDIO1_TX_THRESHOLD : + stream_id =ACP_SDW0_AUDIO1_TX ; +break ; +case ACP_AUDIO2_TX_THRESHOLD : + stream_id =ACP_SDW0_AUDIO2_TX ; +break ; +case ACP_AUDIO0_RX_THRESHOLD : + stream_id =ACP_SDW0_AUDIO0_RX ; +break ; +case ACP_AUDIO1_RX_THRESHOLD : + stream_id =ACP_SDW0_AUDIO1_RX ; +break ; +case ACP_AUDIO2_RX_THRESHOLD : + stream_id =ACP_SDW0_AUDIO2_RX ; +break ; + } + + adata->sdw0_dma_intr_stat[stream_id] =1 ; + sdw_dma_irq_flag =1 ; + } + } + }
sound/soc/amd/ps/pci-ps.c static irqreturn_t acp63_irq_handler(int irq, void *dev_id) · line 225
Quoted 10 lines
sound/soc/amd/ps/pci-ps.c +10
-0+ +/* SDW1 BT RX */ +if (ext_intr_stat1 &ACP_P1_AUDIO1_RX_THRESHOLD ) { +writel (ACP_P1_AUDIO1_RX_THRESHOLD , + adata->acp63_base +ACP_EXTERNAL_INTR_STAT1 ); + adata->sdw1_dma_intr_stat[ACP_SDW1_AUDIO1_RX ] =1 ; + sdw_dma_irq_flag =1 ; + } + +/* SDW1 BT TX*/
keep spaces before */
Quoted 24 lines
sound/soc/amd/ps/pci-ps.c +12
-2+if (ext_intr_stat1 &ACP_P1_AUDIO1_TX_THRESHOLD ) { +writel (ACP_P1_AUDIO1_TX_THRESHOLD , + adata->acp63_base +ACP_EXTERNAL_INTR_STAT1 ); + adata->sdw1_dma_intr_stat[ACP_SDW1_AUDIO1_TX ] =1 ; + sdw_dma_irq_flag =1 ; + } + +if (sdw_dma_irq_flag) +return IRQ_WAKE_THREAD ; +if (irq_flag)return IRQ_HANDLED ;else @@ -544,8 +624,8 @@ static int snd_acp63_probe(struct pci_dev *pci, ret =acp63_init (adata->acp63_base, &pci->dev);if (ret) goto release_regions; - ret =devm_request_irq (&pci->dev, pci->irq, acp63_irq_handler, - irqflags,"ACP_PCI_IRQ" , adata); + ret =devm_request_threaded_irq (&pci->dev, pci->irq, acp63_irq_handler, + acp63_irq_thread, irqflags,"ACP_PCI_IRQ" , adata);if (ret) {dev_err (&pci->dev,"ACP PCI IRQ request failed\n" ); goto de_init;
Mukunda,Vijendar
maintainerRe: [PATCH V3 5/9] ASoC: amd: ps: add support for SoundWire DMA interrupts
Quoted 5 lines · Pierre-Louis Bossart
Quoted 5 lines
sound/soc/amd/ps/acp63.h +5
-0+enum amd_sdw0_channel { +ACP_SDW0_AUDIO0_TX =0 , +ACP_SDW0_AUDIO1_TX , +ACP_SDW0_AUDIO2_TX , +ACP_SDW0_AUDIO0_RX ,
Quoted 8 lines
sound/soc/amd/ps/acp63.h enum acp_pdev_mask { · line 189
Quoted 7 lines
sound/soc/amd/ps/acp63.h +7
-0+ACP_SDW0_AUDIO1_RX , + ACP_SDW0_AUDIO2_RX, +}; + +enum amd_sdw1_channel { +ACP_SDW1_AUDIO1_TX , + ACP_SDW1_AUDIO1_RX,any specify reason why SDW0 starts with AUDIO0 and SDW1 with AUDIO1?
Currently, SDW0 instance uses 3 TX, 3 RX ports whereas SDW1 instance uses 1 TX, 1 RX ports.
For SDW1 instance, It uses AUDIO1 register set as per our register spec. We have mantained similar mapping convention here for enums as well. We have already described SoundWire instance TX/RX ports mapping in comments in amd_manager.h file.
Please refer comments mentioned in amd_manager.h file.
Quoted 32 lines
Quoted 32 lines
sound/soc/amd/ps/acp63.h +6
-0+}; +struct pdm_stream_instance {u16 num_pages;u16 channels;@@ -239,6 +253,8 @@ struct sdw_dma_ring_buf_reg {* @sdw0_dev_index: SoundWire Manager-0 platform device index * @sdw1_dev_index: SoundWire Manager-1 platform device index * @sdw_dma_dev_index: SoundWire DMA controller platform device index +* @sdw0-dma_intr_stat: DMA interrupt status array for SoundWire manager-SW0 instance +* @sdw_dma_intr_stat: DMA interrupt status array for SoundWire manager-SW1 instance * @acp_reset: flag set to true when bus reset is applied across all * the active SoundWire manager instances */ @@ -256,6 +272,8 @@ struct acp63_dev_data {u16 sdw0_dev_index;u16 sdw1_dev_index;u16 sdw_dma_dev_index; +u16 sdw0_dma_intr_stat[ACP63_SDW0_DMA_MAX_STREAMS ]; +u16 sdw1_dma_intr_stat[ACP63_SDW1_DMA_MAX_STREAMS ];bool acp_reset; };sound/soc/amd/ps/pci-ps.c +0
-0@@ -99,14 +99,44 @@ static int acp63_deinit(void __iomem *acp_base, struct device *dev)return 0 ; }
Quoted 14 lines
sound/soc/amd/ps/pci-ps.c static int acp63_deinit(void __iomem *acp_base, struct device *dev) · line 114
Quoted 13 lines
sound/soc/amd/ps/pci-ps.c +13
-0+static irqreturn_t acp63_irq_thread (int irq,void *context) +{ +struct sdw_dma_dev_data *sdw_dma_data; +struct acp63_dev_data *adata = context; +u32 stream_index; +u16 pdev_index; + + pdev_index = adata->sdw_dma_dev_index; + sdw_dma_data =dev_get_drvdata (&adata->pdev[pdev_index]->dev); + +for (stream_index =0 ; stream_index <ACP63_SDW0_DMA_MAX_STREAMS ; stream_index++) { +if (adata->sdw0_dma_intr_stat[stream_index]) { +if (sdw_dma_data->sdw0_dma_stream[stream_index])can this test be false?
Our intention is to invoke period elapsed callback for active substreams based on irq received. Its good to have a NULL check for substream.
Quoted 9 lines
sound/soc/amd/ps/pci-ps.c static int acp63_deinit(void __iomem *acp_base, struct device *dev) · line 121
Quoted 8 lines
sound/soc/amd/ps/pci-ps.c +7
-0+snd_pcm_period_elapsed (sdw_dma_data->sdw0_dma_stream[stream_index]); + adata->sdw0_dma_intr_stat[stream_index] =0 ; + } + } +for (stream_index =0 ; stream_index <ACP63_SDW1_DMA_MAX_STREAMS ; stream_index++) { +if (adata->sdw1_dma_intr_stat[stream_index]) { +if (sdw_dma_data->sdw1_dma_stream[stream_index])can this test be false?
Please refer above comments.
Quoted 59 lines
Quoted 59 lines
sound/soc/amd/ps/pci-ps.c +43
-0+snd_pcm_period_elapsed (sdw_dma_data->sdw1_dma_stream[stream_index]); + adata->sdw1_dma_intr_stat[stream_index] =0 ; + } + } +return IRQ_HANDLED ; +} +static irqreturn_t acp63_irq_handler (int irq,void *dev_id) {struct acp63_dev_data *adata;struct pdm_dev_data *ps_pdm_data;struct amd_sdw_manager *amd_manager;u32 ext_intr_stat, ext_intr_stat1; +u32 stream_id =0 ;u16 irq_flag =0 ; +u16 sdw_dma_irq_flag =0 ;u16 pdev_index; +u16 index; adata = dev_id;if (!adata)@@ -153,6 +183,56 @@ static irqreturn_t acp63_irq_handler(int irq, void *dev_id)snd_pcm_period_elapsed (ps_pdm_data->capture_stream); irq_flag =1 ; } +if (ext_intr_stat &ACP_SDW_DMA_IRQ_MASK ) { +for (index =ACP_AUDIO2_RX_THRESHOLD ; index <=ACP_AUDIO0_TX_THRESHOLD ; index++) { +if (ext_intr_stat &BIT (index)) { +writel (BIT (index), adata->acp63_base +ACP_EXTERNAL_INTR_STAT ); +switch (index) { +case ACP_AUDIO0_TX_THRESHOLD : + stream_id =ACP_SDW0_AUDIO0_TX ; +break ; +case ACP_AUDIO1_TX_THRESHOLD : + stream_id =ACP_SDW0_AUDIO1_TX ; +break ; +case ACP_AUDIO2_TX_THRESHOLD : + stream_id =ACP_SDW0_AUDIO2_TX ; +break ; +case ACP_AUDIO0_RX_THRESHOLD : + stream_id =ACP_SDW0_AUDIO0_RX ; +break ; +case ACP_AUDIO1_RX_THRESHOLD : + stream_id =ACP_SDW0_AUDIO1_RX ; +break ; +case ACP_AUDIO2_RX_THRESHOLD : + stream_id =ACP_SDW0_AUDIO2_RX ; +break ; + } + + adata->sdw0_dma_intr_stat[stream_id] =1 ; + sdw_dma_irq_flag =1 ; + } + } + } + +/* SDW1 BT RX */ +if (ext_intr_stat1 &ACP_P1_AUDIO1_RX_THRESHOLD ) {
Quoted 8 lines
sound/soc/amd/ps/pci-ps.c static irqreturn_t acp63_irq_handler(int irq, void *dev_id) · line 225
Quoted 7 lines
sound/soc/amd/ps/pci-ps.c +7
-0+writel (ACP_P1_AUDIO1_RX_THRESHOLD , + adata->acp63_base +ACP_EXTERNAL_INTR_STAT1 ); + adata->sdw1_dma_intr_stat[ACP_SDW1_AUDIO1_RX ] =1 ; + sdw_dma_irq_flag =1 ; + } + +/* SDW1 BT TX*/ keep spaces before */
will fix it.
Quoted 25 lines
Quoted 25 lines
sound/soc/amd/ps/pci-ps.c +12
-2+if (ext_intr_stat1 &ACP_P1_AUDIO1_TX_THRESHOLD ) { +writel (ACP_P1_AUDIO1_TX_THRESHOLD , + adata->acp63_base +ACP_EXTERNAL_INTR_STAT1 ); + adata->sdw1_dma_intr_stat[ACP_SDW1_AUDIO1_TX ] =1 ; + sdw_dma_irq_flag =1 ; + } + +if (sdw_dma_irq_flag) +return IRQ_WAKE_THREAD ; +if (irq_flag)return IRQ_HANDLED ;else @@ -544,8 +624,8 @@ static int snd_acp63_probe(struct pci_dev *pci, ret =acp63_init (adata->acp63_base, &pci->dev);if (ret) goto release_regions; - ret =devm_request_irq (&pci->dev, pci->irq, acp63_irq_handler, - irqflags,"ACP_PCI_IRQ" , adata); + ret =devm_request_threaded_irq (&pci->dev, pci->irq, acp63_irq_handler, + acp63_irq_thread, irqflags,"ACP_PCI_IRQ" , adata);if (ret) {dev_err (&pci->dev,"ACP PCI IRQ request failed\n" ); goto de_init;
Vijendar Mukunda
maintainerPATCH v3 6/9 ASoC: amd: ps: add pm ops support for SoundWire dma driver
In reply to Vijendar MukundaAdd support pm ops support for SoundWire dma driver.
--- sound/soc/amd/ps/ps-sdw-dma.c | 98 ++++++++++++++++++++++++++++++++++- 1 file changed, 96 insertions(+), 2 deletions(-)
sound/soc/amd/ps/ps-sdw-dma.c +96 -2
@@ -12,6 +12,7 @@#include <sound/pcm_params.h> #include <sound/soc.h> #include <sound/soc-dai.h> +#include <linux/pm_runtime.h> #include <linux/soundwire/sdw_amd.h> #include "acp63.h"
@@ -102,6 +103,29 @@ static const struct snd_pcm_hardware acp63_sdw_hardware_capture = { .periods_max = SDW_CAPTURE_MAX_NUM_PERIODS, }; +static void acp63_enable_disable_sdw_dma_interrupts (void __iomem *acp_base,bool enable) +{ +u32 ext_intr_cntl, ext_intr_cntl1; +u32 irq_mask =ACP_SDW_DMA_IRQ_MASK ; +u32 irq_mask1 =ACP_P1_SDW_DMA_IRQ_MASK ; + +if (enable) { + ext_intr_cntl =readl (acp_base +ACP_EXTERNAL_INTR_CNTL ); + ext_intr_cntl |= irq_mask; +writel (ext_intr_cntl, acp_base +ACP_EXTERNAL_INTR_CNTL ); + ext_intr_cntl1 =readl (acp_base +ACP_EXTERNAL_INTR_CNTL1 ); + ext_intr_cntl1 |= irq_mask1; +writel (ext_intr_cntl1, acp_base +ACP_EXTERNAL_INTR_CNTL1 ); + }else { + ext_intr_cntl =readl (acp_base +ACP_EXTERNAL_INTR_CNTL ); + ext_intr_cntl &= ~irq_mask; +writel (ext_intr_cntl, acp_base +ACP_EXTERNAL_INTR_CNTL ); + ext_intr_cntl1 =readl (acp_base +ACP_EXTERNAL_INTR_CNTL1 ); + ext_intr_cntl1 &= ~irq_mask1; +writel (ext_intr_cntl1, acp_base +ACP_EXTERNAL_INTR_CNTL1 ); + } +} +static void acp63_config_dma (struct acp_sdw_dma_stream *stream,void __iomem *acp_base,u32 stream_id) {
@@ -464,16 +488,86 @@ static int acp63_sdw_platform_probe(struct platform_device *pdev) status =devm_snd_soc_register_component (&pdev->dev, &acp63_sdw_component,NULL ,0 ); -if (status) +if (status) {dev_err (&pdev->dev,"Fail to register sdw dma component\n" ); +return status; + } +pm_runtime_set_autosuspend_delay (&pdev->dev,ACP_SUSPEND_DELAY_MS ); +pm_runtime_use_autosuspend (&pdev->dev); +pm_runtime_mark_last_busy (&pdev->dev); +pm_runtime_set_active (&pdev->dev); +pm_runtime_enable (&pdev->dev); +return 0 ; +} -return status; +static int acp63_sdw_platform_remove (struct platform_device *pdev) +{ +pm_runtime_disable (&pdev->dev); +return 0 ; } +static int acp_restore_sdw_dma_config (struct sdw_dma_dev_data *sdw_data) +{ +struct acp_sdw_dma_stream *stream; +struct snd_pcm_substream *substream; +struct snd_pcm_runtime *runtime; +u32 period_bytes, buf_size, water_mark_size_reg; +u32 stream_count; +int index, instance, ret; + +for (instance =0 ; instance <AMD_SDW_MAX_MANAGERS ; instance++) { +if (instance ==ACP_SDW0 ) + stream_count =ACP63_SDW0_DMA_MAX_STREAMS ; +else + stream_count =ACP63_SDW1_DMA_MAX_STREAMS ; + +for (index =0 ; index < stream_count; index++) { +if (instance ==ACP_SDW0 ) { + substream = sdw_data->sdw0_dma_stream[index]; + water_mark_size_reg = + sdw0_dma_ring_buf_reg[index].water_mark_size_reg; + }else { + substream = sdw_data->sdw1_dma_stream[index]; + water_mark_size_reg = + sdw1_dma_ring_buf_reg[index].water_mark_size_reg; + } + +if (substream && substream->runtime) { + runtime = substream->runtime; + stream = runtime->private_data; + period_bytes =frames_to_bytes (runtime, runtime->period_size); + buf_size =frames_to_bytes (runtime, runtime->buffer_size); +acp63_config_dma (stream, sdw_data->acp_base, index); + ret =acp63_configure_sdw_ringbuffer (sdw_data->acp_base, index, + buf_size, instance); +if (ret) +return ret; +writel (period_bytes, sdw_data->acp_base + water_mark_size_reg); + } + } + } +acp63_enable_disable_sdw_dma_interrupts (sdw_data->acp_base, true); +return 0 ; +} + +static int __maybe_unused acp63_sdw_pcm_resume (struct device *dev) +{ +struct sdw_dma_dev_data *sdw_data; + + sdw_data =dev_get_drvdata (dev); +return acp_restore_sdw_dma_config (sdw_data); +} + +static const struct dev_pm_ops acp63_pm_ops = { +SET_SYSTEM_SLEEP_PM_OPS (NULL , acp63_sdw_pcm_resume) +}; +static struct platform_driver acp63_sdw_dma_driver = { .probe = acp63_sdw_platform_probe, + .remove = acp63_sdw_platform_remove, .driver = { .name ="amd_ps_sdw_dma" , + .pm = &acp63_pm_ops, }, };
Signature · 1 line
2.34.1
Re: [PATCH V3 6/9] ASoC: amd: ps: add pm ops support for SoundWire dma driver
Quoted 90 lines · Vijendar Mukunda
Add support pm ops support for SoundWire dma driver.
Signed-off-by Vijendar Mukunda <[email protected]>--- sound/soc/amd/ps/ps-sdw-dma.c | 98 ++++++++++++++++++++++++++++++++++- 1 file changed, 96 insertions(+), 2 deletions(-)sound/soc/amd/ps/ps-sdw-dma.c +55
-2@@ -12,6 +12,7 @@#include <sound/pcm_params.h> #include <sound/soc.h> #include <sound/soc-dai.h> +#include <linux/pm_runtime.h> #include <linux/soundwire/sdw_amd.h> #include "acp63.h" @@ -102,6 +103,29 @@ static const struct snd_pcm_hardware acp63_sdw_hardware_capture = { .periods_max = SDW_CAPTURE_MAX_NUM_PERIODS, }; +static void acp63_enable_disable_sdw_dma_interrupts (void __iomem *acp_base,bool enable) +{ +u32 ext_intr_cntl, ext_intr_cntl1; +u32 irq_mask =ACP_SDW_DMA_IRQ_MASK ; +u32 irq_mask1 =ACP_P1_SDW_DMA_IRQ_MASK ; + +if (enable) { + ext_intr_cntl =readl (acp_base +ACP_EXTERNAL_INTR_CNTL ); + ext_intr_cntl |= irq_mask; +writel (ext_intr_cntl, acp_base +ACP_EXTERNAL_INTR_CNTL ); + ext_intr_cntl1 =readl (acp_base +ACP_EXTERNAL_INTR_CNTL1 ); + ext_intr_cntl1 |= irq_mask1; +writel (ext_intr_cntl1, acp_base +ACP_EXTERNAL_INTR_CNTL1 ); + }else { + ext_intr_cntl =readl (acp_base +ACP_EXTERNAL_INTR_CNTL ); + ext_intr_cntl &= ~irq_mask; +writel (ext_intr_cntl, acp_base +ACP_EXTERNAL_INTR_CNTL ); + ext_intr_cntl1 =readl (acp_base +ACP_EXTERNAL_INTR_CNTL1 ); + ext_intr_cntl1 &= ~irq_mask1; +writel (ext_intr_cntl1, acp_base +ACP_EXTERNAL_INTR_CNTL1 ); + } +} +static void acp63_config_dma (struct acp_sdw_dma_stream *stream,void __iomem *acp_base,u32 stream_id) {@@ -464,16 +488,86 @@ static int acp63_sdw_platform_probe(struct platform_device *pdev) status =devm_snd_soc_register_component (&pdev->dev, &acp63_sdw_component,NULL ,0 ); -if (status) +if (status) {dev_err (&pdev->dev,"Fail to register sdw dma component\n" ); +return status; + } +pm_runtime_set_autosuspend_delay (&pdev->dev,ACP_SUSPEND_DELAY_MS ); +pm_runtime_use_autosuspend (&pdev->dev); +pm_runtime_mark_last_busy (&pdev->dev); +pm_runtime_set_active (&pdev->dev); +pm_runtime_enable (&pdev->dev); +return 0 ; +} -return status; +static int acp63_sdw_platform_remove (struct platform_device *pdev) +{ +pm_runtime_disable (&pdev->dev); +return 0 ; } +static int acp_restore_sdw_dma_config (struct sdw_dma_dev_data *sdw_data) +{ +struct acp_sdw_dma_stream *stream; +struct snd_pcm_substream *substream; +struct snd_pcm_runtime *runtime; +u32 period_bytes, buf_size, water_mark_size_reg; +u32 stream_count; +int index, instance, ret; + +for (instance =0 ; instance <AMD_SDW_MAX_MANAGERS ; instance++) { +if (instance ==ACP_SDW0 ) + stream_count =ACP63_SDW0_DMA_MAX_STREAMS ; +else + stream_count =ACP63_SDW1_DMA_MAX_STREAMS ; + +for (index =0 ; index < stream_count; index++) { +if (instance ==ACP_SDW0 ) {
sound/soc/amd/ps/ps-sdw-dma.c static int acp63_sdw_platform_probe(struct platform_device *pdev) · line 535
Quoted 10 lines
sound/soc/amd/ps/ps-sdw-dma.c +10
-0+ substream = sdw_data->sdw0_dma_stream[index]; + water_mark_size_reg = + sdw0_dma_ring_buf_reg[index].water_mark_size_reg; + }else { + substream = sdw_data->sdw1_dma_stream[index]; + water_mark_size_reg = + sdw1_dma_ring_buf_reg[index].water_mark_size_reg; + } + +if (substream && substream->runtime) {
can this be false?
Quoted 37 lines
sound/soc/amd/ps/ps-sdw-dma.c +30
-0+ runtime = substream->runtime; + stream = runtime->private_data; + period_bytes =frames_to_bytes (runtime, runtime->period_size); + buf_size =frames_to_bytes (runtime, runtime->buffer_size); +acp63_config_dma (stream, sdw_data->acp_base, index); + ret =acp63_configure_sdw_ringbuffer (sdw_data->acp_base, index, + buf_size, instance); +if (ret) +return ret; +writel (period_bytes, sdw_data->acp_base + water_mark_size_reg); + }> + } + } +acp63_enable_disable_sdw_dma_interrupts (sdw_data->acp_base, true); +return 0 ; +} + +static int __maybe_unused acp63_sdw_pcm_resume (struct device *dev) +{ +struct sdw_dma_dev_data *sdw_data; + + sdw_data =dev_get_drvdata (dev); +return acp_restore_sdw_dma_config (sdw_data); +} + +static const struct dev_pm_ops acp63_pm_ops = { +SET_SYSTEM_SLEEP_PM_OPS (NULL , acp63_sdw_pcm_resume) +}; +static struct platform_driver acp63_sdw_dma_driver = { .probe = acp63_sdw_platform_probe, + .remove = acp63_sdw_platform_remove, .driver = { .name ="amd_ps_sdw_dma" , + .pm = &acp63_pm_ops, }, };
Mukunda,Vijendar
maintainerRe: [PATCH V3 6/9] ASoC: amd: ps: add pm ops support for SoundWire dma driver
Quoted 95 lines · Pierre-Louis Bossart
Quoted 93 lines · Vijendar Mukunda
Add support pm ops support for SoundWire dma driver.
Signed-off-by Vijendar Mukunda <[email protected]>--- sound/soc/amd/ps/ps-sdw-dma.c | 98 ++++++++++++++++++++++++++++++++++- 1 file changed, 96 insertions(+), 2 deletions(-)sound/soc/amd/ps/ps-sdw-dma.c +58
-2@@ -12,6 +12,7 @@#include <sound/pcm_params.h> #include <sound/soc.h> #include <sound/soc-dai.h> +#include <linux/pm_runtime.h> #include <linux/soundwire/sdw_amd.h> #include "acp63.h" @@ -102,6 +103,29 @@ static const struct snd_pcm_hardware acp63_sdw_hardware_capture = { .periods_max = SDW_CAPTURE_MAX_NUM_PERIODS, }; +static void acp63_enable_disable_sdw_dma_interrupts (void __iomem *acp_base,bool enable) +{ +u32 ext_intr_cntl, ext_intr_cntl1; +u32 irq_mask =ACP_SDW_DMA_IRQ_MASK ; +u32 irq_mask1 =ACP_P1_SDW_DMA_IRQ_MASK ; + +if (enable) { + ext_intr_cntl =readl (acp_base +ACP_EXTERNAL_INTR_CNTL ); + ext_intr_cntl |= irq_mask; +writel (ext_intr_cntl, acp_base +ACP_EXTERNAL_INTR_CNTL ); + ext_intr_cntl1 =readl (acp_base +ACP_EXTERNAL_INTR_CNTL1 ); + ext_intr_cntl1 |= irq_mask1; +writel (ext_intr_cntl1, acp_base +ACP_EXTERNAL_INTR_CNTL1 ); + }else { + ext_intr_cntl =readl (acp_base +ACP_EXTERNAL_INTR_CNTL ); + ext_intr_cntl &= ~irq_mask; +writel (ext_intr_cntl, acp_base +ACP_EXTERNAL_INTR_CNTL ); + ext_intr_cntl1 =readl (acp_base +ACP_EXTERNAL_INTR_CNTL1 ); + ext_intr_cntl1 &= ~irq_mask1; +writel (ext_intr_cntl1, acp_base +ACP_EXTERNAL_INTR_CNTL1 ); + } +} +static void acp63_config_dma (struct acp_sdw_dma_stream *stream,void __iomem *acp_base,u32 stream_id) {@@ -464,16 +488,86 @@ static int acp63_sdw_platform_probe(struct platform_device *pdev) status =devm_snd_soc_register_component (&pdev->dev, &acp63_sdw_component,NULL ,0 ); -if (status) +if (status) {dev_err (&pdev->dev,"Fail to register sdw dma component\n" ); +return status; + } +pm_runtime_set_autosuspend_delay (&pdev->dev,ACP_SUSPEND_DELAY_MS ); +pm_runtime_use_autosuspend (&pdev->dev); +pm_runtime_mark_last_busy (&pdev->dev); +pm_runtime_set_active (&pdev->dev); +pm_runtime_enable (&pdev->dev); +return 0 ; +} -return status; +static int acp63_sdw_platform_remove (struct platform_device *pdev) +{ +pm_runtime_disable (&pdev->dev); +return 0 ; } +static int acp_restore_sdw_dma_config (struct sdw_dma_dev_data *sdw_data) +{ +struct acp_sdw_dma_stream *stream; +struct snd_pcm_substream *substream; +struct snd_pcm_runtime *runtime; +u32 period_bytes, buf_size, water_mark_size_reg; +u32 stream_count; +int index, instance, ret; + +for (instance =0 ; instance <AMD_SDW_MAX_MANAGERS ; instance++) { +if (instance ==ACP_SDW0 ) + stream_count =ACP63_SDW0_DMA_MAX_STREAMS ; +else + stream_count =ACP63_SDW1_DMA_MAX_STREAMS ; + +for (index =0 ; index < stream_count; index++) { +if (instance ==ACP_SDW0 ) { + substream = sdw_data->sdw0_dma_stream[index]; + water_mark_size_reg = + sdw0_dma_ring_buf_reg[index].water_mark_size_reg;
Quoted 8 lines
sound/soc/amd/ps/ps-sdw-dma.c static int acp63_sdw_platform_probe(struct platform_device *pdev) · line 535
Quoted 7 lines
sound/soc/amd/ps/ps-sdw-dma.c +7
-0+ }else { + substream = sdw_data->sdw1_dma_stream[index]; + water_mark_size_reg = + sdw1_dma_ring_buf_reg[index].water_mark_size_reg; + } + +if (substream && substream->runtime) {can this be false?
Yes if its corrupted somehow. Better to have null checks.
Quoted 37 lines
Quoted 37 lines
sound/soc/amd/ps/ps-sdw-dma.c +30
-0+ runtime = substream->runtime; + stream = runtime->private_data; + period_bytes =frames_to_bytes (runtime, runtime->period_size); + buf_size =frames_to_bytes (runtime, runtime->buffer_size); +acp63_config_dma (stream, sdw_data->acp_base, index); + ret =acp63_configure_sdw_ringbuffer (sdw_data->acp_base, index, + buf_size, instance); +if (ret) +return ret; +writel (period_bytes, sdw_data->acp_base + water_mark_size_reg); + }> + } + } +acp63_enable_disable_sdw_dma_interrupts (sdw_data->acp_base, true); +return 0 ; +} + +static int __maybe_unused acp63_sdw_pcm_resume (struct device *dev) +{ +struct sdw_dma_dev_data *sdw_data; + + sdw_data =dev_get_drvdata (dev); +return acp_restore_sdw_dma_config (sdw_data); +} + +static const struct dev_pm_ops acp63_pm_ops = { +SET_SYSTEM_SLEEP_PM_OPS (NULL , acp63_sdw_pcm_resume) +}; +static struct platform_driver acp63_sdw_dma_driver = { .probe = acp63_sdw_platform_probe, + .remove = acp63_sdw_platform_remove, .driver = { .name ="amd_ps_sdw_dma" , + .pm = &acp63_pm_ops, }, };
Vijendar Mukunda
maintainerPATCH v3 7/9 ASoC: amd: ps: enable SoundWire dma driver build
In reply to Vijendar MukundaEnable SoundWire dma driver build for PS platform.
--- sound/soc/amd/ps/Makefile | 2 ++ 1 file changed, 2 insertions(+)
sound/soc/amd/ps/Makefile +2 -0
@@ -3,7 +3,9 @@ snd-pci-ps-objs := pci-ps.o snd-ps-pdm-dma-objs := ps-pdm-dma.o snd-soc-ps-mach-objs := ps-mach.o +snd-ps-sdw-dma-objs := ps-sdw-dma.o obj-$(CONFIG_SND_SOC_AMD_PS) += snd-pci-ps.o obj-$(CONFIG_SND_SOC_AMD_PS) += snd-ps-pdm-dma.o +obj-$(CONFIG_SND_SOC_AMD_PS) += snd-ps-sdw-dma.o obj-$(CONFIG_SND_SOC_AMD_PS_MACH) += snd-soc-ps-mach.o
Signature · 1 line
2.34.1
Vijendar Mukunda
maintainerPATCH v3 8/9 ASoC: amd: update comments in Kconfig file
In reply to Vijendar MukundaUpdate comments in Kconfig file for Pink Sardine platform.
--- sound/soc/amd/Kconfig | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
sound/soc/amd/Kconfig +2 -1
@@ -136,7 +136,8 @@ config SND_SOC_AMD_PS help This option enables Audio Coprocessor i.e ACP v6.3 support on AMD Pink sardine platform. By enabling this flag build will be - triggered for ACP PCI driver, ACP PDM DMA driver. + triggered for ACP PCI driver, ACP PDM DMA driver, ACP SoundWire + DMA driver. Say m if you have such a device. If unsure select "N".
Signature · 1 line
2.34.1
Vijendar Mukunda
maintainerPATCH v3 9/9 ASoC: amd: ps: Add SoundWire specific checks in pci driver in pm ops.
In reply to Vijendar MukundaAMD SoundWire manager supports different power modes. In case of SoundWire Power off Mode, ACP pci parent driver should invoke acp de-init and init sequence during suspend/resume callbacks.
--- sound/soc/amd/ps/pci-ps.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-)
sound/soc/amd/ps/pci-ps.c +14 -4
@@ -662,10 +662,15 @@ static int snd_acp63_probe(struct pci_dev *pci,static int __maybe_unused snd_acp63_suspend (struct device *dev) {struct acp63_dev_data *adata; -int ret; +int ret =0 ; adata =dev_get_drvdata (dev); - ret =acp63_deinit (adata->acp63_base, dev); +if (adata->pdev_mask &ACP63_SDW_DEV_MASK ) { +if (adata->acp_reset) + ret =acp63_deinit (adata->acp63_base, dev); + }else { + ret =acp63_deinit (adata->acp63_base, dev); + }if (ret)dev_err (dev,"ACP de-init failed\n" );return ret;
@@ -674,10 +679,15 @@ static int __maybe_unused snd_acp63_suspend(struct device *dev)static int __maybe_unused snd_acp63_resume (struct device *dev) {struct acp63_dev_data *adata; -int ret; +int ret =0 ; adata =dev_get_drvdata (dev); - ret =acp63_init (adata->acp63_base, dev); +if (adata->pdev_mask &ACP63_SDW_DEV_MASK ) { +if (adata->acp_reset) + ret =acp63_init (adata->acp63_base, dev); + }else { + ret =acp63_init (adata->acp63_base, dev); + }if (ret)dev_err (dev,"ACP init failed\n" );return ret;
Signature · 1 line
2.34.1
Re: [PATCH V3 9/9] ASoC: amd: ps: Add SoundWire specific checks in pci driver in pm ops.
Quoted 15 lines · Vijendar Mukunda
AMD SoundWire manager supports different power modes. In case of SoundWire Power off Mode, ACP pci parent driver should invoke acp de-init and init sequence during suspend/resume callbacks.
Signed-off-by Vijendar Mukunda <[email protected]>--- sound/soc/amd/ps/pci-ps.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-)sound/soc/amd/ps/pci-ps.c +0
-0
sound/soc/amd/ps/pci-ps.c static int snd_acp63_probe(struct pci_dev *pci, · line 668
Quoted 9 lines
sound/soc/amd/ps/pci-ps.c +2
-2@@ -662,10 +662,15 @@ static int snd_acp63_probe(struct pci_dev *pci,static int __maybe_unused snd_acp63_suspend (struct device *dev) {struct acp63_dev_data *adata; -int ret; +int ret =0 ; adata =dev_get_drvdata (dev); - ret =acp63_deinit (adata->acp63_base, dev); +if (adata->pdev_mask &ACP63_SDW_DEV_MASK ) {
And now back to my comment from the first patch, you are using a bit-wise operation with an enum which is not explicitly defined as a mask. This test would be true for ACP63_SDW_PDM_DEV_MASK as well.
+enum acp_pdev_mask {
+ ACP63_PDM_DEV_MASK = 1,
+ ACP63_SDW_DEV_MASK,
+ ACP63_SDW_PDM_DEV_MASK,
+};
Quoted 26 lines
sound/soc/amd/ps/pci-ps.c +12
-2+if (adata->acp_reset) + ret =acp63_deinit (adata->acp63_base, dev); + }else { + ret =acp63_deinit (adata->acp63_base, dev); + }if (ret)dev_err (dev,"ACP de-init failed\n" );return ret;@@ -674,10 +679,15 @@ static int __maybe_unused snd_acp63_suspend(struct device *dev)static int __maybe_unused snd_acp63_resume (struct device *dev) {struct acp63_dev_data *adata; -int ret; +int ret =0 ; adata =dev_get_drvdata (dev); - ret =acp63_init (adata->acp63_base, dev); +if (adata->pdev_mask &ACP63_SDW_DEV_MASK ) { +if (adata->acp_reset) + ret =acp63_init (adata->acp63_base, dev); + }else { + ret =acp63_init (adata->acp63_base, dev); + }if (ret)dev_err (dev,"ACP init failed\n" );return ret;
Mukunda,Vijendar
maintainerRe: [PATCH V3 9/9] ASoC: amd: ps: Add SoundWire specific checks in pci driver in pm ops.
Quoted 23 lines · Pierre-Louis Bossart
Quoted 21 lines · Vijendar Mukunda
AMD SoundWire manager supports different power modes. In case of SoundWire Power off Mode, ACP pci parent driver should invoke acp de-init and init sequence during suspend/resume callbacks.
Signed-off-by Vijendar Mukunda <[email protected]>--- sound/soc/amd/ps/pci-ps.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-)sound/soc/amd/ps/pci-ps.c +1
-1@@ -662,10 +662,15 @@ static int snd_acp63_probe(struct pci_dev *pci,static int __maybe_unused snd_acp63_suspend (struct device *dev) {struct acp63_dev_data *adata; -int ret; +int ret =0 ;
Quoted 6 lines
sound/soc/amd/ps/pci-ps.c static int snd_acp63_probe(struct pci_dev *pci, · line 668
Quoted 3 lines
sound/soc/amd/ps/pci-ps.c +1
-1adata =dev_get_drvdata (dev); - ret =acp63_deinit (adata->acp63_base, dev); +if (adata->pdev_mask &ACP63_SDW_DEV_MASK ) {And now back to my comment from the first patch, you are using a bit-wise operation with an enum which is not explicitly defined as a mask. This test would be true for
ACP63_SDW_PDM_DEV_MASKas well.
Already provided explanation for the same , in patch 1 review comments. Please refer that one.
Quoted 33 lines
(quoted diff) +5
-0+enum acp_pdev_mask { + ACP63_PDM_DEV_MASK = 1, + ACP63_SDW_DEV_MASK, + ACP63_SDW_PDM_DEV_MASK, +};Quoted 27 lines
sound/soc/amd/ps/pci-ps.c +12
-2+if (adata->acp_reset) + ret =acp63_deinit (adata->acp63_base, dev); + }else { + ret =acp63_deinit (adata->acp63_base, dev); + }if (ret)dev_err (dev,"ACP de-init failed\n" );return ret;@@ -674,10 +679,15 @@ static int __maybe_unused snd_acp63_suspend(struct device *dev)static int __maybe_unused snd_acp63_resume (struct device *dev) {struct acp63_dev_data *adata; -int ret; +int ret =0 ; adata =dev_get_drvdata (dev); - ret =acp63_init (adata->acp63_base, dev); +if (adata->pdev_mask &ACP63_SDW_DEV_MASK ) { +if (adata->acp_reset) + ret =acp63_init (adata->acp63_base, dev); + }else { + ret =acp63_init (adata->acp63_base, dev); + }if (ret)dev_err (dev,"ACP init failed\n" );return ret;