Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

mmc: renesas-sdhi: make renesas_sdhi_sys_dmac main module file

Make renesas_sdhi_sys_dmac.c a top-level module file that makes use of
library code supplied by renesas_sdhi_core.c

This is in order to facilitate adding other variants of SDHI;
in particular SDHI using different DMA controllers.

Signed-off-by: Simon Horman <horms+renesas@verge.net.au>
Acked-by: Arnd Bergmann <arnd@arndb.de>
Reviewed-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
[Arnd: Fixed module build error]
Signed-off-by: Arnd Bergmann <arnd@arndb.de>

authored by

Simon Horman and committed by
Ulf Hansson
9d08428a b5b6a5f4

+137 -129
+22 -1
drivers/mmc/host/renesas_sdhi.h
··· 12 12 #ifndef RENESAS_SDHI_H 13 13 #define RENESAS_SDHI_H 14 14 15 + #include <linux/platform_device.h> 15 16 #include "tmio_mmc.h" 16 17 17 - const struct tmio_mmc_dma_ops *renesas_sdhi_get_dma_ops(void); 18 + struct renesas_sdhi_scc { 19 + unsigned long clk_rate; /* clock rate for SDR104 */ 20 + u32 tap; /* sampling clock position for SDR104 */ 21 + }; 22 + 23 + struct renesas_sdhi_of_data { 24 + unsigned long tmio_flags; 25 + u32 tmio_ocr_mask; 26 + unsigned long capabilities; 27 + unsigned long capabilities2; 28 + enum dma_slave_buswidth dma_buswidth; 29 + dma_addr_t dma_rx_offset; 30 + unsigned bus_shift; 31 + int scc_offset; 32 + struct renesas_sdhi_scc *taps; 33 + int taps_num; 34 + }; 35 + 36 + int renesas_sdhi_probe(struct platform_device *pdev, 37 + const struct tmio_mmc_dma_ops *dma_ops); 38 + int renesas_sdhi_remove(struct platform_device *pdev); 18 39 #endif
+8 -126
drivers/mmc/host/renesas_sdhi_core.c
··· 1 1 /* 2 - * SuperH Mobile SDHI 2 + * Renesas SDHI 3 3 * 4 4 * Copyright (C) 2016 Sang Engineering, Wolfram Sang 5 5 * Copyright (C) 2015-16 Renesas Electronics Corporation ··· 23 23 #include <linux/kernel.h> 24 24 #include <linux/clk.h> 25 25 #include <linux/slab.h> 26 - #include <linux/mod_devicetable.h> 27 - #include <linux/module.h> 28 26 #include <linux/of_device.h> 29 27 #include <linux/platform_device.h> 30 28 #include <linux/mmc/host.h> ··· 45 47 #define SDHI_VER_GEN3_SDMMC 0xcd10 46 48 47 49 #define host_to_priv(host) container_of((host)->pdata, struct renesas_sdhi, mmc_data) 48 - 49 - struct renesas_sdhi_scc { 50 - unsigned long clk_rate; /* clock rate for SDR104 */ 51 - u32 tap; /* sampling clock position for SDR104 */ 52 - }; 53 - 54 - struct renesas_sdhi_of_data { 55 - unsigned long tmio_flags; 56 - u32 tmio_ocr_mask; 57 - unsigned long capabilities; 58 - unsigned long capabilities2; 59 - enum dma_slave_buswidth dma_buswidth; 60 - dma_addr_t dma_rx_offset; 61 - unsigned bus_shift; 62 - int scc_offset; 63 - struct renesas_sdhi_scc *taps; 64 - int taps_num; 65 - }; 66 - 67 - static const struct renesas_sdhi_of_data of_default_cfg = { 68 - .tmio_flags = TMIO_MMC_HAS_IDLE_WAIT, 69 - }; 70 - 71 - static const struct renesas_sdhi_of_data of_rz_compatible = { 72 - .tmio_flags = TMIO_MMC_HAS_IDLE_WAIT | TMIO_MMC_32BIT_DATA_PORT, 73 - .tmio_ocr_mask = MMC_VDD_32_33, 74 - .capabilities = MMC_CAP_SD_HIGHSPEED | MMC_CAP_SDIO_IRQ, 75 - }; 76 - 77 - static const struct renesas_sdhi_of_data of_rcar_gen1_compatible = { 78 - .tmio_flags = TMIO_MMC_HAS_IDLE_WAIT | TMIO_MMC_WRPROTECT_DISABLE | 79 - TMIO_MMC_CLK_ACTUAL, 80 - .capabilities = MMC_CAP_SD_HIGHSPEED | MMC_CAP_SDIO_IRQ, 81 - }; 82 - 83 - /* Definitions for sampling clocks */ 84 - static struct renesas_sdhi_scc rcar_gen2_scc_taps[] = { 85 - { 86 - .clk_rate = 156000000, 87 - .tap = 0x00000703, 88 - }, 89 - { 90 - .clk_rate = 0, 91 - .tap = 0x00000300, 92 - }, 93 - }; 94 - 95 - static const struct renesas_sdhi_of_data of_rcar_gen2_compatible = { 96 - .tmio_flags = TMIO_MMC_HAS_IDLE_WAIT | TMIO_MMC_WRPROTECT_DISABLE | 97 - TMIO_MMC_CLK_ACTUAL | TMIO_MMC_MIN_RCAR2, 98 - .capabilities = MMC_CAP_SD_HIGHSPEED | MMC_CAP_SDIO_IRQ, 99 - .dma_buswidth = DMA_SLAVE_BUSWIDTH_4_BYTES, 100 - .dma_rx_offset = 0x2000, 101 - .scc_offset = 0x0300, 102 - .taps = rcar_gen2_scc_taps, 103 - .taps_num = ARRAY_SIZE(rcar_gen2_scc_taps), 104 - }; 105 - 106 - /* Definitions for sampling clocks */ 107 - static struct renesas_sdhi_scc rcar_gen3_scc_taps[] = { 108 - { 109 - .clk_rate = 0, 110 - .tap = 0x00000300, 111 - }, 112 - }; 113 - 114 - static const struct renesas_sdhi_of_data of_rcar_gen3_compatible = { 115 - .tmio_flags = TMIO_MMC_HAS_IDLE_WAIT | TMIO_MMC_WRPROTECT_DISABLE | 116 - TMIO_MMC_CLK_ACTUAL | TMIO_MMC_MIN_RCAR2, 117 - .capabilities = MMC_CAP_SD_HIGHSPEED | MMC_CAP_SDIO_IRQ, 118 - .bus_shift = 2, 119 - .scc_offset = 0x1000, 120 - .taps = rcar_gen3_scc_taps, 121 - .taps_num = ARRAY_SIZE(rcar_gen3_scc_taps), 122 - }; 123 - 124 - static const struct of_device_id renesas_sdhi_of_match[] = { 125 - { .compatible = "renesas,sdhi-shmobile" }, 126 - { .compatible = "renesas,sdhi-sh73a0", .data = &of_default_cfg, }, 127 - { .compatible = "renesas,sdhi-r8a73a4", .data = &of_default_cfg, }, 128 - { .compatible = "renesas,sdhi-r8a7740", .data = &of_default_cfg, }, 129 - { .compatible = "renesas,sdhi-r7s72100", .data = &of_rz_compatible, }, 130 - { .compatible = "renesas,sdhi-r8a7778", .data = &of_rcar_gen1_compatible, }, 131 - { .compatible = "renesas,sdhi-r8a7779", .data = &of_rcar_gen1_compatible, }, 132 - { .compatible = "renesas,sdhi-r8a7790", .data = &of_rcar_gen2_compatible, }, 133 - { .compatible = "renesas,sdhi-r8a7791", .data = &of_rcar_gen2_compatible, }, 134 - { .compatible = "renesas,sdhi-r8a7792", .data = &of_rcar_gen2_compatible, }, 135 - { .compatible = "renesas,sdhi-r8a7793", .data = &of_rcar_gen2_compatible, }, 136 - { .compatible = "renesas,sdhi-r8a7794", .data = &of_rcar_gen2_compatible, }, 137 - { .compatible = "renesas,sdhi-r8a7795", .data = &of_rcar_gen3_compatible, }, 138 - { .compatible = "renesas,sdhi-r8a7796", .data = &of_rcar_gen3_compatible, }, 139 - {}, 140 - }; 141 - MODULE_DEVICE_TABLE(of, renesas_sdhi_of_match); 142 50 143 51 struct renesas_sdhi { 144 52 struct clk *clk; ··· 456 552 renesas_sdhi_sdbuf_width(host, enable ? 32 : 16); 457 553 } 458 554 459 - static int renesas_sdhi_probe(struct platform_device *pdev) 555 + int renesas_sdhi_probe(struct platform_device *pdev, 556 + const struct tmio_mmc_dma_ops *dma_ops) 460 557 { 461 - const struct renesas_sdhi_of_data *of_data = of_device_get_match_data(&pdev->dev); 558 + const struct renesas_sdhi_of_data *of_data = of_device_get_match_data( &pdev->dev); 462 559 struct renesas_sdhi *priv; 463 560 struct tmio_mmc_data *mmc_data; 464 561 struct tmio_mmc_data *mmd = pdev->dev.platform_data; ··· 573 668 /* All SDHI have SDIO status bits which must be 1 */ 574 669 mmc_data->flags |= TMIO_MMC_SDIO_STATUS_SETBITS; 575 670 576 - ret = tmio_mmc_host_probe(host, mmc_data, renesas_sdhi_get_dma_ops()); 671 + ret = tmio_mmc_host_probe(host, mmc_data, dma_ops); 577 672 if (ret < 0) 578 673 goto efree; 579 674 ··· 638 733 eprobe: 639 734 return ret; 640 735 } 736 + EXPORT_SYMBOL_GPL(renesas_sdhi_probe); 641 737 642 - static int renesas_sdhi_remove(struct platform_device *pdev) 738 + int renesas_sdhi_remove(struct platform_device *pdev) 643 739 { 644 740 struct mmc_host *mmc = platform_get_drvdata(pdev); 645 741 struct tmio_mmc_host *host = mmc_priv(mmc); ··· 649 743 650 744 return 0; 651 745 } 652 - 653 - static const struct dev_pm_ops tmio_mmc_dev_pm_ops = { 654 - SET_SYSTEM_SLEEP_PM_OPS(pm_runtime_force_suspend, 655 - pm_runtime_force_resume) 656 - SET_RUNTIME_PM_OPS(tmio_mmc_host_runtime_suspend, 657 - tmio_mmc_host_runtime_resume, 658 - NULL) 659 - }; 660 - 661 - static struct platform_driver renesas_sdhi_driver = { 662 - .driver = { 663 - .name = "sh_mobile_sdhi", 664 - .pm = &tmio_mmc_dev_pm_ops, 665 - .of_match_table = renesas_sdhi_of_match, 666 - }, 667 - .probe = renesas_sdhi_probe, 668 - .remove = renesas_sdhi_remove, 669 - }; 670 - 671 - module_platform_driver(renesas_sdhi_driver); 672 - 673 - MODULE_DESCRIPTION("Renesas SDHI driver"); 674 - MODULE_AUTHOR("Magnus Damm"); 675 - MODULE_LICENSE("GPL v2"); 676 - MODULE_ALIAS("platform:sh_mobile_sdhi"); 746 + EXPORT_SYMBOL_GPL(renesas_sdhi_remove);
+107 -2
drivers/mmc/host/renesas_sdhi_sys_dmac.c
··· 13 13 #include <linux/dmaengine.h> 14 14 #include <linux/mfd/tmio.h> 15 15 #include <linux/mmc/host.h> 16 + #include <linux/mod_devicetable.h> 17 + #include <linux/module.h> 16 18 #include <linux/pagemap.h> 17 19 #include <linux/scatterlist.h> 18 20 21 + #include "renesas_sdhi.h" 19 22 #include "tmio_mmc.h" 20 23 21 24 #define TMIO_MMC_MIN_DMA_LEN 8 25 + 26 + static const struct renesas_sdhi_of_data of_default_cfg = { 27 + .tmio_flags = TMIO_MMC_HAS_IDLE_WAIT, 28 + }; 29 + 30 + static const struct renesas_sdhi_of_data of_rz_compatible = { 31 + .tmio_flags = TMIO_MMC_HAS_IDLE_WAIT | TMIO_MMC_32BIT_DATA_PORT, 32 + .tmio_ocr_mask = MMC_VDD_32_33, 33 + .capabilities = MMC_CAP_SD_HIGHSPEED | MMC_CAP_SDIO_IRQ, 34 + }; 35 + 36 + static const struct renesas_sdhi_of_data of_rcar_gen1_compatible = { 37 + .tmio_flags = TMIO_MMC_HAS_IDLE_WAIT | TMIO_MMC_WRPROTECT_DISABLE | 38 + TMIO_MMC_CLK_ACTUAL, 39 + .capabilities = MMC_CAP_SD_HIGHSPEED | MMC_CAP_SDIO_IRQ, 40 + }; 41 + 42 + /* Definitions for sampling clocks */ 43 + static struct renesas_sdhi_scc rcar_gen2_scc_taps[] = { 44 + { 45 + .clk_rate = 156000000, 46 + .tap = 0x00000703, 47 + }, 48 + { 49 + .clk_rate = 0, 50 + .tap = 0x00000300, 51 + }, 52 + }; 53 + 54 + static const struct renesas_sdhi_of_data of_rcar_gen2_compatible = { 55 + .tmio_flags = TMIO_MMC_HAS_IDLE_WAIT | TMIO_MMC_WRPROTECT_DISABLE | 56 + TMIO_MMC_CLK_ACTUAL | TMIO_MMC_MIN_RCAR2, 57 + .capabilities = MMC_CAP_SD_HIGHSPEED | MMC_CAP_SDIO_IRQ, 58 + .dma_buswidth = DMA_SLAVE_BUSWIDTH_4_BYTES, 59 + .dma_rx_offset = 0x2000, 60 + .scc_offset = 0x0300, 61 + .taps = rcar_gen2_scc_taps, 62 + .taps_num = ARRAY_SIZE(rcar_gen2_scc_taps), 63 + }; 64 + 65 + /* Definitions for sampling clocks */ 66 + static struct renesas_sdhi_scc rcar_gen3_scc_taps[] = { 67 + { 68 + .clk_rate = 0, 69 + .tap = 0x00000300, 70 + }, 71 + }; 72 + 73 + static const struct renesas_sdhi_of_data of_rcar_gen3_compatible = { 74 + .tmio_flags = TMIO_MMC_HAS_IDLE_WAIT | TMIO_MMC_WRPROTECT_DISABLE | 75 + TMIO_MMC_CLK_ACTUAL | TMIO_MMC_MIN_RCAR2, 76 + .capabilities = MMC_CAP_SD_HIGHSPEED | MMC_CAP_SDIO_IRQ, 77 + .bus_shift = 2, 78 + .scc_offset = 0x1000, 79 + .taps = rcar_gen3_scc_taps, 80 + .taps_num = ARRAY_SIZE(rcar_gen3_scc_taps), 81 + }; 82 + 83 + static const struct of_device_id renesas_sdhi_sys_dmac_of_match[] = { 84 + { .compatible = "renesas,sdhi-shmobile" }, 85 + { .compatible = "renesas,sdhi-sh73a0", .data = &of_default_cfg, }, 86 + { .compatible = "renesas,sdhi-r8a73a4", .data = &of_default_cfg, }, 87 + { .compatible = "renesas,sdhi-r8a7740", .data = &of_default_cfg, }, 88 + { .compatible = "renesas,sdhi-r7s72100", .data = &of_rz_compatible, }, 89 + { .compatible = "renesas,sdhi-r8a7778", .data = &of_rcar_gen1_compatible, }, 90 + { .compatible = "renesas,sdhi-r8a7779", .data = &of_rcar_gen1_compatible, }, 91 + { .compatible = "renesas,sdhi-r8a7790", .data = &of_rcar_gen2_compatible, }, 92 + { .compatible = "renesas,sdhi-r8a7791", .data = &of_rcar_gen2_compatible, }, 93 + { .compatible = "renesas,sdhi-r8a7792", .data = &of_rcar_gen2_compatible, }, 94 + { .compatible = "renesas,sdhi-r8a7793", .data = &of_rcar_gen2_compatible, }, 95 + { .compatible = "renesas,sdhi-r8a7794", .data = &of_rcar_gen2_compatible, }, 96 + { .compatible = "renesas,sdhi-r8a7795", .data = &of_rcar_gen3_compatible, }, 97 + { .compatible = "renesas,sdhi-r8a7796", .data = &of_rcar_gen3_compatible, }, 98 + {}, 99 + }; 100 + MODULE_DEVICE_TABLE(of, renesas_sdhi_sys_dmac_of_match); 101 + 22 102 23 103 static void renesas_sdhi_sys_dmac_enable_dma(struct tmio_mmc_host *host, 24 104 bool enable) ··· 445 365 .abort = renesas_sdhi_sys_dmac_abort_dma, 446 366 }; 447 367 448 - const struct tmio_mmc_dma_ops *renesas_sdhi_get_dma_ops(void) 368 + static int renesas_sdhi_sys_dmac_probe(struct platform_device *pdev) 449 369 { 450 - return &renesas_sdhi_sys_dmac_dma_ops; 370 + return renesas_sdhi_probe(pdev, &renesas_sdhi_sys_dmac_dma_ops); 451 371 } 372 + 373 + static const struct dev_pm_ops renesas_sdhi_sys_dmac_dev_pm_ops = { 374 + SET_SYSTEM_SLEEP_PM_OPS(pm_runtime_force_suspend, 375 + pm_runtime_force_resume) 376 + SET_RUNTIME_PM_OPS(tmio_mmc_host_runtime_suspend, 377 + tmio_mmc_host_runtime_resume, 378 + NULL) 379 + }; 380 + 381 + static struct platform_driver renesas_sys_dmac_sdhi_driver = { 382 + .driver = { 383 + .name = "sh_mobile_sdhi", 384 + .pm = &renesas_sdhi_sys_dmac_dev_pm_ops, 385 + .of_match_table = renesas_sdhi_sys_dmac_of_match, 386 + }, 387 + .probe = renesas_sdhi_sys_dmac_probe, 388 + .remove = renesas_sdhi_remove, 389 + }; 390 + 391 + module_platform_driver(renesas_sys_dmac_sdhi_driver); 392 + 393 + MODULE_DESCRIPTION("Renesas SDHI driver"); 394 + MODULE_AUTHOR("Magnus Damm"); 395 + MODULE_LICENSE("GPL v2"); 396 + MODULE_ALIAS("platform:sh_mobile_sdhi");