diff --git a/asoc/codecs/wcd-spi.c b/asoc/codecs/wcd-spi.c index 4c7a85338ed4..3834374a65a8 100644 --- a/asoc/codecs/wcd-spi.c +++ b/asoc/codecs/wcd-spi.c @@ -1,6 +1,6 @@ // SPDX-License-Identifier: GPL-2.0-only /* - * Copyright (c) 2016-2019, The Linux Foundation. All rights reserved. + * Copyright (c) 2016-2020, The Linux Foundation. All rights reserved. */ #include @@ -1531,6 +1531,17 @@ static const struct component_ops wcd_spi_component_ops = { .unbind = wcd_spi_component_unbind, }; +#ifdef CONFIG_WCD_SPI_DMA_MASKING +static void arch_setup_spi_archdata(struct spi_device *spi) +{ + if (spi->dev.coherent_dma_mask == DMA_MASK_NONE && + spi->dev.dma_mask == NULL) { + spi->dev.coherent_dma_mask = DMA_BIT_MASK(sizeof(dma_addr_t) * 8); + spi->dev.dma_mask = &spi->dev.coherent_dma_mask; + } +} +#endif + static int wcd_spi_probe(struct spi_device *spi) { struct wcd_spi_priv *wcd_spi; @@ -1557,8 +1568,11 @@ static int wcd_spi_probe(struct spi_device *spi) mutex_init(&wcd_spi->xfer_mutex); INIT_DELAYED_WORK(&wcd_spi->clk_dwork, wcd_spi_clk_work); init_completion(&wcd_spi->resume_comp); - arch_setup_dma_ops(&spi->dev, 0, 0, NULL, true); +#ifdef CONFIG_WCD_SPI_DMA_MASKING + arch_setup_spi_archdata(spi); +#endif + arch_setup_dma_ops(&spi->dev, 0, 0, NULL, true); wcd_spi->spi = spi; spi_set_drvdata(spi, wcd_spi);