Commit 8237d99c authored by Mark Brown's avatar Mark Brown

Merge remote-tracking branches 'asoc/topic/pxa', 'asoc/topic/qcom' and...

Merge remote-tracking branches 'asoc/topic/pxa', 'asoc/topic/qcom' and 'asoc/topic/rockchip' into asoc-next
ROCKCHIP RK3288 with HDMI and analog audio
Required properties:
- compatible: "rockchip,rk3288-hdmi-analog"
- rockchip,model: The user-visible name of this sound complex
- rockchip,i2s-controller: The phandle of the Rockchip I2S controller that's
connected to the CODEC
- rockchip,audio-codec: The phandle of the analog audio codec.
- rockchip,routing: A list of the connections between audio components.
Each entry is a pair of strings, the first being the
connection's sink, the second being the connection's
source. For this driver the first string should always be
"Analog".
Optionnal properties:
- rockchip,hp-en-gpios = The phandle of the GPIO that power up/down the
headphone (when the analog output is an headphone).
- rockchip,hp-det-gpios = The phandle of the GPIO that detects the headphone
(when the analog output is an headphone).
- pinctrl-names, pinctrl-0: Please refer to pinctrl-bindings.txt
Example:
sound {
compatible = "rockchip,rockchip-audio-es8388";
rockchip,model = "Analog audio output";
rockchip,i2s-controller = <&i2s>;
rockchip,audio-codec = <&es8388>;
rockchip,routing = "Analog", "LOUT2",
"Analog", "ROUT2";
rockchip,hp-en-gpios = <&gpio8 0 GPIO_ACTIVE_HIGH>;
rockchip,hp-det-gpios = <&gpio7 7 GPIO_ACTIVE_HIGH>;
pinctrl-names = "default";
pinctrl-0 = <&headphone>;
};
...@@ -22,9 +22,6 @@ ...@@ -22,9 +22,6 @@
#include <asm/mach-types.h> #include <asm/mach-types.h>
#include "pxa2xx-ac97.h"
#define E740_AUDIO_OUT 1 #define E740_AUDIO_OUT 1
#define E740_AUDIO_IN 2 #define E740_AUDIO_IN 2
......
...@@ -22,8 +22,6 @@ ...@@ -22,8 +22,6 @@
#include <asm/mach-types.h> #include <asm/mach-types.h>
#include "pxa2xx-ac97.h"
static int e750_spk_amp_event(struct snd_soc_dapm_widget *w, static int e750_spk_amp_event(struct snd_soc_dapm_widget *w,
struct snd_kcontrol *kcontrol, int event) struct snd_kcontrol *kcontrol, int event)
{ {
......
...@@ -21,8 +21,6 @@ ...@@ -21,8 +21,6 @@
#include <mach/audio.h> #include <mach/audio.h>
#include <mach/eseries-gpio.h> #include <mach/eseries-gpio.h>
#include "pxa2xx-ac97.h"
static int e800_spk_amp_event(struct snd_soc_dapm_widget *w, static int e800_spk_amp_event(struct snd_soc_dapm_widget *w,
struct snd_kcontrol *kcontrol, int event) struct snd_kcontrol *kcontrol, int event)
{ {
......
...@@ -30,8 +30,6 @@ ...@@ -30,8 +30,6 @@
#include <asm/mach-types.h> #include <asm/mach-types.h>
#include <mach/audio.h> #include <mach/audio.h>
#include "pxa2xx-ac97.h"
static struct snd_soc_dai_link em_x270_dai[] = { static struct snd_soc_dai_link em_x270_dai[] = {
{ {
.name = "AC97", .name = "AC97",
......
...@@ -53,7 +53,6 @@ ...@@ -53,7 +53,6 @@
#include <sound/initval.h> #include <sound/initval.h>
#include <sound/ac97_codec.h> #include <sound/ac97_codec.h>
#include "pxa2xx-ac97.h"
#include "../codecs/wm9713.h" #include "../codecs/wm9713.h"
#define AC97_GPIO_PULL 0x58 #define AC97_GPIO_PULL 0x58
......
...@@ -27,8 +27,6 @@ ...@@ -27,8 +27,6 @@
#include <mach/audio.h> #include <mach/audio.h>
#include <linux/platform_data/asoc-palm27x.h> #include <linux/platform_data/asoc-palm27x.h>
#include "pxa2xx-ac97.h"
static struct snd_soc_jack hs_jack; static struct snd_soc_jack hs_jack;
/* Headphones jack detection DAPM pins */ /* Headphones jack detection DAPM pins */
......
...@@ -27,8 +27,6 @@ ...@@ -27,8 +27,6 @@
#include <mach/regs-ac97.h> #include <mach/regs-ac97.h>
#include <mach/audio.h> #include <mach/audio.h>
#include "pxa2xx-ac97.h"
static void pxa2xx_ac97_warm_reset(struct snd_ac97 *ac97) static void pxa2xx_ac97_warm_reset(struct snd_ac97 *ac97)
{ {
pxa2xx_ac97_try_warm_reset(ac97); pxa2xx_ac97_try_warm_reset(ac97);
......
/*
* linux/sound/soc/pxa/pxa2xx-ac97.h
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*/
#ifndef _PXA2XX_AC97_H
#define _PXA2XX_AC97_H
/* pxa2xx DAI ID's */
#define PXA2XX_DAI_AC97_HIFI 0
#define PXA2XX_DAI_AC97_AUX 1
#define PXA2XX_DAI_AC97_MIC 2
#endif
...@@ -31,8 +31,6 @@ ...@@ -31,8 +31,6 @@
#include <mach/tosa.h> #include <mach/tosa.h>
#include <mach/audio.h> #include <mach/audio.h>
#include "pxa2xx-ac97.h"
#define TOSA_HP 0 #define TOSA_HP 0
#define TOSA_MIC_INT 1 #define TOSA_MIC_INT 1
#define TOSA_HEADSET 2 #define TOSA_HEADSET 2
......
...@@ -22,7 +22,6 @@ ...@@ -22,7 +22,6 @@
#include <sound/soc.h> #include <sound/soc.h>
#include "../codecs/wm9713.h" #include "../codecs/wm9713.h"
#include "pxa2xx-ac97.h"
#include "pxa-ssp.h" #include "pxa-ssp.h"
/* /*
......
...@@ -175,29 +175,28 @@ static int apq8016_lpass_init(struct platform_device *pdev) ...@@ -175,29 +175,28 @@ static int apq8016_lpass_init(struct platform_device *pdev)
drvdata->pcnoc_mport_clk = devm_clk_get(dev, "pcnoc-mport-clk"); drvdata->pcnoc_mport_clk = devm_clk_get(dev, "pcnoc-mport-clk");
if (IS_ERR(drvdata->pcnoc_mport_clk)) { if (IS_ERR(drvdata->pcnoc_mport_clk)) {
dev_err(&pdev->dev, "%s() error getting pcnoc-mport-clk: %ld\n", dev_err(&pdev->dev, "error getting pcnoc-mport-clk: %ld\n",
__func__, PTR_ERR(drvdata->pcnoc_mport_clk)); PTR_ERR(drvdata->pcnoc_mport_clk));
return PTR_ERR(drvdata->pcnoc_mport_clk); return PTR_ERR(drvdata->pcnoc_mport_clk);
} }
ret = clk_prepare_enable(drvdata->pcnoc_mport_clk); ret = clk_prepare_enable(drvdata->pcnoc_mport_clk);
if (ret) { if (ret) {
dev_err(&pdev->dev, "%s() Error enabling pcnoc-mport-clk: %d\n", dev_err(&pdev->dev, "Error enabling pcnoc-mport-clk: %d\n",
__func__, ret); ret);
return ret; return ret;
} }
drvdata->pcnoc_sway_clk = devm_clk_get(dev, "pcnoc-sway-clk"); drvdata->pcnoc_sway_clk = devm_clk_get(dev, "pcnoc-sway-clk");
if (IS_ERR(drvdata->pcnoc_sway_clk)) { if (IS_ERR(drvdata->pcnoc_sway_clk)) {
dev_err(&pdev->dev, "%s() error getting pcnoc-sway-clk: %ld\n", dev_err(&pdev->dev, "error getting pcnoc-sway-clk: %ld\n",
__func__, PTR_ERR(drvdata->pcnoc_sway_clk)); PTR_ERR(drvdata->pcnoc_sway_clk));
return PTR_ERR(drvdata->pcnoc_sway_clk); return PTR_ERR(drvdata->pcnoc_sway_clk);
} }
ret = clk_prepare_enable(drvdata->pcnoc_sway_clk); ret = clk_prepare_enable(drvdata->pcnoc_sway_clk);
if (ret) { if (ret) {
dev_err(&pdev->dev, "%s() Error enabling pcnoc_sway_clk: %d\n", dev_err(&pdev->dev, "Error enabling pcnoc_sway_clk: %d\n", ret);
__func__, ret);
return ret; return ret;
} }
......
...@@ -33,13 +33,10 @@ static int lpass_cpu_daiops_set_sysclk(struct snd_soc_dai *dai, int clk_id, ...@@ -33,13 +33,10 @@ static int lpass_cpu_daiops_set_sysclk(struct snd_soc_dai *dai, int clk_id,
struct lpass_data *drvdata = snd_soc_dai_get_drvdata(dai); struct lpass_data *drvdata = snd_soc_dai_get_drvdata(dai);
int ret; int ret;
if (IS_ERR(drvdata->mi2s_osr_clk[dai->driver->id]))
return 0;
ret = clk_set_rate(drvdata->mi2s_osr_clk[dai->driver->id], freq); ret = clk_set_rate(drvdata->mi2s_osr_clk[dai->driver->id], freq);
if (ret) if (ret)
dev_err(dai->dev, "%s() error setting mi2s osrclk to %u: %d\n", dev_err(dai->dev, "error setting mi2s osrclk to %u: %d\n",
__func__, freq, ret); freq, ret);
return ret; return ret;
} }
...@@ -50,23 +47,16 @@ static int lpass_cpu_daiops_startup(struct snd_pcm_substream *substream, ...@@ -50,23 +47,16 @@ static int lpass_cpu_daiops_startup(struct snd_pcm_substream *substream,
struct lpass_data *drvdata = snd_soc_dai_get_drvdata(dai); struct lpass_data *drvdata = snd_soc_dai_get_drvdata(dai);
int ret; int ret;
if (!IS_ERR(drvdata->mi2s_osr_clk[dai->driver->id])) { ret = clk_prepare_enable(drvdata->mi2s_osr_clk[dai->driver->id]);
ret = clk_prepare_enable( if (ret) {
drvdata->mi2s_osr_clk[dai->driver->id]); dev_err(dai->dev, "error in enabling mi2s osr clk: %d\n", ret);
if (ret) { return ret;
dev_err(dai->dev, "%s() error in enabling mi2s osr clk: %d\n",
__func__, ret);
return ret;
}
} }
ret = clk_prepare_enable(drvdata->mi2s_bit_clk[dai->driver->id]); ret = clk_prepare_enable(drvdata->mi2s_bit_clk[dai->driver->id]);
if (ret) { if (ret) {
dev_err(dai->dev, "%s() error in enabling mi2s bit clk: %d\n", dev_err(dai->dev, "error in enabling mi2s bit clk: %d\n", ret);
__func__, ret); clk_disable_unprepare(drvdata->mi2s_osr_clk[dai->driver->id]);
if (!IS_ERR(drvdata->mi2s_osr_clk[dai->driver->id]))
clk_disable_unprepare(
drvdata->mi2s_osr_clk[dai->driver->id]);
return ret; return ret;
} }
...@@ -80,8 +70,7 @@ static void lpass_cpu_daiops_shutdown(struct snd_pcm_substream *substream, ...@@ -80,8 +70,7 @@ static void lpass_cpu_daiops_shutdown(struct snd_pcm_substream *substream,
clk_disable_unprepare(drvdata->mi2s_bit_clk[dai->driver->id]); clk_disable_unprepare(drvdata->mi2s_bit_clk[dai->driver->id]);
if (!IS_ERR(drvdata->mi2s_osr_clk[dai->driver->id])) clk_disable_unprepare(drvdata->mi2s_osr_clk[dai->driver->id]);
clk_disable_unprepare(drvdata->mi2s_osr_clk[dai->driver->id]);
} }
static int lpass_cpu_daiops_hw_params(struct snd_pcm_substream *substream, static int lpass_cpu_daiops_hw_params(struct snd_pcm_substream *substream,
...@@ -96,8 +85,7 @@ static int lpass_cpu_daiops_hw_params(struct snd_pcm_substream *substream, ...@@ -96,8 +85,7 @@ static int lpass_cpu_daiops_hw_params(struct snd_pcm_substream *substream,
bitwidth = snd_pcm_format_width(format); bitwidth = snd_pcm_format_width(format);
if (bitwidth < 0) { if (bitwidth < 0) {
dev_err(dai->dev, "%s() invalid bit width given: %d\n", dev_err(dai->dev, "invalid bit width given: %d\n", bitwidth);
__func__, bitwidth);
return bitwidth; return bitwidth;
} }
...@@ -115,8 +103,7 @@ static int lpass_cpu_daiops_hw_params(struct snd_pcm_substream *substream, ...@@ -115,8 +103,7 @@ static int lpass_cpu_daiops_hw_params(struct snd_pcm_substream *substream,
regval |= LPAIF_I2SCTL_BITWIDTH_32; regval |= LPAIF_I2SCTL_BITWIDTH_32;
break; break;
default: default:
dev_err(dai->dev, "%s() invalid bitwidth given: %d\n", dev_err(dai->dev, "invalid bitwidth given: %d\n", bitwidth);
__func__, bitwidth);
return -EINVAL; return -EINVAL;
} }
...@@ -143,8 +130,8 @@ static int lpass_cpu_daiops_hw_params(struct snd_pcm_substream *substream, ...@@ -143,8 +130,8 @@ static int lpass_cpu_daiops_hw_params(struct snd_pcm_substream *substream,
regval |= LPAIF_I2SCTL_SPKMONO_STEREO; regval |= LPAIF_I2SCTL_SPKMONO_STEREO;
break; break;
default: default:
dev_err(dai->dev, "%s() invalid channels given: %u\n", dev_err(dai->dev, "invalid channels given: %u\n",
__func__, channels); channels);
return -EINVAL; return -EINVAL;
} }
} else { } else {
...@@ -170,8 +157,8 @@ static int lpass_cpu_daiops_hw_params(struct snd_pcm_substream *substream, ...@@ -170,8 +157,8 @@ static int lpass_cpu_daiops_hw_params(struct snd_pcm_substream *substream,
regval |= LPAIF_I2SCTL_MICMONO_STEREO; regval |= LPAIF_I2SCTL_MICMONO_STEREO;
break; break;
default: default:
dev_err(dai->dev, "%s() invalid channels given: %u\n", dev_err(dai->dev, "invalid channels given: %u\n",
__func__, channels); channels);
return -EINVAL; return -EINVAL;
} }
} }
...@@ -180,16 +167,15 @@ static int lpass_cpu_daiops_hw_params(struct snd_pcm_substream *substream, ...@@ -180,16 +167,15 @@ static int lpass_cpu_daiops_hw_params(struct snd_pcm_substream *substream,
LPAIF_I2SCTL_REG(drvdata->variant, dai->driver->id), LPAIF_I2SCTL_REG(drvdata->variant, dai->driver->id),
regval); regval);
if (ret) { if (ret) {
dev_err(dai->dev, "%s() error writing to i2sctl reg: %d\n", dev_err(dai->dev, "error writing to i2sctl reg: %d\n", ret);
__func__, ret);
return ret; return ret;
} }
ret = clk_set_rate(drvdata->mi2s_bit_clk[dai->driver->id], ret = clk_set_rate(drvdata->mi2s_bit_clk[dai->driver->id],
rate * bitwidth * 2); rate * bitwidth * 2);
if (ret) { if (ret) {
dev_err(dai->dev, "%s() error setting mi2s bitclk to %u: %d\n", dev_err(dai->dev, "error setting mi2s bitclk to %u: %d\n",
__func__, rate * bitwidth * 2, ret); rate * bitwidth * 2, ret);
return ret; return ret;
} }
...@@ -206,8 +192,7 @@ static int lpass_cpu_daiops_hw_free(struct snd_pcm_substream *substream, ...@@ -206,8 +192,7 @@ static int lpass_cpu_daiops_hw_free(struct snd_pcm_substream *substream,
LPAIF_I2SCTL_REG(drvdata->variant, dai->driver->id), LPAIF_I2SCTL_REG(drvdata->variant, dai->driver->id),
0); 0);
if (ret) if (ret)
dev_err(dai->dev, "%s() error writing to i2sctl reg: %d\n", dev_err(dai->dev, "error writing to i2sctl reg: %d\n", ret);
__func__, ret);
return ret; return ret;
} }
...@@ -231,8 +216,7 @@ static int lpass_cpu_daiops_prepare(struct snd_pcm_substream *substream, ...@@ -231,8 +216,7 @@ static int lpass_cpu_daiops_prepare(struct snd_pcm_substream *substream,
LPAIF_I2SCTL_REG(drvdata->variant, dai->driver->id), LPAIF_I2SCTL_REG(drvdata->variant, dai->driver->id),
mask, val); mask, val);
if (ret) if (ret)
dev_err(dai->dev, "%s() error writing to i2sctl reg: %d\n", dev_err(dai->dev, "error writing to i2sctl reg: %d\n", ret);
__func__, ret);
return ret; return ret;
} }
...@@ -261,8 +245,8 @@ static int lpass_cpu_daiops_trigger(struct snd_pcm_substream *substream, ...@@ -261,8 +245,8 @@ static int lpass_cpu_daiops_trigger(struct snd_pcm_substream *substream,
dai->driver->id), dai->driver->id),
mask, val); mask, val);
if (ret) if (ret)
dev_err(dai->dev, "%s() error writing to i2sctl reg: %d\n", dev_err(dai->dev, "error writing to i2sctl reg: %d\n",
__func__, ret); ret);
break; break;
case SNDRV_PCM_TRIGGER_STOP: case SNDRV_PCM_TRIGGER_STOP:
case SNDRV_PCM_TRIGGER_SUSPEND: case SNDRV_PCM_TRIGGER_SUSPEND:
...@@ -280,8 +264,8 @@ static int lpass_cpu_daiops_trigger(struct snd_pcm_substream *substream, ...@@ -280,8 +264,8 @@ static int lpass_cpu_daiops_trigger(struct snd_pcm_substream *substream,
dai->driver->id), dai->driver->id),
mask, val); mask, val);
if (ret) if (ret)
dev_err(dai->dev, "%s() error writing to i2sctl reg: %d\n", dev_err(dai->dev, "error writing to i2sctl reg: %d\n",
__func__, ret); ret);
break; break;
} }
...@@ -308,8 +292,7 @@ int asoc_qcom_lpass_cpu_dai_probe(struct snd_soc_dai *dai) ...@@ -308,8 +292,7 @@ int asoc_qcom_lpass_cpu_dai_probe(struct snd_soc_dai *dai)
ret = regmap_write(drvdata->lpaif_map, ret = regmap_write(drvdata->lpaif_map,
LPAIF_I2SCTL_REG(drvdata->variant, dai->driver->id), 0); LPAIF_I2SCTL_REG(drvdata->variant, dai->driver->id), 0);
if (ret) if (ret)
dev_err(dai->dev, "%s() error writing to i2sctl reg: %d\n", dev_err(dai->dev, "error writing to i2sctl reg: %d\n", ret);
__func__, ret);
return ret; return ret;
} }
...@@ -451,8 +434,7 @@ int asoc_qcom_lpass_cpu_platform_probe(struct platform_device *pdev) ...@@ -451,8 +434,7 @@ int asoc_qcom_lpass_cpu_platform_probe(struct platform_device *pdev)
dsp_of_node = of_parse_phandle(pdev->dev.of_node, "qcom,adsp", 0); dsp_of_node = of_parse_phandle(pdev->dev.of_node, "qcom,adsp", 0);
if (dsp_of_node) { if (dsp_of_node) {
dev_err(&pdev->dev, "%s() DSP exists and holds audio resources\n", dev_err(&pdev->dev, "DSP exists and holds audio resources\n");
__func__);
return -EBUSY; return -EBUSY;
} }
...@@ -473,8 +455,7 @@ int asoc_qcom_lpass_cpu_platform_probe(struct platform_device *pdev) ...@@ -473,8 +455,7 @@ int asoc_qcom_lpass_cpu_platform_probe(struct platform_device *pdev)
drvdata->lpaif = devm_ioremap_resource(&pdev->dev, res); drvdata->lpaif = devm_ioremap_resource(&pdev->dev, res);
if (IS_ERR((void const __force *)drvdata->lpaif)) { if (IS_ERR((void const __force *)drvdata->lpaif)) {
dev_err(&pdev->dev, "%s() error mapping reg resource: %ld\n", dev_err(&pdev->dev, "error mapping reg resource: %ld\n",
__func__,
PTR_ERR((void const __force *)drvdata->lpaif)); PTR_ERR((void const __force *)drvdata->lpaif));
return PTR_ERR((void const __force *)drvdata->lpaif); return PTR_ERR((void const __force *)drvdata->lpaif);
} }
...@@ -486,8 +467,8 @@ int asoc_qcom_lpass_cpu_platform_probe(struct platform_device *pdev) ...@@ -486,8 +467,8 @@ int asoc_qcom_lpass_cpu_platform_probe(struct platform_device *pdev)
drvdata->lpaif_map = devm_regmap_init_mmio(&pdev->dev, drvdata->lpaif, drvdata->lpaif_map = devm_regmap_init_mmio(&pdev->dev, drvdata->lpaif,
&lpass_cpu_regmap_config); &lpass_cpu_regmap_config);
if (IS_ERR(drvdata->lpaif_map)) { if (IS_ERR(drvdata->lpaif_map)) {
dev_err(&pdev->dev, "%s() error initializing regmap: %ld\n", dev_err(&pdev->dev, "error initializing regmap: %ld\n",
__func__, PTR_ERR(drvdata->lpaif_map)); PTR_ERR(drvdata->lpaif_map));
return PTR_ERR(drvdata->lpaif_map); return PTR_ERR(drvdata->lpaif_map);
} }
...@@ -505,9 +486,10 @@ int asoc_qcom_lpass_cpu_platform_probe(struct platform_device *pdev) ...@@ -505,9 +486,10 @@ int asoc_qcom_lpass_cpu_platform_probe(struct platform_device *pdev)
clk_name); clk_name);
if (IS_ERR(drvdata->mi2s_osr_clk[dai_id])) { if (IS_ERR(drvdata->mi2s_osr_clk[dai_id])) {
dev_warn(&pdev->dev, dev_warn(&pdev->dev,
"%s() error getting mi2s-osr-clk: %ld\n", "error getting optional mi2s-osr-clk: %ld\n",
__func__,
PTR_ERR(drvdata->mi2s_osr_clk[dai_id])); PTR_ERR(drvdata->mi2s_osr_clk[dai_id]));
drvdata->mi2s_osr_clk[dai_id] = NULL;
} }
if (variant->num_dai > 1) if (variant->num_dai > 1)
...@@ -519,8 +501,7 @@ int asoc_qcom_lpass_cpu_platform_probe(struct platform_device *pdev) ...@@ -519,8 +501,7 @@ int asoc_qcom_lpass_cpu_platform_probe(struct platform_device *pdev)
clk_name); clk_name);
if (IS_ERR(drvdata->mi2s_bit_clk[dai_id])) { if (IS_ERR(drvdata->mi2s_bit_clk[dai_id])) {
dev_err(&pdev->dev, dev_err(&pdev->dev,
"%s() error getting mi2s-bit-clk: %ld\n", "error getting mi2s-bit-clk: %ld\n",
__func__,
PTR_ERR(drvdata->mi2s_bit_clk[dai_id])); PTR_ERR(drvdata->mi2s_bit_clk[dai_id]));
return PTR_ERR(drvdata->mi2s_bit_clk[dai_id]); return PTR_ERR(drvdata->mi2s_bit_clk[dai_id]);
} }
...@@ -528,24 +509,23 @@ int asoc_qcom_lpass_cpu_platform_probe(struct platform_device *pdev) ...@@ -528,24 +509,23 @@ int asoc_qcom_lpass_cpu_platform_probe(struct platform_device *pdev)
drvdata->ahbix_clk = devm_clk_get(&pdev->dev, "ahbix-clk"); drvdata->ahbix_clk = devm_clk_get(&pdev->dev, "ahbix-clk");
if (IS_ERR(drvdata->ahbix_clk)) { if (IS_ERR(drvdata->ahbix_clk)) {
dev_err(&pdev->dev, "%s() error getting ahbix-clk: %ld\n", dev_err(&pdev->dev, "error getting ahbix-clk: %ld\n",
__func__, PTR_ERR(drvdata->ahbix_clk)); PTR_ERR(drvdata->ahbix_clk));
return PTR_ERR(drvdata->ahbix_clk); return PTR_ERR(drvdata->ahbix_clk);
} }
ret = clk_set_rate(drvdata->ahbix_clk, LPASS_AHBIX_CLOCK_FREQUENCY); ret = clk_set_rate(drvdata->ahbix_clk, LPASS_AHBIX_CLOCK_FREQUENCY);
if (ret) { if (ret) {
dev_err(&pdev->dev, "%s() error setting rate on ahbix_clk: %d\n", dev_err(&pdev->dev, "error setting rate on ahbix_clk: %d\n",
__func__, ret); ret);
return ret; return ret;
} }
dev_dbg(&pdev->dev, "%s() set ahbix_clk rate to %lu\n", __func__, dev_dbg(&pdev->dev, "set ahbix_clk rate to %lu\n",
clk_get_rate(drvdata->ahbix_clk)); clk_get_rate(drvdata->ahbix_clk));
ret = clk_prepare_enable(drvdata->ahbix_clk); ret = clk_prepare_enable(drvdata->ahbix_clk);
if (ret) { if (ret) {
dev_err(&pdev->dev, "%s() error enabling ahbix_clk: %d\n", dev_err(&pdev->dev, "error enabling ahbix_clk: %d\n", ret);
__func__, ret);
return ret; return ret;
} }
...@@ -554,15 +534,14 @@ int asoc_qcom_lpass_cpu_platform_probe(struct platform_device *pdev) ...@@ -554,15 +534,14 @@ int asoc_qcom_lpass_cpu_platform_probe(struct platform_device *pdev)
variant->dai_driver, variant->dai_driver,
variant->num_dai); variant->num_dai);
if (ret) { if (ret) {
dev_err(&pdev->dev, "%s() error registering cpu driver: %d\n", dev_err(&pdev->dev, "error registering cpu driver: %d\n", ret);
__func__, ret);
goto err_clk; goto err_clk;
} }
ret = asoc_qcom_lpass_platform_register(pdev); ret = asoc_qcom_lpass_platform_register(pdev);
if (ret) { if (ret) {
dev_err(&pdev->dev, "%s() error registering platform driver: %d\n", dev_err(&pdev->dev, "error registering platform driver: %d\n",
__func__, ret); ret);
goto err_clk; goto err_clk;
} }
......
...@@ -89,8 +89,7 @@ static int lpass_platform_pcmops_open(struct snd_pcm_substream *substream) ...@@ -89,8 +89,7 @@ static int lpass_platform_pcmops_open(struct snd_pcm_substream *substream)
LPAIF_DMACTL_REG(v, dma_ch, dir), 0); LPAIF_DMACTL_REG(v, dma_ch, dir), 0);
if (ret) { if (ret) {
dev_err(soc_runtime->dev, dev_err(soc_runtime->dev,
"%s() error writing to rdmactl reg: %d\n", "error writing to rdmactl reg: %d\n", ret);
__func__, ret);
return ret; return ret;
} }
...@@ -103,8 +102,8 @@ static int lpass_platform_pcmops_open(struct snd_pcm_substream *substream) ...@@ -103,8 +102,8 @@ static int lpass_platform_pcmops_open(struct snd_pcm_substream *substream)
ret = snd_pcm_hw_constraint_integer(runtime, ret = snd_pcm_hw_constraint_integer(runtime,
SNDRV_PCM_HW_PARAM_PERIODS); SNDRV_PCM_HW_PARAM_PERIODS);
if (ret < 0) { if (ret < 0) {
dev_err(soc_runtime->dev, "%s() setting constraints failed: %d\n", dev_err(soc_runtime->dev, "setting constraints failed: %d\n",
__func__, ret); ret);
return -EINVAL; return -EINVAL;
} }
...@@ -151,8 +150,8 @@ static int lpass_platform_pcmops_hw_params(struct snd_pcm_substream *substream, ...@@ -151,8 +150,8 @@ static int lpass_platform_pcmops_hw_params(struct snd_pcm_substream *substream,
bitwidth = snd_pcm_format_width(format); bitwidth = snd_pcm_format_width(format);
if (bitwidth < 0) { if (bitwidth < 0) {
dev_err(soc_runtime->dev, "%s() invalid bit width given: %d\n", dev_err(soc_runtime->dev, "invalid bit width given: %d\n",
__func__, bitwidth); bitwidth);
return bitwidth; return bitwidth;
} }
...@@ -177,8 +176,9 @@ static int lpass_platform_pcmops_hw_params(struct snd_pcm_substream *substream, ...@@ -177,8 +176,9 @@ static int lpass_platform_pcmops_hw_params(struct snd_pcm_substream *substream,
regval |= LPAIF_DMACTL_WPSCNT_FOUR; regval |= LPAIF_DMACTL_WPSCNT_FOUR;
break; break;
default: default:
dev_err(soc_runtime->dev, "%s() invalid PCM config given: bw=%d, ch=%u\n", dev_err(soc_runtime->dev,
__func__, bitwidth, channels); "invalid PCM config given: bw=%d, ch=%u\n",
bitwidth, channels);
return -EINVAL; return -EINVAL;
} }
break; break;
...@@ -201,22 +201,23 @@ static int lpass_platform_pcmops_hw_params(struct snd_pcm_substream *substream, ...@@ -201,22 +201,23 @@ static int lpass_platform_pcmops_hw_params(struct snd_pcm_substream *substream,
regval |= LPAIF_DMACTL_WPSCNT_EIGHT; regval |= LPAIF_DMACTL_WPSCNT_EIGHT;
break; break;
default: default:
dev_err(soc_runtime->dev, "%s() invalid PCM config given: bw=%d, ch=%u\n", dev_err(soc_runtime->dev,
__func__, bitwidth, channels); "invalid PCM config given: bw=%d, ch=%u\n",
bitwidth, channels);
return -EINVAL; return -EINVAL;
} }
break; break;
default: default:
dev_err(soc_runtime->dev, "%s() invalid PCM config given: bw=%d, ch=%u\n", dev_err(soc_runtime->dev, "invalid PCM config given: bw=%d, ch=%u\n",
__func__, bitwidth, channels); bitwidth, channels);
return -EINVAL; return -EINVAL;
} }
ret = regmap_write(drvdata->lpaif_map, ret = regmap_write(drvdata->lpaif_map,
LPAIF_DMACTL_REG(v, ch, dir), regval); LPAIF_DMACTL_REG(v, ch, dir), regval);
if (ret) { if (ret) {
dev_err(soc_runtime->dev, "%s() error writing to rdmactl reg: %d\n", dev_err(soc_runtime->dev, "error writing to rdmactl reg: %d\n",
__func__, ret); ret);
return ret; return ret;
} }
...@@ -237,8 +238,8 @@ static int lpass_platform_pcmops_hw_free(struct snd_pcm_substream *substream) ...@@ -237,8 +238,8 @@ static int lpass_platform_pcmops_hw_free(struct snd_pcm_substream *substream)
reg = LPAIF_DMACTL_REG(v, pcm_data->dma_ch, substream->stream); reg = LPAIF_DMACTL_REG(v, pcm_data->dma_ch, substream->stream);
ret = regmap_write(drvdata->lpaif_map, reg, 0); ret = regmap_write(drvdata->lpaif_map, reg, 0);
if (ret) if (ret)
dev_err(soc_runtime->dev, "%s() error writing to rdmactl reg: %d\n", dev_err(soc_runtime->dev, "error writing to rdmactl reg: %d\n",
__func__, ret); ret);
return ret; return ret;
} }
...@@ -260,8 +261,8 @@ static int lpass_platform_pcmops_prepare(struct snd_pcm_substream *substream) ...@@ -260,8 +261,8 @@ static int lpass_platform_pcmops_prepare(struct snd_pcm_substream *substream)
LPAIF_DMABASE_REG(v, ch, dir), LPAIF_DMABASE_REG(v, ch, dir),
runtime->dma_addr); runtime->dma_addr);
if (ret) { if (ret) {
dev_err(soc_runtime->dev, "%s() error writing to rdmabase reg: %d\n", dev_err(soc_runtime->dev, "error writing to rdmabase reg: %d\n",
__func__, ret); ret);
return ret; return ret;
} }
...@@ -269,8 +270,8 @@ static int lpass_platform_pcmops_prepare(struct snd_pcm_substream *substream) ...@@ -269,8 +270,8 @@ static int lpass_platform_pcmops_prepare(struct snd_pcm_substream *substream)
LPAIF_DMABUFF_REG(v, ch, dir), LPAIF_DMABUFF_REG(v, ch, dir),
(snd_pcm_lib_buffer_bytes(substream) >> 2) - 1); (snd_pcm_lib_buffer_bytes(substream) >> 2) - 1);
if (ret) { if (ret) {
dev_err(soc_runtime->dev, "%s() error writing to rdmabuff reg: %d\n", dev_err(soc_runtime->dev, "error writing to rdmabuff reg: %d\n",
__func__, ret); ret);
return ret; return ret;
} }
...@@ -278,8 +279,8 @@ static int lpass_platform_pcmops_prepare(struct snd_pcm_substream *substream) ...@@ -278,8 +279,8 @@ static int lpass_platform_pcmops_prepare(struct snd_pcm_substream *substream)
LPAIF_DMAPER_REG(v, ch, dir), LPAIF_DMAPER_REG(v, ch, dir),
(snd_pcm_lib_period_bytes(substream) >> 2) - 1); (snd_pcm_lib_period_bytes(substream) >> 2) - 1);
if (ret) { if (ret) {
dev_err(soc_runtime->dev, "%s() error writing to rdmaper reg: %d\n", dev_err(soc_runtime->dev, "error writing to rdmaper reg: %d\n",
__func__, ret); ret);
return ret; return ret;
} }
...@@ -287,8 +288,8 @@ static int lpass_platform_pcmops_prepare(struct snd_pcm_substream *substream) ...@@ -287,8 +288,8 @@ static int lpass_platform_pcmops_prepare(struct snd_pcm_substream *substream)
LPAIF_DMACTL_REG(v, ch, dir), LPAIF_DMACTL_REG(v, ch, dir),
LPAIF_DMACTL_ENABLE_MASK, LPAIF_DMACTL_ENABLE_ON); LPAIF_DMACTL_ENABLE_MASK, LPAIF_DMACTL_ENABLE_ON);
if (ret) { if (ret) {
dev_err(soc_runtime->dev, "%s() error writing to rdmactl reg: %d\n", dev_err(soc_runtime->dev, "error writing to rdmactl reg: %d\n",
__func__, ret); ret);
return ret; return ret;
} }
...@@ -317,8 +318,8 @@ static int lpass_platform_pcmops_trigger(struct snd_pcm_substream *substream, ...@@ -317,8 +318,8 @@ static int lpass_platform_pcmops_trigger(struct snd_pcm_substream *substream,
LPAIF_IRQCLEAR_REG(v, LPAIF_IRQ_PORT_HOST), LPAIF_IRQCLEAR_REG(v, LPAIF_IRQ_PORT_HOST),
LPAIF_IRQ_ALL(ch)); LPAIF_IRQ_ALL(ch));
if (ret) { if (ret) {
dev_err(soc_runtime->dev, "%s() error writing to irqclear reg: %d\n", dev_err(soc_runtime->dev,
__func__, ret); "error writing to irqclear reg: %d\n", ret);
return ret; return ret;
} }
...@@ -327,8 +328,8 @@ static int lpass_platform_pcmops_trigger(struct snd_pcm_substream *substream, ...@@ -327,8 +328,8 @@ static int lpass_platform_pcmops_trigger(struct snd_pcm_substream *substream,
LPAIF_IRQ_ALL(ch), LPAIF_IRQ_ALL(ch),
LPAIF_IRQ_ALL(ch)); LPAIF_IRQ_ALL(ch));
if (ret) { if (ret) {
dev_err(soc_runtime->dev, "%s() error writing to irqen reg: %d\n", dev_err(soc_runtime->dev,
__func__, ret); "error writing to irqen reg: %d\n", ret);
return ret; return ret;
} }
...@@ -337,8 +338,8 @@ static int lpass_platform_pcmops_trigger(struct snd_pcm_substream *substream, ...@@ -337,8 +338,8 @@ static int lpass_platform_pcmops_trigger(struct snd_pcm_substream *substream,
LPAIF_DMACTL_ENABLE_MASK, LPAIF_DMACTL_ENABLE_MASK,
LPAIF_DMACTL_ENABLE_ON); LPAIF_DMACTL_ENABLE_ON);
if (ret) { if (ret) {
dev_err(soc_runtime->dev, "%s() error writing to rdmactl reg: %d\n", dev_err(soc_runtime->dev,
__func__, ret); "error writing to rdmactl reg: %d\n", ret);
return ret; return ret;
} }
break; break;
...@@ -350,8 +351,8 @@ static int lpass_platform_pcmops_trigger(struct snd_pcm_substream *substream, ...@@ -350,8 +351,8 @@ static int lpass_platform_pcmops_trigger(struct snd_pcm_substream *substream,
LPAIF_DMACTL_ENABLE_MASK, LPAIF_DMACTL_ENABLE_MASK,
LPAIF_DMACTL_ENABLE_OFF); LPAIF_DMACTL_ENABLE_OFF);
if (ret) { if (ret) {
dev_err(soc_runtime->dev, "%s() error writing to rdmactl reg: %d\n", dev_err(soc_runtime->dev,
__func__, ret); "error writing to rdmactl reg: %d\n", ret);
return ret; return ret;
} }
...@@ -359,8 +360,8 @@ static int lpass_platform_pcmops_trigger(struct snd_pcm_substream *substream, ...@@ -359,8 +360,8 @@ static int lpass_platform_pcmops_trigger(struct snd_pcm_substream *substream,
LPAIF_IRQEN_REG(v, LPAIF_IRQ_PORT_HOST), LPAIF_IRQEN_REG(v, LPAIF_IRQ_PORT_HOST),
LPAIF_IRQ_ALL(ch), 0); LPAIF_IRQ_ALL(ch), 0);
if (ret) { if (ret) {
dev_err(soc_runtime->dev, "%s() error writing to irqen reg: %d\n", dev_err(soc_runtime->dev,
__func__, ret); "error writing to irqen reg: %d\n", ret);
return ret; return ret;
} }
break; break;
...@@ -386,16 +387,16 @@ static snd_pcm_uframes_t lpass_platform_pcmops_pointer( ...@@ -386,16 +387,16 @@ static snd_pcm_uframes_t lpass_platform_pcmops_pointer(
ret = regmap_read(drvdata->lpaif_map, ret = regmap_read(drvdata->lpaif_map,
LPAIF_DMABASE_REG(v, ch, dir), &base_addr); LPAIF_DMABASE_REG(v, ch, dir), &base_addr);
if (ret) { if (ret) {
dev_err(soc_runtime->dev, "%s() error reading from rdmabase reg: %d\n", dev_err(soc_runtime->dev,
__func__, ret); "error reading from rdmabase reg: %d\n", ret);
return ret; return ret;
} }
ret = regmap_read(drvdata->lpaif_map, ret = regmap_read(drvdata->lpaif_map,
LPAIF_DMACURR_REG(v, ch, dir), &curr_addr); LPAIF_DMACURR_REG(v, ch, dir), &curr_addr);
if (ret) { if (ret) {
dev_err(soc_runtime->dev, "%s() error reading from rdmacurr reg: %d\n", dev_err(soc_runtime->dev,
__func__, ret); "error reading from rdmacurr reg: %d\n", ret);
return ret; return ret;
} }
...@@ -439,8 +440,8 @@ static irqreturn_t lpass_dma_interrupt_handler( ...@@ -439,8 +440,8 @@ static irqreturn_t lpass_dma_interrupt_handler(
LPAIF_IRQCLEAR_REG(v, LPAIF_IRQ_PORT_HOST), LPAIF_IRQCLEAR_REG(v, LPAIF_IRQ_PORT_HOST),
LPAIF_IRQ_PER(chan)); LPAIF_IRQ_PER(chan));
if (rv) { if (rv) {
dev_err(soc_runtime->dev, "%s() error writing to irqclear reg: %d\n", dev_err(soc_runtime->dev,
__func__, rv); "error writing to irqclear reg: %d\n", rv);
return IRQ_NONE; return IRQ_NONE;
} }
snd_pcm_period_elapsed(substream); snd_pcm_period_elapsed(substream);
...@@ -452,11 +453,11 @@ static irqreturn_t lpass_dma_interrupt_handler( ...@@ -452,11 +453,11 @@ static irqreturn_t lpass_dma_interrupt_handler(
LPAIF_IRQCLEAR_REG(v, LPAIF_IRQ_PORT_HOST), LPAIF_IRQCLEAR_REG(v, LPAIF_IRQ_PORT_HOST),
LPAIF_IRQ_XRUN(chan)); LPAIF_IRQ_XRUN(chan));
if (rv) { if (rv) {
dev_err(soc_runtime->dev, "%s() error writing to irqclear reg: %d\n", dev_err(soc_runtime->dev,
__func__, rv); "error writing to irqclear reg: %d\n", rv);
return IRQ_NONE; return IRQ_NONE;
} }
dev_warn(soc_runtime->dev, "%s() xrun warning\n", __func__); dev_warn(soc_runtime->dev, "xrun warning\n");
snd_pcm_stop(substream, SNDRV_PCM_STATE_XRUN); snd_pcm_stop(substream, SNDRV_PCM_STATE_XRUN);
ret = IRQ_HANDLED; ret = IRQ_HANDLED;
} }
...@@ -466,11 +467,11 @@ static irqreturn_t lpass_dma_interrupt_handler( ...@@ -466,11 +467,11 @@ static irqreturn_t lpass_dma_interrupt_handler(
LPAIF_IRQCLEAR_REG(v, LPAIF_IRQ_PORT_HOST), LPAIF_IRQCLEAR_REG(v, LPAIF_IRQ_PORT_HOST),
LPAIF_IRQ_ERR(chan)); LPAIF_IRQ_ERR(chan));
if (rv) { if (rv) {
dev_err(soc_runtime->dev, "%s() error writing to irqclear reg: %d\n", dev_err(soc_runtime->dev,
__func__, rv); "error writing to irqclear reg: %d\n", rv);
return IRQ_NONE; return IRQ_NONE;
} }
dev_err(soc_runtime->dev, "%s() bus access error\n", __func__); dev_err(soc_runtime->dev, "bus access error\n");
snd_pcm_stop(substream, SNDRV_PCM_STATE_DISCONNECTED); snd_pcm_stop(substream, SNDRV_PCM_STATE_DISCONNECTED);
ret = IRQ_HANDLED; ret = IRQ_HANDLED;
} }
...@@ -488,8 +489,7 @@ static irqreturn_t lpass_platform_lpaif_irq(int irq, void *data) ...@@ -488,8 +489,7 @@ static irqreturn_t lpass_platform_lpaif_irq(int irq, void *data)
rv = regmap_read(drvdata->lpaif_map, rv = regmap_read(drvdata->lpaif_map,
LPAIF_IRQSTAT_REG(v, LPAIF_IRQ_PORT_HOST), &irqs); LPAIF_IRQSTAT_REG(v, LPAIF_IRQ_PORT_HOST), &irqs);
if (rv) { if (rv) {
pr_err("%s() error reading from irqstat reg: %d\n", pr_err("error reading from irqstat reg: %d\n", rv);
__func__, rv);
return IRQ_NONE; return IRQ_NONE;
} }
...@@ -571,8 +571,8 @@ int asoc_qcom_lpass_platform_register(struct platform_device *pdev) ...@@ -571,8 +571,8 @@ int asoc_qcom_lpass_platform_register(struct platform_device *pdev)
drvdata->lpaif_irq = platform_get_irq_byname(pdev, "lpass-irq-lpaif"); drvdata->lpaif_irq = platform_get_irq_byname(pdev, "lpass-irq-lpaif");
if (drvdata->lpaif_irq < 0) { if (drvdata->lpaif_irq < 0) {
dev_err(&pdev->dev, "%s() error getting irq handle: %d\n", dev_err(&pdev->dev, "error getting irq handle: %d\n",
__func__, drvdata->lpaif_irq); drvdata->lpaif_irq);
return -ENODEV; return -ENODEV;
} }
...@@ -580,8 +580,7 @@ int asoc_qcom_lpass_platform_register(struct platform_device *pdev) ...@@ -580,8 +580,7 @@ int asoc_qcom_lpass_platform_register(struct platform_device *pdev)
ret = regmap_write(drvdata->lpaif_map, ret = regmap_write(drvdata->lpaif_map,
LPAIF_IRQEN_REG(v, LPAIF_IRQ_PORT_HOST), 0); LPAIF_IRQEN_REG(v, LPAIF_IRQ_PORT_HOST), 0);
if (ret) { if (ret) {
dev_err(&pdev->dev, "%s() error writing to irqen reg: %d\n", dev_err(&pdev->dev, "error writing to irqen reg: %d\n", ret);
__func__, ret);
return ret; return ret;
} }
...@@ -589,8 +588,7 @@ int asoc_qcom_lpass_platform_register(struct platform_device *pdev) ...@@ -589,8 +588,7 @@ int asoc_qcom_lpass_platform_register(struct platform_device *pdev)
lpass_platform_lpaif_irq, IRQF_TRIGGER_RISING, lpass_platform_lpaif_irq, IRQF_TRIGGER_RISING,
"lpass-irq-lpaif", drvdata); "lpass-irq-lpaif", drvdata);
if (ret) { if (ret) {
dev_err(&pdev->dev, "%s() irq request failed: %d\n", dev_err(&pdev->dev, "irq request failed: %d\n", ret);
__func__, ret);
return ret; return ret;
} }
......
...@@ -36,8 +36,7 @@ static int storm_ops_hw_params(struct snd_pcm_substream *substream, ...@@ -36,8 +36,7 @@ static int storm_ops_hw_params(struct snd_pcm_substream *substream,
bitwidth = snd_pcm_format_width(format); bitwidth = snd_pcm_format_width(format);
if (bitwidth < 0) { if (bitwidth < 0) {
dev_err(card->dev, "%s() invalid bit width given: %d\n", dev_err(card->dev, "invalid bit width given: %d\n", bitwidth);
__func__, bitwidth);
return bitwidth; return bitwidth;
} }
...@@ -50,8 +49,8 @@ static int storm_ops_hw_params(struct snd_pcm_substream *substream, ...@@ -50,8 +49,8 @@ static int storm_ops_hw_params(struct snd_pcm_substream *substream,
ret = snd_soc_dai_set_sysclk(soc_runtime->cpu_dai, 0, sysclk_freq, 0); ret = snd_soc_dai_set_sysclk(soc_runtime->cpu_dai, 0, sysclk_freq, 0);
if (ret) { if (ret) {
dev_err(card->dev, "%s() error setting sysclk to %u: %d\n", dev_err(card->dev, "error setting sysclk to %u: %d\n",
__func__, sysclk_freq, ret); sysclk_freq, ret);
return ret; return ret;
} }
...@@ -76,16 +75,14 @@ static int storm_parse_of(struct snd_soc_card *card) ...@@ -76,16 +75,14 @@ static int storm_parse_of(struct snd_soc_card *card)
dai_link->cpu_of_node = of_parse_phandle(np, "cpu", 0); dai_link->cpu_of_node = of_parse_phandle(np, "cpu", 0);
if (!dai_link->cpu_of_node) { if (!dai_link->cpu_of_node) {
dev_err(card->dev, "%s() error getting cpu phandle\n", dev_err(card->dev, "error getting cpu phandle\n");
__func__);
return -EINVAL; return -EINVAL;
} }
dai_link->platform_of_node = dai_link->cpu_of_node; dai_link->platform_of_node = dai_link->cpu_of_node;
dai_link->codec_of_node = of_parse_phandle(np, "codec", 0); dai_link->codec_of_node = of_parse_phandle(np, "codec", 0);
if (!dai_link->codec_of_node) { if (!dai_link->codec_of_node) {
dev_err(card->dev, "%s() error getting codec phandle\n", dev_err(card->dev, "error getting codec phandle\n");
__func__);
return -EINVAL; return -EINVAL;
} }
...@@ -106,8 +103,7 @@ static int storm_platform_probe(struct platform_device *pdev) ...@@ -106,8 +103,7 @@ static int storm_platform_probe(struct platform_device *pdev)
ret = snd_soc_of_parse_card_name(card, "qcom,model"); ret = snd_soc_of_parse_card_name(card, "qcom,model");
if (ret) { if (ret) {
dev_err(&pdev->dev, "%s() error parsing card name: %d\n", dev_err(&pdev->dev, "error parsing card name: %d\n", ret);
__func__, ret);
return ret; return ret;
} }
...@@ -116,15 +112,13 @@ static int storm_platform_probe(struct platform_device *pdev) ...@@ -116,15 +112,13 @@ static int storm_platform_probe(struct platform_device *pdev)
ret = storm_parse_of(card); ret = storm_parse_of(card);
if (ret) { if (ret) {
dev_err(&pdev->dev, "%s() error resolving dai links: %d\n", dev_err(&pdev->dev, "error resolving dai links: %d\n", ret);
__func__, ret);
return ret; return ret;
} }
ret = devm_snd_soc_register_card(&pdev->dev, card); ret = devm_snd_soc_register_card(&pdev->dev, card);
if (ret) if (ret)
dev_err(&pdev->dev, "%s() error registering soundcard: %d\n", dev_err(&pdev->dev, "error registering soundcard: %d\n", ret);
__func__, ret);
return ret; return ret;
......
...@@ -42,6 +42,15 @@ config SND_SOC_ROCKCHIP_RT5645 ...@@ -42,6 +42,15 @@ config SND_SOC_ROCKCHIP_RT5645
Say Y or M here if you want to add support for SoC audio on Rockchip Say Y or M here if you want to add support for SoC audio on Rockchip
boards using the RT5645/RT5650 codec, such as Veyron. boards using the RT5645/RT5650 codec, such as Veyron.
config SND_SOC_RK3288_HDMI_ANALOG
tristate "ASoC support multiple codecs for Rockchip RK3288 boards"
depends on SND_SOC_ROCKCHIP && I2C && GPIOLIB && CLKDEV_LOOKUP
select SND_SOC_ROCKCHIP_I2S
select SND_SOC_HDMI_CODEC
help
Say Y or M here if you want to add support for SoC audio on Rockchip
RK3288 boards using an analog output and the built-in HDMI audio.
config SND_SOC_RK3399_GRU_SOUND config SND_SOC_RK3399_GRU_SOUND
tristate "ASoC support multiple codecs for Rockchip RK3399 GRU boards" tristate "ASoC support multiple codecs for Rockchip RK3399 GRU boards"
depends on SND_SOC_ROCKCHIP && I2C && GPIOLIB && CLKDEV_LOOKUP && SPI depends on SND_SOC_ROCKCHIP && I2C && GPIOLIB && CLKDEV_LOOKUP && SPI
......
...@@ -7,8 +7,10 @@ obj-$(CONFIG_SND_SOC_ROCKCHIP_SPDIF) += snd-soc-rockchip-spdif.o ...@@ -7,8 +7,10 @@ obj-$(CONFIG_SND_SOC_ROCKCHIP_SPDIF) += snd-soc-rockchip-spdif.o
snd-soc-rockchip-max98090-objs := rockchip_max98090.o snd-soc-rockchip-max98090-objs := rockchip_max98090.o
snd-soc-rockchip-rt5645-objs := rockchip_rt5645.o snd-soc-rockchip-rt5645-objs := rockchip_rt5645.o
snd-soc-rk3288-hdmi-analog-objs := rk3288_hdmi_analog.o
snd-soc-rk3399-gru-sound-objs := rk3399_gru_sound.o snd-soc-rk3399-gru-sound-objs := rk3399_gru_sound.o
obj-$(CONFIG_SND_SOC_ROCKCHIP_MAX98090) += snd-soc-rockchip-max98090.o obj-$(CONFIG_SND_SOC_ROCKCHIP_MAX98090) += snd-soc-rockchip-max98090.o
obj-$(CONFIG_SND_SOC_ROCKCHIP_RT5645) += snd-soc-rockchip-rt5645.o obj-$(CONFIG_SND_SOC_ROCKCHIP_RT5645) += snd-soc-rockchip-rt5645.o
obj-$(CONFIG_SND_SOC_RK3288_HDMI_ANALOG) += snd-soc-rk3288-hdmi-analog.o
obj-$(CONFIG_SND_SOC_RK3399_GRU_SOUND) += snd-soc-rk3399-gru-sound.o obj-$(CONFIG_SND_SOC_RK3399_GRU_SOUND) += snd-soc-rk3399-gru-sound.o
/*
* Rockchip machine ASoC driver for RK3288 boards that have an HDMI and analog
* audio output
*
* Copyright (c) 2016, Collabora Ltd.
*
* Authors: Sjoerd Simons <sjoerd.simons@collabora.com>,
* Romain Perier <romain.perier@collabora.com>
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
#include <linux/module.h>
#include <linux/platform_device.h>
#include <linux/slab.h>
#include <linux/gpio.h>
#include <linux/of_gpio.h>
#include <sound/core.h>
#include <sound/jack.h>
#include <sound/pcm.h>
#include <sound/pcm_params.h>
#include <sound/soc.h>
#include <sound/soc-dapm.h>
#include "rockchip_i2s.h"
#define DRV_NAME "rk3288-snd-hdmi-analog"
struct rk_drvdata {
int gpio_hp_en;
int gpio_hp_det;
};
static int rk_hp_power(struct snd_soc_dapm_widget *w,
struct snd_kcontrol *k, int event)
{
struct rk_drvdata *machine = snd_soc_card_get_drvdata(w->dapm->card);
if (!gpio_is_valid(machine->gpio_hp_en))
return 0;
gpio_set_value_cansleep(machine->gpio_hp_en,
SND_SOC_DAPM_EVENT_ON(event));
return 0;
}
static struct snd_soc_jack headphone_jack;
static struct snd_soc_jack_pin headphone_jack_pins[] = {
{
.pin = "Analog",
.mask = SND_JACK_HEADPHONE
},
};
static const struct snd_soc_dapm_widget rk_dapm_widgets[] = {
SND_SOC_DAPM_HP("Analog", rk_hp_power),
SND_SOC_DAPM_LINE("HDMI", NULL),
};
static const struct snd_kcontrol_new rk_mc_controls[] = {
SOC_DAPM_PIN_SWITCH("Analog"),
SOC_DAPM_PIN_SWITCH("HDMI"),
};
static int rk_hw_params(struct snd_pcm_substream *substream,
struct snd_pcm_hw_params *params)
{
int ret = 0;
struct snd_soc_pcm_runtime *rtd = substream->private_data;
struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
struct snd_soc_dai *codec_dai = rtd->codec_dai;
int mclk;
switch (params_rate(params)) {
case 8000:
case 16000:
case 24000:
case 32000:
case 48000:
case 64000:
case 96000:
mclk = 12288000;
break;
case 11025:
case 22050:
case 44100:
case 88200:
mclk = 11289600;
break;
default:
return -EINVAL;
}
ret = snd_soc_dai_set_sysclk(cpu_dai, 0, mclk,
SND_SOC_CLOCK_OUT);
if (ret && ret != -ENOTSUPP) {
dev_err(codec_dai->dev, "Can't set cpu clock %d\n", ret);
return ret;
}
ret = snd_soc_dai_set_sysclk(codec_dai, 0, mclk,
SND_SOC_CLOCK_IN);
if (ret && ret != -ENOTSUPP) {
dev_err(codec_dai->dev, "Can't set codec clock %d\n", ret);
return ret;
}
return 0;
}
static struct snd_soc_jack_gpio rk_hp_jack_gpio = {
.name = "Headphone detection",
.report = SND_JACK_HEADPHONE,
.debounce_time = 150
};
static int rk_init(struct snd_soc_pcm_runtime *runtime)
{
struct rk_drvdata *machine = snd_soc_card_get_drvdata(runtime->card);
/* Enable Headset Jack detection */
if (gpio_is_valid(machine->gpio_hp_det)) {
snd_soc_card_jack_new(runtime->card, "Headphone Jack",
SND_JACK_HEADPHONE, &headphone_jack,
headphone_jack_pins,
ARRAY_SIZE(headphone_jack_pins));
rk_hp_jack_gpio.gpio = machine->gpio_hp_det;
snd_soc_jack_add_gpios(&headphone_jack, 1, &rk_hp_jack_gpio);
}
return 0;
}
static struct snd_soc_ops rk_ops = {
.hw_params = rk_hw_params,
};
static struct snd_soc_dai_link_component rk_codecs[] = {
{ },
{
.name = "hdmi-audio-codec.2.auto",
.dai_name = "hdmi-hifi.0",
},
};
static struct snd_soc_dai_link rk_dailink = {
.name = "Codecs",
.stream_name = "Audio",
.init = rk_init,
.ops = &rk_ops,
.codecs = rk_codecs,
.num_codecs = ARRAY_SIZE(rk_codecs),
/* Set codecs as slave */
.dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF |
SND_SOC_DAIFMT_CBS_CFS,
};
static struct snd_soc_card snd_soc_card_rk = {
.name = "ROCKCHIP-I2S",
.dai_link = &rk_dailink,
.num_links = 1,
.num_aux_devs = 0,
.dapm_widgets = rk_dapm_widgets,
.num_dapm_widgets = ARRAY_SIZE(rk_dapm_widgets),
.controls = rk_mc_controls,
.num_controls = ARRAY_SIZE(rk_mc_controls),
};
static int snd_rk_mc_probe(struct platform_device *pdev)
{
int ret = 0;
struct snd_soc_card *card = &snd_soc_card_rk;
struct device_node *np = pdev->dev.of_node;
struct rk_drvdata *machine;
struct of_phandle_args args;
machine = devm_kzalloc(&pdev->dev, sizeof(struct rk_drvdata),
GFP_KERNEL);
if (!machine)
return -ENOMEM;
card->dev = &pdev->dev;
machine->gpio_hp_det = of_get_named_gpio(np,
"rockchip,hp-det-gpios", 0);
if (!gpio_is_valid(machine->gpio_hp_det) && machine->gpio_hp_det != -ENODEV)
return machine->gpio_hp_det;
machine->gpio_hp_en = of_get_named_gpio(np,
"rockchip,hp-en-gpios", 0);
if (!gpio_is_valid(machine->gpio_hp_en) && machine->gpio_hp_en != -ENODEV)
return machine->gpio_hp_en;
if (gpio_is_valid(machine->gpio_hp_en)) {
ret = devm_gpio_request_one(&pdev->dev, machine->gpio_hp_en,
GPIOF_OUT_INIT_LOW, "hp_en");
if (ret) {
dev_err(card->dev, "cannot get hp_en gpio\n");
return ret;
}
}
ret = snd_soc_of_parse_card_name(card, "rockchip,model");
if (ret) {
dev_err(card->dev, "SoC parse card name failed %d\n", ret);
return ret;
}
rk_dailink.codecs[0].of_node = of_parse_phandle(np,
"rockchip,audio-codec",
0);
if (!rk_dailink.codecs[0].of_node) {
dev_err(&pdev->dev,
"Property 'rockchip,audio-codec' missing or invalid\n");
return -EINVAL;
}
ret = of_parse_phandle_with_fixed_args(np, "rockchip,audio-codec",
0, 0, &args);
if (ret) {
dev_err(&pdev->dev,
"Unable to parse property 'rockchip,audio-codec'\n");
return ret;
}
ret = snd_soc_get_dai_name(&args, &rk_dailink.codecs[0].dai_name);
if (ret) {
dev_err(&pdev->dev, "Unable to get codec_dai_name\n");
return ret;
}
rk_dailink.cpu_of_node = of_parse_phandle(np, "rockchip,i2s-controller",
0);
if (!rk_dailink.cpu_of_node) {
dev_err(&pdev->dev,
"Property 'rockchip,i2s-controller' missing or invalid\n");
return -EINVAL;
}
rk_dailink.platform_of_node = rk_dailink.cpu_of_node;
ret = snd_soc_of_parse_audio_routing(card, "rockchip,routing");
if (ret) {
dev_err(&pdev->dev,
"Unable to parse 'rockchip,routing' property\n");
return ret;
}
snd_soc_card_set_drvdata(card, machine);
ret = devm_snd_soc_register_card(&pdev->dev, card);
if (ret == -EPROBE_DEFER)
return -EPROBE_DEFER;
if (ret) {
dev_err(&pdev->dev,
"Soc register card failed %d\n", ret);
return ret;
}
platform_set_drvdata(pdev, card);
return ret;
}
static const struct of_device_id rockchip_sound_of_match[] = {
{ .compatible = "rockchip,rk3288-hdmi-analog", },
{},
};
MODULE_DEVICE_TABLE(of, rockchip_sound_of_match);
static struct platform_driver rockchip_sound_driver = {
.probe = snd_rk_mc_probe,
.driver = {
.name = DRV_NAME,
.owner = THIS_MODULE,
.pm = &snd_soc_pm_ops,
.of_match_table = rockchip_sound_of_match,
},
};
module_platform_driver(rockchip_sound_driver);
MODULE_AUTHOR("Sjoerd Simons <sjoerd.simons@collabora.com>");
MODULE_DESCRIPTION("Rockchip RK3288 machine ASoC driver");
MODULE_LICENSE("GPL v2");
MODULE_ALIAS("platform:" DRV_NAME);
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment