[ rockchip64 ] fix SD card voltage toggling vis codec on rk3328
This commit is contained in:
parent
b36f2be759
commit
dc75fea037
@ -0,0 +1,125 @@
|
||||
Existing RK3328 codec drivers have overloaded the GRF phandle to assume
|
||||
implicit control of the limited-function GPIO_MUTE pin, which is usually
|
||||
used to enable an external audio line driver IC. Since this pin has a
|
||||
proper binding of its own (see gpio/rockchip,rk3328-grf-gpio.txt), make
|
||||
a GPIO explicit in the codec binding too. This will help avoid ambiguity
|
||||
on boards that use that pin for some other purpose.
|
||||
|
||||
(and while touching the example, enforce the "don't include status" rule)
|
||||
|
||||
Signed-off-by: Robin Murphy <robin.murphy@arm.com>
|
||||
---
|
||||
.../devicetree/bindings/sound/rockchip,rk3328-codec.txt | 7 ++++++-
|
||||
1 file changed, 6 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/Documentation/devicetree/bindings/sound/rockchip,rk3328-codec.txt b/Documentation/devicetree/bindings/sound/rockchip,rk3328-codec.txt
|
||||
index 2469588c7ccb..1ecd75d2032a 100644
|
||||
--- a/Documentation/devicetree/bindings/sound/rockchip,rk3328-codec.txt
|
||||
+++ b/Documentation/devicetree/bindings/sound/rockchip,rk3328-codec.txt
|
||||
@@ -10,6 +10,11 @@ Required properties:
|
||||
- clock-names: should be "pclk".
|
||||
- spk-depop-time-ms: speak depop time msec.
|
||||
|
||||
+Optional properties:
|
||||
+
|
||||
+- mute-gpios: GPIO specifier for external line driver control (typically the
|
||||
+ dedicated GPIO_MUTE pin)
|
||||
+
|
||||
Example for rk3328 internal codec:
|
||||
|
||||
codec: codec@ff410000 {
|
||||
@@ -18,6 +23,6 @@ codec: codec@ff410000 {
|
||||
rockchip,grf = <&grf>;
|
||||
clocks = <&cru PCLK_ACODEC>;
|
||||
clock-names = "pclk";
|
||||
+ mute-gpios = <&grf_gpio 0 GPIO_ACTIVE_LOW>;
|
||||
spk-depop-time-ms = 100;
|
||||
- status = "disabled";
|
||||
};
|
||||
|
||||
diff --git a/sound/soc/codecs/rk3328_codec.c b/sound/soc/codecs/rk3328_codec.c
|
||||
index 287c962ba00d..f0e9ef21c5f8 100644
|
||||
--- a/sound/soc/codecs/rk3328_codec.c
|
||||
+++ b/sound/soc/codecs/rk3328_codec.c
|
||||
@@ -7,6 +7,7 @@
|
||||
#include <linux/clk.h>
|
||||
#include <linux/delay.h>
|
||||
#include <linux/device.h>
|
||||
+#include <linux/gpio/consumer.h>
|
||||
#include <linux/module.h>
|
||||
#include <linux/of.h>
|
||||
#include <linux/platform_device.h>
|
||||
@@ -31,7 +32,7 @@
|
||||
|
||||
struct rk3328_codec_priv {
|
||||
struct regmap *regmap;
|
||||
- struct regmap *grf;
|
||||
+ struct gpio_desc *mute;
|
||||
struct clk *mclk;
|
||||
struct clk *pclk;
|
||||
unsigned int sclk;
|
||||
@@ -106,16 +107,6 @@ static int rk3328_set_dai_fmt(struct snd_soc_dai *dai, unsigned int fmt)
|
||||
return 0;
|
||||
}
|
||||
|
||||
-static void rk3328_analog_output(struct rk3328_codec_priv *rk3328, int mute)
|
||||
-{
|
||||
- unsigned int val = BIT(17);
|
||||
-
|
||||
- if (mute)
|
||||
- val |= BIT(1);
|
||||
-
|
||||
- regmap_write(rk3328->grf, RK3328_GRF_SOC_CON10, val);
|
||||
-}
|
||||
-
|
||||
static int rk3328_digital_mute(struct snd_soc_dai *dai, int mute)
|
||||
{
|
||||
struct rk3328_codec_priv *rk3328 =
|
||||
@@ -205,7 +196,7 @@ static int rk3328_codec_open_playback(struct rk3328_codec_priv *rk3328)
|
||||
}
|
||||
|
||||
msleep(rk3328->spk_depop_time);
|
||||
- rk3328_analog_output(rk3328, 1);
|
||||
+ gpiod_set_value(rk3328->mute, 0);
|
||||
|
||||
regmap_update_bits(rk3328->regmap, HPOUTL_GAIN_CTRL,
|
||||
HPOUTL_GAIN_MASK, OUT_VOLUME);
|
||||
@@ -246,7 +237,7 @@ static int rk3328_codec_close_playback(struct rk3328_codec_priv *rk3328)
|
||||
{
|
||||
size_t i;
|
||||
|
||||
- rk3328_analog_output(rk3328, 0);
|
||||
+ gpiod_set_value(rk3328->mute, 1);
|
||||
|
||||
regmap_update_bits(rk3328->regmap, HPOUTL_GAIN_CTRL,
|
||||
HPOUTL_GAIN_MASK, 0);
|
||||
@@ -446,7 +437,6 @@ static int rk3328_platform_probe(struct platform_device *pdev)
|
||||
dev_err(&pdev->dev, "missing 'rockchip,grf'\n");
|
||||
return PTR_ERR(grf);
|
||||
}
|
||||
- rk3328->grf = grf;
|
||||
/* enable i2s_acodec_en */
|
||||
regmap_write(grf, RK3328_GRF_SOC_CON2,
|
||||
(BIT(14) << 16 | BIT(14)));
|
||||
@@ -458,7 +448,7 @@ static int rk3328_platform_probe(struct platform_device *pdev)
|
||||
rk3328->spk_depop_time = 200;
|
||||
}
|
||||
|
||||
- rk3328_analog_output(rk3328, 0);
|
||||
+ rk3328->mute = gpiod_get_optional(&pdev->dev, "mute", GPIOD_OUT_HIGH);
|
||||
|
||||
rk3328->mclk = devm_clk_get(&pdev->dev, "mclk");
|
||||
if (IS_ERR(rk3328->mclk))
|
||||
|
||||
diff --git a/arch/arm64/boot/dts/rockchip/rk3328-rock64.dts b/arch/arm64/boot/dts/rockchip/rk3328-rock64.dts
|
||||
index 62936b432f9a..bf3e546f5266 100644
|
||||
--- a/arch/arm64/boot/dts/rockchip/rk3328-rock64.dts
|
||||
+++ b/arch/arm64/boot/dts/rockchip/rk3328-rock64.dts
|
||||
@@ -104,6 +104,7 @@
|
||||
};
|
||||
|
||||
&codec {
|
||||
+ mute-gpios = <&grf_gpio 0 GPIO_ACTIVE_LOW>;
|
||||
status = "okay";
|
||||
|
||||
port@0 {
|
||||
Loading…
Reference in New Issue
Block a user