Re: [RFC PATCH v6 1/9] mmc: dw_mmc: Add external dma interface support
On 08/21/2015 03:30 PM, Shawn Lin wrote: On 2015/8/21 14:27, Jaehoon Chung wrote: Hi, Shawn. Is this based on Ulf's repository? no, it's based on https://github.com/jh80chung/dw-mmc.git tags/dw-mmc-for-ulf-v4.2 :) Oh..I will rebase to Ulf's next branch on this weekend. Then could you rebase this patch? And i added more comments at below.. :) Best Regards, Jaehoon Chung On 08/20/2015 05:43 PM, Shawn Lin wrote: DesignWare MMC Controller can supports two types of DMA mode: external dma and internal dma. We get a RK312x platform integrated dw_mmc and ARM pl330 dma controller. This patch add edmac ops to support these platforms. I've tested it on RK31xx platform with edmac mode and RK3288 platform with idmac mode. Signed-off-by: Shawn Lin shawn@rock-chips.com --- Changes in v6: - add trans_mode condition for IDMAC initialization suggested by Heiko - re-test my patch on rk3188 platform and update commit msg - update performance of pio vs edmac in cover letter Changes in v5: - add the title of cover letter - fix typo of comment - add macro for reading HCON register - add Acked-by: Krzysztof Kozlowski k.kozlow...@samsung.com for exynos_defconfig patch - add Acked-by: Vineet Gupta vgu...@synopsys.com for axs10x_defconfig patch - add Acked-by: Govindraj Raja govindraj.r...@imgtec.com and Acked-by: Ralf Baechle r...@linux-mips.org for pistachio_defconfig patch - add Acked-by: Joachim Eastwood manab...@gmail.com for lpc18xx_defconfig patch - add Acked-by: Wei Xu xuw...@hisilicon.com for hisi_defconfig patch - rebase on https://github.com/jh80chung/dw-mmc.git tags/dw-mmc-for-ulf-v4.2 for merging easily Changes in v4: - remove host-trans_mode and use host-use_dma to indicate transfer mode. - remove all bt-bindings' changes since we don't need new properities. - check transfer mode at runtime by reading HCON reg - spilt defconfig changes for each sub-architecture - fix the title of cover letter - reuse some code for reducing code size Changes in v3: - choose transfer mode at runtime - remove all CONFIG_MMC_DW_IDMAC config option - add supports-idmac property for some platforms Changes in v2: - Fix typo of dev_info msg - remove unused dmach from declaration of dw_mci_dma_slave drivers/mmc/host/Kconfig| 11 +- drivers/mmc/host/dw_mmc-pltfm.c | 2 + drivers/mmc/host/dw_mmc.c | 264 drivers/mmc/host/dw_mmc.h | 5 + include/linux/mmc/dw_mmc.h | 27 +++- 5 files changed, 242 insertions(+), 67 deletions(-) diff --git a/drivers/mmc/host/Kconfig b/drivers/mmc/host/Kconfig index 6a0f9c7..a86c0eb 100644 --- a/drivers/mmc/host/Kconfig +++ b/drivers/mmc/host/Kconfig @@ -607,15 +607,7 @@ config MMC_DW help This selects support for the Synopsys DesignWare Mobile Storage IP block, this provides host support for SD and MMC interfaces, in both - PIO and external DMA modes. - -config MMC_DW_IDMAC -bool Internal DMAC interface -depends on MMC_DW -help - This selects support for the internal DMAC block within the Synopsys - Designware Mobile Storage IP block. This disables the external DMA - interface. + PIO, internal DMA mode and external DMA modes. config MMC_DW_PLTFM tristate Synopsys Designware MCI Support as platform device @@ -644,7 +636,6 @@ config MMC_DW_K3 tristate K3 specific extensions for Synopsys DW Memory Card Interface depends on MMC_DW select MMC_DW_PLTFM -select MMC_DW_IDMAC help This selects support for Hisilicon K3 SoC specific extensions to the Synopsys DesignWare Memory Card Interface driver. Select this option diff --git a/drivers/mmc/host/dw_mmc-pltfm.c b/drivers/mmc/host/dw_mmc-pltfm.c index ec6dbcd..7e1d13b 100644 --- a/drivers/mmc/host/dw_mmc-pltfm.c +++ b/drivers/mmc/host/dw_mmc-pltfm.c @@ -59,6 +59,8 @@ int dw_mci_pltfm_register(struct platform_device *pdev, host-pdata = pdev-dev.platform_data; regs = platform_get_resource(pdev, IORESOURCE_MEM, 0); +/* Get registers' physical base address */ +host-phy_regs = (void *)(regs-start); host-regs = devm_ioremap_resource(pdev-dev, regs); if (IS_ERR(host-regs)) return PTR_ERR(host-regs); Is this board specific code? If so, separate the patch. diff --git a/drivers/mmc/host/dw_mmc.c b/drivers/mmc/host/dw_mmc.c index fcbf552..f943619 100644 --- a/drivers/mmc/host/dw_mmc.c +++ b/drivers/mmc/host/dw_mmc.c @@ -56,7 +56,6 @@ #define DW_MCI_FREQ_MAX2/* unit: HZ */ #define DW_MCI_FREQ_MIN40/* unit: HZ */ -#ifdef CONFIG_MMC_DW_IDMAC #define IDMAC_INT_CLR(SDMMC_IDMAC_INT_AI | SDMMC_IDMAC_INT_NI | \ SDMMC_IDMAC_INT_CES | SDMMC_IDMAC_INT_DU | \ SDMMC_IDMAC_INT_FBE | SDMMC_IDMAC_INT_RI | \ @@ -102,7 +101,6 @@ struct
Re: [RFC PATCH v6 1/9] mmc: dw_mmc: Add external dma interface support
On 2015/8/21 14:27, Jaehoon Chung wrote: Hi, Shawn. Is this based on Ulf's repository? no, it's based on https://github.com/jh80chung/dw-mmc.git tags/dw-mmc-for-ulf-v4.2 :) On 08/20/2015 05:43 PM, Shawn Lin wrote: DesignWare MMC Controller can supports two types of DMA mode: external dma and internal dma. We get a RK312x platform integrated dw_mmc and ARM pl330 dma controller. This patch add edmac ops to support these platforms. I've tested it on RK31xx platform with edmac mode and RK3288 platform with idmac mode. Signed-off-by: Shawn Lin shawn@rock-chips.com --- Changes in v6: - add trans_mode condition for IDMAC initialization suggested by Heiko - re-test my patch on rk3188 platform and update commit msg - update performance of pio vs edmac in cover letter Changes in v5: - add the title of cover letter - fix typo of comment - add macro for reading HCON register - add Acked-by: Krzysztof Kozlowski k.kozlow...@samsung.com for exynos_defconfig patch - add Acked-by: Vineet Gupta vgu...@synopsys.com for axs10x_defconfig patch - add Acked-by: Govindraj Raja govindraj.r...@imgtec.com and Acked-by: Ralf Baechle r...@linux-mips.org for pistachio_defconfig patch - add Acked-by: Joachim Eastwood manab...@gmail.com for lpc18xx_defconfig patch - add Acked-by: Wei Xu xuw...@hisilicon.com for hisi_defconfig patch - rebase on https://github.com/jh80chung/dw-mmc.git tags/dw-mmc-for-ulf-v4.2 for merging easily Changes in v4: - remove host-trans_mode and use host-use_dma to indicate transfer mode. - remove all bt-bindings' changes since we don't need new properities. - check transfer mode at runtime by reading HCON reg - spilt defconfig changes for each sub-architecture - fix the title of cover letter - reuse some code for reducing code size Changes in v3: - choose transfer mode at runtime - remove all CONFIG_MMC_DW_IDMAC config option - add supports-idmac property for some platforms Changes in v2: - Fix typo of dev_info msg - remove unused dmach from declaration of dw_mci_dma_slave drivers/mmc/host/Kconfig| 11 +- drivers/mmc/host/dw_mmc-pltfm.c | 2 + drivers/mmc/host/dw_mmc.c | 264 drivers/mmc/host/dw_mmc.h | 5 + include/linux/mmc/dw_mmc.h | 27 +++- 5 files changed, 242 insertions(+), 67 deletions(-) diff --git a/drivers/mmc/host/Kconfig b/drivers/mmc/host/Kconfig index 6a0f9c7..a86c0eb 100644 --- a/drivers/mmc/host/Kconfig +++ b/drivers/mmc/host/Kconfig @@ -607,15 +607,7 @@ config MMC_DW help This selects support for the Synopsys DesignWare Mobile Storage IP block, this provides host support for SD and MMC interfaces, in both - PIO and external DMA modes. - -config MMC_DW_IDMAC - bool Internal DMAC interface - depends on MMC_DW - help - This selects support for the internal DMAC block within the Synopsys - Designware Mobile Storage IP block. This disables the external DMA - interface. + PIO, internal DMA mode and external DMA modes. config MMC_DW_PLTFM tristate Synopsys Designware MCI Support as platform device @@ -644,7 +636,6 @@ config MMC_DW_K3 tristate K3 specific extensions for Synopsys DW Memory Card Interface depends on MMC_DW select MMC_DW_PLTFM - select MMC_DW_IDMAC help This selects support for Hisilicon K3 SoC specific extensions to the Synopsys DesignWare Memory Card Interface driver. Select this option diff --git a/drivers/mmc/host/dw_mmc-pltfm.c b/drivers/mmc/host/dw_mmc-pltfm.c index ec6dbcd..7e1d13b 100644 --- a/drivers/mmc/host/dw_mmc-pltfm.c +++ b/drivers/mmc/host/dw_mmc-pltfm.c @@ -59,6 +59,8 @@ int dw_mci_pltfm_register(struct platform_device *pdev, host-pdata = pdev-dev.platform_data; regs = platform_get_resource(pdev, IORESOURCE_MEM, 0); + /* Get registers' physical base address */ + host-phy_regs = (void *)(regs-start); host-regs = devm_ioremap_resource(pdev-dev, regs); if (IS_ERR(host-regs)) return PTR_ERR(host-regs); Is this board specific code? If so, separate the patch. diff --git a/drivers/mmc/host/dw_mmc.c b/drivers/mmc/host/dw_mmc.c index fcbf552..f943619 100644 --- a/drivers/mmc/host/dw_mmc.c +++ b/drivers/mmc/host/dw_mmc.c @@ -56,7 +56,6 @@ #define DW_MCI_FREQ_MAX 2 /* unit: HZ */ #define DW_MCI_FREQ_MIN 40 /* unit: HZ */ -#ifdef CONFIG_MMC_DW_IDMAC #define IDMAC_INT_CLR (SDMMC_IDMAC_INT_AI | SDMMC_IDMAC_INT_NI | \ SDMMC_IDMAC_INT_CES | SDMMC_IDMAC_INT_DU | \ SDMMC_IDMAC_INT_FBE | SDMMC_IDMAC_INT_RI | \ @@ -102,7 +101,6 @@ struct idmac_desc { /* Each descriptor can transfer up to 4KB of data in chained mode */ #define DW_MCI_DESC_DATA_LENGTH 0x1000 -#endif /* CONFIG_MMC_DW_IDMAC */ static bool dw_mci_reset(struct dw_mci
Re: [RFC PATCH v6 1/9] mmc: dw_mmc: Add external dma interface support
On 08/21/2015 04:27 PM, Shawn Lin wrote: On 2015/8/21 14:35, Jaehoon Chung wrote: On 08/21/2015 03:30 PM, Shawn Lin wrote: On 2015/8/21 14:27, Jaehoon Chung wrote: Hi, Shawn. Is this based on Ulf's repository? no, it's based on https://github.com/jh80chung/dw-mmc.git tags/dw-mmc-for-ulf-v4.2 :) Oh..I will rebase to Ulf's next branch on this weekend. Then could you rebase this patch? And i added more comments at below.. :) Okay, I will rebase to Ulf's next. Best Regards, Jaehoon Chung [...] index ec6dbcd..7e1d13b 100644 --- a/drivers/mmc/host/dw_mmc-pltfm.c +++ b/drivers/mmc/host/dw_mmc-pltfm.c @@ -59,6 +59,8 @@ int dw_mci_pltfm_register(struct platform_device *pdev, host-pdata = pdev-dev.platform_data; regs = platform_get_resource(pdev, IORESOURCE_MEM, 0); +/* Get registers' physical base address */ +host-phy_regs = (void *)(regs-start); host-regs = devm_ioremap_resource(pdev-dev, regs); if (IS_ERR(host-regs)) return PTR_ERR(host-regs); Is this board specific code? If so, separate the patch. It's might not board specific code. dmaengine need dw_mmc's *physical* fifo address for data transfer, so I get controller physical address here in order to calculate physical fifo address. regs is from dt-bindings, for instance: dwmmc0@1220 { compatible = snps,dw-mshc; clocks = clock 351, clock 132; clock-names = biu, ciu; reg = 0x1220 0x1000; interrupts = 0 75 0; #address-cells = 1; #size-cells = 0; }; so, host-phy_regs will be 0x1220 . [...] +static void dw_mci_dmac_complete_dma(void *arg) { +struct dw_mci *host = arg; struct mmc_data *data = host-data; dev_vdbg(host-dev, DMA complete\n); +if (host-use_dma == TRANS_MODE_EDMAC) +if (data (data-flags MMC_DATA_READ)) Combine one condition. okay. [...] +u32 fifo_offset = host-fifo_reg - host-regs; +int ret = 0; + +/* Set external dma config: burst size, burst width */ +cfg.dst_addr = (dma_addr_t)(host-phy_regs + fifo_offset); host-phy_regs is not assigned? we got it at dw_mci_pltfm_register. See comments above. :) [...] mmc-max_blk_count = mmc-max_req_size / 512; +} else if (host-use_dma == TRANS_MODE_EDMAC) { +mmc-max_segs = 64; +mmc-max_blk_size = 65536; +mmc-max_blk_count = 65535; +mmc-max_req_size = +mmc-max_blk_size * mmc-max_blk_count; +mmc-max_seg_size = mmc-max_req_size; Fix the indention Hmm..I check it attentively but can't find the indention . Might it's because you apply it against Ulf's repo? [...] -/* Alloc memory for sg translation */ -host-sg_cpu = dmam_alloc_coherent(host-dev, PAGE_SIZE, - host-sg_dma, GFP_KERNEL); -if (!host-sg_cpu) { -dev_err(host-dev, %s: could not alloc DMA memory\n, -__func__); +/* Check tansfer mode */ +trans_mode = SDMMC_GET_TRANS_MODE(mci_readl(host, HCON)); +if (trans_mode == 0) { +trans_mode = TRANS_MODE_IDMAC; +} else if (trans_mode == 1 || trans_mode == 2) { +trans_mode = TRANS_MODE_EDMAC; +} else { +trans_mode = TRANS_MODE_PIO; what are trans_mode 0, 1, 2? (00 - none) is NO-DMA interface, isn't? is it IDMAC mode? No, I guess the databook's ambiguous description confuse everybody. I got double comfirm from my ASCI team as well as Synoposys 2b'00: NO-DMA interface -- It support IDMAC actually 2b'01 2b'02: DW_DMA GENERIC_DMA -- Support 2 types of external dma. 2b'02: NON-DW-DMA -- only support PIO Then Could you add the comment about this? Use definition instead of 0, 1, 2. Developer don't know meaning that is 0, 1, 2. Best Regards, Jaehoon Chung refer to the description below: Parameter Name: DMA_INTERFACE Legal Values: 0-3 Default Value: 0 Description: 0- No DMA Interface 1- DesignWare DMA Interface 2- Generic DMA Interface 3- Non DW DMA Interface In DesignWare DMA mode, request/acknowledge protocol meets DW_ahb_dmac controller protocol. In this mode, host data bus is also used for DMA transfers.Generic DMA-type interface has simpler request/acknowledge handshake and has dedicated read/write data bus for DMA transfers. Non DW DMAC interface uses dw_dma_single interface in addition to the existing interface and uses host data bus for DMA transfers. This is configurable only if INTERNAL_DMAC=0. goto no_dma; } +dev_info(host-dev, Using external DMA controller.\n); +} if (!host-dma_ops) goto no_dma; @@ -2562,12 +2720,12 @@ static void dw_mci_init_dma(struct dw_mci *host) goto no_dma; } -host-use_dma = 1; +host-use_dma =
Re: [RFC PATCH v6 1/9] mmc: dw_mmc: Add external dma interface support
On 2015/8/21 15:38, Jaehoon Chung wrote: On 08/21/2015 04:27 PM, Shawn Lin wrote: On 2015/8/21 14:35, Jaehoon Chung wrote: On 08/21/2015 03:30 PM, Shawn Lin wrote: On 2015/8/21 14:27, Jaehoon Chung wrote: Hi, Shawn. Is this based on Ulf's repository? no, it's based on https://github.com/jh80chung/dw-mmc.git tags/dw-mmc-for-ulf-v4.2 :) Oh..I will rebase to Ulf's next branch on this weekend. Then could you rebase this patch? And i added more comments at below.. :) Okay, I will rebase to Ulf's next. Best Regards, Jaehoon Chung [...] index ec6dbcd..7e1d13b 100644 --- a/drivers/mmc/host/dw_mmc-pltfm.c +++ b/drivers/mmc/host/dw_mmc-pltfm.c @@ -59,6 +59,8 @@ int dw_mci_pltfm_register(struct platform_device *pdev, host-pdata = pdev-dev.platform_data; regs = platform_get_resource(pdev, IORESOURCE_MEM, 0); +/* Get registers' physical base address */ +host-phy_regs = (void *)(regs-start); host-regs = devm_ioremap_resource(pdev-dev, regs); if (IS_ERR(host-regs)) return PTR_ERR(host-regs); Is this board specific code? If so, separate the patch. It's might not board specific code. dmaengine need dw_mmc's *physical* fifo address for data transfer, so I get controller physical address here in order to calculate physical fifo address. regs is from dt-bindings, for instance: dwmmc0@1220 { compatible = snps,dw-mshc; clocks = clock 351, clock 132; clock-names = biu, ciu; reg = 0x1220 0x1000; interrupts = 0 75 0; #address-cells = 1; #size-cells = 0; }; so, host-phy_regs will be 0x1220 . [...] +static void dw_mci_dmac_complete_dma(void *arg) { +struct dw_mci *host = arg; struct mmc_data *data = host-data; dev_vdbg(host-dev, DMA complete\n); +if (host-use_dma == TRANS_MODE_EDMAC) +if (data (data-flags MMC_DATA_READ)) Combine one condition. okay. [...] +u32 fifo_offset = host-fifo_reg - host-regs; +int ret = 0; + +/* Set external dma config: burst size, burst width */ +cfg.dst_addr = (dma_addr_t)(host-phy_regs + fifo_offset); host-phy_regs is not assigned? we got it at dw_mci_pltfm_register. See comments above. :) [...] mmc-max_blk_count = mmc-max_req_size / 512; +} else if (host-use_dma == TRANS_MODE_EDMAC) { +mmc-max_segs = 64; +mmc-max_blk_size = 65536; +mmc-max_blk_count = 65535; +mmc-max_req_size = +mmc-max_blk_size * mmc-max_blk_count; +mmc-max_seg_size = mmc-max_req_size; Fix the indention Hmm..I check it attentively but can't find the indention . Might it's because you apply it against Ulf's repo? [...] -/* Alloc memory for sg translation */ -host-sg_cpu = dmam_alloc_coherent(host-dev, PAGE_SIZE, - host-sg_dma, GFP_KERNEL); -if (!host-sg_cpu) { -dev_err(host-dev, %s: could not alloc DMA memory\n, -__func__); +/* Check tansfer mode */ +trans_mode = SDMMC_GET_TRANS_MODE(mci_readl(host, HCON)); +if (trans_mode == 0) { +trans_mode = TRANS_MODE_IDMAC; +} else if (trans_mode == 1 || trans_mode == 2) { +trans_mode = TRANS_MODE_EDMAC; +} else { +trans_mode = TRANS_MODE_PIO; what are trans_mode 0, 1, 2? (00 - none) is NO-DMA interface, isn't? is it IDMAC mode? No, I guess the databook's ambiguous description confuse everybody. I got double comfirm from my ASCI team as well as Synoposys 2b'00: NO-DMA interface -- It support IDMAC actually 2b'01 2b'02: DW_DMA GENERIC_DMA -- Support 2 types of external dma. 2b'02: NON-DW-DMA -- only support PIO Then Could you add the comment about this? Use definition instead of 0, 1, 2. Developer don't know meaning that is 0, 1, 2. Okay. :))) Best Regards, Jaehoon Chung refer to the description below: Parameter Name: DMA_INTERFACE Legal Values: 0-3 Default Value: 0 Description: 0- No DMA Interface 1- DesignWare DMA Interface 2- Generic DMA Interface 3- Non DW DMA Interface In DesignWare DMA mode, request/acknowledge protocol meets DW_ahb_dmac controller protocol. In this mode, host data bus is also used for DMA transfers.Generic DMA-type interface has simpler request/acknowledge handshake and has dedicated read/write data bus for DMA transfers. Non DW DMAC interface uses dw_dma_single interface in addition to the existing interface and uses host data bus for DMA transfers. This is configurable only if INTERNAL_DMAC=0. goto no_dma; } +dev_info(host-dev, Using external DMA controller.\n); +} if (!host-dma_ops) goto no_dma; @@ -2562,12 +2720,12 @@ static void dw_mci_init_dma(struct dw_mci *host) goto no_dma; } -host-use_dma = 1; +host-use_dma = trans_mode; Also
Re: [RFC PATCH v6 1/9] mmc: dw_mmc: Add external dma interface support
On 2015/8/21 14:35, Jaehoon Chung wrote: On 08/21/2015 03:30 PM, Shawn Lin wrote: On 2015/8/21 14:27, Jaehoon Chung wrote: Hi, Shawn. Is this based on Ulf's repository? no, it's based on https://github.com/jh80chung/dw-mmc.git tags/dw-mmc-for-ulf-v4.2 :) Oh..I will rebase to Ulf's next branch on this weekend. Then could you rebase this patch? And i added more comments at below.. :) Okay, I will rebase to Ulf's next. Best Regards, Jaehoon Chung [...] index ec6dbcd..7e1d13b 100644 --- a/drivers/mmc/host/dw_mmc-pltfm.c +++ b/drivers/mmc/host/dw_mmc-pltfm.c @@ -59,6 +59,8 @@ int dw_mci_pltfm_register(struct platform_device *pdev, host-pdata = pdev-dev.platform_data; regs = platform_get_resource(pdev, IORESOURCE_MEM, 0); +/* Get registers' physical base address */ +host-phy_regs = (void *)(regs-start); host-regs = devm_ioremap_resource(pdev-dev, regs); if (IS_ERR(host-regs)) return PTR_ERR(host-regs); Is this board specific code? If so, separate the patch. It's might not board specific code. dmaengine need dw_mmc's *physical* fifo address for data transfer, so I get controller physical address here in order to calculate physical fifo address. regs is from dt-bindings, for instance: dwmmc0@1220 { compatible = snps,dw-mshc; clocks = clock 351, clock 132; clock-names = biu, ciu; reg = 0x1220 0x1000; interrupts = 0 75 0; #address-cells = 1; #size-cells = 0; }; so, host-phy_regs will be 0x1220 . [...] +static void dw_mci_dmac_complete_dma(void *arg) { +struct dw_mci *host = arg; struct mmc_data *data = host-data; dev_vdbg(host-dev, DMA complete\n); +if (host-use_dma == TRANS_MODE_EDMAC) +if (data (data-flags MMC_DATA_READ)) Combine one condition. okay. [...] +u32 fifo_offset = host-fifo_reg - host-regs; +int ret = 0; + +/* Set external dma config: burst size, burst width */ +cfg.dst_addr = (dma_addr_t)(host-phy_regs + fifo_offset); host-phy_regs is not assigned? we got it at dw_mci_pltfm_register. See comments above. :) [...] mmc-max_blk_count = mmc-max_req_size / 512; +} else if (host-use_dma == TRANS_MODE_EDMAC) { +mmc-max_segs = 64; +mmc-max_blk_size = 65536; +mmc-max_blk_count = 65535; +mmc-max_req_size = +mmc-max_blk_size * mmc-max_blk_count; +mmc-max_seg_size = mmc-max_req_size; Fix the indention Hmm..I check it attentively but can't find the indention . Might it's because you apply it against Ulf's repo? [...] -/* Alloc memory for sg translation */ -host-sg_cpu = dmam_alloc_coherent(host-dev, PAGE_SIZE, - host-sg_dma, GFP_KERNEL); -if (!host-sg_cpu) { -dev_err(host-dev, %s: could not alloc DMA memory\n, -__func__); +/* Check tansfer mode */ +trans_mode = SDMMC_GET_TRANS_MODE(mci_readl(host, HCON)); +if (trans_mode == 0) { +trans_mode = TRANS_MODE_IDMAC; +} else if (trans_mode == 1 || trans_mode == 2) { +trans_mode = TRANS_MODE_EDMAC; +} else { +trans_mode = TRANS_MODE_PIO; what are trans_mode 0, 1, 2? (00 - none) is NO-DMA interface, isn't? is it IDMAC mode? No, I guess the databook's ambiguous description confuse everybody. I got double comfirm from my ASCI team as well as Synoposys 2b'00: NO-DMA interface -- It support IDMAC actually 2b'01 2b'02: DW_DMA GENERIC_DMA -- Support 2 types of external dma. 2b'02: NON-DW-DMA -- only support PIO refer to the description below: Parameter Name: DMA_INTERFACE Legal Values: 0-3 Default Value: 0 Description: 0- No DMA Interface 1- DesignWare DMA Interface 2- Generic DMA Interface 3- Non DW DMA Interface In DesignWare DMA mode, request/acknowledge protocol meets DW_ahb_dmac controller protocol. In this mode, host data bus is also used for DMA transfers.Generic DMA-type interface has simpler request/acknowledge handshake and has dedicated read/write data bus for DMA transfers. Non DW DMAC interface uses dw_dma_single interface in addition to the existing interface and uses host data bus for DMA transfers. This is configurable only if INTERNAL_DMAC=0. goto no_dma; } +dev_info(host-dev, Using external DMA controller.\n); +} if (!host-dma_ops) goto no_dma; @@ -2562,12 +2720,12 @@ static void dw_mci_init_dma(struct dw_mci *host) goto no_dma; } -host-use_dma = 1; +host-use_dma = trans_mode; Also confuse, if trans_mode is assigned host-use_dma, can mode value be directly assigned to host-use_dma? Good idea, I will do it. :) trans_mode = TRAMS_MODE_PIO; host-use_dma = trans_mode; [...] @@ -2890,7 +3047,7 @@ int dw_mci_probe(struct dw_mci *host) * Get the host
Re: [RFC PATCH v6 1/9] mmc: dw_mmc: Add external dma interface support
Hi, Shawn. Is this based on Ulf's repository? On 08/20/2015 05:43 PM, Shawn Lin wrote: DesignWare MMC Controller can supports two types of DMA mode: external dma and internal dma. We get a RK312x platform integrated dw_mmc and ARM pl330 dma controller. This patch add edmac ops to support these platforms. I've tested it on RK31xx platform with edmac mode and RK3288 platform with idmac mode. Signed-off-by: Shawn Lin shawn@rock-chips.com --- Changes in v6: - add trans_mode condition for IDMAC initialization suggested by Heiko - re-test my patch on rk3188 platform and update commit msg - update performance of pio vs edmac in cover letter Changes in v5: - add the title of cover letter - fix typo of comment - add macro for reading HCON register - add Acked-by: Krzysztof Kozlowski k.kozlow...@samsung.com for exynos_defconfig patch - add Acked-by: Vineet Gupta vgu...@synopsys.com for axs10x_defconfig patch - add Acked-by: Govindraj Raja govindraj.r...@imgtec.com and Acked-by: Ralf Baechle r...@linux-mips.org for pistachio_defconfig patch - add Acked-by: Joachim Eastwood manab...@gmail.com for lpc18xx_defconfig patch - add Acked-by: Wei Xu xuw...@hisilicon.com for hisi_defconfig patch - rebase on https://github.com/jh80chung/dw-mmc.git tags/dw-mmc-for-ulf-v4.2 for merging easily Changes in v4: - remove host-trans_mode and use host-use_dma to indicate transfer mode. - remove all bt-bindings' changes since we don't need new properities. - check transfer mode at runtime by reading HCON reg - spilt defconfig changes for each sub-architecture - fix the title of cover letter - reuse some code for reducing code size Changes in v3: - choose transfer mode at runtime - remove all CONFIG_MMC_DW_IDMAC config option - add supports-idmac property for some platforms Changes in v2: - Fix typo of dev_info msg - remove unused dmach from declaration of dw_mci_dma_slave drivers/mmc/host/Kconfig| 11 +- drivers/mmc/host/dw_mmc-pltfm.c | 2 + drivers/mmc/host/dw_mmc.c | 264 drivers/mmc/host/dw_mmc.h | 5 + include/linux/mmc/dw_mmc.h | 27 +++- 5 files changed, 242 insertions(+), 67 deletions(-) diff --git a/drivers/mmc/host/Kconfig b/drivers/mmc/host/Kconfig index 6a0f9c7..a86c0eb 100644 --- a/drivers/mmc/host/Kconfig +++ b/drivers/mmc/host/Kconfig @@ -607,15 +607,7 @@ config MMC_DW help This selects support for the Synopsys DesignWare Mobile Storage IP block, this provides host support for SD and MMC interfaces, in both - PIO and external DMA modes. - -config MMC_DW_IDMAC - bool Internal DMAC interface - depends on MMC_DW - help - This selects support for the internal DMAC block within the Synopsys - Designware Mobile Storage IP block. This disables the external DMA - interface. + PIO, internal DMA mode and external DMA modes. config MMC_DW_PLTFM tristate Synopsys Designware MCI Support as platform device @@ -644,7 +636,6 @@ config MMC_DW_K3 tristate K3 specific extensions for Synopsys DW Memory Card Interface depends on MMC_DW select MMC_DW_PLTFM - select MMC_DW_IDMAC help This selects support for Hisilicon K3 SoC specific extensions to the Synopsys DesignWare Memory Card Interface driver. Select this option diff --git a/drivers/mmc/host/dw_mmc-pltfm.c b/drivers/mmc/host/dw_mmc-pltfm.c index ec6dbcd..7e1d13b 100644 --- a/drivers/mmc/host/dw_mmc-pltfm.c +++ b/drivers/mmc/host/dw_mmc-pltfm.c @@ -59,6 +59,8 @@ int dw_mci_pltfm_register(struct platform_device *pdev, host-pdata = pdev-dev.platform_data; regs = platform_get_resource(pdev, IORESOURCE_MEM, 0); + /* Get registers' physical base address */ + host-phy_regs = (void *)(regs-start); host-regs = devm_ioremap_resource(pdev-dev, regs); if (IS_ERR(host-regs)) return PTR_ERR(host-regs); Is this board specific code? If so, separate the patch. diff --git a/drivers/mmc/host/dw_mmc.c b/drivers/mmc/host/dw_mmc.c index fcbf552..f943619 100644 --- a/drivers/mmc/host/dw_mmc.c +++ b/drivers/mmc/host/dw_mmc.c @@ -56,7 +56,6 @@ #define DW_MCI_FREQ_MAX 2 /* unit: HZ */ #define DW_MCI_FREQ_MIN 40 /* unit: HZ */ -#ifdef CONFIG_MMC_DW_IDMAC #define IDMAC_INT_CLR(SDMMC_IDMAC_INT_AI | SDMMC_IDMAC_INT_NI | \ SDMMC_IDMAC_INT_CES | SDMMC_IDMAC_INT_DU | \ SDMMC_IDMAC_INT_FBE | SDMMC_IDMAC_INT_RI | \ @@ -102,7 +101,6 @@ struct idmac_desc { /* Each descriptor can transfer up to 4KB of data in chained mode */ #define DW_MCI_DESC_DATA_LENGTH 0x1000 -#endif /* CONFIG_MMC_DW_IDMAC */ static bool dw_mci_reset(struct dw_mci *host); static bool dw_mci_ctrl_reset(struct dw_mci *host, u32 reset); @@
[RFC PATCH v6 1/9] mmc: dw_mmc: Add external dma interface support
DesignWare MMC Controller can supports two types of DMA mode: external dma and internal dma. We get a RK312x platform integrated dw_mmc and ARM pl330 dma controller. This patch add edmac ops to support these platforms. I've tested it on RK31xx platform with edmac mode and RK3288 platform with idmac mode. Signed-off-by: Shawn Lin shawn@rock-chips.com --- Changes in v6: - add trans_mode condition for IDMAC initialization suggested by Heiko - re-test my patch on rk3188 platform and update commit msg - update performance of pio vs edmac in cover letter Changes in v5: - add the title of cover letter - fix typo of comment - add macro for reading HCON register - add Acked-by: Krzysztof Kozlowski k.kozlow...@samsung.com for exynos_defconfig patch - add Acked-by: Vineet Gupta vgu...@synopsys.com for axs10x_defconfig patch - add Acked-by: Govindraj Raja govindraj.r...@imgtec.com and Acked-by: Ralf Baechle r...@linux-mips.org for pistachio_defconfig patch - add Acked-by: Joachim Eastwood manab...@gmail.com for lpc18xx_defconfig patch - add Acked-by: Wei Xu xuw...@hisilicon.com for hisi_defconfig patch - rebase on https://github.com/jh80chung/dw-mmc.git tags/dw-mmc-for-ulf-v4.2 for merging easily Changes in v4: - remove host-trans_mode and use host-use_dma to indicate transfer mode. - remove all bt-bindings' changes since we don't need new properities. - check transfer mode at runtime by reading HCON reg - spilt defconfig changes for each sub-architecture - fix the title of cover letter - reuse some code for reducing code size Changes in v3: - choose transfer mode at runtime - remove all CONFIG_MMC_DW_IDMAC config option - add supports-idmac property for some platforms Changes in v2: - Fix typo of dev_info msg - remove unused dmach from declaration of dw_mci_dma_slave drivers/mmc/host/Kconfig| 11 +- drivers/mmc/host/dw_mmc-pltfm.c | 2 + drivers/mmc/host/dw_mmc.c | 264 drivers/mmc/host/dw_mmc.h | 5 + include/linux/mmc/dw_mmc.h | 27 +++- 5 files changed, 242 insertions(+), 67 deletions(-) diff --git a/drivers/mmc/host/Kconfig b/drivers/mmc/host/Kconfig index 6a0f9c7..a86c0eb 100644 --- a/drivers/mmc/host/Kconfig +++ b/drivers/mmc/host/Kconfig @@ -607,15 +607,7 @@ config MMC_DW help This selects support for the Synopsys DesignWare Mobile Storage IP block, this provides host support for SD and MMC interfaces, in both - PIO and external DMA modes. - -config MMC_DW_IDMAC - bool Internal DMAC interface - depends on MMC_DW - help - This selects support for the internal DMAC block within the Synopsys - Designware Mobile Storage IP block. This disables the external DMA - interface. + PIO, internal DMA mode and external DMA modes. config MMC_DW_PLTFM tristate Synopsys Designware MCI Support as platform device @@ -644,7 +636,6 @@ config MMC_DW_K3 tristate K3 specific extensions for Synopsys DW Memory Card Interface depends on MMC_DW select MMC_DW_PLTFM - select MMC_DW_IDMAC help This selects support for Hisilicon K3 SoC specific extensions to the Synopsys DesignWare Memory Card Interface driver. Select this option diff --git a/drivers/mmc/host/dw_mmc-pltfm.c b/drivers/mmc/host/dw_mmc-pltfm.c index ec6dbcd..7e1d13b 100644 --- a/drivers/mmc/host/dw_mmc-pltfm.c +++ b/drivers/mmc/host/dw_mmc-pltfm.c @@ -59,6 +59,8 @@ int dw_mci_pltfm_register(struct platform_device *pdev, host-pdata = pdev-dev.platform_data; regs = platform_get_resource(pdev, IORESOURCE_MEM, 0); + /* Get registers' physical base address */ + host-phy_regs = (void *)(regs-start); host-regs = devm_ioremap_resource(pdev-dev, regs); if (IS_ERR(host-regs)) return PTR_ERR(host-regs); diff --git a/drivers/mmc/host/dw_mmc.c b/drivers/mmc/host/dw_mmc.c index fcbf552..f943619 100644 --- a/drivers/mmc/host/dw_mmc.c +++ b/drivers/mmc/host/dw_mmc.c @@ -56,7 +56,6 @@ #define DW_MCI_FREQ_MAX2 /* unit: HZ */ #define DW_MCI_FREQ_MIN40 /* unit: HZ */ -#ifdef CONFIG_MMC_DW_IDMAC #define IDMAC_INT_CLR (SDMMC_IDMAC_INT_AI | SDMMC_IDMAC_INT_NI | \ SDMMC_IDMAC_INT_CES | SDMMC_IDMAC_INT_DU | \ SDMMC_IDMAC_INT_FBE | SDMMC_IDMAC_INT_RI | \ @@ -102,7 +101,6 @@ struct idmac_desc { /* Each descriptor can transfer up to 4KB of data in chained mode */ #define DW_MCI_DESC_DATA_LENGTH0x1000 -#endif /* CONFIG_MMC_DW_IDMAC */ static bool dw_mci_reset(struct dw_mci *host); static bool dw_mci_ctrl_reset(struct dw_mci *host, u32 reset); @@ -407,7 +405,6 @@ static int dw_mci_get_dma_dir(struct mmc_data *data) return DMA_FROM_DEVICE; } -#ifdef CONFIG_MMC_DW_IDMAC static void dw_mci_dma_cleanup(struct dw_mci *host) { struct