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

dmaengine: ste_dma40: Allow memcpy channels to be configured from DT

At this moment in time the memcpy channels which can be used by the D40
are fixed, as each supported platform in Mainline uses the same ones.
However, platforms do exist which don't follow this convention, so
these will need to be tailored. Fortunately, these platforms will be DT
only, so this change has very little impact on platform data.

Cc: Dan Williams <djbw@fb.com>
Cc: Per Forlin <per.forlin@stericsson.com>
Cc: Rabin Vincent <rabin@rab.in>
Acked-by: Vinod Koul <vinod.koul@intel.com>
Acked-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Lee Jones <lee.jones@linaro.org>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>

authored by

Lee Jones and committed by
Linus Walleij
a7dacb68 8cc5af12

+36 -8
+2
Documentation/devicetree/bindings/dma/ste-dma40.txt
··· 6 6 - reg-names: Names of the above areas to use during resource look-up 7 7 - interrupt: Should contain the DMAC interrupt number 8 8 - #dma-cells: must be <3> 9 + - memcpy-channels: Channels to be used for memcpy 9 10 10 11 Optional properties: 11 12 - dma-channels: Number of channels supported by hardware - if not present ··· 22 21 interrupts = <0 25 0x4>; 23 22 24 23 #dma-cells = <2>; 24 + memcpy-channels = <56 57 58 59 60>; 25 25 dma-channels = <8>; 26 26 }; 27 27
+32 -8
drivers/dma/ste_dma40.c
··· 58 58 #define D40_ALLOC_PHY BIT(30) 59 59 #define D40_ALLOC_LOG_FREE 0 60 60 61 + #define D40_MEMCPY_MAX_CHANS 8 62 + 61 63 /* Reserved event lines for memcpy only. */ 62 64 #define DB8500_DMA_MEMCPY_EV_0 51 63 65 #define DB8500_DMA_MEMCPY_EV_1 56 ··· 524 522 * @phy_start: Physical memory start of the DMA registers. 525 523 * @phy_size: Size of the DMA register map. 526 524 * @irq: The IRQ number. 525 + * @num_memcpy_chans: The number of channels used for memcpy (mem-to-mem 526 + * transfers). 527 527 * @num_phy_chans: The number of physical channels. Read from HW. This 528 528 * is the number of available channels for this driver, not counting "Secure 529 529 * mode" allocated physical channels. ··· 569 565 phys_addr_t phy_start; 570 566 resource_size_t phy_size; 571 567 int irq; 568 + int num_memcpy_chans; 572 569 int num_phy_chans; 573 570 int num_log_chans; 574 571 struct device_dma_parameters dma_parms; ··· 2943 2938 } 2944 2939 2945 2940 d40_chan_init(base, &base->dma_memcpy, base->log_chans, 2946 - base->num_log_chans, ARRAY_SIZE(dma40_memcpy_channels)); 2941 + base->num_log_chans, base->num_memcpy_chans); 2947 2942 2948 2943 dma_cap_zero(base->dma_memcpy.cap_mask); 2949 2944 dma_cap_set(DMA_MEMCPY, base->dma_memcpy.cap_mask); ··· 3144 3139 struct d40_base *base = NULL; 3145 3140 int num_log_chans = 0; 3146 3141 int num_phy_chans; 3142 + int num_memcpy_chans; 3147 3143 int clk_ret = -EINVAL; 3148 3144 int i; 3149 3145 u32 pid; ··· 3215 3209 else 3216 3210 num_phy_chans = 4 * (readl(virtbase + D40_DREG_ICFG) & 0x7) + 4; 3217 3211 3212 + /* The number of channels used for memcpy */ 3213 + if (plat_data->num_of_memcpy_chans) 3214 + num_memcpy_chans = plat_data->num_of_memcpy_chans; 3215 + else 3216 + num_memcpy_chans = ARRAY_SIZE(dma40_memcpy_channels); 3217 + 3218 3218 num_log_chans = num_phy_chans * D40_MAX_LOG_CHAN_PER_PHY; 3219 3219 3220 3220 dev_info(&pdev->dev, ··· 3228 3216 rev, res->start, num_phy_chans, num_log_chans); 3229 3217 3230 3218 base = kzalloc(ALIGN(sizeof(struct d40_base), 4) + 3231 - (num_phy_chans + num_log_chans + ARRAY_SIZE(dma40_memcpy_channels)) * 3219 + (num_phy_chans + num_log_chans + num_memcpy_chans) * 3232 3220 sizeof(struct d40_chan), GFP_KERNEL); 3233 3221 3234 3222 if (base == NULL) { ··· 3238 3226 3239 3227 base->rev = rev; 3240 3228 base->clk = clk; 3229 + base->num_memcpy_chans = num_memcpy_chans; 3241 3230 base->num_phy_chans = num_phy_chans; 3242 3231 base->num_log_chans = num_log_chans; 3243 3232 base->phy_start = res->start; ··· 3482 3469 struct device_node *np) 3483 3470 { 3484 3471 struct stedma40_platform_data *pdata; 3485 - 3486 - /* 3487 - * FIXME: Fill in this routine as more support is added. 3488 - * First platform enabled (u8500) doens't need any extra 3489 - * properties to run, so this is fairly sparce currently. 3490 - */ 3472 + int num_memcpy = 0; 3473 + const const __be32 *list; 3491 3474 3492 3475 pdata = devm_kzalloc(&pdev->dev, 3493 3476 sizeof(struct stedma40_platform_data), 3494 3477 GFP_KERNEL); 3495 3478 if (!pdata) 3496 3479 return -ENOMEM; 3480 + 3481 + list = of_get_property(np, "memcpy-channels", &num_memcpy); 3482 + num_memcpy /= sizeof(*list); 3483 + 3484 + if (num_memcpy > D40_MEMCPY_MAX_CHANS || num_memcpy <= 0) { 3485 + d40_err(&pdev->dev, 3486 + "Invalid number of memcpy channels specified (%d)\n", 3487 + num_memcpy); 3488 + return -EINVAL; 3489 + } 3490 + pdata->num_of_memcpy_chans = num_memcpy; 3491 + 3492 + of_property_read_u32_array(np, "memcpy-channels", 3493 + dma40_memcpy_channels, 3494 + num_memcpy); 3497 3495 3498 3496 pdev->dev.platform_data = pdata; 3499 3497
+2
include/linux/platform_data/dma-ste-dma40.h
··· 132 132 * @num_of_soft_lli_chans: The number of channels that needs to be configured 133 133 * to use SoftLLI. 134 134 * @use_esram_lcla: flag for mapping the lcla into esram region 135 + * @num_of_memcpy_chans: The number of channels reserved for memcpy. 135 136 * @num_of_phy_chans: The number of physical channels implemented in HW. 136 137 * 0 means reading the number of channels from DMA HW but this is only valid 137 138 * for 'multiple of 4' channels, like 8. ··· 142 141 int *soft_lli_chans; 143 142 int num_of_soft_lli_chans; 144 143 bool use_esram_lcla; 144 + int num_of_memcpy_chans; 145 145 int num_of_phy_chans; 146 146 }; 147 147