diff options
Diffstat (limited to 'sound/soc/blackfin')
-rw-r--r-- | sound/soc/blackfin/bf5xx-ac97-pcm.c | 2 | ||||
-rw-r--r-- | sound/soc/blackfin/bf5xx-ac97.c | 94 | ||||
-rw-r--r-- | sound/soc/blackfin/bf5xx-ad73311.c | 4 | ||||
-rw-r--r-- | sound/soc/blackfin/bf5xx-i2s-pcm.c | 2 | ||||
-rw-r--r-- | sound/soc/blackfin/bf5xx-i2s.c | 14 | ||||
-rw-r--r-- | sound/soc/blackfin/bf5xx-sport.c | 104 |
6 files changed, 89 insertions, 131 deletions
diff --git a/sound/soc/blackfin/bf5xx-ac97-pcm.c b/sound/soc/blackfin/bf5xx-ac97-pcm.c index 8067cfafa3a7..8cfed1a5dcbe 100644 --- a/sound/soc/blackfin/bf5xx-ac97-pcm.c +++ b/sound/soc/blackfin/bf5xx-ac97-pcm.c | |||
@@ -297,7 +297,7 @@ static int bf5xx_pcm_copy(struct snd_pcm_substream *substream, int channel, | |||
297 | } | 297 | } |
298 | #endif | 298 | #endif |
299 | 299 | ||
300 | struct snd_pcm_ops bf5xx_pcm_ac97_ops = { | 300 | static struct snd_pcm_ops bf5xx_pcm_ac97_ops = { |
301 | .open = bf5xx_pcm_open, | 301 | .open = bf5xx_pcm_open, |
302 | .ioctl = snd_pcm_lib_ioctl, | 302 | .ioctl = snd_pcm_lib_ioctl, |
303 | .hw_params = bf5xx_pcm_hw_params, | 303 | .hw_params = bf5xx_pcm_hw_params, |
diff --git a/sound/soc/blackfin/bf5xx-ac97.c b/sound/soc/blackfin/bf5xx-ac97.c index 3be2be60576d..8a935f2d1767 100644 --- a/sound/soc/blackfin/bf5xx-ac97.c +++ b/sound/soc/blackfin/bf5xx-ac97.c | |||
@@ -31,72 +31,46 @@ | |||
31 | #include "bf5xx-sport.h" | 31 | #include "bf5xx-sport.h" |
32 | #include "bf5xx-ac97.h" | 32 | #include "bf5xx-ac97.h" |
33 | 33 | ||
34 | #if defined(CONFIG_BF54x) | ||
35 | #define PIN_REQ_SPORT_0 {P_SPORT0_TFS, P_SPORT0_DTPRI, P_SPORT0_TSCLK, \ | ||
36 | P_SPORT0_RFS, P_SPORT0_DRPRI, P_SPORT0_RSCLK, 0} | ||
37 | |||
38 | #define PIN_REQ_SPORT_1 {P_SPORT1_TFS, P_SPORT1_DTPRI, P_SPORT1_TSCLK, \ | ||
39 | P_SPORT1_RFS, P_SPORT1_DRPRI, P_SPORT1_RSCLK, 0} | ||
40 | |||
41 | #define PIN_REQ_SPORT_2 {P_SPORT2_TFS, P_SPORT2_DTPRI, P_SPORT2_TSCLK, \ | ||
42 | P_SPORT2_RFS, P_SPORT2_DRPRI, P_SPORT2_RSCLK, 0} | ||
43 | |||
44 | #define PIN_REQ_SPORT_3 {P_SPORT3_TFS, P_SPORT3_DTPRI, P_SPORT3_TSCLK, \ | ||
45 | P_SPORT3_RFS, P_SPORT3_DRPRI, P_SPORT3_RSCLK, 0} | ||
46 | #else | ||
47 | #define PIN_REQ_SPORT_0 {P_SPORT0_DTPRI, P_SPORT0_TSCLK, P_SPORT0_RFS, \ | ||
48 | P_SPORT0_DRPRI, P_SPORT0_RSCLK, 0} | ||
49 | |||
50 | #define PIN_REQ_SPORT_1 {P_SPORT1_DTPRI, P_SPORT1_TSCLK, P_SPORT1_RFS, \ | ||
51 | P_SPORT1_DRPRI, P_SPORT1_RSCLK, 0} | ||
52 | #endif | ||
53 | |||
54 | static int *cmd_count; | 34 | static int *cmd_count; |
55 | static int sport_num = CONFIG_SND_BF5XX_SPORT_NUM; | 35 | static int sport_num = CONFIG_SND_BF5XX_SPORT_NUM; |
56 | 36 | ||
37 | #define SPORT_REQ(x) \ | ||
38 | [x] = {P_SPORT##x##_TFS, P_SPORT##x##_DTPRI, P_SPORT##x##_TSCLK, \ | ||
39 | P_SPORT##x##_RFS, P_SPORT##x##_DRPRI, P_SPORT##x##_RSCLK, 0} | ||
57 | static u16 sport_req[][7] = { | 40 | static u16 sport_req[][7] = { |
58 | PIN_REQ_SPORT_0, | 41 | #ifdef SPORT0_TCR1 |
59 | #ifdef PIN_REQ_SPORT_1 | 42 | SPORT_REQ(0), |
60 | PIN_REQ_SPORT_1, | 43 | #endif |
44 | #ifdef SPORT1_TCR1 | ||
45 | SPORT_REQ(1), | ||
61 | #endif | 46 | #endif |
62 | #ifdef PIN_REQ_SPORT_2 | 47 | #ifdef SPORT2_TCR1 |
63 | PIN_REQ_SPORT_2, | 48 | SPORT_REQ(2), |
64 | #endif | 49 | #endif |
65 | #ifdef PIN_REQ_SPORT_3 | 50 | #ifdef SPORT3_TCR1 |
66 | PIN_REQ_SPORT_3, | 51 | SPORT_REQ(3), |
67 | #endif | 52 | #endif |
68 | }; | 53 | }; |
69 | 54 | ||
55 | #define SPORT_PARAMS(x) \ | ||
56 | [x] = { \ | ||
57 | .dma_rx_chan = CH_SPORT##x##_RX, \ | ||
58 | .dma_tx_chan = CH_SPORT##x##_TX, \ | ||
59 | .err_irq = IRQ_SPORT##x##_ERROR, \ | ||
60 | .regs = (struct sport_register *)SPORT##x##_TCR1, \ | ||
61 | } | ||
70 | static struct sport_param sport_params[4] = { | 62 | static struct sport_param sport_params[4] = { |
71 | { | 63 | #ifdef SPORT0_TCR1 |
72 | .dma_rx_chan = CH_SPORT0_RX, | 64 | SPORT_PARAMS(0), |
73 | .dma_tx_chan = CH_SPORT0_TX, | ||
74 | .err_irq = IRQ_SPORT0_ERROR, | ||
75 | .regs = (struct sport_register *)SPORT0_TCR1, | ||
76 | }, | ||
77 | #ifdef PIN_REQ_SPORT_1 | ||
78 | { | ||
79 | .dma_rx_chan = CH_SPORT1_RX, | ||
80 | .dma_tx_chan = CH_SPORT1_TX, | ||
81 | .err_irq = IRQ_SPORT1_ERROR, | ||
82 | .regs = (struct sport_register *)SPORT1_TCR1, | ||
83 | }, | ||
84 | #endif | 65 | #endif |
85 | #ifdef PIN_REQ_SPORT_2 | 66 | #ifdef SPORT1_TCR1 |
86 | { | 67 | SPORT_PARAMS(1), |
87 | .dma_rx_chan = CH_SPORT2_RX, | ||
88 | .dma_tx_chan = CH_SPORT2_TX, | ||
89 | .err_irq = IRQ_SPORT2_ERROR, | ||
90 | .regs = (struct sport_register *)SPORT2_TCR1, | ||
91 | }, | ||
92 | #endif | 68 | #endif |
93 | #ifdef PIN_REQ_SPORT_3 | 69 | #ifdef SPORT2_TCR1 |
94 | { | 70 | SPORT_PARAMS(2), |
95 | .dma_rx_chan = CH_SPORT3_RX, | 71 | #endif |
96 | .dma_tx_chan = CH_SPORT3_TX, | 72 | #ifdef SPORT3_TCR1 |
97 | .err_irq = IRQ_SPORT3_ERROR, | 73 | SPORT_PARAMS(3), |
98 | .regs = (struct sport_register *)SPORT3_TCR1, | ||
99 | } | ||
100 | #endif | 74 | #endif |
101 | }; | 75 | }; |
102 | 76 | ||
@@ -332,11 +306,11 @@ static int bf5xx_ac97_probe(struct platform_device *pdev, | |||
332 | if (cmd_count == NULL) | 306 | if (cmd_count == NULL) |
333 | return -ENOMEM; | 307 | return -ENOMEM; |
334 | 308 | ||
335 | if (peripheral_request_list(&sport_req[sport_num][0], "soc-audio")) { | 309 | if (peripheral_request_list(sport_req[sport_num], "soc-audio")) { |
336 | pr_err("Requesting Peripherals failed\n"); | 310 | pr_err("Requesting Peripherals failed\n"); |
337 | ret = -EFAULT; | 311 | ret = -EFAULT; |
338 | goto peripheral_err; | 312 | goto peripheral_err; |
339 | } | 313 | } |
340 | 314 | ||
341 | #ifdef CONFIG_SND_BF5XX_HAVE_COLD_RESET | 315 | #ifdef CONFIG_SND_BF5XX_HAVE_COLD_RESET |
342 | /* Request PB3 as reset pin */ | 316 | /* Request PB3 as reset pin */ |
@@ -383,9 +357,9 @@ sport_config_err: | |||
383 | sport_err: | 357 | sport_err: |
384 | #ifdef CONFIG_SND_BF5XX_HAVE_COLD_RESET | 358 | #ifdef CONFIG_SND_BF5XX_HAVE_COLD_RESET |
385 | gpio_free(CONFIG_SND_BF5XX_RESET_GPIO_NUM); | 359 | gpio_free(CONFIG_SND_BF5XX_RESET_GPIO_NUM); |
386 | #endif | ||
387 | gpio_err: | 360 | gpio_err: |
388 | peripheral_free_list(&sport_req[sport_num][0]); | 361 | #endif |
362 | peripheral_free_list(sport_req[sport_num]); | ||
389 | peripheral_err: | 363 | peripheral_err: |
390 | free_page((unsigned long)cmd_count); | 364 | free_page((unsigned long)cmd_count); |
391 | cmd_count = NULL; | 365 | cmd_count = NULL; |
@@ -398,7 +372,7 @@ static void bf5xx_ac97_remove(struct platform_device *pdev, | |||
398 | { | 372 | { |
399 | free_page((unsigned long)cmd_count); | 373 | free_page((unsigned long)cmd_count); |
400 | cmd_count = NULL; | 374 | cmd_count = NULL; |
401 | peripheral_free_list(&sport_req[sport_num][0]); | 375 | peripheral_free_list(sport_req[sport_num]); |
402 | #ifdef CONFIG_SND_BF5XX_HAVE_COLD_RESET | 376 | #ifdef CONFIG_SND_BF5XX_HAVE_COLD_RESET |
403 | gpio_free(CONFIG_SND_BF5XX_RESET_GPIO_NUM); | 377 | gpio_free(CONFIG_SND_BF5XX_RESET_GPIO_NUM); |
404 | #endif | 378 | #endif |
diff --git a/sound/soc/blackfin/bf5xx-ad73311.c b/sound/soc/blackfin/bf5xx-ad73311.c index 7f2a5e199075..edfbdc024e66 100644 --- a/sound/soc/blackfin/bf5xx-ad73311.c +++ b/sound/soc/blackfin/bf5xx-ad73311.c | |||
@@ -114,7 +114,7 @@ static int snd_ad73311_configure(void) | |||
114 | SSYNC(); | 114 | SSYNC(); |
115 | 115 | ||
116 | /* When TUVF is set, the data is already send out */ | 116 | /* When TUVF is set, the data is already send out */ |
117 | while (!(status & TUVF) && count++ < 10000) { | 117 | while (!(status & TUVF) && ++count < 10000) { |
118 | udelay(1); | 118 | udelay(1); |
119 | status = bfin_read_SPORT_STAT(); | 119 | status = bfin_read_SPORT_STAT(); |
120 | SSYNC(); | 120 | SSYNC(); |
@@ -123,7 +123,7 @@ static int snd_ad73311_configure(void) | |||
123 | SSYNC(); | 123 | SSYNC(); |
124 | local_irq_enable(); | 124 | local_irq_enable(); |
125 | 125 | ||
126 | if (count == 10000) { | 126 | if (count >= 10000) { |
127 | printk(KERN_ERR "ad73311: failed to configure codec\n"); | 127 | printk(KERN_ERR "ad73311: failed to configure codec\n"); |
128 | return -1; | 128 | return -1; |
129 | } | 129 | } |
diff --git a/sound/soc/blackfin/bf5xx-i2s-pcm.c b/sound/soc/blackfin/bf5xx-i2s-pcm.c index 53d290b3ea47..1318c4f627b7 100644 --- a/sound/soc/blackfin/bf5xx-i2s-pcm.c +++ b/sound/soc/blackfin/bf5xx-i2s-pcm.c | |||
@@ -184,7 +184,7 @@ static int bf5xx_pcm_mmap(struct snd_pcm_substream *substream, | |||
184 | return 0 ; | 184 | return 0 ; |
185 | } | 185 | } |
186 | 186 | ||
187 | struct snd_pcm_ops bf5xx_pcm_i2s_ops = { | 187 | static struct snd_pcm_ops bf5xx_pcm_i2s_ops = { |
188 | .open = bf5xx_pcm_open, | 188 | .open = bf5xx_pcm_open, |
189 | .ioctl = snd_pcm_lib_ioctl, | 189 | .ioctl = snd_pcm_lib_ioctl, |
190 | .hw_params = bf5xx_pcm_hw_params, | 190 | .hw_params = bf5xx_pcm_hw_params, |
diff --git a/sound/soc/blackfin/bf5xx-i2s.c b/sound/soc/blackfin/bf5xx-i2s.c index d1d95d2393fe..964824419678 100644 --- a/sound/soc/blackfin/bf5xx-i2s.c +++ b/sound/soc/blackfin/bf5xx-i2s.c | |||
@@ -287,6 +287,13 @@ static int bf5xx_i2s_resume(struct platform_device *pdev, | |||
287 | #define BF5XX_I2S_FORMATS (SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S24_LE |\ | 287 | #define BF5XX_I2S_FORMATS (SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S24_LE |\ |
288 | SNDRV_PCM_FMTBIT_S32_LE) | 288 | SNDRV_PCM_FMTBIT_S32_LE) |
289 | 289 | ||
290 | static struct snd_soc_dai_ops bf5xx_i2s_dai_ops = { | ||
291 | .startup = bf5xx_i2s_startup, | ||
292 | .shutdown = bf5xx_i2s_shutdown, | ||
293 | .hw_params = bf5xx_i2s_hw_params, | ||
294 | .set_fmt = bf5xx_i2s_set_dai_fmt, | ||
295 | }; | ||
296 | |||
290 | struct snd_soc_dai bf5xx_i2s_dai = { | 297 | struct snd_soc_dai bf5xx_i2s_dai = { |
291 | .name = "bf5xx-i2s", | 298 | .name = "bf5xx-i2s", |
292 | .id = 0, | 299 | .id = 0, |
@@ -304,12 +311,7 @@ struct snd_soc_dai bf5xx_i2s_dai = { | |||
304 | .channels_max = 2, | 311 | .channels_max = 2, |
305 | .rates = BF5XX_I2S_RATES, | 312 | .rates = BF5XX_I2S_RATES, |
306 | .formats = BF5XX_I2S_FORMATS,}, | 313 | .formats = BF5XX_I2S_FORMATS,}, |
307 | .ops = { | 314 | .ops = &bf5xx_i2s_dai_ops, |
308 | .startup = bf5xx_i2s_startup, | ||
309 | .shutdown = bf5xx_i2s_shutdown, | ||
310 | .hw_params = bf5xx_i2s_hw_params, | ||
311 | .set_fmt = bf5xx_i2s_set_dai_fmt, | ||
312 | }, | ||
313 | }; | 315 | }; |
314 | EXPORT_SYMBOL_GPL(bf5xx_i2s_dai); | 316 | EXPORT_SYMBOL_GPL(bf5xx_i2s_dai); |
315 | 317 | ||
diff --git a/sound/soc/blackfin/bf5xx-sport.c b/sound/soc/blackfin/bf5xx-sport.c index 3b99e484d555..b7953c8cf838 100644 --- a/sound/soc/blackfin/bf5xx-sport.c +++ b/sound/soc/blackfin/bf5xx-sport.c | |||
@@ -133,7 +133,7 @@ static void setup_desc(struct dmasg *desc, void *buf, int fragcount, | |||
133 | int i; | 133 | int i; |
134 | 134 | ||
135 | for (i = 0; i < fragcount; ++i) { | 135 | for (i = 0; i < fragcount; ++i) { |
136 | desc[i].next_desc_addr = (unsigned long)&(desc[i + 1]); | 136 | desc[i].next_desc_addr = &(desc[i + 1]); |
137 | desc[i].start_addr = (unsigned long)buf + i*fragsize; | 137 | desc[i].start_addr = (unsigned long)buf + i*fragsize; |
138 | desc[i].cfg = cfg; | 138 | desc[i].cfg = cfg; |
139 | desc[i].x_count = x_count; | 139 | desc[i].x_count = x_count; |
@@ -143,12 +143,12 @@ static void setup_desc(struct dmasg *desc, void *buf, int fragcount, | |||
143 | } | 143 | } |
144 | 144 | ||
145 | /* make circular */ | 145 | /* make circular */ |
146 | desc[fragcount-1].next_desc_addr = (unsigned long)desc; | 146 | desc[fragcount-1].next_desc_addr = desc; |
147 | 147 | ||
148 | pr_debug("setup desc: desc0=%p, next0=%lx, desc1=%p," | 148 | pr_debug("setup desc: desc0=%p, next0=%p, desc1=%p," |
149 | "next1=%lx\nx_count=%x,y_count=%x,addr=0x%lx,cfs=0x%x\n", | 149 | "next1=%p\nx_count=%x,y_count=%x,addr=0x%lx,cfs=0x%x\n", |
150 | &(desc[0]), desc[0].next_desc_addr, | 150 | desc, desc[0].next_desc_addr, |
151 | &(desc[1]), desc[1].next_desc_addr, | 151 | desc+1, desc[1].next_desc_addr, |
152 | desc[0].x_count, desc[0].y_count, | 152 | desc[0].x_count, desc[0].y_count, |
153 | desc[0].start_addr, desc[0].cfg); | 153 | desc[0].start_addr, desc[0].cfg); |
154 | } | 154 | } |
@@ -184,22 +184,20 @@ static inline int sport_hook_rx_dummy(struct sport_device *sport) | |||
184 | BUG_ON(sport->curr_rx_desc == sport->dummy_rx_desc); | 184 | BUG_ON(sport->curr_rx_desc == sport->dummy_rx_desc); |
185 | 185 | ||
186 | /* Maybe the dummy buffer descriptor ring is damaged */ | 186 | /* Maybe the dummy buffer descriptor ring is damaged */ |
187 | sport->dummy_rx_desc->next_desc_addr = \ | 187 | sport->dummy_rx_desc->next_desc_addr = sport->dummy_rx_desc + 1; |
188 | (unsigned long)(sport->dummy_rx_desc+1); | ||
189 | 188 | ||
190 | local_irq_save(flags); | 189 | local_irq_save(flags); |
191 | desc = (struct dmasg *)get_dma_next_desc_ptr(sport->dma_rx_chan); | 190 | desc = get_dma_next_desc_ptr(sport->dma_rx_chan); |
192 | /* Copy the descriptor which will be damaged to backup */ | 191 | /* Copy the descriptor which will be damaged to backup */ |
193 | temp_desc = *desc; | 192 | temp_desc = *desc; |
194 | desc->x_count = 0xa; | 193 | desc->x_count = 0xa; |
195 | desc->y_count = 0; | 194 | desc->y_count = 0; |
196 | desc->next_desc_addr = (unsigned long)(sport->dummy_rx_desc); | 195 | desc->next_desc_addr = sport->dummy_rx_desc; |
197 | local_irq_restore(flags); | 196 | local_irq_restore(flags); |
198 | /* Waiting for dummy buffer descriptor is already hooked*/ | 197 | /* Waiting for dummy buffer descriptor is already hooked*/ |
199 | while ((get_dma_curr_desc_ptr(sport->dma_rx_chan) - | 198 | while ((get_dma_curr_desc_ptr(sport->dma_rx_chan) - |
200 | sizeof(struct dmasg)) != | 199 | sizeof(struct dmasg)) != sport->dummy_rx_desc) |
201 | (unsigned long)sport->dummy_rx_desc) | 200 | continue; |
202 | ; | ||
203 | sport->curr_rx_desc = sport->dummy_rx_desc; | 201 | sport->curr_rx_desc = sport->dummy_rx_desc; |
204 | /* Restore the damaged descriptor */ | 202 | /* Restore the damaged descriptor */ |
205 | *desc = temp_desc; | 203 | *desc = temp_desc; |
@@ -210,14 +208,12 @@ static inline int sport_hook_rx_dummy(struct sport_device *sport) | |||
210 | static inline int sport_rx_dma_start(struct sport_device *sport, int dummy) | 208 | static inline int sport_rx_dma_start(struct sport_device *sport, int dummy) |
211 | { | 209 | { |
212 | if (dummy) { | 210 | if (dummy) { |
213 | sport->dummy_rx_desc->next_desc_addr = \ | 211 | sport->dummy_rx_desc->next_desc_addr = sport->dummy_rx_desc; |
214 | (unsigned long) sport->dummy_rx_desc; | ||
215 | sport->curr_rx_desc = sport->dummy_rx_desc; | 212 | sport->curr_rx_desc = sport->dummy_rx_desc; |
216 | } else | 213 | } else |
217 | sport->curr_rx_desc = sport->dma_rx_desc; | 214 | sport->curr_rx_desc = sport->dma_rx_desc; |
218 | 215 | ||
219 | set_dma_next_desc_addr(sport->dma_rx_chan, \ | 216 | set_dma_next_desc_addr(sport->dma_rx_chan, sport->curr_rx_desc); |
220 | (unsigned long)(sport->curr_rx_desc)); | ||
221 | set_dma_x_count(sport->dma_rx_chan, 0); | 217 | set_dma_x_count(sport->dma_rx_chan, 0); |
222 | set_dma_x_modify(sport->dma_rx_chan, 0); | 218 | set_dma_x_modify(sport->dma_rx_chan, 0); |
223 | set_dma_config(sport->dma_rx_chan, (DMAFLOW_LARGE | NDSIZE_9 | \ | 219 | set_dma_config(sport->dma_rx_chan, (DMAFLOW_LARGE | NDSIZE_9 | \ |
@@ -231,14 +227,12 @@ static inline int sport_rx_dma_start(struct sport_device *sport, int dummy) | |||
231 | static inline int sport_tx_dma_start(struct sport_device *sport, int dummy) | 227 | static inline int sport_tx_dma_start(struct sport_device *sport, int dummy) |
232 | { | 228 | { |
233 | if (dummy) { | 229 | if (dummy) { |
234 | sport->dummy_tx_desc->next_desc_addr = \ | 230 | sport->dummy_tx_desc->next_desc_addr = sport->dummy_tx_desc; |
235 | (unsigned long) sport->dummy_tx_desc; | ||
236 | sport->curr_tx_desc = sport->dummy_tx_desc; | 231 | sport->curr_tx_desc = sport->dummy_tx_desc; |
237 | } else | 232 | } else |
238 | sport->curr_tx_desc = sport->dma_tx_desc; | 233 | sport->curr_tx_desc = sport->dma_tx_desc; |
239 | 234 | ||
240 | set_dma_next_desc_addr(sport->dma_tx_chan, \ | 235 | set_dma_next_desc_addr(sport->dma_tx_chan, sport->curr_tx_desc); |
241 | (unsigned long)(sport->curr_tx_desc)); | ||
242 | set_dma_x_count(sport->dma_tx_chan, 0); | 236 | set_dma_x_count(sport->dma_tx_chan, 0); |
243 | set_dma_x_modify(sport->dma_tx_chan, 0); | 237 | set_dma_x_modify(sport->dma_tx_chan, 0); |
244 | set_dma_config(sport->dma_tx_chan, | 238 | set_dma_config(sport->dma_tx_chan, |
@@ -261,11 +255,9 @@ int sport_rx_start(struct sport_device *sport) | |||
261 | BUG_ON(sport->curr_rx_desc != sport->dummy_rx_desc); | 255 | BUG_ON(sport->curr_rx_desc != sport->dummy_rx_desc); |
262 | local_irq_save(flags); | 256 | local_irq_save(flags); |
263 | while ((get_dma_curr_desc_ptr(sport->dma_rx_chan) - | 257 | while ((get_dma_curr_desc_ptr(sport->dma_rx_chan) - |
264 | sizeof(struct dmasg)) != | 258 | sizeof(struct dmasg)) != sport->dummy_rx_desc) |
265 | (unsigned long)sport->dummy_rx_desc) | 259 | continue; |
266 | ; | 260 | sport->dummy_rx_desc->next_desc_addr = sport->dma_rx_desc; |
267 | sport->dummy_rx_desc->next_desc_addr = | ||
268 | (unsigned long)(sport->dma_rx_desc); | ||
269 | local_irq_restore(flags); | 261 | local_irq_restore(flags); |
270 | sport->curr_rx_desc = sport->dma_rx_desc; | 262 | sport->curr_rx_desc = sport->dma_rx_desc; |
271 | } else { | 263 | } else { |
@@ -310,23 +302,21 @@ static inline int sport_hook_tx_dummy(struct sport_device *sport) | |||
310 | BUG_ON(sport->dummy_tx_desc == NULL); | 302 | BUG_ON(sport->dummy_tx_desc == NULL); |
311 | BUG_ON(sport->curr_tx_desc == sport->dummy_tx_desc); | 303 | BUG_ON(sport->curr_tx_desc == sport->dummy_tx_desc); |
312 | 304 | ||
313 | sport->dummy_tx_desc->next_desc_addr = \ | 305 | sport->dummy_tx_desc->next_desc_addr = sport->dummy_tx_desc + 1; |
314 | (unsigned long)(sport->dummy_tx_desc+1); | ||
315 | 306 | ||
316 | /* Shorten the time on last normal descriptor */ | 307 | /* Shorten the time on last normal descriptor */ |
317 | local_irq_save(flags); | 308 | local_irq_save(flags); |
318 | desc = (struct dmasg *)get_dma_next_desc_ptr(sport->dma_tx_chan); | 309 | desc = get_dma_next_desc_ptr(sport->dma_tx_chan); |
319 | /* Store the descriptor which will be damaged */ | 310 | /* Store the descriptor which will be damaged */ |
320 | temp_desc = *desc; | 311 | temp_desc = *desc; |
321 | desc->x_count = 0xa; | 312 | desc->x_count = 0xa; |
322 | desc->y_count = 0; | 313 | desc->y_count = 0; |
323 | desc->next_desc_addr = (unsigned long)(sport->dummy_tx_desc); | 314 | desc->next_desc_addr = sport->dummy_tx_desc; |
324 | local_irq_restore(flags); | 315 | local_irq_restore(flags); |
325 | /* Waiting for dummy buffer descriptor is already hooked*/ | 316 | /* Waiting for dummy buffer descriptor is already hooked*/ |
326 | while ((get_dma_curr_desc_ptr(sport->dma_tx_chan) - \ | 317 | while ((get_dma_curr_desc_ptr(sport->dma_tx_chan) - \ |
327 | sizeof(struct dmasg)) != \ | 318 | sizeof(struct dmasg)) != sport->dummy_tx_desc) |
328 | (unsigned long)sport->dummy_tx_desc) | 319 | continue; |
329 | ; | ||
330 | sport->curr_tx_desc = sport->dummy_tx_desc; | 320 | sport->curr_tx_desc = sport->dummy_tx_desc; |
331 | /* Restore the damaged descriptor */ | 321 | /* Restore the damaged descriptor */ |
332 | *desc = temp_desc; | 322 | *desc = temp_desc; |
@@ -347,11 +337,9 @@ int sport_tx_start(struct sport_device *sport) | |||
347 | /* Hook the normal buffer descriptor */ | 337 | /* Hook the normal buffer descriptor */ |
348 | local_irq_save(flags); | 338 | local_irq_save(flags); |
349 | while ((get_dma_curr_desc_ptr(sport->dma_tx_chan) - | 339 | while ((get_dma_curr_desc_ptr(sport->dma_tx_chan) - |
350 | sizeof(struct dmasg)) != | 340 | sizeof(struct dmasg)) != sport->dummy_tx_desc) |
351 | (unsigned long)sport->dummy_tx_desc) | 341 | continue; |
352 | ; | 342 | sport->dummy_tx_desc->next_desc_addr = sport->dma_tx_desc; |
353 | sport->dummy_tx_desc->next_desc_addr = | ||
354 | (unsigned long)(sport->dma_tx_desc); | ||
355 | local_irq_restore(flags); | 343 | local_irq_restore(flags); |
356 | sport->curr_tx_desc = sport->dma_tx_desc; | 344 | sport->curr_tx_desc = sport->dma_tx_desc; |
357 | } else { | 345 | } else { |
@@ -536,19 +524,17 @@ static int sport_config_rx_dummy(struct sport_device *sport) | |||
536 | unsigned config; | 524 | unsigned config; |
537 | 525 | ||
538 | pr_debug("%s entered\n", __func__); | 526 | pr_debug("%s entered\n", __func__); |
539 | #if L1_DATA_A_LENGTH != 0 | 527 | if (L1_DATA_A_LENGTH) |
540 | desc = (struct dmasg *) l1_data_sram_alloc(2 * sizeof(*desc)); | 528 | desc = l1_data_sram_zalloc(2 * sizeof(*desc)); |
541 | #else | 529 | else { |
542 | { | ||
543 | dma_addr_t addr; | 530 | dma_addr_t addr; |
544 | desc = dma_alloc_coherent(NULL, 2 * sizeof(*desc), &addr, 0); | 531 | desc = dma_alloc_coherent(NULL, 2 * sizeof(*desc), &addr, 0); |
532 | memset(desc, 0, 2 * sizeof(*desc)); | ||
545 | } | 533 | } |
546 | #endif | ||
547 | if (desc == NULL) { | 534 | if (desc == NULL) { |
548 | pr_err("Failed to allocate memory for dummy rx desc\n"); | 535 | pr_err("Failed to allocate memory for dummy rx desc\n"); |
549 | return -ENOMEM; | 536 | return -ENOMEM; |
550 | } | 537 | } |
551 | memset(desc, 0, 2 * sizeof(*desc)); | ||
552 | sport->dummy_rx_desc = desc; | 538 | sport->dummy_rx_desc = desc; |
553 | desc->start_addr = (unsigned long)sport->dummy_buf; | 539 | desc->start_addr = (unsigned long)sport->dummy_buf; |
554 | config = DMAFLOW_LARGE | NDSIZE_9 | compute_wdsize(sport->wdsize) | 540 | config = DMAFLOW_LARGE | NDSIZE_9 | compute_wdsize(sport->wdsize) |
@@ -559,8 +545,8 @@ static int sport_config_rx_dummy(struct sport_device *sport) | |||
559 | desc->y_count = 0; | 545 | desc->y_count = 0; |
560 | desc->y_modify = 0; | 546 | desc->y_modify = 0; |
561 | memcpy(desc+1, desc, sizeof(*desc)); | 547 | memcpy(desc+1, desc, sizeof(*desc)); |
562 | desc->next_desc_addr = (unsigned long)(desc+1); | 548 | desc->next_desc_addr = desc + 1; |
563 | desc[1].next_desc_addr = (unsigned long)desc; | 549 | desc[1].next_desc_addr = desc; |
564 | return 0; | 550 | return 0; |
565 | } | 551 | } |
566 | 552 | ||
@@ -571,19 +557,17 @@ static int sport_config_tx_dummy(struct sport_device *sport) | |||
571 | 557 | ||
572 | pr_debug("%s entered\n", __func__); | 558 | pr_debug("%s entered\n", __func__); |
573 | 559 | ||
574 | #if L1_DATA_A_LENGTH != 0 | 560 | if (L1_DATA_A_LENGTH) |
575 | desc = (struct dmasg *) l1_data_sram_alloc(2 * sizeof(*desc)); | 561 | desc = l1_data_sram_zalloc(2 * sizeof(*desc)); |
576 | #else | 562 | else { |
577 | { | ||
578 | dma_addr_t addr; | 563 | dma_addr_t addr; |
579 | desc = dma_alloc_coherent(NULL, 2 * sizeof(*desc), &addr, 0); | 564 | desc = dma_alloc_coherent(NULL, 2 * sizeof(*desc), &addr, 0); |
565 | memset(desc, 0, 2 * sizeof(*desc)); | ||
580 | } | 566 | } |
581 | #endif | ||
582 | if (!desc) { | 567 | if (!desc) { |
583 | pr_err("Failed to allocate memory for dummy tx desc\n"); | 568 | pr_err("Failed to allocate memory for dummy tx desc\n"); |
584 | return -ENOMEM; | 569 | return -ENOMEM; |
585 | } | 570 | } |
586 | memset(desc, 0, 2 * sizeof(*desc)); | ||
587 | sport->dummy_tx_desc = desc; | 571 | sport->dummy_tx_desc = desc; |
588 | desc->start_addr = (unsigned long)sport->dummy_buf + \ | 572 | desc->start_addr = (unsigned long)sport->dummy_buf + \ |
589 | sport->dummy_count; | 573 | sport->dummy_count; |
@@ -595,8 +579,8 @@ static int sport_config_tx_dummy(struct sport_device *sport) | |||
595 | desc->y_count = 0; | 579 | desc->y_count = 0; |
596 | desc->y_modify = 0; | 580 | desc->y_modify = 0; |
597 | memcpy(desc+1, desc, sizeof(*desc)); | 581 | memcpy(desc+1, desc, sizeof(*desc)); |
598 | desc->next_desc_addr = (unsigned long)(desc+1); | 582 | desc->next_desc_addr = desc + 1; |
599 | desc[1].next_desc_addr = (unsigned long)desc; | 583 | desc[1].next_desc_addr = desc; |
600 | return 0; | 584 | return 0; |
601 | } | 585 | } |
602 | 586 | ||
@@ -872,17 +856,15 @@ struct sport_device *sport_init(struct sport_param *param, unsigned wdsize, | |||
872 | sport->wdsize = wdsize; | 856 | sport->wdsize = wdsize; |
873 | sport->dummy_count = dummy_count; | 857 | sport->dummy_count = dummy_count; |
874 | 858 | ||
875 | #if L1_DATA_A_LENGTH != 0 | 859 | if (L1_DATA_A_LENGTH) |
876 | sport->dummy_buf = l1_data_sram_alloc(dummy_count * 2); | 860 | sport->dummy_buf = l1_data_sram_zalloc(dummy_count * 2); |
877 | #else | 861 | else |
878 | sport->dummy_buf = kmalloc(dummy_count * 2, GFP_KERNEL); | 862 | sport->dummy_buf = kzalloc(dummy_count * 2, GFP_KERNEL); |
879 | #endif | ||
880 | if (sport->dummy_buf == NULL) { | 863 | if (sport->dummy_buf == NULL) { |
881 | pr_err("Failed to allocate dummy buffer\n"); | 864 | pr_err("Failed to allocate dummy buffer\n"); |
882 | goto __error; | 865 | goto __error; |
883 | } | 866 | } |
884 | 867 | ||
885 | memset(sport->dummy_buf, 0, dummy_count * 2); | ||
886 | ret = sport_config_rx_dummy(sport); | 868 | ret = sport_config_rx_dummy(sport); |
887 | if (ret) { | 869 | if (ret) { |
888 | pr_err("Failed to config rx dummy ring\n"); | 870 | pr_err("Failed to config rx dummy ring\n"); |
@@ -939,6 +921,7 @@ void sport_done(struct sport_device *sport) | |||
939 | sport = NULL; | 921 | sport = NULL; |
940 | } | 922 | } |
941 | EXPORT_SYMBOL(sport_done); | 923 | EXPORT_SYMBOL(sport_done); |
924 | |||
942 | /* | 925 | /* |
943 | * It is only used to send several bytes when dma is not enabled | 926 | * It is only used to send several bytes when dma is not enabled |
944 | * sport controller is configured but not enabled. | 927 | * sport controller is configured but not enabled. |
@@ -1029,4 +1012,3 @@ EXPORT_SYMBOL(sport_send_and_recv); | |||
1029 | MODULE_AUTHOR("Roy Huang"); | 1012 | MODULE_AUTHOR("Roy Huang"); |
1030 | MODULE_DESCRIPTION("SPORT driver for ADI Blackfin"); | 1013 | MODULE_DESCRIPTION("SPORT driver for ADI Blackfin"); |
1031 | MODULE_LICENSE("GPL"); | 1014 | MODULE_LICENSE("GPL"); |
1032 | |||