Commit Graph

14 Commits

Author SHA1 Message Date
Arnaud Ferraris 25ae1a04da
ASoC: sun50i-codec-analog: Add support for internal bias
In order to properly bias headset microphones, there should be a pull-up
resistor between pins HBIAS and MIC2P. This can be an external resistor,
but the codec also provides an internal 2.2K resistor which is enabled
by a register.

This patch enables or disables the internal bias resistor based on a
device tree property.

Signed-off-by: Arnaud Ferraris <arnaud.ferraris@collabora.com>
[Samuel: split binding and implementation; move to device probe]
Signed-off-by: Samuel Holland <samuel@sholland.org>
Link: https://lore.kernel.org/r/20220621035452.60272-3-samuel@sholland.org
Signed-off-by: Mark Brown <broonie@kernel.org>
2022-06-27 13:18:04 +01:00
Samuel Holland 7829e68d55
ASoC: sun50i-codec-analog: Enable DAPM for earpiece switch
By including the earpiece mute switch in the DAPM graph, both the
earpiece amplifier and the Mixer/DAC inputs can be powered off when
the earpiece is muted.

While the widget is really just a simple switch, it is represented
as a "mixer with named controls" to avoid including the widget name
in the kcontrol name. Otherwise, it is not possible to give the widget
an accurate, descriptive name without changing the kcontrol name
seen by userspace (which should be stable).

The mute switch is between the source selection and the amplifier,
as per the diagram in the SoC manual.

Signed-off-by: Samuel Holland <samuel@sholland.org>
Link: https://lore.kernel.org/r/20200726025334.59931-9-samuel@sholland.org
Signed-off-by: Mark Brown <broonie@kernel.org>
2020-08-17 16:19:17 +01:00
Samuel Holland 95d34762f2
ASoC: sun50i-codec-analog: Enable DAPM for line out switch
By including the line out mute switch in the DAPM graph, the
Mixer/DAC inputs can be powered off when the line output is muted.

The line outputs have an unusual routing scheme. The left side mute
switch is between the source selection and the amplifier, as usual.
The right side source selection comes *after* its amplifier (and
after the left side amplifier), and its mute switch controls
whichever source is currently selected. This matches the diagram in
the SoC manual.

Signed-off-by: Samuel Holland <samuel@sholland.org>
Reviewed-by: Chen-Yu Tsai <wens@csie.org>
Link: https://lore.kernel.org/r/20200726025334.59931-8-samuel@sholland.org
Signed-off-by: Mark Brown <broonie@kernel.org>
2020-08-17 16:19:17 +01:00
Samuel Holland dd8286a349
ASoC: sun50i-codec-analog: Make line out routes stereo
This matches the hardware more accurately, and is necessary for
including the (stereo) line out mute switch in the DAPM graph.

Signed-off-by: Samuel Holland <samuel@sholland.org>
Reviewed-by: Chen-Yu Tsai <wens@csie.org>
Link: https://lore.kernel.org/r/20200726025334.59931-7-samuel@sholland.org
Signed-off-by: Mark Brown <broonie@kernel.org>
2020-08-17 16:19:16 +01:00
Samuel Holland 4b9f39e14c
ASoC: sun50i-codec-analog: Enable DAPM for headphone switch
By including the headphone mute switch to the DAPM graph, both the
headphone amplifier and the Mixer/DAC inputs can be powered off when
the headphones are muted.

The mute switch is between the source selection and the amplifier,
as per the diagram in the SoC manual.

Signed-off-by: Samuel Holland <samuel@sholland.org>
Reviewed-by: Chen-Yu Tsai <wens@csie.org>
Link: https://lore.kernel.org/r/20200726025334.59931-6-samuel@sholland.org
Signed-off-by: Mark Brown <broonie@kernel.org>
2020-08-17 16:19:15 +01:00
Samuel Holland 241a578a9e
ASoC: sun50i-codec-analog: Make headphone routes stereo
This matches the hardware more accurately, and is necessary for
including the (stereo) headphone mute switch in the DAPM graph.

Signed-off-by: Samuel Holland <samuel@sholland.org>
Reviewed-by: Chen-Yu Tsai <wens@csie.org>
Link: https://lore.kernel.org/r/20200726025334.59931-5-samuel@sholland.org
Signed-off-by: Mark Brown <broonie@kernel.org>
2020-08-17 16:19:14 +01:00
Samuel Holland cababecb33
ASoC: sun50i-codec-analog: Group and sort mixer routes
Sort the controls in the same order as the bits in the register. Then
group the routes by sink, and sort them in the same order as the
controls. This makes it much easier to verify that all mixer inputs are
accounted for.

Signed-off-by: Samuel Holland <samuel@sholland.org>
Acked-by: Chen-Yu Tsai <wens@csie.org>
Link: https://lore.kernel.org/r/20200726025334.59931-4-samuel@sholland.org
Signed-off-by: Mark Brown <broonie@kernel.org>
2020-08-17 16:19:13 +01:00
Samuel Holland 9b7612bb75
ASoC: sun50i-codec-analog: Gate the amplifier clock during suspend
The clock must be running for the zero-crossing mute functionality.
However, it must be gated for VDD-SYS to be turned off during system
suspend. Disable it in the suspend callback, after everything has
already been muted, to avoid pops when muting/unmuting outputs.

Signed-off-by: Samuel Holland <samuel@sholland.org>
Acked-by: Chen-Yu Tsai <wens@csie.org>
Link: https://lore.kernel.org/r/20200726025334.59931-3-samuel@sholland.org
Signed-off-by: Mark Brown <broonie@kernel.org>
2020-08-17 16:19:12 +01:00
Samuel Holland ad5b7f69a0
ASoC: sun50i-codec-analog: Fix duplicate use of ADC enable bits
The same enable bits are currently used for both the "Left/Right ADC"
and the "Left/Right ADC Mixer" widgets. This happens to work in practice
because the widgets are always enabled/disabled at the same time, but
each register bit should only be associated with a single widget.

To keep symmetry with the DAC widgets, keep the bits on the ADC widgets,
and remove them from the ADC Mixer widgets.

Fixes: 42371f327d ("ASoC: sunxi: Add new driver for Allwinner A64 codec's analog path controls")
Reported-by: Ondrej Jirman <megous@megous.com>
Signed-off-by: Samuel Holland <samuel@sholland.org>
Acked-by: Chen-Yu Tsai <wens@csie.org>
Link: https://lore.kernel.org/r/20200726025334.59931-2-samuel@sholland.org
Signed-off-by: Mark Brown <broonie@kernel.org>
2020-08-17 16:19:11 +01:00
YueHaibing 54dd39e4ac
ASoC: sunxi: sun50i-codec-analog: use devm_platform_ioremap_resource() to simplify code
Use devm_platform_ioremap_resource() to simplify the code a bit.
This is detected by coccinelle.

Reported-by: Hulk Robot <hulkci@huawei.com>
Signed-off-by: YueHaibing <yuehaibing@huawei.com>
Link: https://lore.kernel.org/r/20190727150738.54764-34-yuehaibing@huawei.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2019-07-31 12:09:20 +01:00
Luca Weiss 1fe08602d1
ASoC: sunxi: sun50i-codec-analog: Add earpiece
This adds the necessary registers and audio routes to play audio using
the Earpiece, that's supported on the A64.

Signed-off-by: Luca Weiss <luca@z3ntu.xyz>
Reviewed-by: Chen-Yu Tsai <wens@csie.org>
Link: https://lore.kernel.org/r/20190703184814.27191-1-luca@z3ntu.xyz
Signed-off-by: Mark Brown <broonie@kernel.org>
2019-07-05 17:58:31 +01:00
Chen-Yu Tsai 5fd812e6f5
ASoC: sunxi: sun50i-codec-analog: Rename hpvcc regulator supply to cpvdd
The A64 datasheet lists the supply rail for the headphone amp's charge
pump as "CPVDD". cpvdd-supply is the name of the property for this power
rail specified in the device tree bindings. "HPVCC" was the name used in
the A33 datasheet for the same function.

Rename the supply so it matches the datasheet, bindings, and the subject
from the original commit.

Fixes: ca0412a057 ("ASoC: sunxi: sun50i-codec-analog: Add support for cpvdd regulator supply")
Signed-off-by: Chen-Yu Tsai <wens@csie.org>
Signed-off-by: Mark Brown <broonie@kernel.org>
2019-02-19 15:36:02 +00:00
Chen-Yu Tsai ca0412a057
ASoC: sunxi: sun50i-codec-analog: Add support for cpvdd regulator supply
On the Allwinner A64 SoCs, the audio codec has a built-in headphone
amplifier. This amplifier has a power supply separate from the rest of
the analog audio circuitry, labeled cpvdd.

This patch adds a DAPM widget for this supply, and ties it to the
headphone amp widget.

Signed-off-by: Chen-Yu Tsai <wens@csie.org>
Acked-by: Maxime Ripard <maxime.ripard@bootlin.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
2018-11-23 14:01:34 +00:00
Vasily Khoruzhick 42371f327d
ASoC: sunxi: Add new driver for Allwinner A64 codec's analog path controls
The internal codec on A64 is split into 2 parts. The analog path controls
are routed through an embedded custom register bus accessed through
the PRCM block.

Add an ASoC component driver for it. This should be tied to the codec
audio card as an auxiliary device.

Signed-off-by: Vasily Khoruzhick <anarsoul@gmail.com>
Acked-by: Maxime Ripard <maxime.ripard@bootlin.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
2018-10-17 11:11:01 +01:00