Commit 4c88f89f authored by Arnaud Pouliquen's avatar Arnaud Pouliquen Committed by Mark Brown

ASoC: sti: reset refactoring

Reset is common to player and reader, migrate function in sti_uniperif.c
Signed-off-by: default avatarArnaud Pouliquen <arnaud.pouliquen@st.com>
Signed-off-by: default avatarMark Brown <broonie@kernel.org>
parent 748abba8
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
#include <linux/module.h> #include <linux/module.h>
#include <linux/pinctrl/consumer.h> #include <linux/pinctrl/consumer.h>
#include <linux/delay.h>
#include "uniperif.h" #include "uniperif.h"
...@@ -97,6 +98,28 @@ static const struct of_device_id snd_soc_sti_match[] = { ...@@ -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, int sti_uniperiph_set_tdm_slot(struct snd_soc_dai *dai, unsigned int tx_mask,
unsigned int rx_mask, int slots, unsigned int rx_mask, int slots,
int slot_width) int slot_width)
......
...@@ -1397,6 +1397,8 @@ static inline int sti_uniperiph_get_unip_tdm_frame_size(struct uniperif *uni) ...@@ -1397,6 +1397,8 @@ static inline int sti_uniperiph_get_unip_tdm_frame_size(struct uniperif *uni)
return (uni->tdm_slot.slots * uni->tdm_slot.slot_width / 8); return (uni->tdm_slot.slots * uni->tdm_slot.slot_width / 8);
} }
int sti_uniperiph_reset(struct uniperif *uni);
int sti_uniperiph_set_tdm_slot(struct snd_soc_dai *dai, unsigned int tx_mask, int sti_uniperiph_set_tdm_slot(struct snd_soc_dai *dai, unsigned int tx_mask,
unsigned int rx_mask, int slots, unsigned int rx_mask, int slots,
int slot_width); int slot_width);
......
...@@ -6,7 +6,6 @@ ...@@ -6,7 +6,6 @@
*/ */
#include <linux/clk.h> #include <linux/clk.h>
#include <linux/delay.h>
#include <linux/io.h> #include <linux/io.h>
#include <linux/mfd/syscon.h> #include <linux/mfd/syscon.h>
...@@ -55,25 +54,6 @@ static const struct snd_pcm_hardware uni_player_pcm_hw = { ...@@ -55,25 +54,6 @@ static const struct snd_pcm_hardware uni_player_pcm_hw = {
.buffer_bytes_max = 256 * PAGE_SIZE .buffer_bytes_max = 256 * PAGE_SIZE
}; };
static inline int reset_player(struct uniperif *player)
{
int count = 10;
if (player->ver < SND_ST_UNIPERIF_VERSION_UNI_PLR_TOP_1_0) {
while (GET_UNIPERIF_SOFT_RST_SOFT_RST(player) && count) {
udelay(5);
count--;
}
}
if (!count) {
dev_err(player->dev, "Failed to reset uniperif\n");
return -EIO;
}
return 0;
}
/* /*
* uni_player_irq_handler * uni_player_irq_handler
* In case of error audio stream is stopped; stop action is protected via PCM * In case of error audio stream is stopped; stop action is protected via PCM
...@@ -858,10 +838,8 @@ static int uni_player_prepare(struct snd_pcm_substream *substream, ...@@ -858,10 +838,8 @@ static int uni_player_prepare(struct snd_pcm_substream *substream,
SET_UNIPERIF_I2S_FMT_NO_OF_SAMPLES_TO_READ(player, 0); SET_UNIPERIF_I2S_FMT_NO_OF_SAMPLES_TO_READ(player, 0);
/* Reset uniperipheral player */
SET_UNIPERIF_SOFT_RST_SOFT_RST(player);
return reset_player(player); return sti_uniperiph_reset(player);
} }
static int uni_player_start(struct uniperif *player) static int uni_player_start(struct uniperif *player)
...@@ -893,10 +871,7 @@ static int uni_player_start(struct uniperif *player) ...@@ -893,10 +871,7 @@ static int uni_player_start(struct uniperif *player)
SET_UNIPERIF_ITM_BSET_UNDERFLOW_REC_FAILED(player); SET_UNIPERIF_ITM_BSET_UNDERFLOW_REC_FAILED(player);
} }
/* Reset uniperipheral player */ ret = sti_uniperiph_reset(player);
SET_UNIPERIF_SOFT_RST_SOFT_RST(player);
ret = reset_player(player);
if (ret < 0) { if (ret < 0) {
clk_disable_unprepare(player->clk); clk_disable_unprepare(player->clk);
return ret; return ret;
...@@ -945,10 +920,7 @@ static int uni_player_stop(struct uniperif *player) ...@@ -945,10 +920,7 @@ static int uni_player_stop(struct uniperif *player)
/* Turn the player off */ /* Turn the player off */
SET_UNIPERIF_CTRL_OPERATION_OFF(player); SET_UNIPERIF_CTRL_OPERATION_OFF(player);
/* Soft reset the player */ ret = sti_uniperiph_reset(player);
SET_UNIPERIF_SOFT_RST_SOFT_RST(player);
ret = reset_player(player);
if (ret < 0) if (ret < 0)
return ret; return ret;
......
...@@ -6,7 +6,6 @@ ...@@ -6,7 +6,6 @@
*/ */
#include <linux/clk.h> #include <linux/clk.h>
#include <linux/delay.h>
#include <linux/io.h> #include <linux/io.h>
#include <sound/soc.h> #include <sound/soc.h>
...@@ -186,7 +185,6 @@ static int uni_reader_prepare(struct snd_pcm_substream *substream, ...@@ -186,7 +185,6 @@ static int uni_reader_prepare(struct snd_pcm_substream *substream,
struct uniperif *reader = priv->dai_data.uni; struct uniperif *reader = priv->dai_data.uni;
struct snd_pcm_runtime *runtime = substream->runtime; struct snd_pcm_runtime *runtime = substream->runtime;
int transfer_size, trigger_limit, ret; int transfer_size, trigger_limit, ret;
int count = 10;
/* The reader should be stopped */ /* The reader should be stopped */
if (reader->state != UNIPERIF_STATE_STOPPED) { if (reader->state != UNIPERIF_STATE_STOPPED) {
...@@ -288,18 +286,7 @@ static int uni_reader_prepare(struct snd_pcm_substream *substream, ...@@ -288,18 +286,7 @@ static int uni_reader_prepare(struct snd_pcm_substream *substream,
} }
/* Reset uniperipheral reader */ /* Reset uniperipheral reader */
SET_UNIPERIF_SOFT_RST_SOFT_RST(reader); return sti_uniperiph_reset(reader);
while (GET_UNIPERIF_SOFT_RST_SOFT_RST(reader)) {
udelay(5);
count--;
}
if (!count) {
dev_err(reader->dev, "Failed to reset uniperif\n");
return -EIO;
}
return 0;
} }
static int uni_reader_start(struct uniperif *reader) static int uni_reader_start(struct uniperif *reader)
......
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