Skip to contentSkip to conversation

ASoC: dwc: I2S Controller instance param added

PATCH In review Vijendar Mukunda 3 participants 8 messages Apr 18, 2018 – Apr 19, 2018 1 message not in the archive

Subsystems (3)
lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

Vijendar Mukunda

author maintainer
#1 lore raw

PATCH v2 1/3 ASoC: dwc: I2S Controller instance param added

When multiple I2S controller instances created, i2s_instance parameter refers to i2s controller instance value.

---
v1->v2: removed acp dma driver specific macros from dwc header file

 include/sound/designware_i2s.h | 4 ++++
 sound/soc/dwc/dwc-i2s.c        | 1 +
 sound/soc/dwc/local.h          | 1 +
 3 files changed, 6 insertions(+)
include/sound/designware_i2s.h +4 -0
index 830f5ca..2a94e7c 100644
@@ -44,6 +44,10 @@ struct i2s_platform_data {
 	int channel;
 	u32 snd_fmts;
 	u32 snd_rates;
+	/* i2s_instance parameter returns I2S controller instance value
+	 * when multiple I2S controllers instantiated
+	 */
+	u32 i2s_instance;
 
 	#define DW_I2S_QUIRK_COMP_REG_OFFSET	(1 << 0)
 	#define DW_I2S_QUIRK_COMP_PARAM1	(1 << 1)
sound/soc/dwc/dwc-i2s.c +1 -0
index 65112b9..58f81a4 100644
@@ -553,6 +553,7 @@ static int dw_configure_dai_by_pd(struct dw_i2s_dev *dev,
 
 	if (dev->quirks & DW_I2S_QUIRK_16BIT_IDX_OVERRIDE)
 		idx = 1;
+	dev->i2s_instance = pdata->i2s_instance;
 	/* Set DMA slaves info */
 	dev->play_dma_data.pd.data = pdata->play_dma_data;
 	dev->capture_dma_data.pd.data = pdata->capture_dma_data;
sound/soc/dwc/local.h +1 -0
index 91dc70a..e89e464 100644
@@ -98,6 +98,7 @@ struct dw_i2s_dev {
 	u32 ccr;
 	u32 xfer_resolution;
 	u32 fifo_th;
+	u32 i2s_instance;
 
 	/* data related to DMA transfers b/w i2s and DMAC */
 	union dw_i2s_snd_dma_data play_dma_data;
Signature · 1 line
2.7.4
maintainer
#2 lore raw
Quoted 2 lines · Vijendar Mukunda

When multiple I2S controller instances created, i2s_instance parameter refers to i2s controller instance value.

You're missing the point here a bit - it's not just the defines for the magic numbers that are the problem, it's the whole idea of passing instance numbers around like this that's the big problem. Whatever you are trying to do here is most likely better accomplished at the machine driver level. If I'm missing something here and this is a useful concept to have in the driver it really needs to be articulated much more clearly than in your very brief changelog, and most likely done at the subsystem level (though the fact that we've managed to get this far without needing it is a bit of a red flag).

author maintainer
#3 lore raw
Quoted 4 lines · Mark Brown
Quoted 2 lines · Vijendar Mukunda

When multiple I2S controller instances created, i2s_instance parameter refers to i2s controller instance value.

Quoted 10 lines

You're missing the point here a bit - it's not just the defines for the magic numbers that are the problem, it's the whole idea of passing instance numbers around like this that's the big problem. Whatever you are trying to do here is most likely better accomplished at the machine driver level. If I'm missing something here and this is a useful concept to have in the driver it really needs to be articulated much more clearly than in your very brief changelog, and most likely done at the subsystem level (though the fact that we've managed to get this far without needing it is a bit of a red flag).

In Audio Coprocessor (ACP), There are three I2S controllers can be configured/enabled.(I2S SP, I2S MICSP, BT I2S)
Default enabled I2S controller instance is I2S SP instance.
There is a requirement to enable BT I2S controller Instance along with
I2S SP controller instance in one of our platforms Which has multiple codecs connected to each instance.

AMD GPU ACP driver creates devices for Playback and capture devices for both the I2S Controller instances using MFD framework. Designware driver probe call gets invoked for every device creation with
resource information and platform data provided by GPU driver.

We have added one more parameter i2s instance to dwc platform data.
So that AMDGPU ACP Driver will pass I2S controller instance value to dwc driver while creating device nodes for I2S Controllers.

In ACP DMA Driver acp_dma_open () call, We are retrieving dwc controller dev data as mentioned below. dw_i2s_dev *dev = snd_soc_dai_get_drvdata(prtd->cpu_dai);

From dev->i2s_instance , ACP DMA Driver gets to know current I2S controller instance value. We want to make ACP DMA driver platform independent one so that it will work across all platforms.

This is a generic implementation. Any platform which uses Designware I2S controller can use this implementation when multiple I2S controller instances are created.
This patch stores the I2S controller instance value in platform data. Please suggest us, if there is any better way to handle it.

maintainer
#4 lore raw
Quoted 10 lines · Mukunda,Vijendar
Quoted 8 lines · Mark Brown
Quoted 2 lines · Vijendar Mukunda

When multiple I2S controller instances created, i2s_instance parameter refers to i2s controller instance value.

You're missing the point here a bit - it's not just the defines for the magic numbers that are the problem, it's the whole idea of passing instance numbers around like this that's the big problem. Whatever you

Quoted 6 lines

In Audio Coprocessor (ACP), There are three I2S controllers can be configured/enabled.(I2S SP, I2S MICSP, BT I2S)
Default enabled I2S controller instance is I2S SP instance. There is a requirement to enable BT I2S controller Instance along with I2S SP controller instance in one of our platforms Which has multiple codecs connected to each instance.

Describing how the system is wired up is the function of the machine driver. The individual drivers should just take configuration from the machine driver.

Quoted 3 lines

We have added one more parameter i2s instance to dwc platform data. So that AMDGPU ACP Driver will pass I2S controller instance value to dwc driver while creating device nodes for I2S Controllers.

This is not the way to do this - you can already get the struct device for all the children from when they were instantiated, you should be able to use this to reference them so you can bind the machine driver. There's facilities for doing this (mostly serializing into dev_name() as this was mostly used by board file based machines) which are already used, if there's problems we should extend those rather than hacking things into every single driver.

author maintainer
#5 lore raw

PATCH v2 2/3 ASoC: amd: dma driver changes for BT I2S instance

In reply to a message not in the archive

With in ACP, There are three I2S controllers can be configured/enabled ( I2S SP, I2S MICSP, I2S BT). Default enabled I2S controller instance is I2S SP. This patch provides required changes to support I2S BT controller Instance.

---
v1->v2: defined i2s instance macros in acp header file

 sound/soc/amd/Kconfig       |   1 +
 sound/soc/amd/acp-pcm-dma.c | 388 +++++++++++++++++++++++++++-----------------
 sound/soc/amd/acp.h         |  67 +++++++-
 3 files changed, 298 insertions(+), 158 deletions(-)
sound/soc/amd/Kconfig +1 -0
index 6cbf9cf..6b7c620 100644
@@ -1,5 +1,6 @@
 config SND_SOC_AMD_ACP
 	tristate "AMD Audio Coprocessor support"
+	select SND_DESIGNWARE_PCM
 	help
 	 This option enables ACP DMA support on AMD platform.
 
sound/soc/amd/acp-pcm-dma.c +238 -150

557 lines not on this page · raw message

sound/soc/amd/acp.h +59 -8

115 lines not on this page · raw message

Signature · 1 line
2.7.4
#6 lore raw

Re: [PATCH v2 2/3] ASoC: amd: dma driver changes for BT I2S instance

Hi Vijendar,

Quoted 5 lines · Vijendar Mukunda

With in ACP, There are three I2S controllers can be configured/enabled ( I2S SP, I2S MICSP, I2S BT). Default enabled I2S controller instance is I2S SP. This patch provides required changes to support I2S BT controller Instance.

I like the direction this patch is taking, but I think it would be easier to review if you could split it into 2 parts:
(1) the cleanup of the existing driver to use a simplified flow for
playback vs capture paths.
(2) adding the BT I2S channel.

Thanks,
-Dan

author maintainer
#7 lore raw

Re: [PATCH v2 2/3] ASoC: amd: dma driver changes for BT I2S instance

Quoted 18 lines · Daniel Kurtz

Hi Vijendar,

Quoted 5 lines · Vijendar Mukunda

With in ACP, There are three I2S controllers can be configured/enabled ( I2S SP, I2S MICSP, I2S BT). Default enabled I2S controller instance is I2S SP. This patch provides required changes to support I2S BT controller Instance.

I like the direction this patch is taking, but I think it would be easier to review if you could split it into 2 parts:
(1) the cleanup of the existing driver to use a simplified flow for
playback vs capture paths.
(2) adding the BT I2S channel.

Quoted 3 lines

Thanks,
-Dan

Hi Dan,

I am fine with splitting the patch into two parts.

Thanks,
Vijendar

author maintainer
#8 lore raw

PATCH v2 3/3 ASoC: amd: enabling bt i2s config after acp reset

In reply to a message not in the archive

On ST/CZ based platforms, for specific platform bt uart mux to be defined for bt i2s.
By default, these pins will be used for uart. After acp reset , it requires to reprogram bt i2s config mux pins to enable bt i2s instance.
added bt i2s enablement sequence during acp init.

---
v1->v2: fixed kbuild errors

 sound/soc/amd/acp-da7219-max98357a.c | 2 ++
 sound/soc/amd/acp-pcm-dma.c          | 9 +++++++++
 sound/soc/amd/acp.h                  | 1 +
 3 files changed, 12 insertions(+)
sound/soc/amd/acp-da7219-max98357a.c +2 -0
index b205c78..9ff2138 100644
@@ -44,6 +44,7 @@
 
 static struct snd_soc_jack cz_jack;
 struct clk *da7219_dai_clk;
+extern int bt_pad_enable;
 
 static int cz_da7219_init(struct snd_soc_pcm_runtime *rtd)
 {
@@ -251,6 +252,7 @@ static int cz_probe(struct platform_device *pdev)
 				cz_card.name, ret);
 		return ret;
 	}
+	bt_pad_enable = device_property_read_bool(&pdev->dev, "bt-pad-enable");
 	return 0;
 }
 
sound/soc/amd/acp-pcm-dma.c +9 -0
index 7c392fe..b52c660 100644
@@ -46,6 +46,8 @@
 
 #define DRV_NAME "acp_audio_dma"
 
+bool bt_pad_enable = false;
+EXPORT_SYMBOL(bt_pad_enable);
 
 static const struct snd_pcm_hardware acp_pcm_hardware_playback = {
 	.info = SNDRV_PCM_INFO_INTERLEAVED |
@@ -525,6 +527,13 @@ static int acp_init(void __iomem *acp_mmio, u32 asic_type)
 	val &= ~ACP_SOFT_RESET__SoftResetAud_MASK;
 	acp_reg_write(val, acp_mmio, mmACP_SOFT_RESET);
 
+	/* For BT instance change pins from UART to BT */
+	if (bt_pad_enable) {
+		val = acp_reg_read(acp_mmio, mmACP_BT_UART_PAD_SEL);
+		val |= ACP_BT_UART_PAD_SELECT_MASK;
+		acp_reg_write(val, acp_mmio, mmACP_BT_UART_PAD_SEL);
+	}
+
 	/* initiailize Onion control DAGB register */
 	acp_reg_write(ACP_ONION_CNTL_DEFAULT, acp_mmio,
 		      mmACP_AXI2DAGB_ONION_CNTL);
sound/soc/amd/acp.h +1 -0
index 95c39a3..520a08f 100644
@@ -110,6 +110,7 @@
 #define ACP_I2S_MIC_16BIT_RESOLUTION_EN 0x01
 #define ACP_I2S_SP_16BIT_RESOLUTION_EN	0x02
 #define ACP_I2S_BT_16BIT_RESOLUTION_EN	0x04
+#define ACP_BT_UART_PAD_SELECT_MASK	0x1
 
 enum acp_dma_priority_level {
 	/* 0x0 Specifies the DMA channel is given normal priority */
Signature · 1 line
2.7.4