Commit 8836c273 authored by Mike Frysinger's avatar Mike Frysinger Committed by Mark Brown

ASoC: Blackfin: drop unnecessary dma casts

Signed-off-by: default avatarMike Frysinger <vapier.adi@gmail.com>
Signed-off-by: default avatarBryan Wu <cooloney@kernel.org>
Signed-off-by: default avatarMark Brown <broonie@opensource.wolfsonmicro.com>
parent 92a950ff
...@@ -133,7 +133,7 @@ static void setup_desc(struct dmasg *desc, void *buf, int fragcount, ...@@ -133,7 +133,7 @@ static void setup_desc(struct dmasg *desc, void *buf, int fragcount,
int i; int i;
for (i = 0; i < fragcount; ++i) { for (i = 0; i < fragcount; ++i) {
desc[i].next_desc_addr = (unsigned long)&(desc[i + 1]); desc[i].next_desc_addr = &(desc[i + 1]);
desc[i].start_addr = (unsigned long)buf + i*fragsize; desc[i].start_addr = (unsigned long)buf + i*fragsize;
desc[i].cfg = cfg; desc[i].cfg = cfg;
desc[i].x_count = x_count; desc[i].x_count = x_count;
...@@ -143,12 +143,12 @@ static void setup_desc(struct dmasg *desc, void *buf, int fragcount, ...@@ -143,12 +143,12 @@ static void setup_desc(struct dmasg *desc, void *buf, int fragcount,
} }
/* make circular */ /* make circular */
desc[fragcount-1].next_desc_addr = (unsigned long)desc; desc[fragcount-1].next_desc_addr = desc;
pr_debug("setup desc: desc0=%p, next0=%lx, desc1=%p," pr_debug("setup desc: desc0=%p, next0=%p, desc1=%p,"
"next1=%lx\nx_count=%x,y_count=%x,addr=0x%lx,cfs=0x%x\n", "next1=%p\nx_count=%x,y_count=%x,addr=0x%lx,cfs=0x%x\n",
&(desc[0]), desc[0].next_desc_addr, desc, desc[0].next_desc_addr,
&(desc[1]), desc[1].next_desc_addr, desc+1, desc[1].next_desc_addr,
desc[0].x_count, desc[0].y_count, desc[0].x_count, desc[0].y_count,
desc[0].start_addr, desc[0].cfg); desc[0].start_addr, desc[0].cfg);
} }
...@@ -184,22 +184,20 @@ static inline int sport_hook_rx_dummy(struct sport_device *sport) ...@@ -184,22 +184,20 @@ static inline int sport_hook_rx_dummy(struct sport_device *sport)
BUG_ON(sport->curr_rx_desc == sport->dummy_rx_desc); BUG_ON(sport->curr_rx_desc == sport->dummy_rx_desc);
/* Maybe the dummy buffer descriptor ring is damaged */ /* Maybe the dummy buffer descriptor ring is damaged */
sport->dummy_rx_desc->next_desc_addr = \ sport->dummy_rx_desc->next_desc_addr = sport->dummy_rx_desc + 1;
(unsigned long)(sport->dummy_rx_desc+1);
local_irq_save(flags); local_irq_save(flags);
desc = (struct dmasg *)get_dma_next_desc_ptr(sport->dma_rx_chan); desc = get_dma_next_desc_ptr(sport->dma_rx_chan);
/* Copy the descriptor which will be damaged to backup */ /* Copy the descriptor which will be damaged to backup */
temp_desc = *desc; temp_desc = *desc;
desc->x_count = 0xa; desc->x_count = 0xa;
desc->y_count = 0; desc->y_count = 0;
desc->next_desc_addr = (unsigned long)(sport->dummy_rx_desc); desc->next_desc_addr = sport->dummy_rx_desc;
local_irq_restore(flags); local_irq_restore(flags);
/* Waiting for dummy buffer descriptor is already hooked*/ /* Waiting for dummy buffer descriptor is already hooked*/
while ((get_dma_curr_desc_ptr(sport->dma_rx_chan) - while ((get_dma_curr_desc_ptr(sport->dma_rx_chan) -
sizeof(struct dmasg)) != sizeof(struct dmasg)) != sport->dummy_rx_desc)
(unsigned long)sport->dummy_rx_desc) continue;
;
sport->curr_rx_desc = sport->dummy_rx_desc; sport->curr_rx_desc = sport->dummy_rx_desc;
/* Restore the damaged descriptor */ /* Restore the damaged descriptor */
*desc = temp_desc; *desc = temp_desc;
...@@ -210,14 +208,12 @@ static inline int sport_hook_rx_dummy(struct sport_device *sport) ...@@ -210,14 +208,12 @@ static inline int sport_hook_rx_dummy(struct sport_device *sport)
static inline int sport_rx_dma_start(struct sport_device *sport, int dummy) static inline int sport_rx_dma_start(struct sport_device *sport, int dummy)
{ {
if (dummy) { if (dummy) {
sport->dummy_rx_desc->next_desc_addr = \ sport->dummy_rx_desc->next_desc_addr = sport->dummy_rx_desc;
(unsigned long) sport->dummy_rx_desc;
sport->curr_rx_desc = sport->dummy_rx_desc; sport->curr_rx_desc = sport->dummy_rx_desc;
} else } else
sport->curr_rx_desc = sport->dma_rx_desc; sport->curr_rx_desc = sport->dma_rx_desc;
set_dma_next_desc_addr(sport->dma_rx_chan, \ set_dma_next_desc_addr(sport->dma_rx_chan, sport->curr_rx_desc);
(unsigned long)(sport->curr_rx_desc));
set_dma_x_count(sport->dma_rx_chan, 0); set_dma_x_count(sport->dma_rx_chan, 0);
set_dma_x_modify(sport->dma_rx_chan, 0); set_dma_x_modify(sport->dma_rx_chan, 0);
set_dma_config(sport->dma_rx_chan, (DMAFLOW_LARGE | NDSIZE_9 | \ 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,14 +227,12 @@ static inline int sport_rx_dma_start(struct sport_device *sport, int dummy)
static inline int sport_tx_dma_start(struct sport_device *sport, int dummy) static inline int sport_tx_dma_start(struct sport_device *sport, int dummy)
{ {
if (dummy) { if (dummy) {
sport->dummy_tx_desc->next_desc_addr = \ sport->dummy_tx_desc->next_desc_addr = sport->dummy_tx_desc;
(unsigned long) sport->dummy_tx_desc;
sport->curr_tx_desc = sport->dummy_tx_desc; sport->curr_tx_desc = sport->dummy_tx_desc;
} else } else
sport->curr_tx_desc = sport->dma_tx_desc; sport->curr_tx_desc = sport->dma_tx_desc;
set_dma_next_desc_addr(sport->dma_tx_chan, \ set_dma_next_desc_addr(sport->dma_tx_chan, sport->curr_tx_desc);
(unsigned long)(sport->curr_tx_desc));
set_dma_x_count(sport->dma_tx_chan, 0); set_dma_x_count(sport->dma_tx_chan, 0);
set_dma_x_modify(sport->dma_tx_chan, 0); set_dma_x_modify(sport->dma_tx_chan, 0);
set_dma_config(sport->dma_tx_chan, set_dma_config(sport->dma_tx_chan,
...@@ -261,11 +255,9 @@ int sport_rx_start(struct sport_device *sport) ...@@ -261,11 +255,9 @@ int sport_rx_start(struct sport_device *sport)
BUG_ON(sport->curr_rx_desc != sport->dummy_rx_desc); BUG_ON(sport->curr_rx_desc != sport->dummy_rx_desc);
local_irq_save(flags); local_irq_save(flags);
while ((get_dma_curr_desc_ptr(sport->dma_rx_chan) - while ((get_dma_curr_desc_ptr(sport->dma_rx_chan) -
sizeof(struct dmasg)) != sizeof(struct dmasg)) != sport->dummy_rx_desc)
(unsigned long)sport->dummy_rx_desc) continue;
; sport->dummy_rx_desc->next_desc_addr = sport->dma_rx_desc;
sport->dummy_rx_desc->next_desc_addr =
(unsigned long)(sport->dma_rx_desc);
local_irq_restore(flags); local_irq_restore(flags);
sport->curr_rx_desc = sport->dma_rx_desc; sport->curr_rx_desc = sport->dma_rx_desc;
} else { } else {
...@@ -310,23 +302,21 @@ static inline int sport_hook_tx_dummy(struct sport_device *sport) ...@@ -310,23 +302,21 @@ static inline int sport_hook_tx_dummy(struct sport_device *sport)
BUG_ON(sport->dummy_tx_desc == NULL); BUG_ON(sport->dummy_tx_desc == NULL);
BUG_ON(sport->curr_tx_desc == sport->dummy_tx_desc); BUG_ON(sport->curr_tx_desc == sport->dummy_tx_desc);
sport->dummy_tx_desc->next_desc_addr = \ sport->dummy_tx_desc->next_desc_addr = sport->dummy_tx_desc + 1;
(unsigned long)(sport->dummy_tx_desc+1);
/* Shorten the time on last normal descriptor */ /* Shorten the time on last normal descriptor */
local_irq_save(flags); local_irq_save(flags);
desc = (struct dmasg *)get_dma_next_desc_ptr(sport->dma_tx_chan); desc = get_dma_next_desc_ptr(sport->dma_tx_chan);
/* Store the descriptor which will be damaged */ /* Store the descriptor which will be damaged */
temp_desc = *desc; temp_desc = *desc;
desc->x_count = 0xa; desc->x_count = 0xa;
desc->y_count = 0; desc->y_count = 0;
desc->next_desc_addr = (unsigned long)(sport->dummy_tx_desc); desc->next_desc_addr = sport->dummy_tx_desc;
local_irq_restore(flags); local_irq_restore(flags);
/* Waiting for dummy buffer descriptor is already hooked*/ /* Waiting for dummy buffer descriptor is already hooked*/
while ((get_dma_curr_desc_ptr(sport->dma_tx_chan) - \ while ((get_dma_curr_desc_ptr(sport->dma_tx_chan) - \
sizeof(struct dmasg)) != \ sizeof(struct dmasg)) != sport->dummy_tx_desc)
(unsigned long)sport->dummy_tx_desc) continue;
;
sport->curr_tx_desc = sport->dummy_tx_desc; sport->curr_tx_desc = sport->dummy_tx_desc;
/* Restore the damaged descriptor */ /* Restore the damaged descriptor */
*desc = temp_desc; *desc = temp_desc;
...@@ -347,11 +337,9 @@ int sport_tx_start(struct sport_device *sport) ...@@ -347,11 +337,9 @@ int sport_tx_start(struct sport_device *sport)
/* Hook the normal buffer descriptor */ /* Hook the normal buffer descriptor */
local_irq_save(flags); local_irq_save(flags);
while ((get_dma_curr_desc_ptr(sport->dma_tx_chan) - while ((get_dma_curr_desc_ptr(sport->dma_tx_chan) -
sizeof(struct dmasg)) != sizeof(struct dmasg)) != sport->dummy_tx_desc)
(unsigned long)sport->dummy_tx_desc) continue;
; sport->dummy_tx_desc->next_desc_addr = sport->dma_tx_desc;
sport->dummy_tx_desc->next_desc_addr =
(unsigned long)(sport->dma_tx_desc);
local_irq_restore(flags); local_irq_restore(flags);
sport->curr_tx_desc = sport->dma_tx_desc; sport->curr_tx_desc = sport->dma_tx_desc;
} else { } else {
...@@ -536,19 +524,17 @@ static int sport_config_rx_dummy(struct sport_device *sport) ...@@ -536,19 +524,17 @@ static int sport_config_rx_dummy(struct sport_device *sport)
unsigned config; unsigned config;
pr_debug("%s entered\n", __func__); pr_debug("%s entered\n", __func__);
#if L1_DATA_A_LENGTH != 0 if (L1_DATA_A_LENGTH)
desc = (struct dmasg *) l1_data_sram_alloc(2 * sizeof(*desc)); desc = l1_data_sram_zalloc(2 * sizeof(*desc));
#else else {
{
dma_addr_t addr; dma_addr_t addr;
desc = dma_alloc_coherent(NULL, 2 * sizeof(*desc), &addr, 0); desc = dma_alloc_coherent(NULL, 2 * sizeof(*desc), &addr, 0);
memset(desc, 0, 2 * sizeof(*desc));
} }
#endif
if (desc == NULL) { if (desc == NULL) {
pr_err("Failed to allocate memory for dummy rx desc\n"); pr_err("Failed to allocate memory for dummy rx desc\n");
return -ENOMEM; return -ENOMEM;
} }
memset(desc, 0, 2 * sizeof(*desc));
sport->dummy_rx_desc = desc; sport->dummy_rx_desc = desc;
desc->start_addr = (unsigned long)sport->dummy_buf; desc->start_addr = (unsigned long)sport->dummy_buf;
config = DMAFLOW_LARGE | NDSIZE_9 | compute_wdsize(sport->wdsize) config = DMAFLOW_LARGE | NDSIZE_9 | compute_wdsize(sport->wdsize)
...@@ -559,8 +545,8 @@ static int sport_config_rx_dummy(struct sport_device *sport) ...@@ -559,8 +545,8 @@ static int sport_config_rx_dummy(struct sport_device *sport)
desc->y_count = 0; desc->y_count = 0;
desc->y_modify = 0; desc->y_modify = 0;
memcpy(desc+1, desc, sizeof(*desc)); memcpy(desc+1, desc, sizeof(*desc));
desc->next_desc_addr = (unsigned long)(desc+1); desc->next_desc_addr = desc + 1;
desc[1].next_desc_addr = (unsigned long)desc; desc[1].next_desc_addr = desc;
return 0; return 0;
} }
...@@ -571,19 +557,17 @@ static int sport_config_tx_dummy(struct sport_device *sport) ...@@ -571,19 +557,17 @@ static int sport_config_tx_dummy(struct sport_device *sport)
pr_debug("%s entered\n", __func__); pr_debug("%s entered\n", __func__);
#if L1_DATA_A_LENGTH != 0 if (L1_DATA_A_LENGTH)
desc = (struct dmasg *) l1_data_sram_alloc(2 * sizeof(*desc)); desc = l1_data_sram_zalloc(2 * sizeof(*desc));
#else else {
{
dma_addr_t addr; dma_addr_t addr;
desc = dma_alloc_coherent(NULL, 2 * sizeof(*desc), &addr, 0); desc = dma_alloc_coherent(NULL, 2 * sizeof(*desc), &addr, 0);
memset(desc, 0, 2 * sizeof(*desc));
} }
#endif
if (!desc) { if (!desc) {
pr_err("Failed to allocate memory for dummy tx desc\n"); pr_err("Failed to allocate memory for dummy tx desc\n");
return -ENOMEM; return -ENOMEM;
} }
memset(desc, 0, 2 * sizeof(*desc));
sport->dummy_tx_desc = desc; sport->dummy_tx_desc = desc;
desc->start_addr = (unsigned long)sport->dummy_buf + \ desc->start_addr = (unsigned long)sport->dummy_buf + \
sport->dummy_count; sport->dummy_count;
...@@ -595,8 +579,8 @@ static int sport_config_tx_dummy(struct sport_device *sport) ...@@ -595,8 +579,8 @@ static int sport_config_tx_dummy(struct sport_device *sport)
desc->y_count = 0; desc->y_count = 0;
desc->y_modify = 0; desc->y_modify = 0;
memcpy(desc+1, desc, sizeof(*desc)); memcpy(desc+1, desc, sizeof(*desc));
desc->next_desc_addr = (unsigned long)(desc+1); desc->next_desc_addr = desc + 1;
desc[1].next_desc_addr = (unsigned long)desc; desc[1].next_desc_addr = desc;
return 0; return 0;
} }
...@@ -872,17 +856,15 @@ struct sport_device *sport_init(struct sport_param *param, unsigned wdsize, ...@@ -872,17 +856,15 @@ struct sport_device *sport_init(struct sport_param *param, unsigned wdsize,
sport->wdsize = wdsize; sport->wdsize = wdsize;
sport->dummy_count = dummy_count; sport->dummy_count = dummy_count;
#if L1_DATA_A_LENGTH != 0 if (L1_DATA_A_LENGTH)
sport->dummy_buf = l1_data_sram_alloc(dummy_count * 2); sport->dummy_buf = l1_data_sram_zalloc(dummy_count * 2);
#else else
sport->dummy_buf = kmalloc(dummy_count * 2, GFP_KERNEL); sport->dummy_buf = kzalloc(dummy_count * 2, GFP_KERNEL);
#endif
if (sport->dummy_buf == NULL) { if (sport->dummy_buf == NULL) {
pr_err("Failed to allocate dummy buffer\n"); pr_err("Failed to allocate dummy buffer\n");
goto __error; goto __error;
} }
memset(sport->dummy_buf, 0, dummy_count * 2);
ret = sport_config_rx_dummy(sport); ret = sport_config_rx_dummy(sport);
if (ret) { if (ret) {
pr_err("Failed to config rx dummy ring\n"); pr_err("Failed to config rx dummy ring\n");
...@@ -939,6 +921,7 @@ void sport_done(struct sport_device *sport) ...@@ -939,6 +921,7 @@ void sport_done(struct sport_device *sport)
sport = NULL; sport = NULL;
} }
EXPORT_SYMBOL(sport_done); EXPORT_SYMBOL(sport_done);
/* /*
* It is only used to send several bytes when dma is not enabled * It is only used to send several bytes when dma is not enabled
* sport controller is configured but not enabled. * sport controller is configured but not enabled.
...@@ -1029,4 +1012,3 @@ EXPORT_SYMBOL(sport_send_and_recv); ...@@ -1029,4 +1012,3 @@ EXPORT_SYMBOL(sport_send_and_recv);
MODULE_AUTHOR("Roy Huang"); MODULE_AUTHOR("Roy Huang");
MODULE_DESCRIPTION("SPORT driver for ADI Blackfin"); MODULE_DESCRIPTION("SPORT driver for ADI Blackfin");
MODULE_LICENSE("GPL"); MODULE_LICENSE("GPL");
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