summaryrefslogtreecommitdiffstats
path: root/sound/soc/sti/sti_uniperif.c
diff options
context:
space:
mode:
Diffstat (limited to 'sound/soc/sti/sti_uniperif.c')
-rw-r--r--sound/soc/sti/sti_uniperif.c43
1 files changed, 35 insertions, 8 deletions
diff --git a/sound/soc/sti/sti_uniperif.c b/sound/soc/sti/sti_uniperif.c
index 549fac3..98eb205 100644
--- a/sound/soc/sti/sti_uniperif.c
+++ b/sound/soc/sti/sti_uniperif.c
@@ -7,6 +7,7 @@
#include <linux/module.h>
#include <linux/pinctrl/consumer.h>
+#include <linux/delay.h>
#include "uniperif.h"
@@ -97,6 +98,28 @@ static const struct of_device_id snd_soc_sti_match[] = {
{},
};
+int sti_uniperiph_reset(struct uniperif *uni)
+{
+ int count = 10;
+
+ /* Reset uniperipheral uni */
+ SET_UNIPERIF_SOFT_RST_SOFT_RST(uni);
+
+ if (uni->ver < SND_ST_UNIPERIF_VERSION_UNI_PLR_TOP_1_0) {
+ while (GET_UNIPERIF_SOFT_RST_SOFT_RST(uni) && count) {
+ udelay(5);
+ count--;
+ }
+ }
+
+ if (!count) {
+ dev_err(uni->dev, "Failed to reset uniperif\n");
+ return -EIO;
+ }
+
+ return 0;
+}
+
int sti_uniperiph_set_tdm_slot(struct snd_soc_dai *dai, unsigned int tx_mask,
unsigned int rx_mask, int slots,
int slot_width)
@@ -293,7 +316,7 @@ static int sti_uniperiph_dai_suspend(struct snd_soc_dai *dai)
/* The uniperipheral should be in stopped state */
if (uni->state != UNIPERIF_STATE_STOPPED) {
- dev_err(uni->dev, "%s: invalid uni state( %d)",
+ dev_err(uni->dev, "%s: invalid uni state( %d)\n",
__func__, (int)uni->state);
return -EBUSY;
}
@@ -301,7 +324,7 @@ static int sti_uniperiph_dai_suspend(struct snd_soc_dai *dai)
/* Pinctrl: switch pinstate to sleep */
ret = pinctrl_pm_select_sleep_state(uni->dev);
if (ret)
- dev_err(uni->dev, "%s: failed to select pinctrl state",
+ dev_err(uni->dev, "%s: failed to select pinctrl state\n",
__func__);
return ret;
@@ -322,7 +345,7 @@ static int sti_uniperiph_dai_resume(struct snd_soc_dai *dai)
/* pinctrl: switch pinstate to default */
ret = pinctrl_pm_select_default_state(uni->dev);
if (ret)
- dev_err(uni->dev, "%s: failed to select pinctrl state",
+ dev_err(uni->dev, "%s: failed to select pinctrl state\n",
__func__);
return ret;
@@ -366,11 +389,12 @@ static int sti_uniperiph_cpu_dai_of(struct device_node *node,
const struct of_device_id *of_id;
const struct sti_uniperiph_dev_data *dev_data;
const char *mode;
+ int ret;
/* Populate data structure depending on compatibility */
of_id = of_match_node(snd_soc_sti_match, node);
if (!of_id->data) {
- dev_err(dev, "data associated to device is missing");
+ dev_err(dev, "data associated to device is missing\n");
return -EINVAL;
}
dev_data = (struct sti_uniperiph_dev_data *)of_id->data;
@@ -389,7 +413,7 @@ static int sti_uniperiph_cpu_dai_of(struct device_node *node,
uni->mem_region = platform_get_resource(priv->pdev, IORESOURCE_MEM, 0);
if (!uni->mem_region) {
- dev_err(dev, "Failed to get memory resource");
+ dev_err(dev, "Failed to get memory resource\n");
return -ENODEV;
}
@@ -403,7 +427,7 @@ static int sti_uniperiph_cpu_dai_of(struct device_node *node,
uni->irq = platform_get_irq(priv->pdev, 0);
if (uni->irq < 0) {
- dev_err(dev, "Failed to get IRQ resource");
+ dev_err(dev, "Failed to get IRQ resource\n");
return -ENXIO;
}
@@ -421,12 +445,15 @@ static int sti_uniperiph_cpu_dai_of(struct device_node *node,
dai_data->stream = dev_data->stream;
if (priv->dai_data.stream == SNDRV_PCM_STREAM_PLAYBACK) {
- uni_player_init(priv->pdev, uni);
+ ret = uni_player_init(priv->pdev, uni);
stream = &dai->playback;
} else {
- uni_reader_init(priv->pdev, uni);
+ ret = uni_reader_init(priv->pdev, uni);
stream = &dai->capture;
}
+ if (ret < 0)
+ return ret;
+
dai->ops = uni->dai_ops;
stream->stream_name = dai->name;
OpenPOWER on IntegriCloud