From patchwork Mon Nov 16 16:00:21 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 7628581 Return-Path: X-Original-To: patchwork-linux-spi@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 162629F2EC for ; Mon, 16 Nov 2015 16:01:50 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id EABFD20501 for ; Mon, 16 Nov 2015 16:01:48 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 92C742049E for ; Mon, 16 Nov 2015 16:01:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753090AbbKPQBG (ORCPT ); Mon, 16 Nov 2015 11:01:06 -0500 Received: from mout.kundenserver.de ([212.227.17.24]:59743 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752501AbbKPQBB (ORCPT ); Mon, 16 Nov 2015 11:01:01 -0500 Received: from wuerfel.localnet ([134.3.118.24]) by mrelayeu.kundenserver.de (mreue103) with ESMTPSA (Nemesis) id 0MBZzS-1a8lo60jIM-00AXo2; Mon, 16 Nov 2015 17:00:24 +0100 From: Arnd Bergmann To: Mark Brown , linux-spi@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Kukjin Kim , Krzysztof Kozlowski , linux-arm-kernel@lists.infradead.org, linux-samsung-soc@vger.kernel.org Subject: [PATCH] SPI: s3c64xx: pass DMA arguments in platform data Date: Mon, 16 Nov 2015 17:00:21 +0100 Message-ID: <8391350.6B0EUH1WXO@wuerfel> User-Agent: KMail/4.11.5 (Linux/3.16.0-10-generic; KDE/4.11.5; x86_64; ; ) MIME-Version: 1.0 X-Provags-ID: V03:K0:IEUpRSuAFLFc/gaIaMo2YIQJZMOOwmHiK2GIQEy/mQ0L94lTuWq vLGZZ0UYMAR3LRyoH/QBql3dbVanY8xhF4kNkiWoDEuIAorlppif9a+i5ozhWGFHNyajgMO XHP/e1o7E9iMrD6nAnG0JuwkD8SqTbgKWPJXZ1ZYDziY1SJs1gF1jC+7R0+2IdJ6tsIUos3 i9IM236wqseO7xSl6CnBA== X-UI-Out-Filterresults: notjunk:1; V01:K0:TTjg+dxphuY=:hUXKoXn5m9Oity786RdwUF rmi+xSXwaz3Ln9NnX5QUQWL1iTxiry4YAJSPl2wVQ0itB4pF5dE689sObpAT/PMqWceMKuKb3 NgqNwjzd1Z1GNzCupw8LIMHq2CCRkALUyKf2Jc7qFIzdCESpHYBFRX/oPYXi9oqcGj/XYtpxn shJjMglRkf/ZqEC7Jom80cHFP0aHz0iEd+IvvhPlk7OAgD8suJfjy3awPsaSVfzBg4mT8v5B+ DXQ9IsDyoQ8vNppyOK0jJ4ldgK97DRob6Jofb37E6gj+wvWssjQXoT9lFO5o4oQ/UYRUDoz3t D61h9Me0VdHCw02CrKHMA0KJNRReesRmXiCXyWW4kIv81wQfQePFPWoY8J4BQgJ428gaC9Tij prAtOYX55ZPwD2zvg9aMLC6mymMiVCCDw+gNpAgZIcZzTKfwCr3o3kSEa82zMKAXpwaRxIspT aQBdI1L3x3CLUMwum9IPWALqkusi5jX4HiwzerNwv3S5LdXYOhNuppfj1ZtcNPy1R1fV6CQbu 53MglDUHx9DE/MlKgNjiWO6Gk2ZR3cOj3wlwf+wjXKDt3rWko9VLbweFXYlVNReB+TxjjRk1R ScGGp9+TSfl8xj3fwASvn9V0V9Vj66AmdDXQdT8/b+8M5+hGq7aZ566RElciK5j4x2mErVJYl 04glqU46emZM37YAwmT5lfwyVo6ot4i5kCHoEUzh10TPu+gmO03HWFwKyt5scXM1rSoTlMb61 3hNFGCOHInWazHoP Sender: linux-spi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-spi@vger.kernel.org X-Spam-Status: No, score=-7.7 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The s3c64xx platform data already contains a pointer to the DMA filter function, but not to the associated data. This simplifies the code and makes it more generic by passing the data along with the filter function like we do for other drivers. Signed-off-by: Arnd Bergmann --- arch/arm/plat-samsung/devs.c | 32 ++++++++++++++------------------ drivers/spi/spi-s3c64xx.c | 28 ++++++++-------------------- include/linux/platform_data/spi-s3c64xx.h | 2 ++ 3 files changed, 24 insertions(+), 38 deletions(-) -- To unsubscribe from this list: send the line "unsubscribe linux-spi" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/arch/arm/plat-samsung/devs.c b/arch/arm/plat-samsung/devs.c index 314131a4525d..817981c05d73 100644 --- a/arch/arm/plat-samsung/devs.c +++ b/arch/arm/plat-samsung/devs.c @@ -1105,9 +1105,7 @@ struct platform_device s3c_device_wdt = { #ifdef CONFIG_S3C64XX_DEV_SPI0 static struct resource s3c64xx_spi0_resource[] = { [0] = DEFINE_RES_MEM(S3C_PA_SPI0, SZ_256), - [1] = DEFINE_RES_DMA((uintptr_t)DMACH_SPI0_TX), - [2] = DEFINE_RES_DMA((uintptr_t)DMACH_SPI0_RX), - [3] = DEFINE_RES_IRQ(IRQ_SPI0), + [1] = DEFINE_RES_IRQ(IRQ_SPI0), }; struct platform_device s3c64xx_device_spi0 = { @@ -1135,11 +1133,13 @@ void __init s3c64xx_spi0_set_platdata(int (*cfg_gpio)(void), int src_clk_nr, pd.num_cs = num_cs; pd.src_clk_nr = src_clk_nr; pd.cfg_gpio = (cfg_gpio) ? cfg_gpio : s3c64xx_spi0_cfg_gpio; -#if defined(CONFIG_PL330_DMA) - pd.filter = pl330_filter; -#elif defined(CONFIG_S3C64XX_PL080) +#if defined(CONFIG_S3C64XX_PL080) + pd.dma_tx = DMACH_SPI0_TX; + pd.dma_rx = DMACH_SPI0_RX; pd.filter = pl08x_filter_id; #elif defined(CONFIG_S3C24XX_DMAC) + pd.dma_tx = (void *)DMACH_SPI0_TX; + pd.dma_rx = (void *)DMACH_SPI0_RX; pd.filter = s3c24xx_dma_filter; #endif @@ -1150,9 +1150,7 @@ void __init s3c64xx_spi0_set_platdata(int (*cfg_gpio)(void), int src_clk_nr, #ifdef CONFIG_S3C64XX_DEV_SPI1 static struct resource s3c64xx_spi1_resource[] = { [0] = DEFINE_RES_MEM(S3C_PA_SPI1, SZ_256), - [1] = DEFINE_RES_DMA((uintptr_t)DMACH_SPI1_TX), - [2] = DEFINE_RES_DMA((uintptr_t)DMACH_SPI1_RX), - [3] = DEFINE_RES_IRQ(IRQ_SPI1), + [1] = DEFINE_RES_IRQ(IRQ_SPI1), }; struct platform_device s3c64xx_device_spi1 = { @@ -1180,9 +1178,9 @@ void __init s3c64xx_spi1_set_platdata(int (*cfg_gpio)(void), int src_clk_nr, pd.num_cs = num_cs; pd.src_clk_nr = src_clk_nr; pd.cfg_gpio = (cfg_gpio) ? cfg_gpio : s3c64xx_spi1_cfg_gpio; -#if defined(CONFIG_PL330_DMA) - pd.filter = pl330_filter; -#elif defined(CONFIG_S3C64XX_PL080) +#if defined(CONFIG_S3C64XX_PL080) + pd.dma_tx = DMACH_SPI1_TX; + pd.dma_rx = DMACH_SPI1_RX; pd.filter = pl08x_filter_id; #endif @@ -1193,9 +1191,7 @@ void __init s3c64xx_spi1_set_platdata(int (*cfg_gpio)(void), int src_clk_nr, #ifdef CONFIG_S3C64XX_DEV_SPI2 static struct resource s3c64xx_spi2_resource[] = { [0] = DEFINE_RES_MEM(S3C_PA_SPI2, SZ_256), - [1] = DEFINE_RES_DMA((uintptr_t)DMACH_SPI2_TX), - [2] = DEFINE_RES_DMA((uintptr_t)DMACH_SPI2_RX), - [3] = DEFINE_RES_IRQ(IRQ_SPI2), + [1] = DEFINE_RES_IRQ(IRQ_SPI2), }; struct platform_device s3c64xx_device_spi2 = { @@ -1223,9 +1219,9 @@ void __init s3c64xx_spi2_set_platdata(int (*cfg_gpio)(void), int src_clk_nr, pd.num_cs = num_cs; pd.src_clk_nr = src_clk_nr; pd.cfg_gpio = (cfg_gpio) ? cfg_gpio : s3c64xx_spi2_cfg_gpio; -#if defined(CONFIG_PL330_DMA) - pd.filter = pl330_filter; -#elif defined(CONFIG_S3C64XX_PL080) +#if defined(CONFIG_S3C64XX_PL080) + pd.dma_tx = DMACH_SPI2_TX; + pd.dma_rx = DMACH_SPI2_RX; pd.filter = pl08x_filter_id; #endif diff --git a/drivers/spi/spi-s3c64xx.c b/drivers/spi/spi-s3c64xx.c index 8e86e7f6663a..8b7499623957 100644 --- a/drivers/spi/spi-s3c64xx.c +++ b/drivers/spi/spi-s3c64xx.c @@ -133,7 +133,6 @@ struct s3c64xx_spi_dma_data { struct dma_chan *ch; enum dma_transfer_direction direction; - unsigned int dmach; }; /** @@ -325,7 +324,7 @@ static int s3c64xx_spi_prepare_transfer(struct spi_master *spi) /* Acquire DMA channels */ sdd->rx_dma.ch = dma_request_slave_channel_compat(mask, filter, - (void *)(long)sdd->rx_dma.dmach, dev, "rx"); + sdd->cntrlr_info->dma_rx, dev, "rx"); if (!sdd->rx_dma.ch) { dev_err(dev, "Failed to get RX DMA channel\n"); ret = -EBUSY; @@ -334,7 +333,7 @@ static int s3c64xx_spi_prepare_transfer(struct spi_master *spi) spi->dma_rx = sdd->rx_dma.ch; sdd->tx_dma.ch = dma_request_slave_channel_compat(mask, filter, - (void *)(long)sdd->tx_dma.dmach, dev, "tx"); + sdd->cntrlr_info->dma_tx, dev, "tx"); if (!sdd->tx_dma.ch) { dev_err(dev, "Failed to get TX DMA channel\n"); ret = -EBUSY; @@ -1028,7 +1027,6 @@ static inline struct s3c64xx_spi_port_config *s3c64xx_spi_get_port_config( static int s3c64xx_spi_probe(struct platform_device *pdev) { struct resource *mem_res; - struct resource *res; struct s3c64xx_spi_driver_data *sdd; struct s3c64xx_spi_info *sci = dev_get_platdata(&pdev->dev); struct spi_master *master; @@ -1087,20 +1085,9 @@ static int s3c64xx_spi_probe(struct platform_device *pdev) sdd->cur_bpw = 8; - if (!sdd->pdev->dev.of_node) { - res = platform_get_resource(pdev, IORESOURCE_DMA, 0); - if (!res) { - dev_warn(&pdev->dev, "Unable to get SPI tx dma resource. Switching to poll mode\n"); - sdd->port_conf->quirks = S3C64XX_SPI_QUIRK_POLL; - } else - sdd->tx_dma.dmach = res->start; - - res = platform_get_resource(pdev, IORESOURCE_DMA, 1); - if (!res) { - dev_warn(&pdev->dev, "Unable to get SPI rx dma resource. Switching to poll mode\n"); - sdd->port_conf->quirks = S3C64XX_SPI_QUIRK_POLL; - } else - sdd->rx_dma.dmach = res->start; + if (sci && (!sci->dma_tx || !sci->dma_rx)) { + dev_warn(&pdev->dev, "Unable to get SPI tx data. Switching to poll mode\n"); + sdd->port_conf->quirks = S3C64XX_SPI_QUIRK_POLL; } sdd->tx_dma.direction = DMA_MEM_TO_DEV; @@ -1197,9 +1184,10 @@ static int s3c64xx_spi_probe(struct platform_device *pdev) dev_dbg(&pdev->dev, "Samsung SoC SPI Driver loaded for Bus SPI-%d with %d Slaves attached\n", sdd->port_id, master->num_chipselect); - dev_dbg(&pdev->dev, "\tIOmem=[%pR]\tFIFO %dbytes\tDMA=[Rx-%d, Tx-%d]\n", + dev_dbg(&pdev->dev, "\tIOmem=[%pR]\tFIFO %dbytes\tDMA=[Rx-%p, Tx-%p]\n", mem_res, (FIFO_LVL_MASK(sdd) >> 1) + 1, - sdd->rx_dma.dmach, sdd->tx_dma.dmach); + sdd->cntrlr_info->dma_rx, + sdd->cntrlr_info->dma_tx); pm_runtime_mark_last_busy(&pdev->dev); pm_runtime_put_autosuspend(&pdev->dev); diff --git a/include/linux/platform_data/spi-s3c64xx.h b/include/linux/platform_data/spi-s3c64xx.h index d3889b98a1a1..fb5625bcca9a 100644 --- a/include/linux/platform_data/spi-s3c64xx.h +++ b/include/linux/platform_data/spi-s3c64xx.h @@ -40,6 +40,8 @@ struct s3c64xx_spi_info { int num_cs; int (*cfg_gpio)(void); dma_filter_fn filter; + void *dma_tx; + void *dma_rx; }; /**