From nobody Thu Dec 18 07:53:42 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0EB0BC77B76 for ; Fri, 14 Apr 2023 14:03:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230204AbjDNODi (ORCPT ); Fri, 14 Apr 2023 10:03:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53144 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230032AbjDNODd (ORCPT ); Fri, 14 Apr 2023 10:03:33 -0400 Received: from mail-lj1-x22b.google.com (mail-lj1-x22b.google.com [IPv6:2a00:1450:4864:20::22b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 008255BB0 for ; Fri, 14 Apr 2023 07:02:58 -0700 (PDT) Received: by mail-lj1-x22b.google.com with SMTP id y35so4153985ljq.6 for ; Fri, 14 Apr 2023 07:02:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=semihalf.com; s=google; t=1681480964; x=1684072964; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Bxyap3C7vnCZiYWpHQpZz2VAx2t0ZhWrLbyvgckvU+w=; b=Gmjqkxzo0Ck8WXLqKCS9AX4CDT5afRvDrQ056Cxb+7URvPCCz52K9LHM9xdOe1eB3Q YYXx57/aeFlMeSfqfwdlGYby2qHNZw3tU8RT1qzD/FSDO8CaEQSGTDVhtCUafa0gq+cs JVfA2W7e9VIOYwjOFJnvwHBgZYT+NRJoKH2a3270NYNRZoQgN/cTrdVD2hQum6JbkXq1 ee/+scJ6CLbubujQ8zSxxye9zexdPAZAKEjtv5qNEoXBvUWBJY3064Pare1kJ39wm7se p/QY6G4R1ZW3xXDv+qTo4HU74giHUYMZAcwoyYqifB9WMib8xRcrxQrcHYWc4RbDF+mt NJKw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1681480964; x=1684072964; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Bxyap3C7vnCZiYWpHQpZz2VAx2t0ZhWrLbyvgckvU+w=; b=i5VXCvlDATnuYUCV35dLg2uijLAWqGRDOokSIo5AtS3Ix6nCMvFm7WvGqIQf/ZUEC0 +UDFrmJO4zO83G/Z9tIaYyBXJO4Xx+yCfwtCsW3lth30ztxj/uIM61d5LGLuw94BDosC XwzndC+Ox9WmQZdjauxER/TvrLiB5jNNQ62hOMsMTHoHLflJUc+/tPrZBgvkokDyTDo3 77QWC7SBtTO2c2gYB72w/w5L6GarH7PHBB7g4XfFUbezL45wPVnp4hqd8Jum6OMkSNv5 ScqJfGK6/1YLqek5R+WpVItlk0kbntjys7KtsQC7Iwl2+Ry99G+tesZteSIcIz5/3HXA McBQ== X-Gm-Message-State: AAQBX9ekOn+izZil1bAGDUd6S8zC7C+bWKI31zSgPJJ6cPXIpUNjTrcC rfAzY/ChK1LXltJOq/jh7VZabA== X-Google-Smtp-Source: AKy350b5uDMDwSZXnP+ykH/7bIaFsCQIcUysiVn/LCImS52AjBEm2D7lyPja+s0isp2EYILrAX1fyg== X-Received: by 2002:a2e:9f14:0:b0:29a:9b26:4e25 with SMTP id u20-20020a2e9f14000000b0029a9b264e25mr1698870ljk.6.1681480963267; Fri, 14 Apr 2023 07:02:43 -0700 (PDT) Received: from panikiel.roam.corp.google.com (staticline-31-182-201-26.toya.net.pl. [31.182.201.26]) by smtp.gmail.com with ESMTPSA id 15-20020a2eb2cf000000b002a76e2dedbcsm828684ljz.139.2023.04.14.07.02.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 14 Apr 2023 07:02:42 -0700 (PDT) From: =?UTF-8?q?Pawe=C5=82=20Anikiel?= To: alsa-devel@alsa-project.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, lgirdwood@gmail.com, broonie@kernel.org Cc: perex@perex.cz, tiwai@suse.com, robh+dt@kernel.org, krzysztof.kozlowski+dt@linaro.org, dinguyen@kernel.org, lars@metafoo.de, nuno.sa@analog.com, upstream@semihalf.com, =?UTF-8?q?Pawe=C5=82=20Anikiel?= Subject: [PATCH 1/9] ASoC: Add Chameleon v3 audio Date: Fri, 14 Apr 2023 16:01:55 +0200 Message-ID: <20230414140203.707729-2-pan@semihalf.com> X-Mailer: git-send-email 2.40.0.634.g4ca3ef3211-goog In-Reply-To: <20230414140203.707729-1-pan@semihalf.com> References: <20230414140203.707729-1-pan@semihalf.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Add machine and platform drivers for ASoC audio on Chameleon v3. The board has two audio sources: HDMI audio from the it68051 chip (RX only), and analog audio from the ssm2603 chip (RX and TX). Signed-off-by: Pawe=C5=82 Anikiel --- .../boot/dts/socfpga_arria10_chameleonv3.dts | 28 ++ sound/soc/Kconfig | 1 + sound/soc/Makefile | 1 + sound/soc/chameleonv3/Kconfig | 7 + sound/soc/chameleonv3/Makefile | 2 + sound/soc/chameleonv3/chv3-audio.c | 111 ++++++ sound/soc/chameleonv3/chv3-i2s.c | 347 ++++++++++++++++++ sound/soc/chameleonv3/chv3-it68051.c | 41 +++ 8 files changed, 538 insertions(+) create mode 100644 sound/soc/chameleonv3/Kconfig create mode 100644 sound/soc/chameleonv3/Makefile create mode 100644 sound/soc/chameleonv3/chv3-audio.c create mode 100644 sound/soc/chameleonv3/chv3-i2s.c create mode 100644 sound/soc/chameleonv3/chv3-it68051.c diff --git a/arch/arm/boot/dts/socfpga_arria10_chameleonv3.dts b/arch/arm/b= oot/dts/socfpga_arria10_chameleonv3.dts index 422d00cd4c74..c75f41058196 100644 --- a/arch/arm/boot/dts/socfpga_arria10_chameleonv3.dts +++ b/arch/arm/boot/dts/socfpga_arria10_chameleonv3.dts @@ -15,6 +15,34 @@ aliases { i2c0 =3D &i2c0; i2c1 =3D &i2c1; }; + + soc { + i2s0: i2s@c0060300 { + compatible =3D "google,chv3-i2s"; + reg =3D <0xc0060300 0x100>, + <0xc0060f00 0x10>; + interrupts =3D <0 20 IRQ_TYPE_LEVEL_HIGH>; + }; + + i2s1: i2s@c0060400 { + compatible =3D "google,chv3-i2s"; + reg =3D <0xc0060400 0x100>, + <0xc0060f10 0x10>; + interrupts =3D <0 21 IRQ_TYPE_LEVEL_HIGH>; + }; + }; + + sound { + compatible =3D "google,chv3-audio"; + google,audio-cpu0 =3D <&i2s1>; + google,audio-codec0 =3D <&ssm2603>; + google,audio-cpu1 =3D <&i2s0>; + google,audio-codec1 =3D <&it68051>; + }; + + it68051: audio-codec { + compatible =3D "ite,it68051"; + }; }; =20 &gmac0 { diff --git a/sound/soc/Kconfig b/sound/soc/Kconfig index 848fbae26c3b..d5a24819a0eb 100644 --- a/sound/soc/Kconfig +++ b/sound/soc/Kconfig @@ -72,6 +72,7 @@ source "sound/soc/apple/Kconfig" source "sound/soc/atmel/Kconfig" source "sound/soc/au1x/Kconfig" source "sound/soc/bcm/Kconfig" +source "sound/soc/chameleonv3/Kconfig" source "sound/soc/cirrus/Kconfig" source "sound/soc/dwc/Kconfig" source "sound/soc/fsl/Kconfig" diff --git a/sound/soc/Makefile b/sound/soc/Makefile index 507eaed1d6a1..5572f4ebe59e 100644 --- a/sound/soc/Makefile +++ b/sound/soc/Makefile @@ -40,6 +40,7 @@ obj-$(CONFIG_SND_SOC) +=3D amd/ obj-$(CONFIG_SND_SOC) +=3D atmel/ obj-$(CONFIG_SND_SOC) +=3D au1x/ obj-$(CONFIG_SND_SOC) +=3D bcm/ +obj-$(CONFIG_SND_SOC) +=3D chameleonv3/ obj-$(CONFIG_SND_SOC) +=3D cirrus/ obj-$(CONFIG_SND_SOC) +=3D dwc/ obj-$(CONFIG_SND_SOC) +=3D fsl/ diff --git a/sound/soc/chameleonv3/Kconfig b/sound/soc/chameleonv3/Kconfig new file mode 100644 index 000000000000..8386c44d6e92 --- /dev/null +++ b/sound/soc/chameleonv3/Kconfig @@ -0,0 +1,7 @@ +# SPDX-License-Identifier: GPL-2.0-only +config SND_SOC_CHV3 + tristate "SoC Audio support for Chameleon v3" + select SND_SOC_SSM2602 + select SND_SOC_SSM2602_I2C + help + Say Y if you want to add audio support for the Chameleon v3. diff --git a/sound/soc/chameleonv3/Makefile b/sound/soc/chameleonv3/Makefile new file mode 100644 index 000000000000..a542ad412b93 --- /dev/null +++ b/sound/soc/chameleonv3/Makefile @@ -0,0 +1,2 @@ +# SPDX-License-Identifier: GPL-2.0-only +obj-$(CONFIG_SND_SOC_CHV3) +=3D chv3-i2s.o chv3-audio.o chv3-it68051.o diff --git a/sound/soc/chameleonv3/chv3-audio.c b/sound/soc/chameleonv3/chv= 3-audio.c new file mode 100644 index 000000000000..e860447c2cef --- /dev/null +++ b/sound/soc/chameleonv3/chv3-audio.c @@ -0,0 +1,111 @@ +// SPDX-License-Identifier: GPL-2.0-only +#include +#include +#include + +#include + +static int chv3_ssm2603_hw_params(struct snd_pcm_substream *substream, + struct snd_pcm_hw_params *params) +{ + struct snd_soc_pcm_runtime *rtd =3D asoc_substream_to_rtd(substream); + struct snd_soc_dai *dai =3D asoc_rtd_to_codec(rtd, 0); + + return snd_soc_dai_set_sysclk(dai, 0, 22579200, SND_SOC_CLOCK_IN); +} + +static const struct snd_soc_ops chv3_ssm2603_ops =3D { + .hw_params =3D chv3_ssm2603_hw_params, +}; + +SND_SOC_DAILINK_DEFS(ssm2603, + DAILINK_COMP_ARRAY(COMP_CPU("chv3-i2s")), + DAILINK_COMP_ARRAY(COMP_CODEC(NULL, "ssm2602-hifi")), /* 2602 - not a typ= o */ + DAILINK_COMP_ARRAY(COMP_EMPTY())); + +SND_SOC_DAILINK_DEFS(it68051, + DAILINK_COMP_ARRAY(COMP_CPU("chv3-i2s")), + DAILINK_COMP_ARRAY(COMP_CODEC(NULL, "it68051-hifi")), + DAILINK_COMP_ARRAY(COMP_EMPTY())); + +static struct snd_soc_dai_link chv3_audio_dais[] =3D { +{ + .name =3D "ssm2603", + .stream_name =3D "ssm2603 PCM", + .dai_fmt =3D SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_CBM_CFM, + .ops =3D &chv3_ssm2603_ops, + SND_SOC_DAILINK_REG(ssm2603), +}, +{ + .name =3D "it68051", + .stream_name =3D "it68051 PCM", + .dai_fmt =3D SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_CBM_CFM, + SND_SOC_DAILINK_REG(it68051), +}, +}; + +static struct snd_soc_card chv3_audio_card =3D { + .name =3D "chv3-audio", + .owner =3D THIS_MODULE, + .dai_link =3D chv3_audio_dais, + .num_links =3D 2, +}; + +static int chv3_audio_probe(struct platform_device *pdev) +{ + struct snd_soc_card *card =3D &chv3_audio_card; + struct device_node *np; + + card->dev =3D &pdev->dev; + + np =3D of_parse_phandle(pdev->dev.of_node, "google,audio-cpu0", 0); + if (!np) { + dev_err(&pdev->dev, "no google,audio-cpu0 property\n"); + return -EINVAL; + } + chv3_audio_dais[0].cpus->of_node =3D np; + chv3_audio_dais[0].platforms->of_node =3D np; + + np =3D of_parse_phandle(pdev->dev.of_node, "google,audio-codec0", 0); + if (!np) { + dev_err(&pdev->dev, "no google,audio-codec0 property\n"); + return -EINVAL; + } + chv3_audio_dais[0].codecs->of_node =3D np; + + np =3D of_parse_phandle(pdev->dev.of_node, "google,audio-cpu1", 0); + if (!np) { + dev_err(&pdev->dev, "no google,audio-cpu1 property\n"); + return -EINVAL; + } + chv3_audio_dais[1].cpus->of_node =3D np; + chv3_audio_dais[1].platforms->of_node =3D np; + + np =3D of_parse_phandle(pdev->dev.of_node, "google,audio-codec1", 0); + if (!np) { + dev_err(&pdev->dev, "no google,audio-codec1 property\n"); + return -EINVAL; + } + chv3_audio_dais[1].codecs->of_node =3D np; + + return devm_snd_soc_register_card(card->dev, card); +} + +static const struct of_device_id chv3_audio_dt_ids[] =3D { + { .compatible =3D "google,chv3-audio" }, + { }, +}; + +static struct platform_driver chv3_audio_driver =3D { + .driver =3D { + .name =3D "chv3-audio", + .of_match_table =3D of_match_ptr(chv3_audio_dt_ids), + }, + .probe =3D chv3_audio_probe, +}; + +module_platform_driver(chv3_audio_driver); + +MODULE_AUTHOR("Pawel Anikiel "); +MODULE_DESCRIPTION("ALSA SoC Chameleon v3 audio driver"); +MODULE_LICENSE("GPL"); diff --git a/sound/soc/chameleonv3/chv3-i2s.c b/sound/soc/chameleonv3/chv3-= i2s.c new file mode 100644 index 000000000000..e946bff2e6fc --- /dev/null +++ b/sound/soc/chameleonv3/chv3-i2s.c @@ -0,0 +1,347 @@ +// SPDX-License-Identifier: GPL-2.0-only +#include +#include +#include + +#include + +/* + * The I2S interface consists of two ring buffers - one for RX and one for + * TX. A ring buffer has a producer index and a consumer index. Depending + * on which way the data is flowing, either the software or the hardware + * writes data and updates the producer index, and the other end reads data + * and updates the consumer index. + * + * The pointer managed by software is updated using the .ack callback + * (see chv3_dma_ack). This seems to be the only way to reliably obtain + * the appl_ptr from within the driver and pass it to hardware. + * + * Because of the two pointer design, the ring buffer can never be full. W= ith + * capture this isn't a problem, because the hardware being the producer + * will wait for the consumer index to move out of the way. With playback, + * however, this is problematic, because ALSA wants to fill up the buffer + * completely when waiting for hardware. In the .ack callback, the driver + * would have to wait for the consumer index to move out of the way by + * busy-waiting, which would keep stalling the kernel for quite a long tim= e. + * + * The workaround to this problem is to "lie" to ALSA that the hw_pointer + * is one period behind what it actually is (see chv3_dma_pointer). This + * way, ALSA will not try to fill up the entire buffer, and all callbacks + * are wait-free. + */ + +#define I2S_TX_ENABLE 0x00 +#define I2S_TX_BASE_ADDR 0x04 +#define I2S_TX_BUFFER_SIZE 0x08 +#define I2S_TX_PRODUCER_IDX 0x0c +#define I2S_TX_CONSUMER_IDX 0x10 +#define I2S_RX_ENABLE 0x14 +#define I2S_RX_BASE_ADDR 0x18 +#define I2S_RX_BUFFER_SIZE 0x1c +#define I2S_RX_PRODUCER_IDX 0x20 +#define I2S_RX_CONSUMER_IDX 0x24 + +#define I2S_SOFT_RESET 0x2c +#define I2S_SOFT_RESET_RX_BIT 0x1 +#define I2S_SOFT_RESET_TX_BIT 0x2 + +#define I2S_RX_IRQ 0x4c +#define I2S_RX_IRQ_CONST 0x50 +#define I2S_TX_IRQ 0x54 +#define I2S_TX_IRQ_CONST 0x58 + +#define I2S_IRQ_MASK 0x8 +#define I2S_IRQ_CLR 0xc +#define I2S_IRQ_RX_BIT 0x1 +#define I2S_IRQ_TX_BIT 0x2 + +#define I2S_MAX_BUFFER_SIZE 0x200000 + +struct chv3_i2s_dev { + struct device *dev; + void __iomem *iobase; + void __iomem *iobase_irq; + struct snd_pcm_substream *rx_substream; + struct snd_pcm_substream *tx_substream; + int tx_bytes_to_fetch; + bool tx_ready; +}; + +static struct snd_soc_dai_driver chv3_i2s_dai =3D { + .name =3D "chv3-i2s", + .capture =3D { + .channels_min =3D 1, + .channels_max =3D 128, + .rates =3D SNDRV_PCM_RATE_CONTINUOUS, + .rate_min =3D 8000, + .rate_max =3D 96000, + .formats =3D SNDRV_PCM_FMTBIT_S32_LE, + }, + .playback =3D { + .channels_min =3D 1, + .channels_max =3D 128, + .rates =3D SNDRV_PCM_RATE_CONTINUOUS, + .rate_min =3D 8000, + .rate_max =3D 96000, + .formats =3D SNDRV_PCM_FMTBIT_S32_LE, + }, +}; + +static const struct snd_pcm_hardware chv3_dma_hw =3D { + .info =3D SNDRV_PCM_INFO_INTERLEAVED | + SNDRV_PCM_INFO_MMAP | + SNDRV_PCM_INFO_MMAP_VALID | + SNDRV_PCM_INFO_BLOCK_TRANSFER, + .buffer_bytes_max =3D I2S_MAX_BUFFER_SIZE, + .period_bytes_min =3D 64, + .period_bytes_max =3D 8192, + .periods_min =3D 4, + .periods_max =3D 256, +}; + +static inline void chv3_i2s_wr(struct chv3_i2s_dev *i2s, int offset, u32 v= al) +{ + writel(val, i2s->iobase + offset); +} + +static inline u32 chv3_i2s_rd(struct chv3_i2s_dev *i2s, int offset) +{ + return readl(i2s->iobase + offset); +} + +static irqreturn_t chv3_i2s_isr(int irq, void *data) +{ + struct chv3_i2s_dev *i2s =3D data; + u32 reg; + + reg =3D readl(i2s->iobase_irq + I2S_IRQ_CLR); + if (!reg) + return IRQ_NONE; + + if (reg & I2S_IRQ_RX_BIT) + snd_pcm_period_elapsed(i2s->rx_substream); + + if (reg & I2S_IRQ_TX_BIT) { + if (i2s->tx_ready) + snd_pcm_period_elapsed(i2s->tx_substream); + i2s->tx_ready =3D 1; + } + + writel(reg, i2s->iobase_irq + I2S_IRQ_CLR); + + return IRQ_HANDLED; +} + +static int chv3_dma_open(struct snd_soc_component *component, + struct snd_pcm_substream *substream) +{ + struct snd_soc_pcm_runtime *rtd =3D asoc_substream_to_rtd(substream); + struct chv3_i2s_dev *i2s =3D snd_soc_dai_get_drvdata(asoc_rtd_to_cpu(rtd,= 0)); + int res; + + snd_soc_set_runtime_hwparams(substream, &chv3_dma_hw); + + res =3D snd_pcm_hw_constraint_pow2(substream->runtime, 0, + SNDRV_PCM_HW_PARAM_BUFFER_BYTES); + if (res) + return res; + + if (substream->stream =3D=3D SNDRV_PCM_STREAM_CAPTURE) + i2s->rx_substream =3D substream; + else + i2s->tx_substream =3D substream; + + return 0; +} +static int chv3_dma_close(struct snd_soc_component *component, + struct snd_pcm_substream *substream) +{ + struct snd_soc_pcm_runtime *rtd =3D asoc_substream_to_rtd(substream); + struct chv3_i2s_dev *i2s =3D snd_soc_dai_get_drvdata(asoc_rtd_to_cpu(rtd,= 0)); + + if (substream->pstr->stream =3D=3D SNDRV_PCM_STREAM_CAPTURE) + chv3_i2s_wr(i2s, I2S_RX_ENABLE, 0); + else + chv3_i2s_wr(i2s, I2S_TX_ENABLE, 0); + + return 0; +} + +static int chv3_dma_pcm_construct(struct snd_soc_component *component, + struct snd_soc_pcm_runtime *rtd) +{ + struct chv3_i2s_dev *i2s =3D snd_soc_dai_get_drvdata(asoc_rtd_to_cpu(rtd,= 0)); + struct snd_pcm_substream *substream; + int res; + + substream =3D rtd->pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream; + if (substream) { + res =3D snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, i2s->dev, + I2S_MAX_BUFFER_SIZE, &substream->dma_buffer); + if (res) + return res; + } + + substream =3D rtd->pcm->streams[SNDRV_PCM_STREAM_CAPTURE].substream; + if (substream) { + res =3D snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, i2s->dev, + I2S_MAX_BUFFER_SIZE, &substream->dma_buffer); + if (res) + return res; + } + + return 0; +} + +static int chv3_dma_hw_params(struct snd_soc_component *component, + struct snd_pcm_substream *substream, + struct snd_pcm_hw_params *params) +{ + snd_pcm_set_runtime_buffer(substream, &substream->dma_buffer); + return 0; +} + +static int chv3_dma_prepare(struct snd_soc_component *component, + struct snd_pcm_substream *substream) +{ + struct snd_soc_pcm_runtime *rtd =3D asoc_substream_to_rtd(substream); + struct chv3_i2s_dev *i2s =3D snd_soc_dai_get_drvdata(asoc_rtd_to_cpu(rtd,= 0)); + unsigned int buffer_bytes, period_bytes, period_size; + + buffer_bytes =3D snd_pcm_lib_buffer_bytes(substream); + period_bytes =3D snd_pcm_lib_period_bytes(substream); + period_size =3D substream->runtime->period_size; + + if (substream->pstr->stream =3D=3D SNDRV_PCM_STREAM_CAPTURE) { + chv3_i2s_wr(i2s, I2S_SOFT_RESET, I2S_SOFT_RESET_RX_BIT); + chv3_i2s_wr(i2s, I2S_RX_BASE_ADDR, substream->dma_buffer.addr); + chv3_i2s_wr(i2s, I2S_RX_BUFFER_SIZE, buffer_bytes); + chv3_i2s_wr(i2s, I2S_RX_IRQ, (period_size << 8) | 1); + chv3_i2s_wr(i2s, I2S_RX_ENABLE, 1); + } else { + i2s->tx_ready =3D 0; + chv3_i2s_wr(i2s, I2S_SOFT_RESET, I2S_SOFT_RESET_TX_BIT); + chv3_i2s_wr(i2s, I2S_TX_BASE_ADDR, substream->dma_buffer.addr); + chv3_i2s_wr(i2s, I2S_TX_BUFFER_SIZE, buffer_bytes); + chv3_i2s_wr(i2s, I2S_TX_IRQ, ((period_bytes / i2s->tx_bytes_to_fetch) <<= 8) | 1); + chv3_i2s_wr(i2s, I2S_TX_ENABLE, 1); + } + writel(I2S_IRQ_RX_BIT | I2S_IRQ_TX_BIT, i2s->iobase_irq + I2S_IRQ_MASK); + + return 0; +} + +static snd_pcm_uframes_t chv3_dma_pointer(struct snd_soc_component *compon= ent, + struct snd_pcm_substream *substream) +{ + struct snd_soc_pcm_runtime *rtd =3D asoc_substream_to_rtd(substream); + struct chv3_i2s_dev *i2s =3D snd_soc_dai_get_drvdata(asoc_rtd_to_cpu(rtd,= 0)); + u32 period_bytes, buffer_bytes; + u32 idx_bytes; + + period_bytes =3D snd_pcm_lib_period_bytes(substream); + buffer_bytes =3D snd_pcm_lib_buffer_bytes(substream); + + if (substream->pstr->stream =3D=3D SNDRV_PCM_STREAM_CAPTURE) { + idx_bytes =3D chv3_i2s_rd(i2s, I2S_RX_PRODUCER_IDX); + } else { + idx_bytes =3D chv3_i2s_rd(i2s, I2S_TX_CONSUMER_IDX); + if (i2s->tx_ready) + idx_bytes =3D (idx_bytes - period_bytes) & (buffer_bytes - 1); + else + idx_bytes =3D 0; + } + + return bytes_to_frames(substream->runtime, idx_bytes); +} + +static int chv3_dma_ack(struct snd_soc_component *component, + struct snd_pcm_substream *substream) +{ + struct snd_pcm_runtime *runtime =3D substream->runtime; + struct snd_soc_pcm_runtime *rtd =3D asoc_substream_to_rtd(substream); + struct chv3_i2s_dev *i2s =3D snd_soc_dai_get_drvdata(asoc_rtd_to_cpu(rtd,= 0)); + unsigned int bytes, idx; + + bytes =3D frames_to_bytes(runtime, runtime->control->appl_ptr); + idx =3D bytes & (snd_pcm_lib_buffer_bytes(substream) - 1); + + if (substream->pstr->stream =3D=3D SNDRV_PCM_STREAM_CAPTURE) + chv3_i2s_wr(i2s, I2S_RX_CONSUMER_IDX, idx); + else + chv3_i2s_wr(i2s, I2S_TX_PRODUCER_IDX, idx); + + return 0; +} + +static const struct snd_soc_component_driver chv3_i2s_comp =3D { + .name =3D "chv3-i2s-comp", + .open =3D chv3_dma_open, + .close =3D chv3_dma_close, + .pcm_construct =3D chv3_dma_pcm_construct, + .hw_params =3D chv3_dma_hw_params, + .prepare =3D chv3_dma_prepare, + .pointer =3D chv3_dma_pointer, + .ack =3D chv3_dma_ack, +}; + +static int chv3_i2s_probe(struct platform_device *pdev) +{ + struct chv3_i2s_dev *i2s; + int res; + int irq; + + i2s =3D devm_kzalloc(&pdev->dev, sizeof(*i2s), GFP_KERNEL); + if (!i2s) + return -ENOMEM; + + i2s->iobase =3D devm_platform_ioremap_resource(pdev, 0); + if (IS_ERR(i2s->iobase)) + return PTR_ERR(i2s->iobase); + + i2s->iobase_irq =3D devm_platform_ioremap_resource(pdev, 1); + if (IS_ERR(i2s->iobase_irq)) + return PTR_ERR(i2s->iobase_irq); + + i2s->tx_bytes_to_fetch =3D (chv3_i2s_rd(i2s, I2S_TX_IRQ_CONST) >> 8) & 0x= ffff; + + i2s->dev =3D &pdev->dev; + dev_set_drvdata(&pdev->dev, i2s); + + irq =3D platform_get_irq(pdev, 0); + if (irq < 0) + return -ENXIO; + res =3D devm_request_irq(i2s->dev, irq, chv3_i2s_isr, 0, "chv3-i2s", i2s); + if (res) + return res; + + res =3D devm_snd_soc_register_component(&pdev->dev, &chv3_i2s_comp, + &chv3_i2s_dai, 1); + if (res) { + dev_err(&pdev->dev, "couldn't register component: %d\n", res); + return res; + } + + dev_info(&pdev->dev, "probed\n"); + + return 0; +} + +static const struct of_device_id chv3_i2s_of_match[] =3D { + { .compatible =3D "google,chv3-i2s" }, + {}, +}; + +static struct platform_driver chv3_i2s_driver =3D { + .probe =3D chv3_i2s_probe, + .driver =3D { + .name =3D "chv3-i2s", + .of_match_table =3D chv3_i2s_of_match, + }, +}; + +module_platform_driver(chv3_i2s_driver); + +MODULE_AUTHOR("Pawel Anikiel "); +MODULE_DESCRIPTION("Chameleon v3 I2S interface"); +MODULE_LICENSE("GPL"); diff --git a/sound/soc/chameleonv3/chv3-it68051.c b/sound/soc/chameleonv3/c= hv3-it68051.c new file mode 100644 index 000000000000..4813e699ec9c --- /dev/null +++ b/sound/soc/chameleonv3/chv3-it68051.c @@ -0,0 +1,41 @@ +// SPDX-License-Identifier: GPL-2.0-only +#include +#include + +static struct snd_soc_dai_driver it68051_dai =3D { + .name =3D "it68051-hifi", + .capture =3D { + .stream_name =3D "Capture", + .channels_min =3D 8, + .channels_max =3D 8, + .rates =3D SNDRV_PCM_RATE_CONTINUOUS, + .formats =3D SNDRV_PCM_FMTBIT_S32_LE, + }, +}; + +static const struct snd_soc_component_driver soc_component_dev_it68051 =3D= { +}; + +static int it68051_probe(struct platform_device *pdev) +{ + return devm_snd_soc_register_component(&pdev->dev, + &soc_component_dev_it68051, &it68051_dai, 1); +} + +static const struct of_device_id it68051_of_match[] =3D { + { .compatible =3D "ite,it68051", }, + { } +}; + +static struct platform_driver it68051_platform_driver =3D { + .driver =3D { + .name =3D "it68051", + .of_match_table =3D it68051_of_match, + }, + .probe =3D it68051_probe, +}; +module_platform_driver(it68051_platform_driver); + +MODULE_DESCRIPTION("ASoC IT68051 driver"); +MODULE_AUTHOR("Pawel Anikiel "); +MODULE_LICENSE("GPL"); --=20 2.40.0.634.g4ca3ef3211-goog From nobody Thu Dec 18 07:53:42 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E3BB7C77B6E for ; Fri, 14 Apr 2023 14:03:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230149AbjDNODY (ORCPT ); Fri, 14 Apr 2023 10:03:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52778 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229744AbjDNODV (ORCPT ); Fri, 14 Apr 2023 10:03:21 -0400 Received: from mail-lj1-x22a.google.com (mail-lj1-x22a.google.com [IPv6:2a00:1450:4864:20::22a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 124E7B772 for ; Fri, 14 Apr 2023 07:02:48 -0700 (PDT) Received: by mail-lj1-x22a.google.com with SMTP id y35so4153977ljq.6 for ; Fri, 14 Apr 2023 07:02:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=semihalf.com; s=google; t=1681480964; x=1684072964; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=WLixTRfjgENcovszATtGl8QPdC0Pd1weyqx+S/unz9w=; b=HYr1AJD9m6oRzthxD0R3069MK8VuvZvtWAoQpZlxrFyHMJ4nU/c5FyZKYeOig8uMSj uGFMmqbadrconO75X6ztpe44p+Ku6G7jL5DmcgyZ1hq12rZFhpZ6hyVtTplNqNBCzJWu XfOR18dwtShwQIar93V5opgVMYaHKJAAYppuruB8+KyzpQPzzM4N+zat0BH2h1IsLCmq UMYJwaoRl7kYzee5Fphzl71rnWPD6vbafkgCvs4E0mDq4T8ySmSLUpqwL0LRET4UdM4B z/7G1KR9DON5ir3hrOMhn9Sal2JyF3iatNVjX0jZFvvZVnEuhX3iMEH7k8m2fup6CVSj mgiQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1681480964; x=1684072964; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=WLixTRfjgENcovszATtGl8QPdC0Pd1weyqx+S/unz9w=; b=iHTBAG9Lnvk2zguShDK71ZOvMP36TiG/JWeIPQ+KssRAgMxDOYIPdNVm1GM97CROD7 bzgcS7yPMtKZ2DzQh4mD4DBWB1yIcLY4DqmSzSvZ2KxYlQv+JtUhOsTSHwlYVWAImOzU CuKd2749oyqW+UhUdJN3W0StBT+QmuaUJfLVEPe8toiqiJlyUkRA6MPNTGYcjxrH/4JP zNq3SeDDVLTdNEZ+48ysUjmwdvH1pR+QeyJD5NX/SzXGW2taEM1RJcfOvqmMPLfV2OBa gj756AeCEdmvQyStGyxGlNnKvPabbbY1BWINdOBzphj/hgwNCAxF+IllciOiGgvdpfpv QlNQ== X-Gm-Message-State: AAQBX9eqDk0ZJpX2EBuEVR6cB5ay3KEBhLRUUMGpt5hg1201G5mlM/ac 49naU+rYT0t9/Jaj3QKiD/T89g== X-Google-Smtp-Source: AKy350ZYVGEPLLxfVYu+/HWW1CWF15hmWbDiIZLuRfjxN0aQCDsV6QACgfOZTdQ+VsxwMQxddFYJ+A== X-Received: by 2002:a05:651c:d5:b0:2a7:6f60:34f2 with SMTP id 21-20020a05651c00d500b002a76f6034f2mr2103167ljr.33.1681480964321; Fri, 14 Apr 2023 07:02:44 -0700 (PDT) Received: from panikiel.roam.corp.google.com (staticline-31-182-201-26.toya.net.pl. [31.182.201.26]) by smtp.gmail.com with ESMTPSA id 15-20020a2eb2cf000000b002a76e2dedbcsm828684ljz.139.2023.04.14.07.02.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 14 Apr 2023 07:02:44 -0700 (PDT) From: =?UTF-8?q?Pawe=C5=82=20Anikiel?= To: alsa-devel@alsa-project.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, lgirdwood@gmail.com, broonie@kernel.org Cc: perex@perex.cz, tiwai@suse.com, robh+dt@kernel.org, krzysztof.kozlowski+dt@linaro.org, dinguyen@kernel.org, lars@metafoo.de, nuno.sa@analog.com, upstream@semihalf.com, =?UTF-8?q?Pawe=C5=82=20Anikiel?= Subject: [PATCH 2/9] dt-bindings: ASoC: Add chv3-i2s Date: Fri, 14 Apr 2023 16:01:56 +0200 Message-ID: <20230414140203.707729-3-pan@semihalf.com> X-Mailer: git-send-email 2.40.0.634.g4ca3ef3211-goog In-Reply-To: <20230414140203.707729-1-pan@semihalf.com> References: <20230414140203.707729-1-pan@semihalf.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Add binding for chv3-i2s device. Signed-off-by: Pawe=C5=82 Anikiel --- .../bindings/sound/google,chv3-i2s.yaml | 42 +++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 Documentation/devicetree/bindings/sound/google,chv3-i2s= .yaml diff --git a/Documentation/devicetree/bindings/sound/google,chv3-i2s.yaml b= /Documentation/devicetree/bindings/sound/google,chv3-i2s.yaml new file mode 100644 index 000000000000..6f49cf059ac5 --- /dev/null +++ b/Documentation/devicetree/bindings/sound/google,chv3-i2s.yaml @@ -0,0 +1,42 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/sound/google,chv3-i2s.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Google Chameleon v3 I2S device + +maintainers: + - Pawe=C5=82 Anikiel + +description: | + I2S device for the Google Chameleon v3. The device handles both RX + and TX using a producer/consumer ring buffer design. + +properties: + compatible: + const: google,chv3-i2s + reg: + items: + - description: core registers + - description: irq registers + interrupts: + maxItems: 1 + +required: + - compatible + - reg + - interrupts + +additionalProperties: false + +examples: + - | + #include + + i2s0: i2s@c0060300 { + compatible =3D "google,chv3-i2s"; + reg =3D <0xc0060300 0x100>, + <0xc0060f00 0x10>; + interrupts =3D <0 20 IRQ_TYPE_LEVEL_HIGH>; + }; --=20 2.40.0.634.g4ca3ef3211-goog From nobody Thu Dec 18 07:53:42 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 16D5CC77B76 for ; Fri, 14 Apr 2023 14:03:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230175AbjDNODe (ORCPT ); Fri, 14 Apr 2023 10:03:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53162 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230156AbjDNODc (ORCPT ); Fri, 14 Apr 2023 10:03:32 -0400 Received: from mail-lj1-x236.google.com (mail-lj1-x236.google.com [IPv6:2a00:1450:4864:20::236]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B8441A24D for ; Fri, 14 Apr 2023 07:02:59 -0700 (PDT) Received: by mail-lj1-x236.google.com with SMTP id r9so5220766ljp.9 for ; Fri, 14 Apr 2023 07:02:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=semihalf.com; s=google; t=1681480966; x=1684072966; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=pAsx/vtlSONsGJaMiUuvZrWP17NNhM0s9aopfUG3YMs=; b=Qi8J8nvWCtFhQJhd2UX1NuWmfKbSuxCdjqjnDbhKFiBYPv3xo/hUC6Do2yDnUCewAT tl4VOteQPr1vA9ehtzJx9//7fZlv2nySr+BsyVTmcwpIEX1nKSDMlvaAlyUlYHXNsEpx gRf0Q7SM1nyAeFaDsOuPiresr4FTfzZwyOvBn6qzJEFghHmpmtp+Uap2CZHpoeicqPFC TlO8OVPwTjnp/FJTOYL+dZPoyeFIcpk/Gn0o5iSNzBJScOAyrh8sVcPPbEZrjuWTThOR QJ0AsZSe1L+lXynCjQG2TIcE/AElygHP+mila0NJdBrRzO7TCSkxv+fOFSljBz39gnOD M3xw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1681480966; x=1684072966; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=pAsx/vtlSONsGJaMiUuvZrWP17NNhM0s9aopfUG3YMs=; b=C/FMo0u6q1OWPiCelLU+nrnapW1L3JEAzqkr2raohmRjPh8hquL3BN0GriX3XJ6TyW u8SWAHmmr9D15Rn7TNRUkQFqm3fOWQZKxqV1OmVxNLXQlGeyuiRT1DuPc+gSzMKqavCa //hFyeTRJ5VxZfZDHIs9zYMeJ9X3cwaYTckb32Ht5nn6nin+hp7t1/raCeq7drTjmmZh j9DXMmhQL25cBkd6iuQpQOP9VFvBZLC9oWdyjIFtX6JXgzrKH6g61JyZVzs/0raOa2mJ gA7iyL9pZ8bGGfFMuajWkOXF4tzW8EWvDE/NIVTlWDdTg93+vokfesjYTmdAL7Y53uSb wriw== X-Gm-Message-State: AAQBX9esu1tZAP7+EJfEQB+2V6yggXHKLT9l/LgXFADZqtvC1i001Ew5 mphxUaLR1Jy75f/7hLoWPyYXlT4SM3dOg1fDLCv73Q== X-Google-Smtp-Source: AKy350Z+QDZGlS7XF9A1X0316HTp53Mi+Jrm8uEaFMhPQvNowT32YfQLUfNynbysrYJBu0ehToQ6JA== X-Received: by 2002:a2e:9d84:0:b0:295:d7a8:559b with SMTP id c4-20020a2e9d84000000b00295d7a8559bmr1714528ljj.10.1681480965408; Fri, 14 Apr 2023 07:02:45 -0700 (PDT) Received: from panikiel.roam.corp.google.com (staticline-31-182-201-26.toya.net.pl. [31.182.201.26]) by smtp.gmail.com with ESMTPSA id 15-20020a2eb2cf000000b002a76e2dedbcsm828684ljz.139.2023.04.14.07.02.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 14 Apr 2023 07:02:45 -0700 (PDT) From: =?UTF-8?q?Pawe=C5=82=20Anikiel?= To: alsa-devel@alsa-project.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, lgirdwood@gmail.com, broonie@kernel.org Cc: perex@perex.cz, tiwai@suse.com, robh+dt@kernel.org, krzysztof.kozlowski+dt@linaro.org, dinguyen@kernel.org, lars@metafoo.de, nuno.sa@analog.com, upstream@semihalf.com, =?UTF-8?q?Pawe=C5=82=20Anikiel?= Subject: [PATCH 3/9] dt-bindings: ASoC: Add chv3-audio Date: Fri, 14 Apr 2023 16:01:57 +0200 Message-ID: <20230414140203.707729-4-pan@semihalf.com> X-Mailer: git-send-email 2.40.0.634.g4ca3ef3211-goog In-Reply-To: <20230414140203.707729-1-pan@semihalf.com> References: <20230414140203.707729-1-pan@semihalf.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Add binding for chv3-audio device. Signed-off-by: Pawe=C5=82 Anikiel --- .../bindings/sound/google,chv3-audio.yaml | 49 +++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 Documentation/devicetree/bindings/sound/google,chv3-aud= io.yaml diff --git a/Documentation/devicetree/bindings/sound/google,chv3-audio.yaml= b/Documentation/devicetree/bindings/sound/google,chv3-audio.yaml new file mode 100644 index 000000000000..8b602b60eaee --- /dev/null +++ b/Documentation/devicetree/bindings/sound/google,chv3-audio.yaml @@ -0,0 +1,49 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/sound/google,chv3-audio.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Google Chameleon v3 audio + +maintainers: + - Pawe=C5=82 Anikiel + +properties: + compatible: + const: google,chv3-audio + + google,audio-cpu0: + $ref: /schemas/types.yaml#/definitions/phandle + description: The phandle of controller #0 + + google,audio-codec0: + $ref: /schemas/types.yaml#/definitions/phandle + description: The phandle of codec #0 + + google,audio-cpu1: + $ref: /schemas/types.yaml#/definitions/phandle + description: The phandle of controller #1 + + google,audio-codec1: + $ref: /schemas/types.yaml#/definitions/phandle + description: The phandle of codec #1 + +required: + - compatible + - google,audio-cpu0: + - google,audio-codec0: + - google,audio-cpu1: + - google,audio-codec1: + +additionalProperties: false + +examples: + - | + sound { + compatible =3D "google,chv3-audio"; + google,audio-cpu0 =3D <&i2s1>; + google,audio-codec0 =3D <&ssm2603>; + google,audio-cpu1 =3D <&i2s0>; + google,audio-codec1 =3D <&it68051>; + }; --=20 2.40.0.634.g4ca3ef3211-goog From nobody Thu Dec 18 07:53:42 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id BFEDFC77B72 for ; Fri, 14 Apr 2023 14:03:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230128AbjDNODk (ORCPT ); Fri, 14 Apr 2023 10:03:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53178 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230151AbjDNODe (ORCPT ); Fri, 14 Apr 2023 10:03:34 -0400 Received: from mail-lf1-x12f.google.com (mail-lf1-x12f.google.com [IPv6:2a00:1450:4864:20::12f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3AF0FA5FF for ; Fri, 14 Apr 2023 07:03:00 -0700 (PDT) Received: by mail-lf1-x12f.google.com with SMTP id bi41so5400276lfb.7 for ; Fri, 14 Apr 2023 07:03:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=semihalf.com; s=google; t=1681480967; x=1684072967; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=L6n77Uz+PsEL5Zjj7L5BoLRIOYIh+FfJEj7GLcVMFvg=; b=to1vKMIM1WC0fNpuIs5zm3Xd24aEi6aKDV9OLiqX3WkQ186p1OuycU1BZvA94dDYsT r09kVB9ndrgzrg5+P/PlIVIj6pggSuDLvitGJaAe+apJV9pcgVmTgO5MbPN5TvD/C6IL 0EtgNlqLzaUciDl3qcozHuoFcBoCWUVp+BLw+RrVuKI8qRirPnozw5rxTutWT69uV17+ kN29a9NOcNSqMukp4uOHgo0o0MbaVDiICQZpYsoHoF+uMeXyqgAMD1r/CBKX7CUpimbT 1r/morRdVUAFqIRIASuMeGpTdR3NjQC7ZlYp/eI2C4He8BfW4P+1LR9KmoDtUFbzgXAQ vCeQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1681480967; x=1684072967; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=L6n77Uz+PsEL5Zjj7L5BoLRIOYIh+FfJEj7GLcVMFvg=; b=e7A8o5kRj72xvITgvgYeduLZbqc/1HHamdkT2g0s0NYEMfYB21xqwMgT7/ihfZoOQK c26qQV03f6tN9DOnDRXH88vu6UAXc6uZBIHhX4NyXBZDwAaMIbM8rIg5Pefdndn1Fg4a 9B20Msrko9RWNMcJEifGowTBCeim5tp4zKH5br1VRBMKTjzQ45Z3zRcCp/Hr50MuN4UJ ZwmeMA5JKn30BI5Ci1VCAAo6ZQfwtJWaFRB6TUrFTJcfThAZRerDaCsU5mvGt4EOcvbN 6rzLI3GhZK2q052g1IVUzkwCnkWJTpG1GFl79Ln28r0XTPkDkC6f901gMi5yA6Rk90BF kJ1A== X-Gm-Message-State: AAQBX9ceCcrOEdszqZerx1GjC+yhuK/8yk2Lx58kwSUzs7Kg+mhKvjqc n23lIdIgyebzpacvWFZg3z/E1w== X-Google-Smtp-Source: AKy350ZSXgVjOCNXI2VQYGW1Lkq/T4J5v7tUI1rYH+arf0uiLVP1zRg1drMxe3NixehsPq/kIrQ5fw== X-Received: by 2002:a05:6512:4012:b0:4eb:2b62:134f with SMTP id br18-20020a056512401200b004eb2b62134fmr2780018lfb.16.1681480966909; Fri, 14 Apr 2023 07:02:46 -0700 (PDT) Received: from panikiel.roam.corp.google.com (staticline-31-182-201-26.toya.net.pl. [31.182.201.26]) by smtp.gmail.com with ESMTPSA id 15-20020a2eb2cf000000b002a76e2dedbcsm828684ljz.139.2023.04.14.07.02.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 14 Apr 2023 07:02:46 -0700 (PDT) From: =?UTF-8?q?Pawe=C5=82=20Anikiel?= To: alsa-devel@alsa-project.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, lgirdwood@gmail.com, broonie@kernel.org Cc: perex@perex.cz, tiwai@suse.com, robh+dt@kernel.org, krzysztof.kozlowski+dt@linaro.org, dinguyen@kernel.org, lars@metafoo.de, nuno.sa@analog.com, upstream@semihalf.com, =?UTF-8?q?Pawe=C5=82=20Anikiel?= Subject: [PATCH 4/9] dt-bindings: ASoC: Add it68051 Date: Fri, 14 Apr 2023 16:01:58 +0200 Message-ID: <20230414140203.707729-5-pan@semihalf.com> X-Mailer: git-send-email 2.40.0.634.g4ca3ef3211-goog In-Reply-To: <20230414140203.707729-1-pan@semihalf.com> References: <20230414140203.707729-1-pan@semihalf.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Add binding for it68051 device. Signed-off-by: Pawe=C5=82 Anikiel --- .../bindings/sound/ite,it68051.yaml | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 Documentation/devicetree/bindings/sound/ite,it68051.yaml diff --git a/Documentation/devicetree/bindings/sound/ite,it68051.yaml b/Doc= umentation/devicetree/bindings/sound/ite,it68051.yaml new file mode 100644 index 000000000000..341c171b8a8a --- /dev/null +++ b/Documentation/devicetree/bindings/sound/ite,it68051.yaml @@ -0,0 +1,23 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/sound/ite,it68051.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: it68051 audio codec + +maintainers: + - Pawe=C5=82 Anikiel + +properties: + compatible: + const: ite,it68051 + +required: + - compatible + +examples: + - | + it68051: audio-codec { + compatible =3D "ite,it68051"; + }; --=20 2.40.0.634.g4ca3ef3211-goog From nobody Thu Dec 18 07:53:42 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id BD92BC77B6E for ; Fri, 14 Apr 2023 14:03:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230236AbjDNODo (ORCPT ); Fri, 14 Apr 2023 10:03:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53176 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230161AbjDNODe (ORCPT ); Fri, 14 Apr 2023 10:03:34 -0400 Received: from mail-lj1-x22e.google.com (mail-lj1-x22e.google.com [IPv6:2a00:1450:4864:20::22e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 731FBA5DE for ; Fri, 14 Apr 2023 07:03:01 -0700 (PDT) Received: by mail-lj1-x22e.google.com with SMTP id e8so783468ljn.2 for ; Fri, 14 Apr 2023 07:03:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=semihalf.com; s=google; t=1681480969; x=1684072969; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=3BhiBeghWpmkkfmklnaJ7LFrAZ1yIM3t/W3PcrsTKic=; b=ZIvH3A0hDweRAj48aerjGTpcA9Lg0NU1e7NMCLoS5TAsG28rGY5S7MJJ7LbPV4gE60 W3yYf12rm7y/sW/HEklbkSOvWJmDZWZQwiNpOVw7yVUoaxeeA7zFBZZ2zB5PR2zDlVC1 Jzxwbywa7p9UNHh/9090nxIM5BcN7qcekxA/XokHqil/W1PBhRURVtoj6oU2VBK+otcw kw8969oMp59kuqP0RWc9XYTRRZzccaxfh74IrcxN4FN1C60ATu7fDzedKERcZi8/WvrA RwNOJP8JIaYO06sGP69Q2Ktqq3xpmsNOvXg03BYydaElGUOPwCRTFZOiF2qBZlKogThI ebPA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1681480969; x=1684072969; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=3BhiBeghWpmkkfmklnaJ7LFrAZ1yIM3t/W3PcrsTKic=; b=KUIWoRX/26/n0wCO+I12dA01Q3pXh3GC+BWEwdZ58EU8auNZ7ED9ZSRxLRqmxNG8MU R25V8e3S+XfdllK6c9EL+PU/Q7A7+YS6/scrOyeoSONmrrdPl+UsuNk2L0Nrw9J72gWK 1KOcgGrHPwtN4mMkFkNL61WQndS7XYt1VRruulEkobGED9lWC6Xn2Uwdyh/PcIt8FUVb OazTV5ue7j51ih3JGwQGSL78BhLCQsNQT50yqd+bxgjD/JiIswoe37QQeyDez3Z5HVLn WZNQuzVk6OxbC+2WCza9sN0yIY2FhO7e3EV7dn+s7MdDGX0HyuE02QYzzIS/UDW3hMPl Rdpg== X-Gm-Message-State: AAQBX9clQlZ6B6bKbcEhoDQ4/Rjx3IRHhpPvh+ShtYwnCP+OpkxcgVfy QA7UajeeFL5tt9m72cthK/b7Sg== X-Google-Smtp-Source: AKy350aAUvPCStAOQkhJe5KNXKrPlT0yHPb0kYSRktYXq6/BaxKviwWfDLqFxScPxtJeHZ5xGmQ/WQ== X-Received: by 2002:a2e:804b:0:b0:295:9906:64e4 with SMTP id p11-20020a2e804b000000b00295990664e4mr1768345ljg.2.1681480968304; Fri, 14 Apr 2023 07:02:48 -0700 (PDT) Received: from panikiel.roam.corp.google.com (staticline-31-182-201-26.toya.net.pl. [31.182.201.26]) by smtp.gmail.com with ESMTPSA id 15-20020a2eb2cf000000b002a76e2dedbcsm828684ljz.139.2023.04.14.07.02.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 14 Apr 2023 07:02:47 -0700 (PDT) From: =?UTF-8?q?Pawe=C5=82=20Anikiel?= To: alsa-devel@alsa-project.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, lgirdwood@gmail.com, broonie@kernel.org Cc: perex@perex.cz, tiwai@suse.com, robh+dt@kernel.org, krzysztof.kozlowski+dt@linaro.org, dinguyen@kernel.org, lars@metafoo.de, nuno.sa@analog.com, upstream@semihalf.com, =?UTF-8?q?Pawe=C5=82=20Anikiel?= Subject: [PATCH 5/9] ASoC: ssm2602: Add workaround for playback with external MCLK Date: Fri, 14 Apr 2023 16:01:59 +0200 Message-ID: <20230414140203.707729-6-pan@semihalf.com> X-Mailer: git-send-email 2.40.0.634.g4ca3ef3211-goog In-Reply-To: <20230414140203.707729-1-pan@semihalf.com> References: <20230414140203.707729-1-pan@semihalf.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Apply a workaround for what seems to be a hardware quirk: when using an external MCLK signal, powering on Output and DAC for the first time produces output distortions unless they're powered together with whole chip power. The workaround powers them on in probe for the first time, as doing it later may be impossible (e.g. when starting playback while recording, whole chip power will already be on). Here are some initialization sequences run after all other control registers were set (`ssmset reg val` sets the value of a register via i2c): ssmset 0x09 0x01 # core ssmset 0x06 0x07 # chip, out OK ssmset 0x09 0x01 # core ssmset 0x06 0x87 # out, dac ssmset 0x06 0x07 # chip OK (disable MCLK) ssmset 0x09 0x01 # core ssmset 0x06 0x1f # chip ssmset 0x06 0x07 # out, dac (enable MCLK) OK ssmset 0x09 0x01 # core ssmset 0x06 0x1f # chip ssmset 0x06 0x07 # out, dac NOT OK ssmset 0x06 0x1f # chip ssmset 0x09 0x01 # core ssmset 0x06 0x07 # out, dac NOT OK ssmset 0x09 0x01 # core ssmset 0x06 0x0f # chip, out ssmset 0x06 0x07 # dac NOT OK ssmset 0x09 0x01 # core ssmset 0x06 0x17 # chip, dac ssmset 0x06 0x07 # out NOT OK Here are some sequences run at the very start before a sw reset (and later using one of the NOT OK sequences from above): ssmset 0x09 0x01 # core ssmset 0x06 0x07 # chip, out, dac OK (disable MCLK) ssmset 0x09 0x01 # core ssmset 0x06 0x07 # chip, out, dac (enable MCLK after reset) NOT OK ssmset 0x09 0x01 # core ssmset 0x06 0x17 # chip, dac NOT OK ssmset 0x09 0x01 # core ssmset 0x06 0x0f # chip, out NOT OK ssmset 0x06 0x07 # chip, out, dac NOT OK This was tested on a Google Chameleon v3 board using an SSM2603 with an external MCLK. This doesn't seem to just be a PCB issue, as this was also observed on a ZYBO Z7-10: https://ez.analog.com/audio/f/q-a/543726/solved-ssm2603-right-output-offset= -issue/480229 Signed-off-by: Pawe=C5=82 Anikiel --- sound/soc/codecs/ssm2602.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/sound/soc/codecs/ssm2602.c b/sound/soc/codecs/ssm2602.c index cbbe83b85ada..021e0c860fa1 100644 --- a/sound/soc/codecs/ssm2602.c +++ b/sound/soc/codecs/ssm2602.c @@ -589,6 +589,17 @@ static int ssm260x_component_probe(struct snd_soc_comp= onent *component) return ret; } =20 + /* Workaround for what seems to be a hardware quirk: when using an + * external MCLK signal, powering on Output and DAC for the first + * time produces output distortions unless they're powered together + * with whole chip power. We power them here for the first time, + * as doing it later may be impossible (e.g. when starting playback + * while recording, whole chip power will already be on) + */ + regmap_write(ssm2602->regmap, SSM2602_ACTIVE, 0x01); + regmap_write(ssm2602->regmap, SSM2602_PWR, 0x07); + regmap_write(ssm2602->regmap, SSM2602_RESET, 0x00); + /* set the update bits */ regmap_update_bits(ssm2602->regmap, SSM2602_LINVOL, LINVOL_LRIN_BOTH, LINVOL_LRIN_BOTH); --=20 2.40.0.634.g4ca3ef3211-goog From nobody Thu Dec 18 07:53:42 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id EC925C77B6E for ; Fri, 14 Apr 2023 14:03:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230243AbjDNODr (ORCPT ); Fri, 14 Apr 2023 10:03:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53150 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230156AbjDNODf (ORCPT ); Fri, 14 Apr 2023 10:03:35 -0400 Received: from mail-lj1-x230.google.com (mail-lj1-x230.google.com [IPv6:2a00:1450:4864:20::230]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5981EAD36 for ; Fri, 14 Apr 2023 07:03:02 -0700 (PDT) Received: by mail-lj1-x230.google.com with SMTP id bx15so17066511ljb.7 for ; Fri, 14 Apr 2023 07:03:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=semihalf.com; s=google; t=1681480970; x=1684072970; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=b/pTs4z9rhsBzBw4ml9qs5JBHN4WLKpluPzA9XU/6Jk=; b=OXpk08I1AC9etobtye7i60c27lC4lj7/SZW9B5ttLpNUFKqf0S6rQ6xjLnu0O6h2DD rSG1RCCO6BeNy6NOLso/6J68yWcbnJ4MCO0bFEEK07LPLj66vlhIql0CIAKOAdAb9GMf /mNuvuM+bh5rghs6+bfmEU/hQmU6MFLUkIopX7dNWDZ6k3DniD+TkQlzdYDFlPRKdMRM VVi4SQyrVEx3XqVLJdWk9o2XfkRdnTfEoxMRjBRchUg5BfUo55RQiZHWx9feBm8xe4C1 rbpklvVxxNTe6IeiPG1crcrDS90TCgdjp2ZjVW3NeU8bR+s7SwN0MdYEJuGEgYZNRO7B LujQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1681480970; x=1684072970; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=b/pTs4z9rhsBzBw4ml9qs5JBHN4WLKpluPzA9XU/6Jk=; b=g4Uy6qQP0pdfKQ/I0/zags5oMREYKnOgNXwmWewjqsswWNvQId6ql74mmTiJ/jqhc3 CGuU5HRWtCaYGK4qUHZvQog7lGWr60qnKrqYm7EapkRyz/cux9B9zbzQ2TvgwQESQy7g nmsw2IG3zAc9q5Wy+UuX74+5KZBLSiC7xVMPylv+NUNBGPqLukieNhwQM8Bue6TodhAR UIEda2bKRe3kYRi5ZmfshAoSfkHljtcVEUwf5wD637HIVqAOeer/s1trdxR5POfgkCjc HGkpRWXqz60AZqeVi5m4Ewkn0OxKUYU5K1cd9FIV62eBkFrFfkm/IclKMPFnCyF3P6tZ lSvA== X-Gm-Message-State: AAQBX9carFQscbVqFD7HesQDEC+71Ao9uHrcw3tRhbjtYtqIQYIDeNUN +HCdiSOFIReGTySV4uuzxGHWXg== X-Google-Smtp-Source: AKy350a2jetYlrjNvabc9jILg3C4DgASyuZ+RZVm6baefXeSjrRJTfnzHFRX467sNw55w+dKiuBNqg== X-Received: by 2002:a2e:978a:0:b0:2a8:ad32:3d59 with SMTP id y10-20020a2e978a000000b002a8ad323d59mr770788lji.9.1681480970216; Fri, 14 Apr 2023 07:02:50 -0700 (PDT) Received: from panikiel.roam.corp.google.com (staticline-31-182-201-26.toya.net.pl. [31.182.201.26]) by smtp.gmail.com with ESMTPSA id 15-20020a2eb2cf000000b002a76e2dedbcsm828684ljz.139.2023.04.14.07.02.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 14 Apr 2023 07:02:49 -0700 (PDT) From: =?UTF-8?q?Pawe=C5=82=20Anikiel?= To: alsa-devel@alsa-project.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, lgirdwood@gmail.com, broonie@kernel.org Cc: perex@perex.cz, tiwai@suse.com, robh+dt@kernel.org, krzysztof.kozlowski+dt@linaro.org, dinguyen@kernel.org, lars@metafoo.de, nuno.sa@analog.com, upstream@semihalf.com, =?UTF-8?q?Pawe=C5=82=20Anikiel?= Subject: [PATCH 6/9] ASoC: ssm2602: Add support for CLKDIV2 Date: Fri, 14 Apr 2023 16:02:00 +0200 Message-ID: <20230414140203.707729-7-pan@semihalf.com> X-Mailer: git-send-email 2.40.0.634.g4ca3ef3211-goog In-Reply-To: <20230414140203.707729-1-pan@semihalf.com> References: <20230414140203.707729-1-pan@semihalf.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The SSM260x chips have an internal MCLK /2 divider (bit D7 in register R8). Add logic that allows for more MCLK values using this divider. Signed-off-by: Pawe=C5=82 Anikiel --- sound/soc/codecs/ssm2602.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/sound/soc/codecs/ssm2602.c b/sound/soc/codecs/ssm2602.c index 021e0c860fa1..35c4743e756e 100644 --- a/sound/soc/codecs/ssm2602.c +++ b/sound/soc/codecs/ssm2602.c @@ -280,9 +280,12 @@ static inline int ssm2602_get_coeff(int mclk, int rate) int i; =20 for (i =3D 0; i < ARRAY_SIZE(ssm2602_coeff_table); i++) { - if (ssm2602_coeff_table[i].rate =3D=3D rate && - ssm2602_coeff_table[i].mclk =3D=3D mclk) - return ssm2602_coeff_table[i].srate; + if (ssm2602_coeff_table[i].rate =3D=3D rate) { + if (ssm2602_coeff_table[i].mclk =3D=3D mclk) + return ssm2602_coeff_table[i].srate; + if (ssm2602_coeff_table[i].mclk =3D=3D mclk / 2) + return ssm2602_coeff_table[i].srate | SRATE_CORECLK_DIV2; + } } return -EINVAL; } @@ -365,18 +368,24 @@ static int ssm2602_set_dai_sysclk(struct snd_soc_dai = *codec_dai, switch (freq) { case 12288000: case 18432000: + case 24576000: + case 36864000: ssm2602->sysclk_constraints =3D &ssm2602_constraints_12288000; break; case 11289600: case 16934400: + case 22579200: + case 33868800: ssm2602->sysclk_constraints =3D &ssm2602_constraints_11289600; break; case 12000000: + case 24000000: ssm2602->sysclk_constraints =3D NULL; break; default: return -EINVAL; } + ssm2602->sysclk =3D freq; } else { unsigned int mask; --=20 2.40.0.634.g4ca3ef3211-goog From nobody Thu Dec 18 07:53:42 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0F15DC77B6E for ; Fri, 14 Apr 2023 14:03:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230287AbjDNODx (ORCPT ); Fri, 14 Apr 2023 10:03:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53382 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230231AbjDNODn (ORCPT ); Fri, 14 Apr 2023 10:03:43 -0400 Received: from mail-lj1-x232.google.com (mail-lj1-x232.google.com [IPv6:2a00:1450:4864:20::232]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9C42C211F for ; Fri, 14 Apr 2023 07:03:03 -0700 (PDT) Received: by mail-lj1-x232.google.com with SMTP id n22so17290597ljq.8 for ; Fri, 14 Apr 2023 07:03:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=semihalf.com; s=google; t=1681480971; x=1684072971; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=l00HAAnjKLxvI4M71LWAa1g6hA4VFu1YZpxf8JORAUs=; b=JzlusrDNdzUZCKHh7U6SmI+KlP/mVczAn9Xb3MZfbiz5r8m1L0lqAf9Z0JgZD3Tqxx X/DTdKdcVdFoEc02n65cBpez+thdu+oE08qMKBCO03cEzFiculVhVRZbG5DLG4CFH5bk EuymseLwwLz74StstE7lynJG+54dZLY4rdi+sSD39UBUKIAUmFkdUUPAgn0+lE7xe9xI aXGxbRy0yeAy20z1zjWdIESJpZ63qTDpzC6yhXnOVrFJUvqPVIkSeblw+Zm3H288fGw7 1AGJlriLqc33CclcKMinnVNJN0MwG6Pgb1IsmYYrXUCl7cZ0DdbTtOPnhdownoKzOkWs bywg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1681480971; x=1684072971; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=l00HAAnjKLxvI4M71LWAa1g6hA4VFu1YZpxf8JORAUs=; b=Th1L7dvCDgZ/g7/ffOCBEwCFE31ln1YYW9LQWi1Uk0Lr7SZYr1skxPBrus+J5ZRuPR SYXhtbZDCopIGCYCg125tF/E/x30ro1D1iBxQh3pEkgAXMXwjYLftkkAcOsxfbeXcrW/ DThRIoB0M6XM6sGz+Vx5MKXzzVT/Qg6fwsbxwX9nU07TeDNabnelFEUt7I9Qi+Tj0vua 1nJowcj+XaDhel55DYEughiYaE76rpmSZAcbkLY1EOPaGnzPfWe5ebafU1Gp8QzgmFqX +xkxjTr/3f4GkdNEA8ahSITFg8+E7A5KYUPCDhthudZRNnwwD96E6nAvEuoHxxe2nSCv AhMQ== X-Gm-Message-State: AAQBX9eSWQMNQ8vr9qTSczge9w+MI+koeKHVt58emKuJfPgCr8DY2a+p 6HU0jfCyayZwUl1+yNJxZ1kr8A== X-Google-Smtp-Source: AKy350ZxhF8jz5Saa4u19lC/KyENjhrRMahkQQL0VeYcZWqgqY9MaL+3miI6fzj/xv1zhuIzYZZSRw== X-Received: by 2002:a2e:99d2:0:b0:2a7:ace8:e0ba with SMTP id l18-20020a2e99d2000000b002a7ace8e0bamr2212415ljj.42.1681480971325; Fri, 14 Apr 2023 07:02:51 -0700 (PDT) Received: from panikiel.roam.corp.google.com (staticline-31-182-201-26.toya.net.pl. [31.182.201.26]) by smtp.gmail.com with ESMTPSA id 15-20020a2eb2cf000000b002a76e2dedbcsm828684ljz.139.2023.04.14.07.02.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 14 Apr 2023 07:02:51 -0700 (PDT) From: =?UTF-8?q?Pawe=C5=82=20Anikiel?= To: alsa-devel@alsa-project.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, lgirdwood@gmail.com, broonie@kernel.org Cc: perex@perex.cz, tiwai@suse.com, robh+dt@kernel.org, krzysztof.kozlowski+dt@linaro.org, dinguyen@kernel.org, lars@metafoo.de, nuno.sa@analog.com, upstream@semihalf.com, =?UTF-8?q?Pawe=C5=82=20Anikiel?= Subject: [PATCH 7/9] ASoC: ssm2602: Add mute gpio Date: Fri, 14 Apr 2023 16:02:01 +0200 Message-ID: <20230414140203.707729-8-pan@semihalf.com> X-Mailer: git-send-email 2.40.0.634.g4ca3ef3211-goog In-Reply-To: <20230414140203.707729-1-pan@semihalf.com> References: <20230414140203.707729-1-pan@semihalf.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The SSM2603 has a hardware mute pin. Add an optional mute gpio to control it. Signed-off-by: Pawe=C5=82 Anikiel --- sound/soc/codecs/ssm2602.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/sound/soc/codecs/ssm2602.c b/sound/soc/codecs/ssm2602.c index 35c4743e756e..dd81e62d7a3b 100644 --- a/sound/soc/codecs/ssm2602.c +++ b/sound/soc/codecs/ssm2602.c @@ -14,6 +14,7 @@ #include #include #include +#include #include =20 #include @@ -32,6 +33,8 @@ struct ssm2602_priv { =20 enum ssm2602_type type; unsigned int clk_out_pwr; + + struct gpio_desc *mute_gpiod; }; =20 /* @@ -352,6 +355,10 @@ static int ssm2602_mute(struct snd_soc_dai *dai, int m= ute, int direction) else regmap_update_bits(ssm2602->regmap, SSM2602_APDIGI, APDIGI_ENABLE_DAC_MUTE, 0); + + if (ssm2602->mute_gpiod) + gpiod_set_value_cansleep(ssm2602->mute_gpiod, mute); + return 0; } =20 @@ -680,6 +687,10 @@ int ssm2602_probe(struct device *dev, enum ssm2602_typ= e type, ssm2602->type =3D type; ssm2602->regmap =3D regmap; =20 + ssm2602->mute_gpiod =3D devm_gpiod_get_optional(dev, "mute", GPIOD_OUT_LO= W); + if (IS_ERR(ssm2602->mute_gpiod)) + return PTR_ERR(ssm2602->mute_gpiod); + return devm_snd_soc_register_component(dev, &soc_component_dev_ssm2602, &ssm2602_dai, 1); } --=20 2.40.0.634.g4ca3ef3211-goog From nobody Thu Dec 18 07:53:42 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 77031C77B6E for ; Fri, 14 Apr 2023 14:03:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230224AbjDNODv (ORCPT ); Fri, 14 Apr 2023 10:03:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53374 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230223AbjDNODn (ORCPT ); Fri, 14 Apr 2023 10:03:43 -0400 Received: from mail-lj1-x22a.google.com (mail-lj1-x22a.google.com [IPv6:2a00:1450:4864:20::22a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7BBD7A5E6 for ; Fri, 14 Apr 2023 07:03:04 -0700 (PDT) Received: by mail-lj1-x22a.google.com with SMTP id z38so2823488ljq.12 for ; Fri, 14 Apr 2023 07:03:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=semihalf.com; s=google; t=1681480973; x=1684072973; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=76axTl8cbJUBy7OLAwyWyTtD7GTYfsTJiThiXMDIx3s=; b=SB1cVRyWZbrKZUFHSptgTkU1gCg6LU7UXA+761173EAj6Vq0hW3AwJe9c1WFRia95a y0/8K8hQMEDHSv7dvOdub+XGJE4Og/J8gc3u+1c4ZCYsBgtuq6vbexJ53O3gINqltJev CA5R5tLb85MQ+wtym2dYzB10QlkOI++8ifVF6o5z0LOG70v8JVdgoLFO+SVSGLZkONoi GMFrh22TWgY0MJFeT5YRpgnePigt/z8Lxd+XVKVpwXSHUDDJICe9h2ZWnh5aqTiLRB26 LzfR+GRmY+4c9Vh3opEtGsC5KlBNPtKojYkByTTCIgb+mc3gn/NtI9g5zL/s0D8yZ8hy E+9w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1681480973; x=1684072973; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=76axTl8cbJUBy7OLAwyWyTtD7GTYfsTJiThiXMDIx3s=; b=HBi6j9hs6aTbwkabNtTGIgkH8fcv25w46ASsM8KNzT4bGy/GCIzLLtIPCWpjGX7J8U w/bw4pBcq+pxJBhrVS/pbJNYvpvmLPZh+szc0At5U0kcKPHM8WNhFfDo+WaaxDI/4Tft NZWeO+SKdK7TgLvV5GohNScqZHMtIqvxC0a8K/EPGv+yjHSSpBa8xYNxv6aJL87Ay92X NpQttNOIWyARDSRHW2aHVLcOOAo3r0zxTtAs7D1fXZcgAILkm/3pWI5vDH42KRAbmS2K vtGChZq0aXgx9jg5Jxh1Aes6HB7kLuR8Y1g4UGvSiGXh2BNqucYDgrlJKP90PmeybQ0t TTng== X-Gm-Message-State: AAQBX9d4/v0Pgitp2eBSNJJ993MzY1Kwlwq+7XkIiqYtFb23shEOLHwR BXlaJW9kLt9wmqmUKFUtXKmWGA== X-Google-Smtp-Source: AKy350ZzWs16uKXN2YB3yLTeEJy4YSzcbJzgsMuyu+FmMB5GC0CIO/mMbAp72GN1rsJ9oQhuSxCppg== X-Received: by 2002:a2e:9b49:0:b0:2a8:ae90:83d6 with SMTP id o9-20020a2e9b49000000b002a8ae9083d6mr584641ljj.48.1681480972484; Fri, 14 Apr 2023 07:02:52 -0700 (PDT) Received: from panikiel.roam.corp.google.com (staticline-31-182-201-26.toya.net.pl. [31.182.201.26]) by smtp.gmail.com with ESMTPSA id 15-20020a2eb2cf000000b002a76e2dedbcsm828684ljz.139.2023.04.14.07.02.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 14 Apr 2023 07:02:52 -0700 (PDT) From: =?UTF-8?q?Pawe=C5=82=20Anikiel?= To: alsa-devel@alsa-project.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, lgirdwood@gmail.com, broonie@kernel.org Cc: perex@perex.cz, tiwai@suse.com, robh+dt@kernel.org, krzysztof.kozlowski+dt@linaro.org, dinguyen@kernel.org, lars@metafoo.de, nuno.sa@analog.com, upstream@semihalf.com, =?UTF-8?q?Pawe=C5=82=20Anikiel?= Subject: [PATCH 8/9] dt-bindings: ASoC: Add mute-gpio to ssm2602 Date: Fri, 14 Apr 2023 16:02:02 +0200 Message-ID: <20230414140203.707729-9-pan@semihalf.com> X-Mailer: git-send-email 2.40.0.634.g4ca3ef3211-goog In-Reply-To: <20230414140203.707729-1-pan@semihalf.com> References: <20230414140203.707729-1-pan@semihalf.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Add mute-gpio to ssm2602 Signed-off-by: Pawe=C5=82 Anikiel --- Documentation/devicetree/bindings/sound/adi,ssm2602.txt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Documentation/devicetree/bindings/sound/adi,ssm2602.txt b/Docu= mentation/devicetree/bindings/sound/adi,ssm2602.txt index 3b3302fe399b..132aa9668e7e 100644 --- a/Documentation/devicetree/bindings/sound/adi,ssm2602.txt +++ b/Documentation/devicetree/bindings/sound/adi,ssm2602.txt @@ -11,6 +11,10 @@ Required properties: - reg : the I2C address of the device for I2C, the chip select number for SPI. =20 +Optional properties: + +- mute-gpios: GPIO specifier for the mute pin + Example: =20 ssm2602: ssm2602@1a { --=20 2.40.0.634.g4ca3ef3211-goog From nobody Thu Dec 18 07:53:42 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7CE46C77B72 for ; Fri, 14 Apr 2023 14:03:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230313AbjDNOD5 (ORCPT ); Fri, 14 Apr 2023 10:03:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53374 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230249AbjDNODs (ORCPT ); Fri, 14 Apr 2023 10:03:48 -0400 Received: from mail-lj1-x22d.google.com (mail-lj1-x22d.google.com [IPv6:2a00:1450:4864:20::22d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 48DA9E60 for ; Fri, 14 Apr 2023 07:03:05 -0700 (PDT) Received: by mail-lj1-x22d.google.com with SMTP id r9so5221317ljp.9 for ; Fri, 14 Apr 2023 07:03:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=semihalf.com; s=google; t=1681480974; x=1684072974; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=8YA5l458OG2xTSndJtJKAZvkZUt5Wi8ebzINtZE34dg=; b=m3EUEris+Gszu2c+E8GGw6gGzpt4sDNj107p2ZIilXUFmbTbGsKLm6NdlOpQpptIUX N4Qq7fKgJ3NbBQfGSO/Y2l9AXqga816Fb33t7GdzoycHpBzJi0BPR+Im58EHuYePTr6K 35qfsSB/ws4Q1yFa4Mq8SFyn4LPeWPvhJRHe+T0wrel5WDLLUzplMShn5K6uIirBp2Q0 2QU3tAnK7/4Wls5/mUAMlPpLRAjT3/jrwlbR8R7vYexFu+KGiUFTzVpY41YACjeaziR0 mnRcRfK/RHRl3paL2KBQ3tG2yGWJlybKfJsDKRb+2XagAOqcQx51qVWjGhX2UP5NiqV6 6Tkw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1681480974; x=1684072974; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=8YA5l458OG2xTSndJtJKAZvkZUt5Wi8ebzINtZE34dg=; b=RdIl9WpbV/v9Kl7mWEQWuUy1VAsx5in666vPMhIlmRnhgABPWosLHWgMqUbITRKGyh gj3o1fWEBO1+ASE3SIZx/jFN/eYGnw1UulfRbHJuU3DWWza2trirJOlvNuzwsSRQq89K ZIM8MGR1RX8toDnXC5W3u010g1w86jzYHfg/cROTa5vB/ZoHM1KiEHLnnN4LgKXiMtqN f9lNNTPlMu6JZYSLlbJNABttIJ/R9veV/+0UMFq7pL3I2OG6ITUtUjJIlaMc5l2g5XJ2 mU/NXgCRgIqbPzBkuOoV4WoJWr/LLn77jWsJWtJ4X6TdhUlMsfvQ6xptAPfoge3oEEgh yHbQ== X-Gm-Message-State: AAQBX9epSoa/FDPrPGUIezALMzTm87vu3BtHV6Qrxs+CHhst3F6hzxv4 xbMgafe7p673sTGo8GyMLuNJvQ== X-Google-Smtp-Source: AKy350YAbEsWVjeiiZRye1QbGqhGM+1HTvCZL1EsMT7NMasjE6Bie7EA43J69Wcu8qE2YMAwAr66iw== X-Received: by 2002:a2e:880a:0:b0:2a8:a573:aed5 with SMTP id x10-20020a2e880a000000b002a8a573aed5mr1333306ljh.27.1681480973763; Fri, 14 Apr 2023 07:02:53 -0700 (PDT) Received: from panikiel.roam.corp.google.com (staticline-31-182-201-26.toya.net.pl. [31.182.201.26]) by smtp.gmail.com with ESMTPSA id 15-20020a2eb2cf000000b002a76e2dedbcsm828684ljz.139.2023.04.14.07.02.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 14 Apr 2023 07:02:53 -0700 (PDT) From: =?UTF-8?q?Pawe=C5=82=20Anikiel?= To: alsa-devel@alsa-project.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, lgirdwood@gmail.com, broonie@kernel.org Cc: perex@perex.cz, tiwai@suse.com, robh+dt@kernel.org, krzysztof.kozlowski+dt@linaro.org, dinguyen@kernel.org, lars@metafoo.de, nuno.sa@analog.com, upstream@semihalf.com, =?UTF-8?q?Pawe=C5=82=20Anikiel?= Subject: [PATCH 9/9] ARM: dts: chameleonv3: Add ssm2603 mute gpio Date: Fri, 14 Apr 2023 16:02:03 +0200 Message-ID: <20230414140203.707729-10-pan@semihalf.com> X-Mailer: git-send-email 2.40.0.634.g4ca3ef3211-goog In-Reply-To: <20230414140203.707729-1-pan@semihalf.com> References: <20230414140203.707729-1-pan@semihalf.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The ssm2603 mute pin is connected to a gpio expander. Add this connection to the devicetree. Signed-off-by: Pawe=C5=82 Anikiel --- arch/arm/boot/dts/socfpga_arria10_chameleonv3.dts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/arch/arm/boot/dts/socfpga_arria10_chameleonv3.dts b/arch/arm/b= oot/dts/socfpga_arria10_chameleonv3.dts index c75f41058196..81e83ce0f8e7 100644 --- a/arch/arm/boot/dts/socfpga_arria10_chameleonv3.dts +++ b/arch/arm/boot/dts/socfpga_arria10_chameleonv3.dts @@ -3,6 +3,7 @@ * Copyright 2022 Google LLC */ /dts-v1/; +#include #include "socfpga_arria10_mercury_aa1.dtsi" =20 / { @@ -67,6 +68,7 @@ &i2c0 { ssm2603: audio-codec@1a { compatible =3D "adi,ssm2603"; reg =3D <0x1a>; + mute-gpios =3D <&u80 0 GPIO_ACTIVE_LOW>; }; }; =20 --=20 2.40.0.634.g4ca3ef3211-goog