public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Krzysztof Kozlowski <krzk@kernel.org>
To: Igor Prusov <ivprusov@salutedevices.com>,
	Liam Girdwood <lgirdwood@gmail.com>,
	Mark Brown <broonie@kernel.org>, Rob Herring <robh@kernel.org>,
	Krzysztof Kozlowski <krzk+dt@kernel.org>,
	Conor Dooley <conor+dt@kernel.org>,
	Jaroslav Kysela <perex@perex.cz>, Takashi Iwai <tiwai@suse.com>
Cc: prusovigor@gmail.com, kernel@salutedevices.com,
	David Yang <yangxiaohua@everest-semi.com>,
	Viktor Prutyanov <vvprutyanov@sberdevices.ru>,
	linux-sound@vger.kernel.org, devicetree@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH 2/2] ASoC: codecs: add ES7243E ADC driver
Date: Wed, 10 Jul 2024 12:34:47 +0200	[thread overview]
Message-ID: <05ed39c6-3c0b-4a43-b655-d26c69f686fa@kernel.org> (raw)
In-Reply-To: <20240709104117.33431-3-ivprusov@salutedevices.com>

On 09/07/2024 12:41, Igor Prusov wrote:
> Add support for Everest Semi es7243e, which is a 24 bit, 8 to 48 kHz
> stereo audio ADC with I2C control and I2S output.
> 
> Datasheet: https://www.pawpaw.cn/media/documents/2022-04/ES7243E_DS_pawpaw%E6%9C%A8%E7%93%9C%E7%A7%91%E6%8A%80.pdf
> 
> Signed-off-by: David Yang <yangxiaohua@everest-semi.com>
> Signed-off-by: Igor Prusov <ivprusov@salutedevices.com>
> Signed-off-by: Viktor Prutyanov <vvprutyanov@sberdevices.ru>
> ---
>  sound/soc/codecs/Kconfig   |   3 +
>  sound/soc/codecs/Makefile  |   2 +
>  sound/soc/codecs/es7243e.c | 676 +++++++++++++++++++++++++++++++++++++
>  3 files changed, 681 insertions(+)
>  create mode 100644 sound/soc/codecs/es7243e.c
> 
> diff --git a/sound/soc/codecs/Kconfig b/sound/soc/codecs/Kconfig
> index 4afc43d3f71f..bfc21073ea24 100644
> --- a/sound/soc/codecs/Kconfig
> +++ b/sound/soc/codecs/Kconfig
> @@ -1097,6 +1097,9 @@ config SND_SOC_ES7134
>  config SND_SOC_ES7241
>  	tristate "Everest Semi ES7241 CODEC"
>  
> +config SND_SOC_ES7243E
> +	tristate "Everest Semi ES7243E CODEC"
> +
>  config SND_SOC_ES83XX_DSM_COMMON
>  	depends on ACPI
>  	tristate
> diff --git a/sound/soc/codecs/Makefile b/sound/soc/codecs/Makefile
> index b4df22186e25..9469903662f8 100644
> --- a/sound/soc/codecs/Makefile
> +++ b/sound/soc/codecs/Makefile
> @@ -118,6 +118,7 @@ snd-soc-da9055-y := da9055.o
>  snd-soc-dmic-y := dmic.o
>  snd-soc-es7134-y := es7134.o
>  snd-soc-es7241-y := es7241.o
> +snd-soc-es7243-y := es7243.o
>  snd-soc-es83xx-dsm-common-y := es83xx-dsm-common.o
>  snd-soc-es8316-y := es8316.o
>  snd-soc-es8326-y := es8326.o
> @@ -515,6 +516,7 @@ obj-$(CONFIG_SND_SOC_DA9055)	+= snd-soc-da9055.o
>  obj-$(CONFIG_SND_SOC_DMIC)	+= snd-soc-dmic.o
>  obj-$(CONFIG_SND_SOC_ES7134)	+= snd-soc-es7134.o
>  obj-$(CONFIG_SND_SOC_ES7241)	+= snd-soc-es7241.o
> +obj-$(CONFIG_SND_SOC_ES7243E)	+= snd-soc-es7243e.o
>  obj-$(CONFIG_SND_SOC_ES83XX_DSM_COMMON)    += snd-soc-es83xx-dsm-common.o
>  obj-$(CONFIG_SND_SOC_ES8316)    += snd-soc-es8316.o
>  obj-$(CONFIG_SND_SOC_ES8326)    += snd-soc-es8326.o
> diff --git a/sound/soc/codecs/es7243e.c b/sound/soc/codecs/es7243e.c
> new file mode 100644
> index 000000000000..be877d980cec
> --- /dev/null
> +++ b/sound/soc/codecs/es7243e.c
> @@ -0,0 +1,676 @@
> +// SPDX-License-Identifier: GPL-2.0-only
> +/**
> + * es7243e.c - ASoC Everest Semiconductor ES7243E audio ADC driver
> + *
> + * Copyright (c) 2024, SaluteDevices. All Rights Reserved.
> + *
> + * Authors: Viktor Prutyanov <vvprutyanov@sberdevices.ru>
> + *	    Igor Prusov <ivprusov@salutedevices.com>
> + *
> + * Based on ES7243E driver by David Yang <yangxiaohua@everest-semi.com>
> + */
> +
> +#include <linux/clk.h>
> +#include <linux/module.h>
> +#include <linux/moduleparam.h>

Same issues.


> +
> +static const struct regmap_config es7243e_regmap_config = {

But this one is correct...

> +	.reg_bits = 8,
> +	.val_bits = 8,
> +	.max_register = ES7243E_CHIP_VER,
> +	.cache_type = REGCACHE_MAPLE,
> +};
> +
> +struct coeff_div {

declarations go before definitions.

> +	u32 mclk;		/* mclk frequency */
> +	u32 sr_rate;		/* sample rate */
> +	u8 osr;			/* ADC over sample rate */
> +	u8 mclk_pre;		/* mclk prediv/premult */
> +	u8 cf_dsp_div;		/* adclrck divider and daclrck divider */
> +	u8 scale;		/* ADC gain scale up */
> +	u8 lrckdiv;		/* lrck divider */
> +	u8 bclkdiv;		/* sclk divider */
> +};
> +
> +static const struct coeff_div coeff_div[] = {
> +	/* mclk     lrck   osr   pre   div   scale lrdiv bclkdiv */
> +	{ 24576000, 8000,  0x20, 0x50, 0x00, 0x00, 0x0b, 0x2f },
> +	{ 24576000, 12000, 0x20, 0x30, 0x00, 0x00, 0x07, 0x1f },
> +	{ 24576000, 16000, 0x20, 0x20, 0x00, 0x00, 0x05, 0x17 },
> +	{ 24576000, 24000, 0x20, 0x10, 0x00, 0x00, 0x03, 0x0f },
> +	{ 24576000, 32000, 0x20, 0x21, 0x00, 0x00, 0x02, 0x0b },
> +	{ 24576000, 48000, 0x20, 0x00, 0x00, 0x00, 0x01, 0x07 },
> +	{ 12288000, 8000,  0x20, 0x20, 0x00, 0x00, 0x05, 0x17 },
> +	{ 12288000, 12000, 0x20, 0x10, 0x00, 0x00, 0x03, 0x0f },
> +	{ 12288000, 16000, 0x20, 0x21, 0x00, 0x00, 0x02, 0x0b },
> +	{ 12288000, 24000, 0x20, 0x00, 0x00, 0x00, 0x01, 0x07 },
> +	{ 12288000, 32000, 0x20, 0x22, 0x00, 0x00, 0x01, 0x05 },
> +	{ 12288000, 48000, 0x20, 0x01, 0x00, 0x00, 0x00, 0x03 },
> +	{ 6144000,  8000,  0x20, 0x21, 0x00, 0x00, 0x02, 0x0b },
> +	{ 6144000,  12000, 0x20, 0x00, 0x00, 0x00, 0x01, 0x07 },
> +	{ 6144000,  16000, 0x20, 0x22, 0x00, 0x00, 0x01, 0x05 },
> +	{ 6144000,  24000, 0x20, 0x01, 0x00, 0x00, 0x00, 0x03 },
> +	{ 6144000,  32000, 0x20, 0x23, 0x00, 0x00, 0x00, 0x02 },
> +	{ 6144000,  48000, 0x20, 0x02, 0x00, 0x00, 0x00, 0x01 },
> +	{ 3072000,  8000,  0x20, 0x22, 0x00, 0x00, 0x01, 0x05 },
> +	{ 3072000,  12000, 0x20, 0x01, 0x00, 0x00, 0x00, 0x03 },
> +	{ 3072000,  16000, 0x20, 0x23, 0x00, 0x00, 0x00, 0x02 },
> +	{ 3072000,  24000, 0x20, 0x02, 0x00, 0x00, 0x00, 0x01 },
> +	{ 3072000,  32000, 0x10, 0x03, 0x20, 0x04, 0x00, 0x02 },
> +	{ 3072000,  48000, 0x20, 0x03, 0x00, 0x00, 0x00, 0x00 },
> +	{ 1536000,  8000,  0x20, 0x23, 0x00, 0x00, 0x00, 0x02 },
> +	{ 1536000,  12000, 0x20, 0x02, 0x00, 0x00, 0x00, 0x01 },
> +	{ 1536000,  16000, 0x10, 0x03, 0x20, 0x04, 0x00, 0x00 },
> +	{ 1536000,  24000, 0x20, 0x03, 0x00, 0x00, 0x00, 0x00 },
> +	{ 32768000, 8000,  0x20, 0x70, 0x00, 0x00, 0x0f, 0x3f },
> +	{ 32768000, 16000, 0x20, 0x30, 0x00, 0x00, 0x07, 0x1f },
> +	{ 32768000, 32000, 0x20, 0x10, 0x00, 0x00, 0x03, 0x0f },
> +	{ 16384000, 8000,  0x20, 0x30, 0x00, 0x00, 0x07, 0x1f },
> +	{ 16384000, 16000, 0x20, 0x10, 0x00, 0x00, 0x03, 0x0f },
> +	{ 16384000, 32000, 0x20, 0x00, 0x00, 0x00, 0x01, 0x07 },
> +	{ 8192000,  8000,  0x20, 0x10, 0x00, 0x00, 0x03, 0x0f },
> +	{ 8192000,  16000, 0x20, 0x00, 0x00, 0x00, 0x01, 0x07 },
> +	{ 8192000,  32000, 0x20, 0x01, 0x00, 0x00, 0x00, 0x03 },
> +	{ 4096000,  8000,  0x20, 0x00, 0x00, 0x00, 0x01, 0x07 },
> +	{ 4096000,  16000, 0x20, 0x01, 0x00, 0x00, 0x00, 0x03 },
> +	{ 4096000,  32000, 0x20, 0x02, 0x00, 0x00, 0x00, 0x01 },
> +	{ 2048000,  8000,  0x20, 0x01, 0x00, 0x00, 0x00, 0x03 },
> +	{ 2048000,  16000, 0x20, 0x02, 0x00, 0x00, 0x00, 0x01 },
> +	{ 2048000,  32000, 0x20, 0x03, 0x00, 0x00, 0x00, 0x00 },
> +	{ 1024000,  8000,  0x20, 0x02, 0x00, 0x00, 0x00, 0x01 },
> +	{ 1024000,  16000, 0x20, 0x03, 0x00, 0x00, 0x00, 0x00 },
> +	{ 22579200, 11025, 0x20, 0x30, 0x00, 0x00, 0x07, 0x1f },
> +	{ 22579200, 22050, 0x20, 0x10, 0x00, 0x00, 0x03, 0x0f },
> +	{ 22579200, 44100, 0x20, 0x00, 0x00, 0x00, 0x01, 0x07 },
> +	{ 11289600, 11025, 0x20, 0x10, 0x00, 0x00, 0x03, 0x0f },
> +	{ 11289600, 22050, 0x20, 0x00, 0x00, 0x00, 0x01, 0x07 },
> +	{ 11289600, 44100, 0x20, 0x01, 0x00, 0x00, 0x00, 0x03 },
> +	{ 56448000, 11025, 0x20, 0x00, 0x00, 0x00, 0x01, 0x07 },
> +	{ 56448000, 22050, 0x20, 0x01, 0x00, 0x00, 0x00, 0x03 },
> +	{ 56448000, 44100, 0x20, 0x02, 0x00, 0x00, 0x00, 0x01 },
> +	{ 28224000, 11025, 0x20, 0x01, 0x00, 0x00, 0x00, 0x03 },
> +	{ 28224000, 22050, 0x20, 0x02, 0x00, 0x00, 0x00, 0x01 },
> +	{ 28224000, 44100, 0x20, 0x03, 0x00, 0x00, 0x00, 0x00 },
> +	{ 14112000, 11025, 0x20, 0x02, 0x00, 0x00, 0x00, 0x01 },
> +	{ 14112000, 22050, 0x20, 0x03, 0x00, 0x00, 0x00, 0x00 },
> +};
> +
> +static const struct coeff_div *get_coeff(int mclk, int rate)
> +{
> +	int i;
> +
> +	for (i = 0; i < ARRAY_SIZE(coeff_div); i++)
> +		if (coeff_div[i].sr_rate == rate && coeff_div[i].mclk == mclk)
> +			return &coeff_div[i];
> +
> +	return NULL;
> +}
> +
> +static unsigned int rates_12288[] = {

Not a const?

Best regards,
Krzysztof


      reply	other threads:[~2024-07-10 10:34 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-07-09 10:41 [PATCH 0/2] Add ES7243E ADC driver Igor Prusov
2024-07-09 10:41 ` [PATCH 1/2] ASoC: dt-bindings: Add bindings for Everest ES7243E Igor Prusov
2024-07-10 10:35   ` Krzysztof Kozlowski
2024-07-09 10:41 ` [PATCH 2/2] ASoC: codecs: add ES7243E ADC driver Igor Prusov
2024-07-10 10:34   ` Krzysztof Kozlowski [this message]

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=05ed39c6-3c0b-4a43-b655-d26c69f686fa@kernel.org \
    --to=krzk@kernel.org \
    --cc=broonie@kernel.org \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=ivprusov@salutedevices.com \
    --cc=kernel@salutedevices.com \
    --cc=krzk+dt@kernel.org \
    --cc=lgirdwood@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-sound@vger.kernel.org \
    --cc=perex@perex.cz \
    --cc=prusovigor@gmail.com \
    --cc=robh@kernel.org \
    --cc=tiwai@suse.com \
    --cc=vvprutyanov@sberdevices.ru \
    --cc=yangxiaohua@everest-semi.com \
    /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