Commit 92a950ff authored by Mike Frysinger's avatar Mike Frysinger Committed by Mark Brown

ASoC: Blackfin: cleanup sport handling in ASoC Blackfin AC97 code

- make sport number handling more dynamic as not all
  Blackfins have a linear sport map starting at 0
- indexes can be macroed away too
Signed-off-by: default avatarMike Frysinger <vapier.adi@gmail.com>
Signed-off-by: default avatarCliff Cai <cliff.cai@analog.com>
Signed-off-by: default avatarBryan Wu <cooloney@kernel.org>
Signed-off-by: default avatarMark Brown <broonie@opensource.wolfsonmicro.com>
parent 0664678a
...@@ -31,72 +31,46 @@ ...@@ -31,72 +31,46 @@
#include "bf5xx-sport.h" #include "bf5xx-sport.h"
#include "bf5xx-ac97.h" #include "bf5xx-ac97.h"
#if defined(CONFIG_BF54x)
#define PIN_REQ_SPORT_0 {P_SPORT0_TFS, P_SPORT0_DTPRI, P_SPORT0_TSCLK, \
P_SPORT0_RFS, P_SPORT0_DRPRI, P_SPORT0_RSCLK, 0}
#define PIN_REQ_SPORT_1 {P_SPORT1_TFS, P_SPORT1_DTPRI, P_SPORT1_TSCLK, \
P_SPORT1_RFS, P_SPORT1_DRPRI, P_SPORT1_RSCLK, 0}
#define PIN_REQ_SPORT_2 {P_SPORT2_TFS, P_SPORT2_DTPRI, P_SPORT2_TSCLK, \
P_SPORT2_RFS, P_SPORT2_DRPRI, P_SPORT2_RSCLK, 0}
#define PIN_REQ_SPORT_3 {P_SPORT3_TFS, P_SPORT3_DTPRI, P_SPORT3_TSCLK, \
P_SPORT3_RFS, P_SPORT3_DRPRI, P_SPORT3_RSCLK, 0}
#else
#define PIN_REQ_SPORT_0 {P_SPORT0_DTPRI, P_SPORT0_TSCLK, P_SPORT0_RFS, \
P_SPORT0_DRPRI, P_SPORT0_RSCLK, 0}
#define PIN_REQ_SPORT_1 {P_SPORT1_DTPRI, P_SPORT1_TSCLK, P_SPORT1_RFS, \
P_SPORT1_DRPRI, P_SPORT1_RSCLK, 0}
#endif
static int *cmd_count; static int *cmd_count;
static int sport_num = CONFIG_SND_BF5XX_SPORT_NUM; static int sport_num = CONFIG_SND_BF5XX_SPORT_NUM;
#define SPORT_REQ(x) \
[x] = {P_SPORT##x##_TFS, P_SPORT##x##_DTPRI, P_SPORT##x##_TSCLK, \
P_SPORT##x##_RFS, P_SPORT##x##_DRPRI, P_SPORT##x##_RSCLK, 0}
static u16 sport_req[][7] = { static u16 sport_req[][7] = {
PIN_REQ_SPORT_0, #ifdef SPORT0_TCR1
#ifdef PIN_REQ_SPORT_1 SPORT_REQ(0),
PIN_REQ_SPORT_1,
#endif #endif
#ifdef PIN_REQ_SPORT_2 #ifdef SPORT1_TCR1
PIN_REQ_SPORT_2, SPORT_REQ(1),
#endif #endif
#ifdef PIN_REQ_SPORT_3 #ifdef SPORT2_TCR1
PIN_REQ_SPORT_3, SPORT_REQ(2),
#endif #endif
}; #ifdef SPORT3_TCR1
SPORT_REQ(3),
#endif
};
#define SPORT_PARAMS(x) \
[x] = { \
.dma_rx_chan = CH_SPORT##x##_RX, \
.dma_tx_chan = CH_SPORT##x##_TX, \
.err_irq = IRQ_SPORT##x##_ERROR, \
.regs = (struct sport_register *)SPORT##x##_TCR1, \
}
static struct sport_param sport_params[4] = { static struct sport_param sport_params[4] = {
{ #ifdef SPORT0_TCR1
.dma_rx_chan = CH_SPORT0_RX, SPORT_PARAMS(0),
.dma_tx_chan = CH_SPORT0_TX,
.err_irq = IRQ_SPORT0_ERROR,
.regs = (struct sport_register *)SPORT0_TCR1,
},
#ifdef PIN_REQ_SPORT_1
{
.dma_rx_chan = CH_SPORT1_RX,
.dma_tx_chan = CH_SPORT1_TX,
.err_irq = IRQ_SPORT1_ERROR,
.regs = (struct sport_register *)SPORT1_TCR1,
},
#endif #endif
#ifdef PIN_REQ_SPORT_2 #ifdef SPORT1_TCR1
{ SPORT_PARAMS(1),
.dma_rx_chan = CH_SPORT2_RX,
.dma_tx_chan = CH_SPORT2_TX,
.err_irq = IRQ_SPORT2_ERROR,
.regs = (struct sport_register *)SPORT2_TCR1,
},
#endif #endif
#ifdef PIN_REQ_SPORT_3 #ifdef SPORT2_TCR1
{ SPORT_PARAMS(2),
.dma_rx_chan = CH_SPORT3_RX, #endif
.dma_tx_chan = CH_SPORT3_TX, #ifdef SPORT3_TCR1
.err_irq = IRQ_SPORT3_ERROR, SPORT_PARAMS(3),
.regs = (struct sport_register *)SPORT3_TCR1,
}
#endif #endif
}; };
...@@ -332,11 +306,11 @@ static int bf5xx_ac97_probe(struct platform_device *pdev, ...@@ -332,11 +306,11 @@ static int bf5xx_ac97_probe(struct platform_device *pdev,
if (cmd_count == NULL) if (cmd_count == NULL)
return -ENOMEM; return -ENOMEM;
if (peripheral_request_list(&sport_req[sport_num][0], "soc-audio")) { if (peripheral_request_list(sport_req[sport_num], "soc-audio")) {
pr_err("Requesting Peripherals failed\n"); pr_err("Requesting Peripherals failed\n");
ret = -EFAULT; ret = -EFAULT;
goto peripheral_err; goto peripheral_err;
} }
#ifdef CONFIG_SND_BF5XX_HAVE_COLD_RESET #ifdef CONFIG_SND_BF5XX_HAVE_COLD_RESET
/* Request PB3 as reset pin */ /* Request PB3 as reset pin */
...@@ -385,7 +359,7 @@ static int bf5xx_ac97_probe(struct platform_device *pdev, ...@@ -385,7 +359,7 @@ static int bf5xx_ac97_probe(struct platform_device *pdev,
gpio_free(CONFIG_SND_BF5XX_RESET_GPIO_NUM); gpio_free(CONFIG_SND_BF5XX_RESET_GPIO_NUM);
#endif #endif
gpio_err: gpio_err:
peripheral_free_list(&sport_req[sport_num][0]); peripheral_free_list(sport_req[sport_num]);
peripheral_err: peripheral_err:
free_page((unsigned long)cmd_count); free_page((unsigned long)cmd_count);
cmd_count = NULL; cmd_count = NULL;
...@@ -398,7 +372,7 @@ static void bf5xx_ac97_remove(struct platform_device *pdev, ...@@ -398,7 +372,7 @@ static void bf5xx_ac97_remove(struct platform_device *pdev,
{ {
free_page((unsigned long)cmd_count); free_page((unsigned long)cmd_count);
cmd_count = NULL; cmd_count = NULL;
peripheral_free_list(&sport_req[sport_num][0]); peripheral_free_list(sport_req[sport_num]);
#ifdef CONFIG_SND_BF5XX_HAVE_COLD_RESET #ifdef CONFIG_SND_BF5XX_HAVE_COLD_RESET
gpio_free(CONFIG_SND_BF5XX_RESET_GPIO_NUM); gpio_free(CONFIG_SND_BF5XX_RESET_GPIO_NUM);
#endif #endif
......
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