From: Vasily Khoruzhick <anarsoul@gmail.com>
To: Liam Girdwood <lgirdwood@gmail.com>,
Mark Brown <broonie@kernel.org>, Rob Herring <robh+dt@kernel.org>,
Mark Rutland <mark.rutland@arm.com>,
Maxime Ripard <maxime.ripard@bootlin.com>,
Jaroslav Kysela <perex@perex.cz>, Takashi Iwai <tiwai@suse.com>,
Marcus Cooper <codekipper@gmail.com>,
Mylene JOSSERAND <mylene.josserand@free-electrons.com>,
alsa-devel@alsa-project.org, devicetree@vger.kernel.org,
linux-arm-kernel@lists.infradead.org
Cc: Vasily Khoruzhick <anarsoul@gmail.com>
Subject: [PATCH 03/10] ASoC: sun8i-codec: add support for speaker amp GPIO
Date: Fri, 12 Oct 2018 20:32:23 -0700 [thread overview]
Message-ID: <20181013033230.6506-4-anarsoul@gmail.com> (raw)
In-Reply-To: <20181013033230.6506-1-anarsoul@gmail.com>
Some boards may have external amplifier for speaker that is controlled
via GPIO, add support for it in similar way as it's done in sun4i-codec
Signed-off-by: Vasily Khoruzhick <anarsoul@gmail.com>
---
.../bindings/sound/sun8i-a33-codec.txt | 3 +++
sound/soc/sunxi/sun8i-codec.c | 27 +++++++++++++++++++
2 files changed, 30 insertions(+)
diff --git a/Documentation/devicetree/bindings/sound/sun8i-a33-codec.txt b/Documentation/devicetree/bindings/sound/sun8i-a33-codec.txt
index 2ca3d138528e..21ab72b29ee4 100644
--- a/Documentation/devicetree/bindings/sound/sun8i-a33-codec.txt
+++ b/Documentation/devicetree/bindings/sound/sun8i-a33-codec.txt
@@ -25,6 +25,9 @@ Required properties:
- "bus": the parent APB clock for this controller
- "mod": the parent module clock
+Optional properties:
+- allwinner,pa-gpios: gpio to enable external amplifier
+
Here is an example to add a sound card and the codec binding on sun8i SoCs that
are similar to A33 using simple-card:
diff --git a/sound/soc/sunxi/sun8i-codec.c b/sound/soc/sunxi/sun8i-codec.c
index e681e194ad4c..96879dad3425 100644
--- a/sound/soc/sunxi/sun8i-codec.c
+++ b/sound/soc/sunxi/sun8i-codec.c
@@ -24,6 +24,7 @@
#include <linux/io.h>
#include <linux/pm_runtime.h>
#include <linux/regmap.h>
+#include <linux/gpio/consumer.h>
#include <sound/pcm_params.h>
#include <sound/soc.h>
@@ -97,8 +98,22 @@ struct sun8i_codec {
struct regmap *regmap;
struct clk *clk_module;
struct clk *clk_bus;
+ struct gpio_desc *gpio_pa;
};
+static int sun8i_codec_spk_event(struct snd_soc_dapm_widget *w,
+ struct snd_kcontrol *k, int event)
+{
+ struct snd_soc_component *component =
+ snd_soc_dapm_to_component(w->dapm);
+ struct sun8i_codec *scodec = snd_soc_component_get_drvdata(component);
+
+ gpiod_set_value_cansleep(scodec->gpio_pa,
+ !!SND_SOC_DAPM_EVENT_ON(event));
+
+ return 0;
+}
+
static int sun8i_codec_runtime_resume(struct device *dev)
{
struct sun8i_codec *scodec = dev_get_drvdata(dev);
@@ -432,6 +447,9 @@ static const struct snd_soc_dapm_widget sun8i_codec_dapm_widgets[] = {
SOC_MIXER_ARRAY("Right Digital ADC Mixer", SND_SOC_NOPM, 0, 0,
sun8i_input_mixer_controls),
+ /* Speaker */
+ SND_SOC_DAPM_SPK("Speaker", sun8i_codec_spk_event),
+
/* Clocks */
SND_SOC_DAPM_SUPPLY("MODCLK AFI1", SUN8I_MOD_CLK_ENA,
SUN8I_MOD_CLK_ENA_AIF1, 0, NULL, 0),
@@ -570,6 +588,15 @@ static int sun8i_codec_probe(struct platform_device *pdev)
return PTR_ERR(scodec->clk_bus);
}
+ scodec->gpio_pa = devm_gpiod_get_optional(&pdev->dev, "allwinner,pa",
+ GPIOD_OUT_LOW);
+ if (IS_ERR(scodec->gpio_pa)) {
+ ret = PTR_ERR(scodec->gpio_pa);
+ if (ret != -EPROBE_DEFER)
+ dev_err(&pdev->dev, "Failed to get pa gpio: %d\n", ret);
+ return ret;
+ }
+
res_base = platform_get_resource(pdev, IORESOURCE_MEM, 0);
base = devm_ioremap_resource(&pdev->dev, res_base);
if (IS_ERR(base)) {
--
2.19.0
next prev parent reply other threads:[~2018-10-13 3:32 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-10-13 3:32 [PATCH 00/10] Add support for audiocodec in Allwinner A64 Vasily Khoruzhick
2018-10-13 3:32 ` [PATCH 01/10] ASoC: sun4i-i2s: Add compatibility with A64 codec I2S Vasily Khoruzhick
2018-10-13 4:32 ` Chen-Yu Tsai
2018-10-13 4:36 ` Vasily Khoruzhick
2018-10-13 3:32 ` [PATCH 02/10] ASoC: sun8i-codec: Don't hardcode BCLK / LRCK ratio Vasily Khoruzhick
2018-10-13 3:32 ` Vasily Khoruzhick [this message]
2018-10-13 4:00 ` [PATCH 03/10] ASoC: sun8i-codec: add support for speaker amp GPIO Chen-Yu Tsai
2018-10-13 4:21 ` Vasily Khoruzhick
2018-10-13 4:34 ` Chen-Yu Tsai
2018-10-13 3:32 ` [PATCH 04/10] ASoC: sun8i-codec-analog: split regmap code into separate driver Vasily Khoruzhick
2018-10-13 3:32 ` [PATCH 05/10] ASoC: dt-binding: Add bindings for Allwinner A64 codec's analog path controls Vasily Khoruzhick
2018-10-13 3:32 ` [PATCH 06/10] ASoC: sunxi: Add new driver " Vasily Khoruzhick
2018-10-13 3:32 ` [PATCH 07/10] ASoC: sunxi: allow the sun8i-codec driver to be built on ARM64 Vasily Khoruzhick
2018-10-13 3:32 ` [PATCH 08/10] arm64: dts: allwinner: a64: add nodes necessary for analog sound support Vasily Khoruzhick
2018-10-13 3:32 ` [PATCH 09/10] arm64: dts: allwinner: a64: enable sound on Pine64 and SoPine Vasily Khoruzhick
2018-10-13 3:32 ` [PATCH 10/10] arm64: dts: allwinner: a64: enable sound on Pinebook Vasily Khoruzhick
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20181013033230.6506-4-anarsoul@gmail.com \
--to=anarsoul@gmail.com \
--cc=alsa-devel@alsa-project.org \
--cc=broonie@kernel.org \
--cc=codekipper@gmail.com \
--cc=devicetree@vger.kernel.org \
--cc=lgirdwood@gmail.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=mark.rutland@arm.com \
--cc=maxime.ripard@bootlin.com \
--cc=mylene.josserand@free-electrons.com \
--cc=perex@perex.cz \
--cc=robh+dt@kernel.org \
--cc=tiwai@suse.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).