diff mbox series

[v6,6/7] ASoC: codecs: Add support for the Lantiq PEF2256 codec

Message ID 20230417171601.74656-7-herve.codina@bootlin.com
State New
Headers show
Series Add the Lantiq PEF2256 audio support | expand

Commit Message

Herve Codina April 17, 2023, 5:16 p.m. UTC
The Lantiq PEF2256 is a framer and line interface component designed to
fulfill all required interfacing between an analog E1/T1/J1 line and the
digital PCM system highway/H.100 bus.

The codec support allows to use some of the PCM system highway
time-slots as audio channels to transport audio data over the E1/T1/J1
lines. It provides also line carrier detection events reported through
the ALSA jack detection feature.

Signed-off-by: Herve Codina <herve.codina@bootlin.com>
---
 sound/soc/codecs/Kconfig         |  14 ++
 sound/soc/codecs/Makefile        |   2 +
 sound/soc/codecs/pef2256-codec.c | 390 +++++++++++++++++++++++++++++++
 3 files changed, 406 insertions(+)
 create mode 100644 sound/soc/codecs/pef2256-codec.c

Comments

kernel test robot April 22, 2023, 4:18 a.m. UTC | #1
Hi Herve,

kernel test robot noticed the following build warnings:

[auto build test WARNING on lee-mfd/for-mfd-next]
[also build test WARNING on linusw-pinctrl/devel linusw-pinctrl/for-next broonie-sound/for-next linus/master v6.3-rc7 next-20230421]
[cannot apply to lee-mfd/for-mfd-fixes]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Herve-Codina/dt-bindings-mfd-Add-the-Lantiq-PEF2256-E1-T1-J1-framer/20230418-011757
base:   https://git.kernel.org/pub/scm/linux/kernel/git/lee/mfd.git for-mfd-next
patch link:    https://lore.kernel.org/r/20230417171601.74656-7-herve.codina%40bootlin.com
patch subject: [PATCH v6 6/7] ASoC: codecs: Add support for the Lantiq PEF2256 codec
config: loongarch-randconfig-s051-20230421 (https://download.01.org/0day-ci/archive/20230422/202304221213.LXOnsKtj-lkp@intel.com/config)
compiler: loongarch64-linux-gcc (GCC) 12.1.0
reproduce:
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # apt-get install sparse
        # sparse version: v0.6.4-39-gce1a6720-dirty
        # https://github.com/intel-lab-lkp/linux/commit/1b22af56c892af6c0b5f6f18eff40f1fbefcb699
        git remote add linux-review https://github.com/intel-lab-lkp/linux
        git fetch --no-tags linux-review Herve-Codina/dt-bindings-mfd-Add-the-Lantiq-PEF2256-E1-T1-J1-framer/20230418-011757
        git checkout 1b22af56c892af6c0b5f6f18eff40f1fbefcb699
        # save the config file
        mkdir build_dir && cp config build_dir/.config
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__' O=build_dir ARCH=loongarch olddefconfig
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__' O=build_dir ARCH=loongarch SHELL=/bin/bash sound/soc/codecs/

If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <lkp@intel.com>
| Link: https://lore.kernel.org/oe-kbuild-all/202304221213.LXOnsKtj-lkp@intel.com/

sparse warnings: (new ones prefixed by >>)
>> sound/soc/codecs/pef2256-codec.c:137:26: sparse: sparse: restricted snd_pcm_format_t degrades to integer
>> sound/soc/codecs/pef2256-codec.c:139:59: sparse: sparse: incorrect type in argument 1 (different base types) @@     expected restricted snd_pcm_format_t [usertype] format @@     got unsigned int [assigned] i @@
   sound/soc/codecs/pef2256-codec.c:139:59: sparse:     expected restricted snd_pcm_format_t [usertype] format
   sound/soc/codecs/pef2256-codec.c:139:59: sparse:     got unsigned int [assigned] i
   sound/soc/codecs/pef2256-codec.c:177:26: sparse: sparse: restricted snd_pcm_format_t degrades to integer
>> sound/soc/codecs/pef2256-codec.c:179:62: sparse: sparse: incorrect type in argument 1 (different base types) @@     expected restricted snd_pcm_format_t [usertype] format @@     got int [assigned] i @@
   sound/soc/codecs/pef2256-codec.c:179:62: sparse:     expected restricted snd_pcm_format_t [usertype] format
   sound/soc/codecs/pef2256-codec.c:179:62: sparse:     got int [assigned] i

vim +137 sound/soc/codecs/pef2256-codec.c

   118	
   119	static int pef2256_dai_hw_rule_format_by_channels(struct snd_soc_dai *dai,
   120							  struct snd_pcm_hw_params *params,
   121							  unsigned int nb_ts)
   122	{
   123		struct snd_mask *f_old = hw_param_mask(params, SNDRV_PCM_HW_PARAM_FORMAT);
   124		unsigned int channels = params_channels(params);
   125		unsigned int slot_width;
   126		struct snd_mask f_new;
   127		unsigned int i;
   128	
   129		if (!channels || channels > nb_ts) {
   130			dev_err(dai->dev, "channels %u not supported\n", nb_ts);
   131			return -EINVAL;
   132		}
   133	
   134		slot_width = (nb_ts / channels) * 8;
   135	
   136		snd_mask_none(&f_new);
 > 137		for (i = 0; i <= SNDRV_PCM_FORMAT_LAST; i++) {
   138			if (snd_mask_test(f_old, i)) {
 > 139				if (snd_pcm_format_physical_width(i) <= slot_width)
   140					snd_mask_set(&f_new, i);
   141			}
   142		}
   143	
   144		return snd_mask_refine(f_old, &f_new);
   145	}
   146	
   147	static int pef2256_dai_hw_rule_playback_format_by_channels(struct snd_pcm_hw_params *params,
   148								   struct snd_pcm_hw_rule *rule)
   149	{
   150		struct snd_soc_dai *dai = rule->private;
   151		struct pef2256_codec *pef2256 = snd_soc_component_get_drvdata(dai->component);
   152	
   153		return pef2256_dai_hw_rule_format_by_channels(dai, params, pef2256->max_chan_playback);
   154	}
   155	
   156	static int pef2256_dai_hw_rule_capture_format_by_channels(struct snd_pcm_hw_params *params,
   157								  struct snd_pcm_hw_rule *rule)
   158	{
   159		struct snd_soc_dai *dai = rule->private;
   160		struct pef2256_codec *pef2256 = snd_soc_component_get_drvdata(dai->component);
   161	
   162		return pef2256_dai_hw_rule_format_by_channels(dai, params, pef2256->max_chan_capture);
   163	}
   164	
   165	static u64 pef2256_formats(u8 nb_ts)
   166	{
   167		u64 formats;
   168		unsigned int chan_width;
   169		unsigned int format_width;
   170		int i;
   171	
   172		if (!nb_ts)
   173			return 0;
   174	
   175		formats = 0;
   176		chan_width = nb_ts * 8;
   177		for (i = 0; i <= SNDRV_PCM_FORMAT_LAST; i++) {
   178			/* Support physical width multiple of 8bit */
 > 179			format_width = snd_pcm_format_physical_width(i);
   180			if (format_width == 0 || format_width % 8)
   181				continue;
   182	
   183			/*
   184			 * And support physical width that can fit N times in the
   185			 * channel
   186			 */
   187			if (format_width > chan_width || chan_width % format_width)
   188				continue;
   189	
   190			formats |= (1ULL << i);
   191		}
   192		return formats;
   193	}
   194
diff mbox series

Patch

diff --git a/sound/soc/codecs/Kconfig b/sound/soc/codecs/Kconfig
index 0be061953e9a..4f78da914fc7 100644
--- a/sound/soc/codecs/Kconfig
+++ b/sound/soc/codecs/Kconfig
@@ -168,6 +168,7 @@  config SND_SOC_ALL_CODECS
 	imply SND_SOC_PCM512x_I2C
 	imply SND_SOC_PCM512x_SPI
 	imply SND_SOC_PEB2466
+	imply SND_SOC_PEF2256
 	imply SND_SOC_RK3328
 	imply SND_SOC_RK817
 	imply SND_SOC_RT274
@@ -1252,6 +1253,19 @@  config SND_SOC_PEB2466
 	  To compile this driver as a module, choose M here: the module
 	  will be called snd-soc-peb2466.
 
+config SND_SOC_PEF2256
+	tristate "Lantiq PEF2256 codec"
+	depends on MFD_PEF2256
+	help
+	  Enable support for the Lantiq PEF2256 (FALC56) codec.
+	  The PEF2256 is a framer and line interface between analog E1/T1/J1
+	  line and a digital PCM bus.
+	  This codec allows to use some of the time slots available on the
+	  PEF2256 PCM bus to transport some audio data.
+
+	  To compile this driver as a module, choose M here: the module
+	  will be called snd-soc-pef2256.
+
 config SND_SOC_RK3328
 	tristate "Rockchip RK3328 audio CODEC"
 	select REGMAP_MMIO
diff --git a/sound/soc/codecs/Makefile b/sound/soc/codecs/Makefile
index 20b388b77f1f..11bd66d46f7b 100644
--- a/sound/soc/codecs/Makefile
+++ b/sound/soc/codecs/Makefile
@@ -188,6 +188,7 @@  snd-soc-pcm512x-objs := pcm512x.o
 snd-soc-pcm512x-i2c-objs := pcm512x-i2c.o
 snd-soc-pcm512x-spi-objs := pcm512x-spi.o
 snd-soc-peb2466-objs := peb2466.o
+snd-soc-pef2256-objs := pef2256-codec.o
 snd-soc-rk3328-objs := rk3328_codec.o
 snd-soc-rk817-objs := rk817_codec.o
 snd-soc-rl6231-objs := rl6231.o
@@ -551,6 +552,7 @@  obj-$(CONFIG_SND_SOC_PCM512x)	+= snd-soc-pcm512x.o
 obj-$(CONFIG_SND_SOC_PCM512x_I2C)	+= snd-soc-pcm512x-i2c.o
 obj-$(CONFIG_SND_SOC_PCM512x_SPI)	+= snd-soc-pcm512x-spi.o
 obj-$(CONFIG_SND_SOC_PEB2466)	+= snd-soc-peb2466.o
+obj-$(CONFIG_SND_SOC_PEF2256)	+= snd-soc-pef2256.o
 obj-$(CONFIG_SND_SOC_RK3328)	+= snd-soc-rk3328.o
 obj-$(CONFIG_SND_SOC_RK817)	+= snd-soc-rk817.o
 obj-$(CONFIG_SND_SOC_RL6231)	+= snd-soc-rl6231.o
diff --git a/sound/soc/codecs/pef2256-codec.c b/sound/soc/codecs/pef2256-codec.c
new file mode 100644
index 000000000000..aa749fa6747e
--- /dev/null
+++ b/sound/soc/codecs/pef2256-codec.c
@@ -0,0 +1,390 @@ 
+// SPDX-License-Identifier: GPL-2.0
+//
+// pef2256.c  --  Lantiq PEF2256 ALSA SoC driver
+//
+// Copyright 2023 CS GROUP France
+//
+// Author: Herve Codina <herve.codina@bootlin.com>
+
+#include <linux/clk.h>
+#include <linux/mfd/pef2256.h>
+#include <linux/module.h>
+#include <linux/notifier.h>
+#include <linux/platform_device.h>
+#include <linux/slab.h>
+#include <sound/jack.h>
+#include <sound/pcm_params.h>
+#include <sound/soc.h>
+#include <sound/tlv.h>
+
+#define PEF2256_NB_CHANNEL	32
+#define PEF2256_JACK_MASK (SND_JACK_LINEIN | SND_JACK_LINEOUT)
+
+struct pef2256_codec {
+	struct pef2256 *pef2256;
+	struct device *dev;
+	struct snd_soc_jack jack;
+	struct notifier_block nb;
+	struct work_struct carrier_work;
+	int max_chan_playback;
+	int max_chan_capture;
+};
+
+static int pef2256_dai_set_tdm_slot(struct snd_soc_dai *dai, unsigned int tx_mask,
+				    unsigned int rx_mask, int slots, int width)
+{
+	struct pef2256_codec *pef2256 = snd_soc_component_get_drvdata(dai->component);
+
+	switch (width) {
+	case 0:
+		/* Not set -> default 8 */
+	case 8:
+		break;
+	default:
+		dev_err(dai->dev, "tdm slot width %d not supported\n", width);
+		return -EINVAL;
+	}
+
+	pef2256->max_chan_playback = hweight32(tx_mask);
+	if (pef2256->max_chan_playback > PEF2256_NB_CHANNEL) {
+		dev_err(dai->dev, "too much tx slots defined (mask = 0x%x) support max %d\n",
+			tx_mask, PEF2256_NB_CHANNEL);
+		return -EINVAL;
+	}
+
+	pef2256->max_chan_capture = hweight32(rx_mask);
+	if (pef2256->max_chan_capture > PEF2256_NB_CHANNEL) {
+		dev_err(dai->dev, "too much rx slots defined (mask = 0x%x) support max %d\n",
+			rx_mask, PEF2256_NB_CHANNEL);
+		return -EINVAL;
+	}
+
+	return 0;
+}
+
+/*
+ * The constraints for format/channel is to match with the number of 8bit
+ * time-slots available.
+ */
+static int pef2256_dai_hw_rule_channels_by_format(struct snd_soc_dai *dai,
+						  struct snd_pcm_hw_params *params,
+						  unsigned int nb_ts)
+{
+	struct snd_interval *c = hw_param_interval(params, SNDRV_PCM_HW_PARAM_CHANNELS);
+	snd_pcm_format_t format = params_format(params);
+	struct snd_interval ch = {0};
+
+	switch (snd_pcm_format_physical_width(format)) {
+	case 8:
+		ch.max = nb_ts;
+		break;
+	case 16:
+		ch.max = nb_ts / 2;
+		break;
+	case 32:
+		ch.max = nb_ts / 4;
+		break;
+	case 64:
+		ch.max = nb_ts / 8;
+		break;
+	default:
+		dev_err(dai->dev, "format physical width %u not supported\n",
+			snd_pcm_format_physical_width(format));
+		return -EINVAL;
+	}
+
+	ch.min = ch.max ? 1 : 0;
+
+	return snd_interval_refine(c, &ch);
+}
+
+static int pef2256_dai_hw_rule_playback_channels_by_format(struct snd_pcm_hw_params *params,
+							   struct snd_pcm_hw_rule *rule)
+{
+	struct snd_soc_dai *dai = rule->private;
+	struct pef2256_codec *pef2256 = snd_soc_component_get_drvdata(dai->component);
+
+	return pef2256_dai_hw_rule_channels_by_format(dai, params, pef2256->max_chan_playback);
+}
+
+static int pef2256_dai_hw_rule_capture_channels_by_format(struct snd_pcm_hw_params *params,
+							  struct snd_pcm_hw_rule *rule)
+{
+	struct snd_soc_dai *dai = rule->private;
+	struct pef2256_codec *pef2256 = snd_soc_component_get_drvdata(dai->component);
+
+	return pef2256_dai_hw_rule_channels_by_format(dai, params, pef2256->max_chan_capture);
+}
+
+static int pef2256_dai_hw_rule_format_by_channels(struct snd_soc_dai *dai,
+						  struct snd_pcm_hw_params *params,
+						  unsigned int nb_ts)
+{
+	struct snd_mask *f_old = hw_param_mask(params, SNDRV_PCM_HW_PARAM_FORMAT);
+	unsigned int channels = params_channels(params);
+	unsigned int slot_width;
+	struct snd_mask f_new;
+	unsigned int i;
+
+	if (!channels || channels > nb_ts) {
+		dev_err(dai->dev, "channels %u not supported\n", nb_ts);
+		return -EINVAL;
+	}
+
+	slot_width = (nb_ts / channels) * 8;
+
+	snd_mask_none(&f_new);
+	for (i = 0; i <= SNDRV_PCM_FORMAT_LAST; i++) {
+		if (snd_mask_test(f_old, i)) {
+			if (snd_pcm_format_physical_width(i) <= slot_width)
+				snd_mask_set(&f_new, i);
+		}
+	}
+
+	return snd_mask_refine(f_old, &f_new);
+}
+
+static int pef2256_dai_hw_rule_playback_format_by_channels(struct snd_pcm_hw_params *params,
+							   struct snd_pcm_hw_rule *rule)
+{
+	struct snd_soc_dai *dai = rule->private;
+	struct pef2256_codec *pef2256 = snd_soc_component_get_drvdata(dai->component);
+
+	return pef2256_dai_hw_rule_format_by_channels(dai, params, pef2256->max_chan_playback);
+}
+
+static int pef2256_dai_hw_rule_capture_format_by_channels(struct snd_pcm_hw_params *params,
+							  struct snd_pcm_hw_rule *rule)
+{
+	struct snd_soc_dai *dai = rule->private;
+	struct pef2256_codec *pef2256 = snd_soc_component_get_drvdata(dai->component);
+
+	return pef2256_dai_hw_rule_format_by_channels(dai, params, pef2256->max_chan_capture);
+}
+
+static u64 pef2256_formats(u8 nb_ts)
+{
+	u64 formats;
+	unsigned int chan_width;
+	unsigned int format_width;
+	int i;
+
+	if (!nb_ts)
+		return 0;
+
+	formats = 0;
+	chan_width = nb_ts * 8;
+	for (i = 0; i <= SNDRV_PCM_FORMAT_LAST; i++) {
+		/* Support physical width multiple of 8bit */
+		format_width = snd_pcm_format_physical_width(i);
+		if (format_width == 0 || format_width % 8)
+			continue;
+
+		/*
+		 * And support physical width that can fit N times in the
+		 * channel
+		 */
+		if (format_width > chan_width || chan_width % format_width)
+			continue;
+
+		formats |= (1ULL << i);
+	}
+	return formats;
+}
+
+static int pef2256_dai_startup(struct snd_pcm_substream *substream,
+			       struct snd_soc_dai *dai)
+{
+	struct pef2256_codec *pef2256 = snd_soc_component_get_drvdata(dai->component);
+	snd_pcm_hw_rule_func_t hw_rule_channels_by_format;
+	snd_pcm_hw_rule_func_t hw_rule_format_by_channels;
+	unsigned int frame_bits;
+	u64 format;
+	int ret;
+
+	if (substream->stream == SNDRV_PCM_STREAM_CAPTURE) {
+		format = pef2256_formats(pef2256->max_chan_capture);
+		hw_rule_channels_by_format = pef2256_dai_hw_rule_capture_channels_by_format;
+		hw_rule_format_by_channels = pef2256_dai_hw_rule_capture_format_by_channels;
+		frame_bits = pef2256->max_chan_capture * 8;
+	} else {
+		format = pef2256_formats(pef2256->max_chan_playback);
+		hw_rule_channels_by_format = pef2256_dai_hw_rule_playback_channels_by_format;
+		hw_rule_format_by_channels = pef2256_dai_hw_rule_playback_format_by_channels;
+		frame_bits = pef2256->max_chan_playback * 8;
+	}
+
+	ret = snd_pcm_hw_constraint_mask64(substream->runtime,
+					   SNDRV_PCM_HW_PARAM_FORMAT, format);
+	if (ret) {
+		dev_err(dai->dev, "Failed to add format constraint (%d)\n", ret);
+		return ret;
+	}
+
+	ret = snd_pcm_hw_rule_add(substream->runtime, 0, SNDRV_PCM_HW_PARAM_CHANNELS,
+				  hw_rule_channels_by_format, dai,
+				  SNDRV_PCM_HW_PARAM_FORMAT, -1);
+	if (ret) {
+		dev_err(dai->dev, "Failed to add channels rule (%d)\n", ret);
+		return ret;
+	}
+
+	ret = snd_pcm_hw_rule_add(substream->runtime, 0,  SNDRV_PCM_HW_PARAM_FORMAT,
+				  hw_rule_format_by_channels, dai,
+				  SNDRV_PCM_HW_PARAM_CHANNELS, -1);
+	if (ret) {
+		dev_err(dai->dev, "Failed to add format rule (%d)\n", ret);
+		return ret;
+	}
+
+	ret = snd_pcm_hw_constraint_single(substream->runtime,
+					   SNDRV_PCM_HW_PARAM_FRAME_BITS,
+					   frame_bits);
+	if (ret < 0) {
+		dev_err(dai->dev, "Failed to add frame_bits constraint (%d)\n", ret);
+		return ret;
+	}
+
+	return 0;
+}
+
+static u64 pef2256_dai_formats[] = {
+	SND_SOC_POSSIBLE_DAIFMT_DSP_B,
+};
+
+static const struct snd_soc_dai_ops pef2256_dai_ops = {
+	.startup	= pef2256_dai_startup,
+	.set_tdm_slot	= pef2256_dai_set_tdm_slot,
+	.auto_selectable_formats     = pef2256_dai_formats,
+	.num_auto_selectable_formats = ARRAY_SIZE(pef2256_dai_formats),
+};
+
+static struct snd_soc_dai_driver pef2256_dai_driver = {
+	.name = "pef2256",
+	.playback = {
+		.stream_name = "Playback",
+		.channels_min = 1,
+		.channels_max = PEF2256_NB_CHANNEL,
+		.rates = SNDRV_PCM_RATE_8000,
+		.formats = U64_MAX, /* Will be refined on DAI .startup() */
+	},
+	.capture = {
+		.stream_name = "Capture",
+		.channels_min = 1,
+		.channels_max = PEF2256_NB_CHANNEL,
+		.rates = SNDRV_PCM_RATE_8000,
+		.formats = U64_MAX, /* Will be refined on DAI .startup() */
+	},
+	.ops = &pef2256_dai_ops,
+};
+
+static void pef2256_carrier_work(struct work_struct *work)
+{
+	struct pef2256_codec *pef2256 = container_of(work, struct pef2256_codec, carrier_work);
+	int status;
+
+	status = pef2256_get_carrier(pef2256->pef2256) ? PEF2256_JACK_MASK : 0;
+	snd_soc_jack_report(&pef2256->jack, status, PEF2256_JACK_MASK);
+}
+
+static int pef2256_carrier_notifier(struct notifier_block *nb, unsigned long action,
+				    void *data)
+{
+	struct pef2256_codec *pef2256 = container_of(nb, struct pef2256_codec, nb);
+
+	switch (action) {
+	case PEF2256_EVENT_CARRIER:
+		queue_work(system_power_efficient_wq, &pef2256->carrier_work);
+		break;
+	default:
+		return NOTIFY_DONE;
+	}
+
+	return NOTIFY_OK;
+}
+
+static int pef2256_component_probe(struct snd_soc_component *component)
+{
+	struct pef2256_codec *pef2256 = snd_soc_component_get_drvdata(component);
+	char *name;
+	int ret;
+
+	INIT_WORK(&pef2256->carrier_work, pef2256_carrier_work);
+
+	name = "carrier";
+	if (component->name_prefix) {
+		name = kasprintf(GFP_KERNEL, "%s carrier", component->name_prefix);
+		if (!name)
+			return -ENOMEM;
+	}
+
+	ret = snd_soc_card_jack_new(component->card, name, PEF2256_JACK_MASK, &pef2256->jack);
+	if (component->name_prefix)
+		kfree(name); /* A copy is done by snd_soc_card_jack_new */
+	if (ret) {
+		dev_err(component->dev, "Cannot create jack\n");
+		return ret;
+	}
+
+	pef2256->nb.notifier_call = pef2256_carrier_notifier;
+	ret = pef2256_register_event_notifier(pef2256->pef2256, &pef2256->nb);
+	if (ret) {
+		dev_err(component->dev, "Cannot register event notifier\n");
+		return ret;
+	}
+
+	/* Queue work to set the initial value */
+	queue_work(system_power_efficient_wq, &pef2256->carrier_work);
+
+	return 0;
+}
+
+static void pef2256_component_remove(struct snd_soc_component *component)
+{
+	struct pef2256_codec *pef2256 = snd_soc_component_get_drvdata(component);
+
+	pef2256_unregister_event_notifier(pef2256->pef2256, &pef2256->nb);
+	cancel_work_sync(&pef2256->carrier_work);
+}
+
+static const struct snd_soc_component_driver pef2256_component_driver = {
+	.probe		= pef2256_component_probe,
+	.remove		= pef2256_component_remove,
+	.endianness	= 1,
+};
+
+static int pef2256_codec_probe(struct platform_device *pdev)
+{
+	struct pef2256_codec *pef2256;
+
+	pef2256 = devm_kzalloc(&pdev->dev, sizeof(*pef2256), GFP_KERNEL);
+	if (!pef2256)
+		return -ENOMEM;
+
+	pef2256->dev = &pdev->dev;
+	pef2256->pef2256 = dev_get_drvdata(pef2256->dev->parent);
+
+	platform_set_drvdata(pdev, pef2256);
+
+	return devm_snd_soc_register_component(&pdev->dev, &pef2256_component_driver,
+					       &pef2256_dai_driver, 1);
+}
+
+static const struct of_device_id pef2256_codec_of_match[] = {
+	{ .compatible = "lantiq,pef2256-codec" },
+	{} /* sentinel */
+};
+MODULE_DEVICE_TABLE(of, pef2256_codec_of_match);
+
+static struct platform_driver pef2256_codec_driver = {
+	.driver = {
+		.name = "lantiq-pef2256-codec",
+		.of_match_table = pef2256_codec_of_match,
+	},
+	.probe = pef2256_codec_probe,
+};
+module_platform_driver(pef2256_codec_driver);
+
+MODULE_AUTHOR("Herve Codina <herve.codina@bootlin.com>");
+MODULE_DESCRIPTION("PEF2256 ALSA SoC driver");
+MODULE_LICENSE("GPL");