Skip to content

Commit 9ac0013

Browse files
Peter Ujfalusibroonie
authored andcommitted
ASoC: davinci-mcasp: Fix dra7 DMA offset when using CFG port
The TX and RX offset is different for each serializers when using the CFG port for DMA access. When using the CFG port only one serializer can be used per direction so print error message and only configure the first serializer's offset. Reported-by: Misael Lopez Cruz <[email protected]> Suggested-by: Misael Lopez Cruz <[email protected]> Signed-off-by: Peter Ujfalusi <[email protected]> Signed-off-by: Mark Brown <[email protected]>
1 parent 1a695a9 commit 9ac0013

File tree

2 files changed

+54
-6
lines changed

2 files changed

+54
-6
lines changed

sound/soc/davinci/davinci-mcasp.c

Lines changed: 52 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1513,8 +1513,9 @@ static struct davinci_mcasp_pdata am33xx_mcasp_pdata = {
15131513
};
15141514

15151515
static struct davinci_mcasp_pdata dra7_mcasp_pdata = {
1516-
.tx_dma_offset = 0x200,
1517-
.rx_dma_offset = 0x284,
1516+
/* The CFG port offset will be calculated if it is needed */
1517+
.tx_dma_offset = 0,
1518+
.rx_dma_offset = 0,
15181519
.version = MCASP_VERSION_4,
15191520
};
15201521

@@ -1734,6 +1735,52 @@ static int davinci_mcasp_get_dma_type(struct davinci_mcasp *mcasp)
17341735
return PCM_EDMA;
17351736
}
17361737

1738+
static u32 davinci_mcasp_txdma_offset(struct davinci_mcasp_pdata *pdata)
1739+
{
1740+
int i;
1741+
u32 offset = 0;
1742+
1743+
if (pdata->version != MCASP_VERSION_4)
1744+
return pdata->tx_dma_offset;
1745+
1746+
for (i = 0; i < pdata->num_serializer; i++) {
1747+
if (pdata->serial_dir[i] == TX_MODE) {
1748+
if (!offset) {
1749+
offset = DAVINCI_MCASP_TXBUF_REG(i);
1750+
} else {
1751+
pr_err("%s: Only one serializer allowed!\n",
1752+
__func__);
1753+
break;
1754+
}
1755+
}
1756+
}
1757+
1758+
return offset;
1759+
}
1760+
1761+
static u32 davinci_mcasp_rxdma_offset(struct davinci_mcasp_pdata *pdata)
1762+
{
1763+
int i;
1764+
u32 offset = 0;
1765+
1766+
if (pdata->version != MCASP_VERSION_4)
1767+
return pdata->rx_dma_offset;
1768+
1769+
for (i = 0; i < pdata->num_serializer; i++) {
1770+
if (pdata->serial_dir[i] == RX_MODE) {
1771+
if (!offset) {
1772+
offset = DAVINCI_MCASP_RXBUF_REG(i);
1773+
} else {
1774+
pr_err("%s: Only one serializer allowed!\n",
1775+
__func__);
1776+
break;
1777+
}
1778+
}
1779+
}
1780+
1781+
return offset;
1782+
}
1783+
17371784
static int davinci_mcasp_probe(struct platform_device *pdev)
17381785
{
17391786
struct snd_dmaengine_dai_dma_data *dma_data;
@@ -1862,7 +1909,7 @@ static int davinci_mcasp_probe(struct platform_device *pdev)
18621909
if (dat)
18631910
dma_data->addr = dat->start;
18641911
else
1865-
dma_data->addr = mem->start + pdata->tx_dma_offset;
1912+
dma_data->addr = mem->start + davinci_mcasp_txdma_offset(pdata);
18661913

18671914
dma = &mcasp->dma_request[SNDRV_PCM_STREAM_PLAYBACK];
18681915
res = platform_get_resource(pdev, IORESOURCE_DMA, 0);
@@ -1883,7 +1930,8 @@ static int davinci_mcasp_probe(struct platform_device *pdev)
18831930
if (dat)
18841931
dma_data->addr = dat->start;
18851932
else
1886-
dma_data->addr = mem->start + pdata->rx_dma_offset;
1933+
dma_data->addr =
1934+
mem->start + davinci_mcasp_rxdma_offset(pdata);
18871935

18881936
dma = &mcasp->dma_request[SNDRV_PCM_STREAM_CAPTURE];
18891937
res = platform_get_resource(pdev, IORESOURCE_DMA, 1);

sound/soc/davinci/davinci-mcasp.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,9 +85,9 @@
8585
(n << 2))
8686

8787
/* Transmit Buffer for Serializer n */
88-
#define DAVINCI_MCASP_TXBUF_REG 0x200
88+
#define DAVINCI_MCASP_TXBUF_REG(n) (0x200 + (n << 2))
8989
/* Receive Buffer for Serializer n */
90-
#define DAVINCI_MCASP_RXBUF_REG 0x280
90+
#define DAVINCI_MCASP_RXBUF_REG(n) (0x280 + (n << 2))
9191

9292
/* McASP FIFO Registers */
9393
#define DAVINCI_MCASP_V2_AFIFO_BASE (0x1010)

0 commit comments

Comments
 (0)