12a68ea78SSimon Horman /*
22a68ea78SSimon Horman  * DMA support for Internal DMAC with SDHI SD/SDIO controller
32a68ea78SSimon Horman  *
42a68ea78SSimon Horman  * Copyright (C) 2016-17 Renesas Electronics Corporation
52a68ea78SSimon Horman  * Copyright (C) 2016-17 Horms Solutions, Simon Horman
62a68ea78SSimon Horman  *
72a68ea78SSimon Horman  * This program is free software; you can redistribute it and/or modify
82a68ea78SSimon Horman  * it under the terms of the GNU General Public License version 2 as
92a68ea78SSimon Horman  * published by the Free Software Foundation.
102a68ea78SSimon Horman  */
112a68ea78SSimon Horman 
120cbc94daSWolfram Sang #include <linux/bitops.h>
132a68ea78SSimon Horman #include <linux/device.h>
142a68ea78SSimon Horman #include <linux/dma-mapping.h>
152a68ea78SSimon Horman #include <linux/io-64-nonatomic-hi-lo.h>
162a68ea78SSimon Horman #include <linux/mfd/tmio.h>
172a68ea78SSimon Horman #include <linux/mmc/host.h>
182a68ea78SSimon Horman #include <linux/mod_devicetable.h>
192a68ea78SSimon Horman #include <linux/module.h>
202a68ea78SSimon Horman #include <linux/pagemap.h>
212a68ea78SSimon Horman #include <linux/scatterlist.h>
22cd09780fSSimon Horman #include <linux/sys_soc.h>
232a68ea78SSimon Horman 
242a68ea78SSimon Horman #include "renesas_sdhi.h"
252a68ea78SSimon Horman #include "tmio_mmc.h"
262a68ea78SSimon Horman 
272a68ea78SSimon Horman #define DM_CM_DTRAN_MODE	0x820
282a68ea78SSimon Horman #define DM_CM_DTRAN_CTRL	0x828
292a68ea78SSimon Horman #define DM_CM_RST		0x830
302a68ea78SSimon Horman #define DM_CM_INFO1		0x840
312a68ea78SSimon Horman #define DM_CM_INFO1_MASK	0x848
322a68ea78SSimon Horman #define DM_CM_INFO2		0x850
332a68ea78SSimon Horman #define DM_CM_INFO2_MASK	0x858
342a68ea78SSimon Horman #define DM_DTRAN_ADDR		0x880
352a68ea78SSimon Horman 
362a68ea78SSimon Horman /* DM_CM_DTRAN_MODE */
372a68ea78SSimon Horman #define DTRAN_MODE_CH_NUM_CH0	0	/* "downstream" = for write commands */
382a68ea78SSimon Horman #define DTRAN_MODE_CH_NUM_CH1	BIT(16)	/* "uptream" = for read commands */
392a68ea78SSimon Horman #define DTRAN_MODE_BUS_WID_TH	(BIT(5) | BIT(4))
402a68ea78SSimon Horman #define DTRAN_MODE_ADDR_MODE	BIT(0)	/* 1 = Increment address */
412a68ea78SSimon Horman 
422a68ea78SSimon Horman /* DM_CM_DTRAN_CTRL */
432a68ea78SSimon Horman #define DTRAN_CTRL_DM_START	BIT(0)
442a68ea78SSimon Horman 
452a68ea78SSimon Horman /* DM_CM_RST */
462a68ea78SSimon Horman #define RST_DTRANRST1		BIT(9)
472a68ea78SSimon Horman #define RST_DTRANRST0		BIT(8)
489faf870eSSergei Shtylyov #define RST_RESERVED_BITS	GENMASK_ULL(31, 0)
492a68ea78SSimon Horman 
502a68ea78SSimon Horman /* DM_CM_INFO1 and DM_CM_INFO1_MASK */
512a68ea78SSimon Horman #define INFO1_CLEAR		0
52d2332f88SSergei Shtylyov #define INFO1_MASK_CLEAR	GENMASK_ULL(31, 0)
532a68ea78SSimon Horman #define INFO1_DTRANEND1		BIT(17)
542a68ea78SSimon Horman #define INFO1_DTRANEND0		BIT(16)
552a68ea78SSimon Horman 
562a68ea78SSimon Horman /* DM_CM_INFO2 and DM_CM_INFO2_MASK */
57d2332f88SSergei Shtylyov #define INFO2_MASK_CLEAR	GENMASK_ULL(31, 0)
582a68ea78SSimon Horman #define INFO2_DTRANERR1		BIT(17)
592a68ea78SSimon Horman #define INFO2_DTRANERR0		BIT(16)
602a68ea78SSimon Horman 
612a68ea78SSimon Horman /*
622a68ea78SSimon Horman  * Specification of this driver:
632a68ea78SSimon Horman  * - host->chan_{rx,tx} will be used as a flag of enabling/disabling the dma
642a68ea78SSimon Horman  * - Since this SDHI DMAC register set has 16 but 32-bit width, we
652a68ea78SSimon Horman  *   need a custom accessor.
662a68ea78SSimon Horman  */
672a68ea78SSimon Horman 
680cbc94daSWolfram Sang static unsigned long global_flags;
690cbc94daSWolfram Sang /*
700cbc94daSWolfram Sang  * Workaround for avoiding to use RX DMAC by multiple channels.
710cbc94daSWolfram Sang  * On R-Car H3 ES1.* and M3-W ES1.0, when multiple SDHI channels use
720cbc94daSWolfram Sang  * RX DMAC simultaneously, sometimes hundreds of bytes data are not
730cbc94daSWolfram Sang  * stored into the system memory even if the DMAC interrupt happened.
740cbc94daSWolfram Sang  * So, this driver then uses one RX DMAC channel only.
750cbc94daSWolfram Sang  */
760cbc94daSWolfram Sang #define SDHI_INTERNAL_DMAC_ONE_RX_ONLY	0
770cbc94daSWolfram Sang #define SDHI_INTERNAL_DMAC_RX_IN_USE	1
780cbc94daSWolfram Sang 
792a68ea78SSimon Horman /* Definitions for sampling clocks */
802a68ea78SSimon Horman static struct renesas_sdhi_scc rcar_gen3_scc_taps[] = {
812a68ea78SSimon Horman 	{
822a68ea78SSimon Horman 		.clk_rate = 0,
832a68ea78SSimon Horman 		.tap = 0x00000300,
842a68ea78SSimon Horman 	},
852a68ea78SSimon Horman };
862a68ea78SSimon Horman 
8726eb2607SMasaharu Hayakawa static const struct renesas_sdhi_of_data of_rcar_r8a7795_compatible = {
8826eb2607SMasaharu Hayakawa 	.tmio_flags	= TMIO_MMC_HAS_IDLE_WAIT | TMIO_MMC_CLK_ACTUAL |
8926eb2607SMasaharu Hayakawa 			  TMIO_MMC_HAVE_CBSY | TMIO_MMC_MIN_RCAR2 |
9026eb2607SMasaharu Hayakawa 			  TMIO_MMC_HAVE_4TAP_HS400,
9126eb2607SMasaharu Hayakawa 	.capabilities	= MMC_CAP_SD_HIGHSPEED | MMC_CAP_SDIO_IRQ |
9226eb2607SMasaharu Hayakawa 			  MMC_CAP_CMD23,
9326eb2607SMasaharu Hayakawa 	.capabilities2	= MMC_CAP2_NO_WRITE_PROTECT,
9426eb2607SMasaharu Hayakawa 	.bus_shift	= 2,
9526eb2607SMasaharu Hayakawa 	.scc_offset	= 0x1000,
9626eb2607SMasaharu Hayakawa 	.taps		= rcar_gen3_scc_taps,
9726eb2607SMasaharu Hayakawa 	.taps_num	= ARRAY_SIZE(rcar_gen3_scc_taps),
9826eb2607SMasaharu Hayakawa 	/* DMAC can handle 0xffffffff blk count but only 1 segment */
9926eb2607SMasaharu Hayakawa 	.max_blk_count	= 0xffffffff,
10026eb2607SMasaharu Hayakawa 	.max_segs	= 1,
10126eb2607SMasaharu Hayakawa };
10226eb2607SMasaharu Hayakawa 
1032a68ea78SSimon Horman static const struct renesas_sdhi_of_data of_rcar_gen3_compatible = {
1042ad1db05SMasahiro Yamada 	.tmio_flags	= TMIO_MMC_HAS_IDLE_WAIT | TMIO_MMC_CLK_ACTUAL |
1052ad1db05SMasahiro Yamada 			  TMIO_MMC_HAVE_CBSY | TMIO_MMC_MIN_RCAR2,
1062a68ea78SSimon Horman 	.capabilities	= MMC_CAP_SD_HIGHSPEED | MMC_CAP_SDIO_IRQ |
1072a68ea78SSimon Horman 			  MMC_CAP_CMD23,
108ef5332c1SWolfram Sang 	.capabilities2	= MMC_CAP2_NO_WRITE_PROTECT,
1092a68ea78SSimon Horman 	.bus_shift	= 2,
1102a68ea78SSimon Horman 	.scc_offset	= 0x1000,
1112a68ea78SSimon Horman 	.taps		= rcar_gen3_scc_taps,
1122a68ea78SSimon Horman 	.taps_num	= ARRAY_SIZE(rcar_gen3_scc_taps),
113ebca50dfSWolfram Sang 	/* DMAC can handle 0xffffffff blk count but only 1 segment */
1142a68ea78SSimon Horman 	.max_blk_count	= 0xffffffff,
1152a68ea78SSimon Horman 	.max_segs	= 1,
1162a68ea78SSimon Horman };
1172a68ea78SSimon Horman 
1182a68ea78SSimon Horman static const struct of_device_id renesas_sdhi_internal_dmac_of_match[] = {
11926eb2607SMasaharu Hayakawa 	{ .compatible = "renesas,sdhi-r8a7795", .data = &of_rcar_r8a7795_compatible, },
12026eb2607SMasaharu Hayakawa 	{ .compatible = "renesas,sdhi-r8a7796", .data = &of_rcar_r8a7795_compatible, },
121d6dc425aSSimon Horman 	{ .compatible = "renesas,rcar-gen3-sdhi", .data = &of_rcar_gen3_compatible, },
1222a68ea78SSimon Horman 	{},
1232a68ea78SSimon Horman };
1242a68ea78SSimon Horman MODULE_DEVICE_TABLE(of, renesas_sdhi_internal_dmac_of_match);
1252a68ea78SSimon Horman 
1262a68ea78SSimon Horman static void
1272a68ea78SSimon Horman renesas_sdhi_internal_dmac_dm_write(struct tmio_mmc_host *host,
1282a68ea78SSimon Horman 				    int addr, u64 val)
1292a68ea78SSimon Horman {
1302a68ea78SSimon Horman 	writeq(val, host->ctl + addr);
1312a68ea78SSimon Horman }
1322a68ea78SSimon Horman 
1332a68ea78SSimon Horman static void
1342a68ea78SSimon Horman renesas_sdhi_internal_dmac_enable_dma(struct tmio_mmc_host *host, bool enable)
1352a68ea78SSimon Horman {
136058db286SMasahiro Yamada 	struct renesas_sdhi *priv = host_to_priv(host);
137058db286SMasahiro Yamada 
1382a68ea78SSimon Horman 	if (!host->chan_tx || !host->chan_rx)
1392a68ea78SSimon Horman 		return;
1402a68ea78SSimon Horman 
1412a68ea78SSimon Horman 	if (!enable)
1422a68ea78SSimon Horman 		renesas_sdhi_internal_dmac_dm_write(host, DM_CM_INFO1,
1432a68ea78SSimon Horman 						    INFO1_CLEAR);
1442a68ea78SSimon Horman 
145058db286SMasahiro Yamada 	if (priv->dma_priv.enable)
146058db286SMasahiro Yamada 		priv->dma_priv.enable(host, enable);
1472a68ea78SSimon Horman }
1482a68ea78SSimon Horman 
1492a68ea78SSimon Horman static void
1502a68ea78SSimon Horman renesas_sdhi_internal_dmac_abort_dma(struct tmio_mmc_host *host) {
1512a68ea78SSimon Horman 	u64 val = RST_DTRANRST1 | RST_DTRANRST0;
1522a68ea78SSimon Horman 
1532a68ea78SSimon Horman 	renesas_sdhi_internal_dmac_enable_dma(host, false);
1542a68ea78SSimon Horman 
1552a68ea78SSimon Horman 	renesas_sdhi_internal_dmac_dm_write(host, DM_CM_RST,
1562a68ea78SSimon Horman 					    RST_RESERVED_BITS & ~val);
1572a68ea78SSimon Horman 	renesas_sdhi_internal_dmac_dm_write(host, DM_CM_RST,
1582a68ea78SSimon Horman 					    RST_RESERVED_BITS | val);
1592a68ea78SSimon Horman 
1600cbc94daSWolfram Sang 	clear_bit(SDHI_INTERNAL_DMAC_RX_IN_USE, &global_flags);
1610cbc94daSWolfram Sang 
1622a68ea78SSimon Horman 	renesas_sdhi_internal_dmac_enable_dma(host, true);
1632a68ea78SSimon Horman }
1642a68ea78SSimon Horman 
1652a68ea78SSimon Horman static void
1662a68ea78SSimon Horman renesas_sdhi_internal_dmac_dataend_dma(struct tmio_mmc_host *host) {
16790d95106SMasahiro Yamada 	struct renesas_sdhi *priv = host_to_priv(host);
16890d95106SMasahiro Yamada 
16990d95106SMasahiro Yamada 	tasklet_schedule(&priv->dma_priv.dma_complete);
1702a68ea78SSimon Horman }
1712a68ea78SSimon Horman 
1722a68ea78SSimon Horman static void
1732a68ea78SSimon Horman renesas_sdhi_internal_dmac_start_dma(struct tmio_mmc_host *host,
1742a68ea78SSimon Horman 				     struct mmc_data *data)
1752a68ea78SSimon Horman {
1762a68ea78SSimon Horman 	struct scatterlist *sg = host->sg_ptr;
1772a68ea78SSimon Horman 	u32 dtran_mode = DTRAN_MODE_BUS_WID_TH | DTRAN_MODE_ADDR_MODE;
1782a68ea78SSimon Horman 
179ae275b9dSMasaharu Hayakawa 	if (!dma_map_sg(&host->pdev->dev, sg, host->sg_len,
180ae275b9dSMasaharu Hayakawa 			mmc_get_dma_dir(data)))
18148e1dc10SYoshihiro Shimoda 		goto force_pio;
1822a68ea78SSimon Horman 
183ae275b9dSMasaharu Hayakawa 	/* This DMAC cannot handle if buffer is not 8-bytes alignment */
184fe6e0494SYoshihiro Shimoda 	if (!IS_ALIGNED(sg_dma_address(sg), 8))
185fe6e0494SYoshihiro Shimoda 		goto force_pio_with_unmap;
186ae275b9dSMasaharu Hayakawa 
1872a68ea78SSimon Horman 	if (data->flags & MMC_DATA_READ) {
1882a68ea78SSimon Horman 		dtran_mode |= DTRAN_MODE_CH_NUM_CH1;
1890cbc94daSWolfram Sang 		if (test_bit(SDHI_INTERNAL_DMAC_ONE_RX_ONLY, &global_flags) &&
1900cbc94daSWolfram Sang 		    test_and_set_bit(SDHI_INTERNAL_DMAC_RX_IN_USE, &global_flags))
191fe6e0494SYoshihiro Shimoda 			goto force_pio_with_unmap;
1922a68ea78SSimon Horman 	} else {
1932a68ea78SSimon Horman 		dtran_mode |= DTRAN_MODE_CH_NUM_CH0;
1942a68ea78SSimon Horman 	}
1952a68ea78SSimon Horman 
1962a68ea78SSimon Horman 	renesas_sdhi_internal_dmac_enable_dma(host, true);
1972a68ea78SSimon Horman 
1982a68ea78SSimon Horman 	/* set dma parameters */
1992a68ea78SSimon Horman 	renesas_sdhi_internal_dmac_dm_write(host, DM_CM_DTRAN_MODE,
2002a68ea78SSimon Horman 					    dtran_mode);
2012a68ea78SSimon Horman 	renesas_sdhi_internal_dmac_dm_write(host, DM_DTRAN_ADDR,
202a028b435SNiklas Söderlund 					    sg_dma_address(sg));
20348e1dc10SYoshihiro Shimoda 
20448e1dc10SYoshihiro Shimoda 	return;
20548e1dc10SYoshihiro Shimoda 
206fe6e0494SYoshihiro Shimoda force_pio_with_unmap:
207fe6e0494SYoshihiro Shimoda 	dma_unmap_sg(&host->pdev->dev, sg, host->sg_len, mmc_get_dma_dir(data));
208fe6e0494SYoshihiro Shimoda 
20948e1dc10SYoshihiro Shimoda force_pio:
21048e1dc10SYoshihiro Shimoda 	host->force_pio = true;
21148e1dc10SYoshihiro Shimoda 	renesas_sdhi_internal_dmac_enable_dma(host, false);
2122a68ea78SSimon Horman }
2132a68ea78SSimon Horman 
2142a68ea78SSimon Horman static void renesas_sdhi_internal_dmac_issue_tasklet_fn(unsigned long arg)
2152a68ea78SSimon Horman {
2162a68ea78SSimon Horman 	struct tmio_mmc_host *host = (struct tmio_mmc_host *)arg;
2172a68ea78SSimon Horman 
2182a68ea78SSimon Horman 	tmio_mmc_enable_mmc_irqs(host, TMIO_STAT_DATAEND);
2192a68ea78SSimon Horman 
2202a68ea78SSimon Horman 	/* start the DMAC */
2212a68ea78SSimon Horman 	renesas_sdhi_internal_dmac_dm_write(host, DM_CM_DTRAN_CTRL,
2222a68ea78SSimon Horman 					    DTRAN_CTRL_DM_START);
2232a68ea78SSimon Horman }
2242a68ea78SSimon Horman 
2252a68ea78SSimon Horman static void renesas_sdhi_internal_dmac_complete_tasklet_fn(unsigned long arg)
2262a68ea78SSimon Horman {
2272a68ea78SSimon Horman 	struct tmio_mmc_host *host = (struct tmio_mmc_host *)arg;
2282a68ea78SSimon Horman 	enum dma_data_direction dir;
2292a68ea78SSimon Horman 
2302a68ea78SSimon Horman 	spin_lock_irq(&host->lock);
2312a68ea78SSimon Horman 
2322a68ea78SSimon Horman 	if (!host->data)
2332a68ea78SSimon Horman 		goto out;
2342a68ea78SSimon Horman 
2352a68ea78SSimon Horman 	if (host->data->flags & MMC_DATA_READ)
2362a68ea78SSimon Horman 		dir = DMA_FROM_DEVICE;
2372a68ea78SSimon Horman 	else
2382a68ea78SSimon Horman 		dir = DMA_TO_DEVICE;
2392a68ea78SSimon Horman 
2402a68ea78SSimon Horman 	renesas_sdhi_internal_dmac_enable_dma(host, false);
2412a68ea78SSimon Horman 	dma_unmap_sg(&host->pdev->dev, host->sg_ptr, host->sg_len, dir);
2422a68ea78SSimon Horman 
2430cbc94daSWolfram Sang 	if (dir == DMA_FROM_DEVICE)
2440cbc94daSWolfram Sang 		clear_bit(SDHI_INTERNAL_DMAC_RX_IN_USE, &global_flags);
2450cbc94daSWolfram Sang 
2462a68ea78SSimon Horman 	tmio_mmc_do_data_irq(host);
2472a68ea78SSimon Horman out:
2482a68ea78SSimon Horman 	spin_unlock_irq(&host->lock);
2492a68ea78SSimon Horman }
2502a68ea78SSimon Horman 
2512a68ea78SSimon Horman static void
2522a68ea78SSimon Horman renesas_sdhi_internal_dmac_request_dma(struct tmio_mmc_host *host,
2532a68ea78SSimon Horman 				       struct tmio_mmc_data *pdata)
2542a68ea78SSimon Horman {
25590d95106SMasahiro Yamada 	struct renesas_sdhi *priv = host_to_priv(host);
25690d95106SMasahiro Yamada 
257d2332f88SSergei Shtylyov 	/* Disable DMAC interrupts, we don't use them */
258d2332f88SSergei Shtylyov 	renesas_sdhi_internal_dmac_dm_write(host, DM_CM_INFO1_MASK,
259d2332f88SSergei Shtylyov 					    INFO1_MASK_CLEAR);
260d2332f88SSergei Shtylyov 	renesas_sdhi_internal_dmac_dm_write(host, DM_CM_INFO2_MASK,
261d2332f88SSergei Shtylyov 					    INFO2_MASK_CLEAR);
262d2332f88SSergei Shtylyov 
2632a68ea78SSimon Horman 	/* Each value is set to non-zero to assume "enabling" each DMA */
2642a68ea78SSimon Horman 	host->chan_rx = host->chan_tx = (void *)0xdeadbeaf;
2652a68ea78SSimon Horman 
26690d95106SMasahiro Yamada 	tasklet_init(&priv->dma_priv.dma_complete,
2672a68ea78SSimon Horman 		     renesas_sdhi_internal_dmac_complete_tasklet_fn,
2682a68ea78SSimon Horman 		     (unsigned long)host);
2692a68ea78SSimon Horman 	tasklet_init(&host->dma_issue,
2702a68ea78SSimon Horman 		     renesas_sdhi_internal_dmac_issue_tasklet_fn,
2712a68ea78SSimon Horman 		     (unsigned long)host);
2722a68ea78SSimon Horman }
2732a68ea78SSimon Horman 
2742a68ea78SSimon Horman static void
2752a68ea78SSimon Horman renesas_sdhi_internal_dmac_release_dma(struct tmio_mmc_host *host)
2762a68ea78SSimon Horman {
2772a68ea78SSimon Horman 	/* Each value is set to zero to assume "disabling" each DMA */
2782a68ea78SSimon Horman 	host->chan_rx = host->chan_tx = NULL;
2792a68ea78SSimon Horman }
2802a68ea78SSimon Horman 
28110154068SJulia Lawall static const struct tmio_mmc_dma_ops renesas_sdhi_internal_dmac_dma_ops = {
2822a68ea78SSimon Horman 	.start = renesas_sdhi_internal_dmac_start_dma,
2832a68ea78SSimon Horman 	.enable = renesas_sdhi_internal_dmac_enable_dma,
2842a68ea78SSimon Horman 	.request = renesas_sdhi_internal_dmac_request_dma,
2852a68ea78SSimon Horman 	.release = renesas_sdhi_internal_dmac_release_dma,
2862a68ea78SSimon Horman 	.abort = renesas_sdhi_internal_dmac_abort_dma,
2872a68ea78SSimon Horman 	.dataend = renesas_sdhi_internal_dmac_dataend_dma,
2882a68ea78SSimon Horman };
2892a68ea78SSimon Horman 
290cd09780fSSimon Horman /*
291cd09780fSSimon Horman  * Whitelist of specific R-Car Gen3 SoC ES versions to use this DMAC
292cd09780fSSimon Horman  * implementation as others may use a different implementation.
293cd09780fSSimon Horman  */
294cd09780fSSimon Horman static const struct soc_device_attribute gen3_soc_whitelist[] = {
2951abf9e52SWolfram Sang 	/* specific ones */
2960cbc94daSWolfram Sang 	{ .soc_id = "r8a7795", .revision = "ES1.*",
2970cbc94daSWolfram Sang 	  .data = (void *)BIT(SDHI_INTERNAL_DMAC_ONE_RX_ONLY) },
2980cbc94daSWolfram Sang 	{ .soc_id = "r8a7796", .revision = "ES1.0",
2990cbc94daSWolfram Sang 	  .data = (void *)BIT(SDHI_INTERNAL_DMAC_ONE_RX_ONLY) },
3001abf9e52SWolfram Sang 	/* generic ones */
3012e1501a8SFabrizio Castro 	{ .soc_id = "r8a774a1" },
3021abf9e52SWolfram Sang 	{ .soc_id = "r8a7795" },
3031abf9e52SWolfram Sang 	{ .soc_id = "r8a7796" },
304caeffcf1SMasaharu Hayakawa 	{ .soc_id = "r8a77965" },
305e419768fSSergei Shtylyov 	{ .soc_id = "r8a77980" },
3061abf9e52SWolfram Sang 	{ .soc_id = "r8a77995" },
307cd09780fSSimon Horman 	{ /* sentinel */ }
308cd09780fSSimon Horman };
309cd09780fSSimon Horman 
3102a68ea78SSimon Horman static int renesas_sdhi_internal_dmac_probe(struct platform_device *pdev)
3112a68ea78SSimon Horman {
3120cbc94daSWolfram Sang 	const struct soc_device_attribute *soc = soc_device_match(gen3_soc_whitelist);
3130cbc94daSWolfram Sang 
3140cbc94daSWolfram Sang 	if (!soc)
315cd09780fSSimon Horman 		return -ENODEV;
316cd09780fSSimon Horman 
3170cbc94daSWolfram Sang 	global_flags |= (unsigned long)soc->data;
3180cbc94daSWolfram Sang 
3192a68ea78SSimon Horman 	return renesas_sdhi_probe(pdev, &renesas_sdhi_internal_dmac_dma_ops);
3202a68ea78SSimon Horman }
3212a68ea78SSimon Horman 
3222a68ea78SSimon Horman static const struct dev_pm_ops renesas_sdhi_internal_dmac_dev_pm_ops = {
3232a68ea78SSimon Horman 	SET_SYSTEM_SLEEP_PM_OPS(pm_runtime_force_suspend,
3242a68ea78SSimon Horman 				pm_runtime_force_resume)
3252a68ea78SSimon Horman 	SET_RUNTIME_PM_OPS(tmio_mmc_host_runtime_suspend,
3262a68ea78SSimon Horman 			   tmio_mmc_host_runtime_resume,
3272a68ea78SSimon Horman 			   NULL)
3282a68ea78SSimon Horman };
3292a68ea78SSimon Horman 
3302a68ea78SSimon Horman static struct platform_driver renesas_internal_dmac_sdhi_driver = {
3312a68ea78SSimon Horman 	.driver		= {
3322a68ea78SSimon Horman 		.name	= "renesas_sdhi_internal_dmac",
3332a68ea78SSimon Horman 		.pm	= &renesas_sdhi_internal_dmac_dev_pm_ops,
3342a68ea78SSimon Horman 		.of_match_table = renesas_sdhi_internal_dmac_of_match,
3352a68ea78SSimon Horman 	},
3362a68ea78SSimon Horman 	.probe		= renesas_sdhi_internal_dmac_probe,
3372a68ea78SSimon Horman 	.remove		= renesas_sdhi_remove,
3382a68ea78SSimon Horman };
3392a68ea78SSimon Horman 
3402a68ea78SSimon Horman module_platform_driver(renesas_internal_dmac_sdhi_driver);
3412a68ea78SSimon Horman 
3422a68ea78SSimon Horman MODULE_DESCRIPTION("Renesas SDHI driver for internal DMAC");
3432a68ea78SSimon Horman MODULE_AUTHOR("Yoshihiro Shimoda");
3442a68ea78SSimon Horman MODULE_LICENSE("GPL v2");
345