devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Andre Przywara <andre.przywara@arm.com>
To: Ryan Walklin <ryan@testtoast.com>
Cc: Liam Girdwood <lgirdwood@gmail.com>,
	Mark Brown <broonie@kernel.org>, Jaroslav Kysela <perex@perex.cz>,
	Takashi Iwai <tiwai@suse.com>, Chen-Yu Tsai <wens@csie.org>,
	Jernej Skrabec <jernej.skrabec@gmail.com>,
	Samuel Holland <samuel@sholland.org>,
	linux-sound@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org,
	linux-sunxi@lists.linux.dev, devicetree@vger.kernel.org,
	linux-clk@vger.kernel.org, Marcus Cooper <codekipper@gmail.com>
Subject: Re: [PATCH 1/6] ASoC: sun4i-codec: Add support for different DAC FIFOC addresses to quirks
Date: Tue, 8 Oct 2024 13:22:21 +0100	[thread overview]
Message-ID: <20241008132221.4c365a9f@donnerap.manchester.arm.com> (raw)
In-Reply-To: <20240929100750.860329-2-ryan@testtoast.com>

On Sun, 29 Sep 2024 23:06:02 +1300
Ryan Walklin <ryan@testtoast.com> wrote:

Hi,

> From: Marcus Cooper <codekipper@gmail.com>
> 
> The Allwinner H616 SoC uses a different register address to control the
> output FIFO.
> 
> Allow this to be specified separately from the ADC FIFO control
> register.

That looks good to me, it follows the existing regmap_field pattern for the
input FIFO, and I can confirm it changes every user of the DAC register.

> Signed-off-by: Marcus Cooper <codekipper@gmail.com>
> Signed-off-by: Ryan Walklin <ryan@testtoast.com>

Reviewed-by: Andre Przywara <andre.przywara@arm.com>

Cheers,
Andre

> ---
>  sound/soc/sunxi/sun4i-codec.c | 83 +++++++++++++++++++++--------------
>  1 file changed, 51 insertions(+), 32 deletions(-)
> 
> diff --git a/sound/soc/sunxi/sun4i-codec.c b/sound/soc/sunxi/sun4i-codec.c
> index 330bc0c09f56b..37f5678b55291 100644
> --- a/sound/soc/sunxi/sun4i-codec.c
> +++ b/sound/soc/sunxi/sun4i-codec.c
> @@ -238,6 +238,8 @@ struct sun4i_codec {
>  
>  	/* ADC_FIFOC register is at different offset on different SoCs */
>  	struct regmap_field *reg_adc_fifoc;
> +	/* DAC_FIFOC register is at different offset on different SoCs */
> +	struct regmap_field *reg_dac_fifoc;
>  
>  	struct snd_dmaengine_dai_dma_data	capture_dma_data;
>  	struct snd_dmaengine_dai_dma_data	playback_dma_data;
> @@ -246,19 +248,19 @@ struct sun4i_codec {
>  static void sun4i_codec_start_playback(struct sun4i_codec *scodec)
>  {
>  	/* Flush TX FIFO */
> -	regmap_set_bits(scodec->regmap, SUN4I_CODEC_DAC_FIFOC,
> -			BIT(SUN4I_CODEC_DAC_FIFOC_FIFO_FLUSH));
> +	regmap_field_set_bits(scodec->reg_dac_fifoc,
> +			      BIT(SUN4I_CODEC_DAC_FIFOC_FIFO_FLUSH));
>  
>  	/* Enable DAC DRQ */
> -	regmap_set_bits(scodec->regmap, SUN4I_CODEC_DAC_FIFOC,
> -			BIT(SUN4I_CODEC_DAC_FIFOC_DAC_DRQ_EN));
> +	regmap_field_set_bits(scodec->reg_dac_fifoc,
> +			      BIT(SUN4I_CODEC_DAC_FIFOC_DAC_DRQ_EN));
>  }
>  
>  static void sun4i_codec_stop_playback(struct sun4i_codec *scodec)
>  {
>  	/* Disable DAC DRQ */
> -	regmap_clear_bits(scodec->regmap, SUN4I_CODEC_DAC_FIFOC,
> -			  BIT(SUN4I_CODEC_DAC_FIFOC_DAC_DRQ_EN));
> +	regmap_field_clear_bits(scodec->reg_dac_fifoc,
> +				BIT(SUN4I_CODEC_DAC_FIFOC_DAC_DRQ_EN));
>  }
>  
>  static void sun4i_codec_start_capture(struct sun4i_codec *scodec)
> @@ -356,13 +358,13 @@ static int sun4i_codec_prepare_playback(struct snd_pcm_substream *substream,
>  	u32 val;
>  
>  	/* Flush the TX FIFO */
> -	regmap_set_bits(scodec->regmap, SUN4I_CODEC_DAC_FIFOC,
> -			   BIT(SUN4I_CODEC_DAC_FIFOC_FIFO_FLUSH));
> +	regmap_field_set_bits(scodec->reg_dac_fifoc,
> +			      BIT(SUN4I_CODEC_DAC_FIFOC_FIFO_FLUSH));
>  
>  	/* Set TX FIFO Empty Trigger Level */
> -	regmap_update_bits(scodec->regmap, SUN4I_CODEC_DAC_FIFOC,
> -			   0x3f << SUN4I_CODEC_DAC_FIFOC_TX_TRIG_LEVEL,
> -			   0xf << SUN4I_CODEC_DAC_FIFOC_TX_TRIG_LEVEL);
> +	regmap_field_update_bits(scodec->reg_dac_fifoc,
> +				 0x3f << SUN4I_CODEC_DAC_FIFOC_TX_TRIG_LEVEL,
> +				 0xf << SUN4I_CODEC_DAC_FIFOC_TX_TRIG_LEVEL);
>  
>  	if (substream->runtime->rate > 32000)
>  		/* Use 64 bits FIR filter */
> @@ -371,13 +373,13 @@ static int sun4i_codec_prepare_playback(struct snd_pcm_substream *substream,
>  		/* Use 32 bits FIR filter */
>  		val = BIT(SUN4I_CODEC_DAC_FIFOC_FIR_VERSION);
>  
> -	regmap_update_bits(scodec->regmap, SUN4I_CODEC_DAC_FIFOC,
> -			   BIT(SUN4I_CODEC_DAC_FIFOC_FIR_VERSION),
> -			   val);
> +	regmap_field_update_bits(scodec->reg_dac_fifoc,
> +				 BIT(SUN4I_CODEC_DAC_FIFOC_FIR_VERSION),
> +				 val);
>  
>  	/* Send zeros when we have an underrun */
> -	regmap_clear_bits(scodec->regmap, SUN4I_CODEC_DAC_FIFOC,
> -			   BIT(SUN4I_CODEC_DAC_FIFOC_SEND_LASAT));
> +	regmap_field_clear_bits(scodec->reg_dac_fifoc,
> +				BIT(SUN4I_CODEC_DAC_FIFOC_SEND_LASAT));
>  
>  	return 0;
>  };
> @@ -510,9 +512,9 @@ static int sun4i_codec_hw_params_playback(struct sun4i_codec *scodec,
>  	u32 val;
>  
>  	/* Set DAC sample rate */
> -	regmap_update_bits(scodec->regmap, SUN4I_CODEC_DAC_FIFOC,
> -			   7 << SUN4I_CODEC_DAC_FIFOC_DAC_FS,
> -			   hwrate << SUN4I_CODEC_DAC_FIFOC_DAC_FS);
> +	regmap_field_update_bits(scodec->reg_dac_fifoc,
> +				 7 << SUN4I_CODEC_DAC_FIFOC_DAC_FS,
> +				 hwrate << SUN4I_CODEC_DAC_FIFOC_DAC_FS);
>  
>  	/* Set the number of channels we want to use */
>  	if (params_channels(params) == 1)
> @@ -520,27 +522,27 @@ static int sun4i_codec_hw_params_playback(struct sun4i_codec *scodec,
>  	else
>  		val = 0;
>  
> -	regmap_update_bits(scodec->regmap, SUN4I_CODEC_DAC_FIFOC,
> -			   BIT(SUN4I_CODEC_DAC_FIFOC_MONO_EN),
> -			   val);
> +	regmap_field_update_bits(scodec->reg_dac_fifoc,
> +				 BIT(SUN4I_CODEC_DAC_FIFOC_MONO_EN),
> +				 val);
>  
>  	/* Set the number of sample bits to either 16 or 24 bits */
>  	if (hw_param_interval(params, SNDRV_PCM_HW_PARAM_SAMPLE_BITS)->min == 32) {
> -		regmap_set_bits(scodec->regmap, SUN4I_CODEC_DAC_FIFOC,
> -				   BIT(SUN4I_CODEC_DAC_FIFOC_TX_SAMPLE_BITS));
> +		regmap_field_set_bits(scodec->reg_dac_fifoc,
> +				      BIT(SUN4I_CODEC_DAC_FIFOC_TX_SAMPLE_BITS));
>  
>  		/* Set TX FIFO mode to padding the LSBs with 0 */
> -		regmap_clear_bits(scodec->regmap, SUN4I_CODEC_DAC_FIFOC,
> -				   BIT(SUN4I_CODEC_DAC_FIFOC_TX_FIFO_MODE));
> +		regmap_field_clear_bits(scodec->reg_dac_fifoc,
> +					BIT(SUN4I_CODEC_DAC_FIFOC_TX_FIFO_MODE));
>  
>  		scodec->playback_dma_data.addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES;
>  	} else {
> -		regmap_clear_bits(scodec->regmap, SUN4I_CODEC_DAC_FIFOC,
> -				   BIT(SUN4I_CODEC_DAC_FIFOC_TX_SAMPLE_BITS));
> +		regmap_field_clear_bits(scodec->reg_dac_fifoc,
> +					BIT(SUN4I_CODEC_DAC_FIFOC_TX_SAMPLE_BITS));
>  
>  		/* Set TX FIFO mode to repeat the MSB */
> -		regmap_set_bits(scodec->regmap, SUN4I_CODEC_DAC_FIFOC,
> -				   BIT(SUN4I_CODEC_DAC_FIFOC_TX_FIFO_MODE));
> +		regmap_field_set_bits(scodec->reg_dac_fifoc,
> +				      BIT(SUN4I_CODEC_DAC_FIFOC_TX_FIFO_MODE));
>  
>  		scodec->playback_dma_data.addr_width = DMA_SLAVE_BUSWIDTH_2_BYTES;
>  	}
> @@ -587,8 +589,8 @@ static int sun4i_codec_startup(struct snd_pcm_substream *substream,
>  	 * Stop issuing DRQ when we have room for less than 16 samples
>  	 * in our TX FIFO
>  	 */
> -	regmap_set_bits(scodec->regmap, SUN4I_CODEC_DAC_FIFOC,
> -			   3 << SUN4I_CODEC_DAC_FIFOC_DRQ_CLR_CNT);
> +	regmap_field_set_bits(scodec->reg_dac_fifoc,
> +			      3 << SUN4I_CODEC_DAC_FIFOC_DRQ_CLR_CNT);
>  
>  	return clk_prepare_enable(scodec->clk_module);
>  }
> @@ -1565,6 +1567,7 @@ struct sun4i_codec_quirks {
>  	const struct snd_soc_component_driver *codec;
>  	struct snd_soc_card * (*create_card)(struct device *dev);
>  	struct reg_field reg_adc_fifoc;	/* used for regmap_field */
> +	struct reg_field reg_dac_fifoc;	/* used for regmap_field */
>  	unsigned int reg_dac_txdata;	/* TX FIFO offset for DMA config */
>  	unsigned int reg_adc_rxdata;	/* RX FIFO offset for DMA config */
>  	bool has_reset;
> @@ -1575,6 +1578,7 @@ static const struct sun4i_codec_quirks sun4i_codec_quirks = {
>  	.codec		= &sun4i_codec_codec,
>  	.create_card	= sun4i_codec_create_card,
>  	.reg_adc_fifoc	= REG_FIELD(SUN4I_CODEC_ADC_FIFOC, 0, 31),
> +	.reg_dac_fifoc	= REG_FIELD(SUN4I_CODEC_DAC_FIFOC, 0, 31),
>  	.reg_dac_txdata	= SUN4I_CODEC_DAC_TXDATA,
>  	.reg_adc_rxdata	= SUN4I_CODEC_ADC_RXDATA,
>  };
> @@ -1584,6 +1588,7 @@ static const struct sun4i_codec_quirks sun6i_a31_codec_quirks = {
>  	.codec		= &sun6i_codec_codec,
>  	.create_card	= sun6i_codec_create_card,
>  	.reg_adc_fifoc	= REG_FIELD(SUN6I_CODEC_ADC_FIFOC, 0, 31),
> +	.reg_dac_fifoc	= REG_FIELD(SUN4I_CODEC_DAC_FIFOC, 0, 31),
>  	.reg_dac_txdata	= SUN4I_CODEC_DAC_TXDATA,
>  	.reg_adc_rxdata	= SUN6I_CODEC_ADC_RXDATA,
>  	.has_reset	= true,
> @@ -1594,6 +1599,7 @@ static const struct sun4i_codec_quirks sun7i_codec_quirks = {
>  	.codec		= &sun7i_codec_codec,
>  	.create_card	= sun4i_codec_create_card,
>  	.reg_adc_fifoc	= REG_FIELD(SUN4I_CODEC_ADC_FIFOC, 0, 31),
> +	.reg_dac_fifoc	= REG_FIELD(SUN4I_CODEC_DAC_FIFOC, 0, 31),
>  	.reg_dac_txdata	= SUN4I_CODEC_DAC_TXDATA,
>  	.reg_adc_rxdata	= SUN4I_CODEC_ADC_RXDATA,
>  };
> @@ -1603,6 +1609,7 @@ static const struct sun4i_codec_quirks sun8i_a23_codec_quirks = {
>  	.codec		= &sun8i_a23_codec_codec,
>  	.create_card	= sun8i_a23_codec_create_card,
>  	.reg_adc_fifoc	= REG_FIELD(SUN6I_CODEC_ADC_FIFOC, 0, 31),
> +	.reg_dac_fifoc	= REG_FIELD(SUN4I_CODEC_DAC_FIFOC, 0, 31),
>  	.reg_dac_txdata	= SUN4I_CODEC_DAC_TXDATA,
>  	.reg_adc_rxdata	= SUN6I_CODEC_ADC_RXDATA,
>  	.has_reset	= true,
> @@ -1618,6 +1625,7 @@ static const struct sun4i_codec_quirks sun8i_h3_codec_quirks = {
>  	.codec		= &sun8i_a23_codec_codec,
>  	.create_card	= sun8i_h3_codec_create_card,
>  	.reg_adc_fifoc	= REG_FIELD(SUN6I_CODEC_ADC_FIFOC, 0, 31),
> +	.reg_dac_fifoc	= REG_FIELD(SUN4I_CODEC_DAC_FIFOC, 0, 31),
>  	.reg_dac_txdata	= SUN8I_H3_CODEC_DAC_TXDATA,
>  	.reg_adc_rxdata	= SUN6I_CODEC_ADC_RXDATA,
>  	.has_reset	= true,
> @@ -1632,6 +1640,7 @@ static const struct sun4i_codec_quirks sun8i_v3s_codec_quirks = {
>  	.codec		= &sun8i_a23_codec_codec,
>  	.create_card	= sun8i_v3s_codec_create_card,
>  	.reg_adc_fifoc	= REG_FIELD(SUN6I_CODEC_ADC_FIFOC, 0, 31),
> +	.reg_dac_fifoc	= REG_FIELD(SUN4I_CODEC_DAC_FIFOC, 0, 31),
>  	.reg_dac_txdata	= SUN8I_H3_CODEC_DAC_TXDATA,
>  	.reg_adc_rxdata	= SUN6I_CODEC_ADC_RXDATA,
>  	.has_reset	= true,
> @@ -1739,6 +1748,16 @@ static int sun4i_codec_probe(struct platform_device *pdev)
>  		return ret;
>  	}
>  
> +	scodec->reg_dac_fifoc = devm_regmap_field_alloc(&pdev->dev,
> +							scodec->regmap,
> +							quirks->reg_dac_fifoc);
> +	if (IS_ERR(scodec->reg_dac_fifoc)) {
> +		ret = PTR_ERR(scodec->reg_dac_fifoc);
> +		dev_err(&pdev->dev, "Failed to create regmap fields: %d\n",
> +			ret);
> +		return ret;
> +	}
> +
>  	/* Enable the bus clock */
>  	if (clk_prepare_enable(scodec->clk_apb)) {
>  		dev_err(&pdev->dev, "Failed to enable the APB clock\n");


  reply	other threads:[~2024-10-08 12:22 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-09-29 10:06 [PATCH 0/6] ASoC: add Allwinner H616 audio codec support Ryan Walklin
2024-09-29 10:06 ` [PATCH 1/6] ASoC: sun4i-codec: Add support for different DAC FIFOC addresses to quirks Ryan Walklin
2024-10-08 12:22   ` Andre Przywara [this message]
2024-09-29 10:06 ` [PATCH 2/6] ASoC: sun4i-codec: Add playback only flag " Ryan Walklin
2024-10-08 12:32   ` Andre Przywara
2024-10-20  6:04     ` Ryan Walklin
2024-10-20 10:19       ` Andre Przywara
2024-09-29 10:06 ` [PATCH 3/6] clk: sunxi-ng: h616: Add sigma-delta modulation settings for audio PLL Ryan Walklin
2024-10-01 13:28   ` Andre Przywara
2024-10-18  9:29     ` Andre Przywara
2024-10-20  6:38       ` Ryan Walklin
2024-09-29 10:06 ` [PATCH 4/6] dt-bindings: allwinner: add H616 sun4i audio codec binding Ryan Walklin
2024-09-29 19:56   ` Krzysztof Kozlowski
2024-10-20  6:58     ` Ryan Walklin
2024-10-20 10:27       ` Andre Przywara
2024-09-29 10:06 ` [PATCH 5/6] ASoC: sun4i-codec: support allwinner H616 codec Ryan Walklin
2024-10-18  9:55   ` Andre Przywara
2024-09-29 10:06 ` [PATCH 6/6] arm64: dts: allwinner: h616: Add audio codec node Ryan Walklin
2024-10-08 12:37   ` Andre Przywara
2024-10-18 10:07     ` Andre Przywara
2024-10-05 18:44 ` [PATCH 0/6] ASoC: add Allwinner H616 audio codec support Philippe Simons

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20241008132221.4c365a9f@donnerap.manchester.arm.com \
    --to=andre.przywara@arm.com \
    --cc=broonie@kernel.org \
    --cc=codekipper@gmail.com \
    --cc=devicetree@vger.kernel.org \
    --cc=jernej.skrabec@gmail.com \
    --cc=lgirdwood@gmail.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-clk@vger.kernel.org \
    --cc=linux-sound@vger.kernel.org \
    --cc=linux-sunxi@lists.linux.dev \
    --cc=perex@perex.cz \
    --cc=ryan@testtoast.com \
    --cc=samuel@sholland.org \
    --cc=tiwai@suse.com \
    --cc=wens@csie.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).