From patchwork Wed Nov 22 06:27:11 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Ellerman X-Patchwork-Id: 13464231 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ellerman.id.au header.i=@ellerman.id.au header.b="Es1OeICh" Received: from gandalf.ozlabs.org (mail.ozlabs.org [IPv6:2404:9400:2221:ea00::3]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A1793B9 for ; Wed, 22 Nov 2023 00:40:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ellerman.id.au; s=201909; t=1700642425; bh=9t38CRmxoGslme1oDdCBYnIFuNIGXQJC58kogLp05I4=; h=From:To:Cc:Subject:Date:From; b=Es1OeIChfBIqSMVJQquprMlMzKskGtXS1G6bRs71UW8ZwdWlD31p9Btdc3DZbyakB 8LrOVwpW/1iMTZ13foqFc/A6KaQxBY1gUNq4yg7rSaBwCKRv5lMXubc0DOx5P8gTcB CApE+z/9fb/mr2SkQhVQel2NiPM09acCR2htWjfEvXglocvylb/+Ob0kytoywsA8zk stEGiV/2P659bE1TotUdBtVswziAcaKott5+qPtBGottcUsKdIpiu4yW8ePR6+pkmQ AxRCDIe8gZB+4NBzKgVmPHZuScZv+ACMjzxewuTV9LosWZlC7D5fppRcT/y0E/8fcZ Fj76DIZXttMWQ== Received: from authenticated.ozlabs.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mail.ozlabs.org (Postfix) with ESMTPSA id 4SZvnz2dWFz4xNG; Wed, 22 Nov 2023 19:40:23 +1100 (AEDT) From: Michael Ellerman To: shengjiu.wang@gmail.com, Xiubo.Lee@gmail.com, festevam@gmail.com, nicoleotsuka@gmail.com, james.schulman@cirrus.com, david.rhodes@cirrus.com, rf@opensource.cirrus.com Cc: , broonie@kernel.org, perex@perex.cz, tiwai@suse.com, alsa-devel@alsa-project.org, linux-sound@vger.kernel.org, patches@opensource.cirrus.com, paul.gortmaker@windriver.com Subject: [PATCH 1/2] ASoC: fsl: mpc8610_hpcd: Remove unused driver Date: Wed, 22 Nov 2023 17:27:11 +1100 Message-ID: <20231122062712.2250426-1-mpe@ellerman.id.au> X-Mailer: git-send-email 2.41.0 Precedence: bulk X-Mailing-List: linux-sound@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 The mpc8610_hpcd.c driver depends on CONFIG_MPC8610_HPCD which was removed in commit 248667f8bbde ("powerpc: drop HPCD/MPC8610 evaluation platform support"). That makes the driver unbuildable and unusable, so remove it. Depends-on: 248667f8bbde ("powerpc: drop HPCD/MPC8610 evaluation platform support") Signed-off-by: Michael Ellerman --- MAINTAINERS | 1 - sound/soc/fsl/Kconfig | 13 - sound/soc/fsl/Makefile | 4 - sound/soc/fsl/mpc8610_hpcd.c | 451 ----------------------------------- 4 files changed, 469 deletions(-) delete mode 100644 sound/soc/fsl/mpc8610_hpcd.c diff --git a/MAINTAINERS b/MAINTAINERS index ea790149af79..27b2f5bb2061 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -8581,7 +8581,6 @@ L: linuxppc-dev@lists.ozlabs.org S: Maintained F: sound/soc/fsl/fsl* F: sound/soc/fsl/imx* -F: sound/soc/fsl/mpc8610_hpcd.c FREESCALE SOC SOUND QMC DRIVER M: Herve Codina diff --git a/sound/soc/fsl/Kconfig b/sound/soc/fsl/Kconfig index 725c530a3636..bec2aa561930 100644 --- a/sound/soc/fsl/Kconfig +++ b/sound/soc/fsl/Kconfig @@ -183,19 +183,6 @@ config SND_SOC_POWERPC_QMC_AUDIO comment "SoC Audio support for Freescale PPC boards:" -config SND_SOC_MPC8610_HPCD - tristate "ALSA SoC support for the Freescale MPC8610 HPCD board" - # I2C is necessary for the CS4270 driver - depends on MPC8610_HPCD && I2C - select SND_SOC_FSL_SSI - select SND_SOC_FSL_UTILS - select SND_SOC_POWERPC_DMA - select SND_SOC_CS4270 - select SND_SOC_CS4270_VD33_ERRATA - default y if MPC8610_HPCD - help - Say Y if you want to enable audio on the Freescale MPC8610 HPCD. - config SND_SOC_P1022_DS tristate "ALSA SoC support for the Freescale P1022 DS board" # I2C is necessary for the WM8776 driver diff --git a/sound/soc/fsl/Makefile b/sound/soc/fsl/Makefile index 8db7e97d0bd5..b45eda80c196 100644 --- a/sound/soc/fsl/Makefile +++ b/sound/soc/fsl/Makefile @@ -1,8 +1,4 @@ # SPDX-License-Identifier: GPL-2.0 -# MPC8610 HPCD Machine Support -snd-soc-mpc8610-hpcd-objs := mpc8610_hpcd.o -obj-$(CONFIG_SND_SOC_MPC8610_HPCD) += snd-soc-mpc8610-hpcd.o - # P1022 DS Machine Support snd-soc-p1022-ds-objs := p1022_ds.o obj-$(CONFIG_SND_SOC_P1022_DS) += snd-soc-p1022-ds.o diff --git a/sound/soc/fsl/mpc8610_hpcd.c b/sound/soc/fsl/mpc8610_hpcd.c deleted file mode 100644 index 52fb9e7bcca4..000000000000 --- a/sound/soc/fsl/mpc8610_hpcd.c +++ /dev/null @@ -1,451 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0 -// -// Freescale MPC8610HPCD ALSA SoC Machine driver -// -// Author: Timur Tabi -// -// Copyright 2007-2010 Freescale Semiconductor, Inc. - -#include -#include -#include -#include -#include -#include -#include - -#include "fsl_dma.h" -#include "fsl_ssi.h" -#include "fsl_utils.h" - -/* There's only one global utilities register */ -static phys_addr_t guts_phys; - -/** - * mpc8610_hpcd_data: machine-specific ASoC device data - * - * This structure contains data for a single sound platform device on an - * MPC8610 HPCD. Some of the data is taken from the device tree. - */ -struct mpc8610_hpcd_data { - struct snd_soc_dai_link dai[2]; - struct snd_soc_card card; - unsigned int dai_format; - unsigned int codec_clk_direction; - unsigned int cpu_clk_direction; - unsigned int clk_frequency; - unsigned int ssi_id; /* 0 = SSI1, 1 = SSI2, etc */ - unsigned int dma_id[2]; /* 0 = DMA1, 1 = DMA2, etc */ - unsigned int dma_channel_id[2]; /* 0 = ch 0, 1 = ch 1, etc*/ - char codec_dai_name[DAI_NAME_SIZE]; - char platform_name[2][DAI_NAME_SIZE]; /* One for each DMA channel */ -}; - -/** - * mpc8610_hpcd_machine_probe: initialize the board - * - * This function is used to initialize the board-specific hardware. - * - * Here we program the DMACR and PMUXCR registers. - */ -static int mpc8610_hpcd_machine_probe(struct snd_soc_card *card) -{ - struct mpc8610_hpcd_data *machine_data = - container_of(card, struct mpc8610_hpcd_data, card); - struct ccsr_guts __iomem *guts; - - guts = ioremap(guts_phys, sizeof(struct ccsr_guts)); - if (!guts) { - dev_err(card->dev, "could not map global utilities\n"); - return -ENOMEM; - } - - /* Program the signal routing between the SSI and the DMA */ - guts_set_dmacr(guts, machine_data->dma_id[0], - machine_data->dma_channel_id[0], - CCSR_GUTS_DMACR_DEV_SSI); - guts_set_dmacr(guts, machine_data->dma_id[1], - machine_data->dma_channel_id[1], - CCSR_GUTS_DMACR_DEV_SSI); - - guts_set_pmuxcr_dma(guts, machine_data->dma_id[0], - machine_data->dma_channel_id[0], 0); - guts_set_pmuxcr_dma(guts, machine_data->dma_id[1], - machine_data->dma_channel_id[1], 0); - - switch (machine_data->ssi_id) { - case 0: - clrsetbits_be32(&guts->pmuxcr, - CCSR_GUTS_PMUXCR_SSI1_MASK, CCSR_GUTS_PMUXCR_SSI1_SSI); - break; - case 1: - clrsetbits_be32(&guts->pmuxcr, - CCSR_GUTS_PMUXCR_SSI2_MASK, CCSR_GUTS_PMUXCR_SSI2_SSI); - break; - } - - iounmap(guts); - - return 0; -} - -/** - * mpc8610_hpcd_startup: program the board with various hardware parameters - * - * This function takes board-specific information, like clock frequencies - * and serial data formats, and passes that information to the codec and - * transport drivers. - */ -static int mpc8610_hpcd_startup(struct snd_pcm_substream *substream) -{ - struct snd_soc_pcm_runtime *rtd = snd_soc_substream_to_rtd(substream); - struct mpc8610_hpcd_data *machine_data = - container_of(rtd->card, struct mpc8610_hpcd_data, card); - struct device *dev = rtd->card->dev; - int ret = 0; - - /* Tell the codec driver what the serial protocol is. */ - ret = snd_soc_dai_set_fmt(snd_soc_rtd_to_codec(rtd, 0), machine_data->dai_format); - if (ret < 0) { - dev_err(dev, "could not set codec driver audio format\n"); - return ret; - } - - /* - * Tell the codec driver what the MCLK frequency is, and whether it's - * a slave or master. - */ - ret = snd_soc_dai_set_sysclk(snd_soc_rtd_to_codec(rtd, 0), 0, - machine_data->clk_frequency, - machine_data->codec_clk_direction); - if (ret < 0) { - dev_err(dev, "could not set codec driver clock params\n"); - return ret; - } - - return 0; -} - -/** - * mpc8610_hpcd_machine_remove: Remove the sound device - * - * This function is called to remove the sound device for one SSI. We - * de-program the DMACR and PMUXCR register. - */ -static int mpc8610_hpcd_machine_remove(struct snd_soc_card *card) -{ - struct mpc8610_hpcd_data *machine_data = - container_of(card, struct mpc8610_hpcd_data, card); - struct ccsr_guts __iomem *guts; - - guts = ioremap(guts_phys, sizeof(struct ccsr_guts)); - if (!guts) { - dev_err(card->dev, "could not map global utilities\n"); - return -ENOMEM; - } - - /* Restore the signal routing */ - - guts_set_dmacr(guts, machine_data->dma_id[0], - machine_data->dma_channel_id[0], 0); - guts_set_dmacr(guts, machine_data->dma_id[1], - machine_data->dma_channel_id[1], 0); - - switch (machine_data->ssi_id) { - case 0: - clrsetbits_be32(&guts->pmuxcr, - CCSR_GUTS_PMUXCR_SSI1_MASK, CCSR_GUTS_PMUXCR_SSI1_LA); - break; - case 1: - clrsetbits_be32(&guts->pmuxcr, - CCSR_GUTS_PMUXCR_SSI2_MASK, CCSR_GUTS_PMUXCR_SSI2_LA); - break; - } - - iounmap(guts); - - return 0; -} - -/** - * mpc8610_hpcd_ops: ASoC machine driver operations - */ -static const struct snd_soc_ops mpc8610_hpcd_ops = { - .startup = mpc8610_hpcd_startup, -}; - -/** - * mpc8610_hpcd_probe: platform probe function for the machine driver - * - * Although this is a machine driver, the SSI node is the "master" node with - * respect to audio hardware connections. Therefore, we create a new ASoC - * device for each new SSI node that has a codec attached. - */ -static int mpc8610_hpcd_probe(struct platform_device *pdev) -{ - struct device *dev = pdev->dev.parent; - /* ssi_pdev is the platform device for the SSI node that probed us */ - struct platform_device *ssi_pdev = to_platform_device(dev); - struct device_node *np = ssi_pdev->dev.of_node; - struct device_node *codec_np = NULL; - struct mpc8610_hpcd_data *machine_data; - struct snd_soc_dai_link_component *comp; - int ret; - const char *sprop; - const u32 *iprop; - - /* Find the codec node for this SSI. */ - codec_np = of_parse_phandle(np, "codec-handle", 0); - if (!codec_np) { - dev_err(dev, "invalid codec node\n"); - return -EINVAL; - } - - machine_data = kzalloc(sizeof(struct mpc8610_hpcd_data), GFP_KERNEL); - if (!machine_data) { - ret = -ENOMEM; - goto error_alloc; - } - - comp = devm_kzalloc(&pdev->dev, 6 * sizeof(*comp), GFP_KERNEL); - if (!comp) { - ret = -ENOMEM; - goto error_alloc; - } - - machine_data->dai[0].cpus = &comp[0]; - machine_data->dai[0].codecs = &comp[1]; - machine_data->dai[0].platforms = &comp[2]; - - machine_data->dai[0].num_cpus = 1; - machine_data->dai[0].num_codecs = 1; - machine_data->dai[0].num_platforms = 1; - - machine_data->dai[1].cpus = &comp[3]; - machine_data->dai[1].codecs = &comp[4]; - machine_data->dai[1].platforms = &comp[5]; - - machine_data->dai[1].num_cpus = 1; - machine_data->dai[1].num_codecs = 1; - machine_data->dai[1].num_platforms = 1; - - machine_data->dai[0].cpus->dai_name = dev_name(&ssi_pdev->dev); - machine_data->dai[0].ops = &mpc8610_hpcd_ops; - - /* ASoC core can match codec with device node */ - machine_data->dai[0].codecs->of_node = codec_np; - - /* The DAI name from the codec (snd_soc_dai_driver.name) */ - machine_data->dai[0].codecs->dai_name = "cs4270-hifi"; - - /* We register two DAIs per SSI, one for playback and the other for - * capture. Currently, we only support codecs that have one DAI for - * both playback and capture. - */ - memcpy(&machine_data->dai[1], &machine_data->dai[0], - sizeof(struct snd_soc_dai_link)); - - /* Get the device ID */ - iprop = of_get_property(np, "cell-index", NULL); - if (!iprop) { - dev_err(&pdev->dev, "cell-index property not found\n"); - ret = -EINVAL; - goto error; - } - machine_data->ssi_id = be32_to_cpup(iprop); - - /* Get the serial format and clock direction. */ - sprop = of_get_property(np, "fsl,mode", NULL); - if (!sprop) { - dev_err(&pdev->dev, "fsl,mode property not found\n"); - ret = -EINVAL; - goto error; - } - - if (strcasecmp(sprop, "i2s-slave") == 0) { - machine_data->dai_format = - SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_CBP_CFP; - machine_data->codec_clk_direction = SND_SOC_CLOCK_OUT; - machine_data->cpu_clk_direction = SND_SOC_CLOCK_IN; - - /* In i2s-slave mode, the codec has its own clock source, so we - * need to get the frequency from the device tree and pass it to - * the codec driver. - */ - iprop = of_get_property(codec_np, "clock-frequency", NULL); - if (!iprop || !*iprop) { - dev_err(&pdev->dev, "codec bus-frequency " - "property is missing or invalid\n"); - ret = -EINVAL; - goto error; - } - machine_data->clk_frequency = be32_to_cpup(iprop); - } else if (strcasecmp(sprop, "i2s-master") == 0) { - machine_data->dai_format = - SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_CBC_CFC; - machine_data->codec_clk_direction = SND_SOC_CLOCK_IN; - machine_data->cpu_clk_direction = SND_SOC_CLOCK_OUT; - } else if (strcasecmp(sprop, "lj-slave") == 0) { - machine_data->dai_format = - SND_SOC_DAIFMT_LEFT_J | SND_SOC_DAIFMT_CBP_CFP; - machine_data->codec_clk_direction = SND_SOC_CLOCK_OUT; - machine_data->cpu_clk_direction = SND_SOC_CLOCK_IN; - } else if (strcasecmp(sprop, "lj-master") == 0) { - machine_data->dai_format = - SND_SOC_DAIFMT_LEFT_J | SND_SOC_DAIFMT_CBC_CFC; - machine_data->codec_clk_direction = SND_SOC_CLOCK_IN; - machine_data->cpu_clk_direction = SND_SOC_CLOCK_OUT; - } else if (strcasecmp(sprop, "rj-slave") == 0) { - machine_data->dai_format = - SND_SOC_DAIFMT_RIGHT_J | SND_SOC_DAIFMT_CBP_CFP; - machine_data->codec_clk_direction = SND_SOC_CLOCK_OUT; - machine_data->cpu_clk_direction = SND_SOC_CLOCK_IN; - } else if (strcasecmp(sprop, "rj-master") == 0) { - machine_data->dai_format = - SND_SOC_DAIFMT_RIGHT_J | SND_SOC_DAIFMT_CBC_CFC; - machine_data->codec_clk_direction = SND_SOC_CLOCK_IN; - machine_data->cpu_clk_direction = SND_SOC_CLOCK_OUT; - } else if (strcasecmp(sprop, "ac97-slave") == 0) { - machine_data->dai_format = - SND_SOC_DAIFMT_AC97 | SND_SOC_DAIFMT_CBP_CFP; - machine_data->codec_clk_direction = SND_SOC_CLOCK_OUT; - machine_data->cpu_clk_direction = SND_SOC_CLOCK_IN; - } else if (strcasecmp(sprop, "ac97-master") == 0) { - machine_data->dai_format = - SND_SOC_DAIFMT_AC97 | SND_SOC_DAIFMT_CBC_CFC; - machine_data->codec_clk_direction = SND_SOC_CLOCK_IN; - machine_data->cpu_clk_direction = SND_SOC_CLOCK_OUT; - } else { - dev_err(&pdev->dev, - "unrecognized fsl,mode property '%s'\n", sprop); - ret = -EINVAL; - goto error; - } - - if (!machine_data->clk_frequency) { - dev_err(&pdev->dev, "unknown clock frequency\n"); - ret = -EINVAL; - goto error; - } - - /* Find the playback DMA channel to use. */ - machine_data->dai[0].platforms->name = machine_data->platform_name[0]; - ret = fsl_asoc_get_dma_channel(np, "fsl,playback-dma", - &machine_data->dai[0], - &machine_data->dma_channel_id[0], - &machine_data->dma_id[0]); - if (ret) { - dev_err(&pdev->dev, "missing/invalid playback DMA phandle\n"); - goto error; - } - - /* Find the capture DMA channel to use. */ - machine_data->dai[1].platforms->name = machine_data->platform_name[1]; - ret = fsl_asoc_get_dma_channel(np, "fsl,capture-dma", - &machine_data->dai[1], - &machine_data->dma_channel_id[1], - &machine_data->dma_id[1]); - if (ret) { - dev_err(&pdev->dev, "missing/invalid capture DMA phandle\n"); - goto error; - } - - /* Initialize our DAI data structure. */ - machine_data->dai[0].stream_name = "playback"; - machine_data->dai[1].stream_name = "capture"; - machine_data->dai[0].name = machine_data->dai[0].stream_name; - machine_data->dai[1].name = machine_data->dai[1].stream_name; - - machine_data->card.probe = mpc8610_hpcd_machine_probe; - machine_data->card.remove = mpc8610_hpcd_machine_remove; - machine_data->card.name = pdev->name; /* The platform driver name */ - machine_data->card.owner = THIS_MODULE; - machine_data->card.dev = &pdev->dev; - machine_data->card.num_links = 2; - machine_data->card.dai_link = machine_data->dai; - - /* Register with ASoC */ - ret = snd_soc_register_card(&machine_data->card); - if (ret) { - dev_err(&pdev->dev, "could not register card\n"); - goto error; - } - - of_node_put(codec_np); - - return 0; - -error: - kfree(machine_data); -error_alloc: - of_node_put(codec_np); - return ret; -} - -/** - * mpc8610_hpcd_remove: remove the platform device - * - * This function is called when the platform device is removed. - */ -static void mpc8610_hpcd_remove(struct platform_device *pdev) -{ - struct snd_soc_card *card = platform_get_drvdata(pdev); - struct mpc8610_hpcd_data *machine_data = - container_of(card, struct mpc8610_hpcd_data, card); - - snd_soc_unregister_card(card); - kfree(machine_data); -} - -static struct platform_driver mpc8610_hpcd_driver = { - .probe = mpc8610_hpcd_probe, - .remove_new = mpc8610_hpcd_remove, - .driver = { - /* The name must match 'compatible' property in the device tree, - * in lowercase letters. - */ - .name = "snd-soc-mpc8610hpcd", - }, -}; - -/** - * mpc8610_hpcd_init: machine driver initialization. - * - * This function is called when this module is loaded. - */ -static int __init mpc8610_hpcd_init(void) -{ - struct device_node *guts_np; - struct resource res; - - pr_info("Freescale MPC8610 HPCD ALSA SoC machine driver\n"); - - /* Get the physical address of the global utilities registers */ - guts_np = of_find_compatible_node(NULL, NULL, "fsl,mpc8610-guts"); - if (of_address_to_resource(guts_np, 0, &res)) { - pr_err("mpc8610-hpcd: missing/invalid global utilities node\n"); - of_node_put(guts_np); - return -EINVAL; - } - guts_phys = res.start; - of_node_put(guts_np); - - return platform_driver_register(&mpc8610_hpcd_driver); -} - -/** - * mpc8610_hpcd_exit: machine driver exit - * - * This function is called when this driver is unloaded. - */ -static void __exit mpc8610_hpcd_exit(void) -{ - platform_driver_unregister(&mpc8610_hpcd_driver); -} - -module_init(mpc8610_hpcd_init); -module_exit(mpc8610_hpcd_exit); - -MODULE_AUTHOR("Timur Tabi "); -MODULE_DESCRIPTION("Freescale MPC8610 HPCD ALSA SoC machine driver"); -MODULE_LICENSE("GPL v2"); From patchwork Wed Nov 22 06:27:12 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Ellerman X-Patchwork-Id: 13464232 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ellerman.id.au header.i=@ellerman.id.au header.b="dnjYfhAk" Received: from gandalf.ozlabs.org (mail.ozlabs.org [IPv6:2404:9400:2221:ea00::3]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A168AA1 for ; Wed, 22 Nov 2023 00:40:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ellerman.id.au; s=201909; t=1700642425; bh=DKmJA9kPwY0pYmSFefnnTEBX7rhZEPhwivx0te30dDk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=dnjYfhAkmtIfhlw3gykE6Pm6ewUleP0xnPhyeeLTNraw/NXzOuFHExLzepi0IjOJ9 pUWrjNqQvpQCnh76up5HvMC8W/uIEDuJTsce1mVeby4tboPHlsEUrwONxfYsamDy2S ZOymiRwgSHYmNPzQQibFxNFfhCLWNNKO1I4lwNNgx6PW4aLGyel7HbZ9rl+K8NvvZx 3gtN8t0sWzULbFgQ+xHbAYmFjKWQx/KTmqz3Tx9GFyKnV/Y3aE9mbwZiOAyUmmPy3I RK1I68KGNV6UKMFn5+vRb218412JmLXdyEyo7DE2W9qbLzF9n/D3H2lMRdedHu93G9 iLwHtF/CW7NgA== Received: from authenticated.ozlabs.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mail.ozlabs.org (Postfix) with ESMTPSA id 4SZvp16F96z4x3D; Wed, 22 Nov 2023 19:40:25 +1100 (AEDT) From: Michael Ellerman To: shengjiu.wang@gmail.com, Xiubo.Lee@gmail.com, festevam@gmail.com, nicoleotsuka@gmail.com, james.schulman@cirrus.com, david.rhodes@cirrus.com, rf@opensource.cirrus.com Cc: , broonie@kernel.org, perex@perex.cz, tiwai@suse.com, alsa-devel@alsa-project.org, linux-sound@vger.kernel.org, patches@opensource.cirrus.com, paul.gortmaker@windriver.com Subject: [PATCH 2/2] ASoC: cs4270: Remove unused codec Date: Wed, 22 Nov 2023 17:27:12 +1100 Message-ID: <20231122062712.2250426-2-mpe@ellerman.id.au> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231122062712.2250426-1-mpe@ellerman.id.au> References: <20231122062712.2250426-1-mpe@ellerman.id.au> Precedence: bulk X-Mailing-List: linux-sound@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 The only driver to enable SND_SOC_CS4270 was SND_SOC_MPC8610_HPCD, which was dropped in the preceding commit. Remove the codec as unused. Signed-off-by: Michael Ellerman --- sound/soc/codecs/Kconfig | 14 - sound/soc/codecs/Makefile | 2 - sound/soc/codecs/cs4270.c | 762 -------------------------------------- 3 files changed, 778 deletions(-) delete mode 100644 sound/soc/codecs/cs4270.c diff --git a/sound/soc/codecs/Kconfig b/sound/soc/codecs/Kconfig index 3429419ca694..412540e0fced 100644 --- a/sound/soc/codecs/Kconfig +++ b/sound/soc/codecs/Kconfig @@ -85,7 +85,6 @@ config SND_SOC_ALL_CODECS imply SND_SOC_CS42L73 imply SND_SOC_CS4234 imply SND_SOC_CS4265 - imply SND_SOC_CS4270 imply SND_SOC_CS4271_I2C imply SND_SOC_CS4271_SPI imply SND_SOC_CS42XX8_I2C @@ -894,19 +893,6 @@ config SND_SOC_CS4265 depends on I2C select REGMAP_I2C -# Cirrus Logic CS4270 Codec -config SND_SOC_CS4270 - tristate "Cirrus Logic CS4270 CODEC" - depends on I2C - -# Cirrus Logic CS4270 Codec VD = 3.3V Errata -# Select if you are affected by the errata where the part will not function -# if MCLK divide-by-1.5 is selected and VD is set to 3.3V. The driver will -# not select any sample rates that require MCLK to be divided by 1.5. -config SND_SOC_CS4270_VD33_ERRATA - bool - depends on SND_SOC_CS4270 - config SND_SOC_CS4271 tristate diff --git a/sound/soc/codecs/Makefile b/sound/soc/codecs/Makefile index 2078bb0d981e..e762e2babc75 100644 --- a/sound/soc/codecs/Makefile +++ b/sound/soc/codecs/Makefile @@ -89,7 +89,6 @@ snd-soc-cs42l73-objs := cs42l73.o snd-soc-cs42l83-i2c-objs := cs42l83-i2c.o snd-soc-cs4234-objs := cs4234.o snd-soc-cs4265-objs := cs4265.o -snd-soc-cs4270-objs := cs4270.o snd-soc-cs4271-objs := cs4271.o snd-soc-cs4271-i2c-objs := cs4271-i2c.o snd-soc-cs4271-spi-objs := cs4271-spi.o @@ -478,7 +477,6 @@ obj-$(CONFIG_SND_SOC_CS42L73) += snd-soc-cs42l73.o obj-$(CONFIG_SND_SOC_CS42L83) += snd-soc-cs42l83-i2c.o obj-$(CONFIG_SND_SOC_CS4234) += snd-soc-cs4234.o obj-$(CONFIG_SND_SOC_CS4265) += snd-soc-cs4265.o -obj-$(CONFIG_SND_SOC_CS4270) += snd-soc-cs4270.o obj-$(CONFIG_SND_SOC_CS4271) += snd-soc-cs4271.o obj-$(CONFIG_SND_SOC_CS4271_I2C) += snd-soc-cs4271-i2c.o obj-$(CONFIG_SND_SOC_CS4271_SPI) += snd-soc-cs4271-spi.o diff --git a/sound/soc/codecs/cs4270.c b/sound/soc/codecs/cs4270.c deleted file mode 100644 index 3bbb90c827f2..000000000000 --- a/sound/soc/codecs/cs4270.c +++ /dev/null @@ -1,762 +0,0 @@ -/* - * CS4270 ALSA SoC (ASoC) codec driver - * - * Author: Timur Tabi - * - * Copyright 2007-2009 Freescale Semiconductor, Inc. This file is licensed - * under the terms of the GNU General Public License version 2. This - * program is licensed "as is" without any warranty of any kind, whether - * express or implied. - * - * This is an ASoC device driver for the Cirrus Logic CS4270 codec. - * - * Current features/limitations: - * - * - Software mode is supported. Stand-alone mode is not supported. - * - Only I2C is supported, not SPI - * - Support for master and slave mode - * - The machine driver's 'startup' function must call - * cs4270_set_dai_sysclk() with the value of MCLK. - * - Only I2S and left-justified modes are supported - * - Power management is supported - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#define CS4270_FORMATS (SNDRV_PCM_FMTBIT_S8 | SNDRV_PCM_FMTBIT_S16_LE | \ - SNDRV_PCM_FMTBIT_S18_3LE | SNDRV_PCM_FMTBIT_S20_3LE | \ - SNDRV_PCM_FMTBIT_S24_3LE | SNDRV_PCM_FMTBIT_S24_LE) - -/* CS4270 registers addresses */ -#define CS4270_CHIPID 0x01 /* Chip ID */ -#define CS4270_PWRCTL 0x02 /* Power Control */ -#define CS4270_MODE 0x03 /* Mode Control */ -#define CS4270_FORMAT 0x04 /* Serial Format, ADC/DAC Control */ -#define CS4270_TRANS 0x05 /* Transition Control */ -#define CS4270_MUTE 0x06 /* Mute Control */ -#define CS4270_VOLA 0x07 /* DAC Channel A Volume Control */ -#define CS4270_VOLB 0x08 /* DAC Channel B Volume Control */ - -#define CS4270_FIRSTREG 0x01 -#define CS4270_LASTREG 0x08 -#define CS4270_NUMREGS (CS4270_LASTREG - CS4270_FIRSTREG + 1) -#define CS4270_I2C_INCR 0x80 - -/* Bit masks for the CS4270 registers */ -#define CS4270_CHIPID_ID 0xF0 -#define CS4270_CHIPID_REV 0x0F -#define CS4270_PWRCTL_FREEZE 0x80 -#define CS4270_PWRCTL_PDN_ADC 0x20 -#define CS4270_PWRCTL_PDN_DAC 0x02 -#define CS4270_PWRCTL_PDN 0x01 -#define CS4270_PWRCTL_PDN_ALL \ - (CS4270_PWRCTL_PDN_ADC | CS4270_PWRCTL_PDN_DAC | CS4270_PWRCTL_PDN) -#define CS4270_MODE_SPEED_MASK 0x30 -#define CS4270_MODE_1X 0x00 -#define CS4270_MODE_2X 0x10 -#define CS4270_MODE_4X 0x20 -#define CS4270_MODE_SLAVE 0x30 -#define CS4270_MODE_DIV_MASK 0x0E -#define CS4270_MODE_DIV1 0x00 -#define CS4270_MODE_DIV15 0x02 -#define CS4270_MODE_DIV2 0x04 -#define CS4270_MODE_DIV3 0x06 -#define CS4270_MODE_DIV4 0x08 -#define CS4270_MODE_POPGUARD 0x01 -#define CS4270_FORMAT_FREEZE_A 0x80 -#define CS4270_FORMAT_FREEZE_B 0x40 -#define CS4270_FORMAT_LOOPBACK 0x20 -#define CS4270_FORMAT_DAC_MASK 0x18 -#define CS4270_FORMAT_DAC_LJ 0x00 -#define CS4270_FORMAT_DAC_I2S 0x08 -#define CS4270_FORMAT_DAC_RJ16 0x18 -#define CS4270_FORMAT_DAC_RJ24 0x10 -#define CS4270_FORMAT_ADC_MASK 0x01 -#define CS4270_FORMAT_ADC_LJ 0x00 -#define CS4270_FORMAT_ADC_I2S 0x01 -#define CS4270_TRANS_ONE_VOL 0x80 -#define CS4270_TRANS_SOFT 0x40 -#define CS4270_TRANS_ZERO 0x20 -#define CS4270_TRANS_INV_ADC_A 0x08 -#define CS4270_TRANS_INV_ADC_B 0x10 -#define CS4270_TRANS_INV_DAC_A 0x02 -#define CS4270_TRANS_INV_DAC_B 0x04 -#define CS4270_TRANS_DEEMPH 0x01 -#define CS4270_MUTE_AUTO 0x20 -#define CS4270_MUTE_ADC_A 0x08 -#define CS4270_MUTE_ADC_B 0x10 -#define CS4270_MUTE_POLARITY 0x04 -#define CS4270_MUTE_DAC_A 0x01 -#define CS4270_MUTE_DAC_B 0x02 - -/* Power-on default values for the registers - * - * This array contains the power-on default values of the registers, with the - * exception of the "CHIPID" register (01h). The lower four bits of that - * register contain the hardware revision, so it is treated as volatile. - */ -static const struct reg_default cs4270_reg_defaults[] = { - { 2, 0x00 }, - { 3, 0x30 }, - { 4, 0x00 }, - { 5, 0x60 }, - { 6, 0x20 }, - { 7, 0x00 }, - { 8, 0x00 }, -}; - -static const char *supply_names[] = { - "va", "vd", "vlc" -}; - -/* Private data for the CS4270 */ -struct cs4270_private { - struct regmap *regmap; - unsigned int mclk; /* Input frequency of the MCLK pin */ - unsigned int mode; /* The mode (I2S or left-justified) */ - unsigned int slave_mode; - unsigned int manual_mute; - - /* power domain regulators */ - struct regulator_bulk_data supplies[ARRAY_SIZE(supply_names)]; - - /* reset gpio */ - struct gpio_desc *reset_gpio; -}; - -static const struct snd_soc_dapm_widget cs4270_dapm_widgets[] = { -SND_SOC_DAPM_INPUT("AINL"), -SND_SOC_DAPM_INPUT("AINR"), - -SND_SOC_DAPM_OUTPUT("AOUTL"), -SND_SOC_DAPM_OUTPUT("AOUTR"), -}; - -static const struct snd_soc_dapm_route cs4270_dapm_routes[] = { - { "Capture", NULL, "AINL" }, - { "Capture", NULL, "AINR" }, - - { "AOUTL", NULL, "Playback" }, - { "AOUTR", NULL, "Playback" }, -}; - -/** - * struct cs4270_mode_ratios - clock ratio tables - * @ratio: the ratio of MCLK to the sample rate - * @speed_mode: the Speed Mode bits to set in the Mode Control register for - * this ratio - * @mclk: the Ratio Select bits to set in the Mode Control register for this - * ratio - * - * The data for this chart is taken from Table 5 of the CS4270 reference - * manual. - * - * This table is used to determine how to program the Mode Control register. - * It is also used by cs4270_set_dai_sysclk() to tell ALSA which sampling - * rates the CS4270 currently supports. - * - * @speed_mode is the corresponding bit pattern to be written to the - * MODE bits of the Mode Control Register - * - * @mclk is the corresponding bit pattern to be wirten to the MCLK bits of - * the Mode Control Register. - * - * In situations where a single ratio is represented by multiple speed - * modes, we favor the slowest speed. E.g, for a ratio of 128, we pick - * double-speed instead of quad-speed. However, the CS4270 errata states - * that divide-By-1.5 can cause failures, so we avoid that mode where - * possible. - * - * Errata: There is an errata for the CS4270 where divide-by-1.5 does not - * work if Vd is 3.3V. If this effects you, select the - * CONFIG_SND_SOC_CS4270_VD33_ERRATA Kconfig option, and the driver will - * never select any sample rates that require divide-by-1.5. - */ -struct cs4270_mode_ratios { - unsigned int ratio; - u8 speed_mode; - u8 mclk; -}; - -static struct cs4270_mode_ratios cs4270_mode_ratios[] = { - {64, CS4270_MODE_4X, CS4270_MODE_DIV1}, -#ifndef CONFIG_SND_SOC_CS4270_VD33_ERRATA - {96, CS4270_MODE_4X, CS4270_MODE_DIV15}, -#endif - {128, CS4270_MODE_2X, CS4270_MODE_DIV1}, - {192, CS4270_MODE_4X, CS4270_MODE_DIV3}, - {256, CS4270_MODE_1X, CS4270_MODE_DIV1}, - {384, CS4270_MODE_2X, CS4270_MODE_DIV3}, - {512, CS4270_MODE_1X, CS4270_MODE_DIV2}, - {768, CS4270_MODE_1X, CS4270_MODE_DIV3}, - {1024, CS4270_MODE_1X, CS4270_MODE_DIV4} -}; - -/* The number of MCLK/LRCK ratios supported by the CS4270 */ -#define NUM_MCLK_RATIOS ARRAY_SIZE(cs4270_mode_ratios) - -static bool cs4270_reg_is_readable(struct device *dev, unsigned int reg) -{ - return (reg >= CS4270_FIRSTREG) && (reg <= CS4270_LASTREG); -} - -static bool cs4270_reg_is_volatile(struct device *dev, unsigned int reg) -{ - /* Unreadable registers are considered volatile */ - if ((reg < CS4270_FIRSTREG) || (reg > CS4270_LASTREG)) - return true; - - return reg == CS4270_CHIPID; -} - -/** - * cs4270_set_dai_sysclk - determine the CS4270 samples rates. - * @codec_dai: the codec DAI - * @clk_id: the clock ID (ignored) - * @freq: the MCLK input frequency - * @dir: the clock direction (ignored) - * - * This function is used to tell the codec driver what the input MCLK - * frequency is. - * - * The value of MCLK is used to determine which sample rates are supported - * by the CS4270. The ratio of MCLK / Fs must be equal to one of nine - * supported values - 64, 96, 128, 192, 256, 384, 512, 768, and 1024. - * - * This function calculates the nine ratios and determines which ones match - * a standard sample rate. If there's a match, then it is added to the list - * of supported sample rates. - * - * This function must be called by the machine driver's 'startup' function, - * otherwise the list of supported sample rates will not be available in - * time for ALSA. - * - * For setups with variable MCLKs, pass 0 as 'freq' argument. This will cause - * theoretically possible sample rates to be enabled. Call it again with a - * proper value set one the external clock is set (most probably you would do - * that from a machine's driver 'hw_param' hook. - */ -static int cs4270_set_dai_sysclk(struct snd_soc_dai *codec_dai, - int clk_id, unsigned int freq, int dir) -{ - struct snd_soc_component *component = codec_dai->component; - struct cs4270_private *cs4270 = snd_soc_component_get_drvdata(component); - - cs4270->mclk = freq; - return 0; -} - -/** - * cs4270_set_dai_fmt - configure the codec for the selected audio format - * @codec_dai: the codec DAI - * @format: a SND_SOC_DAIFMT_x value indicating the data format - * - * This function takes a bitmask of SND_SOC_DAIFMT_x bits and programs the - * codec accordingly. - * - * Currently, this function only supports SND_SOC_DAIFMT_I2S and - * SND_SOC_DAIFMT_LEFT_J. The CS4270 codec also supports right-justified - * data for playback only, but ASoC currently does not support different - * formats for playback vs. record. - */ -static int cs4270_set_dai_fmt(struct snd_soc_dai *codec_dai, - unsigned int format) -{ - struct snd_soc_component *component = codec_dai->component; - struct cs4270_private *cs4270 = snd_soc_component_get_drvdata(component); - - /* set DAI format */ - switch (format & SND_SOC_DAIFMT_FORMAT_MASK) { - case SND_SOC_DAIFMT_I2S: - case SND_SOC_DAIFMT_LEFT_J: - cs4270->mode = format & SND_SOC_DAIFMT_FORMAT_MASK; - break; - default: - dev_err(component->dev, "invalid dai format\n"); - return -EINVAL; - } - - /* set master/slave audio interface */ - switch (format & SND_SOC_DAIFMT_MASTER_MASK) { - case SND_SOC_DAIFMT_CBS_CFS: - cs4270->slave_mode = 1; - break; - case SND_SOC_DAIFMT_CBM_CFM: - cs4270->slave_mode = 0; - break; - default: - /* all other modes are unsupported by the hardware */ - dev_err(component->dev, "Unknown master/slave configuration\n"); - return -EINVAL; - } - - return 0; -} - -/** - * cs4270_hw_params - program the CS4270 with the given hardware parameters. - * @substream: the audio stream - * @params: the hardware parameters to set - * @dai: the SOC DAI (ignored) - * - * This function programs the hardware with the values provided. - * Specifically, the sample rate and the data format. - * - * The .ops functions are used to provide board-specific data, like input - * frequencies, to this driver. This function takes that information, - * combines it with the hardware parameters provided, and programs the - * hardware accordingly. - */ -static int cs4270_hw_params(struct snd_pcm_substream *substream, - struct snd_pcm_hw_params *params, - struct snd_soc_dai *dai) -{ - struct snd_soc_component *component = dai->component; - struct cs4270_private *cs4270 = snd_soc_component_get_drvdata(component); - int ret; - unsigned int i; - unsigned int rate; - unsigned int ratio; - int reg; - - /* Figure out which MCLK/LRCK ratio to use */ - - rate = params_rate(params); /* Sampling rate, in Hz */ - ratio = cs4270->mclk / rate; /* MCLK/LRCK ratio */ - - for (i = 0; i < NUM_MCLK_RATIOS; i++) { - if (cs4270_mode_ratios[i].ratio == ratio) - break; - } - - if (i == NUM_MCLK_RATIOS) { - /* We did not find a matching ratio */ - dev_err(component->dev, "could not find matching ratio\n"); - return -EINVAL; - } - - /* Set the sample rate */ - - reg = snd_soc_component_read(component, CS4270_MODE); - reg &= ~(CS4270_MODE_SPEED_MASK | CS4270_MODE_DIV_MASK); - reg |= cs4270_mode_ratios[i].mclk; - - if (cs4270->slave_mode) - reg |= CS4270_MODE_SLAVE; - else - reg |= cs4270_mode_ratios[i].speed_mode; - - ret = snd_soc_component_write(component, CS4270_MODE, reg); - if (ret < 0) { - dev_err(component->dev, "i2c write failed\n"); - return ret; - } - - /* Set the DAI format */ - - reg = snd_soc_component_read(component, CS4270_FORMAT); - reg &= ~(CS4270_FORMAT_DAC_MASK | CS4270_FORMAT_ADC_MASK); - - switch (cs4270->mode) { - case SND_SOC_DAIFMT_I2S: - reg |= CS4270_FORMAT_DAC_I2S | CS4270_FORMAT_ADC_I2S; - break; - case SND_SOC_DAIFMT_LEFT_J: - reg |= CS4270_FORMAT_DAC_LJ | CS4270_FORMAT_ADC_LJ; - break; - default: - dev_err(component->dev, "unknown dai format\n"); - return -EINVAL; - } - - ret = snd_soc_component_write(component, CS4270_FORMAT, reg); - if (ret < 0) { - dev_err(component->dev, "i2c write failed\n"); - return ret; - } - - return ret; -} - -/** - * cs4270_dai_mute - enable/disable the CS4270 external mute - * @dai: the SOC DAI - * @mute: 0 = disable mute, 1 = enable mute - * @direction: (ignored) - * - * This function toggles the mute bits in the MUTE register. The CS4270's - * mute capability is intended for external muting circuitry, so if the - * board does not have the MUTEA or MUTEB pins connected to such circuitry, - * then this function will do nothing. - */ -static int cs4270_dai_mute(struct snd_soc_dai *dai, int mute, int direction) -{ - struct snd_soc_component *component = dai->component; - struct cs4270_private *cs4270 = snd_soc_component_get_drvdata(component); - int reg6; - - reg6 = snd_soc_component_read(component, CS4270_MUTE); - - if (mute) - reg6 |= CS4270_MUTE_DAC_A | CS4270_MUTE_DAC_B; - else { - reg6 &= ~(CS4270_MUTE_DAC_A | CS4270_MUTE_DAC_B); - reg6 |= cs4270->manual_mute; - } - - return snd_soc_component_write(component, CS4270_MUTE, reg6); -} - -/** - * cs4270_soc_put_mute - put callback for the 'Master Playback switch' - * alsa control. - * @kcontrol: mixer control - * @ucontrol: control element information - * - * This function basically passes the arguments on to the generic - * snd_soc_put_volsw() function and saves the mute information in - * our private data structure. This is because we want to prevent - * cs4270_dai_mute() neglecting the user's decision to manually - * mute the codec's output. - * - * Returns 0 for success. - */ -static int cs4270_soc_put_mute(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) -{ - struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); - struct cs4270_private *cs4270 = snd_soc_component_get_drvdata(component); - int left = !ucontrol->value.integer.value[0]; - int right = !ucontrol->value.integer.value[1]; - - cs4270->manual_mute = (left ? CS4270_MUTE_DAC_A : 0) | - (right ? CS4270_MUTE_DAC_B : 0); - - return snd_soc_put_volsw(kcontrol, ucontrol); -} - -/* A list of non-DAPM controls that the CS4270 supports */ -static const struct snd_kcontrol_new cs4270_snd_controls[] = { - SOC_DOUBLE_R("Master Playback Volume", - CS4270_VOLA, CS4270_VOLB, 0, 0xFF, 1), - SOC_SINGLE("Digital Sidetone Switch", CS4270_FORMAT, 5, 1, 0), - SOC_SINGLE("Soft Ramp Switch", CS4270_TRANS, 6, 1, 0), - SOC_SINGLE("Zero Cross Switch", CS4270_TRANS, 5, 1, 0), - SOC_SINGLE("De-emphasis filter", CS4270_TRANS, 0, 1, 0), - SOC_SINGLE("Popguard Switch", CS4270_MODE, 0, 1, 1), - SOC_SINGLE("Auto-Mute Switch", CS4270_MUTE, 5, 1, 0), - SOC_DOUBLE("Master Capture Switch", CS4270_MUTE, 3, 4, 1, 1), - SOC_DOUBLE_EXT("Master Playback Switch", CS4270_MUTE, 0, 1, 1, 1, - snd_soc_get_volsw, cs4270_soc_put_mute), -}; - -static const struct snd_soc_dai_ops cs4270_dai_ops = { - .hw_params = cs4270_hw_params, - .set_sysclk = cs4270_set_dai_sysclk, - .set_fmt = cs4270_set_dai_fmt, - .mute_stream = cs4270_dai_mute, - .no_capture_mute = 1, -}; - -static struct snd_soc_dai_driver cs4270_dai = { - .name = "cs4270-hifi", - .playback = { - .stream_name = "Playback", - .channels_min = 2, - .channels_max = 2, - .rates = SNDRV_PCM_RATE_CONTINUOUS, - .rate_min = 4000, - .rate_max = 216000, - .formats = CS4270_FORMATS, - }, - .capture = { - .stream_name = "Capture", - .channels_min = 2, - .channels_max = 2, - .rates = SNDRV_PCM_RATE_CONTINUOUS, - .rate_min = 4000, - .rate_max = 216000, - .formats = CS4270_FORMATS, - }, - .ops = &cs4270_dai_ops, -}; - -/** - * cs4270_probe - ASoC probe function - * @component: ASoC component - * - * This function is called when ASoC has all the pieces it needs to - * instantiate a sound driver. - */ -static int cs4270_probe(struct snd_soc_component *component) -{ - struct cs4270_private *cs4270 = snd_soc_component_get_drvdata(component); - int ret; - - /* Disable auto-mute. This feature appears to be buggy. In some - * situations, auto-mute will not deactivate when it should, so we want - * this feature disabled by default. An application (e.g. alsactl) can - * re-enabled it by using the controls. - */ - ret = snd_soc_component_update_bits(component, CS4270_MUTE, CS4270_MUTE_AUTO, 0); - if (ret < 0) { - dev_err(component->dev, "i2c write failed\n"); - return ret; - } - - /* Disable automatic volume control. The hardware enables, and it - * causes volume change commands to be delayed, sometimes until after - * playback has started. An application (e.g. alsactl) can - * re-enabled it by using the controls. - */ - ret = snd_soc_component_update_bits(component, CS4270_TRANS, - CS4270_TRANS_SOFT | CS4270_TRANS_ZERO, 0); - if (ret < 0) { - dev_err(component->dev, "i2c write failed\n"); - return ret; - } - - ret = regulator_bulk_enable(ARRAY_SIZE(cs4270->supplies), - cs4270->supplies); - - return ret; -} - -/** - * cs4270_remove - ASoC remove function - * @component: ASoC component - * - * This function is the counterpart to cs4270_probe(). - */ -static void cs4270_remove(struct snd_soc_component *component) -{ - struct cs4270_private *cs4270 = snd_soc_component_get_drvdata(component); - - regulator_bulk_disable(ARRAY_SIZE(cs4270->supplies), cs4270->supplies); -}; - -#ifdef CONFIG_PM - -/* This suspend/resume implementation can handle both - a simple standby - * where the codec remains powered, and a full suspend, where the voltage - * domain the codec is connected to is teared down and/or any other hardware - * reset condition is asserted. - * - * The codec's own power saving features are enabled in the suspend callback, - * and all registers are written back to the hardware when resuming. - */ - -static int cs4270_soc_suspend(struct snd_soc_component *component) -{ - struct cs4270_private *cs4270 = snd_soc_component_get_drvdata(component); - int reg, ret; - - reg = snd_soc_component_read(component, CS4270_PWRCTL) | CS4270_PWRCTL_PDN_ALL; - if (reg < 0) - return reg; - - ret = snd_soc_component_write(component, CS4270_PWRCTL, reg); - if (ret < 0) - return ret; - - regulator_bulk_disable(ARRAY_SIZE(cs4270->supplies), - cs4270->supplies); - - return 0; -} - -static int cs4270_soc_resume(struct snd_soc_component *component) -{ - struct cs4270_private *cs4270 = snd_soc_component_get_drvdata(component); - int reg, ret; - - ret = regulator_bulk_enable(ARRAY_SIZE(cs4270->supplies), - cs4270->supplies); - if (ret != 0) - return ret; - - /* In case the device was put to hard reset during sleep, we need to - * wait 500ns here before any I2C communication. */ - ndelay(500); - - /* first restore the entire register cache ... */ - regcache_sync(cs4270->regmap); - - /* ... then disable the power-down bits */ - reg = snd_soc_component_read(component, CS4270_PWRCTL); - reg &= ~CS4270_PWRCTL_PDN_ALL; - - return snd_soc_component_write(component, CS4270_PWRCTL, reg); -} -#else -#define cs4270_soc_suspend NULL -#define cs4270_soc_resume NULL -#endif /* CONFIG_PM */ - -/* - * ASoC codec driver structure - */ -static const struct snd_soc_component_driver soc_component_device_cs4270 = { - .probe = cs4270_probe, - .remove = cs4270_remove, - .suspend = cs4270_soc_suspend, - .resume = cs4270_soc_resume, - .controls = cs4270_snd_controls, - .num_controls = ARRAY_SIZE(cs4270_snd_controls), - .dapm_widgets = cs4270_dapm_widgets, - .num_dapm_widgets = ARRAY_SIZE(cs4270_dapm_widgets), - .dapm_routes = cs4270_dapm_routes, - .num_dapm_routes = ARRAY_SIZE(cs4270_dapm_routes), - .idle_bias_on = 1, - .use_pmdown_time = 1, - .endianness = 1, -}; - -/* - * cs4270_of_match - the device tree bindings - */ -static const struct of_device_id cs4270_of_match[] = { - { .compatible = "cirrus,cs4270", }, - { } -}; -MODULE_DEVICE_TABLE(of, cs4270_of_match); - -static const struct regmap_config cs4270_regmap = { - .reg_bits = 8, - .val_bits = 8, - .max_register = CS4270_LASTREG, - .reg_defaults = cs4270_reg_defaults, - .num_reg_defaults = ARRAY_SIZE(cs4270_reg_defaults), - .cache_type = REGCACHE_MAPLE, - .write_flag_mask = CS4270_I2C_INCR, - - .readable_reg = cs4270_reg_is_readable, - .volatile_reg = cs4270_reg_is_volatile, -}; - -/** - * cs4270_i2c_remove - deinitialize the I2C interface of the CS4270 - * @i2c_client: the I2C client object - * - * This function puts the chip into low power mode when the i2c device - * is removed. - */ -static void cs4270_i2c_remove(struct i2c_client *i2c_client) -{ - struct cs4270_private *cs4270 = i2c_get_clientdata(i2c_client); - - gpiod_set_value_cansleep(cs4270->reset_gpio, 0); -} - -/** - * cs4270_i2c_probe - initialize the I2C interface of the CS4270 - * @i2c_client: the I2C client object - * - * This function is called whenever the I2C subsystem finds a device that - * matches the device ID given via a prior call to i2c_add_driver(). - */ -static int cs4270_i2c_probe(struct i2c_client *i2c_client) -{ - struct cs4270_private *cs4270; - unsigned int val; - int ret, i; - - cs4270 = devm_kzalloc(&i2c_client->dev, sizeof(struct cs4270_private), - GFP_KERNEL); - if (!cs4270) - return -ENOMEM; - - /* get the power supply regulators */ - for (i = 0; i < ARRAY_SIZE(supply_names); i++) - cs4270->supplies[i].supply = supply_names[i]; - - ret = devm_regulator_bulk_get(&i2c_client->dev, - ARRAY_SIZE(cs4270->supplies), - cs4270->supplies); - if (ret < 0) - return ret; - - /* reset the device */ - cs4270->reset_gpio = devm_gpiod_get_optional(&i2c_client->dev, "reset", - GPIOD_OUT_LOW); - if (IS_ERR(cs4270->reset_gpio)) { - dev_dbg(&i2c_client->dev, "Error getting CS4270 reset GPIO\n"); - return PTR_ERR(cs4270->reset_gpio); - } - - if (cs4270->reset_gpio) { - dev_dbg(&i2c_client->dev, "Found reset GPIO\n"); - gpiod_set_value_cansleep(cs4270->reset_gpio, 1); - } - - /* Sleep 500ns before i2c communications */ - ndelay(500); - - cs4270->regmap = devm_regmap_init_i2c(i2c_client, &cs4270_regmap); - if (IS_ERR(cs4270->regmap)) - return PTR_ERR(cs4270->regmap); - - /* Verify that we have a CS4270 */ - ret = regmap_read(cs4270->regmap, CS4270_CHIPID, &val); - if (ret < 0) { - dev_err(&i2c_client->dev, "failed to read i2c at addr %X\n", - i2c_client->addr); - return ret; - } - /* The top four bits of the chip ID should be 1100. */ - if ((val & 0xF0) != 0xC0) { - dev_err(&i2c_client->dev, "device at addr %X is not a CS4270\n", - i2c_client->addr); - return -ENODEV; - } - - dev_info(&i2c_client->dev, "found device at i2c address %X\n", - i2c_client->addr); - dev_info(&i2c_client->dev, "hardware revision %X\n", val & 0xF); - - i2c_set_clientdata(i2c_client, cs4270); - - ret = devm_snd_soc_register_component(&i2c_client->dev, - &soc_component_device_cs4270, &cs4270_dai, 1); - return ret; -} - -/* - * cs4270_id - I2C device IDs supported by this driver - */ -static const struct i2c_device_id cs4270_id[] = { - {"cs4270", 0}, - {} -}; -MODULE_DEVICE_TABLE(i2c, cs4270_id); - -/* - * cs4270_i2c_driver - I2C device identification - * - * This structure tells the I2C subsystem how to identify and support a - * given I2C device type. - */ -static struct i2c_driver cs4270_i2c_driver = { - .driver = { - .name = "cs4270", - .of_match_table = cs4270_of_match, - }, - .id_table = cs4270_id, - .probe = cs4270_i2c_probe, - .remove = cs4270_i2c_remove, -}; - -module_i2c_driver(cs4270_i2c_driver); - -MODULE_AUTHOR("Timur Tabi "); -MODULE_DESCRIPTION("Cirrus Logic CS4270 ALSA SoC Codec Driver"); -MODULE_LICENSE("GPL");