From patchwork Fri Nov 24 16:24:47 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 119603 Delivered-To: patch@linaro.org Received: by 10.140.22.164 with SMTP id 33csp2442772qgn; Fri, 24 Nov 2017 08:26:33 -0800 (PST) X-Google-Smtp-Source: AGs4zMZZtNnMwQycZZFOl1pahcWPFXd8hpm67LgL9YO/La/xAk3Ghsz09irxwdNVYQaQ9rAkGIVo X-Received: by 10.99.103.5 with SMTP id b5mr29029158pgc.447.1511540793344; Fri, 24 Nov 2017 08:26:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1511540793; cv=none; d=google.com; s=arc-20160816; b=L28E+DnV38VlrP/4tyC6hD6oNnETwtAFKrW7ah4NDT1xCdKCLdJtlEvNVNGp17S/yo +KMVBOuYGrPrH+SJ9XrrrFWRpAkrLrRCFVy0oGOvXH5Dp8t0vS8vJJ3nxyBBUGPIt/0t t3PAPpqz8q5td/qiOuEXPAx3Mv70JGLNTJ4imGqIuqdbuUaAtXENtlSHk8UXXwloTpHk vIaZ46uwyegV4D/2t6l/fqBOgMLVaB+5WAfJHvcmj1t4I8IGznJ7Oyg3IrSpRtJ9TUcS oQCgtnIggFkylFf2lG+bgdSSqyD371L/g07JKtQ+pGmdQ6QHPkgPCZFhDkxe+q4ky4Ab 1WPQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:dkim-filter :arc-authentication-results; bh=c+EHMWt8wkl77BtVml3MCDlk+lxr4N53V7b+o2/VmWU=; b=EawUG0LOuq6D4bJ0YU9wkol0ZRdy96XiwyAnZ0apS/YBfbXnvbp48u9sotVLolOQ9g wzfsLRL1waoawyEtIyOMrVFRGL/JcI+m29LdW8DyHdEzGJF0LBd70U0g/rbNsOQyeVGC A/f4ewiL5j2QDHrdN/wPhtPy+X5tEy+PLcnb+P942XK/VOdLuwv8Wp18CWcB0L/2Powr mxpynkeoFVImL/+jbpK8qAInvdcBfPhF3EcnTg2BBdLbKyUfkuxIuBmvuSMdzo7tVPEc hD2QxJqZoL3oGLa2/ttjmXaSz9hVh7AMNZrnsiQyypc3upDF/wKOktCY3g5zPWhBxPAo FSzw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=DizQJPbW; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f30si18709741plf.535.2017.11.24.08.26.33; Fri, 24 Nov 2017 08:26:33 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=DizQJPbW; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753873AbdKXQ0P (ORCPT + 28 others); Fri, 24 Nov 2017 11:26:15 -0500 Received: from conuserg-11.nifty.com ([210.131.2.78]:61638 "EHLO conuserg-11.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753780AbdKXQ0I (ORCPT ); Fri, 24 Nov 2017 11:26:08 -0500 Received: from grover.sesame (FL1-125-199-20-195.osk.mesh.ad.jp [125.199.20.195]) (authenticated) by conuserg-11.nifty.com with ESMTP id vAOGP9Vw007100; Sat, 25 Nov 2017 01:25:19 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-11.nifty.com vAOGP9Vw007100 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1511540720; bh=c+EHMWt8wkl77BtVml3MCDlk+lxr4N53V7b+o2/VmWU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=DizQJPbWUqTkBStHdUWlxZzxRKlyw1ANlWG/EuKXv+TOVRvTEIayRYUjTN67WG9t+ 16/iGjpsQDL+iMv0qfCcZYKxZl4c3i+IpdJESUePEZHODLa7Ux+xV4d14bQvirwYC8 IzdefrrGI7oLgvf7tvbxZu04rGZiNXdCBgDC5d9Sbcl9j7CuXFOzzege+aEaADu3y7 sFmoggSZnaNILVOQdAw7CRwEz4V8xI2WBqxEBdMdZ0XEdPMt6vIYQ70r2kjcHCp/uP uqnu4ntiBayWenu5H5hgA+qOUM1x+gGfRSeKs+KyLr6c2/oD29J8xGh2Irlqf7RZgo cSWsqbDDWHl+A== X-Nifty-SrcIP: [125.199.20.195] From: Masahiro Yamada To: linux-mmc@vger.kernel.org, Wolfram Sang Cc: Simon Horman , Yoshihiro Shimoda , linux-renesas-soc@vger.kernel.org, Masahiro Yamada , linux-kernel@vger.kernel.org, Ulf Hansson Subject: [PATCH v2 12/22] mmc: tmio, renesas_sdhi: move struct tmio_mmc_dma to renesas_sdhi.h Date: Sat, 25 Nov 2017 01:24:47 +0900 Message-Id: <1511540697-27387-13-git-send-email-yamada.masahiro@socionext.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1511540697-27387-1-git-send-email-yamada.masahiro@socionext.com> References: <1511540697-27387-1-git-send-email-yamada.masahiro@socionext.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org struct tmio_mmc_dma looks like TMIO core data, but in fact, Renesas private data. Move it to renesas_sdhi.h (probably, it is better to rename it to renesas_sdhi_dma, or squash it into struct renesas_sdhi). I also moved struct renesas_sdhi and host_to_priv() to that header because they are necessary to convert the tmio_mmc_host pointer into the renesas_sdhi pointer. Signed-off-by: Masahiro Yamada --- Changes in v2: - Newly added drivers/mmc/host/renesas_sdhi.h | 19 +++++++++++++++++++ drivers/mmc/host/renesas_sdhi_core.c | 14 -------------- drivers/mmc/host/renesas_sdhi_internal_dmac.c | 6 ++++-- drivers/mmc/host/renesas_sdhi_sys_dmac.c | 16 ++++++++++------ drivers/mmc/host/tmio_mmc.h | 7 ------- 5 files changed, 33 insertions(+), 29 deletions(-) -- 2.7.4 diff --git a/drivers/mmc/host/renesas_sdhi.h b/drivers/mmc/host/renesas_sdhi.h index b9dfea5..9a507b3 100644 --- a/drivers/mmc/host/renesas_sdhi.h +++ b/drivers/mmc/host/renesas_sdhi.h @@ -35,6 +35,25 @@ struct renesas_sdhi_of_data { unsigned short max_segs; }; +struct tmio_mmc_dma { + enum dma_slave_buswidth dma_buswidth; + bool (*filter)(struct dma_chan *chan, void *arg); + void (*enable)(struct tmio_mmc_host *host, bool enable); +}; + +struct renesas_sdhi { + struct clk *clk; + struct clk *clk_cd; + struct tmio_mmc_data mmc_data; + struct tmio_mmc_dma dma_priv; + struct pinctrl *pinctrl; + struct pinctrl_state *pins_default, *pins_uhs; + void __iomem *scc_ctl; +}; + +#define host_to_priv(host) \ + container_of((host)->pdata, struct renesas_sdhi, mmc_data) + int renesas_sdhi_probe(struct platform_device *pdev, const struct tmio_mmc_dma_ops *dma_ops); int renesas_sdhi_remove(struct platform_device *pdev); diff --git a/drivers/mmc/host/renesas_sdhi_core.c b/drivers/mmc/host/renesas_sdhi_core.c index 267e2e0..34fd194 100644 --- a/drivers/mmc/host/renesas_sdhi_core.c +++ b/drivers/mmc/host/renesas_sdhi_core.c @@ -46,19 +46,6 @@ #define SDHI_VER_GEN3_SD 0xcc10 #define SDHI_VER_GEN3_SDMMC 0xcd10 -#define host_to_priv(host) \ - container_of((host)->pdata, struct renesas_sdhi, mmc_data) - -struct renesas_sdhi { - struct clk *clk; - struct clk *clk_cd; - struct tmio_mmc_data mmc_data; - struct tmio_mmc_dma dma_priv; - struct pinctrl *pinctrl; - struct pinctrl_state *pins_default, *pins_uhs; - void __iomem *scc_ctl; -}; - static void renesas_sdhi_sdbuf_width(struct tmio_mmc_host *host, int width) { u32 val; @@ -539,7 +526,6 @@ int renesas_sdhi_probe(struct platform_device *pdev, host->bus_shift = of_data->bus_shift; } - host->dma = dma_priv; host->write16_hook = renesas_sdhi_write16_hook; host->clk_enable = renesas_sdhi_clk_enable; host->clk_update = renesas_sdhi_clk_update; diff --git a/drivers/mmc/host/renesas_sdhi_internal_dmac.c b/drivers/mmc/host/renesas_sdhi_internal_dmac.c index 41cbe84..691a99f 100644 --- a/drivers/mmc/host/renesas_sdhi_internal_dmac.c +++ b/drivers/mmc/host/renesas_sdhi_internal_dmac.c @@ -103,6 +103,8 @@ renesas_sdhi_internal_dmac_dm_write(struct tmio_mmc_host *host, static void renesas_sdhi_internal_dmac_enable_dma(struct tmio_mmc_host *host, bool enable) { + struct renesas_sdhi *priv = host_to_priv(host); + if (!host->chan_tx || !host->chan_rx) return; @@ -110,8 +112,8 @@ renesas_sdhi_internal_dmac_enable_dma(struct tmio_mmc_host *host, bool enable) renesas_sdhi_internal_dmac_dm_write(host, DM_CM_INFO1, INFO1_CLEAR); - if (host->dma->enable) - host->dma->enable(host, enable); + if (priv->dma_priv.enable) + priv->dma_priv.enable(host, enable); } static void diff --git a/drivers/mmc/host/renesas_sdhi_sys_dmac.c b/drivers/mmc/host/renesas_sdhi_sys_dmac.c index e210644..aeb3838 100644 --- a/drivers/mmc/host/renesas_sdhi_sys_dmac.c +++ b/drivers/mmc/host/renesas_sdhi_sys_dmac.c @@ -117,11 +117,13 @@ MODULE_DEVICE_TABLE(of, renesas_sdhi_sys_dmac_of_match); static void renesas_sdhi_sys_dmac_enable_dma(struct tmio_mmc_host *host, bool enable) { + struct renesas_sdhi *priv = host_to_priv(host); + if (!host->chan_tx || !host->chan_rx) return; - if (host->dma->enable) - host->dma->enable(host, enable); + if (priv->dma_priv.enable) + priv->dma_priv.enable(host, enable); } static void renesas_sdhi_sys_dmac_abort_dma(struct tmio_mmc_host *host) @@ -359,6 +361,8 @@ static void renesas_sdhi_sys_dmac_issue_tasklet_fn(unsigned long priv) static void renesas_sdhi_sys_dmac_request_dma(struct tmio_mmc_host *host, struct tmio_mmc_data *pdata) { + struct renesas_sdhi *priv = host_to_priv(host); + /* We can only either use DMA for both Tx and Rx or not use it at all */ if (!host->pdev->dev.of_node && (!pdata->chan_priv_tx || !pdata->chan_priv_rx)) @@ -378,7 +382,7 @@ static void renesas_sdhi_sys_dmac_request_dma(struct tmio_mmc_host *host, dma_cap_set(DMA_SLAVE, mask); host->chan_tx = dma_request_slave_channel_compat(mask, - host->dma->filter, pdata->chan_priv_tx, + priv->dma_priv.filter, pdata->chan_priv_tx, &host->pdev->dev, "tx"); dev_dbg(&host->pdev->dev, "%s: TX: got channel %p\n", __func__, host->chan_tx); @@ -389,7 +393,7 @@ static void renesas_sdhi_sys_dmac_request_dma(struct tmio_mmc_host *host, cfg.direction = DMA_MEM_TO_DEV; cfg.dst_addr = res->start + (CTL_SD_DATA_PORT << host->bus_shift); - cfg.dst_addr_width = host->dma->dma_buswidth; + cfg.dst_addr_width = priv->dma_priv.dma_buswidth; if (!cfg.dst_addr_width) cfg.dst_addr_width = DMA_SLAVE_BUSWIDTH_2_BYTES; cfg.src_addr = 0; @@ -398,7 +402,7 @@ static void renesas_sdhi_sys_dmac_request_dma(struct tmio_mmc_host *host, goto ecfgtx; host->chan_rx = dma_request_slave_channel_compat(mask, - host->dma->filter, pdata->chan_priv_rx, + priv->dma_priv.filter, pdata->chan_priv_rx, &host->pdev->dev, "rx"); dev_dbg(&host->pdev->dev, "%s: RX: got channel %p\n", __func__, host->chan_rx); @@ -408,7 +412,7 @@ static void renesas_sdhi_sys_dmac_request_dma(struct tmio_mmc_host *host, cfg.direction = DMA_DEV_TO_MEM; cfg.src_addr = cfg.dst_addr + host->pdata->dma_rx_offset; - cfg.src_addr_width = host->dma->dma_buswidth; + cfg.src_addr_width = priv->dma_priv.dma_buswidth; if (!cfg.src_addr_width) cfg.src_addr_width = DMA_SLAVE_BUSWIDTH_2_BYTES; cfg.dst_addr = 0; diff --git a/drivers/mmc/host/tmio_mmc.h b/drivers/mmc/host/tmio_mmc.h index 37409c5..dc470d3 100644 --- a/drivers/mmc/host/tmio_mmc.h +++ b/drivers/mmc/host/tmio_mmc.h @@ -112,12 +112,6 @@ struct tmio_mmc_data; struct tmio_mmc_host; -struct tmio_mmc_dma { - enum dma_slave_buswidth dma_buswidth; - bool (*filter)(struct dma_chan *chan, void *arg); - void (*enable)(struct tmio_mmc_host *host, bool enable); -}; - struct tmio_mmc_dma_ops { void (*start)(struct tmio_mmc_host *host, struct mmc_data *data); void (*enable)(struct tmio_mmc_host *host, bool enable); @@ -149,7 +143,6 @@ struct tmio_mmc_host { struct platform_device *pdev; struct tmio_mmc_data *pdata; - struct tmio_mmc_dma *dma; /* DMA support */ bool force_pio;