aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--sound/soc/sti/sti_uniperif.c23
-rw-r--r--sound/soc/sti/uniperif.h2
-rw-r--r--sound/soc/sti/uniperif_player.c34
-rw-r--r--sound/soc/sti/uniperif_reader.c15
4 files changed, 29 insertions, 45 deletions
diff --git a/sound/soc/sti/sti_uniperif.c b/sound/soc/sti/sti_uniperif.c
index ee91ae5f812a..98eb205a0b62 100644
--- a/sound/soc/sti/sti_uniperif.c
+++ b/sound/soc/sti/sti_uniperif.c
@@ -7,6 +7,7 @@
7 7
8#include <linux/module.h> 8#include <linux/module.h>
9#include <linux/pinctrl/consumer.h> 9#include <linux/pinctrl/consumer.h>
10#include <linux/delay.h>
10 11
11#include "uniperif.h" 12#include "uniperif.h"
12 13
@@ -97,6 +98,28 @@ static const struct of_device_id snd_soc_sti_match[] = {
97 {}, 98 {},
98}; 99};
99 100
101int sti_uniperiph_reset(struct uniperif *uni)
102{
103 int count = 10;
104
105 /* Reset uniperipheral uni */
106 SET_UNIPERIF_SOFT_RST_SOFT_RST(uni);
107
108 if (uni->ver < SND_ST_UNIPERIF_VERSION_UNI_PLR_TOP_1_0) {
109 while (GET_UNIPERIF_SOFT_RST_SOFT_RST(uni) && count) {
110 udelay(5);
111 count--;
112 }
113 }
114
115 if (!count) {
116 dev_err(uni->dev, "Failed to reset uniperif\n");
117 return -EIO;
118 }
119
120 return 0;
121}
122
100int sti_uniperiph_set_tdm_slot(struct snd_soc_dai *dai, unsigned int tx_mask, 123int sti_uniperiph_set_tdm_slot(struct snd_soc_dai *dai, unsigned int tx_mask,
101 unsigned int rx_mask, int slots, 124 unsigned int rx_mask, int slots,
102 int slot_width) 125 int slot_width)
diff --git a/sound/soc/sti/uniperif.h b/sound/soc/sti/uniperif.h
index 1993c655fb79..d487dd2ef016 100644
--- a/sound/soc/sti/uniperif.h
+++ b/sound/soc/sti/uniperif.h
@@ -1397,6 +1397,8 @@ static inline int sti_uniperiph_get_unip_tdm_frame_size(struct uniperif *uni)
1397 return (uni->tdm_slot.slots * uni->tdm_slot.slot_width / 8); 1397 return (uni->tdm_slot.slots * uni->tdm_slot.slot_width / 8);
1398} 1398}
1399 1399
1400int sti_uniperiph_reset(struct uniperif *uni);
1401
1400int sti_uniperiph_set_tdm_slot(struct snd_soc_dai *dai, unsigned int tx_mask, 1402int sti_uniperiph_set_tdm_slot(struct snd_soc_dai *dai, unsigned int tx_mask,
1401 unsigned int rx_mask, int slots, 1403 unsigned int rx_mask, int slots,
1402 int slot_width); 1404 int slot_width);
diff --git a/sound/soc/sti/uniperif_player.c b/sound/soc/sti/uniperif_player.c
index c9b4670b772b..00022aa48280 100644
--- a/sound/soc/sti/uniperif_player.c
+++ b/sound/soc/sti/uniperif_player.c
@@ -6,7 +6,6 @@
6 */ 6 */
7 7
8#include <linux/clk.h> 8#include <linux/clk.h>
9#include <linux/delay.h>
10#include <linux/io.h> 9#include <linux/io.h>
11#include <linux/mfd/syscon.h> 10#include <linux/mfd/syscon.h>
12 11
@@ -55,25 +54,6 @@ static const struct snd_pcm_hardware uni_player_pcm_hw = {
55 .buffer_bytes_max = 256 * PAGE_SIZE 54 .buffer_bytes_max = 256 * PAGE_SIZE
56}; 55};
57 56
58static inline int reset_player(struct uniperif *player)
59{
60 int count = 10;
61
62 if (player->ver < SND_ST_UNIPERIF_VERSION_UNI_PLR_TOP_1_0) {
63 while (GET_UNIPERIF_SOFT_RST_SOFT_RST(player) && count) {
64 udelay(5);
65 count--;
66 }
67 }
68
69 if (!count) {
70 dev_err(player->dev, "Failed to reset uniperif\n");
71 return -EIO;
72 }
73
74 return 0;
75}
76
77/* 57/*
78 * uni_player_irq_handler 58 * uni_player_irq_handler
79 * In case of error audio stream is stopped; stop action is protected via PCM 59 * 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 838
859 SET_UNIPERIF_I2S_FMT_NO_OF_SAMPLES_TO_READ(player, 0); 839 SET_UNIPERIF_I2S_FMT_NO_OF_SAMPLES_TO_READ(player, 0);
860 840
861 /* Reset uniperipheral player */
862 SET_UNIPERIF_SOFT_RST_SOFT_RST(player);
863 841
864 return reset_player(player); 842 return sti_uniperiph_reset(player);
865} 843}
866 844
867static int uni_player_start(struct uniperif *player) 845static int uni_player_start(struct uniperif *player)
@@ -893,10 +871,7 @@ static int uni_player_start(struct uniperif *player)
893 SET_UNIPERIF_ITM_BSET_UNDERFLOW_REC_FAILED(player); 871 SET_UNIPERIF_ITM_BSET_UNDERFLOW_REC_FAILED(player);
894 } 872 }
895 873
896 /* Reset uniperipheral player */ 874 ret = sti_uniperiph_reset(player);
897 SET_UNIPERIF_SOFT_RST_SOFT_RST(player);
898
899 ret = reset_player(player);
900 if (ret < 0) { 875 if (ret < 0) {
901 clk_disable_unprepare(player->clk); 876 clk_disable_unprepare(player->clk);
902 return ret; 877 return ret;
@@ -945,10 +920,7 @@ static int uni_player_stop(struct uniperif *player)
945 /* Turn the player off */ 920 /* Turn the player off */
946 SET_UNIPERIF_CTRL_OPERATION_OFF(player); 921 SET_UNIPERIF_CTRL_OPERATION_OFF(player);
947 922
948 /* Soft reset the player */ 923 ret = sti_uniperiph_reset(player);
949 SET_UNIPERIF_SOFT_RST_SOFT_RST(player);
950
951 ret = reset_player(player);
952 if (ret < 0) 924 if (ret < 0)
953 return ret; 925 return ret;
954 926
diff --git a/sound/soc/sti/uniperif_reader.c b/sound/soc/sti/uniperif_reader.c
index 09314f8be841..59043f7a0e5c 100644
--- a/sound/soc/sti/uniperif_reader.c
+++ b/sound/soc/sti/uniperif_reader.c
@@ -6,7 +6,6 @@
6 */ 6 */
7 7
8#include <linux/clk.h> 8#include <linux/clk.h>
9#include <linux/delay.h>
10#include <linux/io.h> 9#include <linux/io.h>
11 10
12#include <sound/soc.h> 11#include <sound/soc.h>
@@ -186,7 +185,6 @@ static int uni_reader_prepare(struct snd_pcm_substream *substream,
186 struct uniperif *reader = priv->dai_data.uni; 185 struct uniperif *reader = priv->dai_data.uni;
187 struct snd_pcm_runtime *runtime = substream->runtime; 186 struct snd_pcm_runtime *runtime = substream->runtime;
188 int transfer_size, trigger_limit, ret; 187 int transfer_size, trigger_limit, ret;
189 int count = 10;
190 188
191 /* The reader should be stopped */ 189 /* The reader should be stopped */
192 if (reader->state != UNIPERIF_STATE_STOPPED) { 190 if (reader->state != UNIPERIF_STATE_STOPPED) {
@@ -288,18 +286,7 @@ static int uni_reader_prepare(struct snd_pcm_substream *substream,
288 } 286 }
289 287
290 /* Reset uniperipheral reader */ 288 /* Reset uniperipheral reader */
291 SET_UNIPERIF_SOFT_RST_SOFT_RST(reader); 289 return sti_uniperiph_reset(reader);
292
293 while (GET_UNIPERIF_SOFT_RST_SOFT_RST(reader)) {
294 udelay(5);
295 count--;
296 }
297 if (!count) {
298 dev_err(reader->dev, "Failed to reset uniperif\n");
299 return -EIO;
300 }
301
302 return 0;
303} 290}
304 291
305static int uni_reader_start(struct uniperif *reader) 292static int uni_reader_start(struct uniperif *reader)